diff --git "a/data/train/cpp-002.jsonl" "b/data/train/cpp-002.jsonl" new file mode 100644--- /dev/null +++ "b/data/train/cpp-002.jsonl" @@ -0,0 +1,586 @@ +{"question_id": 1304, "task_id": "find-n-unique-integers-sum-up-to-zero", "difficulty": "Easy", "problem_description": "Given an integer n, return any array containing n unique integers such that they add up to 0.\n \nExample 1:\n\nInput: n = 5\nOutput: [-7,-1,1,3,4]\nExplanation: These arrays also are accepted [-5,-1,1,2,3] , [-3,-1,2,-2,4].\n\nExample 2:\n\nInput: n = 3\nOutput: [-1,0,1]\n\nExample 3:\n\nInput: n = 1\nOutput: [0]\n\n \nConstraints:\n\n1 <= n <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == [1, -1, 0]\n assert candidate(n = 100) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50]\n assert candidate(n = 2) == [1, -1]\n assert candidate(n = 1) == [0]\n assert candidate(n = 1000) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375, 376, -376, 377, -377, 378, -378, 379, -379, 380, -380, 381, -381, 382, -382, 383, -383, 384, -384, 385, -385, 386, -386, 387, -387, 388, -388, 389, -389, 390, -390, 391, -391, 392, -392, 393, -393, 394, -394, 395, -395, 396, -396, 397, -397, 398, -398, 399, -399, 400, -400, 401, -401, 402, -402, 403, -403, 404, -404, 405, -405, 406, -406, 407, -407, 408, -408, 409, -409, 410, -410, 411, -411, 412, -412, 413, -413, 414, -414, 415, -415, 416, -416, 417, -417, 418, -418, 419, -419, 420, -420, 421, -421, 422, -422, 423, -423, 424, -424, 425, -425, 426, -426, 427, -427, 428, -428, 429, -429, 430, -430, 431, -431, 432, -432, 433, -433, 434, -434, 435, -435, 436, -436, 437, -437, 438, -438, 439, -439, 440, -440, 441, -441, 442, -442, 443, -443, 444, -444, 445, -445, 446, -446, 447, -447, 448, -448, 449, -449, 450, -450, 451, -451, 452, -452, 453, -453, 454, -454, 455, -455, 456, -456, 457, -457, 458, -458, 459, -459, 460, -460, 461, -461, 462, -462, 463, -463, 464, -464, 465, -465, 466, -466, 467, -467, 468, -468, 469, -469, 470, -470, 471, -471, 472, -472, 473, -473, 474, -474, 475, -475, 476, -476, 477, -477, 478, -478, 479, -479, 480, -480, 481, -481, 482, -482, 483, -483, 484, -484, 485, -485, 486, -486, 487, -487, 488, -488, 489, -489, 490, -490, 491, -491, 492, -492, 493, -493, 494, -494, 495, -495, 496, -496, 497, -497, 498, -498, 499, -499, 500, -500]\n assert candidate(n = 10) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]\n assert candidate(n = 5) == [1, -1, 2, -2, 0]\n assert candidate(n = 601) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 0]\n assert candidate(n = 105) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 0]\n assert candidate(n = 666) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333]\n assert candidate(n = 995) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375, 376, -376, 377, -377, 378, -378, 379, -379, 380, -380, 381, -381, 382, -382, 383, -383, 384, -384, 385, -385, 386, -386, 387, -387, 388, -388, 389, -389, 390, -390, 391, -391, 392, -392, 393, -393, 394, -394, 395, -395, 396, -396, 397, -397, 398, -398, 399, -399, 400, -400, 401, -401, 402, -402, 403, -403, 404, -404, 405, -405, 406, -406, 407, -407, 408, -408, 409, -409, 410, -410, 411, -411, 412, -412, 413, -413, 414, -414, 415, -415, 416, -416, 417, -417, 418, -418, 419, -419, 420, -420, 421, -421, 422, -422, 423, -423, 424, -424, 425, -425, 426, -426, 427, -427, 428, -428, 429, -429, 430, -430, 431, -431, 432, -432, 433, -433, 434, -434, 435, -435, 436, -436, 437, -437, 438, -438, 439, -439, 440, -440, 441, -441, 442, -442, 443, -443, 444, -444, 445, -445, 446, -446, 447, -447, 448, -448, 449, -449, 450, -450, 451, -451, 452, -452, 453, -453, 454, -454, 455, -455, 456, -456, 457, -457, 458, -458, 459, -459, 460, -460, 461, -461, 462, -462, 463, -463, 464, -464, 465, -465, 466, -466, 467, -467, 468, -468, 469, -469, 470, -470, 471, -471, 472, -472, 473, -473, 474, -474, 475, -475, 476, -476, 477, -477, 478, -478, 479, -479, 480, -480, 481, -481, 482, -482, 483, -483, 484, -484, 485, -485, 486, -486, 487, -487, 488, -488, 489, -489, 490, -490, 491, -491, 492, -492, 493, -493, 494, -494, 495, -495, 496, -496, 497, -497, 0]\n assert candidate(n = 50) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25]\n assert candidate(n = 300) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150]\n assert candidate(n = 123) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 0]\n assert candidate(n = 333) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 0]\n assert candidate(n = 550) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275]\n assert candidate(n = 4) == [1, -1, 2, -2]\n assert candidate(n = 600) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300]\n assert candidate(n = 64) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32]\n assert candidate(n = 16) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8]\n assert candidate(n = 450) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225]\n assert candidate(n = 99) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 0]\n assert candidate(n = 17) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 0]\n assert candidate(n = 501) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 0]\n assert candidate(n = 23) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 0]\n assert candidate(n = 51) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 0]\n assert candidate(n = 80) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40]\n assert candidate(n = 128) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64]\n assert candidate(n = 101) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 0]\n assert candidate(n = 8) == [1, -1, 2, -2, 3, -3, 4, -4]\n assert candidate(n = 250) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125]\n assert candidate(n = 999) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375, 376, -376, 377, -377, 378, -378, 379, -379, 380, -380, 381, -381, 382, -382, 383, -383, 384, -384, 385, -385, 386, -386, 387, -387, 388, -388, 389, -389, 390, -390, 391, -391, 392, -392, 393, -393, 394, -394, 395, -395, 396, -396, 397, -397, 398, -398, 399, -399, 400, -400, 401, -401, 402, -402, 403, -403, 404, -404, 405, -405, 406, -406, 407, -407, 408, -408, 409, -409, 410, -410, 411, -411, 412, -412, 413, -413, 414, -414, 415, -415, 416, -416, 417, -417, 418, -418, 419, -419, 420, -420, 421, -421, 422, -422, 423, -423, 424, -424, 425, -425, 426, -426, 427, -427, 428, -428, 429, -429, 430, -430, 431, -431, 432, -432, 433, -433, 434, -434, 435, -435, 436, -436, 437, -437, 438, -438, 439, -439, 440, -440, 441, -441, 442, -442, 443, -443, 444, -444, 445, -445, 446, -446, 447, -447, 448, -448, 449, -449, 450, -450, 451, -451, 452, -452, 453, -453, 454, -454, 455, -455, 456, -456, 457, -457, 458, -458, 459, -459, 460, -460, 461, -461, 462, -462, 463, -463, 464, -464, 465, -465, 466, -466, 467, -467, 468, -468, 469, -469, 470, -470, 471, -471, 472, -472, 473, -473, 474, -474, 475, -475, 476, -476, 477, -477, 478, -478, 479, -479, 480, -480, 481, -481, 482, -482, 483, -483, 484, -484, 485, -485, 486, -486, 487, -487, 488, -488, 489, -489, 490, -490, 491, -491, 492, -492, 493, -493, 494, -494, 495, -495, 496, -496, 497, -497, 498, -498, 499, -499, 0]\n assert candidate(n = 75) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 0]\n assert candidate(n = 32) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16]\n assert candidate(n = 997) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375, 376, -376, 377, -377, 378, -378, 379, -379, 380, -380, 381, -381, 382, -382, 383, -383, 384, -384, 385, -385, 386, -386, 387, -387, 388, -388, 389, -389, 390, -390, 391, -391, 392, -392, 393, -393, 394, -394, 395, -395, 396, -396, 397, -397, 398, -398, 399, -399, 400, -400, 401, -401, 402, -402, 403, -403, 404, -404, 405, -405, 406, -406, 407, -407, 408, -408, 409, -409, 410, -410, 411, -411, 412, -412, 413, -413, 414, -414, 415, -415, 416, -416, 417, -417, 418, -418, 419, -419, 420, -420, 421, -421, 422, -422, 423, -423, 424, -424, 425, -425, 426, -426, 427, -427, 428, -428, 429, -429, 430, -430, 431, -431, 432, -432, 433, -433, 434, -434, 435, -435, 436, -436, 437, -437, 438, -438, 439, -439, 440, -440, 441, -441, 442, -442, 443, -443, 444, -444, 445, -445, 446, -446, 447, -447, 448, -448, 449, -449, 450, -450, 451, -451, 452, -452, 453, -453, 454, -454, 455, -455, 456, -456, 457, -457, 458, -458, 459, -459, 460, -460, 461, -461, 462, -462, 463, -463, 464, -464, 465, -465, 466, -466, 467, -467, 468, -468, 469, -469, 470, -470, 471, -471, 472, -472, 473, -473, 474, -474, 475, -475, 476, -476, 477, -477, 478, -478, 479, -479, 480, -480, 481, -481, 482, -482, 483, -483, 484, -484, 485, -485, 486, -486, 487, -487, 488, -488, 489, -489, 490, -490, 491, -491, 492, -492, 493, -493, 494, -494, 495, -495, 496, -496, 497, -497, 498, -498, 0]\n assert candidate(n = 256) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128]\n assert candidate(n = 20) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]\n assert candidate(n = 201) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 0]\n assert candidate(n = 889) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375, 376, -376, 377, -377, 378, -378, 379, -379, 380, -380, 381, -381, 382, -382, 383, -383, 384, -384, 385, -385, 386, -386, 387, -387, 388, -388, 389, -389, 390, -390, 391, -391, 392, -392, 393, -393, 394, -394, 395, -395, 396, -396, 397, -397, 398, -398, 399, -399, 400, -400, 401, -401, 402, -402, 403, -403, 404, -404, 405, -405, 406, -406, 407, -407, 408, -408, 409, -409, 410, -410, 411, -411, 412, -412, 413, -413, 414, -414, 415, -415, 416, -416, 417, -417, 418, -418, 419, -419, 420, -420, 421, -421, 422, -422, 423, -423, 424, -424, 425, -425, 426, -426, 427, -427, 428, -428, 429, -429, 430, -430, 431, -431, 432, -432, 433, -433, 434, -434, 435, -435, 436, -436, 437, -437, 438, -438, 439, -439, 440, -440, 441, -441, 442, -442, 443, -443, 444, -444, 0]\n assert candidate(n = 19) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 0]\n assert candidate(n = 667) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 0]\n assert candidate(n = 513) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 0]\n assert candidate(n = 13) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 0]\n assert candidate(n = 150) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75]\n assert candidate(n = 800) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375, 376, -376, 377, -377, 378, -378, 379, -379, 380, -380, 381, -381, 382, -382, 383, -383, 384, -384, 385, -385, 386, -386, 387, -387, 388, -388, 389, -389, 390, -390, 391, -391, 392, -392, 393, -393, 394, -394, 395, -395, 396, -396, 397, -397, 398, -398, 399, -399, 400, -400]\n assert candidate(n = 11) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 0]\n assert candidate(n = 876) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375, 376, -376, 377, -377, 378, -378, 379, -379, 380, -380, 381, -381, 382, -382, 383, -383, 384, -384, 385, -385, 386, -386, 387, -387, 388, -388, 389, -389, 390, -390, 391, -391, 392, -392, 393, -393, 394, -394, 395, -395, 396, -396, 397, -397, 398, -398, 399, -399, 400, -400, 401, -401, 402, -402, 403, -403, 404, -404, 405, -405, 406, -406, 407, -407, 408, -408, 409, -409, 410, -410, 411, -411, 412, -412, 413, -413, 414, -414, 415, -415, 416, -416, 417, -417, 418, -418, 419, -419, 420, -420, 421, -421, 422, -422, 423, -423, 424, -424, 425, -425, 426, -426, 427, -427, 428, -428, 429, -429, 430, -430, 431, -431, 432, -432, 433, -433, 434, -434, 435, -435, 436, -436, 437, -437, 438, -438]\n assert candidate(n = 200) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100]\n assert candidate(n = 400) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200]\n assert candidate(n = 512) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256]\n assert candidate(n = 9) == [1, -1, 2, -2, 3, -3, 4, -4, 0]\n assert candidate(n = 6) == [1, -1, 2, -2, 3, -3]\n assert candidate(n = 750) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375]\n assert candidate(n = 120) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60]\n assert candidate(n = 499) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 0]\n assert candidate(n = 199) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 0]\n assert candidate(n = 500) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250]\n assert candidate(n = 998) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20, 21, -21, 22, -22, 23, -23, 24, -24, 25, -25, 26, -26, 27, -27, 28, -28, 29, -29, 30, -30, 31, -31, 32, -32, 33, -33, 34, -34, 35, -35, 36, -36, 37, -37, 38, -38, 39, -39, 40, -40, 41, -41, 42, -42, 43, -43, 44, -44, 45, -45, 46, -46, 47, -47, 48, -48, 49, -49, 50, -50, 51, -51, 52, -52, 53, -53, 54, -54, 55, -55, 56, -56, 57, -57, 58, -58, 59, -59, 60, -60, 61, -61, 62, -62, 63, -63, 64, -64, 65, -65, 66, -66, 67, -67, 68, -68, 69, -69, 70, -70, 71, -71, 72, -72, 73, -73, 74, -74, 75, -75, 76, -76, 77, -77, 78, -78, 79, -79, 80, -80, 81, -81, 82, -82, 83, -83, 84, -84, 85, -85, 86, -86, 87, -87, 88, -88, 89, -89, 90, -90, 91, -91, 92, -92, 93, -93, 94, -94, 95, -95, 96, -96, 97, -97, 98, -98, 99, -99, 100, -100, 101, -101, 102, -102, 103, -103, 104, -104, 105, -105, 106, -106, 107, -107, 108, -108, 109, -109, 110, -110, 111, -111, 112, -112, 113, -113, 114, -114, 115, -115, 116, -116, 117, -117, 118, -118, 119, -119, 120, -120, 121, -121, 122, -122, 123, -123, 124, -124, 125, -125, 126, -126, 127, -127, 128, -128, 129, -129, 130, -130, 131, -131, 132, -132, 133, -133, 134, -134, 135, -135, 136, -136, 137, -137, 138, -138, 139, -139, 140, -140, 141, -141, 142, -142, 143, -143, 144, -144, 145, -145, 146, -146, 147, -147, 148, -148, 149, -149, 150, -150, 151, -151, 152, -152, 153, -153, 154, -154, 155, -155, 156, -156, 157, -157, 158, -158, 159, -159, 160, -160, 161, -161, 162, -162, 163, -163, 164, -164, 165, -165, 166, -166, 167, -167, 168, -168, 169, -169, 170, -170, 171, -171, 172, -172, 173, -173, 174, -174, 175, -175, 176, -176, 177, -177, 178, -178, 179, -179, 180, -180, 181, -181, 182, -182, 183, -183, 184, -184, 185, -185, 186, -186, 187, -187, 188, -188, 189, -189, 190, -190, 191, -191, 192, -192, 193, -193, 194, -194, 195, -195, 196, -196, 197, -197, 198, -198, 199, -199, 200, -200, 201, -201, 202, -202, 203, -203, 204, -204, 205, -205, 206, -206, 207, -207, 208, -208, 209, -209, 210, -210, 211, -211, 212, -212, 213, -213, 214, -214, 215, -215, 216, -216, 217, -217, 218, -218, 219, -219, 220, -220, 221, -221, 222, -222, 223, -223, 224, -224, 225, -225, 226, -226, 227, -227, 228, -228, 229, -229, 230, -230, 231, -231, 232, -232, 233, -233, 234, -234, 235, -235, 236, -236, 237, -237, 238, -238, 239, -239, 240, -240, 241, -241, 242, -242, 243, -243, 244, -244, 245, -245, 246, -246, 247, -247, 248, -248, 249, -249, 250, -250, 251, -251, 252, -252, 253, -253, 254, -254, 255, -255, 256, -256, 257, -257, 258, -258, 259, -259, 260, -260, 261, -261, 262, -262, 263, -263, 264, -264, 265, -265, 266, -266, 267, -267, 268, -268, 269, -269, 270, -270, 271, -271, 272, -272, 273, -273, 274, -274, 275, -275, 276, -276, 277, -277, 278, -278, 279, -279, 280, -280, 281, -281, 282, -282, 283, -283, 284, -284, 285, -285, 286, -286, 287, -287, 288, -288, 289, -289, 290, -290, 291, -291, 292, -292, 293, -293, 294, -294, 295, -295, 296, -296, 297, -297, 298, -298, 299, -299, 300, -300, 301, -301, 302, -302, 303, -303, 304, -304, 305, -305, 306, -306, 307, -307, 308, -308, 309, -309, 310, -310, 311, -311, 312, -312, 313, -313, 314, -314, 315, -315, 316, -316, 317, -317, 318, -318, 319, -319, 320, -320, 321, -321, 322, -322, 323, -323, 324, -324, 325, -325, 326, -326, 327, -327, 328, -328, 329, -329, 330, -330, 331, -331, 332, -332, 333, -333, 334, -334, 335, -335, 336, -336, 337, -337, 338, -338, 339, -339, 340, -340, 341, -341, 342, -342, 343, -343, 344, -344, 345, -345, 346, -346, 347, -347, 348, -348, 349, -349, 350, -350, 351, -351, 352, -352, 353, -353, 354, -354, 355, -355, 356, -356, 357, -357, 358, -358, 359, -359, 360, -360, 361, -361, 362, -362, 363, -363, 364, -364, 365, -365, 366, -366, 367, -367, 368, -368, 369, -369, 370, -370, 371, -371, 372, -372, 373, -373, 374, -374, 375, -375, 376, -376, 377, -377, 378, -378, 379, -379, 380, -380, 381, -381, 382, -382, 383, -383, 384, -384, 385, -385, 386, -386, 387, -387, 388, -388, 389, -389, 390, -390, 391, -391, 392, -392, 393, -393, 394, -394, 395, -395, 396, -396, 397, -397, 398, -398, 399, -399, 400, -400, 401, -401, 402, -402, 403, -403, 404, -404, 405, -405, 406, -406, 407, -407, 408, -408, 409, -409, 410, -410, 411, -411, 412, -412, 413, -413, 414, -414, 415, -415, 416, -416, 417, -417, 418, -418, 419, -419, 420, -420, 421, -421, 422, -422, 423, -423, 424, -424, 425, -425, 426, -426, 427, -427, 428, -428, 429, -429, 430, -430, 431, -431, 432, -432, 433, -433, 434, -434, 435, -435, 436, -436, 437, -437, 438, -438, 439, -439, 440, -440, 441, -441, 442, -442, 443, -443, 444, -444, 445, -445, 446, -446, 447, -447, 448, -448, 449, -449, 450, -450, 451, -451, 452, -452, 453, -453, 454, -454, 455, -455, 456, -456, 457, -457, 458, -458, 459, -459, 460, -460, 461, -461, 462, -462, 463, -463, 464, -464, 465, -465, 466, -466, 467, -467, 468, -468, 469, -469, 470, -470, 471, -471, 472, -472, 473, -473, 474, -474, 475, -475, 476, -476, 477, -477, 478, -478, 479, -479, 480, -480, 481, -481, 482, -482, 483, -483, 484, -484, 485, -485, 486, -486, 487, -487, 488, -488, 489, -489, 490, -490, 491, -491, 492, -492, 493, -493, 494, -494, 495, -495, 496, -496, 497, -497, 498, -498, 499, -499]\n assert candidate(n = 7) == [1, -1, 2, -2, 3, -3, 0]\n assert candidate(n = 25) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 0]\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().sumZero", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector sumZero(int n) {", "container": "Solution", "callable": "sumZero", "parameters": [{"name": "n", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1305, "task_id": "all-elements-in-two-binary-search-trees", "difficulty": "Medium", "problem_description": "Given two binary search trees root1 and root2, return a list containing all the integers from both trees sorted in ascending order.\n \nExample 1:\n\n\nInput: root1 = [2,1,4], root2 = [1,0,3]\nOutput: [0,1,1,2,3,4]\n\nExample 2:\n\n\nInput: root1 = [1,null,8], root2 = [8,1]\nOutput: [1,1,8,8]\n\n \nConstraints:\n\nThe number of nodes in each tree is in the range [0, 5000].\n-105 <= Node.val <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root1 = tree_node([5, 3, 6]),root2 = tree_node([2, 2, 3, None, None, 4, 4])) == [2, 2, 3, 4, 3, 4, 5, 6]\n assert candidate(root1 = tree_node([]),root2 = tree_node([5])) == [5]\n assert candidate(root1 = tree_node([5, 3, 7]),root2 = tree_node([2, 6, 8])) == [3, 5, 6, 2, 7, 8]\n assert candidate(root1 = tree_node([]),root2 = tree_node([])) == []\n assert candidate(root1 = tree_node([2, 1, 4]),root2 = tree_node([1, 0, 3])) == [0, 1, 1, 2, 3, 4]\n assert candidate(root1 = tree_node([10]),root2 = tree_node([5, 15])) == [10, 15, 5]\n assert candidate(root1 = tree_node([5]),root2 = tree_node([])) == [5]\n assert candidate(root1 = tree_node([1, None, 8]),root2 = tree_node([8, 1])) == [1, 1, 8, 8]\n assert candidate(root1 = tree_node([5, 3, 6]),root2 = tree_node([2, 4, 7])) == [3, 4, 2, 5, 6, 7]\n assert candidate(root1 = tree_node([30, 15, 45, 10, 20, 40, 50, 5, 12, 18, 22, 35, 42, 48, 55]),root2 = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 8, 12, 17, 23, 28, 33, 38])) == [3, 5, 5, 8, 10, 10, 12, 12, 15, 15, 17, 18, 20, 20, 22, 23, 25, 28, 30, 30, 33, 35, 35, 38, 40, 42, 45, 48, 50, 55]\n assert candidate(root1 = tree_node([10, None, 20, None, 30, None, 40, None, 50]),root2 = tree_node([5, None, 15, None, 25, None, 35, None, 45])) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(root1 = tree_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19]),root2 = tree_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20])) == [15, 7, 16, 8, 17, 3, 18, 4, 19, 9, 1, 11, 5, 13, 20, 10, 2, 12, 6, 14]\n assert candidate(root1 = tree_node([1, None, None, None]),root2 = tree_node([2, None, None, None])) == [1, 2]\n assert candidate(root1 = tree_node([50, 30, 70, 20, 40, 60, 80, None, 25, 35, 45, 55, 65, 75, 85]),root2 = tree_node([45, 35, 55, 25, 48, 58, 75, None, 28, 32, 42, 47, 57, 70, 78])) == [20, 25, 25, 28, 30, 35, 35, 32, 40, 45, 48, 42, 45, 47, 50, 55, 58, 57, 55, 60, 65, 70, 70, 75, 75, 78, 80, 85]\n assert candidate(root1 = tree_node([20, 10, 30, 5, 15, 25, 35, 1, 7, 12, 18, 23, 27, 32, 38]),root2 = tree_node([30, 15, 45, 10, 20, 35, 50, 5, 12, 18, 25, 40, 42, 48, 55])) == [1, 5, 5, 7, 10, 10, 12, 12, 15, 15, 18, 18, 20, 20, 23, 25, 25, 27, 30, 30, 32, 35, 38, 40, 35, 42, 45, 48, 50, 55]\n assert candidate(root1 = tree_node([100000, -100000]),root2 = tree_node([50000, -50000])) == [-100000, -50000, 50000, 100000]\n assert candidate(root1 = tree_node([5, 3, 8, 1, 4, 7, 10]),root2 = tree_node([2, 6, 9, 0, 3, 5, 11, 2, 4, 6, 8, 10, 12])) == [1, 2, 0, 3, 4, 4, 5, 6, 6, 3, 7, 8, 8, 2, 10, 10, 5, 12, 9, 11]\n assert candidate(root1 = tree_node([1, None, 2, None, 3, None, 4, None, 5]),root2 = tree_node([6, None, 7, None, 8, None, 9, None, 10])) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(root1 = tree_node([100]),root2 = tree_node([50, 25, 75, 10, 30, 60, 80, 5, 15, 20, 40, 55, 65, 70, 85])) == [5, 10, 15, 25, 20, 30, 40, 50, 55, 60, 65, 75, 70, 80, 85, 100]\n assert candidate(root1 = tree_node([5, 2, 6, 1, 3, None, None]),root2 = tree_node([3, 1, 7, None, 2, None, 8, None, None, None, None, None, None])) == [1, 1, 2, 2, 3, 3, 5, 6, 7, 8]\n assert candidate(root1 = tree_node([1, 0, 3, None, None, 2, None, None, None, None, None, None, None]),root2 = tree_node([4, 3, 5, None, None, None, None, None, None, None, None, None, None])) == [0, 1, 2, 3, 3, 4, 5]\n assert candidate(root1 = tree_node([100, 50, 150, 25, 75, 125, 175]),root2 = tree_node([200, 150, 250, 125, 175, 225, 275])) == [25, 50, 75, 100, 125, 125, 150, 150, 175, 175, 200, 225, 250, 275]\n assert candidate(root1 = tree_node([1]),root2 = tree_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(root1 = tree_node([1, None, 2, None, 3, None, 4, None, 5]),root2 = tree_node([5, None, 4, None, 3, None, 2, None, 1])) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]\n assert candidate(root1 = tree_node([50, 25, 75, 10, 40, 60, 90, 5, 20, 30, 45, 55, 65, 80, 95]),root2 = tree_node([30, 15, 45, 10, 20, 35, 50, 25, 40, 42, 46, 48, 52, 54, 58])) == [5, 10, 20, 25, 25, 10, 30, 40, 40, 15, 42, 20, 45, 46, 30, 48, 35, 50, 52, 45, 54, 50, 55, 58, 60, 65, 75, 80, 90, 95]\n assert candidate(root1 = tree_node([100, 50, 150, None, 75, 125, 175]),root2 = tree_node([80, 60, 90, 55, 65, 85, 95])) == [50, 55, 60, 65, 75, 80, 85, 90, 95, 100, 125, 150, 175]\n assert candidate(root1 = tree_node([-5, -10, -3, -15, -7]),root2 = tree_node([-20, -12, -8, -17, -13])) == [-17, -15, -12, -13, -20, -10, -8, -7, -5, -3]\n assert candidate(root1 = tree_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19]),root2 = tree_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30])) == [15, 7, 16, 8, 17, 3, 18, 4, 19, 9, 1, 11, 5, 13, 20, 10, 22, 2, 24, 12, 26, 6, 28, 14, 30]\n assert candidate(root1 = tree_node([5, 2, 7, 1, 3, None, 8, None, None, 4, 6]),root2 = tree_node([15, 12, 20, 10, 13, 18, 25, None, 11, 14, 16, 19, 21, 24, 26])) == [1, 2, 4, 3, 6, 5, 7, 8, 10, 11, 12, 14, 13, 16, 15, 19, 18, 21, 20, 24, 25, 26]\n assert candidate(root1 = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),root2 = tree_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == [3, 7, 2, 8, 4, 9, 2, 9, 1, 6, 10, 5, 1, 6, 3, 7, 10, 5, 8, 4]\n assert candidate(root1 = tree_node([5, 3, 7, 2, 4, 6, 8]),root2 = tree_node([5, 3, 7, 2, 4, 6, 8])) == [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]\n assert candidate(root1 = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180]),root2 = tree_node([90, 40, 130, 30, 60, 110, 150, 20, 50, 70, 80, 100, 120, 140, 160])) == [10, 20, 25, 30, 30, 50, 50, 40, 60, 70, 60, 75, 80, 80, 90, 100, 100, 110, 110, 120, 125, 130, 140, 140, 150, 150, 160, 160, 175, 180]\n assert candidate(root1 = tree_node([20, 10, 30, 5, 15, 25, 35]),root2 = tree_node([18, 9, 21, 8, 11, 19, 22])) == [5, 8, 9, 10, 11, 15, 18, 19, 20, 21, 22, 25, 30, 35]\n assert candidate(root1 = tree_node([30, 15, 45, 10, 20, 35, 40]),root2 = tree_node([50, 25, 75, 12, 38, 60, 80, 7, 18, 28, 42, 55, 65, 78, 90])) == [7, 10, 12, 15, 18, 20, 25, 28, 30, 35, 38, 42, 45, 40, 50, 55, 60, 65, 75, 78, 80, 90]\n assert candidate(root1 = tree_node([50, 30, 70, 20, 40, 60, 80]),root2 = tree_node([45, 35, 55, 33, 37, 53, 57])) == [20, 30, 33, 35, 37, 40, 45, 50, 53, 55, 57, 60, 70, 80]\n assert candidate(root1 = tree_node([10, None, 20, None, 30, None, 40, None, 50]),root2 = tree_node([15, None, 25, None, 35, None, 45, None, 55])) == [10, 15, 20, 25, 30, 35, 40, 45, 50, 55]\n assert candidate(root1 = tree_node([50, 25, 75, 10, 40, 60, 90]),root2 = tree_node([20, 15, 28, 12, 18, 26, 30])) == [10, 12, 15, 18, 20, 25, 26, 28, 30, 40, 50, 60, 75, 90]\n assert candidate(root1 = tree_node([5, 3, 8, 1, 4, 7, 9, None, 2, 6, None, None, None, None, None, None, None, None, None, None, None]),root2 = tree_node([10, 8, 12, 6, 9, 11, 13, None, 5, 7, 14])) == [1, 2, 3, 6, 4, 5, 6, 5, 7, 8, 8, 7, 9, 9, 14, 10, 11, 12, 13]\n assert candidate(root1 = tree_node([50, 25, 75, 12, 37, 62, 87, 6, 18, 31, 43, 56, 70, 81, 93, 3, 9, 15, 21, 27, 34, 39, 46, 51, 58, 65, 68, 74, 79, 84, 89, 96]),root2 = tree_node([60, 30, 90, 15, 45, 75, 105, 7, 23, 35, 55, 85, 115, 3, 11, 17, 29, 33, 37, 51, 59, 63, 67, 73, 77, 81, 83, 87, 91, 95, 99])) == [17, 7, 29, 15, 33, 23, 37, 30, 51, 35, 59, 45, 63, 55, 67, 60, 73, 85, 77, 75, 81, 96, 3, 6, 9, 12, 15, 18, 21, 25, 27, 31, 34, 37, 39, 43, 46, 50, 51, 56, 58, 62, 65, 70, 68, 75, 74, 81, 79, 87, 84, 93, 89, 115, 83, 90, 87, 3, 91, 105, 95, 11, 99]\n assert candidate(root1 = tree_node([30, 10, 50, 5, 20, 40, 60, 3, 7, 15, 25, 35, 45, 55, 65]),root2 = tree_node([40, 20, 60, 10, 30, 50, 70, 5, 15, 25, 35, 45, 55, 65, 75])) == [3, 5, 5, 7, 10, 10, 15, 15, 20, 20, 25, 25, 30, 30, 35, 35, 40, 40, 45, 45, 50, 50, 55, 55, 60, 60, 65, 65, 70, 75]\n assert candidate(root1 = tree_node([100, 90, 110, 80, 95, 105, 120, 70, 85, 92, 98, 102, 115, 118, 125]),root2 = tree_node([200, 190, 210, 180, 195, 205, 215, 170, 185, 192, 198, 202, 215, 218, 225])) == [70, 80, 85, 90, 92, 95, 98, 100, 102, 105, 115, 110, 118, 120, 125, 170, 180, 185, 190, 192, 195, 198, 200, 202, 205, 215, 210, 218, 215, 225]\n assert candidate(root1 = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),root2 = tree_node([5, 6, 7, 8, 9, 10, 11, 12, 13, 14])) == [8, 4, 9, 2, 10, 5, 1, 6, 3, 7, 12, 8, 13, 6, 14, 9, 5, 10, 7, 11]\n assert candidate(root1 = tree_node([3, 1, 5, None, 2, None, None]),root2 = tree_node([4, 2, 6, None, 3, None, None])) == [1, 2, 2, 3, 3, 4, 5, 6]\n assert candidate(root1 = tree_node([5, 2, 7, 1, None, 6, 8]),root2 = tree_node([3, 1, 6, None, 2, 5, 7])) == [1, 1, 2, 2, 3, 5, 5, 6, 6, 7, 7, 8]\n assert candidate(root1 = tree_node([5, 5, 5, 5, 5, 5, 5]),root2 = tree_node([5, 5, 5, 5, 5, 5, 5])) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(root1 = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 190]),root2 = tree_node([90, 40, 160, 30, 50, 130, 180, 20, 40, 50, 60, 120, 150, 170, 190])) == [10, 20, 25, 30, 30, 40, 40, 50, 50, 50, 60, 60, 75, 80, 90, 100, 110, 120, 125, 130, 140, 150, 150, 160, 160, 170, 175, 180, 190, 190]\n assert candidate(root1 = tree_node([10, 5, 15, 3, 7, 12, 18, 1, 4, 6, 8, 11, 13, 17, 19]),root2 = tree_node([8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15])) == [1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 15, 15, 17, 18, 19]\n assert candidate(root1 = tree_node([20, 10, 30, 5, 15, 25, 35]),root2 = tree_node([12, 8, 18, 6, 10, 16, 20])) == [5, 6, 8, 10, 10, 12, 15, 16, 18, 20, 20, 25, 30, 35]\n assert candidate(root1 = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180]),root2 = tree_node([90, 40, 140, 30, 60, 100, 160, 20, 50, 70, 90, 110, 130, 150, 170])) == [10, 20, 25, 30, 30, 50, 50, 40, 60, 70, 60, 75, 80, 90, 90, 100, 110, 110, 100, 125, 130, 140, 140, 150, 150, 160, 160, 170, 175, 180]\n assert candidate(root1 = tree_node([10000, 5000, 15000, 2500, 7500, 12500, 17500]),root2 = tree_node([10000, 9999, 10001, 9998, 9999, 10000, 10002])) == [2500, 5000, 7500, 9998, 9999, 9999, 10000, 10000, 10000, 10001, 10002, 12500, 15000, 17500]\n assert candidate(root1 = tree_node([1]),root2 = tree_node([2, 3, 4, 5, 6, 7, 8, 9, 10])) == [1, 9, 5, 10, 3, 6, 2, 7, 4, 8]\n assert candidate(root1 = tree_node([10, 5, 15, 2, 7, 12, 18, 1, 4, 6, 8, 11, 13, 16, 19]),root2 = tree_node([15, 7, 20, 3, 11, 17, 25, 1, 5, 9, 12, 14, 18, 22, 28])) == [1, 1, 2, 3, 4, 5, 5, 6, 7, 7, 8, 9, 10, 11, 11, 12, 12, 13, 15, 15, 14, 16, 17, 18, 18, 19, 20, 22, 25, 28]\n assert candidate(root1 = tree_node([50, 30, 70, 20, 40, 60, 80]),root2 = tree_node([45, 35, 55, 25, 48, 58, 75])) == [20, 25, 30, 35, 40, 48, 45, 50, 58, 55, 60, 70, 75, 80]\n assert candidate(root1 = tree_node([1000, 500, 1500, 250, 750, 1250, 1750, 125, 375, 625, 875, 1125, 1375, 1625, 1875]),root2 = tree_node([1500, 1250, 1750, 1125, 1375, 1625, 1875, 1000, 750, 1250, 1500, 875, 1375, 1625, 1875])) == [125, 250, 375, 500, 625, 750, 875, 1000, 1000, 1125, 1125, 750, 1250, 1250, 1250, 1375, 1375, 1500, 1500, 1500, 875, 1625, 1625, 1375, 1750, 1750, 1625, 1875, 1875, 1875]\n assert candidate(root1 = tree_node([50, 30, 70, 20, 40, 60, 80, 10, 25, 35, 45, 55, 65, 75, 85]),root2 = tree_node([30, 10, 50, 5, 20, 40, 60, 3, 7, 15, 25, 35, 45, 55, 65])) == [3, 5, 7, 10, 10, 15, 20, 20, 25, 25, 30, 30, 35, 35, 40, 40, 45, 45, 50, 50, 55, 55, 60, 60, 65, 65, 70, 75, 80, 85]\n assert candidate(root1 = tree_node([100000, -100000, None, None, None]),root2 = tree_node([-100000, 100000, None, None, None])) == [-100000, 100000, 100000, -100000]\n assert candidate(root1 = tree_node([100, -100, 200, -200, 0, 150, 250]),root2 = tree_node([150, 100, 250, 50, 125, 200, 300, -50, 75, 110, 130, 180, 225, 275, 350])) == [-200, -100, -50, 0, 50, 75, 100, 100, 110, 125, 130, 150, 150, 180, 200, 200, 225, 250, 250, 275, 300, 350]\n assert candidate(root1 = tree_node([5, 3, 7, 2, 4, 6, 8]),root2 = tree_node([3, 1, 6, None, 2, 5, 9])) == [1, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 8, 9]\n assert candidate(root1 = tree_node([50, 25, 75, 10, 40, 60, 90, 5, 20, 30, 45, 55, 70, 85, 100]),root2 = tree_node([30, 15, 45, 10, 20, 35, 40, 5, 12, 25, 38, 42, 50, 48, 52])) == [5, 5, 10, 10, 12, 15, 20, 25, 25, 20, 30, 38, 30, 40, 42, 35, 45, 50, 50, 45, 48, 40, 52, 55, 60, 70, 75, 85, 90, 100]\n assert candidate(root1 = tree_node([50, 30, 70, 20, 40, 60, 80, 10, 25, 35, 45, 55, 65, 75, 85]),root2 = tree_node([45, 35, 55, 25, 40, 50, 60, 15, 30, 42, 48, 52, 58, 62, 68])) == [10, 15, 20, 25, 25, 30, 30, 35, 35, 40, 42, 40, 45, 48, 45, 50, 52, 50, 55, 58, 55, 60, 62, 60, 65, 68, 70, 75, 80, 85]\n assert candidate(root1 = tree_node([1, 0, 2]),root2 = tree_node([2, 1, 3])) == [0, 1, 1, 2, 2, 3]\n assert candidate(root1 = tree_node([0]),root2 = tree_node([0, 0, 0, 0, 0])) == [0, 0, 0, 0, 0, 0]\n assert candidate(root1 = tree_node([50, 25, 75, 12, 37, 62, 87, 6, 18, 31, 43, 56, 70, 81, 93]),root2 = tree_node([45, 22, 60, 10, 30, 50, 70, 5, 15, 25, 35, 40, 55, 65, 75])) == [5, 6, 10, 12, 15, 18, 22, 25, 25, 30, 31, 35, 37, 43, 45, 40, 50, 50, 55, 56, 60, 62, 65, 70, 70, 75, 75, 81, 87, 93]\n assert candidate(root1 = tree_node([100, 50, 150, 25, 75, 125, 175]),root2 = tree_node([110, 60, 160, 55, 65, 130, 170, 50, 62, 120, 135, 165, 175])) == [25, 50, 50, 55, 62, 60, 75, 100, 120, 65, 125, 135, 110, 150, 165, 130, 175, 175, 160, 170]\n assert candidate(root1 = tree_node([2, 1, None, None, None, None, 3, 4, None, None, None, None, None, None, 5, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None]),root2 = tree_node([1, None, 3, None, None, 2, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None])) == [1, 1, 2, 3]\n assert candidate(root1 = tree_node([1, 2, 3, 4, 5, 6, 7]),root2 = tree_node([8, 9, 10, 11, 12, 13, 14])) == [4, 2, 5, 1, 6, 3, 7, 11, 9, 12, 8, 13, 10, 14]\n assert candidate(root1 = tree_node([10]),root2 = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9])) == [8, 4, 9, 2, 5, 1, 6, 3, 7, 10]\n assert candidate(root1 = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180]),root2 = tree_node([50, 25, 75, 15, 35, 65, 85, 10, 20, 40, 50, 70, 90, 110, 130])) == [10, 10, 15, 20, 25, 25, 30, 40, 35, 50, 50, 50, 60, 70, 65, 75, 80, 90, 75, 100, 110, 110, 85, 125, 130, 140, 150, 160, 175, 180]\n assert candidate(root1 = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7]),root2 = tree_node([7, None, 6, None, 5, None, 4, None, 3, None, 2, None, 1])) == [1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(root1 = tree_node([50, 25, 75, 10, 40, 60, 90, 5, 20, 30, 45, 55, 70, 85, 100]),root2 = tree_node([60, 30, 90, 15, 45, 75, 120, 10, 25, 35, 50, 65, 80, 105, 130])) == [5, 10, 10, 15, 20, 25, 25, 30, 30, 35, 40, 45, 45, 50, 50, 55, 60, 60, 65, 70, 75, 75, 80, 85, 90, 90, 100, 105, 120, 130]\n assert candidate(root1 = tree_node([100, 50, 150, 25, 75, 125, 175]),root2 = tree_node([80, 60, 90, 55, 65, 85, 95])) == [25, 50, 55, 60, 65, 75, 80, 85, 90, 95, 100, 125, 150, 175]\n assert candidate(root1 = tree_node([50, 25, 75, 12, 37, 62, 88, 6, 18, 31, 43, 56, 70, 82, 95]),root2 = tree_node([50, 25, 75, 12, 37, 62, 88, 6, 18, 31, 43, 56, 70, 82, 95])) == [6, 6, 12, 12, 18, 18, 25, 25, 31, 31, 37, 37, 43, 43, 50, 50, 56, 56, 62, 62, 70, 70, 75, 75, 82, 82, 88, 88, 95, 95]\n assert candidate(root1 = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 130, 160, 180]),root2 = tree_node([90, 40, 140, 35, 45, 135, 145, 32, 37, 42, 48, 132, 138, 142, 147])) == [10, 25, 30, 32, 35, 37, 40, 42, 45, 48, 50, 60, 75, 80, 90, 100, 110, 125, 130, 132, 135, 138, 140, 142, 145, 147, 150, 160, 175, 180]\n assert candidate(root1 = tree_node([5, 2, 7, 1, None, 6, 8]),root2 = tree_node([5, 2, 7, 1, None, 6, 8])) == [1, 1, 2, 2, 5, 5, 6, 6, 7, 7, 8, 8]\n assert candidate(root1 = tree_node([5]),root2 = tree_node([5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5])) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(root1 = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),root2 = tree_node([11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == [8, 4, 9, 2, 10, 5, 1, 6, 3, 7, 18, 14, 19, 12, 20, 15, 11, 16, 13, 17]\n assert candidate(root1 = tree_node([500, 250, 750, 125, 375, 625, 875, 63, 188, 313, 438, 563, 688, 813, 938]),root2 = tree_node([450, 225, 675, 113, 338, 500, 825, 57, 169, 294, 388, 450, 588, 732, 898])) == [57, 63, 113, 125, 169, 188, 225, 250, 294, 313, 338, 375, 388, 438, 450, 450, 500, 500, 563, 588, 625, 675, 688, 732, 750, 813, 825, 875, 898, 938]\n assert candidate(root1 = tree_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]),root2 = tree_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30])) == [15, 7, 16, 8, 17, 3, 18, 4, 19, 9, 20, 10, 21, 1, 22, 2, 23, 11, 24, 12, 25, 5, 26, 6, 27, 13, 28, 14, 29, 30]\n assert candidate(root1 = tree_node([100]),root2 = tree_node([50, 25, 75, 12, 37, 63, 88, 6, 18, 30, 44, 56, 70, 82, 93])) == [6, 12, 18, 25, 30, 37, 44, 50, 56, 63, 70, 75, 82, 88, 93, 100]\n assert candidate(root1 = tree_node([5, 1, 7, None, 2, None, 8]),root2 = tree_node([3, 1, 6, None, 2, 5, 9])) == [1, 1, 2, 2, 3, 5, 5, 6, 7, 8, 9]\n assert candidate(root1 = tree_node([10, 5, 15, 3, 7, 13, 18, 1, 4, 6, 8, 12, 14, 17, 20]),root2 = tree_node([11, 6, 16, 5, 7, 13, 17, 4, 8, 12, 14, 15, 18, 19, 21])) == [1, 3, 4, 4, 5, 5, 6, 7, 8, 8, 6, 10, 12, 12, 7, 13, 14, 14, 11, 15, 15, 13, 17, 18, 18, 16, 19, 17, 20, 21]\n assert candidate(root1 = tree_node([50, 25, 75, 10, 40, 60, 90, 5, 20, 30, 45, 55, 65, 80, 95]),root2 = tree_node([100, 50, 150, 25, 75, 125, 175])) == [5, 10, 20, 25, 25, 30, 40, 45, 50, 50, 55, 60, 65, 75, 75, 80, 90, 95, 100, 125, 150, 175]\n assert candidate(root1 = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180]),root2 = tree_node([90, 40, 140, 20, 60, 120, 160, 15, 25, 50, 55, 115, 130, 155, 170])) == [10, 15, 20, 25, 25, 30, 40, 50, 50, 60, 60, 55, 75, 80, 90, 100, 110, 115, 120, 125, 130, 140, 140, 150, 155, 160, 160, 170, 175, 180]\n assert candidate(root1 = tree_node([1, None, None]),root2 = tree_node([1, None, None])) == [1, 1]\n assert candidate(root1 = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 130, 160, 180]),root2 = tree_node([90, 40, 140, 35, 45, 85, 135, 33, 37, 43, 47, 83, 87, 133, 137])) == [10, 25, 30, 33, 35, 37, 40, 43, 45, 47, 50, 60, 75, 80, 90, 83, 85, 87, 100, 110, 125, 130, 140, 133, 135, 137, 150, 160, 175, 180]\n assert candidate(root1 = tree_node([5, 2, 8, None, 3, 6, 9, None, None, 4, 7]),root2 = tree_node([3, 1, 7, 2, 4, 6, 8])) == [2, 2, 1, 3, 4, 3, 5, 4, 6, 6, 7, 7, 8, 8, 9]\n assert candidate(root1 = tree_node([1]),root2 = tree_node([2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])) == [1, 9, 5, 10, 3, 11, 6, 12, 2, 13, 7, 14, 4, 15, 8, 16]\n assert candidate(root1 = tree_node([20, 10, 30, 5, 15, 25, 35, None, None, None, None, 22, 27, 32, 37]),root2 = tree_node([18, 9, 21, 8, 11, 19, 22, None, None, None, None, 20, 25, 28, 31])) == [5, 8, 9, 10, 11, 15, 18, 20, 20, 19, 22, 25, 25, 21, 27, 28, 22, 30, 31, 32, 35, 37]\n assert candidate(root1 = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),root2 = tree_node([15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == [8, 4, 8, 9, 2, 10, 5, 11, 1, 12, 6, 12, 7, 13, 3, 14, 7, 14, 6, 11, 5, 15, 15, 4, 10, 3, 13, 2, 9, 1]\n assert candidate(root1 = tree_node([10, None, 20, None, None, 15, None, None, None, None, None, None, None, None, None]),root2 = tree_node([20, None, 30, None, None, 25, None, None, None, None, None, None, None, None, None])) == [10, 20, 20, 30]\n assert candidate(root1 = tree_node([100, 50, 150, 25, 75, 125, 175, 12, 37, 62, 87, 112, 137, 162, 187]),root2 = tree_node([80, 60, 90, 55, 65, 85, 95, 50, 60, 70, 80, 90, 100, 110, 120])) == [12, 25, 37, 50, 50, 55, 60, 60, 62, 70, 65, 75, 80, 80, 87, 90, 85, 100, 100, 90, 110, 95, 112, 120, 125, 137, 150, 162, 175, 187]\n assert candidate(root1 = tree_node([1, 3, 5, 7, 9, 11, 13]),root2 = tree_node([2, 4, 6, 8, 10, 12, 14])) == [7, 3, 8, 4, 9, 1, 10, 2, 11, 5, 12, 6, 13, 14]\n assert candidate(root1 = tree_node([100, 50, 150, 25, 75, 125, 175]),root2 = tree_node([90, 40, 140, 30, 60, 130, 160])) == [25, 30, 40, 50, 60, 75, 90, 100, 125, 130, 140, 150, 160, 175]\n assert candidate(root1 = tree_node([1, 0, 2, None, None, 1.5, None, None, None, None, None, None, None]),root2 = tree_node([2, 1, 3, None, None, 1.5, None, None, None, None, None, None, None])) == [0, 1, 1, 1.5, 2, 2, 1.5, 3]\n assert candidate(root1 = tree_node([10000, 5000, 15000, 2500, 7500, 12500, 17500, 1250, 3750, 6250, 8750, 11250, 14375, 16250, 18750]),root2 = tree_node([10000, 5000, 15000, 2500, 7500, 12500, 17500, 1250, 3750, 6250, 8750, 11250, 14375, 16250, 18750])) == [1250, 1250, 2500, 2500, 3750, 3750, 5000, 5000, 6250, 6250, 7500, 7500, 8750, 8750, 10000, 10000, 11250, 11250, 12500, 12500, 14375, 14375, 15000, 15000, 16250, 16250, 17500, 17500, 18750, 18750]\n"}, "metadata": {"canonical_parameter_names": ["root1", "root2"], "leetcode_dataset_entry_point": "Solution().getAllElements", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector getAllElements(TreeNode* root1, TreeNode* root2) {", "container": "Solution", "callable": "getAllElements", "parameters": [{"name": "root1", "type": "TreeNode*"}, {"name": "root2", "type": "TreeNode*"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1306, "task_id": "jump-game-iii", "difficulty": "Medium", "problem_description": "Given an array of non-negative integers arr, you are initially positioned at start index of the array. When you are at index i, you can jump to i + arr[i] or i - arr[i], check if you can reach any index with value 0.\nNotice that you can not jump outside of the array at any time.\n \nExample 1:\n\nInput: arr = [4,2,3,0,3,1,2], start = 5\nOutput: true\nExplanation: \nAll possible ways to reach at index 3 with value 0 are: \nindex 5 -> index 4 -> index 1 -> index 3 \nindex 5 -> index 6 -> index 4 -> index 1 -> index 3 \n\nExample 2:\n\nInput: arr = [4,2,3,0,3,1,2], start = 0\nOutput: true \nExplanation: \nOne possible way to reach at index 3 with value 0 is: \nindex 0 -> index 4 -> index 1 -> index 3\n\nExample 3:\n\nInput: arr = [3,0,2,1,2], start = 2\nOutput: false\nExplanation: There is no way to reach at index 1 with value 0.\n\n \nConstraints:\n\n1 <= arr.length <= 5 * 104\n0 <= arr[i] < arr.length\n0 <= start < arr.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [5, 0, 5, 0, 5, 0],start = 1) == True\n assert candidate(arr = [5, 0, 0, 0, 0, 0],start = 0) == True\n assert candidate(arr = [4, 2, 3, 0, 3, 1, 2],start = 0) == True\n assert candidate(arr = [0, 1, 0, 1, 0, 1, 0],start = 1) == True\n assert candidate(arr = [0, 1, 0, 1, 0],start = 4) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],start = 5) == True\n assert candidate(arr = [3, 0, 2, 1, 2],start = 2) == False\n assert candidate(arr = [0, 1, 0, 1, 0],start = 3) == True\n assert candidate(arr = [0, 1, 1, 0, 1, 1],start = 4) == True\n assert candidate(arr = [0, 1, 0, 1, 0, 1, 0],start = 0) == True\n assert candidate(arr = [1, 2, 3, 4, 0],start = 0) == False\n assert candidate(arr = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],start = 0) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0],start = 5) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 0) == True\n assert candidate(arr = [0, 1, 0, 1, 0],start = 2) == True\n assert candidate(arr = [0, 1, 0, 1, 0],start = 0) == True\n assert candidate(arr = [4, 2, 3, 0, 3, 1, 2],start = 5) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],start = 5) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5],start = 3) == True\n assert candidate(arr = [1, 2, 3, 4, 0],start = 4) == True\n assert candidate(arr = [2, 3, 1, 1, 4],start = 3) == False\n assert candidate(arr = [1, 1, 1, 1, 1, 1],start = 0) == False\n assert candidate(arr = [0, 1],start = 1) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5],start = 0) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],start = 0) == False\n assert candidate(arr = [1, 2, 3, 4, 0],start = 2) == False\n assert candidate(arr = [2, 3, 0, 1, 4],start = 2) == True\n assert candidate(arr = [5, 0, 0, 0, 0, 0, 0, 0, 0, 0],start = 1) == True\n assert candidate(arr = [0, 1, 0, 1, 0],start = 1) == True\n assert candidate(arr = [1, 0, 1, 0, 1, 0],start = 0) == True\n assert candidate(arr = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],start = 6) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],start = 15) == True\n assert candidate(arr = [2, 0, 1, 1, 3, 0, 2, 0, 1, 0],start = 1) == True\n assert candidate(arr = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],start = 1) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 18) == True\n assert candidate(arr = [1, 3, 0, 0, 2, 4, 2, 0, 1, 3],start = 5) == True\n assert candidate(arr = [5, 0, 2, 0, 3, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0],start = 1) == True\n assert candidate(arr = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 0],start = 1) == True\n assert candidate(arr = [3, 5, 2, 1, 0, 0, 1, 2, 3],start = 5) == True\n assert candidate(arr = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],start = 0) == False\n assert candidate(arr = [5, 1, 4, 1, 2, 3, 0, 1],start = 2) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5],start = 6) == True\n assert candidate(arr = [5, 2, 1, 4, 0, 0, 0, 3, 1, 2, 1],start = 0) == True\n assert candidate(arr = [4, 0, 1, 0, 2, 3, 0, 1],start = 2) == True\n assert candidate(arr = [0, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],start = 15) == True\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],start = 10) == True\n assert candidate(arr = [5, 0, 0, 0, 0, 0, 0, 0, 0, 5],start = 9) == True\n assert candidate(arr = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],start = 10) == True\n assert candidate(arr = [3, 2, 1, 0, 4, 2, 0, 3, 0, 1],start = 0) == True\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0],start = 19) == True\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0],start = 0) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 24) == True\n assert candidate(arr = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 0) == True\n assert candidate(arr = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0],start = 10) == True\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3],start = 15) == False\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],start = 20) == True\n assert candidate(arr = [3, 4, 1, 2, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2],start = 19) == True\n assert candidate(arr = [4, 2, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],start = 13) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],start = 0) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0],start = 5) == False\n assert candidate(arr = [4, 0, 5, 0, 3, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5],start = 1) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],start = 19) == True\n assert candidate(arr = [4, 2, 3, 0, 3, 1, 2, 3, 0, 1],start = 8) == True\n assert candidate(arr = [3, 4, 2, 3, 0, 1, 2, 0, 1, 3],start = 0) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 14) == True\n assert candidate(arr = [2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0],start = 0) == False\n assert candidate(arr = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],start = 6) == True\n assert candidate(arr = [5, 3, 0, 0, 2, 0, 1, 0, 0, 3, 0],start = 2) == True\n assert candidate(arr = [1, 3, 0, 0, 2, 3, 4, 0, 0, 5, 4, 3],start = 1) == True\n assert candidate(arr = [4, 0, 5, 3, 0, 1, 2, 0, 3, 1],start = 5) == True\n assert candidate(arr = [4, 1, 3, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 2) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0],start = 19) == True\n assert candidate(arr = [2, 3, 0, 1, 4, 5, 6, 0, 2, 1],start = 3) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 5) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 19) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],start = 9) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0],start = 39) == False\n assert candidate(arr = [1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 0],start = 0) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 9) == True\n assert candidate(arr = [0, 2, 1, 0, 1, 0, 1, 0, 1, 0],start = 8) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],start = 5) == True\n assert candidate(arr = [2, 0, 2, 0, 1, 0, 1, 0, 2, 0, 1, 0, 1, 0, 2, 0],start = 14) == True\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],start = 10) == True\n assert candidate(arr = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 34) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0],start = 13) == True\n assert candidate(arr = [5, 0, 1, 2, 3, 0, 1, 0, 2, 3, 0],start = 5) == True\n assert candidate(arr = [4, 2, 3, 1, 0, 2, 3, 4, 5, 0],start = 2) == True\n assert candidate(arr = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],start = 14) == True\n assert candidate(arr = [2, 3, 4, 5, 0, 0, 5, 4, 3, 2],start = 5) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],start = 0) == True\n assert candidate(arr = [10, 8, 5, 0, 12, 10, 7, 3, 8, 4, 2, 9, 0, 6, 1],start = 5) == False\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],start = 10) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],start = 20) == True\n assert candidate(arr = [5, 1, 3, 2, 4, 0, 6],start = 2) == True\n assert candidate(arr = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0],start = 1) == True\n assert candidate(arr = [3, 0, 2, 5, 0, 1, 2, 0, 0, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],start = 1) == True\n assert candidate(arr = [2, 1, 0, 0, 2, 1, 0, 1, 0, 1, 0, 1, 0],start = 2) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 0, 11, 13, 15, 17],start = 4) == False\n assert candidate(arr = [2, 3, 1, 1, 2, 4, 2, 0, 1, 3, 1, 2, 3, 4, 0],start = 6) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0],start = 14) == True\n assert candidate(arr = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0],start = 10) == True\n assert candidate(arr = [2, 3, 1, 1, 4, 2, 3, 1, 1, 4],start = 5) == False\n assert candidate(arr = [2, 4, 3, 2, 0, 1, 2, 3, 4, 0],start = 0) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],start = 21) == True\n assert candidate(arr = [0, 3, 0, 5, 0, 0, 3, 1, 0, 2],start = 5) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 0, 1, 2, 3, 4],start = 8) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],start = 4) == True\n assert candidate(arr = [3, 2, 1, 4, 5, 6, 0, 1, 2, 3],start = 8) == True\n assert candidate(arr = [0, 3, 2, 1, 5, 4, 3, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 0],start = 10) == True\n assert candidate(arr = [1, 0, 3, 4, 0, 5, 2, 0, 0, 3, 2],start = 4) == True\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],start = 10) == True\n"}, "metadata": {"canonical_parameter_names": ["arr", "start"], "leetcode_dataset_entry_point": "Solution().canReach", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool canReach(vector& arr, int start) {", "container": "Solution", "callable": "canReach", "parameters": [{"name": "arr", "type": "vector&"}, {"name": "start", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1307, "task_id": "verbal-arithmetic-puzzle", "difficulty": "Hard", "problem_description": "Given an equation, represented by words on the left side and the result on the right side.\nYou need to check if the equation is solvable under the following rules:\n\nEach character is decoded as one digit (0 - 9).\nNo two characters can map to the same digit.\nEach words[i] and result are decoded as one number without leading zeros.\nSum of numbers on the left side (words) will equal to the number on the right side (result).\n\nReturn true if the equation is solvable, otherwise return false.\n \nExample 1:\n\nInput: words = [\"SEND\",\"MORE\"], result = \"MONEY\"\nOutput: true\nExplanation: Map 'S'-> 9, 'E'->5, 'N'->6, 'D'->7, 'M'->1, 'O'->0, 'R'->8, 'Y'->'2'\nSuch that: \"SEND\" + \"MORE\" = \"MONEY\" , 9567 + 1085 = 10652\nExample 2:\n\nInput: words = [\"SIX\",\"SEVEN\",\"SEVEN\"], result = \"TWENTY\"\nOutput: true\nExplanation: Map 'S'-> 6, 'I'->5, 'X'->0, 'E'->8, 'V'->7, 'N'->2, 'T'->1, 'W'->'3', 'Y'->4\nSuch that: \"SIX\" + \"SEVEN\" + \"SEVEN\" = \"TWENTY\" , 650 + 68782 + 68782 = 138214\nExample 3:\n\nInput: words = [\"LEET\",\"CODE\"], result = \"POINT\"\nOutput: false\nExplanation: There is no possible mapping to satisfy the equation, so we return false.\nNote that two different characters cannot map to the same digit.\n\n \nConstraints:\n\n2 <= words.length <= 5\n1 <= words[i].length, result.length <= 7\nwords[i], result contain only uppercase English letters.\nThe number of different characters used in the expression is at most 10.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['SEND', 'MORE'],result = \"MONEY\") == True\n assert candidate(words = ['A', 'A', 'A', 'A'],result = \"AA\") == False\n assert candidate(words = ['LEET', 'CODE'],result = \"POINT\") == False\n assert candidate(words = ['HELLO', 'WORLD'],result = \"HIALL\") == False\n assert candidate(words = ['AA', 'BB'],result = \"CC\") == True\n assert candidate(words = ['SIX', 'SEVEN', 'SEVEN'],result = \"TWENTY\") == True\n assert candidate(words = ['CAT', 'DOG'],result = \"BIRD\") == True\n assert candidate(words = ['ABA', 'B'],result = \"ABC\") == True\n assert candidate(words = ['A', 'B'],result = \"C\") == True\n assert candidate(words = ['ABC', 'BCD'],result = \"DEE\") == False\n assert candidate(words = ['HELLO', 'WORLD'],result = \"PEACE\") == True\n assert candidate(words = ['LONG', 'WORDS', 'HERE'],result = \"ADDITION\") == False\n assert candidate(words = ['CASTLE', 'KNIGHT'],result = \"BATTLE\") == False\n assert candidate(words = ['MAX', 'MIN'],result = \"SUM\") == True\n assert candidate(words = ['ALGEBRA', 'GEOMETRY'],result = \"MATHEMATICS\") == False\n assert candidate(words = ['BAT', 'BALL', 'BASE'],result = \"TABLE\") == False\n assert candidate(words = ['EULER', 'GAUSS'],result = \"ARITHMETIC\") == False\n assert candidate(words = ['COMPUTER', 'SCIENCE'],result = \"DISCOVERY\") == False\n assert candidate(words = ['FAST', 'CAR'],result = \"RACING\") == False\n assert candidate(words = ['HEAL', 'HURT'],result = \"BALANCE\") == False\n assert candidate(words = ['MATH', 'ENGLISH', 'SCIENCE'],result = \"CURRICULUM\") == False\n assert candidate(words = ['HELLO', 'WORLD'],result = \"PYTHON\") == False\n assert candidate(words = ['SAINT', 'SEER'],result = \"VISION\") == False\n assert candidate(words = ['SUN', 'MOON', 'STAR'],result = \"GALAXY\") == False\n assert candidate(words = ['SNOW', 'ICE'],result = \"COLD\") == True\n assert candidate(words = ['HELLO', 'WORLD'],result = \"HAPPY\") == False\n assert candidate(words = ['A', 'BB', 'CCC', 'DDDD'],result = \"E\") == False\n assert candidate(words = ['HELLO', 'WORLD'],result = \"DISPATCH\") == False\n assert candidate(words = ['KNIGHT', 'KNIGHT'],result = \"WARLORD\") == False\n assert candidate(words = ['ZERO', 'ONE', 'TWO', 'THREE'],result = \"SIX\") == False\n assert candidate(words = ['FIVE', 'NINE', 'ELEVEN'],result = \"TWENTYFIVE\") == False\n assert candidate(words = ['TRUE', 'FALSE'],result = \"PARADOX\") == False\n assert candidate(words = ['STAR', 'SHIP'],result = \"GALAXY\") == False\n assert candidate(words = ['TEN', 'TEN', 'TEN'],result = \"THIRTY\") == False\n assert candidate(words = ['HOUSE', 'DOG'],result = \"FAMILY\") == False\n assert candidate(words = ['MATH', 'ROCKS'],result = \"LEARNING\") == False\n assert candidate(words = ['SIX', 'EIGHT', 'TEN'],result = \"TWENTYFOUR\") == False\n assert candidate(words = ['APPLE', 'BANANA'],result = \"GRAPE\") == False\n assert candidate(words = ['ONE', 'TWO', 'THREE', 'FOUR', 'FIVE'],result = \"SUMUP\") == False\n assert candidate(words = ['FOUR', 'FIVE', 'SIX'],result = \"FIFTEEN\") == False\n assert candidate(words = ['UP', 'DOWN'],result = \"ZERO\") == True\n assert candidate(words = ['SUN', 'MOON'],result = \"STAR\") == True\n assert candidate(words = ['BIG', 'DOG'],result = \"ANIMAL\") == False\n assert candidate(words = ['HELLO', 'WORLD'],result = \"PLANETS\") == False\n assert candidate(words = ['MOON', 'EARTH'],result = \"UNIVERSE\") == False\n assert candidate(words = ['APPLE', 'BANANA', 'CHERRY'],result = \"FRUITBOWL\") == False\n assert candidate(words = ['HAPPY', 'BIRTHDAY'],result = \"CELEBRATE\") == False\n assert candidate(words = ['ABACAXI', 'MANGO', 'KIWI'],result = \"FRUITS\") == False\n assert candidate(words = ['CAT', 'DOG', 'MOUSE'],result = \"PIG\") == False\n assert candidate(words = ['UNIVERSAL', 'GALAXY', 'EARTH'],result = \"COSMOS\") == False\n assert candidate(words = ['BIRD', 'FLY', 'HIGH'],result = \"FLIGHT\") == False\n assert candidate(words = ['ALICE', 'BOB'],result = \"GAME\") == False\n assert candidate(words = ['RIGHT', 'WRONG'],result = \"FALSE\") == False\n assert candidate(words = ['CAT', 'DOG', 'MOUSE'],result = \"CLAW\") == False\n assert candidate(words = ['ALICE', 'BOB', 'CHARLIE'],result = \"FRIENDSHIP\") == False\n assert candidate(words = ['PHOENIX', 'DRAGON'],result = \"MYTHICAL\") == False\n assert candidate(words = ['PYTHON', 'ROCKS'],result = \"PROGRAM\") == False\n assert candidate(words = ['FLY', 'FLY', 'HIGH'],result = \"SKYLINE\") == False\n assert candidate(words = ['SEND', 'MORE', 'MONEY'],result = \"TWICE\") == False\n assert candidate(words = ['UNO', 'DOS', 'TRES'],result = \"SEIS\") == True\n assert candidate(words = ['WIZARD', 'WAND'],result = \"MAGIC\") == False\n assert candidate(words = ['LUCK', 'IN', 'THE', 'DRAW'],result = \"SUCCESS\") == False\n assert candidate(words = ['STAR', 'NIGHT'],result = \"TWILIGHT\") == False\n assert candidate(words = ['SUN', 'MOON', 'STARS'],result = \"SKYLINE\") == False\n assert candidate(words = ['BLACK', 'WHITE', 'GRAY'],result = \"COLORS\") == False\n assert candidate(words = ['JAVA', 'PYTHON', 'CPLUSPLUS'],result = \"PROGRAMMING\") == False\n assert candidate(words = ['AARDVARK', 'ANTELOPE'],result = \"MAMMALS\") == False\n assert candidate(words = ['NINE', 'NINE'],result = \"EIGHTEEN\") == False\n assert candidate(words = ['ALICE', 'BOB', 'CHARLIE'],result = \"FICTION\") == False\n assert candidate(words = ['ZERO', 'ONE', 'TWO', 'THREE'],result = \"SUM\") == False\n assert candidate(words = ['MAGIC', 'WAND'],result = \"WIZARD\") == False\n assert candidate(words = ['JAVA', 'PYTHON'],result = \"SCRIPT\") == False\n assert candidate(words = ['KNIGHT', 'BISHOP'],result = \"CHECKMATE\") == False\n assert candidate(words = ['COMPUTER', 'SCIENCE', 'PROGRAMMING'],result = \"DEVELOPMENT\") == False\n assert candidate(words = ['EARTH', 'MOON'],result = \"UNIVERSE\") == False\n assert candidate(words = ['SIXTY', 'SIXTY'],result = \"ONETWENTY\") == False\n assert candidate(words = ['SNOW', 'FALL'],result = \"SNOWBALL\") == False\n assert candidate(words = ['FALCON', 'HAWK'],result = \"BIRD\") == False\n assert candidate(words = ['APPLE', 'BANANA'],result = \"GRAPES\") == False\n assert candidate(words = ['ZEBRA', 'ELEPHANT'],result = \"WILDLIFE\") == False\n assert candidate(words = ['ZERO', 'ONE'],result = \"SUM\") == False\n assert candidate(words = ['EARTH', 'WATER'],result = \"PLANET\") == False\n assert candidate(words = ['APPLE', 'BANANA', 'CHERRY'],result = \"FRUIT\") == False\n assert candidate(words = ['ONE', 'TWO', 'THREE', 'FOUR'],result = \"TEN\") == False\n assert candidate(words = ['ONE', 'TWO', 'THREE', 'FOUR'],result = \"SUM\") == False\n assert candidate(words = ['MATH', 'IS', 'FUN'],result = \"JOKES\") == False\n assert candidate(words = ['DOG', 'CAT'],result = \"ANIMAL\") == False\n assert candidate(words = ['GREEN', 'BLUE', 'YELLOW'],result = \"COLORS\") == False\n assert candidate(words = ['ZERO', 'ONE', 'TWO', 'THREE'],result = \"FIVE\") == False\n assert candidate(words = ['MAT', 'ADD', 'SUB'],result = \"SUM\") == False\n assert candidate(words = ['KANGAROO', 'KANGAROO', 'KANGAROO'],result = \"JUMPOUTS\") == False\n assert candidate(words = ['OCEAN', 'SEA', 'LAKE'],result = \"WATERBODY\") == False\n assert candidate(words = ['WITCH', 'WAND'],result = \"MAGIC\") == True\n assert candidate(words = ['HAPPY', 'JOY'],result = \"BLISS\") == True\n assert candidate(words = ['STAR', 'PLANET', 'GALAXY'],result = \"COSMOS\") == False\n assert candidate(words = ['FAST', 'SLOW'],result = \"BALANCE\") == False\n assert candidate(words = ['LEFT', 'RIGHT'],result = \"EQUAL\") == False\n assert candidate(words = ['COOL', 'DRINK'],result = \"REFRESH\") == False\n assert candidate(words = ['MAGICAL', 'REALM'],result = \"MYSTERY\") == False\n assert candidate(words = ['LEARN', 'PYTHON'],result = \"CODEING\") == False\n assert candidate(words = ['CAR', 'BIKE'],result = \"VEHICLE\") == False\n assert candidate(words = ['HEART', 'SOUL'],result = \"LOVE\") == False\n assert candidate(words = ['MATH', 'IS', 'FUN'],result = \"GAMES\") == False\n assert candidate(words = ['PARIS', 'BERLIN'],result = \"ROME\") == False\n assert candidate(words = ['ABCDEFGHIJK', 'LMNOPQRS'],result = \"TUVWXYZ\") == False\n assert candidate(words = ['SUN', 'MOON'],result = \"AURA\") == True\n assert candidate(words = ['MATH', 'SCI', 'ENG'],result = \"STUDY\") == False\n assert candidate(words = ['UNICORN', 'PEGASUS'],result = \"MYTHOLOGY\") == False\n assert candidate(words = ['SUN', 'MOON', 'STAR'],result = \"SKY\") == False\n assert candidate(words = ['ALPHA', 'BETA', 'GAMMA'],result = \"DELTA\") == True\n assert candidate(words = ['PYTHON', 'JAVA'],result = \"SCRIPT\") == False\n assert candidate(words = ['CLOCK', 'BELL'],result = \"TICKTOCK\") == False\n assert candidate(words = ['DAY', 'NIGHT'],result = \"TIMELESS\") == False\n assert candidate(words = ['TEN', 'TWO'],result = \"TWELVE\") == False\n assert candidate(words = ['FAST', 'RUN', 'JUMP'],result = \"ATHLETE\") == False\n assert candidate(words = ['APPLE', 'BANANA'],result = \"CHERRY\") == True\n assert candidate(words = ['ALCHEMY', 'ENCHANT'],result = \"MAGICAL\") == False\n assert candidate(words = ['HELLO', 'WORLD'],result = \"PEACEFUL\") == False\n assert candidate(words = ['PYTHON', 'JAVA', 'CPLUS'],result = \"PROGRAMMING\") == False\n assert candidate(words = ['PYTHON', 'JAVA'],result = \"SCRIPT\") == False\n assert candidate(words = ['SUN', 'MOON', 'STAR'],result = \"UNIVERSAL\") == False\n assert candidate(words = ['MOUNTAIN', 'CLIMBER'],result = \"ADVENTURE\") == False\n assert candidate(words = ['PYTHON', 'JAVA', 'CPLUSPLUS'],result = \"PROGRAMMING\") == False\n assert candidate(words = ['HELLO', 'WORLD'],result = \"HALLO\") == False\n assert candidate(words = ['ONE', 'TWO', 'THREE'],result = \"SIX\") == False\n assert candidate(words = ['ABCDE', 'FGHIJ'],result = \"KLMNO\") == False\n assert candidate(words = ['SKY', 'TREE'],result = \"FOREST\") == False\n assert candidate(words = ['PI', 'E'],result = \"CIRCLE\") == False\n assert candidate(words = ['FOUR', 'FIVE', 'SIX'],result = \"FIFTEEN\") == False\n assert candidate(words = ['RED', 'BLUE'],result = \"COLOR\") == False\n assert candidate(words = ['JUMP', 'HIGH', 'LONG'],result = \"JUMPROPE\") == False\n assert candidate(words = ['SUN', 'MOON', 'STAR'],result = \"PLANET\") == False\n assert candidate(words = ['HIGH', 'LOW'],result = \"AMPLITUDE\") == False\n assert candidate(words = ['ALPACA', 'ANIMAL', 'ZOO'],result = \"WILDLIFE\") == False\n assert candidate(words = ['HAPPY', 'JOY'],result = \"HARMONY\") == False\n assert candidate(words = ['SPY', 'SPY'],result = \"QUIZ\") == True\n assert candidate(words = ['APPLE', 'BANANA'],result = \"FRUIT\") == False\n assert candidate(words = ['HAPPY', 'SAD'],result = \"JOY\") == False\n assert candidate(words = ['CRYPT', 'GRAPH', 'DRY'],result = \"DRYRUN\") == False\n assert candidate(words = ['GENIE', 'BOTTLE'],result = \"WISHES\") == False\n assert candidate(words = ['RED', 'BLUE'],result = \"GREEN\") == False\n assert candidate(words = ['HELLO', 'WORLD'],result = \"HELLOWORLD\") == False\n assert candidate(words = ['BIRD', 'FLY'],result = \"SKY\") == False\n assert candidate(words = ['MYTH', 'HERO'],result = \"LEGEND\") == False\n assert candidate(words = ['Babbage', 'Difference', 'Engine'],result = \"Calculator\") == False\n assert candidate(words = ['ZERO', 'ONE', 'TWO', 'THREE'],result = \"SUM\") == False\n assert candidate(words = ['PYTHON', 'JAVA', 'CPP'],result = \"PROGRAM\") == False\n assert candidate(words = ['TREE', 'FOREST'],result = \"GREEN\") == False\n"}, "metadata": {"canonical_parameter_names": ["words", "result"], "leetcode_dataset_entry_point": "Solution().isSolvable", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool isSolvable(vector& words, string result) {", "container": "Solution", "callable": "isSolvable", "parameters": [{"name": "words", "type": "vector&"}, {"name": "result", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1309, "task_id": "decrypt-string-from-alphabet-to-integer-mapping", "difficulty": "Easy", "problem_description": "You are given a string s formed by digits and '#'. We want to map s to English lowercase characters as follows:\n\nCharacters ('a' to 'i') are represented by ('1' to '9') respectively.\nCharacters ('j' to 'z') are represented by ('10#' to '26#') respectively.\n\nReturn the string formed after mapping.\nThe test cases are generated so that a unique mapping will always exist.\n \nExample 1:\n\nInput: s = \"10#11#12\"\nOutput: \"jkab\"\nExplanation: \"j\" -> \"10#\" , \"k\" -> \"11#\" , \"a\" -> \"1\" , \"b\" -> \"2\".\n\nExample 2:\n\nInput: s = \"1326#\"\nOutput: \"acz\"\n\n \nConstraints:\n\n1 <= s.length <= 1000\ns consists of digits and the '#' letter.\ns will be a valid string such that mapping is always possible.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"11#11#11#11#11#11#11#11#11#11#\") == \"kkkkkkkkkk\"\n assert candidate(s = \"12345678910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"26#25#24#23#22#21#\") == \"zyxwvu\"\n assert candidate(s = \"1326#\") == \"acz\"\n assert candidate(s = \"25#24#23#22#21#20#19#18#17#16#15#14#13#\") == \"yxwvutsrqponm\"\n assert candidate(s = \"11#12#13#14#15#16#17#18#19#\") == \"klmnopqrs\"\n assert candidate(s = \"10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#\") == \"jklmnopqrstuvwxyz\"\n assert candidate(s = \"12345678910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26\") == \"abcdefghijklmnopqrstuvwxybf\"\n assert candidate(s = \"10#11#12\") == \"jkab\"\n assert candidate(s = \"10#20#30#40#50#60#70#80#90#\") == \"jt~ˆ’œ¦°º\"\n assert candidate(s = \"10#11#12#13#14#15#\") == \"jklmno\"\n assert candidate(s = \"10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#987654321#\") == \"jklmnopqrstuvwxyzihgfedcu\"\n assert candidate(s = \"20#21#22#23#24#25#26#\") == \"tuvwxyz\"\n assert candidate(s = \"10#10#10#10#10#10#10#10#10#10#\") == \"jjjjjjjjjj\"\n assert candidate(s = \"26#25#24#23#22#21#20#19#18#17#16#15#14#13#12#11#10#\") == \"zyxwvutsrqponmlkj\"\n assert candidate(s = \"25#26#\") == \"yz\"\n assert candidate(s = \"123456789\") == \"abcdefghi\"\n assert candidate(s = \"11#22#33#44#55#66#77#88#99#\") == \"kvŒ—¢­¸Ã\"\n assert candidate(s = \"25#26#10#10#10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#\") == \"yzjjjklmnopqrstuvwxyz\"\n assert candidate(s = \"52525252525252525252525252525252525252525252525252525252525252525252525252525#\") == \"ebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebey\"\n assert candidate(s = \"26#25#24#23#22#21#20#19#18#17#16#15#14#13#12#11#10#987654321\") == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"10#20#30#40#50#60#70#80#90#11#21#31#41#51#61#71#81#91#26#\") == \"jt~ˆ’œ¦°ºku‰“§±»z\"\n assert candidate(s = \"12345678910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#98765432112345678910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#987654321\") == \"abcdefghijklmnopqrstuvwxyzihgfedcbaabcdefghijklmnopqrstuvwxyzihgfedcba\"\n assert candidate(s = \"12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#987654321\") == \"lmnopqrstuvwxyzihgfedcba\"\n assert candidate(s = \"910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26\") == \"ijklmnopqrstuvwxybf\"\n assert candidate(s = \"12345678910#20#30#40#50#60#70#80#90#11#21#31#41#51#61#71#81#91#26#\") == \"abcdefghijt~ˆ’œ¦°ºku‰“§±»z\"\n assert candidate(s = \"910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#987654321\") == \"ijklmnopqrstuvwxyzihgfedcba\"\n assert candidate(s = \"26#10#26#10#26#10#26#10#26#10#26#10#26#10#26#10#\") == \"zjzjzjzjzjzjzjzj\"\n assert candidate(s = \"10#20#30#11#21#31#12#22#32#13#23#33#14#24#34#15#25#35#16#26#36#\") == \"jt~kulv€mwnx‚oyƒpz„\"\n assert candidate(s = \"91#82#73#64#55#46#37#28#19#10#11#12#13#14#15#16#17#18#\") == \"»²© —Ž\u0085|sjklmnopqr\"\n assert candidate(s = \"12#14#16#18#20#22#24#26#11#13#15#17#19#21#23#25#\") == \"lnprtvxzkmoqsuwy\"\n assert candidate(s = \"11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#11#\") == \"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk\"\n assert candidate(s = \"25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#25#26#\") == \"yzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyzyz\"\n assert candidate(s = \"11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#987654321\") == \"klmnopqrstuvwxyzihgfedcba\"\n assert candidate(s = \"99999999999999999999999999999999999999999999999999999999999999999999999999999#10#\") == \"iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiÃj\"\n assert candidate(s = \"10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#\") == \"jklmnopqrstuvwxyzjklmnopqrstuvwxyz\"\n assert candidate(s = \"10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#\") == \"jjjjjjjjjjjjjjjjjjjjjjjj\"\n assert candidate(s = \"910#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#\") == \"ijklmnopqrstuvwxyz\"\n assert candidate(s = \"10#20#30#11#21#31#12#22#32#13#23#14#24#15#25#16#26\") == \"jt~kulv€mwnxoypbf\"\n assert candidate(s = \"10#20#30#40#50#60#70#80#90#10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#\") == \"jt~ˆ’œ¦°ºjklmnopqrstuvwxyz\"\n assert candidate(s = \"10#10#10#11#11#11#12#12#12#13#13#13#14#14#14#15#15#15#16#16#16#17#17#17#18#18#18#19#19#19#20#20#20#21#21#21#22#22#22#23#23#23#24#24#24#25#25#25#26#26#26#\") == \"jjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz\"\n assert candidate(s = \"10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#\") == \"jjjjjjjjjjjjjjjjjjjjjjj\"\n assert candidate(s = \"10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#10#\") == \"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().freqAlphabets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string freqAlphabets(string s) {", "container": "Solution", "callable": "freqAlphabets", "parameters": [{"name": "s", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1310, "task_id": "xor-queries-of-a-subarray", "difficulty": "Medium", "problem_description": "You are given an array arr of positive integers. You are also given the array queries where queries[i] = [lefti, righti].\nFor each query i compute the XOR of elements from lefti to righti (that is, arr[lefti] XOR arr[lefti + 1] XOR ... XOR arr[righti] ).\nReturn an array answer where answer[i] is the answer to the ith query.\n \nExample 1:\n\nInput: arr = [1,3,4,8], queries = [[0,1],[1,2],[0,3],[3,3]]\nOutput: [2,7,14,8] \nExplanation: \nThe binary representation of the elements in the array are:\n1 = 0001 \n3 = 0011 \n4 = 0100 \n8 = 1000 \nThe XOR values for queries are:\n[0,1] = 1 xor 3 = 2 \n[1,2] = 3 xor 4 = 7 \n[0,3] = 1 xor 3 xor 4 xor 8 = 14 \n[3,3] = 8\n\nExample 2:\n\nInput: arr = [4,8,2,10], queries = [[2,3],[1,3],[0,0],[0,3]]\nOutput: [8,0,4,4]\n\n \nConstraints:\n\n1 <= arr.length, queries.length <= 3 * 104\n1 <= arr[i] <= 109\nqueries[i].length == 2\n0 <= lefti <= righti < arr.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [4, 8, 2, 10],queries = [[2, 3], [1, 3], [0, 0], [0, 3]]) == [8, 0, 4, 4]\n assert candidate(arr = [10, 5, 2, 3, 15],queries = [[0, 4], [1, 2], [2, 3], [0, 1], [3, 4]]) == [1, 7, 1, 15, 12]\n assert candidate(arr = [5, 2, 3, 9],queries = [[0, 0], [1, 3], [0, 2], [2, 3]]) == [5, 8, 4, 10]\n assert candidate(arr = [7, 11, 15, 22, 29],queries = [[0, 2], [1, 3], [0, 4], [4, 4]]) == [3, 18, 8, 29]\n assert candidate(arr = [5, 1, 4, 2],queries = [[0, 2], [1, 3], [0, 1], [2, 2]]) == [0, 7, 4, 4]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [11, 0, 11, 0, 3]\n assert candidate(arr = [15, 10, 5, 3],queries = [[0, 3], [1, 1], [0, 0], [2, 3]]) == [3, 10, 15, 6]\n assert candidate(arr = [5, 2, 4, 6, 1],queries = [[0, 2], [1, 4], [0, 4], [3, 3]]) == [3, 1, 4, 6]\n assert candidate(arr = [7, 11, 13, 8],queries = [[0, 2], [1, 3], [2, 3], [0, 1]]) == [1, 14, 5, 12]\n assert candidate(arr = [5, 1, 4, 2],queries = [[0, 0], [1, 1], [0, 1], [0, 3]]) == [5, 1, 4, 2]\n assert candidate(arr = [15, 14, 13, 12, 11],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == [15, 14, 13, 12, 11]\n assert candidate(arr = [1, 1, 1, 1],queries = [[0, 1], [1, 2], [0, 3], [3, 3]]) == [0, 0, 0, 1]\n assert candidate(arr = [5, 1, 4, 2],queries = [[0, 1], [2, 3], [0, 2], [1, 2]]) == [4, 6, 0, 5]\n assert candidate(arr = [1, 3, 4, 8],queries = [[0, 1], [1, 2], [0, 3], [3, 3]]) == [2, 7, 14, 8]\n assert candidate(arr = [3, 6, 9, 12, 15],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == [3, 6, 9, 12, 15]\n assert candidate(arr = [7, 11, 15],queries = [[0, 2], [0, 0], [1, 1], [2, 2]]) == [3, 7, 11, 15]\n assert candidate(arr = [2, 6, 1, 8, 3, 9, 4],queries = [[0, 6], [2, 5], [1, 3], [4, 6], [0, 2]]) == [3, 3, 15, 14, 5]\n assert candidate(arr = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 4]]) == [503538687, 587645496, 362994761, 847757604, 111254601, 996193791, 161737801, 518034651, 195148873, 1025255708]\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],queries = [[0, 10], [1, 8], [2, 9], [0, 3], [6, 8], [5, 7], [0, 1], [9, 10]]) == [2047, 510, 1020, 15, 448, 224, 3, 1536]\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],queries = [[0, 10], [1, 5], [3, 7], [0, 6], [6, 10], [2, 9]]) == [2047, 992, 248, 2032, 31, 510]\n assert candidate(arr = [8, 13, 21, 34, 55, 89, 144, 233],queries = [[0, 7], [1, 5], [3, 6], [4, 7], [0, 6]]) == [37, 84, 220, 23, 204]\n assert candidate(arr = [255, 128, 64, 32, 16, 8, 4, 2, 1],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [0, 7], [1, 6], [2, 5], [3, 4], [0, 6], [1, 5], [2, 4], [0, 5], [1, 4], [0, 4], [1, 3], [0, 3], [1, 2], [0, 2], [1, 1], [0, 1], [0, 0]]) == [0, 254, 124, 56, 16, 1, 252, 120, 48, 3, 248, 112, 7, 240, 15, 224, 31, 192, 63, 128, 127, 255]\n assert candidate(arr = [3, 6, 8, 12, 15, 9, 7, 11],queries = [[0, 7], [2, 5], [1, 6], [4, 6], [0, 3], [3, 7]]) == [11, 2, 3, 1, 1, 6]\n assert candidate(arr = [987654321, 876543219, 765432198, 654321987, 543219876, 432198765, 321987654, 219876543, 198765432, 98765432, 87654321],queries = [[0, 9], [1, 5], [3, 7], [0, 6], [6, 9], [2, 8]]) == [768397751, 117666047, 8926579, 787233800, 269601273, 651120525]\n assert candidate(arr = [29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10],queries = [[0, 19], [1, 18], [3, 17], [4, 16], [6, 15]]) == [0, 23, 27, 13, 1]\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576],queries = [[0, 20], [2, 7], [5, 9], [0, 10], [10, 20], [4, 15]]) == [2097151, 252, 992, 2047, 2096128, 65520]\n assert candidate(arr = [123456789, 987654321, 135792468, 246813579, 975318642, 864213579, 753186429, 642135798, 531864297, 421357986],queries = [[0, 9], [1, 4], [3, 6], [0, 5], [5, 9], [2, 8]]) == [1049048706, 106058268, 737300943, 847988034, 1066314123, 438303364]\n assert candidate(arr = [123, 456, 789, 101, 202, 303, 404, 505, 606, 707, 808, 909, 1010],queries = [[0, 12], [1, 8], [2, 9], [3, 10], [4, 11], [5, 12], [0, 4], [6, 8], [0, 7], [8, 10], [0, 1], [11, 12]]) == [129, 366, 613, 600, 432, 648, 521, 563, 843, 949, 435, 127]\n assert candidate(arr = [13, 7, 18, 5, 12, 6, 9, 4, 8, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 8], [1, 7]]) == [24, 31, 16, 6, 10, 18, 23]\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [682, 340, 168, 80, 32, 683, 343, 175, 95, 63, 31, 15, 7, 3, 1]\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1023, 510, 252, 120, 48]\n assert candidate(arr = [123, 456, 789, 101, 202, 303, 404, 505, 606, 707],queries = [[0, 9], [2, 7], [1, 8], [4, 5], [0, 3]]) == [982, 760, 366, 485, 707]\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10], [0, 9], [10, 19], [0, 4], [5, 9], [10, 14], [15, 19]]) == [0, 9, 0, 5, 0, 1, 0, 5, 0, 9, 1, 1, 5, 4, 5, 4]\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7], [0, 1], [1, 2], [2, 3], [3, 4]]) == [26, 55, 31, 51, 17, 5, 21, 19, 1, 6, 2, 12]\n assert candidate(arr = [987654321, 987654322, 987654323, 987654324, 987654325, 987654326, 987654327, 987654328, 987654329, 987654330],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [11, 0, 11, 0, 3]\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 3], [5, 9], [1, 2], [6, 7], [8, 9]]) == [682, 340, 168, 80, 32, 640, 21, 256, 8, 2]\n assert candidate(arr = [9, 3, 5, 7, 11, 13, 17, 19, 23, 29],queries = [[0, 9], [1, 4], [3, 6], [0, 5], [5, 9], [2, 8]]) == [6, 10, 16, 14, 5, 17]\n assert candidate(arr = [13, 29, 17, 23, 19, 31, 2, 5, 7, 11, 13, 17, 19, 23, 29],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [0, 6], [7, 14]]) == [20, 4, 14, 12, 10, 20, 0, 24, 12]\n assert candidate(arr = [21, 33, 47, 59, 71, 83, 97, 101, 103, 107, 109, 113, 127],queries = [[0, 12], [2, 7], [5, 9], [0, 8], [9, 12], [4, 11]]) == [95, 4, 91, 87, 8, 0]\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],queries = [[0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [0, 0], [10, 10], [0, 5], [5, 10]]) == [2047, 1022, 508, 248, 112, 32, 1024, 1, 2016, 63]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [20, 1, 16, 1, 20, 1, 8, 1, 4, 1]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7]]) == [0, 14, 2, 12, 4, 10, 6, 8]\n assert candidate(arr = [2, 6, 3, 9, 11, 12, 5],queries = [[0, 6], [1, 4], [2, 3], [4, 5], [0, 5]]) == [12, 7, 10, 7, 9]\n assert candidate(arr = [6, 2, 8, 4, 10, 12, 14, 16, 18, 20],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [22, 4, 20, 12, 6]\n assert candidate(arr = [13, 19, 31, 14, 20, 27, 25, 22, 23, 29, 30, 18, 21, 16, 26, 15, 24, 17, 28, 11, 3, 10, 5, 6, 7, 8, 9, 4, 12, 1],queries = [[0, 29], [5, 24], [10, 22], [15, 28], [20, 26], [25, 27], [0, 28], [1, 27], [2, 26], [3, 25], [4, 24], [5, 23], [6, 22], [7, 21], [8, 20], [9, 19], [10, 18], [11, 17], [12, 16], [13, 15], [0, 27], [1, 26], [2, 25], [3, 24], [4, 23], [5, 22], [6, 21], [7, 20], [8, 19], [9, 18], [10, 17], [11, 16], [12, 15], [0, 26], [1, 25], [2, 24], [3, 23], [4, 22], [5, 21], [6, 20], [7, 19], [8, 18], [9, 17], [10, 16], [11, 15], [12, 14], [0, 25], [1, 24], [2, 23], [3, 22], [4, 21], [5, 20], [6, 19], [7, 18], [8, 17], [9, 16], [10, 15], [11, 14], [12, 13], [0, 24], [1, 23], [2, 22], [3, 21], [4, 20], [5, 19], [6, 18], [7, 17], [8, 16], [9, 15], [10, 14], [11, 13], [12, 12]]) == [2, 17, 14, 21, 12, 5, 3, 2, 21, 3, 5, 22, 11, 23, 11, 31, 9, 11, 8, 5, 15, 6, 28, 11, 2, 16, 14, 29, 8, 20, 21, 26, 16, 11, 15, 20, 12, 4, 21, 4, 30, 3, 8, 4, 2, 31, 2, 7, 19, 10, 1, 31, 7, 21, 31, 25, 28, 13, 5, 10, 0, 21, 15, 11, 28, 12, 9, 14, 1, 19, 23, 21]\n assert candidate(arr = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 5], [5, 9]]) == [524095, 241270, 30061, 201228, 30433, 130751, 292406]\n assert candidate(arr = [2, 6, 12, 8, 3, 10],queries = [[0, 5], [1, 3], [2, 4], [0, 2], [4, 5]]) == [9, 2, 7, 8, 9]\n assert candidate(arr = [3, 8, 15, 2, 7, 9, 6, 11, 5, 10],queries = [[0, 9], [2, 5], [4, 7], [0, 4], [6, 9], [1, 8]]) == [10, 3, 3, 1, 2, 3]\n assert candidate(arr = [2, 6, 8, 10, 12, 14, 16, 18],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 3], [4, 7]]) == [6, 22, 0, 6, 6, 0]\n assert candidate(arr = [123456789, 987654321, 135792468, 246813579, 1112131415, 1514131211, 1010101010, 2020202020, 3030303030, 4040404040],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [5, 9], [0, 0], [9, 9], [1, 7], [2, 6], [3, 5], [0, 3], [4, 8], [1, 6], [2, 5], [3, 4]]) == [592308591, 3569715250, 1518674357, 720695493, 410388572, 2036495916, 1513070403, 123456789, 4040404040, 1616595204, 585955217, 381688791, 992719227, 3904238684, 405970720, 517479555, 1291834588]\n assert candidate(arr = [5, 12, 25, 50, 100, 200, 400, 800, 1600, 3200],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 9], [0, 4], [6, 8]]) == [2302, 1147, 567, 270, 172, 2232, 70, 1264]\n assert candidate(arr = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990, 999999989, 999999988, 999999987, 999999986, 999999985, 999999984, 999999983, 999999982, 999999981],queries = [[0, 19], [2, 7], [5, 9], [0, 6], [6, 19], [2, 15]]) == [1004, 7, 999999991, 1000000001, 23, 15]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7], [0, 0], [14, 14]]) == [0, 14, 2, 12, 4, 10, 6, 8, 1, 15]\n assert candidate(arr = [6, 9, 4, 7, 3, 8, 10, 12],queries = [[0, 7], [2, 5], [1, 4], [3, 6], [0, 3], [4, 7]]) == [1, 8, 9, 6, 12, 13]\n assert candidate(arr = [123, 456, 789, 101112, 131415, 161718, 192021, 222324],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 3], [4, 7]]) == [29918, 200913, 130828, 232367, 100446, 130176]\n assert candidate(arr = [31, 15, 7, 3, 1],queries = [[0, 4], [1, 3], [2, 2], [3, 3], [0, 3], [1, 2]]) == [21, 11, 7, 3, 20, 8]\n assert candidate(arr = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10], [0, 18], [1, 17], [2, 16], [3, 15], [4, 14], [5, 13], [6, 12], [7, 11], [8, 10], [0, 17], [1, 16], [2, 15], [3, 14], [4, 13], [5, 12], [6, 11], [7, 10], [8, 9], [0, 16], [1, 15], [2, 14], [3, 13], [4, 12], [5, 11], [6, 10], [7, 9], [0, 15], [1, 14], [2, 13], [3, 12], [4, 11], [5, 10], [6, 9], [7, 8], [0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [0, 13], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7], [0, 12], [1, 11], [2, 10], [3, 9], [4, 8], [5, 7], [0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 8], [1, 7], [2, 6], [3, 5], [0, 7], [1, 6], [2, 5], [0, 6], [1, 5], [2, 4], [0, 5], [1, 4], [0, 4], [1, 3], [0, 3], [1, 2], [0, 2], [1, 1], [0, 1], [0, 0]]) == [8388600, 4194288, 2097120, 1048512, 524160, 261888, 130560, 64512, 30720, 12288, 4194296, 2097136, 1048544, 524224, 262016, 130816, 65024, 31744, 14336, 2097144, 1048560, 524256, 262080, 130944, 65280, 32256, 15360, 6144, 1048568, 524272, 262112, 131008, 65408, 32512, 15872, 7168, 524280, 262128, 131040, 65472, 32640, 16128, 7680, 3072, 262136, 131056, 65504, 32704, 16256, 7936, 3584, 131064, 65520, 32736, 16320, 8064, 3840, 1536, 65528, 32752, 16352, 8128, 3968, 1792, 32760, 16368, 8160, 4032, 1920, 768, 16376, 8176, 4064, 1984, 896, 8184, 4080, 2016, 960, 384, 4088, 2032, 992, 448, 2040, 1008, 480, 1016, 496, 224, 504, 240, 248, 112, 120, 48, 56, 16, 24, 8]\n assert candidate(arr = [97, 43, 27, 58, 103, 82, 75, 34, 69, 20, 15, 88, 47, 62, 91],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13]]) == [123, 65, 84, 96, 2, 106, 44, 34, 69, 20, 15, 88, 47, 62]\n assert candidate(arr = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],queries = [[0, 9], [1, 6], [2, 7], [3, 8], [4, 9], [0, 5], [5, 8], [0, 1], [8, 9]]) == [67, 9, 83, 25, 103, 63, 16, 27, 11]\n assert candidate(arr = [255, 127, 63, 31, 15, 7, 3, 1],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 3], [4, 7], [0, 5], [2, 7], [1, 4], [0, 1], [6, 7], [0, 0], [7, 7]]) == [170, 84, 40, 16, 160, 10, 168, 42, 80, 128, 2, 255, 1]\n assert candidate(arr = [17, 23, 5, 31, 4, 6, 7, 9],queries = [[0, 7], [2, 5], [3, 6], [1, 4], [0, 0], [7, 7]]) == [16, 24, 26, 9, 17, 9]\n assert candidate(arr = [123456789, 987654321, 135792468, 246813579, 111213141, 191817161, 151413121, 121110987, 765432109, 890123456],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [541748032, 304059029, 90073865, 176057750, 231612316]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8]]) == [0, 14, 2, 12, 4, 10, 6]\n assert candidate(arr = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 9], [0, 4], [6, 8]]) == [524095, 241270, 30061, 201228, 30433, 292406, 231689, 151730]\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5],queries = [[0, 14], [5, 10], [2, 12], [0, 7], [8, 14]]) == [4, 14, 5, 15, 11]\n assert candidate(arr = [31, 28, 30, 29, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[0, 29], [1, 28], [2, 27], [3, 26], [4, 25], [5, 24], [6, 23], [7, 22], [8, 21], [9, 20], [10, 19], [11, 18], [12, 17], [13, 16], [14, 15], [0, 15], [15, 29]]) == [1, 28, 3, 25, 1, 28, 1, 16, 1, 28, 1, 24, 1, 28, 1, 0, 17]\n assert candidate(arr = [8, 16, 32, 64, 128, 256, 512, 1024],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 6], [1, 5], [2, 4], [0, 5], [1, 4], [2, 3]]) == [2040, 1008, 480, 192, 1016, 496, 224, 504, 240, 96]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [1, 4], [3, 6], [0, 5], [5, 9], [2, 8]]) == [11, 0, 0, 7, 10, 2]\n assert candidate(arr = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],queries = [[0, 14], [1, 12], [3, 11], [4, 10], [6, 9]]) == [16, 0, 28, 20, 12]\n assert candidate(arr = [17, 23, 31, 47, 59, 67, 71, 83, 97, 101],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 9], [0, 4], [6, 8]]) == [94, 42, 92, 16, 120, 83, 13, 117]\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [0, 4], [5, 8]]) == [511, 254, 124, 56, 16, 31, 480]\n assert candidate(arr = [25, 35, 45, 55, 65, 75, 85, 95, 105],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [0, 4], [5, 8]]) == [73, 57, 69, 61, 97, 40]\n assert candidate(arr = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 3], [5, 9], [1, 2], [6, 7], [8, 9]]) == [1015, 0, 7, 0, 7, 1020, 999999991, 1, 3, 15]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],queries = [[0, 15], [1, 14], [2, 13], [3, 12], [4, 11], [5, 10], [6, 9], [7, 8], [0, 0], [15, 15]]) == [16, 1, 12, 1, 8, 1, 12, 1, 1, 16]\n assert candidate(arr = [2147483647, 1073741823, 536870911, 268435455, 134217727],queries = [[0, 4], [1, 3], [0, 2], [3, 4], [2, 2]]) == [1476395007, 805306367, 1610612735, 134217728, 536870911]\n assert candidate(arr = [234, 567, 890, 1234, 5678, 9012, 3456, 7890, 12345, 67890, 112233, 445566, 778899, 101112, 212223, 313233, 414243, 515253, 616263, 717273],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [650028, 203295, 687983, 893088, 783953, 993262, 800805, 900957, 410396, 48987]\n assert candidate(arr = [134217728, 67108864, 33554432, 16777216, 8388608, 4194304, 2097152, 1048576, 524288, 262144],queries = [[0, 9], [1, 5], [3, 7], [0, 6], [6, 9], [2, 8]]) == [268173312, 130023424, 32505856, 266338304, 3932160, 66584576]\n"}, "metadata": {"canonical_parameter_names": ["arr", "queries"], "leetcode_dataset_entry_point": "Solution().xorQueries", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector xorQueries(vector& arr, vector>& queries) {", "container": "Solution", "callable": "xorQueries", "parameters": [{"name": "arr", "type": "vector&"}, {"name": "queries", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1311, "task_id": "get-watched-videos-by-your-friends", "difficulty": "Medium", "problem_description": "There are n people, each person has a unique id between 0 and n-1. Given the arrays watchedVideos and friends, where watchedVideos[i] and friends[i] contain the list of watched videos and the list of friends respectively for the person with id = i.\nLevel 1 of videos are all watched videos by your friends, level 2 of videos are all watched videos by the friends of your friends and so on. In general, the level k of videos are all watched videos by people with the shortest path exactly equal to k with you. Given your id and the level of videos, return the list of videos ordered by their frequencies (increasing). For videos with the same frequency order them alphabetically from least to greatest. \n \nExample 1:\n\n\nInput: watchedVideos = [[\"A\",\"B\"],[\"C\"],[\"B\",\"C\"],[\"D\"]], friends = [[1,2],[0,3],[0,3],[1,2]], id = 0, level = 1\nOutput: [\"B\",\"C\"] \nExplanation: \nYou have id = 0 (green color in the figure) and your friends are (yellow color in the figure):\nPerson with id = 1 -> watchedVideos = [\"C\"] \nPerson with id = 2 -> watchedVideos = [\"B\",\"C\"] \nThe frequencies of watchedVideos by your friends are: \nB -> 1 \nC -> 2\n\nExample 2:\n\n\nInput: watchedVideos = [[\"A\",\"B\"],[\"C\"],[\"B\",\"C\"],[\"D\"]], friends = [[1,2],[0,3],[0,3],[1,2]], id = 0, level = 2\nOutput: [\"D\"]\nExplanation: \nYou have id = 0 (green color in the figure) and the only friend of your friends is the person with id = 3 (yellow color in the figure).\n\n \nConstraints:\n\nn == watchedVideos.length == friends.length\n2 <= n <= 100\n1 <= watchedVideos[i].length <= 100\n1 <= watchedVideos[i][j].length <= 8\n0 <= friends[i].length < n\n0 <= friends[i][j] < n\n0 <= id < n\n1 <= level < n\nif friends[i] contains j, then friends[j] contains i\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(watchedVideos = [['Action', 'Comedy'], ['Action'], ['Comedy', 'Drama'], ['Drama']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 3,level = 1) == ['Action', 'Comedy', 'Drama']\n assert candidate(watchedVideos = [['X', 'Y'], ['Y', 'Z'], ['Z', 'X'], ['X', 'Y', 'Z']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 1,level = 1) == ['Z', 'X', 'Y']\n assert candidate(watchedVideos = [['X', 'Y'], ['Z'], ['X', 'Z'], ['W']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 1,level = 1) == ['W', 'X', 'Y']\n assert candidate(watchedVideos = [['A', 'B'], ['C'], ['B', 'C'], ['D']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 0,level = 1) == ['B', 'C']\n assert candidate(watchedVideos = [['M', 'N'], ['N'], ['M', 'N'], ['O']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 2,level = 1) == ['M', 'N', 'O']\n assert candidate(watchedVideos = [['Movie1', 'Movie2'], ['Movie3'], ['Movie2', 'Movie3'], ['Movie4']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 2,level = 2) == ['Movie3']\n assert candidate(watchedVideos = [['Movie1', 'Movie2'], ['Movie2', 'Movie3'], ['Movie3', 'Movie4'], ['Movie4', 'Movie5']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 2,level = 2) == ['Movie2', 'Movie3']\n assert candidate(watchedVideos = [['P', 'Q'], ['R'], ['P', 'R'], ['S']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 3,level = 1) == ['P', 'R']\n assert candidate(watchedVideos = [['X', 'Y'], ['Y', 'Z'], ['X', 'Z'], ['W']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 1,level = 1) == ['W', 'X', 'Y']\n assert candidate(watchedVideos = [['Movie1'], ['Movie2'], ['Movie3'], ['Movie4']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 2,level = 2) == ['Movie2']\n assert candidate(watchedVideos = [['A', 'B'], ['C'], ['B', 'C'], ['D']],friends = [[1, 2], [0, 3], [0, 3], [1, 2]],id = 0,level = 2) == ['D']\n assert candidate(watchedVideos = [['Fitness', 'Yoga'], ['Yoga', 'Pilates'], ['Pilates', 'Meditation'], ['Meditation', 'TaiChi'], ['TaiChi', 'Fitness'], ['Fitness', 'Yoga']],friends = [[1, 5], [0, 2], [1, 3], [2, 4], [3, 5], [0, 4]],id = 0,level = 3) == ['Meditation', 'TaiChi']\n assert candidate(watchedVideos = [['Thriller', 'Horror'], ['Horror', 'Comedy'], ['Comedy', 'Drama'], ['Drama', 'Thriller'], ['Action', 'Thriller']],friends = [[1, 3], [0, 2, 4], [1, 3], [0, 2], [1]],id = 0,level = 2) == ['Action', 'Comedy', 'Drama', 'Thriller']\n assert candidate(watchedVideos = [['Reality', 'TalkShow'], ['Reality'], ['TalkShow', 'Documentary'], ['Documentary'], ['Reality', 'TalkShow'], ['Documentary', 'Reality'], ['TalkShow']],friends = [[1, 2], [0, 3], [0, 4], [1, 5], [2, 6], [3, 6], [4, 5]],id = 2,level = 2) == ['Reality', 'TalkShow']\n assert candidate(watchedVideos = [['Romance', 'Horror'], ['Romance', 'Drama'], ['Horror', 'Drama'], ['Romance'], ['Horror', 'Drama', 'Romance']],friends = [[1, 2, 3], [0, 4], [0, 3], [0, 2, 4], [1, 3]],id = 2,level = 1) == ['Horror', 'Romance']\n assert candidate(watchedVideos = [['Thriller'], ['Horror', 'Thriller'], ['Horror'], ['Comedy', 'Horror'], ['Comedy', 'Drama'], ['Drama', 'Thriller']],friends = [[1, 2, 3], [0, 2, 4], [0, 1, 4, 5], [0, 4, 5], [1, 2, 3, 5], [2, 3, 4]],id = 3,level = 3) == []\n assert candidate(watchedVideos = [['Thriller', 'Horror'], ['Horror', 'Romance'], ['Romance', 'Action'], ['Action', 'Comedy'], ['Comedy', 'Thriller']],friends = [[1, 3], [0, 2, 4], [1, 3], [0, 2], [1]],id = 0,level = 2) == ['Action', 'Comedy', 'Romance', 'Thriller']\n assert candidate(watchedVideos = [['Action', 'Adventure'], ['Adventure', 'Horror'], ['Horror', 'SciFi'], ['SciFi', 'Drama'], ['Drama', 'Action'], ['Action', 'Horror'], ['Horror', 'SciFi'], ['SciFi', 'Adventure'], ['Adventure', 'Drama'], ['Drama', 'Action']],friends = [[1, 3, 5, 7], [0, 2, 4, 6, 8], [1, 3, 5, 7, 9], [0, 2, 4, 6, 8], [1, 3, 5, 7, 9], [0, 2, 4, 6, 8], [1, 3, 5, 7, 9], [0, 2, 4, 6, 8], [1, 3, 5, 7, 9], [2, 4, 6, 8]],id = 4,level = 2) == ['Action', 'Drama', 'Adventure', 'Horror', 'SciFi']\n assert candidate(watchedVideos = [['Action'], ['Action', 'Adventure'], ['Action', 'Adventure', 'Comedy'], ['Action', 'Adventure', 'Comedy', 'Drama'], ['Action', 'Adventure', 'Comedy', 'Drama', 'Thriller']],friends = [[1, 2], [0, 3], [0, 3, 4], [1, 2, 4], [2, 3]],id = 3,level = 2) == ['Action']\n assert candidate(watchedVideos = [['Horror', 'Thriller'], ['Horror'], ['Thriller'], ['Horror', 'Thriller'], ['Horror'], ['Thriller', 'Comedy']],friends = [[1, 2], [0, 3], [0, 3, 4], [1, 2, 5], [2], [3]],id = 0,level = 2) == ['Thriller', 'Horror']\n assert candidate(watchedVideos = [['Adventure', 'Sci-Fi'], ['Sci-Fi', 'Animation'], ['Animation', 'Adventure'], ['Adventure', 'Drama'], ['Drama', 'Sci-Fi'], ['Sci-Fi', 'Adventure']],friends = [[1, 4], [0, 2, 5], [1, 3], [2], [0], [1]],id = 1,level = 3) == []\n assert candidate(watchedVideos = [['Thriller', 'Horror'], ['Horror', 'SciFi'], ['SciFi', 'Comedy'], ['Comedy', 'Thriller'], ['Thriller', 'SciFi']],friends = [[1, 2], [0, 3], [0, 4], [1, 4], [2, 3]],id = 0,level = 2) == ['Comedy', 'SciFi', 'Thriller']\n assert candidate(watchedVideos = [['Romance', 'Drama'], ['Drama', 'Thriller'], ['Thriller', 'Horror'], ['Horror', 'Comedy'], ['Comedy', 'Romance'], ['Romance', 'Thriller']],friends = [[1, 2], [0, 3, 5], [0, 4], [1, 4], [2, 3], [1]],id = 3,level = 1) == ['Comedy', 'Drama', 'Romance', 'Thriller']\n assert candidate(watchedVideos = [['Anime', 'Cartoon'], ['Drama', 'Horror'], ['Cartoon'], ['Sci-Fi', 'Drama'], ['Horror', 'Anime']],friends = [[1, 2], [0, 3], [0, 4], [1, 4], [2, 3]],id = 0,level = 2) == ['Anime', 'Drama', 'Horror', 'Sci-Fi']\n assert candidate(watchedVideos = [['Drama', 'Romance'], ['Romance', 'Adventure'], ['Adventure', 'Thriller'], ['Thriller', 'SciFi'], ['SciFi', 'Drama'], ['Drama', 'Adventure']],friends = [[1, 5], [0, 2], [1, 3], [2, 4], [3, 5], [0, 4]],id = 3,level = 3) == ['Drama', 'Romance']\n assert candidate(watchedVideos = [['Adventure', 'Sci-Fi'], ['Action', 'Adventure'], ['Sci-Fi'], ['Drama'], ['Comedy', 'Drama']],friends = [[1, 2, 3], [0, 3, 4], [0, 3, 4], [0, 1, 2, 4], [1, 2, 3]],id = 0,level = 2) == ['Comedy', 'Drama']\n assert candidate(watchedVideos = [['Sci-Fi', 'Horror'], ['Romance'], ['Sci-Fi', 'Drama'], ['Romance', 'Sci-Fi'], ['Horror', 'Drama'], ['Comedy'], ['Drama'], ['Romance']],friends = [[1, 2, 3], [0, 4, 5], [0, 3, 6], [0, 2, 4, 7], [1, 3, 5, 7], [1, 4, 6], [2, 5], [3, 4, 7]],id = 1,level = 3) == []\n assert candidate(watchedVideos = [['MusicVideo', 'Pop'], ['Pop', 'Rock'], ['Rock', 'HipHop'], ['HipHop', 'Jazz'], ['Jazz', 'Pop'], ['Pop', 'MusicVideo']],friends = [[1, 3], [0, 2], [1, 3], [0, 2, 4], [3, 5], [4]],id = 2,level = 3) == ['MusicVideo', 'Pop']\n assert candidate(watchedVideos = [['SciFi', 'Romance'], ['Action', 'Adventure'], ['Action', 'SciFi'], ['Romance', 'Adventure'], ['SciFi', 'Drama'], ['SciFi', 'Adventure', 'Drama']],friends = [[1, 2], [0, 3, 4], [0, 3], [1, 2], [2, 5], [4]],id = 2,level = 2) == ['Action', 'Adventure']\n assert candidate(watchedVideos = [['Thriller', 'Horror'], ['Horror'], ['Horror', 'Thriller'], ['Action', 'Drama'], ['Action'], ['Drama', 'Thriller'], ['Drama'], ['Thriller', 'Horror'], ['Drama', 'Horror'], ['Drama', 'Action']],friends = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 2, 3, 4, 5, 6, 7, 8], [1, 0, 3, 4, 5, 6, 7, 8, 9], [1, 0, 2, 4, 5, 6, 7, 8, 9], [1, 2, 3, 0, 5, 6, 7, 8, 9], [1, 2, 3, 4, 0, 6, 7, 8, 9], [1, 2, 3, 4, 5, 0, 7, 8, 9], [1, 2, 3, 4, 5, 6, 0, 8, 9], [1, 2, 3, 4, 5, 6, 7, 0, 9], [1, 2, 3, 4, 5, 6, 7, 8, 0]],id = 4,level = 4) == []\n assert candidate(watchedVideos = [['Documentary'], ['Documentary', 'Animation'], ['Animation', 'Horror'], ['Horror', 'Sci-Fi'], ['Sci-Fi', 'Documentary'], ['Animation', 'Sci-Fi']],friends = [[1, 2], [0, 3, 4], [0, 3], [1, 2, 5], [1, 5], [3, 4]],id = 3,level = 2) == ['Sci-Fi', 'Documentary']\n assert candidate(watchedVideos = [['Fantasy', 'Comedy'], ['Fantasy'], ['Fantasy', 'Comedy'], ['Drama'], ['Fantasy', 'Drama'], ['Comedy', 'Drama']],friends = [[1, 2], [0, 3, 4], [0, 3], [1, 2, 5], [2], [3]],id = 3,level = 2) == ['Comedy', 'Drama', 'Fantasy']\n assert candidate(watchedVideos = [['Adventure', 'Comedy'], ['Action', 'Adventure'], ['Comedy', 'Drama'], ['Drama'], ['Action', 'Adventure']],friends = [[1, 2], [0, 3, 4], [0, 3], [1, 2], [1]],id = 1,level = 2) == ['Comedy', 'Drama']\n assert candidate(watchedVideos = [['Drama'], ['Drama', 'Drama'], ['Thriller'], ['Thriller', 'Thriller', 'Drama'], ['Thriller', 'Drama']],friends = [[1, 2], [0, 3], [0, 3, 4], [1, 2, 4], [2, 3]],id = 1,level = 3) == []\n assert candidate(watchedVideos = [['Anime', 'Cartoon'], ['Cartoon', 'Action'], ['Action', 'Adventure'], ['Adventure', 'Comedy'], ['Comedy', 'Anime']],friends = [[1, 2], [0, 3], [0, 4], [1, 4], [2, 3]],id = 1,level = 3) == []\n assert candidate(watchedVideos = [['Sci-Fi', 'Adventure'], ['Action', 'Drama'], ['Drama', 'Sci-Fi'], ['Adventure', 'Comedy'], ['Comedy', 'Action']],friends = [[1, 2], [0, 3, 4], [0, 3], [1, 2], [1, 4]],id = 0,level = 2) == ['Action', 'Adventure', 'Comedy']\n assert candidate(watchedVideos = [['RealityShow', 'TalkShow'], ['TalkShow', 'Documentary'], ['Documentary', 'RealityShow'], ['RealityShow', 'Drama'], ['Drama', 'TalkShow'], ['TalkShow', 'RealityShow']],friends = [[1, 2], [0, 3], [0, 3], [1, 4], [3, 5], [1, 5]],id = 0,level = 2) == ['Drama', 'RealityShow']\n assert candidate(watchedVideos = [['Action', 'Drama'], ['Comedy', 'Romance'], ['Action', 'Comedy'], ['Romance'], ['Action', 'Romance'], ['Drama', 'Comedy']],friends = [[1, 2, 3], [0, 4], [0, 5], [0, 5], [1, 5], [2, 3, 4]],id = 0,level = 2) == ['Action', 'Comedy', 'Drama', 'Romance']\n assert candidate(watchedVideos = [['Animation', 'Comedy'], ['Comedy', 'Adventure'], ['Adventure', 'Animation'], ['Animation', 'Comedy'], ['Adventure'], ['Adventure', 'Comedy'], ['Comedy'], ['Animation', 'Adventure'], ['Comedy', 'Animation'], ['Animation', 'Adventure']],friends = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 0, 9], [0, 1, 2, 3, 4, 5, 6, 7, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8]],id = 3,level = 5) == []\n assert candidate(watchedVideos = [['Documentary', 'Biography'], ['Biography', 'Historical'], ['Historical', 'War'], ['War', 'Documentary'], ['Documentary', 'Biography'], ['Biography', 'Historical'], ['Historical', 'War'], ['War', 'Documentary']],friends = [[1, 2, 4], [0, 3, 5], [0, 4, 6], [1, 5, 7], [0, 2, 8], [1, 3, 8], [2], [3], [4, 5]],id = 0,level = 3) == ['Documentary', 'War']\n assert candidate(watchedVideos = [['Thriller', 'Horror'], ['Comedy', 'Action'], ['Drama', 'Comedy'], ['Horror', 'Thriller'], ['Action', 'Drama']],friends = [[1, 2], [0, 3, 4], [0, 3], [1, 2], [1, 2]],id = 0,level = 2) == ['Action', 'Drama', 'Horror', 'Thriller']\n assert candidate(watchedVideos = [['Comedy'], ['Comedy', 'Horror'], ['Horror', 'Drama'], ['Comedy', 'Drama', 'Thriller'], ['Drama', 'Thriller'], ['Drama', 'Thriller', 'Horror'], ['Horror', 'Drama', 'Comedy'], ['Horror', 'Drama', 'Comedy', 'Thriller']],friends = [[1, 3, 4], [0, 2, 5], [1, 4], [0, 5, 7], [0, 2, 6], [1, 3, 6], [4, 7], [3, 6]],id = 5,level = 3) == []\n assert candidate(watchedVideos = [['Adventure', 'Action'], ['Action', 'Comedy'], ['Comedy', 'Horror'], ['Horror', 'Drama'], ['Drama', 'Adventure']],friends = [[1, 2], [0, 3], [0, 4], [1, 4], [2, 3]],id = 4,level = 2) == ['Adventure', 'Comedy', 'Action']\n assert candidate(watchedVideos = [['Adventure', 'Action'], ['Action', 'Drama'], ['Adventure', 'Drama'], ['Drama', 'Action'], ['Adventure', 'Drama'], ['Action', 'Adventure'], ['Adventure', 'Action'], ['Drama', 'Action'], ['Action', 'Adventure'], ['Adventure', 'Drama']],friends = [[1, 2], [0, 3], [0, 4], [1, 5], [2, 6], [3, 6], [4, 7], [5, 8], [6, 9], [7, 8]],id = 4,level = 4) == ['Action', 'Adventure', 'Drama']\n assert candidate(watchedVideos = [['Thriller', 'Romance'], ['Action'], ['Romance', 'Drama'], ['Drama', 'Thriller'], ['Action', 'Thriller'], ['Action', 'Romance']],friends = [[1, 2], [0, 3], [0, 4], [1, 5], [2, 5], [3, 4]],id = 1,level = 3) == ['Action', 'Thriller']\n assert candidate(watchedVideos = [['RealityShow', 'TalkShow'], ['RealityShow'], ['TalkShow'], ['RealityShow', 'TalkShow'], ['RealityShow', 'TalkShow'], ['RealityShow', 'TalkShow'], ['RealityShow', 'TalkShow'], ['RealityShow', 'TalkShow'], ['RealityShow', 'TalkShow'], ['RealityShow', 'TalkShow']],friends = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [0], [0], [0], [0], [0], [0], [0], [0], [0]],id = 0,level = 1) == ['RealityShow', 'TalkShow']\n assert candidate(watchedVideos = [['Animation', 'ShortFilm'], ['ShortFilm', 'Documentary'], ['Documentary', 'Animation'], ['Animation', 'LiveAction'], ['LiveAction', 'ShortFilm'], ['ShortFilm', 'Documentary']],friends = [[1, 5], [0, 2], [1, 3], [2, 4], [3, 5], [0, 4]],id = 3,level = 2) == ['Documentary', 'ShortFilm']\n assert candidate(watchedVideos = [['Animation', 'Comedy'], ['Animation'], ['Animation', 'Comedy'], ['Drama'], ['Comedy', 'Drama'], ['Drama']],friends = [[1, 2], [0, 3], [0, 3, 4, 5], [1, 2, 5], [2], [2, 3]],id = 2,level = 3) == []\n assert candidate(watchedVideos = [['Music', 'Documentary'], ['Documentary', 'Animation'], ['Animation', 'Music'], ['Music', 'Animation'], ['Animation', 'Music']],friends = [[1, 2, 3, 4], [0, 2, 3, 4], [0, 1, 3, 4], [0, 1, 2, 4], [0, 1, 2, 3]],id = 1,level = 3) == []\n assert candidate(watchedVideos = [['Action'], ['Action', 'Comedy'], ['Comedy'], ['Drama', 'Action'], ['Drama'], ['Action', 'Drama'], ['Action', 'Comedy'], ['Comedy', 'Drama']],friends = [[1, 2, 3], [0, 2, 3, 4], [0, 1, 5, 6], [0, 1, 6, 7], [1, 6], [2, 7], [2, 3, 4, 7], [3, 5, 6]],id = 4,level = 2) == ['Action', 'Comedy', 'Drama']\n assert candidate(watchedVideos = [['Documentary'], ['Comedy'], ['Drama'], ['Comedy'], ['Documentary'], ['Drama'], ['Comedy'], ['Documentary'], ['Drama'], ['Comedy'], ['Documentary']],friends = [[1, 2, 3], [0, 4, 5], [0, 6, 7], [0, 8, 9], [1, 10], [1], [2], [2], [3], [3], [4]],id = 4,level = 2) == ['Documentary', 'Drama']\n assert candidate(watchedVideos = [['Action', 'Horror'], ['Horror', 'Sci-Fi'], ['Action', 'Sci-Fi'], ['Sci-Fi', 'Adventure'], ['Adventure', 'Action'], ['Adventure', 'Horror']],friends = [[1, 2, 3], [0, 4], [0, 3], [0, 2, 4], [1, 3]],id = 0,level = 3) == []\n assert candidate(watchedVideos = [['SciFi', 'Adventure'], ['Adventure', 'Fantasy'], ['Fantasy', 'Mystery'], ['Mystery', 'Horror'], ['Horror', 'SciFi']],friends = [[1, 4], [0, 2], [1, 3], [2, 4], [0, 3]],id = 2,level = 2) == ['Adventure', 'Horror', 'SciFi']\n assert candidate(watchedVideos = [['Adventure', 'Animation'], ['Action', 'Adventure'], ['Animation', 'Comedy'], ['Action', 'Comedy'], ['Adventure', 'Comedy'], ['Animation', 'Action']],friends = [[1, 2, 3], [0, 4, 5], [0, 3, 5], [0, 2, 4], [1, 3, 5], [1, 2, 4]],id = 1,level = 2) == ['Action', 'Animation', 'Comedy']\n assert candidate(watchedVideos = [['SciFi', 'Romance'], ['Action', 'Adventure'], ['Action', 'SciFi'], ['Romance', 'Adventure'], ['SciFi', 'Drama']],friends = [[1, 2], [0, 3], [0, 3, 4], [1, 2], [2]],id = 0,level = 3) == []\n assert candidate(watchedVideos = [['Animation', 'Action'], ['Adventure', 'Comedy'], ['Action', 'Comedy'], ['Animation', 'Adventure'], ['Drama', 'Adventure']],friends = [[1, 3], [0, 2, 4], [1, 3], [0, 2], [1, 4]],id = 2,level = 3) == []\n assert candidate(watchedVideos = [['Reality', 'TalkShow'], ['Reality', 'Documentary'], ['TalkShow', 'Documentary'], ['Documentary'], ['Reality', 'TalkShow'], ['Documentary', 'Reality'], ['TalkShow'], ['Reality', 'Documentary'], ['TalkShow', 'Documentary']],friends = [[1, 2], [0, 3], [0, 4], [1, 5], [2, 6], [3, 6], [4, 5], [6, 7], [7, 8]],id = 3,level = 3) == ['Documentary', 'Reality', 'TalkShow']\n assert candidate(watchedVideos = [['Comedy'], ['Action'], ['Romance'], ['Action', 'Romance'], ['Comedy', 'Romance'], ['Comedy', 'Action']],friends = [[1, 2, 3, 4], [0, 4, 5], [0, 5, 3], [0, 2, 5], [0, 1, 3], [1, 2, 4]],id = 2,level = 3) == []\n assert candidate(watchedVideos = [['Thriller'], ['Horror'], ['Sci-Fi'], ['Thriller', 'Horror'], ['Sci-Fi', 'Thriller'], ['Horror', 'Sci-Fi']],friends = [[1, 2], [0, 3, 4], [0, 5], [1, 5], [1, 5], [2, 3, 4]],id = 2,level = 3) == []\n assert candidate(watchedVideos = [['Romantic', 'Comedy'], ['Action', 'Adventure'], ['Drama', 'Thriller'], ['Comedy', 'Romantic'], ['Adventure', 'Action'], ['Thriller', 'Drama'], ['Romantic', 'Drama'], ['Action', 'Comedy'], ['Adventure', 'Thriller']],friends = [[1, 2, 4], [0, 3, 5], [0, 4, 6], [1, 5, 7], [0, 2, 8], [1, 3, 8], [2], [3], [4, 5]],id = 4,level = 2) == ['Action', 'Adventure', 'Romantic', 'Thriller', 'Drama']\n assert candidate(watchedVideos = [['Documentary'], ['Documentary', 'Animation'], ['Animation'], ['Documentary', 'Animation', 'Comedy'], ['Comedy', 'Action'], ['Action', 'Comedy'], ['Comedy']],friends = [[1, 2, 3], [0, 2, 4], [0, 1, 3, 5], [0, 2, 4, 5, 6], [1, 3, 5], [2, 3, 4, 6], [3, 5]],id = 1,level = 4) == []\n assert candidate(watchedVideos = [['Horror'], ['Horror', 'Thriller'], ['Thriller'], ['Horror', 'Thriller', 'Comedy'], ['Comedy', 'Action'], ['Action', 'Comedy'], ['Action', 'Comedy'], ['Comedy', 'Thriller'], ['Thriller', 'Horror']],friends = [[1, 2, 3], [0, 2, 3, 4], [0, 1, 5, 6], [0, 1, 6, 7], [1, 6], [2, 7], [2, 3, 4, 7], [3, 5, 6], [3, 7]],id = 5,level = 3) == ['Action', 'Comedy']\n assert candidate(watchedVideos = [['Horror', 'SciFi'], ['Adventure', 'SciFi'], ['Horror', 'Comedy'], ['Comedy', 'SciFi'], ['Adventure', 'Comedy']],friends = [[1, 3, 4], [0, 2], [1, 3], [0, 2, 4], [0, 3]],id = 0,level = 2) == ['Comedy', 'Horror']\n assert candidate(watchedVideos = [['Adventure', 'Action'], ['Action'], ['Adventure', 'Action'], ['Adventure'], ['Action', 'Adventure'], ['Action'], ['Adventure', 'Action'], ['Action', 'Adventure']],friends = [[1, 2, 3, 4, 5, 6, 7], [0, 2, 3, 4, 5, 6, 7], [0, 1, 3, 4, 5, 6, 7], [0, 1, 2, 4, 5, 6, 7], [0, 1, 2, 3, 5, 6, 7], [0, 1, 2, 3, 4, 6, 7], [0, 1, 2, 3, 4, 5, 7], [0, 1, 2, 3, 4, 5, 6]],id = 6,level = 3) == []\n assert candidate(watchedVideos = [['Adventure', 'Comedy'], ['Action', 'Adventure'], ['Comedy', 'Drama'], ['Drama'], ['Action', 'Adventure']],friends = [[1, 2], [0, 3, 4], [0, 3], [1, 2], [1]],id = 0,level = 2) == ['Action', 'Adventure', 'Drama']\n assert candidate(watchedVideos = [['Romance'], ['Romance', 'Comedy'], ['Romance'], ['Comedy'], ['Romance', 'Action'], ['Action', 'Drama'], ['Drama', 'Action'], ['Drama'], ['Comedy', 'Romance'], ['Romance', 'Drama']],friends = [[1, 2, 3, 4], [0, 5, 6, 7, 8, 9], [0, 9, 8], [0, 5, 7], [0, 5, 8, 9], [1, 3, 4, 6, 9], [1, 5, 9], [1, 3, 9], [2, 4, 9], [2, 3, 4, 5, 6, 7]],id = 5,level = 3) == []\n assert candidate(watchedVideos = [['Action', 'Adventure'], ['Sci-Fi', 'Thriller'], ['Adventure', 'Sci-Fi'], ['Action', 'Thriller'], ['Action', 'Sci-Fi'], ['Adventure', 'Thriller'], ['Adventure', 'Sci-Fi'], ['Action', 'Adventure'], ['Action', 'Thriller'], ['Sci-Fi', 'Adventure']],friends = [[1, 2, 3], [0, 4, 5], [0, 6, 7], [0, 8, 9], [1], [1, 2], [2], [2], [3], [3, 4]],id = 2,level = 2) == ['Action', 'Sci-Fi', 'Thriller']\n"}, "metadata": {"canonical_parameter_names": ["watchedVideos", "friends", "id", "level"], "leetcode_dataset_entry_point": "Solution().watchedVideosByFriends", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector watchedVideosByFriends(vector>& watchedVideos, vector>& friends, int id, int level) {", "container": "Solution", "callable": "watchedVideosByFriends", "parameters": [{"name": "watchedVideos", "type": "vector>&"}, {"name": "friends", "type": "vector>&"}, {"name": "id", "type": "int"}, {"name": "level", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1312, "task_id": "minimum-insertion-steps-to-make-a-string-palindrome", "difficulty": "Hard", "problem_description": "Given a string s. In one step you can insert any character at any index of the string.\nReturn the minimum number of steps to make s palindrome.\nA Palindrome String is one that reads the same backward as well as forward.\n \nExample 1:\n\nInput: s = \"zzazz\"\nOutput: 0\nExplanation: The string \"zzazz\" is already palindrome we do not need any insertions.\n\nExample 2:\n\nInput: s = \"mbadm\"\nOutput: 2\nExplanation: String can be \"mbdadbm\" or \"mdbabdm\".\n\nExample 3:\n\nInput: s = \"leetcode\"\nOutput: 5\nExplanation: Inserting 5 characters the string becomes \"leetcodocteel\".\n\n \nConstraints:\n\n1 <= s.length <= 500\ns consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"race\") == 3\n assert candidate(s = \"noon\") == 0\n assert candidate(s = \"abcba\") == 0\n assert candidate(s = \"abcdef\") == 5\n assert candidate(s = \"zzazz\") == 0\n assert candidate(s = \"google\") == 2\n assert candidate(s = \"mbadm\") == 2\n assert candidate(s = \"abcd\") == 3\n assert candidate(s = \"algorithm\") == 8\n assert candidate(s = \"leetcode\") == 5\n assert candidate(s = \"aabb\") == 2\n assert candidate(s = \"abacabadabacabadabacaba\") == 0\n assert candidate(s = \"noonappa\") == 4\n assert candidate(s = \"wasitacaroracatisawwasitacaroracatisaw\") == 0\n assert candidate(s = \"amanaplanacanalpanamanaplanacanalpanama\") == 0\n assert candidate(s = \"aaaabaaaa\") == 0\n assert candidate(s = \"aabaa\") == 0\n assert candidate(s = \"abcde\") == 4\n assert candidate(s = \"abcdabcdabcd\") == 7\n assert candidate(s = \"racecarrace\") == 3\n assert candidate(s = \"rotorlevel\") == 5\n assert candidate(s = \"flzxrpfr\") == 5\n assert candidate(s = \"geeksforgeeks\") == 8\n assert candidate(s = \"abcdefghijklijklkjihgfedcba\") == 2\n assert candidate(s = \"aaaaabbbbb\") == 5\n assert candidate(s = \"flasflasflas\") == 7\n assert candidate(s = \"abcdefghikjlmnopqrstuvwxyzzyxwvutnmlkjihgfedcba\") == 7\n assert candidate(s = \"noonnoonnoonnoon\") == 0\n assert candidate(s = \"mississippimississippi\") == 6\n assert candidate(s = \"jglkhflhfl\") == 5\n assert candidate(s = \"abca\") == 1\n assert candidate(s = \"verylongstringthatneedsmanyinsertionstopalindrome\") == 27\n assert candidate(s = \"bananaananabanana\") == 2\n assert candidate(s = \"abcdxyzzyxwvutrdcba\") == 5\n assert candidate(s = \"abcdxyzzyxdcba\") == 0\n assert candidate(s = \"qzihxknhzvqt\") == 5\n assert candidate(s = \"triplepletriple\") == 10\n assert candidate(s = \"xyxzzxyxyxyxyxyx\") == 3\n assert candidate(s = \"abcdbca\") == 2\n assert candidate(s = \"kayak\") == 0\n assert candidate(s = \"flrif\") == 2\n assert candidate(s = \"abcdefghijjiuhgfedcba\") == 1\n assert candidate(s = \"aabaaabaabaaa\") == 2\n assert candidate(s = \"pqrstuabutsrqp\") == 1\n assert candidate(s = \"xyxz\") == 1\n assert candidate(s = \"abcda\") == 2\n assert candidate(s = \"ababababababab\") == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(s = \"abababababa\") == 0\n assert candidate(s = \"deeee\") == 1\n assert candidate(s = \"abcbabc\") == 2\n assert candidate(s = \"abcdefedcbafedcba\") == 4\n assert candidate(s = \"randomstring\") == 9\n assert candidate(s = \"thisisaverylongstringthatneedsmuchinsertionstobecomeapalindrome\") == 42\n assert candidate(s = \"abbaabbaba\") == 2\n assert candidate(s = \"wasitacaroracatisaw\") == 0\n assert candidate(s = \"trinitrotoluene\") == 8\n assert candidate(s = \"xyxxyxyxyxyx\") == 1\n assert candidate(s = \"aibohphobia\") == 0\n assert candidate(s = \"abcdefedcba\") == 0\n assert candidate(s = \"level\") == 0\n assert candidate(s = \"aabbccdd\") == 6\n assert candidate(s = \"stats\") == 0\n assert candidate(s = \"levellevellevel\") == 0\n assert candidate(s = \"fdlhdlf\") == 2\n assert candidate(s = \"abccbaabc\") == 3\n assert candidate(s = \"abababab\") == 1\n assert candidate(s = \"abacaxabaycabacaxaba\") == 5\n assert candidate(s = \"radar\") == 0\n assert candidate(s = \"xyxzxy\") == 1\n assert candidate(s = \"abacabadabacaba\") == 0\n assert candidate(s = \"pwwkew\") == 3\n assert candidate(s = \"redivider\") == 0\n assert candidate(s = \"abcdabcd\") == 5\n assert candidate(s = \"banana\") == 1\n assert candidate(s = \"noonnoonnoonnoonnoon\") == 0\n assert candidate(s = \"anana\") == 0\n assert candidate(s = \"noonabbada\") == 6\n assert candidate(s = \"agbdba\") == 1\n assert candidate(s = \"ananana\") == 0\n assert candidate(s = \"detartrated\") == 0\n assert candidate(s = \"abcdedcbaabcdedcba\") == 0\n assert candidate(s = \"hellohello\") == 5\n assert candidate(s = \"abccba\") == 0\n assert candidate(s = \"aabbccddeeff\") == 10\n assert candidate(s = \"xyxzxyxyyzz\") == 4\n assert candidate(s = \"madamimadam\") == 0\n assert candidate(s = \"abcdefghikjlmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == 2\n assert candidate(s = \"bbbbabc\") == 2\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 50\n assert candidate(s = \"cabbbbb\") == 2\n assert candidate(s = \"amanaplanacanalpanama\") == 0\n assert candidate(s = \"aebcbda\") == 2\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 25\n assert candidate(s = \"abcdefg\") == 6\n assert candidate(s = \"zyelkx\") == 5\n assert candidate(s = \"aaaaabbbbbaaaaa\") == 0\n assert candidate(s = \"abbbbac\") == 1\n assert candidate(s = \"abcbbbb\") == 2\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 25\n assert candidate(s = \"noonoonnoon\") == 1\n assert candidate(s = \"repaper\") == 0\n assert candidate(s = \"xyzxyz\") == 3\n assert candidate(s = \"abcdedcba\") == 0\n assert candidate(s = \"mamad\") == 2\n assert candidate(s = \"noonhighnoon\") == 1\n assert candidate(s = \"abacdfgdcaba\") == 1\n assert candidate(s = \"abcabc\") == 3\n assert candidate(s = \"rotor\") == 0\n assert candidate(s = \"abcdefghihgfedcba\") == 0\n assert candidate(s = \"racecar\") == 0\n assert candidate(s = \"racecarrracecar\") == 0\n assert candidate(s = \"madamimadamimadam\") == 0\n assert candidate(s = \"aabbccddeeefff\") == 11\n assert candidate(s = \"xyzyxyzyx\") == 0\n assert candidate(s = \"aabbcc\") == 4\n assert candidate(s = \"mississippi\") == 4\n assert candidate(s = \"flamingo\") == 7\n assert candidate(s = \"zxcvbnmasdfghjkloiuytrewq\") == 24\n assert candidate(s = \"amcelkpal\") == 6\n assert candidate(s = \"abbababa\") == 1\n assert candidate(s = \"aaabaaaa\") == 1\n assert candidate(s = \"abcdabcda\") == 4\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minInsertions", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minInsertions(string s) {", "container": "Solution", "callable": "minInsertions", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1313, "task_id": "decompress-run-length-encoded-list", "difficulty": "Easy", "problem_description": "We are given a list nums of integers representing a list compressed with run-length encoding.\nConsider each adjacent pair of elements [freq, val] = [nums[2*i], nums[2*i+1]] (with i >= 0).  For each such pair, there are freq elements with value val concatenated in a sublist. Concatenate all the sublists from left to right to generate the decompressed list.\nReturn the decompressed list.\n \nExample 1:\n\nInput: nums = [1,2,3,4]\nOutput: [2,4,4,4]\nExplanation: The first pair [1,2] means we have freq = 1 and val = 2 so we generate the array [2].\nThe second pair [3,4] means we have freq = 3 and val = 4 so we generate [4,4,4].\nAt the end the concatenation [2] + [4,4,4] is [2,4,4,4].\n\nExample 2:\n\nInput: nums = [1,1,2,3]\nOutput: [1,3,3]\n\n \nConstraints:\n\n2 <= nums.length <= 100\nnums.length % 2 == 0\n1 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 9, 2, 8, 3, 7]) == [9, 8, 8, 7, 7, 7]\n assert candidate(nums = [3, 1, 2, 2]) == [1, 1, 1, 2, 2]\n assert candidate(nums = [2, 5, 3, 1]) == [5, 5, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4]) == [2, 4, 4, 4]\n assert candidate(nums = [2, 5, 3, 7]) == [5, 5, 7, 7, 7]\n assert candidate(nums = [2, 5, 3, 6]) == [5, 5, 6, 6, 6]\n assert candidate(nums = [10, 1, 5, 2]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]\n assert candidate(nums = [4, 6, 2, 7]) == [6, 6, 6, 6, 7, 7]\n assert candidate(nums = [5, 10, 3, 20]) == [10, 10, 10, 10, 10, 20, 20, 20]\n assert candidate(nums = [4, 8, 1, 6]) == [8, 8, 8, 8, 6]\n assert candidate(nums = [1, 1, 2, 3]) == [1, 3, 3]\n assert candidate(nums = [1, 9, 3, 8, 2, 4]) == [9, 8, 8, 8, 4, 4]\n assert candidate(nums = [4, 7, 1, 2]) == [7, 7, 7, 7, 2]\n assert candidate(nums = [1, 9, 1, 8, 1, 7, 1, 6, 1, 5, 1, 4, 1, 3, 1, 2, 1, 1]) == [9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [2, 5, 4, 1]) == [5, 5, 1, 1, 1, 1]\n assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [99, 99, 1, 1]) == [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 1]\n assert candidate(nums = [7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == [7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1]\n assert candidate(nums = [1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8, 92, 9, 91, 10, 90, 11, 89, 12, 88, 13, 87, 14, 86, 15, 85, 16, 84, 17, 83, 18, 82, 19, 81, 20, 80]) == [99, 98, 98, 97, 97, 97, 96, 96, 96, 96, 95, 95, 95, 95, 95, 94, 94, 94, 94, 94, 94, 93, 93, 93, 93, 93, 93, 93, 92, 92, 92, 92, 92, 92, 92, 92, 91, 91, 91, 91, 91, 91, 91, 91, 91, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 89, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 88, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 87, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 85, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 84, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 82, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80]\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10]) == [2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == [100, 99, 99, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 96, 96]\n assert candidate(nums = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5, 5, 6, 4, 7, 3, 8, 2, 9, 1, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 10]\n assert candidate(nums = [30, 10, 20, 20, 10, 30, 5, 5]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 5, 5, 5, 5, 5]\n assert candidate(nums = [2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [2, 3, 3, 2, 2, 3, 3, 2]) == [3, 3, 2, 2, 2, 3, 3, 2, 2, 2]\n assert candidate(nums = [5, 5, 10, 10, 15, 15]) == [5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]\n assert candidate(nums = [10, 5, 6, 3, 2, 8, 9, 1]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 3, 3, 3, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [2, 1, 4, 2, 6, 3, 8, 4, 10, 5, 12, 6]) == [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [2, 50, 3, 40, 4, 30, 5, 20, 6, 10]) == [50, 50, 40, 40, 40, 30, 30, 30, 30, 20, 20, 20, 20, 20, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]) == [3, 3, 7, 7, 7, 7, 7, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53]\n assert candidate(nums = [7, 1, 3, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1]\n assert candidate(nums = [1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1, 16, 1, 17, 1, 18, 1, 19, 1, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [2, 2, 2, 4, 2, 6, 2, 8, 2, 10, 2, 12, 2, 14, 2, 16, 2, 18, 2, 20, 2, 22, 2, 24, 2, 26, 2, 28, 2, 30]) == [2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 28, 28, 30, 30]\n assert candidate(nums = [10, 5, 3, 6, 7, 1]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [2, 2, 2, 2, 2, 2]\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1, 16, 1, 17, 1, 18, 1, 19, 1, 20]) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [2, 2, 4, 4, 6, 6, 8, 8, 10, 10]) == [2, 2, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [99, 1, 1, 2]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]\n assert candidate(nums = [10, 5, 3, 3, 7, 2]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4]) == [1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(nums = [5, 10, 4, 20, 3, 30, 2, 40, 1, 50]) == [10, 10, 10, 10, 10, 20, 20, 20, 20, 30, 30, 30, 40, 40, 50]\n assert candidate(nums = [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7]) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [8, 1, 7, 2, 6, 3, 5, 4, 4, 5, 3, 6, 2, 7, 1, 8]) == [1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8]\n assert candidate(nums = [7, 1, 7, 2, 7, 3, 7, 4, 7, 5, 7, 6]) == [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [99, 1, 1, 99]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 99]\n assert candidate(nums = [33, 3, 33, 3, 33, 3, 33, 3, 33, 3]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [50, 1, 50, 2]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20]) == [3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 7, 7, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97]) == [100, 99, 99, 98, 98, 98, 97, 97, 97, 97]\n assert candidate(nums = [25, 9, 15, 3, 5, 8]) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 8, 8, 8, 8, 8]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [10, 5, 3, 2, 7, 9]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 2, 2, 2, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [100, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [10, 5, 3, 1, 7, 2, 6, 9]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]\n assert candidate(nums = [5, 10, 3, 20, 7, 30]) == [10, 10, 10, 10, 10, 20, 20, 20, 30, 30, 30, 30, 30, 30, 30]\n assert candidate(nums = [5, 5, 3, 3, 2, 2, 1, 1]) == [5, 5, 5, 5, 5, 3, 3, 3, 2, 2, 1]\n assert candidate(nums = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5, 5, 6]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == [100, 99, 99, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 96, 96, 95, 95, 95, 95, 95, 95, 94, 94, 94, 94, 94, 94, 94, 93, 93, 93, 93, 93, 93, 93, 93, 92, 92, 92, 92, 92, 92, 92, 92, 92, 91, 91, 91, 91, 91, 91, 91, 91, 91, 91]\n assert candidate(nums = [1, 1, 1, 2, 1, 3, 1, 4, 1, 5]) == [1, 2, 3, 4, 5]\n assert candidate(nums = [2, 1, 3, 2, 2, 3, 4, 4, 10, 5, 20, 6]) == [1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [10, 5, 6, 3, 2, 9, 1, 8]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 3, 3, 3, 3, 9, 9, 8]\n assert candidate(nums = [33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [25, 1, 25, 2, 25, 3, 25, 4, 25, 5]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [5, 1, 5, 2, 5, 3, 5, 4, 5, 5]) == [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]\n assert candidate(nums = [7, 1, 6, 2, 5, 3, 4, 4, 3, 5]) == [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5]\n assert candidate(nums = [100, 1, 1, 100]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100]\n assert candidate(nums = [20, 1, 15, 2, 10, 3, 5, 4, 3, 5]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(nums = [5, 10, 3, 20, 1, 30]) == [10, 10, 10, 10, 10, 20, 20, 20, 30]\n assert candidate(nums = [20, 30, 10, 40, 5, 50, 2, 60]) == [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60]\n assert candidate(nums = [3, 3, 2, 2, 1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [3, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93]) == [100, 99, 99, 98, 98, 98, 97, 97, 97, 97, 96, 96, 96, 96, 96, 95, 95, 95, 95, 95, 95, 94, 94, 94, 94, 94, 94, 94, 93, 93, 93, 93, 93, 93, 93, 93]\n assert candidate(nums = [2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [10, 5, 8, 15, 6, 25]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 15, 15, 15, 15, 15, 15, 15, 15, 25, 25, 25, 25, 25, 25]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == [8, 8, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1]\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == [3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 7, 7, 9, 9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13]\n assert candidate(nums = [2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20]) == [2, 2, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [2, 4, 4, 4, 6, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 7, 7, 7, 7, 7, 7, 7, 5, 5, 5, 5, 5, 5, 3, 3, 3, 3, 1, 1]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().decompressRLElist", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector decompressRLElist(vector& nums) {", "container": "Solution", "callable": "decompressRLElist", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1314, "task_id": "matrix-block-sum", "difficulty": "Medium", "problem_description": "Given a m x n matrix mat and an integer k, return a matrix answer where each answer[i][j] is the sum of all elements mat[r][c] for:\n\ni - k <= r <= i + k,\nj - k <= c <= j + k, and\n(r, c) is a valid position in the matrix.\n\n \nExample 1:\n\nInput: mat = [[1,2,3],[4,5,6],[7,8,9]], k = 1\nOutput: [[12,21,16],[27,45,33],[24,39,28]]\n\nExample 2:\n\nInput: mat = [[1,2,3],[4,5,6],[7,8,9]], k = 2\nOutput: [[45,45,45],[45,45,45],[45,45,45]]\n\n \nConstraints:\n\nm == mat.length\nn == mat[i].length\n1 <= m, n, k <= 100\n1 <= mat[i][j] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],k = 2) == [[45, 45, 45], [45, 45, 45], [45, 45, 45]]\n assert candidate(mat = [[5, 10, 15], [20, 25, 30], [35, 40, 45]],k = 0) == [[5, 10, 15], [20, 25, 30], [35, 40, 45]]\n assert candidate(mat = [[1, 2], [3, 4]],k = 1) == [[10, 10], [10, 10]]\n assert candidate(mat = [[5, 6, 7], [8, 9, 10], [11, 12, 13]],k = 0) == [[5, 6, 7], [8, 9, 10], [11, 12, 13]]\n assert candidate(mat = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],k = 1) == [[4, 6, 4], [6, 9, 6], [4, 6, 4]]\n assert candidate(mat = [[5]],k = 1) == [[5]]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],k = 1) == [[12, 21, 16], [27, 45, 33], [24, 39, 28]]\n assert candidate(mat = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],k = 0) == [[10, 20, 30], [40, 50, 60], [70, 80, 90]]\n assert candidate(mat = [[5]],k = 0) == [[5]]\n assert candidate(mat = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],k = 5) == [[9, 9, 9], [9, 9, 9], [9, 9, 9]]\n assert candidate(mat = [[2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2]],k = 0) == [[2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2]]\n assert candidate(mat = [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5]],k = 3) == [[80, 100, 120, 120, 100, 80], [100, 125, 150, 150, 125, 100], [120, 150, 180, 180, 150, 120], [120, 150, 180, 180, 150, 120], [100, 125, 150, 150, 125, 100], [80, 100, 120, 120, 100, 80]]\n assert candidate(mat = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19], [20, 19, 18, 17, 16, 15, 14, 13, 12]],k = 2) == [[69, 94, 120, 125, 130, 135, 140, 114, 87], [126, 168, 210, 210, 210, 210, 210, 168, 126], [126, 168, 210, 210, 210, 210, 210, 168, 126], [102, 138, 175, 180, 185, 190, 195, 158, 120]]\n assert candidate(mat = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],k = 1) == [[4, 6, 4], [6, 9, 6], [6, 9, 6], [6, 9, 6], [4, 6, 4]]\n assert candidate(mat = [[10, 20, 30, 40, 50, 60], [70, 80, 90, 100, 110, 120], [130, 140, 150, 160, 170, 180], [190, 200, 210, 220, 230, 240], [250, 260, 270, 280, 290, 300]],k = 2) == [[720, 1020, 1350, 1500, 1260, 990], [1320, 1840, 2400, 2600, 2160, 1680], [2100, 2900, 3750, 4000, 3300, 2550], [2040, 2800, 3600, 3800, 3120, 2400], [1800, 2460, 3150, 3300, 2700, 2070]]\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]],k = 2) == [[63, 90, 120, 102, 81], [114, 160, 210, 176, 138], [180, 250, 325, 270, 210], [174, 240, 310, 256, 198], [153, 210, 270, 222, 171]]\n assert candidate(mat = [[9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9]],k = 0) == [[9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9]]\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],k = 0) == [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]\n assert candidate(mat = [[5, 10, 15, 20], [25, 30, 35, 40], [45, 50, 55, 60], [65, 70, 75, 80]],k = 3) == [[680, 680, 680, 680], [680, 680, 680, 680], [680, 680, 680, 680], [680, 680, 680, 680]]\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [12, 14, 16, 18, 20]],k = 2) == [[60, 92, 130, 116, 96], [102, 152, 210, 184, 150], [102, 152, 210, 184, 150], [93, 136, 185, 160, 129]]\n assert candidate(mat = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]],k = 3) == [[64, 64, 64, 64], [64, 64, 64, 64], [64, 64, 64, 64], [64, 64, 64, 64]]\n assert candidate(mat = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],k = 1) == [[4, 4], [6, 6], [6, 6], [6, 6], [6, 6], [4, 4]]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 3) == [[16, 20, 24, 28, 28, 28, 24, 20, 16], [20, 25, 30, 35, 35, 35, 30, 25, 20], [24, 30, 36, 42, 42, 42, 36, 30, 24], [28, 35, 42, 49, 49, 49, 42, 35, 28], [28, 35, 42, 49, 49, 49, 42, 35, 28], [28, 35, 42, 49, 49, 49, 42, 35, 28], [24, 30, 36, 42, 42, 42, 36, 30, 24], [20, 25, 30, 35, 35, 35, 30, 25, 20], [16, 20, 24, 28, 28, 28, 24, 20, 16]]\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],k = 2) == [[9, 12, 12, 9], [12, 16, 16, 12], [15, 20, 20, 15], [12, 16, 16, 12], [9, 12, 12, 9]]\n assert candidate(mat = [[10, 20, 30, 40, 50, 60], [70, 80, 90, 100, 110, 120], [130, 140, 150, 160, 170, 180], [190, 200, 210, 220, 230, 240], [250, 260, 270, 280, 290, 300], [310, 320, 330, 340, 350, 360]],k = 1) == [[180, 300, 360, 420, 480, 340], [450, 720, 810, 900, 990, 690], [810, 1260, 1350, 1440, 1530, 1050], [1170, 1800, 1890, 1980, 2070, 1410], [1530, 2340, 2430, 2520, 2610, 1770], [1140, 1740, 1800, 1860, 1920, 1300]]\n assert candidate(mat = [[3, 0, 1, 4, 2], [5, 6, 3, 2, 1], [1, 2, 0, 1, 5], [4, 1, 0, 1, 7], [1, 0, 3, 0, 5]],k = 1) == [[14, 18, 16, 13, 9], [17, 21, 19, 19, 15], [19, 22, 16, 20, 17], [9, 12, 8, 22, 19], [6, 9, 5, 16, 13]]\n assert candidate(mat = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120], [130, 140, 150, 160]],k = 1) == [[140, 240, 300, 220], [330, 540, 630, 450], [570, 900, 990, 690], [460, 720, 780, 540]]\n assert candidate(mat = [[2, 1, 3, 4], [1, 2, 2, 1], [3, 3, 2, 4], [4, 1, 5, 4]],k = 1) == [[6, 11, 13, 10], [12, 19, 22, 16], [14, 23, 24, 18], [11, 18, 19, 15]]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],k = 3) == [[45, 45, 45], [45, 45, 45], [45, 45, 45]]\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8]],k = 0) == [[1, 2], [3, 4], [5, 6], [7, 8]]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],k = 1) == [[12, 21, 16], [27, 45, 33], [45, 72, 51], [63, 99, 69], [48, 75, 52]]\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]],k = 2) == [[63, 90, 120, 102, 81], [114, 160, 210, 176, 138], [180, 250, 325, 270, 210], [174, 240, 310, 256, 198], [153, 210, 270, 222, 171]]\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]],k = 1) == [[16, 27, 33, 39, 28], [39, 63, 72, 81, 57], [69, 108, 117, 126, 87], [99, 153, 162, 171, 117], [76, 117, 123, 129, 88]]\n assert candidate(mat = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]],k = 1) == [[20, 30, 30, 30, 20], [30, 45, 45, 45, 30], [30, 45, 45, 45, 30], [30, 45, 45, 45, 30], [20, 30, 30, 30, 20]]\n assert candidate(mat = [[1, 3, 1], [1, 5, 1], [4, 2, 4]],k = 2) == [[22, 22, 22], [22, 22, 22], [22, 22, 22]]\n assert candidate(mat = [[100, 200], [300, 400], [500, 600]],k = 1) == [[1000, 1000], [2100, 2100], [1800, 1800]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],k = 1) == [[26, 42, 48, 54, 60, 66, 72, 78, 84, 58], [69, 108, 117, 126, 135, 144, 153, 162, 171, 117], [66, 102, 108, 114, 120, 126, 132, 138, 144, 98]]\n assert candidate(mat = [[2, 4, 6, 8, 10], [12, 14, 16, 18, 20], [22, 24, 26, 28, 30], [32, 34, 36, 38, 40], [42, 44, 46, 48, 50]],k = 2) == [[126, 180, 240, 204, 162], [228, 320, 420, 352, 276], [360, 500, 650, 540, 420], [348, 480, 620, 512, 396], [306, 420, 540, 444, 342]]\n assert candidate(mat = [[100, 99, 98, 97, 96, 95], [94, 93, 92, 91, 90, 89], [88, 87, 86, 85, 84, 83], [82, 81, 80, 79, 78, 77], [76, 75, 74, 73, 72, 71]],k = 2) == [[837, 1110, 1380, 1365, 1086, 810], [1080, 1432, 1780, 1760, 1400, 1044], [1305, 1730, 2150, 2125, 1690, 1260], [1008, 1336, 1660, 1640, 1304, 972], [729, 966, 1200, 1185, 942, 702]]\n assert candidate(mat = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]],k = 2) == [[27, 42, 42, 36], [42, 64, 64, 54], [42, 64, 64, 54], [36, 54, 54, 45]]\n assert candidate(mat = [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5]],k = 1) == [[20, 30, 30, 30, 30, 20], [30, 45, 45, 45, 45, 30], [30, 45, 45, 45, 45, 30], [30, 45, 45, 45, 45, 30], [30, 45, 45, 45, 45, 30], [20, 30, 30, 30, 30, 20]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35]],k = 2) == [[81, 114, 150, 165, 180, 150, 117], [150, 208, 270, 290, 310, 256, 198], [240, 330, 425, 450, 475, 390, 300], [234, 320, 410, 430, 450, 368, 282], [207, 282, 360, 375, 390, 318, 243]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]],k = 3) == [[280, 360, 444, 532, 560, 588, 616, 540, 460, 376], [280, 360, 444, 532, 560, 588, 616, 540, 460, 376], [280, 360, 444, 532, 560, 588, 616, 540, 460, 376], [280, 360, 444, 532, 560, 588, 616, 540, 460, 376]]\n assert candidate(mat = [[5, 4, 3, 2, 1], [10, 9, 8, 7, 6], [15, 14, 13, 12, 11], [20, 19, 18, 17, 16], [25, 24, 23, 22, 21]],k = 2) == [[81, 102, 120, 90, 63], [138, 176, 210, 160, 114], [210, 270, 325, 250, 180], [198, 256, 310, 240, 174], [171, 222, 270, 210, 153]]\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],k = 3) == [[160, 210, 210, 210, 176], [160, 210, 210, 210, 176], [160, 210, 210, 210, 176], [160, 210, 210, 210, 176]]\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],k = 3) == [[16, 16, 16, 16], [16, 16, 16, 16], [16, 16, 16, 16], [16, 16, 16, 16]]\n assert candidate(mat = [[9, 2, 3, 4, 6], [7, 1, 8, 5, 3], [6, 5, 4, 7, 9], [2, 3, 1, 4, 5], [8, 6, 7, 2, 3]],k = 1) == [[19, 30, 23, 29, 18], [30, 45, 39, 49, 34], [24, 37, 38, 46, 33], [30, 42, 39, 42, 30], [19, 27, 23, 22, 14]]\n assert candidate(mat = [[5, 10, 15, 20], [25, 30, 35, 40], [45, 50, 55, 60]],k = 2) == [[270, 390, 390, 315], [270, 390, 390, 315], [270, 390, 390, 315]]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 3) == [[16, 20, 24, 28, 28, 28, 28, 24, 20, 16], [20, 25, 30, 35, 35, 35, 35, 30, 25, 20], [24, 30, 36, 42, 42, 42, 42, 36, 30, 24], [28, 35, 42, 49, 49, 49, 49, 42, 35, 28], [28, 35, 42, 49, 49, 49, 49, 42, 35, 28], [28, 35, 42, 49, 49, 49, 49, 42, 35, 28], [28, 35, 42, 49, 49, 49, 49, 42, 35, 28], [24, 30, 36, 42, 42, 42, 42, 36, 30, 24], [20, 25, 30, 35, 35, 35, 35, 30, 25, 20], [16, 20, 24, 28, 28, 28, 28, 24, 20, 16]]\n assert candidate(mat = [[3, 6, 9, 12, 15], [18, 21, 24, 27, 30], [33, 36, 39, 42, 45], [48, 51, 54, 57, 60], [63, 66, 69, 72, 75]],k = 1) == [[48, 81, 99, 117, 84], [117, 189, 216, 243, 171], [207, 324, 351, 378, 261], [297, 459, 486, 513, 351], [228, 351, 369, 387, 264]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24]],k = 2) == [[72, 102, 135, 150, 126, 99], [132, 184, 240, 260, 216, 168], [132, 184, 240, 260, 216, 168], [126, 174, 225, 240, 198, 153]]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 3) == [[16, 20, 24, 28, 28, 28, 28, 24, 20, 16], [20, 25, 30, 35, 35, 35, 35, 30, 25, 20], [20, 25, 30, 35, 35, 35, 35, 30, 25, 20], [20, 25, 30, 35, 35, 35, 35, 30, 25, 20], [16, 20, 24, 28, 28, 28, 28, 24, 20, 16]]\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 2) == [[9, 12, 15, 12, 9], [12, 16, 20, 16, 12], [15, 20, 25, 20, 15], [12, 16, 20, 16, 12], [9, 12, 15, 12, 9]]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],k = 0) == [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]\n assert candidate(mat = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120], [130, 140, 150, 160]],k = 1) == [[140, 240, 300, 220], [330, 540, 630, 450], [570, 900, 990, 690], [460, 720, 780, 540]]\n assert candidate(mat = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]],k = 0) == [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 7], [3, 4, 5, 6, 7, 8], [4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10], [6, 7, 8, 9, 10, 11]],k = 1) == [[8, 15, 21, 27, 33, 24], [15, 27, 36, 45, 54, 39], [21, 36, 45, 54, 63, 45], [27, 45, 54, 63, 72, 51], [33, 54, 63, 72, 81, 57], [24, 39, 45, 51, 57, 40]]\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11], [4, 6, 8, 10, 12], [5, 7, 9, 11, 13]],k = 3) == [[88, 130, 130, 130, 120], [120, 175, 175, 175, 160], [120, 175, 175, 175, 160], [120, 175, 175, 175, 160], [104, 150, 150, 150, 136]]\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 3) == [[16, 20, 20, 20, 16], [20, 25, 25, 25, 20], [20, 25, 25, 25, 20], [20, 25, 25, 25, 20], [16, 20, 20, 20, 16]]\n assert candidate(mat = [[100, 200, 300, 400, 500], [600, 700, 800, 900, 1000], [1100, 1200, 1300, 1400, 1500], [1600, 1700, 1800, 1900, 2000]],k = 3) == [[16000, 21000, 21000, 21000, 17600], [16000, 21000, 21000, 21000, 17600], [16000, 21000, 21000, 21000, 17600], [16000, 21000, 21000, 21000, 17600]]\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]],k = 1) == [[10, 10], [21, 21], [33, 33], [45, 45], [57, 57], [42, 42]]\n assert candidate(mat = [[1, 3, 5, 7], [9, 11, 13, 15], [17, 19, 21, 23], [25, 27, 29, 31]],k = 2) == [[99, 144, 144, 117], [180, 256, 256, 204], [180, 256, 256, 204], [171, 240, 240, 189]]\n assert candidate(mat = [[1, 3, 5, 7], [9, 11, 13, 15], [17, 19, 21, 23], [25, 27, 29, 31]],k = 1) == [[24, 42, 54, 40], [60, 99, 117, 84], [108, 171, 189, 132], [88, 138, 150, 104]]\n assert candidate(mat = [[5, 3, 2, 4, 1], [3, 7, 8, 6, 2], [9, 1, 0, 5, 7], [4, 6, 3, 8, 9], [0, 2, 5, 3, 1]],k = 1) == [[18, 28, 30, 23, 13], [28, 38, 36, 35, 25], [30, 41, 44, 48, 37], [22, 30, 33, 41, 33], [12, 20, 27, 29, 21]]\n assert candidate(mat = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65], [30, 40, 50, 60, 70]],k = 0) == [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65], [30, 40, 50, 60, 70]]\n assert candidate(mat = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],k = 3) == [[136, 136, 136, 136], [136, 136, 136, 136], [136, 136, 136, 136], [136, 136, 136, 136]]\n assert candidate(mat = [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5]],k = 1) == [[20, 30, 30, 30, 30, 20], [30, 45, 45, 45, 45, 30], [30, 45, 45, 45, 45, 30], [30, 45, 45, 45, 45, 30], [30, 45, 45, 45, 45, 30], [20, 30, 30, 30, 30, 20]]\n assert candidate(mat = [[9, 8, 7], [6, 5, 4], [3, 2, 1]],k = 2) == [[45, 45, 45], [45, 45, 45], [45, 45, 45]]\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],k = 1) == [[16, 27, 33, 39, 28], [39, 63, 72, 81, 57], [69, 108, 117, 126, 87], [56, 87, 93, 99, 68]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90], [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]],k = 4) == [[575, 705, 840, 980, 1125, 1170, 1060, 945, 825, 700], [840, 1026, 1218, 1416, 1620, 1674, 1512, 1344, 1170, 990], [1155, 1407, 1666, 1932, 2205, 2268, 2044, 1813, 1575, 1330], [1520, 1848, 2184, 2528, 2880, 2952, 2656, 2352, 2040, 1720], [1935, 2349, 2772, 3204, 3645, 3726, 3348, 2961, 2565, 2160], [2385, 2889, 3402, 3924, 4455, 4536, 4068, 3591, 3105, 2610], [2320, 2808, 3304, 3808, 4320, 4392, 3936, 3472, 3000, 2520], [2205, 2667, 3136, 3612, 4095, 4158, 3724, 3283, 2835, 2380], [2040, 2466, 2898, 3336, 3780, 3834, 3432, 3024, 2610, 2190], [1825, 2205, 2590, 2980, 3375, 3420, 3060, 2695, 2325, 1950]]\n assert candidate(mat = [[2, 4, 6, 8, 10], [12, 14, 16, 18, 20], [22, 24, 26, 28, 30], [32, 34, 36, 38, 40]],k = 2) == [[126, 180, 240, 204, 162], [228, 320, 420, 352, 276], [228, 320, 420, 352, 276], [216, 300, 390, 324, 252]]\n assert candidate(mat = [[3, 3, 3, 3], [3, 3, 3, 3], [3, 3, 3, 3], [3, 3, 3, 3]],k = 2) == [[27, 36, 36, 27], [36, 48, 48, 36], [36, 48, 48, 36], [27, 36, 36, 27]]\n assert candidate(mat = [[100, 200, 300], [400, 500, 600], [700, 800, 900], [1000, 1100, 1200], [1300, 1400, 1500]],k = 0) == [[100, 200, 300], [400, 500, 600], [700, 800, 900], [1000, 1100, 1200], [1300, 1400, 1500]]\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 2) == [[9, 12, 15, 12, 9], [12, 16, 20, 16, 12], [15, 20, 25, 20, 15], [12, 16, 20, 16, 12], [9, 12, 15, 12, 9]]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]],k = 2) == [[45, 45, 45], [78, 78, 78], [120, 120, 120], [165, 165, 165], [150, 150, 150], [126, 126, 126]]\n assert candidate(mat = [[2, 1, 3], [1, 1, 1], [3, 2, 1]],k = 2) == [[15, 15, 15], [15, 15, 15], [15, 15, 15]]\n assert candidate(mat = [[10, 20, 30, 40, 50], [60, 70, 80, 90, 100], [110, 120, 130, 140, 150], [160, 170, 180, 190, 200], [210, 220, 230, 240, 250]],k = 1) == [[160, 270, 330, 390, 280], [390, 630, 720, 810, 570], [690, 1080, 1170, 1260, 870], [990, 1530, 1620, 1710, 1170], [760, 1170, 1230, 1290, 880]]\n assert candidate(mat = [[100, 200, 300], [400, 500, 600], [700, 800, 900]],k = 1) == [[1200, 2100, 1600], [2700, 4500, 3300], [2400, 3900, 2800]]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],k = 1) == [[12, 21, 16], [27, 45, 33], [45, 72, 51], [36, 57, 40]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30]],k = 1) == [[18, 30, 36, 42, 48, 34], [45, 72, 81, 90, 99, 69], [81, 126, 135, 144, 153, 105], [117, 180, 189, 198, 207, 141], [90, 138, 144, 150, 156, 106]]\n assert candidate(mat = [[2, 3, 4], [5, 6, 7], [8, 9, 10], [11, 12, 13], [14, 15, 16]],k = 2) == [[54, 54, 54], [90, 90, 90], [135, 135, 135], [126, 126, 126], [108, 108, 108]]\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 0) == [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 1) == [[4, 6, 6, 6, 4], [6, 9, 9, 9, 6], [6, 9, 9, 9, 6], [6, 9, 9, 9, 6], [4, 6, 6, 6, 4]]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]],k = 1) == [[12, 21, 16], [27, 45, 33], [45, 72, 51], [63, 99, 69], [81, 126, 87], [60, 93, 64]]\n assert candidate(mat = [[2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13], [14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25], [26, 27, 28, 29, 30, 31], [32, 33, 34, 35, 36, 37]],k = 2) == [[81, 114, 150, 165, 138, 108], [144, 200, 260, 280, 232, 180], [225, 310, 400, 425, 350, 270], [315, 430, 550, 575, 470, 360], [288, 392, 500, 520, 424, 324], [243, 330, 420, 435, 354, 270]]\n assert candidate(mat = [[3, 0, 1, 4, 2], [5, 6, 3, 2, 1], [1, 2, 0, 1, 5], [4, 1, 0, 1, 7], [1, 0, 3, 0, 5]],k = 2) == [[21, 28, 36, 27, 19], [26, 34, 49, 36, 27], [30, 38, 58, 44, 35], [26, 30, 48, 37, 28], [12, 14, 31, 25, 22]]\n assert candidate(mat = [[20, 30, 40, 50, 60], [70, 80, 90, 100, 110], [120, 130, 140, 150, 160], [170, 180, 190, 200, 210], [220, 230, 240, 250, 260]],k = 2) == [[720, 1020, 1350, 1140, 900], [1260, 1760, 2300, 1920, 1500], [1950, 2700, 3500, 2900, 2250], [1860, 2560, 3300, 2720, 2100], [1620, 2220, 2850, 2340, 1800]]\n assert candidate(mat = [[5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5]],k = 2) == [[45, 60, 75, 75, 75, 60, 45], [60, 80, 100, 100, 100, 80, 60], [60, 80, 100, 100, 100, 80, 60], [45, 60, 75, 75, 75, 60, 45]]\n"}, "metadata": {"canonical_parameter_names": ["mat", "k"], "leetcode_dataset_entry_point": "Solution().matrixBlockSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector> matrixBlockSum(vector>& mat, int k) {", "container": "Solution", "callable": "matrixBlockSum", "parameters": [{"name": "mat", "type": "vector>&"}, {"name": "k", "type": "int"}], "return_type": "vector>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1315, "task_id": "sum-of-nodes-with-even-valued-grandparent", "difficulty": "Medium", "problem_description": "Given the root of a binary tree, return the sum of values of nodes with an even-valued grandparent. If there are no nodes with an even-valued grandparent, return 0.\nA grandparent of a node is the parent of its parent if it exists.\n \nExample 1:\n\n\nInput: root = [6,7,8,2,7,1,3,9,null,1,4,null,null,null,5]\nOutput: 18\nExplanation: The red nodes are the nodes with even-value grandparent while the blue nodes are the even-value grandparents.\n\nExample 2:\n\n\nInput: root = [1]\nOutput: 0\n\n \nConstraints:\n\nThe number of nodes in the tree is in the range [1, 104].\n1 <= Node.val <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([8, 4, 5, 0, 1, None, None, None, None, 7])) == 8\n assert candidate(root = tree_node([4, 2, 7, 1, 3, 6, 9, 8, None, None, None, None, 5])) == 27\n assert candidate(root = tree_node([4, 2, 5, 1, 3, None, 7, None, None, None, None, None, 9])) == 11\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == 38\n assert candidate(root = tree_node([2, 1, 3, None, None, 4, None, None, None, 5])) == 4\n assert candidate(root = tree_node([5, 14, 3, None, 10, None, 7])) == 0\n assert candidate(root = tree_node([2, 1, 3, None, None, 4, 5, 6, 7])) == 9\n assert candidate(root = tree_node([5, 3, 1, 4, None, 2, 6, 8, None, None, None, None, 7])) == 0\n assert candidate(root = tree_node([2, None, 3, None, 4, None, 5])) == 4\n assert candidate(root = tree_node([11, 10, 12, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == 15\n assert candidate(root = tree_node([6, 7, 8, 2, 7, 1, 3, 9, None, 1, 4, None, None, None, 5])) == 18\n assert candidate(root = tree_node([4, 2, 7, 1, 3, 6, 9])) == 19\n assert candidate(root = tree_node([6, 11, 1, None, None, 2, None, None, 3, None, None, 4, None, None, 5, None, None, 6, None, None, 7, None, None, 8, None, None, 9, None, None, 10, None, None, 11, None, None, 12, None, None, 13, None, None, 14, None, None, 15, None, None, 16, None, None, 17, None, None, 18, None, None, 19, None, None, 20, None, None, 21, None, None, 22, None, None, 23, None, None, 24, None, None, 25, None, None, 26, None, None, 27, None, None, 28, None, None, 29, None, None, 30])) == 2\n assert candidate(root = tree_node([1])) == 0\n assert candidate(root = tree_node([2, 3, 4, 5, 6, 7, 8])) == 26\n assert candidate(root = tree_node([5, 3, 7, 2, 4, 6, 8, 1, None, None, None, None, None, None, 9])) == 0\n assert candidate(root = tree_node([3, None, 9, 6, None, 10, 11, 2, None, None, None, 8, None, 7])) == 17\n assert candidate(root = tree_node([3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45])) == 114\n assert candidate(root = tree_node([6, 3, 8, 1, 4, 7, 9, 0, 5, None, None, None, 10, None, None, None, None, 11, None, None, 12])) == 31\n assert candidate(root = tree_node([24, 12, 16, 6, 10, 8, 20, 3, 9, 7, 11, 5, 15, 1, 13, None, None, None, None, None, None, None, None, None, 4, None, None, None, 14, 17, 18, 19, None, 21, 22, 23])) == 161\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 40, 60, 90, 110, 140, 160, 190, 5, 15, 30, 45, 55, 65, 80, 100, 115, 130, 135, 155, 165, 180, 195])) == 1200\n assert candidate(root = tree_node([18, 4, 5, 2, 9, 10, 6, None, None, 1, 3, None, None, 7, 8, None, None, 11, 12, 13, 14, 15, 16, 17])) == 89\n assert candidate(root = tree_node([20, 12, 13, 8, 11, 14, 15, None, None, None, 10, None, 9, 16, 17, 18, 19, None, None, None, None, 21, 22, None, 23])) == 81\n assert candidate(root = tree_node([8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15])) == 96\n assert candidate(root = tree_node([5, 3, 1, 6, 2, None, 8, 4, None, None, None, 7, 9])) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100])) == 2568\n assert candidate(root = tree_node([16, 12, 20, 8, 14, 18, 22, 4, 10, 13, 15, 17, 19, 21, 23])) == 184\n assert candidate(root = tree_node([2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32])) == 296\n assert candidate(root = tree_node([14, 11, 8, 6, 12, 9, 5, 2, 4, 13, 7, 3, 10, None, None, None, None, None, None, None, 1, None, None, 15, 16, 17, None, None, None, None, 18, 19, 20, 21])) == 67\n assert candidate(root = tree_node([30, 15, 45, 10, 20, 40, 50, 5, 12, 18, 22, 35, 42, 48, 55, 3, 7, 9, 11, 13, 17, 19, 21, 23, 37, 38, 41, 43, 47, 49, 53, 57, 59])) == 551\n assert candidate(root = tree_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150])) == 1140\n assert candidate(root = tree_node([13, 11, 17, 7, 3, 16, 20, 1, 5, 9, 15, 12, None, None, None, 4, 6, 8, 10, 14, None, 18, 19, 21, 2, None, None, None, None, None, None, None, None, None, None, None])) == 23\n assert candidate(root = tree_node([14, 7, 27, 4, 9, 20, 35, 2, 6, 8, 11, 16, 22, 29, 42])) == 68\n assert candidate(root = tree_node([18, 9, 21, 15, 5, 10, 3, 7, None, 6, None, 8, 2, None, 4, None, None, 1, None, None, None, 11])) == 44\n assert candidate(root = tree_node([10, 5, None, 3, 7, None, None, 2, None, 6, 8, 1, None, None, None, 4, 9, 10, None, None, None, None, 11, 12, 13, 14, 15])) == 60\n assert candidate(root = tree_node([50, 25, 75, 12, 37, 63, 90, 6, 20, 30, 40, 55, 65, 85, 95])) == 202\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 1, 7, 9, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, 39, 41, 43, 45, 47, 49])) == 178\n assert candidate(root = tree_node([6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6])) == 666\n assert candidate(root = tree_node([6, 10, 14, 4, 8, 12, 16, 2, 6, 10, 14, 18, 22, 26, 30, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31])) == 424\n assert candidate(root = tree_node([22, 6, 18, 2, 14, 16, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41])) == 493\n assert candidate(root = tree_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30])) == 228\n assert candidate(root = tree_node([18, 3, 20, None, 5, 15, 25, None, None, None, None, 13, None, 22])) == 58\n assert candidate(root = tree_node([6, 2, 12, 1, 5, 9, 15, 0, None, None, 3, 7, 11, 13, 19, None, None, None, 4, 6, 8, 10, 12, 14, 16, 18, 20])) == 83\n assert candidate(root = tree_node([25, 15, 35, 10, 20, 30, 40, 5, 11, 16, 24, 29, 31, 34, 41])) == 0\n assert candidate(root = tree_node([10, 4, 6, 8, 2, None, 5, None, None, None, None, 1, 3, 7, 9, 11, 13, 15, 17, 19])) == 19\n assert candidate(root = tree_node([6, 2, 8, 0, 4, 7, 9, None, None, 3, 5])) == 28\n assert candidate(root = tree_node([5, 3, 8, 2, 4, 7, 9, None, None, 6, None, None, None, None, 10])) == 10\n assert candidate(root = tree_node([30, 10, 50, 5, 15, 40, 60, 3, 7, 13, 17, 35, 45, 55, 65])) == 360\n assert candidate(root = tree_node([32, 16, 48, 8, 24, 36, 56, 4, 12, 20, 28, 32, 40, 52, 60])) == 372\n assert candidate(root = tree_node([8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15])) == 96\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 190, 5, 15, 22, 35, 55, 65, 72, 78, 85, 95, 105, 135, 137, 145, 155, 172, 180, 195, 200])) == 1755\n assert candidate(root = tree_node([8, 3, 6, 1, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16])) == 74\n assert candidate(root = tree_node([40, 20, 60, 10, 30, 50, 70, 5, 15, 25, 35, 45, 55, 65, 75])) == 480\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, None, None, 6])) == 28\n assert candidate(root = tree_node([15, 5, 6, 3, 1, None, None, 2, 4, None, None, None, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])) == 279\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 20, 2, 4, 6, 8, 11, 13, 18, 22])) == 42\n assert candidate(root = tree_node([8, 6, 5, 2, 4, 9, 7, None, None, 1, None, None, 3, 10, None, None, 11, 12, 13, None, None, 14, 15, None, 16])) == 34\n assert candidate(root = tree_node([3, 9, 20, None, None, 15, 7, None, None, 25, 35, None, None, 45, 55])) == 60\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, None, None, 30, 60, 90, 110, 140, 180, 20, 40, 55, 65, 85, 95, 105, 115, 130, 145, 160, 185, 195, None, None, 22, 28, 35, 45, 58, 68, 72, 82, 92, 102, 112, 118, 128, 135, 148, 155, 165, 175, 188, 198])) == 3331\n assert candidate(root = tree_node([50, 25, 75, 10, 40, 60, 90, 5, 15, 30, 45, 55, 65, 70, 100, 2, 6, 12, 20, 35, 43, 53, 57, 63, 67, 73, 77, 85, 95, 105])) == 993\n assert candidate(root = tree_node([10, 4, 15, 1, None, 11, 19, 6, None, None, 12, None, None, 5])) == 37\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 13, 17, 23, 27, 33, 37, 1, 4, 6, 8, 12, 14, 16, 18, 22, 24, 26, 28, 32, 34, 36, 38, 39])) == 240\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])) == 210\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 2, 7, 13, 18, 23, 28, 33, 38])) == 242\n assert candidate(root = tree_node([8, 5, 10, 3, 6, None, 11, 1, None, 4, 7, None, 14])) == 34\n assert candidate(root = tree_node([4, 2, 7, 1, 3, 6, 9, 9, None, 1, 4, None, None, None, 5, 6, None, None, 8, 10])) == 33\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 1, 3, 7, 13, 19, 23, 29, 37])) == 212\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 20, 1, 4, 6, 8, 11, 14, 17, 22, 0, None, None, None, None, None, None, 9, None, None, 13, None, None, 16, None, None, 18, None, None, 21, None, None])) == 92\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == 108\n assert candidate(root = tree_node([22, 11, 44, 7, 33, 55, 66, 1, 5, 9, 27, 50, 70, 100, 200])) == 581\n assert candidate(root = tree_node([2, 1, 5, 2, 3, 4, 8, 5, 6, 7, 9, 10, 11, 12, 13])) == 17\n assert candidate(root = tree_node([6, 2, 10, 1, 3, 7, 13, None, 4, None, 5, 8, 12, 14, 16])) == 83\n assert candidate(root = tree_node([46, 23, 69, 11, 35, 55, 82, 5, 19, 30, 40, 50, 60, 70, 80, 2, 7, 14, 21, 27, 32, 39, 45, 47, 53, 57, 61, 67, 73, 77, 81, 1, 3, 8, 12, 20, 26, 31, 37, 43, 49, 52, 58, 62, 66, 72, 76, 83, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None])) == 1042\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == 108\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 40, 60, 90, 110, 140, 160, 190])) == 1200\n assert candidate(root = tree_node([32, 16, 48, 8, 24, 36, 60, 4, 12, 20, 28, 32, 44, 52, 56, 2, 6, 10, 14, 18, 22, 26, 30, 34, 46, 50, 54, 58, None, None, 3, None, None, None, None, None, None, None, None, None, None, None, None, None, 7, None, None, None, 11, None, None, None, None, None, None, None, None, None, 15, None, None, None, None, None, None, None, None, None, 19, None, None, None, None, None, None, None, None, None])) == 782\n assert candidate(root = tree_node([4, 2, 5, 1, 3, None, 6, 0, 8, None, None, 7, 9])) == 18\n assert candidate(root = tree_node([17, 5, 10, None, None, 8, 9, None, None, 3, None, None, 13])) == 3\n assert candidate(root = tree_node([50, 25, 75, 12, 37, 60, 82, 6, 20, None, 40, 55, 70, 10, 5, 15, 30, 45, 65, 77, None, None, None, None, 58])) == 404\n assert candidate(root = tree_node([16, 8, 24, 4, 12, 20, 28, 2, 6, 10, 14, 18, 22, 26, 30])) == 192\n assert candidate(root = tree_node([24, 12, 25, 6, 18, 21, 29, 3, 9, 15, None, 19, 23, 27, 31, 1, 5, 7, 11, 13, None, 17, None, None, 22, None, 26, None, 30, 2, 4, 8, 10, 14, 16, None, None, None, None, None, 20, None, None, 25, None, None, 28, None, None, 32])) == 138\n assert candidate(root = tree_node([6, 7, 8, 2, 7, 1, 3, 9, None, 1, 4, None, None, None, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == 31\n assert candidate(root = tree_node([2, 1, 3, None, None, 4, None, None, None, 5, None, None, None, 6, None, None, None, 7, None, None, None, 8, None, None, None, 9, None, None, None, 10])) == 4\n assert candidate(root = tree_node([6, 7, 8, 2, 7, 1, 3, 9, None, 1, 4, 8, None, None, None, 5, 6, 7])) == 32\n assert candidate(root = tree_node([14, 8, 22, 4, 12, 16, 28, 2, 6, 10, 14, 18, 22, 26, 30])) == 188\n assert candidate(root = tree_node([7, 5, 9, 3, 6, 8, 10, 2, 4, None, None, None, None, None, None])) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == 38\n assert candidate(root = tree_node([22, 17, 30, 10, 21, 28, 32, 5, 14, 19, 29, None, 35, 3, None, None, 12, None, 18, None, None, None, None, None, 24, 26, 31, 33, 36])) == 240\n"}, "metadata": {"canonical_parameter_names": ["root"], "leetcode_dataset_entry_point": "Solution().sumEvenGrandparent", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int sumEvenGrandparent(TreeNode* root) {", "container": "Solution", "callable": "sumEvenGrandparent", "parameters": [{"name": "root", "type": "TreeNode*"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1316, "task_id": "distinct-echo-substrings", "difficulty": "Hard", "problem_description": "Return the number of distinct non-empty substrings of text that can be written as the concatenation of some string with itself (i.e. it can be written as a + a where a is some string).\n \nExample 1:\n\nInput: text = \"abcabcabc\"\nOutput: 3\nExplanation: The 3 substrings are \"abcabc\", \"bcabca\" and \"cabcab\".\n\nExample 2:\n\nInput: text = \"leetcodeleetcode\"\nOutput: 2\nExplanation: The 2 substrings are \"ee\" and \"leetcodeleetcode\".\n\n \nConstraints:\n\n1 <= text.length <= 2000\ntext has only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(text = \"ababab\") == 2\n assert candidate(text = \"\") == 0\n assert candidate(text = \"abcabcabc\") == 3\n assert candidate(text = \"aaaa\") == 2\n assert candidate(text = \"ab\") == 0\n assert candidate(text = \"abbbabbb\") == 2\n assert candidate(text = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 51\n assert candidate(text = \"abcd\") == 0\n assert candidate(text = \"abacaba\") == 0\n assert candidate(text = \"abc\") == 0\n assert candidate(text = \"leetcodeleetcode\") == 2\n assert candidate(text = \"banana\") == 2\n assert candidate(text = \"xyzxyzxyzxyz\") == 4\n assert candidate(text = \"abcdefg\") == 0\n assert candidate(text = \"racecar racecar\") == 0\n assert candidate(text = \"a\") == 0\n assert candidate(text = \"abababab\") == 3\n assert candidate(text = \"aabbccddeeff\") == 6\n assert candidate(text = \"mississippi\") == 4\n assert candidate(text = \"ababababab\") == 4\n assert candidate(text = \"xyxyxyxyxyxyxyxyxyxyxyxy\") == 11\n assert candidate(text = \"abacaxiabacaxiabacaxi\") == 7\n assert candidate(text = \"abcabcabcabcabcabcabc\") == 9\n assert candidate(text = \"abcdeabcdeabcdeabcde\") == 6\n assert candidate(text = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 33\n assert candidate(text = \"repeatedrepeatedrepeatedrepeated\") == 9\n assert candidate(text = \"tattattattattattat\") == 8\n assert candidate(text = \"aaaaabaaaabaaaa\") == 7\n assert candidate(text = \"racecaracecaracecar\") == 6\n assert candidate(text = \"abcababcababcab\") == 6\n assert candidate(text = \"aabbccddeeffaabbccddeeff\") == 7\n assert candidate(text = \"xyxyxyxyxyxyxyxyxyxyxy\") == 10\n assert candidate(text = \"abacabaabacaba\") == 3\n assert candidate(text = \"leetcodeleetcodeleetcodeleetcode\") == 10\n assert candidate(text = \"thisisaverylongstringthatrepeatstitselfthisisaverylongstringthatrepeatstitself\") == 2\n assert candidate(text = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 26\n assert candidate(text = \"aaaabaaaab\") == 3\n assert candidate(text = \"abcabcabcabcabcabc\") == 7\n assert candidate(text = \"aaaaaaa\") == 3\n assert candidate(text = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 20\n assert candidate(text = \"abababababab\") == 5\n assert candidate(text = \"aaaaabcabcabcabcabc\") == 8\n assert candidate(text = \"qwertyqwertyqwerty\") == 6\n assert candidate(text = \"aabbccddeeffaabbccddeeffaabbccddeeff\") == 18\n assert candidate(text = \"xyzxyzxyzxyzxyzxyz\") == 7\n assert candidate(text = \"aabbaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 27\n assert candidate(text = \"abababababababababababababababababababababababababababababababababab\") == 33\n assert candidate(text = \"leetcodeisgoodandleetcodeisgood\") == 2\n assert candidate(text = \"supercalifragilisticexpialidocioussupercalifragilisticexpialidocious\") == 2\n assert candidate(text = \"abacabacabacabac\") == 5\n assert candidate(text = \"patternpatternpatternpattern\") == 9\n assert candidate(text = \"mississippimississippi\") == 5\n assert candidate(text = \"abcdabcdabcdabcd\") == 5\n assert candidate(text = \"zxcvbnmlkjhgfdsazxcvbnmlkjhgfdsa\") == 1\n assert candidate(text = \"abcdefgabcdefgabcdefg\") == 7\n assert candidate(text = \"abracadabraabracadabra\") == 3\n assert candidate(text = \"hellohellohellohellohello\") == 11\n assert candidate(text = \"zzzzzzzzzzzzzzzzzzzz\") == 10\n assert candidate(text = \"zzzzzzzzzzzzzzzz\") == 8\n assert candidate(text = \"abababa\") == 2\n assert candidate(text = \"ababababababab\") == 6\n assert candidate(text = \"aaaaaaaaaa\") == 5\n assert candidate(text = \"abcdabcdeabcd\") == 1\n assert candidate(text = \"racecar\") == 0\n assert candidate(text = \"abcdefghabcdefgh\") == 1\n assert candidate(text = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\") == 32\n assert candidate(text = \"xyzxyzxyzxyzxyzxyzxyzxyz\") == 10\n assert candidate(text = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 30\n assert candidate(text = \"abcabcabcabc\") == 4\n assert candidate(text = \"abcdefghijabcdefghijabcdefghij\") == 10\n assert candidate(text = \"pneumonoultramicroscopicsilicovolcanoconiosis\") == 0\n assert candidate(text = \"aaaaa\") == 2\n assert candidate(text = \"abracadabrabracadabra\") == 4\n assert candidate(text = \"aaaaaa\") == 3\n assert candidate(text = \"abacabadabacabadabacaba\") == 8\n assert candidate(text = \"aaaaabbbbbaaaaabbbbb\") == 5\n assert candidate(text = \"noonnoonnoonnoon\") == 7\n assert candidate(text = \"abacabadabacaba\") == 0\n assert candidate(text = \"xyxyxyxyxyxyxyxy\") == 7\n assert candidate(text = \"abracadabraabracadabraabracadabraabracadabraabracadabraabracadabra\") == 25\n assert candidate(text = \"abcabcabcabcabc\") == 6\n assert candidate(text = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 43\n assert candidate(text = \"abababababababab\") == 7\n assert candidate(text = \"aaaaaaaaaabaaaaaaaaaa\") == 5\n assert candidate(text = \"aaaabbbbcccc\") == 6\n assert candidate(text = \"noonnoonnoonnoonnoon\") == 10\n assert candidate(text = \"abcxyzabcxyzabcxyz\") == 6\n assert candidate(text = \"abcabca\") == 2\n assert candidate(text = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == 52\n assert candidate(text = \"uniqueuniqueuniqueunique\") == 7\n assert candidate(text = \"racecaracecar\") == 2\n assert candidate(text = \"abcdefabcdefabcdef\") == 6\n assert candidate(text = \"bananabananaananabanana\") == 7\n assert candidate(text = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 32\n assert candidate(text = \"bananaabanana\") == 3\n assert candidate(text = \"aaaabbbbccccddddeeeeffff\") == 12\n assert candidate(text = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 27\n assert candidate(text = \"hellohellohellohellohellohellohellohellohellohello\") == 22\n"}, "metadata": {"canonical_parameter_names": ["text"], "leetcode_dataset_entry_point": "Solution().distinctEchoSubstrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int distinctEchoSubstrings(string text) {", "container": "Solution", "callable": "distinctEchoSubstrings", "parameters": [{"name": "text", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1317, "task_id": "convert-integer-to-the-sum-of-two-no-zero-integers", "difficulty": "Easy", "problem_description": "No-Zero integer is a positive integer that does not contain any 0 in its decimal representation.\nGiven an integer n, return a list of two integers [a, b] where:\n\na and b are No-Zero integers.\na + b = n\n\nThe test cases are generated so that there is at least one valid solution. If there are many valid solutions, you can return any of them.\n \nExample 1:\n\nInput: n = 2\nOutput: [1,1]\nExplanation: Let a = 1 and b = 1.\nBoth a and b are no-zero integers, and a + b = 2 = n.\n\nExample 2:\n\nInput: n = 11\nOutput: [2,9]\nExplanation: Let a = 2 and b = 9.\nBoth a and b are no-zero integers, and a + b = 11 = n.\nNote that there are other valid answers as [8, 3] that can be accepted.\n\n \nConstraints:\n\n2 <= n <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 101) == [2, 99]\n assert candidate(n = 1010) == [11, 999]\n assert candidate(n = 11) == [2, 9]\n assert candidate(n = 104) == [5, 99]\n assert candidate(n = 1001) == [2, 999]\n assert candidate(n = 2) == [1, 1]\n assert candidate(n = 9999) == [1, 9998]\n assert candidate(n = 100) == [1, 99]\n assert candidate(n = 210) == [11, 199]\n assert candidate(n = 9801) == [2, 9799]\n assert candidate(n = 2345) == [1, 2344]\n assert candidate(n = 2100) == [111, 1989]\n assert candidate(n = 1111) == [112, 999]\n assert candidate(n = 10606) == [611, 9995]\n assert candidate(n = 8888) == [1, 8887]\n assert candidate(n = 1000) == [1, 999]\n assert candidate(n = 43) == [1, 42]\n assert candidate(n = 10202) == [211, 9991]\n assert candidate(n = 1357) == [1, 1356]\n assert candidate(n = 10001) == [2, 9999]\n assert candidate(n = 32109) == [111, 31998]\n assert candidate(n = 6789) == [1, 6788]\n assert candidate(n = 6005) == [6, 5999]\n assert candidate(n = 8181) == [2, 8179]\n assert candidate(n = 2468) == [1, 2467]\n assert candidate(n = 2048) == [49, 1999]\n assert candidate(n = 999) == [1, 998]\n assert candidate(n = 3030) == [31, 2999]\n assert candidate(n = 9012) == [13, 8999]\n assert candidate(n = 87654) == [1, 87653]\n assert candidate(n = 43210) == [11, 43199]\n assert candidate(n = 54321) == [2, 54319]\n assert candidate(n = 9090) == [91, 8999]\n assert candidate(n = 65) == [1, 64]\n assert candidate(n = 12345) == [1, 12344]\n assert candidate(n = 21) == [2, 19]\n assert candidate(n = 432) == [1, 431]\n assert candidate(n = 543) == [1, 542]\n assert candidate(n = 87) == [1, 86]\n assert candidate(n = 98) == [1, 97]\n assert candidate(n = 10303) == [311, 9992]\n assert candidate(n = 2023) == [24, 1999]\n assert candidate(n = 10505) == [511, 9994]\n assert candidate(n = 65432) == [1, 65431]\n assert candidate(n = 9998) == [1, 9997]\n assert candidate(n = 7007) == [8, 6999]\n assert candidate(n = 10101) == [112, 9989]\n assert candidate(n = 7070) == [71, 6999]\n assert candidate(n = 6543) == [1, 6542]\n assert candidate(n = 10404) == [411, 9993]\n assert candidate(n = 7777) == [1, 7776]\n assert candidate(n = 8080) == [81, 7999]\n assert candidate(n = 4999) == [1, 4998]\n assert candidate(n = 98765) == [1, 98764]\n assert candidate(n = 9876) == [1, 9875]\n assert candidate(n = 987) == [1, 986]\n assert candidate(n = 76543) == [1, 76542]\n assert candidate(n = 8901) == [2, 8899]\n assert candidate(n = 5678) == [1, 5677]\n assert candidate(n = 67890) == [1, 67889]\n assert candidate(n = 4004) == [5, 3999]\n assert candidate(n = 2000) == [1, 1999]\n assert candidate(n = 4567) == [1, 4566]\n assert candidate(n = 6006) == [7, 5999]\n assert candidate(n = 8008) == [9, 7999]\n assert candidate(n = 6666) == [1, 6665]\n assert candidate(n = 76) == [1, 75]\n assert candidate(n = 4680) == [1, 4679]\n assert candidate(n = 765) == [1, 764]\n assert candidate(n = 2020) == [21, 1999]\n assert candidate(n = 3050) == [51, 2999]\n assert candidate(n = 32) == [1, 31]\n assert candidate(n = 1023) == [24, 999]\n assert candidate(n = 7890) == [1, 7889]\n assert candidate(n = 90123) == [124, 89999]\n assert candidate(n = 7654) == [1, 7653]\n assert candidate(n = 876) == [1, 875]\n assert candidate(n = 7006) == [7, 6999]\n assert candidate(n = 21098) == [1111, 19987]\n assert candidate(n = 5050) == [51, 4999]\n assert candidate(n = 5002) == [3, 4999]\n assert candidate(n = 9997) == [1, 9996]\n assert candidate(n = 3003) == [4, 2999]\n assert candidate(n = 8765) == [1, 8764]\n assert candidate(n = 10987) == [988, 9999]\n assert candidate(n = 321) == [2, 319]\n assert candidate(n = 23456) == [1, 23455]\n assert candidate(n = 56789) == [1, 56788]\n assert candidate(n = 89012) == [13, 88999]\n assert candidate(n = 3333) == [1, 3332]\n assert candidate(n = 3456) == [1, 3455]\n assert candidate(n = 1098) == [99, 999]\n assert candidate(n = 10000) == [1, 9999]\n assert candidate(n = 5432) == [1, 5431]\n assert candidate(n = 2109) == [111, 1998]\n assert candidate(n = 54) == [1, 53]\n assert candidate(n = 654) == [1, 653]\n assert candidate(n = 8642) == [1, 8641]\n assert candidate(n = 5555) == [1, 5554]\n assert candidate(n = 3210) == [11, 3199]\n assert candidate(n = 9009) == [11, 8998]\n assert candidate(n = 6060) == [61, 5999]\n assert candidate(n = 5005) == [6, 4999]\n assert candidate(n = 4444) == [1, 4443]\n assert candidate(n = 4321) == [2, 4319]\n assert candidate(n = 34567) == [1, 34566]\n assert candidate(n = 2222) == [1, 2221]\n assert candidate(n = 6234) == [1, 6233]\n assert candidate(n = 10707) == [711, 9996]\n assert candidate(n = 109) == [11, 98]\n assert candidate(n = 4040) == [41, 3999]\n assert candidate(n = 1234) == [1, 1233]\n assert candidate(n = 7272) == [1, 7271]\n assert candidate(n = 45678) == [1, 45677]\n assert candidate(n = 78901) == [2, 78899]\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().getNoZeroIntegers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector getNoZeroIntegers(int n) {", "container": "Solution", "callable": "getNoZeroIntegers", "parameters": [{"name": "n", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1318, "task_id": "minimum-flips-to-make-a-or-b-equal-to-c", "difficulty": "Medium", "problem_description": "Given 3 positives numbers a, b and c. Return the minimum flips required in some bits of a and b to make ( a OR b == c ). (bitwise OR operation).\\r\nFlip operation consists of change any single bit 1 to 0 or change the bit 0 to 1 in their binary representation.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\n\\r\n\\r\nInput: a = 2, b = 6, c = 5\\r\nOutput: 3\\r\nExplanation: After flips a = 1 , b = 4 , c = 5 such that (a OR b == c)\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: a = 4, b = 2, c = 7\\r\nOutput: 1\\r\n\\r\n\\r\nExample 3:\\r\n\\r\n\\r\nInput: a = 1, b = 2, c = 3\\r\nOutput: 0\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= a <= 10^9\\r\n\t1 <= b <= 10^9\\r\n\t1 <= c <= 10^9\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(a = 10,b = 15,c = 25) == 4\n assert candidate(a = 2,b = 6,c = 5) == 3\n assert candidate(a = 1,b = 2,c = 3) == 0\n assert candidate(a = 8,b = 3,c = 11) == 0\n assert candidate(a = 4,b = 2,c = 7) == 1\n assert candidate(a = 1000000000,b = 1000000000,c = 1) == 27\n assert candidate(a = 123,b = 456,c = 789) == 9\n assert candidate(a = 1000000007,b = 1000000009,c = 1000000011) == 1\n assert candidate(a = 8388607,b = 16777215,c = 16777215) == 0\n assert candidate(a = 65535,b = 65535,c = 65535) == 0\n assert candidate(a = 987654321,b = 123456789,c = 864197532) == 20\n assert candidate(a = 123456789,b = 987654321,c = 135792468) == 25\n assert candidate(a = 1048575,b = 2097151,c = 3145727) == 2\n assert candidate(a = 123456789,b = 987654321,c = 1234567890) == 26\n assert candidate(a = 255,b = 128,c = 254) == 1\n assert candidate(a = 894967295,b = 1073741823,c = 2147483647) == 1\n assert candidate(a = 255,b = 255,c = 0) == 16\n assert candidate(a = 16777215,b = 33554431,c = 67108863) == 1\n assert candidate(a = 1023,b = 511,c = 1535) == 2\n assert candidate(a = 1023,b = 2047,c = 3071) == 2\n assert candidate(a = 1073741824,b = 536870912,c = 1610612736) == 0\n assert candidate(a = 255,b = 128,c = 383) == 3\n assert candidate(a = 987654,b = 321456,c = 654321) == 9\n assert candidate(a = 987654321,b = 348712387,c = 1) == 30\n assert candidate(a = 2147483647,b = 0,c = 2147483647) == 0\n assert candidate(a = 777,b = 888,c = 999) == 6\n assert candidate(a = 123456789,b = 987654321,c = 999999999) == 10\n assert candidate(a = 134217728,b = 67108864,c = 201326592) == 0\n assert candidate(a = 15,b = 30,c = 45) == 4\n assert candidate(a = 1023,b = 512,c = 1024) == 12\n assert candidate(a = 123456789,b = 987654321,c = 1000000000) == 16\n assert candidate(a = 123456789,b = 987654321,c = 987654321) == 7\n assert candidate(a = 134217727,b = 67108863,c = 201326592) == 53\n assert candidate(a = 1000000000,b = 1,c = 1000000001) == 0\n assert candidate(a = 32,b = 16,c = 48) == 0\n assert candidate(a = 14,b = 28,c = 42) == 4\n assert candidate(a = 8,b = 3,c = 15) == 1\n assert candidate(a = 999,b = 888,c = 777) == 8\n assert candidate(a = 2147483647,b = 2147483647,c = 0) == 62\n assert candidate(a = 1000000,b = 999999,c = 1000001) == 5\n assert candidate(a = 1073741823,b = 536870912,c = 805306368) == 28\n assert candidate(a = 8,b = 16,c = 24) == 0\n assert candidate(a = 1048575,b = 524287,c = 1572863) == 2\n assert candidate(a = 1000000000,b = 999999999,c = 1000000000) == 9\n assert candidate(a = 2147483647,b = 2147483647,c = 1) == 60\n assert candidate(a = 1000000000,b = 500000000,c = 1000000001) == 8\n assert candidate(a = 1023,b = 512,c = 768) == 8\n assert candidate(a = 134217727,b = 268435455,c = 335544319) == 4\n assert candidate(a = 897,b = 564,c = 231) == 6\n assert candidate(a = 511,b = 255,c = 127) == 3\n assert candidate(a = 134217727,b = 268435455,c = 536870911) == 1\n assert candidate(a = 1023,b = 511,c = 255) == 3\n assert candidate(a = 536870911,b = 268435455,c = 805306367) == 2\n assert candidate(a = 255,b = 511,c = 1023) == 1\n assert candidate(a = 255,b = 128,c = 191) == 1\n assert candidate(a = 1000000000,b = 1000000000,c = 500000000) == 21\n assert candidate(a = 1000000000,b = 500000000,c = 1500000000) == 14\n assert candidate(a = 65535,b = 131071,c = 262143) == 1\n assert candidate(a = 500,b = 600,c = 700) == 3\n assert candidate(a = 2147483647,b = 2147483647,c = 4294967295) == 1\n assert candidate(a = 65535,b = 32768,c = 98304) == 16\n assert candidate(a = 255,b = 128,c = 64) == 8\n assert candidate(a = 16777215,b = 255,c = 16777470) == 19\n assert candidate(a = 100000000,b = 200000000,c = 300000000) == 10\n assert candidate(a = 5349,b = 7281,c = 12630) == 11\n assert candidate(a = 123456789,b = 987654321,c = 101110101) == 20\n assert candidate(a = 29,b = 15,c = 31) == 0\n assert candidate(a = 7,b = 14,c = 21) == 4\n assert candidate(a = 3,b = 12,c = 15) == 0\n assert candidate(a = 1048576,b = 2097152,c = 3145727) == 21\n assert candidate(a = 25,b = 50,c = 75) == 4\n assert candidate(a = 500000000,b = 500000000,c = 1000000000) == 21\n assert candidate(a = 31,b = 15,c = 7) == 3\n assert candidate(a = 1,b = 1,c = 0) == 2\n assert candidate(a = 1048575,b = 1048576,c = 2097151) == 0\n assert candidate(a = 536870911,b = 268435455,c = 703687440) == 32\n assert candidate(a = 348712387,b = 987654321,c = 1000000000) == 18\n assert candidate(a = 170,b = 85,c = 255) == 0\n assert candidate(a = 987654,b = 321456,c = 1309110) == 8\n assert candidate(a = 1023,b = 512,c = 1535) == 3\n assert candidate(a = 999999,b = 888888,c = 777777) == 8\n assert candidate(a = 1048575,b = 524287,c = 262143) == 3\n assert candidate(a = 65535,b = 65535,c = 131071) == 1\n assert candidate(a = 89,b = 67,c = 45) == 6\n assert candidate(a = 1,b = 1023,c = 1023) == 0\n assert candidate(a = 858993459,b = 2576980377,c = 1717986918) == 32\n assert candidate(a = 65535,b = 32767,c = 98303) == 2\n assert candidate(a = 536870911,b = 1073741823,c = 2147483647) == 1\n assert candidate(a = 1,b = 1000000000,c = 1000000000) == 1\n assert candidate(a = 8,b = 3,c = 10) == 1\n assert candidate(a = 789,b = 456,c = 1245) == 4\n assert candidate(a = 4294967295,b = 2147483647,c = 4294967294) == 2\n"}, "metadata": {"canonical_parameter_names": ["a", "b", "c"], "leetcode_dataset_entry_point": "Solution().minFlips", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minFlips(int a, int b, int c) {", "container": "Solution", "callable": "minFlips", "parameters": [{"name": "a", "type": "int"}, {"name": "b", "type": "int"}, {"name": "c", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1319, "task_id": "number-of-operations-to-make-network-connected", "difficulty": "Medium", "problem_description": "There are n computers numbered from 0 to n - 1 connected by ethernet cables connections forming a network where connections[i] = [ai, bi] represents a connection between computers ai and bi. Any computer can reach any other computer directly or indirectly through the network.\nYou are given an initial computer network connections. You can extract certain cables between two directly connected computers, and place them between any pair of disconnected computers to make them directly connected.\nReturn the minimum number of times you need to do this in order to make all the computers connected. If it is not possible, return -1.\n \nExample 1:\n\n\nInput: n = 4, connections = [[0,1],[0,2],[1,2]]\nOutput: 1\nExplanation: Remove cable between computer 1 and 2 and place between computers 1 and 3.\n\nExample 2:\n\n\nInput: n = 6, connections = [[0,1],[0,2],[0,3],[1,2],[1,3]]\nOutput: 2\n\nExample 3:\n\nInput: n = 6, connections = [[0,1],[0,2],[0,3],[1,2]]\nOutput: -1\nExplanation: There are not enough cables.\n\n \nConstraints:\n\n1 <= n <= 105\n1 <= connections.length <= min(n * (n - 1) / 2, 105)\nconnections[i].length == 2\n0 <= ai, bi < n\nai != bi\nThere are no repeated connections.\nNo two computers are connected by more than one cable.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 0\n assert candidate(n = 5,connections = [[0, 1], [1, 2], [3, 4]]) == -1\n assert candidate(n = 6,connections = [[0, 1], [0, 2], [0, 3], [1, 2]]) == -1\n assert candidate(n = 5,connections = [[0, 1], [2, 3]]) == -1\n assert candidate(n = 3,connections = [[0, 1], [1, 2]]) == 0\n assert candidate(n = 7,connections = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3]]) == 3\n assert candidate(n = 5,connections = [[0, 1], [0, 2], [3, 4]]) == -1\n assert candidate(n = 2,connections = [[0, 1]]) == 0\n assert candidate(n = 4,connections = [[0, 1], [0, 2], [1, 2]]) == 1\n assert candidate(n = 10,connections = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == -1\n assert candidate(n = 1,connections = []) == 0\n assert candidate(n = 6,connections = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3]]) == 2\n assert candidate(n = 7,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [5, 6]]) == -1\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [4, 5], [5, 6], [7, 8], [8, 9]]) == -1\n assert candidate(n = 7,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [4, 5], [5, 6]]) == 1\n assert candidate(n = 15,connections = [[0, 1], [1, 2], [3, 4], [4, 5], [5, 6], [7, 8], [8, 9], [9, 10], [11, 12], [12, 13], [13, 14]]) == -1\n assert candidate(n = 20,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 0\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [6, 7], [7, 8], [8, 9], [9, 6], [0, 6], [1, 7], [2, 8], [3, 9], [4, 0]]) == 0\n assert candidate(n = 15,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 5]]) == 1\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [3, 4], [4, 5], [6, 7], [7, 8], [8, 9]]) == -1\n assert candidate(n = 9,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [0, 8]]) == 0\n assert candidate(n = 14,connections = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [13, 0], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == 0\n assert candidate(n = 8,connections = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4]]) == 1\n assert candidate(n = 20,connections = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [0, 2], [1, 3], [4, 6], [5, 7], [8, 10], [9, 11], [12, 14], [13, 15], [16, 18], [17, 19]]) == 4\n assert candidate(n = 11,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == -1\n assert candidate(n = 12,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [4, 5], [5, 3], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 10]]) == 2\n assert candidate(n = 12,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [3, 5], [4, 5], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [10, 11]]) == 3\n assert candidate(n = 13,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == 0\n assert candidate(n = 100,connections = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [20, 21], [22, 23], [24, 25], [26, 27], [28, 29], [30, 31], [32, 33], [34, 35], [36, 37], [38, 39], [40, 41], [42, 43], [44, 45], [46, 47], [48, 49], [50, 51], [52, 53], [54, 55], [56, 57], [58, 59], [60, 61], [62, 63], [64, 65], [66, 67], [68, 69], [70, 71], [72, 73], [74, 75], [76, 77], [78, 79], [80, 81], [82, 83], [84, 85], [86, 87], [88, 89], [90, 91], [92, 93], [94, 95], [96, 97], [98, 99]]) == -1\n assert candidate(n = 15,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [3, 5], [4, 5], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [10, 11], [12, 13], [12, 14], [13, 14]]) == 4\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [0, 5], [5, 10], [10, 3], [3, 8], [8, 1]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [6, 7], [7, 8], [8, 9], [9, 6]]) == 1\n assert candidate(n = 8,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0]]) == 0\n assert candidate(n = 15,connections = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 1\n assert candidate(n = 30,connections = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25], [24, 26], [25, 27], [26, 28], [27, 29], [0, 29]]) == 0\n assert candidate(n = 30,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29]]) == 0\n assert candidate(n = 12,connections = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11]]) == -1\n assert candidate(n = 25,connections = [[0, 1], [0, 2], [0, 3], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == -1\n assert candidate(n = 20,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [8, 9]]) == 2\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [5, 6], [7, 8], [8, 9]]) == -1\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [1, 3], [2, 5], [4, 7], [6, 8]]) == 0\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [0, 11]]) == 0\n assert candidate(n = 7,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 0\n assert candidate(n = 15,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [0, 14]]) == 0\n assert candidate(n = 11,connections = [[0, 1], [0, 2], [0, 3], [1, 2], [2, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 1\n assert candidate(n = 20,connections = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19]]) == -1\n assert candidate(n = 15,connections = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14]]) == 0\n assert candidate(n = 25,connections = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [1, 7], [1, 8], [2, 9], [2, 10], [2, 11], [2, 12], [3, 13], [3, 14], [3, 15], [3, 16], [4, 17], [4, 18], [4, 19], [4, 20], [5, 21], [6, 22], [7, 23], [8, 24]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 1\n assert candidate(n = 8,connections = [[0, 1], [1, 2], [2, 3], [4, 5], [5, 6], [6, 7]]) == -1\n assert candidate(n = 14,connections = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 7], [13, 13]]) == 3\n assert candidate(n = 14,connections = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]]) == 1\n assert candidate(n = 8,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 0\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [0, 2], [1, 3]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 1\n assert candidate(n = 16,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 0], [0, 7], [7, 14], [14, 6], [6, 13], [13, 5], [5, 12], [12, 4], [4, 11], [11, 3], [3, 10], [10, 2], [2, 9], [9, 1], [1, 8]]) == 0\n assert candidate(n = 8,connections = [[0, 1], [1, 2], [2, 3], [0, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 3], [3, 6], [2, 5]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 3]]) == 1\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [3, 4], [4, 5], [5, 6], [7, 8], [8, 9]]) == -1\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0]]) == 0\n assert candidate(n = 15,connections = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]]) == 0\n assert candidate(n = 7,connections = [[0, 1], [1, 2], [3, 4], [4, 5]]) == -1\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]]) == 0\n assert candidate(n = 15,connections = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 14]]) == 0\n assert candidate(n = 30,connections = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [20, 21], [22, 23], [24, 25], [26, 27], [28, 29]]) == -1\n assert candidate(n = 20,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 0]]) == 0\n assert candidate(n = 30,connections = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20], [17, 21], [18, 22], [19, 23], [20, 24], [21, 25], [22, 26], [23, 27], [24, 28], [25, 29]]) == 0\n assert candidate(n = 20,connections = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [5, 6], [6, 7], [7, 8], [8, 9]]) == -1\n assert candidate(n = 5,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 2], [1, 3], [2, 4], [3, 0], [4, 1]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 5], [5, 1]]) == 0\n assert candidate(n = 20,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 9]]) == 1\n assert candidate(n = 16,connections = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15]]) == -1\n assert candidate(n = 9,connections = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [0, 8], [1, 7], [2, 5], [3, 6]]) == 0\n assert candidate(n = 9,connections = [[0, 1], [0, 2], [1, 2], [3, 4], [4, 5], [5, 6], [7, 8]]) == -1\n assert candidate(n = 15,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == 0\n assert candidate(n = 15,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 0\n assert candidate(n = 25,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24]]) == 0\n assert candidate(n = 20,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == 0\n assert candidate(n = 7,connections = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 6]]) == 1\n assert candidate(n = 20,connections = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [0, 3], [2, 5], [4, 7], [6, 9], [8, 11], [10, 13], [12, 15], [14, 17], [16, 19]]) == 0\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11]]) == 0\n"}, "metadata": {"canonical_parameter_names": ["n", "connections"], "leetcode_dataset_entry_point": "Solution().makeConnected", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int makeConnected(int n, vector>& connections) {", "container": "Solution", "callable": "makeConnected", "parameters": [{"name": "n", "type": "int"}, {"name": "connections", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1320, "task_id": "minimum-distance-to-type-a-word-using-two-fingers", "difficulty": "Hard", "problem_description": "\nYou have a keyboard layout as shown above in the X-Y plane, where each English uppercase letter is located at some coordinate.\n\nFor example, the letter 'A' is located at coordinate (0, 0), the letter 'B' is located at coordinate (0, 1), the letter 'P' is located at coordinate (2, 3) and the letter 'Z' is located at coordinate (4, 1).\n\nGiven the string word, return the minimum total distance to type such string using only two fingers.\nThe distance between coordinates (x1, y1) and (x2, y2) is |x1 - x2| + |y1 - y2|.\nNote that the initial positions of your two fingers are considered free so do not count towards your total distance, also your two fingers do not have to start at the first letter or the first two letters.\n \nExample 1:\n\nInput: word = \"CAKE\"\nOutput: 3\nExplanation: Using two fingers, one optimal way to type \"CAKE\" is: \nFinger 1 on letter 'C' -> cost = 0 \nFinger 1 on letter 'A' -> cost = Distance from letter 'C' to letter 'A' = 2 \nFinger 2 on letter 'K' -> cost = 0 \nFinger 2 on letter 'E' -> cost = Distance from letter 'K' to letter 'E' = 1 \nTotal distance = 3\n\nExample 2:\n\nInput: word = \"HAPPY\"\nOutput: 6\nExplanation: Using two fingers, one optimal way to type \"HAPPY\" is:\nFinger 1 on letter 'H' -> cost = 0\nFinger 1 on letter 'A' -> cost = Distance from letter 'H' to letter 'A' = 2\nFinger 2 on letter 'P' -> cost = 0\nFinger 2 on letter 'P' -> cost = Distance from letter 'P' to letter 'P' = 0\nFinger 1 on letter 'Y' -> cost = Distance from letter 'A' to letter 'Y' = 4\nTotal distance = 6\n\n \nConstraints:\n\n2 <= word.length <= 300\nword consists of uppercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"QWERTYUIOPASDFGHJKLZXCVBNM\") == 52\n assert candidate(word = \"ZZZZZ\") == 0\n assert candidate(word = \"CAKE\") == 3\n assert candidate(word = \"RHYTHM\") == 9\n assert candidate(word = \"FINGER\") == 8\n assert candidate(word = \"ALPHABET\") == 12\n assert candidate(word = \"ABCD\") == 2\n assert candidate(word = \"QWERTYUIOPASDFGHJKLMZXCVBNM\") == 54\n assert candidate(word = \"NEW\") == 3\n assert candidate(word = \"HAPPY\") == 6\n assert candidate(word = \"ABCMN\") == 3\n assert candidate(word = \"LONGEST\") == 8\n assert candidate(word = \"MISSISSIPPI\") == 5\n assert candidate(word = \"YEAR\") == 7\n assert candidate(word = \"ZXY\") == 1\n assert candidate(word = \"OPTIMIZATION\") == 17\n assert candidate(word = \"YYYYYY\") == 0\n assert candidate(word = \"ACB\") == 1\n assert candidate(word = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\") == 36\n assert candidate(word = \"MOUSE\") == 5\n assert candidate(word = \"ZZZZ\") == 0\n assert candidate(word = \"AA\") == 0\n assert candidate(word = \"TRANSFER\") == 15\n assert candidate(word = \"ABCDEFGHIJKLMNOP\") == 18\n assert candidate(word = \"PYTHON\") == 6\n assert candidate(word = \"QRSTUVWXYZ\") == 12\n assert candidate(word = \"KEYBOARD\") == 15\n assert candidate(word = \"ABAB\") == 0\n assert candidate(word = \"A\") == 0\n assert candidate(word = \"ABCDEFG\") == 5\n assert candidate(word = \"DISTANCE\") == 11\n assert candidate(word = \"ALGORITHMS\") == 14\n assert candidate(word = \"CAPABILITY\") == 13\n assert candidate(word = \"HASHMAP\") == 9\n assert candidate(word = \"LONGWORDLONGWORDLONGWORDLONGWORDLONGWORDLONGWORDLONGWORD\") == 122\n assert candidate(word = \"SPECIAL\") == 12\n assert candidate(word = \"DEPLOYMENT\") == 14\n assert candidate(word = \"VOLCANOES\") == 15\n assert candidate(word = \"VICTORY\") == 10\n assert candidate(word = \"BACKSPACENOTPOSSIBLE\") == 35\n assert candidate(word = \"PROSPERING\") == 18\n assert candidate(word = \"METHOD\") == 7\n assert candidate(word = \"ROBUST\") == 7\n assert candidate(word = \"PLANNING\") == 11\n assert candidate(word = \"JOY\") == 2\n assert candidate(word = \"DEPTHFIRSTSEARCH\") == 29\n assert candidate(word = \"CONCEPT\") == 7\n assert candidate(word = \"INTEGRATION\") == 19\n assert candidate(word = \"PLENTY\") == 7\n assert candidate(word = \"COORDINATION\") == 18\n assert candidate(word = \"ACCOMPLISHED\") == 18\n assert candidate(word = \"RUBY\") == 7\n assert candidate(word = \"SERVER\") == 10\n assert candidate(word = \"PYTHONIC\") == 8\n assert candidate(word = \"PRODUCT\") == 8\n assert candidate(word = \"JUST\") == 3\n assert candidate(word = \"RESEARCH\") == 13\n assert candidate(word = \"PYTHONCODING\") == 15\n assert candidate(word = \"INITIATION\") == 9\n assert candidate(word = \"OBJECTORIENTED\") == 22\n assert candidate(word = \"REQUIREMENT\") == 15\n assert candidate(word = \"BANANA\") == 1\n assert candidate(word = \"FINANCE\") == 10\n assert candidate(word = \"HELLOFROMTHEOTHERSIDE\") == 35\n assert candidate(word = \"DEDICATED\") == 10\n assert candidate(word = \"SUPERLONGWORD\") == 23\n assert candidate(word = \"ACCOMPLISHMENT\") == 20\n assert candidate(word = \"PROGRAMMER\") == 13\n assert candidate(word = \"SPECIALCHARACTERS\") == 32\n assert candidate(word = \"NETWORK\") == 10\n assert candidate(word = \"AWESOME\") == 11\n assert candidate(word = \"PROGRESS\") == 9\n assert candidate(word = \"WIN\") == 2\n assert candidate(word = \"OBJECTIVE\") == 15\n assert candidate(word = \"FLOURISH\") == 10\n assert candidate(word = \"PROSPEROUS\") == 16\n assert candidate(word = \"EXPERIMENT\") == 14\n assert candidate(word = \"FINGERBOARD\") == 20\n assert candidate(word = \"PATIENCE\") == 13\n assert candidate(word = \"ADJUSTMENT\") == 13\n assert candidate(word = \"EXCEL\") == 6\n assert candidate(word = \"SUPERCALIFRAGILISTICEXPIALIDOCIOUS\") == 59\n assert candidate(word = \"FRANK\") == 7\n assert candidate(word = \"SOFTWARE\") == 18\n assert candidate(word = \"TWOPOINTERS\") == 15\n assert candidate(word = \"ANALYSIS\") == 13\n assert candidate(word = \"RESOLUTION\") == 15\n assert candidate(word = \"LONGWORDFORTESTING\") == 32\n assert candidate(word = \"INTERACTION\") == 18\n assert candidate(word = \"UNOBTRUDES\") == 17\n assert candidate(word = \"FINGERMOVEMENT\") == 20\n assert candidate(word = \"PEACE\") == 5\n assert candidate(word = \"DEPONIBLE\") == 11\n assert candidate(word = \"ASTARSEARCH\") == 22\n assert candidate(word = \"ANGULAR\") == 10\n assert candidate(word = \"SERVICE\") == 12\n assert candidate(word = \"PROSPERITY\") == 19\n assert candidate(word = \"RECOGNITION\") == 13\n assert candidate(word = \"KINDNESS\") == 7\n assert candidate(word = \"PYTHONPYTHONPYTHON\") == 26\n assert candidate(word = \"PARTNER\") == 12\n assert candidate(word = \"IDEAL\") == 5\n assert candidate(word = \"PRODUCTIVE\") == 14\n assert candidate(word = \"HARMONY\") == 10\n assert candidate(word = \"MYSQL\") == 5\n assert candidate(word = \"PYTHONISFUN\") == 17\n assert candidate(word = \"UNIVERSAL\") == 16\n assert candidate(word = \"KEYBOARDLAYOUT\") == 29\n assert candidate(word = \"SAFE\") == 4\n assert candidate(word = \"TYPESCRIPT\") == 20\n assert candidate(word = \"TREE\") == 3\n assert candidate(word = \"FINGERFINGER\") == 20\n assert candidate(word = \"AAAAA\") == 0\n assert candidate(word = \"GENTLE\") == 7\n assert candidate(word = \"ETHICAL\") == 8\n assert candidate(word = \"BACKTRACKING\") == 21\n assert candidate(word = \"AFFLUENT\") == 11\n assert candidate(word = \"TIMECOMPLEXITY\") == 27\n assert candidate(word = \"HUMBLE\") == 11\n assert candidate(word = \"API\") == 2\n assert candidate(word = \"OVERCOME\") == 14\n assert candidate(word = \"DOBRE\") == 8\n assert candidate(word = \"PRACTICE\") == 13\n assert candidate(word = \"PLAIN\") == 8\n assert candidate(word = \"ACHIEVEMENT\") == 14\n assert candidate(word = \"COMPUTERSCIENCE\") == 28\n assert candidate(word = \"SUCCESSFUL\") == 9\n assert candidate(word = \"GOAL\") == 5\n assert candidate(word = \"CHANGE\") == 9\n assert candidate(word = \"FULFILLMENT\") == 12\n assert candidate(word = \"PRINCIPLE\") == 13\n assert candidate(word = \"CODER\") == 5\n assert candidate(word = \"ALLOCATION\") == 13\n assert candidate(word = \"DIJKSTRAS\") == 14\n assert candidate(word = \"INTERPRETATION\") == 22\n assert candidate(word = \"INTEGRITY\") == 16\n assert candidate(word = \"HACK\") == 4\n assert candidate(word = \"QWJRTYUPASDFGZXCVB\") == 43\n assert candidate(word = \"SUPERLATIVE\") == 23\n assert candidate(word = \"PERSISTENT\") == 16\n assert candidate(word = \"MULTIPLEFINGERS\") == 24\n assert candidate(word = \"OPERATION\") == 16\n assert candidate(word = \"DELIVERY\") == 14\n assert candidate(word = \"DETERMINATION\") == 20\n assert candidate(word = \"DATASTRUCTURE\") == 24\n assert candidate(word = \"CALCULATION\") == 19\n assert candidate(word = \"OPULANCE\") == 15\n assert candidate(word = \"TOP\") == 1\n assert candidate(word = \"SIMULATION\") == 19\n assert candidate(word = \"ATTENTIVE\") == 12\n assert candidate(word = \"PROFILING\") == 9\n assert candidate(word = \"EFFICIENT\") == 7\n assert candidate(word = \"MEMORYMANAGEMENT\") == 26\n assert candidate(word = \"STRATEGY\") == 18\n assert candidate(word = \"THRIVE\") == 9\n assert candidate(word = \"ENERGETIC\") == 15\n assert candidate(word = \"THEQUICKBROWNFOXJUMPSOVERTHELAZYDOG\") == 73\n assert candidate(word = \"CUSTOMIZATION\") == 20\n assert candidate(word = \"OPTIMIZE\") == 11\n assert candidate(word = \"ELITE\") == 6\n assert candidate(word = \"PROGRAMMINGISFUN\") == 24\n assert candidate(word = \"COMMITTED\") == 9\n assert candidate(word = \"EFFECTIVE\") == 10\n assert candidate(word = \"REPORT\") == 6\n assert candidate(word = \"SPACESAVING\") == 22\n assert candidate(word = \"INTERFACE\") == 15\n assert candidate(word = \"NEURALNETWORKS\") == 29\n assert candidate(word = \"CORRECT\") == 9\n assert candidate(word = \"KNIGHTMARCH\") == 17\n assert candidate(word = \"SIMPLE\") == 8\n assert candidate(word = \"TECHNOLOGY\") == 16\n assert candidate(word = \"QUEUE\") == 2\n assert candidate(word = \"ABACAXABABACAB\") == 15\n assert candidate(word = \"PROGRAMMING\") == 14\n assert candidate(word = \"SEARCH\") == 10\n assert candidate(word = \"MULTIPLEWORDSHEREANDTHERE\") == 49\n assert candidate(word = \"LOAD\") == 7\n assert candidate(word = \"CONFIDENT\") == 11\n assert candidate(word = \"HTML\") == 4\n assert candidate(word = \"SECURE\") == 10\n assert candidate(word = \"MECHANISM\") == 13\n assert candidate(word = \"WEALTHY\") == 15\n assert candidate(word = \"FLAWLESS\") == 12\n assert candidate(word = \"MORAL\") == 6\n assert candidate(word = \"RESPONSIBLE\") == 19\n assert candidate(word = \"DEVOTED\") == 6\n assert candidate(word = \"PASSIONATE\") == 15\n assert candidate(word = \"RANDOMKEYPAD\") == 24\n assert candidate(word = \"BACKSPACENEEDED\") == 20\n assert candidate(word = \"JAVA\") == 2\n assert candidate(word = \"CHALLENGE\") == 11\n assert candidate(word = \"PRESENTATION\") == 17\n assert candidate(word = \"BOOMING\") == 7\n assert candidate(word = \"HELLOWORLD\") == 13\n assert candidate(word = \"EQUITABLE\") == 16\n assert candidate(word = \"GREATEST\") == 10\n assert candidate(word = \"DATASTRUCTURES\") == 26\n assert candidate(word = \"EXCELLENCE\") == 14\n assert candidate(word = \"PRECISE\") == 10\n assert candidate(word = \"OBTAINED\") == 11\n assert candidate(word = \"EXECUTION\") == 9\n assert candidate(word = \"DELICATE\") == 11\n assert candidate(word = \"KRUSKALSMST\") == 16\n assert candidate(word = \"AAABBBCCCDDD\") == 2\n assert candidate(word = \"BEST\") == 4\n assert candidate(word = \"ABCDEFGHIJABCDEFGHIJ\") == 24\n assert candidate(word = \"EXEMPLARY\") == 19\n assert candidate(word = \"PRIMSMST\") == 9\n assert candidate(word = \"MANAGER\") == 10\n assert candidate(word = \"RELATIONSHIP\") == 19\n assert candidate(word = \"COMMUNICATION\") == 15\n assert candidate(word = \"FINGERPRINT\") == 17\n assert candidate(word = \"RECOMMENDATION\") == 18\n assert candidate(word = \"MULTITHREADING\") == 24\n assert candidate(word = \"MEETING\") == 8\n assert candidate(word = \"TRIUMPHANT\") == 17\n assert candidate(word = \"PRIDE\") == 5\n assert candidate(word = \"STRETCH\") == 8\n assert candidate(word = \"FINGERLATERALMOVEMENT\") == 38\n assert candidate(word = \"CLIENT\") == 6\n assert candidate(word = \"BOOM\") == 2\n assert candidate(word = \"AFFLUENCE\") == 13\n assert candidate(word = \"CONSECUTIVE\") == 16\n assert candidate(word = \"GREAT\") == 8\n assert candidate(word = \"MARKET\") == 9\n assert candidate(word = \"GENUINE\") == 8\n assert candidate(word = \"BIGDATAANALYSIS\") == 24\n assert candidate(word = \"CONVINCED\") == 10\n assert candidate(word = \"UNIT\") == 3\n assert candidate(word = \"CONFIGURATION\") == 25\n assert candidate(word = \"PLAN\") == 6\n assert candidate(word = \"ADAPTABLE\") == 13\n assert candidate(word = \"TEAMWORK\") == 15\n assert candidate(word = \"AAAAAAAAA\") == 0\n assert candidate(word = \"ACHIEVE\") == 8\n assert candidate(word = \"UTILIZATION\") == 17\n assert candidate(word = \"THRIVING\") == 10\n assert candidate(word = \"PERFORMANCE\") == 20\n assert candidate(word = \"MODEST\") == 6\n assert candidate(word = \"DEVELOPMENT\") == 13\n assert candidate(word = \"ACHIEVED\") == 9\n assert candidate(word = \"BREADTHFIRSTSEARCH\") == 35\n assert candidate(word = \"ASSURED\") == 9\n assert candidate(word = \"TRIUMPH\") == 12\n assert candidate(word = \"ENTHUSIASTIC\") == 17\n assert candidate(word = \"BUSINESS\") == 11\n assert candidate(word = \"PHP\") == 0\n assert candidate(word = \"EARNED\") == 10\n assert candidate(word = \"BBBBC\") == 0\n assert candidate(word = \"LONGKEYSEQUENCE\") == 20\n assert candidate(word = \"RIGHT\") == 5\n assert candidate(word = \"PERFECTION\") == 14\n assert candidate(word = \"PRINCIPLED\") == 14\n assert candidate(word = \"DEBUGGINGISSLOW\") == 23\n assert candidate(word = \"GUARANTEED\") == 13\n assert candidate(word = \"PROSPER\") == 11\n assert candidate(word = \"SYNCHRONIZATION\") == 25\n assert candidate(word = \"ACCOUNTABLE\") == 14\n assert candidate(word = \"VIVACIOUS\") == 10\n assert candidate(word = \"ACCURATE\") == 14\n assert candidate(word = \"INITIALIZE\") == 17\n assert candidate(word = \"ABUNDANCE\") == 12\n assert candidate(word = \"EXACT\") == 10\n assert candidate(word = \"PREMIERE\") == 12\n assert candidate(word = \"PNEUMONULA\") == 19\n assert candidate(word = \"SYNTAXERRORHANDLING\") == 36\n assert candidate(word = \"PYTHONANDJAVA\") == 15\n assert candidate(word = \"PROBLEM\") == 10\n assert candidate(word = \"DECIDED\") == 4\n assert candidate(word = \"INFORMATION\") == 18\n assert candidate(word = \"CODINGCHALLENGES\") == 23\n assert candidate(word = \"TRANSACTION\") == 16\n assert candidate(word = \"CONTESTSAREFUN\") == 24\n assert candidate(word = \"DYNAMIC\") == 11\n assert candidate(word = \"PATTERN\") == 11\n assert candidate(word = \"CONCURRENT\") == 12\n assert candidate(word = \"TEST\") == 2\n assert candidate(word = \"SUPERIOR\") == 10\n assert candidate(word = \"LOVEPYTHON\") == 17\n assert candidate(word = \"COLLABORATION\") == 22\n assert candidate(word = \"MINIMALIZATION\") == 20\n assert candidate(word = \"MACHINELEARNING\") == 28\n assert candidate(word = \"PLETHORA\") == 16\n assert candidate(word = \"MEMORIZATION\") == 21\n assert candidate(word = \"PROTECTED\") == 11\n assert candidate(word = \"JAVASCRIPT\") == 19\n assert candidate(word = \"EXCEPTIONAL\") == 20\n assert candidate(word = \"FLOURISHING\") == 15\n assert candidate(word = \"COORDINATOR\") == 17\n assert candidate(word = \"VARIABLESANDTYPES\") == 33\n assert candidate(word = \"TEAM\") == 6\n assert candidate(word = \"TRAVELINGSALESMANPROBLEM\") == 51\n assert candidate(word = \"VUE\") == 1\n assert candidate(word = \"DIRECT\") == 10\n assert candidate(word = \"AVOIDDISTANCE\") == 17\n assert candidate(word = \"PREMIUM\") == 10\n assert candidate(word = \"FLEXIBLE\") == 12\n assert candidate(word = \"CPLUSPLUS\") == 15\n assert candidate(word = \"BUG\") == 2\n assert candidate(word = \"COOLCODE\") == 8\n assert candidate(word = \"CONGRATULATIONS\") == 25\n assert candidate(word = \"MONGODB\") == 8\n assert candidate(word = \"NETWORKFLOW\") == 16\n assert candidate(word = \"SIMULATEDANNEALING\") == 34\n assert candidate(word = \"STRONG\") == 6\n assert candidate(word = \"POSTGRESQL\") == 17\n assert candidate(word = \"TARGET\") == 11\n assert candidate(word = \"PROJECT\") == 10\n assert candidate(word = \"ARTIFICIALINTELLIGENCE\") == 37\n assert candidate(word = \"DATABASE\") == 10\n assert candidate(word = \"RECURSION\") == 13\n assert candidate(word = \"REACT\") == 9\n assert candidate(word = \"FRAMEWORK\") == 16\n assert candidate(word = \"OPTIMAL\") == 10\n assert candidate(word = \"REACHED\") == 8\n assert candidate(word = \"EXCELLENT\") == 12\n assert candidate(word = \"KANGAROO\") == 11\n assert candidate(word = \"GENETICALGORITHM\") == 24\n assert candidate(word = \"STRESS\") == 5\n assert candidate(word = \"PYTHONPROGRAMMING\") == 23\n assert candidate(word = \"GRAPH\") == 5\n assert candidate(word = \"MIGHTY\") == 6\n assert candidate(word = \"HONEST\") == 6\n assert candidate(word = \"ACCELERATION\") == 18\n assert candidate(word = \"XYLOPHONE\") == 15\n assert candidate(word = \"LUXURY\") == 6\n assert candidate(word = \"LOYAL\") == 8\n assert candidate(word = \"DIVIDEANDCONQUER\") == 25\n assert candidate(word = \"IDENTIFICATION\") == 19\n assert candidate(word = \"HONORABLE\") == 11\n assert candidate(word = \"TYPINGISAWAYTORELAX\") == 37\n assert candidate(word = \"ENGINEERING\") == 15\n assert candidate(word = \"TYPINGWITHTWOFINGERS\") == 39\n assert candidate(word = \"COMPANY\") == 10\n assert candidate(word = \"ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ\") == 84\n assert candidate(word = \"ARRAY\") == 4\n assert candidate(word = \"CSS\") == 0\n assert candidate(word = \"CYBER\") == 7\n assert candidate(word = \"ENGINEER\") == 9\n assert candidate(word = \"FUTURE\") == 7\n assert candidate(word = \"APPLICATION\") == 14\n assert candidate(word = \"STACK\") == 6\n assert candidate(word = \"VICTORIOUS\") == 13\n assert candidate(word = \"IMPLEMENTATION\") == 18\n assert candidate(word = \"HELLOUNIVERSE\") == 23\n assert candidate(word = \"PROCESS\") == 9\n assert candidate(word = \"FUNCTION\") == 9\n assert candidate(word = \"CAREER\") == 6\n assert candidate(word = \"INITIATIVE\") == 12\n assert candidate(word = \"RESULT\") == 8\n assert candidate(word = \"EMPATHY\") == 12\n assert candidate(word = \"ABILITY\") == 8\n assert candidate(word = \"SUPPLIER\") == 10\n assert candidate(word = \"INTERVENTION\") == 20\n assert candidate(word = \"ATTAINED\") == 8\n assert candidate(word = \"ALGORITHM\") == 13\n assert candidate(word = \"LEADER\") == 7\n assert candidate(word = \"SOFTWAREENGINEERING\") == 36\n assert candidate(word = \"SUPERABUNDANCE\") == 26\n assert candidate(word = \"TENACIOUS\") == 11\n assert candidate(word = \"FAIR\") == 5\n assert candidate(word = \"HELLOWORLDHELLOWORLD\") == 29\n assert candidate(word = \"REFACTOR\") == 14\n assert candidate(word = \"SATISFACTION\") == 20\n assert candidate(word = \"ALGORITHMSANDDATA\") == 26\n assert candidate(word = \"PROLIFIC\") == 5\n assert candidate(word = \"GRAPHALGORITHMS\") == 24\n assert candidate(word = \"CAREFUL\") == 12\n assert candidate(word = \"ECONOMY\") == 7\n assert candidate(word = \"OUTSTANDING\") == 12\n assert candidate(word = \"GREEDYALGORITHM\") == 27\n assert candidate(word = \"VIP\") == 1\n assert candidate(word = \"BAAABBBCCCDDDDEEEEFFFFGGGGHHHHIIIIJJJJKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSTTTTUUUUVVVVWWWWWXXXXYYYYZZZZZ\") == 36\n assert candidate(word = \"COMPASSION\") == 12\n assert candidate(word = \"ARCHITECTURE\") == 20\n assert candidate(word = \"BELLMANFORD\") == 17\n assert candidate(word = \"WORKFLOW\") == 10\n assert candidate(word = \"NODEJS\") == 7\n assert candidate(word = \"RESILIENT\") == 14\n assert candidate(word = \"ZYXWVUTSRQPONMLKJIHGFEDCBA\") == 36\n assert candidate(word = \"HAPPINESS\") == 12\n assert candidate(word = \"RELIABLE\") == 10\n assert candidate(word = \"POWERFUL\") == 11\n assert candidate(word = \"PERFECT\") == 10\n assert candidate(word = \"TRUSTWORTHY\") == 18\n assert candidate(word = \"TRANSPARENT\") == 23\n assert candidate(word = \"MINIMIZE\") == 8\n assert candidate(word = \"COMPLEXITY\") == 20\n assert candidate(word = \"TENDER\") == 6\n assert candidate(word = \"ACCEPTANCE\") == 13\n assert candidate(word = \"FLASK\") == 5\n assert candidate(word = \"KNOWLEDGE\") == 13\n assert candidate(word = \"RICH\") == 3\n assert candidate(word = \"ENVIRONMENT\") == 17\n assert candidate(word = \"GAINED\") == 7\n assert candidate(word = \"DISCOVER\") == 13\n assert candidate(word = \"DOUBTFREE\") == 13\n assert candidate(word = \"LUXURIOUS\") == 9\n assert candidate(word = \"SECURITY\") == 14\n assert candidate(word = \"INDUSTRY\") == 13\n assert candidate(word = \"MOVEMENTOFKEYS\") == 19\n assert candidate(word = \"DJANGO\") == 6\n assert candidate(word = \"FUNCTIONCALLSARE\") == 28\n assert candidate(word = \"CONSCIENTIOUS\") == 16\n assert candidate(word = \"HELLOORLD\") == 9\n assert candidate(word = \"REVISION\") == 11\n assert candidate(word = \"INNOVATION\") == 12\n assert candidate(word = \"EXCLUSIVE\") == 18\n assert candidate(word = \"SURE\") == 5\n assert candidate(word = \"TRUST\") == 4\n assert candidate(word = \"DYNAMICPROGRAMMING\") == 31\n assert candidate(word = \"LEARN\") == 8\n assert candidate(word = \"SUCCESS\") == 5\n assert candidate(word = \"AAAAAAAAAABBBBBBBBBBCCCCCCCCCC\") == 1\n assert candidate(word = \"EVOLUTION\") == 11\n assert candidate(word = \"SOLUTION\") == 10\n assert candidate(word = \"OPPORTUNITY\") == 14\n assert candidate(word = \"ABUNDANT\") == 9\n assert candidate(word = \"FAILURE\") == 10\n assert candidate(word = \"REVOLUTION\") == 14\n assert candidate(word = \"SEQUENCE\") == 11\n assert candidate(word = \"FINGERFINGERFINGER\") == 32\n assert candidate(word = \"LINKEDLIST\") == 14\n assert candidate(word = \"EXPERIENCE\") == 14\n assert candidate(word = \"OPEN\") == 3\n assert candidate(word = \"LOVE\") == 4\n assert candidate(word = \"CONCLUSION\") == 14\n assert candidate(word = \"SKILL\") == 5\n assert candidate(word = \"EVALUATION\") == 19\n assert candidate(word = \"FINGERTYPINGISFUN\") == 32\n assert candidate(word = \"MAGNIFICENT\") == 13\n assert candidate(word = \"LEETCODE\") == 8\n assert candidate(word = \"CUSTOMER\") == 12\n assert candidate(word = \"STRIGHT\") == 8\n assert candidate(word = \"SPACECOMPLEXITY\") == 28\n assert candidate(word = \"DEPENDABLE\") == 13\n assert candidate(word = \"DEVELOPER\") == 10\n assert candidate(word = \"EXPRESS\") == 11\n assert candidate(word = \"KEYPADTYPING\") == 24\n assert candidate(word = \"PROFESSION\") == 12\n assert candidate(word = \"REPOSITION\") == 11\n assert candidate(word = \"KNAPSACKPROBLEM\") == 28\n assert candidate(word = \"DESIGN\") == 8\n assert candidate(word = \"DEBUG\") == 6\n assert candidate(word = \"TRACING\") == 11\n assert candidate(word = \"STURDY\") == 9\n assert candidate(word = \"WEALTH\") == 11\n assert candidate(word = \"TRANSFORMATION\") == 29\n assert candidate(word = \"EFFORT\") == 5\n assert candidate(word = \"EXERCISE\") == 11\n"}, "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().minimumDistance", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumDistance(string word) {", "container": "Solution", "callable": "minimumDistance", "parameters": [{"name": "word", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1324, "task_id": "print-words-vertically", "difficulty": "Medium", "problem_description": "Given a string s. Return all the words vertically in the same order in which they appear in s.\\r\nWords are returned as a list of strings, complete with spaces when is necessary. (Trailing spaces are not allowed).\\r\nEach word would be put on only one column and that in one column there will be only one word.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: s = \"HOW ARE YOU\"\\r\nOutput: [\"HAY\",\"ORO\",\"WEU\"]\\r\nExplanation: Each word is printed vertically. \\r\n \"HAY\"\\r\n \"ORO\"\\r\n \"WEU\"\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: s = \"TO BE OR NOT TO BE\"\\r\nOutput: [\"TBONTB\",\"OEROOE\",\" T\"]\\r\nExplanation: Trailing spaces is not allowed. \\r\n\"TBONTB\"\\r\n\"OEROOE\"\\r\n\" T\"\\r\n\\r\n\\r\nExample 3:\\r\n\\r\n\\r\nInput: s = \"CONTEST IS COMING\"\\r\nOutput: [\"CIC\",\"OSO\",\"N M\",\"T I\",\"E N\",\"S G\",\"T\"]\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= s.length <= 200\\r\n\ts contains only upper case English letters.\\r\n\tIt's guaranteed that there is only one space between 2 words.\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"AB CD\") == ['AC', 'BD']\n assert candidate(s = \"A B C D\") == ['ABCD']\n assert candidate(s = \"A B C D E\") == ['ABCDE']\n assert candidate(s = \"SINGLEWORD\") == ['S', 'I', 'N', 'G', 'L', 'E', 'W', 'O', 'R', 'D']\n assert candidate(s = \"A B C\") == ['ABC']\n assert candidate(s = \"PYTHON\") == ['P', 'Y', 'T', 'H', 'O', 'N']\n assert candidate(s = \"HELLO WORLD\") == ['HW', 'EO', 'LR', 'LL', 'OD']\n assert candidate(s = \"ABCD EF GHIJK\") == ['AEG', 'BFH', 'C I', 'D J', ' K']\n assert candidate(s = \"PROGRAMMING IS FUN\") == ['PIF', 'RSU', 'O N', 'G', 'R', 'A', 'M', 'M', 'I', 'N', 'G']\n assert candidate(s = \"MAKE AMERICA GREAT AGAIN\") == ['MAGA', 'AMRG', 'KEEA', 'ERAI', ' ITN', ' C', ' A']\n assert candidate(s = \"SPACE BETWEEN\") == ['SB', 'PE', 'AT', 'CW', 'EE', ' E', ' N']\n assert candidate(s = \"UPPER CASE ONLY\") == ['UCO', 'PAN', 'PSL', 'EEY', 'R']\n assert candidate(s = \"HOW ARE YOU\") == ['HAY', 'ORO', 'WEU']\n assert candidate(s = \"PYTHON CODING CHALLENGE\") == ['PCC', 'YOH', 'TDA', 'HIL', 'ONL', 'NGE', ' N', ' G', ' E']\n assert candidate(s = \"JUMP HIGH\") == ['JH', 'UI', 'MG', 'PH']\n assert candidate(s = \"A\") == ['A']\n assert candidate(s = \"ALIGNED TEXT VERTICALLY\") == ['ATV', 'LEE', 'IXR', 'GTT', 'N I', 'E C', 'D A', ' L', ' L', ' Y']\n assert candidate(s = \"KEEP IT SIMPLE\") == ['KIS', 'ETI', 'E M', 'P P', ' L', ' E']\n assert candidate(s = \"HELLO HELLO HELLO\") == ['HHH', 'EEE', 'LLL', 'LLL', 'OOO']\n assert candidate(s = \"TO BE OR NOT TO BE\") == ['TBONTB', 'OEROOE', ' T']\n assert candidate(s = \"CONTEST IS COMING\") == ['CIC', 'OSO', 'N M', 'T I', 'E N', 'S G', 'T']\n assert candidate(s = \"SAME LENGTH\") == ['SL', 'AE', 'MN', 'EG', ' T', ' H']\n assert candidate(s = \"PYTHON IS FUN\") == ['PIF', 'YSU', 'T N', 'H', 'O', 'N']\n assert candidate(s = \"MULTIPLE SPACES BETWEEN WORDS\") == ['MSBW', 'UPEO', 'LATR', 'TCWD', 'IEES', 'PSE', 'L N', 'E']\n assert candidate(s = \"VERTICAL PRINTING TEST\") == ['VPT', 'ERE', 'RIS', 'TNT', 'IT', 'CI', 'AN', 'LG']\n assert candidate(s = \"VERTICALALIGNMENT WITH SPACES\") == ['VWS', 'EIP', 'RTA', 'THC', 'I E', 'C S', 'A', 'L', 'A', 'L', 'I', 'G', 'N', 'M', 'E', 'N', 'T']\n assert candidate(s = \"VERYLONGWORDSTOCHALLENGEIMPLEMENTATION\") == ['V', 'E', 'R', 'Y', 'L', 'O', 'N', 'G', 'W', 'O', 'R', 'D', 'S', 'T', 'O', 'C', 'H', 'A', 'L', 'L', 'E', 'N', 'G', 'E', 'I', 'M', 'P', 'L', 'E', 'M', 'E', 'N', 'T', 'A', 'T', 'I', 'O', 'N']\n assert candidate(s = \"SHORT LONGER LONGEST\") == ['SLL', 'HOO', 'ONN', 'RGG', 'TEE', ' RS', ' T']\n assert candidate(s = \"UNIVERSITY OF WATERLOO\") == ['UOW', 'NFA', 'I T', 'V E', 'E R', 'R L', 'S O', 'I O', 'T', 'Y']\n assert candidate(s = \"VERTICAL ALIGNMENT TEST\") == ['VAT', 'ELE', 'RIS', 'TGT', 'IN', 'CM', 'AE', 'LN', ' T']\n assert candidate(s = \"COMPACT AND READABLE CODE\") == ['CARC', 'ONEO', 'MDAD', 'P DE', 'A A', 'C B', 'T L', ' E']\n assert candidate(s = \"MIXED CASE words\") == ['MCw', 'IAo', 'XSr', 'EEd', 'D s']\n assert candidate(s = \"LONGESTWORDHERE SHORT MEDIUM\") == ['LSM', 'OHE', 'NOD', 'GRI', 'ETU', 'S M', 'T', 'W', 'O', 'R', 'D', 'H', 'E', 'R', 'E']\n assert candidate(s = \"SMALL BIGGEST WORD\") == ['SBW', 'MIO', 'AGR', 'LGD', 'LE', ' S', ' T']\n assert candidate(s = \"HELLO WORLD THIS IS A TEST\") == ['HWTIAT', 'EOHS E', 'LRI S', 'LLS T', 'OD']\n assert candidate(s = \"MIXED LENGTH WORDS HERE\") == ['MLWH', 'IEOE', 'XNRR', 'EGDE', 'DTS', ' H']\n assert candidate(s = \"COMPUTER SCIENCE DEPARTMENT\") == ['CSD', 'OCE', 'MIP', 'PEA', 'UNR', 'TCT', 'EEM', 'R E', ' N', ' T']\n assert candidate(s = \"VERYLONGWORDSTO TEST THE SYSTEM\") == ['VTTS', 'EEHY', 'RSES', 'YT T', 'L E', 'O M', 'N', 'G', 'W', 'O', 'R', 'D', 'S', 'T', 'O']\n assert candidate(s = \"SAMEWORDSAMEWORD\") == ['S', 'A', 'M', 'E', 'W', 'O', 'R', 'D', 'S', 'A', 'M', 'E', 'W', 'O', 'R', 'D']\n assert candidate(s = \"SMALL WORDS\") == ['SW', 'MO', 'AR', 'LD', 'LS']\n assert candidate(s = \"VERTICAL PRINTING IS FUN\") == ['VPIF', 'ERSU', 'RI N', 'TN', 'IT', 'CI', 'AN', 'LG']\n assert candidate(s = \"ALGORITHMS DATA STRUCTURES\") == ['ADS', 'LAT', 'GTR', 'OAU', 'R C', 'I T', 'T U', 'H R', 'M E', 'S S']\n assert candidate(s = \"A B C D E F G H I J K L M N O P Q R S T U V W X Y Z\") == ['ABCDEFGHIJKLMNOPQRSTUVWXYZ']\n assert candidate(s = \"EFFICIENT AND POWERFUL\") == ['EAP', 'FNO', 'FDW', 'I E', 'C R', 'I F', 'E U', 'N L', 'T']\n assert candidate(s = \"AVERYLONGWORD THATFITSSNICELY INTOTHECOLUMN\") == ['ATI', 'VHN', 'EAT', 'RTO', 'YFT', 'LIH', 'OTE', 'NSC', 'GSO', 'WNL', 'OIU', 'RCM', 'DEN', ' L', ' Y']\n assert candidate(s = \"MIXEDCASEANDUPPERCASE\") == ['M', 'I', 'X', 'E', 'D', 'C', 'A', 'S', 'E', 'A', 'N', 'D', 'U', 'P', 'P', 'E', 'R', 'C', 'A', 'S', 'E']\n assert candidate(s = \"MIXEDCASE mixedcase\") == ['Mm', 'Ii', 'Xx', 'Ee', 'Dd', 'Cc', 'Aa', 'Ss', 'Ee']\n assert candidate(s = \"MIXED CASE Words AND NUMBERS 123\") == ['MCWAN1', 'IAoNU2', 'XSrDM3', 'EEd B', 'D s E', ' R', ' S']\n assert candidate(s = \"SPACES ARE IGNORED BETWEEN WORDS\") == ['SAIBW', 'PRGEO', 'AENTR', 'C OWD', 'E RES', 'S EE', ' DN']\n assert candidate(s = \"PYTHONPROGRAMMING\") == ['P', 'Y', 'T', 'H', 'O', 'N', 'P', 'R', 'O', 'G', 'R', 'A', 'M', 'M', 'I', 'N', 'G']\n assert candidate(s = \"CHECK FOR SPACES IN BETWEEN\") == ['CFSIB', 'HOPNE', 'ERA T', 'C C W', 'K E E', ' S E', ' N']\n assert candidate(s = \"DATA SCIENCE AND MACHINE LEARNING\") == ['DSAML', 'ACNAE', 'TIDCA', 'AE HR', ' N IN', ' C NI', ' E EN', ' G']\n assert candidate(s = \"LEADING AND TRAILING SPACES\") == ['LATS', 'ENRP', 'ADAA', 'D IC', 'I LE', 'N IS', 'G N', ' G']\n assert candidate(s = \"VERYLONGWORDSHOULDTESTTHEFUNCTION\") == ['V', 'E', 'R', 'Y', 'L', 'O', 'N', 'G', 'W', 'O', 'R', 'D', 'S', 'H', 'O', 'U', 'L', 'D', 'T', 'E', 'S', 'T', 'T', 'H', 'E', 'F', 'U', 'N', 'C', 'T', 'I', 'O', 'N']\n assert candidate(s = \"MULTILINE VERTICAL OUTPUT\") == ['MVO', 'UEU', 'LRT', 'TTP', 'IIU', 'LCT', 'IA', 'NL', 'E']\n assert candidate(s = \"LONGESTWORD IN A SENTENCE\") == ['LIAS', 'ON E', 'N N', 'G T', 'E E', 'S N', 'T C', 'W E', 'O', 'R', 'D']\n assert candidate(s = \"ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE TEN\") == ['OTTFFSSENT', 'NWHOIIEIIE', 'EORUVXVGNN', ' ERE EHE', ' E NT']\n assert candidate(s = \"ALIGNED COLUMN OUTPUT PRINTING\") == ['ACOP', 'LOUR', 'ILTI', 'GUPN', 'NMUT', 'ENTI', 'D N', ' G']\n assert candidate(s = \"ANOTHEREXAMPLEFOR TESTING\") == ['AT', 'NE', 'OS', 'TT', 'HI', 'EN', 'RG', 'E', 'X', 'A', 'M', 'P', 'L', 'E', 'F', 'O', 'R']\n assert candidate(s = \"SHORT LONGEST SHORTEST\") == ['SLS', 'HOH', 'ONO', 'RGR', 'TET', ' SE', ' TS', ' T']\n assert candidate(s = \"SAMEWORD SAMEWORD SAMEWORD\") == ['SSS', 'AAA', 'MMM', 'EEE', 'WWW', 'OOO', 'RRR', 'DDD']\n assert candidate(s = \"ALIGNED ROWS\") == ['AR', 'LO', 'IW', 'GS', 'N', 'E', 'D']\n assert candidate(s = \"JUSTIFIED TEXT\") == ['JT', 'UE', 'SX', 'TT', 'I', 'F', 'I', 'E', 'D']\n assert candidate(s = \"SHORTEST LONGEST WORD\") == ['SLW', 'HOO', 'ONR', 'RGD', 'TE', 'ES', 'ST', 'T']\n assert candidate(s = \"ENDING SPACES ARE NOT ALLOWED \") == ['ESANA', 'NPROL', 'DAETL', 'IC O', 'NE W', 'GS E', ' D']\n assert candidate(s = \"S P A C E S E P A R A T E D\") == ['SPACESEPARATED']\n assert candidate(s = \"VERYLONGWORDTHATREQUIRESPROPERVERTICALALIGNMENT\") == ['V', 'E', 'R', 'Y', 'L', 'O', 'N', 'G', 'W', 'O', 'R', 'D', 'T', 'H', 'A', 'T', 'R', 'E', 'Q', 'U', 'I', 'R', 'E', 'S', 'P', 'R', 'O', 'P', 'E', 'R', 'V', 'E', 'R', 'T', 'I', 'C', 'A', 'L', 'A', 'L', 'I', 'G', 'N', 'M', 'E', 'N', 'T']\n assert candidate(s = \"MIX SOME VERY LONG WORDS IN THIS STRING\") == ['MSVLWITS', 'IOEOONHT', 'XMRNR IR', ' EYGD SI', ' S N', ' G']\n assert candidate(s = \"MULTILINE TEXT PRINTING\") == ['MTP', 'UER', 'LXI', 'TTN', 'I T', 'L I', 'I N', 'N G', 'E']\n assert candidate(s = \"VERY LONG WORDS IN THIS SENTENCE\") == ['VLWITS', 'EOONHE', 'RNR IN', 'YGD ST', ' S E', ' N', ' C', ' E']\n assert candidate(s = \"LEADING SPACES ARE IGNORED\") == ['LSAI', 'EPRG', 'AAEN', 'DC O', 'IE R', 'NS E', 'G D']\n assert candidate(s = \"VERTICAL PRINTING TEST CASE\") == ['VPTC', 'EREA', 'RISS', 'TNTE', 'IT', 'CI', 'AN', 'LG']\n assert candidate(s = \"REALLYLONGWORD THATS EVENLONGER\") == ['RTE', 'EHV', 'AAE', 'LTN', 'LSL', 'Y O', 'L N', 'O G', 'N E', 'G R', 'W', 'O', 'R', 'D']\n assert candidate(s = \"SIXTEENCHARACTERLIMITHERE\") == ['S', 'I', 'X', 'T', 'E', 'E', 'N', 'C', 'H', 'A', 'R', 'A', 'C', 'T', 'E', 'R', 'L', 'I', 'M', 'I', 'T', 'H', 'E', 'R', 'E']\n assert candidate(s = \"HIGH LEVEL LANGUAGE\") == ['HLL', 'IEA', 'GVN', 'HEG', ' LU', ' A', ' G', ' E']\n assert candidate(s = \"SAMELENGTH WORDS\") == ['SW', 'AO', 'MR', 'ED', 'LS', 'E', 'N', 'G', 'T', 'H']\n assert candidate(s = \"ONECHAR PER WORD A B C D E\") == ['OPWABCDE', 'NEO', 'ERR', 'C D', 'H', 'A', 'R']\n assert candidate(s = \"VARYING WORD LENGTHS\") == ['VWL', 'AOE', 'RRN', 'YDG', 'I T', 'N H', 'G S']\n assert candidate(s = \"PYTHON IS AWESOME\") == ['PIA', 'YSW', 'T E', 'H S', 'O O', 'N M', ' E']\n assert candidate(s = \"SHOULD HANDLE LARGE WORDS CORRECTLY\") == ['SHLWC', 'HAAOO', 'ONRRR', 'UDGDR', 'LLESE', 'DE C', ' T', ' L', ' Y']\n assert candidate(s = \"ONEVERYLONGWORDHERE\") == ['O', 'N', 'E', 'V', 'E', 'R', 'Y', 'L', 'O', 'N', 'G', 'W', 'O', 'R', 'D', 'H', 'E', 'R', 'E']\n assert candidate(s = \"HELLO WORLD FROM ALIBABA CLOUD\") == ['HWFAC', 'EORLL', 'LROIO', 'LLMBU', 'OD AD', ' B', ' A']\n assert candidate(s = \"DIFFERENT LENGTH WORDS\") == ['DLW', 'IEO', 'FNR', 'FGD', 'ETS', 'RH', 'E', 'N', 'T']\n assert candidate(s = \"UPPERCASE WORDS ONLY\") == ['UWO', 'PON', 'PRL', 'EDY', 'RS', 'C', 'A', 'S', 'E']\n assert candidate(s = \"THIS IS A LONG STRING FOR TESTING\") == ['TIALSFT', 'HS OTOE', 'I NRRS', 'S GI T', ' N I', ' G N', ' G']\n assert candidate(s = \"LEADING AND TRAILING SPACES ARE NOT ALLOWED\") == ['LATSANA', 'ENRPROL', 'ADAAETL', 'D IC O', 'I LE W', 'N IS E', 'G N D', ' G']\n assert candidate(s = \"SPECIAL CASES LIKE EMPTY STRING\") == ['SCLES', 'PAIMT', 'ESKPR', 'CEETI', 'IS YN', 'A G', 'L']\n assert candidate(s = \"UNIVERSAL ACCEPTANCE OF PYTHON\") == ['UAOP', 'NCFY', 'IC T', 'VE H', 'EP O', 'RT N', 'SA', 'AN', 'LC', ' E']\n assert candidate(s = \"HELLO WORLD FROM THE OTHER SIDE\") == ['HWFTOS', 'EORHTI', 'LROEHD', 'LLM EE', 'OD R']\n assert candidate(s = \"TESTING WITH SPECIAL CHARACTERS !@#\") == ['TWSC!', 'EIPH@', 'STEA#', 'THCR', 'I IA', 'N AC', 'G LT', ' E', ' R', ' S']\n assert candidate(s = \"MULTILINE STRING WITH MULTIPLE LINES\") == ['MSWML', 'UTIUI', 'LRTLN', 'TIHTE', 'IN IS', 'LG P', 'I L', 'N E', 'E']\n assert candidate(s = \"SHORTEST WORD\") == ['SW', 'HO', 'OR', 'RD', 'T', 'E', 'S', 'T']\n assert candidate(s = \"TEST WITH MANY WORDS AND DIFFERENT LENGTHS\") == ['TWMWADL', 'EIAONIE', 'STNRDFN', 'THYD FG', ' S ET', ' RH', ' ES', ' N', ' T']\n assert candidate(s = \"EXTREMELYLONGWORD SOMETIMES ARE NECESSARY\") == ['ESAN', 'XORE', 'TMEC', 'RE E', 'ET S', 'MI S', 'EM A', 'LE R', 'YS Y', 'L', 'O', 'N', 'G', 'W', 'O', 'R', 'D']\n assert candidate(s = \"EQUAL LENGTH WORDS HERE\") == ['ELWH', 'QEOE', 'UNRR', 'AGDE', 'LTS', ' H']\n assert candidate(s = \"HELLO WORLD THIS IS A VERTICALLY PRINTED TEXT\") == ['HWTIAVPT', 'EOHS ERE', 'LRI RIX', 'LLS TNT', 'OD IT', ' CE', ' AD', ' L', ' L', ' Y']\n assert candidate(s = \"SINGLE\") == ['S', 'I', 'N', 'G', 'L', 'E']\n assert candidate(s = \"PYTHONCODE JAVA CODE CSHARP\") == ['PJCC', 'YAOS', 'TVDH', 'HAEA', 'O R', 'N P', 'C', 'O', 'D', 'E']\n assert candidate(s = \"WITH MANY DIFFERENT LENGTHS\") == ['WMDL', 'IAIE', 'TNFN', 'HYFG', ' ET', ' RH', ' ES', ' N', ' T']\n assert candidate(s = \"DIFFERENT LENGTHS\") == ['DL', 'IE', 'FN', 'FG', 'ET', 'RH', 'ES', 'N', 'T']\n assert candidate(s = \"PYTHON PROGRAMMING\") == ['PP', 'YR', 'TO', 'HG', 'OR', 'NA', ' M', ' M', ' I', ' N', ' G']\n assert candidate(s = \"ALMOSTDONE\") == ['A', 'L', 'M', 'O', 'S', 'T', 'D', 'O', 'N', 'E']\n assert candidate(s = \"VARYING LENGTHS IN THIS STRING\") == ['VLITS', 'AENHT', 'RN IR', 'YG SI', 'IT N', 'NH G', 'GS']\n assert candidate(s = \"AVERYLONGWORDWITHNOSPACE\") == ['A', 'V', 'E', 'R', 'Y', 'L', 'O', 'N', 'G', 'W', 'O', 'R', 'D', 'W', 'I', 'T', 'H', 'N', 'O', 'S', 'P', 'A', 'C', 'E']\n assert candidate(s = \"PROGRAMMING CHALLENGES ARE FUN\") == ['PCAF', 'RHRU', 'OAEN', 'GL', 'RL', 'AE', 'MN', 'MG', 'IE', 'NS', 'G']\n assert candidate(s = \"TESTING EDGE CASES HERE\") == ['TECH', 'EDAE', 'SGSR', 'TEEE', 'I S', 'N', 'G']\n assert candidate(s = \"DIFFERENT SPACING TEST\") == ['DST', 'IPE', 'FAS', 'FCT', 'EI', 'RN', 'EG', 'N', 'T']\n assert candidate(s = \"MIXED SPACES AND VARYING LENGTHS\") == ['MSAVL', 'IPNAE', 'XADRN', 'EC YG', 'DE IT', ' S NH', ' GS']\n assert candidate(s = \"SPARSEMATRIX AND DENSEMATRIX\") == ['SAD', 'PNE', 'ADN', 'R S', 'S E', 'E M', 'M A', 'A T', 'T R', 'R I', 'I X', 'X']\n assert candidate(s = \"ALIGNED COLUMN OUTPUT\") == ['ACO', 'LOU', 'ILT', 'GUP', 'NMU', 'ENT', 'D']\n assert candidate(s = \"UPPERCASE LOWERCASE MIXEDCASE\") == ['ULM', 'POI', 'PWX', 'EEE', 'RRD', 'CCC', 'AAA', 'SSS', 'EEE']\n assert candidate(s = \"REALLYLONGWORD AND SHORT\") == ['RAS', 'ENH', 'ADO', 'L R', 'L T', 'Y', 'L', 'O', 'N', 'G', 'W', 'O', 'R', 'D']\n assert candidate(s = \"ONE\") == ['O', 'N', 'E']\n assert candidate(s = \"PYTHONJAVAJS CPLUSPLUS RUBY\") == ['PCR', 'YPU', 'TLB', 'HUY', 'OS', 'NP', 'JL', 'AU', 'VS', 'A', 'J', 'S']\n assert candidate(s = \"MULTILINE STRINGS ARE NOT ALLOWED\") == ['MSANA', 'UTROL', 'LRETL', 'TI O', 'IN W', 'LG E', 'IS D', 'N', 'E']\n assert candidate(s = \"VERTICAL PRINTING\") == ['VP', 'ER', 'RI', 'TN', 'IT', 'CI', 'AN', 'LG']\n assert candidate(s = \"VERTICAL PRINTING OF STRINGS\") == ['VPOS', 'ERFT', 'RI R', 'TN I', 'IT N', 'CI G', 'AN S', 'LG']\n assert candidate(s = \"TRAILING SPACES ARE NOT ALLOWED \") == ['TSANA', 'RPROL', 'AAETL', 'IC O', 'LE W', 'IS E', 'N D', 'G']\n assert candidate(s = \"MULTILINE VERTICAL PRINT\") == ['MVP', 'UER', 'LRI', 'TTN', 'IIT', 'LC', 'IA', 'NL', 'E']\n assert candidate(s = \"SINGLELETTERS ABC DEF GHI\") == ['SADG', 'IBEH', 'NCFI', 'G', 'L', 'E', 'L', 'E', 'T', 'T', 'E', 'R', 'S']\n assert candidate(s = \"SMALL LARGER LARGEST\") == ['SLL', 'MAA', 'ARR', 'LGG', 'LEE', ' RS', ' T']\n assert candidate(s = \"SAME LENGTH WORDS\") == ['SLW', 'AEO', 'MNR', 'EGD', ' TS', ' H']\n assert candidate(s = \"ALIGNS WORDS CORRECTLY\") == ['AWC', 'LOO', 'IRR', 'GDR', 'NSE', 'S C', ' T', ' L', ' Y']\n assert candidate(s = \"MIXED CASE STRING\") == ['MCS', 'IAT', 'XSR', 'EEI', 'D N', ' G']\n assert candidate(s = \"UPPERCASE LOWERCASE MIXED\") == ['ULM', 'POI', 'PWX', 'EEE', 'RRD', 'CC', 'AA', 'SS', 'EE']\n assert candidate(s = \"VERIFYING THE CORRECTNESS OF THE IMPLEMENTATION\") == ['VTCOTI', 'EHOFHM', 'RER EP', 'I R L', 'F E E', 'Y C M', 'I T E', 'N N N', 'G E T', ' S A', ' S T', ' I', ' O', ' N']\n assert candidate(s = \"HELLO WORLD HELLO WORLD\") == ['HWHW', 'EOEO', 'LRLR', 'LLLL', 'ODOD']\n assert candidate(s = \"PYTHON IS A GREAT LANGUAGE\") == ['PIAGL', 'YS RA', 'T EN', 'H AG', 'O TU', 'N A', ' G', ' E']\n assert candidate(s = \"MIXEDCASE Words ARE Allowed\") == ['MWAA', 'IoRl', 'XrEl', 'Ed o', 'Ds w', 'C e', 'A d', 'S', 'E']\n assert candidate(s = \"ONE TWO THREE FOUR FIVE SIX\") == ['OTTFFS', 'NWHOII', 'EORUVX', ' ERE', ' E']\n assert candidate(s = \"SPECIAL !@#$%^&*() CHARACTERS ARE NOT ALLOWED BUT UPPER CASE ONLY\") == ['S!CANABUCO', 'P@HROLUPAN', 'E#AETLTPSL', 'C$R O EEY', 'I%A W R', 'A^C E', 'L&T D', ' *E', ' (R', ' )S']\n assert candidate(s = \"MIXED CASE WITH VARYING LENGTHS\") == ['MCWVL', 'IAIAE', 'XSTRN', 'EEHYG', 'D IT', ' NH', ' GS']\n assert candidate(s = \"HELLO WORLD FROM PYTHON\") == ['HWFP', 'EORY', 'LROT', 'LLMH', 'OD O', ' N']\n assert candidate(s = \"LONGESTWORDINASENTENCEISHERE\") == ['L', 'O', 'N', 'G', 'E', 'S', 'T', 'W', 'O', 'R', 'D', 'I', 'N', 'A', 'S', 'E', 'N', 'T', 'E', 'N', 'C', 'E', 'I', 'S', 'H', 'E', 'R', 'E']\n assert candidate(s = \"EQUAL LENGTH WORDS\") == ['ELW', 'QEO', 'UNR', 'AGD', 'LTS', ' H']\n assert candidate(s = \"ONE TWO THREE FOUR FIVE SIX SEVEN\") == ['OTTFFSS', 'NWHOIIE', 'EORUVXV', ' ERE E', ' E N']\n assert candidate(s = \"MIXED LENGTHS SHORTEST LONGEST MIDDLE\") == ['MLSLM', 'IEHOI', 'XNOND', 'EGRGD', 'DTTEL', ' HESE', ' SST', ' T']\n assert candidate(s = \"PYTHON PROGRAMMING LANGUAGE\") == ['PPL', 'YRA', 'TON', 'HGG', 'ORU', 'NAA', ' MG', ' ME', ' I', ' N', ' G']\n assert candidate(s = \"LONGESTWORDFORTESTING VARYING LENGTHS TESTING\") == ['LVLT', 'OAEE', 'NRNS', 'GYGT', 'EITI', 'SNHN', 'TGSG', 'W', 'O', 'R', 'D', 'F', 'O', 'R', 'T', 'E', 'S', 'T', 'I', 'N', 'G']\n assert candidate(s = \"DIFFERENT LENGTH WORDS HERE\") == ['DLWH', 'IEOE', 'FNRR', 'FGDE', 'ETS', 'RH', 'E', 'N', 'T']\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().printVertically", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector printVertically(string s) {", "container": "Solution", "callable": "printVertically", "parameters": [{"name": "s", "type": "string"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1325, "task_id": "delete-leaves-with-a-given-value", "difficulty": "Medium", "problem_description": "Given a binary tree root and an integer target, delete all the leaf nodes with value target.\nNote that once you delete a leaf node with value target, if its parent node becomes a leaf node and has the value target, it should also be deleted (you need to continue doing that until you cannot).\n \nExample 1:\n\n\nInput: root = [1,2,3,2,null,2,4], target = 2\nOutput: [1,null,3,null,4]\nExplanation: Leaf nodes in green with value (target = 2) are removed (Picture in left). \nAfter removing, new nodes become leaf nodes with value (target = 2) (Picture in center).\n\nExample 2:\n\n\nInput: root = [1,3,3,3,2], target = 3\nOutput: [1,3,null,null,2]\n\nExample 3:\n\n\nInput: root = [1,2,null,2,null,2], target = 2\nOutput: [1]\nExplanation: Leaf nodes in green with value (target = 2) are removed at each step.\n\n \nConstraints:\n\nThe number of nodes in the tree is in the range [1, 3000].\n1 <= Node.val, target <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert is_same_tree(candidate(root = tree_node([1, 2, None, 2, None, 2]),target = 2), tree_node([1]))\n assert candidate(root = tree_node([1000, 1000, 1000, 1000, 1000, 1000, 1000]),target = 1000) == None\n assert candidate(root = tree_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),target = 1) == None\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, None, 4, 5, None, 6, 7, None, 8, 9, 10]),target = 5), tree_node([1, 2, 3, None, 4, 5, None, 6, 7, None, 8, 9, 10]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 2, None, 2, 4]),target = 2), tree_node([1, None, 3, None, 4]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 2, 2, 4, 2, None, 2, None, 2, None, 2]),target = 2), tree_node([1, 2, 3, 4, None, None, 4]))\n assert is_same_tree(candidate(root = tree_node([1, 3, 3, 3, 2]),target = 3), tree_node([1, 3, None, None, 2]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, None, None, None, 4]),target = 4), tree_node([1, 2, 3]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),target = 15), tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 2, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2]),target = 3), tree_node([1, 2, 2, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3]),target = 4), tree_node([1, 2, 3]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]),target = 2), tree_node([1]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, None, None, 4, 5]),target = 2), tree_node([1, None, 3, 4, 5]))\n assert candidate(root = tree_node([1, None, 1, None, 1, None, 1]),target = 1) == None\n assert is_same_tree(candidate(root = tree_node([1, 2, 3]),target = 2), tree_node([1, None, 3]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7]),target = 7), tree_node([1, 2, 3, 4, 5, 6]))\n assert candidate(root = tree_node([1, 1, 1, 1, 1, 1, 1]),target = 1) == None\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]),target = 2), tree_node([1, None, 3]))\n assert candidate(root = tree_node([1, None, 1, None, 1, None, 1, None, 1]),target = 1) == None\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),target = 10), tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, None, 11, 12, 13, 14, 15]))\n assert is_same_tree(candidate(root = tree_node([1, None, 3, None, 4, 5, None, 6, 7]),target = 2), tree_node([1, None, 3, None, 4, 5, None, 6, 7]))\n assert candidate(root = tree_node([1]),target = 1) == None\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, None, None, 4, 5]),target = 5), tree_node([1, 2, 3, None, None, 4]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 2, 2, 2, 4]),target = 2), tree_node([1, None, 3, None, 4]))\n assert is_same_tree(candidate(root = tree_node([1, None, 3, 3, 3]),target = 3), tree_node([1]))\n assert is_same_tree(candidate(root = tree_node([1, None, 3, 2, 2, None, 4, 2, None, 2]),target = 2), tree_node([1, None, 3, 2, None, None, 4]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7]),target = 3), tree_node([1, 2, 3, 4, 5, 6, 7]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 2, 2, 2, 2]),target = 2), tree_node([1, None, 3]))\n assert candidate(root = tree_node([1, None, 1, 1, 1, 1, 1, 1]),target = 1) == None\n"}, "metadata": {"canonical_parameter_names": ["root", "target"], "leetcode_dataset_entry_point": "Solution().removeLeafNodes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "TreeNode* removeLeafNodes(TreeNode* root, int target) {", "container": "Solution", "callable": "removeLeafNodes", "parameters": [{"name": "root", "type": "TreeNode*"}, {"name": "target", "type": "int"}], "return_type": "TreeNode*", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1326, "task_id": "minimum-number-of-taps-to-open-to-water-a-garden", "difficulty": "Hard", "problem_description": "There is a one-dimensional garden on the x-axis. The garden starts at the point 0 and ends at the point n. (i.e., the length of the garden is n).\nThere are n + 1 taps located at points [0, 1, ..., n] in the garden.\nGiven an integer n and an integer array ranges of length n + 1 where ranges[i] (0-indexed) means the i-th tap can water the area [i - ranges[i], i + ranges[i]] if it was open.\nReturn the minimum number of taps that should be open to water the whole garden, If the garden cannot be watered return -1.\n \nExample 1:\n\n\nInput: n = 5, ranges = [3,4,1,1,0,0]\nOutput: 1\nExplanation: The tap at point 0 can cover the interval [-3,3]\nThe tap at point 1 can cover the interval [-3,5]\nThe tap at point 2 can cover the interval [1,3]\nThe tap at point 3 can cover the interval [2,4]\nThe tap at point 4 can cover the interval [4,4]\nThe tap at point 5 can cover the interval [5,5]\nOpening Only the second tap will water the whole garden [0,5]\n\nExample 2:\n\nInput: n = 3, ranges = [0,0,0,0]\nOutput: -1\nExplanation: Even if you activate all the four taps you cannot water the whole garden.\n\n \nConstraints:\n\n1 <= n <= 104\nranges.length == n + 1\n0 <= ranges[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,ranges = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 5,ranges = [3, 4, 1, 1, 0, 0]) == 1\n assert candidate(n = 8,ranges = [4, 0, 0, 0, 0, 0, 0, 0, 4]) == 2\n assert candidate(n = 3,ranges = [0, 0, 0, 0]) == -1\n assert candidate(n = 2,ranges = [1, 0, 1]) == 2\n assert candidate(n = 6,ranges = [1, 2, 3, 4, 5, 6, 7]) == 1\n assert candidate(n = 8,ranges = [4, 0, 0, 0, 0, 0, 1, 0, 1]) == -1\n assert candidate(n = 7,ranges = [1, 2, 1, 0, 2, 1, 0, 1]) == 3\n assert candidate(n = 10,ranges = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(n = 6,ranges = [1, 2, 1, 0, 2, 1, 0]) == 2\n assert candidate(n = 1,ranges = [1, 1]) == 1\n assert candidate(n = 6,ranges = [1, 2, 2, 1, 0, 1, 0]) == 2\n assert candidate(n = 20,ranges = [0, 2, 1, 1, 0, 2, 1, 0, 1, 0, 1, 0, 1, 0, 2, 1, 0, 1, 0, 1, 0]) == 8\n assert candidate(n = 7,ranges = [1, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(n = 12,ranges = [0, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2]) == 6\n assert candidate(n = 20,ranges = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 6\n assert candidate(n = 20,ranges = [5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 20,ranges = [4, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 1, 2, 0, 1, 0, 0, 1, 0, 1, 0]) == -1\n assert candidate(n = 10,ranges = [2, 3, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 3\n assert candidate(n = 20,ranges = [5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5]) == -1\n assert candidate(n = 15,ranges = [3, 0, 0, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0]) == -1\n assert candidate(n = 14,ranges = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 7,ranges = [3, 2, 2, 3, 2, 2, 1, 1]) == 2\n assert candidate(n = 10,ranges = [2, 3, 0, 2, 1, 0, 1, 0, 1, 0, 1]) == 5\n assert candidate(n = 14,ranges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1]) == 1\n assert candidate(n = 25,ranges = [4, 2, 1, 1, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 7,ranges = [0, 1, 0, 0, 1, 0, 1, 0]) == -1\n assert candidate(n = 12,ranges = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(n = 12,ranges = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 2\n assert candidate(n = 15,ranges = [1, 2, 2, 3, 1, 2, 3, 0, 1, 2, 1, 0, 1, 2, 1, 0]) == 4\n assert candidate(n = 9,ranges = [0, 0, 2, 0, 0, 0, 2, 0, 0, 2]) == 3\n assert candidate(n = 11,ranges = [0, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 5\n assert candidate(n = 12,ranges = [4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4]) == -1\n assert candidate(n = 12,ranges = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == -1\n assert candidate(n = 9,ranges = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 5\n assert candidate(n = 10,ranges = [2, 2, 0, 2, 2, 0, 1, 0, 1, 2, 0]) == 4\n assert candidate(n = 12,ranges = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 3\n assert candidate(n = 10,ranges = [3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(n = 9,ranges = [0, 0, 1, 0, 0, 0, 0, 0, 1, 1]) == -1\n assert candidate(n = 25,ranges = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 8,ranges = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(n = 15,ranges = [3, 1, 4, 2, 1, 0, 1, 0, 0, 2, 3, 0, 1, 0, 1, 0]) == 4\n assert candidate(n = 8,ranges = [0, 1, 2, 3, 4, 3, 2, 1, 0]) == 1\n assert candidate(n = 13,ranges = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(n = 12,ranges = [0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 4]) == -1\n assert candidate(n = 20,ranges = [3, 1, 0, 0, 0, 0, 0, 2, 2, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0]) == -1\n assert candidate(n = 7,ranges = [3, 2, 1, 0, 0, 0, 2, 1]) == -1\n assert candidate(n = 7,ranges = [3, 0, 1, 2, 0, 1, 0, 1]) == 4\n assert candidate(n = 12,ranges = [0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0]) == 1\n assert candidate(n = 20,ranges = [10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 8,ranges = [0, 1, 0, 0, 0, 2, 1, 0, 1]) == -1\n assert candidate(n = 15,ranges = [3, 0, 1, 1, 0, 2, 1, 0, 0, 2, 3, 1, 0, 1, 0, 1]) == 5\n assert candidate(n = 9,ranges = [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == -1\n assert candidate(n = 15,ranges = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(n = 12,ranges = [2, 3, 0, 1, 0, 3, 0, 1, 0, 0, 1, 0, 1]) == -1\n assert candidate(n = 10,ranges = [3, 1, 2, 1, 3, 2, 1, 1, 2, 3, 1]) == 3\n assert candidate(n = 12,ranges = [0, 0, 3, 0, 0, 2, 0, 1, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 25,ranges = [0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 20,ranges = [10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10]) == 2\n assert candidate(n = 11,ranges = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 6\n assert candidate(n = 8,ranges = [3, 0, 2, 1, 1, 0, 2, 1, 1]) == 2\n assert candidate(n = 10,ranges = [2, 3, 1, 1, 0, 2, 1, 0, 1, 2, 1]) == 3\n assert candidate(n = 18,ranges = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == -1\n assert candidate(n = 10,ranges = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1]) == 2\n assert candidate(n = 8,ranges = [0, 0, 2, 0, 0, 0, 2, 1, 1]) == 2\n assert candidate(n = 18,ranges = [5, 0, 3, 0, 0, 0, 0, 2, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 4]) == 6\n assert candidate(n = 14,ranges = [0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0]) == -1\n assert candidate(n = 10,ranges = [2, 3, 1, 4, 0, 1, 2, 0, 3, 1, 2]) == 2\n assert candidate(n = 11,ranges = [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == -1\n assert candidate(n = 8,ranges = [1, 0, 1, 1, 0, 0, 0, 1, 1]) == -1\n assert candidate(n = 15,ranges = [3, 0, 0, 0, 3, 2, 0, 1, 0, 0, 2, 0, 0, 0, 1]) == -1\n assert candidate(n = 10,ranges = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 3\n assert candidate(n = 13,ranges = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 9,ranges = [4, 0, 0, 0, 4, 0, 0, 0, 4, 0]) == 2\n assert candidate(n = 10,ranges = [2, 3, 1, 4, 0, 0, 2, 0, 1, 0, 1]) == 3\n assert candidate(n = 15,ranges = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(n = 18,ranges = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == -1\n assert candidate(n = 15,ranges = [3, 0, 1, 1, 0, 0, 0, 1, 2, 1, 0, 1, 1, 0, 0, 3]) == -1\n assert candidate(n = 14,ranges = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1]) == 1\n assert candidate(n = 9,ranges = [0, 2, 1, 3, 1, 2, 0, 1, 0, 2]) == 3\n assert candidate(n = 14,ranges = [3, 2, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1]) == -1\n assert candidate(n = 20,ranges = [5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5]) == -1\n assert candidate(n = 7,ranges = [3, 2, 0, 0, 1, 0, 1, 1]) == 3\n assert candidate(n = 12,ranges = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 1\n assert candidate(n = 50,ranges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == -1\n assert candidate(n = 12,ranges = [0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]) == -1\n assert candidate(n = 15,ranges = [1, 2, 2, 3, 1, 2, 3, 2, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(n = 20,ranges = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(n = 25,ranges = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 3\n assert candidate(n = 20,ranges = [4, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(n = 10,ranges = [2, 3, 1, 0, 0, 1, 2, 1, 0, 2, 0]) == 3\n assert candidate(n = 20,ranges = [2, 0, 0, 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0]) == -1\n assert candidate(n = 20,ranges = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 2\n"}, "metadata": {"canonical_parameter_names": ["n", "ranges"], "leetcode_dataset_entry_point": "Solution().minTaps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minTaps(int n, vector& ranges) {", "container": "Solution", "callable": "minTaps", "parameters": [{"name": "n", "type": "int"}, {"name": "ranges", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1328, "task_id": "break-a-palindrome", "difficulty": "Medium", "problem_description": "Given a palindromic string of lowercase English letters palindrome, replace exactly one character with any lowercase English letter so that the resulting string is not a palindrome and that it is the lexicographically smallest one possible.\nReturn the resulting string. If there is no way to replace a character to make it not a palindrome, return an empty string.\nA string a is lexicographically smaller than a string b (of the same length) if in the first position where a and b differ, a has a character strictly smaller than the corresponding character in b. For example, \"abcc\" is lexicographically smaller than \"abcd\" because the first position they differ is at the fourth character, and 'c' is smaller than 'd'.\n \nExample 1:\n\nInput: palindrome = \"abccba\"\nOutput: \"aaccba\"\nExplanation: There are many ways to make \"abccba\" not a palindrome, such as \"zbccba\", \"aaccba\", and \"abacba\".\nOf all the ways, \"aaccba\" is the lexicographically smallest.\n\nExample 2:\n\nInput: palindrome = \"a\"\nOutput: \"\"\nExplanation: There is no way to replace a single character to make \"a\" not a palindrome, so return an empty string.\n\n \nConstraints:\n\n1 <= palindrome.length <= 1000\npalindrome consists of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(palindrome = \"refer\") == \"aefer\"\n assert candidate(palindrome = \"abba\") == \"aaba\"\n assert candidate(palindrome = \"rotor\") == \"aotor\"\n assert candidate(palindrome = \"aa\") == \"ab\"\n assert candidate(palindrome = \"aba\") == \"abb\"\n assert candidate(palindrome = \"a\") == \"\"\n assert candidate(palindrome = \"madam\") == \"aadam\"\n assert candidate(palindrome = \"abccba\") == \"aaccba\"\n assert candidate(palindrome = \"racecar\") == \"aacecar\"\n assert candidate(palindrome = \"moom\") == \"aoom\"\n assert candidate(palindrome = \"aabaa\") == \"aabab\"\n assert candidate(palindrome = \"zzz\") == \"azz\"\n assert candidate(palindrome = \"xyx\") == \"ayx\"\n assert candidate(palindrome = \"level\") == \"aevel\"\n assert candidate(palindrome = \"aaaaa\") == \"aaaab\"\n assert candidate(palindrome = \"abcdedcba\") == \"aacdedcba\"\n assert candidate(palindrome = \"abcba\") == \"aacba\"\n assert candidate(palindrome = \"bcb\") == \"acb\"\n assert candidate(palindrome = \"noon\") == \"aoon\"\n assert candidate(palindrome = \"mamad\") == \"aamad\"\n assert candidate(palindrome = \"deified\") == \"aeified\"\n assert candidate(palindrome = \"z\") == \"\"\n assert candidate(palindrome = \"aabaaa\") == \"aaaaaa\"\n assert candidate(palindrome = \"toot\") == \"aoot\"\n assert candidate(palindrome = \"babababab\") == \"aabababab\"\n assert candidate(palindrome = \"peep\") == \"aeep\"\n assert candidate(palindrome = \"ppppppppp\") == \"apppppppp\"\n assert candidate(palindrome = \"aabbaa\") == \"aaabaa\"\n assert candidate(palindrome = \"abcdefghihgfedcba\") == \"aacdefghihgfedcba\"\n assert candidate(palindrome = \"zzzzzzzz\") == \"azzzzzzz\"\n assert candidate(palindrome = \"bbaab\") == \"abaab\"\n assert candidate(palindrome = \"redder\") == \"aedder\"\n assert candidate(palindrome = \"abcdefghgfedcba\") == \"aacdefghgfedcba\"\n assert candidate(palindrome = \"abcdefghijklmnoponmlkjihgfedcbaedcbafghijklmnop\") == \"aacdefghijklmnoponmlkjihgfedcbaedcbafghijklmnop\"\n assert candidate(palindrome = \"abacaba\") == \"aaacaba\"\n assert candidate(palindrome = \"aabbccddeeffgggggeeeddccbbaa\") == \"aaabccddeeffgggggeeeddccbbaa\"\n assert candidate(palindrome = \"xyzzyx\") == \"ayzzyx\"\n assert candidate(palindrome = \"kayakkayak\") == \"aayakkayak\"\n assert candidate(palindrome = \"repaper\") == \"aepaper\"\n assert candidate(palindrome = \"aaaaaaaa\") == \"aaaaaaab\"\n assert candidate(palindrome = \"ivicc\") == \"avicc\"\n assert candidate(palindrome = \"abaacaaba\") == \"aaaacaaba\"\n assert candidate(palindrome = \"racecarxracecar\") == \"aacecarxracecar\"\n assert candidate(palindrome = \"abacdfgdcaba\") == \"aaacdfgdcaba\"\n assert candidate(palindrome = \"nnnnnnnnna\") == \"annnnnnnna\"\n assert candidate(palindrome = \"aaaaaaaaa\") == \"aaaaaaaab\"\n assert candidate(palindrome = \"abcdddcba\") == \"aacdddcba\"\n assert candidate(palindrome = \"aabbccddeeffgggeeeddccbbaa\") == \"aaabccddeeffgggeeeddccbbaa\"\n assert candidate(palindrome = \"stats\") == \"atats\"\n assert candidate(palindrome = \"aacaaca\") == \"aaaaaca\"\n assert candidate(palindrome = \"reviver\") == \"aeviver\"\n assert candidate(palindrome = \"aabbccddeedccbaa\") == \"aaabccddeedccbaa\"\n assert candidate(palindrome = \"amanaplanacanalpanama\") == \"aaanaplanacanalpanama\"\n assert candidate(palindrome = \"xyzyx\") == \"ayzyx\"\n assert candidate(palindrome = \"ababababab\") == \"aaabababab\"\n assert candidate(palindrome = \"zzzzzzzzz\") == \"azzzzzzzz\"\n assert candidate(palindrome = \"abaababa\") == \"aaaababa\"\n assert candidate(palindrome = \"aaaaaaaaaa\") == \"aaaaaaaaab\"\n assert candidate(palindrome = \"aabbccddeedccbbaa\") == \"aaabccddeedccbbaa\"\n assert candidate(palindrome = \"noonnoon\") == \"aoonnoon\"\n assert candidate(palindrome = \"aabbccddeeffgggeeddccbbaa\") == \"aaabccddeeffgggeeddccbbaa\"\n assert candidate(palindrome = \"reviled\") == \"aeviled\"\n assert candidate(palindrome = \"aabbbaa\") == \"aaabbaa\"\n assert candidate(palindrome = \"aabbccddeeffggfeeddccbbaa\") == \"aaabccddeeffggfeeddccbbaa\"\n assert candidate(palindrome = \"rotator\") == \"aotator\"\n assert candidate(palindrome = \"abccbaa\") == \"aaccbaa\"\n assert candidate(palindrome = \"bbbbb\") == \"abbbb\"\n assert candidate(palindrome = \"aaa\") == \"aab\"\n assert candidate(palindrome = \"aabbccddeccbaa\") == \"aaabccddeccbaa\"\n assert candidate(palindrome = \"ababababa\") == \"aaabababa\"\n assert candidate(palindrome = \"aabbccddeeffgggggggeeeddccbbaa\") == \"aaabccddeeffgggggggeeeddccbbaa\"\n assert candidate(palindrome = \"aaaabaaa\") == \"aaaabaab\"\n assert candidate(palindrome = \"fedcbafedcba\") == \"aedcbafedcba\"\n assert candidate(palindrome = \"abcbaba\") == \"aacbaba\"\n assert candidate(palindrome = \"aaabaaa\") == \"aaabaab\"\n assert candidate(palindrome = \"zyxwvutsrqponmlkjihgfedcbaedcba\") == \"ayxwvutsrqponmlkjihgfedcbaedcba\"\n assert candidate(palindrome = \"sees\") == \"aees\"\n assert candidate(palindrome = \"aabbccddeeffggggggfeeddccbbaa\") == \"aaabccddeeffggggggfeeddccbbaa\"\n assert candidate(palindrome = \"aaaaaaa\") == \"aaaaaab\"\n assert candidate(palindrome = \"bbcb\") == \"abcb\"\n assert candidate(palindrome = \"zyxwvutsrqponmlkjihgfedcbaedcbafghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == \"ayxwvutsrqponmlkjihgfedcbaedcbafghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\"\n assert candidate(palindrome = \"civic\") == \"aivic\"\n assert candidate(palindrome = \"zzzzzzz\") == \"azzzzzz\"\n assert candidate(palindrome = \"babababababababababababababababababa\") == \"aabababababababababababababababababa\"\n assert candidate(palindrome = \"repaid\") == \"aepaid\"\n assert candidate(palindrome = \"rotorrotor\") == \"aotorrotor\"\n assert candidate(palindrome = \"abcdeedcba\") == \"aacdeedcba\"\n assert candidate(palindrome = \"reeve\") == \"aeeve\"\n assert candidate(palindrome = \"abcddddcba\") == \"aacddddcba\"\n assert candidate(palindrome = \"kayak\") == \"aayak\"\n assert candidate(palindrome = \"reviler\") == \"aeviler\"\n assert candidate(palindrome = \"abcdefedcba\") == \"aacdefedcba\"\n assert candidate(palindrome = \"rotavator\") == \"aotavator\"\n assert candidate(palindrome = \"madamimadam\") == \"aadamimadam\"\n assert candidate(palindrome = \"redivider\") == \"aedivider\"\n assert candidate(palindrome = \"abacabadaba\") == \"aaacabadaba\"\n assert candidate(palindrome = \"abcddcba\") == \"aacddcba\"\n assert candidate(palindrome = \"aaaabaaaa\") == \"aaaabaaab\"\n assert candidate(palindrome = \"leveler\") == \"aeveler\"\n assert candidate(palindrome = \"abababa\") == \"aaababa\"\n assert candidate(palindrome = \"abecba\") == \"aaecba\"\n assert candidate(palindrome = \"zaz\") == \"aaz\"\n assert candidate(palindrome = \"aabbccbaa\") == \"aaabccbaa\"\n assert candidate(palindrome = \"abcdcba\") == \"aacdcba\"\n assert candidate(palindrome = \"aabbccddeeffggggfeeddccbbaa\") == \"aaabccddeeffggggfeeddccbbaa\"\n assert candidate(palindrome = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcb\") == \"acbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcb\"\n assert candidate(palindrome = \"anana\") == \"aaana\"\n assert candidate(palindrome = \"bababababa\") == \"aababababa\"\n assert candidate(palindrome = \"zzzzz\") == \"azzzz\"\n assert candidate(palindrome = \"abcaaba\") == \"aacaaba\"\n assert candidate(palindrome = \"bob\") == \"aob\"\n assert candidate(palindrome = \"abaabaaabaabaa\") == \"aaaabaaabaabaa\"\n assert candidate(palindrome = \"deed\") == \"aeed\"\n assert candidate(palindrome = \"detartrated\") == \"aetartrated\"\n assert candidate(palindrome = \"civiccivic\") == \"aiviccivic\"\n assert candidate(palindrome = \"zzzz\") == \"azzz\"\n assert candidate(palindrome = \"repel\") == \"aepel\"\n assert candidate(palindrome = \"deedeed\") == \"aeedeed\"\n"}, "metadata": {"canonical_parameter_names": ["palindrome"], "leetcode_dataset_entry_point": "Solution().breakPalindrome", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string breakPalindrome(string palindrome) {", "container": "Solution", "callable": "breakPalindrome", "parameters": [{"name": "palindrome", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1329, "task_id": "sort-the-matrix-diagonally", "difficulty": "Medium", "problem_description": "A matrix diagonal is a diagonal line of cells starting from some cell in either the topmost row or leftmost column and going in the bottom-right direction until reaching the matrix's end. For example, the matrix diagonal starting from mat[2][0], where mat is a 6 x 3 matrix, includes cells mat[2][0], mat[3][1], and mat[4][2].\nGiven an m x n matrix mat of integers, sort each matrix diagonal in ascending order and return the resulting matrix.\n \nExample 1:\n\n\nInput: mat = [[3,3,1,1],[2,2,1,2],[1,1,1,2]]\nOutput: [[1,1,1,1],[1,2,2,2],[1,2,3,3]]\n\nExample 2:\n\nInput: mat = [[11,25,66,1,69,7],[23,55,17,45,15,52],[75,31,36,44,58,8],[22,27,33,25,68,4],[84,28,14,11,5,50]]\nOutput: [[5,17,4,1,52,7],[11,11,25,45,8,69],[14,23,25,44,58,15],[22,27,31,36,50,66],[84,28,75,33,55,68]]\n\n \nConstraints:\n\nm == mat.length\nn == mat[i].length\n1 <= m, n <= 100\n1 <= mat[i][j] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1]]) == [[1]]\n assert candidate(mat = [[37, 47, 1, 44], [20, 3, 2, 90], [96, 50, 4, 24]]) == [[3, 2, 1, 44], [20, 4, 24, 90], [96, 50, 37, 47]]\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]\n assert candidate(mat = [[30, 29, 28, 27, 26, 25], [24, 23, 22, 21, 20, 19], [18, 17, 16, 15, 14, 13], [12, 11, 10, 9, 8, 7], [6, 5, 4, 3, 2, 1]]) == [[2, 1, 7, 13, 19, 25], [3, 9, 8, 14, 20, 26], [4, 10, 16, 15, 21, 27], [5, 11, 17, 23, 22, 28], [6, 12, 18, 24, 30, 29]]\n assert candidate(mat = [[30, 29, 19, 53, 22], [47, 27, 45, 54, 30], [28, 42, 23, 45, 52], [40, 11, 52, 33, 46], [15, 50, 46, 32, 48]]) == [[23, 29, 19, 30, 22], [32, 27, 45, 52, 53], [11, 42, 30, 45, 54], [40, 28, 47, 33, 46], [15, 50, 46, 52, 48]]\n assert candidate(mat = [[11, 25, 66, 1, 69, 7], [23, 55, 17, 45, 15, 52], [75, 31, 36, 44, 58, 8], [22, 27, 33, 25, 68, 4], [84, 28, 14, 11, 5, 50]]) == [[5, 17, 4, 1, 52, 7], [11, 11, 25, 45, 8, 69], [14, 23, 25, 44, 58, 15], [22, 27, 31, 36, 50, 66], [84, 28, 75, 33, 55, 68]]\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8]]) == [[1, 2], [3, 4], [5, 6], [7, 8]]\n assert candidate(mat = [[9, 8, 7], [6, 5, 4], [3, 2, 1]]) == [[1, 4, 7], [2, 5, 8], [3, 6, 9]]\n assert candidate(mat = [[3, 3, 1, 1], [2, 2, 1, 2], [1, 1, 1, 2]]) == [[1, 1, 1, 1], [1, 2, 2, 2], [1, 2, 3, 3]]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == [[1, 2, 3], [4, 5, 6], [7, 8, 9]]\n assert candidate(mat = [[10, 9, 8, 7], [6, 5, 4, 3], [2, 1, 0, -1]]) == [[0, -1, 3, 7], [1, 5, 4, 8], [2, 6, 10, 9]]\n assert candidate(mat = [[100, 99, 98], [97, 96, 95], [94, 93, 92]]) == [[92, 95, 98], [93, 96, 99], [94, 97, 100]]\n assert candidate(mat = [[10, 9, 8, 7], [6, 5, 4, 3], [2, 1, 1, 1]]) == [[1, 1, 3, 7], [1, 5, 4, 8], [2, 6, 10, 9]]\n assert candidate(mat = [[37, 71], [58, 62]]) == [[37, 71], [58, 62]]\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]\n assert candidate(mat = [[1, 10, 3, 7, 5], [6, 2, 8, 4, 1], [11, 13, 12, 15, 14], [17, 16, 19, 18, 20]]) == [[1, 8, 3, 1, 5], [6, 2, 10, 4, 7], [11, 13, 12, 15, 14], [17, 16, 19, 18, 20]]\n assert candidate(mat = [[100, 99, 98, 97, 96, 95, 94, 93, 92, 91], [90, 89, 88, 87, 86, 85, 84, 83, 82, 81], [80, 79, 78, 77, 76, 75, 74, 73, 72, 71], [70, 69, 68, 67, 66, 65, 64, 63, 62, 61], [60, 59, 58, 57, 56, 55, 54, 53, 52, 51], [50, 49, 48, 47, 46, 45, 44, 43, 42, 41], [40, 39, 38, 37, 36, 35, 34, 33, 32, 31], [30, 29, 28, 27, 26, 25, 24, 23, 22, 21], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == [[1, 11, 21, 31, 41, 51, 61, 71, 81, 91], [2, 12, 22, 32, 42, 52, 62, 72, 82, 92], [3, 13, 23, 33, 43, 53, 63, 73, 83, 93], [4, 14, 24, 34, 44, 54, 64, 74, 84, 94], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95], [6, 16, 26, 36, 46, 56, 66, 76, 86, 96], [7, 17, 27, 37, 47, 57, 67, 77, 87, 97], [8, 18, 28, 38, 48, 58, 68, 78, 88, 98], [9, 19, 29, 39, 49, 59, 69, 79, 89, 99], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]\n assert candidate(mat = [[99, 98, 97, 96, 95], [94, 93, 92, 91, 90], [89, 88, 87, 86, 85], [84, 83, 82, 81, 80], [79, 78, 77, 76, 75]]) == [[75, 80, 85, 90, 95], [76, 81, 86, 91, 96], [77, 82, 87, 92, 97], [78, 83, 88, 93, 98], [79, 84, 89, 94, 99]]\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14], [2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15], [3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14, 1], [4, 6, 8, 10, 12, 14, 1, 2, 3, 5, 7, 9, 11, 13, 15], [5, 7, 9, 11, 13, 15, 2, 3, 4, 6, 8, 10, 12, 14, 1], [6, 8, 10, 12, 14, 1, 2, 3, 4, 5, 7, 9, 11, 13, 15]]) == [[1, 1, 2, 2, 1, 3, 2, 4, 1, 5, 1, 3, 2, 1, 15], [2, 2, 2, 3, 3, 4, 6, 5, 7, 6, 8, 4, 12, 13, 14], [1, 3, 3, 3, 4, 4, 5, 6, 7, 7, 6, 10, 10, 12, 14], [2, 1, 6, 5, 4, 5, 6, 5, 7, 8, 8, 9, 11, 11, 15], [3, 5, 4, 9, 8, 7, 9, 7, 8, 9, 8, 10, 9, 14, 13], [4, 6, 8, 7, 12, 11, 10, 12, 11, 9, 10, 9, 11, 12, 15], [5, 7, 9, 11, 10, 15, 14, 13, 12, 11, 10, 11, 12, 14, 13], [6, 8, 10, 12, 14, 13, 15, 14, 13, 15, 14, 13, 15, 13, 15]]\n assert candidate(mat = [[1, 9, 3, 7, 5], [6, 2, 8, 4, 10], [11, 13, 12, 15, 14], [17, 16, 19, 18, 20]]) == [[1, 8, 3, 7, 5], [6, 2, 9, 4, 10], [11, 13, 12, 15, 14], [17, 16, 19, 18, 20]]\n assert candidate(mat = [[15, 25, 35, 45, 55], [14, 24, 34, 44, 54], [13, 23, 33, 43, 53], [12, 22, 32, 42, 52], [11, 21, 31, 41, 51]]) == [[15, 25, 35, 45, 55], [14, 24, 34, 44, 54], [13, 23, 33, 43, 53], [12, 22, 32, 42, 52], [11, 21, 31, 41, 51]]\n assert candidate(mat = [[8, 5, 2, 7], [9, 6, 3, 4], [1, 0, 5, 8], [2, 1, 6, 3]]) == [[3, 3, 2, 7], [0, 5, 5, 4], [1, 6, 6, 8], [2, 1, 9, 8]]\n assert candidate(mat = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]\n assert candidate(mat = [[99, 98, 97, 96, 95, 94, 93, 92, 91, 90], [89, 88, 87, 86, 85, 84, 83, 82, 81, 80], [79, 78, 77, 76, 75, 74, 73, 72, 71, 70], [69, 68, 67, 66, 65, 64, 63, 62, 61, 60], [59, 58, 57, 56, 55, 54, 53, 52, 51, 50], [49, 48, 47, 46, 45, 44, 43, 42, 41, 40], [39, 38, 37, 36, 35, 34, 33, 32, 31, 30], [29, 28, 27, 26, 25, 24, 23, 22, 21, 20], [19, 18, 17, 16, 15, 14, 13, 12, 11, 10], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]]) == [[0, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 11, 21, 31, 41, 51, 61, 71, 81, 91], [2, 12, 22, 32, 42, 52, 62, 72, 82, 92], [3, 13, 23, 33, 43, 53, 63, 73, 83, 93], [4, 14, 24, 34, 44, 54, 64, 74, 84, 94], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95], [6, 16, 26, 36, 46, 56, 66, 76, 86, 96], [7, 17, 27, 37, 47, 57, 67, 77, 87, 97], [8, 18, 28, 38, 48, 58, 68, 78, 88, 98], [9, 19, 29, 39, 49, 59, 69, 79, 89, 99]]\n assert candidate(mat = [[50, 30, 10, 90], [80, 60, 40, 20], [70, 50, 30, 10], [60, 40, 20, 80], [50, 30, 10, 70], [40, 20, 80, 60], [30, 10, 70, 50]]) == [[30, 10, 10, 90], [20, 50, 30, 20], [10, 50, 60, 40], [30, 40, 70, 80], [20, 50, 60, 80], [10, 50, 60, 70], [30, 40, 70, 80]]\n assert candidate(mat = [[9, 7, 5, 3, 1], [10, 8, 6, 4, 2], [11, 9, 7, 5, 3], [12, 10, 8, 6, 4], [13, 11, 9, 7, 5]]) == [[5, 4, 3, 2, 1], [7, 6, 5, 4, 3], [9, 8, 7, 6, 5], [11, 10, 9, 8, 7], [13, 12, 11, 10, 9]]\n assert candidate(mat = [[1, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7], [3, 4, 5, 6, 7, 8], [4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10]]) == [[1, 4, 5, 6, 7, 10], [2, 3, 6, 7, 8, 9], [3, 4, 5, 6, 7, 8], [4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10]]\n assert candidate(mat = [[1, 3, 5, 7, 9], [10, 8, 6, 4, 2], [11, 13, 15, 17, 19], [20, 18, 16, 14, 12]]) == [[1, 3, 4, 2, 9], [10, 8, 6, 5, 7], [11, 13, 14, 12, 19], [20, 18, 16, 15, 17]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60]]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60]]\n assert candidate(mat = [[100, 99, 98, 97, 96, 95, 94, 93, 92, 91], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]]) == [[2, 3, 4, 5, 6, 7, 8, 9, 10, 91], [1, 13, 14, 15, 16, 17, 18, 19, 20, 92], [11, 12, 24, 25, 26, 27, 28, 29, 30, 93], [21, 22, 23, 100, 99, 98, 97, 96, 95, 94]]\n assert candidate(mat = [[50, 40, 30, 20, 10], [55, 45, 35, 25, 15], [60, 50, 40, 30, 20], [65, 55, 45, 35, 25], [70, 60, 50, 40, 30]]) == [[30, 25, 20, 15, 10], [40, 35, 30, 25, 20], [50, 45, 40, 35, 30], [60, 55, 50, 45, 40], [70, 65, 60, 55, 50]]\n assert candidate(mat = [[1, 9, 2, 8, 3, 7, 4, 6, 5], [2, 8, 3, 7, 4, 6, 5, 9, 1], [3, 7, 4, 6, 5, 9, 1, 2, 8], [4, 6, 5, 9, 1, 2, 8, 3, 7], [5, 9, 1, 2, 8, 3, 7, 4, 6]]) == [[1, 1, 2, 4, 1, 2, 4, 1, 5], [2, 4, 3, 2, 4, 3, 5, 8, 6], [1, 2, 8, 3, 5, 8, 3, 7, 9], [4, 3, 5, 8, 6, 7, 8, 6, 7], [5, 9, 6, 7, 9, 9, 7, 9, 6]]\n assert candidate(mat = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [10, 9, 8, 7, 6, 5, 4, 3, 2], [11, 10, 9, 8, 7, 6, 5, 4, 3], [12, 11, 10, 9, 8, 7, 6, 5, 4], [13, 12, 11, 10, 9, 8, 7, 6, 5]]) == [[9, 8, 7, 6, 5, 4, 3, 2, 1], [10, 9, 8, 7, 6, 5, 4, 3, 2], [11, 10, 9, 8, 7, 6, 5, 4, 3], [12, 11, 10, 9, 8, 7, 6, 5, 4], [13, 12, 11, 10, 9, 8, 7, 6, 5]]\n assert candidate(mat = [[5, 4, 3, 2, 1], [9, 8, 7, 6, 5], [13, 12, 11, 10, 9], [17, 16, 15, 14, 13], [21, 20, 19, 18, 17]]) == [[5, 4, 3, 2, 1], [9, 8, 7, 6, 5], [13, 12, 11, 10, 9], [17, 16, 15, 14, 13], [21, 20, 19, 18, 17]]\n assert candidate(mat = [[10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10]]) == [[10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10]]\n assert candidate(mat = [[25, 24, 23, 22, 21, 20], [19, 18, 17, 16, 15, 14], [13, 12, 11, 10, 9, 8], [7, 6, 5, 4, 3, 2], [1, 2, 3, 4, 5, 6]]) == [[4, 3, 2, 8, 14, 20], [4, 5, 6, 9, 15, 21], [3, 5, 11, 10, 16, 22], [2, 6, 12, 18, 17, 23], [1, 7, 13, 19, 25, 24]]\n assert candidate(mat = [[50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39], [38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28], [27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17], [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6], [5, 4, 3, 2, 1, 60, 59, 58, 57, 56, 55]]) == [[12, 11, 10, 9, 8, 7, 6, 17, 28, 39, 60], [1, 24, 23, 22, 21, 20, 19, 18, 29, 40, 59], [2, 13, 36, 35, 34, 33, 32, 31, 30, 41, 58], [3, 14, 25, 48, 47, 46, 45, 44, 43, 42, 57], [4, 15, 26, 37, 50, 51, 52, 53, 54, 55, 56], [5, 16, 27, 38, 49, 60, 59, 58, 57, 56, 55]]\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [12, 14, 16, 18, 20]]) == [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [12, 14, 16, 18, 20]]\n assert candidate(mat = [[9, 1, 4, 7, 3, 8], [6, 5, 2, 9, 1, 4], [3, 8, 5, 2, 9, 1], [8, 3, 9, 1, 4, 7], [1, 4, 7, 3, 8, 6]]) == [[1, 1, 4, 1, 3, 8], [3, 5, 2, 7, 1, 4], [3, 6, 5, 2, 9, 7], [4, 3, 8, 8, 4, 9], [1, 8, 7, 9, 9, 6]]\n assert candidate(mat = [[10, 9, 8, 7, 6, 5, 4], [3, 2, 1, 10, 9, 8, 7], [4, 3, 2, 1, 10, 9, 8], [5, 4, 3, 2, 1, 10, 9], [6, 5, 4, 3, 2, 1, 10]]) == [[2, 1, 8, 7, 6, 5, 4], [3, 2, 1, 10, 9, 8, 7], [4, 3, 2, 1, 10, 9, 8], [5, 4, 3, 2, 1, 10, 9], [6, 5, 4, 3, 10, 9, 10]]\n assert candidate(mat = [[50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66], [67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83], [84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34], [35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51]]) == [[4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 64, 65, 66], [3, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 63, 82, 83], [2, 21, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 62, 81, 100], [1, 20, 39, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 80, 99], [18, 19, 38, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 98], [35, 36, 37, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97]]\n assert candidate(mat = [[14, 13], [12, 11], [10, 9], [8, 7], [6, 5], [4, 3], [2, 1]]) == [[11, 13], [9, 14], [7, 12], [5, 10], [3, 8], [1, 6], [2, 4]]\n assert candidate(mat = [[97, 96, 95, 94, 93, 92, 91, 90], [89, 88, 87, 86, 85, 84, 83, 82], [81, 80, 79, 78, 77, 76, 75, 74], [73, 72, 71, 70, 69, 68, 67, 66], [65, 64, 63, 62, 61, 60, 59, 58], [57, 56, 55, 54, 53, 52, 51, 50], [49, 48, 47, 46, 45, 44, 43, 42], [41, 40, 39, 38, 37, 36, 35, 34], [33, 32, 31, 30, 29, 28, 27, 26], [25, 24, 23, 22, 21, 20, 19, 18], [17, 16, 15, 14, 13, 12, 11, 10], [9, 8, 7, 6, 5, 4, 3, 2], [1, 2, 3, 4, 5, 6, 7, 8]]) == [[34, 42, 50, 58, 66, 74, 82, 90], [26, 43, 51, 59, 67, 75, 83, 91], [18, 35, 52, 60, 68, 76, 84, 92], [10, 27, 44, 61, 69, 77, 85, 93], [2, 19, 36, 53, 70, 78, 86, 94], [3, 11, 28, 45, 62, 79, 87, 95], [4, 8, 20, 37, 54, 71, 88, 96], [5, 7, 12, 29, 46, 63, 80, 97], [5, 6, 13, 21, 38, 55, 72, 89], [4, 6, 14, 22, 30, 47, 64, 81], [3, 7, 15, 23, 31, 39, 56, 73], [2, 8, 16, 24, 32, 40, 48, 65], [1, 9, 17, 25, 33, 41, 49, 57]]\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14]]) == [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14]]\n assert candidate(mat = [[100, 99, 98, 97, 96], [95, 94, 93, 92, 91], [90, 89, 88, 87, 86], [85, 84, 83, 82, 81], [80, 79, 78, 77, 76]]) == [[76, 81, 86, 91, 96], [77, 82, 87, 92, 97], [78, 83, 88, 93, 98], [79, 84, 89, 94, 99], [80, 85, 90, 95, 100]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24, 25, 26, 27], [28, 29, 30, 31, 32, 33, 34, 35, 36], [37, 38, 39, 40, 41, 42, 43, 44, 45]]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24, 25, 26, 27], [28, 29, 30, 31, 32, 33, 34, 35, 36], [37, 38, 39, 40, 41, 42, 43, 44, 45]]\n assert candidate(mat = [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [3, 5, 7, 9, 11, 13], [4, 6, 8, 10, 12, 14], [5, 7, 9, 11, 13, 15], [6, 8, 10, 12, 14, 16]]) == [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [3, 5, 7, 9, 11, 13], [4, 6, 8, 10, 12, 14], [5, 7, 9, 11, 13, 15], [6, 8, 10, 12, 14, 16]]\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30]]) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30]]\n assert candidate(mat = [[1, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90]]) == [[1, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90], [1, 10, 20, 30, 40, 50, 60, 70, 80, 90]]\n assert candidate(mat = [[5, 10, 15, 20, 25], [30, 35, 40, 45, 50], [55, 60, 65, 70, 75], [80, 85, 90, 95, 100], [105, 110, 115, 120, 125]]) == [[5, 10, 15, 20, 25], [30, 35, 40, 45, 50], [55, 60, 65, 70, 75], [80, 85, 90, 95, 100], [105, 110, 115, 120, 125]]\n assert candidate(mat = [[5, 20, 30, 40, 50], [15, 10, 35, 45, 55], [20, 25, 5, 50, 60], [25, 35, 45, 15, 65]]) == [[5, 20, 30, 40, 50], [15, 5, 35, 45, 55], [20, 25, 10, 50, 60], [25, 35, 45, 15, 65]]\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30], [31, 32, 33, 34, 35]]) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30], [31, 32, 33, 34, 35]]\n assert candidate(mat = [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5]]) == [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5]]\n assert candidate(mat = [[99, 98, 97, 96, 95, 94, 93, 92, 91], [90, 89, 88, 87, 86, 85, 84, 83, 82], [81, 80, 79, 78, 77, 76, 75, 74, 73], [72, 71, 70, 69, 68, 67, 66, 65, 64], [63, 62, 61, 60, 59, 58, 57, 56, 55], [54, 53, 52, 51, 50, 49, 48, 47, 46], [45, 44, 43, 42, 41, 40, 39, 38, 37], [36, 35, 34, 33, 32, 31, 30, 29, 28], [27, 26, 25, 24, 23, 22, 21, 20, 19], [18, 17, 16, 15, 14, 13, 12, 11, 10], [9, 8, 7, 6, 5, 4, 3, 2, 1]]) == [[19, 28, 37, 46, 55, 64, 73, 82, 91], [10, 29, 38, 47, 56, 65, 74, 83, 92], [1, 20, 39, 48, 57, 66, 75, 84, 93], [2, 11, 30, 49, 58, 67, 76, 85, 94], [3, 12, 21, 40, 59, 68, 77, 86, 95], [4, 13, 22, 31, 50, 69, 78, 87, 96], [5, 14, 23, 32, 41, 60, 79, 88, 97], [6, 15, 24, 33, 42, 51, 70, 89, 98], [7, 16, 25, 34, 43, 52, 61, 80, 99], [8, 17, 26, 35, 44, 53, 62, 71, 90], [9, 18, 27, 36, 45, 54, 63, 72, 81]]\n assert candidate(mat = [[99, 22, 33, 11, 44], [55, 66, 77, 88, 99], [10, 20, 30, 40, 50], [60, 70, 80, 90, 100], [15, 25, 35, 45, 55]]) == [[30, 22, 33, 11, 44], [20, 55, 40, 50, 99], [10, 45, 66, 77, 88], [25, 35, 55, 90, 100], [15, 60, 70, 80, 99]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22], [23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33], [34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44], [45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55]]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22], [23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33], [34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44], [45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55]]\n assert candidate(mat = [[100, 99, 98, 97, 96, 95], [94, 93, 92, 91, 90, 89], [88, 87, 86, 85, 84, 83], [82, 81, 80, 79, 78, 77], [76, 75, 74, 73, 72, 71]]) == [[72, 71, 77, 83, 89, 95], [73, 79, 78, 84, 90, 96], [74, 80, 86, 85, 91, 97], [75, 81, 87, 93, 92, 98], [76, 82, 88, 94, 100, 99]]\n assert candidate(mat = [[4, 3, 2, 1], [5, 9, 8, 7], [6, 10, 11, 12], [7, 6, 5, 4], [8, 7, 6, 5]]) == [[4, 3, 2, 1], [5, 4, 8, 7], [6, 5, 9, 12], [7, 6, 5, 11], [8, 7, 6, 10]]\n assert candidate(mat = [[9, 7, 8, 6, 5, 4], [3, 2, 1, 10, 11, 12], [15, 14, 13, 18, 17, 16], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30]]) == [[2, 1, 8, 6, 5, 4], [3, 9, 7, 10, 11, 12], [15, 14, 13, 18, 17, 16], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30]]\n assert candidate(mat = [[9, 7, 5, 3, 1], [8, 6, 4, 2, 0], [7, 5, 3, 1, 9], [6, 4, 2, 0, 8], [5, 3, 1, 9, 7]]) == [[0, 1, 2, 0, 1], [2, 3, 4, 5, 3], [1, 5, 6, 7, 9], [3, 4, 8, 7, 8], [5, 6, 7, 9, 9]]\n assert candidate(mat = [[45, 12, 23, 34, 45, 56, 67, 78, 89, 90], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [11, 22, 33, 44, 55, 66, 77, 88, 99, 100], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]]) == [[8, 7, 6, 5, 4, 3, 2, 1, 0, 90], [9, 33, 12, 23, 34, 45, 56, 67, 78, 89], [11, 22, 35, 44, 55, 65, 75, 85, 95, 100], [5, 15, 25, 45, 45, 55, 66, 77, 88, 99]]\n assert candidate(mat = [[50, 24, 78, 42, 31], [63, 83, 92, 22, 58], [30, 50, 14, 32, 59], [97, 35, 88, 64, 50]]) == [[14, 24, 22, 42, 31], [50, 50, 32, 59, 58], [30, 63, 64, 50, 78], [97, 35, 88, 83, 92]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3]]) == [[1, 2, 2, 2, 1, 6], [3, 3, 3, 3, 4, 5], [2, 4, 4, 4, 3, 7], [4, 5, 5, 4, 5, 6], [3, 6, 5, 6, 5, 8], [8, 7, 7, 6, 6, 7]]\n assert candidate(mat = [[95, 85, 65, 25, 55, 75, 35, 45, 15], [10, 90, 80, 70, 60, 50, 40, 30, 20], [5, 15, 25, 35, 45, 55, 65, 75, 85]]) == [[25, 35, 45, 25, 50, 40, 30, 20, 15], [10, 90, 80, 65, 55, 55, 75, 35, 45], [5, 15, 95, 85, 70, 60, 65, 75, 85]]\n assert candidate(mat = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65]]) == [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65]]\n assert candidate(mat = [[7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [7, 1, 7, 1, 7, 1, 7, 1, 7, 1], [7, 7, 2, 2, 2, 2, 2, 2, 2, 2], [7, 1, 2, 3, 3, 3, 3, 3, 3, 3], [7, 1, 2, 3, 4, 4, 4, 4, 4, 4], [7, 1, 2, 3, 4, 5, 5, 5, 5, 5], [7, 1, 2, 3, 4, 5, 6, 6, 6, 6]]) == [[1, 2, 1, 2, 1, 2, 1, 2, 1, 7], [2, 2, 3, 2, 3, 2, 3, 2, 7, 7], [1, 3, 3, 4, 3, 4, 3, 4, 3, 7], [1, 2, 4, 4, 5, 4, 5, 4, 7, 7], [1, 2, 3, 5, 5, 6, 5, 6, 5, 7], [1, 2, 3, 4, 7, 6, 7, 6, 7, 7], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]]\n assert candidate(mat = [[9, 7, 11, 8, 5, 4], [12, 14, 10, 3, 13, 15], [6, 2, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25]]) == [[9, 7, 3, 8, 5, 4], [2, 14, 10, 11, 13, 15], [6, 12, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15], [15, 13, 11, 9, 7, 5, 3, 1]]) == [[1, 2, 3, 3, 1, 2, 1, 8], [3, 5, 6, 5, 4, 3, 6, 7], [1, 8, 7, 7, 5, 4, 5, 15], [15, 13, 11, 9, 7, 9, 11, 13]]\n assert candidate(mat = [[100, 99, 98, 97, 96], [95, 94, 93, 92, 91], [90, 89, 88, 87, 86], [85, 84, 83, 82, 81], [80, 79, 78, 77, 76]]) == [[76, 81, 86, 91, 96], [77, 82, 87, 92, 97], [78, 83, 88, 93, 98], [79, 84, 89, 94, 99], [80, 85, 90, 95, 100]]\n assert candidate(mat = [[7, 17, 12, 5, 10, 9, 3], [14, 2, 11, 16, 13, 18, 8], [15, 4, 6, 1, 19, 12, 17], [10, 3, 15, 7, 2, 14, 6], [5, 9, 1, 18, 17, 13, 4]]) == [[2, 1, 4, 5, 10, 8, 3], [4, 6, 2, 12, 6, 17, 9], [1, 14, 7, 11, 14, 12, 18], [9, 3, 15, 7, 13, 16, 13], [5, 10, 15, 18, 17, 17, 19]]\n assert candidate(mat = [[4, 3, 2, 1], [8, 7, 6, 5], [12, 11, 10, 9], [16, 15, 14, 13], [20, 19, 18, 17]]) == [[4, 3, 2, 1], [8, 7, 6, 5], [12, 11, 10, 9], [16, 15, 14, 13], [20, 19, 18, 17]]\n assert candidate(mat = [[3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3], [3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3], [3, 2, 1, 1, 1, 1, 1, 1, 1, 2, 3, 3], [3, 2, 1, 1, 1, 1, 1, 1, 2, 3, 3, 3], [3, 2, 1, 1, 1, 1, 1, 2, 3, 3, 3, 3], [3, 2, 1, 1, 1, 1, 2, 3, 3, 3, 3, 3], [3, 2, 1, 1, 1, 2, 3, 3, 3, 3, 3, 3], [3, 2, 1, 1, 2, 3, 3, 3, 3, 3, 3, 3], [3, 2, 1, 2, 3, 3, 3, 3, 3, 3, 3, 3], [3, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]]) == [[1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3], [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3], [1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3], [1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3], [1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3], [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3], [1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3], [2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3], [2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]]\n assert candidate(mat = [[100, 99, 98, 97, 96, 95], [94, 93, 92, 91, 90, 89], [88, 87, 86, 85, 84, 83], [82, 81, 80, 79, 78, 77], [76, 75, 74, 73, 72, 71]]) == [[72, 71, 77, 83, 89, 95], [73, 79, 78, 84, 90, 96], [74, 80, 86, 85, 91, 97], [75, 81, 87, 93, 92, 98], [76, 82, 88, 94, 100, 99]]\n assert candidate(mat = [[5, 12, 11, 10, 9], [8, 4, 3, 2, 1], [9, 8, 7, 6, 5], [10, 9, 8, 7, 6], [11, 10, 9, 8, 7], [12, 11, 10, 9, 8]]) == [[4, 3, 2, 1, 9], [8, 5, 6, 5, 10], [9, 8, 7, 6, 11], [10, 9, 8, 7, 12], [11, 10, 9, 8, 7], [12, 11, 10, 9, 8]]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2]]) == [[1, 2, 3, 2, 2, 1, 7], [3, 4, 4, 3, 3, 5, 6], [2, 6, 5, 5, 4, 4, 8], [8, 7, 7, 6, 5, 6, 7]]\n assert candidate(mat = [[4, 3, 2, 1], [8, 7, 6, 5], [12, 11, 10, 9], [16, 15, 14, 13]]) == [[4, 3, 2, 1], [8, 7, 6, 5], [12, 11, 10, 9], [16, 15, 14, 13]]\n assert candidate(mat = [[33, 22, 11, 44, 55], [66, 77, 88, 99, 100], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == [[3, 4, 5, 44, 55], [2, 9, 10, 11, 100], [1, 8, 15, 22, 99], [6, 7, 14, 33, 88], [11, 12, 13, 20, 77], [16, 17, 18, 19, 66]]\n assert candidate(mat = [[5, 20, 15, 80, 75], [45, 10, 55, 60, 15], [12, 65, 35, 90, 100], [10, 25, 40, 50, 65], [5, 15, 25, 35, 45]]) == [[5, 20, 15, 15, 75], [35, 10, 55, 60, 80], [12, 40, 35, 65, 100], [10, 25, 45, 45, 90], [5, 15, 25, 65, 50]]\n"}, "metadata": {"canonical_parameter_names": ["mat"], "leetcode_dataset_entry_point": "Solution().diagonalSort", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector> diagonalSort(vector>& mat) {", "container": "Solution", "callable": "diagonalSort", "parameters": [{"name": "mat", "type": "vector>&"}], "return_type": "vector>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1330, "task_id": "reverse-subarray-to-maximize-array-value", "difficulty": "Hard", "problem_description": "You are given an integer array nums. The value of this array is defined as the sum of |nums[i] - nums[i + 1]| for all 0 <= i < nums.length - 1.\nYou are allowed to select any subarray of the given array and reverse it. You can perform this operation only once.\nFind maximum possible value of the final array.\n \nExample 1:\n\nInput: nums = [2,3,1,5,4]\nOutput: 10\nExplanation: By reversing the subarray [3,1,5] the array becomes [2,5,1,3,4] whose value is 10.\n\nExample 2:\n\nInput: nums = [2,4,9,24,2,1,10]\nOutput: 68\n\n \nConstraints:\n\n2 <= nums.length <= 3 * 104\n-105 <= nums[i] <= 105\nThe answer is guaranteed to fit in a 32-bit integer.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 2, 4, 5]) == 9\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 230\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == 22\n assert candidate(nums = [1, -1, 1, -1, 1]) == 8\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == 10\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000]) == 800000\n assert candidate(nums = [-10, -5, 0, 5, 10]) == 40\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 230\n assert candidate(nums = [2, 4, 9, 24, 2, 1, 10]) == 68\n assert candidate(nums = [1, 2, 3, 4, 5]) == 8\n assert candidate(nums = [1, 3, 2, 1, 2, 3, 1]) == 9\n assert candidate(nums = [-1, 4, -2, 3]) == 16\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [-100000, 100000, -100000, 100000]) == 600000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 200\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 38\n assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 100000, 1, 100000, 1]) == 399996\n assert candidate(nums = [100, -100, 100, -100]) == 600\n assert candidate(nums = [100000, -100000, 100000, -100000]) == 600000\n assert candidate(nums = [-100000, 100000, -100000, 100000, -100000]) == 800000\n assert candidate(nums = [5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [2, 3, 1, 5, 4]) == 10\n assert candidate(nums = [1, 2, 1, 2, 1]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 38\n assert candidate(nums = [5, 3, 8, 6, 7, 2, 4, 1, 9]) == 33\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [100000, -100000, 50000, -50000, 25000, -25000, 12500]) == 687500\n assert candidate(nums = [-10, 10, -10, 10, -10, 10, -10, 10, -10, 10]) == 180\n assert candidate(nums = [1, 3, 5, 7, 9, 8, 6, 4, 2, 0]) == 29\n assert candidate(nums = [-10, 10, -20, 20, -30, 30, -40, 40, -50, 50]) == 580\n assert candidate(nums = [100000, 0, -100000, 100000, 0, -100000, 100000]) == 900000\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15, 14, 16, 15, 17, 16, 18, 17, 19, 18, 20, 19, 21, 20]) == 91\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995]) == 11\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == 9\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4]) == 38\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == 53\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 9, 1]) == 39\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 38\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400]) == 2900\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [-50000, 50000, -50000, 50000, -50000]) == 400000\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 9\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15]) == 38\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000, -100000]) == 1000000\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 21\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [100000, 0, -100000, 0, 100000, 0, -100000, 0, 100000]) == 900000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 580\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 23\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 53\n assert candidate(nums = [1, -100000, 2, -99999, 3, -99998, 4, -99997, 5, -99996]) == 900013\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 23\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9]) == 36\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 0\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9, 10]) == 43\n assert candidate(nums = [10000, 1000, 100, 10, 1, 0, -1, -10, -100, -1000, -10000]) == 31000\n assert candidate(nums = [1, 2, 3, -1, -2, -3, 4, 5, 6, -4, -5, -6, 7, 8, 9]) == 70\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 28\n assert candidate(nums = [0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10]) == 219\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 38\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 38\n assert candidate(nums = [-100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000]) == 1800000\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000]) == 800000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 23\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97]) == 675\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 17\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 320\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [-5, 5, -15, 15, -25, 25, -35, 35, -45, 45, -55, 55]) == 710\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5, 0, 6, 4, 3, 2, 1]) == 59\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 107\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4]) == 38\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 33\n assert candidate(nums = [1, 2, 3, 100, 3, 2, 1, 99, 2, 1, 0]) == 399\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40]) == 380\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 68\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000]) == 1400000\n assert candidate(nums = [-100000, -100000, -100000, -100000, -100000, -100000, -100000, -100000, -100000, -100000]) == 0\n assert candidate(nums = [-100000, -99999, -99998, -99997, -99996, -99995, -99994, -99993, -99992, -99991]) == 23\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 36\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15]) == 236\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 32\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 49\n assert candidate(nums = [1, 2, 3, 4, 5, 10000, 6, 7, 8, 9, 10]) == 20011\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 230\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 53\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500]) == 5800\n assert candidate(nums = [1, 200000, 3, 400000, 5, 600000, 7, 800000, 9, 1000000]) == 5799951\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 4000, 3000, 2000, 1000]) == 12000\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 31\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == 859\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9]) == 48\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5]) == 140\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxValueAfterReverse", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxValueAfterReverse(vector& nums) {", "container": "Solution", "callable": "maxValueAfterReverse", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1331, "task_id": "rank-transform-of-an-array", "difficulty": "Easy", "problem_description": "Given an array of integers arr, replace each element with its rank.\nThe rank represents how large the element is. The rank has the following rules:\n\nRank is an integer starting from 1.\nThe larger the element, the larger the rank. If two elements are equal, their rank must be the same.\nRank should be as small as possible.\n\n \nExample 1:\n\nInput: arr = [40,10,20,30]\nOutput: [4,1,2,3]\nExplanation: 40 is the largest element. 10 is the smallest. 20 is the second smallest. 30 is the third smallest.\nExample 2:\n\nInput: arr = [100,100,100]\nOutput: [1,1,1]\nExplanation: Same elements share the same rank.\n\nExample 3:\n\nInput: arr = [37,12,28,9,100,56,80,5,12]\nOutput: [5,3,4,2,8,6,7,1,3]\n\n \nConstraints:\n\n0 <= arr.length <= 105\n-109 <= arr[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [5, 4, 3, 2, 1]) == [5, 4, 3, 2, 1]\n assert candidate(arr = [-10, 100, 0, 5, 3]) == [1, 5, 2, 4, 3]\n assert candidate(arr = [-10, -20, -30, -40, -50]) == [5, 4, 3, 2, 1]\n assert candidate(arr = [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]\n assert candidate(arr = [0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1]\n assert candidate(arr = [1000000000, -1000000000, 0, 500000000, -500000000]) == [5, 1, 3, 4, 2]\n assert candidate(arr = [1]) == [1]\n assert candidate(arr = [40, 10, 20, 30]) == [4, 1, 2, 3]\n assert candidate(arr = [1000000000, -1000000000, 0]) == [3, 1, 2]\n assert candidate(arr = [37, 12, 28, 9, 100, 56, 80, 5, 12]) == [5, 3, 4, 2, 8, 6, 7, 1, 3]\n assert candidate(arr = []) == []\n assert candidate(arr = [100, 100, 100]) == [1, 1, 1]\n assert candidate(arr = [1, 1, 2, 2, 3, 3]) == [1, 1, 2, 2, 3, 3]\n assert candidate(arr = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == [11, 10, 12, 9, 13, 8, 14, 7, 15, 6, 16, 5, 17, 4, 18, 3, 19, 2, 20, 1]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [1000000000, 999999999, 1000000001, 999999998, 1000000002, 999999997, 1000000003, 999999996, 1000000004, 999999995]) == [6, 5, 7, 4, 8, 3, 9, 2, 10, 1]\n assert candidate(arr = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500]) == [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]\n assert candidate(arr = [100, 200, 100, 300, 200, 400, 300, 500]) == [1, 2, 1, 3, 2, 4, 3, 5]\n assert candidate(arr = [123456789, 987654321, 123456789, 987654321, 456789123]) == [1, 3, 1, 3, 2]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(arr = [50, 20, 30, 40, 10, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [5, 2, 3, 4, 1, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr = [10, 20, 20, 10, 30, 40, 50, 50, 40, 30]) == [1, 2, 2, 1, 3, 4, 5, 5, 4, 3]\n assert candidate(arr = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, -1, -10, -100, -1000, -10000, -100000, -1000000, -10000000, -100000000, -1000000000]) == [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == [21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 1, 2, 3, 4, 5]\n assert candidate(arr = [49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == [1, 1, 1, 1, 1]\n assert candidate(arr = [1, 3, 2, 6, 5, 4, 7, 9, 8, 10, 11, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == [1, 3, 2, 6, 5, 4, 7, 9, 8, 10, 11, 13, 12, 15, 14, 17, 16, 19, 18, 20]\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -1, -2, -3, -4, -5]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6]\n assert candidate(arr = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == [1, 1, 1, 1, 1]\n assert candidate(arr = [-1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000, -1000000000]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [1000, 999, 1001, 998, 1002, 997, 1003, 996, 1004]) == [5, 4, 6, 3, 7, 2, 8, 1, 9]\n assert candidate(arr = [1, 3, 2, 1, 4, 2, 3, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]) == [1, 3, 2, 1, 4, 2, 3, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [100, 100, 100, 99, 99, 98, 98, 98, 97, 97, 97, 97]) == [4, 4, 4, 3, 3, 2, 2, 2, 1, 1, 1, 1]\n assert candidate(arr = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [1000000000, -1000000000, 1000000000, -1000000000, 0, 0, 500000000, -500000000]) == [5, 1, 5, 1, 3, 3, 4, 2]\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [1000000000, -1000000000, 500000000, -500000000, 250000000, -250000000, 125000000, -125000000, 62500000, -62500000]) == [10, 1, 9, 2, 8, 3, 7, 4, 6, 5]\n assert candidate(arr = [5, 2, 9, 5, 9, 1, 5, 7, 8, 9, 1, 2, 3, 4, 6, 7, 8, 9]) == [5, 2, 9, 5, 9, 1, 5, 7, 8, 9, 1, 2, 3, 4, 6, 7, 8, 9]\n assert candidate(arr = [10, 20, 20, 10, 30, 40, 30, 20, 50, 60, 50, 40, 70, 80, 70, 60, 90, 100, 90, 80]) == [1, 2, 2, 1, 3, 4, 3, 2, 5, 6, 5, 4, 7, 8, 7, 6, 9, 10, 9, 8]\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]\n assert candidate(arr = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == [11, 10, 12, 9, 13, 8, 14, 7, 15, 6, 16, 5, 17, 4, 18, 3, 19, 2, 20, 1]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [5, 3, 1, 2, 4, 5, 3, 1, 2, 4, 5, 3, 1, 2, 4, 5, 3, 1, 2, 4]) == [5, 3, 1, 2, 4, 5, 3, 1, 2, 4, 5, 3, 1, 2, 4, 5, 3, 1, 2, 4]\n assert candidate(arr = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [5, 3, 1, 4, 2, 1, 3, 5, 4]) == [5, 3, 1, 4, 2, 1, 3, 5, 4]\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [0, 1, 0, 2, 1, 0, 3, 2, 1, 0, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1]) == [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(arr = [50, 50, 40, 40, 30, 30, 20, 20, 10, 10, 5, 5, 1, 1, -1, -1, -5, -5, -10, -10]) == [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]\n assert candidate(arr = [987654321, 123456789, 987654321, 123456789, 987654321]) == [2, 1, 2, 1, 2]\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(arr = [1000000, 999999, 1000001, 999998, 1000002, 999997, 1000003, 999996, 1000004, 999995]) == [6, 5, 7, 4, 8, 3, 9, 2, 10, 1]\n assert candidate(arr = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(arr = [-999999999, -888888888, -777777777, -666666666, -555555555, -444444444, -333333333, -222222222, -111111111, 0]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, -1, -1, -2, -2, -3, -3, -4, -4]) == [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(arr = [100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == [9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == [21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [-1000000000, -999999999, -999999998, -999999997, -999999996, -999999995, -999999994, -999999993, -999999992, -999999991]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(arr = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [5, 3, 5, 2, 3, 3, 9, 0, 123, -1, -100]) == [6, 5, 6, 4, 5, 5, 7, 3, 8, 2, 1]\n assert candidate(arr = [5, 3, 1, 2, 4, 6, 7, 8, 9, 10]) == [5, 3, 1, 2, 4, 6, 7, 8, 9, 10]\n assert candidate(arr = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [5, 3, 5, 2, 4, 3, 5, 1]) == [5, 3, 5, 2, 4, 3, 5, 1]\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]\n assert candidate(arr = [100, 50, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750]) == [2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(arr = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70]) == [31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]\n assert candidate(arr = [5, 3, 1, 2, 4, 3, 2, 1]) == [5, 3, 1, 2, 4, 3, 2, 1]\n assert candidate(arr = [5, 3, 1, 4, 2, 6, 8, 7, 10, 9]) == [5, 3, 1, 4, 2, 6, 8, 7, 10, 9]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(arr = [5, 3, 1, 2, 4, 1, 3, 5, 2, 4, 6, 7, 8, 6, 7, 8, 9, 10, 9, 10]) == [5, 3, 1, 2, 4, 1, 3, 5, 2, 4, 6, 7, 8, 6, 7, 8, 9, 10, 9, 10]\n assert candidate(arr = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035, 30517, 15258, 7629, 3814, 1907]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [999999999, 1000000000, -1000000000, -999999999, 500000000, -500000000, 1, -1]) == [7, 8, 1, 2, 6, 3, 5, 4]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(arr = [-1, -2, -3, -1, -2, -3, -1, -2, -3]) == [3, 2, 1, 3, 2, 1, 3, 2, 1]\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(arr = [1000, 999, 1000, 998, 1000, 997, 1000, 996, 1000, 995, 1000, 994, 1000, 993, 1000]) == [8, 7, 8, 6, 8, 5, 8, 4, 8, 3, 8, 2, 8, 1, 8]\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(arr = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [1000000, 999999, 1000001, 1000000, 999998]) == [3, 2, 4, 3, 1]\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().arrayRankTransform", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector arrayRankTransform(vector& arr) {", "container": "Solution", "callable": "arrayRankTransform", "parameters": [{"name": "arr", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1332, "task_id": "remove-palindromic-subsequences", "difficulty": "Easy", "problem_description": "You are given a string s consisting only of letters 'a' and 'b'. In a single step you can remove one palindromic subsequence from s.\nReturn the minimum number of steps to make the given string empty.\nA string is a subsequence of a given string if it is generated by deleting some characters of a given string without changing its order. Note that a subsequence does not necessarily need to be contiguous.\nA string is called palindrome if is one that reads the same backward as well as forward.\n \nExample 1:\n\nInput: s = \"ababa\"\nOutput: 1\nExplanation: s is already a palindrome, so its entirety can be removed in a single step.\n\nExample 2:\n\nInput: s = \"abb\"\nOutput: 2\nExplanation: \"abb\" -> \"bb\" -> \"\". \nRemove palindromic subsequence \"a\" then \"bb\".\n\nExample 3:\n\nInput: s = \"baabb\"\nOutput: 2\nExplanation: \"baabb\" -> \"b\" -> \"\". \nRemove palindromic subsequence \"baab\" then \"b\".\n\n \nConstraints:\n\n1 <= s.length <= 1000\ns[i] is either 'a' or 'b'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"b\") == 1\n assert candidate(s = \"aabbab\") == 2\n assert candidate(s = \"baba\") == 2\n assert candidate(s = \"aababb\") == 2\n assert candidate(s = \"abbaab\") == 2\n assert candidate(s = \"ab\") == 2\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"ababa\") == 1\n assert candidate(s = \"bbaabaaa\") == 2\n assert candidate(s = \"aabbaa\") == 1\n assert candidate(s = \"\") == 1\n assert candidate(s = \"abb\") == 2\n assert candidate(s = \"baabb\") == 2\n assert candidate(s = \"aaaa\") == 1\n assert candidate(s = \"bbbb\") == 1\n assert candidate(s = \"abab\") == 2\n assert candidate(s = \"baaaabb\") == 2\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbb\") == 2\n assert candidate(s = \"babbabbbaba\") == 2\n assert candidate(s = \"baabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabba\") == 2\n assert candidate(s = \"bababababababababa\") == 2\n assert candidate(s = \"bbaabbababb\") == 2\n assert candidate(s = \"baaabaaaaaabbaaab\") == 2\n assert candidate(s = \"aabbaabbaabb\") == 2\n assert candidate(s = \"baabbaab\") == 1\n assert candidate(s = \"baaababbabaababbabaababbabaababbabaababbabaababbabaababbabaababbabaababbabaababbabaababbabaababb\") == 2\n assert candidate(s = \"abaababaababaababa\") == 2\n assert candidate(s = \"aaabbaabbaabbaabba\") == 2\n assert candidate(s = \"aabaaaab\") == 2\n assert candidate(s = \"bbaaabbaaabbaaabbaa\") == 2\n assert candidate(s = \"aabbabbaa\") == 1\n assert candidate(s = \"bababa\") == 2\n assert candidate(s = \"aaaaaaaabbaaaaaaa\") == 2\n assert candidate(s = \"aaabbbbbabbaabbbbabbaabbbbabbaabbbbabbaabbbbabbaabbbbabbaabbbbabbaabbbbabbaabbbbabbaabbbbabbaabbbb\") == 2\n assert candidate(s = \"aabbbbbaaa\") == 2\n assert candidate(s = \"abbbabbbabbb\") == 2\n assert candidate(s = \"abbaababbababbab\") == 2\n assert candidate(s = \"aabbaabbabbaabbaabbabbaabbabbaabbaabbabbaabbabbaabbaabbabbaabbaabbabbaabbaabbabbaabbaabbabbaabbaabb\") == 2\n assert candidate(s = \"baabbaabbbaaba\") == 2\n assert candidate(s = \"bbbbbaaaaaaaaabbbb\") == 2\n assert candidate(s = \"abbaabbbaabbaabbba\") == 2\n assert candidate(s = \"aaabbbabaabbaa\") == 2\n assert candidate(s = \"aaabbbbaaaaabbbbaa\") == 2\n assert candidate(s = \"bbbbbaaaaa\") == 2\n assert candidate(s = \"aabbbaaabbbaa\") == 1\n assert candidate(s = \"bbbbbaaabbbbbaaabbbb\") == 2\n assert candidate(s = \"baababababababababab\") == 2\n assert candidate(s = \"bbbaabbaabbaabbaabbb\") == 1\n assert candidate(s = \"bbbbbbbbbba\") == 2\n assert candidate(s = \"bbaabbaabbaabbaab\") == 2\n assert candidate(s = \"abbbabbbabbbbaba\") == 2\n assert candidate(s = \"babbabbabbabbabbab\") == 1\n assert candidate(s = \"abaaabbaaabbbaaaab\") == 2\n assert candidate(s = \"aabbaabbaab\") == 2\n assert candidate(s = \"aabbaabbbaabbaabbba\") == 2\n assert candidate(s = \"bbaabbaab\") == 2\n assert candidate(s = \"bbaabbbaaabb\") == 2\n assert candidate(s = \"bbbbbbbbbbb\") == 1\n assert candidate(s = \"abbaaabaaa\") == 2\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 1\n assert candidate(s = \"ababbbababbbabaabb\") == 2\n assert candidate(s = \"abbaabbaabbaabba\") == 1\n assert candidate(s = \"aabbbbaaabaaaabbbb\") == 2\n assert candidate(s = \"abbbabbbabbbabbbabbb\") == 2\n assert candidate(s = \"babababababababab\") == 1\n assert candidate(s = \"abbaabbbaabbaabbaa\") == 2\n assert candidate(s = \"bbaabaaaabb\") == 2\n assert candidate(s = \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\") == 1\n assert candidate(s = \"bababababa\") == 2\n assert candidate(s = \"aaabbbaaabbbbaaa\") == 2\n assert candidate(s = \"aaaaaaaaaabbbbbbbb\") == 2\n assert candidate(s = \"aabbaaabbbaaabbaaa\") == 2\n assert candidate(s = \"ababababababab\") == 2\n assert candidate(s = \"aaaaaa\") == 1\n assert candidate(s = \"abababababa\") == 1\n assert candidate(s = \"abababababababab\") == 2\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbaaaaaaaaaaabbbbbbbbbbaaaaaaaaaaabbbbbbbbbbaaaaaaaaaaabbbbbbbbbbaaaaaaaaaa\") == 1\n assert candidate(s = \"baaaaaaaaaabbbbbbbbbbaaaaaaaaaabbbbbbbbbbaaaaaaaaaabbbbbbbbbbaaaaaaaaaabbbbbbbbbbaaaaaaaaaa\") == 2\n assert candidate(s = \"abababababab\") == 2\n assert candidate(s = \"ababababababababab\") == 2\n assert candidate(s = \"aabaaabbaaaab\") == 2\n assert candidate(s = \"abababbabababababab\") == 2\n assert candidate(s = \"baaaabbbaabb\") == 2\n assert candidate(s = \"bbbbbbbbaaaaaabbbbbbbbaaaaaabbbbbbbbaaaaaabbbbbbbbaaaaaabbbbbbbbaaaaaabbbbbbbbaaaaaabbbbbbbbaaaaaa\") == 2\n assert candidate(s = \"aaaaaaaaaaaaaaaaaa\") == 1\n assert candidate(s = \"bbbababaabbabababb\") == 2\n assert candidate(s = \"bbbbabbbbb\") == 2\n assert candidate(s = \"aaaaaaabbbbb\") == 2\n assert candidate(s = \"bbaabbbaa\") == 2\n assert candidate(s = \"baabbaaabbbaabbaab\") == 2\n assert candidate(s = \"abbbbbba\") == 1\n assert candidate(s = \"bbbbbbbbbbbbbbbbbbb\") == 1\n assert candidate(s = \"babbbbabbbbabbbbab\") == 1\n assert candidate(s = \"abababababababababababababab\") == 2\n assert candidate(s = \"aabbbaaaabbbbaa\") == 2\n assert candidate(s = \"abaabaabaabaabaaba\") == 1\n assert candidate(s = \"aabbaabbbaaabbbaab\") == 2\n assert candidate(s = \"aabababababa\") == 2\n assert candidate(s = \"aaaabbbb\") == 2\n assert candidate(s = \"abbaabbbaabbaa\") == 2\n assert candidate(s = \"ababababababababababab\") == 2\n assert candidate(s = \"baabbaabbaabbaab\") == 1\n assert candidate(s = \"ababbababbab\") == 2\n assert candidate(s = \"abababababababababab\") == 2\n assert candidate(s = \"abaabaabaabaabaabaa\") == 2\n assert candidate(s = \"abababab\") == 2\n assert candidate(s = \"bbbbbaaabbbbabab\") == 2\n assert candidate(s = \"bababababababa\") == 2\n assert candidate(s = \"babababab\") == 1\n assert candidate(s = \"aabbabbbabaabbabbb\") == 2\n assert candidate(s = \"abababa\") == 1\n assert candidate(s = \"aabbbbbaa\") == 1\n assert candidate(s = \"bbbaaaabbbbbaaaabb\") == 2\n assert candidate(s = \"aabbaabbaabbaabbaabbaab\") == 2\n assert candidate(s = \"ababbbabaabab\") == 2\n assert candidate(s = \"aaaaaaaaaabbbaaaaaaaaaaabbbaaaaaaaaaaabbbaaaaaaaaaaabbbaaaaaaaaaaabbbaaaaaaaaaaabbbaaaaaaaaaaa\") == 2\n assert candidate(s = \"babab\") == 1\n assert candidate(s = \"abababababababababababa\") == 1\n assert candidate(s = \"aabbaabbbaa\") == 2\n assert candidate(s = \"babababababababababa\") == 2\n assert candidate(s = \"abbabbabb\") == 2\n assert candidate(s = \"bbbbbaaaabaaaabbbb\") == 2\n assert candidate(s = \"bbbbbbbbbaaaaaaaaaa\") == 2\n assert candidate(s = \"ababababbababa\") == 2\n assert candidate(s = \"ababbbaba\") == 1\n assert candidate(s = \"abababaabbabababab\") == 2\n assert candidate(s = \"bbbbbbbbbbbbbbbbbb\") == 1\n assert candidate(s = \"aabbaabbaabbaabbaa\") == 1\n assert candidate(s = \"aaaaabbbbbaaaa\") == 2\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbbaaaaaaaaa\") == 2\n assert candidate(s = \"aabbaabbabbaaabb\") == 2\n assert candidate(s = \"bbaabbaabbaa\") == 2\n assert candidate(s = \"aabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabb\") == 2\n assert candidate(s = \"bababbbabababbbaba\") == 2\n assert candidate(s = \"baabbaabbaabba\") == 2\n assert candidate(s = \"ababab\") == 2\n assert candidate(s = \"aabbabba\") == 2\n assert candidate(s = \"ababbbbaababbbbaabab\") == 2\n assert candidate(s = \"bbaaabaaabaaaaabbb\") == 2\n assert candidate(s = \"bababababab\") == 1\n assert candidate(s = \"bababababababab\") == 1\n assert candidate(s = \"bbaaaabbbbaaa\") == 2\n assert candidate(s = \"bbbaabbbbabbbabbbba\") == 2\n assert candidate(s = \"abbaabbaabba\") == 1\n assert candidate(s = \"bbaabbaabbaabbaabbaabbaab\") == 2\n assert candidate(s = \"abaababa\") == 2\n assert candidate(s = \"ababbbababbbababbbab\") == 2\n assert candidate(s = \"ababbababbabab\") == 2\n assert candidate(s = \"baaaaab\") == 1\n assert candidate(s = \"aababbabaab\") == 2\n assert candidate(s = \"aabbaaabbaa\") == 1\n assert candidate(s = \"abababababababababa\") == 1\n assert candidate(s = \"aaaaaaaaabbbbbbbbb\") == 2\n assert candidate(s = \"bbbaaabbbbaaaabbba\") == 2\n assert candidate(s = \"bbaaaaabbbbba\") == 2\n assert candidate(s = \"abbbbaaaaabbba\") == 2\n assert candidate(s = \"abbaabba\") == 1\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaa\") == 1\n assert candidate(s = \"aabbaaaabbbbaaabbbbaaaabbbaaabbbbaaaabbbaaabbbbaaaabbbaaabbbbaaaabbbaaabbbbaaaabbbaaabbbbaaaabbbbaaaabb\") == 2\n assert candidate(s = \"abbbbabbbbabbbbabbbb\") == 2\n assert candidate(s = \"ababababa\") == 1\n assert candidate(s = \"abababbabaabbababbab\") == 2\n assert candidate(s = \"babbbbbbbabbbbbbb\") == 2\n assert candidate(s = \"bbaaaaaabbbaaaaaab\") == 2\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababababababababababababab\") == 2\n assert candidate(s = \"bbbbbaaaaabbbbbaaaaa\") == 2\n assert candidate(s = \"ababbababa\") == 2\n assert candidate(s = \"babababa\") == 2\n assert candidate(s = \"aababbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabbabbaabb\") == 2\n assert candidate(s = \"baabbaabbaab\") == 1\n assert candidate(s = \"ababbbababbbabaab\") == 2\n assert candidate(s = \"ababababababababababababababababababababababababababababababababababababababababababababababababababababababababab\") == 2\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().removePalindromeSub", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int removePalindromeSub(string s) {", "container": "Solution", "callable": "removePalindromeSub", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1333, "task_id": "filter-restaurants-by-vegan-friendly-price-and-distance", "difficulty": "Medium", "problem_description": "Given the array restaurants where  restaurants[i] = [idi, ratingi, veganFriendlyi, pricei, distancei]. You have to filter the restaurants using three filters.\nThe veganFriendly filter will be either true (meaning you should only include restaurants with veganFriendlyi set to true) or false (meaning you can include any restaurant). In addition, you have the filters maxPrice and maxDistance which are the maximum value for price and distance of restaurants you should consider respectively.\nReturn the array of restaurant IDs after filtering, ordered by rating from highest to lowest. For restaurants with the same rating, order them by id from highest to lowest. For simplicity veganFriendlyi and veganFriendly take value 1 when it is true, and 0 when it is false.\n \nExample 1:\n\nInput: restaurants = [[1,4,1,40,10],[2,8,0,50,5],[3,8,1,30,4],[4,10,0,10,3],[5,1,1,15,1]], veganFriendly = 1, maxPrice = 50, maxDistance = 10\nOutput: [3,1,5] \nExplanation: \nThe restaurants are:\nRestaurant 1 [id=1, rating=4, veganFriendly=1, price=40, distance=10]\nRestaurant 2 [id=2, rating=8, veganFriendly=0, price=50, distance=5]\nRestaurant 3 [id=3, rating=8, veganFriendly=1, price=30, distance=4]\nRestaurant 4 [id=4, rating=10, veganFriendly=0, price=10, distance=3]\nRestaurant 5 [id=5, rating=1, veganFriendly=1, price=15, distance=1] \nAfter filter restaurants with veganFriendly = 1, maxPrice = 50 and maxDistance = 10 we have restaurant 3, restaurant 1 and restaurant 5 (ordered by rating from highest to lowest). \n\nExample 2:\n\nInput: restaurants = [[1,4,1,40,10],[2,8,0,50,5],[3,8,1,30,4],[4,10,0,10,3],[5,1,1,15,1]], veganFriendly = 0, maxPrice = 50, maxDistance = 10\nOutput: [4,3,2,1,5]\nExplanation: The restaurants are the same as in example 1, but in this case the filter veganFriendly = 0, therefore all restaurants are considered.\n\nExample 3:\n\nInput: restaurants = [[1,4,1,40,10],[2,8,0,50,5],[3,8,1,30,4],[4,10,0,10,3],[5,1,1,15,1]], veganFriendly = 0, maxPrice = 30, maxDistance = 3\nOutput: [4,5]\n\n \nConstraints:\n\n1 <= restaurants.length <= 10^4\nrestaurants[i].length == 5\n1 <= idi, ratingi, pricei, distancei <= 10^5\n1 <= maxPrice, maxDistance <= 10^5\nveganFriendlyi and veganFriendly are 0 or 1.\nAll idi are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(restaurants = [[1, 4, 1, 40, 10], [2, 8, 0, 50, 5], [3, 8, 1, 30, 4], [4, 10, 0, 10, 3], [5, 1, 1, 15, 1]],veganFriendly = 0,maxPrice = 50,maxDistance = 10) == [4, 3, 2, 1, 5]\n assert candidate(restaurants = [[1, 4, 1, 40, 10], [2, 8, 0, 50, 5], [3, 8, 1, 30, 4], [4, 10, 0, 10, 3], [5, 1, 1, 15, 1]],veganFriendly = 0,maxPrice = 30,maxDistance = 3) == [4, 5]\n assert candidate(restaurants = [[1, 4, 1, 40, 10], [2, 8, 0, 50, 5], [3, 8, 1, 30, 4], [4, 10, 0, 10, 3], [5, 1, 1, 15, 1]],veganFriendly = 1,maxPrice = 50,maxDistance = 10) == [3, 1, 5]\n assert candidate(restaurants = [[100, 95, 1, 10, 1], [200, 94, 0, 20, 2], [300, 93, 1, 30, 3], [400, 92, 0, 40, 4], [500, 91, 1, 50, 5]],veganFriendly = 1,maxPrice = 50,maxDistance = 5) == [100, 300, 500]\n assert candidate(restaurants = [[101, 9, 1, 25, 7], [102, 7, 0, 35, 12], [103, 9, 1, 20, 5], [104, 5, 0, 20, 8], [105, 9, 1, 20, 5], [106, 8, 1, 30, 3], [107, 6, 0, 35, 6]],veganFriendly = 1,maxPrice = 30,maxDistance = 8) == [105, 103, 101, 106]\n assert candidate(restaurants = [[1001, 45, 1, 30, 12], [2002, 65, 0, 20, 6], [3003, 50, 1, 25, 7], [4004, 40, 0, 15, 4], [5005, 75, 1, 5, 2], [6006, 55, 0, 40, 22], [7007, 45, 1, 10, 16], [8008, 35, 0, 25, 12], [9009, 25, 1, 35, 22], [10010, 80, 1, 10, 6]],veganFriendly = 0,maxPrice = 45,maxDistance = 20) == [10010, 5005, 2002, 3003, 7007, 1001, 4004, 8008]\n assert candidate(restaurants = [[10001, 10, 1, 100, 100], [20002, 20, 0, 80, 90], [30003, 30, 1, 70, 80], [40004, 40, 0, 60, 70], [50005, 50, 1, 50, 60], [60006, 60, 0, 40, 50], [70007, 70, 1, 30, 40], [80008, 80, 0, 20, 30], [90009, 90, 1, 10, 20], [100010, 100, 1, 0, 10]],veganFriendly = 0,maxPrice = 100,maxDistance = 100) == [100010, 90009, 80008, 70007, 60006, 50005, 40004, 30003, 20002, 10001]\n assert candidate(restaurants = [[11, 3, 1, 20, 10], [12, 8, 1, 18, 8], [13, 5, 0, 15, 7], [14, 7, 0, 12, 6], [15, 9, 1, 9, 5]],veganFriendly = 1,maxPrice = 20,maxDistance = 10) == [15, 12, 11]\n assert candidate(restaurants = [[401, 5, 1, 10, 10], [402, 6, 1, 15, 9], [403, 7, 1, 20, 8], [404, 8, 1, 25, 7], [405, 9, 1, 30, 6], [406, 10, 1, 35, 5]],veganFriendly = 1,maxPrice = 20,maxDistance = 7) == []\n assert candidate(restaurants = [[101, 99, 1, 10, 5], [202, 98, 0, 20, 3], [303, 99, 1, 10, 2], [404, 98, 0, 25, 5], [505, 97, 1, 15, 4], [606, 98, 0, 10, 4]],veganFriendly = 1,maxPrice = 15,maxDistance = 5) == [303, 101, 505]\n assert candidate(restaurants = [[401, 10, 0, 10, 1], [402, 9, 1, 15, 2], [403, 8, 0, 20, 3], [404, 7, 1, 25, 4], [405, 6, 0, 30, 5], [406, 5, 1, 12, 6]],veganFriendly = 1,maxPrice = 25,maxDistance = 5) == [402, 404]\n assert candidate(restaurants = [[10, 9, 1, 15, 5], [11, 7, 0, 20, 6], [12, 9, 1, 18, 3], [13, 8, 0, 25, 4], [14, 7, 1, 10, 2], [15, 10, 0, 5, 1]],veganFriendly = 1,maxPrice = 20,maxDistance = 5) == [12, 10, 14]\n assert candidate(restaurants = [[30, 10, 1, 10, 1], [31, 9, 0, 15, 2], [32, 8, 1, 20, 3], [33, 7, 1, 25, 4], [34, 6, 0, 30, 5], [35, 5, 1, 35, 6]],veganFriendly = 1,maxPrice = 30,maxDistance = 5) == [30, 32, 33]\n assert candidate(restaurants = [[301, 9, 0, 15, 10], [302, 8, 1, 20, 8], [303, 7, 0, 25, 6], [304, 6, 1, 30, 4], [305, 5, 0, 35, 2], [306, 4, 1, 40, 0]],veganFriendly = 1,maxPrice = 20,maxDistance = 8) == [302]\n assert candidate(restaurants = [[26, 2, 1, 40, 10], [27, 8, 0, 35, 9], [28, 7, 1, 30, 8], [29, 9, 0, 25, 7], [30, 6, 1, 20, 6]],veganFriendly = 0,maxPrice = 35,maxDistance = 9) == [29, 27, 28, 30]\n assert candidate(restaurants = [[10001, 10, 1, 100, 100], [20002, 20, 0, 80, 90], [30003, 30, 1, 70, 80], [40004, 40, 0, 60, 70], [50005, 50, 1, 50, 60], [60006, 60, 0, 40, 50], [70007, 70, 1, 30, 40], [80008, 80, 0, 20, 30], [90009, 90, 1, 10, 20], [100010, 100, 1, 0, 10]],veganFriendly = 1,maxPrice = 60,maxDistance = 70) == [100010, 90009, 70007, 50005]\n assert candidate(restaurants = [[101, 80, 1, 10, 5], [202, 85, 0, 20, 3], [303, 80, 1, 10, 2], [404, 80, 0, 25, 5], [505, 85, 1, 15, 4], [606, 80, 0, 10, 4]],veganFriendly = 1,maxPrice = 20,maxDistance = 5) == [505, 303, 101]\n assert candidate(restaurants = [[101, 50, 1, 10, 5], [202, 70, 0, 20, 3], [303, 70, 1, 10, 2], [404, 80, 0, 25, 5], [505, 60, 1, 15, 4], [606, 60, 0, 10, 4]],veganFriendly = 1,maxPrice = 15,maxDistance = 4) == [303, 505]\n assert candidate(restaurants = [[24, 9, 1, 20, 5], [25, 10, 0, 25, 3], [26, 8, 1, 15, 2], [27, 7, 1, 10, 1], [28, 6, 0, 5, 1], [29, 5, 1, 30, 4]],veganFriendly = 1,maxPrice = 20,maxDistance = 3) == [26, 27]\n assert candidate(restaurants = [[1, 100, 1, 1, 1], [2, 100, 1, 2, 2], [3, 100, 1, 3, 3], [4, 100, 1, 4, 4], [5, 100, 1, 5, 5], [6, 100, 1, 6, 6], [7, 100, 1, 7, 7], [8, 100, 1, 8, 8], [9, 100, 1, 9, 9], [10, 100, 1, 10, 10]],veganFriendly = 1,maxPrice = 5,maxDistance = 5) == [5, 4, 3, 2, 1]\n assert candidate(restaurants = [[101, 10, 0, 100, 100], [102, 9, 1, 95, 95], [103, 8, 0, 90, 90], [104, 7, 1, 85, 85], [105, 6, 0, 80, 80]],veganFriendly = 0,maxPrice = 90,maxDistance = 90) == [103, 104, 105]\n assert candidate(restaurants = [[10001, 5, 0, 50, 50], [20002, 15, 1, 40, 40], [30003, 25, 0, 30, 30], [40004, 35, 1, 20, 20], [50005, 45, 0, 10, 10], [60006, 55, 1, 5, 5]],veganFriendly = 0,maxPrice = 40,maxDistance = 40) == [60006, 50005, 40004, 30003, 20002]\n assert candidate(restaurants = [[42, 10, 1, 10, 1], [43, 9, 0, 15, 2], [44, 8, 1, 20, 3], [45, 7, 1, 25, 4], [46, 6, 0, 30, 5], [47, 5, 1, 35, 6]],veganFriendly = 0,maxPrice = 5,maxDistance = 1) == []\n assert candidate(restaurants = [[21, 6, 0, 30, 9], [22, 7, 0, 25, 7], [23, 9, 1, 18, 5], [24, 8, 1, 22, 4], [25, 10, 0, 15, 3]],veganFriendly = 1,maxPrice = 25,maxDistance = 6) == [23, 24]\n assert candidate(restaurants = [[54, 10, 1, 10, 1], [55, 9, 0, 15, 2], [56, 8, 1, 20, 3], [57, 7, 1, 25, 4], [58, 6, 0, 30, 5], [59, 5, 1, 35, 6]],veganFriendly = 1,maxPrice = 35,maxDistance = 6) == [54, 56, 57, 59]\n assert candidate(restaurants = [[901, 9, 0, 10, 1], [902, 8, 1, 15, 2], [903, 7, 0, 20, 3], [904, 6, 1, 25, 4], [905, 5, 0, 12, 5]],veganFriendly = 0,maxPrice = 25,maxDistance = 5) == [901, 902, 903, 904, 905]\n assert candidate(restaurants = [[41, 2, 0, 45, 10], [42, 8, 1, 35, 9], [43, 7, 1, 30, 8], [44, 9, 0, 25, 7], [45, 6, 1, 20, 6]],veganFriendly = 1,maxPrice = 30,maxDistance = 7) == [45]\n assert candidate(restaurants = [[101, 80, 1, 10, 5], [202, 85, 0, 20, 3], [303, 80, 1, 10, 2], [404, 80, 0, 25, 5], [505, 85, 1, 15, 4], [606, 80, 0, 10, 4]],veganFriendly = 0,maxPrice = 10,maxDistance = 5) == [606, 303, 101]\n assert candidate(restaurants = [[101, 50, 1, 30, 10], [202, 20, 0, 20, 5], [303, 40, 1, 25, 8], [404, 30, 0, 15, 3], [505, 60, 1, 5, 1], [606, 55, 0, 40, 20], [707, 45, 1, 10, 15], [808, 35, 0, 25, 10], [909, 25, 1, 35, 20], [1010, 70, 1, 10, 5]],veganFriendly = 1,maxPrice = 35,maxDistance = 15) == [1010, 505, 101, 707, 303]\n assert candidate(restaurants = [[601, 7, 1, 25, 10], [602, 8, 0, 30, 15], [603, 9, 1, 45, 8], [604, 6, 0, 35, 15], [605, 8, 1, 50, 6], [606, 9, 1, 35, 10], [607, 7, 0, 40, 8]],veganFriendly = 0,maxPrice = 50,maxDistance = 20) == [606, 603, 605, 602, 607, 601, 604]\n assert candidate(restaurants = [[701, 10, 0, 20, 20], [702, 9, 0, 25, 25], [703, 8, 0, 30, 30], [704, 7, 0, 35, 35], [705, 6, 0, 40, 40], [706, 5, 0, 45, 45], [707, 4, 0, 50, 50], [708, 3, 0, 55, 55], [709, 2, 0, 60, 60], [710, 1, 0, 65, 65]],veganFriendly = 0,maxPrice = 40,maxDistance = 40) == [701, 702, 703, 704, 705]\n assert candidate(restaurants = [[36, 5, 1, 15, 2], [37, 4, 0, 10, 3], [38, 3, 1, 5, 4], [39, 2, 1, 20, 5], [40, 1, 0, 25, 6], [41, 8, 1, 10, 1]],veganFriendly = 1,maxPrice = 20,maxDistance = 5) == [41, 36, 38, 39]\n assert candidate(restaurants = [[101, 95, 1, 20, 15], [202, 85, 0, 55, 18], [303, 95, 1, 25, 12], [404, 75, 0, 22, 14], [505, 88, 1, 18, 16], [606, 80, 0, 30, 10]],veganFriendly = 1,maxPrice = 30,maxDistance = 20) == [303, 101, 505]\n assert candidate(restaurants = [[1, 5, 1, 10, 1], [2, 5, 1, 10, 1], [3, 5, 1, 10, 1], [4, 5, 1, 10, 1], [5, 5, 1, 10, 1]],veganFriendly = 1,maxPrice = 10,maxDistance = 1) == [5, 4, 3, 2, 1]\n assert candidate(restaurants = [[101, 80, 1, 10, 5], [202, 85, 0, 20, 3], [303, 80, 1, 10, 2], [404, 80, 0, 25, 5], [505, 85, 1, 15, 4], [606, 80, 0, 10, 4]],veganFriendly = 0,maxPrice = 25,maxDistance = 5) == [505, 202, 606, 404, 303, 101]\n assert candidate(restaurants = [[101, 5, 1, 100, 5], [102, 9, 0, 50, 4], [103, 6, 1, 40, 3], [104, 7, 0, 30, 2], [105, 8, 1, 20, 1], [106, 4, 0, 10, 6], [107, 9, 1, 15, 2]],veganFriendly = 0,maxPrice = 50,maxDistance = 4) == [107, 102, 105, 104, 103]\n assert candidate(restaurants = [[35, 6, 0, 20, 17], [36, 7, 1, 45, 21], [37, 6, 0, 35, 15], [38, 9, 1, 25, 10], [39, 8, 0, 45, 25], [40, 11, 1, 10, 4], [41, 13, 0, 22, 18]],veganFriendly = 1,maxPrice = 45,maxDistance = 25) == [40, 38, 36]\n assert candidate(restaurants = [[201, 10, 0, 1000, 50], [202, 9, 1, 900, 45], [203, 8, 0, 800, 40], [204, 7, 1, 700, 35], [205, 6, 0, 600, 30], [206, 5, 1, 500, 25], [207, 4, 0, 400, 20], [208, 3, 1, 300, 15], [209, 2, 0, 200, 10], [210, 1, 1, 100, 5]],veganFriendly = 1,maxPrice = 500,maxDistance = 30) == [206, 208, 210]\n assert candidate(restaurants = [[301, 7, 0, 20, 4], [302, 9, 1, 10, 2], [303, 6, 0, 25, 5], [304, 8, 1, 15, 3], [305, 9, 0, 30, 1], [306, 7, 1, 12, 6]],veganFriendly = 0,maxPrice = 15,maxDistance = 4) == [302, 304]\n assert candidate(restaurants = [[401, 8, 1, 25, 10], [402, 7, 0, 30, 15], [403, 9, 1, 20, 5], [404, 8, 0, 20, 8], [405, 6, 1, 20, 5], [406, 9, 1, 30, 3], [407, 5, 0, 35, 6]],veganFriendly = 1,maxPrice = 30,maxDistance = 15) == [406, 403, 401, 405]\n assert candidate(restaurants = [[101, 90, 1, 30, 5], [202, 85, 0, 40, 10], [303, 90, 1, 30, 4], [404, 85, 0, 45, 8], [505, 85, 1, 25, 6], [606, 80, 0, 35, 7]],veganFriendly = 1,maxPrice = 35,maxDistance = 10) == [303, 101, 505]\n assert candidate(restaurants = [[101, 50, 1, 30, 10], [202, 20, 0, 20, 5], [303, 40, 1, 25, 8], [404, 30, 0, 15, 3], [505, 60, 1, 5, 1], [606, 55, 0, 40, 20], [707, 45, 1, 10, 15], [808, 35, 0, 25, 10], [909, 25, 1, 35, 20], [1010, 70, 1, 10, 5]],veganFriendly = 0,maxPrice = 20,maxDistance = 5) == [1010, 505, 404, 202]\n assert candidate(restaurants = [[701, 6, 1, 25, 10], [702, 8, 0, 30, 15], [703, 7, 1, 45, 8], [704, 9, 0, 35, 15], [705, 5, 1, 50, 6], [706, 8, 1, 35, 10], [707, 6, 0, 40, 8]],veganFriendly = 1,maxPrice = 40,maxDistance = 15) == [706, 701]\n assert candidate(restaurants = [[22, 6, 0, 20, 17], [23, 7, 1, 45, 21], [24, 6, 0, 35, 15], [25, 9, 1, 25, 10], [26, 8, 0, 45, 25], [27, 11, 1, 10, 4]],veganFriendly = 1,maxPrice = 40,maxDistance = 20) == [27, 25]\n assert candidate(restaurants = [[301, 6, 1, 30, 10], [302, 8, 0, 40, 12], [303, 7, 1, 45, 8], [304, 9, 1, 50, 6], [305, 5, 0, 35, 15], [306, 8, 1, 45, 10], [307, 7, 0, 40, 8]],veganFriendly = 0,maxPrice = 50,maxDistance = 15) == [304, 306, 302, 307, 303, 301, 305]\n assert candidate(restaurants = [[101, 100, 1, 5, 5], [102, 100, 1, 5, 6], [103, 100, 1, 5, 7], [104, 100, 1, 5, 8], [105, 100, 1, 5, 9]],veganFriendly = 1,maxPrice = 5,maxDistance = 9) == [105, 104, 103, 102, 101]\n assert candidate(restaurants = [[501, 10, 0, 50, 100], [502, 10, 0, 55, 95], [503, 10, 0, 60, 90], [504, 10, 0, 65, 85], [505, 10, 0, 70, 80], [506, 10, 0, 75, 75], [507, 10, 0, 80, 70], [508, 10, 0, 85, 65], [509, 10, 0, 90, 60]],veganFriendly = 0,maxPrice = 80,maxDistance = 70) == [507]\n assert candidate(restaurants = [[36, 6, 1, 40, 9], [37, 8, 0, 35, 8], [38, 7, 1, 30, 7], [39, 9, 0, 25, 6], [40, 10, 1, 20, 5]],veganFriendly = 1,maxPrice = 30,maxDistance = 8) == [40, 38]\n assert candidate(restaurants = [[101, 1, 1, 5, 5], [102, 1, 1, 6, 6], [103, 1, 1, 7, 7], [104, 1, 1, 8, 8], [105, 1, 1, 9, 9]],veganFriendly = 1,maxPrice = 10,maxDistance = 10) == [105, 104, 103, 102, 101]\n assert candidate(restaurants = [[101, 50, 1, 30, 10], [202, 20, 0, 20, 5], [303, 40, 1, 25, 8], [404, 30, 0, 15, 3], [505, 60, 1, 5, 1], [606, 55, 0, 40, 20], [707, 45, 1, 10, 15], [808, 35, 0, 25, 10], [909, 25, 1, 35, 20], [1010, 70, 1, 10, 5]],veganFriendly = 1,maxPrice = 50,maxDistance = 20) == [1010, 505, 101, 707, 303, 909]\n assert candidate(restaurants = [[2001, 100, 0, 50, 50], [2002, 99, 1, 49, 49], [2003, 98, 0, 48, 48], [2004, 97, 1, 47, 47], [2005, 96, 0, 46, 46]],veganFriendly = 0,maxPrice = 50,maxDistance = 50) == [2001, 2002, 2003, 2004, 2005]\n assert candidate(restaurants = [[10, 10, 0, 100, 100], [20, 9, 1, 90, 90], [30, 8, 0, 80, 80], [40, 7, 1, 70, 70], [50, 6, 0, 60, 60]],veganFriendly = 0,maxPrice = 100,maxDistance = 100) == [10, 20, 30, 40, 50]\n assert candidate(restaurants = [[31, 1, 0, 45, 10], [32, 3, 0, 30, 8], [33, 2, 1, 25, 6], [34, 4, 1, 20, 5], [35, 5, 0, 15, 4]],veganFriendly = 1,maxPrice = 25,maxDistance = 7) == [34, 33]\n assert candidate(restaurants = [[101, 6, 0, 20, 5], [102, 9, 1, 18, 2], [103, 5, 0, 10, 3], [104, 8, 1, 12, 4], [105, 7, 1, 15, 6], [106, 9, 0, 22, 3]],veganFriendly = 0,maxPrice = 25,maxDistance = 6) == [106, 102, 104, 105, 101, 103]\n assert candidate(restaurants = [[101, 95, 1, 20, 15], [202, 85, 0, 55, 18], [303, 95, 1, 25, 12], [404, 75, 0, 22, 14], [505, 88, 1, 18, 16], [606, 80, 0, 30, 10]],veganFriendly = 0,maxPrice = 55,maxDistance = 20) == [303, 101, 505, 202, 606, 404]\n assert candidate(restaurants = [[601, 9, 1, 10, 1], [602, 8, 0, 15, 2], [603, 7, 1, 20, 3], [604, 6, 0, 25, 4], [605, 5, 1, 12, 5]],veganFriendly = 1,maxPrice = 15,maxDistance = 4) == [601]\n assert candidate(restaurants = [[10001, 5, 0, 50, 50], [20002, 15, 1, 40, 40], [30003, 25, 0, 30, 30], [40004, 35, 1, 20, 20], [50005, 45, 0, 10, 10], [60006, 55, 1, 5, 5]],veganFriendly = 1,maxPrice = 50,maxDistance = 50) == [60006, 40004, 20002]\n assert candidate(restaurants = [[801, 8, 1, 15, 3], [802, 9, 0, 10, 2], [803, 7, 1, 25, 4], [804, 6, 0, 20, 5], [805, 5, 1, 12, 1]],veganFriendly = 1,maxPrice = 20,maxDistance = 4) == [801, 805]\n assert candidate(restaurants = [[48, 1, 1, 5, 1], [49, 2, 0, 10, 2], [50, 3, 1, 15, 3], [51, 4, 1, 20, 4], [52, 5, 0, 25, 5], [53, 6, 1, 30, 6]],veganFriendly = 1,maxPrice = 25,maxDistance = 5) == [51, 50, 48]\n assert candidate(restaurants = [[10, 9, 1, 25, 7], [20, 8, 0, 35, 9], [30, 10, 1, 20, 5], [40, 7, 0, 45, 3], [50, 6, 1, 15, 2]],veganFriendly = 1,maxPrice = 30,maxDistance = 8) == [30, 10, 50]\n assert candidate(restaurants = [[1, 99, 0, 1, 1], [2, 98, 0, 2, 2], [3, 97, 0, 3, 3], [4, 96, 0, 4, 4], [5, 95, 0, 5, 5], [6, 94, 0, 6, 6], [7, 93, 0, 7, 7], [8, 92, 0, 8, 8], [9, 91, 0, 9, 9]],veganFriendly = 0,maxPrice = 9,maxDistance = 9) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(restaurants = [[3001, 9, 1, 9, 9], [3002, 8, 0, 8, 8], [3003, 7, 1, 7, 7], [3004, 6, 0, 6, 6], [3005, 5, 1, 5, 5], [3006, 4, 0, 4, 4], [3007, 3, 1, 3, 3], [3008, 2, 0, 2, 2], [3009, 1, 1, 1, 1]],veganFriendly = 1,maxPrice = 10,maxDistance = 10) == [3001, 3003, 3005, 3007, 3009]\n assert candidate(restaurants = [[51, 6, 1, 40, 10], [52, 8, 1, 35, 9], [53, 7, 1, 30, 8], [54, 9, 1, 25, 7], [55, 10, 1, 20, 6]],veganFriendly = 1,maxPrice = 30,maxDistance = 8) == [55, 54, 53]\n assert candidate(restaurants = [[501, 6, 1, 10, 5], [502, 7, 0, 15, 4], [503, 8, 1, 20, 3], [504, 9, 0, 25, 2], [505, 10, 1, 12, 1]],veganFriendly = 0,maxPrice = 25,maxDistance = 5) == [505, 504, 503, 502, 501]\n assert candidate(restaurants = [[101, 80, 1, 10, 5], [202, 85, 0, 20, 3], [303, 80, 1, 10, 2], [404, 80, 0, 25, 5], [505, 85, 1, 15, 4], [606, 80, 0, 10, 4]],veganFriendly = 1,maxPrice = 100,maxDistance = 100) == [505, 303, 101]\n assert candidate(restaurants = [[201, 3, 0, 40, 15], [202, 5, 1, 45, 20], [203, 8, 1, 50, 10], [204, 4, 0, 50, 25], [205, 6, 0, 40, 15], [206, 7, 1, 45, 15], [207, 9, 1, 35, 10]],veganFriendly = 1,maxPrice = 50,maxDistance = 20) == [207, 203, 206, 202]\n assert candidate(restaurants = [[100, 90, 1, 10, 20], [200, 85, 0, 15, 25], [300, 80, 1, 5, 15], [400, 75, 0, 25, 10], [500, 70, 1, 20, 5]],veganFriendly = 0,maxPrice = 25,maxDistance = 20) == [100, 300, 400, 500]\n assert candidate(restaurants = [[201, 8, 1, 10, 4], [202, 6, 0, 15, 3], [203, 9, 1, 20, 2], [204, 7, 0, 25, 5], [205, 8, 1, 12, 3], [206, 9, 0, 30, 4]],veganFriendly = 1,maxPrice = 30,maxDistance = 5) == [203, 205, 201]\n assert candidate(restaurants = [[17, 2, 0, 30, 13], [18, 5, 1, 40, 18], [19, 7, 1, 50, 22], [20, 1, 0, 60, 30], [21, 4, 0, 10, 2]],veganFriendly = 1,maxPrice = 55,maxDistance = 28) == [19, 18]\n assert candidate(restaurants = [[11, 3, 1, 60, 20], [12, 8, 0, 70, 22], [13, 9, 1, 20, 10], [14, 10, 0, 5, 5], [15, 8, 1, 35, 12], [16, 12, 0, 15, 9]],veganFriendly = 0,maxPrice = 75,maxDistance = 25) == [16, 14, 13, 15, 12, 11]\n assert candidate(restaurants = [[66, 1, 1, 1, 1], [77, 1, 0, 2, 2], [88, 2, 1, 3, 3], [99, 2, 0, 4, 4], [100, 3, 1, 5, 5]],veganFriendly = 0,maxPrice = 5,maxDistance = 5) == [100, 99, 88, 77, 66]\n assert candidate(restaurants = [[12, 3, 0, 60, 7], [13, 2, 1, 45, 6], [14, 5, 1, 55, 8], [15, 4, 0, 35, 5], [16, 6, 1, 40, 9], [17, 7, 1, 30, 3]],veganFriendly = 1,maxPrice = 50,maxDistance = 10) == [17, 16, 13]\n assert candidate(restaurants = [[18, 9, 1, 20, 5], [19, 10, 0, 25, 3], [20, 8, 1, 15, 2], [21, 7, 1, 10, 1], [22, 6, 0, 5, 1], [23, 5, 1, 30, 4]],veganFriendly = 0,maxPrice = 100,maxDistance = 10) == [19, 18, 20, 21, 22, 23]\n assert candidate(restaurants = [[60, 10, 1, 10, 1], [61, 9, 0, 15, 2], [62, 8, 1, 20, 3], [63, 7, 1, 25, 4], [64, 6, 0, 30, 5], [65, 5, 1, 35, 6]],veganFriendly = 1,maxPrice = 10,maxDistance = 1) == [60]\n assert candidate(restaurants = [[1001, 1, 1, 1, 1], [1002, 2, 0, 2, 2], [1003, 3, 1, 3, 3], [1004, 4, 0, 4, 4], [1005, 5, 1, 5, 5], [1006, 6, 0, 6, 6], [1007, 7, 1, 7, 7]],veganFriendly = 1,maxPrice = 7,maxDistance = 7) == [1007, 1005, 1003, 1001]\n assert candidate(restaurants = [[28, 5, 0, 30, 15], [29, 8, 1, 40, 20], [30, 6, 0, 25, 10], [31, 7, 1, 5, 5], [32, 9, 0, 10, 4], [33, 12, 1, 35, 12], [34, 10, 0, 15, 9]],veganFriendly = 0,maxPrice = 55,maxDistance = 28) == [33, 34, 32, 29, 31, 30, 28]\n assert candidate(restaurants = [[10, 9, 1, 20, 1], [20, 8, 0, 10, 2], [30, 7, 1, 5, 3], [40, 10, 1, 15, 2], [50, 6, 0, 25, 4], [60, 8, 1, 30, 1]],veganFriendly = 1,maxPrice = 30,maxDistance = 3) == [40, 10, 60, 30]\n assert candidate(restaurants = [[6, 5, 1, 20, 5], [7, 7, 0, 25, 3], [8, 6, 1, 15, 2], [9, 9, 1, 10, 1], [10, 10, 0, 5, 1], [11, 8, 1, 30, 4]],veganFriendly = 1,maxPrice = 25,maxDistance = 4) == [9, 8]\n assert candidate(restaurants = [[1, 100, 1, 1, 1], [2, 99, 0, 2, 2], [3, 98, 1, 3, 3], [4, 97, 0, 4, 4], [5, 96, 1, 5, 5], [6, 95, 0, 6, 6], [7, 94, 1, 7, 7], [8, 93, 0, 8, 8], [9, 92, 1, 9, 9], [10, 91, 0, 10, 10]],veganFriendly = 1,maxPrice = 10,maxDistance = 10) == [1, 3, 5, 7, 9]\n assert candidate(restaurants = [[6, 9, 0, 20, 6], [7, 7, 1, 15, 3], [8, 6, 1, 25, 2], [9, 10, 0, 5, 1], [10, 4, 1, 35, 8]],veganFriendly = 1,maxPrice = 30,maxDistance = 5) == [7, 8]\n assert candidate(restaurants = [[1000, 95, 1, 40, 50], [2000, 90, 0, 50, 60], [3000, 85, 1, 30, 40], [4000, 80, 0, 40, 30], [5000, 75, 1, 20, 20], [6000, 70, 0, 30, 10]],veganFriendly = 1,maxPrice = 30,maxDistance = 30) == [5000]\n assert candidate(restaurants = [[501, 9, 1, 25, 7], [502, 6, 0, 40, 12], [503, 8, 1, 45, 8], [504, 7, 0, 35, 15], [505, 9, 1, 50, 6], [506, 6, 1, 35, 10], [507, 8, 0, 40, 8]],veganFriendly = 1,maxPrice = 50,maxDistance = 20) == [505, 501, 503, 506]\n assert candidate(restaurants = [[11, 3, 1, 10, 10], [22, 2, 0, 9, 9], [33, 3, 1, 8, 8], [44, 2, 0, 7, 7], [55, 3, 1, 6, 6]],veganFriendly = 1,maxPrice = 10,maxDistance = 10) == [55, 33, 11]\n assert candidate(restaurants = [[601, 5, 1, 5, 5], [602, 6, 1, 10, 10], [603, 7, 1, 15, 15], [604, 8, 1, 20, 20], [605, 9, 1, 25, 25], [606, 10, 1, 30, 30]],veganFriendly = 1,maxPrice = 25,maxDistance = 25) == [605, 604, 603, 602, 601]\n assert candidate(restaurants = [[11, 50, 1, 20, 10], [12, 50, 1, 20, 9], [13, 50, 1, 20, 8], [14, 50, 1, 20, 7], [15, 50, 1, 20, 6], [16, 50, 1, 20, 5], [17, 50, 1, 20, 4], [18, 50, 1, 20, 3], [19, 50, 1, 20, 2], [20, 50, 1, 20, 1]],veganFriendly = 1,maxPrice = 20,maxDistance = 10) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]\n assert candidate(restaurants = [[6, 6, 0, 55, 15], [7, 7, 1, 35, 7], [8, 9, 0, 25, 8], [9, 7, 1, 5, 1], [10, 5, 0, 10, 4]],veganFriendly = 1,maxPrice = 40,maxDistance = 10) == [9, 7]\n assert candidate(restaurants = [[16, 1, 0, 40, 7], [17, 3, 1, 20, 5], [18, 2, 1, 30, 4], [19, 4, 0, 50, 3], [20, 5, 1, 45, 2]],veganFriendly = 0,maxPrice = 45,maxDistance = 7) == [20, 17, 18, 16]\n assert candidate(restaurants = [[101, 95, 1, 20, 15], [202, 85, 0, 55, 18], [303, 95, 1, 25, 12], [404, 75, 0, 22, 14], [505, 88, 1, 18, 16], [606, 80, 0, 30, 10]],veganFriendly = 1,maxPrice = 55,maxDistance = 20) == [303, 101, 505]\n assert candidate(restaurants = [[701, 10, 0, 20, 1], [702, 9, 1, 25, 2], [703, 8, 0, 30, 3], [704, 7, 1, 15, 4], [705, 6, 0, 10, 5]],veganFriendly = 0,maxPrice = 30,maxDistance = 5) == [701, 702, 703, 704, 705]\n assert candidate(restaurants = [[46, 1, 0, 50, 10], [47, 3, 1, 45, 9], [48, 2, 1, 40, 8], [49, 4, 0, 35, 7], [50, 5, 1, 30, 6]],veganFriendly = 0,maxPrice = 45,maxDistance = 9) == [50, 49, 47, 48]\n"}, "metadata": {"canonical_parameter_names": ["restaurants", "veganFriendly", "maxPrice", "maxDistance"], "leetcode_dataset_entry_point": "Solution().filterRestaurants", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector filterRestaurants(vector>& restaurants, int veganFriendly, int maxPrice, int maxDistance) {", "container": "Solution", "callable": "filterRestaurants", "parameters": [{"name": "restaurants", "type": "vector>&"}, {"name": "veganFriendly", "type": "int"}, {"name": "maxPrice", "type": "int"}, {"name": "maxDistance", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1334, "task_id": "find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance", "difficulty": "Medium", "problem_description": "There are n cities numbered from 0 to n-1. Given the array edges where edges[i] = [fromi, toi, weighti] represents a bidirectional and weighted edge between cities fromi and toi, and given the integer distanceThreshold.\nReturn the city with the smallest number of cities that are reachable through some path and whose distance is at most distanceThreshold, If there are multiple such cities, return the city with the greatest number.\nNotice that the distance of a path connecting cities i and j is equal to the sum of the edges' weights along that path.\n \nExample 1:\n\n\nInput: n = 4, edges = [[0,1,3],[1,2,1],[1,3,4],[2,3,1]], distanceThreshold = 4\nOutput: 3\nExplanation: The figure above describes the graph. \nThe neighboring cities at a distanceThreshold = 4 for each city are:\nCity 0 -> [City 1, City 2] \nCity 1 -> [City 0, City 2, City 3] \nCity 2 -> [City 0, City 1, City 3] \nCity 3 -> [City 1, City 2] \nCities 0 and 3 have 2 neighboring cities at a distanceThreshold = 4, but we have to return city 3 since it has the greatest number.\n\nExample 2:\n\n\nInput: n = 5, edges = [[0,1,2],[0,4,8],[1,2,3],[1,4,2],[2,3,1],[3,4,1]], distanceThreshold = 2\nOutput: 0\nExplanation: The figure above describes the graph. \nThe neighboring cities at a distanceThreshold = 2 for each city are:\nCity 0 -> [City 1] \nCity 1 -> [City 0, City 4] \nCity 2 -> [City 3, City 4] \nCity 3 -> [City 2, City 4]\nCity 4 -> [City 1, City 2, City 3] \nThe city 0 has 1 neighboring city at a distanceThreshold = 2.\n\n \nConstraints:\n\n2 <= n <= 100\n1 <= edges.length <= n * (n - 1) / 2\nedges[i].length == 3\n0 <= fromi < toi < n\n1 <= weighti, distanceThreshold <= 10^4\nAll pairs (fromi, toi) are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,edges = [[0, 1, 2], [0, 4, 8], [1, 2, 3], [1, 4, 2], [2, 3, 1], [3, 4, 1]],distanceThreshold = 2) == 0\n assert candidate(n = 4,edges = [[0, 1, 3], [1, 2, 1], [1, 3, 4], [2, 3, 1]],distanceThreshold = 4) == 3\n assert candidate(n = 6,edges = [[0, 1, 10], [0, 2, 3], [1, 2, 1], [1, 3, 7], [2, 4, 2], [3, 4, 8], [4, 5, 6]],distanceThreshold = 20) == 5\n assert candidate(n = 3,edges = [[0, 1, 5], [1, 2, 5], [0, 2, 5]],distanceThreshold = 10) == 2\n assert candidate(n = 7,edges = [[0, 1, 1], [0, 2, 1], [1, 2, 1], [1, 3, 1], [2, 3, 1], [2, 4, 1], [3, 4, 1], [3, 5, 1], [4, 5, 1], [4, 6, 1], [5, 6, 1]],distanceThreshold = 1) == 6\n assert candidate(n = 10,edges = [[0, 1, 2], [0, 5, 3], [1, 2, 1], [1, 3, 4], [2, 4, 3], [2, 5, 2], [3, 4, 1], [3, 6, 5], [4, 7, 2], [5, 6, 1], [6, 7, 3], [7, 8, 1], [8, 9, 4]],distanceThreshold = 5) == 9\n assert candidate(n = 6,edges = [[0, 1, 1], [0, 2, 5], [1, 2, 1], [1, 3, 3], [1, 4, 7], [2, 3, 1], [2, 4, 2], [3, 4, 1], [3, 5, 2], [4, 5, 2]],distanceThreshold = 4) == 5\n assert candidate(n = 10,edges = [[0, 1, 2], [1, 2, 2], [2, 3, 2], [3, 4, 2], [4, 5, 2], [5, 6, 2], [6, 7, 2], [7, 8, 2], [8, 9, 2], [9, 0, 2]],distanceThreshold = 5) == 9\n assert candidate(n = 10,edges = [[0, 1, 3], [0, 2, 5], [0, 3, 7], [0, 4, 9], [1, 2, 4], [1, 3, 6], [1, 4, 8], [1, 5, 2], [2, 3, 3], [2, 4, 5], [2, 5, 7], [2, 6, 1], [3, 4, 4], [3, 5, 6], [3, 6, 8], [3, 7, 2], [4, 5, 3], [4, 6, 5], [4, 7, 7], [4, 8, 1], [5, 6, 4], [5, 7, 6], [5, 8, 8], [5, 9, 2], [6, 7, 3], [6, 8, 5], [6, 9, 7], [7, 8, 4], [7, 9, 6], [8, 9, 5]],distanceThreshold = 20) == 9\n assert candidate(n = 9,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 0, 1], [0, 2, 1], [1, 3, 1], [2, 4, 1], [3, 5, 1], [4, 6, 1], [5, 7, 1], [6, 8, 1], [7, 0, 1], [8, 1, 1]],distanceThreshold = 2) == 8\n assert candidate(n = 10,edges = [[0, 1, 100], [0, 5, 100], [0, 4, 100], [1, 2, 100], [1, 5, 100], [2, 3, 100], [3, 4, 100], [4, 5, 100], [5, 6, 100], [6, 7, 100], [7, 8, 100], [8, 9, 100], [9, 0, 100]],distanceThreshold = 50) == 9\n assert candidate(n = 6,edges = [[0, 1, 2], [1, 2, 4], [2, 3, 6], [3, 4, 8], [4, 5, 10], [0, 5, 12], [1, 4, 14], [2, 5, 16]],distanceThreshold = 10) == 5\n assert candidate(n = 6,edges = [[0, 1, 10], [1, 2, 15], [2, 3, 20], [0, 3, 25], [0, 2, 30], [1, 3, 35]],distanceThreshold = 50) == 5\n assert candidate(n = 8,edges = [[0, 1, 4], [0, 2, 1], [1, 2, 2], [1, 3, 5], [2, 3, 1], [3, 4, 3], [4, 5, 2], [4, 6, 6], [5, 6, 1], [6, 7, 3]],distanceThreshold = 6) == 7\n assert candidate(n = 6,edges = [[0, 1, 3], [0, 2, 4], [0, 4, 5], [1, 2, 1], [1, 3, 2], [1, 5, 6], [2, 3, 3], [2, 5, 1], [3, 5, 2], [4, 5, 4]],distanceThreshold = 7) == 5\n assert candidate(n = 12,edges = [[0, 1, 2], [0, 4, 4], [0, 11, 6], [1, 2, 1], [1, 3, 3], [1, 4, 2], [2, 3, 1], [2, 4, 3], [2, 5, 2], [3, 4, 1], [3, 6, 4], [3, 7, 5], [4, 5, 1], [4, 6, 2], [4, 7, 3], [5, 6, 1], [5, 7, 2], [5, 8, 4], [5, 9, 5], [6, 8, 1], [6, 9, 3], [6, 10, 4], [7, 8, 2], [7, 9, 1], [7, 10, 3], [8, 9, 1], [8, 10, 2], [8, 11, 6], [9, 10, 1], [9, 11, 3], [10, 11, 2]],distanceThreshold = 5) == 11\n assert candidate(n = 7,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [0, 6, 10], [0, 3, 1], [1, 4, 1], [2, 5, 1]],distanceThreshold = 15) == 6\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [0, 4, 4], [0, 5, 5], [0, 6, 6], [0, 7, 7], [0, 8, 8], [1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [1, 7, 6], [1, 8, 7], [2, 3, 1], [2, 4, 2], [2, 5, 3], [2, 6, 4], [2, 7, 5], [2, 8, 6], [3, 4, 1], [3, 5, 2], [3, 6, 3], [3, 7, 4], [3, 8, 5], [4, 5, 1], [4, 6, 2], [4, 7, 3], [4, 8, 4], [5, 6, 1], [5, 7, 2], [5, 8, 3], [6, 7, 1], [6, 8, 2], [7, 8, 1]],distanceThreshold = 5) == 8\n assert candidate(n = 7,edges = [[0, 1, 2], [0, 6, 5], [1, 2, 3], [1, 3, 1], [1, 6, 4], [2, 3, 1], [2, 4, 3], [3, 4, 1], [3, 5, 2], [4, 5, 2], [5, 6, 3]],distanceThreshold = 5) == 6\n assert candidate(n = 7,edges = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [0, 5, 6], [0, 6, 7], [1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [2, 3, 1], [2, 4, 2], [2, 5, 3], [2, 6, 4], [3, 4, 1], [3, 5, 2], [3, 6, 3], [4, 5, 1], [4, 6, 2], [5, 6, 1]],distanceThreshold = 10) == 6\n assert candidate(n = 9,edges = [[0, 1, 5], [0, 3, 4], [1, 2, 1], [1, 3, 2], [2, 3, 3], [2, 4, 2], [3, 4, 4], [3, 5, 6], [3, 6, 7], [4, 5, 1], [5, 6, 1], [5, 7, 3], [5, 8, 2], [6, 8, 4]],distanceThreshold = 10) == 0\n assert candidate(n = 7,edges = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 4], [1, 4, 3], [2, 3, 2], [2, 5, 5], [3, 4, 1], [3, 5, 3], [3, 6, 4], [4, 5, 1], [5, 6, 2]],distanceThreshold = 5) == 6\n assert candidate(n = 8,edges = [[0, 1, 7], [0, 2, 5], [1, 2, 9], [1, 3, 8], [1, 4, 4], [2, 3, 2], [2, 5, 3], [3, 5, 6], [3, 6, 7], [4, 5, 1], [4, 7, 3], [5, 6, 8], [6, 7, 6]],distanceThreshold = 15) == 7\n assert candidate(n = 7,edges = [[0, 1, 4], [0, 2, 6], [1, 2, 5], [1, 3, 3], [1, 4, 8], [2, 4, 7], [3, 4, 5], [4, 5, 9], [4, 6, 2]],distanceThreshold = 10) == 5\n assert candidate(n = 10,edges = [[0, 1, 4], [0, 2, 5], [0, 3, 6], [1, 2, 1], [1, 3, 2], [1, 4, 3], [2, 3, 1], [2, 4, 2], [2, 5, 3], [3, 4, 1], [3, 5, 2], [3, 6, 3], [4, 5, 1], [4, 6, 2], [4, 7, 3], [5, 6, 1], [5, 7, 2], [5, 8, 3], [6, 7, 1], [6, 8, 2], [6, 9, 3], [7, 8, 1], [7, 9, 2], [8, 9, 1]],distanceThreshold = 5) == 0\n assert candidate(n = 6,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [0, 4, 4], [0, 5, 5], [1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [2, 3, 1], [2, 4, 2], [2, 5, 3], [3, 4, 1], [3, 5, 2], [4, 5, 1]],distanceThreshold = 5) == 5\n assert candidate(n = 8,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [0, 4, 15], [1, 5, 10], [2, 6, 9], [3, 7, 12]],distanceThreshold = 20) == 7\n assert candidate(n = 6,edges = [[0, 1, 3], [0, 2, 5], [1, 2, 2], [1, 3, 4], [1, 4, 6], [2, 3, 1], [2, 4, 3], [3, 4, 1], [3, 5, 2], [4, 5, 2]],distanceThreshold = 4) == 0\n assert candidate(n = 12,edges = [[0, 1, 10], [0, 5, 30], [0, 4, 100], [1, 2, 50], [1, 5, 20], [2, 3, 10], [3, 4, 20], [4, 5, 30], [5, 6, 10], [6, 7, 20], [7, 8, 10], [8, 9, 30], [9, 10, 20], [10, 11, 10], [11, 0, 50]],distanceThreshold = 60) == 11\n assert candidate(n = 6,edges = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 4], [1, 4, 5], [2, 3, 2], [2, 4, 3], [3, 4, 1], [3, 5, 1], [4, 5, 2]],distanceThreshold = 5) == 0\n assert candidate(n = 10,edges = [[0, 1, 2], [1, 2, 3], [0, 3, 4], [3, 4, 5], [4, 5, 1], [2, 5, 2], [5, 6, 3], [6, 7, 4], [7, 8, 5], [8, 9, 6], [0, 9, 7]],distanceThreshold = 10) == 9\n assert candidate(n = 7,edges = [[0, 1, 4], [1, 2, 3], [2, 3, 2], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 0, 4]],distanceThreshold = 6) == 0\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 5], [1, 2, 2], [1, 3, 6], [2, 4, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7]],distanceThreshold = 10) == 7\n assert candidate(n = 9,edges = [[0, 1, 4], [0, 2, 9], [0, 3, 5], [0, 4, 3], [1, 2, 10], [1, 3, 2], [1, 4, 8], [2, 3, 5], [2, 4, 7], [3, 4, 4], [5, 6, 2], [5, 7, 3], [5, 8, 5], [6, 7, 1], [6, 8, 4], [7, 8, 2]],distanceThreshold = 7) == 8\n assert candidate(n = 6,edges = [[0, 1, 3], [1, 2, 2], [2, 3, 3], [3, 4, 2], [4, 5, 3], [5, 0, 2]],distanceThreshold = 6) == 5\n assert candidate(n = 10,edges = [[0, 1, 4], [0, 2, 15], [0, 3, 10], [1, 2, 3], [1, 3, 12], [1, 4, 20], [2, 3, 7], [2, 4, 13], [2, 5, 8], [3, 4, 1], [3, 5, 6], [3, 6, 14], [4, 5, 9], [4, 6, 11], [5, 6, 5], [6, 7, 17], [6, 8, 22], [7, 8, 2], [7, 9, 23], [8, 9, 18]],distanceThreshold = 30) == 9\n assert candidate(n = 8,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 0, 1]],distanceThreshold = 3) == 7\n assert candidate(n = 10,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [9, 0, 5], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 5, 10], [4, 6, 10], [5, 7, 10], [6, 8, 10], [7, 9, 10], [8, 0, 10], [9, 1, 10]],distanceThreshold = 25) == 9\n assert candidate(n = 10,edges = [[0, 1, 5], [0, 4, 8], [1, 2, 3], [1, 4, 2], [2, 3, 1], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 1], [7, 8, 2], [8, 9, 1], [9, 5, 3]],distanceThreshold = 10) == 0\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [1, 2, 1], [1, 3, 1], [2, 3, 1], [4, 5, 2], [4, 6, 3], [4, 7, 4], [5, 6, 1], [5, 7, 2], [6, 7, 1]],distanceThreshold = 3) == 7\n assert candidate(n = 7,edges = [[0, 1, 1], [0, 6, 6], [1, 2, 1], [1, 5, 5], [2, 3, 1], [2, 4, 4], [3, 4, 1], [3, 6, 6], [4, 5, 1], [5, 6, 6]],distanceThreshold = 6) == 6\n assert candidate(n = 15,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 0, 1]],distanceThreshold = 7) == 14\n assert candidate(n = 6,edges = [[0, 1, 2], [0, 5, 10], [1, 2, 1], [1, 4, 3], [2, 3, 2], [3, 4, 2], [3, 5, 3], [4, 5, 5]],distanceThreshold = 6) == 5\n assert candidate(n = 8,edges = [[0, 1, 4], [1, 2, 4], [2, 3, 4], [3, 4, 4], [4, 5, 4], [5, 6, 4], [6, 7, 4], [0, 7, 8], [0, 3, 5], [1, 4, 5], [2, 5, 5], [3, 6, 5], [4, 7, 5]],distanceThreshold = 12) == 7\n assert candidate(n = 8,edges = [[0, 1, 5], [0, 2, 5], [0, 7, 6], [1, 2, 5], [1, 3, 3], [1, 6, 4], [1, 7, 3], [2, 3, 5], [2, 4, 5], [3, 4, 3], [3, 5, 2], [4, 5, 2], [4, 6, 5], [5, 6, 5], [6, 7, 5]],distanceThreshold = 8) == 0\n assert candidate(n = 10,edges = [[0, 1, 10], [0, 2, 20], [1, 2, 30], [1, 3, 40], [2, 4, 50], [3, 4, 60], [4, 5, 70], [5, 6, 80], [6, 7, 90], [7, 8, 100], [8, 9, 110], [0, 9, 120]],distanceThreshold = 200) == 8\n assert candidate(n = 9,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [0, 8, 1]],distanceThreshold = 4) == 8\n assert candidate(n = 7,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 0, 1]],distanceThreshold = 2) == 6\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5], [3, 4, 6], [4, 5, 7], [5, 6, 8], [6, 7, 9], [7, 8, 10], [8, 0, 11], [0, 3, 12], [1, 4, 13], [2, 5, 14], [3, 6, 15], [4, 7, 16], [5, 8, 17]],distanceThreshold = 20) == 7\n assert candidate(n = 7,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 0, 8]],distanceThreshold = 10) == 5\n assert candidate(n = 12,edges = [[0, 1, 7], [0, 2, 10], [0, 3, 12], [0, 4, 8], [0, 5, 9], [0, 6, 5], [0, 7, 2], [0, 8, 6], [0, 9, 8], [0, 10, 3], [0, 11, 4], [1, 2, 6], [1, 3, 4], [1, 4, 2], [1, 5, 7], [1, 6, 8], [1, 7, 9], [1, 8, 3], [1, 9, 5], [1, 10, 11], [1, 11, 2], [2, 3, 10], [2, 4, 3], [2, 5, 12], [2, 6, 6], [2, 7, 1], [2, 8, 4], [2, 9, 7], [2, 10, 5], [2, 11, 8], [3, 4, 5], [3, 5, 10], [3, 6, 9], [3, 7, 11], [3, 8, 2], [3, 9, 6], [3, 10, 1], [3, 11, 4], [4, 5, 2], [4, 6, 10], [4, 7, 3], [4, 8, 5], [4, 9, 1], [4, 10, 7], [4, 11, 8], [5, 6, 3], [5, 7, 11], [5, 8, 9], [5, 9, 4], [5, 10, 6], [5, 11, 2], [6, 7, 5], [6, 8, 10], [6, 9, 3], [6, 10, 12], [6, 11, 4], [7, 8, 3], [7, 9, 2], [7, 10, 5], [7, 11, 1], [8, 9, 5], [8, 10, 2], [8, 11, 4], [9, 10, 7], [9, 11, 3], [10, 11, 2]],distanceThreshold = 10) == 11\n assert candidate(n = 10,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 0, 11]],distanceThreshold = 15) == 8\n assert candidate(n = 6,edges = [[0, 1, 2], [0, 2, 4], [0, 3, 5], [1, 2, 1], [1, 3, 8], [1, 4, 3], [2, 3, 2], [2, 4, 6], [3, 4, 7], [3, 5, 3], [4, 5, 1]],distanceThreshold = 5) == 5\n assert candidate(n = 8,edges = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [1, 4, 5], [1, 5, 6], [2, 6, 7], [2, 7, 8], [3, 7, 9]],distanceThreshold = 10) == 7\n assert candidate(n = 6,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [0, 5, 7]],distanceThreshold = 9) == 5\n assert candidate(n = 9,edges = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [0, 5, 6], [0, 6, 7], [0, 7, 8], [0, 8, 9], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [1, 3, 4], [2, 4, 5], [3, 5, 6], [4, 6, 7], [5, 7, 8], [6, 8, 9], [1, 4, 6], [2, 5, 7], [3, 6, 8], [4, 7, 9], [5, 8, 10], [1, 5, 8], [2, 6, 9], [3, 7, 10], [4, 8, 11], [1, 6, 9], [2, 7, 10], [3, 8, 11], [1, 7, 10], [2, 8, 11], [1, 8, 11]],distanceThreshold = 15) == 8\n assert candidate(n = 9,edges = [[0, 1, 100], [1, 2, 100], [2, 3, 100], [3, 4, 100], [4, 5, 100], [5, 6, 100], [6, 7, 100], [7, 8, 100], [0, 8, 100], [0, 4, 50], [1, 5, 50], [2, 6, 50], [3, 7, 50], [4, 8, 50], [5, 0, 50], [6, 1, 50], [7, 2, 50], [8, 3, 50]],distanceThreshold = 150) == 8\n assert candidate(n = 10,edges = [[0, 1, 4], [0, 2, 8], [0, 3, 7], [0, 4, 9], [0, 5, 10], [0, 6, 1], [0, 7, 2], [0, 8, 6], [0, 9, 8], [1, 2, 2], [1, 3, 9], [1, 4, 3], [1, 5, 5], [1, 6, 1], [1, 7, 4], [1, 8, 7], [1, 9, 1], [2, 3, 7], [2, 4, 5], [2, 5, 10], [2, 6, 6], [2, 7, 1], [2, 8, 4], [2, 9, 3], [3, 4, 3], [3, 5, 9], [3, 6, 5], [3, 7, 10], [3, 8, 6], [3, 9, 1], [4, 5, 5], [4, 6, 9], [4, 7, 7], [4, 8, 1], [4, 9, 8], [5, 6, 8], [5, 7, 6], [5, 8, 10], [5, 9, 4], [6, 7, 7], [6, 8, 5], [6, 9, 3], [7, 8, 4], [7, 9, 2], [8, 9, 5]],distanceThreshold = 10) == 9\n assert candidate(n = 6,edges = [[0, 1, 2], [0, 3, 4], [1, 2, 1], [1, 4, 5], [2, 3, 1], [3, 4, 3], [4, 5, 2]],distanceThreshold = 5) == 5\n assert candidate(n = 9,edges = [[0, 1, 5], [0, 2, 7], [0, 3, 9], [1, 4, 11], [1, 5, 13], [2, 5, 15], [2, 6, 17], [3, 6, 19], [4, 7, 21], [4, 8, 23], [5, 7, 25], [5, 8, 27], [6, 8, 29]],distanceThreshold = 20) == 8\n assert candidate(n = 8,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8], [0, 7, 9], [1, 6, 10]],distanceThreshold = 15) == 7\n"}, "metadata": {"canonical_parameter_names": ["n", "edges", "distanceThreshold"], "leetcode_dataset_entry_point": "Solution().findTheCity", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int findTheCity(int n, vector>& edges, int distanceThreshold) {", "container": "Solution", "callable": "findTheCity", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "vector>&"}, {"name": "distanceThreshold", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1335, "task_id": "minimum-difficulty-of-a-job-schedule", "difficulty": "Hard", "problem_description": "You want to schedule a list of jobs in d days. Jobs are dependent (i.e To work on the ith job, you have to finish all the jobs j where 0 <= j < i).\nYou have to finish at least one task every day. The difficulty of a job schedule is the sum of difficulties of each day of the d days. The difficulty of a day is the maximum difficulty of a job done on that day.\nYou are given an integer array jobDifficulty and an integer d. The difficulty of the ith job is jobDifficulty[i].\nReturn the minimum difficulty of a job schedule. If you cannot find a schedule for the jobs return -1.\n \nExample 1:\n\n\nInput: jobDifficulty = [6,5,4,3,2,1], d = 2\nOutput: 7\nExplanation: First day you can finish the first 5 jobs, total difficulty = 6.\nSecond day you can finish the last job, total difficulty = 1.\nThe difficulty of the schedule = 6 + 1 = 7 \n\nExample 2:\n\nInput: jobDifficulty = [9,9,9], d = 4\nOutput: -1\nExplanation: If you finish a job per day you will still have a free day. you cannot find a schedule for the given jobs.\n\nExample 3:\n\nInput: jobDifficulty = [1,1,1], d = 3\nOutput: 3\nExplanation: The schedule is one job per day. total difficulty will be 3.\n\n \nConstraints:\n\n1 <= jobDifficulty.length <= 300\n0 <= jobDifficulty[i] <= 1000\n1 <= d <= 10\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 10) == 55\n assert candidate(jobDifficulty = [300, 500, 1000],d = 3) == 1800\n assert candidate(jobDifficulty = [6, 5, 4, 3, 2, 1],d = 2) == 7\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 5) == 20\n assert candidate(jobDifficulty = [15, 97, 88, 92, 49],d = 2) == 112\n assert candidate(jobDifficulty = [7, 1, 7, 1, 7, 1],d = 3) == 15\n assert candidate(jobDifficulty = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],d = 5) == 25\n assert candidate(jobDifficulty = [0, 0, 0, 0],d = 4) == 0\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50],d = 3) == 80\n assert candidate(jobDifficulty = [1000, 0, 1000, 0, 1000],d = 3) == 2000\n assert candidate(jobDifficulty = [30, 10, 40, 20, 10, 50],d = 3) == 90\n assert candidate(jobDifficulty = [100, 200, 300],d = 1) == 300\n assert candidate(jobDifficulty = [3, 2, 1],d = 1) == 3\n assert candidate(jobDifficulty = [1],d = 1) == 1\n assert candidate(jobDifficulty = [5, 4, 3, 2, 1],d = 1) == 5\n assert candidate(jobDifficulty = [9, 9, 9],d = 4) == -1\n assert candidate(jobDifficulty = [5, 4, 3, 2, 1],d = 5) == 15\n assert candidate(jobDifficulty = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],d = 10) == 30\n assert candidate(jobDifficulty = [1, 2],d = 2) == 3\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50],d = 2) == 60\n assert candidate(jobDifficulty = [1, 1, 1],d = 3) == 3\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50],d = 5) == 150\n assert candidate(jobDifficulty = [500, 400, 300, 200, 100, 900, 800, 700, 600, 500],d = 4) == 1700\n assert candidate(jobDifficulty = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 10) == 10\n assert candidate(jobDifficulty = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1],d = 5) == 32\n assert candidate(jobDifficulty = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],d = 10) == 550\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],d = 15) == 1200\n assert candidate(jobDifficulty = [10, 4, 15, 8, 12, 9, 5, 6, 7, 11, 3],d = 4) == 32\n assert candidate(jobDifficulty = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 10) == 55\n assert candidate(jobDifficulty = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],d = 10) == 15\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 300],d = 15) == 405\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],d = 5) == 25\n assert candidate(jobDifficulty = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 3) == 13\n assert candidate(jobDifficulty = [8, 5, 7, 9, 4, 2, 6, 3, 10, 1, 12, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],d = 20) == 220\n assert candidate(jobDifficulty = [9, 4, 5, 3, 2, 8, 7, 1, 6, 10],d = 5) == 29\n assert candidate(jobDifficulty = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 29) == 29\n assert candidate(jobDifficulty = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],d = 10) == 180\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 10) == 65\n assert candidate(jobDifficulty = [300, 200, 100, 250, 400, 350, 500, 450, 550, 600],d = 5) == 1450\n assert candidate(jobDifficulty = [5, 8, 6, 5, 3, 4, 2, 7, 1, 9],d = 4) == 23\n assert candidate(jobDifficulty = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60],d = 25) == 660\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],d = 15) == 1350\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],d = 5) == 400\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],d = 10) == 60\n assert candidate(jobDifficulty = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],d = 10) == 6500\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 4) == 16\n assert candidate(jobDifficulty = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 10) == 10\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],d = 1) == 30\n assert candidate(jobDifficulty = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6],d = 5) == 21\n assert candidate(jobDifficulty = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],d = 7) == 35\n assert candidate(jobDifficulty = [10, 100, 20, 50, 30, 70, 40, 60, 90, 80, 10, 200, 150, 300, 250],d = 5) == 480\n assert candidate(jobDifficulty = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],d = 15) == 75\n assert candidate(jobDifficulty = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],d = 10) == 100\n assert candidate(jobDifficulty = [8, 7, 6, 5, 4, 3, 2, 1],d = 3) == 11\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 300],d = 10) == 345\n assert candidate(jobDifficulty = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],d = 5) == 25\n assert candidate(jobDifficulty = [9, 18, 1, 5, 19, 12, 4, 7, 8, 6],d = 5) == 44\n assert candidate(jobDifficulty = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980],d = 10) == 9855\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],d = 15) == 135\n assert candidate(jobDifficulty = [3, 6, 1, 9, 10, 5, 4, 8, 7, 2],d = 10) == 55\n assert candidate(jobDifficulty = [300, 299, 298, 297, 296, 295, 294, 293, 292, 291, 290, 289, 288, 287, 286, 285, 284, 283, 282, 281, 280, 279, 278, 277, 276, 275, 274, 273, 272, 271],d = 5) == 1390\n assert candidate(jobDifficulty = [7, 8, 4, 3, 2, 9, 10, 11, 1, 2],d = 3) == 14\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],d = 3) == 130\n assert candidate(jobDifficulty = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950, 1050, 1150, 1250, 1350, 1450, 1550, 1650, 1750, 1850, 1950],d = 10) == 6000\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],d = 15) == 1200\n assert candidate(jobDifficulty = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 3) == 13\n assert candidate(jobDifficulty = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000],d = 10) == 3250\n assert candidate(jobDifficulty = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500],d = 5) == 1400\n assert candidate(jobDifficulty = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],d = 10) == 5500\n assert candidate(jobDifficulty = [200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],d = 5) == 300\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],d = 30) == 465\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],d = 5) == 40\n assert candidate(jobDifficulty = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],d = 25) == 50\n assert candidate(jobDifficulty = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],d = 10) == 45\n assert candidate(jobDifficulty = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 10) == 10\n assert candidate(jobDifficulty = [3, 6, 5, 10, 12, 8, 7, 4, 15, 11, 9, 1, 14, 13, 2, 16, 18, 17, 19, 20, 21, 22, 23, 24, 25],d = 10) == 86\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],d = 30) == 465\n assert candidate(jobDifficulty = [300, 200, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],d = 10) == 300\n assert candidate(jobDifficulty = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],d = 2) == 20\n assert candidate(jobDifficulty = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 15, 14, 13, 12, 11, 20, 19, 18, 17, 16],d = 10) == 69\n assert candidate(jobDifficulty = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 50, 100, 150, 200, 250, 300],d = 10) == 2300\n assert candidate(jobDifficulty = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],d = 2) == 1100\n assert candidate(jobDifficulty = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],d = 10) == 140\n assert candidate(jobDifficulty = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991],d = 5) == 2993\n assert candidate(jobDifficulty = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],d = 15) == 1500\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],d = 3) == 130\n assert candidate(jobDifficulty = [300, 250, 200, 150, 100, 50, 10, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 10) == 353\n assert candidate(jobDifficulty = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],d = 10) == 10000\n assert candidate(jobDifficulty = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],d = 10) == 550\n assert candidate(jobDifficulty = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],d = 5) == 500\n assert candidate(jobDifficulty = [9, 18, 7, 16, 15, 14, 13, 2, 11, 10, 8, 6, 5, 4, 3, 1, 12, 17, 19, 20],d = 5) == 46\n assert candidate(jobDifficulty = [500, 300, 700, 100, 200, 400, 800, 600, 900],d = 4) == 1900\n assert candidate(jobDifficulty = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],d = 15) == 255\n assert candidate(jobDifficulty = [5, 8, 3, 1, 9, 4, 6, 7, 2, 10, 15, 12, 14, 11, 13, 16, 18, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],d = 8) == 64\n assert candidate(jobDifficulty = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],d = 29) == 87\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 7) == 31\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],d = 5) == 25\n assert candidate(jobDifficulty = [2, 3, 6, 5, 4, 7, 8, 9, 10, 1, 11, 12, 13, 14, 15],d = 7) == 41\n assert candidate(jobDifficulty = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],d = 1) == 0\n assert candidate(jobDifficulty = [300, 250, 200, 150, 100, 50, 0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000],d = 7) == 1600\n assert candidate(jobDifficulty = [5, 3, 8, 6, 2, 7, 4, 9, 1, 10],d = 4) == 25\n assert candidate(jobDifficulty = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105],d = 7) == 240\n assert candidate(jobDifficulty = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 10) == 10\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],d = 10) == 75\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 7) == 41\n assert candidate(jobDifficulty = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],d = 7) == 36\n assert candidate(jobDifficulty = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 10) == 10\n assert candidate(jobDifficulty = [200, 150, 100, 50, 0, 50, 100, 150, 200],d = 6) == 600\n assert candidate(jobDifficulty = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],d = 20) == -1\n assert candidate(jobDifficulty = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],d = 10) == 10000\n assert candidate(jobDifficulty = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],d = 5) == 400\n"}, "metadata": {"canonical_parameter_names": ["jobDifficulty", "d"], "leetcode_dataset_entry_point": "Solution().minDifficulty", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minDifficulty(vector& jobDifficulty, int d) {", "container": "Solution", "callable": "minDifficulty", "parameters": [{"name": "jobDifficulty", "type": "vector&"}, {"name": "d", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1337, "task_id": "the-k-weakest-rows-in-a-matrix", "difficulty": "Easy", "problem_description": "You are given an m x n binary matrix mat of 1's (representing soldiers) and 0's (representing civilians). The soldiers are positioned in front of the civilians. That is, all the 1's will appear to the left of all the 0's in each row.\nA row i is weaker than a row j if one of the following is true:\n\nThe number of soldiers in row i is less than the number of soldiers in row j.\nBoth rows have the same number of soldiers and i < j.\n\nReturn the indices of the k weakest rows in the matrix ordered from weakest to strongest.\n \nExample 1:\n\nInput: mat = \n[[1,1,0,0,0],\n [1,1,1,1,0],\n [1,0,0,0,0],\n [1,1,0,0,0],\n [1,1,1,1,1]], \nk = 3\nOutput: [2,0,3]\nExplanation: \nThe number of soldiers in each row is: \n- Row 0: 2 \n- Row 1: 4 \n- Row 2: 1 \n- Row 3: 2 \n- Row 4: 5 \nThe rows ordered from weakest to strongest are [2,0,3,1,4].\n\nExample 2:\n\nInput: mat = \n[[1,0,0,0],\n [1,1,1,1],\n [1,0,0,0],\n [1,0,0,0]], \nk = 2\nOutput: [0,2]\nExplanation: \nThe number of soldiers in each row is: \n- Row 0: 1 \n- Row 1: 4 \n- Row 2: 1 \n- Row 3: 1 \nThe rows ordered from weakest to strongest are [0,2,3,1].\n\n \nConstraints:\n\nm == mat.length\nn == mat[i].length\n2 <= n, m <= 100\n1 <= k <= m\nmatrix[i][j] is either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 2) == [0, 1]\n assert candidate(mat = [[0, 0, 0, 0], [1, 0, 0, 0], [1, 1, 0, 0], [1, 1, 1, 0]],k = 2) == [0, 1]\n assert candidate(mat = [[1, 1, 1, 1], [0, 0, 0, 0], [1, 0, 0, 0], [0, 1, 1, 1]],k = 3) == [1, 2, 0]\n assert candidate(mat = [[0, 0, 0, 0], [0, 0, 0, 0], [1, 1, 1, 1], [1, 1, 1, 1]],k = 2) == [0, 1]\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],k = 1) == [0]\n assert candidate(mat = [[1, 1, 0, 0, 0], [1, 1, 1, 1, 0], [1, 0, 0, 0, 0], [1, 1, 0, 0, 0], [1, 1, 1, 1, 1]],k = 3) == [2, 0, 3]\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],k = 4) == [0, 1, 2, 3]\n assert candidate(mat = [[1, 1, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0]],k = 4) == [3, 2, 1, 0]\n assert candidate(mat = [[1, 1, 1, 0, 0], [1, 1, 1, 1, 0], [1, 0, 0, 0, 0], [1, 1, 0, 0, 0], [1, 1, 1, 1, 1]],k = 4) == [2, 3, 0, 1]\n assert candidate(mat = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]],k = 1) == [0]\n assert candidate(mat = [[1, 0, 0, 0], [1, 1, 1, 1], [1, 0, 0, 0], [1, 0, 0, 0]],k = 2) == [0, 2]\n assert candidate(mat = [[1, 1, 1, 0, 0], [1, 1, 1, 1, 0], [1, 0, 0, 0, 0], [1, 1, 0, 0, 0], [1, 1, 1, 1, 1]],k = 5) == [2, 3, 0, 1, 4]\n assert candidate(mat = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],k = 4) == [0, 1, 2, 3]\n assert candidate(mat = [[1, 1, 1, 0], [1, 0, 0, 0], [1, 1, 0, 0]],k = 2) == [1, 2]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 7) == [9, 10, 8, 7, 6, 5, 4]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 10) == [10, 11, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [6, 5, 4, 3, 2]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [5, 4, 3, 2, 1]\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 4) == [0, 1, 2, 3]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 3) == [0, 1, 2]\n assert candidate(mat = [[1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 2) == [4, 3]\n assert candidate(mat = [[1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1]],k = 7) == [1, 5, 3, 0, 2, 4, 6]\n assert candidate(mat = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 6) == [1, 8, 9, 0, 3, 4]\n assert candidate(mat = [[1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]],k = 6) == [5, 4, 3, 2, 1, 0]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0]],k = 5) == [4, 3, 2, 1, 0]\n assert candidate(mat = [[1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0]],k = 5) == [3, 0, 2, 1, 4]\n assert candidate(mat = [[1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 2) == [3, 4]\n assert candidate(mat = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]],k = 6) == [1, 3, 5, 0, 2, 4]\n assert candidate(mat = [[1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 3) == [0, 1, 2]\n assert candidate(mat = [[1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0]],k = 3) == [3, 2, 5]\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]],k = 2) == [0, 1]\n assert candidate(mat = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 7) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(mat = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [1, 2, 3, 4, 5]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [1, 7, 6, 5, 3]\n assert candidate(mat = [[1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [5, 6, 7, 4, 3]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 3) == [5, 4, 3]\n assert candidate(mat = [[1, 1, 1, 1, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0]],k = 5) == [3, 1, 5, 4, 0]\n assert candidate(mat = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]],k = 3) == [3, 2, 0]\n assert candidate(mat = [[1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]],k = 4) == [4, 3, 2, 0]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0]],k = 5) == [4, 3, 2, 1, 0]\n assert candidate(mat = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 4) == [1, 5, 4, 3]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]],k = 3) == [5, 4, 3]\n assert candidate(mat = [[1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0]],k = 3) == [3, 4, 1]\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 0]],k = 4) == [0, 1, 2, 3]\n assert candidate(mat = [[1, 1, 1, 1, 0, 0], [1, 1, 1, 0, 0, 0], [1, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]],k = 3) == [4, 3, 2]\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [0, 1, 2, 3, 4]\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [0, 1, 2, 3, 4]\n assert candidate(mat = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0]],k = 4) == [1, 0, 3, 2]\n assert candidate(mat = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [0, 1, 2, 3, 4]\n assert candidate(mat = [[1, 1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1]],k = 3) == [3, 2, 1]\n assert candidate(mat = [[1, 1, 1, 1, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0]],k = 5) == [3, 4, 1, 0, 2]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [1, 4, 2, 0, 3]\n assert candidate(mat = [[1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 4) == [4, 3, 2, 1]\n assert candidate(mat = [[1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 4) == [8, 9, 7, 0]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 10) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]],k = 3) == [0, 1, 2]\n assert candidate(mat = [[1, 0, 0, 0, 0], [1, 1, 0, 0, 0], [1, 1, 1, 0, 0], [1, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]],k = 6) == [5, 0, 1, 2, 3, 4]\n assert candidate(mat = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [1, 0, 2, 3, 4]\n assert candidate(mat = [[1, 1, 0, 0, 0], [1, 1, 1, 0, 0], [1, 1, 1, 1, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0]],k = 3) == [5, 4, 0]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0]],k = 4) == [5, 1, 6, 4]\n assert candidate(mat = [[1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 3) == [2, 3, 4]\n assert candidate(mat = [[1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [4, 3, 2, 1, 0]\n assert candidate(mat = [[1, 1, 0, 0, 0], [1, 1, 1, 0, 0], [1, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 1, 0, 0], [1, 1, 0, 0, 0]],k = 6) == [4, 5, 0, 7, 1, 6]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0]],k = 5) == [3, 4, 5, 0, 1]\n assert candidate(mat = [[1, 1, 0, 0], [1, 0, 0, 0], [1, 1, 1, 0], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 0, 0]],k = 4) == [1, 0, 5, 2]\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 4) == [0, 1, 2, 3]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 10) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(mat = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]],k = 5) == [1, 3, 4, 0, 2]\n assert candidate(mat = [[1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]],k = 4) == [4, 3, 2, 1]\n assert candidate(mat = [[1, 1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0]],k = 4) == [2, 1, 5, 0]\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 7) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(mat = [[1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]],k = 6) == [2, 0, 3, 4, 1, 5]\n assert candidate(mat = [[1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0]],k = 4) == [0, 1, 2, 3]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 6) == [10, 9, 8, 7, 6, 5]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 3) == [0, 1, 2]\n assert candidate(mat = [[1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1]],k = 4) == [0, 1, 2, 3]\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 3) == [0, 1, 2]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 2) == [0, 1]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 5) == [9, 8, 7, 6, 5]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]],k = 7) == [9, 8, 7, 6, 5, 4, 3]\n"}, "metadata": {"canonical_parameter_names": ["mat", "k"], "leetcode_dataset_entry_point": "Solution().kWeakestRows", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector kWeakestRows(vector>& mat, int k) {", "container": "Solution", "callable": "kWeakestRows", "parameters": [{"name": "mat", "type": "vector>&"}, {"name": "k", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1338, "task_id": "reduce-array-size-to-the-half", "difficulty": "Medium", "problem_description": "You are given an integer array arr. You can choose a set of integers and remove all the occurrences of these integers in the array.\nReturn the minimum size of the set so that at least half of the integers of the array are removed.\n \nExample 1:\n\nInput: arr = [3,3,3,3,5,5,5,2,2,7]\nOutput: 2\nExplanation: Choosing {3,7} will make the new array [5,5,5,2,2] which has size 5 (i.e equal to half of the size of the old array).\nPossible sets of size 2 are {3,5},{3,2},{5,2}.\nChoosing set {2,7} is not possible as it will make the new array [3,3,3,3,5,5,5] which has a size greater than half of the size of the old array.\n\nExample 2:\n\nInput: arr = [7,7,7,7,7,7]\nOutput: 1\nExplanation: The only possible set you can choose is {7}. This will make the new array empty.\n\n \nConstraints:\n\n2 <= arr.length <= 105\narr.length is even.\n1 <= arr[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [7, 7, 7, 7, 7, 7]) == 1\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6]) == 2\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == 2\n assert candidate(arr = [10, 10, 20, 20, 20, 30, 30, 30, 30, 30]) == 1\n assert candidate(arr = [3, 3, 3, 3, 5, 5, 5, 2, 2, 7]) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 2\n assert candidate(arr = [10, 20, 20, 10, 10, 30, 50, 10, 20, 20]) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5]) == 2\n assert candidate(arr = [10, 10, 20, 20, 30, 30, 30, 40, 40, 40, 40]) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 4]) == 2\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4]) == 2\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 3, 3, 4, 5]) == 2\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 3\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 2\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 2\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]) == 3\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 25\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == 2\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 2\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 8\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 1\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 3\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8, 9]) == 3\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200]) == 1\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 3\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 3\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 2\n assert candidate(arr = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 1\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 4\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 2\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7]) == 3\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 3\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 4\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5]) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3]) == 1\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 1\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300]) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 5\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 4\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == 3\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 3\n assert candidate(arr = [5, 5, 5, 5, 5, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 2\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 1\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 5\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 1\n assert candidate(arr = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 70, 70, 70, 70, 70, 70, 70]) == 3\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 2\n assert candidate(arr = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]) == 3\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 2\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7]) == 2\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 2\n assert candidate(arr = [99, 99, 98, 98, 97, 97, 96, 96, 95, 95, 94, 94, 93, 93, 92, 92, 91, 91, 90, 90, 89, 89, 88, 88, 87, 87, 86, 86, 85, 85, 84, 84, 83, 83, 82, 82, 81, 81, 80, 80, 79, 79, 78, 78, 77, 77, 76, 76, 75, 75, 74, 74, 73, 73, 72, 72, 71, 71, 70, 70, 69, 69, 68, 68, 67, 67, 66, 66, 65, 65, 64, 64, 63, 63, 62, 62, 61, 61, 60, 60, 59, 59, 58, 58, 57, 57, 56, 56, 55, 55, 54, 54, 53, 53, 52, 52, 51, 51, 50, 50]) == 25\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5]) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 2\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == 3\n assert candidate(arr = [1, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 2\n assert candidate(arr = [7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10]) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]) == 3\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(arr = [100, 100, 100, 100, 100, 200, 200, 200, 200, 200, 200, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400]) == 2\n assert candidate(arr = [10, 20, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40, 40, 50, 50, 50, 50, 50, 50, 50]) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == 3\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8]) == 3\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 2, 2, 2, 3, 3, 4]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11]) == 2\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 2\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 2\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 3\n assert candidate(arr = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7]) == 3\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4]) == 1\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().minSetSize", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minSetSize(vector& arr) {", "container": "Solution", "callable": "minSetSize", "parameters": [{"name": "arr", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1339, "task_id": "maximum-product-of-splitted-binary-tree", "difficulty": "Medium", "problem_description": "Given the root of a binary tree, split the binary tree into two subtrees by removing one edge such that the product of the sums of the subtrees is maximized.\nReturn the maximum product of the sums of the two subtrees. Since the answer may be too large, return it modulo 109 + 7.\nNote that you need to maximize the answer before taking the mod and not after taking it.\n \nExample 1:\n\n\nInput: root = [1,2,3,4,5,6]\nOutput: 110\nExplanation: Remove the red edge and get 2 binary trees with sum 11 and 10. Their product is 110 (11*10)\n\nExample 2:\n\n\nInput: root = [1,null,2,3,4,null,null,5,6]\nOutput: 90\nExplanation: Remove the red edge and get 2 binary trees with sum 15 and 6.Their product is 90 (15*6)\n\n \nConstraints:\n\nThe number of nodes in the tree is in the range [2, 5 * 104].\n1 <= Node.val <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([1, 2, 3])) == 9\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18])) == 825\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6])) == 110\n assert candidate(root = tree_node([1, None, 2, 3, 4, None, None, 5, 6])) == 90\n assert candidate(root = tree_node([2, 3, 9, 10, 7, 4, 6, 5, 8, 11, 13, None, 14, 9, 1, None, 2, 3, None, None, None, None, None, None, 4, 6])) == 3410\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 130, 160, 180])) == 486675\n assert candidate(root = tree_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100])) == 270725\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20, None, 21, None, 22, None, 23, None, 24, None, 25, None, 26, None, 27, None, 28, None, 29, None, 30, None, 31])) == 61503\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])) == 756\n assert candidate(root = tree_node([1, 2, 2, 3, None, None, 3, None, None, 4, None, None, 4])) == 88\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])) == 24600\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50])) == 374900\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100])) == 5933400\n assert candidate(root = tree_node([10, 2, 20, 1, None, 15, 30, 8, None, None, None, 9, None, 7, None, 6, None, 5, None, 4, None, 3, None, 2, None, 1, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None])) == 3672\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])) == 756\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40])) == 166875\n assert candidate(root = tree_node([9999, 4999, 4999, 2499, 2500, 2499, 2500, 1249, 1250, 1250, 1250, 1249, 1250, 1249, 1250, 624, 625, 625, 625, 625, 625, 625, 625, 625, 625, 625, 625, 625, 625, 625, 625])) == 599780020\n assert candidate(root = tree_node([5000, 2500, 7500, 1250, 3750, 6250, 8750, 625, 1875, 2500, 5000, 4375, 7500, 8125, 9375])) == 263281243\n assert candidate(root = tree_node([5, 2, 9, 1, 3, 8, 12, None, None, None, None, 6, 10, 11, 13])) == 1584\n assert candidate(root = tree_node([7, 3, 15, None, None, 9, 20])) == 680\n assert candidate(root = tree_node([2, 3, 9, 10, 7, 4, 6, 5, 8, 11, 13, None, 14, 9, 1, None, 2, 3, None, None, None, None, None, None, 4, 6, 7, 8, 11, 13, None, 14, 9, 1, None, 2, 3, None, None, None, None, None, None, 4, 6, 7, 8, 11, 13, None, 14, 9, 1, None, 2, 3, None, None, None, None, None, None, 4, 6])) == 18522\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, 2, 4, None, None, None, None, None, 25, 20])) == 2970\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, 6, None, None, 7, 8, None, None, 9, 10])) == 756\n assert candidate(root = tree_node([500, 250, 750, 125, 375, 500, 1000, 62, 188, 250, 500, 375, 625, 875, 1125, 31, 94, 125, 250, 375, 438, 625, 750, 875, 1000, 1125, 1250, 1375, 1500, 1625, 1750, 1875])) == 123145250\n assert candidate(root = tree_node([10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == 899800054\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, None, None, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == 11025\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, None, None, None, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50])) == 376650\n assert candidate(root = tree_node([7, 3, 6, 2, 4, None, 10, 1, 5, None, None, 8, 9, 11, 12])) == 1520\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20])) == 11024\n assert candidate(root = tree_node([999, 499, 1499, 249, 749, 999, 1999, 124, 374, 499, 749, 999, 1249, 1499, 1749, 62, 187, 249, 374, 499, 562, 749, 999, 1249, 1499, 1749, 1999, 2249, 2499, 2749, 2999, 3249, 3499, 3749, 3999, 4249, 4499, 4749, 4999, 5249, 5499, 5749, 5999])) == 930774628\n assert candidate(root = tree_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80])) == 115500\n assert candidate(root = tree_node([5, 10, None, 15, 20, None, None, 25, 30, 35, 40, None, None, None, None, 45, 50, None, None, None, None, None, None, 55, 60])) == 18900\n assert candidate(root = tree_node([25000, 12500, 37500, 6250, 18750, 25000, 50000, 3125, 9375, 15625, 21875, 12500, 18750, 31250, 37500, 1562, 4688, 7812, 9375, 12500, 15625, 18750, 21875, 25000, 31250, 37500, 43750, 46875, 50000, 53125, 56250, 59375, 62500])) == 650111233\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 130, 160, 190])) == 496125\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 1, 7, 13, 17, 23, 27, 33, 37, 0, 2, 6, 8, 12, 14, 16, 18, 22, 24, 26, 28, 32, 34, 36, 38])) == 90405\n assert candidate(root = tree_node([500, 400, 600, 300, 450, 550, 650, 200, 350, 425, 475, 525, 575, 625, 675, 100, 250, 325, 375, 412, 437, 462, 487, 512, 537, 562, 587, 612, 637, 662, 687, 90, 160, 225, 275, 312, 337, 362, 387, 402, 447, 492, 532, 557, 592, 627, 642, 677, 702, 65, 125, 187, 237, 262, 287, 302, 347, 392, 417, 432, 477, 502, 527, 542, 577, 602, 632, 657, 692, 717, 742, 767, 792])) == 287180438\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 190, None, 40, 55, 65, 70, 85, 90, 115, 120, 130, 145, 155, 165, 185, 195, None, 35, 45, 56, 64, 72, 78, 82, 88, 95, 105, 117, 123, 127, 133, 138, 143, 148, 153, 158, 163, 168, 173, 178, 183, 188, 193, None, 9, 11, 13, 17, 21, 23, 27, 29, 33, 37, 41, 43, 47, 49, 51, 53, 57, 59, 61, 63, 67, 69, 71, 73, 77, 79, 81, 83, 87, 89, 91, 93, 97, 99])) == 16555528\n assert candidate(root = tree_node([5000, 2500, 7500, 1250, 3750, 6250, 8750, 625, 1875, 2500, 4375, 5625, 7187, 9375, 10625, 3125, 937, 1250, 1687, 2187, 3125, 3750, 4687, 5312, 5937, 6562, 7187, 7812, 8437, 9062, 9687, 10312, 10937, 11562, 12187, 12812, 13437, 14062, 14687, 15312])) == 398822622\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, 1, 2, 6, 8, 16, 20, None, None, None, None, 9, 12, None, None, None, None, 17, 21])) == 7176\n assert candidate(root = tree_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) == 225\n assert candidate(root = tree_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400])) == 16687500\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8])) == 315\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15])) == 3575\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180])) == 491825\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])) == 53354\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20, None])) == 11025\n assert candidate(root = tree_node([5, 3, 8, 2, 4, 7, 9, 1, 6, None, None, 10, 11, None, None, 12, 13, None, None, 14, 15, None, None, 16])) == 4588\n assert candidate(root = tree_node([1000, 500, 1500, 250, 750, 1250, 1750, 100, 300, 600, 800, 1100, 1400, 1600, 1800, 50, 150, 250, 350, 450, 650, 750, 850, 950, 1050, 1150, 1250, 1350, 1450, 1550, 1650, 1750, 1850, 1950])) == 277680000\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20, None, 21, None, 22, None, 23, None, 24, None, 25, None, 26, None, 27, None, 28, None, 29, None, 30, None, 31, None, 32, None, 33, None, 34, None, 35, None, 36, None, 37, None, 38, None, 39, None, 40, None, 41, None, 42, None, 43, None, 44, None, 45, None, 46, None, 47, None, 48, None, 49, None, 50])) == 406350\n assert candidate(root = tree_node([10000, 5000, 15000, 2500, 7500, 12500, 17500, 1000, 3000, 6000, 8000, 11000, 13000, 16000, 18000, 500, 1500, 2500, 3500, 4500, 6500, 7500, 8500, 9500, 10500, 11500, 12500, 13500, 14500, 15500])) == 482499888\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, None, None, None, None, 9, 10, 11, 12, 13, None, None, 14, 15, 16, 17])) == 5670\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, 6, 7, None, None, 8, 9])) == 504\n assert candidate(root = tree_node([1, None, 2, None, None, None, 3, None, None, None, 4, None, None, None, 5, None, None, None, 6, None, None, None, 7, None, None, None, 8, None, None, None, 9])) == 2\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == 10829\n assert candidate(root = tree_node([1000, 900, 100, 800, 950, 50, 150, 700, 850, 925, 975, 25, 75, 125, 175, 650, 750, 825, 875, 912, 937, 962, 987, 10, 30, 60, 80, 110, 140, 160, 180, 5, 15, 20, 40, 85, 90, 113, 130, 153, 172, 183, 190])) == 68450028\n assert candidate(root = tree_node([50, 25, 75, 12, 37, 50, 100, 6, 18, 25, 37, 43, 62, 75, 87, 3, 9, 12, 25, 37, 43, 56, 62, 75, 87, 100, 112, 125, 137, 150, 162, 175, 187])) == 1189628\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == 3500\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180, 5, 15, 20, 40, 85, 95, 115, 135, 155, 170, 185, 3, 7, 12, 18, 35, 45, 77, 90, 113, 130, 153, 172, 183, 190])) == 3437925\n assert candidate(root = tree_node([9999, None, 9998, None, 9997, None, 9996, None, 9995, None, 9994, None, 9993, None, 9992, None, 9991, None, 9990, None, 9989, None, 9988, None, 9987, None, 9986, None, 9985, None, 9984, None, 9983, None, 9982, None, 9981, None, 9980, None, 9979, None, 9978, None, 9977, None, 9976, None, 9975, None, 9974, None, 9973, None, 9972, None, 9971, None, 9970, None, 9969, None, 9968, None, 9967, None, 9966, None, 9965, None, 9964, None, 9963, None, 9962, None, 9961, None, 9960])) == 836127827\n assert candidate(root = tree_node([4, 2, 6, 1, 3, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])) == 53244\n assert candidate(root = tree_node([1000, 500, 1500, 250, 750, 1250, 1750, 125, 375, 625, 875, 1125, 1375, 1625, 1875, 62, 188, 288, 462, 512, 688, 748, 1062, 1112, 1288, 1348, 1662, 1712, 1888, 1938, 31, 83, 133, 183, 233, 283, 333, 383, 433, 483, 533, 583, 633, 683, 733, 783, 833, 883, 933, 983, 141, 191, 241, 291, 341, 391, 441, 491, 541, 591, 641, 691, 741, 791, 841, 891, 941, 991, 26, 76, 126, 176, 226, 276, 326, 376, 426, 476, 526, 576, 626, 676, 726, 776, 826, 876, 926, 976, 3, 53, 103, 153, 203, 253, 303, 353, 403, 453, 503, 553, 603, 653, 703, 753, 803, 853, 903, 953, 18, 68, 118, 168, 218, 268, 318, 368, 418, 468, 518, 568, 618, 668, 718, 768, 818, 868, 918, 968])) == 533225977\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, None, None, 6, None, 7, None, None, None, None, 8, None, 9, None, None, None, None, 10, None, 11, None, None, None, None, 12, None, 13, None, None, None, None, 14, None, 15])) == 192\n assert candidate(root = tree_node([10000, 5000, 5000, 2500, 2500, 2500, 2500, 1250, 1250, 1250, 1250, 1250, 1250, 1250, 1250])) == 375000000\n"}, "metadata": {"canonical_parameter_names": ["root"], "leetcode_dataset_entry_point": "Solution().maxProduct", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxProduct(TreeNode* root) {", "container": "Solution", "callable": "maxProduct", "parameters": [{"name": "root", "type": "TreeNode*"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1340, "task_id": "jump-game-v", "difficulty": "Hard", "problem_description": "Given an array of integers arr and an integer d. In one step you can jump from index i to index:\n\ni + x where: i + x < arr.length and 0 < x <= d.\ni - x where: i - x >= 0 and 0 < x <= d.\n\nIn addition, you can only jump from index i to index j if arr[i] > arr[j] and arr[i] > arr[k] for all indices k between i and j (More formally min(i, j) < k < max(i, j)).\nYou can choose any index of the array and start jumping. Return the maximum number of indices you can visit.\nNotice that you can not jump outside of the array at any time.\n \nExample 1:\n\n\nInput: arr = [6,4,14,6,8,13,9,7,10,6,12], d = 2\nOutput: 4\nExplanation: You can start at index 10. You can jump 10 --> 8 --> 6 --> 7 as shown.\nNote that if you start at index 6 you can only jump to index 7. You cannot jump to index 5 because 13 > 9. You cannot jump to index 4 because index 5 is between index 4 and 6 and 13 > 9.\nSimilarly You cannot jump from index 3 to index 2 or index 1.\n\nExample 2:\n\nInput: arr = [3,3,3,3,3], d = 3\nOutput: 1\nExplanation: You can start at any index. You always cannot jump to any index.\n\nExample 3:\n\nInput: arr = [7,6,5,4,3,2,1], d = 1\nOutput: 7\nExplanation: Start at index 0. You can visit all the indicies. \n\n \nConstraints:\n\n1 <= arr.length <= 1000\n1 <= arr[i] <= 105\n1 <= d <= arr.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 10\n assert candidate(arr = [1, 2, 3, 4, 5],d = 4) == 5\n assert candidate(arr = [1, 2, 3, 4, 5],d = 2) == 5\n assert candidate(arr = [3, 3, 3, 3, 3],d = 3) == 1\n assert candidate(arr = [5, 4, 3, 2, 1],d = 4) == 5\n assert candidate(arr = [7, 6, 5, 4, 3, 2, 1],d = 1) == 7\n assert candidate(arr = [6, 4, 14, 6, 8, 13, 9, 7, 10, 6, 12],d = 2) == 4\n assert candidate(arr = [5, 4, 3, 2, 1],d = 1) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3],d = 2) == 2\n assert candidate(arr = [1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5],d = 2) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],d = 5) == 1\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],d = 5) == 10\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 15\n assert candidate(arr = [3, 5, 2, 1, 4, 7, 6, 8, 9, 10],d = 3) == 7\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],d = 4) == 10\n assert candidate(arr = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10, 1],d = 10) == 10\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 5) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1],d = 3) == 5\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],d = 2) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 10) == 20\n assert candidate(arr = [1, 5, 3, 8, 2, 7, 4, 9, 6, 10],d = 5) == 5\n assert candidate(arr = [10, 1, 10, 1, 10, 1, 10],d = 2) == 2\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],d = 6) == 16\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 2) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 5) == 20\n assert candidate(arr = [8, 7, 6, 5, 4, 3, 2, 1, 9, 10, 11, 12, 13, 14, 15, 16, 17],d = 4) == 13\n assert candidate(arr = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 7) == 17\n assert candidate(arr = [6, 1, 5, 3, 2, 7, 4],d = 3) == 4\n assert candidate(arr = [6, 8, 9, 2, 1, 5, 3, 4, 7],d = 2) == 3\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],d = 2) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 2) == 10\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1],d = 1) == 2\n assert candidate(arr = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5],d = 2) == 6\n assert candidate(arr = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],d = 1) == 9\n assert candidate(arr = [6, 12, 8, 14, 3, 10, 11, 9, 5, 7, 2, 4, 13, 1, 6],d = 4) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],d = 5) == 15\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 20\n assert candidate(arr = [10, 20, 30, 40, 50, 45, 44, 43, 42, 41],d = 3) == 6\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 6) == 15\n assert candidate(arr = [4, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],d = 3) == 4\n assert candidate(arr = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5],d = 3) == 5\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 10) == 11\n assert candidate(arr = [2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9],d = 3) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 2) == 20\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10],d = 2) == 6\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 1) == 1\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],d = 10) == 10\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1],d = 3) == 2\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 50, 40, 30, 20, 10],d = 5) == 6\n assert candidate(arr = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6],d = 2) == 6\n assert candidate(arr = [1, 5, 2, 6, 3, 7, 4, 8],d = 2) == 5\n assert candidate(arr = [3, 8, 1, 6, 2, 9, 5, 4, 7],d = 3) == 4\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 4) == 10\n assert candidate(arr = [2, 6, 4, 8, 4, 6, 4, 8, 4, 6, 4, 8, 4, 6, 4, 8, 4, 6, 4, 8],d = 2) == 3\n assert candidate(arr = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1],d = 2) == 3\n assert candidate(arr = [8, 3, 5, 2, 4, 6, 7, 1, 9],d = 3) == 6\n assert candidate(arr = [3, 1, 5, 4, 2, 6, 7, 8, 9, 1],d = 5) == 7\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],d = 5) == 10\n assert candidate(arr = [1, 3, 5, 2, 4, 6, 8, 7, 9],d = 3) == 6\n assert candidate(arr = [10, 20, 15, 25, 30, 5, 40, 35, 50, 45],d = 5) == 6\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],d = 1) == 1\n assert candidate(arr = [10, 20, 10, 30, 10, 40, 10, 50, 10, 60, 10, 70, 10, 80, 10, 90, 10, 100, 10],d = 1) == 2\n assert candidate(arr = [1, 6, 5, 4, 3, 2, 7],d = 3) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 15\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],d = 4) == 15\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 2) == 15\n assert candidate(arr = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15, 14, 16, 15, 17, 16, 18, 17, 19, 18, 20],d = 2) == 19\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 10\n assert candidate(arr = [5, 1, 4, 1, 3, 1, 2, 1],d = 2) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 5) == 20\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 5) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 9) == 10\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 3) == 20\n assert candidate(arr = [5, 6, 1, 2, 9, 3, 4, 8, 7, 10],d = 3) == 4\n assert candidate(arr = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],d = 4) == 2\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],d = 5) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],d = 4) == 15\n assert candidate(arr = [1, 6, 5, 4, 6, 1, 2, 3, 4, 6, 5, 4, 6, 1, 2, 3, 4, 6, 5, 4],d = 2) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4],d = 4) == 5\n assert candidate(arr = [1, 6, 3, 5, 2, 4, 7, 8, 10, 9],d = 4) == 6\n assert candidate(arr = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55],d = 5) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 5) == 10\n assert candidate(arr = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1],d = 5) == 10\n assert candidate(arr = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12],d = 3) == 11\n assert candidate(arr = [3, 1, 2, 1, 3, 1, 2, 1, 3],d = 1) == 2\n assert candidate(arr = [1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10],d = 5) == 9\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 4) == 10\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],d = 1) == 1\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9],d = 4) == 9\n assert candidate(arr = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100],d = 5) == 2\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10],d = 3) == 6\n assert candidate(arr = [10, 2, 8, 4, 7, 9, 3, 1, 5, 6],d = 4) == 5\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2],d = 2) == 3\n assert candidate(arr = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6],d = 5) == 6\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],d = 3) == 10\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],d = 4) == 10\n assert candidate(arr = [7, 2, 8, 9, 1, 3, 5, 6, 4],d = 3) == 4\n assert candidate(arr = [5, 1, 3, 4, 2, 6, 7, 8, 9, 10],d = 2) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],d = 3) == 6\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],d = 2) == 9\n assert candidate(arr = [5, 1, 3, 2, 4, 6, 7, 8, 10, 9],d = 2) == 7\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1],d = 2) == 2\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],d = 4) == 10\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 9, 7, 5, 3, 1],d = 2) == 6\n assert candidate(arr = [1, 3, 2, 4, 5, 6, 7, 8, 9],d = 3) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],d = 4) == 5\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14],d = 3) == 8\n assert candidate(arr = [8, 7, 6, 7, 6, 5, 6, 7, 8, 9, 8, 7, 6, 7, 8],d = 3) == 5\n assert candidate(arr = [3, 5, 1, 2, 4, 6, 8, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 4) == 18\n assert candidate(arr = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 8, 12, 9, 13, 10],d = 4) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 10\n assert candidate(arr = [1, 5, 5, 5, 1, 5, 5, 5, 1],d = 2) == 2\n assert candidate(arr = [2, 1, 5, 3, 4, 8, 6, 7, 10, 9],d = 3) == 5\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 10, 1, 9, 2, 8, 3, 7, 4, 6, 5],d = 5) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 3) == 10\n assert candidate(arr = [8, 3, 5, 2, 4, 7, 6, 1, 10, 9],d = 5) == 5\n assert candidate(arr = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10],d = 3) == 10\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5],d = 2) == 2\n assert candidate(arr = [50, 40, 30, 20, 10, 1, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1],d = 5) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],d = 5) == 20\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],d = 5) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 3) == 10\n"}, "metadata": {"canonical_parameter_names": ["arr", "d"], "leetcode_dataset_entry_point": "Solution().maxJumps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxJumps(vector& arr, int d) {", "container": "Solution", "callable": "maxJumps", "parameters": [{"name": "arr", "type": "vector&"}, {"name": "d", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1342, "task_id": "number-of-steps-to-reduce-a-number-to-zero", "difficulty": "Easy", "problem_description": "Given an integer num, return the number of steps to reduce it to zero.\nIn one step, if the current number is even, you have to divide it by 2, otherwise, you have to subtract 1 from it.\n \nExample 1:\n\nInput: num = 14\nOutput: 6\nExplanation: \nStep 1) 14 is even; divide by 2 and obtain 7. \nStep 2) 7 is odd; subtract 1 and obtain 6.\nStep 3) 6 is even; divide by 2 and obtain 3. \nStep 4) 3 is odd; subtract 1 and obtain 2. \nStep 5) 2 is even; divide by 2 and obtain 1. \nStep 6) 1 is odd; subtract 1 and obtain 0.\n\nExample 2:\n\nInput: num = 8\nOutput: 4\nExplanation: \nStep 1) 8 is even; divide by 2 and obtain 4. \nStep 2) 4 is even; divide by 2 and obtain 2. \nStep 3) 2 is even; divide by 2 and obtain 1. \nStep 4) 1 is odd; subtract 1 and obtain 0.\n\nExample 3:\n\nInput: num = 123\nOutput: 12\n\n \nConstraints:\n\n0 <= num <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = 14) == 6\n assert candidate(num = 1000000) == 26\n assert candidate(num = 8) == 4\n assert candidate(num = 65535) == 31\n assert candidate(num = 0) == 0\n assert candidate(num = 2) == 2\n assert candidate(num = 1) == 1\n assert candidate(num = 123) == 12\n assert candidate(num = 8191) == 25\n assert candidate(num = 750000) == 29\n assert candidate(num = 500000) == 25\n assert candidate(num = 1234567) == 31\n assert candidate(num = 131072) == 18\n assert candidate(num = 1023) == 19\n assert candidate(num = 777777) == 31\n assert candidate(num = 127) == 13\n assert candidate(num = 888888) == 27\n assert candidate(num = 16384) == 15\n assert candidate(num = 31) == 9\n assert candidate(num = 100001) == 23\n assert candidate(num = 1048575) == 39\n assert candidate(num = 8192) == 14\n assert candidate(num = 123456789) == 42\n assert candidate(num = 15) == 7\n assert candidate(num = 135792468) == 36\n assert candidate(num = 32768) == 16\n assert candidate(num = 63) == 11\n assert candidate(num = 3125) == 17\n assert candidate(num = 5318008) == 32\n assert candidate(num = 1000002) == 27\n assert candidate(num = 2097151) == 41\n assert candidate(num = 131071) == 33\n assert candidate(num = 16383) == 27\n assert candidate(num = 665772) == 27\n assert candidate(num = 987654321) == 46\n assert candidate(num = 4096) == 13\n assert candidate(num = 511) == 17\n assert candidate(num = 524288) == 20\n assert candidate(num = 7) == 5\n assert candidate(num = 543210) == 28\n assert candidate(num = 1048576) == 21\n assert candidate(num = 567890) == 27\n assert candidate(num = 255) == 15\n assert candidate(num = 8675309) == 37\n assert candidate(num = 1024) == 11\n assert candidate(num = 246813579) == 42\n assert candidate(num = 100000) == 22\n assert candidate(num = 54321) == 22\n assert candidate(num = 262143) == 35\n assert candidate(num = 123456) == 22\n assert candidate(num = 999999) == 31\n assert candidate(num = 32767) == 29\n assert candidate(num = 65536) == 17\n assert candidate(num = 2048) == 12\n assert candidate(num = 1000001) == 27\n assert candidate(num = 536870911) == 57\n assert candidate(num = 2147483647) == 61\n assert candidate(num = 3) == 3\n assert candidate(num = 987654) == 27\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().numberOfSteps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numberOfSteps(int num) {", "container": "Solution", "callable": "numberOfSteps", "parameters": [{"name": "num", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1343, "task_id": "number-of-sub-arrays-of-size-k-and-average-greater-than-or-equal-to-threshold", "difficulty": "Medium", "problem_description": "Given an array of integers arr and two integers k and threshold, return the number of sub-arrays of size k and average greater than or equal to threshold.\n \nExample 1:\n\nInput: arr = [2,2,2,2,5,5,5,8], k = 3, threshold = 4\nOutput: 3\nExplanation: Sub-arrays [2,5,5],[5,5,5] and [5,5,8] have averages 4, 5 and 6 respectively. All other sub-arrays of size 3 have averages less than 4 (the threshold).\n\nExample 2:\n\nInput: arr = [11,13,17,23,29,31,7,5,2,3], k = 3, threshold = 5\nOutput: 6\nExplanation: The first 6 sub-arrays of size 3 have averages greater than 5. Note that averages are not integers.\n\n \nConstraints:\n\n1 <= arr.length <= 105\n1 <= arr[i] <= 104\n1 <= k <= arr.length\n0 <= threshold <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 2, 2, 2, 5, 5, 5, 8],k = 3,threshold = 4) == 3\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5],k = 3,threshold = 5) == 5\n assert candidate(arr = [10000, 10000, 10000],k = 3,threshold = 10000) == 1\n assert candidate(arr = [1, 2, 3, 4, 5],k = 2,threshold = 3) == 2\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000],k = 1,threshold = 10000) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1],k = 2,threshold = 1) == 7\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4,threshold = 5) == 4\n assert candidate(arr = [10, 20, 30, 40, 50],k = 1,threshold = 10) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5,threshold = 1) == 6\n assert candidate(arr = [5, 5, 5, 5, 5],k = 5,threshold = 5) == 1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5],k = 4,threshold = 6) == 0\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5],k = 5,threshold = 5) == 4\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4,threshold = 5) == 3\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000],k = 5,threshold = 10000) == 1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3],k = 4,threshold = 3) == 4\n assert candidate(arr = [1, 1, 1, 1, 1],k = 2,threshold = 1) == 4\n assert candidate(arr = [1, 2, 3, 4, 5],k = 2,threshold = 2) == 3\n assert candidate(arr = [11, 13, 17, 23, 29, 31, 7, 5, 2, 3],k = 3,threshold = 5) == 6\n assert candidate(arr = [10, 20, 30, 40, 50],k = 4,threshold = 25) == 2\n assert candidate(arr = [9, 7, 3, 5, 6, 2, 0, 8, 1, 4],k = 4,threshold = 4) == 4\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 11,threshold = 5.5) == 0\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 6,threshold = 15) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 10,threshold = 13) == 8\n assert candidate(arr = [1, 3, 2, 6, 5, 4, 8, 7, 9, 10],k = 3,threshold = 6) == 3\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 7,threshold = 7) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10,threshold = 10.5) == 6\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 2,threshold = 55) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,threshold = 5) == 4\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],k = 3,threshold = 3) == 6\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6,threshold = 10) == 8\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 6,threshold = 10) == 8\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 5,threshold = 5) == 9\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 20,threshold = 9) == 1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10,threshold = 5) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 7,threshold = 10) == 8\n assert candidate(arr = [2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6],k = 6,threshold = 3) == 8\n assert candidate(arr = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25],k = 10,threshold = 25) == 6\n assert candidate(arr = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 20,threshold = 5000) == 1\n assert candidate(arr = [3, 6, 1, 3, 9, 6, 1, 7, 8, 2],k = 3,threshold = 5) == 4\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 5,threshold = 5) == 9\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 10,threshold = 3) == 11\n assert candidate(arr = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 15,threshold = 50) == 6\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 19,threshold = 1) == 2\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 11,threshold = 800) == 3\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5,threshold = 5) == 4\n assert candidate(arr = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 7,threshold = 5000) == 6\n assert candidate(arr = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 10,threshold = 5000) == 6\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 3,threshold = 10) == 15\n assert candidate(arr = [5000, 4000, 3000, 2000, 1000, 0, 0, 0, 0, 0, 0, 0],k = 5,threshold = 2000) == 2\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,threshold = 1) == 11\n assert candidate(arr = [4999, 5000, 4999, 5000, 4999, 5000, 4999, 5000, 4999, 5000],k = 3,threshold = 5000) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,threshold = 5.5) == 3\n assert candidate(arr = [10000, 1, 10000, 1, 10000, 1, 10000, 1, 10000, 1],k = 5,threshold = 5000) == 3\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 5,threshold = 1.5) == 8\n assert candidate(arr = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],k = 3,threshold = 10) == 14\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2,threshold = 5) == 5\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 3,threshold = 8) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,threshold = 5) == 11\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10,threshold = 55) == 1\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 7,threshold = 15) == 5\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 10,threshold = 10000) == 1\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 5,threshold = 12) == 7\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10,threshold = 10) == 6\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85],k = 7,threshold = 92) == 5\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 4,threshold = 3.5) == 5\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 5,threshold = 20) == 8\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 5,threshold = 15) == 11\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 3,threshold = 55) == 4\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 8,threshold = 9000) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 6,threshold = 10) == 8\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5,threshold = 550) == 3\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 7,threshold = 1) == 9\n assert candidate(arr = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6,threshold = 4) == 9\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1],k = 3,threshold = 2) == 18\n assert candidate(arr = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 5,threshold = 5000) == 6\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10,threshold = 10.5) == 6\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 5,threshold = 4) == 11\n assert candidate(arr = [10000, 1, 10000, 1, 10000, 1, 10000, 1, 10000, 1],k = 2,threshold = 5000) == 9\n assert candidate(arr = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],k = 7,threshold = 15) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,threshold = 1) == 73\n assert candidate(arr = [2, 3, 1, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 6,threshold = 5) == 9\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,threshold = 1) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5,threshold = 10) == 9\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 7,threshold = 15) == 5\n assert candidate(arr = [40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2],k = 10,threshold = 15) == 9\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 5,threshold = 15) == 6\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 3,threshold = 4) == 5\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1],k = 4,threshold = 2) == 18\n assert candidate(arr = [1, 1, 1, 1, 10, 1, 1, 1, 1, 10, 1, 1, 1, 1, 10],k = 3,threshold = 3) == 7\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 6,threshold = 55) == 3\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 4,threshold = 5) == 7\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4,threshold = 5) == 4\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 4,threshold = 55) == 4\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5,threshold = 450) == 4\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 3,threshold = 15) == 12\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4,threshold = 5) == 4\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 6,threshold = 10) == 3\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 6,threshold = 500) == 3\n assert candidate(arr = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 9,threshold = 9999) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10,threshold = 8) == 3\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 4,threshold = 15) == 4\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 8,threshold = 100) == 9\n assert candidate(arr = [5000, 4000, 3000, 2000, 1000, 0, 1000, 2000, 3000, 4000, 5000],k = 4,threshold = 3000) == 2\n assert candidate(arr = [3, 5, 1, 8, 7, 9, 4, 6, 2, 10, 11, 12],k = 5,threshold = 6) == 5\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 2,threshold = 500) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,threshold = 5) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10,threshold = 0.5) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5,threshold = 6) == 3\n"}, "metadata": {"canonical_parameter_names": ["arr", "k", "threshold"], "leetcode_dataset_entry_point": "Solution().numOfSubarrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numOfSubarrays(vector& arr, int k, int threshold) {", "container": "Solution", "callable": "numOfSubarrays", "parameters": [{"name": "arr", "type": "vector&"}, {"name": "k", "type": "int"}, {"name": "threshold", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1344, "task_id": "angle-between-hands-of-a-clock", "difficulty": "Medium", "problem_description": "Given two numbers, hour and minutes, return the smaller angle (in degrees) formed between the hour and the minute hand.\nAnswers within 10-5 of the actual value will be accepted as correct.\n \nExample 1:\n\n\nInput: hour = 12, minutes = 30\nOutput: 165\n\nExample 2:\n\n\nInput: hour = 3, minutes = 30\nOutput: 75\n\nExample 3:\n\n\nInput: hour = 3, minutes = 15\nOutput: 7.5\n\n \nConstraints:\n\n1 <= hour <= 12\n0 <= minutes <= 59\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(hour = 3,minutes = 30) == 75.0\n assert candidate(hour = 11,minutes = 59) == 5.5\n assert candidate(hour = 3,minutes = 15) == 7.5\n assert candidate(hour = 7,minutes = 30) == 45.0\n assert candidate(hour = 11,minutes = 0) == 30.0\n assert candidate(hour = 2,minutes = 10) == 5.0\n assert candidate(hour = 12,minutes = 30) == 165.0\n assert candidate(hour = 1,minutes = 0) == 30.0\n assert candidate(hour = 1,minutes = 55) == 87.5\n assert candidate(hour = 9,minutes = 45) == 22.5\n assert candidate(hour = 1,minutes = 5) == 2.5\n assert candidate(hour = 12,minutes = 0) == 0.0\n assert candidate(hour = 6,minutes = 0) == 180.0\n assert candidate(hour = 7,minutes = 10) == 155.0\n assert candidate(hour = 7,minutes = 35) == 17.5\n assert candidate(hour = 2,minutes = 5) == 32.5\n assert candidate(hour = 6,minutes = 15) == 97.5\n assert candidate(hour = 5,minutes = 0) == 150.0\n assert candidate(hour = 2,minutes = 47) == 161.5\n assert candidate(hour = 4,minutes = 0) == 120.0\n assert candidate(hour = 10,minutes = 25) == 162.5\n assert candidate(hour = 8,minutes = 23) == 113.5\n assert candidate(hour = 11,minutes = 15) == 112.5\n assert candidate(hour = 4,minutes = 50) == 155.0\n assert candidate(hour = 8,minutes = 18) == 141.0\n assert candidate(hour = 8,minutes = 20) == 130.0\n assert candidate(hour = 10,minutes = 31) == 129.5\n assert candidate(hour = 5,minutes = 10) == 95.0\n assert candidate(hour = 12,minutes = 15) == 82.5\n assert candidate(hour = 5,minutes = 14) == 73.0\n assert candidate(hour = 5,minutes = 45) == 97.5\n assert candidate(hour = 12,minutes = 59) == 35.5\n assert candidate(hour = 12,minutes = 1) == 5.5\n assert candidate(hour = 10,minutes = 10) == 115.0\n assert candidate(hour = 7,minutes = 22) == 89.0\n assert candidate(hour = 12,minutes = 47) == 101.5\n assert candidate(hour = 2,minutes = 40) == 160.0\n assert candidate(hour = 5,minutes = 55) == 152.5\n assert candidate(hour = 7,minutes = 0) == 150.0\n assert candidate(hour = 4,minutes = 48) == 144.0\n assert candidate(hour = 6,minutes = 37) == 23.5\n assert candidate(hour = 2,minutes = 24) == 72.0\n assert candidate(hour = 8,minutes = 40) == 20.0\n assert candidate(hour = 5,minutes = 15) == 67.5\n assert candidate(hour = 4,minutes = 10) == 65.0\n assert candidate(hour = 8,minutes = 50) == 35.0\n assert candidate(hour = 4,minutes = 40) == 100.0\n assert candidate(hour = 4,minutes = 25) == 17.5\n assert candidate(hour = 1,minutes = 37) == 173.5\n assert candidate(hour = 3,minutes = 47) == 168.5\n assert candidate(hour = 10,minutes = 48) == 36.0\n assert candidate(hour = 8,minutes = 32) == 64.0\n assert candidate(hour = 1,minutes = 10) == 25.0\n assert candidate(hour = 7,minutes = 5) == 177.5\n assert candidate(hour = 6,minutes = 30) == 15.0\n assert candidate(hour = 7,minutes = 59) == 114.5\n assert candidate(hour = 8,minutes = 28) == 86.0\n assert candidate(hour = 9,minutes = 27) == 121.5\n assert candidate(hour = 4,minutes = 55) == 177.5\n assert candidate(hour = 10,minutes = 35) == 107.5\n assert candidate(hour = 7,minutes = 32) == 34.0\n assert candidate(hour = 6,minutes = 33) == 1.5\n assert candidate(hour = 10,minutes = 20) == 170.0\n assert candidate(hour = 1,minutes = 50) == 115.0\n assert candidate(hour = 5,minutes = 37) == 53.5\n assert candidate(hour = 5,minutes = 47) == 108.5\n assert candidate(hour = 11,minutes = 5) == 57.5\n assert candidate(hour = 2,minutes = 30) == 105.0\n assert candidate(hour = 2,minutes = 20) == 50.0\n assert candidate(hour = 12,minutes = 45) == 112.5\n assert candidate(hour = 8,minutes = 0) == 120.0\n assert candidate(hour = 7,minutes = 47) == 48.5\n"}, "metadata": {"canonical_parameter_names": ["hour", "minutes"], "leetcode_dataset_entry_point": "Solution().angleClock", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "double angleClock(int hour, int minutes) {", "container": "Solution", "callable": "angleClock", "parameters": [{"name": "hour", "type": "int"}, {"name": "minutes", "type": "int"}], "return_type": "double", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1345, "task_id": "jump-game-iv", "difficulty": "Hard", "problem_description": "Given an array of integers arr, you are initially positioned at the first index of the array.\nIn one step you can jump from index i to index:\n\ni + 1 where: i + 1 < arr.length.\ni - 1 where: i - 1 >= 0.\nj where: arr[i] == arr[j] and i != j.\n\nReturn the minimum number of steps to reach the last index of the array.\nNotice that you can not jump outside of the array at any time.\n \nExample 1:\n\nInput: arr = [100,-23,-23,404,100,23,23,23,3,404]\nOutput: 3\nExplanation: You need three jumps from index 0 --> 4 --> 3 --> 9. Note that index 9 is the last index of the array.\n\nExample 2:\n\nInput: arr = [7]\nOutput: 0\nExplanation: Start index is the last index. You do not need to jump.\n\nExample 3:\n\nInput: arr = [7,6,9,6,9,6,9,7]\nOutput: 1\nExplanation: You can jump directly from index 0 to index 7 which is last index of the array.\n\n \nConstraints:\n\n1 <= arr.length <= 5 * 104\n-108 <= arr[i] <= 108\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [11, 22, 7, 7, 7, 7, 7, 7, 7, 22, 13]) == 3\n assert candidate(arr = [6, 1, 9, 6, 9, 1, 9, 6, 1, 9]) == 3\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 11, 11, 11, 11, 11, 11]) == 3\n assert candidate(arr = [7, 6, 9, 6, 9, 6, 9, 7]) == 1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 1]) == 2\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 1\n assert candidate(arr = [1, 2, 3, 5, 3, 2, 1, 2, 3, 4]) == 4\n assert candidate(arr = [7]) == 0\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 1\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0]) == 2\n assert candidate(arr = [100, -23, -23, 404, 100, 23, 23, 23, 3, 404]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 9\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == 4\n assert candidate(arr = [7, 7, 7, 7, 11, 11, 11, 11, 7, 7, 7, 7]) == 1\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1]) == 1\n assert candidate(arr = [7, 7, 7, 7, 12, 7, 7, 7, 7, 7]) == 1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [10, 20, 30, 20, 10, 10, 20, 30, 10]) == 1\n assert candidate(arr = [10, 20, 30, 40, 50, 40, 30, 20, 10, 5, 10, 20, 30, 40, 50, 40, 30, 20, 10]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 3, 3, 3, 3, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]) == 3\n assert candidate(arr = [6, 1, 9, 8, 4, 10, 9, 4, 10, 4, 10, 9, 10, 9, 8, 10, 9, 4, 10, 9, 10, 9, 8, 10, 9, 4, 10, 9]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [10, 22, 10, 20, 11, 22, 10, 30, 10, 40, 10, 50, 10, 60, 10, 70, 10, 80, 10, 90, 10, 100, 10, 110, 10, 120, 10, 130, 10, 140, 10, 150, 10, 160, 10, 170, 10, 180, 10, 190, 10, 200]) == 2\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]) == 3\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6]) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(arr = [1, 3, 5, 3, 1, 2, 4, 2, 6, 4, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19]) == 37\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 9, 8, 7, 6, 5, 4]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().minJumps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minJumps(vector& arr) {", "container": "Solution", "callable": "minJumps", "parameters": [{"name": "arr", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1346, "task_id": "check-if-n-and-its-double-exist", "difficulty": "Easy", "problem_description": "Given an array arr of integers, check if there exist two indices i and j such that :\n\ni != j\n0 <= i, j < arr.length\narr[i] == 2 * arr[j]\n\n \nExample 1:\n\nInput: arr = [10,2,5,3]\nOutput: true\nExplanation: For i = 0 and j = 2, arr[i] == 10 == 2 * 5 == 2 * arr[j]\n\nExample 2:\n\nInput: arr = [3,1,7,11]\nOutput: false\nExplanation: There is no i and j that satisfy the conditions.\n\n \nConstraints:\n\n2 <= arr.length <= 500\n-103 <= arr[i] <= 103\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 4, 6, 8, 10]) == True\n assert candidate(arr = [6, 10, 1, 0, -3, 3]) == True\n assert candidate(arr = [-3, -6, -1, 0, 1, 2, 3]) == True\n assert candidate(arr = [-2, -4, -6, -8, -10]) == True\n assert candidate(arr = [100, 200, 300, 400, 500]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64]) == True\n assert candidate(arr = [-10, -20, -5, -3]) == True\n assert candidate(arr = [1, 2, 3, 6, 12]) == True\n assert candidate(arr = [0, 0]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(arr = [-10, 10]) == False\n assert candidate(arr = [10, 2, 5, 3]) == True\n assert candidate(arr = [1, 2, 3, 4, 5]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6]) == True\n assert candidate(arr = [1, 2, 4, 8, 16]) == True\n assert candidate(arr = [-2, 0, 10, -19, 4, 6, -8]) == False\n assert candidate(arr = [1, 3, 5, 7, 9]) == False\n assert candidate(arr = [3, 1, 7, 11]) == False\n assert candidate(arr = [-10, -20, -30, -40, -50]) == True\n assert candidate(arr = [-10, -5, -3, -1, 2]) == True\n assert candidate(arr = [10, 5, 15, 20, 25]) == True\n assert candidate(arr = [1, -1, 2, -2, 4, -4, 8, -8, 16, -16]) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8]) == True\n assert candidate(arr = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536]) == True\n assert candidate(arr = [2, 1, 4, 2, 8, 4, 16]) == True\n assert candidate(arr = [1, 2, 3, 5, 6, 10, 20, 40]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == True\n assert candidate(arr = [-100, -50, -25, -12, -6, -3, -1, 0, 1, 2, 4]) == True\n assert candidate(arr = [4, 8, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 5]) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -10, -20]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256]) == True\n assert candidate(arr = [0, 0, 0, 0]) == True\n assert candidate(arr = [100, 50, 25, 12, 6, 3, 1]) == True\n assert candidate(arr = [101, 202, 50, 25, 12, 6, 3]) == True\n assert candidate(arr = [1000, 501, 250, 125, 62, 31, 15, 7, 3, 1]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 60]) == True\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == False\n assert candidate(arr = [100, 50, 25, 125, 625, 3125]) == True\n assert candidate(arr = [-1, 2, -3, 6, -4, 8]) == False\n assert candidate(arr = [-10, -20, 5, 3, 15]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 250, 125]) == True\n assert candidate(arr = [-1, -2, -3, -6, -12]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == True\n assert candidate(arr = [100, 50, 25, 12.5, 6.25, 3.125, 1.5625]) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(arr = [1, 0, 2, 0, 4, 0, 8, 0]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200]) == True\n assert candidate(arr = [3, 6, 9, 18, 27, 54, 81]) == True\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56]) == True\n assert candidate(arr = [1, 2, 3, 6, 9, 18, 36, 72]) == True\n assert candidate(arr = [-1, -2, -3, -4, -5]) == True\n assert candidate(arr = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010]) == True\n assert candidate(arr = [1, 5, 10, 15, 20, 25, 50, 100]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == True\n assert candidate(arr = [2, 4, 8, 16, 32, 64, 128, 256, 512]) == True\n assert candidate(arr = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10]) == True\n assert candidate(arr = [1, 2, 3, 6, 12, 24, 48, 96, 192, 384]) == True\n assert candidate(arr = [-1, -2, -4, -8, -16]) == True\n assert candidate(arr = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == True\n assert candidate(arr = [0, 0, 1, 2, 4]) == True\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 220, 330, 440, 550, 660, 770, 880, 990, 1100]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 38]) == True\n assert candidate(arr = [1, 2, 3, 5, 6, 10, 15, 20, 30, 60]) == True\n assert candidate(arr = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6]) == True\n assert candidate(arr = [-2, 2, -4, 4, -8, 8, -16, 16]) == True\n assert candidate(arr = [-10, -5, -15, -20, -25]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == True\n assert candidate(arr = [-1, 1, -2, 2, -4, 4, 8, -8]) == True\n assert candidate(arr = [0, 1, 2, 3, 6, 12, 24, 48, 96]) == True\n assert candidate(arr = [13, 26, 52, 104, 208, 416]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == True\n assert candidate(arr = [-5, 10, -15, 20, -25, 50, -75]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 50, 75]) == True\n assert candidate(arr = [21, 42, 84, 168, 336, 672, 1344]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == True\n assert candidate(arr = [5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560]) == True\n assert candidate(arr = [6, 12, 18, 24, 48]) == True\n assert candidate(arr = [1, 0, 2, 0, 4, 0, 8, 0, 16, 0]) == True\n assert candidate(arr = [1, 2, 3, 6, 12, 24, 48, 96]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 40]) == True\n assert candidate(arr = [1000, -500, 250, -125, 62.5, 31.25]) == True\n assert candidate(arr = [-1, 2, -2, 4, -4, 8]) == True\n assert candidate(arr = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(arr = [1, 5, 25, 125, 625, 3125, 15625, 78125]) == False\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == True\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8]) == True\n assert candidate(arr = [15, 30, 45, 90, 135, 270]) == True\n assert candidate(arr = [-10, -5, -1, -2, -3, -4, -6, -8, -12, -16]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 1000, 2000]) == True\n assert candidate(arr = [10, 20, 40, 80, 160, 320, 640]) == True\n assert candidate(arr = [-10, -5, 0, 5, 10]) == True\n assert candidate(arr = [-10, -20, -30, -40, -50, -100, -200, -300]) == True\n assert candidate(arr = [-3, -6, -9, -12, -15, -18, -21, -24]) == True\n assert candidate(arr = [3, 6, 12, 24, 48, 96, 192, 384]) == True\n assert candidate(arr = [0, 0, 0, 0, 0]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(arr = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == True\n assert candidate(arr = [-5, -10, -15, -20, -25, -30, -35, -40, -45]) == True\n assert candidate(arr = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049]) == False\n assert candidate(arr = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 10]) == True\n assert candidate(arr = [11, 22, 44, 88, 176, 352, 704]) == True\n assert candidate(arr = [0, 0, 0, 0, 0]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24]) == True\n assert candidate(arr = [100, 51, 25, 12, 6, 3, 1]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 17, 19, 21]) == False\n assert candidate(arr = [0, 1, 2, 4, 8, 16, 32]) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0]) == True\n assert candidate(arr = [1, 3, 9, 27, 81, 243, 729]) == False\n assert candidate(arr = [0, 1, 2, 3, 4, 8, 16]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 50, 100]) == True\n assert candidate(arr = [9, 18, 36, 72, 144, 288, 576]) == True\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 18, 36, 72]) == True\n assert candidate(arr = [7, 14, 28, 56, 112, 224, 448]) == True\n assert candidate(arr = [1000, 500, 250, 125, 62.5]) == True\n assert candidate(arr = [1, 2, 3, 6, 12, 24, 48, 96, 192, 384, 768]) == True\n assert candidate(arr = [100, 50, 25, 12, 6, 3, 1, 0]) == True\n assert candidate(arr = [1, 5, 10, 20, 25, 50, 100]) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(arr = [-2, -4, -6, -8, -16]) == True\n assert candidate(arr = [-10, -20, -30, -200, -300, -150]) == True\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == True\n assert candidate(arr = [0, 1, 2, 4, 8, 16, 32, 64]) == True\n assert candidate(arr = [1, 2, 3, 5, 6, 10, 15, 20, 30, 60, 120, 240]) == True\n assert candidate(arr = [100, 50, 25, 12, 6, 3, 1, 0, -1, -2, -4]) == True\n assert candidate(arr = [7, 14, 28, 56, 112, 224]) == True\n assert candidate(arr = [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == True\n assert candidate(arr = [-5, -10, -15, -20, -25, -30, -35, -40, -45, -50]) == True\n assert candidate(arr = [7, 14, 28, 56, 112, 224, 448, 896]) == True\n assert candidate(arr = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230, 115]) == True\n assert candidate(arr = [10, 5, 15, 20, 2, 25, 50]) == True\n assert candidate(arr = [-2, -4, -1, -3, -5, -10]) == True\n assert candidate(arr = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == True\n assert candidate(arr = [-1, -2, -4, -8, -16, -32, -64]) == True\n assert candidate(arr = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32]) == True\n assert candidate(arr = [1, 2, 3, 6, 9, 18, 27, 54]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == True\n assert candidate(arr = [1, 0, 2, 0, 4, 0, 8, 0, 16, 0, 32, 0, 64, 0, 128, 0]) == True\n assert candidate(arr = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == True\n assert candidate(arr = [-2, -4, -8, -16, -32, -64, -128]) == True\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().checkIfExist", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool checkIfExist(vector& arr) {", "container": "Solution", "callable": "checkIfExist", "parameters": [{"name": "arr", "type": "vector&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1347, "task_id": "minimum-number-of-steps-to-make-two-strings-anagram", "difficulty": "Medium", "problem_description": "You are given two strings of the same length s and t. In one step you can choose any character of t and replace it with another character.\nReturn the minimum number of steps to make t an anagram of s.\nAn Anagram of a string is a string that contains the same characters with a different (or the same) ordering.\n \nExample 1:\n\nInput: s = \"bab\", t = \"aba\"\nOutput: 1\nExplanation: Replace the first 'a' in t with b, t = \"bba\" which is anagram of s.\n\nExample 2:\n\nInput: s = \"leetcode\", t = \"practice\"\nOutput: 5\nExplanation: Replace 'p', 'r', 'a', 'i' and 'c' from t with proper characters to make t anagram of s.\n\nExample 3:\n\nInput: s = \"anagram\", t = \"mangaar\"\nOutput: 0\nExplanation: \"anagram\" and \"mangaar\" are anagrams. \n\n \nConstraints:\n\n1 <= s.length <= 5 * 104\ns.length == t.length\ns and t consist of lowercase English letters only.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abacabadabacaba\",t = \"abcadbabacabaab\") == 1\n assert candidate(s = \"transform\",t = \"formartin\") == 1\n assert candidate(s = \"hello\",t = \"billion\") == 4\n assert candidate(s = \"aabbcc\",t = \"ccbbaa\") == 0\n assert candidate(s = \"minimum\",t = \"numinum\") == 2\n assert candidate(s = \"hello\",t = \"bello\") == 1\n assert candidate(s = \"leetcode\",t = \"practice\") == 5\n assert candidate(s = \"aaabbb\",t = \"bbbaaa\") == 0\n assert candidate(s = \"transform\",t = \"formtrans\") == 0\n assert candidate(s = \"anagram\",t = \"mangaar\") == 0\n assert candidate(s = \"abcd\",t = \"dcba\") == 0\n assert candidate(s = \"transform\",t = \"formant\") == 0\n assert candidate(s = \"bab\",t = \"aba\") == 1\n assert candidate(s = \"aaa\",t = \"bbb\") == 3\n assert candidate(s = \"abc\",t = \"def\") == 3\n assert candidate(s = \"abcde\",t = \"edcba\") == 0\n assert candidate(s = \"xyz\",t = \"zyx\") == 0\n assert candidate(s = \"antidisestablishmentarianism\",t = \"staimnariesmedtahilbesdisantii\") == 3\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzyyxwwvvuuttrrssqqppoonnmmllkkjjiihhggffeeeeddccbbaa\") == 2\n assert candidate(s = \"optimization\",t = \"inipotizaton\") == 1\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",t = \"sinsivocnoclaocivlospercimicroscopoultraomneupnc\") == 5\n assert candidate(s = \"thisisaverylongstringthatwearetesting\",t = \"testingaverylongstringthatwesarethis\") == 0\n assert candidate(s = \"pythonprogramming\",t = \"gnimmargorpnohtyp\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzyyxwwvvuuttrrssqqppoonnmmllkkjjiihhggeeffddccbbaa\") == 0\n assert candidate(s = \"floccinaucinihilipilification\",t = \"nicihilopilicifinaucinnilociflloa\") == 5\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",t = \"abcdefghijklmnopqrstuvwzyx\") == 0\n assert candidate(s = \"mississippi\",t = \"ppissimissim\") == 1\n assert candidate(s = \"aquickbrownfoxjumpsoverthelazydog\",t = \"aquickbrownfoxjumpsoverthelazydog\") == 0\n assert candidate(s = \"aaaaabbbbccccddddd\",t = \"dddddaaaaabbbcccc\") == 0\n assert candidate(s = \"bbaacc\",t = \"aabacc\") == 1\n assert candidate(s = \"aabbccddeeff\",t = \"fedcbafedcba\") == 0\n assert candidate(s = \"xylophone\",t = \"poloxynhe\") == 0\n assert candidate(s = \"almostthere\",t = \"lmostahere\") == 0\n assert candidate(s = \"abcdabcdabcd\",t = \"ddddccccbbbaaa\") == 2\n assert candidate(s = \"strength\",t = \"grenstht\") == 0\n assert candidate(s = \"pythonprogramming\",t = \"prognimmargyphnot\") == 0\n assert candidate(s = \"algorithms\",t = \"logarithms\") == 0\n assert candidate(s = \"pythonprogramming\",t = \"programmingpython\") == 0\n assert candidate(s = \"supercalifragilisticexpialidocious\",t = \"pseudopseudohypoparathyroidism\") == 11\n assert candidate(s = \"characterization\",t = \"carricahztinoe\") == 0\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\",t = \"doglazythequickbrownfoxjumpsoverthelazy\") == 4\n assert candidate(s = \"longestword\",t = \"wordlongset\") == 0\n assert candidate(s = \"photosynthesis\",t = \"synthesphotosis\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzyyxxwwvvuuttrrssqqppoonnmmllkkjjiihhggffeeddccbbaa\") == 0\n assert candidate(s = \"supercalifragilisticexpialidocious\",t = \"ecilafragisticexpialidocuosspr\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeeeddccbbaa\") == 2\n assert candidate(s = \"onomatopoeia\",t = \"pneumonoultramicroscopicsilicovolcanoconiosis\") == 33\n assert candidate(s = \"mississippi\",t = \"ppissimisss\") == 1\n assert candidate(s = \"mississippi\",t = \"pississippi\") == 1\n assert candidate(s = \"abcdefghij\",t = \"jihgfedcba\") == 0\n assert candidate(s = \"abracadabra\",t = \"arabracadab\") == 0\n assert candidate(s = \"permutations\",t = \"interpromust\") == 1\n assert candidate(s = \"aabbcceeddffee\",t = \"eeddffccbbbaaa\") == 2\n assert candidate(s = \"programmingisfun\",t = \"funprogrammingis\") == 0\n assert candidate(s = \"abracadabra\",t = \"occipital\") == 7\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == 0\n assert candidate(s = \"aabbccddeeff\",t = \"zzzzyyxxwwvvuutt\") == 16\n assert candidate(s = \"elephant\",t = \"tehlanpe\") == 0\n assert candidate(s = \"elephant\",t = \"talehpen\") == 0\n assert candidate(s = \"permutations\",t = \"pertumations\") == 0\n assert candidate(s = \"synchronized\",t = \"chronizedsyn\") == 0\n assert candidate(s = \"elevenletters\",t = \"twelvethletters\") == 4\n assert candidate(s = \"thisisaverylongstring\",t = \"stringlongaverythisis\") == 0\n assert candidate(s = \"interstellar\",t = \"stellarestri\") == 1\n assert candidate(s = \"mississippi\",t = \"pisissmipis\") == 0\n assert candidate(s = \"supercalifragilisticexpialidocious\",t = \"ciousiliexpalodicisgratefulsuper\") == 2\n assert candidate(s = \"xylophone\",t = \"polyphonex\") == 1\n assert candidate(s = \"elephant\",t = \"telephone\") == 2\n assert candidate(s = \"mississippi\",t = \"psissimippi\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"abcdefghijklmnopqrstuvwxyzzzyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(s = \"mississippi\",t = \"pissimissi\") == 0\n assert candidate(s = \"amazingrace\",t = \"raceingazam\") == 0\n assert candidate(s = \"mississippi\",t = \"pississimissm\") == 3\n assert candidate(s = \"algorithm\",t = \"logarithmxx\") == 2\n assert candidate(s = \"reducibility\",t = \"reducibility\") == 0\n assert candidate(s = \"recharacterization\",t = \"characterizationre\") == 0\n assert candidate(s = \"programming\",t = \"gimmnoprram\") == 1\n assert candidate(s = \"frequencydistribution\",t = \"charactercount\") == 5\n assert candidate(s = \"thecommunistmanifesto\",t = \"theCommunistManifesto\") == 2\n assert candidate(s = \"characterization\",t = \"intercharacterization\") == 5\n assert candidate(s = \"aaaaabbbbcccccdddddeeeee\",t = \"eeeeeaaaaabbbbbcccccddddd\") == 1\n assert candidate(s = \"xylophone\",t = \"polyphonicx\") == 3\n assert candidate(s = \"thisisaverylongstringwithvariouscharacters\",t = \"thisisanotherlongstringwithdifferentcharacters\") == 10\n assert candidate(s = \"supercalifragilisticexpialidocious\",t = \"ecilapersixfulicadogstcilxpiaiodisu\") == 2\n assert candidate(s = \"characterization\",t = \"charizmatation\") == 1\n assert candidate(s = \"programming\",t = \"remmprogain\") == 1\n assert candidate(s = \"supercalifragilisticexpialidocious\",t = \"pronunciationdictionary\") == 7\n assert candidate(s = \"multimedia\",t = \"meediamult\") == 1\n assert candidate(s = \"xylophone\",t = \"phonexylo\") == 0\n assert candidate(s = \"mississippi\",t = \"ssissippiim\") == 0\n assert candidate(s = \"development\",t = \"elopmentd\") == 0\n assert candidate(s = \"interviewquestion\",t = \"questioverntein\") == 0\n assert candidate(s = \"anagramanagram\",t = \"mangaarmangaar\") == 0\n assert candidate(s = \"congratulations\",t = \"congratulations\") == 0\n assert candidate(s = \"programming\",t = \"pgmromanig\") == 0\n assert candidate(s = \"thequickbrownfox\",t = \"quickbrownfoxt\") == 0\n assert candidate(s = \"algorithm\",t = \"logarithm\") == 0\n assert candidate(s = \"racecar\",t = \"carrace\") == 0\n assert candidate(s = \"congratulations\",t = \"gratulationscon\") == 0\n assert candidate(s = \"optimization\",t = \"tionsimipazy\") == 2\n assert candidate(s = \"rhythm\",t = \"myrthh\") == 0\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",t = \"mnbvcxzlkjhgfdsapoiuytrewq\") == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(s = \"aabbccddeeff\",t = \"ffeeddccbbaa\") == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(s = \"unitedstates\",t = \"statedinutes\") == 0\n assert candidate(s = \"supercalifragilisticexpialidocious\",t = \"expialidocioussupercalifragilistic\") == 0\n assert candidate(s = \"unanimous\",t = \"manusiousun\") == 2\n assert candidate(s = \"abacabadabacabadabacabad\",t = \"bacdabcdabcdabcdabcdabcd\") == 6\n assert candidate(s = \"characterization\",t = \"recharacterization\") == 2\n assert candidate(s = \"abacaxi\",t = \"xicabaa\") == 0\n assert candidate(s = \"programming\",t = \"gnimmargorp\") == 0\n assert candidate(s = \"mississippi\",t = \"ppiimississ\") == 0\n"}, "metadata": {"canonical_parameter_names": ["s", "t"], "leetcode_dataset_entry_point": "Solution().minSteps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minSteps(string s, string t) {", "container": "Solution", "callable": "minSteps", "parameters": [{"name": "s", "type": "string"}, {"name": "t", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1349, "task_id": "maximum-students-taking-exam", "difficulty": "Hard", "problem_description": "Given a m * n matrix seats  that represent seats distributions in a classroom. If a seat is broken, it is denoted by '#' character otherwise it is denoted by a '.' character.\nStudents can see the answers of those sitting next to the left, right, upper left and upper right, but he cannot see the answers of the student sitting directly in front or behind him. Return the maximum number of students that can take the exam together without any cheating being possible.\nStudents must be placed in seats in good condition.\n \nExample 1:\n\n\nInput: seats = [[\"#\",\".\",\"#\",\"#\",\".\",\"#\"],\n  [\".\",\"#\",\"#\",\"#\",\"#\",\".\"],\n  [\"#\",\".\",\"#\",\"#\",\".\",\"#\"]]\nOutput: 4\nExplanation: Teacher can place 4 students in available seats so they don't cheat on the exam. \n\nExample 2:\n\nInput: seats = [[\".\",\"#\"],\n  [\"#\",\"#\"],\n  [\"#\",\".\"],\n  [\"#\",\"#\"],\n  [\".\",\"#\"]]\nOutput: 3\nExplanation: Place all students in available seats. \n\n\nExample 3:\n\nInput: seats = [[\"#\",\".\",\".\",\".\",\"#\"],\n  [\".\",\"#\",\".\",\"#\",\".\"],\n  [\".\",\".\",\"#\",\".\",\".\"],\n  [\".\",\"#\",\".\",\"#\",\".\"],\n  [\"#\",\".\",\".\",\".\",\"#\"]]\nOutput: 10\nExplanation: Place students in available seats in column 1, 3 and 5.\n\n \nConstraints:\n\nseats contains only characters '.' and'#'.\nm == seats.length\nn == seats[i].length\n1 <= m <= 8\n1 <= n <= 8\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(seats = [['#', '.', '.', '.', '#'], ['.', '#', '.', '#', '.'], ['.', '.', '#', '.', '.'], ['.', '#', '.', '#', '.'], ['#', '.', '.', '.', '#']]) == 10\n assert candidate(seats = [['#', '.', '#', '#', '.', '#'], ['.', '#', '#', '#', '#', '.'], ['#', '.', '#', '#', '.', '#']]) == 4\n assert candidate(seats = [['.', '.#'], ['#', '#'], ['#', '.'], ['#', '#'], ['.', '#']]) == 3\n assert candidate(seats = [['.', '#'], ['#', '#'], ['#', '.'], ['#', '#'], ['.', '#']]) == 3\n assert candidate(seats = [['#', '.', '#', '#', '.', '#'], ['.', '#', '#', '#', '#', '.'], ['#', '.', '#', '#', '.', '#']]) == 4\n assert candidate(seats = [['#', '.', '.', '.', '#'], ['.', '#', '.', '#', '.'], ['.', '.', '#', '.', '.'], ['.', '#', '.', '#', '.'], ['#', '.', '.', '.', '#']]) == 10\n assert candidate(seats = [['#', '.', '.', '.', '#'], ['.', '#', '.', '#', '.'], ['.', '.', '#', '.', '.'], ['.', '#', '.', '#', '.'], ['#', '.', '.', '.', '#']]) == 10\n assert candidate(seats = [['.', '#'], ['#', '#'], ['#', '.'], ['#', '#'], ['.', '#']]) == 3\n assert candidate(seats = [['.', '.', '.', '#', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '#', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 23\n assert candidate(seats = [['.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.']]) == 15\n assert candidate(seats = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 32\n assert candidate(seats = [['.', '#', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '#', '.', '.', '.'], ['.', '#', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '#', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 31\n assert candidate(seats = [['.', '.', '#'], ['.', '#', '.'], ['#', '.', '.'], ['.', '.', '#'], ['.', '#', '.'], ['#', '.', '.']]) == 8\n assert candidate(seats = [['.', '.', '.', '.', '.', '.'], ['#', '.', '#', '.', '#', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.'], ['#', '.', '#', '.', '.', '#']]) == 16\n assert candidate(seats = [['.', '.', '.', '#'], ['.', '#', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '#', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '#']]) == 15\n assert candidate(seats = [['#', '.', '.', '.', '#'], ['.', '.', '#', '.', '.'], ['.', '#', '.', '#', '.'], ['.', '.', '#', '.', '.'], ['#', '.', '.', '.', '#']]) == 9\n assert candidate(seats = [['#', '.', '#', '#', '#', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 30\n assert candidate(seats = [['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.'], ['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.'], ['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.']]) == 9\n assert candidate(seats = [['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#']]) == 9\n assert candidate(seats = [['.', '#', '.', '#', '.'], ['#', '.', '.', '.', '#'], ['.', '#', '.', '#', '.'], ['#', '.', '.', '.', '#'], ['.', '#', '.', '#', '.']]) == 11\n assert candidate(seats = [['.', '.', '#', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '.']]) == 23\n assert candidate(seats = [['.', '#', '.', '.', '#', '.', '#'], ['#', '.', '#', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#'], ['#', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['#', '.', '.', '.', '.', '.', '#']]) == 16\n assert candidate(seats = [['.', '.', '#', '#', '.', '.', '#'], ['#', '.', '.', '.', '#', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '#']]) == 12\n assert candidate(seats = [['.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.']]) == 14\n assert candidate(seats = [['.', '#', '.', '#', '.', '#'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.', '.']]) == 15\n assert candidate(seats = [['.', '.', '.', '#', '.'], ['#', '.', '#', '.', '#'], ['.', '#', '.', '#', '.'], ['#', '.', '#', '.', '#'], ['.', '.', '.', '#', '.']]) == 9\n assert candidate(seats = [['.', '#', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 24\n assert candidate(seats = [['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.', '.']]) == 21\n assert candidate(seats = [['#', '.', '.', '#', '.', '#', '.', '#'], ['.', '#', '.', '.', '#', '.', '#', '.'], ['#', '.', '#', '.', '.', '#', '.', '#'], ['.', '#', '.', '#', '.', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '.', '#'], ['.', '#', '.', '#', '.', '#', '.', '.'], ['#', '.', '#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#', '.', '#']]) == 19\n assert candidate(seats = [['#', '.', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '.', '#'], ['.', '#', '.', '#', '.', '#', '.', '.'], ['#', '.', '.', '.', '.', '.', '#', '.'], ['.', '#', '#', '.', '#', '.', '.', '#'], ['#', '.', '.', '#', '.', '.', '#', '.'], ['.', '#', '.', '.', '#', '#', '.', '#']]) == 20\n assert candidate(seats = [['#', '#', '.', '.', '#'], ['.', '.', '.', '.', '.'], ['#', '.', '.', '.', '#'], ['.', '.', '.', '.', '.'], ['#', '#', '.', '.', '#'], ['.', '.', '.', '.', '.']]) == 12\n assert candidate(seats = [['#', '#', '#', '#', '#', '#'], ['#', '#', '#', '#', '#', '#'], ['#', '#', '#', '#', '#', '#'], ['#', '#', '#', '#', '#', '#']]) == 0\n assert candidate(seats = [['.', '.', '#', '.', '#', '.', '.', '.'], ['#', '.', '.', '.', '.', '.', '#', '.'], ['.', '#', '.', '.', '#', '.', '.', '#'], ['.', '.', '#', '.', '.', '#', '.', '.'], ['#', '.', '.', '.', '#', '.', '.', '#'], ['.', '#', '.', '.', '.', '.', '#', '.'], ['.', '.', '#', '.', '#', '.', '.', '.']]) == 23\n assert candidate(seats = [['.', '.', '#', '.', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '#', '.']]) == 16\n assert candidate(seats = [['.', '.', '#', '.', '.', '#'], ['.', '#', '.', '#', '.', '.'], ['#', '.', '.', '.', '#', '.'], ['.', '#', '.', '.', '.', '#'], ['#', '.', '#', '.', '.', '.'], ['.', '.', '.', '#', '.', '#']]) == 13\n assert candidate(seats = [['.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.']]) == 18\n assert candidate(seats = [['#', '#', '.', '#', '#', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '#', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 28\n assert candidate(seats = [['#', '.', '.', '.', '.', '#', '.'], ['.', '#', '.', '.', '#', '.', '.'], ['.', '.', '#', '#', '.', '.', '.'], ['.', '#', '.', '.', '#', '.', '.'], ['#', '.', '.', '.', '.', '#', '.']]) == 15\n assert candidate(seats = [['.', '.', '#', '#', '.', '.'], ['#', '.', '.', '.', '.', '#'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.'], ['#', '.', '#', '.', '.', '#']]) == 14\n assert candidate(seats = [['.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '#', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '#', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 22\n assert candidate(seats = [['.', '.', '.', '.', '.', '.'], ['#', '#', '.', '#', '#', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '#', '#', '#', '.'], ['.', '.', '.', '.', '.', '.']]) == 13\n assert candidate(seats = [['#', '.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '.', '.', '.'], ['.', '.', '.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.', '#']]) == 28\n assert candidate(seats = [['.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.']]) == 18\n assert candidate(seats = [['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '#', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.']]) == 28\n assert candidate(seats = [['.', '.', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 32\n assert candidate(seats = [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.']]) == 15\n assert candidate(seats = [['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.'], ['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.'], ['#', '#', '#', '#', '#']]) == 6\n assert candidate(seats = [['#', '.', '.', '.', '.', '#'], ['.', '#', '.', '.', '#', '.'], ['.', '.', '#', '.', '.', '.'], ['.', '#', '.', '.', '#', '.'], ['#', '.', '.', '.', '.', '#']]) == 11\n assert candidate(seats = [['.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.'], ['.', '#', '.', '#', '.'], ['.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.']]) == 13\n assert candidate(seats = [['.', '#', '.', '.', '#', '.', '.', '.'], ['#', '.', '.', '.', '.', '.', '#', '.'], ['.', '#', '.', '.', '#', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '#', '.', '.', '#'], ['.', '#', '.', '.', '.', '.', '#', '.'], ['.', '.', '#', '.', '#', '.', '.', '.']]) == 24\n assert candidate(seats = [['#', '.', '#', '.', '#', '.', '#'], ['.', '#', '.', '#', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '#'], ['.', '#', '.', '#', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '#'], ['.', '#', '.', '#', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '#']]) == 12\n assert candidate(seats = [['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.']]) == 12\n assert candidate(seats = [['#', '.', '#', '.', '#', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.'], ['#', '.', '#', '.', '.', '#']]) == 16\n assert candidate(seats = [['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['.', '.', '#', '.', '#', '.', '.'], ['.', '.', '.', '#', '.', '.', '.'], ['.', '.', '#', '.', '#', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '.']]) == 24\n assert candidate(seats = [['.', '.', '.', '#', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == 32\n assert candidate(seats = [['#', '.', '.', '.', '#'], ['.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.'], ['#', '.', '.', '.', '#']]) == 10\n assert candidate(seats = [['#', '.', '#', '.', '#', '.', '#'], ['.', '#', '.', '#', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '#'], ['.', '#', '.', '#', '.', '#', '.'], ['#', '.', '#', '.', '#', '.', '#']]) == 9\n assert candidate(seats = [['.', '.', '.', '#'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['#', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.']]) == 11\n assert candidate(seats = [['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '#', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '#']]) == 29\n assert candidate(seats = [['#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.']]) == 9\n assert candidate(seats = [['#', '.', '.', '#'], ['.', '.', '.', '.'], ['#', '.', '.', '#'], ['.', '.', '.', '.'], ['#', '.', '.', '#']]) == 7\n assert candidate(seats = [['#', '.', '.', '#', '.', '#'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '.'], ['#', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.']]) == 13\n assert candidate(seats = [['#', '.', '.', '.', '.', '#', '.'], ['.', '#', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.', '.'], ['#', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '#']]) == 20\n assert candidate(seats = [['.', '#', '.', '.', '#', '.'], ['#', '.', '#', '.', '.', '#'], ['.', '#', '.', '.', '#', '.'], ['.', '.', '#', '.', '.', '#'], ['.', '#', '.', '.', '#', '.']]) == 12\n assert candidate(seats = [['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.'], ['.', '#', '.', '#', '.', '#'], ['#', '.', '#', '.', '#', '.']]) == 9\n assert candidate(seats = [['.', '.', '.', '.', '.', '#', '.'], ['#', '.', '#', '#', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '#', '.', '#'], ['.', '.', '.', '.', '.', '#', '.']]) == 15\n"}, "metadata": {"canonical_parameter_names": ["seats"], "leetcode_dataset_entry_point": "Solution().maxStudents", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxStudents(vector>& seats) {", "container": "Solution", "callable": "maxStudents", "parameters": [{"name": "seats", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1351, "task_id": "count-negative-numbers-in-a-sorted-matrix", "difficulty": "Easy", "problem_description": "Given a m x n matrix grid which is sorted in non-increasing order both row-wise and column-wise, return the number of negative numbers in grid.\n \nExample 1:\n\nInput: grid = [[4,3,2,-1],[3,2,1,-1],[1,1,-1,-2],[-1,-1,-2,-3]]\nOutput: 8\nExplanation: There are 8 negatives number in the matrix.\n\nExample 2:\n\nInput: grid = [[3,2],[1,0]]\nOutput: 0\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 100\n-100 <= grid[i][j] <= 100\n\n \nFollow up: Could you find an O(n + m) solution?", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[-1, -1], [-1, -1]]) == 4\n assert candidate(grid = [[-3], [-2], [-1], [0], [1]]) == 0\n assert candidate(grid = [[-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]]) == 12\n assert candidate(grid = [[-1, -1, -1], [-5, -5, -5]]) == 6\n assert candidate(grid = [[3, 2], [1, 0]]) == 0\n assert candidate(grid = [[4, 3, 2, -1], [3, 2, 1, -1], [1, 1, -1, -2], [-1, -1, -2, -3]]) == 8\n assert candidate(grid = [[1, -1], [-1, -1]]) == 3\n assert candidate(grid = [[-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]]) == 16\n assert candidate(grid = [[5, 2, 1], [4, 3, 1], [3, 2, 1]]) == 0\n assert candidate(grid = [[1, 2, 3], [4, 5, 6]]) == 0\n assert candidate(grid = [[-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]]) == 12\n assert candidate(grid = [[100, 90, 80, -10], [-9, -8, -7, -6], [-5, -4, -3, -2], [-4, -3, -2, -1]]) == 13\n assert candidate(grid = [[1]]) == 0\n assert candidate(grid = [[-5]]) == 1\n assert candidate(grid = [[1, 2, 3], [0, -1, -2], [-3, -4, -5]]) == 5\n assert candidate(grid = [[-1]]) == 1\n assert candidate(grid = [[5, 4, 3, 2, 1], [4, 3, 2, 1, 0], [3, 2, 1, 0, -1], [2, 1, 0, -1, -2], [1, 0, -1, -2, -3]]) == 6\n assert candidate(grid = [[-1, 0], [0, -1]]) == 1\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]) == 0\n assert candidate(grid = [[-1, 2, -3, 4, -5], [6, -7, 8, -9, 10], [-11, 12, -13, 14, -15], [16, -17, 18, -19, 20]]) == 10\n assert candidate(grid = [[1, 0, 0, 0, 0], [-1, 0, 0, 0, 0], [-1, -1, 0, 0, 0], [-1, -1, -1, 0, 0], [-1, -1, -1, -1, 0]]) == 20\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, -1]]) == 1\n assert candidate(grid = [[50, 40, 30, 20, 10, 0, -10, -20], [-5, -10, -15, -20, -25, -30, -35, -40], [-50, -60, -70, -80, -90, -100, -110, -120]]) == 18\n assert candidate(grid = [[-100, -99, -98, -97, -96], [-95, -94, -93, -92, -91], [-90, -89, -88, -87, -86], [-85, -84, -83, -82, -81], [-80, -79, -78, -77, -76]]) == 25\n assert candidate(grid = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [8, 7, 6, 5, 4, 3, 2, 1, 0, -1], [7, 6, 5, 4, 3, 2, 1, 0, -1, -2], [6, 5, 4, 3, 2, 1, 0, -1, -2, -3], [5, 4, 3, 2, 1, 0, -1, -2, -3, -4], [4, 3, 2, 1, 0, -1, -2, -3, -4, -5], [3, 2, 1, 0, -1, -2, -3, -4, -5, -6], [2, 1, 0, -1, -2, -3, -4, -5, -6, -7], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8]]) == 36\n assert candidate(grid = [[-99, -98, -97, -96, -95, -94, -93, -92, -91, -90], [-89, -88, -87, -86, -85, -84, -83, -82, -81, -80], [-79, -78, -77, -76, -75, -74, -73, -72, -71, -70], [-69, -68, -67, -66, -65, -64, -63, -62, -61, -60], [-59, -58, -57, -56, -55, -54, -53, -52, -51, -50], [-49, -48, -47, -46, -45, -44, -43, -42, -41, -40], [-39, -38, -37, -36, -35, -34, -33, -32, -31, -30], [-29, -28, -27, -26, -25, -24, -23, -22, -21, -20], [-19, -18, -17, -16, -15, -14, -13, -12, -11, -10], [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0]]) == 100\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-2, -2, -2, -2, -2, -2, -2, -2, -2, -2], [-3, -3, -3, -3, -3, -3, -3, -3, -3, -3]]) == 30\n assert candidate(grid = [[1, 1, 1, -1, -1, -1], [1, 1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1]]) == 13\n assert candidate(grid = [[9, -9, 8, -8], [7, -7, 6, -6], [5, -5, 4, -4], [3, -3, 2, -2], [1, -1, 0, -1]]) == 15\n assert candidate(grid = [[99, 98, 97, 96, 95, 94], [93, 92, 91, 90, -1, -2], [-3, -4, -5, -6, -7, -8], [-9, -10, -11, -12, -13, -14]]) == 14\n assert candidate(grid = [[10, -10, 20, -20, 30, -30], [9, -9, 18, -18, 27, -27], [8, -8, 16, -16, 24, -24], [7, -7, 14, -14, 21, -21]]) == 20\n assert candidate(grid = [[0, 0, 0, 0, -1], [0, 0, -1, -1, -1], [0, -1, -1, -1, -1], [-1, -1, -1, -1, -1]]) == 13\n assert candidate(grid = [[-5, -4, -3, -2, -1], [0, 0, 0, 0, 0], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == 20\n assert candidate(grid = [[1, 0, -1, 0, -1], [0, -1, 0, -1, 0], [-1, 0, -1, 0, -1], [0, -1, 0, -1, 0], [-1, 0, -1, 0, -1]]) == 15\n assert candidate(grid = [[-50, -40, -30, -20, -10], [30, 20, 10, 0, -10], [-20, -10, 0, 10, 20], [10, 0, 10, 20, 30], [0, 10, 20, 30, 40]]) == 0\n assert candidate(grid = [[90, 80, 70, 60, 50, 40, 30, 20, 10, 0], [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]]) == 10\n assert candidate(grid = [[-10, -9, -8, -7, -6, -5, -4, -3, -2, -1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[-5, -4, -3, -2, -1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[-1, -1, -1, 0], [1, 0, -1, -1], [1, -1, -1, -1], [-1, -1, -1, -1]]) == 11\n assert candidate(grid = [[-3, -2, -1, 0], [2, 1, 0, -1], [1, 0, -1, -2], [0, -1, -2, -3]]) == 6\n assert candidate(grid = [[10, -5, 3, 2, -1], [-3, 0, -1, 0, -4], [-5, -6, -7, -8, -9]]) == 14\n assert candidate(grid = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [8, 7, 6, 5, 4, 3, 2, 1, 0, -1], [7, 6, 5, 4, 3, 2, 1, 0, -1, -2], [6, 5, 4, 3, 2, 1, 0, -1, -2, -3], [5, 4, 3, 2, 1, 0, -1, -2, -3, -4], [4, 3, 2, 1, 0, -1, -2, -3, -4, -5], [3, 2, 1, 0, -1, -2, -3, -4, -5, -6], [2, 1, 0, -1, -2, -3, -4, -5, -6, -7], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8]]) == 36\n assert candidate(grid = [[-100, -99, -98, -97, -96], [0, 0, 0, -1, -2], [-3, -4, -5, -6, -7], [-8, -9, -10, -11, -12]]) == 14\n assert candidate(grid = [[1, -1, -2, -3], [-1, -2, -3, -4], [-2, -3, -4, -5], [-3, -4, -5, -6]]) == 15\n assert candidate(grid = [[-1, -2, -3, -4, -5, -6, -7, -8, -9, -10], [-2, -3, -4, -5, -6, -7, -8, -9, -10, -11], [-3, -4, -5, -6, -7, -8, -9, -10, -11, -12]]) == 30\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, -1], [0, 0, 0, 0, 0, 0, 0, 0, -1, -1], [0, 0, 0, 0, 0, 0, 0, -1, -1, -1], [0, 0, 0, 0, 0, 0, -1, -1, -1, -1], [0, 0, 0, 0, 0, -1, -1, -1, -1, -1], [0, 0, 0, 0, -1, -1, -1, -1, -1, -1], [0, 0, 0, -1, -1, -1, -1, -1, -1, -1], [0, 0, -1, -1, -1, -1, -1, -1, -1, -1], [0, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == 45\n assert candidate(grid = [[-1, 0, 1, 2, 3], [0, -1, -2, -3, -4], [-1, -2, -3, -4, -5], [-10, -20, -30, -40, -50]]) == 14\n assert candidate(grid = [[10, -10, 20, -20], [5, -5, 15, -15], [0, 0, 0, 0], [-1, -2, -3, -4]]) == 4\n assert candidate(grid = [[99, 98, 97, 96, 95, 94, 93, 92, 91, 90], [89, 88, 87, 86, 85, 84, 83, 82, 81, 80], [79, 78, 77, 76, 75, 74, 73, 72, 71, 70], [69, 68, 67, 66, 65, 64, 63, 62, 61, 60], [59, 58, 57, 56, 55, 54, 53, 52, 51, 50], [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10], [-11, -12, -13, -14, -15, -16, -17, -18, -19, -20], [-21, -22, -23, -24, -25, -26, -27, -28, -29, -30], [-31, -32, -33, -34, -35, -36, -37, -38, -39, -40], [-41, -42, -43, -44, -45, -46, -47, -48, -49, -50]]) == 50\n assert candidate(grid = [[-1, 1, -1, 1, -1], [1, -1, 1, -1, 1], [-1, 1, -1, 1, -1], [1, -1, 1, -1, 1], [-1, 1, -1, 1, -1]]) == 15\n assert candidate(grid = [[2, 1, 0, -1, -2], [1, 0, -1, -2, -3], [0, -1, -2, -3, -4], [-1, -2, -3, -4, -5], [-2, -3, -4, -5, -6]]) == 19\n assert candidate(grid = [[100, 90, 80, 70, 60, 50, 40, 30, 20, 10], [90, 80, 70, 60, 50, 40, 30, 20, 10, 0], [80, 70, 60, 50, 40, 30, 20, 10, 0, -10], [70, 60, 50, 40, 30, 20, 10, 0, -10, -20], [60, 50, 40, 30, 20, 10, 0, -10, -20, -30]]) == 6\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[-1, -2, -3, -4], [-5, -6, -7, -8], [-9, -10, -11, -12], [-13, -14, -15, -16]]) == 16\n assert candidate(grid = [[-1, -2, -3, -4, -5], [-6, -7, -8, -9, -10], [-11, -12, -13, -14, -15], [-16, -17, -18, -19, -20]]) == 20\n assert candidate(grid = [[1, -1, 0, 0], [-1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(grid = [[5, 4, 3, 2, 1], [4, 3, 2, 1, 0], [3, 2, 1, -1, -2], [2, 1, -2, -3, -4], [1, 0, -3, -4, -5]]) == 8\n assert candidate(grid = [[99, 98, 97, 96, 95], [-1, -2, -3, -4, -5], [-10, -20, -30, -40, -50], [-100, -101, -102, -103, -104]]) == 15\n assert candidate(grid = [[10, -5, -4, -3], [-7, -6, -5, -4], [-8, -7, -6, -5], [-9, -8, -7, -6]]) == 15\n assert candidate(grid = [[50, 40, 30, 20, 10], [45, 35, 25, 15, 5], [40, 30, 20, 10, 0], [35, 25, 15, 5, -5]]) == 1\n assert candidate(grid = [[-1, -2, -3, -4, -5], [-2, -3, -4, -5, -6], [-3, -4, -5, -6, -7], [-4, -5, -6, -7, -8], [-5, -6, -7, -8, -9]]) == 25\n assert candidate(grid = [[1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9], [1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]]) == 90\n assert candidate(grid = [[0, 0, 0, 0, -1], [0, 0, 0, -1, -2], [0, 0, -1, -2, -3], [0, -1, -2, -3, -4], [-1, -2, -3, -4, -5]]) == 15\n assert candidate(grid = [[-100, -99, -98, -97, -96, -95, -94, -93, -92, -91], [-90, -89, -88, -87, -86, -85, -84, -83, -82, -81], [-80, -79, -78, -77, -76, -75, -74, -73, -72, -71], [-70, -69, -68, -67, -66, -65, -64, -63, -62, -61], [-60, -59, -58, -57, -56, -55, -54, -53, -52, -51], [-50, -49, -48, -47, -46, -45, -44, -43, -42, -41], [-40, -39, -38, -37, -36, -35, -34, -33, -32, -31], [-30, -29, -28, -27, -26, -25, -24, -23, -22, -21], [-20, -19, -18, -17, -16, -15, -14, -13, -12, -11], [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]]) == 100\n assert candidate(grid = [[-5, -4, -3, -2, -1], [-10, -9, -8, -7, -6], [-15, -14, -13, -12, -11], [-20, -19, -18, -17, -16], [-25, -24, -23, -22, -21]]) == 25\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, -1, -2], [0, -1, -2, -3], [-1, -2, -3, -4]]) == 9\n assert candidate(grid = [[1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1]]) == 20\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, -1], [0, 0, -1, -1], [0, -1, -1, -1]]) == 6\n assert candidate(grid = [[50, 40, 30, 20, 10], [45, 35, 25, 15, 5], [40, 30, 20, 10, 0], [35, 25, 15, 5, -5], [30, 20, 10, 0, -10]]) == 2\n assert candidate(grid = [[10, 8, 6, 4, 2, 0, -2, -4], [-6, -8, -10, -12, -14, -16, -18, -20], [-10, -12, -14, -16, -18, -20, -22, -24]]) == 18\n assert candidate(grid = [[-10, -20, -30, -40], [-20, -30, -40, -50], [-30, -40, -50, -60], [-40, -50, -60, -70]]) == 16\n assert candidate(grid = [[-10, -20, -30, -40, -50, -60, -70, -80, -90], [-110, -120, -130, -140, -150, -160, -170, -180, -190], [-200, -210, -220, -230, -240, -250, -260, -270, -280]]) == 27\n assert candidate(grid = [[-100, -99, -98, -97], [-96, -95, -94, -93], [-92, -91, -90, -89], [-88, -87, -86, -85]]) == 16\n assert candidate(grid = [[10, 20, 30, 40, 50], [20, 30, 40, 50, 60], [30, 40, 50, 60, 70], [40, 50, 60, 70, 80], [50, 60, 70, 80, 90]]) == 0\n assert candidate(grid = [[-10, -9, -8, -7, -6, -5, -4, -3, -2, -1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 0\n assert candidate(grid = [[-100, -99, -98, -97, -96, -95, -94, -93, -92, -91], [-90, -89, -88, -87, -86, -85, -84, -83, -82, -81], [-80, -79, -78, -77, -76, -75, -74, -73, -72, -71], [-70, -69, -68, -67, -66, -65, -64, -63, -62, -61]]) == 40\n assert candidate(grid = [[-50, -49, -48, -47, -46, -45], [-44, -43, -42, -41, -40, -39], [-38, -37, -36, -35, -34, -33], [-32, -31, -30, -29, -28, -27]]) == 24\n assert candidate(grid = [[-100, -99, -98], [-99, -98, -97], [-98, -97, -96], [-97, -96, -95]]) == 12\n assert candidate(grid = [[10, 5, 0, -10, -20], [-5, -15, -20, -25, -30], [-1, -2, -3, -4, -5]]) == 12\n assert candidate(grid = [[1, -1, 0], [1, -1, 0], [1, -1, 0]]) == 6\n assert candidate(grid = [[1, 0, -1], [-1, -2, -3], [-2, -3, -4], [-3, -4, -5]]) == 10\n assert candidate(grid = [[9, 7, 5, 3, 1], [-1, -3, -5, -7, -9], [-2, -4, -6, -8, -10], [-3, -6, -9, -12, -15]]) == 15\n assert candidate(grid = [[0, 0, 0], [0, 0, -1], [0, -1, -2], [-1, -2, -3]]) == 6\n assert candidate(grid = [[5, 4, 3, 2, 1], [4, 3, 2, 1, -1], [3, 2, 1, -1, -2], [2, 1, -1, -2, -3], [1, -1, -2, -3, -4]]) == 10\n assert candidate(grid = [[1, 0, -1], [-1, 0, 1], [0, 1, -1]]) == 1\n assert candidate(grid = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, -1], [8, 7, 6, 5, 4, 3, 2, 1, -2, -3], [7, 6, 5, 4, 3, 2, 1, -3, -4, -5]]) == 6\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, -1, -1], [0, 0, 0, -1, -1, -2], [-1, -1, -2, -3, -4, -5]]) == 11\n assert candidate(grid = [[-2, -1, 0, 1, 2], [3, 4, 5, 6, 7], [8, 9, 10, 11, 12], [-13, -14, -15, -16, -17], [-18, -19, -20, -21, -22]]) == 10\n assert candidate(grid = [[1, -1, 2, -2, 3, -3, 4, -4], [1, -1, 2, -2, 3, -3, 4, -4], [1, -1, 2, -2, 3, -3, 4, -4], [1, -1, 2, -2, 3, -3, 4, -4]]) == 28\n assert candidate(grid = [[5, 4, 3, 2, 1, 0, -1, -2, -3, -4], [-4, -3, -2, -1, 0, 1, 2, 3, 4, 5], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [0, -1, -2, -3, -4, -5, -6, -7, -8, -9]]) == 9\n assert candidate(grid = [[5, 4, 3, 2, 1], [-1, -2, -3, -4, -5], [-6, -7, -8, -9, -10]]) == 10\n assert candidate(grid = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, -1], [8, 7, 6, 5, 4, 3, 2, 1, -1, -2], [7, 6, 5, 4, 3, 2, 1, -1, -2, -3], [6, 5, 4, 3, 2, 1, -1, -2, -3, -4], [5, 4, 3, 2, 1, -1, -2, -3, -4, -5], [4, 3, 2, 1, -1, -2, -3, -4, -5, -6], [3, 2, 1, -1, -2, -3, -4, -5, -6, -7], [2, 1, -1, -2, -3, -4, -5, -6, -7, -8], [1, -1, -2, -3, -4, -5, -6, -7, -8, -9]]) == 45\n assert candidate(grid = [[100, -50, 0], [90, -40, 0], [80, -30, 0], [70, -20, 0], [60, -10, 0]]) == 10\n assert candidate(grid = [[50, 20, 10, 0, -10, -20], [-30, -40, -50, -60, -70, -80], [-90, -100, -110, -120, -130, -140]]) == 14\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().countNegatives", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countNegatives(vector>& grid) {", "container": "Solution", "callable": "countNegatives", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1353, "task_id": "maximum-number-of-events-that-can-be-attended", "difficulty": "Medium", "problem_description": "You are given an array of events where events[i] = [startDayi, endDayi]. Every event i starts at startDayi and ends at endDayi.\nYou can attend an event i at any day d where startTimei <= d <= endTimei. You can only attend one event at any time d.\nReturn the maximum number of events you can attend.\n \nExample 1:\n\n\nInput: events = [[1,2],[2,3],[3,4]]\nOutput: 3\nExplanation: You can attend all the three events.\nOne way to attend them all is as shown.\nAttend the first event on day 1.\nAttend the second event on day 2.\nAttend the third event on day 3.\n\nExample 2:\n\nInput: events= [[1,2],[2,3],[3,4],[1,2]]\nOutput: 4\n\n \nConstraints:\n\n1 <= events.length <= 105\nevents[i].length == 2\n1 <= startDayi <= endDayi <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(events = [[1, 100], [1, 100], [1, 100], [1, 100], [1, 100]]) == 5\n assert candidate(events = [[1, 3], [2, 4], [3, 5], [4, 6]]) == 4\n assert candidate(events = [[10, 15], [20, 25], [30, 35], [40, 45], [50, 55]]) == 5\n assert candidate(events = [[5, 5], [1, 5], [1, 5], [1, 5]]) == 4\n assert candidate(events = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15]]) == 7\n assert candidate(events = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 5\n assert candidate(events = [[1, 2], [2, 2], [3, 3], [4, 4], [5, 5]]) == 5\n assert candidate(events = [[1, 5], [1, 5], [1, 5], [2, 3], [2, 3]]) == 5\n assert candidate(events = [[1, 2], [2, 3], [3, 4]]) == 3\n assert candidate(events = [[1, 2], [2, 3], [3, 4], [1, 2]]) == 4\n assert candidate(events = [[1, 10], [2, 2], [3, 3], [4, 4], [5, 5]]) == 5\n assert candidate(events = [[1, 10], [2, 3], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10]]) == 8\n assert candidate(events = [[1, 3], [2, 3], [3, 4], [4, 5], [5, 6]]) == 5\n assert candidate(events = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]) == 2\n assert candidate(events = [[1, 2], [2, 2], [3, 4], [4, 5]]) == 4\n assert candidate(events = [[1, 100], [1, 100], [1, 100]]) == 3\n assert candidate(events = [[1, 100000], [1, 100000], [1, 100000], [1, 100000], [1, 100000]]) == 5\n assert candidate(events = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 9\n assert candidate(events = [[1, 2], [2, 2], [3, 3], [3, 4]]) == 4\n assert candidate(events = [[1, 1], [1, 2], [1, 3], [1, 4]]) == 4\n assert candidate(events = [[1, 5], [1, 10], [1, 15], [1, 20], [2, 6], [2, 11], [2, 16], [2, 21], [3, 7], [3, 12], [3, 17], [3, 22], [4, 8], [4, 13], [4, 18], [4, 23], [5, 9], [5, 14], [5, 19], [5, 24]]) == 20\n assert candidate(events = [[1, 100000], [50000, 60000], [50000, 55000], [30000, 40000], [10000, 20000], [60000, 70000]]) == 6\n assert candidate(events = [[10, 20], [10, 20], [10, 20], [10, 20], [10, 20], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20]]) == 11\n assert candidate(events = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10]]) == 11\n assert candidate(events = [[1, 30000], [2, 29999], [3, 29998], [4, 29997], [5, 29996], [6, 29995], [7, 29994], [8, 29993], [9, 29992], [10, 29991]]) == 10\n assert candidate(events = [[1, 3], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13]]) == 10\n assert candidate(events = [[1, 100000], [100000, 100000], [1, 100000], [100000, 100000], [1, 100000], [100000, 100000], [1, 100000], [100000, 100000], [1, 100000], [100000, 100000]]) == 6\n assert candidate(events = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10]]) == 10\n assert candidate(events = [[1, 3], [2, 3], [3, 3], [4, 6], [5, 6], [6, 6], [7, 9], [8, 9], [9, 9], [10, 12], [11, 12], [12, 12]]) == 12\n assert candidate(events = [[1, 5], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [20, 21], [22, 23], [24, 25], [26, 27], [28, 29]]) == 15\n assert candidate(events = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 10\n assert candidate(events = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25], [24, 26], [25, 27], [26, 28], [27, 29], [28, 30]]) == 29\n assert candidate(events = [[5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20], [17, 21], [18, 22], [19, 23], [20, 24], [21, 25]]) == 17\n assert candidate(events = [[1, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12], [12, 14], [14, 16], [16, 18], [18, 20], [20, 22], [22, 24], [24, 26], [26, 28], [28, 30], [30, 32], [32, 34], [34, 36], [36, 38], [38, 40], [40, 42], [42, 44], [44, 46], [46, 48], [48, 50], [50, 52], [52, 54], [54, 56], [56, 58], [58, 60]]) == 30\n assert candidate(events = [[1, 100], [1, 100], [2, 99], [2, 99], [3, 98], [3, 98], [4, 97], [4, 97], [5, 96], [5, 96], [6, 95], [6, 95]]) == 12\n assert candidate(events = [[2, 2], [3, 3], [1, 2], [1, 3], [1, 4]]) == 4\n assert candidate(events = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 10\n assert candidate(events = [[1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11], [1, 20], [2, 19], [3, 18], [4, 17], [5, 16]]) == 15\n assert candidate(events = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [1, 2], [2, 3], [3, 4], [4, 5]]) == 16\n assert candidate(events = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [11, 15], [12, 15], [13, 15], [14, 15], [15, 15], [16, 20], [17, 20], [18, 20], [19, 20], [20, 20]]) == 20\n assert candidate(events = [[1, 2], [3, 4], [2, 3], [4, 5], [1, 5]]) == 5\n assert candidate(events = [[5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16], [12, 17], [13, 18], [14, 19], [15, 20]]) == 11\n assert candidate(events = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [1, 5], [5, 10], [1, 3], [3, 5]]) == 10\n assert candidate(events = [[1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10]]) == 10\n assert candidate(events = [[1, 2], [1, 2], [1, 2], [2, 3], [2, 3], [2, 3], [3, 4], [3, 4], [3, 4], [4, 5], [4, 5], [4, 5], [5, 6], [5, 6], [5, 6], [6, 7], [6, 7], [6, 7], [7, 8], [7, 8], [7, 8]]) == 8\n assert candidate(events = [[1, 100000], [2, 99999], [3, 99998], [4, 99997], [5, 99996], [6, 99995], [7, 99994], [8, 99993], [9, 99992], [10, 99991]]) == 10\n assert candidate(events = [[5, 21], [1, 10], [2, 20], [3, 19], [4, 18], [5, 17], [6, 16], [7, 15], [8, 14], [9, 13], [10, 12], [11, 11], [12, 10], [13, 9], [14, 8], [15, 7], [16, 6], [17, 5], [18, 4], [19, 3], [20, 2], [21, 1]]) == 21\n assert candidate(events = [[1, 2], [1, 2], [1, 2], [1, 2], [2, 3], [2, 3], [2, 3], [2, 3], [3, 4], [3, 4], [3, 4], [3, 4], [4, 5], [4, 5], [4, 5], [4, 5], [5, 6], [5, 6], [5, 6], [5, 6], [6, 7], [6, 7], [6, 7], [6, 7], [7, 8], [7, 8], [7, 8], [7, 8], [8, 9], [8, 9], [8, 9], [8, 9], [9, 10], [9, 10], [9, 10], [9, 10]]) == 10\n assert candidate(events = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21]]) == 20\n assert candidate(events = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 10\n assert candidate(events = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 10]]) == 10\n assert candidate(events = [[1, 20], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 19\n assert candidate(events = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == 1\n assert candidate(events = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 10\n assert candidate(events = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 10\n assert candidate(events = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]]) == 10\n assert candidate(events = [[1, 2], [2, 5], [3, 4], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11]]) == 9\n assert candidate(events = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]]) == 15\n assert candidate(events = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20]]) == 18\n assert candidate(events = [[2, 4], [2, 5], [2, 7], [2, 8], [2, 9], [4, 7], [5, 7], [5, 8], [5, 9], [7, 10], [8, 10], [9, 10]]) == 9\n assert candidate(events = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 9\n assert candidate(events = [[1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11], [11, 10], [12, 9], [13, 8], [14, 7], [15, 6], [16, 5], [17, 4], [18, 3], [19, 2], [20, 1]]) == 20\n assert candidate(events = [[1, 2], [2, 3], [3, 4], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15], [13, 16], [14, 17], [15, 18], [16, 19], [17, 20]]) == 20\n assert candidate(events = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 10\n assert candidate(events = [[1, 4], [1, 4], [1, 4], [2, 4], [2, 4], [3, 4], [3, 4], [4, 4], [4, 4], [4, 4]]) == 4\n assert candidate(events = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22]]) == 20\n assert candidate(events = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]) == 2\n assert candidate(events = [[1, 5], [5, 5], [1, 5], [2, 3], [4, 6]]) == 5\n assert candidate(events = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12]]) == 11\n assert candidate(events = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20], [17, 21], [18, 22], [19, 23], [20, 24], [21, 25], [22, 26], [23, 27], [24, 28], [25, 29], [26, 30], [27, 31], [28, 32], [29, 33], [30, 34], [31, 35], [32, 36], [33, 37], [34, 38], [35, 39], [36, 40], [37, 41], [38, 42], [39, 43], [40, 44], [41, 45], [42, 46], [43, 47], [44, 48], [45, 49], [46, 50]]) == 46\n assert candidate(events = [[1, 5], [2, 3], [3, 4], [2, 5], [1, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 9\n assert candidate(events = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7]]) == 5\n assert candidate(events = [[10, 15], [20, 25], [15, 20], [25, 30], [10, 25], [20, 30], [15, 30]]) == 7\n assert candidate(events = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == 15\n assert candidate(events = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21], [21, 23], [23, 25], [25, 27], [27, 29], [29, 31], [31, 33], [33, 35], [35, 37], [37, 39], [39, 41], [41, 43], [43, 45], [45, 47], [47, 49], [49, 51], [51, 53], [53, 55], [55, 57], [57, 59], [59, 61], [61, 63]]) == 31\n assert candidate(events = [[10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55], [55, 60]]) == 10\n assert candidate(events = [[1, 50000], [50001, 100000], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21]]) == 22\n assert candidate(events = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25], [1, 25], [2, 24], [3, 23], [4, 22], [5, 21]]) == 10\n assert candidate(events = [[1, 3], [1, 10], [2, 5], [2, 8], [3, 6], [3, 9], [4, 7], [4, 10], [5, 8], [5, 11], [6, 9], [6, 12], [7, 10], [7, 13], [8, 11], [8, 14], [9, 12], [9, 15], [10, 13], [10, 16]]) == 16\n assert candidate(events = [[1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5]]) == 5\n assert candidate(events = [[5, 5], [1, 5], [1, 5], [2, 3], [2, 3], [3, 4], [3, 4], [4, 5], [4, 5]]) == 5\n assert candidate(events = [[1, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55], [55, 60], [60, 65], [65, 70], [70, 75], [75, 80], [80, 85], [85, 90], [90, 95], [95, 100]]) == 20\n assert candidate(events = [[1, 2], [3, 4], [2, 3], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]]) == 10\n assert candidate(events = [[10, 20], [21, 30], [31, 40], [41, 50], [51, 60], [61, 70], [71, 80], [81, 90], [91, 100], [101, 110], [111, 120], [121, 130], [131, 140], [141, 150], [151, 160]]) == 15\n assert candidate(events = [[1, 5], [1, 5], [2, 6], [2, 6], [3, 7], [3, 7], [4, 8], [4, 8], [5, 9], [5, 9], [6, 10], [6, 10], [7, 11], [7, 11], [8, 12], [8, 12], [9, 13], [9, 13], [10, 14], [10, 14]]) == 14\n assert candidate(events = [[1, 5], [5, 10], [10, 15], [15, 20], [20, 25], [1, 25], [2, 24], [3, 23], [4, 22], [5, 21], [6, 20], [7, 19], [8, 18], [9, 17], [10, 16], [11, 15], [12, 14], [13, 13], [14, 12], [15, 11]]) == 20\n assert candidate(events = [[3, 6], [2, 6], [1, 6], [1, 5], [2, 5], [3, 5], [2, 4], [3, 4], [4, 5], [4, 6], [4, 7]]) == 7\n assert candidate(events = [[1, 2], [2, 3], [3, 4], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 10\n assert candidate(events = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 10\n assert candidate(events = [[1, 3], [2, 5], [3, 7], [4, 10], [5, 15], [6, 20], [7, 25], [8, 30], [9, 35], [10, 40]]) == 10\n assert candidate(events = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6]]) == 6\n assert candidate(events = [[1, 2], [1, 2], [1, 2], [2, 3], [2, 3], [2, 3], [3, 4], [3, 4], [3, 4], [4, 5], [4, 5], [4, 5], [5, 6], [5, 6], [5, 6], [6, 7], [6, 7], [6, 7]]) == 7\n assert candidate(events = [[1, 2], [2, 3], [2, 3], [3, 4], [3, 4], [4, 5], [4, 5], [5, 6]]) == 6\n assert candidate(events = [[1, 10], [1, 20], [1, 30], [2, 20], [2, 30], [2, 40], [3, 30], [3, 40], [3, 50], [4, 40], [4, 50], [4, 60], [5, 50], [5, 60], [5, 70]]) == 15\n assert candidate(events = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 10\n assert candidate(events = [[1, 20000], [1, 30000], [2, 30000], [2, 40000], [3, 40000], [3, 50000], [4, 50000], [4, 60000], [5, 60000], [5, 70000]]) == 10\n assert candidate(events = [[1, 2], [2, 3], [2, 3], [3, 4], [3, 4], [4, 5], [4, 5], [5, 6], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 10\n assert candidate(events = [[1, 2], [2, 5], [5, 6], [6, 10], [10, 15]]) == 5\n"}, "metadata": {"canonical_parameter_names": ["events"], "leetcode_dataset_entry_point": "Solution().maxEvents", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxEvents(vector>& events) {", "container": "Solution", "callable": "maxEvents", "parameters": [{"name": "events", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1354, "task_id": "construct-target-array-with-multiple-sums", "difficulty": "Hard", "problem_description": "You are given an array target of n integers. From a starting array arr consisting of n 1's, you may perform the following procedure :\n\nlet x be the sum of all elements currently in your array.\nchoose index i, such that 0 <= i < n and set the value of arr at index i to x.\nYou may repeat this procedure as many times as needed.\n\nReturn true if it is possible to construct the target array from arr, otherwise, return false.\n \nExample 1:\n\nInput: target = [9,3,5]\nOutput: true\nExplanation: Start with arr = [1, 1, 1] \n[1, 1, 1], sum = 3 choose index 1\n[1, 3, 1], sum = 5 choose index 2\n[1, 3, 5], sum = 9 choose index 0\n[9, 3, 5] Done\n\nExample 2:\n\nInput: target = [1,1,1,2]\nOutput: false\nExplanation: Impossible to create target array from [1,1,1,1].\n\nExample 3:\n\nInput: target = [8,5]\nOutput: true\n\n \nConstraints:\n\nn == target.length\n1 <= n <= 5 * 104\n1 <= target[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(target = [1, 2, 3, 4, 5]) == False\n assert candidate(target = [1000000000, 1, 1]) == False\n assert candidate(target = [5, 7, 1]) == True\n assert candidate(target = [10, 1]) == True\n assert candidate(target = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == False\n assert candidate(target = [5, 5, 5]) == False\n assert candidate(target = [1000000000, 1000000000]) == False\n assert candidate(target = [1000000000, 1]) == True\n assert candidate(target = [1, 1, 1, 2]) == False\n assert candidate(target = [5, 10, 15]) == False\n assert candidate(target = [1, 1000000000, 1000000000]) == False\n assert candidate(target = [9, 3, 5]) == True\n assert candidate(target = [1, 1, 1]) == True\n assert candidate(target = [2, 900000000]) == False\n assert candidate(target = [8, 5]) == True\n assert candidate(target = [1, 1000000000]) == True\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(target = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == False\n assert candidate(target = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == False\n assert candidate(target = [21, 17, 13, 9, 5, 1]) == False\n assert candidate(target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == False\n assert candidate(target = [100, 100, 100, 100, 100, 99, 98, 97, 96, 95]) == False\n assert candidate(target = [5, 10, 15, 20, 25, 30]) == False\n assert candidate(target = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == False\n assert candidate(target = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == False\n assert candidate(target = [37, 11, 25, 7, 19]) == False\n assert candidate(target = [41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131]) == False\n assert candidate(target = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == False\n assert candidate(target = [1, 1000000000, 1, 1000000000, 1, 1000000000]) == False\n assert candidate(target = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == False\n assert candidate(target = [2, 6, 10, 14, 18, 22]) == False\n assert candidate(target = [100, 100, 100, 100, 99]) == False\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 20]) == False\n assert candidate(target = [13, 11, 10]) == False\n assert candidate(target = [81, 27, 9, 3, 1]) == False\n assert candidate(target = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == False\n assert candidate(target = [5, 7, 9, 13, 21, 34, 55]) == False\n assert candidate(target = [10, 5, 15, 20]) == False\n assert candidate(target = [987, 654, 321]) == False\n assert candidate(target = [18, 5, 7]) == False\n assert candidate(target = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == False\n assert candidate(target = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == False\n assert candidate(target = [3, 5, 11, 13, 17]) == False\n assert candidate(target = [50, 25, 50, 25, 50, 25, 50, 25, 50, 25, 50, 25, 50, 25, 50, 25, 50, 25, 50, 25]) == False\n assert candidate(target = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994]) == False\n assert candidate(target = [21, 15, 12]) == False\n assert candidate(target = [1000000000, 999999999, 999999998, 999999997, 999999996]) == False\n assert candidate(target = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == False\n assert candidate(target = [7, 14, 21, 28, 35, 42, 49]) == False\n assert candidate(target = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000001]) == False\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(target = [123456789, 987654321, 456789123, 321987654]) == False\n assert candidate(target = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == False\n assert candidate(target = [999999999, 999999999, 1]) == False\n assert candidate(target = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == False\n assert candidate(target = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == False\n assert candidate(target = [8, 13, 21, 34, 55, 89]) == False\n assert candidate(target = [100, 99, 98, 97]) == False\n assert candidate(target = [1000000000, 1, 1, 1, 1]) == False\n assert candidate(target = [123456789, 987654321, 111111111]) == False\n assert candidate(target = [17, 7, 17, 7, 17]) == False\n assert candidate(target = [4, 12, 33, 55]) == False\n assert candidate(target = [1000000000, 1000000000, 1000000000, 1]) == False\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == False\n assert candidate(target = [45, 12, 18, 30, 36, 24]) == False\n assert candidate(target = [314159265, 271828182, 161803398, 141421356]) == False\n assert candidate(target = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == False\n assert candidate(target = [7, 11, 15, 22]) == False\n assert candidate(target = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == False\n assert candidate(target = [17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17]) == False\n assert candidate(target = [999999999, 1, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == False\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000]) == False\n assert candidate(target = [33, 17, 13]) == True\n assert candidate(target = [1, 1, 2, 3, 6, 11, 20, 37, 68]) == False\n assert candidate(target = [101, 103, 107, 109]) == False\n assert candidate(target = [10, 15, 3]) == False\n assert candidate(target = [7, 18, 5, 4]) == False\n assert candidate(target = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == False\n assert candidate(target = [2, 900000000, 900000000]) == False\n assert candidate(target = [123456789, 987654321]) == False\n assert candidate(target = [100, 200, 300, 400, 500]) == False\n assert candidate(target = [1, 1000000000, 1000000000, 1000000000]) == False\n assert candidate(target = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711]) == False\n assert candidate(target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == False\n assert candidate(target = [5, 11, 19, 29, 41]) == False\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000]) == False\n assert candidate(target = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]) == False\n assert candidate(target = [10, 15, 20, 30]) == False\n assert candidate(target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == False\n assert candidate(target = [1000000000, 1000000000, 999999999, 1]) == False\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(target = [123456789, 987654321, 456789123, 321987654, 654321987, 789456123, 123789456, 456123789, 789654321, 987456123]) == False\n assert candidate(target = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1]) == False\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == False\n assert candidate(target = [3, 9, 20, 5]) == False\n assert candidate(target = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1]) == False\n assert candidate(target = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536]) == False\n assert candidate(target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == False\n"}, "metadata": {"canonical_parameter_names": ["target"], "leetcode_dataset_entry_point": "Solution().isPossible", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool isPossible(vector& target) {", "container": "Solution", "callable": "isPossible", "parameters": [{"name": "target", "type": "vector&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1356, "task_id": "sort-integers-by-the-number-of-1-bits", "difficulty": "Easy", "problem_description": "You are given an integer array arr. Sort the integers in the array in ascending order by the number of 1's in their binary representation and in case of two or more integers have the same number of 1's you have to sort them in ascending order.\nReturn the array after sorting it.\n \nExample 1:\n\nInput: arr = [0,1,2,3,4,5,6,7,8]\nOutput: [0,1,2,4,8,3,5,6,7]\nExplantion: [0] is the only integer with 0 bits.\n[1,2,4,8] all have 1 bit.\n[3,5,6] have 2 bits.\n[7] has 3 bits.\nThe sorted array by bits is [0,1,2,4,8,3,5,6,7]\n\nExample 2:\n\nInput: arr = [1024,512,256,128,64,32,16,8,4,2,1]\nOutput: [1,2,4,8,16,32,64,128,256,512,1024]\nExplantion: All integers have 1 bit in the binary representation, you should just sort them in ascending order.\n\n \nConstraints:\n\n1 <= arr.length <= 500\n0 <= arr[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [3, 7, 8, 9]) == [8, 3, 9, 7]\n assert candidate(arr = [1, 3, 5, 7, 9]) == [1, 3, 5, 9, 7]\n assert candidate(arr = [1, 0, 2, 3, 4]) == [0, 1, 2, 4, 3]\n assert candidate(arr = [3, 8, 3, 6, 5, 7, 9, 2]) == [2, 8, 3, 3, 5, 6, 9, 7]\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15]) == [1, 3, 5, 9, 7, 11, 13, 15]\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8]) == [0, 1, 2, 4, 8, 3, 5, 6, 7]\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]\n assert candidate(arr = [10, 100, 1000, 10000]) == [10, 100, 10000, 1000]\n assert candidate(arr = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]\n assert candidate(arr = [31, 15, 7, 3, 1, 0, 16, 8, 4, 2]) == [0, 1, 2, 4, 8, 16, 3, 7, 15, 31]\n assert candidate(arr = [8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191]\n assert candidate(arr = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == [3, 5, 9, 17, 7, 11, 13, 19, 21, 25, 15, 23, 27, 29, 31]\n assert candidate(arr = [123, 456, 789, 101, 234, 567, 890, 112, 345, 678]) == [112, 101, 456, 234, 345, 678, 789, 123, 567, 890]\n assert candidate(arr = [4095, 4094, 4093, 4092, 4091, 4090, 4089, 4088, 4087, 4086, 4085, 4084]) == [4084, 4088, 4085, 4086, 4089, 4090, 4092, 4087, 4091, 4093, 4094, 4095]\n assert candidate(arr = [4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095]\n assert candidate(arr = [123, 456, 789, 101, 234, 567, 890, 111, 222, 333]) == [101, 456, 234, 333, 789, 111, 123, 222, 567, 890]\n assert candidate(arr = [33, 2, 7, 5, 8, 9, 6, 11, 14]) == [2, 8, 5, 6, 9, 33, 7, 11, 14]\n assert candidate(arr = [9, 5, 3, 7, 11, 13, 19, 21, 23, 29, 31, 37, 41, 43, 47]) == [3, 5, 9, 7, 11, 13, 19, 21, 37, 41, 23, 29, 43, 31, 47]\n assert candidate(arr = [1234, 4321, 5678, 8765, 9876, 6789, 2345, 5432]) == [1234, 2345, 4321, 5432, 6789, 9876, 5678, 8765]\n assert candidate(arr = [3, 7, 8, 9, 6, 5, 2, 1, 0, 4]) == [0, 1, 2, 4, 8, 3, 5, 6, 9, 7]\n assert candidate(arr = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0]) == [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535]\n assert candidate(arr = [8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 2, 4, 8, 16, 32]) == [0, 1, 2, 4, 8, 16, 32, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191]\n assert candidate(arr = [49, 33, 25, 17, 9, 5, 3, 1, 0, 2, 6, 10, 18, 34, 66, 130]) == [0, 1, 2, 3, 5, 6, 9, 10, 17, 18, 33, 34, 66, 130, 25, 49]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [1023, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1023]\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]\n assert candidate(arr = [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == [0, 1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512, 1024, 1024, 2048, 2048]\n assert candidate(arr = [13, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [17, 18, 20, 24, 13, 19, 21, 22, 25, 26, 28, 23, 27, 29, 30]\n assert candidate(arr = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]) == [3, 5, 17, 7, 11, 13, 19, 37, 41, 23, 29, 43, 53, 31, 47]\n assert candidate(arr = [1234, 2345, 3456, 4567, 5678, 6789, 7890, 8901, 9012]) == [3456, 1234, 2345, 6789, 8901, 9012, 5678, 4567, 7890]\n assert candidate(arr = [4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 8191, 16383, 32767]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767]\n assert candidate(arr = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515, 1616, 1717]) == [101, 202, 404, 808, 1313, 1616, 707, 1414, 303, 606, 909, 1111, 1212, 505, 1010, 1717, 1515]\n assert candidate(arr = [63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48]) == [48, 49, 50, 52, 56, 51, 53, 54, 57, 58, 60, 55, 59, 61, 62, 63]\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 2, 4, 8, 16, 32, 64, 128, 256]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 3, 7, 15, 31, 63, 127, 255, 511, 1023]\n assert candidate(arr = [5, 3, 15, 7, 8, 12, 9, 6, 2, 4, 10, 14, 13, 11, 1]) == [1, 2, 4, 8, 3, 5, 6, 9, 10, 12, 7, 11, 13, 14, 15]\n assert candidate(arr = [8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0]) == [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191]\n assert candidate(arr = [9, 5, 6, 2, 31, 14, 12, 10, 28, 20, 24]) == [2, 5, 6, 9, 10, 12, 20, 24, 14, 28, 31]\n assert candidate(arr = [1001, 1010, 1011, 1100, 1101, 1110, 1111, 100, 101, 110, 111, 10, 1, 0]) == [0, 1, 10, 100, 101, 1100, 110, 1101, 1110, 111, 1111, 1001, 1010, 1011]\n assert candidate(arr = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988]) == [9988, 9992, 10000, 9989, 9990, 9993, 9994, 9996, 9991, 9995, 9997, 9998, 9999]\n assert candidate(arr = [1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == [10000, 1000, 100000, 1000000, 10000000, 100000000, 1000000000]\n assert candidate(arr = [8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191]\n assert candidate(arr = [9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111, 1110, 1101, 1100, 1011, 1010, 1001, 1000, 999, 888, 777, 666, 555, 444, 333, 222, 111, 110, 101, 100, 99, 88, 77, 66, 55, 44, 33, 22, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 4, 8, 3, 5, 6, 9, 10, 33, 66, 7, 11, 22, 44, 88, 100, 77, 99, 101, 777, 1100, 55, 110, 333, 555, 666, 1101, 1110, 3333, 6666, 111, 222, 444, 888, 1000, 1111, 2222, 4444, 8888, 1001, 1010, 7777, 999, 1011, 5555, 9999]\n assert candidate(arr = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 0]) == [0, 1, 3, 7, 15, 31, 62, 125, 250, 500, 1000]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]) == [1, 2, 4, 8, 16, 32, 3, 5, 6, 9, 10, 12, 17, 18, 20, 24, 33, 34, 36, 40, 48, 7, 11, 13, 14, 19, 21, 22, 25, 26, 28, 35, 37, 38, 41, 42, 44, 49, 50, 52, 56, 15, 23, 27, 29, 30, 39, 43, 45, 46, 51, 53, 54, 57, 58, 60, 31, 47, 55, 59, 61, 62, 63]\n assert candidate(arr = [31, 15, 7, 3, 1, 0, 32, 16, 8, 4, 2]) == [0, 1, 2, 4, 8, 16, 32, 3, 7, 15, 31]\n assert candidate(arr = [15, 31, 63, 127, 255, 511, 1023, 2047]) == [15, 31, 63, 127, 255, 511, 1023, 2047]\n assert candidate(arr = [3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767]) == [3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767]\n assert candidate(arr = [500, 125, 62, 31, 15, 7, 3, 1, 0, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 3, 7, 15, 31, 62, 125, 500]\n assert candidate(arr = [129, 258, 516, 1032, 2064, 4128, 8256]) == [129, 258, 516, 1032, 2064, 4128, 8256]\n assert candidate(arr = [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]\n assert candidate(arr = [1001, 1010, 1100, 1101, 1110, 1111, 999, 998, 997, 996, 995, 994]) == [1100, 1101, 1110, 994, 996, 1111, 995, 997, 998, 1001, 1010, 999]\n assert candidate(arr = [9, 5, 1, 3, 7, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == [1, 3, 5, 9, 17, 7, 11, 13, 19, 21, 25, 15, 23, 27, 29, 31]\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 3, 5, 6, 7, 9, 10, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 3, 5, 6, 9, 10, 12, 17, 18, 20, 24, 7, 13, 14, 19, 21, 22, 25, 26, 28, 15, 23, 27, 29, 30]\n assert candidate(arr = [64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == [64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]\n assert candidate(arr = [32, 16, 8, 4, 2, 1, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]\n assert candidate(arr = [13, 29, 11, 7, 3, 1, 0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 3, 7, 11, 13, 29]\n assert candidate(arr = [1001, 1100, 1010, 1110, 1000, 1111, 1101, 1011, 111, 110, 101, 11, 10, 1, 0]) == [0, 1, 10, 11, 101, 1100, 110, 1101, 1110, 111, 1000, 1111, 1001, 1010, 1011]\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == [1, 3, 5, 9, 17, 7, 11, 13, 19, 21, 25, 15, 23, 27, 29, 31]\n assert candidate(arr = [9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111, 1010, 1101, 1000, 111, 110, 101, 11, 10, 1, 0]) == [0, 1, 10, 11, 101, 110, 1101, 3333, 6666, 111, 1000, 1111, 2222, 4444, 8888, 1010, 7777, 5555, 9999]\n assert candidate(arr = [8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 4, 8, 16, 3, 5, 6, 9, 10, 12, 17, 18, 20, 7, 11, 13, 14, 19, 15]\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]\n assert candidate(arr = [1234, 4321, 5678, 8765, 9876, 6789, 3456, 7890]) == [3456, 1234, 4321, 6789, 9876, 5678, 8765, 7890]\n assert candidate(arr = [31, 15, 7, 3, 1, 0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 3, 7, 15, 31]\n assert candidate(arr = [5, 3, 15, 7, 11, 13, 19, 21, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == [3, 5, 7, 11, 13, 19, 21, 37, 41, 67, 73, 97, 15, 23, 29, 43, 53, 71, 83, 89, 31, 47, 59, 61, 79]\n assert candidate(arr = [31, 29, 28, 27, 26, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [1, 3, 5, 9, 17, 7, 11, 13, 19, 21, 25, 26, 28, 15, 23, 27, 29, 31]\n assert candidate(arr = [33, 65, 129, 257, 513, 1025, 2049, 4097, 8193, 16385, 32769, 65537, 131073, 262145, 524289, 1048577, 2097153, 4194305, 8388609, 16777217]) == [33, 65, 129, 257, 513, 1025, 2049, 4097, 8193, 16385, 32769, 65537, 131073, 262145, 524289, 1048577, 2097153, 4194305, 8388609, 16777217]\n assert candidate(arr = [3, 5, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == [3, 5, 6, 9, 12, 18, 24, 33, 36, 21, 42, 15, 27, 30, 39, 45]\n assert candidate(arr = [1234, 4321, 2345, 5432, 3456, 6543, 4567, 7654, 5678, 8765, 6789, 9876, 7890, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 1, 2, 4, 8, 3, 5, 6, 9, 10, 12, 7, 11, 13, 14, 15, 3456, 1234, 2345, 4321, 5432, 6789, 9876, 5678, 8765, 4567, 6543, 7890, 7654]\n assert candidate(arr = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989]) == [9992, 10000, 9989, 9990, 9993, 9994, 9996, 9991, 9995, 9997, 9998, 9999]\n assert candidate(arr = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == [17, 18, 20, 24, 19, 21, 22, 25, 26, 28, 23, 27, 29, 30, 31]\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0]) == [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]\n assert candidate(arr = [777, 888, 999, 1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999]) == [777, 3333, 6666, 888, 1111, 2222, 4444, 8888, 7777, 999, 5555, 9999]\n assert candidate(arr = [32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0]) == [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767]\n assert candidate(arr = [9, 5, 3, 7, 11, 13, 14, 19, 21, 22, 25, 29]) == [3, 5, 9, 7, 11, 13, 14, 19, 21, 22, 25, 29]\n assert candidate(arr = [1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012]) == [1008, 1001, 1002, 1004, 1009, 1010, 1012, 1003, 1005, 1006, 1011, 1007]\n assert candidate(arr = [9, 5, 6, 7, 8, 4, 2, 3, 1, 0]) == [0, 1, 2, 4, 8, 3, 5, 6, 9, 7]\n assert candidate(arr = [1431655765, 1431655764, 1431655763, 1431655762, 1431655761, 1431655760, 1431655759, 1431655758, 1431655757, 1431655756, 1431655755, 1431655754, 1431655753, 1431655752, 1431655751, 1431655750, 1431655749]) == [1431655752, 1431655760, 1431655749, 1431655750, 1431655753, 1431655754, 1431655756, 1431655761, 1431655762, 1431655764, 1431655751, 1431655755, 1431655757, 1431655758, 1431655763, 1431655765, 1431655759]\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == [100, 200, 400, 800, 300, 600, 900, 1100, 1200, 500, 700, 1000]\n assert candidate(arr = [13, 7, 14, 28, 35, 42, 56, 70, 84, 98]) == [7, 13, 14, 28, 35, 42, 56, 70, 84, 98]\n assert candidate(arr = [9, 5, 3, 7, 2, 8, 6, 4, 1, 0, 11, 13, 14, 10, 12]) == [0, 1, 2, 4, 8, 3, 5, 6, 9, 10, 12, 7, 11, 13, 14]\n assert candidate(arr = [8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == [0, 1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512, 1024, 1024, 2048, 2048, 4096, 4096, 8192, 8192]\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [0, 1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512, 1024, 1024]\n assert candidate(arr = [500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1, 0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 3, 6, 12, 25, 50, 100, 200, 400, 300, 500]\n assert candidate(arr = [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 1023, 511]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 511, 1023]\n assert candidate(arr = [1431655765, 2863311530, 1431655764, 715827882, 357913941, 178956970, 89478485, 44739242, 22369621, 11184810, 5592405, 2796202, 1398101, 699050, 349525, 174762, 87381, 43690, 21845, 10922, 5461, 2730, 1365, 682, 341, 170, 85, 42, 21, 10, 5, 2, 1, 0]) == [0, 1, 2, 5, 10, 21, 42, 85, 170, 341, 682, 1365, 2730, 5461, 10922, 21845, 43690, 87381, 174762, 349525, 699050, 1398101, 2796202, 5592405, 11184810, 22369621, 44739242, 89478485, 178956970, 357913941, 715827882, 1431655764, 1431655765, 2863311530]\n assert candidate(arr = [15, 7, 3, 1, 0, 8, 16, 4]) == [0, 1, 4, 8, 16, 3, 7, 15]\n assert candidate(arr = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == [9009, 1001, 2002, 4004, 5005, 8008, 3003, 6006, 7007]\n assert candidate(arr = [1374, 8314, 5296, 7916, 4154, 9666, 8078, 2933, 269, 9218, 4688, 7266, 2650, 9016, 1350, 8202]) == [8202, 9218, 269, 4688, 1350, 4154, 5296, 2650, 7266, 8314, 9016, 9666, 1374, 2933, 7916, 8078]\n assert candidate(arr = [1234, 4321, 5678, 8765, 2345, 5432, 6789, 9876, 3456, 6543, 7890, 8907]) == [3456, 1234, 2345, 4321, 5432, 6789, 9876, 5678, 8765, 8907, 6543, 7890]\n assert candidate(arr = [32767, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0]) == [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32767]\n assert candidate(arr = [13, 9, 6, 5, 12, 10, 3, 7, 2, 8, 4, 1, 0]) == [0, 1, 2, 4, 8, 3, 5, 6, 9, 10, 12, 7, 13]\n assert candidate(arr = [31, 15, 7, 3, 1, 0, 2, 4, 8, 16]) == [0, 1, 2, 4, 8, 16, 3, 7, 15, 31]\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]) == [0, 1, 1, 3, 3, 7, 7, 15, 15, 31, 31, 63, 63, 127, 127, 255, 255, 511, 511, 1023, 1023]\n assert candidate(arr = [5, 3, 1, 9, 7, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == [1, 3, 5, 9, 17, 33, 7, 11, 13, 19, 21, 25, 35, 37, 15, 23, 27, 29, 39, 31]\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().sortByBits", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector sortByBits(vector& arr) {", "container": "Solution", "callable": "sortByBits", "parameters": [{"name": "arr", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1358, "task_id": "number-of-substrings-containing-all-three-characters", "difficulty": "Medium", "problem_description": "Given a string s consisting only of characters a, b and c.\nReturn the number of substrings containing at least one occurrence of all these characters a, b and c.\n \nExample 1:\n\nInput: s = \"abcabc\"\nOutput: 10\nExplanation: The substrings containing at least one occurrence of the characters a, b and c are \"abc\", \"abca\", \"abcab\", \"abcabc\", \"bca\", \"bcab\", \"bcabc\", \"cab\", \"cabc\" and \"abc\" (again). \n\nExample 2:\n\nInput: s = \"aaacb\"\nOutput: 3\nExplanation: The substrings containing at least one occurrence of the characters a, b and c are \"aaacb\", \"aacb\" and \"acb\". \n\nExample 3:\n\nInput: s = \"abc\"\nOutput: 1\n\n \nConstraints:\n\n3 <= s.length <= 5 x 10^4\ns only consists of a, b or c characters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaabbbccc\") == 9\n assert candidate(s = \"abcba\") == 5\n assert candidate(s = \"cba\") == 1\n assert candidate(s = \"cbaacb\") == 8\n assert candidate(s = \"bbbacbac\") == 18\n assert candidate(s = \"ccccabc\") == 9\n assert candidate(s = \"abcabcabc\") == 28\n assert candidate(s = \"abcabcabcabc\") == 55\n assert candidate(s = \"aabbc\") == 2\n assert candidate(s = \"cccbaab\") == 9\n assert candidate(s = \"aabbbc\") == 2\n assert candidate(s = \"aabcbc\") == 6\n assert candidate(s = \"abcabc\") == 10\n assert candidate(s = \"aabbaacc\") == 8\n assert candidate(s = \"abacbc\") == 8\n assert candidate(s = \"abacabacabc\") == 41\n assert candidate(s = \"aaaabbbbcccc\") == 16\n assert candidate(s = \"ccbaaabb\") == 10\n assert candidate(s = \"baccab\") == 7\n assert candidate(s = \"bca\") == 1\n assert candidate(s = \"abc\") == 1\n assert candidate(s = \"ccccbaaa\") == 12\n assert candidate(s = \"aaacb\") == 3\n assert candidate(s = \"ccccbaab\") == 12\n assert candidate(s = \"abcababc\") == 18\n assert candidate(s = \"aabbcc\") == 4\n assert candidate(s = \"aaaabbbccc\") == 12\n assert candidate(s = \"abacbac\") == 14\n assert candidate(s = \"abcacbacbacbabc\") == 89\n assert candidate(s = \"aabbcacabcabc\") == 59\n assert candidate(s = \"ccabababc\") == 17\n assert candidate(s = \"abacbabacbabacbab\") == 112\n assert candidate(s = \"aabccbabcbacbac\") == 85\n assert candidate(s = \"abcabcabccba\") == 52\n assert candidate(s = \"aabbccbaa\") == 18\n assert candidate(s = \"aaabbbcccbbbccc\") == 27\n assert candidate(s = \"acbacbacbacbacb\") == 91\n assert candidate(s = \"abacbacbacb\") == 44\n assert candidate(s = \"aabcbacbacbabc\") == 75\n assert candidate(s = \"bcabcabcabcabc\") == 78\n assert candidate(s = \"aaabbbcccabcabcabc\") == 115\n assert candidate(s = \"abacbacbacbacbabcababcabc\") == 271\n assert candidate(s = \"acbacbacbacb\") == 55\n assert candidate(s = \"abacbacbacbabc\") == 76\n assert candidate(s = \"cccbbbaaa\") == 9\n assert candidate(s = \"caabcbacbacb\") == 52\n assert candidate(s = \"abbbcccaabbbabc\") == 59\n assert candidate(s = \"abacbcabc\") == 26\n assert candidate(s = \"aaabbbcccbbbaaa\") == 45\n assert candidate(s = \"bacbacbacbacb\") == 66\n assert candidate(s = \"cabcbacbacbabcb\") == 88\n assert candidate(s = \"abacbcacab\") == 31\n assert candidate(s = \"bbbbbbcccaaa\") == 18\n assert candidate(s = \"aaaaaaaaaabbbccc\") == 30\n assert candidate(s = \"ccbbbaaabbbccc\") == 36\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 406\n assert candidate(s = \"abcabcabcab\") == 45\n assert candidate(s = \"aabbaaccabcabcabc\") == 104\n assert candidate(s = \"bacbacbacbacbacba\") == 120\n assert candidate(s = \"ccccbbbaaaaa\") == 20\n assert candidate(s = \"abababababababab\") == 0\n assert candidate(s = \"abacbcabcabcab\") == 76\n assert candidate(s = \"abababababab\") == 0\n assert candidate(s = \"cacbacbacbac\") == 54\n assert candidate(s = \"cabbacbac\") == 25\n assert candidate(s = \"aabbaacccbaab\") == 45\n assert candidate(s = \"abcabcabcabcabcabc\") == 136\n assert candidate(s = \"cbacbacbacbac\") == 66\n assert candidate(s = \"aabbbcccaaaabbbccc\") == 86\n assert candidate(s = \"bacbacbacbacba\") == 78\n assert candidate(s = \"aabacababaac\") == 40\n assert candidate(s = \"abcababccbaabc\") == 69\n assert candidate(s = \"ababababcabcab\") == 57\n assert candidate(s = \"aaabbbcccbbb\") == 18\n assert candidate(s = \"abcabcabcabcababc\") == 117\n assert candidate(s = \"abccbaabccbaab\") == 66\n assert candidate(s = \"baccabaccabacc\") == 69\n assert candidate(s = \"abacbcacbacb\") == 52\n assert candidate(s = \"cccccbbaaaabbbccc\") == 68\n assert candidate(s = \"bbcccaabbcccaab\") == 65\n assert candidate(s = \"aabbbccccaaaabbbbccc\") == 103\n assert candidate(s = \"abababab\") == 0\n assert candidate(s = \"cbacbacbacbacbacbacbacbacbacbacb\") == 465\n assert candidate(s = \"abcbaabcbaabc\") == 58\n assert candidate(s = \"aabcbabacabc\") == 49\n assert candidate(s = \"aabacbacbacbac\") == 75\n assert candidate(s = \"aabbaaccbbacbbacaacabcbacbacbacbac\") == 498\n assert candidate(s = \"abacbabacbabac\") == 71\n assert candidate(s = \"aabbbcccaabbbabc\") == 70\n assert candidate(s = \"aaaabbccccabbbccc\") == 85\n assert candidate(s = \"cccaaaabbbcccbbb\") == 51\n assert candidate(s = \"ccccbbaaaabc\") == 30\n assert candidate(s = \"acbacbacbacbacbacbacbacbacbacbac\") == 465\n assert candidate(s = \"abcbbccaaa\") == 20\n assert candidate(s = \"cccaabbbaaacc\") == 34\n assert candidate(s = \"ccccccccabbaabbcbbb\") == 100\n assert candidate(s = \"cccbababac\") == 23\n assert candidate(s = \"ccccabcabcabc\") == 60\n assert candidate(s = \"aabacbababcabc\") == 69\n assert candidate(s = \"aaabbbcccbbbaaabbbc\") == 87\n assert candidate(s = \"abccabccabccabc\") == 85\n assert candidate(s = \"abcbacbacbacbaca\") == 103\n assert candidate(s = \"abcabcabcabacbacb\") == 119\n assert candidate(s = \"aabbbcccabcabcabc\") == 103\n assert candidate(s = \"abacbcabcabc\") == 53\n assert candidate(s = \"aabbaaccaabbcc\") == 52\n assert candidate(s = \"abcabcabacbcab\") == 76\n assert candidate(s = \"aabbbccc\") == 6\n assert candidate(s = \"aabbaacccbbcabab\") == 77\n assert candidate(s = \"babababacacacacbcbbcbcbcbacbacbacb\") == 441\n assert candidate(s = \"cacbacbacbacbacbac\") == 135\n assert candidate(s = \"cccbbaaaabacbacb\") == 78\n assert candidate(s = \"ccccbbbaaa\") == 12\n assert candidate(s = \"aaaaaaaaaabcabcabcabcabc\") == 208\n assert candidate(s = \"aabbbccccaaa\") == 23\n assert candidate(s = \"abacbacbac\") == 35\n assert candidate(s = \"aabbbaccccba\") == 36\n assert candidate(s = \"ccbaabccababab\") == 62\n assert candidate(s = \"ccccbaabccc\") == 33\n assert candidate(s = \"ccccbaa\") == 8\n assert candidate(s = \"bacabcabcabcabcabcabcabc\") == 252\n assert candidate(s = \"ccccccaaaabbbccc\") == 48\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabc\") == 496\n assert candidate(s = \"abacbabcc\") == 25\n assert candidate(s = \"abacbacbacbacb\") == 77\n assert candidate(s = \"bacbacbacbacbacbacbac\") == 190\n assert candidate(s = \"abcabcabcabcabc\") == 91\n assert candidate(s = \"bbaacccaaaabbccba\") == 76\n assert candidate(s = \"aaaaabbbbbccccc\") == 25\n assert candidate(s = \"aaabbbcccabc\") == 34\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().numberOfSubstrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numberOfSubstrings(string s) {", "container": "Solution", "callable": "numberOfSubstrings", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1359, "task_id": "count-all-valid-pickup-and-delivery-options", "difficulty": "Hard", "problem_description": "Given n orders, each order consists of a pickup and a delivery service.\nCount all valid pickup/delivery possible sequences such that delivery(i) is always after of pickup(i). \nSince the answer may be too large, return it modulo 10^9 + 7.\n \nExample 1:\n\nInput: n = 1\nOutput: 1\nExplanation: Unique order (P1, D1), Delivery 1 always is after of Pickup 1.\n\nExample 2:\n\nInput: n = 2\nOutput: 6\nExplanation: All possible orders: \n(P1,P2,D1,D2), (P1,P2,D2,D1), (P1,D1,P2,D2), (P2,P1,D1,D2), (P2,P1,D2,D1) and (P2,D2,P1,D1).\nThis is an invalid order (P1,D2,P2,D1) because Pickup 2 is after of Delivery 2.\n\nExample 3:\n\nInput: n = 3\nOutput: 90\n\n \nConstraints:\n\n1 <= n <= 500\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 90\n assert candidate(n = 250) == 418733499\n assert candidate(n = 100) == 14159051\n assert candidate(n = 4) == 2520\n assert candidate(n = 2) == 6\n assert candidate(n = 20) == 580270580\n assert candidate(n = 1) == 1\n assert candidate(n = 500) == 764678010\n assert candidate(n = 50) == 784760423\n assert candidate(n = 10) == 850728840\n assert candidate(n = 5) == 113400\n assert candidate(n = 12) == 67543367\n assert candidate(n = 125) == 129345050\n assert candidate(n = 110) == 120658916\n assert candidate(n = 300) == 234038968\n assert candidate(n = 60) == 988537746\n assert candidate(n = 30) == 920731808\n assert candidate(n = 450) == 586675271\n assert candidate(n = 80) == 189044563\n assert candidate(n = 175) == 82390790\n assert candidate(n = 495) == 498394413\n assert candidate(n = 8) == 729647433\n assert candidate(n = 18) == 368349166\n assert candidate(n = 75) == 149163518\n assert candidate(n = 350) == 436707893\n assert candidate(n = 150) == 707081203\n assert candidate(n = 15) == 621371750\n assert candidate(n = 200) == 880584563\n assert candidate(n = 400) == 467993882\n assert candidate(n = 499) == 496638171\n assert candidate(n = 55) == 22089728\n assert candidate(n = 25) == 586091532\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().countOrders", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countOrders(int n) {", "container": "Solution", "callable": "countOrders", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1360, "task_id": "number-of-days-between-two-dates", "difficulty": "Easy", "problem_description": "Write a program to count the number of days between two dates.\nThe two dates are given as strings, their format is YYYY-MM-DD as shown in the examples.\n \nExample 1:\nInput: date1 = \"2019-06-29\", date2 = \"2019-06-30\"\nOutput: 1\nExample 2:\nInput: date1 = \"2020-01-15\", date2 = \"2019-12-31\"\nOutput: 15\n\n \nConstraints:\n\nThe given dates are valid dates between the years 1971 and 2100.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(date1 = \"2019-02-28\",date2 = \"2019-03-01\") == 1\n assert candidate(date1 = \"2020-01-15\",date2 = \"2019-12-31\") == 15\n assert candidate(date1 = \"2000-03-01\",date2 = \"2000-02-29\") == 1\n assert candidate(date1 = \"2023-10-01\",date2 = \"2023-10-02\") == 1\n assert candidate(date1 = \"2022-02-28\",date2 = \"2022-03-01\") == 1\n assert candidate(date1 = \"2012-01-01\",date2 = \"2012-12-31\") == 365\n assert candidate(date1 = \"2021-10-10\",date2 = \"2021-10-10\") == 0\n assert candidate(date1 = \"2021-10-01\",date2 = \"2021-10-10\") == 9\n assert candidate(date1 = \"2020-02-28\",date2 = \"2020-03-01\") == 2\n assert candidate(date1 = \"1971-01-01\",date2 = \"2100-12-31\") == 47481\n assert candidate(date1 = \"2019-06-29\",date2 = \"2019-06-30\") == 1\n assert candidate(date1 = \"2023-01-01\",date2 = \"2023-12-31\") == 364\n assert candidate(date1 = \"2023-01-01\",date2 = \"2023-01-01\") == 0\n assert candidate(date1 = \"2050-06-15\",date2 = \"2050-06-14\") == 1\n assert candidate(date1 = \"2023-10-01\",date2 = \"2023-10-01\") == 0\n assert candidate(date1 = \"2016-02-29\",date2 = \"2016-02-28\") == 1\n assert candidate(date1 = \"2000-02-28\",date2 = \"2000-03-01\") == 2\n assert candidate(date1 = \"2023-04-10\",date2 = \"2023-04-01\") == 9\n assert candidate(date1 = \"2000-02-29\",date2 = \"2000-03-01\") == 1\n assert candidate(date1 = \"2100-02-28\",date2 = \"2100-03-01\") == 1\n assert candidate(date1 = \"2023-10-01\",date2 = \"2023-09-01\") == 30\n assert candidate(date1 = \"1971-01-02\",date2 = \"1971-01-01\") == 1\n assert candidate(date1 = \"2012-02-29\",date2 = \"2012-03-31\") == 31\n assert candidate(date1 = \"1985-04-12\",date2 = \"2023-07-25\") == 13983\n assert candidate(date1 = \"1972-02-29\",date2 = \"1972-03-01\") == 1\n assert candidate(date1 = \"2017-10-01\",date2 = \"2018-10-01\") == 365\n assert candidate(date1 = \"2023-06-04\",date2 = \"2023-06-04\") == 0\n assert candidate(date1 = \"2004-02-28\",date2 = \"2004-03-01\") == 2\n assert candidate(date1 = \"2021-06-30\",date2 = \"2021-09-30\") == 92\n assert candidate(date1 = \"2004-03-01\",date2 = \"2004-02-29\") == 1\n assert candidate(date1 = \"2025-01-01\",date2 = \"2026-01-01\") == 365\n assert candidate(date1 = \"2024-03-01\",date2 = \"2024-02-29\") == 1\n assert candidate(date1 = \"2023-11-30\",date2 = \"2023-12-01\") == 1\n assert candidate(date1 = \"2100-01-01\",date2 = \"2100-12-31\") == 364\n assert candidate(date1 = \"2020-02-29\",date2 = \"2020-03-01\") == 1\n assert candidate(date1 = \"2015-06-30\",date2 = \"2016-06-30\") == 366\n assert candidate(date1 = \"1980-02-29\",date2 = \"1981-02-28\") == 365\n assert candidate(date1 = \"2099-12-31\",date2 = \"2100-01-01\") == 1\n assert candidate(date1 = \"2023-06-01\",date2 = \"2023-07-01\") == 30\n assert candidate(date1 = \"2100-12-31\",date2 = \"2099-12-31\") == 365\n assert candidate(date1 = \"2020-02-01\",date2 = \"2021-02-01\") == 366\n assert candidate(date1 = \"2000-01-01\",date2 = \"2100-12-31\") == 36889\n assert candidate(date1 = \"2016-02-29\",date2 = \"2017-02-28\") == 365\n assert candidate(date1 = \"2020-01-31\",date2 = \"2020-02-29\") == 29\n assert candidate(date1 = \"1980-02-28\",date2 = \"1980-03-01\") == 2\n assert candidate(date1 = \"2050-11-15\",date2 = \"2050-11-15\") == 0\n assert candidate(date1 = \"2099-12-30\",date2 = \"2100-01-01\") == 2\n assert candidate(date1 = \"2024-11-01\",date2 = \"2023-11-01\") == 366\n assert candidate(date1 = \"2016-06-30\",date2 = \"2016-06-01\") == 29\n assert candidate(date1 = \"2023-02-28\",date2 = \"2024-02-29\") == 366\n assert candidate(date1 = \"2019-01-31\",date2 = \"2019-02-28\") == 28\n assert candidate(date1 = \"2021-01-01\",date2 = \"2021-12-31\") == 364\n assert candidate(date1 = \"2024-02-28\",date2 = \"2024-02-29\") == 1\n assert candidate(date1 = \"2004-12-31\",date2 = \"2005-01-01\") == 1\n assert candidate(date1 = \"2023-06-05\",date2 = \"2023-06-04\") == 1\n assert candidate(date1 = \"2016-02-28\",date2 = \"2016-02-29\") == 1\n assert candidate(date1 = \"2023-04-30\",date2 = \"2023-05-01\") == 1\n assert candidate(date1 = \"2019-12-31\",date2 = \"2020-01-01\") == 1\n assert candidate(date1 = \"2025-12-31\",date2 = \"2026-01-01\") == 1\n assert candidate(date1 = \"2023-06-30\",date2 = \"2023-07-01\") == 1\n assert candidate(date1 = \"2000-02-29\",date2 = \"2004-02-29\") == 1461\n assert candidate(date1 = \"2021-12-31\",date2 = \"2022-01-01\") == 1\n assert candidate(date1 = \"2024-02-28\",date2 = \"2024-03-01\") == 2\n assert candidate(date1 = \"2077-07-04\",date2 = \"2077-07-05\") == 1\n assert candidate(date1 = \"2018-04-30\",date2 = \"2018-05-01\") == 1\n assert candidate(date1 = \"2019-10-15\",date2 = \"2020-10-15\") == 366\n assert candidate(date1 = \"2004-02-29\",date2 = \"2004-03-01\") == 1\n assert candidate(date1 = \"2012-12-31\",date2 = \"2013-01-01\") == 1\n assert candidate(date1 = \"1999-02-28\",date2 = \"1999-03-01\") == 1\n assert candidate(date1 = \"2023-10-01\",date2 = \"2023-09-29\") == 2\n assert candidate(date1 = \"2012-02-28\",date2 = \"2012-03-01\") == 2\n assert candidate(date1 = \"2020-03-01\",date2 = \"2020-02-28\") == 2\n assert candidate(date1 = \"2020-02-29\",date2 = \"2019-02-28\") == 366\n assert candidate(date1 = \"2000-01-01\",date2 = \"2000-12-31\") == 365\n assert candidate(date1 = \"2023-10-15\",date2 = \"2024-10-15\") == 366\n assert candidate(date1 = \"2023-08-31\",date2 = \"2023-09-01\") == 1\n assert candidate(date1 = \"2024-02-29\",date2 = \"2024-03-01\") == 1\n assert candidate(date1 = \"2015-06-15\",date2 = \"2015-06-14\") == 1\n assert candidate(date1 = \"2000-01-01\",date2 = \"2004-01-01\") == 1461\n assert candidate(date1 = \"1999-12-31\",date2 = \"1971-01-01\") == 10591\n assert candidate(date1 = \"2024-12-31\",date2 = \"2025-01-01\") == 1\n assert candidate(date1 = \"1980-06-15\",date2 = \"1980-07-15\") == 30\n assert candidate(date1 = \"2023-03-01\",date2 = \"2023-02-28\") == 1\n assert candidate(date1 = \"2023-10-02\",date2 = \"2023-10-01\") == 1\n assert candidate(date1 = \"2020-03-01\",date2 = \"2020-02-29\") == 1\n assert candidate(date1 = \"2050-06-15\",date2 = \"2050-07-15\") == 30\n assert candidate(date1 = \"2021-06-01\",date2 = \"2022-06-01\") == 365\n assert candidate(date1 = \"2023-12-31\",date2 = \"2023-01-01\") == 364\n assert candidate(date1 = \"2019-12-31\",date2 = \"2020-01-31\") == 31\n assert candidate(date1 = \"2023-05-31\",date2 = \"2023-06-01\") == 1\n assert candidate(date1 = \"1971-01-01\",date2 = \"1971-01-02\") == 1\n assert candidate(date1 = \"1996-02-29\",date2 = \"1997-02-28\") == 365\n assert candidate(date1 = \"2023-12-31\",date2 = \"2024-01-01\") == 1\n assert candidate(date1 = \"2019-11-11\",date2 = \"2020-02-29\") == 110\n assert candidate(date1 = \"2100-12-31\",date2 = \"2100-01-01\") == 364\n assert candidate(date1 = \"2023-01-31\",date2 = \"2023-02-28\") == 28\n assert candidate(date1 = \"2100-12-31\",date2 = \"2100-12-30\") == 1\n assert candidate(date1 = \"2023-09-30\",date2 = \"2023-10-01\") == 1\n assert candidate(date1 = \"2023-10-31\",date2 = \"2023-11-01\") == 1\n assert candidate(date1 = \"2023-11-05\",date2 = \"2024-11-05\") == 366\n assert candidate(date1 = \"2019-02-28\",date2 = \"2020-02-29\") == 366\n assert candidate(date1 = \"1972-02-28\",date2 = \"1972-02-29\") == 1\n assert candidate(date1 = \"2023-10-15\",date2 = \"2023-10-15\") == 0\n assert candidate(date1 = \"2019-06-15\",date2 = \"2019-06-14\") == 1\n assert candidate(date1 = \"1996-02-28\",date2 = \"1996-02-29\") == 1\n assert candidate(date1 = \"1996-04-15\",date2 = \"1996-05-15\") == 30\n assert candidate(date1 = \"1980-03-01\",date2 = \"1980-02-29\") == 1\n assert candidate(date1 = \"2023-10-15\",date2 = \"2022-10-15\") == 365\n assert candidate(date1 = \"2024-03-15\",date2 = \"2024-03-01\") == 14\n assert candidate(date1 = \"2024-03-01\",date2 = \"2025-03-01\") == 365\n assert candidate(date1 = \"2023-06-04\",date2 = \"2023-06-05\") == 1\n assert candidate(date1 = \"2022-12-31\",date2 = \"2023-01-01\") == 1\n assert candidate(date1 = \"2000-01-01\",date2 = \"2001-01-01\") == 366\n assert candidate(date1 = \"2023-11-01\",date2 = \"2024-11-01\") == 366\n assert candidate(date1 = \"1971-01-01\",date2 = \"1971-12-31\") == 364\n assert candidate(date1 = \"2050-12-31\",date2 = \"2051-01-01\") == 1\n assert candidate(date1 = \"2000-02-29\",date2 = \"1999-02-28\") == 366\n assert candidate(date1 = \"2004-02-28\",date2 = \"2004-02-29\") == 1\n assert candidate(date1 = \"2020-01-01\",date2 = \"2020-12-31\") == 365\n assert candidate(date1 = \"2012-02-29\",date2 = \"2012-03-01\") == 1\n assert candidate(date1 = \"2024-02-28\",date2 = \"2025-02-28\") == 366\n assert candidate(date1 = \"2012-02-29\",date2 = \"2013-02-28\") == 365\n assert candidate(date1 = \"2020-02-28\",date2 = \"2020-02-29\") == 1\n assert candidate(date1 = \"2016-06-01\",date2 = \"2016-06-30\") == 29\n assert candidate(date1 = \"2008-02-29\",date2 = \"2009-02-28\") == 365\n assert candidate(date1 = \"2023-02-14\",date2 = \"2023-03-14\") == 28\n assert candidate(date1 = \"2023-07-31\",date2 = \"2023-08-01\") == 1\n assert candidate(date1 = \"1987-07-04\",date2 = \"1999-07-04\") == 4383\n assert candidate(date1 = \"2023-10-01\",date2 = \"2023-09-30\") == 1\n assert candidate(date1 = \"2016-02-28\",date2 = \"2016-03-01\") == 2\n assert candidate(date1 = \"1980-02-29\",date2 = \"1980-03-01\") == 1\n assert candidate(date1 = \"2025-06-15\",date2 = \"2026-06-15\") == 365\n assert candidate(date1 = \"2023-01-01\",date2 = \"2024-01-01\") == 365\n assert candidate(date1 = \"2023-05-05\",date2 = \"2022-05-05\") == 365\n assert candidate(date1 = \"2023-09-29\",date2 = \"2023-10-01\") == 2\n assert candidate(date1 = \"2016-02-29\",date2 = \"2016-03-01\") == 1\n assert candidate(date1 = \"1999-12-31\",date2 = \"2000-01-01\") == 1\n assert candidate(date1 = \"2019-09-15\",date2 = \"2023-09-15\") == 1461\n"}, "metadata": {"canonical_parameter_names": ["date1", "date2"], "leetcode_dataset_entry_point": "Solution().daysBetweenDates", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int daysBetweenDates(string date1, string date2) {", "container": "Solution", "callable": "daysBetweenDates", "parameters": [{"name": "date1", "type": "string"}, {"name": "date2", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1361, "task_id": "validate-binary-tree-nodes", "difficulty": "Medium", "problem_description": "You have n binary tree nodes numbered from 0 to n - 1 where node i has two children leftChild[i] and rightChild[i], return true if and only if all the given nodes form exactly one valid binary tree.\nIf node i has no left child then leftChild[i] will equal -1, similarly for the right child.\nNote that the nodes have no values and that we only use the node numbers in this problem.\n \nExample 1:\n\n\nInput: n = 4, leftChild = [1,-1,3,-1], rightChild = [2,-1,-1,-1]\nOutput: true\n\nExample 2:\n\n\nInput: n = 4, leftChild = [1,-1,3,-1], rightChild = [2,3,-1,-1]\nOutput: false\n\nExample 3:\n\n\nInput: n = 2, leftChild = [1,0], rightChild = [-1,-1]\nOutput: false\n\n \nConstraints:\n\nn == leftChild.length == rightChild.length\n1 <= n <= 104\n-1 <= leftChild[i], rightChild[i] <= n - 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 2,leftChild = [1, 0],rightChild = [-1, -1]) == False\n assert candidate(n = 3,leftChild = [1, -1, -1],rightChild = [2, -1, -1]) == True\n assert candidate(n = 3,leftChild = [1, 0, -1],rightChild = [-1, -1, -1]) == False\n assert candidate(n = 1,leftChild = [-1],rightChild = [-1]) == True\n assert candidate(n = 4,leftChild = [1, -1, 3, -1],rightChild = [2, -1, -1, -1]) == True\n assert candidate(n = 4,leftChild = [1, -1, 3, -1],rightChild = [2, 3, -1, -1]) == False\n assert candidate(n = 5,leftChild = [1, 2, 3, 4, -1],rightChild = [-1, -1, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, 4, 5, -1],rightChild = [-1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, -1, -1, -1],rightChild = [4, 5, -1, -1, -1, -1]) == True\n assert candidate(n = 3,leftChild = [1, 2, -1],rightChild = [-1, -1, 1]) == False\n assert candidate(n = 5,leftChild = [1, 3, -1, -1, -1],rightChild = [2, 4, -1, -1, -1]) == True\n assert candidate(n = 5,leftChild = [1, 2, -1, -1, -1],rightChild = [3, 4, -1, -1, -1]) == True\n assert candidate(n = 13,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, -1]) == True\n assert candidate(n = 5,leftChild = [1, 2, -1, -1, -1],rightChild = [3, 4, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, 4, 5, -1],rightChild = [-1, -1, -1, -1, 3, -1]) == False\n assert candidate(n = 5,leftChild = [1, 2, -1, -1, -1],rightChild = [2, -1, -1, -1, -1]) == False\n assert candidate(n = 5,leftChild = [1, -1, 2, 0, -1],rightChild = [-1, 2, -1, -1, -1]) == False\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, 3, 4],rightChild = [-1, -1, 5, -1, -1, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, 3, 4, -1, -1, -1],rightChild = [5, 6, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, -1, -1, -1, -1, -1, -1],rightChild = [5, 6, 7, 8, -1, 9, -1, -1, -1, -1]) == True\n assert candidate(n = 5,leftChild = [1, 2, 3, -1, -1],rightChild = [-1, -1, -1, 4, 0]) == False\n assert candidate(n = 6,leftChild = [1, 2, 3, -1, 5, -1],rightChild = [2, 3, 4, -1, -1, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, -1, 6, 7, -1],rightChild = [-1, 5, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 5,leftChild = [1, -1, -1, -1, 2],rightChild = [-1, 3, 4, -1, -1]) == False\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, -1, -1],rightChild = [3, 4, 5, 0, -1, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, 3, -1, -1, -1, -1, -1],rightChild = [-1, -1, -1, 4, -1, 5, 6, 7]) == False\n assert candidate(n = 7,leftChild = [1, 2, -1, -1, -1, -1, -1],rightChild = [-1, -1, 3, 4, 5, 6, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, 5, -1, 6, 7],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1]) == False\n assert candidate(n = 9,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, 5, 6, 7, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, -1, -1, -1, -1, -1],rightChild = [-1, 6, 7, -1, -1, 8, -1, -1, 9, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, -1, -1, -1],rightChild = [-1, -1, 4, -1, 5, -1]) == True\n assert candidate(n = 5,leftChild = [1, -1, -1, -1, -1],rightChild = [2, 3, 4, -1, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, 3, -1, -1, -1, 6, -1],rightChild = [3, 4, 5, -1, -1, -1, -1, -1]) == False\n assert candidate(n = 12,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 9,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, -1],rightChild = [2, 3, 4, 5, 6, 7, 8, -1, -1]) == False\n assert candidate(n = 10,leftChild = [1, 2, -1, -1, 5, 6, 7, 8, 9, -1],rightChild = [-1, 3, 4, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, 3, -1, -1, -1, -1, -1],rightChild = [2, 3, 4, -1, -1, -1, -1, 7]) == False\n assert candidate(n = 7,leftChild = [1, 2, 3, 4, 5, -1, -1],rightChild = [-1, -1, -1, -1, 6, -1, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, 5, 6, -1, -1],rightChild = [-1, -1, -1, -1, -1, -1, 7, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, 4, -1],rightChild = [-1, 3, -1, 5, -1, -1]) == False\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, -1, -1, -1, -1, -1],rightChild = [2, 3, 4, 5, 6, -1, -1]) == False\n assert candidate(n = 5,leftChild = [1, 2, -1, -1, -1],rightChild = [3, 4, 2, -1, -1]) == False\n assert candidate(n = 5,leftChild = [1, 3, -1, -1, -1],rightChild = [-1, 2, 4, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, -1, 4, -1, -1],rightChild = [-1, -1, 3, -1, 5, -1]) == True\n assert candidate(n = 9,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, -1, -1, 0],rightChild = [-1, -1, -1, -1, -1, -1]) == False\n assert candidate(n = 5,leftChild = [1, 2, 3, -1, -1],rightChild = [-1, -1, -1, 4, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, -1, 3, 4, 5, -1, -1],rightChild = [-1, -1, -1, -1, 6, 7, -1, -1]) == False\n assert candidate(n = 11,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, -1],rightChild = [3, 4, 5, 6, 7, 8, 9, -1, -1, -1]) == False\n assert candidate(n = 6,leftChild = [1, 2, 3, -1, 4, -1],rightChild = [-1, -1, -1, 5, -1, -1]) == False\n assert candidate(n = 8,leftChild = [1, -1, 3, 5, -1, 7, -1, -1],rightChild = [2, 4, 6, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, -1, -1],rightChild = [-1, -1, 3, 4, 5, -1]) == True\n assert candidate(n = 6,leftChild = [1, -1, -1, 2, -1, -1],rightChild = [2, 3, 4, -1, 5, -1]) == False\n assert candidate(n = 6,leftChild = [1, 2, 3, 4, -1, -1],rightChild = [-1, -1, -1, -1, 5, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, -1, -1],rightChild = [3, 4, -1, -1, -1, 5]) == False\n assert candidate(n = 8,leftChild = [1, -1, 2, -1, 3, 4, -1, -1],rightChild = [-1, 5, -1, 6, 7, -1, -1, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, -1, -1, -1, -1, 6, 7],rightChild = [3, 4, 5, -1, -1, -1, -1, -1]) == False\n assert candidate(n = 6,leftChild = [1, -1, -1, -1, -1, -1],rightChild = [2, 3, 4, 5, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, 4, 5, -1],rightChild = [-1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, -1, -1, -1, -1],rightChild = [5, -1, 6, -1, 7, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, -1, 3, 5, -1, -1],rightChild = [2, 4, -1, -1, -1, -1]) == True\n assert candidate(n = 10,leftChild = [1, -1, 2, -1, 3, -1, 4, -1, 5, -1],rightChild = [2, 3, 4, 5, 6, 7, 8, 9, -1, -1]) == False\n assert candidate(n = 7,leftChild = [1, -1, -1, 5, -1, -1, -1],rightChild = [2, 3, 4, 6, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, -1, -1],rightChild = [3, 4, -1, -1, 5, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, 3, -1, -1, 5, 6],rightChild = [-1, -1, -1, 4, -1, -1, -1]) == False\n assert candidate(n = 5,leftChild = [1, 2, -1, -1, -1],rightChild = [-1, 3, -1, 4, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, -1, 4, 5, -1, -1],rightChild = [-1, -1, -1, -1, -1, 6, -1]) == False\n assert candidate(n = 7,leftChild = [1, 2, -1, -1, 4, -1, -1],rightChild = [3, -1, 5, 6, -1, -1, -1]) == False\n assert candidate(n = 5,leftChild = [1, 2, -1, -1, -1],rightChild = [-1, 3, 4, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, -1, 2, -1, 3, -1],rightChild = [-1, -1, -1, -1, -1, 4]) == False\n assert candidate(n = 10,leftChild = [1, -1, 3, -1, -1, 6, -1, -1, -1, -1],rightChild = [2, 4, 5, 7, 8, 9, -1, -1, -1, -1]) == True\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, -1, -1, -1, 7, -1, 9],rightChild = [-1, -1, -1, -1, 5, 6, 8, -1, -1, -1]) == False\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, -1, -1],rightChild = [3, 4, -1, -1, 5, -1]) == True\n assert candidate(n = 9,leftChild = [1, 2, 3, 4, -1, -1, -1, 7, -1],rightChild = [-1, -1, -1, -1, 5, 6, 8, -1, -1]) == False\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, -1, -1, -1, -1, -1, -1],rightChild = [-1, 5, 6, 7, -1, 8, 9, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, -1, -1, -1],rightChild = [-1, -1, -1, 4, 5, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, -1, -1, -1],rightChild = [2, 3, 4, -1, -1, -1]) == False\n assert candidate(n = 12,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, 3, 4, -1, -1],rightChild = [-1, -1, 5, -1, 3, -1]) == False\n assert candidate(n = 6,leftChild = [1, -1, 3, -1, -1, -1],rightChild = [2, -1, -1, 4, 5, -1]) == True\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, 6, -1, -1, 8, -1],rightChild = [-1, -1, -1, -1, -1, -1, 7, -1, -1, 9]) == False\n assert candidate(n = 7,leftChild = [1, -1, -1, -1, -1, -1, -1],rightChild = [2, 3, 4, 5, 6, -1, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, 3, -1, 5, -1, -1],rightChild = [4, -1, -1, -1, 6, -1, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, 5, 6, -1, -1],rightChild = [-1, -1, -1, -1, -1, -1, 7, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, -1, -1, -1, -1, -1],rightChild = [3, 4, 5, 6, -1, -1, -1]) == True\n assert candidate(n = 5,leftChild = [1, 2, 3, 4, -1],rightChild = [-1, -1, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, -1, 4],rightChild = [2, -1, 3, -1, 5, -1]) == False\n assert candidate(n = 7,leftChild = [1, 2, 3, 4, -1, -1, -1],rightChild = [5, -1, 4, -1, -1, -1, -1]) == False\n assert candidate(n = 5,leftChild = [1, 2, -1, -1, 4],rightChild = [-1, -1, -1, 3, -1]) == False\n assert candidate(n = 9,leftChild = [1, 2, 3, 4, 5, 6, -1, -1, -1],rightChild = [-1, -1, -1, -1, -1, -1, 7, 8, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, 3, -1, -1, -1, -1],rightChild = [4, 5, 6, -1, -1, -1, -1]) == True\n assert candidate(n = 5,leftChild = [1, 2, -1, 3, -1],rightChild = [4, -1, -1, -1, -1]) == False\n assert candidate(n = 7,leftChild = [1, -1, 2, 3, -1, 4, -1],rightChild = [-1, -1, -1, 5, 6, -1, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, 5, 6, -1, -1],rightChild = [7, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 9,leftChild = [1, 2, 3, -1, -1, -1, -1, -1, -1],rightChild = [4, 5, 6, 7, 8, -1, -1, -1, -1]) == True\n assert candidate(n = 12,leftChild = [1, 2, -1, 4, -1, 6, -1, -1, 8, -1, -1, -1],rightChild = [-1, 3, 5, -1, 7, -1, 9, -1, 10, -1, 11, -1]) == False\n assert candidate(n = 5,leftChild = [1, -1, -1, -1, -1],rightChild = [2, -1, 3, -1, 4]) == False\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, 5, 6, 7, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, -1, 9],rightChild = [2, -1, -1, -1, 5, 6, -1, -1, 9, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, -1, -1, -1, -1, -1, -1],rightChild = [2, 3, 4, 5, 6, 7, -1, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, -1, -1, -1, -1],rightChild = [-1, -1, -1, -1, 5, 6, 7, -1]) == True\n assert candidate(n = 5,leftChild = [1, -1, -1, -1, -1],rightChild = [2, 3, 4, -1, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, 3, 4, 5, -1, -1],rightChild = [-1, -1, -1, 6, -1, -1, -1]) == True\n assert candidate(n = 9,leftChild = [1, 2, -1, 4, -1, -1, 7, -1, -1],rightChild = [-1, 3, -1, -1, 5, 6, -1, -1, 8]) == False\n assert candidate(n = 8,leftChild = [1, 2, -1, -1, -1, -1, -1, -1],rightChild = [3, 4, 5, 6, 7, -1, -1, -1]) == True\n assert candidate(n = 5,leftChild = [1, 2, -1, -1, -1],rightChild = [2, 4, 3, -1, -1]) == False\n assert candidate(n = 10,leftChild = [1, 2, -1, -1, -1, -1, -1, -1, -1, -1],rightChild = [3, 4, 5, 6, 7, 8, 9, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, -1, 2, -1, -1, -1],rightChild = [2, -1, 3, 4, 5, -1]) == False\n assert candidate(n = 5,leftChild = [1, 2, -1, 4, -1],rightChild = [-1, -1, 3, -1, -1]) == True\n assert candidate(n = 10,leftChild = [1, 2, -1, -1, 3, 4, -1, 5, 6, -1],rightChild = [-1, -1, -1, 3, 5, 6, 7, 8, 9, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, -1, -1, -1, 3, 5, -1],rightChild = [4, -1, -1, -1, 6, -1, 7, -1]) == True\n assert candidate(n = 8,leftChild = [1, -1, -1, 4, -1, -1, -1, -1],rightChild = [2, 3, 5, -1, 6, 7, -1, -1]) == True\n assert candidate(n = 9,leftChild = [1, 2, 3, 4, 5, 6, -1, 8, -1],rightChild = [-1, -1, -1, -1, -1, -1, 7, -1, -1]) == True\n assert candidate(n = 11,leftChild = [1, 2, -1, 4, 5, 6, -1, 8, -1, -1, -1],rightChild = [-1, 3, -1, 7, -1, -1, 9, -1, 10, -1, -1]) == True\n assert candidate(n = 8,leftChild = [1, 2, -1, -1, -1, 6, 7, -1],rightChild = [-1, -1, 3, 4, 5, -1, -1, -1]) == True\n assert candidate(n = 9,leftChild = [1, 2, -1, 4, 5, -1, -1, -1, -1],rightChild = [-1, -1, 3, -1, -1, 6, -1, -1, 7]) == False\n assert candidate(n = 8,leftChild = [1, 2, -1, 3, 4, 5, 6, -1],rightChild = [-1, -1, -1, -1, -1, 7, -1, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, -1, -1, 6, 7],rightChild = [5, -1, -1, -1, -1, -1, -1, -1]) == False\n assert candidate(n = 6,leftChild = [1, 2, 3, 4, -1, -1],rightChild = [5, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 10,leftChild = [1, -1, 2, 3, -1, 4, 5, 6, 7, 8],rightChild = [-1, 2, 3, -1, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(n = 5,leftChild = [1, -1, -1, -1, -1],rightChild = [-1, 2, 3, 4, -1]) == True\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, -1],rightChild = [2, 3, 4, 5, 6, 7, 8, 9, -1, -1]) == False\n assert candidate(n = 7,leftChild = [1, 2, -1, -1, -1, 5, 6],rightChild = [2, -1, 3, 4, -1, -1, -1]) == False\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, -1, 6, 7, 8, -1],rightChild = [-1, -1, -1, -1, 9, -1, -1, -1, -1, -1]) == False\n assert candidate(n = 8,leftChild = [1, 2, 3, 4, -1, 6, 7, -1],rightChild = [5, -1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, 3, 4, 5, 6, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 7,leftChild = [1, 2, 3, 4, 5, -1, -1],rightChild = [-1, 6, -1, -1, -1, -1, -1]) == True\n assert candidate(n = 4,leftChild = [1, -1, -1, -1],rightChild = [2, 3, 0, -1]) == False\n assert candidate(n = 6,leftChild = [1, -1, 3, -1, -1, 4],rightChild = [2, 5, -1, -1, -1, -1]) == True\n assert candidate(n = 11,leftChild = [1, 2, 3, 4, -1, -1, -1, -1, -1, -1, -1],rightChild = [5, 6, 7, 8, 9, -1, 10, -1, -1, -1, -1]) == True\n assert candidate(n = 6,leftChild = [1, 2, -1, -1, -1, 4],rightChild = [3, -1, -1, -1, 5, -1]) == False\n assert candidate(n = 6,leftChild = [1, -1, 2, 3, -1, -1],rightChild = [-1, -1, -1, 4, -1, 5]) == False\n assert candidate(n = 10,leftChild = [1, 2, 3, 4, 5, 6, 7, 8, 9, -1],rightChild = [-1, -1, -1, -1, -1, -1, -1, -1, -1, 0]) == False\n"}, "metadata": {"canonical_parameter_names": ["n", "leftChild", "rightChild"], "leetcode_dataset_entry_point": "Solution().validateBinaryTreeNodes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool validateBinaryTreeNodes(int n, vector& leftChild, vector& rightChild) {", "container": "Solution", "callable": "validateBinaryTreeNodes", "parameters": [{"name": "n", "type": "int"}, {"name": "leftChild", "type": "vector&"}, {"name": "rightChild", "type": "vector&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1362, "task_id": "closest-divisors", "difficulty": "Medium", "problem_description": "Given an integer num, find the closest two integers in absolute difference whose product equals num + 1 or num + 2.\nReturn the two integers in any order.\n \nExample 1:\n\nInput: num = 8\nOutput: [3,3]\nExplanation: For num + 1 = 9, the closest divisors are 3 & 3, for num + 2 = 10, the closest divisors are 2 & 5, hence 3 & 3 is chosen.\n\nExample 2:\n\nInput: num = 123\nOutput: [5,25]\n\nExample 3:\n\nInput: num = 999\nOutput: [40,25]\n\n \nConstraints:\n\n1 <= num <= 10^9\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = 1000000000) == [23658, 42269]\n assert candidate(num = 999) == [25, 40]\n assert candidate(num = 8) == [3, 3]\n assert candidate(num = 1) == [1, 2]\n assert candidate(num = 100) == [6, 17]\n assert candidate(num = 123) == [5, 25]\n assert candidate(num = 100000000) == [7122, 14041]\n assert candidate(num = 111111111) == [9352, 11881]\n assert candidate(num = 555555555) == [1457, 381301]\n assert candidate(num = 456789) == [170, 2687]\n assert candidate(num = 888888888) == [21847, 40687]\n assert candidate(num = 999999998) == [31250, 32000]\n assert candidate(num = 4) == [2, 3]\n assert candidate(num = 234567890) == [13707, 17113]\n assert candidate(num = 999999997) == [2997, 333667]\n assert candidate(num = 1048575) == [1024, 1024]\n assert candidate(num = 800000000) == [20201, 39602]\n assert candidate(num = 123456789) == [370, 333667]\n assert candidate(num = 300000000) == [49, 6122449]\n assert candidate(num = 104729) == [30, 3491]\n assert candidate(num = 65535) == [256, 256]\n assert candidate(num = 500000000) == [11829, 42269]\n assert candidate(num = 499999999) == [20000, 25000]\n assert candidate(num = 135792468) == [7810, 17387]\n assert candidate(num = 1000000001) == [23658, 42269]\n assert candidate(num = 77777777) == [7213, 10783]\n assert candidate(num = 2000000000) == [38038, 52579]\n assert candidate(num = 100000001) == [7122, 14041]\n assert candidate(num = 499999) == [625, 800]\n assert candidate(num = 319912345) == [12039, 26573]\n assert candidate(num = 345678901) == [10853, 31851]\n assert candidate(num = 456789123) == [17525, 26065]\n assert candidate(num = 789012345) == [24293, 32479]\n assert candidate(num = 987654321) == [1402, 704461]\n assert candidate(num = 1048576) == [17, 61681]\n assert candidate(num = 2) == [2, 2]\n assert candidate(num = 8675309) == [2653, 3270]\n assert candidate(num = 600000001) == [98, 6122449]\n assert candidate(num = 1122334455) == [8, 140291807]\n assert candidate(num = 42424242) == [124, 342131]\n assert candidate(num = 999999999) == [31250, 32000]\n assert candidate(num = 1000000) == [101, 9901]\n assert candidate(num = 49) == [5, 10]\n assert candidate(num = 750000000) == [4727, 158663]\n assert candidate(num = 876543210) == [12652, 69281]\n assert candidate(num = 500000001) == [3362, 148721]\n assert candidate(num = 65536) == [198, 331]\n assert candidate(num = 314159) == [560, 561]\n assert candidate(num = 271828182) == [11, 24711653]\n assert candidate(num = 678901234) == [22686, 29926]\n assert candidate(num = 2147483647) == [32768, 65536]\n assert candidate(num = 3) == [2, 2]\n assert candidate(num = 15) == [4, 4]\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().closestDivisors", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector closestDivisors(int num) {", "container": "Solution", "callable": "closestDivisors", "parameters": [{"name": "num", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1363, "task_id": "largest-multiple-of-three", "difficulty": "Hard", "problem_description": "Given an array of digits digits, return the largest multiple of three that can be formed by concatenating some of the given digits in any order. If there is no answer return an empty string.\nSince the answer may not fit in an integer data type, return the answer as a string. Note that the returning answer must not contain unnecessary leading zeros.\n \nExample 1:\n\nInput: digits = [8,1,9]\nOutput: \"981\"\n\nExample 2:\n\nInput: digits = [8,6,7,1,0]\nOutput: \"8760\"\n\nExample 3:\n\nInput: digits = [1]\nOutput: \"\"\n\n \nConstraints:\n\n1 <= digits.length <= 104\n0 <= digits[i] <= 9\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(digits = [5, 5, 5]) == \"555\"\n assert candidate(digits = [3, 3, 3]) == \"333\"\n assert candidate(digits = [3, 3, 3, 3, 3]) == \"33333\"\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"9876543210\"\n assert candidate(digits = [0, 0, 0]) == \"0\"\n assert candidate(digits = [3, 3, 3, 3]) == \"3333\"\n assert candidate(digits = [2, 2, 2, 2, 2, 2, 2]) == \"222222\"\n assert candidate(digits = [3, 6, 9, 1, 8]) == \"98631\"\n assert candidate(digits = [8, 6, 7, 1, 0]) == \"8760\"\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"987654321\"\n assert candidate(digits = [1]) == \"\"\n assert candidate(digits = [1, 4, 7, 8, 5, 2]) == \"875421\"\n assert candidate(digits = [1, 1, 1, 2, 2, 2, 3, 3, 3]) == \"333222111\"\n assert candidate(digits = [3, 6, 9, 3, 6, 9]) == \"996633\"\n assert candidate(digits = [5, 5, 5, 5, 5, 5]) == \"555555\"\n assert candidate(digits = [1, 1, 1, 2, 2, 2]) == \"222111\"\n assert candidate(digits = [1, 4, 7, 2, 5, 8, 3, 6, 9, 0]) == \"9876543210\"\n assert candidate(digits = [2, 2, 2, 2, 2, 2]) == \"222222\"\n assert candidate(digits = [8, 1, 9]) == \"981\"\n assert candidate(digits = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"9876543210\"\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5]) == \"555555\"\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"111111111\"\n assert candidate(digits = [2, 5, 8, 1, 4, 7, 0, 3, 6, 9]) == \"9876543210\"\n assert candidate(digits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"0\"\n assert candidate(digits = [0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"0\"\n assert candidate(digits = [2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == \"33333222222\"\n assert candidate(digits = [2, 3, 6, 9, 9, 3, 2, 6, 2, 3]) == \"9966333222\"\n assert candidate(digits = [3, 0, 3, 0, 3, 0, 3, 0, 3, 0]) == \"3333300000\"\n assert candidate(digits = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == \"33333333333333333333\"\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"99999999999999999999\"\n assert candidate(digits = [9, 6, 3, 0, 9, 6, 3, 0, 9, 6, 3, 0, 9, 6, 3, 0, 9, 6, 3, 0]) == \"99999666663333300000\"\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 0, 0, 0]) == \"555555000\"\n assert candidate(digits = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == \"444333222111\"\n assert candidate(digits = [2, 5, 8, 2, 6, 3, 6, 9, 0, 5]) == \"98665530\"\n assert candidate(digits = [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4]) == \"988776655443210\"\n assert candidate(digits = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == \"333333333222222222111111111\"\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == \"555555555\"\n assert candidate(digits = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0]) == \"9876543210000\"\n assert candidate(digits = [7, 8, 5, 2, 3, 6, 1, 4, 9, 0]) == \"9876543210\"\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0]) == \"987654321000000\"\n assert candidate(digits = [1, 4, 7, 1, 4, 7, 1, 4, 7]) == \"777444111\"\n assert candidate(digits = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == \"22222222222222222221\"\n assert candidate(digits = [2, 5, 8, 5, 2, 8, 5, 2, 8]) == \"888555222\"\n assert candidate(digits = [5, 8, 4, 2, 7, 9, 3, 6, 0, 1]) == \"9876543210\"\n assert candidate(digits = [2, 3, 4, 5, 6, 7, 8, 9]) == \"9876543\"\n assert candidate(digits = [7, 8, 9, 4, 5, 6, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4]) == \"9988776655443210\"\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"99887766554433221100\"\n assert candidate(digits = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"999888777666555444333222111000\"\n assert candidate(digits = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == \"999888777666555444333222111\"\n assert candidate(digits = [6, 3, 2, 1, 0, 9, 8, 7, 4, 5]) == \"9876543210\"\n assert candidate(digits = [4, 7, 4, 7, 4, 7]) == \"777444\"\n assert candidate(digits = [3, 3, 3, 6, 6, 6, 9, 9, 9, 0, 0, 0]) == \"999666333000\"\n assert candidate(digits = [3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0]) == \"33333333333330000000000000\"\n assert candidate(digits = [5, 2, 5, 2, 5, 2, 5, 2, 5]) == \"555552222\"\n assert candidate(digits = [5, 8, 3, 9, 2, 6, 1, 0]) == \"9865320\"\n assert candidate(digits = [1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == \"999888777666555444333222111\"\n assert candidate(digits = [2, 4, 6, 8, 0, 0, 0, 0, 0, 0]) == \"864000000\"\n assert candidate(digits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"0\"\n assert candidate(digits = [5, 8, 5, 8, 5, 8, 5, 8, 5, 8, 5, 8, 5, 8, 5, 8, 5, 8, 5, 8]) == \"888888888855555555\"\n assert candidate(digits = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == \"777777777777777\"\n assert candidate(digits = [2, 4, 6, 8, 0, 1, 3, 5, 7, 9]) == \"9876543210\"\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"111111111\"\n assert candidate(digits = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == \"777777777777777777777777777\"\n assert candidate(digits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"0\"\n assert candidate(digits = [1, 4, 7, 1, 4, 7, 1, 4, 7, 1, 4, 7, 1, 4, 7, 1, 4, 7, 1, 4, 7, 1, 4, 7, 1, 4, 7, 1, 4, 7]) == \"777777777744444444441111111111\"\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"111111111111111111\"\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"111111111111\"\n assert candidate(digits = [1, 4, 7, 2, 5, 8, 3, 6, 9]) == \"987654321\"\n assert candidate(digits = [9, 9, 9, 6, 6, 6, 3, 3, 3, 0, 0, 0]) == \"999666333000\"\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"999999999999999\"\n assert candidate(digits = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == \"777777777\"\n"}, "metadata": {"canonical_parameter_names": ["digits"], "leetcode_dataset_entry_point": "Solution().largestMultipleOfThree", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string largestMultipleOfThree(vector& digits) {", "container": "Solution", "callable": "largestMultipleOfThree", "parameters": [{"name": "digits", "type": "vector&"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1365, "task_id": "how-many-numbers-are-smaller-than-the-current-number", "difficulty": "Easy", "problem_description": "Given the array nums, for each nums[i] find out how many numbers in the array are smaller than it. That is, for each nums[i] you have to count the number of valid j's such that j != i and nums[j] < nums[i].\nReturn the answer in an array.\n \nExample 1:\n\nInput: nums = [8,1,2,2,3]\nOutput: [4,0,1,1,3]\nExplanation: \nFor nums[0]=8 there exist four smaller numbers than it (1, 2, 2 and 3). \nFor nums[1]=1 does not exist any smaller number than it.\nFor nums[2]=2 there exist one smaller number than it (1). \nFor nums[3]=2 there exist one smaller number than it (1). \nFor nums[4]=3 there exist three smaller numbers than it (1, 2 and 2).\n\nExample 2:\n\nInput: nums = [6,5,4,8]\nOutput: [2,1,0,3]\n\nExample 3:\n\nInput: nums = [7,7,7,7]\nOutput: [0,0,0,0]\n\n \nConstraints:\n\n2 <= nums.length <= 500\n0 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [8, 1, 2, 2, 3]) == [4, 0, 1, 1, 3]\n assert candidate(nums = [100, 99, 98, 97, 96]) == [4, 3, 2, 1, 0]\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 3, 3]) == [0, 0, 2, 2, 4, 4, 6, 6]\n assert candidate(nums = [100, 99, 98, 97]) == [3, 2, 1, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [3, 0, 1, 2, 5]) == [3, 0, 1, 2, 4]\n assert candidate(nums = [10, 20, 30, 40, 50]) == [0, 1, 2, 3, 4]\n assert candidate(nums = [1, 2, 0, 3, 4]) == [1, 2, 0, 3, 4]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [1, 2, 3, 4, 5]) == [0, 1, 2, 3, 4]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [100, 0, 50, 25, 75]) == [4, 0, 2, 1, 3]\n assert candidate(nums = [3, 0, 6, 1, 5]) == [2, 0, 4, 1, 3]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [6, 5, 4, 8]) == [2, 1, 0, 3]\n assert candidate(nums = [5, 5, 5, 5, 1]) == [1, 1, 1, 1, 0]\n assert candidate(nums = [0, 0, 0, 1]) == [0, 0, 0, 3]\n assert candidate(nums = [5, 4, 3, 2, 1]) == [4, 3, 2, 1, 0]\n assert candidate(nums = [7, 7, 7, 7]) == [0, 0, 0, 0]\n assert candidate(nums = [50, 20, 30, 10, 40]) == [4, 1, 2, 0, 3]\n assert candidate(nums = [3, 3, 3, 3, 3]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [2, 2, 2, 2, 2]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [100, 0, 50, 25, 75, 12, 37, 62, 88, 99]) == [9, 0, 4, 2, 6, 1, 3, 5, 7, 8]\n assert candidate(nums = [0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100, 0, 50, 100]) == [0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56, 0, 28, 56]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [8, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [13, 0, 1, 1, 3, 3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 16, 16, 18, 18]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4]) == [0, 0, 0, 0, 4, 4, 4, 4, 8, 8, 8, 8, 12, 12, 12, 12]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 100, 99, 98, 97]) == [5, 4, 3, 2, 1, 0, 9, 8, 7, 6]\n assert candidate(nums = [5, 8, 3, 9, 1, 7, 4, 6, 2, 0]) == [5, 8, 3, 9, 1, 7, 4, 6, 2, 0]\n assert candidate(nums = [42, 23, 78, 56, 34, 12, 90, 67, 89, 2, 3, 1, 5, 6, 7, 8, 9, 10, 11]) == [13, 11, 16, 14, 12, 10, 18, 15, 17, 1, 2, 0, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [42, 31, 77, 28, 55, 19, 89, 64, 42, 77]) == [3, 2, 7, 1, 5, 0, 9, 6, 3, 7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]\n assert candidate(nums = [25, 50, 75, 100, 25, 50, 75, 100]) == [0, 2, 4, 6, 0, 2, 4, 6]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10]) == [0, 2, 4, 6, 8, 10, 0, 2, 4, 6, 8, 10]\n assert candidate(nums = [47, 53, 100, 42, 55, 80, 86, 29, 93, 37, 48, 51, 21, 79, 68, 94, 3, 8, 58, 52]) == [6, 10, 19, 5, 11, 15, 16, 3, 17, 4, 7, 8, 2, 14, 13, 18, 0, 1, 12, 9]\n assert candidate(nums = [100, 99, 98, 97, 96, 95]) == [5, 4, 3, 2, 1, 0]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [2, 1, 0, 3, 4, 9, 8, 7, 6, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [2, 1, 0, 3, 4, 9, 8, 7, 6, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 3, 1, 2, 4, 6, 8, 7, 9, 10]) == [4, 2, 0, 1, 3, 5, 7, 6, 8, 9]\n assert candidate(nums = [34, 67, 23, 89, 23, 67, 34, 23, 67, 89]) == [3, 5, 0, 8, 0, 5, 3, 0, 5, 8]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [50, 25, 75, 25, 50, 75, 50, 25, 75, 50]) == [3, 0, 7, 0, 3, 7, 3, 0, 7, 3]\n assert candidate(nums = [50, 25, 75, 12, 37, 88, 63, 49, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [14, 11, 16, 10, 12, 17, 15, 13, 18, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [3, 1, 2, 4, 5, 9, 8, 7, 6, 0]) == [3, 1, 2, 4, 5, 9, 8, 7, 6, 0]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [0, 0, 2, 2, 4, 4, 6, 6, 8, 8]\n assert candidate(nums = [50, 24, 7, 9, 12, 33, 18, 42, 60, 5]) == [8, 5, 1, 2, 3, 6, 4, 7, 9, 0]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [0, 0, 2, 2, 4, 4, 6, 6, 8, 8]\n assert candidate(nums = [50, 20, 10, 30, 40, 5, 15, 25, 35, 45]) == [9, 3, 1, 5, 7, 0, 2, 4, 6, 8]\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == [0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16]\n assert candidate(nums = [3, 3, 3, 2, 2, 1, 1, 0, 0, 0]) == [7, 7, 7, 5, 5, 3, 3, 0, 0, 0]\n assert candidate(nums = [50, 40, 30, 20, 10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60]) == [9, 7, 5, 3, 1, 0, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 17, 15, 13, 11]\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == [0, 0, 0, 0, 4, 4, 4, 4, 8, 8, 8, 8]\n assert candidate(nums = [23, 45, 67, 89, 12, 34, 56, 78, 90, 11]) == [2, 4, 6, 8, 1, 3, 5, 7, 9, 0]\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 2, 2, 2, 2]) == [3, 3, 3, 0, 0, 0, 6, 6, 6, 6]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == [0, 2, 1, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [50, 40, 30, 20, 10, 0, 0, 0, 0, 0]) == [9, 8, 7, 6, 5, 0, 0, 0, 0, 0]\n assert candidate(nums = [100, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [0, 100, 50, 25, 75, 20, 80, 30, 60, 40, 90]) == [0, 10, 5, 2, 7, 1, 8, 3, 6, 4, 9]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [23, 45, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90]) == [4, 9, 0, 5, 10, 14, 18, 0, 5, 10, 14, 18, 0, 5, 10, 14, 18, 0, 5, 10, 14, 18]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5]) == [13, 11, 9, 7, 5, 4, 3, 2, 1, 0, 13, 11, 9, 7, 5]\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == [0, 0, 2, 2, 4, 4, 6, 6, 8, 8]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [50, 20, 30, 10, 40]) == [4, 1, 2, 0, 3]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0]) == [15, 12, 9, 6, 3, 0, 15, 12, 9, 6, 3, 0, 15, 12, 9, 6, 3, 0]\n assert candidate(nums = [10, 20, 20, 10, 30, 30, 20, 10, 40, 40, 50, 50, 60, 60, 70]) == [0, 3, 3, 0, 6, 6, 3, 0, 8, 8, 10, 10, 12, 12, 14]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [50, 25, 75, 25, 75, 50, 25, 75, 50, 25]) == [4, 0, 7, 0, 7, 4, 0, 7, 4, 0]\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 9, 8, 10]) == [0, 2, 1, 3, 5, 4, 6, 8, 7, 9]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31]) == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [49, 38, 27, 16, 5, 48, 37, 26, 15, 4, 47, 36, 25, 14, 3, 46, 35, 24, 13, 2, 45, 34, 23, 12, 1, 44, 33, 22, 11, 0]) == [29, 23, 17, 11, 5, 28, 22, 16, 10, 4, 27, 21, 15, 9, 3, 26, 20, 14, 8, 2, 25, 19, 13, 7, 1, 24, 18, 12, 6, 0]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70]) == [29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [10, 20, 10, 30, 40, 50, 10]) == [0, 3, 0, 4, 5, 6, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [27, 24, 21, 18, 15, 12, 9, 6, 3, 0, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0, 27, 24, 21, 18, 15, 12, 9, 6, 3, 0]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 0, 3, 6, 9, 12, 15, 18, 21, 24, 27]\n assert candidate(nums = [33, 10, 55, 72, 21, 45, 66, 100, 33, 55, 72, 21, 45, 66, 100, 33, 55, 72, 21, 45, 66, 100]) == [4, 0, 10, 16, 1, 7, 13, 19, 4, 10, 16, 1, 7, 13, 19, 4, 10, 16, 1, 7, 13, 19]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4]) == [18, 14, 10, 6, 2, 0, 2, 6, 10, 14, 18, 14, 10, 6, 2, 0, 2, 6, 10, 14]\n assert candidate(nums = [34, 23, 56, 12, 78, 45, 90, 67, 34, 23, 12, 56, 78, 45, 67, 90]) == [4, 2, 8, 0, 12, 6, 14, 10, 4, 2, 0, 8, 12, 6, 10, 14]\n assert candidate(nums = [42, 32, 55, 11, 22, 33, 44, 55, 66, 77, 88, 99]) == [4, 2, 6, 0, 1, 3, 5, 6, 8, 9, 10, 11]\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [0, 5, 0, 5, 0, 5, 0, 5, 0, 5]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50]) == [0, 2, 4, 6, 8, 10, 11, 12, 13, 14, 0, 2, 4, 6, 8]\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == [0, 19, 1, 18, 2, 17, 3, 16, 4, 15, 5, 14, 6, 13, 7, 12, 8, 11, 9, 10]\n assert candidate(nums = [45, 67, 89, 23, 34, 56, 78, 90, 12, 34, 56, 78, 90, 23, 45, 67, 89]) == [5, 9, 13, 1, 3, 7, 11, 15, 0, 3, 7, 11, 15, 1, 5, 9, 13]\n assert candidate(nums = [10, 20, 10, 20, 30, 40, 50]) == [0, 2, 0, 2, 4, 5, 6]\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().smallerNumbersThanCurrent", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector smallerNumbersThanCurrent(vector& nums) {", "container": "Solution", "callable": "smallerNumbersThanCurrent", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1366, "task_id": "rank-teams-by-votes", "difficulty": "Medium", "problem_description": "In a special ranking system, each voter gives a rank from highest to lowest to all teams participating in the competition.\nThe ordering of teams is decided by who received the most position-one votes. If two or more teams tie in the first position, we consider the second position to resolve the conflict, if they tie again, we continue this process until the ties are resolved. If two or more teams are still tied after considering all positions, we rank them alphabetically based on their team letter.\nYou are given an array of strings votes which is the votes of all voters in the ranking systems. Sort all teams according to the ranking system described above.\nReturn a string of all teams sorted by the ranking system.\n \nExample 1:\n\nInput: votes = [\"ABC\",\"ACB\",\"ABC\",\"ACB\",\"ACB\"]\nOutput: \"ACB\"\nExplanation: \nTeam A was ranked first place by 5 voters. No other team was voted as first place, so team A is the first team.\nTeam B was ranked second by 2 voters and ranked third by 3 voters.\nTeam C was ranked second by 3 voters and ranked third by 2 voters.\nAs most of the voters ranked C second, team C is the second team, and team B is the third.\n\nExample 2:\n\nInput: votes = [\"WXYZ\",\"XYZW\"]\nOutput: \"XWYZ\"\nExplanation:\nX is the winner due to the tie-breaking rule. X has the same votes as W for the first position, but X has one vote in the second position, while W does not have any votes in the second position. \n\nExample 3:\n\nInput: votes = [\"ZMNAGUEDSJYLBOPHRQICWFXTVK\"]\nOutput: \"ZMNAGUEDSJYLBOPHRQICWFXTVK\"\nExplanation: Only one voter, so their votes are used for the ranking.\n\n \nConstraints:\n\n1 <= votes.length <= 1000\n1 <= votes[i].length <= 26\nvotes[i].length == votes[j].length for 0 <= i, j < votes.length.\nvotes[i][j] is an English uppercase letter.\nAll characters of votes[i] are unique.\nAll the characters that occur in votes[0] also occur in votes[j] where 1 <= j < votes.length.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(votes = ['ABC', 'ACB', 'ABC', 'ACB', 'ACB']) == \"ACB\"\n assert candidate(votes = ['WXYZ', 'XYZW']) == \"XWYZ\"\n assert candidate(votes = ['BCA', 'CAB', 'ACB', 'BAC', 'CBA', 'ABC']) == \"ABC\"\n assert candidate(votes = ['A', 'B', 'C', 'D', 'E']) == \"ABCDE\"\n assert candidate(votes = ['ABCDEF', 'BCDEFA', 'CDEFAB', 'DEFABC', 'EFABCD', 'FABCDE']) == \"ABCDEF\"\n assert candidate(votes = ['BCA', 'CAB', 'CBA', 'ABC', 'ACB', 'BAC']) == \"ABC\"\n assert candidate(votes = ['A', 'A', 'A', 'A', 'A']) == \"A\"\n assert candidate(votes = ['BCA', 'CAB', 'ACB', 'ABC', 'ABC', 'ACB']) == \"ACB\"\n assert candidate(votes = ['A', 'A', 'A', 'A']) == \"A\"\n assert candidate(votes = ['ZMNAGUEDSJYLBOPHRQICWFXTVK']) == \"ZMNAGUEDSJYLBOPHRQICWFXTVK\"\n assert candidate(votes = ['RGB', 'GBR', 'BRG', 'RBB', 'BBR', 'RBB', 'RRG', 'GRR']) == \"RBG\"\n assert candidate(votes = ['ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'ZYXWVUTSRQPONMLKJIHGFEDCBA']) == \"AZBYCXDWEVFUGTHSIRJQKPLOMN\"\n assert candidate(votes = ['BCA', 'CAB', 'ABC', 'ACB', 'BAC']) == \"ABC\"\n assert candidate(votes = ['GHIJKL', 'LKHGJI', 'HKLGJI', 'IGJLKH', 'JIGKHL', 'KGLHJI', 'GHILJK']) == \"GHKILJ\"\n assert candidate(votes = ['LMNO', 'NOLM', 'OLMN', 'MNLO', 'LNMO', 'ONML', 'MLOL', 'LONM', 'MOLN', 'NOML', 'OMNL', 'LMON', 'NLMO', 'OMLN', 'LMNO', 'NOLM', 'OLMN', 'MNLO', 'LNMO', 'ONML', 'MLOL', 'LONM', 'MOLN', 'NOML', 'OMNL']) == \"OLMN\"\n assert candidate(votes = ['ABCDEFGH', 'BCDEFGHA', 'CDEFGHAB', 'DEFGHABC', 'EFGHABCD', 'FGHABCDE', 'GHABCDEF', 'HABCDEFG']) == \"ABCDEFGH\"\n assert candidate(votes = ['ABCDEFG', 'GFEDCBA', 'FBCDEAG', 'BCDEAFG', 'CDEABGF', 'DEABCFG', 'EABCDFG']) == \"BCEDAFG\"\n assert candidate(votes = ['ABCD', 'BCDA', 'CDAB', 'DABC', 'ABCD', 'ABCD']) == \"ABCD\"\n assert candidate(votes = ['QWOP', 'WOPQ', 'OPQW', 'PQWO', 'QWPO', 'WPOQ', 'OPWQ', 'POWQ']) == \"PWOQ\"\n assert candidate(votes = ['QWERTYUIOPASDFGHJKLZXCVBNM', 'MNBVCXZLKJHGFDSAPOIUYTREWQ', 'QWERTYUIOPASDFGHJKLZXCVBNM', 'MNBVCXZLKJHGFDSAPOIUYTREWQ', 'QWERTYUIOPASDFGHJKLZXCVBNM', 'MNBVCXZLKJHGFDSAPOIUYTREWQ', 'QWERTYUIOPASDFGHJKLZXCVBNM', 'MNBVCXZLKJHGFDSAPOIUYTREWQ', 'QWERTYUIOPASDFGHJKLZXCVBNM', 'MNBVCXZLKJHGFDSAPOIUYTREWQ']) == \"MQNWBERVCTXYUZILKOJPAHGSDF\"\n assert candidate(votes = ['MNO', 'OMN', 'NMO', 'MON', 'NMN', 'OMM', 'NMM', 'MMM']) == \"MNO\"\n assert candidate(votes = ['UVWXYZ', 'VWXYZU', 'WXYZUV', 'XYZUVW', 'YZUVWX', 'ZUVWXY', 'UVWXYZ', 'VWXYZU', 'WXYZUV', 'XYZUVW', 'YZUVWX', 'ZUVWXY', 'UVWXYZ', 'VWXYZU', 'WXYZUV', 'XYZUVW', 'YZUVWX', 'ZUVWXY', 'UVWXYZ']) == \"UVWXYZ\"\n assert candidate(votes = ['MATH', 'TEAM', 'META', 'HATE', 'HEAT', 'MATE', 'TAME', 'TIME']) == \"TMHAEI\"\n assert candidate(votes = ['ZYX', 'XYZ', 'YZX', 'XZY', 'YXZ', 'ZXY']) == \"XYZ\"\n assert candidate(votes = ['PQRST', 'QPRST', 'RQPST', 'SPQRT', 'TQPRS', 'PQRST', 'QPRST', 'RQPST', 'SPQRT', 'TQPRS', 'PQRST', 'QPRST', 'RQPST', 'SPQRT', 'TQPRS']) == \"QPRST\"\n assert candidate(votes = ['ABCD', 'BCDA', 'CDAB', 'DABC', 'ACBD']) == \"ACBD\"\n assert candidate(votes = ['PQR', 'QPR', 'RQP', 'PRQ', 'RPQ', 'QRP', 'PQR', 'RQP', 'QRP', 'PRQ']) == \"PQR\"\n assert candidate(votes = ['ZYX', 'YZX', 'XZY', 'XYZ', 'YXZ', 'ZXY', 'YZX', 'ZXY']) == \"ZYX\"\n assert candidate(votes = ['ABCDE', 'EDCBA', 'CBADE', 'BCADE', 'DECAB']) == \"BCDEA\"\n assert candidate(votes = ['ABC', 'BAC', 'BCA', 'CAB', 'CBA', 'ACB', 'BAC', 'CAB', 'CBA', 'BCA', 'ACB', 'CAB', 'CBA', 'BCA', 'ACB', 'BAC', 'CAB', 'CBA', 'BCA', 'ACB', 'BAC', 'CAB', 'CBA', 'BCA', 'ACB']) == \"CBA\"\n assert candidate(votes = ['ABCD', 'BCDA', 'CDAB', 'DABC']) == \"ABCD\"\n assert candidate(votes = ['AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA']) == \"AB\"\n assert candidate(votes = ['QWERTYUIOPASDFGHJKLZXCVBNM', 'QWERTYUIOPASDFGHJKLZXCVBNM', 'QWERTYUIOPASDFGHJKLZXCVBNM']) == \"QWERTYUIOPASDFGHJKLZXCVBNM\"\n assert candidate(votes = ['XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY', 'XYZ', 'YZX', 'ZXY']) == \"XYZ\"\n assert candidate(votes = ['EFGHI', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'EFGHI', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'EFGHI', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'EFGHI', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'EFGHI', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'EFGHI', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'EFGHI', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG']) == \"IHGFEJ\"\n assert candidate(votes = ['XYZ', 'YZX', 'ZXY', 'YXZ', 'XZY', 'ZYX', 'XYZ', 'YZX']) == \"YXZ\"\n assert candidate(votes = ['AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA', 'AB', 'BA']) == \"AB\"\n assert candidate(votes = ['TLI', 'LIT', 'ITL', 'TIL', 'ILT', 'LTI', 'TIL', 'LTI', 'ILT', 'TLI']) == \"TLI\"\n assert candidate(votes = ['QWERTY', 'QWRETY', 'QWRTEY', 'QWRTYE', 'QWRYTE']) == \"QWRETY\"\n assert candidate(votes = ['ZEBRA', 'BRACE', 'BEZAR', 'RABZE', 'AREBZ', 'ZERBA']) == \"BZRAEC\"\n assert candidate(votes = ['ZYX', 'YXZ', 'XYZ', 'YZX', 'XZY', 'ZXY']) == \"XYZ\"\n assert candidate(votes = ['GHIJK', 'HIJKG', 'IJKGH', 'JKGHI', 'KGIJH', 'GHIJK', 'HGIJK', 'IGHJK', 'JGIHK', 'KGIJH']) == \"GHIJK\"\n assert candidate(votes = ['WXYZ', 'YZWX', 'ZWXY', 'XWYZ', 'WZYX', 'XYZW']) == \"WXZY\"\n assert candidate(votes = ['PQRSTU', 'QPRSTU', 'QRPTSU', 'QRSTUP', 'QPRTSU', 'QTRPSU', 'QTRSPU', 'QTSRPU', 'QTSPUR', 'QTPRSU', 'QTPSUR', 'QTUSPR', 'QTUSRP', 'QTURPS', 'QTURSP', 'QTUPRS', 'QTUPSR', 'QTRSPU', 'QTSRPU', 'QTRPUS', 'QTRUPS', 'QTPRSU', 'QTPSUR', 'QTUSPR', 'QTURPS', 'QTURSP', 'QTUPRS', 'QTUPSR']) == \"QPTRUS\"\n assert candidate(votes = ['ABCD', 'DCBA', 'BCAD', 'CADB', 'ACDB', 'DABC', 'BCDA']) == \"ABDC\"\n assert candidate(votes = ['LOVE', 'VOTE', 'LEVO', 'OVEL', 'VOLE', 'ELOV']) == \"VLOET\"\n assert candidate(votes = ['LMNO', 'MLON', 'OLNM', 'NOLM', 'ONML', 'MNLO', 'LOMN', 'LONM', 'NMLO', 'OMNL', 'NOLM', 'OLNM']) == \"OLNM\"\n assert candidate(votes = ['A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'C', 'C', 'C', 'C', 'D', 'D', 'D', 'D', 'E', 'E', 'E', 'E', 'F', 'F', 'F', 'F', 'G', 'G', 'G', 'G', 'H', 'H', 'H', 'H', 'I', 'I', 'I', 'I', 'J', 'J', 'J', 'J', 'K', 'K', 'K', 'K', 'L', 'L', 'L', 'L', 'M', 'M', 'M', 'M', 'N', 'N', 'N', 'N', 'O', 'O', 'O', 'O', 'P', 'P', 'P', 'P', 'Q', 'Q', 'Q', 'Q', 'R', 'R', 'R', 'R', 'S', 'S', 'S', 'S', 'T', 'T', 'T', 'T', 'U', 'U', 'U', 'U', 'V', 'V', 'V', 'V', 'W', 'W', 'W', 'W', 'X', 'X', 'X', 'X', 'Y', 'Y', 'Y', 'Y', 'Z', 'Z', 'Z', 'Z']) == \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n assert candidate(votes = ['ABCDEF', 'FEDCBA', 'DEFABC', 'BCDAFE', 'CBAFED', 'AFECBD', 'BDFECA']) == \"BAFDCE\"\n assert candidate(votes = ['AC', 'CA', 'AC', 'CA', 'AC', 'CA', 'AC', 'CA', 'AC', 'CA']) == \"AC\"\n assert candidate(votes = ['LMNO', 'MLNO', 'NOLM', 'OLMN', 'NOML', 'OMNL', 'LONM', 'OLNM', 'MOLN', 'LNOM', 'LOMN', 'MONL', 'NLOM', 'LNMO', 'LNMN', 'OMLN', 'NOLM', 'NLMO', 'MOLN', 'ONLM', 'OMNL', 'LONM', 'OLNM', 'MOLN', 'LNOM', 'LOMN', 'MONL', 'NLOM', 'LNMO', 'LNMN']) == \"LONM\"\n assert candidate(votes = ['PQRST', 'QPRST', 'RSPTQ', 'TRPQS', 'SQPTR', 'PRQST', 'PQRST', 'RQPTS', 'TQRS', 'SPRQT']) == \"PRSTQ\"\n assert candidate(votes = ['PQR', 'QRP', 'RPQ', 'PRQ', 'QPR', 'RQP', 'PQR', 'QRP', 'RPQ', 'PRQ', 'QPR', 'RQP']) == \"PQR\"\n assert candidate(votes = ['ABCDE', 'ACBDE', 'CABDE', 'BCADE', 'DCABE']) == \"ACBDE\"\n assert candidate(votes = ['XYZ', 'YXZ', 'YZX', 'ZXY', 'ZYX', 'XZY', 'YZX', 'ZYX', 'XYZ', 'YXZ', 'XZY', 'XYZ']) == \"XYZ\"\n assert candidate(votes = ['FGHIJK', 'GHIJKF', 'HIJKFG', 'IJKFGH', 'JKFGHI', 'KFGHIJ', 'FGHIJK', 'GHIJKF', 'HIJKFG', 'IJKFGH']) == \"IHGFJK\"\n assert candidate(votes = ['ACBD', 'BDAC', 'CDAB', 'DABC', 'ABCD', 'BACD', 'CABD', 'DABC', 'ACDB', 'BCDA']) == \"ABCD\"\n assert candidate(votes = ['ABCD', 'ABDC', 'ACBD', 'ACDB', 'ADBC', 'ADCB', 'BACD', 'BADC', 'BCAD', 'BCDA', 'BDAC', 'BDCA', 'CABD', 'CADB', 'CBAD', 'CBDA', 'CDAB', 'CDBA', 'DABC', 'DACB', 'DBAC', 'DBCA', 'DCAB', 'DCBA']) == \"ABCD\"\n assert candidate(votes = ['UVWX', 'VWXU', 'WXUV', 'XUVW', 'UVWX', 'VWXU', 'WXUV', 'XUVW', 'UVWX', 'VWXU']) == \"VUWX\"\n assert candidate(votes = ['ZR', 'RZ', 'ZR', 'RZ', 'ZR']) == \"ZR\"\n assert candidate(votes = ['SUNNY', 'UNNYS', 'NUNYS', 'NNYSU', 'NUYNS', 'USNNY', 'NSUNY']) == \"NUSY\"\n assert candidate(votes = ['HELLO', 'OLLEH', 'LOHEL', 'LLOEH', 'HLOEL', 'ELOHL', 'ELLOH', 'OLEHL', 'LELOH', 'OHELL']) == \"LOEH\"\n assert candidate(votes = ['ACB', 'BAC', 'CBA', 'BCA', 'CAB', 'ACB', 'BAC', 'CBA', 'BCA', 'CAB', 'ACB', 'BAC', 'CBA']) == \"CBA\"\n assert candidate(votes = ['EFGHI', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'JEFGH', 'EFGIH', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'JEFGH', 'EFGIH', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'JEFGH', 'EFGIH', 'FGHIJ', 'GHIJE', 'HIJEF', 'IJEFG', 'JEFGH', 'EFGIH']) == \"EFGIJH\"\n assert candidate(votes = ['QWRTY', 'QWYRT', 'WQRTY', 'WQYRT', 'RTQWY', 'RTYQW', 'YRQWT', 'YRTQW', 'TWQRY', 'TYWQR']) == \"WQRTY\"\n assert candidate(votes = ['PYTHON', 'TYHONP', 'YHTNPO', 'HNOTYP', 'NOTYHP', 'OTHNYP']) == \"YTHONP\"\n assert candidate(votes = ['MNO', 'NOM', 'OMN', 'MON', 'NMO', 'OMN', 'MNO']) == \"MNO\"\n assert candidate(votes = ['MNO', 'OMN', 'NMO', 'MON', 'NOM', 'OMN']) == \"MON\"\n assert candidate(votes = ['ABCD', 'DCBA', 'BCDA', 'CBAD', 'ADBC', 'BDAC', 'ACBD', 'CADB', 'DABC', 'DBCA']) == \"ADBC\"\n assert candidate(votes = ['FGHIJ', 'IJFGH', 'JFGHI', 'HGIJF', 'IGHFJ', 'GFHIJ']) == \"IGFJH\"\n assert candidate(votes = ['VWXYZ', 'YZWXV', 'ZWXYV', 'XWYZV', 'WZYXV', 'XYZWV', 'VWYZX', 'WVXYZ', 'XYZVW', 'YZXVW', 'ZXYVW', 'VZWXY', 'WXYVZ', 'XVZXY', 'YZVWX', 'ZVXYW', 'VXYWZ', 'XYWVZ', 'YWVZX', 'YVZXW', 'VZXWY', 'ZXWYV', 'XWYVZ']) == \"XVYZW\"\n assert candidate(votes = ['ABCDE', 'ABCDE', 'ABCDE', 'EABCD', 'DEABC']) == \"AEDBC\"\n assert candidate(votes = ['UV', 'VU', 'UV', 'UV', 'VU', 'UV', 'UV', 'VU', 'VU', 'VU', 'UV', 'VU', 'VU', 'VU', 'VU', 'VU', 'VU', 'VU', 'VU', 'VU']) == \"VU\"\n"}, "metadata": {"canonical_parameter_names": ["votes"], "leetcode_dataset_entry_point": "Solution().rankTeams", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string rankTeams(vector& votes) {", "container": "Solution", "callable": "rankTeams", "parameters": [{"name": "votes", "type": "vector&"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1367, "task_id": "linked-list-in-binary-tree", "difficulty": "Medium", "problem_description": "Given a binary tree root and a linked list with head as the first node. \nReturn True if all the elements in the linked list starting from the head correspond to some downward path connected in the binary tree otherwise return False.\nIn this context downward path means a path that starts at some node and goes downwards.\n \nExample 1:\n\n\nInput: head = [4,2,8], root = [1,4,4,null,2,2,null,1,null,6,8,null,null,null,null,1,3]\nOutput: true\nExplanation: Nodes in blue form a subpath in the binary Tree. \n\nExample 2:\n\n\nInput: head = [1,4,2,6], root = [1,4,4,null,2,2,null,1,null,6,8,null,null,null,null,1,3]\nOutput: true\n\nExample 3:\n\nInput: head = [1,4,2,6,8], root = [1,4,4,null,2,2,null,1,null,6,8,null,null,null,null,1,3]\nOutput: false\nExplanation: There is no path in the binary tree that contains all the elements of the linked list from head.\n\n \nConstraints:\n\nThe number of nodes in the tree will be in the range [1, 2500].\nThe number of nodes in the list will be in the range [1, 100].\n1 <= Node.val <= 100 for each node in the linked list and binary tree.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(head = list_node([4, 2, 8]),root = tree_node([1, 4, 4, None, 2, 2, None, 1, None, 6, 8, None, None, None, None, 1, 3])) == True\n assert candidate(head = list_node([1, 4, 2, 6]),root = tree_node([1, 4, 4, None, 2, 2, None, 1, None, 6, 8, None, None, None, None, 1, 3])) == True\n assert candidate(head = list_node([1, 4, 2, 6, 8]),root = tree_node([1, 4, 4, None, 2, 2, None, 1, None, 6, 8, None, None, None, None, 1, 3])) == False\n assert candidate(head = list_node([10, 1, 3, 7]),root = tree_node([10, 5, 15, 3, 7, 13, 18, 1, None, 2, None, 4, None, 6, None, 14, None, 17])) == False\n assert candidate(head = list_node([7, 8, 9]),root = tree_node([5, 4, 1, None, None, 7, 8, None, None, None, 9])) == False\n assert candidate(head = list_node([20, 21, 22, 23, 24, 25]),root = tree_node([10, 15, 20, 12, 16, 18, 22, 8, 13, 17, 19, 21, 23, 7, 9, 11, 14, 24, 25])) == False\n assert candidate(head = list_node([1, 1, 1, 1, 1]),root = tree_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) == True\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None])) == False\n assert candidate(head = list_node([1, 3, 5, 7, 9]),root = tree_node([1, None, 3, None, 5, None, 7, None, 9])) == True\n assert candidate(head = list_node([1, 3, 5, 7, 9]),root = tree_node([1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9])) == False\n assert candidate(head = list_node([9, 8, 7, 6, 5]),root = tree_node([9, 8, 7, 6, 5, None, None, None, None, None, None])) == False\n assert candidate(head = list_node([2, 1, 3]),root = tree_node([1, 2, 3, None, None, 4, 5])) == False\n assert candidate(head = list_node([3, 2, 1]),root = tree_node([3, 2, 1, None, None, 2, None, None, 1])) == False\n assert candidate(head = list_node([5, 4, 3, 2, 1]),root = tree_node([5, 4, 3, 2, 1, None, None, None, None, None, None])) == False\n assert candidate(head = list_node([1, 2, 3, 4, 5]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])) == False\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7]),root = tree_node([1, 2, 3, 4, 5, 6, 7])) == False\n assert candidate(head = list_node([1, 2, 3, 4, 5]),root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])) == True\n assert candidate(head = list_node([3, 6, 9, 12]),root = tree_node([3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45])) == False\n assert candidate(head = list_node([8, 9, 10, 11]),root = tree_node([5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])) == False\n assert candidate(head = list_node([10, 9, 8]),root = tree_node([10, 9, 8, 8, None, 9, 8, 7, None, 8, None, 6, 8, None, 8, 5, None, 8, None, 8, 4, None, 8, None, 8, 3, None, 8, None, 8, 2, None, 8, None, 8, 1, None, 8])) == True\n assert candidate(head = list_node([3, 3, 3]),root = tree_node([3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3])) == True\n assert candidate(head = list_node([15, 16, 17, 18, 19, 20]),root = tree_node([10, 15, 20, 12, 16, 18, 22, 8, 13, 17, 19, 21, 23, 7, 9, 11, 14, 24, 25])) == False\n assert candidate(head = list_node([5, 6, 7]),root = tree_node([5, 3, 6, 2, 4, None, 7, None, None, 6, None, None, None, None, 7])) == True\n assert candidate(head = list_node([4, 2, 1, 3]),root = tree_node([4, 2, 1, None, None, 3, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None])) == False\n assert candidate(head = list_node([2, 1, 3]),root = tree_node([1, 2, 3, 2, 1, None, 4, None, None, 1, None, None, 3, None, None, 2, None, None, 1])) == False\n assert candidate(head = list_node([5, 8, 9, 7, 3]),root = tree_node([5, 3, 8, 5, 8, 9, 1, None, 7, None, None, None, 9, None, None, None, 7, None, None, None, 3, None, None, None, None, None, None, None, None, None, None, None, None])) == False\n assert candidate(head = list_node([10, 20, 30, 40]),root = tree_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, None, None, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250])) == False\n assert candidate(head = list_node([8, 7, 6]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None])) == False\n assert candidate(head = list_node([25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]),root = tree_node([25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == False\n assert candidate(head = list_node([7, 1, 5]),root = tree_node([3, 7, 7, None, 1, None, None, None, 5, None, 6, None, None, 8])) == True\n assert candidate(head = list_node([10, 5, 3]),root = tree_node([10, 5, 10, 5, 3, 10, 10, None, None, 3, None, None, 10, 10, 10, 3, None, None, 10, None, None, None, None, 10, 10, None, None, None, None, 10])) == True\n assert candidate(head = list_node([1, 2, 3, 4, 5]),root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7])) == False\n assert candidate(head = list_node([5, 3, 8, 6]),root = tree_node([5, 3, 8, 6, 2, 8, 6, 2, 8, 6, 2, 8, 6, 2, 8, 6, 2, 8, 6, 2, 8, 6, 2, 8, 6, 2, 8, 6, 2, 8, 6, 2, 8, 6])) == False\n assert candidate(head = list_node([3, 1, 2]),root = tree_node([1, None, 2, None, 3])) == False\n assert candidate(head = list_node([2, 3, 4]),root = tree_node([5, 2, 1, None, 3, None, 4, None, None, None, 6, 7, 8])) == False\n assert candidate(head = list_node([2, 5, 6, 7]),root = tree_node([2, 1, 3, 2, 5, None, None, 2, 5, None, None, None, None, 6, None, None, None, None, 7, None, None, None, None, None, None, None, None, None, None, None, None])) == False\n assert candidate(head = list_node([3, 4, 5, 6]),root = tree_node([1, None, 3, None, 4, None, 5, None, 6, None, 7])) == True\n assert candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1]),root = tree_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20])) == False\n assert candidate(head = list_node([10, 20, 30, 40]),root = tree_node([10, 5, 10, None, None, 20, None, None, 30, None, 40])) == True\n assert candidate(head = list_node([1, 2, 3, 4, 5]),root = tree_node([1, 2, 1, 2, 3, None, None, 2, 3, None, None, None, None, None, None, None, None, None, 4, None, None, None, None, None, None, None, None, 5])) == False\n assert candidate(head = list_node([7, 8, 9]),root = tree_node([5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4])) == False\n assert candidate(head = list_node([10, 20, 30, 40, 50]),root = tree_node([10, 20, 30, None, 40, None, 50, None, 60, None, 70])) == False\n assert candidate(head = list_node([1, 2, 3, 2, 1]),root = tree_node([1, 2, 3, 2, 1, None, None, 2, None, 1, None, None, 1, None, None, 1, None, None, 1, None, None, 1, None, None, 1])) == False\n assert candidate(head = list_node([10, 9, 8, 7]),root = tree_node([5, 3, 8, 10, 9, 6, 7, None, None, None, None, None, 8, None, None])) == False\n assert candidate(head = list_node([100, 99, 98, 97, 96]),root = tree_node([100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71])) == False\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])) == False\n assert candidate(head = list_node([11, 3, 4]),root = tree_node([11, 3, 14, 3, 4, 9, 14, 3, 4, None, None, 9, 14, None, None, None, None, 4, None, None, None, None, None, None, 4, None, None, None, None, None, 4, None, None, None])) == True\n assert candidate(head = list_node([1, 1, 1, 1, 1]),root = tree_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) == True\n assert candidate(head = list_node([1]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])) == True\n assert candidate(head = list_node([5, 6, 7, 8, 9]),root = tree_node([1, 5, 6, 7, 8, 9, None, None, None, None, None, None])) == False\n assert candidate(head = list_node([3, 7, 9]),root = tree_node([5, 3, 8, 7, 9, None, None, 2, None, None, None, 6, None])) == False\n assert candidate(head = list_node([1, 3, 5, 7, 9, 11]),root = tree_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59])) == False\n assert candidate(head = list_node([5, 5, 5]),root = tree_node([5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5])) == True\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == False\n assert candidate(head = list_node([2, 4, 6, 8, 10]),root = tree_node([2, None, 4, None, 6, None, 8, None, 10])) == True\n assert candidate(head = list_node([1, 2, 3, 4, 5]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == False\n assert candidate(head = list_node([6, 7, 8, 9]),root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, None, None, None, 8, 9])) == False\n assert candidate(head = list_node([7, 3, 1]),root = tree_node([5, 7, 6, 3, None, None, 1, None, None, None, None])) == False\n assert candidate(head = list_node([5, 6, 7, 8, 9]),root = tree_node([3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23])) == False\n assert candidate(head = list_node([7, 8, 9]),root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, None, None, None, 8, None, None, 9])) == True\n assert candidate(head = list_node([7, 3, 1, 5]),root = tree_node([5, 7, 5, None, 3, 7, 5, None, None, 1, None, None, 2, None, None, None, 8])) == False\n assert candidate(head = list_node([1, 2, 1, 2, 3]),root = tree_node([1, 2, 1, 2, 3, None, None, None, None, None, None])) == False\n assert candidate(head = list_node([1, 2, 3, 4, 5]),root = tree_node([1, None, 2, None, 3, None, 4, None, 5])) == True\n assert candidate(head = list_node([25, 24, 23, 22, 21, 20]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])) == False\n assert candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])) == False\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None])) == False\n assert candidate(head = list_node([10, 11, 12]),root = tree_node([5, 10, 15, 8, 11, 13, 18, 7, 12, 9, 14, 16, 19, 6, 17, 20])) == False\n assert candidate(head = list_node([3, 2, 1]),root = tree_node([1, None, 3, None, 2, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])) == False\n assert candidate(head = list_node([1, 3, 2, 3, 1]),root = tree_node([1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1])) == False\n assert candidate(head = list_node([5, 6, 7, 8]),root = tree_node([5, 1, 4, 6, None, 2, None, 7, None, 3, None, 8, None, 4, None, 9, None, 5])) == False\n assert candidate(head = list_node([2, 3, 4, 5, 6, 7, 8]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == False\n assert candidate(head = list_node([9, 5, 1]),root = tree_node([9, 3, 11, 1, None, 5, None, 9, None, 5, None, 1, None, 1, None, 1, None, 9, None, 1, None, 1, None, 1, None, 1])) == False\n assert candidate(head = list_node([1, 2, 3, 2, 1]),root = tree_node([1, 2, 1, 2, 3, 2, 1, 3, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1])) == True\n assert candidate(head = list_node([1, 2, 3]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == False\n assert candidate(head = list_node([6, 7, 8, 9]),root = tree_node([6, 2, 6, 7, 8, 6, 6, 9, None, None, None, 7, 8, None, None, None, 8, 9, None, None, None, None, None, 9, None, None, None, None, None, 9, None, None, None])) == False\n assert candidate(head = list_node([5, 6, 7]),root = tree_node([1, 2, 3, 4, 5, None, None, None, None, 6, None, None, 7, None, None, 8, None, None, 9, None, None, 10, None, None, 11, None, None, 12, None, None, 13])) == True\n assert candidate(head = list_node([1, 1, 1, 1, 1]),root = tree_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) == True\n assert candidate(head = list_node([3, 5, 7, 9]),root = tree_node([3, 5, 7, 1, 5, 7, 9, None, None, 1, None, None, 9, 3, 5, None, 9])) == False\n assert candidate(head = list_node([2, 3, 6]),root = tree_node([1, 2, 3, 4, 2, 6, 3, 4, 2, 6, 3, 4, 2, 6, None, None, None, None, None, None, None, None, None])) == False\n assert candidate(head = list_node([2, 3, 4, 5]),root = tree_node([2, 3, None, 4, None, 5, None, 6, None, 7, None, 8])) == True\n assert candidate(head = list_node([10, 11, 12, 13]),root = tree_node([10, None, 11, None, 12, None, 13, None, 10])) == True\n assert candidate(head = list_node([7, 5, 2]),root = tree_node([7, 5, 2, 7, 5, 2, 7, 5, 2, 7, 5, 2, 7, 5, 2, 7, 5, 2, 7, 5, 2, 7, 5, 2, 7, 5, 2, 7, 5, 2, 7, 5, 2, 7, 5, 2, 7, 5, 2])) == False\n assert candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1]),root = tree_node([9, 8, 7, 6, 5, 4, 3, 2, 1, None, None, 8, 7, 6, 5, 4, 3, 2, 1, None, None, 7, 6, 5, 4, 3, 2, 1])) == False\n assert candidate(head = list_node([7, 1, 2, 1]),root = tree_node([7, 1, 2, 1, 2, 2, None, 2, None, 2, None, 1, None, 1, None, 2, None, 1, None, 1, None, 2, None, 2, None, 2])) == False\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])) == False\n"}, "metadata": {"canonical_parameter_names": ["head", "root"], "leetcode_dataset_entry_point": "Solution().isSubPath", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool isSubPath(ListNode* head, TreeNode* root) {", "container": "Solution", "callable": "isSubPath", "parameters": [{"name": "head", "type": "ListNode*"}, {"name": "root", "type": "TreeNode*"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1368, "task_id": "minimum-cost-to-make-at-least-one-valid-path-in-a-grid", "difficulty": "Hard", "problem_description": "Given an m x n grid. Each cell of the grid has a sign pointing to the next cell you should visit if you are currently in this cell. The sign of grid[i][j] can be:\n\n1 which means go to the cell to the right. (i.e go from grid[i][j] to grid[i][j + 1])\n2 which means go to the cell to the left. (i.e go from grid[i][j] to grid[i][j - 1])\n3 which means go to the lower cell. (i.e go from grid[i][j] to grid[i + 1][j])\n4 which means go to the upper cell. (i.e go from grid[i][j] to grid[i - 1][j])\n\nNotice that there could be some signs on the cells of the grid that point outside the grid.\nYou will initially start at the upper left cell (0, 0). A valid path in the grid is a path that starts from the upper left cell (0, 0) and ends at the bottom-right cell (m - 1, n - 1) following the signs on the grid. The valid path does not have to be the shortest.\nYou can modify the sign on a cell with cost = 1. You can modify the sign on a cell one time only.\nReturn the minimum cost to make the grid have at least one valid path.\n \nExample 1:\n\n\nInput: grid = [[1,1,1,1],[2,2,2,2],[1,1,1,1],[2,2,2,2]]\nOutput: 3\nExplanation: You will start at point (0, 0).\nThe path to (3, 3) is as follows. (0, 0) --> (0, 1) --> (0, 2) --> (0, 3) change the arrow to down with cost = 1 --> (1, 3) --> (1, 2) --> (1, 1) --> (1, 0) change the arrow to down with cost = 1 --> (2, 0) --> (2, 1) --> (2, 2) --> (2, 3) change the arrow to down with cost = 1 --> (3, 3)\nThe total cost = 3.\n\nExample 2:\n\n\nInput: grid = [[1,1,3],[3,2,2],[1,1,4]]\nOutput: 0\nExplanation: You can follow the path from (0, 0) to (2, 2).\n\nExample 3:\n\n\nInput: grid = [[1,2],[4,3]]\nOutput: 1\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 100\n1 <= grid[i][j] <= 4\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 2\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3]]) == 3\n assert candidate(grid = [[4, 4, 4], [4, 4, 4], [4, 4, 4]]) == 4\n assert candidate(grid = [[2, 3, 4, 1], [4, 2, 3, 1], [3, 4, 2, 1], [1, 2, 3, 4]]) == 4\n assert candidate(grid = [[3, 4, 2, 1], [4, 2, 3, 1], [2, 1, 4, 3], [1, 4, 3, 2]]) == 3\n assert candidate(grid = [[1, 1, 1, 1], [2, 2, 2, 2], [1, 1, 1, 1], [2, 2, 2, 2]]) == 3\n assert candidate(grid = [[4, 2, 3], [1, 2, 1], [1, 2, 4]]) == 3\n assert candidate(grid = [[2, 1, 1], [1, 2, 2], [2, 2, 1]]) == 3\n assert candidate(grid = [[1, 2], [4, 3]]) == 1\n assert candidate(grid = [[1, 1, 3], [3, 2, 2], [1, 1, 4]]) == 0\n assert candidate(grid = [[4, 2, 3], [1, 3, 2], [2, 1, 4]]) == 1\n assert candidate(grid = [[2, 2, 2], [2, 2, 2], [2, 2, 2]]) == 4\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]]) == 3\n assert candidate(grid = [[1, 2, 3, 4, 1, 2, 3], [4, 3, 2, 1, 4, 3, 2], [1, 2, 3, 4, 1, 2, 3], [4, 3, 2, 1, 4, 3, 2], [1, 2, 3, 4, 1, 2, 3], [4, 3, 2, 1, 4, 3, 2]]) == 5\n assert candidate(grid = [[4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [4, 3, 3, 3, 3, 3, 3, 3, 3, 4], [4, 3, 2, 2, 2, 2, 2, 2, 3, 4], [4, 3, 2, 1, 1, 1, 2, 2, 3, 4], [4, 3, 2, 1, 4, 1, 2, 2, 3, 4], [4, 3, 2, 1, 4, 4, 1, 2, 3, 4], [4, 3, 2, 1, 4, 4, 4, 1, 3, 4], [4, 3, 2, 1, 4, 4, 4, 4, 3, 4], [4, 3, 2, 1, 4, 4, 4, 4, 4, 4], [4, 3, 2, 1, 4, 4, 4, 4, 4, 4]]) == 8\n assert candidate(grid = [[2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2]]) == 8\n assert candidate(grid = [[1, 1, 1, 4, 1, 1], [2, 2, 2, 4, 2, 2], [1, 1, 1, 4, 1, 1], [4, 4, 4, 1, 4, 4], [1, 1, 1, 4, 1, 1], [2, 2, 2, 4, 2, 2]]) == 5\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 3, 2, 3, 4], [3, 2, 1, 4, 3], [1, 2, 3, 4, 1], [3, 4, 1, 2, 3], [2, 1, 4, 3, 2]]) == 2\n assert candidate(grid = [[1, 1, 1, 2, 3, 4], [4, 3, 2, 1, 1, 1], [1, 2, 3, 4, 2, 1], [2, 3, 4, 1, 3, 4]]) == 3\n assert candidate(grid = [[1, 4, 3, 2, 1], [1, 4, 3, 2, 1], [1, 4, 3, 2, 1], [1, 4, 3, 2, 1], [1, 4, 3, 2, 1]]) == 3\n assert candidate(grid = [[1, 3, 2, 3, 4], [4, 2, 3, 1, 2], [3, 1, 4, 2, 3], [2, 4, 1, 3, 4], [1, 2, 3, 4, 1]]) == 3\n assert candidate(grid = [[2, 1, 2, 3, 2], [1, 2, 1, 2, 1], [2, 1, 2, 1, 2], [1, 2, 1, 2, 1], [2, 1, 2, 1, 2]]) == 4\n assert candidate(grid = [[1, 2, 3, 4, 1], [2, 3, 4, 1, 2], [3, 4, 1, 2, 3], [4, 1, 2, 3, 4], [1, 2, 3, 4, 1]]) == 4\n assert candidate(grid = [[3, 4, 3, 4, 3, 4, 3, 4, 3], [1, 2, 1, 2, 1, 2, 1, 2, 1], [3, 4, 3, 4, 3, 4, 3, 4, 3], [1, 2, 1, 2, 1, 2, 1, 2, 1], [3, 4, 3, 4, 3, 4, 3, 4, 3], [1, 2, 1, 2, 1, 2, 1, 2, 1], [3, 4, 3, 4, 3, 4, 3, 4, 3], [1, 2, 1, 2, 1, 2, 1, 2, 1], [3, 4, 3, 4, 3, 4, 3, 4, 3]]) == 8\n assert candidate(grid = [[2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2]]) == 5\n assert candidate(grid = [[1, 1, 2, 4, 3], [3, 2, 1, 1, 4], [1, 3, 4, 1, 2], [2, 1, 3, 4, 1], [3, 4, 1, 2, 1]]) == 2\n assert candidate(grid = [[1, 2, 3, 4, 1, 2, 3, 4], [4, 3, 2, 1, 4, 3, 2, 1], [1, 2, 3, 4, 1, 2, 3, 4], [2, 1, 4, 3, 2, 1, 4, 3]]) == 5\n assert candidate(grid = [[1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3]]) == 9\n assert candidate(grid = [[2, 2, 2, 4, 4], [4, 3, 3, 2, 1], [3, 1, 1, 3, 2], [2, 1, 4, 3, 1], [4, 3, 2, 1, 2]]) == 2\n assert candidate(grid = [[1, 2, 3, 4], [4, 3, 2, 1], [1, 4, 3, 2], [2, 3, 4, 1]]) == 3\n assert candidate(grid = [[1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [2, 1, 4, 3, 2, 1, 4, 3, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]]) == 6\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [1, 2, 3, 4, 3, 2, 1, 4, 3, 2], [2, 1, 4, 3, 2, 1, 4, 3, 2, 1], [3, 4, 1, 2, 3, 4, 1, 2, 3, 4], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [2, 1, 4, 3, 2, 1, 4, 3, 2, 1]]) == 6\n assert candidate(grid = [[1, 4, 3, 3, 2, 2, 1, 1, 2, 4], [3, 4, 4, 2, 2, 1, 4, 3, 2, 4], [4, 3, 2, 4, 2, 1, 1, 1, 4, 3], [3, 4, 2, 2, 1, 1, 4, 3, 2, 4], [1, 2, 4, 1, 3, 3, 2, 2, 4, 3], [3, 2, 3, 4, 3, 4, 1, 1, 2, 3], [4, 3, 4, 2, 1, 1, 2, 2, 3, 4], [3, 4, 3, 1, 2, 2, 3, 4, 1, 2], [1, 2, 4, 3, 2, 2, 1, 1, 4, 3], [3, 2, 3, 4, 1, 1, 2, 2, 3, 4]]) == 6\n assert candidate(grid = [[1, 3, 2, 4, 1], [1, 1, 3, 2, 4], [3, 4, 1, 1, 3], [2, 3, 4, 1, 1], [1, 2, 3, 4, 2]]) == 1\n assert candidate(grid = [[3, 2, 1, 4, 3, 2, 1, 4, 3, 2], [2, 1, 4, 3, 2, 1, 4, 3, 2, 1], [1, 4, 3, 2, 1, 4, 3, 2, 1, 4], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [3, 2, 1, 4, 3, 2, 1, 4, 3, 2], [2, 1, 4, 3, 2, 1, 4, 3, 2, 1], [1, 4, 3, 2, 1, 4, 3, 2, 1, 4], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [3, 2, 1, 4, 3, 2, 1, 4, 3, 2], [2, 1, 4, 3, 2, 1, 4, 3, 2, 1]]) == 9\n assert candidate(grid = [[4, 4, 4, 4, 4], [4, 4, 4, 4, 4], [4, 4, 4, 4, 4], [4, 4, 4, 4, 4], [4, 4, 4, 4, 4]]) == 8\n assert candidate(grid = [[1, 2, 3, 4, 1, 2], [3, 4, 1, 2, 3, 4], [2, 1, 4, 3, 2, 1], [4, 3, 2, 1, 4, 3], [1, 2, 3, 4, 1, 2], [3, 4, 1, 2, 3, 4]]) == 4\n assert candidate(grid = [[1, 2, 3, 4, 1], [4, 3, 2, 1, 4], [1, 2, 3, 4, 1], [4, 3, 2, 1, 4], [1, 2, 3, 4, 1]]) == 4\n assert candidate(grid = [[1, 2, 3, 4, 3, 2, 1, 4], [4, 3, 2, 1, 4, 3, 2, 1], [1, 4, 3, 2, 1, 4, 3, 2], [2, 1, 4, 3, 2, 1, 4, 3], [3, 2, 1, 4, 3, 2, 1, 4]]) == 5\n assert candidate(grid = [[4, 2, 3, 1, 3, 1, 4], [2, 4, 3, 2, 1, 3, 2], [3, 1, 4, 3, 2, 4, 3], [1, 3, 2, 4, 3, 1, 2], [4, 2, 3, 1, 2, 3, 4]]) == 5\n assert candidate(grid = [[3, 3, 2, 1, 1], [4, 3, 2, 4, 3], [2, 3, 3, 4, 2], [1, 4, 4, 4, 1], [2, 2, 3, 1, 2]]) == 4\n assert candidate(grid = [[1, 1, 2, 2, 3, 3], [4, 4, 1, 1, 2, 2], [3, 3, 4, 4, 1, 1], [2, 2, 3, 3, 4, 4], [1, 1, 2, 2, 3, 3], [4, 4, 1, 1, 2, 2]]) == 4\n assert candidate(grid = [[2, 3, 4, 1, 2], [1, 2, 3, 4, 1], [4, 1, 2, 3, 4], [3, 4, 1, 2, 3], [2, 1, 4, 3, 1]]) == 4\n assert candidate(grid = [[1, 4, 2, 3, 4, 1, 2], [2, 3, 4, 1, 2, 3, 4], [1, 2, 3, 4, 1, 2, 3], [2, 3, 4, 1, 2, 3, 4], [3, 4, 1, 2, 3, 4, 1]]) == 5\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]) == 7\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2]]) == 7\n assert candidate(grid = [[3, 2, 1, 4, 3, 2, 1, 4], [2, 1, 4, 3, 2, 1, 4, 3], [3, 2, 1, 4, 3, 2, 1, 4], [4, 3, 2, 1, 4, 3, 2, 1], [3, 2, 1, 4, 3, 2, 1, 4], [2, 1, 4, 3, 2, 1, 4, 3], [3, 2, 1, 4, 3, 2, 1, 4], [4, 3, 2, 1, 4, 3, 2, 1]]) == 7\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 3, 2, 4], [2, 4, 3, 1], [3, 1, 4, 2], [4, 2, 1, 3]]) == 2\n assert candidate(grid = [[1, 3, 1, 1, 3, 2], [1, 2, 2, 2, 3, 3], [2, 2, 2, 1, 1, 3], [3, 3, 1, 2, 2, 3], [3, 2, 3, 3, 1, 1], [1, 1, 1, 3, 1, 1]]) == 2\n assert candidate(grid = [[1, 2, 1, 2, 1], [3, 4, 3, 4, 3], [1, 2, 1, 2, 1], [3, 4, 3, 4, 3], [1, 2, 1, 2, 1]]) == 4\n assert candidate(grid = [[1, 3, 4, 3, 1, 2], [2, 4, 3, 1, 2, 3], [3, 1, 2, 3, 4, 1], [4, 2, 3, 4, 1, 2], [1, 3, 4, 1, 2, 3], [2, 4, 1, 2, 3, 4]]) == 4\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 1, 1, 4, 3, 2, 1], [1, 2, 3, 4, 1, 2, 4, 3, 2, 1], [1, 2, 3, 4, 1, 2, 3, 4, 2, 1], [1, 2, 3, 4, 1, 2, 3, 4, 3, 1], [1, 2, 3, 4, 1, 2, 3, 4, 4, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 3, 1, 1, 1], [1, 4, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 3\n assert candidate(grid = [[1, 1, 1, 2, 3, 3, 3, 4], [2, 2, 2, 1, 1, 1, 4, 3], [3, 3, 2, 2, 2, 4, 1, 2], [4, 4, 3, 3, 3, 1, 2, 1], [1, 1, 4, 4, 4, 2, 1, 3], [2, 2, 1, 1, 1, 3, 2, 4], [3, 3, 2, 2, 2, 4, 3, 1], [4, 4, 3, 3, 3, 1, 4, 2]]) == 6\n assert candidate(grid = [[4, 3, 2, 1], [1, 2, 3, 4], [4, 3, 2, 1], [1, 2, 3, 4]]) == 4\n assert candidate(grid = [[2, 2, 2, 1, 1], [1, 1, 1, 2, 2], [2, 2, 2, 1, 1], [1, 1, 1, 2, 2], [2, 2, 2, 1, 1]]) == 4\n assert candidate(grid = [[1, 3, 2, 4, 1], [2, 4, 1, 3, 2], [3, 1, 4, 2, 3], [4, 2, 3, 1, 4], [1, 4, 3, 2, 1]]) == 3\n assert candidate(grid = [[4, 3, 2, 1], [3, 2, 1, 4], [2, 1, 4, 3], [1, 4, 3, 2]]) == 3\n assert candidate(grid = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[2, 3, 4, 1, 1, 2], [1, 4, 2, 3, 4, 2], [2, 3, 1, 4, 2, 3], [3, 4, 2, 1, 3, 4], [4, 1, 3, 2, 4, 1], [1, 2, 4, 3, 1, 2]]) == 5\n assert candidate(grid = [[1, 2, 3, 4, 1, 2, 3], [2, 3, 4, 1, 2, 3, 4], [3, 4, 1, 2, 3, 4, 1], [4, 1, 2, 3, 4, 1, 2], [1, 2, 3, 4, 1, 2, 3], [2, 3, 4, 1, 2, 3, 4], [3, 4, 1, 2, 3, 4, 1]]) == 6\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [3, 2, 1, 4, 3, 2, 1, 4, 3, 2], [2, 1, 4, 3, 2, 1, 4, 3, 2, 1], [1, 4, 3, 2, 1, 4, 3, 2, 1, 4]]) == 6\n assert candidate(grid = [[1, 2, 2, 2, 3, 3, 1], [3, 1, 1, 1, 1, 2, 3], [2, 3, 3, 3, 2, 3, 2], [1, 1, 1, 1, 3, 2, 1], [2, 3, 2, 3, 1, 1, 2], [3, 2, 3, 2, 1, 2, 3], [1, 2, 1, 2, 3, 3, 1]]) == 3\n assert candidate(grid = [[2, 3, 4, 1], [4, 1, 2, 3], [1, 2, 3, 4], [3, 4, 1, 2]]) == 2\n assert candidate(grid = [[3, 3, 2, 1, 1], [2, 1, 1, 4, 1], [1, 2, 1, 4, 3], [2, 1, 4, 2, 4], [1, 2, 3, 4, 4]]) == 4\n assert candidate(grid = [[1, 1, 2, 2, 3, 3], [3, 3, 4, 4, 1, 1], [2, 2, 1, 1, 4, 4], [4, 4, 3, 3, 2, 2], [1, 1, 2, 2, 3, 3], [3, 3, 4, 4, 1, 1]]) == 4\n assert candidate(grid = [[1, 2, 3, 4, 1], [1, 2, 3, 4, 1], [1, 2, 3, 4, 1], [1, 2, 3, 4, 1], [1, 2, 3, 4, 1]]) == 3\n assert candidate(grid = [[4, 1, 1, 1, 3], [2, 4, 2, 4, 2], [1, 2, 1, 2, 1], [3, 2, 3, 2, 3], [1, 4, 1, 4, 1]]) == 3\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[2, 2, 4, 1, 2, 4, 1, 3, 3, 4], [1, 1, 1, 3, 3, 4, 2, 1, 3, 1], [3, 2, 2, 1, 1, 2, 4, 4, 4, 3], [4, 1, 3, 2, 4, 1, 3, 2, 3, 1], [2, 3, 4, 2, 1, 4, 1, 1, 3, 4], [1, 4, 1, 4, 2, 1, 2, 4, 3, 4]]) == 3\n assert candidate(grid = [[1, 2, 3, 4, 1, 2, 3, 4], [2, 3, 4, 1, 2, 3, 4, 1], [3, 4, 1, 2, 3, 4, 1, 2], [4, 1, 2, 3, 4, 1, 2, 3], [1, 2, 3, 4, 1, 2, 3, 4]]) == 5\n assert candidate(grid = [[1, 3, 2, 4, 1, 2, 3, 4], [2, 4, 3, 1, 2, 3, 4, 1], [3, 1, 4, 2, 3, 4, 1, 2], [4, 2, 3, 4, 1, 2, 3, 4], [1, 3, 4, 1, 2, 3, 4, 1], [2, 4, 1, 2, 3, 4, 1, 2], [3, 1, 2, 3, 4, 1, 2, 3], [4, 2, 3, 4, 1, 2, 3, 4]]) == 6\n assert candidate(grid = [[1, 2, 2, 3], [3, 4, 1, 2], [1, 3, 4, 2], [2, 1, 3, 4]]) == 2\n assert candidate(grid = [[2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1], [4, 4, 4, 4, 4, 4, 4, 4, 4], [4, 4, 4, 4, 4, 4, 4, 4, 4], [4, 4, 4, 4, 4, 4, 4, 4, 4], [4, 4, 4, 4, 4, 4, 4, 4, 4], [4, 4, 4, 4, 4, 4, 4, 4, 4]]) == 8\n assert candidate(grid = [[3, 3, 3, 3, 3, 3, 3], [2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1], [4, 4, 4, 4, 4, 4, 4], [1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3]]) == 5\n assert candidate(grid = [[3, 1, 1, 2, 1, 4, 1], [3, 3, 4, 1, 3, 3, 3], [3, 4, 2, 2, 3, 1, 3], [3, 3, 3, 1, 1, 4, 3], [1, 3, 2, 3, 4, 4, 2], [2, 2, 4, 1, 3, 2, 4], [4, 4, 1, 1, 2, 3, 3]]) == 4\n assert candidate(grid = [[1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [2, 3, 4, 1, 2, 3, 4, 1, 2, 3], [3, 4, 1, 2, 3, 4, 1, 2, 3, 4], [4, 1, 2, 3, 4, 1, 2, 3, 4, 1], [1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [2, 3, 4, 1, 2, 3, 4, 1, 2, 3], [3, 4, 1, 2, 3, 4, 1, 2, 3, 4], [4, 1, 2, 3, 4, 1, 2, 3, 4, 1], [1, 2, 3, 4, 1, 2, 3, 4, 1, 2], [2, 3, 4, 1, 2, 3, 4, 1, 2, 3]]) == 9\n assert candidate(grid = [[3, 1, 2, 1, 4], [1, 4, 3, 2, 1], [2, 3, 4, 1, 2], [4, 1, 2, 3, 4], [1, 2, 3, 4, 3]]) == 3\n assert candidate(grid = [[4, 4, 4, 2, 4, 1, 2, 4], [1, 4, 2, 4, 2, 4, 4, 4], [2, 1, 3, 3, 1, 3, 3, 1], [4, 2, 3, 4, 1, 2, 4, 4], [1, 3, 4, 4, 1, 2, 3, 1], [2, 4, 2, 2, 4, 4, 1, 2], [4, 3, 4, 2, 1, 2, 3, 4], [4, 4, 4, 1, 3, 4, 2, 3]]) == 7\n assert candidate(grid = [[3, 3, 3, 3, 3, 3, 3], [2, 1, 2, 1, 2, 1, 2], [3, 3, 3, 3, 3, 3, 3], [1, 2, 1, 2, 1, 2, 1], [3, 3, 3, 3, 3, 3, 3], [2, 1, 2, 1, 2, 1, 2]]) == 4\n assert candidate(grid = [[4, 4, 4, 4], [4, 4, 4, 4], [4, 4, 4, 4], [4, 4, 4, 4]]) == 6\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 2, 1, 2, 1, 2, 1], [1, 1, 1, 1, 1, 1, 1], [1, 2, 1, 2, 1, 2, 1], [1, 1, 1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 4, 1, 4, 1, 4, 1], [2, 3, 2, 3, 2, 3, 2], [1, 4, 1, 4, 1, 4, 1], [2, 3, 2, 3, 2, 3, 2], [1, 4, 1, 4, 1, 4, 1], [2, 3, 2, 3, 2, 3, 2], [1, 4, 1, 4, 1, 4, 1]]) == 6\n assert candidate(grid = [[4, 1, 2, 3], [3, 4, 1, 2], [2, 3, 4, 1], [1, 2, 3, 4], [4, 3, 2, 1]]) == 4\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minCost(vector>& grid) {", "container": "Solution", "callable": "minCost", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1370, "task_id": "increasing-decreasing-string", "difficulty": "Easy", "problem_description": "You are given a string s. Reorder the string using the following algorithm:\n\nRemove the smallest character from s and append it to the result.\nRemove the smallest character from s that is greater than the last appended character, and append it to the result.\nRepeat step 2 until no more characters can be removed.\nRemove the largest character from s and append it to the result.\nRemove the largest character from s that is smaller than the last appended character, and append it to the result.\nRepeat step 5 until no more characters can be removed.\nRepeat steps 1 through 6 until all characters from s have been removed.\n\nIf the smallest or largest character appears more than once, you may choose any occurrence to append to the result.\nReturn the resulting string after reordering s using this algorithm.\n \nExample 1:\n\nInput: s = \"aaaabbbbcccc\"\nOutput: \"abccbaabccba\"\nExplanation: After steps 1, 2 and 3 of the first iteration, result = \"abc\"\nAfter steps 4, 5 and 6 of the first iteration, result = \"abccba\"\nFirst iteration is done. Now s = \"aabbcc\" and we go back to step 1\nAfter steps 1, 2 and 3 of the second iteration, result = \"abccbaabc\"\nAfter steps 4, 5 and 6 of the second iteration, result = \"abccbaabccba\"\n\nExample 2:\n\nInput: s = \"rat\"\nOutput: \"art\"\nExplanation: The word \"rat\" becomes \"art\" after re-ordering it with the mentioned algorithm.\n\n \nConstraints:\n\n1 <= s.length <= 500\ns consists of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"rqy\") == \"qry\"\n assert candidate(s = \"fuvofn\") == \"fnouvf\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"vibhu\") == \"bhiuv\"\n assert candidate(s = \"xyyzz\") == \"xyzzy\"\n assert candidate(s = \"ijkpqxz\") == \"ijkpqxz\"\n assert candidate(s = \"hfnmwy\") == \"fhmnwy\"\n assert candidate(s = \"tkfjkj\") == \"fjktkj\"\n assert candidate(s = \"rat\") == \"art\"\n assert candidate(s = \"a\") == \"a\"\n assert candidate(s = \"abacabadabacaba\") == \"abcdcbaabbaaaaa\"\n assert candidate(s = \"ukqay\") == \"akquy\"\n assert candidate(s = \"spo\") == \"ops\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\") == \"abcddcbaabcddcbaabcddcbaabcddcba\"\n assert candidate(s = \"ukqms\") == \"kmqsu\"\n assert candidate(s = \"leetcode\") == \"cdelotee\"\n assert candidate(s = \"mnbvcxzlkjhgfdsapoiuytrewq\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aaaabbbbcccc\") == \"abccbaabccba\"\n assert candidate(s = \"ggggggg\") == \"ggggggg\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"abacaba\") == \"abcbaaa\"\n assert candidate(s = \"aaaazzzz\") == \"azzaazza\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"wzyzxwzyzxwzyz\") == \"wxyzzyxwwyzzzz\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzz\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbazzzzzzzzzzzzzzz\"\n assert candidate(s = \"xzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzy\") == \"xyzzyxxyzzyxxyzzyxxyzzyxxyzzyxxyzzyxxyzzyx\"\n assert candidate(s = \"abacabadabacabadabacabad\") == \"abcddcbaabcdbaabbaaaaaaa\"\n assert candidate(s = \"rearrange\") == \"aegnrrear\"\n assert candidate(s = \"abcdefghiabcdefghiabcdefghiabcdefghiabcdefghi\") == \"abcdefghiihgfedcbaabcdefghiihgfedcbaabcdefghi\"\n assert candidate(s = \"zzzzzyyyyxxxwwvvuuttssrrqqppoonnmmlkkjjiihhggffeedcba\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmkjihgfexyzzyz\"\n assert candidate(s = \"zzzzzyyyxxxwwwwvvvuuttssrrqqppoonnmmlkkjjiihhggffeeddccba\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmkjihgfedcvwxyzzwz\"\n assert candidate(s = \"qwertypoiuytrewqpoiuytr\") == \"eiopqrtuwyywutrqpoierty\"\n assert candidate(s = \"aabbccccdddd\") == \"abcddcbacddc\"\n assert candidate(s = \"ppqqrrsstttuuuuvvvwwxxxyyyzzzz\") == \"pqrstuvwxyzzyxwvutsrqptuvxyzzu\"\n assert candidate(s = \"thisisaverylongstringthatneedstobesortedbythealgorithm\") == \"abdeghilmnorstvyytsronlihgedbaaeghinorsttsroiheesttett\"\n assert candidate(s = \"lkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkj\") == \"jkllkjjkllkjjkllkjjkllkjjkllkjjkllkjjkllkj\"\n assert candidate(s = \"abcdabcdbcdabcdabcdbcdabcdabcdbcd\") == \"abcddcbaabcddcbaabcddcbabcddcbbcd\"\n assert candidate(s = \"nnnnoooppqqrrsssttuuuvvwwxxxyyyzzz\") == \"nopqrstuvwxyzzyxwvutsrqponnosuxyzn\"\n assert candidate(s = \"svilikwd\") == \"diklsvwi\"\n assert candidate(s = \"ppqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpqpq\") == \"pqqppqqppqqppqqppqqppqqppqqppqqppqqppqqppqqppqp\"\n assert candidate(s = \"zabzabzabzabzabzabzabzabzabzabzabzabzab\") == \"abzzbaabzzbaabzzbaabzzbaabzzbaabzzbaabz\"\n assert candidate(s = \"ppqpqpppqpppqpppqpqppppqpqpppppp\") == \"pqqppqqppqqppqqppppppppppppppppp\"\n assert candidate(s = \"fedcbazyxwvutsrqponmlkjihgfedcba\") == \"abcdefghijklmnopqrstuvwxyzfedcba\"\n assert candidate(s = \"successfultesting\") == \"cefgilnstuutsecss\"\n assert candidate(s = \"mmuuxxxaannnltttvvvsssss\") == \"almnstuvxxvutsnmanstvxss\"\n assert candidate(s = \"abababababababababababab\") == \"abbaabbaabbaabbaabbaabba\"\n assert candidate(s = \"aabbbcccddddeeeeefffffff\") == \"abcdeffedcbabcdeffedefff\"\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnooopppqqqrrrssstttuuuvvvwwwxxyyzzz\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmopqrstuvwz\"\n assert candidate(s = \"abracadabraabracadabraabracadabra\") == \"abcdrrdcbaabcdrrbaabrrbaaaaaaaaaa\"\n assert candidate(s = \"xyzzzyyxwvutsrqponmlkjihgfedcba\") == \"abcdefghijklmnopqrstuvwxyzzyxyz\"\n assert candidate(s = \"abcdabcdbca\") == \"abcddcbaabc\"\n assert candidate(s = \"zzzzzyyyyyxxxxxxwwwwvvvvuuuuttttssssrrrrqqqqpppplllloooonnnnmmmmlkkkkjjjjiiihhhhggggffffeeeedddccccbbbaaaaaa\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjhgfecaalxyzxa\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzz\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbazz\"\n assert candidate(s = \"abcdefabcdefabcdefabcdef\") == \"abcdeffedcbaabcdeffedcba\"\n assert candidate(s = \"banana\") == \"abnnaa\"\n assert candidate(s = \"gggggggggggggggggggggggggg\") == \"gggggggggggggggggggggggggg\"\n assert candidate(s = \"mmmmnnnnnnnnlllllkkkkjjjjiiihhhhggggffffffeeeeeeeedddddcccccbbbbbaaaaa\") == \"abcdefghijklmnnmlkjihgfedcbaabcdefghijklmnnmlkjhgfedcbaabcdeflnnfeenne\"\n assert candidate(s = \"mamamamamamamamamamamama\") == \"ammaammaammaammaammaamma\"\n assert candidate(s = \"pppppppppppppppppppppppppppppppppppppppppppppppppppppp\") == \"pppppppppppppppppppppppppppppppppppppppppppppppppppppp\"\n assert candidate(s = \"elephantzoo\") == \"aehlnoptzoe\"\n assert candidate(s = \"elephant\") == \"aehlnpte\"\n assert candidate(s = \"algorithm\") == \"aghilmort\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzz\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbazzzzzz\"\n assert candidate(s = \"bcaaacbcabcabcabcabcabcabcabc\") == \"abccbaabccbaabccbaabccbaabcca\"\n assert candidate(s = \"qazwsxedcrfvtgbyhnujmiklopqazwsxedcrfvtgbyhnujmiklop\") == \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"mississippi\") == \"impsspiissi\"\n assert candidate(s = \"flfrffvfrmfvffvvfrrfmfffffrfrfrff\") == \"flmrvvrmffrvvrffrrffrffffffffffff\"\n assert candidate(s = \"abcdefgfedcbabcdefgfedcba\") == \"abcdefggfedcbaabcdeffedcb\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().sortString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string sortString(string s) {", "container": "Solution", "callable": "sortString", "parameters": [{"name": "s", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1371, "task_id": "find-the-longest-substring-containing-vowels-in-even-counts", "difficulty": "Medium", "problem_description": "Given the string s, return the size of the longest substring containing each vowel an even number of times. That is, 'a', 'e', 'i', 'o', and 'u' must appear an even number of times.\n \nExample 1:\n\nInput: s = \"eleetminicoworoep\"\nOutput: 13\nExplanation: The longest substring is \"leetminicowor\" which contains two each of the vowels: e, i and o and zero of the vowels: a and u.\n\nExample 2:\n\nInput: s = \"leetcodeisgreat\"\nOutput: 5\nExplanation: The longest substring is \"leetc\" which contains two e's.\n\nExample 3:\n\nInput: s = \"bcbcbc\"\nOutput: 6\nExplanation: In this case, the given string \"bcbcbc\" is the longest because all vowels: a, e, i, o and u appear zero times.\n\n \nConstraints:\n\n1 <= s.length <= 5 x 10^5\ns contains only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"bcbcbc\") == 6\n assert candidate(s = \"cbacdcdcdbacdbad\") == 14\n assert candidate(s = \"aeiouaeiouaeiouaeiou\") == 20\n assert candidate(s = \"aaaaaeeeeeiioooouuuu\") == 14\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 5\n assert candidate(s = \"uuuuuuuuuuuuuuuuuuuuuuuuuuu\") == 26\n assert candidate(s = \"aaeeiioouu\") == 10\n assert candidate(s = \"aeiou\") == 0\n assert candidate(s = \"aaaaa\") == 4\n assert candidate(s = \"a\") == 0\n assert candidate(s = \"leetcodeisgreat\") == 5\n assert candidate(s = \"abacabadabacaba\") == 15\n assert candidate(s = \"aeiaaioaaaaeiiiiouuuooaaaaea\") == 18\n assert candidate(s = \"\") == 0\n assert candidate(s = \"aeeeeeiiiiioooouuuu\") == 12\n assert candidate(s = \"xyz\") == 3\n assert candidate(s = \"abcdefghiijkeilmnopqrstuvwxyzaeiou\") == 12\n assert candidate(s = \"aabbeeaabbeeaabb\") == 16\n assert candidate(s = \"eiouaeiouaeiou\") == 10\n assert candidate(s = \"eleetminicoworoep\") == 13\n assert candidate(s = \"bbaeixaaaaooxu\") == 8\n assert candidate(s = \"aioieu\") == 0\n assert candidate(s = \"bcdfghjklmnpqrstvwxyz\") == 21\n assert candidate(s = \"aeiaaioaaaaeiiiiiioooeeeauuaeuia\") == 28\n assert candidate(s = \"aabbccddeeff\") == 12\n assert candidate(s = \"leetcodeleetcode\") == 16\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 52\n assert candidate(s = \"zxcvbnmlkjhgfdsapoiuytrewq\") == 15\n assert candidate(s = \"aaaaaaaa\") == 8\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiouxyzuvwaeiouaeiouaeiou\") == 45\n assert candidate(s = \"eeioouuuaeeioouuua\") == 18\n assert candidate(s = \"aeiouaeiouaeiou\") == 10\n assert candidate(s = \"abacaxebecixodeoxou\") == 9\n assert candidate(s = \"thisisaverylongstringwithvariousvowels\") == 13\n assert candidate(s = \"eiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 40\n assert candidate(s = \"uoieaouioeaoieauoi\") == 12\n assert candidate(s = \"mamad\") == 5\n assert candidate(s = \"leetcodeleetcodeleetcode\") == 21\n assert candidate(s = \"bbaaccddeeffgg\") == 14\n assert candidate(s = \"eiouaeiouaieouaeiouaeiouaeiou\") == 20\n assert candidate(s = \"xyzuvwaeiouaeiouxyzuvwaeiouaeiouxyzuvwaeiouaeiou\") == 47\n assert candidate(s = \"abcdeabcdeabcde\") == 13\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiouaeiouabcdeffedcbaaeiouaeiou\") == 52\n assert candidate(s = \"xyzabcdeiouaeiouabcdeiouaeiouxyz\") == 32\n assert candidate(s = \"bbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 50\n assert candidate(s = \"bcbcbcbaeibcbcbcbaeibcbcbc\") == 26\n assert candidate(s = \"aeeeeiiiooouuuuuuuuu\") == 10\n assert candidate(s = \"bcbcbcabcabcabcabcabcabc\") == 24\n assert candidate(s = \"abacaxebecixodeoxouabacaxebecixodeoxou\") == 38\n assert candidate(s = \"zzzaeizzzaeiouzzzaeiouzzz\") == 19\n assert candidate(s = \"aeiouabcdefghijklmnopqrstuvwxyzaeiou\") == 31\n assert candidate(s = \"uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu\") == 52\n assert candidate(s = \"uvceeaieeaaceeaiaa\") == 17\n assert candidate(s = \"aebecixodeoxouaebecixodeoxou\") == 28\n assert candidate(s = \"vvvvvvvvvvvvvvvvvv\") == 18\n assert candidate(s = \"aebecidofugoeiaoeiu\") == 4\n assert candidate(s = \"aeiouaeiouabcdeffedcbaaeiouaeiou\") == 32\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzaeiouaeiouaeiou\") == 41\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 52\n assert candidate(s = \"leetcodeisgreataeiou\") == 17\n assert candidate(s = \"aeiouaeiouaeiouxyzuvw\") == 17\n assert candidate(s = \"abcdeffedcbabcdeffedcbabcdeffedcbabcdeffedcb\") == 44\n assert candidate(s = \"xyzuvwaeiouxyzuvwaeiou\") == 22\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmaeiouaeiou\") == 31\n assert candidate(s = \"vwxyz\") == 5\n assert candidate(s = \"aabbccddeeffgg\") == 14\n assert candidate(s = \"eleetminicoworoepzzzzzzzzzz\") == 13\n assert candidate(s = \"abecidofug\") == 1\n assert candidate(s = \"eiouaieouaieoua\") == 10\n assert candidate(s = \"aeiaoeiuioeiuaeiaoeiuioeiuaeiaoeiuioeiaoeiu\") == 26\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 50\n assert candidate(s = \"eiouaeiouaeiouaeiouaeiouaeiou\") == 20\n assert candidate(s = \"eleetminicoworoepaeiou\") == 13\n assert candidate(s = \"eeioouuuaeeioouuuaeeioouuuaeeioouuua\") == 36\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 50\n assert candidate(s = \"aabbccddeeffaabbccddeeff\") == 24\n assert candidate(s = \"leetcodeisgreatleetcodeisgreatleetcodeisgreat\") == 35\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().findTheLongestSubstring", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int findTheLongestSubstring(string s) {", "container": "Solution", "callable": "findTheLongestSubstring", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1372, "task_id": "longest-zigzag-path-in-a-binary-tree", "difficulty": "Medium", "problem_description": "You are given the root of a binary tree.\nA ZigZag path for a binary tree is defined as follow:\n\nChoose any node in the binary tree and a direction (right or left).\nIf the current direction is right, move to the right child of the current node; otherwise, move to the left child.\nChange the direction from right to left or from left to right.\nRepeat the second and third steps until you can't move in the tree.\n\nZigzag length is defined as the number of nodes visited - 1. (A single node has a length of 0).\nReturn the longest ZigZag path contained in that tree.\n \nExample 1:\n\n\nInput: root = [1,null,1,1,1,null,null,1,1,null,1,null,null,null,1]\nOutput: 3\nExplanation: Longest ZigZag path in blue nodes (right -> left -> right).\n\nExample 2:\n\n\nInput: root = [1,1,1,null,1,null,null,1,1,null,1]\nOutput: 4\nExplanation: Longest ZigZag path in blue nodes (left -> right -> left -> right).\n\nExample 3:\n\nInput: root = [1]\nOutput: 0\n\n \nConstraints:\n\nThe number of nodes in the tree is in the range [1, 5 * 104].\n1 <= Node.val <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([1, None, 1, 1, 1, None, None, 1, 1, None, 1, None, None, None, 1])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7])) == 2\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5])) == 1\n assert candidate(root = tree_node([1, 1, 1, None, 1, None, None, 1, 1, None, 1])) == 4\n assert candidate(root = tree_node([1])) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, None, None, None, 8, 9, 10, 11, 12, 13, 14, 15])) == 3\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])) == 1\n assert candidate(root = tree_node([1, None, 2, 3, None, None, 4, 5, None, None, 6, None, None, 7, 8, None, None, 9, None, None, 10])) == 5\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, 6, 7, None, None, 8, 9, None, None, None, None, None, None, None, 10])) == 2\n assert candidate(root = tree_node([1, 2, 3, None, 4, 5, None, 6, None, 7, 8, 9, None, 10, None, None, 11, None, None, 12])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, None, None, None, None, None, 9, 10])) == 2\n assert candidate(root = tree_node([1, 2, None, 3, 4, None, None, 5, 6, None, 7, None, 8])) == 4\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6])) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, None, 6, 7, None, 8, None, None, 9, 10, None, None, 11, 12, None, None, 13, 14, None, None, 15, 16])) == 4\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15])) == 1\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9])) == 1\n assert candidate(root = tree_node([1, None, 3, 2, None, None, 4, 5, None, None, 6, 7, None, None, 8, 9])) == 8\n assert candidate(root = tree_node([1, None, 2, 3, None, None, 4, None, 5, None, 6, 7, 8, None, None, None, None, 9, 10, 11, 12, 13, 14, 15])) == 3\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8])) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, 16, 17, None, None, None, None, 18, 19, 20, None, None, 21, 22, None, None, 23, 24])) == 4\n assert candidate(root = tree_node([1, None, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9])) == 2\n assert candidate(root = tree_node([1, None, 2, 3, None, None, 4, 5, None, None, 6, 7, 8, None, None, 9, None, 10])) == 6\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, 6, 7, None, None, 8, 9])) == 2\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, None, 6, None, None, 7, None, 8, None, None, None, 9])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, None, 16])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, None, None, 6, 7, 8, None, None, 9, None, 10, None, 11])) == 2\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])) == 4\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11])) == 1\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, None, None, None, 14, 15, 16, 17, 18, 19, 20])) == 5\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, None, None, 10, 11, None, None, 12, 13, None, None, 14, 15])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, 8, None, 9, None, 10])) == 3\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, 6, None, None, 7, None, None, 8, None, 9])) == 3\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11])) == 2\n assert candidate(root = tree_node([1, 2, None, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])) == 2\n assert candidate(root = tree_node([1, None, 2, None, None, None, 3, None, None, None, None, 4, None, None, None, None, 5])) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, None, None, 6, None, None, 7, 8, 9])) == 4\n assert candidate(root = tree_node([1, 2, 3, 4, None, 5, None, 6, None, 7, None, 8, None, 9])) == 2\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 6, None, 7, None, 8, 9, None, 10])) == 3\n assert candidate(root = tree_node([1, None, 2, 3, None, None, 4, None, None, 5])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, None, None, None, None, None, None, None, 6, 7, 8, 9, 10, 11])) == 1\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, None, 5, 6, None, 7, None, 8, None, None, None, 9])) == 4\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15])) == 2\n assert candidate(root = tree_node([1, 2, 3, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])) == 2\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == 3\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, None, 6, 7, None, None, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, 16, None, 17])) == 3\n assert candidate(root = tree_node([1, None, 2, 3, None, None, 4, None, 5, None, None, 6, None, None, 7])) == 3\n assert candidate(root = tree_node([1, None, 2, 3, None, None, 4, None, 5, None, 6])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15])) == 2\n assert candidate(root = tree_node([1, 2, 3, None, 4, 5, 6, None, 7, None, 8, 9, 10, None, None, None, None, 11, 12, 13, 14])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])) == 4\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, None, 6, 7, None, 8, 9, None, None, None, 10])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, None, 6, None, None, 7, None, 8])) == 3\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15])) == 2\n assert candidate(root = tree_node([1, None, 2, 3, None, 4, None, 5, 6, 7, 8, 9, 10, 11, 12])) == 3\n assert candidate(root = tree_node([1, None, 2, 3, None, None, 4, 5, None, None, 6, None, None, 7, 8, None, None, 9, 10, None, None, 11])) == 5\n assert candidate(root = tree_node([1, None, 2, None, 3, 4, None, None, 5, None, None, 6, 7])) == 3\n assert candidate(root = tree_node([1, None, 2, None, None, None, 3, None, None, None, 4])) == 1\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14])) == 1\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17])) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, None, None, 9, None, None, 10, None, 11, None, 12])) == 2\n assert candidate(root = tree_node([1, None, 2, 3, None, 4, 5, None, 6, None, None, None, 7, None, 8])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, 6, None, None, 7, None, None, 8, None, None, 9])) == 3\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15])) == 1\n assert candidate(root = tree_node([1, None, 2, 3, 4, None, 5, 6, None, None, None, None, 7, 8, None, None, 9, 10])) == 6\n assert candidate(root = tree_node([1, 2, None, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])) == 4\n assert candidate(root = tree_node([1, 2, None, None, 3, None, None, 4, None, None, 5, None, None, 6, None, None, 7, None, None, 8, None, None, 9, None, None, 10])) == 2\n assert candidate(root = tree_node([1, 2, 3, None, 4, 5, None, 6, 7, None, None, None, None, 8, 9, None, None, 10, 11])) == 3\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20])) == 1\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7])) == 1\n assert candidate(root = tree_node([1, None, 2, 3, None, None, 4, 5, None, None, 6, 7, None, None, 8, 9, None, None, 10, 11, None, None, 12, 13, None, None, 14, 15])) == 14\n assert candidate(root = tree_node([1, 2, None, None, 3, 4, None, None, 5, None, None, 6, 7, None, None, 8, None, None, 9, 10, None, None, 11, 12])) == 4\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 6, 7, None, None, None, None, 8, 9, None, None, None, 10, None, None, 11, None, None, 12])) == 2\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])) == 2\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12])) == 1\n assert candidate(root = tree_node([1, 2, None, 3, None, None, 4, None, 5, None, None, 6, None, None, 7, None, None, 8, None, 9])) == 2\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, 6, 7, None, None, 8, 9, None, None, 10, 11])) == 2\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16])) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, None, 6, None, None, 7, None, None, 8, None, None, 9])) == 3\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13])) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, 6, 7, None, None, None, None, None, 8, 9, None, None, 10])) == 3\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20, None, 21, None, 22, None, 23, None, 24, None, 25])) == 1\n assert candidate(root = tree_node([1, None, 2, 3, None, None, 4, 5, None, None, 6, 7, None, None, 8, 9, None, None, 10, 11])) == 10\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9])) == 1\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11])) == 1\n assert candidate(root = tree_node([1, 2, None, 3, 4, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14])) == 3\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, 6, 7, None, None, 8, 9, None, None, 10, None, None, 11])) == 3\n assert candidate(root = tree_node([1, 2, 3, None, 4, 5, None, 6, 7, None, 8, 9, None, 10, 11, None, 12, 13, None, 14, 15])) == 3\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])) == 1\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, 6, None, None, 7, 8, None, 9, 10, None, None, None, 11, 12, 13, None, 14, None, 15, None, 16, None, 17])) == 5\n assert candidate(root = tree_node([1, None, 2, 3, None, None, 4, None, 5, 6, None, 7])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, None, None, None, None, None, 10])) == 2\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, 8, 9, None, None, None, None, 10, 11, 12, None, None, 13, None, None, 14])) == 2\n assert candidate(root = tree_node([1, None, 2, 3, 4, None, None, None, 5, None, 6, None, None, 7, None, 8, None, 9, None, 10])) == 2\n assert candidate(root = tree_node([1, None, 2, 3, None, None, 4, 5, None, 6, None, 7])) == 4\n"}, "metadata": {"canonical_parameter_names": ["root"], "leetcode_dataset_entry_point": "Solution().longestZigZag", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int longestZigZag(TreeNode* root) {", "container": "Solution", "callable": "longestZigZag", "parameters": [{"name": "root", "type": "TreeNode*"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1373, "task_id": "maximum-sum-bst-in-binary-tree", "difficulty": "Hard", "problem_description": "Given a binary tree root, return the maximum sum of all keys of any sub-tree which is also a Binary Search Tree (BST).\nAssume a BST is defined as follows:\n\nThe left subtree of a node contains only nodes with keys less than the node's key.\nThe right subtree of a node contains only nodes with keys greater than the node's key.\nBoth the left and right subtrees must also be binary search trees.\n\n \nExample 1:\n\n\nInput: root = [1,4,3,2,4,2,5,null,null,null,null,null,null,4,6]\nOutput: 20\nExplanation: Maximum sum in a valid Binary search tree is obtained in root node with key equal to 3.\n\nExample 2:\n\n\nInput: root = [4,3,null,1,2]\nOutput: 2\nExplanation: Maximum sum in a valid Binary search tree is obtained in a single root node with key equal to 2.\n\nExample 3:\n\nInput: root = [-4,-2,-5]\nOutput: 0\nExplanation: All values are negatives. Return an empty BST.\n\n \nConstraints:\n\nThe number of nodes in the tree is in the range [1, 4 * 104].\n-4 * 104 <= Node.val <= 4 * 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5])) == 15\n assert candidate(root = tree_node([5, 4, 8, 3, None, 6, 3])) == 7\n assert candidate(root = tree_node([5, 4, 6, None, None, 3, 7])) == 16\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18])) == 58\n assert candidate(root = tree_node([10, 5, 15, 1, 8, None, 7])) == 14\n assert candidate(root = tree_node([-4, -2, -5])) == 0\n assert candidate(root = tree_node([1, None, 10, -5, 20])) == 25\n assert candidate(root = tree_node([2, 1, 3])) == 6\n assert candidate(root = tree_node([0, None, -1])) == 0\n assert candidate(root = tree_node([1, 4, 3, 2, 4, 2, 5, None, None, None, None, None, None, 4, 6])) == 20\n assert candidate(root = tree_node([4, 3, None, 1, 2])) == 2\n assert candidate(root = tree_node([2, 1, 3, None, None, None, 4])) == 10\n assert candidate(root = tree_node([3, 1, 4, None, None, 2])) == 6\n assert candidate(root = tree_node([15, 10, 20, 5, 13, 18, 25, 2, 7, 11, 14, 16, 19, 23, 27, 1, 3, 6, 8, 9, 12, 17, 21, 22, 24, 26, 28, 29, 30])) == 32\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])) == 55\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, None, None, None, 8, 9, 10, 11, None, None, None, None, None, None, None, None, None])) == 11\n assert candidate(root = tree_node([2, 1, 3, 0, 4, None, None, -2, None, None, 5, None, None, None, None, None, 6])) == 9\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 20, 1, 4, 6, 8, 11, 13, 17, 25, None, None, None, None, None, 16, None, None, None, 18, None, None, None, None, 22, None, None, None, None, None, None, None, None, 24, None, None, None, None, None, None, 23])) == 84\n assert candidate(root = tree_node([5, 3, 12, 1, 4, None, 15, None, None, None, None, None, 18, 13, 17])) == 17\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 18, None, None, None, None, 11, 14])) == 95\n assert candidate(root = tree_node([50, 30, 70, 20, 40, 60, 80, 10, 25, 35, 45, 55, 65, 75, 85, 5, 15, None, 28, 32, 38, 43, 48, 52, 58, 63, 68, 72, 78, 82, 88, 90, 92, 95, 98, 100])) == 1051\n assert candidate(root = tree_node([1, 1, 1, 1, 1, None, 1])) == 1\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9])) == 45\n assert candidate(root = tree_node([3, 2, 5, None, None, 4, 6])) == 20\n assert candidate(root = tree_node([10, 5, 15, 1, 8, 12, 20, 0, 4, 9, 11, 14, 18, 13, 19, None, None, 3, None, None, None, None, None, 2, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 1])) == 19\n assert candidate(root = tree_node([10, 5, 15, 1, 8, None, 7, 0, 6, None, 9])) == 17\n assert candidate(root = tree_node([3, 1, 5, 0, 2, 4, 6, -1])) == 20\n assert candidate(root = tree_node([5, 3, 8, 1, 4, 7, 10, 0, 2, 6, 9, 5, 11])) == 23\n assert candidate(root = tree_node([3, 2, 5, 1, None, 4, None])) == 15\n assert candidate(root = tree_node([2, 1, 3, None, 4])) == 5\n assert candidate(root = tree_node([2, 1, 3, None, None, 0, 5])) == 8\n assert candidate(root = tree_node([10, 5, 15, 1, 8, None, 20, -2, None, None, 6, None, None, None, None, None, 25])) == 35\n assert candidate(root = tree_node([30, 10, 50, 5, 20, 40, 60, 1, None, 15, 25, 35, 45, 55, 65, None, 3, 7, 13, 17, 23, 27, 33, 37, 43, 47, 53, 57, 63])) == 63\n assert candidate(root = tree_node([1, None, -1, -2, None, None, -3, None, -4, None, -5])) == 0\n assert candidate(root = tree_node([15, 10, 20, 8, 12, 16, 25, 7, 9, 11, 13, 15, 17, 22, 27])) == 142\n assert candidate(root = tree_node([10, 5, 15, 1, 8, None, 20, None, None, 6, 9])) == 74\n assert candidate(root = tree_node([2, 1, 3, None, None, None, 4, None, 5])) == 15\n assert candidate(root = tree_node([10, 5, 15, 1, 8, 7, 20])) == 42\n assert candidate(root = tree_node([5, 3, 9, -2, 4, None, 10, None, None, 1, 6, None, None, 8])) == 19\n assert candidate(root = tree_node([5, 2, 13, 1, 5, 10, 20, None, None, None, None, 8, 15])) == 33\n assert candidate(root = tree_node([10, 5, 15, 1, 8, None, 20, -3, None, None, 6, None, None, None, 26])) == 35\n assert candidate(root = tree_node([2, 1, 3, 0, 5, None, 7, 0, 6, None, None, 9])) == 9\n assert candidate(root = tree_node([5, 2, 6, None, 4, None, 7])) == 24\n assert candidate(root = tree_node([2, 1, 3, None, None, 0, 4])) == 7\n assert candidate(root = tree_node([10, 5, 15, 1, 8, 7, 20, 0, None, None, None, 6, 12, None, 18])) == 25\n assert candidate(root = tree_node([10, 5, 15, 1, 8, None, 7, None, None, 6, 9])) == 29\n assert candidate(root = tree_node([10, 5, 15, 1, 8, None, 20, -1, None, None, 6, None, None, None, None, None, 26, None, 27])) == 59\n assert candidate(root = tree_node([10, 5, 15, 1, 8, None, 20, None, None, 6, 9, None, None, 16, 25])) == 35\n assert candidate(root = tree_node([5, 2, 6, 1, 3, None, None, None, None, 4])) == 6\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == 15\n assert candidate(root = tree_node([10, 5, 10, 2, 8, None, None, 1, None, None, 9])) == 25\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, 1, None, 6])) == 65\n assert candidate(root = tree_node([15, 10, 20, 8, 12, 16, 25, 6, 9, 11, 13, 14, 17, 19, 30])) == 74\n assert candidate(root = tree_node([5, 2, 3, None, None, None, None, 1])) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7])) == 7\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50])) == 50\n assert candidate(root = tree_node([0, -10, 10, -20, 0, -5, 5, None, None, None, None, None, None, -15, -1, 0, 1, 5, None, None, None, None, None, None, -15, -1, 0, 1, 5])) == 5\n assert candidate(root = tree_node([4, 2, 7, 2, 3, 5, None, 2, None, None, None, None, None, 1])) == 12\n assert candidate(root = tree_node([5, 2, 13, None, None, 10, 15, 6, 12, 11, 14, 13, 16])) == 16\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4])) == 10\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 13, 18, 1, 4, 6, 8, 11, 14, 17, 19])) == 151\n assert candidate(root = tree_node([50, 30, 80, 20, 40, 70, 90, None, None, 25])) == 240\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 18, 1, None, 6, 8, None, 11, 13, 17, 19])) == 21\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 20, 1, None, 6, 8, 11, 13, None, 19])) == 36\n assert candidate(root = tree_node([10, 5, 15, 1, 8, 7, 20, None, None, 6, 9, 11, 19])) == 29\n assert candidate(root = tree_node([5, 2, 6, None, None, 3, 8, None, 4, None, None, 7])) == 8\n assert candidate(root = tree_node([50, 30, 70, 20, 40, 60, 80, None, None, 25, None, None, 55, 65, None, None, 75, 85])) == 145\n assert candidate(root = tree_node([50, 30, 70, 20, 40, 60, 80, 15, 25, 35, 45, 55, 65, 75, 85])) == 750\n assert candidate(root = tree_node([5, 1, 4, None, None, 3, 6])) == 13\n assert candidate(root = tree_node([50, 30, 60, 10, 40, 55, 70, None, 45, None, None, None, 65, 80])) == 120\n assert candidate(root = tree_node([50, 30, 60, 5, 20, 45, 70, None, None, 15, 25, 35, 48, 65, 75, None, None, None, None, 40, 50])) == 210\n assert candidate(root = tree_node([10, 5, 15, 1, 8, 12, 20, None, None, 6, 9, 11, 13, None, None, None, None, None, 18, 22])) == 47\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20])) == 210\n assert candidate(root = tree_node([3, 2, 5, None, 3, None, 9])) == 14\n assert candidate(root = tree_node([2, 1, 3, None, None, None, None, 0, 4])) == 6\n assert candidate(root = tree_node([4, 2, 6, 1, 3, 5, 7, 0, None, None, None, None, None, None, 8])) == 36\n assert candidate(root = tree_node([5, 4, 6, 3, 7, None, None, 2, 8, 1, 9])) == 17\n assert candidate(root = tree_node([1, None, 10, None, None, 5, None, None, 15])) == 11\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12])) == 78\n assert candidate(root = tree_node([20, 10, 30, 5, 15, None, None, 3, 7, 13, 18])) == 121\n assert candidate(root = tree_node([5, 2, 3, None, None, 1])) == 4\n assert candidate(root = tree_node([5, 2, 13, None, None, 9, 21, 7, 11, 14, 25])) == 107\n assert candidate(root = tree_node([50, 10, 60, 5, 20, None, None, 3, 7, 15, 35, 25, 45, 17, 25])) == 70\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 13, 18, 1, None, 6, 8, 12, 14, None, 19])) == 131\n assert candidate(root = tree_node([100, 50, 150, 20, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180])) == 1465\n assert candidate(root = tree_node([4, 2, 6, 1, 3, 5, 7])) == 28\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 18, None, None, None, None, 10, 14])) == 69\n assert candidate(root = tree_node([10, 5, 15, 1, 8, 12, 20, 0, 4, 9, 11, 14, 18, 13, 19])) == 19\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180])) == 1470\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 20, 1, 4, 6, 8, 11, 13, 18, 25, None, None, None, None, None, None, None, None, None, None, None, 14, None, 16, None, None, 17, None, None, None, None, None, None, None, 21, None, 24, None, None, None, None, 19, None, 22, None, 23, None, None, 26, None, 27])) == 34\n assert candidate(root = tree_node([4, 2, 7, 1, 3, 6, 9, 0, 1, 5, 8, None, None, None, None, None, None, None, None, None])) == 22\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180, None, 12, 28, 55, 65, 77, 85, 105, 115, 135, 145, 155, 165, 178, 185, 190])) == 190\n assert candidate(root = tree_node([50, 30, 60, 5, 20, 45, 70, None, None, 10, 25, 40, 55, 65, 80])) == 415\n assert candidate(root = tree_node([5, 3, 6, 2, 4, None, None, 1])) == 21\n assert candidate(root = tree_node([3, 2, 5, None, None, 4, 6, 3, 7])) == 14\n assert candidate(root = tree_node([5, 2, 13, None, None, 8, 14, 3, 12, 7, 11, None, 15])) == 18\n"}, "metadata": {"canonical_parameter_names": ["root"], "leetcode_dataset_entry_point": "Solution().maxSumBST", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxSumBST(TreeNode* root) {", "container": "Solution", "callable": "maxSumBST", "parameters": [{"name": "root", "type": "TreeNode*"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1374, "task_id": "generate-a-string-with-characters-that-have-odd-counts", "difficulty": "Easy", "problem_description": "Given an integer n, return a string with n characters such that each character in such string occurs an odd number of times.\nThe returned string must contain only lowercase English letters. If there are multiples valid strings, return any of them.  \n \nExample 1:\n\nInput: n = 4\nOutput: \"pppz\"\nExplanation: \"pppz\" is a valid string since the character 'p' occurs three times and the character 'z' occurs once. Note that there are many other valid strings such as \"ohhh\" and \"love\".\n\nExample 2:\n\nInput: n = 2\nOutput: \"xy\"\nExplanation: \"xy\" is a valid string since the characters 'x' and 'y' occur once. Note that there are many other valid strings such as \"ag\" and \"ur\".\n\nExample 3:\n\nInput: n = 7\nOutput: \"holasss\"\n\n \nConstraints:\n\n1 <= n <= 500\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 250) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 3) == \"aaa\"\n assert candidate(n = 100) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 4) == \"aaab\"\n assert candidate(n = 2) == \"ab\"\n assert candidate(n = 1) == \"a\"\n assert candidate(n = 500) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 7) == \"aaaaaaa\"\n assert candidate(n = 10) == \"aaaaaaaaab\"\n assert candidate(n = 97) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 267) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 279) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 49) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 125) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 47) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 21) == \"aaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 50) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 5) == \"aaaaa\"\n assert candidate(n = 300) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 222) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 333) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 123) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 87) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 450) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 99) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 37) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 64) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 257) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 23) == \"aaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 167) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 42) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 51) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 175) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 251) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 101) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 495) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 299) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 255) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 375) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 27) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 75) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 249) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 150) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 11) == \"aaaaaaaaaaa\"\n assert candidate(n = 497) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 498) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 399) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 400) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 41) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 275) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 9) == \"aaaaaaaaa\"\n assert candidate(n = 301) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 31) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 200) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab\"\n assert candidate(n = 83) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 499) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 199) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(n = 13) == \"aaaaaaaaaaaaa\"\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().generateTheString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string generateTheString(int n) {", "container": "Solution", "callable": "generateTheString", "parameters": [{"name": "n", "type": "int"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1375, "task_id": "number-of-times-binary-string-is-prefix-aligned", "difficulty": "Medium", "problem_description": "You have a 1-indexed binary string of length n where all the bits are 0 initially. We will flip all the bits of this binary string (i.e., change them from 0 to 1) one by one. You are given a 1-indexed integer array flips where flips[i] indicates that the bit at index i will be flipped in the ith step.\nA binary string is prefix-aligned if, after the ith step, all the bits in the inclusive range [1, i] are ones and all the other bits are zeros.\nReturn the number of times the binary string is prefix-aligned during the flipping process.\n \nExample 1:\n\nInput: flips = [3,2,4,1,5]\nOutput: 2\nExplanation: The binary string is initially \"00000\".\nAfter applying step 1: The string becomes \"00100\", which is not prefix-aligned.\nAfter applying step 2: The string becomes \"01100\", which is not prefix-aligned.\nAfter applying step 3: The string becomes \"01110\", which is not prefix-aligned.\nAfter applying step 4: The string becomes \"11110\", which is prefix-aligned.\nAfter applying step 5: The string becomes \"11111\", which is prefix-aligned.\nWe can see that the string was prefix-aligned 2 times, so we return 2.\n\nExample 2:\n\nInput: flips = [4,1,2,3]\nOutput: 1\nExplanation: The binary string is initially \"0000\".\nAfter applying step 1: The string becomes \"0001\", which is not prefix-aligned.\nAfter applying step 2: The string becomes \"1001\", which is not prefix-aligned.\nAfter applying step 3: The string becomes \"1101\", which is not prefix-aligned.\nAfter applying step 4: The string becomes \"1111\", which is prefix-aligned.\nWe can see that the string was prefix-aligned 1 time, so we return 1.\n\n \nConstraints:\n\nn == flips.length\n1 <= n <= 5 * 104\nflips is a permutation of the integers in the range [1, n].\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(flips = [5, 4, 3, 2, 1]) == 1\n assert candidate(flips = [1, 2, 3, 4, 5]) == 5\n assert candidate(flips = [2, 1, 3, 5, 4]) == 3\n assert candidate(flips = [3, 2, 4, 1, 5]) == 2\n assert candidate(flips = [4, 1, 2, 3]) == 1\n assert candidate(flips = [2, 1, 5, 3, 4]) == 2\n assert candidate(flips = [5, 1, 4, 3, 2, 7, 6, 9, 8, 10]) == 4\n assert candidate(flips = [2, 3, 1, 5, 4]) == 2\n assert candidate(flips = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15]) == 6\n assert candidate(flips = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 3\n assert candidate(flips = [1, 4, 3, 2, 5, 8, 6, 7, 10, 9]) == 5\n assert candidate(flips = [3, 1, 4, 2, 5, 7, 6, 9, 8, 10]) == 5\n assert candidate(flips = [3, 1, 2, 6, 5, 4, 7, 8, 9, 10]) == 6\n assert candidate(flips = [6, 5, 4, 3, 2, 1, 7, 8, 9, 10, 11]) == 6\n assert candidate(flips = [1, 3, 2, 5, 4, 6]) == 4\n assert candidate(flips = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 3\n assert candidate(flips = [2, 5, 6, 1, 4, 3, 8, 9, 7, 10]) == 3\n assert candidate(flips = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6]) == 6\n assert candidate(flips = [1, 3, 5, 7, 2, 4, 6, 8, 9, 10]) == 5\n assert candidate(flips = [1, 3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14]) == 2\n assert candidate(flips = [6, 1, 3, 5, 2, 4]) == 1\n assert candidate(flips = [14, 12, 10, 8, 6, 4, 2, 15, 13, 11, 9, 7, 5, 3, 1]) == 1\n assert candidate(flips = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]) == 5\n assert candidate(flips = [3, 1, 2, 5, 4, 7, 6, 9, 8, 10]) == 5\n assert candidate(flips = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(flips = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(flips = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10]) == 8\n assert candidate(flips = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 2\n assert candidate(flips = [6, 3, 1, 4, 2, 5, 7, 8, 9, 10]) == 5\n assert candidate(flips = [2, 1, 5, 4, 3, 6, 8, 7, 10, 9]) == 5\n assert candidate(flips = [1, 2, 3, 4, 5, 10, 6, 7, 8, 9]) == 6\n assert candidate(flips = [5, 2, 3, 4, 1, 6, 7, 8, 9, 10]) == 6\n assert candidate(flips = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10]) == 6\n assert candidate(flips = [1, 11, 2, 10, 3, 9, 4, 8, 5, 7, 6]) == 2\n assert candidate(flips = [10, 1, 20, 2, 19, 3, 18, 4, 17, 5, 16, 6, 15, 7, 14, 8, 13, 9, 12, 11]) == 1\n assert candidate(flips = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(flips = [1, 5, 3, 4, 2, 6, 7, 8, 9, 10]) == 7\n assert candidate(flips = [6, 5, 4, 3, 2, 1, 7, 8, 9, 10]) == 5\n assert candidate(flips = [1, 3, 5, 2, 4, 6]) == 3\n assert candidate(flips = [1, 5, 2, 4, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 22\n assert candidate(flips = [1, 5, 2, 4, 3, 6, 7, 8, 9, 10]) == 7\n assert candidate(flips = [6, 5, 4, 3, 2, 1]) == 1\n assert candidate(flips = [1, 2, 5, 4, 3, 6, 8, 7, 10, 9]) == 6\n assert candidate(flips = [1, 3, 5, 2, 4, 6, 7, 8, 9, 10]) == 7\n assert candidate(flips = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(flips = [5, 3, 1, 2, 4, 6, 8, 7, 10, 9]) == 4\n assert candidate(flips = [2, 3, 1, 5, 4, 6, 7, 8, 9, 10]) == 7\n assert candidate(flips = [1, 2, 3, 5, 4, 6, 7, 8, 9, 10]) == 9\n assert candidate(flips = [1, 2, 4, 3, 5, 7, 6, 8, 10, 9]) == 7\n assert candidate(flips = [5, 1, 4, 3, 2, 6]) == 2\n assert candidate(flips = [5, 2, 3, 1, 4, 6, 8, 7, 10, 9]) == 4\n assert candidate(flips = [10, 5, 8, 7, 9, 3, 1, 2, 4, 6]) == 1\n assert candidate(flips = [1, 3, 2, 5, 4, 6, 7]) == 5\n assert candidate(flips = [1, 3, 5, 7, 9, 11, 2, 4, 6, 8, 10]) == 2\n assert candidate(flips = [8, 7, 6, 5, 4, 3, 2, 1, 9, 10]) == 3\n assert candidate(flips = [1, 3, 2, 5, 4]) == 3\n assert candidate(flips = [1, 2, 5, 3, 6, 4, 7, 8, 10, 9]) == 6\n assert candidate(flips = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(flips = [1, 6, 2, 7, 3, 8, 4, 9, 5, 10]) == 3\n assert candidate(flips = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(flips = [7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(flips = [1, 3, 5, 2, 4, 6, 8, 7, 10, 9]) == 5\n assert candidate(flips = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(flips = [5, 1, 3, 2, 6, 4, 8, 7, 10, 9]) == 3\n assert candidate(flips = [10, 5, 8, 7, 3, 2, 9, 4, 6, 1]) == 1\n assert candidate(flips = [1, 3, 5, 2, 4]) == 2\n assert candidate(flips = [1, 5, 2, 6, 3, 7, 4, 8, 9, 10]) == 5\n assert candidate(flips = [1, 4, 2, 3, 7, 5, 6, 10, 8, 9]) == 4\n assert candidate(flips = [3, 1, 2, 5, 4, 6, 8, 7, 10, 9]) == 5\n assert candidate(flips = [1, 3, 2, 4, 5, 7, 6, 8, 10, 9]) == 7\n assert candidate(flips = [6, 3, 1, 5, 2, 4, 10, 7, 9, 8]) == 2\n assert candidate(flips = [5, 1, 6, 2, 7, 3, 8, 4, 9, 10]) == 3\n assert candidate(flips = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(flips = [1, 2, 3, 4, 6, 5, 7, 8, 9, 10]) == 9\n assert candidate(flips = [2, 1, 5, 4, 3, 8, 6, 7, 10, 9]) == 4\n assert candidate(flips = [2, 1, 4, 3, 6, 5, 7]) == 4\n assert candidate(flips = [5, 2, 1, 3, 4, 6, 7, 8, 9, 10]) == 6\n assert candidate(flips = [1, 2, 10, 5, 4, 9, 6, 7, 3, 8]) == 3\n assert candidate(flips = [2, 4, 6, 8, 10, 9, 7, 5, 3, 1]) == 1\n assert candidate(flips = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(flips = [2, 3, 1, 5, 6, 4, 8, 7, 10, 9]) == 4\n assert candidate(flips = [7, 1, 2, 3, 4, 5, 6]) == 1\n assert candidate(flips = [1, 5, 3, 4, 2, 6, 7, 8, 10, 9]) == 6\n assert candidate(flips = [2, 1, 3, 5, 4, 6, 7, 8]) == 6\n assert candidate(flips = [1, 2, 3, 4, 5, 6]) == 6\n assert candidate(flips = [1, 2, 5, 4, 3, 6, 7, 8, 9, 10]) == 8\n assert candidate(flips = [5, 1, 4, 3, 2, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 26\n assert candidate(flips = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(flips = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 1\n assert candidate(flips = [10, 5, 1, 6, 2, 7, 3, 8, 4, 9]) == 1\n assert candidate(flips = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == 6\n"}, "metadata": {"canonical_parameter_names": ["flips"], "leetcode_dataset_entry_point": "Solution().numTimesAllBlue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numTimesAllBlue(vector& flips) {", "container": "Solution", "callable": "numTimesAllBlue", "parameters": [{"name": "flips", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1376, "task_id": "time-needed-to-inform-all-employees", "difficulty": "Medium", "problem_description": "A company has n employees with a unique ID for each employee from 0 to n - 1. The head of the company is the one with headID.\nEach employee has one direct manager given in the manager array where manager[i] is the direct manager of the i-th employee, manager[headID] = -1. Also, it is guaranteed that the subordination relationships have a tree structure.\nThe head of the company wants to inform all the company employees of an urgent piece of news. He will inform his direct subordinates, and they will inform their subordinates, and so on until all employees know about the urgent news.\nThe i-th employee needs informTime[i] minutes to inform all of his direct subordinates (i.e., After informTime[i] minutes, all his direct subordinates can start spreading the news).\nReturn the number of minutes needed to inform all the employees about the urgent news.\n \nExample 1:\n\nInput: n = 1, headID = 0, manager = [-1], informTime = [0]\nOutput: 0\nExplanation: The head of the company is the only employee in the company.\n\nExample 2:\n\n\nInput: n = 6, headID = 2, manager = [2,2,-1,2,2,2], informTime = [0,0,1,0,0,0]\nOutput: 1\nExplanation: The head of the company with id = 2 is the direct manager of all the employees in the company and needs 1 minute to inform them all.\nThe tree structure of the employees in the company is shown.\n\n \nConstraints:\n\n1 <= n <= 105\n0 <= headID < n\nmanager.length == n\n0 <= manager[i] < n\nmanager[headID] == -1\ninformTime.length == n\n0 <= informTime[i] <= 1000\ninformTime[i] == 0 if employee i has no subordinates.\nIt is guaranteed that all the employees can be informed.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,headID = 2,manager = [2, 2, -1, 2, 2, 2],informTime = [0, 0, 1, 0, 0, 0]) == 1\n assert candidate(n = 15,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],informTime = [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0]) == 3\n assert candidate(n = 1,headID = 0,manager = [-1],informTime = [0]) == 0\n assert candidate(n = 4,headID = 2,manager = [3, 3, -1, 2],informTime = [0, 0, 162, 954]) == 1116\n assert candidate(n = 7,headID = 6,manager = [1, 2, 3, 4, 5, 6, -1],informTime = [0, 6, 5, 4, 3, 2, 1]) == 21\n assert candidate(n = 4,headID = 2,manager = [3, 3, -1, 2],informTime = [0, 0, 162, 956]) == 1118\n assert candidate(n = 4,headID = 2,manager = [3, 3, -1, 2],informTime = [0, 0, 162, 914]) == 1076\n assert candidate(n = 20,headID = 10,manager = [-1, 10, 10, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(n = 10,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4],informTime = [0, 67, 33, 12, 45, 78, 12, 34, 56, 23]) == 112\n assert candidate(n = 12,headID = 5,manager = [2, 2, 3, 4, 5, -1, 3, 5, 3, 5, 5, 4],informTime = [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(n = 30,headID = 29,manager = [28, 28, 28, 28, 29, 29, 29, 29, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(n = 12,headID = 3,manager = [5, 5, 5, 5, 6, 6, -1, 7, 7, 8, 8, 9],informTime = [0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 10]) == 0\n assert candidate(n = 20,headID = 0,manager = [-1, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8],informTime = [0, 1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9]) == 4\n assert candidate(n = 20,headID = 19,manager = [18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1],informTime = [0, 6, 5, 4, 3, 2, 1, 0, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0]) == 0\n assert candidate(n = 15,headID = 7,manager = [6, 6, 6, 7, 7, 7, 7, -1, 8, 8, 8, 9, 9, 10, 10],informTime = [1, 1, 1, 2, 2, 2, 3, 0, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(n = 18,headID = 9,manager = [9, 9, 9, 9, 9, 9, 9, 9, 9, -1, 10, 10, 11, 11, 12, 12, 13, 13],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == 0\n assert candidate(n = 10,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4],informTime = [0, 2, 2, 1, 1, 3, 3, 4, 4, 5]) == 3\n assert candidate(n = 15,headID = 5,manager = [5, 5, 5, 5, 5, -1, 6, 6, 7, 7, 8, 8, 9, 9, 10],informTime = [0, 12, 34, 56, 78, 90, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 90\n assert candidate(n = 15,headID = 7,manager = [7, 7, 7, 7, 7, 7, 7, -1, 8, 8, 9, 9, 10, 10, 11],informTime = [0, 0, 0, 0, 0, 0, 0, 23, 0, 0, 0, 0, 0, 0, 0]) == 23\n assert candidate(n = 50,headID = 0,manager = [-1, 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24],informTime = [0, 1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24]) == 16\n assert candidate(n = 15,headID = 7,manager = [10, 9, 9, 9, 10, 10, 7, -1, 6, 6, 6, 4, 4, 3, 3],informTime = [0, 0, 0, 0, 0, 0, 1, 5, 0, 0, 0, 1, 1, 2, 2]) == 6\n assert candidate(n = 17,headID = 10,manager = [10, 10, 10, 11, 11, 12, 12, 13, 13, 14, -1, 15, 15, 16, 16, 16, 16],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 50, 50, 20, 20, 10, 10]) == 100\n assert candidate(n = 10,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4],informTime = [0, 67, 34, 23, 56, 45, 12, 89, 34, 12]) == 123\n assert candidate(n = 10,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4],informTime = [0, 67, 13, 10, 15, 20, 8, 5, 7, 12]) == 82\n assert candidate(n = 100,headID = 50,manager = [49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, -1],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(n = 100,headID = 50,manager = [49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, -1, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(n = 10,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4],informTime = [0, 2, 1, 1, 3, 1, 1, 0, 0, 0]) == 5\n assert candidate(n = 20,headID = 0,manager = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],informTime = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 160\n assert candidate(n = 25,headID = 24,manager = [19, 19, 19, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -1],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 0]) == 55\n assert candidate(n = 10,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4],informTime = [0, 67, 34, 0, 0, 0, 0, 0, 0, 0]) == 67\n assert candidate(n = 12,headID = 3,manager = [3, 3, 3, -1, 4, 4, 5, 5, 6, 6, 7, 7],informTime = [0, 0, 0, 100, 50, 50, 25, 25, 10, 10, 5, 5]) == 100\n assert candidate(n = 10,headID = 0,manager = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3],informTime = [0, 6, 5, 4, 3, 2, 1, 7, 8, 9]) == 6\n assert candidate(n = 15,headID = 7,manager = [10, 9, 9, 10, 8, 8, 7, -1, 10, 10, 10, 11, 11, 12, 12],informTime = [0, 6, 5, 4, 3, 2, 1, 0, 7, 8, 9, 10, 11, 12, 13]) == 0\n assert candidate(n = 50,headID = 25,manager = [24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, -1, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(n = 15,headID = 14,manager = [10, 9, 12, 5, 5, 14, 6, 6, 8, 9, 9, 12, 12, 13, -1],informTime = [0, 23, 34, 0, 0, 18, 19, 12, 21, 13, 18, 28, 35, 0, 0]) == 18\n assert candidate(n = 20,headID = 15,manager = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -1, 16, 16, 16, 16],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2]) == 0\n assert candidate(n = 20,headID = 19,manager = [19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, -1],informTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0]) == 0\n assert candidate(n = 9,headID = 0,manager = [-1, 0, 0, 0, 0, 1, 1, 2, 2],informTime = [0, 30, 40, 50, 60, 70, 80, 90, 100]) == 40\n assert candidate(n = 18,headID = 4,manager = [4, 4, 4, 4, -1, 12, 13, 12, 13, 12, 13, 4, 14, 14, 4, 15, 16, 15],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 18, 0, 0, 0]) == 18\n assert candidate(n = 8,headID = 4,manager = [2, 2, 4, 2, 7, 5, 5, -1],informTime = [0, 0, 4, 0, 0, 0, 6, 0]) == 4\n assert candidate(n = 15,headID = 0,manager = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],informTime = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(n = 25,headID = 12,manager = [12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, -1, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20],informTime = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(n = 13,headID = 0,manager = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],informTime = [0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 88\n"}, "metadata": {"canonical_parameter_names": ["n", "headID", "manager", "informTime"], "leetcode_dataset_entry_point": "Solution().numOfMinutes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numOfMinutes(int n, int headID, vector& manager, vector& informTime) {", "container": "Solution", "callable": "numOfMinutes", "parameters": [{"name": "n", "type": "int"}, {"name": "headID", "type": "int"}, {"name": "manager", "type": "vector&"}, {"name": "informTime", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1377, "task_id": "frog-position-after-t-seconds", "difficulty": "Hard", "problem_description": "Given an undirected tree consisting of n vertices numbered from 1 to n. A frog starts jumping from vertex 1. In one second, the frog jumps from its current vertex to another unvisited vertex if they are directly connected. The frog can not jump back to a visited vertex. In case the frog can jump to several vertices, it jumps randomly to one of them with the same probability. Otherwise, when the frog can not jump to any unvisited vertex, it jumps forever on the same vertex.\nThe edges of the undirected tree are given in the array edges, where edges[i] = [ai, bi] means that exists an edge connecting the vertices ai and bi.\nReturn the probability that after t seconds the frog is on the vertex target. Answers within 10-5 of the actual answer will be accepted.\n \nExample 1:\n\n\nInput: n = 7, edges = [[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]], t = 2, target = 4\nOutput: 0.16666666666666666 \nExplanation: The figure above shows the given graph. The frog starts at vertex 1, jumping with 1/3 probability to the vertex 2 after second 1 and then jumping with 1/2 probability to vertex 4 after second 2. Thus the probability for the frog is on the vertex 4 after 2 seconds is 1/3 * 1/2 = 1/6 = 0.16666666666666666. \n\nExample 2:\n\n\nInput: n = 7, edges = [[1,2],[1,3],[1,7],[2,4],[2,6],[3,5]], t = 1, target = 7\nOutput: 0.3333333333333333\nExplanation: The figure above shows the given graph. The frog starts at vertex 1, jumping with 1/3 = 0.3333333333333333 probability to the vertex 7 after second 1. \n\n \nConstraints:\n\n1 <= n <= 100\nedges.length == n - 1\nedges[i].length == 2\n1 <= ai, bi <= n\n1 <= t <= 50\n1 <= target <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],t = 4,target = 10) == 0.16666666666666666\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6]],t = 2,target = 5) == 0.25\n assert candidate(n = 4,edges = [[1, 2], [1, 3], [2, 4]],t = 2,target = 4) == 0.5\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [1, 7], [2, 4], [2, 6], [3, 5]],t = 2,target = 4) == 0.16666666666666666\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [1, 7], [2, 4], [2, 6], [3, 5]],t = 1,target = 7) == 0.3333333333333333\n assert candidate(n = 1,edges = [],t = 10,target = 1) == 1.0\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [1, 4], [2, 5]],t = 3,target = 5) == 0.3333333333333333\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [1, 4], [1, 5]],t = 1,target = 3) == 0.25\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [2, 4], [2, 5]],t = 2,target = 4) == 0.25\n assert candidate(n = 3,edges = [[1, 2], [1, 3]],t = 2,target = 1) == 0\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10]],t = 4,target = 6) == 0.125\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [1, 4], [1, 5]],t = 2,target = 3) == 0.25\n assert candidate(n = 1,edges = [],t = 1,target = 1) == 1.0\n assert candidate(n = 4,edges = [[1, 2], [1, 3], [2, 4]],t = 3,target = 2) == 0\n assert candidate(n = 3,edges = [[1, 2], [1, 3]],t = 1,target = 2) == 0.5\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15]],t = 5,target = 15) == 0.125\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [10, 23], [11, 24], [11, 25], [12, 26], [12, 27], [13, 28], [13, 29], [14, 30]],t = 5,target = 29) == 0.041666666666666664\n assert candidate(n = 14,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],t = 5,target = 14) == 0.08333333333333333\n assert candidate(n = 50,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30], [15, 31], [16, 32], [16, 33], [17, 34], [17, 35], [18, 36], [18, 37], [19, 38], [19, 39], [20, 40], [20, 41], [21, 42], [21, 43], [22, 44], [22, 45], [23, 46], [23, 47], [24, 48], [24, 49], [25, 50]],t = 7,target = 40) == 0.03125\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],t = 3,target = 9) == 0.3333333333333333\n assert candidate(n = 18,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [9, 17], [9, 18]],t = 4,target = 16) == 0.125\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [6, 16], [6, 17], [6, 18], [7, 19], [7, 20], [7, 21], [8, 22], [8, 23], [8, 24], [9, 25], [9, 26], [9, 27], [10, 28], [10, 29], [10, 30]],t = 6,target = 16) == 0.037037037037037035\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12]],t = 3,target = 12) == 0.08333333333333333\n assert candidate(n = 28,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28]],t = 6,target = 24) == 0.0625\n assert candidate(n = 35,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30], [15, 31], [16, 32], [16, 33], [17, 34], [17, 35]],t = 15,target = 34) == 0.03125\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20]],t = 5,target = 15) == 0.125\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25]],t = 6,target = 22) == 0.0625\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25]],t = 4,target = 24) == 0.0625\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15]],t = 5,target = 11) == 0.08333333333333333\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30]],t = 10,target = 30) == 0.125\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15]],t = 3,target = 11) == 0.16666666666666666\n assert candidate(n = 18,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [9, 17], [10, 18]],t = 4,target = 13) == 0.125\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [6, 16], [6, 17], [6, 18], [7, 19], [7, 20], [7, 21], [8, 22], [8, 23], [8, 24], [9, 25]],t = 5,target = 22) == 0.037037037037037035\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [4, 11], [4, 12]],t = 4,target = 10) == 0.05555555555555555\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20]],t = 5,target = 16) == 0.0625\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25]],t = 7,target = 24) == 0.0625\n assert candidate(n = 40,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [4, 11], [4, 12], [5, 13], [5, 14], [6, 15], [6, 16], [6, 17], [7, 18], [7, 19], [8, 20], [8, 21], [8, 22], [9, 23], [9, 24], [10, 25], [10, 26], [10, 27], [11, 28], [11, 29], [11, 30], [12, 31], [12, 32], [12, 33], [13, 34], [13, 35], [14, 36], [14, 37], [14, 38], [15, 39], [15, 40]],t = 6,target = 39) == 0.027777777777777776\n assert candidate(n = 35,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30], [15, 31], [16, 32], [16, 33], [17, 34], [17, 35]],t = 9,target = 32) == 0.03125\n assert candidate(n = 35,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [6, 16], [6, 17], [6, 18], [7, 19], [7, 20], [7, 21], [8, 22], [8, 23], [8, 24], [9, 25], [9, 26], [9, 27], [10, 28], [10, 29], [10, 30], [11, 31], [11, 32], [11, 33], [12, 34], [12, 35]],t = 7,target = 25) == 0.037037037037037035\n assert candidate(n = 22,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22]],t = 5,target = 18) == 0.0625\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [8, 15]],t = 3,target = 10) == 0.08333333333333333\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12]],t = 3,target = 12) == 0.25\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25]],t = 7,target = 16) == 0.0625\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [10, 20]],t = 5,target = 17) == 0.08333333333333333\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20]],t = 5,target = 13) == 0.08333333333333333\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15]],t = 3,target = 11) == 0.08333333333333333\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25]],t = 6,target = 16) == 0.08333333333333333\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [10, 20]],t = 4,target = 15) == 0.125\n assert candidate(n = 18,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17], [12, 18]],t = 3,target = 18) == 0\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [5, 16], [6, 17], [6, 18], [6, 19], [7, 20], [7, 21], [7, 22], [8, 23], [8, 24], [8, 25], [9, 26], [9, 27], [9, 28], [10, 29], [10, 30]],t = 5,target = 23) == 0.037037037037037035\n assert candidate(n = 13,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13]],t = 5,target = 13) == 0.16666666666666666\n assert candidate(n = 18,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18]],t = 4,target = 18) == 0.08333333333333333\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30]],t = 8,target = 27) == 0.041666666666666664\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30]],t = 7,target = 28) == 0.0625\n assert candidate(n = 16,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16]],t = 6,target = 16) == 0.08333333333333333\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25]],t = 7,target = 25) == 0.0625\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [6, 16], [6, 17], [7, 18], [7, 19], [8, 20], [8, 21], [9, 22], [9, 23], [10, 24], [10, 25]],t = 5,target = 20) == 0.05555555555555555\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15]],t = 3,target = 12) == 0.125\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20]],t = 6,target = 15) == 0.08333333333333333\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [10, 20]],t = 4,target = 15) == 0.08333333333333333\n assert candidate(n = 11,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]],t = 4,target = 11) == 0.16666666666666666\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30]],t = 5,target = 29) == 0.0625\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12]],t = 4,target = 9) == 0.125\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20]],t = 6,target = 20) == 0.125\n"}, "metadata": {"canonical_parameter_names": ["n", "edges", "t", "target"], "leetcode_dataset_entry_point": "Solution().frogPosition", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "double frogPosition(int n, vector>& edges, int t, int target) {", "container": "Solution", "callable": "frogPosition", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "vector>&"}, {"name": "t", "type": "int"}, {"name": "target", "type": "int"}], "return_type": "double", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1380, "task_id": "lucky-numbers-in-a-matrix", "difficulty": "Easy", "problem_description": "Given an m x n matrix of distinct numbers, return all lucky numbers in the matrix in any order.\nA lucky number is an element of the matrix such that it is the minimum element in its row and maximum in its column.\n \nExample 1:\n\nInput: matrix = [[3,7,8],[9,11,13],[15,16,17]]\nOutput: [15]\nExplanation: 15 is the only lucky number since it is the minimum in its row and the maximum in its column.\n\nExample 2:\n\nInput: matrix = [[1,10,4,2],[9,3,8,7],[15,16,17,12]]\nOutput: [12]\nExplanation: 12 is the only lucky number since it is the minimum in its row and the maximum in its column.\n\nExample 3:\n\nInput: matrix = [[7,8],[1,2]]\nOutput: [7]\nExplanation: 7 is the only lucky number since it is the minimum in its row and the maximum in its column.\n\n \nConstraints:\n\nm == mat.length\nn == mat[i].length\n1 <= n, m <= 50\n1 <= matrix[i][j] <= 105.\nAll elements in the matrix are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[5, 9, 11], [9, 4, 8], [3, 15, 17]]) == []\n assert candidate(matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == [13]\n assert candidate(matrix = [[33, 18, 46, 39], [68, 35, 41, 26], [55, 87, 52, 37], [17, 47, 99, 22]]) == []\n assert candidate(matrix = [[3, 7, 8], [9, 11, 13], [15, 16, 17]]) == [15]\n assert candidate(matrix = [[5, 1, 4], [1, 5, 7], [8, 3, 2]]) == []\n assert candidate(matrix = [[3, 6], [7, 1], [5, 9]]) == []\n assert candidate(matrix = [[40, 10], [24, 30]]) == []\n assert candidate(matrix = [[5, 9, 11], [9, 2, 8], [1, 6, 3]]) == []\n assert candidate(matrix = [[1, 10, 4, 2], [9, 3, 8, 7], [15, 16, 17, 12]]) == [12]\n assert candidate(matrix = [[1]]) == [1]\n assert candidate(matrix = [[7, 8], [1, 2]]) == [7]\n assert candidate(matrix = [[36376, 85652], [55712, 5396]]) == []\n assert candidate(matrix = [[33, 18, 46], [19, 66, 58], [54, 88, 92]]) == [54]\n assert candidate(matrix = [[100000, 99999, 99998, 99997], [99996, 99995, 99994, 99993], [99992, 99991, 99990, 99989]]) == [99997]\n assert candidate(matrix = [[23, 45, 12, 78, 56], [89, 34, 23, 10, 32], [67, 88, 90, 11, 54], [12, 34, 56, 78, 90], [100, 200, 300, 400, 500]]) == [100]\n assert candidate(matrix = [[100000, 90000, 80000], [70000, 60000, 50000], [40000, 30000, 20000]]) == [80000]\n assert candidate(matrix = [[1, 3, 5, 7, 9], [10, 12, 14, 16, 18], [11, 13, 15, 17, 19], [20, 22, 24, 26, 28], [21, 23, 25, 27, 29]]) == [21]\n assert candidate(matrix = [[55, 54, 53, 52, 51], [45, 44, 43, 42, 41], [35, 34, 33, 32, 31], [25, 24, 23, 22, 21], [15, 14, 13, 12, 11]]) == [51]\n assert candidate(matrix = [[50, 49, 48, 47, 46], [45, 44, 43, 42, 41], [40, 39, 38, 37, 36], [35, 34, 33, 32, 31], [30, 29, 28, 27, 26]]) == [46]\n assert candidate(matrix = [[100000, 99999, 99998], [1, 2, 3], [99997, 99996, 99995]]) == [99998]\n assert candidate(matrix = [[12345, 67890, 23456, 34567], [78901, 89012, 90123, 12346], [65432, 54321, 43210, 32109]]) == []\n assert candidate(matrix = [[3, 6, 9, 12, 15], [2, 5, 8, 11, 14], [1, 4, 7, 10, 13]]) == [3]\n assert candidate(matrix = [[34, 56, 12, 90], [78, 89, 45, 67], [23, 34, 56, 78], [90, 12, 34, 56]]) == []\n assert candidate(matrix = [[42, 58, 76], [89, 21, 34], [95, 67, 12], [56, 45, 83]]) == []\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [7, 8, 9, 10, 11, 12], [12, 11, 10, 9, 8, 7], [13, 14, 15, 16, 17, 18], [18, 17, 16, 15, 14, 13]]) == []\n assert candidate(matrix = [[47, 2, 37, 58, 59], [1, 53, 34, 24, 60], [4, 22, 50, 18, 61], [11, 49, 16, 57, 35], [54, 3, 14, 13, 55]]) == []\n assert candidate(matrix = [[50000, 40000, 30000, 20000, 10000], [40001, 30001, 20001, 10001, 50001], [30002, 20002, 10002, 50002, 40002], [20003, 10003, 50003, 40003, 30003], [10004, 50004, 40004, 30004, 20004]]) == []\n assert candidate(matrix = [[25, 15, 35, 20], [10, 5, 45, 40], [30, 2, 60, 50], [65, 55, 5, 3]]) == []\n assert candidate(matrix = [[50000, 40000, 30000, 20000, 10000], [90000, 80000, 70000, 60000, 50000], [1, 2, 3, 4, 5]]) == [50000]\n assert candidate(matrix = [[100000, 99999, 99998], [1, 2, 3], [99997, 99996, 99995]]) == [99998]\n assert candidate(matrix = [[100000, 1, 100, 10], [1000, 99999, 2, 50], [99998, 500, 3, 1000], [50, 10000, 100000, 4]]) == []\n assert candidate(matrix = [[50000, 50001, 50002, 50003, 50004], [49999, 49998, 49997, 49996, 49995], [49994, 49993, 49992, 49991, 49990]]) == [50000]\n assert candidate(matrix = [[99999, 1, 2, 3, 4, 5], [5, 99998, 6, 7, 8, 9], [9, 10, 99997, 12, 13, 14], [14, 15, 16, 99996, 18, 19], [19, 20, 21, 22, 99995, 24]]) == []\n assert candidate(matrix = [[42, 41, 44, 43], [38, 39, 36, 37], [46, 45, 48, 47], [50, 49, 52, 51]]) == [49]\n assert candidate(matrix = [[50000, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15], [16, 17, 18, 19], [20, 21, 22, 23], [24, 25, 26, 27], [28, 29, 30, 31], [32, 33, 34, 35], [36, 37, 38, 39], [40, 41, 42, 43], [44, 45, 46, 47], [48, 49, 50, 51]]) == []\n assert candidate(matrix = [[34, 77, 56, 23], [89, 10, 45, 67], [55, 88, 22, 33], [44, 66, 77, 88]]) == []\n assert candidate(matrix = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [12, 14, 16, 18, 20], [21, 23, 25, 27, 29]]) == [21]\n assert candidate(matrix = [[100000, 99999, 99998, 99997, 99996], [99995, 99994, 99993, 99992, 99991], [99990, 99989, 99988, 99987, 99986], [99985, 99984, 99983, 99982, 99981]]) == [99996]\n assert candidate(matrix = [[10, 20, 30, 40], [9, 8, 7, 6], [5, 4, 3, 2], [1, 18, 19, 20]]) == [10]\n assert candidate(matrix = [[50000, 1, 50001, 50002], [50003, 50004, 50005, 50006], [50007, 50008, 2, 50009], [50010, 50011, 50012, 50013]]) == [50010]\n assert candidate(matrix = [[33, 44, 55, 66, 77, 88, 99], [22, 34, 45, 56, 67, 78, 89], [11, 23, 35, 46, 57, 68, 79], [10, 21, 32, 43, 54, 65, 76], [9, 20, 31, 42, 53, 64, 75], [8, 19, 30, 41, 52, 63, 74], [7, 18, 29, 40, 51, 62, 73]]) == [33]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16]]) == [16]\n assert candidate(matrix = [[8, 16, 9, 12, 15], [10, 5, 14, 6, 13], [18, 17, 11, 7, 4], [19, 20, 3, 1, 2]]) == []\n assert candidate(matrix = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [5, 1, 55, 59, 60], [2, 3, 6, 7, 8], [61, 62, 63, 64, 65]]) == [61]\n assert candidate(matrix = [[12345, 67890, 11111, 22222], [33333, 44444, 55555, 66666], [77777, 88888, 99999, 100000], [100001, 100002, 100003, 100004]]) == [100001]\n assert candidate(matrix = [[50000, 49999, 1], [49998, 49997, 2], [49996, 49995, 3]]) == [3]\n assert candidate(matrix = [[3, 6, 8, 14, 5], [20, 10, 16, 19, 17], [7, 1, 15, 4, 13], [18, 9, 21, 12, 11]]) == [10]\n assert candidate(matrix = [[40, 20, 60, 70], [30, 10, 50, 80], [25, 5, 35, 90], [15, 2, 45, 100]]) == [20]\n assert candidate(matrix = [[8, 5, 9, 10, 7], [6, 1, 3, 4, 2], [11, 12, 14, 15, 13], [16, 17, 19, 20, 18], [21, 22, 24, 25, 23]]) == [21]\n assert candidate(matrix = [[10, 15, 20, 25], [5, 30, 35, 40], [45, 41, 42, 43], [50, 55, 60, 65]]) == [50]\n assert candidate(matrix = [[85, 21, 17, 45], [62, 59, 100, 58], [90, 28, 29, 83]]) == []\n assert candidate(matrix = [[50000, 45000, 40000, 35000, 30000], [29000, 24000, 20000, 15000, 10000], [9999, 4999, 2499, 1249, 624], [312, 156, 78, 39, 19], [9, 4, 2, 1, 0]]) == [30000]\n assert candidate(matrix = [[34, 67, 89, 12], [12, 98, 23, 45], [56, 33, 78, 88], [87, 66, 55, 44]]) == []\n assert candidate(matrix = [[100, 200, 300, 400], [150, 250, 350, 450], [50, 150, 250, 350], [200, 300, 400, 500]]) == [200]\n assert candidate(matrix = [[100, 99, 98, 97, 96], [95, 94, 93, 92, 91], [90, 89, 88, 87, 86], [85, 84, 83, 82, 81], [80, 79, 78, 77, 76]]) == [96]\n assert candidate(matrix = [[10000, 10001, 10002], [9999, 10000, 10003], [9998, 9997, 10000]]) == [10000]\n assert candidate(matrix = [[98, 99, 100], [95, 96, 97], [92, 93, 94], [89, 90, 91]]) == [98]\n assert candidate(matrix = [[5, 3, 9, 1], [8, 4, 2, 7], [6, 10, 12, 11]]) == []\n assert candidate(matrix = [[5, 8, 9, 10], [1, 3, 4, 7], [11, 12, 13, 14], [6, 2, 0, 15]]) == [11]\n assert candidate(matrix = [[1, 3, 5, 7, 9], [9, 7, 5, 3, 1], [2, 4, 6, 8, 0], [8, 6, 4, 2, 10]]) == []\n assert candidate(matrix = [[55, 56, 57], [54, 53, 58], [51, 52, 59]]) == [55]\n assert candidate(matrix = [[101, 102, 103, 104], [105, 106, 107, 108], [109, 110, 111, 112], [113, 114, 115, 116], [117, 118, 119, 120]]) == [117]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 1], [1, 5, 4, 3, 2], [3, 4, 5, 1, 2]]) == []\n assert candidate(matrix = [[9, 8, 7, 6], [5, 4, 3, 2], [1, 10, 11, 12], [13, 14, 15, 16]]) == [13]\n assert candidate(matrix = [[10, 50, 30, 40], [60, 20, 90, 80], [70, 100, 110, 120], [130, 140, 150, 160]]) == [130]\n assert candidate(matrix = [[100, 90, 80, 70, 60], [50, 40, 30, 20, 10], [1, 101, 201, 301, 401], [9, 109, 209, 309, 409], [8, 108, 208, 308, 408]]) == []\n assert candidate(matrix = [[55, 65, 75, 85, 95], [15, 25, 35, 45, 5], [60, 70, 80, 90, 100], [1, 2, 3, 4, 6]]) == [60]\n assert candidate(matrix = [[1, 2, 3], [6, 5, 4], [7, 8, 9], [12, 11, 10]]) == [10]\n assert candidate(matrix = [[23, 24, 25, 26, 27], [18, 19, 20, 21, 22], [13, 14, 15, 16, 17], [8, 9, 10, 11, 12], [3, 4, 5, 6, 7], [1, 2, 3, 4, 5]]) == [23]\n assert candidate(matrix = [[5, 12, 45, 32], [99, 3, 87, 67], [15, 16, 17, 18], [20, 21, 22, 23]]) == []\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == [31]\n assert candidate(matrix = [[22, 34, 40, 54], [2, 3, 7, 65], [99, 23, 35, 22]]) == []\n assert candidate(matrix = [[1, 99999, 2, 99998, 3, 99997], [99996, 4, 99995, 5, 99994, 6], [7, 99993, 8, 99992, 9, 99991]]) == []\n assert candidate(matrix = [[500, 400, 300], [200, 100, 300], [150, 50, 400], [450, 350, 250]]) == []\n assert candidate(matrix = [[99999, 10000, 10001], [99998, 99997, 10002], [1, 99996, 99995]]) == []\n assert candidate(matrix = [[10, 20, 30, 40], [50, 60, 70, 80], [1, 2, 3, 4], [5, 6, 7, 9]]) == [50]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16], [21, 22, 23, 24, 25]]) == [21]\n assert candidate(matrix = [[2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [11, 13, 15, 17, 19], [20, 18, 16, 14, 12]]) == []\n assert candidate(matrix = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41], [9, 19, 29, 39, 49], [8, 18, 28, 38, 48]]) == [10]\n assert candidate(matrix = [[100, 200, 300, 400, 500], [99, 199, 299, 399, 499], [98, 198, 298, 398, 498], [97, 197, 297, 397, 497], [96, 196, 296, 396, 496]]) == [100]\n assert candidate(matrix = [[34, 73, 89, 52], [12, 76, 87, 42], [61, 94, 66, 21], [71, 54, 62, 78]]) == []\n assert candidate(matrix = [[100000, 99999, 99998], [99997, 99996, 99995], [99994, 99993, 99992]]) == [99998]\n assert candidate(matrix = [[999, 888, 777], [666, 555, 444], [333, 222, 111], [99, 88, 77]]) == [777]\n assert candidate(matrix = [[100, 200, 300], [250, 150, 100], [100, 300, 200], [50, 400, 250]]) == []\n assert candidate(matrix = [[8, 6, 4, 2, 0], [13, 11, 9, 7, 5], [18, 16, 14, 12, 10]]) == [10]\n assert candidate(matrix = [[1, 3, 5, 7, 9], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29], [31, 33, 35, 37, 39]]) == [31]\n assert candidate(matrix = [[2, 4, 6, 8, 10, 12], [1, 3, 5, 7, 9, 11], [11, 9, 7, 5, 3, 1], [12, 10, 8, 6, 4, 2], [13, 15, 17, 19, 21, 23]]) == [13]\n"}, "metadata": {"canonical_parameter_names": ["matrix"], "leetcode_dataset_entry_point": "Solution().luckyNumbers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector luckyNumbers(vector>& matrix) {", "container": "Solution", "callable": "luckyNumbers", "parameters": [{"name": "matrix", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1382, "task_id": "balance-a-binary-search-tree", "difficulty": "Medium", "problem_description": "Given the root of a binary search tree, return a balanced binary search tree with the same node values. If there is more than one answer, return any of them.\nA binary search tree is balanced if the depth of the two subtrees of every node never differs by more than 1.\n \nExample 1:\n\n\nInput: root = [1,null,2,null,3,null,4,null,null]\nOutput: [2,1,3,null,null,null,4]\nExplanation: This is not the only correct answer, [3,1,4,null,2] is also correct.\n\nExample 2:\n\n\nInput: root = [2,1,3]\nOutput: [2,1,3]\n\n \nConstraints:\n\nThe number of nodes in the tree is in the range [1, 104].\n1 <= Node.val <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7])), tree_node([1, 2, 3, 4, 5, 6, 7]))\n assert is_same_tree(candidate(root = tree_node([3, 1, 4, None, 2])), tree_node([2, 1, 3, None, None, None, 4]))\n assert is_same_tree(candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5])), tree_node([3, 1, 4, None, 2, None, 5]))\n assert is_same_tree(candidate(root = tree_node([5, 3, 6, 2, 4, None, 7, 1, None, None, None, 8])), tree_node([4, 2, 6, 1, 3, 5, 8, None, None, None, None, None, None, None, 7]))\n assert is_same_tree(candidate(root = tree_node([10, 5, None, 2, 7, None, None, 1, 3, None, None, 6, 8])), tree_node([7, 5, 3, 2, 1, 6, 8, None, None, None, None, None, None, None, 10]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4])), tree_node([2, 4, 1, None, None, None, 3]))\n assert is_same_tree(candidate(root = tree_node([10, 5, 15, 3, 7, None, 18])), tree_node([7, 3, 15, None, 5, 10, 18]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])), tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]))\n assert is_same_tree(candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, None])), tree_node([2, 1, 3, None, None, None, 4]))\n assert is_same_tree(candidate(root = tree_node([2, 1, 3])), tree_node([2, 1, 3]))\n assert is_same_tree(candidate(root = tree_node([1, None, 2, None, 3])), tree_node([2, 1, 3]))\n assert is_same_tree(candidate(root = tree_node([10, 5, 15, None, None, 6, 20])), tree_node([6, 5, 15, None, 10, None, 20]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13])), tree_node([1, 6, 7, 2, 10, 3, 11, None, 4, 8, 12, None, 5, 9, 13]))\n assert is_same_tree(candidate(root = tree_node([50, 30, 80, 10, 40, 60, 90, 5, 20, 35, 45, 55, 65, 85, 95, 1, 9, 15, 25, 32, 38, 42, 48, 52, 58, 63, 68, 75, 83, 92, 98])), tree_node([50, 30, 80, 10, 40, 60, 90, 5, 20, 35, 45, 55, 65, 85, 95, 1, 9, 15, 25, 32, 38, 42, 48, 52, 58, 63, 68, 75, 83, 92, 98]))\n assert is_same_tree(candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])), tree_node([5, 2, 8, 1, 3, 6, 9, None, None, None, 4, None, 7, None, 10]))\n assert is_same_tree(candidate(root = tree_node([7, 3, 15, None, 4, 10, 20, 2, None, 5, 8, 13, 17, 22, 27])), tree_node([5, 2, 15, 3, 4, 10, 20, None, 22, 27, 7, None, 8, 13, 17]))\n assert is_same_tree(candidate(root = tree_node([9, 4, 20, 2, None, 15, 22, None, None, 11, 17, 21, 27, None, None, None, 13, None, None, None, None, 18, 24, 30, None, None, None, None, 23, 25, 29, 31])), tree_node([25, 11, 24, 4, 17, 29, 21, 2, 9, 15, 30, 23, 18, 20, 22, None, None, None, None, None, None, None, 31, None, None, None, 13, None, None, None, 27]))\n assert is_same_tree(candidate(root = tree_node([15, 10, 20, 5, 12, None, 25, None, None, 11, 13, 22, 30, None, None, 18, 24, None, None, 21, 23, 26, 29, None, None, None, None, 19])), tree_node([24, 12, 25, 10, 18, 20, 30, 5, 11, 26, 29, 15, 22, 21, 19, None, None, None, None, None, None, None, 13, None, None, None, None, None, None, None, 23]))\n assert is_same_tree(candidate(root = tree_node([25, 15, 35, 10, 20, 30, 40, 5, 12, 18, 22, 28, 32, 38, 45, 1, 7, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, 39, 41, 43, 47, 4, 6, 8, 9, 14, 16, 24, 26, 36, 42, 44, 46, 48, 49])), tree_node([44, 14, 30, 6, 26, 49, 38, 1, 10, 13, 18, 21, 27, 33, 41, 47, 4, 7, 9, 12, 24, 17, 42, 20, 48, 23, 28, 31, 35, 39, 45, None, None, None, 5, None, 8, None, 11, None, 16, None, 15, None, 36, None, 19, None, 46, None, 22, None, 25, None, 29, None, 32, None, 37, None, 40, None, 43]))\n assert is_same_tree(candidate(root = tree_node([5, 3, 6, 2, 4, None, 8, 1, None, None, None, 7, 9])), tree_node([5, 2, 7, 1, 3, 6, 8, None, None, None, 4, None, None, None, 9]))\n assert is_same_tree(candidate(root = tree_node([7, 3, 11, 2, 5, 9, 13, 1, 4, 6, 8, 10, 12, 14, 15])), tree_node([7, 3, 11, 2, 5, 9, 13, 1, 4, 6, 8, 10, 12, 14, 15]))\n assert is_same_tree(candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 13, 17, 23, 27, 33, 37, 1, 4, 6, 8, 12, 14, 16, 18, 22, 24, 26, 28, 32, 34, 36, 38])), tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 13, 17, 23, 27, 33, 37, 1, 4, 6, 8, 12, 14, 16, 18, 22, 24, 26, 28, 32, 34, 36, 38]))\n assert is_same_tree(candidate(root = tree_node([50, 30, 70, 20, 40, 60, 80, 10, 25, 35, 45, 55, 65, 75, 85, 5, 15, 22, 28, 32, 38, 43, 47, 52, 58, 63, 68, 72, 78, 82, 87, 90, 95, 100])), tree_node([45, 22, 68, 10, 32, 55, 78, 5, 15, 28, 38, 50, 60, 72, 82, 90, 95, 100, 20, 25, 30, 35, 40, 47, 52, 58, 63, 70, 75, 80, 85, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 43, None, None, None, None, None, None, None, 65, None, None, None, None, None, None, None, 87]))\n assert is_same_tree(candidate(root = tree_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30])), tree_node([16, 8, 24, 4, 12, 20, 28, 2, 6, 10, 14, 18, 22, 26, 30, None, 15, 7, 17, 3, 19, 9, 21, 1, 23, 11, 25, 5, 27, 13, 29]))\n assert is_same_tree(candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 13, 17, 23, 27, 33, 37, 2, 4, 6, 8, 12, 14, 16, 18, 22, 24, 26, 28, 32, 34, 36, 38, 1, 9, 11, 19, 21, 29, 31, 39, 40])), tree_node([14, 6, 26, 11, 39, 20, 33, 2, 19, 7, 40, 16, 23, 28, 36, 1, 9, 4, 5, 29, 31, 10, 12, 15, 17, 22, 24, 27, 30, 34, 37, None, None, None, 3, None, None, None, 21, None, None, None, 8, None, None, None, 13, None, None, None, 18, None, None, None, 25, None, None, None, 32, None, 35, None, 38]))\n assert is_same_tree(candidate(root = tree_node([10, 9, 11, 8, None, None, 12, 7, None, None, None, 13, 14, 6, None, None, None, None, 5])), tree_node([14, 5, 10, 6, 13, 8, 11, None, None, None, 7, None, 9, None, 12]))\n assert is_same_tree(candidate(root = tree_node([5, 3, 8, 2, 4, None, 9, 1, None, None, None, 7, 10, 6, None, None, 11])), tree_node([5, 2, 11, 6, 3, 8, 9, None, 1, None, 4, None, 7, None, 10]))\n assert is_same_tree(candidate(root = tree_node([10, 5, 15, None, None, 12, 20, 11, 13, 18, 25])), tree_node([13, 10, 18, 5, 11, 15, 20, None, None, None, 12, None, None, None, 25]))\n assert is_same_tree(candidate(root = tree_node([5, 3, 6, 2, 4, None, None, 1, None, None, None, None, None, 8, 7])), tree_node([3, 1, 5, None, 2, 4, 6]))\n assert is_same_tree(candidate(root = tree_node([5, 3, 8, 2, 4, 6, 9, 1, None, None, None, None, 7, None, None, 10])), tree_node([4, 1, 7, 10, 2, 5, 8, None, None, None, 3, None, 6, None, 9]))\n assert is_same_tree(candidate(root = tree_node([10, 5, 20, 3, 7, 15, 25, 2, 4, 6, 8, 12, 18, 22, 27, 1, None, None, None, None, None, None, None, None, 9, None, None, 11, None, 13, None, 17, 16, 19, 21, None, 23, None, 24, 26, None, 28, None, 29])), tree_node([12, 3, 20, 1, 6, 9, 25, 26, 16, 4, 8, 29, 15, 23, 24, None, 17, 28, 2, None, 5, 7, 10, None, 19, 21, 18, 11, 22, 13, 27]))\n assert is_same_tree(candidate(root = tree_node([7, 3, 15, None, None, 9, 20])), tree_node([9, 3, 15, None, 7, None, 20]))\n assert is_same_tree(candidate(root = tree_node([10, 5, 15, 3, 7, 12, 20, 1, 4, 6, 8, 11, 13, 19, 21])), tree_node([10, 5, 15, 3, 7, 12, 20, 1, 4, 6, 8, 11, 13, 19, 21]))\n assert is_same_tree(candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 1, 7, 13, 17, 23, 27, 33, 37, 0, 2, 4, 6, 8, 12, 14, 16, 18, 22, 24, 26, 28, 32, 34, 36, 38, 39])), tree_node([16, 7, 26, 1, 13, 22, 32, 0, 5, 10, 15, 18, 24, 28, 34, 38, 39, 2, 4, 6, 8, 12, 14, 20, 23, 25, 27, 30, 33, 35, 37, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 17, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 36]))\n assert is_same_tree(candidate(root = tree_node([10, 5, 15, None, 7, 12, 17, 6, 8, 11, 13, 16, 18])), tree_node([11, 7, 15, 5, 8, 12, 17, None, 6, None, 10, None, 13, 16, 18]))\n assert is_same_tree(candidate(root = tree_node([10, 5, None, 2, 7, None, 1, 3, 6, 8, 9])), tree_node([5, 8, 7, 2, 1, 3, 6, None, None, None, 9, None, None, None, 10]))\n assert is_same_tree(candidate(root = tree_node([20, 15, 25, 10, 18, 22, 30, 5, 13, None, None, 16, 19, None, None, None, None, 1, None, None, 7, 12])), tree_node([20, 1, 12, 5, 15, 7, 25, None, 10, 13, 18, 16, 22, 19, 30]))\n assert is_same_tree(candidate(root = tree_node([20, 10, None, 5, 15, None, 3, 7, None, None, None, None, None, 4])), tree_node([10, 5, 15, None, 3, 7, 20]))\n assert is_same_tree(candidate(root = tree_node([6, 2, 8, 0, 4, 7, 9, None, None, 3, 5, None, None, None, None, None, None, None, None, None, None, None])), tree_node([5, 2, 7, 0, 3, 6, 8, None, None, None, 4, None, None, None, 9]))\n assert is_same_tree(candidate(root = tree_node([2, 1, 3, None, None, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])), tree_node([12, 10, 3, 1, 11, 7, 5, None, 2, 6, 4, None, 13, 8, 9]))\n assert is_same_tree(candidate(root = tree_node([5, 3, 9, 1, 4, 7, 10, None, None, 2, None, 6, 8, None, None, None, None, 11])), tree_node([11, 2, 8, 1, 4, 6, 9, None, 3, None, 5, None, 7, None, 10]))\n assert is_same_tree(candidate(root = tree_node([8, 5, 11, 3, 6, None, None, 2, None, 4, None, 1, None, 7])), tree_node([7, 2, 6, 1, 3, 4, 8, None, None, None, 5, None, None, None, 11]))\n assert is_same_tree(candidate(root = tree_node([7, 1, 9, None, 2, None, 10, None, 3, None, 4, None, 5, None, 6])), tree_node([7, 2, 10, 1, 3, 9, 4, None, None, None, 5, None, None, None, 6]))\n assert is_same_tree(candidate(root = tree_node([10, 5, 15, None, None, 13, 20, 12, 14, 18, 25, 16, 19, 22, 27])), tree_node([22, 16, 15, 5, 19, 14, 20, None, 10, 12, 13, None, 27, 18, 25]))\n assert is_same_tree(candidate(root = tree_node([5, 3, 8, 2, 4, 6, 9, 1, None, 3.5, 4.5, 5.5, 6.5])), tree_node([4.5, 3, 6, 1, 3.5, 5, 8, None, 2, None, 4, None, 5.5, 6.5, 9]))\n assert is_same_tree(candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15])), tree_node([8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15]))\n assert is_same_tree(candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7])), tree_node([4, 2, 6, 1, 3, 5, 7]))\n assert is_same_tree(candidate(root = tree_node([50, 30, 70, 20, 40, 60, 80, 10, 25, 35, 45, 55, 65, 75, 90, 5, 15, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 95])), tree_node([40, 15, 65, 5, 25, 50, 75, 95, 10, 20, 30, 45, 55, 70, 80, None, None, None, None, None, None, None, 35, None, None, None, 60, None, None, None, 90]))\n assert is_same_tree(candidate(root = tree_node([1, 2, None, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8])), tree_node([5, 3, 7, 2, 4, 6, 8, None, None, None, None, None, None, None, 1]))\n assert is_same_tree(candidate(root = tree_node([8, 5, 11, 2, 7, 10, 12, 1, None, 6, None, 9])), tree_node([7, 2, 10, 1, 5, 8, 11, None, None, None, 6, None, 9, None, 12]))\n assert is_same_tree(candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 12, 17, 22, 27, 32, 37, 1, 4, 6, 8, 11, 13, 16, 18, 19, 21, 23, 24, 26, 28, 29, 31, 33, 34, 36, 38, 39, 40])), tree_node([16, 39, 27, 3, 10, 19, 28, 1, 4, 40, 12, 18, 21, 30, 29, 33, 34, 36, 38, 6, 7, 11, 13, 17, 20, 22, 25, 24, 26, 35, 37, None, None, None, None, None, None, None, 5, None, None, None, 8, None, None, None, 15, None, None, None, None, None, None, None, 23, None, None, None, 32, None, None, None, 31]))\n assert is_same_tree(candidate(root = tree_node([8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15])), tree_node([8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15]))\n assert is_same_tree(candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9])), tree_node([5, 2, 7, 1, 3, 6, 8, None, None, None, 4, None, None, None, 9]))\n assert is_same_tree(candidate(root = tree_node([4, 2, 6, 1, 3, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15])), tree_node([4, 2, 6, 1, 3, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15]))\n assert is_same_tree(candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, None, None, 6])), tree_node([7, 5, 15, 3, 6, 10, 18]))\n assert is_same_tree(candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8])), tree_node([4, 2, 6, 1, 3, 5, 7, None, None, None, None, None, None, None, 8]))\n assert is_same_tree(candidate(root = tree_node([4, 2, 6, 1, 3, 5, 7, 0, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5])), tree_node([4, 2, 6, 1, 3, 5, 7, 0, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5]))\n assert is_same_tree(candidate(root = tree_node([25, 10, 30, 5, 15, 27, 40, 1, None, 8, 12, None, 18, 22, 29, 38, None, None, 3, None, 7, None, 11, None, 13, None, 17, None, 21, None, 23, None, 33, None, 35, None, 37, None, 42, None, 45, None, 48])), tree_node([33, 8, 22, 45, 48, 18, 40, 38, 5, 3, 12, 25, 35, 13, 17, None, 21, 1, 10, None, 23, 15, 7, None, 27, 11, 30, None, 37, 29, 42]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])), tree_node([23, 19, 27, 17, 21, 25, 29, 16, 18, 20, 22, 24, 26, 28, 30, None, 8, 4, 9, 2, 10, 5, 11, 1, 12, 6, 13, 3, 14, 7, 15]))\n assert is_same_tree(candidate(root = tree_node([7, 3, 15, None, 5, 9, 20, None, 4, 6, 8, 11, 17, 19, 22, None, 2, None, None, None, None, None, None, 10])), tree_node([6, 19, 15, 5, 22, 9, 20, 3, 10, 4, 7, 2, 8, 11, 17]))\n assert is_same_tree(candidate(root = tree_node([25, 15, 50, 10, 22, 35, 60, 5, 12, 18, 24, 30, 44, 55, 65, 2, 7, None, 13, None, None, 19, 23, None, 29, 33, 41, 47, 53, 63, None, None, None, 3, 8, 11, 14, None, None, 20, None, 28, None, None, 32, None, 36, 40, None, 45, 48, None, 52, 58, 62, 67, None, None, None, None, None, None, 6, None, None, None, None, None, 4, None, None, 9, None, None, 16, None, 21, 26, None, 31, 34, 38, 42, None, None, 46, None, 50, None, 54, 57, 61, 66, 68, None, None, None, None, None, 1, None, None, None, None, None, None, None, None, None, 17, None, 27, None, None, 37, None, None, None, None, None, None, None, None, None, None, 43, None, None, None, 51, None, None, 56, None, None, 64, None, 69])), tree_node([28, 8, 45, 31, 22, 46, 63, 68, 1, 13, 6, 32, 47, 16, 21, 2, 58, 34, 67, 12, 15, 24, 25, 35, 41, 50, 50, 48, 57, 27, 37, None, 5, 26, 3, 62, 7, 38, 42, 10, 11, 14, 18, 19, 20, 23, 30, 29, 33, 44, 36, 4, 40, 55, 9, 53, 54, 17, 60, 52, 61, 66, 65]))\n assert is_same_tree(candidate(root = tree_node([1, None, 3, None, 5, None, 7, None, 9, None, 11, None, 13, None, 15])), tree_node([7, 3, 11, 1, 5, 9, 13, None, None, None, None, None, None, None, 15]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])), tree_node([10, 18, 6, 8, 19, 11, 14, 16, 17, 9, 2, 5, 1, 13, 7, None, None, None, 4, None, None, None, 20, None, None, None, 12, None, 3, None, 15]))\n assert is_same_tree(candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 13, 17, 23, 27, 33, 37, 1, 4, 6, 8, 12, 14, 16, 18, 22, 24, 26, 28, 32, 34, 36, 38, None, None, 2, 9, 11, 19, 21, 29, 31, 39])), tree_node([15, 7, 27, 9, 31, 22, 34, 3, 11, 8, 39, 17, 24, 30, 36, 1, 2, 5, 6, 21, 29, 12, 13, 16, 18, 23, 25, 28, 32, 35, 37, None, None, None, 4, None, None, None, 19, None, None, None, 10, None, None, None, 14, None, None, None, 20, None, None, None, 26, None, None, None, 33, None, None, None, 38]))\n assert is_same_tree(candidate(root = tree_node([50, 30, 70, 20, 40, 60, 80, 10, 25, 35, 45, 55, 65, 75, 90, 5, None, 15, None, 28, None, 32, None, 38, None, 43, None, 48, None, 52, None, 58, None, 63, None, 68, None, 72, None, 78, None, 83, None, 88, None, 95])), tree_node([50, 30, 70, 20, 40, 60, 80, 5, 15, 28, 32, 38, 43, 48, 52, 58, 10, 63, 25, 68, 35, 72, 45, 78, 55, 83, 65, 88, 75, 95, 90]))\n assert is_same_tree(candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])), tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]))\n assert is_same_tree(candidate(root = tree_node([10, 5, 20, 3, 7, 15, 25, 2, 4, 6, 8, 13, 17, 22, 27, 1, 9, 11, 14, 16, 18, 21, 23, 26, 28, 30])), tree_node([21, 4, 15, 9, 16, 10, 20, 1, 3, 14, 18, 8, 13, 30, 25, None, 2, None, 11, None, 5, 6, 7, None, 23, 26, 28, None, 17, 22, 27]))\n assert is_same_tree(candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 12, 17, 22, 27, 32, 37, 1, 4, 6, 8, 11, 13, 16, 18, 21, 23, 26, 28, 31, 33, 36, 38])), tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 12, 17, 22, 27, 32, 37, 1, 4, 6, 8, 11, 13, 16, 18, 21, 23, 26, 28, 31, 33, 36, 38]))\n assert is_same_tree(candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 40, 60, 80, 110, 140, 160, 190, 5, 15, 35, 45, 55, 65, 70, 85, 90, 105, 115, 135, 145, 155, 165, 185, 195, 1, 9, 20, 30, 41, 49, 51, 59, 61, 69, 71, 79, 81, 89, 91, 99, 101, 109, 111, 119, 121, 129, 131, 139, 141, 149, 151, 159, 161, 169, 171, 179, 181, 189, 191, 199, 200])), tree_node([89, 41, 135, 10, 60, 109, 151, 5, 15, 51, 75, 99, 119, 145, 161, 195, 1, 9, 25, 49, 59, 65, 70, 91, 101, 111, 121, 150, 160, 159, 169, 179, 181, 189, 191, 199, 200, 20, 30, 40, 45, 50, 55, 69, 71, 79, 81, 85, 100, 90, 110, 105, 125, 115, 140, 131, 139, 141, 149, 175, 165, 190, 185, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 35, None, None, None, None, None, None, None, 61, None, None, None, None, None, None, None, 80, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 129, None, None, None, None, None, None, None, 155, None, None, None, None, None, None, None, 171]))\n assert is_same_tree(candidate(root = tree_node([10, 5, 15, None, 7, 12, 18, None, 6, 9, 11, 13, 16, None, 8, 14, None, None, 10.5, 14.5, 16.5, 17.5])), tree_node([11, 8, 13, 7, 14, 15, 18, 5, 6, 10, 9, 10.5, 14.5, 16.5, 17.5, None, None, None, None, None, None, None, 12, None, None, None, None, None, None, None, 16]))\n"}, "metadata": {"canonical_parameter_names": ["root"], "leetcode_dataset_entry_point": "Solution().balanceBST", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "TreeNode* balanceBST(TreeNode* root) {", "container": "Solution", "callable": "balanceBST", "parameters": [{"name": "root", "type": "TreeNode*"}], "return_type": "TreeNode*", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1383, "task_id": "maximum-performance-of-a-team", "difficulty": "Hard", "problem_description": "You are given two integers n and k and two integer arrays speed and efficiency both of length n. There are n engineers numbered from 1 to n. speed[i] and efficiency[i] represent the speed and efficiency of the ith engineer respectively.\nChoose at most k different engineers out of the n engineers to form a team with the maximum performance.\nThe performance of a team is the sum of its engineers' speeds multiplied by the minimum efficiency among its engineers.\nReturn the maximum performance of this team. Since the answer can be a huge number, return it modulo 109 + 7.\n \nExample 1:\n\nInput: n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 2\nOutput: 60\nExplanation: \nWe have the maximum performance of the team by selecting engineer 2 (with speed=10 and efficiency=4) and engineer 5 (with speed=5 and efficiency=7). That is, performance = (10 + 5) * min(4, 7) = 60.\n\nExample 2:\n\nInput: n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 3\nOutput: 68\nExplanation:\nThis is the same example as the first but k = 3. We can select engineer 1, engineer 2 and engineer 5 to get the maximum performance of the team. That is, performance = (2 + 10 + 5) * min(5, 4, 7) = 68.\n\nExample 3:\n\nInput: n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 4\nOutput: 72\n\n \nConstraints:\n\n1 <= k <= n <= 105\nspeed.length == n\nefficiency.length == n\n1 <= speed[i] <= 105\n1 <= efficiency[i] <= 108\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,speed = [2, 10, 3, 1, 5, 8],efficiency = [5, 4, 3, 9, 7, 2],k = 2) == 60\n assert candidate(n = 6,speed = [2, 10, 3, 1, 5, 8],efficiency = [5, 4, 3, 9, 7, 2],k = 3) == 68\n assert candidate(n = 5,speed = [4, 1, 12, 7, 8],efficiency = [2, 10, 8, 19, 4],k = 3) == 160\n assert candidate(n = 1,speed = [1],efficiency = [1],k = 1) == 1\n assert candidate(n = 10,speed = [9, 7, 6, 5, 4, 3, 2, 1, 10, 8],efficiency = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 40\n assert candidate(n = 3,speed = [2, 8, 2],efficiency = [2, 7, 1],k = 2) == 56\n assert candidate(n = 10,speed = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],efficiency = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 180\n assert candidate(n = 5,speed = [3, 5, 9, 7, 6],efficiency = [5, 3, 8, 6, 2],k = 4) == 96\n assert candidate(n = 5,speed = [5, 4, 3, 2, 1],efficiency = [1, 2, 3, 4, 5],k = 3) == 18\n assert candidate(n = 5,speed = [10, 20, 30, 40, 50],efficiency = [50, 40, 30, 20, 10],k = 3) == 1800\n assert candidate(n = 3,speed = [1, 2, 3],efficiency = [3, 2, 1],k = 2) == 6\n assert candidate(n = 10,speed = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],efficiency = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 100\n assert candidate(n = 6,speed = [2, 10, 3, 1, 5, 8],efficiency = [5, 4, 3, 9, 7, 2],k = 4) == 72\n assert candidate(n = 5,speed = [1, 1, 1, 1, 1],efficiency = [1, 1, 1, 1, 1],k = 5) == 5\n assert candidate(n = 10,speed = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],efficiency = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 5) == 996499717\n assert candidate(n = 10,speed = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],efficiency = [50, 40, 30, 20, 10, 90, 80, 70, 60, 50],k = 3) == 13650\n assert candidate(n = 50,speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],efficiency = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 10\n assert candidate(n = 25,speed = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000, 130000, 140000, 150000, 160000, 170000, 180000, 190000, 200000, 210000, 220000, 230000, 240000, 250000],efficiency = [250000, 240000, 230000, 220000, 210000, 200000, 190000, 180000, 170000, 160000, 150000, 140000, 130000, 120000, 110000, 100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 15) == 999999062\n assert candidate(n = 20,speed = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],efficiency = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],k = 10) == 2400\n assert candidate(n = 20,speed = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000, 5000, 4000, 3000, 2000, 1000, 500, 400, 300, 200, 100],efficiency = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 10) == 980000000\n assert candidate(n = 5,speed = [10, 10, 10, 10, 10],efficiency = [10, 10, 10, 10, 10],k = 3) == 300\n assert candidate(n = 25,speed = [5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000, 55000, 60000, 65000, 70000, 75000, 80000, 85000, 90000, 95000, 100000, 105000, 110000, 115000, 120000, 125000],efficiency = [125, 120, 115, 110, 105, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5],k = 15) == 33750000\n assert candidate(n = 10,speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],efficiency = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 30\n assert candidate(n = 50,speed = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000, 21000, 22000, 23000, 24000, 25000, 26000, 27000, 28000, 29000, 30000, 31000, 32000, 33000, 34000, 35000, 36000, 37000, 38000, 39000, 40000, 41000, 42000, 43000, 44000, 45000, 46000, 47000, 48000, 49000, 50000],efficiency = [50000, 49000, 48000, 47000, 46000, 45000, 44000, 43000, 42000, 41000, 40000, 39000, 38000, 37000, 36000, 35000, 34000, 33000, 32000, 31000, 30000, 29000, 28000, 27000, 26000, 25000, 24000, 23000, 22000, 21000, 20000, 19000, 18000, 17000, 16000, 15000, 14000, 13000, 12000, 11000, 10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],k = 25) == 499999937\n assert candidate(n = 8,speed = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000],efficiency = [100, 150, 200, 250, 300, 350, 400, 450],k = 4) == 55000000\n assert candidate(n = 15,speed = [2, 4, 5, 7, 8, 10, 12, 15, 18, 20, 25, 30, 35, 40, 45],efficiency = [3, 5, 2, 8, 7, 4, 6, 9, 10, 11, 13, 12, 15, 14, 16],k = 6) == 2145\n assert candidate(n = 15,speed = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],efficiency = [100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30],k = 8) == 15300\n assert candidate(n = 15,speed = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],efficiency = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 2450\n assert candidate(n = 50,speed = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000, 5000, 4000, 3000, 2000, 1000, 500, 400, 300, 200, 100, 99, 88, 77, 66, 55, 44, 33, 22, 11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 200, 300, 400, 500, 600, 700, 800, 900],efficiency = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 999, 888, 777, 666, 555, 444, 333, 222, 111, 11, 22, 33, 44, 55, 66, 77, 88, 99, 100],k = 15) == 2388600\n assert candidate(n = 20,speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],efficiency = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 680\n assert candidate(n = 25,speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],efficiency = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 1350\n assert candidate(n = 20,speed = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],efficiency = [200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 10) == 68000\n assert candidate(n = 50,speed = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000, 3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000, 4100, 4200, 4300, 4400, 4500, 4600, 4700, 4800, 4900, 5000],efficiency = [5000, 4900, 4800, 4700, 4600, 4500, 4400, 4300, 4200, 4100, 4000, 3900, 3800, 3700, 3600, 3500, 3400, 3300, 3200, 3100, 3000, 2900, 2800, 2700, 2600, 2500, 2400, 2300, 2200, 2100, 2000, 1900, 1800, 1700, 1600, 1500, 1400, 1300, 1200, 1100, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],k = 25) == 95000000\n assert candidate(n = 12,speed = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],efficiency = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 12],k = 6) == 40000\n assert candidate(n = 10,speed = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],efficiency = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 5500\n assert candidate(n = 15,speed = [5, 3, 8, 2, 7, 6, 4, 9, 1, 11, 10, 12, 13, 14, 15],efficiency = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 290\n assert candidate(n = 10,speed = [1, 100000, 100, 1000, 10000, 10, 100000, 10000, 1000, 1],efficiency = [100000, 1, 10000, 100, 1000, 100000, 1000, 100, 10, 1],k = 5) == 110111000\n assert candidate(n = 20,speed = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],efficiency = [100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5],k = 10) == 17000\n assert candidate(n = 15,speed = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],efficiency = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 7) == 2940\n assert candidate(n = 20,speed = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],efficiency = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 68000\n assert candidate(n = 75,speed = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600, 610, 620, 630, 640, 650, 660, 670, 680, 690, 700, 710, 720, 730, 740, 750],efficiency = [750, 740, 730, 720, 710, 700, 690, 680, 670, 660, 650, 640, 630, 620, 610, 600, 590, 580, 570, 560, 550, 540, 530, 520, 510, 500, 490, 480, 470, 460, 450, 440, 430, 420, 410, 400, 390, 380, 370, 360, 350, 340, 330, 320, 310, 300, 290, 280, 270, 260, 250, 240, 230, 220, 210, 200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 50) == 3315000\n"}, "metadata": {"canonical_parameter_names": ["n", "speed", "efficiency", "k"], "leetcode_dataset_entry_point": "Solution().maxPerformance", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxPerformance(int n, vector& speed, vector& efficiency, int k) {", "container": "Solution", "callable": "maxPerformance", "parameters": [{"name": "n", "type": "int"}, {"name": "speed", "type": "vector&"}, {"name": "efficiency", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1385, "task_id": "find-the-distance-value-between-two-arrays", "difficulty": "Easy", "problem_description": "Given two integer arrays arr1 and arr2, and the integer d, return the distance value between the two arrays.\nThe distance value is defined as the number of elements arr1[i] such that there is not any element arr2[j] where |arr1[i]-arr2[j]| <= d.\n \nExample 1:\n\nInput: arr1 = [4,5,8], arr2 = [10,9,1,8], d = 2\nOutput: 2\nExplanation: \nFor arr1[0]=4 we have: \n|4-10|=6 > d=2 \n|4-9|=5 > d=2 \n|4-1|=3 > d=2 \n|4-8|=4 > d=2 \nFor arr1[1]=5 we have: \n|5-10|=5 > d=2 \n|5-9|=4 > d=2 \n|5-1|=4 > d=2 \n|5-8|=3 > d=2\nFor arr1[2]=8 we have:\n|8-10|=2 <= d=2\n|8-9|=1 <= d=2\n|8-1|=7 > d=2\n|8-8|=0 <= d=2\n\nExample 2:\n\nInput: arr1 = [1,4,2,3], arr2 = [-4,-3,6,10,20,30], d = 3\nOutput: 2\n\nExample 3:\n\nInput: arr1 = [2,1,100,3], arr2 = [-5,-2,10,-3,7], d = 6\nOutput: 1\n\n \nConstraints:\n\n1 <= arr1.length, arr2.length <= 500\n-1000 <= arr1[i], arr2[j] <= 1000\n0 <= d <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr1 = [10, 20, 30],arr2 = [5, 15, 25],d = 4) == 3\n assert candidate(arr1 = [-1000, 1000],arr2 = [-500, 500],d = 499) == 2\n assert candidate(arr1 = [4, 5, 8],arr2 = [10, 9, 1, 8],d = 2) == 2\n assert candidate(arr1 = [1, 4, 2, 3],arr2 = [-4, -3, 6, 10, 20, 30],d = 3) == 2\n assert candidate(arr1 = [-1, -2, -3],arr2 = [1, 2, 3],d = 2) == 2\n assert candidate(arr1 = [0, 0, 0, 0],arr2 = [1, 2, 3, 4],d = 0) == 4\n assert candidate(arr1 = [1000],arr2 = [-1000],d = 1999) == 1\n assert candidate(arr1 = [1],arr2 = [1],d = 0) == 0\n assert candidate(arr1 = [2, 1, 100, 3],arr2 = [-5, -2, 10, -3, 7],d = 6) == 1\n assert candidate(arr1 = [1, 2, 3],arr2 = [4, 5, 6],d = 0) == 3\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [6, 7, 8, 9, 10],d = 1) == 4\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],d = 49) == 0\n assert candidate(arr1 = [-1000, -900, -800, -700, -600],arr2 = [600, 700, 800, 900, 1000],d = 100) == 5\n assert candidate(arr1 = [-100, -200, -300],arr2 = [-50, -150, -250],d = 49) == 3\n assert candidate(arr1 = [500, 500, 500, 500, 500],arr2 = [500, 500, 500, 500, 500],d = 0) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [1, 2, 3, 4, 5],d = 5) == 4\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [10, 20, 30, 40, 50],d = 10) == 0\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [2, 4, 6, 8, 10],d = 1) == 0\n assert candidate(arr1 = [500, 1000, 1500, 2000],arr2 = [400, 900, 1400, 1900],d = 100) == 0\n assert candidate(arr1 = [0, 100, 200, 300, 400],arr2 = [50, 150, 250, 350, 450],d = 50) == 0\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [50, 150, 250, 350, 450],d = 49) == 5\n assert candidate(arr1 = [0, 5, 10, 15, 20],arr2 = [3, 6, 9, 12, 18],d = 2) == 2\n assert candidate(arr1 = [500, 400, 300, 200, 100],arr2 = [0, 100, 200, 300, 400, 500],d = 99) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [5, 15, 25, 35, 45, 55],d = 9) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [5, 15, 25, 35, 45, 55],d = 4) == 5\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [2, 4, 6, 8, 10],d = 0) == 5\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],d = 1) == 0\n assert candidate(arr1 = [0, 0, 0, 0],arr2 = [1, -1, 2, -2],d = 1) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [6, 7, 8, 9, 10],d = 0) == 5\n assert candidate(arr1 = [-100, -200, -300, -400, -500],arr2 = [100, 200, 300, 400, 500],d = 150) == 5\n assert candidate(arr1 = [-10, -20, -30],arr2 = [10, 20, 30],d = 19) == 3\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [90, 190, 290, 390, 490],d = 9) == 5\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [1, 3, 5, 7, 9],d = 0) == 2\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],d = 0) == 5\n assert candidate(arr1 = [5, 5, 5, 5, 5],arr2 = [1, 2, 3, 4, 6],d = 1) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [0, 2, 4, 6, 8],d = 0) == 5\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90],d = 3) == 3\n assert candidate(arr1 = [-10, -20, -30, -40],arr2 = [-11, -21, -31, -41],d = 0) == 4\n assert candidate(arr1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],arr2 = [5],d = 1) == 7\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],d = 0) == 1\n assert candidate(arr1 = [0, 0, 0, 0, 0],arr2 = [1, 2, 3, 4, 5],d = 0) == 5\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [2, 2, 2, 2, 2],d = 0) == 5\n assert candidate(arr1 = [2, 4, 6, 8, 10],arr2 = [1, 3, 5, 7, 9],d = 1) == 0\n assert candidate(arr1 = [1000, -1000, 500, -500],arr2 = [1000, -1000, 500, -500],d = 0) == 0\n assert candidate(arr1 = [5, 10, 15, 20, 25],arr2 = [3, 6, 9, 12, 18],d = 2) == 2\n assert candidate(arr1 = [5, 15, 25, 35, 45],arr2 = [0, 10, 20, 30, 40],d = 4) == 5\n assert candidate(arr1 = [-1000, -500, 0, 500, 1000],arr2 = [-500, 0, 500],d = 499) == 2\n assert candidate(arr1 = [-1000, 1000, 500, -500],arr2 = [0, -2000, 2000, 1000],d = 500) == 1\n assert candidate(arr1 = [500, 400, 300, 200, 100],arr2 = [-100, -200, -300, -400, -500],d = 100) == 5\n assert candidate(arr1 = [100, 200, 300, 400],arr2 = [50, 150, 250, 350],d = 49) == 4\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],d = 8) == 1\n assert candidate(arr1 = [-500, -1000, -1500, -2000],arr2 = [-400, -900, -1400, -1900],d = 100) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [0, 0, 0, 0, 0],d = 1) == 4\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [5, 15, 25, 35, 45, 55],d = 5) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [2, 4, 6, 8, 10],d = 0) == 5\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [150, 250, 350, 450],d = 49) == 5\n assert candidate(arr1 = [0, 1, 2, 3, 4],arr2 = [0, 0, 0, 0, 0],d = 2) == 2\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],d = 5) == 4\n assert candidate(arr1 = [0, 0, 0, 0],arr2 = [1, 2, 3, 4],d = 0) == 4\n assert candidate(arr1 = [-5, -10, -15, -20, -25],arr2 = [5, 10, 15, 20, 25],d = 4) == 5\n assert candidate(arr1 = [50, 51, 52, 53, 54, 55],arr2 = [50, 55],d = 0) == 4\n assert candidate(arr1 = [1, 1, 1, 1],arr2 = [2, 2, 2, 2],d = 1) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [5, 15, 25, 35, 45],d = 5) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [1, 2, 3, 4, 5],d = 1) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],d = 9) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [0, 2, 4, 6, 8],d = 1) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [5, 15, 25, 35, 45],d = 4) == 5\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9],arr2 = [2, 4, 6, 8, 10, 12, 14, 16, 18],d = 0) == 5\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [10, 20, 30, 40, 50],d = 5) == 4\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [1, 2, 3, 4, 5],d = 10) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [1, 2, 3, 4, 5],d = 0) == 0\n assert candidate(arr1 = [0, 0, 0, 0, 0],arr2 = [-1, -2, -3, -4, -5],d = 1) == 0\n assert candidate(arr1 = [100, 200, 300],arr2 = [95, 195, 295, 105, 205, 305],d = 5) == 0\n assert candidate(arr1 = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],arr2 = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],d = 2) == 0\n assert candidate(arr1 = [-100, -90, -80, -70, -60, -50],arr2 = [-95, -85, -75, -65, -55],d = 4) == 6\n assert candidate(arr1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr2 = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91],d = 9) == 0\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [1, 1, 1, 1, 1],d = 1) == 0\n assert candidate(arr1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],arr2 = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90],d = 1) == 7\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [1, 2, 3, 4, 5],d = 0) == 0\n assert candidate(arr1 = [1000, -1000, 0],arr2 = [500, -500, 0],d = 500) == 0\n assert candidate(arr1 = [0, 10, 20, 30, 40],arr2 = [5, 15, 25, 35, 45],d = 5) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],d = 8) == 9\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],arr2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],d = 0) == 10\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [10, 20, 30, 40, 50],d = 9) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15],arr2 = [2, 4, 6, 8, 10, 12, 14, 16],d = 1) == 0\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [5, 15, 25, 35, 45],d = 6) == 0\n assert candidate(arr1 = [0, 100, 200],arr2 = [50, 150, 250],d = 49) == 3\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [-1, -2, -3, -4, -5],d = 1) == 5\n assert candidate(arr1 = [1, 1, 1, 1],arr2 = [1],d = 1) == 0\n assert candidate(arr1 = [-50, -40, -30, -20, -10],arr2 = [-45, -35, -25, -15, -5],d = 4) == 5\n assert candidate(arr1 = [-10, -20, -30, -40, -50],arr2 = [-5, -15, -25, -35, -45, -55],d = 9) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [2, 4, 6, 8, 10],d = 1) == 0\n assert candidate(arr1 = [0, 0, 0, 0],arr2 = [0, 0, 0, 0],d = 0) == 0\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [50, 150, 250, 350, 450, 550],d = 49) == 5\n assert candidate(arr1 = [-100, -200, -300, -400, -500],arr2 = [-95, -195, -295, -395, -495, -595],d = 5) == 0\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [2, 2, 2, 2, 2],d = 1) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [0, 6, 7, 8, 9],d = 1) == 3\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [90, 190, 290, 390, 490],d = 5) == 5\n assert candidate(arr1 = [1, 10, 100, 1000],arr2 = [-1, -10, -100, -1000],d = 5) == 3\n assert candidate(arr1 = [100, 200, 300, 400],arr2 = [99, 199, 299, 399],d = 1) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [2, 4, 6, 8, 10],d = 1) == 0\n assert candidate(arr1 = [-100, -200, -300, -400],arr2 = [-50, -150, -250, -350],d = 49) == 4\n assert candidate(arr1 = [5, 15, 25, 35],arr2 = [10, 20, 30, 40],d = 5) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [6, 7, 8, 9, 10],d = 1) == 4\n assert candidate(arr1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],arr2 = [1, 3, 5, 7, 9],d = 0) == 5\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [2, 3, 4, 5, 6],d = 0) == 5\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15],arr2 = [2, 4, 6, 8, 10, 12, 14, 16],d = 0) == 8\n assert candidate(arr1 = [-50, -40, -30, -20, -10],arr2 = [-60, -55, -45, -35, -25],d = 5) == 1\n assert candidate(arr1 = [10, 20, 30, 40, 50],arr2 = [15, 25, 35, 45, 55],d = 4) == 5\n assert candidate(arr1 = [10, 20, 30, 40, 50, 60, 70, 80, 90],arr2 = [1, 11, 21, 31, 41, 51, 61, 71, 81],d = 9) == 0\n assert candidate(arr1 = [-100, -200, -300, -400, -500],arr2 = [-50, -150, -250, -350, -450],d = 49) == 5\n assert candidate(arr1 = [500, 400, 300, 200, 100],arr2 = [550, 450, 350, 250, 150],d = 49) == 5\n assert candidate(arr1 = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1],arr2 = [-5, 0, 5],d = 2) == 3\n assert candidate(arr1 = [1, 2, 3, 4, 5],arr2 = [6, 7, 8, 9, 10],d = 4) == 1\n assert candidate(arr1 = [-50, -25, 0, 25, 50],arr2 = [-30, -15, 15, 30],d = 14) == 3\n"}, "metadata": {"canonical_parameter_names": ["arr1", "arr2", "d"], "leetcode_dataset_entry_point": "Solution().findTheDistanceValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int findTheDistanceValue(vector& arr1, vector& arr2, int d) {", "container": "Solution", "callable": "findTheDistanceValue", "parameters": [{"name": "arr1", "type": "vector&"}, {"name": "arr2", "type": "vector&"}, {"name": "d", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1386, "task_id": "cinema-seat-allocation", "difficulty": "Medium", "problem_description": "\nA cinema has n rows of seats, numbered from 1 to n and there are ten seats in each row, labelled from 1 to 10 as shown in the figure above.\nGiven the array reservedSeats containing the numbers of seats already reserved, for example, reservedSeats[i] = [3,8] means the seat located in row 3 and labelled with 8 is already reserved.\nReturn the maximum number of four-person groups you can assign on the cinema seats. A four-person group occupies four adjacent seats in one single row. Seats across an aisle (such as [3,3]��and [3,4]) are not considered to be adjacent, but there is an exceptional case on which an aisle split a four-person group, in that case, the aisle split a four-person group in the middle, which means to have two people on each side.\n \nExample 1:\n\n\nInput: n = 3, reservedSeats = [[1,2],[1,3],[1,8],[2,6],[3,1],[3,10]]\nOutput: 4\nExplanation: The figure above shows the optimal allocation for four groups, where seats mark with blue are already reserved and contiguous seats mark with orange are for one group.\n\nExample 2:\n\nInput: n = 2, reservedSeats = [[2,1],[1,8],[2,6]]\nOutput: 2\n\nExample 3:\n\nInput: n = 4, reservedSeats = [[4,3],[1,4],[4,6],[1,7]]\nOutput: 4\n\n \nConstraints:\n\n1 <= n <= 10^9\n1 <= reservedSeats.length <= min(10*n, 10^4)\nreservedSeats[i].length == 2\n1 <= reservedSeats[i][0] <= n\n1 <= reservedSeats[i][1] <= 10\nAll reservedSeats[i] are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1,reservedSeats = []) == 2\n assert candidate(n = 5,reservedSeats = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 8\n assert candidate(n = 4,reservedSeats = [[4, 3], [1, 4], [4, 6], [1, 7]]) == 4\n assert candidate(n = 5,reservedSeats = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 5\n assert candidate(n = 5,reservedSeats = [[5, 5], [5, 6], [5, 7], [5, 8]]) == 8\n assert candidate(n = 2,reservedSeats = [[2, 1], [1, 8], [2, 6]]) == 2\n assert candidate(n = 5,reservedSeats = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9]]) == 6\n assert candidate(n = 5,reservedSeats = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]]) == 10\n assert candidate(n = 5,reservedSeats = [[1, 2], [1, 3], [2, 2], [2, 3], [2, 4], [3, 2], [3, 3], [4, 4], [4, 5], [4, 6], [5, 7], [5, 8]]) == 4\n assert candidate(n = 1000000000,reservedSeats = [[500000000, 5]]) == 1999999999\n assert candidate(n = 10,reservedSeats = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]]) == 15\n assert candidate(n = 1000000000,reservedSeats = [[1, 2], [1000000000, 9]]) == 1999999998\n assert candidate(n = 10,reservedSeats = [[2, 5], [2, 6], [3, 6], [3, 7], [4, 8], [4, 9], [5, 2], [5, 3], [6, 4], [6, 5], [7, 6], [7, 7], [8, 4], [8, 5], [9, 8], [9, 9]]) == 11\n assert candidate(n = 1,reservedSeats = [[1, 5]]) == 1\n assert candidate(n = 5,reservedSeats = [[2, 4], [2, 5], [2, 6], [2, 7]]) == 8\n assert candidate(n = 5,reservedSeats = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2]]) == 5\n assert candidate(n = 10,reservedSeats = [[2, 5], [2, 6], [3, 1], [3, 10], [4, 2], [4, 3], [5, 4], [5, 5], [6, 2], [6, 3], [7, 8], [7, 9], [8, 4], [8, 5], [9, 6], [9, 7]]) == 12\n assert candidate(n = 3,reservedSeats = [[1, 2], [1, 3], [1, 8], [2, 6], [3, 1], [3, 10]]) == 4\n assert candidate(n = 20,reservedSeats = [[5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [10, 2], [10, 3], [10, 8], [10, 9], [15, 4], [15, 5], [15, 6], [15, 7], [20, 1], [20, 2], [20, 3], [20, 4], [20, 5], [20, 6], [20, 7], [20, 8], [20, 9], [20, 10]]) == 33\n assert candidate(n = 10,reservedSeats = [[3, 2], [3, 3], [3, 4], [4, 4], [4, 5], [5, 5], [5, 6], [6, 6], [6, 7], [7, 7], [7, 8], [8, 8], [8, 9], [9, 9], [9, 10], [10, 10]]) == 12\n assert candidate(n = 30,reservedSeats = [[2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 2], [4, 3], [4, 8], [4, 9], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [6, 2], [6, 3], [6, 4], [6, 5], [7, 6], [7, 7], [7, 8], [7, 9], [8, 2], [8, 3], [8, 4], [8, 5], [9, 6], [9, 7], [9, 8], [9, 9], [10, 2], [10, 3], [10, 4], [10, 5], [11, 6], [11, 7], [11, 8], [11, 9], [12, 2], [12, 3], [12, 4], [12, 5], [13, 6], [13, 7], [13, 8], [13, 9], [14, 2], [14, 3], [14, 4], [14, 5], [15, 6], [15, 7], [15, 8], [15, 9], [16, 2], [16, 3], [16, 4], [16, 5], [17, 6], [17, 7], [17, 8], [17, 9], [18, 2], [18, 3], [18, 4], [18, 5], [19, 6], [19, 7], [19, 8], [19, 9], [20, 2], [20, 3], [20, 4], [20, 5], [21, 6], [21, 7], [21, 8], [21, 9], [22, 2], [22, 3], [22, 4], [22, 5], [23, 6], [23, 7], [23, 8], [23, 9], [24, 2], [24, 3], [24, 4], [24, 5], [25, 6], [25, 7], [25, 8], [25, 9], [26, 2], [26, 3], [26, 4], [26, 5], [27, 6], [27, 7], [27, 8], [27, 9], [28, 2], [28, 3], [28, 4], [28, 5], [29, 6], [29, 7], [29, 8], [29, 9], [30, 2], [30, 3], [30, 4], [30, 5]]) == 28\n assert candidate(n = 7,reservedSeats = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 1], [6, 2], [6, 3], [7, 4], [7, 5]]) == 8\n assert candidate(n = 10,reservedSeats = [[2, 2], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9]]) == 16\n assert candidate(n = 100,reservedSeats = [[10, 3], [10, 4], [20, 3], [20, 4], [30, 3], [30, 4], [40, 3], [40, 4], [50, 3], [50, 4], [60, 3], [60, 4], [70, 3], [70, 4], [80, 3], [80, 4], [90, 3], [90, 4]]) == 191\n assert candidate(n = 10,reservedSeats = [[2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [5, 5], [5, 6], [6, 3], [6, 4], [6, 5], [6, 6], [7, 4], [7, 5], [7, 6], [7, 7], [8, 3], [8, 4], [8, 5], [8, 6], [9, 5], [9, 6], [10, 3], [10, 4], [10, 5], [10, 6]]) == 2\n assert candidate(n = 10,reservedSeats = [[2, 5], [3, 4], [3, 5], [3, 6], [4, 3], [4, 4], [4, 5], [4, 6], [5, 5], [5, 6], [6, 7], [6, 8], [7, 3], [7, 4], [8, 5], [8, 6], [9, 7], [9, 8]]) == 8\n assert candidate(n = 20,reservedSeats = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 5], [2, 6], [3, 3], [3, 4], [4, 7], [4, 8], [5, 2], [5, 3], [6, 8], [6, 9], [7, 1], [7, 2], [8, 5], [8, 6], [9, 4], [9, 5], [10, 9], [10, 10], [11, 1], [11, 10], [12, 2], [12, 9], [13, 3], [13, 8], [14, 4], [14, 7], [15, 5], [15, 6], [16, 2], [16, 3], [17, 8], [17, 9], [18, 4], [18, 5], [19, 6], [19, 7], [20, 1], [20, 10]]) == 17\n assert candidate(n = 20,reservedSeats = [[1, 2], [1, 9], [2, 5], [2, 6], [3, 3], [3, 4], [3, 7], [3, 8], [4, 2], [4, 9], [5, 3], [5, 8], [6, 5], [6, 6], [7, 2], [7, 9], [8, 3], [8, 8], [9, 4], [9, 7], [10, 2], [10, 9], [11, 5], [11, 6], [12, 3], [12, 8], [13, 2], [13, 9], [14, 3], [14, 8], [15, 5], [15, 6], [16, 2], [16, 9], [17, 3], [17, 8], [18, 5], [18, 6], [19, 2], [19, 9], [20, 3], [20, 8]]) == 13\n assert candidate(n = 10,reservedSeats = [[1, 1], [1, 10], [2, 2], [2, 9], [3, 3], [3, 8], [4, 4], [4, 7], [5, 5], [5, 6], [6, 1], [6, 10], [7, 2], [7, 9], [8, 3], [8, 8], [9, 4], [9, 7], [10, 5], [10, 6]]) == 8\n assert candidate(n = 15,reservedSeats = [[2, 2], [2, 3], [2, 8], [2, 9], [3, 4], [3, 5], [3, 6], [3, 7], [4, 1], [4, 10], [5, 3], [5, 4], [5, 7], [5, 8], [6, 1], [6, 10], [7, 2], [7, 3], [7, 8], [7, 9], [8, 2], [8, 3], [8, 8], [8, 9], [9, 1], [9, 10], [10, 4], [10, 5], [10, 6], [10, 7], [11, 2], [11, 3], [11, 8], [11, 9], [12, 4], [12, 5], [12, 6], [12, 7], [13, 1], [13, 10], [14, 2], [14, 3], [14, 8], [14, 9], [15, 4], [15, 5], [15, 6], [15, 7]]) == 15\n assert candidate(n = 10,reservedSeats = []) == 20\n assert candidate(n = 15,reservedSeats = [[1, 2], [1, 3], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 1], [5, 10], [6, 3], [6, 4], [6, 7], [6, 8], [7, 2], [7, 3], [7, 8], [7, 9], [8, 5], [8, 6], [9, 4], [9, 5], [9, 6], [9, 7], [10, 2], [10, 3], [11, 8], [11, 9], [12, 5], [12, 6], [13, 3], [13, 4], [14, 7], [14, 8], [15, 1], [15, 10]]) == 11\n assert candidate(n = 7,reservedSeats = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [2, 10], [3, 1], [3, 10], [4, 1], [4, 10], [5, 1], [5, 10], [6, 1], [6, 10], [7, 1], [7, 10]]) == 12\n assert candidate(n = 8,reservedSeats = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 2], [2, 3], [2, 4], [2, 5], [3, 2], [3, 3], [3, 4], [3, 5], [4, 2], [4, 3], [4, 4], [4, 5], [5, 2], [5, 3], [5, 4], [5, 5], [6, 2], [6, 3], [6, 4], [6, 5], [7, 2], [7, 3], [7, 4], [7, 5], [8, 2], [8, 3], [8, 4], [8, 5]]) == 8\n assert candidate(n = 10,reservedSeats = [[2, 2], [2, 3], [2, 8], [2, 9], [3, 4], [3, 5], [3, 6], [3, 7], [4, 1], [4, 10], [5, 5], [5, 6], [6, 3], [6, 4], [6, 7], [6, 8], [7, 2], [7, 9], [8, 1], [8, 10], [9, 3], [9, 4], [9, 7], [9, 8], [10, 2], [10, 3], [10, 8], [10, 9]]) == 9\n assert candidate(n = 15,reservedSeats = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [11, 2], [12, 3], [13, 4], [14, 5], [15, 6]]) == 17\n assert candidate(n = 10,reservedSeats = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [2, 4], [2, 5], [2, 6], [2, 7], [3, 2], [3, 3], [3, 8], [3, 9], [4, 1], [4, 10], [5, 5], [5, 6], [6, 3], [6, 4], [6, 7], [6, 8], [7, 2], [7, 9], [8, 1], [8, 10], [9, 3], [9, 4], [9, 7], [9, 8], [10, 2], [10, 3], [10, 8], [10, 9]]) == 7\n assert candidate(n = 30,reservedSeats = [[2, 2], [2, 3], [2, 4], [2, 5], [3, 6], [3, 7], [3, 8], [3, 9], [4, 2], [4, 3], [4, 4], [4, 5], [5, 6], [5, 7], [5, 8], [5, 9], [6, 2], [6, 3], [6, 4], [6, 5], [7, 6], [7, 7], [7, 8], [7, 9], [8, 2], [8, 3], [8, 4], [8, 5], [9, 6], [9, 7], [9, 8], [9, 9], [10, 2], [10, 3], [10, 4], [10, 5]]) == 51\n assert candidate(n = 100,reservedSeats = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [50, 2], [50, 3], [50, 4], [50, 5], [50, 6], [50, 7], [50, 8], [50, 9], [50, 10], [75, 2], [75, 3], [75, 4], [75, 5], [75, 6], [75, 7], [75, 8], [75, 9], [75, 10], [99, 2], [99, 3], [99, 4], [99, 5], [99, 6], [99, 7], [99, 8], [99, 9], [99, 10]]) == 192\n assert candidate(n = 3,reservedSeats = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [2, 4], [2, 5], [2, 6], [2, 7], [3, 2], [3, 3], [3, 8], [3, 9]]) == 1\n assert candidate(n = 7,reservedSeats = [[1, 4], [1, 5], [1, 6], [1, 7], [2, 2], [2, 3], [2, 8], [2, 9], [3, 4], [3, 5], [3, 6], [3, 7], [4, 3], [4, 4], [4, 7], [4, 8], [5, 2], [5, 3], [5, 8], [5, 9], [6, 4], [6, 5], [6, 6], [6, 7], [7, 2], [7, 3], [7, 4], [7, 5]]) == 3\n assert candidate(n = 25,reservedSeats = [[10, 2], [10, 3], [11, 8], [11, 9], [12, 4], [12, 5], [13, 6], [13, 7], [14, 2], [14, 3], [15, 8], [15, 9], [16, 4], [16, 5], [17, 6], [17, 7], [18, 2], [18, 3], [19, 8], [19, 9], [20, 4], [20, 5], [21, 6], [21, 7], [22, 2], [22, 3], [23, 8], [23, 9], [24, 4], [24, 5], [25, 6], [25, 7], [1, 2], [1, 3], [2, 8], [2, 9], [3, 4], [3, 5], [4, 6], [4, 7], [5, 2], [5, 3], [6, 8], [6, 9], [7, 4], [7, 5], [8, 6], [8, 7], [9, 2], [9, 3]]) == 25\n assert candidate(n = 12,reservedSeats = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 2], [2, 3], [3, 4], [3, 5], [4, 7], [4, 8], [5, 2], [5, 3], [6, 8], [6, 9], [7, 1], [7, 2], [8, 5], [8, 6], [9, 4], [9, 5], [10, 9], [10, 10], [11, 1], [11, 10], [12, 2], [12, 9]]) == 11\n assert candidate(n = 6,reservedSeats = [[1, 2], [1, 3], [2, 5], [2, 6], [2, 7], [2, 8], [3, 3], [3, 4], [3, 5], [3, 6], [4, 4], [4, 5], [4, 6], [4, 7], [5, 2], [5, 3], [5, 8], [5, 9], [6, 5], [6, 6], [6, 7], [6, 8]]) == 2\n assert candidate(n = 1000,reservedSeats = [[1, 2], [1, 3], [2, 2], [2, 3], [3, 2], [3, 3], [4, 2], [4, 3], [5, 2], [5, 3], [6, 2], [6, 3], [7, 2], [7, 3], [8, 2], [8, 3], [9, 2], [9, 3], [10, 2], [10, 3]]) == 1990\n assert candidate(n = 10,reservedSeats = [[2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 2], [4, 3], [4, 8], [4, 9], [5, 3], [5, 4], [5, 7], [5, 8], [6, 1], [6, 10], [7, 5], [7, 6], [8, 4], [8, 5], [8, 6], [8, 7], [9, 2], [9, 3], [9, 8], [9, 9], [10, 4], [10, 5], [10, 6], [10, 7]]) == 6\n assert candidate(n = 100,reservedSeats = [[1, 1], [1, 10], [10, 1], [10, 10], [20, 1], [20, 10], [30, 1], [30, 10], [40, 1], [40, 10], [50, 1], [50, 10], [60, 1], [60, 10], [70, 1], [70, 10], [80, 1], [80, 10], [90, 1], [90, 10], [100, 1], [100, 10]]) == 200\n assert candidate(n = 50,reservedSeats = [[10, 2], [10, 3], [10, 8], [10, 9], [20, 4], [20, 5], [20, 6], [20, 7], [30, 1], [30, 10], [40, 2], [40, 3], [40, 8], [40, 9], [50, 2], [50, 3], [50, 8], [50, 9]]) == 95\n assert candidate(n = 100,reservedSeats = [[50, 4], [50, 5], [50, 6], [50, 7], [51, 2], [51, 3], [51, 8], [51, 9], [52, 4], [52, 5], [52, 6], [52, 7], [53, 2], [53, 3], [53, 8], [53, 9], [54, 4], [54, 5], [54, 6], [54, 7], [55, 2], [55, 3], [55, 8], [55, 9], [56, 4], [56, 5], [56, 6], [56, 7], [57, 2], [57, 3], [57, 8], [57, 9], [58, 4], [58, 5], [58, 6], [58, 7]]) == 186\n assert candidate(n = 10,reservedSeats = [[1, 2], [1, 3], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 1], [5, 10], [6, 3], [6, 4], [6, 7], [6, 8], [7, 2], [7, 3], [7, 8], [7, 9], [8, 5], [8, 6], [9, 4], [9, 5], [9, 6], [9, 7], [10, 2], [10, 3], [10, 8], [10, 9]]) == 6\n assert candidate(n = 15,reservedSeats = [[5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [6, 2], [6, 3], [6, 8], [6, 9], [7, 4], [7, 5], [7, 6], [7, 7], [8, 3], [8, 4], [8, 5], [8, 6], [9, 2], [9, 3], [9, 8], [9, 9]]) == 22\n assert candidate(n = 10,reservedSeats = [[2, 2], [2, 3], [2, 8], [2, 9], [3, 4], [3, 5], [3, 6], [3, 7], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10]]) == 15\n assert candidate(n = 100,reservedSeats = [[10, 2], [10, 3], [10, 4], [10, 5], [20, 4], [20, 5], [30, 6], [30, 7], [40, 8], [40, 9], [50, 2], [50, 3], [60, 4], [60, 5], [70, 6], [70, 7], [80, 8], [80, 9], [90, 2], [90, 3]]) == 191\n assert candidate(n = 3,reservedSeats = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10]]) == 0\n assert candidate(n = 20,reservedSeats = [[5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]]) == 36\n assert candidate(n = 10,reservedSeats = [[2, 2], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [3, 6], [3, 7], [4, 6], [4, 7], [4, 8], [4, 9], [5, 2], [5, 3], [5, 8], [5, 9], [6, 4], [6, 5], [6, 6], [6, 7], [7, 2], [7, 3], [7, 4], [7, 5], [8, 6], [8, 7], [8, 8], [8, 9], [9, 2], [9, 3], [9, 8], [9, 9], [10, 4], [10, 5], [10, 6], [10, 7]]) == 8\n assert candidate(n = 5,reservedSeats = [[1, 5], [1, 6], [2, 4], [2, 5], [3, 7], [3, 8], [4, 3], [4, 4], [5, 9], [5, 10]]) == 4\n assert candidate(n = 100,reservedSeats = [[10, 3], [10, 4], [10, 5], [10, 6], [20, 2], [20, 3], [20, 8], [20, 9], [30, 4], [30, 5], [30, 6], [30, 7], [40, 1], [40, 2], [40, 3], [40, 4], [40, 5], [40, 6], [40, 7], [40, 8], [40, 9], [40, 10], [50, 4], [50, 5], [50, 6], [50, 7], [60, 2], [60, 3], [60, 8], [60, 9], [70, 4], [70, 5], [70, 6], [70, 7], [80, 1], [80, 2], [80, 3], [80, 4], [80, 5], [80, 6], [80, 7], [80, 8], [80, 9], [80, 10], [90, 3], [90, 4], [90, 5], [90, 6], [100, 2], [100, 3], [100, 8], [100, 9]]) == 183\n assert candidate(n = 25,reservedSeats = [[2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [5, 5], [5, 6], [6, 3], [6, 4], [6, 5], [6, 6], [7, 4], [7, 5], [7, 6], [7, 7], [8, 3], [8, 4], [8, 5], [8, 6], [9, 5], [9, 6], [10, 3], [10, 4], [10, 5], [10, 6], [11, 5], [11, 6], [12, 3], [12, 4], [12, 5], [12, 6], [13, 4], [13, 5], [13, 6], [13, 7], [14, 3], [14, 4], [14, 5], [14, 6], [15, 5], [15, 6], [16, 3], [16, 4], [16, 5], [16, 6], [17, 4], [17, 5], [17, 6], [17, 7], [18, 3], [18, 4], [18, 5], [18, 6], [19, 5], [19, 6], [20, 3], [20, 4], [20, 5], [20, 6], [21, 5], [21, 6], [22, 3], [22, 4], [22, 5], [22, 6], [23, 4], [23, 5], [23, 6], [23, 7], [24, 3], [24, 4], [24, 5], [24, 6], [25, 5], [25, 6]]) == 2\n assert candidate(n = 1000,reservedSeats = [[100, 2], [100, 3], [100, 4], [100, 5], [100, 6], [100, 7], [100, 8], [200, 2], [200, 3], [200, 4], [200, 5], [200, 6], [200, 7], [200, 8], [500, 2], [500, 3], [500, 4], [500, 5], [500, 6], [500, 7], [500, 8], [500, 9], [500, 10], [750, 2], [750, 3], [750, 4], [750, 5], [750, 6], [750, 7], [750, 8], [750, 9], [750, 10], [900, 2], [900, 3], [900, 4], [900, 5], [900, 6], [900, 7], [900, 8], [900, 9], [900, 10], [999, 2], [999, 3], [999, 4], [999, 5], [999, 6], [999, 7], [999, 8], [999, 9], [999, 10]]) == 1988\n assert candidate(n = 10,reservedSeats = [[2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 2], [4, 3], [4, 8], [4, 9]]) == 15\n assert candidate(n = 15,reservedSeats = [[5, 3], [5, 4], [5, 5], [5, 6], [6, 2], [6, 3], [6, 8], [6, 9], [7, 2], [7, 3], [7, 4], [7, 5], [8, 6], [8, 7], [8, 8], [8, 9]]) == 25\n assert candidate(n = 20,reservedSeats = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 1], [6, 2], [6, 3], [7, 4], [7, 5], [8, 6], [8, 7], [9, 8], [9, 9], [10, 10], [10, 1]]) == 32\n assert candidate(n = 5,reservedSeats = [[1, 2], [1, 3], [1, 8], [1, 9], [2, 4], [2, 5], [2, 6], [2, 7], [3, 2], [3, 3], [3, 8], [3, 9], [4, 1], [4, 10], [5, 5], [5, 6]]) == 4\n assert candidate(n = 5,reservedSeats = [[1, 1], [1, 10], [2, 2], [2, 3], [2, 8], [2, 9], [3, 4], [3, 5], [3, 6], [3, 7], [4, 5], [4, 6], [4, 7], [4, 8], [5, 5], [5, 6], [5, 7], [5, 8]]) == 3\n assert candidate(n = 5,reservedSeats = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 4], [2, 5], [2, 6], [2, 7], [3, 6], [3, 7], [3, 8], [3, 9], [4, 8], [4, 9], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]]) == 3\n assert candidate(n = 20,reservedSeats = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 2], [5, 3], [6, 4], [6, 5], [7, 6], [7, 7], [8, 8], [8, 9], [9, 2], [9, 3], [10, 4], [10, 5]]) == 30\n assert candidate(n = 15,reservedSeats = [[1, 2], [1, 3], [1, 8], [1, 9], [2, 4], [2, 5], [2, 6], [2, 7], [3, 2], [3, 3], [3, 8], [3, 9], [4, 1], [4, 10], [5, 2], [5, 3], [5, 8], [5, 9], [6, 4], [6, 5], [6, 6], [6, 7], [7, 2], [7, 3], [7, 8], [7, 9], [8, 1], [8, 10], [9, 2], [9, 3], [9, 8], [9, 9], [10, 4], [10, 5], [10, 6], [10, 7], [11, 2], [11, 3], [11, 8], [11, 9], [12, 1], [12, 10], [13, 2], [13, 3], [13, 8], [13, 9], [14, 4], [14, 5], [14, 6], [14, 7], [15, 2], [15, 3], [15, 8], [15, 9]]) == 14\n assert candidate(n = 20,reservedSeats = [[1, 2], [1, 3], [2, 8], [2, 9], [3, 4], [3, 5], [4, 6], [4, 7], [5, 2], [5, 3], [5, 8], [5, 9], [6, 2], [6, 3], [6, 4], [6, 5], [7, 6], [7, 7], [7, 8], [7, 9], [8, 2], [8, 3], [8, 8], [8, 9], [9, 4], [9, 5], [10, 6], [10, 7], [11, 2], [11, 3], [12, 8], [12, 9], [13, 4], [13, 5], [14, 6], [14, 7], [15, 2], [15, 3], [16, 8], [16, 9], [17, 4], [17, 5], [18, 6], [18, 7], [19, 2], [19, 3], [20, 8], [20, 9]]) == 20\n assert candidate(n = 10,reservedSeats = [[2, 2], [2, 3], [2, 8], [3, 6], [4, 1], [4, 10], [5, 5], [5, 6], [6, 3], [6, 4], [6, 9], [7, 7], [7, 8], [8, 2], [8, 3], [9, 8], [9, 9], [10, 10]]) == 11\n assert candidate(n = 15,reservedSeats = [[2, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 2], [6, 3], [7, 4], [7, 5], [8, 6], [8, 7], [9, 8], [9, 9], [10, 10], [11, 1], [11, 2], [12, 3], [12, 4], [13, 5], [13, 6], [14, 7], [14, 8], [15, 9]]) == 15\n assert candidate(n = 10,reservedSeats = [[2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [4, 3], [4, 4], [4, 5], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [7, 8], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8]]) == 3\n assert candidate(n = 50,reservedSeats = [[10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [20, 2], [20, 3], [20, 4], [20, 5], [20, 6], [20, 7], [20, 8], [25, 5], [25, 6], [25, 7], [25, 8]]) == 94\n assert candidate(n = 20,reservedSeats = [[1, 5], [2, 4], [3, 6], [4, 7], [5, 8], [6, 9], [7, 2], [8, 3], [9, 4], [10, 5], [11, 6], [12, 7], [13, 8], [14, 9], [15, 2], [16, 3], [17, 4], [18, 5], [19, 6], [20, 7]]) == 20\n assert candidate(n = 20,reservedSeats = [[5, 2], [5, 3], [5, 8], [5, 9], [10, 4], [10, 5], [10, 6], [10, 7], [15, 1], [15, 10], [20, 2], [20, 3], [20, 8], [20, 9]]) == 36\n assert candidate(n = 50,reservedSeats = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [10, 2], [10, 3], [10, 8], [10, 9], [15, 1], [15, 2], [15, 3], [15, 4], [15, 5], [15, 6], [15, 7], [15, 8], [15, 9], [15, 10], [20, 1], [20, 2], [20, 3], [20, 4], [20, 5], [20, 6], [20, 7], [20, 8], [20, 9], [20, 10], [25, 1], [25, 2], [25, 3], [25, 4], [25, 5], [25, 6], [25, 7], [25, 8], [25, 9], [25, 10], [30, 1], [30, 2], [30, 3], [30, 4], [30, 5], [30, 6], [30, 7], [30, 8], [30, 9], [30, 10], [35, 1], [35, 2], [35, 3], [35, 4], [35, 5], [35, 6], [35, 7], [35, 8], [35, 9], [35, 10], [40, 1], [40, 2], [40, 3], [40, 4], [40, 5], [40, 6], [40, 7], [40, 8], [40, 9], [40, 10], [45, 1], [45, 2], [45, 3], [45, 4], [45, 5], [45, 6], [45, 7], [45, 8], [45, 9], [45, 10]]) == 83\n"}, "metadata": {"canonical_parameter_names": ["n", "reservedSeats"], "leetcode_dataset_entry_point": "Solution().maxNumberOfFamilies", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxNumberOfFamilies(int n, vector>& reservedSeats) {", "container": "Solution", "callable": "maxNumberOfFamilies", "parameters": [{"name": "n", "type": "int"}, {"name": "reservedSeats", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1387, "task_id": "sort-integers-by-the-power-value", "difficulty": "Medium", "problem_description": "The power of an integer x is defined as the number of steps needed to transform x into 1 using the following steps:\n\nif x is even then x = x / 2\nif x is odd then x = 3 * x + 1\n\nFor example, the power of x = 3 is 7 because 3 needs 7 steps to become 1 (3 --> 10 --> 5 --> 16 --> 8 --> 4 --> 2 --> 1).\nGiven three integers lo, hi and k. The task is to sort all integers in the interval [lo, hi] by the power value in ascending order, if two or more integers have the same power value sort them by ascending order.\nReturn the kth integer in the range [lo, hi] sorted by the power value.\nNotice that for any integer x (lo <= x <= hi) it is guaranteed that x will transform into 1 using these steps and that the power of x is will fit in a 32-bit signed integer.\n \nExample 1:\n\nInput: lo = 12, hi = 15, k = 2\nOutput: 13\nExplanation: The power of 12 is 9 (12 --> 6 --> 3 --> 10 --> 5 --> 16 --> 8 --> 4 --> 2 --> 1)\nThe power of 13 is 9\nThe power of 14 is 17\nThe power of 15 is 17\nThe interval sorted by the power value [12,13,14,15]. For k = 2 answer is the second element which is 13.\nNotice that 12 and 13 have the same power value and we sorted them in ascending order. Same for 14 and 15.\n\nExample 2:\n\nInput: lo = 7, hi = 11, k = 4\nOutput: 7\nExplanation: The power array corresponding to the interval [7, 8, 9, 10, 11] is [16, 3, 19, 6, 14].\nThe interval sorted by power is [8, 10, 11, 7, 9].\nThe fourth number in the sorted array is 7.\n\n \nConstraints:\n\n1 <= lo <= hi <= 1000\n1 <= k <= hi - lo + 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(lo = 1,hi = 10,k = 1) == 1\n assert candidate(lo = 5,hi = 5,k = 1) == 5\n assert candidate(lo = 12,hi = 15,k = 2) == 13\n assert candidate(lo = 1,hi = 10,k = 5) == 5\n assert candidate(lo = 10,hi = 20,k = 5) == 13\n assert candidate(lo = 7,hi = 11,k = 4) == 7\n assert candidate(lo = 10,hi = 20,k = 3) == 20\n assert candidate(lo = 1,hi = 10,k = 3) == 4\n assert candidate(lo = 300,hi = 500,k = 100) == 370\n assert candidate(lo = 100,hi = 200,k = 1) == 128\n assert candidate(lo = 300,hi = 700,k = 150) == 613\n assert candidate(lo = 700,hi = 800,k = 18) == 794\n assert candidate(lo = 100,hi = 200,k = 75) == 183\n assert candidate(lo = 1,hi = 100,k = 100) == 97\n assert candidate(lo = 700,hi = 800,k = 50) == 766\n assert candidate(lo = 800,hi = 900,k = 5) == 802\n assert candidate(lo = 900,hi = 1000,k = 50) == 988\n assert candidate(lo = 600,hi = 800,k = 150) == 756\n assert candidate(lo = 800,hi = 1000,k = 50) == 912\n assert candidate(lo = 500,hi = 900,k = 100) == 692\n assert candidate(lo = 400,hi = 600,k = 100) == 489\n assert candidate(lo = 400,hi = 700,k = 120) == 418\n assert candidate(lo = 750,hi = 850,k = 50) == 758\n assert candidate(lo = 300,hi = 400,k = 100) == 313\n assert candidate(lo = 5,hi = 25,k = 1) == 8\n assert candidate(lo = 300,hi = 350,k = 30) == 338\n assert candidate(lo = 950,hi = 1000,k = 25) == 984\n assert candidate(lo = 200,hi = 300,k = 1) == 256\n assert candidate(lo = 800,hi = 900,k = 50) == 855\n assert candidate(lo = 800,hi = 900,k = 85) == 898\n assert candidate(lo = 500,hi = 600,k = 50) == 509\n assert candidate(lo = 250,hi = 450,k = 150) == 428\n assert candidate(lo = 150,hi = 450,k = 100) == 173\n assert candidate(lo = 300,hi = 350,k = 10) == 309\n assert candidate(lo = 300,hi = 600,k = 150) == 374\n assert candidate(lo = 100,hi = 200,k = 10) == 138\n assert candidate(lo = 400,hi = 600,k = 150) == 486\n assert candidate(lo = 900,hi = 1000,k = 10) == 965\n assert candidate(lo = 250,hi = 500,k = 100) == 312\n assert candidate(lo = 300,hi = 400,k = 50) == 367\n assert candidate(lo = 500,hi = 1000,k = 250) == 658\n assert candidate(lo = 300,hi = 350,k = 25) == 315\n assert candidate(lo = 200,hi = 300,k = 75) == 242\n assert candidate(lo = 50,hi = 150,k = 25) == 56\n assert candidate(lo = 250,hi = 350,k = 100) == 313\n assert candidate(lo = 50,hi = 75,k = 1) == 64\n assert candidate(lo = 500,hi = 1000,k = 150) == 943\n assert candidate(lo = 100,hi = 800,k = 200) == 547\n assert candidate(lo = 100,hi = 500,k = 30) == 150\n assert candidate(lo = 1,hi = 500,k = 250) == 465\n assert candidate(lo = 400,hi = 600,k = 120) == 590\n assert candidate(lo = 1,hi = 100,k = 10) == 3\n assert candidate(lo = 200,hi = 300,k = 50) == 271\n assert candidate(lo = 250,hi = 750,k = 250) == 741\n assert candidate(lo = 300,hi = 400,k = 5) == 384\n assert candidate(lo = 400,hi = 600,k = 200) == 487\n assert candidate(lo = 1,hi = 500,k = 150) == 163\n assert candidate(lo = 150,hi = 250,k = 20) == 234\n assert candidate(lo = 800,hi = 1000,k = 200) == 937\n assert candidate(lo = 1,hi = 1000,k = 1) == 1\n assert candidate(lo = 999,hi = 1000,k = 1) == 999\n assert candidate(lo = 1,hi = 1000,k = 500) == 606\n assert candidate(lo = 200,hi = 300,k = 100) == 231\n assert candidate(lo = 200,hi = 300,k = 10) == 280\n assert candidate(lo = 300,hi = 700,k = 250) == 699\n assert candidate(lo = 250,hi = 400,k = 100) == 263\n assert candidate(lo = 750,hi = 850,k = 30) == 813\n assert candidate(lo = 100,hi = 300,k = 150) == 242\n assert candidate(lo = 25,hi = 75,k = 25) == 36\n assert candidate(lo = 400,hi = 500,k = 100) == 487\n assert candidate(lo = 800,hi = 900,k = 80) == 874\n assert candidate(lo = 50,hi = 75,k = 25) == 55\n assert candidate(lo = 150,hi = 300,k = 75) == 210\n assert candidate(lo = 1,hi = 100,k = 1) == 1\n assert candidate(lo = 500,hi = 1000,k = 300) == 754\n assert candidate(lo = 600,hi = 700,k = 20) == 663\n assert candidate(lo = 800,hi = 900,k = 100) == 889\n assert candidate(lo = 200,hi = 400,k = 150) == 243\n assert candidate(lo = 100,hi = 200,k = 100) == 129\n assert candidate(lo = 100,hi = 200,k = 50) == 114\n assert candidate(lo = 800,hi = 900,k = 25) == 882\n assert candidate(lo = 1,hi = 100,k = 50) == 9\n assert candidate(lo = 500,hi = 600,k = 25) == 538\n assert candidate(lo = 50,hi = 150,k = 50) == 66\n assert candidate(lo = 1000,hi = 1000,k = 1) == 1000\n assert candidate(lo = 1,hi = 100,k = 75) == 67\n assert candidate(lo = 900,hi = 999,k = 15) == 985\n assert candidate(lo = 2,hi = 10,k = 5) == 10\n assert candidate(lo = 1,hi = 1000,k = 750) == 322\n assert candidate(lo = 600,hi = 900,k = 150) == 718\n assert candidate(lo = 50,hi = 100,k = 15) == 93\n assert candidate(lo = 1,hi = 1,k = 1) == 1\n assert candidate(lo = 600,hi = 800,k = 100) == 676\n"}, "metadata": {"canonical_parameter_names": ["lo", "hi", "k"], "leetcode_dataset_entry_point": "Solution().getKth", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int getKth(int lo, int hi, int k) {", "container": "Solution", "callable": "getKth", "parameters": [{"name": "lo", "type": "int"}, {"name": "hi", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1388, "task_id": "pizza-with-3n-slices", "difficulty": "Hard", "problem_description": "There is a pizza with 3n slices of varying size, you and your friends will take slices of pizza as follows:\n\nYou will pick any pizza slice.\nYour friend Alice will pick the next slice in the anti-clockwise direction of your pick.\nYour friend Bob will pick the next slice in the clockwise direction of your pick.\nRepeat until there are no more slices of pizzas.\n\nGiven an integer array slices that represent the sizes of the pizza slices in a clockwise direction, return the maximum possible sum of slice sizes that you can pick.\n \nExample 1:\n\n\nInput: slices = [1,2,3,4,5,6]\nOutput: 10\nExplanation: Pick pizza slice of size 4, Alice and Bob will pick slices with size 3 and 5 respectively. Then Pick slices with size 6, finally Alice and Bob will pick slice of size 2 and 1 respectively. Total = 4 + 6.\n\nExample 2:\n\n\nInput: slices = [8,9,8,6,1,1]\nOutput: 16\nExplanation: Pick pizza slice of size 8 in each turn. If you pick slice with size 9 your partners will pick slices of size 8.\n\n \nConstraints:\n\n3 * n == slices.length\n1 <= slices.length <= 500\n1 <= slices[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(slices = [9, 7, 7, 7, 6, 6]) == 16\n assert candidate(slices = [1000, 1000, 1000, 1000, 1000, 1000]) == 2000\n assert candidate(slices = [10, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(slices = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 21\n assert candidate(slices = [1, 2, 3, 4, 1, 2]) == 6\n assert candidate(slices = [8, 9, 8, 6, 1, 1]) == 16\n assert candidate(slices = [10, 1, 1, 1, 1, 10]) == 11\n assert candidate(slices = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 36\n assert candidate(slices = [7, 8, 9, 1, 2, 3, 4, 5, 6]) == 21\n assert candidate(slices = [7, 7, 7, 7, 7, 7, 7]) == 14\n assert candidate(slices = [1000, 1, 1000, 1, 1000, 1]) == 2000\n assert candidate(slices = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 20\n assert candidate(slices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(slices = [5, 7, 8, 6, 3, 4]) == 13\n assert candidate(slices = [1, 3, 1, 5, 2, 5, 1, 5, 6]) == 16\n assert candidate(slices = [1, 2, 3, 4, 5, 6]) == 10\n assert candidate(slices = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 15\n assert candidate(slices = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300]) == 2100\n assert candidate(slices = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120]) == 798\n assert candidate(slices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == 78\n assert candidate(slices = [1, 1000, 2, 1000, 3, 1000, 4, 1000, 5, 1000, 6, 1000]) == 4000\n assert candidate(slices = [5, 3, 9, 7, 1, 4, 8, 6, 2, 10, 12, 11]) == 38\n assert candidate(slices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(slices = [500, 1, 500, 2, 500, 3, 500, 4, 500, 5, 500, 6]) == 2000\n assert candidate(slices = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8]) == 280\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 55\n assert candidate(slices = [100, 200, 300, 400, 500, 600, 100, 200, 300, 400, 500, 600]) == 2000\n assert candidate(slices = [20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]) == 400\n assert candidate(slices = [800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, 800]) == 3200\n assert candidate(slices = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5, 95, 6]) == 394\n assert candidate(slices = [900, 100, 200, 300, 400, 500, 600, 700, 800, 100, 200, 300, 400, 500, 600, 700, 800, 900, 100, 200, 300, 400, 500, 600, 700]) == 5400\n assert candidate(slices = [10, 1, 15, 2, 20, 3, 25, 4, 30, 5, 35, 6]) == 110\n assert candidate(slices = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 55\n assert candidate(slices = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == 3600\n assert candidate(slices = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 144\n assert candidate(slices = [300, 200, 100, 50, 25, 12, 6, 3, 1, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1]) == 3450\n assert candidate(slices = [15, 1, 25, 3, 20, 4, 2, 30, 5, 6, 7, 8]) == 90\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 560\n assert candidate(slices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 35\n assert candidate(slices = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995]) == 3994\n assert candidate(slices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12]) == 36\n assert candidate(slices = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 12\n assert candidate(slices = [1200, 1100, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 3600\n assert candidate(slices = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150]) == 2278\n assert candidate(slices = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 550\n assert candidate(slices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 144\n assert candidate(slices = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 3600\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125]) == 3485\n assert candidate(slices = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 2000\n assert candidate(slices = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 30\n assert candidate(slices = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 60\n assert candidate(slices = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 360\n assert candidate(slices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12]) == 36\n assert candidate(slices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 12, 11]) == 35\n assert candidate(slices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(slices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 23\n assert candidate(slices = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 21000\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 144\n assert candidate(slices = [300, 1, 100, 2, 200, 3, 150, 4, 250, 5, 350, 6]) == 1100\n assert candidate(slices = [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 64\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 210\n assert candidate(slices = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 5000\n assert candidate(slices = [12, 3, 11, 4, 2, 5, 6, 7, 8, 9, 10, 1]) == 41\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 2244\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150]) == 5050\n assert candidate(slices = [5, 6, 3, 7, 4, 8, 5, 6, 3, 7, 4, 8, 5, 6, 3, 7, 4, 8, 5, 6, 3, 7, 4, 8, 5, 6, 3, 7, 4, 8]) == 75\n assert candidate(slices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(slices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, 11]) == 36\n assert candidate(slices = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 210\n assert candidate(slices = [999, 1, 999, 2, 999, 3, 999, 4, 999, 5, 999, 6, 999, 7, 999, 8, 999, 9, 999, 10, 999, 11, 999, 12, 999, 13, 999, 14, 999, 15]) == 9990\n assert candidate(slices = [9, 2, 8, 1, 5, 6, 7, 3, 4, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 60\n assert candidate(slices = [999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1]) == 3996\n assert candidate(slices = [500, 1, 500, 2, 500, 3, 500, 4, 500, 5, 500, 6]) == 2000\n assert candidate(slices = [200, 150, 100, 50, 100, 150, 200, 250, 300, 350, 400, 450]) == 1200\n assert candidate(slices = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 68\n assert candidate(slices = [5, 7, 4, 6, 10, 3, 8, 2, 9, 1, 11, 6]) == 38\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 560\n assert candidate(slices = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 1000\n assert candidate(slices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 76\n assert candidate(slices = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300]) == 2100\n assert candidate(slices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11, 10]) == 55\n assert candidate(slices = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15]) == 39\n assert candidate(slices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 97\n assert candidate(slices = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 36\n assert candidate(slices = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 180\n assert candidate(slices = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500]) == 5600\n assert candidate(slices = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 133\n assert candidate(slices = [10, 5, 1, 2, 8, 3, 9, 4, 7, 6, 11, 12]) == 38\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 55\n assert candidate(slices = [1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5]) == 50\n assert candidate(slices = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 210\n assert candidate(slices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 114\n assert candidate(slices = [500, 1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6]) == 3994\n assert candidate(slices = [1, 2, 3, 100, 4, 5, 6, 7, 8, 9, 10, 11]) == 127\n assert candidate(slices = [900, 100, 800, 200, 700, 300, 600, 400, 500, 500, 600, 400]) == 3000\n assert candidate(slices = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 28\n assert candidate(slices = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(slices = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 8\n assert candidate(slices = [200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230]) == 2210\n assert candidate(slices = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 560\n assert candidate(slices = [12, 3, 14, 5, 16, 7, 18, 9, 11, 2, 13, 4]) == 61\n assert candidate(slices = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 10000\n assert candidate(slices = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == 3600\n assert candidate(slices = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 90\n assert candidate(slices = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5, 600, 6, 700, 7, 800, 8, 900, 9, 1000, 10, 1100, 11, 1200, 12]) == 6800\n assert candidate(slices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 210\n assert candidate(slices = [300, 200, 100, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == 3600\n assert candidate(slices = [10, 1, 1, 1, 1, 10, 1, 1, 1, 1, 10, 1]) == 31\n assert candidate(slices = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(slices = [500, 300, 200, 400, 100, 600, 700, 800, 900, 100, 100, 100]) == 2500\n assert candidate(slices = [2, 5, 3, 4, 8, 1, 9, 7, 6, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 210\n"}, "metadata": {"canonical_parameter_names": ["slices"], "leetcode_dataset_entry_point": "Solution().maxSizeSlices", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxSizeSlices(vector& slices) {", "container": "Solution", "callable": "maxSizeSlices", "parameters": [{"name": "slices", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1389, "task_id": "create-target-array-in-the-given-order", "difficulty": "Easy", "problem_description": "Given two arrays of integers nums and index. Your task is to create target array under the following rules:\n\nInitially target array is empty.\nFrom left to right read nums[i] and index[i], insert at index index[i] the value nums[i] in target array.\nRepeat the previous step until there are no elements to read in nums and index.\n\nReturn the target array.\nIt is guaranteed that the insertion operations will be valid.\n \nExample 1:\n\nInput: nums = [0,1,2,3,4], index = [0,1,2,2,1]\nOutput: [0,4,1,3,2]\nExplanation:\nnums index target\n0 0 [0]\n1 1 [0,1]\n2 2 [0,1,2]\n3 2 [0,1,3,2]\n4 1 [0,4,1,3,2]\n\nExample 2:\n\nInput: nums = [1,2,3,4,0], index = [0,1,2,3,0]\nOutput: [0,1,2,3,4]\nExplanation:\nnums index target\n1 0 [1]\n2 1 [1,2]\n3 2 [1,2,3]\n4 3 [1,2,3,4]\n0 0 [0,1,2,3,4]\n\nExample 3:\n\nInput: nums = [1], index = [0]\nOutput: [1]\n\n \nConstraints:\n\n1 <= nums.length, index.length <= 100\nnums.length == index.length\n0 <= nums[i] <= 100\n0 <= index[i] <= i\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1],index = [0]) == [1]\n assert candidate(nums = [10, 9, 8, 7, 6],index = [0, 1, 1, 1, 1]) == [10, 6, 7, 8, 9]\n assert candidate(nums = [0, 1, 2, 3, 4],index = [0, 1, 2, 2, 1]) == [0, 4, 1, 3, 2]\n assert candidate(nums = [5, 5, 5, 5],index = [0, 1, 2, 0]) == [5, 5, 5, 5]\n assert candidate(nums = [5, 4, 3, 2, 1],index = [4, 3, 2, 1, 0]) == [1, 5, 2, 4, 3]\n assert candidate(nums = [5, 5, 5, 5],index = [0, 1, 2, 3]) == [5, 5, 5, 5]\n assert candidate(nums = [9, 8, 7, 6, 5],index = [0, 0, 0, 0, 0]) == [5, 6, 7, 8, 9]\n assert candidate(nums = [1, 3, 2],index = [0, 0, 1]) == [3, 2, 1]\n assert candidate(nums = [0, 0, 0, 0],index = [0, 1, 2, 3]) == [0, 0, 0, 0]\n assert candidate(nums = [9, 8, 7, 6, 5],index = [0, 1, 2, 3, 4]) == [9, 8, 7, 6, 5]\n assert candidate(nums = [1, 3, 2],index = [0, 1, 1]) == [1, 2, 3]\n assert candidate(nums = [1, 2, 3, 4, 0],index = [0, 1, 2, 3, 0]) == [0, 1, 2, 3, 4]\n assert candidate(nums = [9, 8, 7, 6],index = [0, 0, 1, 2]) == [8, 7, 6, 9]\n assert candidate(nums = [10, 9, 8, 7, 6],index = [4, 3, 2, 1, 0]) == [6, 10, 7, 9, 8]\n assert candidate(nums = [9, 8, 7, 6],index = [0, 0, 0, 0]) == [6, 7, 8, 9]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],index = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],index = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [5, 5, 3, 2, 6, 5, 9, 4, 1, 3, 1]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],index = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]\n assert candidate(nums = [10, 1, 2, 3, 4, 5],index = [0, 3, 1, 1, 2, 4]) == [10, 3, 4, 2, 5, 1]\n assert candidate(nums = [2, 4, 6, 8, 10],index = [0, 2, 4, 1, 3]) == [2, 8, 4, 10, 6]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],index = [0, 1, 2, 3, 4, 5, 6]) == [7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [5, 10, 15, 20, 25, 30],index = [0, 1, 2, 2, 2, 2]) == [5, 10, 30, 25, 20, 15]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],index = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [42, 31, 20, 10, 0],index = [4, 3, 2, 1, 0]) == [0, 42, 10, 31, 20]\n assert candidate(nums = [5, 3, 8, 6, 2],index = [2, 4, 0, 1, 3]) == [8, 6, 5, 2, 3]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],index = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],index = [8, 7, 6, 5, 4, 3, 2, 1, 0]) == [9, 1, 8, 2, 7, 3, 6, 4, 5]\n assert candidate(nums = [3, 1, 2],index = [0, 1, 1]) == [3, 2, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],index = [0, 1, 0, 3, 2, 3, 4, 5, 6, 7]) == [3, 1, 5, 6, 7, 8, 9, 10, 2, 4]\n assert candidate(nums = [5, 3, 7, 1, 9],index = [0, 1, 1, 2, 3]) == [5, 7, 1, 9, 3]\n assert candidate(nums = [1, 3, 2, 5, 4],index = [0, 1, 1, 2, 3]) == [1, 2, 5, 4, 3]\n assert candidate(nums = [100, 99, 98, 97, 96, 95],index = [0, 0, 0, 0, 0, 0]) == [95, 96, 97, 98, 99, 100]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],index = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [5, 5, 5, 5, 5],index = [4, 3, 2, 1, 0]) == [5, 5, 5, 5, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],index = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == [2, 4, 6, 8, 10, 9, 7, 5, 3, 1]\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1],index = [0, 1, 2, 3, 4, 5, 6, 7]) == [5, 3, 8, 6, 2, 7, 4, 1]\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13],index = [0, 1, 2, 0, 1, 2, 3]) == [10, 11, 12, 13, 7, 8, 9]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],index = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [100, 10, 90, 20, 80, 30, 70, 40, 60, 50]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],index = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [10, 20, 30, 40, 50, 60],index = [5, 4, 3, 2, 1, 0]) == [60, 10, 50, 20, 40, 30]\n assert candidate(nums = [5, 3, 8, 9, 2],index = [0, 1, 2, 3, 4]) == [5, 3, 8, 9, 2]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],index = [0, 0, 1, 2, 1, 0, 3, 4, 5, 6]) == [6, 2, 5, 7, 8, 9, 10, 3, 4, 1]\n assert candidate(nums = [3, 2, 1],index = [1, 1, 1]) == [3, 1, 2]\n assert candidate(nums = [10, 20, 30, 40, 50],index = [0, 2, 1, 2, 4]) == [10, 30, 40, 20, 50]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1],index = [0, 1, 0, 2, 1, 3, 0]) == [1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],index = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],index = [0, 0, 1, 2, 3, 4, 5, 6, 7, 8]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]\n assert candidate(nums = [50, 40, 30, 20, 10],index = [4, 3, 2, 1, 0]) == [10, 50, 20, 40, 30]\n assert candidate(nums = [1, 3, 5, 7, 9],index = [0, 0, 0, 0, 0]) == [9, 7, 5, 3, 1]\n assert candidate(nums = [2, 4, 6, 8, 10],index = [5, 4, 3, 2, 1]) == [2, 10, 4, 8, 6]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],index = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [10, 1, 9, 2, 8, 3, 7, 4, 6, 5]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13],index = [0, 2, 4, 6, 8, 10, 12]) == [1, 3, 5, 7, 9, 11, 13]\n assert candidate(nums = [100, 90, 80, 70, 60],index = [0, 1, 2, 3, 4]) == [100, 90, 80, 70, 60]\n assert candidate(nums = [1, 3, 5, 7, 9, 11],index = [0, 2, 4, 6, 8, 10]) == [1, 3, 5, 7, 9, 11]\n assert candidate(nums = [1, 3, 2, 5, 4, 8, 7, 6, 10, 9],index = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [9, 10, 6, 7, 8, 4, 5, 2, 3, 1]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],index = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],index = [0, 0, 1, 1, 0, 2, 3, 4, 5, 6, 7]) == [5, 1, 9, 2, 6, 5, 3, 5, 1, 4, 3]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],index = [0, 1, 2, 3, 4, 5, 6, 7, 8]) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],index = [0, 0, 0, 0, 0, 0, 0, 0, 0]) == [9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],index = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [9, 0, 8, 1, 7, 2, 6, 3, 5, 4]\n assert candidate(nums = [6, 6, 6, 6, 6],index = [0, 0, 1, 1, 2]) == [6, 6, 6, 6, 6]\n assert candidate(nums = [10, 20, 30, 40, 50],index = [4, 3, 2, 1, 0]) == [50, 10, 40, 20, 30]\n assert candidate(nums = [10, 20, 30, 40, 50],index = [0, 1, 0, 2, 3]) == [30, 10, 40, 50, 20]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],index = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [5, 15, 25, 35, 45],index = [0, 2, 1, 3, 4]) == [5, 25, 15, 35, 45]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],index = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]) == [1, 11, 3, 13, 5, 15, 7, 17, 9, 19]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],index = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5]) == [1, 3, 5, 7, 9, 10, 2, 4, 8, 6]\n assert candidate(nums = [9, 7, 5, 3, 1],index = [4, 3, 2, 1, 0]) == [1, 9, 3, 7, 5]\n assert candidate(nums = [1, 2, 3, 4, 5],index = [2, 2, 2, 2, 2]) == [1, 2, 5, 4, 3]\n assert candidate(nums = [10, 20, 30, 40, 50],index = [0, 2, 1, 4, 3]) == [10, 30, 20, 50, 40]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],index = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 4, 3, 2, 1],index = [0, 1, 2, 2, 2]) == [5, 4, 1, 2, 3]\n assert candidate(nums = [1, 2, 3, 4, 5],index = [2, 3, 4, 0, 1]) == [4, 5, 1, 2, 3]\n assert candidate(nums = [5, 3, 8, 1],index = [2, 2, 1, 0]) == [1, 5, 8, 3]\n assert candidate(nums = [7, 8, 9, 10, 11, 12],index = [1, 3, 3, 2, 0, 5]) == [11, 7, 8, 10, 9, 12]\n assert candidate(nums = [1, 2, 3, 4],index = [0, 0, 0, 0]) == [4, 3, 2, 1]\n assert candidate(nums = [7, 8, 9, 10, 11, 12],index = [0, 0, 1, 1, 2, 2]) == [8, 10, 12, 11, 9, 7]\n assert candidate(nums = [1, 2, 3, 4, 5],index = [4, 3, 2, 1, 0]) == [5, 1, 4, 2, 3]\n assert candidate(nums = [10, 20, 30, 40, 50],index = [0, 2, 1, 3, 1]) == [10, 50, 30, 20, 40]\n assert candidate(nums = [1, 2, 3, 4, 5, 6],index = [5, 4, 3, 2, 1, 0]) == [6, 1, 5, 2, 4, 3]\n assert candidate(nums = [1, 3, 2, 5, 4],index = [0, 0, 1, 1, 2]) == [3, 5, 4, 2, 1]\n assert candidate(nums = [4, 3, 2, 1, 0],index = [2, 2, 2, 2, 2]) == [4, 3, 0, 1, 2]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],index = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0]) == [19, 1, 3, 11, 5, 13, 7, 15, 9, 17]\n assert candidate(nums = [9, 8, 7, 6, 5],index = [4, 4, 4, 4, 4]) == [9, 8, 7, 6, 5]\n assert candidate(nums = [0, 1, 0, 1, 0],index = [0, 1, 2, 3, 4]) == [0, 1, 0, 1, 0]\n assert candidate(nums = [100, 99, 98, 97, 96, 95],index = [5, 4, 3, 2, 1, 0]) == [95, 100, 96, 99, 97, 98]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],index = [0, 5, 2, 3, 1, 4, 6, 7, 8, 9]) == [10, 50, 20, 30, 60, 40, 70, 80, 90, 100]\n assert candidate(nums = [1, 3, 2, 4, 5, 7, 6],index = [0, 1, 1, 3, 4, 5, 5]) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],index = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]\n assert candidate(nums = [1, 3, 5, 7, 9],index = [0, 0, 1, 2, 3]) == [3, 5, 7, 9, 1]\n assert candidate(nums = [10, 20, 30, 40, 50],index = [4, 3, 2, 1, 0]) == [50, 10, 40, 20, 30]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],index = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [10, 9, 8, 7, 6, 5],index = [0, 1, 1, 0, 3, 2]) == [7, 10, 5, 8, 6, 9]\n assert candidate(nums = [7, 8, 9],index = [1, 1, 1]) == [7, 9, 8]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],index = [0, 1, 0, 1, 2, 0, 3, 0, 4, 5, 6]) == [6, 9, 4, 1, 5, 3, 5, 2, 5, 3, 1]\n assert candidate(nums = [0, 1, 1, 1, 0],index = [0, 1, 2, 2, 0]) == [0, 0, 1, 1, 1]\n assert candidate(nums = [3, 2, 1],index = [2, 1, 0]) == [1, 3, 2]\n assert candidate(nums = [6, 5, 4, 3, 2, 1],index = [0, 0, 0, 0, 0, 0]) == [1, 2, 3, 4, 5, 6]\n assert candidate(nums = [100, 99, 98, 97, 96, 95],index = [0, 1, 0, 2, 1, 3]) == [98, 96, 100, 95, 97, 99]\n assert candidate(nums = [10, 20, 30, 40, 50],index = [0, 0, 0, 0, 4]) == [40, 30, 20, 10, 50]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],index = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6],index = [0, 2, 2, 1, 5, 3]) == [1, 4, 2, 6, 3, 5]\n assert candidate(nums = [0, 1, 0, 1, 0],index = [0, 1, 0, 1, 0]) == [0, 0, 1, 0, 1]\n assert candidate(nums = [5, 3, 1, 4, 2],index = [4, 1, 3, 0, 2]) == [4, 5, 2, 3, 1]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],index = [6, 5, 4, 3, 2, 1, 0]) == [1, 7, 2, 6, 3, 5, 4]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],index = [0, 1, 0, 2, 3, 4, 5, 6, 7, 8]) == [3, 1, 4, 5, 6, 7, 8, 9, 10, 2]\n assert candidate(nums = [1, 1, 1, 1, 1],index = [0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],index = [0, 0, 0, 0, 0, 0, 0]) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(nums = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4],index = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]) == [5, 0, 6, 1, 7, 2, 8, 3, 9, 4]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1],index = [0, 1, 2, 3, 4, 5, 6]) == [1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [33, 22, 11, 66, 55, 44],index = [0, 0, 0, 0, 0, 0]) == [44, 55, 66, 11, 22, 33]\n assert candidate(nums = [1, 1, 1, 1, 1],index = [0, 1, 0, 2, 1]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [2, 3, 1, 5, 4],index = [2, 3, 0, 4, 1]) == [1, 4, 2, 3, 5]\n assert candidate(nums = [1, 3, 5, 7, 9],index = [0, 1, 2, 0, 3]) == [7, 1, 3, 9, 5]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],index = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 9, 1, 8, 2, 7, 3, 6, 4, 5]\n"}, "metadata": {"canonical_parameter_names": ["nums", "index"], "leetcode_dataset_entry_point": "Solution().createTargetArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector createTargetArray(vector& nums, vector& index) {", "container": "Solution", "callable": "createTargetArray", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "index", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1390, "task_id": "four-divisors", "difficulty": "Medium", "problem_description": "Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors. If there is no such integer in the array, return 0.\n \nExample 1:\n\nInput: nums = [21,4,7]\nOutput: 32\nExplanation: \n21 has 4 divisors: 1, 3, 7, 21\n4 has 3 divisors: 1, 2, 4\n7 has 2 divisors: 1, 7\nThe answer is the sum of divisors of 21 only.\n\nExample 2:\n\nInput: nums = [21,21]\nOutput: 64\n\nExample 3:\n\nInput: nums = [1,2,3,4,5]\nOutput: 0\n\n \nConstraints:\n\n1 <= nums.length <= 104\n1 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [101, 103, 107, 109, 113]) == 0\n assert candidate(nums = [2310, 2320, 2330, 2340, 2350]) == 0\n assert candidate(nums = [30, 44, 25, 63]) == 0\n assert candidate(nums = [30, 100, 49]) == 0\n assert candidate(nums = [6, 8, 10, 12, 14]) == 69\n assert candidate(nums = [100, 121, 144, 169]) == 0\n assert candidate(nums = [11, 13, 17, 19, 23]) == 0\n assert candidate(nums = [15, 21, 28, 30, 35]) == 104\n assert candidate(nums = [105, 106, 107, 108, 109]) == 162\n assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [110, 111, 112, 113, 114]) == 152\n assert candidate(nums = [21, 21]) == 64\n assert candidate(nums = [15, 21, 25, 49, 77]) == 152\n assert candidate(nums = [6, 8, 10, 12]) == 45\n assert candidate(nums = [10, 15, 21, 28, 30]) == 74\n assert candidate(nums = [100, 101, 102, 103, 104]) == 0\n assert candidate(nums = [30, 49, 64, 81, 97]) == 0\n assert candidate(nums = [30, 49, 64, 81]) == 0\n assert candidate(nums = [10, 15, 21, 22]) == 110\n assert candidate(nums = [21, 4, 7]) == 32\n assert candidate(nums = [30, 40, 50, 60, 70]) == 0\n assert candidate(nums = [1001, 1009, 1013, 1019, 1021]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19]) == 0\n assert candidate(nums = [10, 15, 21, 22, 28]) == 110\n assert candidate(nums = [15, 28, 91]) == 136\n assert candidate(nums = [36, 49, 64, 81, 100]) == 0\n assert candidate(nums = [6, 8, 10, 12, 14]) == 69\n assert candidate(nums = [100, 101, 102, 103, 104]) == 0\n assert candidate(nums = [500, 525, 546, 567, 570, 588, 594, 616, 630, 646, 660, 672, 684]) == 0\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == 162\n assert candidate(nums = [144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484]) == 0\n assert candidate(nums = [231, 252, 273, 294, 315]) == 0\n assert candidate(nums = [901, 903, 917, 923, 925, 927, 931, 943, 945, 949, 957, 963, 965, 979, 987, 989, 993, 995, 999, 1001]) == 10908\n assert candidate(nums = [323, 333, 341, 351, 361]) == 744\n assert candidate(nums = [145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165]) == 1242\n assert candidate(nums = [9999, 10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009, 10010]) == 36664\n assert candidate(nums = [231, 275, 299, 322, 341, 361, 385, 407, 429, 451, 473, 495]) == 2208\n assert candidate(nums = [500, 505, 511, 513, 529, 539, 551, 561, 573, 583, 585, 595, 605, 621, 627, 637, 645, 651, 655, 667, 685]) == 5560\n assert candidate(nums = [220, 280, 300, 330, 350]) == 0\n assert candidate(nums = [882, 924, 966, 1008, 1050]) == 0\n assert candidate(nums = [2048, 2187, 2345, 2500, 2648, 2809, 3003, 3215, 3432, 3654, 3888]) == 3864\n assert candidate(nums = [100, 121, 143, 169, 181]) == 168\n assert candidate(nums = [5005, 5007, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087]) == 6680\n assert candidate(nums = [500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000]) == 0\n assert candidate(nums = [1000, 1001, 1002, 1003, 1005, 1006, 1007, 1009, 1011, 1013, 1015, 1017, 1019, 1021, 1023, 1025, 1027, 1029, 1031, 1033, 1035, 1037, 1039, 1041, 1043, 1045, 1047, 1049, 1051, 1053, 1055]) == 12524\n assert candidate(nums = [56, 84, 91, 112, 119, 126, 133]) == 416\n assert candidate(nums = [1100, 1120, 1122, 1134, 1140, 1155, 1166, 1176, 1183, 1197, 1209, 1225, 1232, 1242, 1254, 1260, 1275]) == 0\n assert candidate(nums = [1485, 1506, 1527, 1548, 1569]) == 4136\n assert candidate(nums = [100, 121, 144, 169, 196, 225]) == 0\n assert candidate(nums = [1275, 1296, 1317, 1338, 1359]) == 1760\n assert candidate(nums = [10001, 10003, 10007, 10009, 10037, 10039, 10061, 10067, 10079]) == 21652\n assert candidate(nums = [1330, 1333, 1343, 1353, 1369]) == 2848\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384]) == 0\n assert candidate(nums = [1105, 1111, 1122, 1147, 1159]) == 3680\n assert candidate(nums = [100000, 99999, 99997, 99989, 99971, 99959, 99949, 99929, 99907]) == 206104\n assert candidate(nums = [961, 1024, 1089, 1156, 1225, 1296, 1369, 1444, 1521, 1600]) == 0\n assert candidate(nums = [100, 121, 143, 169, 189]) == 168\n assert candidate(nums = [12, 18, 20, 24, 30, 36, 40, 42, 44, 45, 48, 50]) == 0\n assert candidate(nums = [435, 456, 477, 498, 519]) == 696\n assert candidate(nums = [540, 561, 582, 603, 624]) == 0\n assert candidate(nums = [11025, 11236, 11449, 11664, 11881, 12100, 12321, 12544, 12769, 12996]) == 0\n assert candidate(nums = [221, 231, 253, 273, 299]) == 876\n assert candidate(nums = [1380, 1401, 1422, 1443, 1464]) == 1872\n assert candidate(nums = [1820, 1833, 1849, 1859, 1877]) == 0\n assert candidate(nums = [713, 721, 741, 759, 779]) == 2440\n assert candidate(nums = [1170, 1191, 1212, 1233, 1254]) == 1592\n assert candidate(nums = [130, 156, 168, 182, 208, 224, 234]) == 0\n assert candidate(nums = [407, 413, 437, 459, 463]) == 1416\n assert candidate(nums = [29, 41, 53, 61, 67, 71, 73, 79, 83, 89, 97, 101]) == 0\n assert candidate(nums = [960, 981, 1002, 1023, 1044]) == 0\n assert candidate(nums = [1363, 1403, 1459, 1489, 1517]) == 4524\n assert candidate(nums = [496, 504, 512, 520, 528]) == 0\n assert candidate(nums = [245, 273, 294, 322, 338, 364, 378]) == 0\n assert candidate(nums = [729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739]) == 2712\n assert candidate(nums = [385, 405, 429, 441, 455, 462, 473, 483, 495]) == 528\n assert candidate(nums = [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 0\n assert candidate(nums = [1800, 1821, 1842, 1863, 1884]) == 2432\n assert candidate(nums = [100, 121, 144, 169, 196]) == 0\n assert candidate(nums = [1065, 1086, 1107, 1128, 1149]) == 1536\n assert candidate(nums = [1369, 1521, 1681, 1849, 2025, 2209, 2401, 2601, 2809, 3025, 3249]) == 0\n assert candidate(nums = [2115, 2136, 2157, 2178, 2199]) == 5816\n assert candidate(nums = [120, 180, 240, 300, 360]) == 0\n assert candidate(nums = [1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063]) == 0\n assert candidate(nums = [1111, 1189, 1247, 1271, 1309]) == 5148\n assert candidate(nums = [2002, 2014, 2021, 2035, 2047]) == 4272\n assert candidate(nums = [1610, 1619, 1643, 1657, 1679]) == 3504\n assert candidate(nums = [110, 132, 154, 176, 198]) == 0\n assert candidate(nums = [913, 943, 979, 1009, 1037]) == 4212\n assert candidate(nums = [700, 715, 729, 741, 756, 765, 777, 784, 792, 805, 819, 828, 832, 840, 855]) == 0\n assert candidate(nums = [330, 351, 372, 393, 414]) == 528\n assert candidate(nums = [855, 876, 897, 918, 939]) == 1256\n assert candidate(nums = [1155, 1365, 1785, 1995, 2310, 2730, 3003, 3276, 3570]) == 0\n assert candidate(nums = [900, 910, 924, 936, 945, 966, 975, 990, 1001, 1008, 1014, 1029, 1035, 1053, 1056, 1065]) == 0\n assert candidate(nums = [561, 609, 657, 703, 759]) == 760\n assert candidate(nums = [1430, 1441, 1451, 1463, 1481]) == 1584\n assert candidate(nums = [100, 121, 143, 169, 180]) == 168\n assert candidate(nums = [1541, 1547, 1561, 1577, 1589]) == 6928\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 0\n assert candidate(nums = [1925, 1931, 1943, 1946, 1957]) == 4120\n assert candidate(nums = [1729, 1739, 1751, 1763, 1771]) == 5544\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 0\n assert candidate(nums = [143, 221, 247, 299, 323]) == 1396\n assert candidate(nums = [1905, 1926, 1947, 1968, 1989]) == 0\n assert candidate(nums = [600, 625, 648, 675, 700, 729, 756, 784, 810, 841, 864, 891]) == 0\n assert candidate(nums = [667, 713, 779, 817, 851]) == 4120\n assert candidate(nums = [65537, 65539, 65543, 65551, 65561, 65579, 65591, 65597]) == 208140\n assert candidate(nums = [645, 666, 687, 708, 729]) == 920\n assert candidate(nums = [105, 126, 147, 168, 189]) == 0\n assert candidate(nums = [1386, 1452, 1518, 1584, 1650]) == 0\n assert candidate(nums = [903, 913, 924, 931, 943]) == 2016\n assert candidate(nums = [841, 961, 1089, 1225, 1369]) == 0\n assert candidate(nums = [609, 621, 637, 651, 671]) == 744\n assert candidate(nums = [121, 125, 143, 147, 169, 175, 182, 189, 196, 209, 221, 225, 245, 253, 265, 275, 287, 299]) == 2100\n assert candidate(nums = [1695, 1716, 1737, 1758, 1779]) == 2376\n assert candidate(nums = [1590, 1611, 1632, 1653, 1674]) == 0\n assert candidate(nums = [496, 672, 728, 840, 924]) == 0\n assert candidate(nums = [121, 144, 169, 196, 225]) == 0\n assert candidate(nums = [1105, 1365, 1615, 1885, 2145, 2415, 2685, 2955, 3225, 3495, 3765]) == 0\n assert candidate(nums = [506, 518, 529, 539, 551]) == 600\n assert candidate(nums = [1331, 1369, 1406, 1444, 1482, 1521, 1562, 1600, 1640, 1681, 1722, 1764]) == 1464\n assert candidate(nums = [406, 429, 455, 462, 494, 518, 546]) == 0\n assert candidate(nums = [45, 60, 77, 84, 91, 99, 100]) == 208\n assert candidate(nums = [325, 351, 375, 399, 425]) == 0\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115]) == 458\n assert candidate(nums = [2010, 2031, 2052, 2073, 2094]) == 5480\n assert candidate(nums = [120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130]) == 686\n assert candidate(nums = [1001, 1007, 1029, 1045, 1067]) == 2256\n assert candidate(nums = [805, 819, 836, 851, 869]) == 1872\n assert candidate(nums = [1221, 1235, 1241, 1254, 1265]) == 1332\n assert candidate(nums = [750, 771, 792, 813, 834]) == 2120\n assert candidate(nums = [703, 707, 713, 725, 729, 735, 741, 745, 749, 759, 763, 779, 783, 799, 803, 805, 815, 825, 833, 835, 837, 841]) == 9572\n assert candidate(nums = [77, 110, 143, 176, 209]) == 504\n assert candidate(nums = [324, 325, 329, 333, 341, 343, 345, 351, 357, 361, 363, 371, 375, 385, 387, 399, 405, 425, 427, 429, 441, 451]) == 2600\n assert candidate(nums = [1021, 1031, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097]) == 0\n assert candidate(nums = [391, 437, 493, 529, 551]) == 2052\n assert candidate(nums = [231, 255, 273, 297, 315, 333, 351]) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sumFourDivisors", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int sumFourDivisors(vector& nums) {", "container": "Solution", "callable": "sumFourDivisors", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1391, "task_id": "check-if-there-is-a-valid-path-in-a-grid", "difficulty": "Medium", "problem_description": "You are given an m x n grid. Each cell of grid represents a street. The street of grid[i][j] can be:\n\n1 which means a street connecting the left cell and the right cell.\n2 which means a street connecting the upper cell and the lower cell.\n3 which means a street connecting the left cell and the lower cell.\n4 which means a street connecting the right cell and the lower cell.\n5 which means a street connecting the left cell and the upper cell.\n6 which means a street connecting the right cell and the upper cell.\n\n\nYou will initially start at the street of the upper-left cell (0, 0). A valid path in the grid is a path that starts from the upper left cell (0, 0) and ends at the bottom-right cell (m - 1, n - 1). The path should only follow the streets.\nNotice that you are not allowed to change any street.\nReturn true if there is a valid path in the grid or false otherwise.\n \nExample 1:\n\n\nInput: grid = [[2,4,3],[6,5,2]]\nOutput: true\nExplanation: As shown you can start at cell (0, 0) and visit all the cells of the grid to reach (m - 1, n - 1).\n\nExample 2:\n\n\nInput: grid = [[1,2,1],[1,2,1]]\nOutput: false\nExplanation: As shown you the street at cell (0, 0) is not connected with any street of any other cell and you will get stuck at cell (0, 0)\n\nExample 3:\n\nInput: grid = [[1,1,2]]\nOutput: false\nExplanation: You will get stuck at cell (0, 1) and you cannot reach cell (0, 2).\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 300\n1 <= grid[i][j] <= 6\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[4, 3, 2, 1], [2, 1, 4, 3], [3, 2, 1, 4]]) == False\n assert candidate(grid = [[2], [2], [2]]) == True\n assert candidate(grid = [[1, 1, 2]]) == False\n assert candidate(grid = [[2, 4, 3], [6, 5, 2]]) == True\n assert candidate(grid = [[4, 1, 3], [6, 1, 6], [3, 2, 4]]) == False\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 3]]) == True\n assert candidate(grid = [[2, 6, 6, 5], [6, 6, 5, 6], [5, 6, 6, 6], [6, 5, 2, 6]]) == False\n assert candidate(grid = [[1, 3, 5, 1], [1, 2, 1, 2], [1, 2, 1, 2]]) == False\n assert candidate(grid = [[5, 3, 1, 1, 2, 3, 6, 4, 4, 5], [6, 1, 3, 2, 2, 1, 4, 3, 5, 4], [4, 3, 5, 1, 2, 2, 2, 1, 3, 4], [4, 1, 4, 2, 3, 3, 1, 1, 2, 4], [1, 2, 2, 4, 2, 3, 3, 3, 1, 4], [2, 2, 4, 1, 4, 2, 1, 1, 3, 4], [6, 4, 4, 1, 4, 1, 3, 1, 4, 1], [5, 1, 5, 4, 2, 2, 1, 2, 6, 4], [1, 1, 3, 1, 2, 5, 2, 3, 6, 5], [2, 2, 1, 4, 4, 1, 3, 1, 4, 6]]) == False\n assert candidate(grid = [[2, 1, 1, 1, 1, 1, 3]]) == False\n assert candidate(grid = [[1, 2, 1], [1, 2, 1]]) == False\n assert candidate(grid = [[4, 3, 3], [6, 5, 2]]) == False\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 1], [1, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 1], [1, 6, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 6, 1], [1, 6, 5, 4, 3, 3, 3, 3, 3, 3, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2, 2, 2, 2, 2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2, 1, 1, 1, 2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2, 1, 6, 1, 2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2, 1, 6, 5, 2, 3, 4, 5, 6, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[1, 4, 2, 5, 6], [2, 6, 5, 3, 3], [5, 4, 1, 6, 2], [1, 2, 1, 2, 1], [1, 3, 6, 4, 5]]) == False\n assert candidate(grid = [[3, 1, 1, 2, 2, 5, 2, 1, 5, 4], [4, 6, 5, 3, 5, 1, 6, 1, 4, 1], [2, 4, 2, 6, 1, 3, 2, 1, 6, 5], [1, 4, 2, 1, 5, 4, 2, 6, 3, 1], [2, 5, 1, 4, 6, 2, 3, 1, 5, 4], [1, 3, 4, 2, 1, 6, 5, 4, 2, 3], [4, 2, 1, 5, 4, 2, 1, 6, 5, 1], [2, 5, 1, 4, 6, 2, 3, 1, 4, 2], [5, 1, 4, 2, 1, 5, 4, 2, 1, 6], [6, 3, 2, 1, 5, 4, 1, 6, 5, 3]]) == False\n assert candidate(grid = [[3, 2, 1, 4, 5, 6, 1, 2], [4, 5, 6, 1, 2, 3, 4, 5], [5, 6, 1, 2, 3, 4, 5, 6], [6, 1, 2, 3, 4, 5, 6, 1], [1, 2, 3, 4, 5, 6, 1, 2], [2, 3, 4, 5, 6, 1, 2, 3]]) == False\n assert candidate(grid = [[3, 3, 6, 6, 4, 4, 5, 2, 5, 4], [3, 6, 3, 1, 2, 2, 3, 1, 3, 5], [4, 2, 2, 6, 3, 5, 5, 4, 1, 2], [1, 1, 5, 2, 1, 1, 1, 2, 6, 5], [2, 3, 1, 2, 1, 2, 1, 4, 1, 5]]) == False\n assert candidate(grid = [[2, 3, 4, 5, 1, 1, 5, 6, 3, 3], [4, 2, 5, 2, 1, 1, 1, 3, 5, 2], [5, 5, 5, 6, 4, 4, 2, 4, 5, 5], [2, 3, 1, 1, 3, 1, 4, 5, 4, 4], [2, 1, 1, 4, 5, 3, 2, 1, 4, 5], [3, 4, 5, 4, 6, 6, 3, 2, 5, 1], [6, 4, 3, 1, 5, 6, 1, 3, 3, 3], [1, 2, 5, 5, 4, 3, 3, 3, 3, 2], [3, 1, 4, 4, 3, 6, 1, 4, 4, 5], [1, 1, 2, 5, 2, 3, 3, 5, 4, 5]]) == False\n assert candidate(grid = [[2, 1, 1, 1, 1, 1, 1, 1, 1, 6], [3, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 4, 5], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 4, 5], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 4, 5], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 4, 5], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4]]) == False\n assert candidate(grid = [[6, 3, 1, 4, 3, 2], [4, 2, 3, 6, 5, 4], [1, 5, 4, 2, 1, 6], [4, 2, 1, 6, 5, 4], [3, 6, 5, 4, 2, 1], [6, 5, 4, 2, 1, 4]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3]]) == False\n assert candidate(grid = [[4, 3, 1, 5, 2, 3, 6, 4, 4, 5], [6, 5, 3, 2, 2, 1, 4, 3, 5, 4], [4, 3, 5, 1, 2, 2, 2, 1, 3, 4], [4, 1, 4, 2, 3, 3, 1, 1, 2, 4], [1, 2, 2, 4, 2, 3, 3, 3, 1, 4], [2, 2, 4, 1, 4, 2, 1, 1, 3, 4], [6, 4, 4, 1, 4, 1, 3, 1, 4, 1], [5, 1, 5, 4, 2, 2, 1, 2, 6, 4], [1, 1, 3, 1, 2, 5, 2, 3, 6, 5], [2, 2, 1, 4, 4, 1, 3, 1, 4, 6]]) == False\n assert candidate(grid = [[2, 5, 3, 4, 3, 2, 1], [1, 6, 5, 4, 3, 2, 4], [4, 3, 2, 1, 6, 5, 3], [3, 2, 1, 6, 5, 4, 2], [6, 5, 4, 2, 1, 4, 3], [5, 4, 2, 1, 6, 5, 1], [2, 1, 6, 5, 4, 2, 6]]) == False\n assert candidate(grid = [[3, 2, 1, 6, 5, 4], [2, 1, 4, 3, 6, 5], [1, 6, 3, 4, 5, 2], [6, 5, 1, 4, 3, 2], [3, 2, 6, 5, 4, 1], [4, 3, 5, 2, 1, 6]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]]) == False\n assert candidate(grid = [[3, 4, 5, 2, 1, 6, 5, 4], [6, 4, 3, 1, 6, 5, 4, 3], [5, 3, 2, 4, 5, 4, 3, 2], [2, 1, 4, 3, 2, 1, 4, 3], [1, 6, 5, 4, 1, 6, 5, 4], [4, 2, 1, 6, 4, 2, 1, 6], [3, 6, 5, 4, 3, 6, 5, 4], [6, 5, 4, 2, 6, 5, 4, 2]]) == False\n assert candidate(grid = [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]) == False\n assert candidate(grid = [[5, 6, 3, 4, 1, 2, 3, 4, 1, 2], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [5, 6, 1, 2, 3, 4, 5, 6, 1, 2], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6]]) == False\n assert candidate(grid = [[1, 5, 1, 3, 3], [1, 1, 4, 1, 6], [3, 2, 5, 1, 2], [3, 1, 5, 1, 3], [1, 1, 6, 1, 2]]) == False\n assert candidate(grid = [[5, 2, 1, 6], [6, 5, 2, 1], [1, 6, 5, 2], [2, 1, 6, 5]]) == False\n assert candidate(grid = [[1, 4, 3, 6, 2, 6, 1, 1, 6, 6], [6, 6, 2, 2, 4, 4, 4, 6, 1, 6], [3, 6, 1, 1, 3, 6, 6, 1, 6, 5], [6, 3, 2, 2, 3, 6, 6, 5, 1, 1], [1, 4, 6, 3, 4, 6, 3, 2, 6, 3], [6, 5, 5, 4, 2, 3, 3, 4, 1, 6], [6, 6, 1, 5, 2, 5, 6, 3, 4, 4], [4, 5, 6, 5, 2, 3, 5, 6, 3, 4], [1, 3, 4, 6, 5, 6, 5, 3, 5, 6], [6, 4, 6, 1, 5, 6, 4, 4, 4, 4]]) == False\n assert candidate(grid = [[2, 3, 1, 4, 2, 3, 6, 5, 1, 4], [4, 2, 5, 3, 4, 2, 5, 3, 4, 2], [5, 3, 4, 2, 5, 3, 4, 2, 5, 3], [4, 2, 5, 3, 4, 2, 5, 3, 4, 2], [5, 3, 4, 2, 5, 3, 4, 2, 5, 3], [4, 2, 5, 3, 4, 2, 5, 3, 4, 2]]) == False\n assert candidate(grid = [[4, 2, 3, 1, 5, 4, 2, 5, 6, 2], [5, 1, 1, 1, 2, 3, 3, 4, 4, 4], [2, 2, 6, 5, 4, 4, 4, 1, 5, 6], [4, 3, 2, 1, 5, 3, 4, 5, 1, 2], [3, 2, 2, 3, 5, 1, 4, 1, 3, 6], [5, 4, 2, 4, 4, 3, 5, 1, 4, 6], [3, 4, 3, 2, 5, 2, 3, 2, 1, 2], [5, 3, 2, 2, 6, 1, 4, 3, 5, 5], [6, 5, 4, 1, 3, 6, 2, 3, 5, 1], [2, 1, 4, 5, 2, 3, 4, 4, 3, 4]]) == False\n assert candidate(grid = [[4, 4, 4, 4, 4], [4, 4, 4, 4, 4], [4, 4, 4, 4, 4], [4, 4, 4, 4, 4], [4, 4, 4, 4, 4]]) == False\n assert candidate(grid = [[6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6]]) == False\n assert candidate(grid = [[6, 1, 1, 1, 1, 1, 2, 4, 3, 2], [5, 4, 6, 5, 4, 2, 2, 5, 4, 6], [3, 2, 2, 6, 4, 1, 3, 1, 1, 3], [5, 3, 2, 1, 2, 5, 4, 3, 4, 4], [5, 2, 1, 4, 3, 3, 3, 1, 2, 5], [1, 2, 3, 1, 6, 1, 4, 4, 5, 3], [3, 1, 4, 4, 1, 4, 1, 4, 2, 4], [1, 2, 6, 3, 4, 1, 5, 1, 1, 1], [3, 4, 2, 1, 6, 3, 2, 6, 4, 1], [1, 5, 6, 5, 6, 4, 2, 4, 5, 3]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1]]) == False\n assert candidate(grid = [[5, 2, 3, 1, 2, 6, 4, 4, 5, 3, 1, 2], [3, 1, 5, 4, 2, 3, 2, 1, 5, 4, 2, 3], [2, 6, 4, 3, 6, 5, 3, 5, 4, 3, 6, 5], [4, 3, 5, 4, 3, 5, 4, 3, 5, 4, 3, 5], [5, 4, 3, 5, 4, 3, 5, 4, 3, 5, 4, 3]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 5, 4, 3, 2], [2, 3, 4, 5, 6, 1, 4, 3, 2, 1], [3, 4, 5, 6, 1, 2, 5, 4, 3, 2], [4, 5, 6, 1, 2, 3, 6, 5, 4, 3], [5, 6, 1, 2, 3, 4, 1, 6, 5, 4], [6, 1, 2, 3, 4, 5, 2, 1, 6, 5]]) == False\n assert candidate(grid = [[2, 6, 6, 2, 6, 6, 2, 2, 2, 5], [3, 3, 3, 5, 5, 3, 5, 6, 5, 6], [1, 5, 6, 4, 5, 6, 1, 1, 6, 3], [1, 4, 5, 6, 4, 3, 6, 4, 1, 6], [3, 3, 3, 2, 5, 4, 1, 4, 4, 1], [1, 5, 4, 1, 3, 3, 5, 4, 1, 6], [1, 1, 4, 1, 4, 2, 1, 1, 3, 6], [1, 4, 5, 2, 1, 4, 4, 6, 4, 5], [5, 1, 6, 6, 1, 6, 3, 5, 1, 3], [4, 3, 5, 1, 4, 1, 4, 1, 5, 1]]) == False\n assert candidate(grid = [[1, 3, 6, 2, 6, 5, 6, 1, 3, 6], [1, 4, 5, 2, 5, 1, 3, 5, 2, 1], [5, 4, 5, 2, 3, 3, 3, 2, 6, 4], [4, 4, 1, 1, 6, 2, 4, 3, 4, 4], [4, 1, 6, 5, 3, 5, 1, 5, 4, 3], [6, 6, 3, 4, 2, 3, 5, 5, 2, 3], [3, 2, 2, 2, 5, 1, 4, 5, 3, 2], [1, 2, 2, 3, 1, 4, 5, 1, 3, 1], [6, 4, 1, 2, 1, 6, 4, 5, 2, 6], [2, 5, 4, 3, 1, 6, 2, 1, 1, 6]]) == False\n assert candidate(grid = [[5, 3, 4, 2, 1, 4, 2, 5, 3, 6], [6, 4, 5, 1, 2, 3, 5, 2, 4, 1], [3, 2, 1, 4, 5, 6, 1, 4, 5, 2], [2, 1, 4, 5, 6, 1, 4, 5, 6, 3], [1, 4, 5, 6, 1, 2, 3, 4, 5, 6], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1], [5, 6, 1, 2, 3, 4, 5, 6, 1, 2], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6]]) == False\n assert candidate(grid = [[5, 5, 1, 6, 3, 1, 4, 2, 5, 4], [2, 1, 4, 1, 2, 3, 1, 4, 6, 2], [4, 5, 1, 1, 6, 2, 6, 1, 2, 6], [2, 6, 5, 2, 4, 6, 1, 2, 1, 3], [4, 1, 2, 5, 1, 4, 4, 1, 3, 2], [3, 2, 1, 3, 5, 4, 1, 2, 6, 3], [1, 2, 2, 3, 1, 2, 5, 1, 2, 4], [1, 3, 2, 6, 3, 2, 2, 1, 6, 4], [6, 3, 6, 1, 1, 6, 2, 3, 6, 3], [6, 3, 4, 4, 6, 2, 3, 1, 2, 1]]) == False\n assert candidate(grid = [[2, 3, 6, 5, 5, 4, 5, 1, 1, 4], [2, 1, 5, 5, 2, 1, 5, 5, 1, 3], [1, 5, 4, 2, 4, 3, 3, 4, 5, 4], [3, 6, 5, 6, 4, 1, 3, 3, 2, 2], [5, 2, 4, 1, 4, 2, 5, 5, 6, 6], [1, 2, 4, 6, 6, 4, 5, 5, 4, 4], [4, 1, 2, 4, 1, 4, 5, 6, 4, 6], [3, 5, 5, 6, 3, 4, 5, 4, 1, 1], [3, 5, 3, 2, 3, 2, 4, 1, 6, 5], [4, 1, 4, 1, 5, 3, 3, 5, 3, 3]]) == False\n assert candidate(grid = [[2, 3, 4, 1, 2, 5, 3, 6, 4, 5], [6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [5, 6, 1, 2, 3, 4, 5, 6, 1, 2], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1], [5, 6, 1, 2, 3, 4, 5, 6, 1, 2], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6]]) == False\n assert candidate(grid = [[2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2], [2, 2, 2, 2, 2, 2, 2, 2]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 6, 5, 4, 3, 2], [2, 1, 6, 5, 4, 3], [3, 2, 1, 6, 5, 4], [4, 3, 2, 1, 6, 5]]) == False\n assert candidate(grid = [[2, 3, 4, 5, 6, 1, 3, 2, 4, 1], [1, 4, 2, 3, 5, 6, 1, 2, 3, 4], [5, 6, 1, 4, 2, 3, 4, 1, 2, 3], [6, 1, 2, 3, 4, 5, 6, 1, 4, 2], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6]]) == False\n assert candidate(grid = [[3, 4, 5, 2], [6, 4, 3, 1], [5, 3, 2, 4], [2, 1, 4, 3]]) == False\n assert candidate(grid = [[1, 4, 2, 3, 6, 5, 4, 1, 2, 6], [5, 3, 1, 2, 1, 1, 4, 2, 3, 5], [4, 2, 1, 5, 4, 2, 1, 3, 6, 1], [1, 6, 2, 3, 1, 5, 4, 1, 2, 4], [2, 5, 1, 2, 6, 3, 1, 6, 4, 1], [5, 3, 4, 1, 6, 1, 2, 5, 1, 3], [1, 2, 6, 3, 1, 4, 1, 6, 2, 1], [4, 2, 1, 5, 4, 2, 3, 1, 6, 5], [3, 6, 1, 2, 4, 1, 5, 4, 2, 3], [2, 1, 5, 4, 1, 3, 1, 6, 2, 4]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 1, 2, 3, 4], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6]]) == False\n assert candidate(grid = [[3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]]) == False\n assert candidate(grid = [[2, 1, 1, 1, 1, 1, 1, 1, 1, 6], [3, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 4, 5], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 4, 5], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 4, 5], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4], [1, 1, 1, 1, 1, 1, 1, 1, 4, 5], [1, 1, 1, 1, 1, 1, 1, 1, 5, 4]]) == False\n assert candidate(grid = [[2, 1, 1, 1, 1], [1, 6, 1, 4, 2], [2, 1, 2, 1, 1], [2, 6, 1, 1, 1], [1, 1, 1, 6, 4]]) == False\n assert candidate(grid = [[6, 4, 5, 2, 1, 3, 3, 1, 4, 6], [2, 4, 6, 5, 1, 1, 4, 3, 3, 2], [5, 5, 5, 4, 3, 2, 1, 4, 1, 3], [1, 1, 5, 2, 4, 4, 1, 4, 3, 5], [6, 1, 2, 1, 6, 3, 2, 2, 5, 3], [1, 4, 6, 3, 3, 4, 2, 4, 1, 3], [4, 4, 1, 2, 5, 1, 5, 3, 5, 2], [2, 3, 1, 1, 1, 1, 5, 4, 5, 5], [4, 2, 2, 3, 5, 5, 5, 4, 6, 6], [2, 4, 3, 6, 3, 2, 3, 5, 6, 5]]) == False\n assert candidate(grid = [[2, 1, 2, 3, 6, 5, 6, 4, 5, 1], [3, 1, 6, 1, 3, 3, 1, 1, 5, 6], [5, 1, 4, 2, 5, 2, 2, 5, 4, 3], [6, 6, 6, 3, 2, 5, 3, 2, 6, 5], [1, 4, 4, 6, 3, 4, 5, 6, 6, 1], [3, 2, 4, 2, 1, 5, 3, 1, 4, 3], [6, 2, 1, 4, 6, 4, 4, 4, 5, 3], [2, 3, 2, 6, 6, 1, 3, 1, 5, 4], [6, 6, 5, 4, 3, 2, 1, 2, 4, 3], [2, 5, 4, 3, 1, 1, 4, 5, 5, 1]]) == False\n assert candidate(grid = [[6, 6, 6, 6, 6, 6, 6, 6, 6, 6], [6, 5, 5, 5, 5, 5, 5, 5, 5, 6], [6, 5, 4, 4, 4, 4, 4, 4, 5, 6], [6, 5, 4, 3, 3, 3, 3, 4, 5, 6], [6, 5, 4, 3, 2, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1, 6, 5, 4, 6], [6, 5, 4, 3, 2, 1, 6, 5, 6, 6], [6, 5, 4, 3, 2, 1, 6, 6, 6, 6]]) == False\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2], [2, 1, 6, 5, 4, 3], [3, 2, 1, 6, 5, 4]]) == False\n assert candidate(grid = [[6, 1, 3, 5, 2, 4, 3, 1, 5, 1], [4, 2, 5, 4, 1, 6, 4, 2, 3, 4], [1, 5, 2, 4, 6, 2, 6, 3, 2, 6], [3, 6, 2, 1, 5, 4, 6, 2, 4, 4], [1, 2, 4, 4, 3, 3, 4, 6, 2, 5], [2, 5, 5, 6, 1, 3, 5, 4, 4, 6], [5, 4, 4, 6, 2, 3, 1, 6, 1, 3], [5, 5, 2, 4, 1, 4, 3, 2, 6, 1], [5, 6, 2, 1, 3, 2, 4, 2, 3, 5], [4, 5, 5, 1, 3, 4, 2, 5, 1, 2]]) == False\n assert candidate(grid = [[6, 2, 1, 3, 5, 4], [4, 5, 6, 1, 2, 3], [3, 2, 1, 6, 5, 4], [2, 1, 4, 3, 5, 6], [5, 6, 3, 2, 4, 1], [1, 4, 2, 5, 3, 6]]) == False\n assert candidate(grid = [[5, 1, 6, 1, 3, 2, 5, 4, 1, 3], [4, 2, 1, 5, 6, 3, 1, 2, 4, 5], [1, 6, 2, 3, 1, 5, 6, 1, 3, 2], [6, 3, 1, 2, 4, 1, 5, 4, 2, 1], [2, 1, 5, 4, 1, 3, 2, 1, 5, 6], [4, 2, 1, 5, 6, 3, 1, 2, 4, 1], [1, 6, 2, 3, 1, 5, 4, 2, 1, 5], [2, 1, 5, 4, 1, 3, 2, 1, 6, 3], [5, 4, 2, 1, 6, 1, 3, 5, 4, 2], [1, 3, 2, 5, 4, 1, 6, 3, 2, 1]]) == False\n assert candidate(grid = [[2, 5, 3, 6, 1, 4], [1, 4, 2, 5, 3, 6], [3, 6, 1, 4, 2, 5], [2, 5, 3, 6, 1, 4], [1, 4, 2, 5, 3, 6]]) == False\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[4, 6, 1, 3, 5, 2], [5, 2, 4, 6, 1, 3], [3, 5, 2, 4, 6, 1], [6, 1, 3, 5, 2, 4], [2, 4, 6, 1, 3, 5], [1, 3, 5, 2, 4, 6]]) == False\n assert candidate(grid = [[2, 1, 4, 3, 2, 1, 4, 3, 2, 1], [1, 4, 3, 2, 1, 4, 3, 2, 1, 4], [4, 3, 2, 1, 4, 3, 2, 1, 4, 3], [3, 2, 1, 4, 3, 2, 1, 4, 3, 2]]) == False\n assert candidate(grid = [[1, 5, 1, 2, 6, 4, 1, 3, 2, 5], [5, 4, 2, 1, 1, 3, 4, 1, 6, 2], [1, 3, 5, 4, 2, 6, 1, 2, 5, 1], [3, 4, 6, 1, 1, 2, 6, 4, 1, 2], [5, 1, 2, 4, 1, 1, 4, 1, 2, 6], [4, 6, 5, 2, 1, 6, 2, 3, 5, 4], [1, 2, 4, 5, 2, 1, 6, 1, 4, 3], [2, 5, 1, 4, 2, 1, 1, 4, 1, 6], [4, 1, 6, 1, 4, 2, 3, 2, 6, 1], [5, 4, 2, 3, 1, 4, 1, 1, 4, 2]]) == False\n assert candidate(grid = [[5, 4, 3, 6, 1, 2], [2, 1, 4, 3, 5, 6], [6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6], [4, 5, 6, 1, 2, 3], [3, 2, 1, 6, 5, 4]]) == False\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 1, 2, 3, 4], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1], [5, 6, 1, 2, 3, 4, 5, 6, 1, 2], [6, 1, 2, 3, 4, 5, 6, 1, 2, 3], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1]]) == False\n assert candidate(grid = [[1, 6, 5, 4, 3, 2, 1, 2, 3, 4], [6, 5, 4, 3, 2, 1, 2, 3, 4, 5], [5, 4, 3, 2, 1, 2, 3, 4, 5, 6], [4, 3, 2, 1, 2, 3, 4, 5, 6, 1], [3, 2, 1, 2, 3, 4, 5, 6, 1, 2], [2, 1, 2, 3, 4, 5, 6, 1, 2, 3], [1, 2, 3, 4, 5, 6, 1, 2, 3, 4], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1]]) == False\n assert candidate(grid = [[2, 6, 2, 5, 4, 3, 5, 1, 6, 5], [5, 4, 3, 5, 4, 3, 5, 4, 3, 5], [4, 3, 5, 4, 3, 5, 4, 3, 5, 4], [3, 5, 4, 3, 5, 4, 3, 5, 4, 3], [5, 4, 3, 5, 4, 3, 5, 4, 3, 5], [4, 3, 5, 4, 3, 5, 4, 3, 5, 4]]) == False\n assert candidate(grid = [[1, 2, 5, 6, 3, 4], [4, 3, 2, 1, 6, 5], [5, 6, 4, 3, 2, 1], [1, 6, 5, 4, 3, 2], [2, 1, 3, 4, 5, 6], [6, 5, 2, 1, 4, 3]]) == False\n assert candidate(grid = [[1, 3, 1, 3, 1, 3, 1, 3, 1, 3], [3, 1, 3, 1, 3, 1, 3, 1, 3, 1], [1, 3, 1, 3, 1, 3, 1, 3, 1, 3], [3, 1, 3, 1, 3, 1, 3, 1, 3, 1], [1, 3, 1, 3, 1, 3, 1, 3, 1, 3], [3, 1, 3, 1, 3, 1, 3, 1, 3, 1]]) == False\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 1, 2, 3, 4], [2, 3, 4, 5, 6, 1, 2, 3, 4, 5], [3, 4, 5, 6, 1, 2, 3, 4, 5, 6], [4, 5, 6, 1, 2, 3, 4, 5, 6, 1], [5, 6, 1, 2, 3, 4, 5, 6, 1, 2], [6, 1, 2, 3, 4, 5, 6, 1, 2, 3]]) == False\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == False\n assert candidate(grid = [[5, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 5], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 5]]) == False\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().hasValidPath", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool hasValidPath(vector>& grid) {", "container": "Solution", "callable": "hasValidPath", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1392, "task_id": "longest-happy-prefix", "difficulty": "Hard", "problem_description": "A string is called a happy prefix if is a non-empty prefix which is also a suffix (excluding itself).\nGiven a string s, return the longest happy prefix of s. Return an empty string \"\" if no such prefix exists.\n \nExample 1:\n\nInput: s = \"level\"\nOutput: \"l\"\nExplanation: s contains 4 prefix excluding itself (\"l\", \"le\", \"lev\", \"leve\"), and suffix (\"l\", \"el\", \"vel\", \"evel\"). The largest prefix which is also suffix is given by \"l\".\n\nExample 2:\n\nInput: s = \"ababab\"\nOutput: \"abab\"\nExplanation: \"abab\" is the largest prefix which is also suffix. They can overlap in the original string.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns contains only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"prefixprefix\") == \"prefix\"\n assert candidate(s = \"abcdef\") == \"\"\n assert candidate(s = \"aaaaa\") == \"aaaa\"\n assert candidate(s = \"aaaaabaaaa\") == \"aaaa\"\n assert candidate(s = \"a\") == \"\"\n assert candidate(s = \"abacabadabacaba\") == \"abacaba\"\n assert candidate(s = \"abcabcabc\") == \"abcabc\"\n assert candidate(s = \"abcabcabcabc\") == \"abcabcabc\"\n assert candidate(s = \"aaaaaabbbaaaa\") == \"aaaa\"\n assert candidate(s = \"happy\") == \"\"\n assert candidate(s = \"noon\") == \"n\"\n assert candidate(s = \"banana\") == \"\"\n assert candidate(s = \"abc\") == \"\"\n assert candidate(s = \"aabbccddeeaabbccdd\") == \"aabbccdd\"\n assert candidate(s = \"abcd\") == \"\"\n assert candidate(s = \"aabbccddeeffgg\") == \"\"\n assert candidate(s = \"suffix\") == \"\"\n assert candidate(s = \"aaaa\") == \"aaa\"\n assert candidate(s = \"mississippi\") == \"\"\n assert candidate(s = \"abcdabc\") == \"abc\"\n assert candidate(s = \"ababab\") == \"abab\"\n assert candidate(s = \"level\") == \"l\"\n assert candidate(s = \"abacababacab\") == \"abacab\"\n assert candidate(s = \"ababababcababab\") == \"ababab\"\n assert candidate(s = \"abacabadabacabadabacaba\") == \"abacabadabacaba\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghij\") == \"abcdefghijabcdefghijabcdefghij\"\n assert candidate(s = \"bananaananabay\") == \"\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"abracadabra\") == \"abra\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"abcdefabcdefabcdef\") == \"abcdefabcdef\"\n assert candidate(s = \"abacabadabacabadabacabadabacabad\") == \"abacabadabacabadabacabad\"\n assert candidate(s = \"abcabcabcabcabcd\") == \"\"\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyz\") == \"xyzxyzxyzxyzxyzxyz\"\n assert candidate(s = \"aababaabaababaaba\") == \"aababaaba\"\n assert candidate(s = \"aaaabaaaa\") == \"aaaa\"\n assert candidate(s = \"zazazazazazazazazazaz\") == \"zazazazazazazazazaz\"\n assert candidate(s = \"abcabcabcabcabcabca\") == \"abcabcabcabcabca\"\n assert candidate(s = \"abbaabbaabbaabbaabbaabba\") == \"abbaabbaabbaabbaabba\"\n assert candidate(s = \"aabaaabaabaaabaabaabaaabaabaab\") == \"aab\"\n assert candidate(s = \"mississippimississippimississippimis\") == \"mississippimississippimis\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\"\n assert candidate(s = \"abcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcba\") == \"abcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcbaabcdefghijkllkjihgfedcba\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"aaaaaaabaaaaaab\") == \"\"\n assert candidate(s = \"aaaaabbbbbccccdddd\") == \"\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"acacacacac\") == \"acacacac\"\n assert candidate(s = \"xyzxyzxyzxyz\") == \"xyzxyzxyz\"\n assert candidate(s = \"mississippimississippi\") == \"mississippi\"\n assert candidate(s = \"aaaaaabbbaaaaa\") == \"aaaaa\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"aaaaabbbbbbbaaaaa\") == \"aaaaa\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"bananaananabanana\") == \"banana\"\n assert candidate(s = \"mississippimississippimiss\") == \"mississippimiss\"\n assert candidate(s = \"aabbaabbaabbaabb\") == \"aabbaabbaabb\"\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacaba\") == \"abacabadabacabadabacabadabacaba\"\n assert candidate(s = \"abcabcabcabcabcabcabc\") == \"abcabcabcabcabcabc\"\n assert candidate(s = \"zazazazazazaz\") == \"zazazazazaz\"\n assert candidate(s = \"abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh\") == \"abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh\"\n assert candidate(s = \"ababcabababa\") == \"aba\"\n assert candidate(s = \"aaabaaaab\") == \"aaab\"\n assert candidate(s = \"aaaaaaaab\") == \"\"\n assert candidate(s = \"abacabacabac\") == \"abacabac\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == \"abcdabcdabcdabcdabcdabcdabcdabcdabcd\"\n assert candidate(s = \"mississippimississippimississippi\") == \"mississippimississippi\"\n assert candidate(s = \"xyzxyzzxyzxyz\") == \"xyzxyz\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"abcdabcde\") == \"\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"ababbababbababbabab\") == \"ababbababbabab\"\n assert candidate(s = \"abcabcabcabcab\") == \"abcabcabcab\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaa\") == \"aaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"ababababababab\") == \"abababababab\"\n assert candidate(s = \"abcdeedcba\") == \"a\"\n assert candidate(s = \"aaaaaa\") == \"aaaaa\"\n assert candidate(s = \"abababababababab\") == \"ababababababab\"\n assert candidate(s = \"ababababababababab\") == \"abababababababab\"\n assert candidate(s = \"abcabcabcabcabcabc\") == \"abcabcabcabcabc\"\n assert candidate(s = \"aaaaaaaaaabaaaaaaaaa\") == \"aaaaaaaaa\"\n assert candidate(s = \"aaaaabaaaabaaaaaa\") == \"aaaaa\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"aaaaaaa\") == \"aaaaaa\"\n assert candidate(s = \"abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh\") == \"abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh\"\n assert candidate(s = \"abababababababababababababab\") == \"ababababababababababababab\"\n assert candidate(s = \"racecaracecarace\") == \"racecarace\"\n assert candidate(s = \"abcdabcdabcdabcdabcd\") == \"abcdabcdabcdabcd\"\n assert candidate(s = \"racecaracecaracecar\") == \"racecaracecar\"\n assert candidate(s = \"abcdeedcbaedcbaedcba\") == \"a\"\n assert candidate(s = \"racecaracecaracecarace\") == \"racecaracecarace\"\n assert candidate(s = \"ababababababababababababa\") == \"abababababababababababa\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"racecaracecaracecaracecaracecarace\") == \"racecaracecaracecaracecarace\"\n assert candidate(s = \"aaaaaabaaaaaab\") == \"aaaaaab\"\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxy\") == \"xyxyxyxyxyxyxyxyxy\"\n assert candidate(s = \"xyxxyxyxyxxyx\") == \"xyxxyx\"\n assert candidate(s = \"zazazazazazaza\") == \"zazazazazaza\"\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\"\n assert candidate(s = \"xyzxyzxyzxyzxyzxyz\") == \"xyzxyzxyzxyzxyz\"\n assert candidate(s = \"aabbccddeeffggaabbccddeeffgg\") == \"aabbccddeeffgg\"\n assert candidate(s = \"abcdabcabc\") == \"abc\"\n assert candidate(s = \"aaaaaaaaaab\") == \"\"\n assert candidate(s = \"aaaaaaabaaaaaaaa\") == \"aaaaaaa\"\n assert candidate(s = \"mnopqrstuvutsrqponm\") == \"m\"\n assert candidate(s = \"ababababc\") == \"\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"abcdefgabcdefg\") == \"abcdefg\"\n assert candidate(s = \"abcdabcabcabcd\") == \"abcd\"\n assert candidate(s = \"abcdeabcdeabcdeabcde\") == \"abcdeabcdeabcde\"\n assert candidate(s = \"aaaaaaabcabcabc\") == \"\"\n assert candidate(s = \"abcdabcdabcdabcdabcda\") == \"abcdabcdabcdabcda\"\n assert candidate(s = \"abcdabcabcabc\") == \"abc\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"\"\n assert candidate(s = \"aaaaaaaaaabaaaaaaaaaa\") == \"aaaaaaaaaa\"\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabad\") == \"abacabadabacabadabacabadabacabadabacabad\"\n assert candidate(s = \"aabbccddeeffaabbccddeeff\") == \"aabbccddeeff\"\n assert candidate(s = \"aaaaaabaaaaa\") == \"aaaaa\"\n assert candidate(s = \"abcdabcabcabcabcabcabcabcabc\") == \"abc\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcd\") == \"\"\n assert candidate(s = \"abcabcabcabcabcabcabcab\") == \"abcabcabcabcabcabcab\"\n assert candidate(s = \"ababababababababababababababababababababababababababababababababababababababab\") == \"abababababababababababababababababababababababababababababababababababababab\"\n assert candidate(s = \"aabbaabbaabbaabbaabb\") == \"aabbaabbaabbaabb\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcd\") == \"abcdabcdabcdabcdabcdabcdabcdabcd\"\n assert candidate(s = \"bananaananabananaananaba\") == \"bananaananaba\"\n assert candidate(s = \"aabaaabaabaaabaab\") == \"aabaaabaab\"\n assert candidate(s = \"abcdefghijkllkjihgfedcba\") == \"a\"\n assert candidate(s = \"aabaaab\") == \"aab\"\n assert candidate(s = \"aaaaaaabaaaaaa\") == \"aaaaaa\"\n assert candidate(s = \"abcdeabcdeabcde\") == \"abcdeabcde\"\n assert candidate(s = \"abcdabcabcde\") == \"\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"zxyxzyxyzxyxzyxzyz\") == \"z\"\n assert candidate(s = \"ababababab\") == \"abababab\"\n assert candidate(s = \"abababababababababababab\") == \"ababababababababababab\"\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyz\") == \"xyzxyzxyzxyzxyzxyzxyz\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\") == \"abcdabcdabcdabcdabcdabcdabcd\"\n assert candidate(s = \"axbyczdxcyzbyxa\") == \"a\"\n assert candidate(s = \"abcdefgabcdefgabcdefg\") == \"abcdefgabcdefg\"\n assert candidate(s = \"abcxyzabcxyzabcxyz\") == \"abcxyzabcxyz\"\n assert candidate(s = \"abcdefghihgfedcba\") == \"a\"\n assert candidate(s = \"racecar\") == \"r\"\n assert candidate(s = \"abcdefghijabcdefghij\") == \"abcdefghij\"\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab\") == \"ababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab\"\n assert candidate(s = \"abcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabc\"\n assert candidate(s = \"bananaabanana\") == \"banana\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabc\") == \"abcabcabcabcabcabcabcabcabcabc\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(s = \"aabaaabaabaaabaabaab\") == \"aab\"\n assert candidate(s = \"ababcabcababc\") == \"ababc\"\n assert candidate(s = \"abababcabababc\") == \"abababc\"\n assert candidate(s = \"abcabcabcabcabc\") == \"abcabcabcabc\"\n assert candidate(s = \"abracadabracadabrac\") == \"abracadabrac\"\n assert candidate(s = \"ababababababababababababababababababab\") == \"abababababababababababababababababab\"\n assert candidate(s = \"xyzxyzyzyzxzyzyzyzyzyz\") == \"\"\n assert candidate(s = \"papapapapapap\") == \"papapapapap\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().longestPrefix", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string longestPrefix(string s) {", "container": "Solution", "callable": "longestPrefix", "parameters": [{"name": "s", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1394, "task_id": "find-lucky-integer-in-an-array", "difficulty": "Easy", "problem_description": "Given an array of integers arr, a lucky integer is an integer that has a frequency in the array equal to its value.\nReturn the largest lucky integer in the array. If there is no lucky integer return -1.\n \nExample 1:\n\nInput: arr = [2,2,3,4]\nOutput: 2\nExplanation: The only lucky number in the array is 2 because frequency[2] == 2.\n\nExample 2:\n\nInput: arr = [1,2,2,3,3,3]\nOutput: 3\nExplanation: 1, 2 and 3 are all lucky numbers, return the largest of them.\n\nExample 3:\n\nInput: arr = [2,2,2,3,3]\nOutput: -1\nExplanation: There are no lucky numbers in the array.\n\n \nConstraints:\n\n1 <= arr.length <= 500\n1 <= arr[i] <= 500\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 1]) == -1\n assert candidate(arr = [5, 5, 4, 4, 4]) == -1\n assert candidate(arr = [5]) == -1\n assert candidate(arr = [5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [2, 2, 3, 4]) == 2\n assert candidate(arr = [300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300, 300]) == -1\n assert candidate(arr = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == -1\n assert candidate(arr = [1]) == 1\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7]) == 7\n assert candidate(arr = [4, 4, 4, 4]) == 4\n assert candidate(arr = [2, 2, 2, 3, 3]) == -1\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4]) == -1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(arr = [6, 6, 6, 6, 6, 6]) == 6\n assert candidate(arr = [3, 3, 3, 3, 3, 3]) == -1\n assert candidate(arr = [1, 2, 2, 3, 3, 3]) == 3\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == -1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3]) == -1\n assert candidate(arr = [3, 3, 3, 3, 3]) == -1\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3]) == -1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == -1\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == -1\n assert candidate(arr = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == -1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == -1\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == -1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(arr = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == -1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 6\n assert candidate(arr = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == -1\n assert candidate(arr = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == -1\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == -1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == -1\n assert candidate(arr = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == -1\n assert candidate(arr = [400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400, 400]) == -1\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == -1\n assert candidate(arr = [2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == -1\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == -1\n assert candidate(arr = [200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200]) == -1\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == -1\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]) == -1\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == -1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(arr = [150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150, 150]) == -1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == -1\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == -1\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == -1\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == -1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == -1\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == -1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == -1\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 6\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().findLucky", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int findLucky(vector& arr) {", "container": "Solution", "callable": "findLucky", "parameters": [{"name": "arr", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1395, "task_id": "count-number-of-teams", "difficulty": "Medium", "problem_description": "There are n soldiers standing in a line. Each soldier is assigned a unique rating value.\nYou have to form a team of 3 soldiers amongst them under the following rules:\n\nChoose 3 soldiers with index (i, j, k) with rating (rating[i], rating[j], rating[k]).\nA team is valid if: (rating[i] < rating[j] < rating[k]) or (rating[i] > rating[j] > rating[k]) where (0 <= i < j < k < n).\n\nReturn the number of teams you can form given the conditions. (soldiers can be part of multiple teams).\n \nExample 1:\n\nInput: rating = [2,5,3,4,1]\nOutput: 3\nExplanation: We can form three teams given the conditions. (2,3,4), (5,4,1), (5,3,1). \n\nExample 2:\n\nInput: rating = [2,1,3]\nOutput: 0\nExplanation: We can't form any team given the conditions.\n\nExample 3:\n\nInput: rating = [1,2,3,4]\nOutput: 4\n\n \nConstraints:\n\nn == rating.length\n3 <= n <= 1000\n1 <= rating[i] <= 105\nAll the integers in rating are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rating = [2, 1, 3]) == 0\n assert candidate(rating = [3, 1, 2, 5, 4]) == 2\n assert candidate(rating = [1, 5, 2, 4, 3]) == 3\n assert candidate(rating = [10, 6, 5, 8]) == 1\n assert candidate(rating = [5, 4, 3, 2, 1]) == 10\n assert candidate(rating = [7, 9, 1, 10, 4, 8]) == 2\n assert candidate(rating = [5, 3, 2, 1, 4]) == 4\n assert candidate(rating = [5, 3, 1, 2, 4]) == 3\n assert candidate(rating = [3, 6, 7, 5, 10, 8]) == 9\n assert candidate(rating = [2, 5, 3, 4, 1]) == 3\n assert candidate(rating = [6, 3, 8, 1, 2, 9, 7]) == 6\n assert candidate(rating = [1, 3, 2, 4, 5]) == 7\n assert candidate(rating = [6, 9, 1, 3, 5, 7, 8, 2, 4]) == 23\n assert candidate(rating = [100, 200, 300, 400, 500]) == 10\n assert candidate(rating = [3, 2, 1, 5, 4]) == 1\n assert candidate(rating = [1, 2, 3, 4]) == 4\n assert candidate(rating = [5, 1, 4, 2, 3]) == 3\n assert candidate(rating = [100, 200, 150, 300, 250, 400, 350]) == 20\n assert candidate(rating = [4, 1, 5, 3, 2, 7, 6, 8, 10, 9]) == 66\n assert candidate(rating = [1, 5, 2, 6, 3, 7, 4, 8, 9]) == 50\n assert candidate(rating = [3, 6, 1, 5, 9, 2, 8, 4, 7, 10]) == 41\n assert candidate(rating = [5, 3, 8, 1, 7, 2, 6, 4]) == 9\n assert candidate(rating = [1, 5, 3, 7, 9, 2, 4, 8, 6, 10]) == 50\n assert candidate(rating = [7, 1, 3, 5, 9, 6, 2, 8, 4]) == 24\n assert candidate(rating = [9, 5, 7, 3, 8, 1, 6, 4, 2, 10]) == 41\n assert candidate(rating = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 455\n assert candidate(rating = [100, 200, 150, 250, 300, 10, 50, 350]) == 19\n assert candidate(rating = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1140\n assert candidate(rating = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 120\n assert candidate(rating = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 20, 12, 19, 13, 18, 14, 17, 15, 16]) == 600\n assert candidate(rating = [15, 12, 14, 11, 13, 10, 16, 17, 9, 8, 7, 6]) == 122\n assert candidate(rating = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == 88\n assert candidate(rating = [50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 60, 70, 80, 90, 100, 110]) == 594\n assert candidate(rating = [50, 25, 75, 100, 60, 30, 80, 40, 90]) == 25\n assert candidate(rating = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5]) == 40\n assert candidate(rating = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 120\n assert candidate(rating = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 84\n assert candidate(rating = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 120\n assert candidate(rating = [3, 1, 2, 6, 5, 4, 9, 8, 7, 10, 12, 11, 14, 13, 15, 16, 17]) == 537\n assert candidate(rating = [23, 17, 11, 5, 29, 25, 19, 13, 31, 27, 21, 15, 33, 28, 22, 16, 35, 30, 24, 18, 37, 32, 26, 20, 39, 34, 28, 23, 41, 36, 31, 25]) == 1835\n assert candidate(rating = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 980\n assert candidate(rating = [2, 1, 3, 6, 5, 4, 8, 7, 9]) == 52\n assert candidate(rating = [3, 1, 2, 4, 6, 5]) == 9\n assert candidate(rating = [5, 7, 9, 3, 6, 2, 8, 4, 1]) == 28\n assert candidate(rating = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 120\n assert candidate(rating = [10, 20, 30, 40, 50, 15, 25, 35, 45, 55, 5, 1, 6, 2, 7, 3, 8, 4, 9, 11]) == 320\n assert candidate(rating = [5, 2, 1, 7, 3, 8, 4, 6, 9, 10]) == 57\n assert candidate(rating = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 50\n assert candidate(rating = [1, 5, 2, 8, 3, 7, 4, 6]) == 19\n assert candidate(rating = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 430\n assert candidate(rating = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 28, 25, 22, 19, 16, 13, 10, 7, 4, 1]) == 525\n assert candidate(rating = [2, 5, 1, 6, 3, 4]) == 3\n assert candidate(rating = [3, 1, 2, 6, 5, 4, 9, 8, 7, 10]) == 63\n assert candidate(rating = [1, 3, 2, 4, 6, 5, 8, 7, 10, 9, 12, 11]) == 170\n assert candidate(rating = [5, 3, 1, 7, 9, 6, 10, 2, 4, 8]) == 30\n assert candidate(rating = [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 10, 20]) == 570\n assert candidate(rating = [15, 25, 10, 20, 5, 30, 35, 50, 45, 40]) == 57\n assert candidate(rating = [5, 1, 2, 4, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 398\n assert candidate(rating = [5, 1, 6, 2, 7, 3, 8, 4, 9, 10]) == 60\n assert candidate(rating = [50, 1, 51, 2, 52, 3, 53, 4, 54, 5]) == 40\n assert candidate(rating = [8, 1, 2, 7, 4, 3, 6, 5]) == 21\n assert candidate(rating = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 60\n assert candidate(rating = [3, 1, 5, 2, 8, 4, 6, 7, 9, 10]) == 71\n assert candidate(rating = [10, 15, 20, 25, 30, 5, 12, 18, 24, 35]) == 44\n assert candidate(rating = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15]) == 239\n assert candidate(rating = [2, 10, 4, 3, 8, 1, 6, 5]) == 15\n assert candidate(rating = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 84\n assert candidate(rating = [15, 18, 12, 19, 21, 14, 22, 20, 23, 24, 25]) == 104\n assert candidate(rating = [7, 6, 9, 10, 5, 8, 2, 1, 4, 3]) == 43\n assert candidate(rating = [25, 20, 30, 10, 40, 50, 15, 25, 35, 45]) == 33\n assert candidate(rating = [5, 2, 8, 3, 1, 9, 4, 6, 7]) == 20\n assert candidate(rating = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 455\n assert candidate(rating = [100, 101, 99, 98, 102, 103, 97, 96, 104, 105, 95, 94]) == 98\n assert candidate(rating = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 120\n assert candidate(rating = [5, 50, 15, 40, 25, 35, 10, 20, 30, 45]) == 47\n assert candidate(rating = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 21, 22, 23, 24, 25]) == 1350\n assert candidate(rating = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == 120\n assert candidate(rating = [5, 3, 7, 1, 9, 4, 6, 8, 2, 10, 11]) == 67\n assert candidate(rating = [20, 50, 40, 60, 10, 70, 30]) == 9\n assert candidate(rating = [20, 30, 10, 40, 50, 15, 25, 35, 45, 5]) == 36\n assert candidate(rating = [30, 20, 10, 50, 40, 60, 80, 70]) == 29\n assert candidate(rating = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 455\n assert candidate(rating = [9, 6, 7, 3, 8, 2, 5, 4, 10, 1]) == 47\n assert candidate(rating = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 120\n assert candidate(rating = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 455\n assert candidate(rating = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 84\n assert candidate(rating = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 50\n assert candidate(rating = [8, 1, 2, 3, 4, 5, 6, 7]) == 35\n assert candidate(rating = [5, 3, 7, 1, 9, 2, 8, 4, 6, 10]) == 34\n assert candidate(rating = [1, 15, 2, 14, 3, 13, 4, 12, 5, 11, 6, 10, 7, 9, 8]) == 203\n assert candidate(rating = [1, 3, 5, 2, 4, 6, 7]) == 22\n assert candidate(rating = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 444\n assert candidate(rating = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 120\n assert candidate(rating = [2, 1, 3, 6, 5, 7, 4, 8, 9, 10]) == 85\n assert candidate(rating = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 84\n assert candidate(rating = [8, 5, 12, 9, 15, 6, 13, 7, 14, 4, 11, 3, 10, 2, 1]) == 179\n assert candidate(rating = [7, 6, 5, 4, 3, 2, 1]) == 35\n assert candidate(rating = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == 978\n assert candidate(rating = [10, 20, 30, 15, 25, 35, 5, 12, 18, 28, 50]) == 56\n assert candidate(rating = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10]) == 70\n assert candidate(rating = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7]) == 881\n assert candidate(rating = [1, 2, 10, 4, 3, 8, 7, 9, 6, 5]) == 50\n assert candidate(rating = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115]) == 560\n assert candidate(rating = [1, 9, 3, 6, 5, 8, 4, 7, 2]) == 32\n assert candidate(rating = [7, 8, 9, 1, 2, 3, 4, 5, 6]) == 21\n assert candidate(rating = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 11, 12, 13, 14, 15]) == 355\n assert candidate(rating = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 444\n assert candidate(rating = [1, 2, 3, 5, 4, 6, 8, 7, 9, 10]) == 104\n assert candidate(rating = [50, 25, 75, 10, 40, 60, 90, 5, 30, 65, 80, 100, 15, 45, 70, 85, 95]) == 238\n assert candidate(rating = [1, 3, 5, 7, 9, 11, 13]) == 35\n assert candidate(rating = [13, 11, 9, 7, 5, 3, 1]) == 35\n assert candidate(rating = [9, 5, 3, 7, 2, 8, 1, 6, 4, 10]) == 37\n assert candidate(rating = [20, 18, 19, 15, 17, 13, 16, 12, 14, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1036\n assert candidate(rating = [100, 200, 150, 300, 50, 400, 250, 350, 10, 20]) == 35\n"}, "metadata": {"canonical_parameter_names": ["rating"], "leetcode_dataset_entry_point": "Solution().numTeams", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numTeams(vector& rating) {", "container": "Solution", "callable": "numTeams", "parameters": [{"name": "rating", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1397, "task_id": "find-all-good-strings", "difficulty": "Hard", "problem_description": "Given the strings s1 and s2 of size n and the string evil, return the number of good strings.\nA good string has size n, it is alphabetically greater than or equal to s1, it is alphabetically smaller than or equal to s2, and it does not contain the string evil as a substring. Since the answer can be a huge number, return this modulo 109 + 7.\n \nExample 1:\n\nInput: n = 2, s1 = \"aa\", s2 = \"da\", evil = \"b\"\nOutput: 51 \nExplanation: There are 25 good strings starting with 'a': \"aa\",\"ac\",\"ad\",...,\"az\". Then there are 25 good strings starting with 'c': \"ca\",\"cc\",\"cd\",...,\"cz\" and finally there is one good string starting with 'd': \"da\". \n\nExample 2:\n\nInput: n = 8, s1 = \"leetcode\", s2 = \"leetgoes\", evil = \"leet\"\nOutput: 0 \nExplanation: All strings greater than or equal to s1 and smaller than or equal to s2 start with the prefix \"leet\", therefore, there is not any good string.\n\nExample 3:\n\nInput: n = 2, s1 = \"gx\", s2 = \"gz\", evil = \"x\"\nOutput: 2\n\n \nConstraints:\n\ns1.length == n\ns2.length == n\ns1 <= s2\n1 <= n <= 500\n1 <= evil.length <= 50\nAll strings consist of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,s1 = \"apple\",s2 = \"zebra\",evil = \"app\") == 11220078\n assert candidate(n = 5,s1 = \"apple\",s2 = \"appla\",evil = \"appl\") == 0\n assert candidate(n = 3,s1 = \"aaa\",s2 = \"zzz\",evil = \"abc\") == 17575\n assert candidate(n = 5,s1 = \"aaaaa\",s2 = \"zzzzz\",evil = \"abc\") == 11879348\n assert candidate(n = 10,s1 = \"abcdefghij\",s2 = \"abcdefghij\",evil = \"ghij\") == 0\n assert candidate(n = 5,s1 = \"apple\",s2 = \"zebra\",evil = \"dog\") == 11219789\n assert candidate(n = 2,s1 = \"gx\",s2 = \"gz\",evil = \"x\") == 2\n assert candidate(n = 3,s1 = \"abc\",s2 = \"xyz\",evil = \"def\") == 16169\n assert candidate(n = 8,s1 = \"leetcode\",s2 = \"leetgoes\",evil = \"leet\") == 0\n assert candidate(n = 3,s1 = \"aaa\",s2 = \"zzz\",evil = \"xyz\") == 17575\n assert candidate(n = 2,s1 = \"aa\",s2 = \"da\",evil = \"b\") == 51\n assert candidate(n = 3,s1 = \"abc\",s2 = \"xyz\",evil = \"de\") == 16120\n assert candidate(n = 10,s1 = \"aaaaaaaaaa\",s2 = \"zzzzzzzzzz\",evil = \"mnop\") == 932258852\n assert candidate(n = 10,s1 = \"abcdefghij\",s2 = \"zzzzzzzzzz\",evil = \"mnop\") == 67339166\n assert candidate(n = 25,s1 = \"abcdefghijklmnopqrstuvwxyz\",s2 = \"abcdefghijklmnopqrstuvwxyz\",evil = \"abcde\") == 0\n assert candidate(n = 45,s1 = \"abcdefghijklmnopqrstuvwxyzabcdefghij\",s2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",evil = \"mnopqr\") == 720631236\n assert candidate(n = 6,s1 = \"aaaaaa\",s2 = \"zzzzzz\",evil = \"ab\") == 306634951\n assert candidate(n = 20,s1 = \"aaabaaabaaabaaabaa\",s2 = \"zzzzzzzzzzzzzzzzzzzz\",evil = \"aaa\") == 357553640\n assert candidate(n = 35,s1 = \"applepieapplepieapplepieapplepie\",s2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",evil = \"apple\") == 695022504\n assert candidate(n = 7,s1 = \"aaaaaaa\",s2 = \"zzzzzzz\",evil = \"abc\") == 29525318\n assert candidate(n = 20,s1 = \"abcdabcdabcdabcdabcd\",s2 = \"zzzzzzzzzzzzzzzzzzzz\",evil = \"zabcd\") == 426896930\n assert candidate(n = 10,s1 = \"abcdefghij\",s2 = \"abcdefghiz\",evil = \"ghi\") == 0\n assert candidate(n = 15,s1 = \"abcdefghijklnmop\",s2 = \"abcdefghijklnmopqrstuvwxyz\",evil = \"mnop\") == 1\n assert candidate(n = 30,s1 = \"abcdefghijklmnopqrstuvwxyzabcde\",s2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",evil = \"vwxyz\") == 858527385\n assert candidate(n = 50,s1 = \"leetcodeleetcodeleetcodeleetcodeleetcode\",s2 = \"leetgoesleetgoesleetgoesleetgoesleetgoes\",evil = \"leet\") == 0\n assert candidate(n = 40,s1 = \"aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxxyyyzzz\",s2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",evil = \"mnopqr\") == 438601268\n assert candidate(n = 10,s1 = \"abcdefghij\",s2 = \"zjklmnopqr\",evil = \"mnop\") == 922212598\n assert candidate(n = 40,s1 = \"abcdefghijabcdefghijabcdefghijabcdefghij\",s2 = \"zjklmnopqrzjklmnopqrzjklmnopqrzjklmnopqr\",evil = \"mnopqr\") == 54391096\n assert candidate(n = 5,s1 = \"aaaaa\",s2 = \"zzzzz\",evil = \"b\") == 9765625\n"}, "metadata": {"canonical_parameter_names": ["n", "s1", "s2", "evil"], "leetcode_dataset_entry_point": "Solution().findGoodStrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int findGoodStrings(int n, string s1, string s2, string evil) {", "container": "Solution", "callable": "findGoodStrings", "parameters": [{"name": "n", "type": "int"}, {"name": "s1", "type": "string"}, {"name": "s2", "type": "string"}, {"name": "evil", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1399, "task_id": "count-largest-group", "difficulty": "Easy", "problem_description": "You are given an integer n.\nEach number from 1 to n is grouped according to the sum of its digits.\nReturn the number of groups that have the largest size.\n \nExample 1:\n\nInput: n = 13\nOutput: 4\nExplanation: There are 9 groups in total, they are grouped according sum of its digits of numbers from 1 to 13:\n[1,10], [2,11], [3,12], [4,13], [5], [6], [7], [8], [9].\nThere are 4 groups with largest size.\n\nExample 2:\n\nInput: n = 2\nOutput: 2\nExplanation: There are 2 groups [1], [2] of size 1.\n\n \nConstraints:\n\n1 <= n <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 200) == 2\n assert candidate(n = 10000) == 1\n assert candidate(n = 9) == 9\n assert candidate(n = 104) == 1\n assert candidate(n = 9999) == 1\n assert candidate(n = 2) == 2\n assert candidate(n = 100) == 1\n assert candidate(n = 1000) == 2\n assert candidate(n = 13) == 4\n assert candidate(n = 25) == 6\n assert candidate(n = 4000) == 1\n assert candidate(n = 2345) == 1\n assert candidate(n = 1111) == 1\n assert candidate(n = 7000) == 2\n assert candidate(n = 4096) == 1\n assert candidate(n = 7500) == 1\n assert candidate(n = 4567) == 1\n assert candidate(n = 2000) == 1\n assert candidate(n = 111) == 1\n assert candidate(n = 8888) == 1\n assert candidate(n = 300) == 1\n assert candidate(n = 333) == 2\n assert candidate(n = 3000) == 2\n assert candidate(n = 99) == 1\n assert candidate(n = 888) == 1\n assert candidate(n = 1024) == 2\n assert candidate(n = 8192) == 1\n assert candidate(n = 999) == 2\n assert candidate(n = 5555) == 1\n assert candidate(n = 8000) == 1\n assert candidate(n = 5000) == 2\n assert candidate(n = 6543) == 1\n assert candidate(n = 7865) == 1\n assert candidate(n = 7777) == 1\n assert candidate(n = 2222) == 1\n assert candidate(n = 2500) == 1\n assert candidate(n = 9000) == 2\n assert candidate(n = 4999) == 2\n assert candidate(n = 3999) == 1\n assert candidate(n = 1234) == 1\n assert candidate(n = 6000) == 1\n assert candidate(n = 1) == 1\n assert candidate(n = 500) == 1\n assert candidate(n = 10) == 1\n assert candidate(n = 1500) == 1\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().countLargestGroup", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countLargestGroup(int n) {", "container": "Solution", "callable": "countLargestGroup", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1400, "task_id": "construct-k-palindrome-strings", "difficulty": "Medium", "problem_description": "Given a string s and an integer k, return true if you can use all the characters in s to construct non-empty k palindrome strings or false otherwise.\n \nExample 1:\n\nInput: s = \"annabelle\", k = 2\nOutput: true\nExplanation: You can construct two palindromes using all characters in s.\nSome possible constructions \"anna\" + \"elble\", \"anbna\" + \"elle\", \"anellena\" + \"b\"\n\nExample 2:\n\nInput: s = \"leetcode\", k = 3\nOutput: false\nExplanation: It is impossible to construct 3 palindromes using all the characters of s.\n\nExample 3:\n\nInput: s = \"true\", k = 4\nOutput: true\nExplanation: The only possible solution is to put each character in a separate string.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists of lowercase English letters.\n1 <= k <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"a\",k = 2) == False\n assert candidate(s = \"aabbcc\",k = 3) == True\n assert candidate(s = \"abcd\",k = 2) == False\n assert candidate(s = \"yzyzyzyzyzyzyzy\",k = 17) == False\n assert candidate(s = \"\",k = 0) == True\n assert candidate(s = \"true\",k = 4) == True\n assert candidate(s = \"aaaaa\",k = 2) == True\n assert candidate(s = \"racecar\",k = 1) == True\n assert candidate(s = \"abcd\",k = 1) == False\n assert candidate(s = \"abacabadabacaba\",k = 7) == True\n assert candidate(s = \"yzyzyzyzyzyzyzy\",k = 2) == True\n assert candidate(s = \"aabbcc\",k = 6) == True\n assert candidate(s = \"annabelle\",k = 2) == True\n assert candidate(s = \"aabbc\",k = 4) == True\n assert candidate(s = \"leetcode\",k = 3) == False\n assert candidate(s = \"aabbccddeeffgghh\",k = 8) == True\n assert candidate(s = \"aaa\",k = 3) == True\n assert candidate(s = \"z\",k = 1) == True\n assert candidate(s = \"abcabcabc\",k = 3) == True\n assert candidate(s = \"aaaaaa\",k = 1) == True\n assert candidate(s = \"a\",k = 1) == True\n assert candidate(s = \"aabb\",k = 2) == True\n assert candidate(s = \"aabbcc\",k = 1) == True\n assert candidate(s = \"abcd\",k = 4) == True\n assert candidate(s = \"aabbc\",k = 3) == True\n assert candidate(s = \"palindrome\",k = 2) == False\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",k = 50) == True\n assert candidate(s = \"mississippi\",k = 4) == True\n assert candidate(s = \"abacabadabacabadabacabad\",k = 10) == True\n assert candidate(s = \"racecar\",k = 5) == True\n assert candidate(s = \"aaabbbccc\",k = 5) == True\n assert candidate(s = \"zyxzyxzyx\",k = 3) == True\n assert candidate(s = \"palindromicracecar\",k = 7) == False\n assert candidate(s = \"level\",k = 1) == True\n assert candidate(s = \"mamad\",k = 3) == True\n assert candidate(s = \"ababababab\",k = 5) == True\n assert candidate(s = \"amanaplanacanalpanama\",k = 13) == True\n assert candidate(s = \"aabbccddeeffgg\",k = 8) == True\n assert candidate(s = \"aabbccddeeffgghhiijj\",k = 10) == True\n assert candidate(s = \"aabaaaacaabbaaaacaaba\",k = 15) == True\n assert candidate(s = \"aabbccddeeefff\",k = 6) == True\n assert candidate(s = \"abcdefghij\",k = 10) == True\n assert candidate(s = \"aabaaa\",k = 3) == True\n assert candidate(s = \"xyxxyxyxyxyxyx\",k = 7) == True\n assert candidate(s = \"palindrome\",k = 5) == False\n assert candidate(s = \"racecarannakayak\",k = 5) == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 20) == True\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\",k = 16) == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 1) == True\n assert candidate(s = \"noonnoonnoon\",k = 3) == True\n assert candidate(s = \"ababababababababababababababababababababababababababababababababababab\",k = 100) == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 26) == True\n assert candidate(s = \"bananaananabananaananabanana\",k = 12) == True\n assert candidate(s = \"mississippi\",k = 5) == True\n assert candidate(s = \"neupq\",k = 5) == True\n assert candidate(s = \"babbabababababa\",k = 11) == True\n assert candidate(s = \"abcabcabcabcabcabc\",k = 9) == True\n assert candidate(s = \"aaaaaaaaaa\",k = 10) == True\n assert candidate(s = \"noonnoonnoon\",k = 6) == True\n assert candidate(s = \"racecarannakayak\",k = 3) == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 52) == True\n assert candidate(s = \"abcabcabc\",k = 9) == True\n assert candidate(s = \"banana\",k = 3) == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 10) == True\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",k = 26) == True\n assert candidate(s = \"thisisaverylongstringwithvariouscharacters\",k = 20) == True\n assert candidate(s = \"noon\",k = 2) == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",k = 1) == True\n assert candidate(s = \"palindrome\",k = 6) == False\n assert candidate(s = \"mississippiissim\",k = 6) == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 100) == False\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 1) == True\n assert candidate(s = \"abcdabcdeabcdabcdef\",k = 7) == True\n assert candidate(s = \"abababababababababababababab\",k = 12) == True\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",k = 20) == True\n assert candidate(s = \"abcdabcdabcdabcd\",k = 8) == True\n assert candidate(s = \"aabbccccddeeeeffff\",k = 7) == True\n assert candidate(s = \"xyzzycba\",k = 6) == True\n assert candidate(s = \"aabbccddeeffgg\",k = 14) == True\n assert candidate(s = \"noonmoon\",k = 2) == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 30) == True\n assert candidate(s = \"racecarr\",k = 2) == True\n assert candidate(s = \"aabaaabbbbccccddddd\",k = 11) == True\n assert candidate(s = \"zzzzzzyyyyxxxwwvvuuttssrrqqppoonnmmllkkjjiihhhgggffeeddccbbaa\",k = 26) == True\n assert candidate(s = \"abracadabra\",k = 5) == True\n assert candidate(s = \"abababababababababababababababababababababab\",k = 20) == True\n assert candidate(s = \"mammamia\",k = 2) == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 100) == False\n assert candidate(s = \"zyxzyxzyxzyx\",k = 12) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 1) == False\n assert candidate(s = \"abcdabcdbabcdbcdbabcdabcdabcd\",k = 10) == True\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\",k = 26) == True\n assert candidate(s = \"aaabbbcccdddeeefffggghhhhiiiiiijjjjjjjkkkkkkkkkllllllllll\",k = 25) == True\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",k = 10) == True\n assert candidate(s = \"thisisaverylongstringwithsomerepeatedcharacters\",k = 15) == True\n assert candidate(s = \"aabbbccccdddddeeeeeffffffgggggghhhhhiiiiijjjjjkkkkklllllm\",k = 14) == True\n assert candidate(s = \"xyzxyzxyz\",k = 9) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 26) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzaaa\",k = 27) == True\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 26) == True\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().canConstruct", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool canConstruct(string s, int k) {", "container": "Solution", "callable": "canConstruct", "parameters": [{"name": "s", "type": "string"}, {"name": "k", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1401, "task_id": "circle-and-rectangle-overlapping", "difficulty": "Medium", "problem_description": "You are given a circle represented as (radius, xCenter, yCenter) and an axis-aligned rectangle represented as (x1, y1, x2, y2), where (x1, y1) are the coordinates of the bottom-left corner, and (x2, y2) are the coordinates of the top-right corner of the rectangle.\nReturn true if the circle and rectangle are overlapped otherwise return false. In other words, check if there is any point (xi, yi) that belongs to the circle and the rectangle at the same time.\n \nExample 1:\n\n\nInput: radius = 1, xCenter = 0, yCenter = 0, x1 = 1, y1 = -1, x2 = 3, y2 = 1\nOutput: true\nExplanation: Circle and rectangle share the point (1,0).\n\nExample 2:\n\nInput: radius = 1, xCenter = 1, yCenter = 1, x1 = 1, y1 = -3, x2 = 2, y2 = -1\nOutput: false\n\nExample 3:\n\n\nInput: radius = 1, xCenter = 0, yCenter = 0, x1 = -1, y1 = 0, x2 = 0, y2 = 1\nOutput: true\n\n \nConstraints:\n\n1 <= radius <= 2000\n-104 <= xCenter, yCenter <= 104\n-104 <= x1 < x2 <= 104\n-104 <= y1 < y2 <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(radius = 3,xCenter = -3,yCenter = -4,x1 = -6,y1 = -6,x2 = -2,y2 = -2) == True\n assert candidate(radius = 2,xCenter = -2,yCenter = -2,x1 = -5,y1 = -5,x2 = -3,y2 = -3) == True\n assert candidate(radius = 5,xCenter = 0,yCenter = 0,x1 = -5,y1 = -5,x2 = 5,y2 = 5) == True\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = 1,y1 = -1,x2 = 3,y2 = 1) == True\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = -1,y1 = 0,x2 = 0,y2 = 1) == True\n assert candidate(radius = 2,xCenter = 3,yCenter = 4,x1 = 0,y1 = 0,x2 = 2,y2 = 2) == False\n assert candidate(radius = 3,xCenter = -3,yCenter = 4,x1 = -5,y1 = 1,x2 = -1,y2 = 8) == True\n assert candidate(radius = 2,xCenter = -2,yCenter = -2,x1 = -4,y1 = -4,x2 = 0,y2 = 0) == True\n assert candidate(radius = 1,xCenter = 1,yCenter = 1,x1 = 1,y1 = -3,x2 = 2,y2 = -1) == False\n assert candidate(radius = 5,xCenter = 5,yCenter = 5,x1 = 0,y1 = 0,x2 = 10,y2 = 10) == True\n assert candidate(radius = 15,xCenter = -10,yCenter = -10,x1 = -20,y1 = -20,x2 = -5,y2 = -5) == True\n assert candidate(radius = 8,xCenter = -20,yCenter = -20,x1 = -25,y1 = -25,x2 = -15,y2 = -15) == True\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = -1,y1 = -1,x2 = 1,y2 = 1) == True\n assert candidate(radius = 25,xCenter = -30,yCenter = 30,x1 = -50,y1 = 10,x2 = -10,y2 = 50) == True\n assert candidate(radius = 100,xCenter = 1000,yCenter = 1000,x1 = 900,y1 = 900,x2 = 1050,y2 = 1050) == True\n assert candidate(radius = 4,xCenter = 1,yCenter = 1,x1 = -2,y1 = -2,x2 = 2,y2 = 2) == True\n assert candidate(radius = 3,xCenter = 0,yCenter = 0,x1 = -3,y1 = -3,x2 = 3,y2 = 3) == True\n assert candidate(radius = 1,xCenter = 10,yCenter = 10,x1 = 11,y1 = 11,x2 = 13,y2 = 13) == False\n assert candidate(radius = 1,xCenter = -4,yCenter = -4,x1 = -5,y1 = -5,x2 = -3,y2 = -3) == True\n assert candidate(radius = 20,xCenter = 50,yCenter = 50,x1 = 20,y1 = 20,x2 = 80,y2 = 80) == True\n assert candidate(radius = 7,xCenter = 2500,yCenter = -2500,x1 = 2490,y1 = -2510,x2 = 2510,y2 = -2490) == True\n assert candidate(radius = 12,xCenter = 18,yCenter = 18,x1 = 10,y1 = 10,x2 = 26,y2 = 26) == True\n assert candidate(radius = 10,xCenter = 0,yCenter = 0,x1 = -20,y1 = -20,x2 = 20,y2 = 20) == True\n assert candidate(radius = 1,xCenter = -10000,yCenter = -10000,x1 = -10001,y1 = -10001,x2 = -9999,y2 = -9999) == True\n assert candidate(radius = 7,xCenter = 0,yCenter = 0,x1 = -8,y1 = -8,x2 = 8,y2 = 8) == True\n assert candidate(radius = 1,xCenter = 2,yCenter = 3,x1 = 1,y1 = 2,x2 = 3,y2 = 4) == True\n assert candidate(radius = 9,xCenter = 0,yCenter = -1,x1 = -5,y1 = -10,x2 = 5,y2 = -5) == True\n assert candidate(radius = 15,xCenter = 25,yCenter = -25,x1 = 15,y1 = -35,x2 = 35,y2 = -15) == True\n assert candidate(radius = 4,xCenter = 10,yCenter = 10,x1 = 5,y1 = 5,x2 = 15,y2 = 15) == True\n assert candidate(radius = 10,xCenter = -15,yCenter = -15,x1 = -25,y1 = -25,x2 = -5,y2 = -5) == True\n assert candidate(radius = 1000,xCenter = 10000,yCenter = 10000,x1 = 9999,y1 = 9999,x2 = 10001,y2 = 10001) == True\n assert candidate(radius = 2,xCenter = 3,yCenter = 4,x1 = 2,y1 = 3,x2 = 4,y2 = 5) == True\n assert candidate(radius = 1,xCenter = 5,yCenter = 0,x1 = 4,y1 = -1,x2 = 6,y2 = 1) == True\n assert candidate(radius = 12,xCenter = -200,yCenter = 200,x1 = -220,y1 = 180,x2 = -180,y2 = 220) == True\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = -1,y1 = -1,x2 = 0,y2 = 0) == True\n assert candidate(radius = 100,xCenter = -500,yCenter = 500,x1 = -600,y1 = 400,x2 = -400,y2 = 600) == True\n assert candidate(radius = 4,xCenter = 0,yCenter = 0,x1 = 4,y1 = 4,x2 = 5,y2 = 5) == False\n assert candidate(radius = 10,xCenter = -10,yCenter = -10,x1 = -20,y1 = -20,x2 = 0,y2 = 0) == True\n assert candidate(radius = 2000,xCenter = -10000,yCenter = -10000,x1 = -10001,y1 = -10001,x2 = -9999,y2 = -9999) == True\n assert candidate(radius = 10,xCenter = 0,yCenter = 0,x1 = -5,y1 = -5,x2 = 5,y2 = 5) == True\n assert candidate(radius = 9,xCenter = 15,yCenter = 15,x1 = 10,y1 = 10,x2 = 20,y2 = 20) == True\n assert candidate(radius = 10,xCenter = 0,yCenter = 0,x1 = -10,y1 = -10,x2 = 10,y2 = 10) == True\n assert candidate(radius = 6,xCenter = -5,yCenter = 5,x1 = -10,y1 = 0,x2 = 0,y2 = 10) == True\n assert candidate(radius = 2,xCenter = 5,yCenter = 5,x1 = 3,y1 = 3,x2 = 7,y2 = 7) == True\n assert candidate(radius = 10,xCenter = 10000,yCenter = 10000,x1 = 9990,y1 = 9990,x2 = 10010,y2 = 10010) == True\n assert candidate(radius = 2000,xCenter = 0,yCenter = 0,x1 = -2001,y1 = -2001,x2 = 2001,y2 = 2001) == True\n assert candidate(radius = 3,xCenter = 10,yCenter = 10,x1 = 5,y1 = 5,x2 = 15,y2 = 15) == True\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = 2,y1 = 2,x2 = 3,y2 = 3) == False\n assert candidate(radius = 500,xCenter = 5000,yCenter = 5000,x1 = 4500,y1 = 4500,x2 = 5500,y2 = 5500) == True\n assert candidate(radius = 2,xCenter = -100,yCenter = 100,x1 = -110,y1 = 90,x2 = -90,y2 = 110) == True\n assert candidate(radius = 4,xCenter = -10,yCenter = 10,x1 = -15,y1 = 5,x2 = -5,y2 = 15) == True\n assert candidate(radius = 1,xCenter = 500,yCenter = 500,x1 = 499,y1 = 499,x2 = 501,y2 = 501) == True\n assert candidate(radius = 10,xCenter = -10000,yCenter = 10000,x1 = -10010,y1 = 9990,x2 = -9990,y2 = 10010) == True\n assert candidate(radius = 20,xCenter = 0,yCenter = 0,x1 = -30,y1 = -30,x2 = 30,y2 = 30) == True\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = -2,y1 = -2,x2 = -1,y2 = -1) == False\n assert candidate(radius = 2,xCenter = 0,yCenter = 0,x1 = 0,y1 = 0,x2 = 4,y2 = 4) == True\n assert candidate(radius = 1,xCenter = 10000,yCenter = 10000,x1 = 9999,y1 = 9999,x2 = 10001,y2 = 10001) == True\n assert candidate(radius = 10,xCenter = 20,yCenter = 20,x1 = 15,y1 = 15,x2 = 25,y2 = 25) == True\n assert candidate(radius = 2,xCenter = -6,yCenter = -6,x1 = -10,y1 = -10,x2 = -5,y2 = -5) == True\n assert candidate(radius = 12,xCenter = 0,yCenter = 0,x1 = -10,y1 = -10,x2 = 10,y2 = 10) == True\n assert candidate(radius = 1,xCenter = -10,yCenter = -10,x1 = -13,y1 = -13,x2 = -11,y2 = -11) == False\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = 1,y1 = 1,x2 = 2,y2 = 2) == False\n assert candidate(radius = 6,xCenter = -2,yCenter = 4,x1 = -6,y1 = 0,x2 = 0,y2 = 6) == True\n assert candidate(radius = 5,xCenter = 25,yCenter = 25,x1 = 20,y1 = 20,x2 = 30,y2 = 30) == True\n assert candidate(radius = 15,xCenter = 15,yCenter = 15,x1 = 20,y1 = 20,x2 = 30,y2 = 30) == True\n assert candidate(radius = 2,xCenter = -2,yCenter = -3,x1 = -4,y1 = -5,x2 = -3,y2 = -4) == True\n assert candidate(radius = 2000,xCenter = 0,yCenter = 0,x1 = -10000,y1 = -10000,x2 = 10000,y2 = 10000) == True\n assert candidate(radius = 8,xCenter = 12,yCenter = 12,x1 = 8,y1 = 8,x2 = 16,y2 = 16) == True\n assert candidate(radius = 15,xCenter = -10,yCenter = 10,x1 = -20,y1 = -10,x2 = 0,y2 = 10) == True\n assert candidate(radius = 300,xCenter = -750,yCenter = 750,x1 = -1000,y1 = 500,x2 = -500,y2 = 1000) == True\n assert candidate(radius = 3,xCenter = 20,yCenter = -20,x1 = 15,y1 = -25,x2 = 25,y2 = -15) == True\n assert candidate(radius = 15,xCenter = 50,yCenter = 50,x1 = 40,y1 = 40,x2 = 60,y2 = 60) == True\n assert candidate(radius = 2000,xCenter = 5000,yCenter = 5000,x1 = 0,y1 = 0,x2 = 10000,y2 = 10000) == True\n assert candidate(radius = 5,xCenter = 10,yCenter = 10,x1 = 5,y1 = 5,x2 = 15,y2 = 15) == True\n assert candidate(radius = 4,xCenter = -4,yCenter = -4,x1 = -6,y1 = -6,x2 = -2,y2 = -2) == True\n assert candidate(radius = 15,xCenter = 15,yCenter = 15,x1 = 10,y1 = 10,x2 = 20,y2 = 20) == True\n assert candidate(radius = 3,xCenter = -3,yCenter = 3,x1 = -6,y1 = 0,x2 = 0,y2 = 6) == True\n assert candidate(radius = 1,xCenter = 10000,yCenter = -10000,x1 = 9999,y1 = -10001,x2 = 10001,y2 = -9999) == True\n assert candidate(radius = 8,xCenter = 100,yCenter = -100,x1 = 90,y1 = -110,x2 = 110,y2 = -90) == True\n assert candidate(radius = 2000,xCenter = 0,yCenter = 0,x1 = -3000,y1 = -3000,x2 = 3000,y2 = 3000) == True\n assert candidate(radius = 10,xCenter = 5,yCenter = 5,x1 = 0,y1 = 0,x2 = 10,y2 = 10) == True\n assert candidate(radius = 1500,xCenter = 5000,yCenter = 5000,x1 = 4500,y1 = 4500,x2 = 5500,y2 = 5500) == True\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = 0,y1 = 0,x2 = 2,y2 = 2) == True\n assert candidate(radius = 7,xCenter = -5,yCenter = 5,x1 = -10,y1 = 0,x2 = -2,y2 = 10) == True\n assert candidate(radius = 4,xCenter = -5,yCenter = 5,x1 = -10,y1 = 0,x2 = 0,y2 = 10) == True\n assert candidate(radius = 10,xCenter = -5,yCenter = -5,x1 = 5,y1 = 5,x2 = 15,y2 = 15) == False\n assert candidate(radius = 500,xCenter = 2500,yCenter = -2500,x1 = 2000,y1 = -3000,x2 = 3000,y2 = -2000) == True\n assert candidate(radius = 5,xCenter = 1,yCenter = 1,x1 = -3,y1 = -3,x2 = 3,y2 = 3) == True\n assert candidate(radius = 2000,xCenter = 1000,yCenter = 1000,x1 = 900,y1 = 900,x2 = 1100,y2 = 1100) == True\n assert candidate(radius = 150,xCenter = 0,yCenter = 0,x1 = -200,y1 = -200,x2 = 200,y2 = 200) == True\n assert candidate(radius = 6,xCenter = -15,yCenter = -15,x1 = -20,y1 = -20,x2 = -10,y2 = -10) == True\n assert candidate(radius = 4,xCenter = 2,yCenter = 2,x1 = -1,y1 = -1,x2 = 3,y2 = 3) == True\n assert candidate(radius = 2,xCenter = 100,yCenter = 100,x1 = 101,y1 = 101,x2 = 103,y2 = 103) == True\n assert candidate(radius = 3,xCenter = 5,yCenter = 5,x1 = 8,y1 = 8,x2 = 12,y2 = 12) == False\n assert candidate(radius = 5,xCenter = -10,yCenter = -10,x1 = -15,y1 = -15,x2 = -5,y2 = -5) == True\n assert candidate(radius = 2,xCenter = 2,yCenter = 2,x1 = 1,y1 = 1,x2 = 3,y2 = 3) == True\n assert candidate(radius = 1,xCenter = 2,yCenter = 2,x1 = 3,y1 = 3,x2 = 5,y2 = 5) == False\n assert candidate(radius = 2,xCenter = -5,yCenter = -5,x1 = -10,y1 = -10,x2 = -2,y2 = -2) == True\n assert candidate(radius = 7,xCenter = -5,yCenter = -5,x1 = -10,y1 = -10,x2 = -2,y2 = -2) == True\n assert candidate(radius = 15,xCenter = -100,yCenter = -100,x1 = -120,y1 = -120,x2 = -80,y2 = -80) == True\n assert candidate(radius = 8,xCenter = 10,yCenter = -10,x1 = 5,y1 = -15,x2 = 15,y2 = -5) == True\n assert candidate(radius = 20,xCenter = -30,yCenter = 30,x1 = -40,y1 = 20,x2 = -20,y2 = 40) == True\n assert candidate(radius = 5,xCenter = -10000,yCenter = 10000,x1 = -10010,y1 = 9990,x2 = -9990,y2 = 10010) == True\n assert candidate(radius = 2,xCenter = 6,yCenter = 6,x1 = 0,y1 = 0,x2 = 5,y2 = 5) == True\n assert candidate(radius = 15,xCenter = -10,yCenter = 10,x1 = -20,y1 = -20,x2 = 0,y2 = 0) == True\n assert candidate(radius = 7,xCenter = 5,yCenter = -5,x1 = 0,y1 = -10,x2 = 10,y2 = 0) == True\n assert candidate(radius = 2,xCenter = 0,yCenter = 0,x1 = -3,y1 = -3,x2 = -2,y2 = -2) == False\n assert candidate(radius = 7,xCenter = 3,yCenter = -3,x1 = 1,y1 = -5,x2 = 5,y2 = -1) == True\n assert candidate(radius = 5,xCenter = 0,yCenter = 0,x1 = -10,y1 = -10,x2 = 10,y2 = 10) == True\n assert candidate(radius = 10,xCenter = 0,yCenter = 0,x1 = -15,y1 = -15,x2 = 15,y2 = 15) == True\n assert candidate(radius = 1,xCenter = 0,yCenter = 0,x1 = 1,y1 = 0,x2 = 2,y2 = 1) == True\n assert candidate(radius = 2000,xCenter = -5000,yCenter = -5000,x1 = -10000,y1 = -10000,x2 = 0,y2 = 0) == True\n assert candidate(radius = 4,xCenter = 15,yCenter = 15,x1 = 10,y1 = 10,x2 = 20,y2 = 20) == True\n assert candidate(radius = 50,xCenter = -100,yCenter = 100,x1 = -150,y1 = 50,x2 = -50,y2 = 150) == True\n"}, "metadata": {"canonical_parameter_names": ["radius", "xCenter", "yCenter", "x1", "y1", "x2", "y2"], "leetcode_dataset_entry_point": "Solution().checkOverlap", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool checkOverlap(int radius, int xCenter, int yCenter, int x1, int y1, int x2, int y2) {", "container": "Solution", "callable": "checkOverlap", "parameters": [{"name": "radius", "type": "int"}, {"name": "xCenter", "type": "int"}, {"name": "yCenter", "type": "int"}, {"name": "x1", "type": "int"}, {"name": "y1", "type": "int"}, {"name": "x2", "type": "int"}, {"name": "y2", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1402, "task_id": "reducing-dishes", "difficulty": "Hard", "problem_description": "A chef has collected data on the satisfaction level of his n dishes. Chef can cook any dish in 1 unit of time.\nLike-time coefficient of a dish is defined as the time taken to cook that dish including previous dishes multiplied by its satisfaction level i.e. time[i] * satisfaction[i].\nReturn the maximum sum of like-time coefficient that the chef can obtain after preparing some amount of dishes.\nDishes can be prepared in any order and the chef can discard some dishes to get this maximum value.\n \nExample 1:\n\nInput: satisfaction = [-1,-8,0,5,-9]\nOutput: 14\nExplanation: After Removing the second and last dish, the maximum total like-time coefficient will be equal to (-1*1 + 0*2 + 5*3 = 14).\nEach dish is prepared in one unit of time.\nExample 2:\n\nInput: satisfaction = [4,3,2]\nOutput: 20\nExplanation: Dishes can be prepared in any order, (2*1 + 3*2 + 4*3 = 20)\n\nExample 3:\n\nInput: satisfaction = [-1,-4,-5]\nOutput: 0\nExplanation: People do not like the dishes. No dish is prepared.\n\n \nConstraints:\n\nn == satisfaction.length\n1 <= n <= 500\n-1000 <= satisfaction[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(satisfaction = [1, -1, 2, -2, 3, -3]) == 22\n assert candidate(satisfaction = [0]) == 0\n assert candidate(satisfaction = [-1]) == 0\n assert candidate(satisfaction = [-500, -500, -500, -500, -500]) == 0\n assert candidate(satisfaction = [0, 0, 0, 0, 0]) == 0\n assert candidate(satisfaction = [-1000, 1000, -500, 500]) == 3500\n assert candidate(satisfaction = [0, 0, 0, 0]) == 0\n assert candidate(satisfaction = [1000, -1000, 1000, -1000, 1000]) == 9000\n assert candidate(satisfaction = [-1, -8, 0, 5, -9]) == 14\n assert candidate(satisfaction = [-10, -20, -30, 10, 20, 30]) == 220\n assert candidate(satisfaction = [1, 2, 3, 4, 5]) == 55\n assert candidate(satisfaction = [100, 200, 300, 400, 500]) == 5500\n assert candidate(satisfaction = [-10, -20, -30, -40, -50]) == 0\n assert candidate(satisfaction = [4, 3, 2]) == 20\n assert candidate(satisfaction = [500, 500, 500, 500, 500]) == 7500\n assert candidate(satisfaction = [-1000, 1000]) == 1000\n assert candidate(satisfaction = [-1, -4, -5]) == 0\n assert candidate(satisfaction = [-5, -4, -3, -2, -1]) == 0\n assert candidate(satisfaction = [-500, -400, -300, -200, -100]) == 0\n assert candidate(satisfaction = [1000, -1000, 1000, -1000, 1000]) == 9000\n assert candidate(satisfaction = [1]) == 1\n assert candidate(satisfaction = [-1, 1, -2, 2, -3, 3]) == 22\n assert candidate(satisfaction = [1000, -1000, 1000, -1000]) == 4000\n assert candidate(satisfaction = [5, -1, 3, 2, -2, 1]) == 52\n assert candidate(satisfaction = [10, 9, 8, 7, 6, 5, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 415\n assert candidate(satisfaction = [100, -90, 50, -40, 30, -20, 10, -5, 0]) == 1320\n assert candidate(satisfaction = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 13600\n assert candidate(satisfaction = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 715\n assert candidate(satisfaction = [-500, -499, -498, -497, -496, -495, -494, -493, -492, -491, -490, -489, -488, -487, -486]) == 0\n assert candidate(satisfaction = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 155\n assert candidate(satisfaction = [999, -999, 998, -998, 997, -997, 996, -996, 995, -995]) == 24945\n assert candidate(satisfaction = [999, 1000, 998, -1000, 500, 499, 501, -499, -501, 0, 1, -1, 2, -2, 3, -3]) == 59488\n assert candidate(satisfaction = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9]) == 525\n assert candidate(satisfaction = [-1, -2, -3, 4, 5, 6, 7, 8]) == 180\n assert candidate(satisfaction = [-1, 0, 1, -2, 2, -3, 3, -4, 4, -5, 5]) == 110\n assert candidate(satisfaction = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, 1, 2, 3, 4, 5]) == 60\n assert candidate(satisfaction = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 6, 7, 8, 9, 10]) == 625\n assert candidate(satisfaction = [5, 4, 3, 2, 1, -1, -2, -3, -4, -5, 6, 7, 8, 9, 10]) == 625\n assert candidate(satisfaction = [-500, -400, -300, -200, -100, 100, 200, 300, 400, 500]) == 9500\n assert candidate(satisfaction = [-10, 0, 10, -20, 0, 20, -30, 0, 30, -40]) == 400\n assert candidate(satisfaction = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50, 60, 70, 80, 90, 100]) == 6250\n assert candidate(satisfaction = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(satisfaction = [-500, 500, -250, 250, 0, 100, -100, 150]) == 5850\n assert candidate(satisfaction = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 95\n assert candidate(satisfaction = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]) == 570\n assert candidate(satisfaction = [-10, 10, -20, 20, -30, 30, -40, 40, -50, 50]) == 950\n assert candidate(satisfaction = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == 229460\n assert candidate(satisfaction = [-100, -200, -300, 50, 100, 150, 200, 250]) == 4000\n assert candidate(satisfaction = [50, 20, -10, 0, -30, 100, -200, 300, -400, 500]) == 8040\n assert candidate(satisfaction = [-100, -200, -300, -400, 100, 200, 300, 400, 500]) == 9500\n assert candidate(satisfaction = [-1, -2, -3, -4, -5, 0, 1, 2, 3, 4, 5]) == 110\n assert candidate(satisfaction = [500, 499, 498, 497, 496, 495, 494, 493, 492, 491, 490, 489, 488, 487, 486]) == 59440\n assert candidate(satisfaction = [500, -1, -2, -3, 0, 1, 2, 3, 4, 5]) == 5105\n assert candidate(satisfaction = [-999, -998, -997, -996, 999, 998, 997, 996]) == 15970\n assert candidate(satisfaction = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5]) == 95\n assert candidate(satisfaction = [5, -5, 15, -15, 25, -25, 35, -35]) == 420\n assert candidate(satisfaction = [5, -1, 3, -2, 4, -3, 2]) == 72\n assert candidate(satisfaction = [-100, 0, 100, -200, 200, -300, 300, -400, 400, -500, 500]) == 11000\n assert candidate(satisfaction = [999, 1000, -999, -1000, 998, 997, -998, -997, 996, -996]) == 24970\n assert candidate(satisfaction = [-100, -90, -80, -70, -60, -50, -40, -30, -20, -10]) == 0\n assert candidate(satisfaction = [10, -1, 2, 5, -7, 8, -2]) == 137\n assert candidate(satisfaction = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 100\n assert candidate(satisfaction = [-5, -2, 0, 1, 3, 6]) == 46\n assert candidate(satisfaction = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, -1, -2, -3, -4, -5]) == 6565\n assert candidate(satisfaction = [-1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1]) == 36\n assert candidate(satisfaction = [-500, 500, -499, 499, -498, 498, -497, 497, -496, 496]) == 12470\n assert candidate(satisfaction = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 100\n assert candidate(satisfaction = [9, -1, -2, 3, -4, 5, -6, 7, -8, 9]) == 235\n assert candidate(satisfaction = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 950\n assert candidate(satisfaction = [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 625\n assert candidate(satisfaction = [-5, -3, -2, 1, 4, 6]) == 43\n assert candidate(satisfaction = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 0\n assert candidate(satisfaction = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 3850\n assert candidate(satisfaction = [900, 100, 200, -900, 50, -50, 300, -300, 400, -400]) == 14450\n assert candidate(satisfaction = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50]) == 950\n assert candidate(satisfaction = [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5]) == 95\n assert candidate(satisfaction = [-100, -200, -300, -400, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 385\n assert candidate(satisfaction = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6]) == 161\n assert candidate(satisfaction = [-999, -998, -997, -996, -995, 995, 996, 997, 998, 999]) == 24945\n assert candidate(satisfaction = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == 40\n assert candidate(satisfaction = [-1, 0, 1, -2, 0, 2, -3, 0, 3]) == 40\n assert candidate(satisfaction = [-5, -3, -1, 1, 3, 5]) == 35\n assert candidate(satisfaction = [-50, -50, 50, 50, -25, -25, 25, 25, -75, 75]) == 1375\n assert candidate(satisfaction = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 465\n assert candidate(satisfaction = [-10, -20, -30, -40, -50, 5, 15, 25, 35, 45]) == 775\n assert candidate(satisfaction = [-9, -8, -7, -6, -5, 1, 2, 3, 4, 5]) == 69\n assert candidate(satisfaction = [-100, -200, -300, 100, 200, 300, 400, 500]) == 9000\n assert candidate(satisfaction = [-1, -2, -3, -4, -5, 6, 7, 8, 9, 10]) == 295\n assert candidate(satisfaction = [-100, -90, -80, 70, 80, 90, 100]) == 1400\n assert candidate(satisfaction = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 0\n assert candidate(satisfaction = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == 110\n assert candidate(satisfaction = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 385\n assert candidate(satisfaction = [50, 100, 150, 200, -10, -20, -30, -40, -50, -60]) == 3940\n assert candidate(satisfaction = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 715\n assert candidate(satisfaction = [100, 100, 100, -1, -1, -1, -1, -1, -1, -1]) == 2672\n assert candidate(satisfaction = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(satisfaction = [-1000, -999, -998, -997, -996, -995, -994, -993, -992, -991, -990, -989, -988, -987, -986, -985, -984, -983, -982, -981, -980]) == 0\n assert candidate(satisfaction = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 0\n assert candidate(satisfaction = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 0\n assert candidate(satisfaction = [-1000, 1000, -999, 999, -998, 998, -997, 997, -996, 996, -995, 995, -994, 994]) == 48909\n assert candidate(satisfaction = [-1, -2, -3, 4, 5, 6]) == 67\n assert candidate(satisfaction = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16]) == 780\n assert candidate(satisfaction = [-500, 500, -400, 400, -300, 300, -200, 200, -100, 100]) == 9500\n assert candidate(satisfaction = [500, -500, 250, -250, 125, -125, 62, -62, 31, -31]) == 7092\n assert candidate(satisfaction = [-1000, -500, 0, 500, 1000, 1500, 2000]) == 28000\n assert candidate(satisfaction = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 55\n assert candidate(satisfaction = [-100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100]) == 0\n assert candidate(satisfaction = [5, 1, 3, 7, -5, -3, 2, 6, -2, 4]) == 207\n assert candidate(satisfaction = [-999, -998, -997, -996, 996, 997, 998, 999]) == 15970\n assert candidate(satisfaction = [-999, 999, -998, 998, -997, 997, -996, 996, -995, 995, -994, 994, -993, 993, -992, 992]) == 63796\n assert candidate(satisfaction = [500, -500, 400, -400, 300, -300, 200, -200, 100, -100, 0]) == 11000\n assert candidate(satisfaction = [-5, -3, -1, 2, 4, 6]) == 50\n assert candidate(satisfaction = [-999, -1000, 1000, 999, -998, 998, 0, 0, 0, 0, 0]) == 23980\n assert candidate(satisfaction = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 1240\n"}, "metadata": {"canonical_parameter_names": ["satisfaction"], "leetcode_dataset_entry_point": "Solution().maxSatisfaction", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxSatisfaction(vector& satisfaction) {", "container": "Solution", "callable": "maxSatisfaction", "parameters": [{"name": "satisfaction", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1403, "task_id": "minimum-subsequence-in-non-increasing-order", "difficulty": "Easy", "problem_description": "Given the array nums, obtain a subsequence of the array whose sum of elements is strictly greater than the sum of the non included elements in such subsequence. \nIf there are multiple solutions, return the subsequence with minimum size and if there still exist multiple solutions, return the subsequence with the maximum total sum of all its elements. A subsequence of an array can be obtained by erasing some (possibly zero) elements from the array. \nNote that the solution with the given constraints is guaranteed to be unique. Also return the answer sorted in non-increasing order.\n \nExample 1:\n\nInput: nums = [4,3,10,9,8]\nOutput: [10,9] \nExplanation: The subsequences [10,9] and [10,8] are minimal such that the sum of their elements is strictly greater than the sum of elements not included. However, the subsequence [10,9] has the maximum total sum of its elements. \n\nExample 2:\n\nInput: nums = [4,4,7,6,7]\nOutput: [7,7,6] \nExplanation: The subsequence [7,7] has the sum of its elements equal to 14 which is not strictly greater than the sum of elements not included (14 = 4 + 4 + 6). Therefore, the subsequence [7,6,7] is the minimal satisfying the conditions. Note the subsequence has to be returned in non-increasing order. \n\n \nConstraints:\n\n1 <= nums.length <= 500\n1 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [4, 4, 7, 6, 7]) == [7, 7, 6]\n assert candidate(nums = [100, 90, 80, 70, 60]) == [100, 90, 80]\n assert candidate(nums = [100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [100]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [5, 5, 5, 5, 5, 5]\n assert candidate(nums = [100, 99, 98, 97, 96]) == [100, 99, 98]\n assert candidate(nums = [4, 3, 10, 9, 8]) == [10, 9]\n assert candidate(nums = [5, 5, 5, 5, 5]) == [5, 5, 5]\n assert candidate(nums = [50, 50, 50, 50, 50]) == [50, 50, 50]\n assert candidate(nums = [5, 5, 5, 5, 5, 1]) == [5, 5, 5]\n assert candidate(nums = [1, 2, 3, 4, 5]) == [5, 4]\n assert candidate(nums = [33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 1]) == [33, 33, 33, 33, 33, 33]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [100, 90, 80, 70]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 9, 9, 8, 8, 7]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == [99, 98, 97, 96, 95]\n assert candidate(nums = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == [50, 45, 40, 35]\n assert candidate(nums = [50, 20, 10, 100, 30, 60, 40, 80, 70, 90]) == [100, 90, 80, 70]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36]\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [100, 20, 19, 18]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == [1000, 1000, 1000, 1000, 1000, 1000]\n assert candidate(nums = [100, 50, 25, 12, 6, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [100, 50]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 500]) == [500]\n assert candidate(nums = [83, 54, 43, 21, 27, 48, 85, 96, 18, 33, 62, 59, 74, 95, 29, 72, 67, 44, 37, 52, 58, 49, 60, 88, 91, 25, 76, 87, 50, 41, 38, 94, 61, 92, 26, 34, 40, 71, 80, 63, 86, 90, 30, 77, 42, 55, 82, 57, 51, 36, 97, 84, 22, 39, 45, 56, 64, 73, 69, 81, 75, 68, 46, 70, 79, 89, 23, 53, 31, 32, 65, 35, 47, 78]) == [97, 96, 95, 94, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50]) == [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [20, 19, 18, 17, 16, 15, 14]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [10, 10, 9, 9, 8, 8, 7]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256]) == [256]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71]\n assert candidate(nums = [34, 34, 23, 23, 12, 12, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [34, 34, 23, 23]\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 1]) == [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]\n assert candidate(nums = [34, 23, 12, 3, 45, 67, 89, 12, 34, 56, 78, 90, 23, 45, 67, 89]) == [90, 89, 89, 78, 67]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [100, 90, 80, 70]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [15, 14, 13, 12, 11]\n assert candidate(nums = [99, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [99, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 1, 2, 3, 4, 5]) == [100, 95, 90, 85, 80, 75, 70]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [100, 90, 80, 70]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == [99, 98, 97, 96, 95, 94, 93, 92]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == [200, 190, 180, 170, 160, 150, 140]\n assert candidate(nums = [100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [100]\n assert candidate(nums = [123, 45, 67, 89, 101, 12, 34, 56, 78, 90, 23, 45, 67, 89, 101]) == [123, 101, 101, 90, 89, 89]\n assert candidate(nums = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 1]) == [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25]\n assert candidate(nums = [29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29]) == [29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29]\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == [100, 99, 98, 97, 96, 95]\n assert candidate(nums = [500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [500, 400]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == [100, 99, 98, 97, 96]\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 2, 3, 4, 5]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [100, 100, 100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [100, 100]\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 100]) == [100, 8, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 1]) == [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31]) == [50, 49, 48, 47, 46, 45, 44, 43, 42]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [20, 19, 18, 17, 16, 15, 14]\n assert candidate(nums = [99, 100, 1, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8, 92, 9, 91, 10]) == [100, 99, 98, 97, 96, 95]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 10, 9, 9, 8, 8, 7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [15, 14, 13, 12, 11]\n assert candidate(nums = [30, 25, 20, 15, 10, 5, 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17]) == [30, 25, 20, 17, 16, 15]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minSubsequence", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector minSubsequence(vector& nums) {", "container": "Solution", "callable": "minSubsequence", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1404, "task_id": "number-of-steps-to-reduce-a-number-in-binary-representation-to-one", "difficulty": "Medium", "problem_description": "Given the binary representation of an integer as a string s, return the number of steps to reduce it to 1 under the following rules:\n\n\nIf the current number is even, you have to divide it by 2.\n\n\nIf the current number is odd, you have to add 1 to it.\n\n\nIt is guaranteed that you can always reach one for all test cases.\n \nExample 1:\n\nInput: s = \"1101\"\nOutput: 6\nExplanation: \"1101\" corressponds to number 13 in their decimal representation.\nStep 1) 13 is odd, add 1 and obtain 14. \nStep 2) 14 is even, divide by 2 and obtain 7.\nStep 3) 7 is odd, add 1 and obtain 8.\nStep 4) 8 is even, divide by 2 and obtain 4.  \nStep 5) 4 is even, divide by 2 and obtain 2. \nStep 6) 2 is even, divide by 2 and obtain 1.  \n\nExample 2:\n\nInput: s = \"10\"\nOutput: 1\nExplanation: \"10\" corresponds to number 2 in their decimal representation.\nStep 1) 2 is even, divide by 2 and obtain 1.  \n\nExample 3:\n\nInput: s = \"1\"\nOutput: 0\n\n \nConstraints:\n\n1 <= s.length <= 500\ns consists of characters '0' or '1'\ns[0] == '1'\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"11101110111\") == 14\n assert candidate(s = \"1111\") == 5\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101\") == 95\n assert candidate(s = \"1100110\") == 10\n assert candidate(s = \"111\") == 4\n assert candidate(s = \"10010\") == 8\n assert candidate(s = \"100000\") == 5\n assert candidate(s = \"100000000000000000000000000000000000000000000000000000000000000\") == 62\n assert candidate(s = \"1001001\") == 12\n assert candidate(s = \"1111111111\") == 11\n assert candidate(s = \"111111111111111111111111111111111111111111111111111111111111111\") == 64\n assert candidate(s = \"1111111\") == 8\n assert candidate(s = \"1101\") == 6\n assert candidate(s = \"11011011\") == 11\n assert candidate(s = \"10\") == 1\n assert candidate(s = \"10101010\") == 12\n assert candidate(s = \"10000000000\") == 10\n assert candidate(s = \"1010101010\") == 15\n assert candidate(s = \"1\") == 0\n assert candidate(s = \"1101001\") == 11\n assert candidate(s = \"101010\") == 9\n assert candidate(s = \"1110011\") == 10\n assert candidate(s = \"1100100\") == 10\n assert candidate(s = \"110011001100110011001100110011001100110011001100110011001100110\") == 94\n assert candidate(s = \"11010\") == 7\n assert candidate(s = \"100000000000000000000000000000000\") == 32\n assert candidate(s = \"1100100100100100100100100100100100\") == 55\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001001001001001001001001\") == 132\n assert candidate(s = \"1011011011011011011011011011011011011011011\") == 58\n assert candidate(s = \"1000100010001\") == 23\n assert candidate(s = \"1011011011011011011011011011011011\") == 46\n assert candidate(s = \"1111111011111110111111101111111\") == 35\n assert candidate(s = \"11111111111111111111111111111111111111111\") == 42\n assert candidate(s = \"1000000000000000000000000000000\") == 30\n assert candidate(s = \"1010101010101010101\") == 29\n assert candidate(s = \"1111000011110000111100001111000\") == 44\n assert candidate(s = \"1010101010101010101010101010101\") == 47\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001001001\") == 107\n assert candidate(s = \"1101101101101101101101101101101101101101101\") == 58\n assert candidate(s = \"1110101010101010101010101010101\") == 46\n assert candidate(s = \"1000000000000000000000000000000000000000000000000000000000000001\") == 127\n assert candidate(s = \"11110101010101010101010101010101010101010101010101010101010101010\") == 96\n assert candidate(s = \"1101101011010110101101011010110\") == 43\n assert candidate(s = \"1010101010101010101010101010101010101010101010101\") == 74\n assert candidate(s = \"1001001001001001001001001001001001001\") == 62\n assert candidate(s = \"101010101010101010101010101010101010101010101\") == 68\n assert candidate(s = \"1110111011101110111011101110111011101110111011101110111011101110\") == 80\n assert candidate(s = \"1101101101101101101101101101101101101101101101101101101101101101\") == 86\n assert candidate(s = \"10101010101010101010101\") == 35\n assert candidate(s = \"10000000000000000000000000000000000000000000000000000000000000001\") == 129\n assert candidate(s = \"110011001100110011001100110011001100110011001100110011001100110011001100\") == 107\n assert candidate(s = \"110111011101110111011101110111011101110111011101110111011101110111011101\") == 91\n assert candidate(s = \"11110000111100001111000011110000111100001111\") == 65\n assert candidate(s = \"1001001001001001001001001001001\") == 52\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101010101010101010101\") == 107\n assert candidate(s = \"1011101010101010101010101010101\") == 46\n assert candidate(s = \"11101110111011101110111011101110111011101110111011101110111011101110111\") == 89\n assert candidate(s = \"1111111111111111111111111111111\") == 32\n assert candidate(s = \"1111000011110000111100001111000011110000111100001111000011110000\") == 93\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111111111111111111111111111111\") == 80\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101010101010101\") == 98\n assert candidate(s = \"1011010110101101011010110101101011010110101101011\") == 69\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111111111111111\") == 65\n assert candidate(s = \"101010101010101010101010101010101010101\") == 59\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101\") == 86\n assert candidate(s = \"1101010101010101010101010101010\") == 46\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101010101010\") == 108\n assert candidate(s = \"11101010101010101010101010101\") == 43\n assert candidate(s = \"1000011111111111111111111111111\") == 36\n assert candidate(s = \"11111111111111111111111111111111111111111111111111111111111111111111\") == 69\n assert candidate(s = \"1010000000000000000000000000000000001\") == 72\n assert candidate(s = \"1000000000000000000000000000000000000000000000000000000000000111\") == 125\n assert candidate(s = \"1011011011011011011011011011011011011011011011011011011011011011011\") == 90\n assert candidate(s = \"1110111011101110111011101110111\") == 39\n assert candidate(s = \"11111111111111111111111111111111111111111111111111111111111111\") == 63\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001001001001001001\") == 122\n assert candidate(s = \"11110000111100001111000011110000\") == 45\n assert candidate(s = \"1101101101101101101101101101101101101101\") == 54\n assert candidate(s = \"1100110011001100110011001100110011001100110011001\") == 74\n assert candidate(s = \"110101010101010101010101010101010101010101010101010101010101010101\") == 99\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101010101010000\") == 96\n assert candidate(s = \"11111111111111111111111111111111\") == 33\n assert candidate(s = \"1101111111000000\") == 18\n assert candidate(s = \"1001001001001001001001001001001001001001\") == 67\n assert candidate(s = \"10101010101010101010101010101010101010101\") == 62\n assert candidate(s = \"10000000000000000000000000000000000000000\") == 40\n assert candidate(s = \"11001100110011001100110011001100110011001100\") == 65\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111111111111010\") == 66\n assert candidate(s = \"1111101010101010101010101010101\") == 45\n assert candidate(s = \"11010101010101010101\") == 30\n assert candidate(s = \"1011101001101001101001101001101\") == 46\n assert candidate(s = \"1100110011001100110011001100110\") == 46\n assert candidate(s = \"1100011000110001100011000110001\") == 50\n assert candidate(s = \"1111101111101111101111101111101111101111101111101\") == 58\n assert candidate(s = \"1001001001001001001001001001001001001001001001001\") == 82\n assert candidate(s = \"11001101100110110\") == 24\n assert candidate(s = \"1110111011101110111011101110111011101110111\") == 54\n assert candidate(s = \"111001000111001000111001000111001000\") == 54\n assert candidate(s = \"1000000000000000000000000000000000000000000000000\") == 48\n assert candidate(s = \"1011011011011011011011011011011011011011011011011011011011011011011011\") == 94\n assert candidate(s = \"1011101110111011101110111011101110111011101110111011101110111011\") == 81\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().numSteps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numSteps(string s) {", "container": "Solution", "callable": "numSteps", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1405, "task_id": "longest-happy-string", "difficulty": "Medium", "problem_description": "A string s is called happy if it satisfies the following conditions:\n\ns only contains the letters 'a', 'b', and 'c'.\ns does not contain any of \"aaa\", \"bbb\", or \"ccc\" as a substring.\ns contains at most a occurrences of the letter 'a'.\ns contains at most b occurrences of the letter 'b'.\ns contains at most c occurrences of the letter 'c'.\n\nGiven three integers a, b, and c, return the longest possible happy string. If there are multiple longest happy strings, return any of them. If there is no such string, return the empty string \"\".\nA substring is a contiguous sequence of characters within a string.\n \nExample 1:\n\nInput: a = 1, b = 1, c = 7\nOutput: \"ccaccbcc\"\nExplanation: \"ccbccacc\" would also be a correct answer.\n\nExample 2:\n\nInput: a = 7, b = 1, c = 0\nOutput: \"aabaa\"\nExplanation: It is the only correct answer in this case.\n\n \nConstraints:\n\n0 <= a, b, c <= 100\na + b + c > 0\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(a = 7,b = 1,c = 0) == \"aabaa\"\n assert candidate(a = 100,b = 100,c = 100) == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 33,b = 33,c = 34) == \"cabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 2,b = 2,c = 2) == \"abcabc\"\n assert candidate(a = 5,b = 5,c = 5) == \"abcabcabcabcabc\"\n assert candidate(a = 5,b = 3,c = 2) == \"aabaabcabc\"\n assert candidate(a = 50,b = 50,c = 0) == \"abababababababababababababababababababababababababababababababababababababababababababababababababab\"\n assert candidate(a = 50,b = 30,c = 20) == \"aabaabaabaabaabaabaabaabaabaabaabaacaabaacaabaacaabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 1,b = 1,c = 7) == \"ccaccbcc\"\n assert candidate(a = 0,b = 0,c = 1) == \"c\"\n assert candidate(a = 0,b = 0,c = 0) == \"\"\n assert candidate(a = 100,b = 0,c = 0) == \"aa\"\n assert candidate(a = 0,b = 0,c = 3) == \"cc\"\n assert candidate(a = 40,b = 30,c = 30) == \"aabaacaabaacaabaacaabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 0,b = 10,c = 10) == \"bcbcbcbcbcbcbcbcbcbc\"\n assert candidate(a = 10,b = 10,c = 1) == \"ababababababababababc\"\n assert candidate(a = 20,b = 10,c = 15) == \"aacaacaacaacaacabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 15,b = 20,c = 10) == \"bbabbabbabbabababcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 45,b = 10,c = 45) == \"acacacacacacacacacacacacacacacacacacacacacacacacacacacacacacacacacacacabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 6,b = 6,c = 6) == \"abcabcabcabcabcabc\"\n assert candidate(a = 3,b = 3,c = 3) == \"abcabcabc\"\n assert candidate(a = 40,b = 20,c = 40) == \"acacacacacacacacacacacacacacacacacacacacabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 15,b = 15,c = 15) == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 33,b = 34,c = 33) == \"babcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 5,b = 5,c = 4) == \"ababcabcabcabc\"\n assert candidate(a = 10,b = 10,c = 20) == \"ccaccbccaccbccaccbcabcabcabcabcabcabcabc\"\n assert candidate(a = 60,b = 40,c = 5) == \"aabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabababababababababababababababababcabcabcabcabc\"\n assert candidate(a = 4,b = 4,c = 3) == \"ababcabcabc\"\n assert candidate(a = 15,b = 15,c = 5) == \"abababababababababababcabcabcabcabc\"\n assert candidate(a = 5,b = 4,c = 4) == \"aabcabcabcabc\"\n assert candidate(a = 5,b = 5,c = 0) == \"ababababab\"\n assert candidate(a = 10,b = 10,c = 5) == \"ababababababcabcabcabcabc\"\n assert candidate(a = 5,b = 0,c = 5) == \"acacacacac\"\n assert candidate(a = 20,b = 20,c = 10) == \"abababababababababababcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 34,b = 33,c = 33) == \"aabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 0,b = 0,c = 100) == \"cc\"\n assert candidate(a = 10,b = 20,c = 10) == \"bbabbcbbabbcbbabbcbabcabcabcabcabcabcabc\"\n assert candidate(a = 30,b = 20,c = 10) == \"aabaabaabaabaabaabaabaabaabaababcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 30,b = 30,c = 20) == \"abababababababababababcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 20,b = 25,c = 20) == \"bbabbcbbabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 0,b = 50,c = 50) == \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc\"\n assert candidate(a = 90,b = 5,c = 5) == \"aabaacaabaacaabaacaabaacaabaacaa\"\n assert candidate(a = 20,b = 19,c = 18) == \"aababcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 6,b = 7,c = 8) == \"cbcabcabcabcabcabcabc\"\n assert candidate(a = 1,b = 1,c = 5) == \"ccaccbc\"\n assert candidate(a = 4,b = 4,c = 5) == \"cabcabcabcabc\"\n assert candidate(a = 2,b = 1,c = 1) == \"aabc\"\n assert candidate(a = 50,b = 50,c = 50) == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 99,b = 1,c = 0) == \"aabaa\"\n assert candidate(a = 34,b = 34,c = 32) == \"abababcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 10,b = 45,c = 45) == \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 2,b = 3,c = 5) == \"ccbcabcabc\"\n assert candidate(a = 15,b = 5,c = 10) == \"aacaacaacaacaacabcabcabcabcabc\"\n assert candidate(a = 1,b = 1,c = 2) == \"cabc\"\n assert candidate(a = 7,b = 8,c = 9) == \"cbcabcabcabcabcabcabcabc\"\n assert candidate(a = 8,b = 8,c = 8) == \"abcabcabcabcabcabcabcabc\"\n assert candidate(a = 33,b = 33,c = 33) == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 25,b = 25,c = 24) == \"ababcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 100,b = 50,c = 50) == \"aabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabaacaabacabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 5,b = 2,c = 2) == \"aabaacabc\"\n assert candidate(a = 25,b = 25,c = 25) == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 99,b = 99,c = 99) == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 15,b = 15,c = 10) == \"ababababababcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 3,b = 3,c = 9) == \"ccaccbccacbcabc\"\n assert candidate(a = 15,b = 15,c = 1) == \"abababababababababababababababc\"\n assert candidate(a = 10,b = 10,c = 10) == \"abcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 9,b = 8,c = 7) == \"aababcabcabcabcabcabcabc\"\n assert candidate(a = 3,b = 3,c = 4) == \"cabcabcabc\"\n assert candidate(a = 1,b = 2,c = 1) == \"babc\"\n assert candidate(a = 3,b = 2,c = 1) == \"aababc\"\n assert candidate(a = 10,b = 1,c = 1) == \"aabaacaa\"\n assert candidate(a = 10,b = 5,c = 15) == \"ccaccaccaccacacabcabcabcabcabc\"\n assert candidate(a = 1,b = 1,c = 1) == \"abc\"\n assert candidate(a = 49,b = 50,c = 51) == \"cbcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 20,b = 10,c = 10) == \"aabaacaabaacaabaacaabcabcabcabcabcabcabc\"\n assert candidate(a = 51,b = 50,c = 49) == \"aababcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 20,b = 30,c = 20) == \"bbabbcbbabbcbbabbcbabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 1,b = 100,c = 1) == \"bbabbcbb\"\n assert candidate(a = 5,b = 5,c = 10) == \"ccaccbccabcabcabcabc\"\n assert candidate(a = 50,b = 50,c = 1) == \"ababababababababababababababababababababababababababababababababababababababababababababababababababc\"\n assert candidate(a = 0,b = 100,c = 0) == \"bb\"\n assert candidate(a = 24,b = 25,c = 25) == \"bcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 10,b = 10,c = 15) == \"ccaccbccabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 1,b = 1,c = 100) == \"ccaccbcc\"\n assert candidate(a = 1,b = 2,c = 3) == \"cbcabc\"\n assert candidate(a = 20,b = 20,c = 19) == \"ababcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 45,b = 45,c = 10) == \"ababababababababababababababababababababababababababababababababababababcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 0,b = 5,c = 5) == \"bcbcbcbcbc\"\n assert candidate(a = 60,b = 40,c = 0) == \"aabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaabaababababababababababababababababababababab\"\n assert candidate(a = 3,b = 7,c = 5) == \"bbcbbcabcabcabc\"\n assert candidate(a = 30,b = 30,c = 30) == \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n assert candidate(a = 30,b = 25,c = 45) == \"ccaccaccaccaccaccaccbccaccbccaccbcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\"\n"}, "metadata": {"canonical_parameter_names": ["a", "b", "c"], "leetcode_dataset_entry_point": "Solution().longestDiverseString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string longestDiverseString(int a, int b, int c) {", "container": "Solution", "callable": "longestDiverseString", "parameters": [{"name": "a", "type": "int"}, {"name": "b", "type": "int"}, {"name": "c", "type": "int"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1406, "task_id": "stone-game-iii", "difficulty": "Hard", "problem_description": "Alice and Bob continue their games with piles of stones. There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.\nAlice and Bob take turns, with Alice starting first. On each player's turn, that player can take 1, 2, or 3 stones from the first remaining stones in the row.\nThe score of each player is the sum of the values of the stones taken. The score of each player is 0 initially.\nThe objective of the game is to end with the highest score, and the winner is the player with the highest score and there could be a tie. The game continues until all the stones have been taken.\nAssume Alice and Bob play optimally.\nReturn \"Alice\" if Alice will win, \"Bob\" if Bob will win, or \"Tie\" if they will end the game with the same score.\n \nExample 1:\n\nInput: stoneValue = [1,2,3,7]\nOutput: \"Bob\"\nExplanation: Alice will always lose. Her best move will be to take three piles and the score become 6. Now the score of Bob is 7 and Bob wins.\n\nExample 2:\n\nInput: stoneValue = [1,2,3,-9]\nOutput: \"Alice\"\nExplanation: Alice must choose all the three piles at the first move to win and leave Bob with negative score.\nIf Alice chooses one pile her score will be 1 and the next move Bob's score becomes 5. In the next move, Alice will take the pile with value = -9 and lose.\nIf Alice chooses two piles her score will be 3 and the next move Bob's score becomes 3. In the next move, Alice will take the pile with value = -9 and also lose.\nRemember that both play optimally so here Alice will choose the scenario that makes her win.\n\nExample 3:\n\nInput: stoneValue = [1,2,3,6]\nOutput: \"Tie\"\nExplanation: Alice cannot win this game. She can end the game in a draw if she decided to choose all the first three piles, otherwise she will lose.\n\n \nConstraints:\n\n1 <= stoneValue.length <= 5 * 104\n-1000 <= stoneValue[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(stoneValue = [0, 0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [1]) == \"Alice\"\n assert candidate(stoneValue = [1, -100, 1, 100]) == \"Tie\"\n assert candidate(stoneValue = [5, 3, 7, 1]) == \"Alice\"\n assert candidate(stoneValue = [5, 3, 1, 4, 2]) == \"Alice\"\n assert candidate(stoneValue = [0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == \"Alice\"\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == \"Tie\"\n assert candidate(stoneValue = [-1, -2, -3, -4]) == \"Tie\"\n assert candidate(stoneValue = [1, 2, 3, 6]) == \"Tie\"\n assert candidate(stoneValue = [0, 0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == \"Alice\"\n assert candidate(stoneValue = [5, 3, -6, 7, 2, 8, -1, 4, 10]) == \"Alice\"\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == \"Bob\"\n assert candidate(stoneValue = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"Alice\"\n assert candidate(stoneValue = [1000, -1000, 1000, -1000]) == \"Alice\"\n assert candidate(stoneValue = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"Alice\"\n assert candidate(stoneValue = [1, 2, 3, 7]) == \"Bob\"\n assert candidate(stoneValue = [1000, -1000, 1000, -1000, 1000]) == \"Alice\"\n assert candidate(stoneValue = [1, 2, 3, -9]) == \"Alice\"\n assert candidate(stoneValue = [-1, -2, -3, -4, -5]) == \"Bob\"\n assert candidate(stoneValue = [3, 2, 10, 4]) == \"Alice\"\n assert candidate(stoneValue = [1000, -1000, 1000, -1000, 1000]) == \"Alice\"\n assert candidate(stoneValue = [5, 10, -5, 1]) == \"Alice\"\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == \"Alice\"\n assert candidate(stoneValue = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8]) == \"Alice\"\n assert candidate(stoneValue = [3, -2, 5, 1, -4, 6, -3, 2, 5, -1, 4, -6, 3, 2, -5, 1, 4, -6, 3, 2, -5, 1, 4, -6, 3, 2, -5]) == \"Alice\"\n assert candidate(stoneValue = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000, 1100, -1200, 1300, -1400, 1500]) == \"Alice\"\n assert candidate(stoneValue = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == \"Alice\"\n assert candidate(stoneValue = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]) == \"Alice\"\n assert candidate(stoneValue = [1000, -999, 998, -997, 996, -995, 994, -993, 992, -991]) == \"Alice\"\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == \"Tie\"\n assert candidate(stoneValue = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == \"Alice\"\n assert candidate(stoneValue = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"Alice\"\n assert candidate(stoneValue = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [5, 10, -5, 20, 25, -30, 35, -40, 45, 50]) == \"Alice\"\n assert candidate(stoneValue = [5, -1, 3, -4, 2, 10, -7, 8, -2, 6]) == \"Alice\"\n assert candidate(stoneValue = [5, 3, 2, 4, 1, 3, 2, 1, 2, 3, 4, 5, 1, 2, 3]) == \"Alice\"\n assert candidate(stoneValue = [100, -99, 100, -99, 100, -99, 100, -99, 100, -99]) == \"Alice\"\n assert candidate(stoneValue = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == \"Alice\"\n assert candidate(stoneValue = [10, 15, -5, 20, -10, 25, -15, 30, -20, 35]) == \"Alice\"\n assert candidate(stoneValue = [100, -50, 200, -150, 300, -200, 400, -250, 500, -300, 600, -350, 700, -400, 800]) == \"Alice\"\n assert candidate(stoneValue = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == \"Bob\"\n assert candidate(stoneValue = [3, 1, 5, 4, 2, 6, 7, 8, 9, 10]) == \"Alice\"\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -100, -90, -80, -70, -60, -50, -40, -30, -20, -10]) == \"Tie\"\n assert candidate(stoneValue = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8]) == \"Alice\"\n assert candidate(stoneValue = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == \"Tie\"\n assert candidate(stoneValue = [-5, -10, -15, -20, -25, -30, -35, -40, -45, -50]) == \"Alice\"\n assert candidate(stoneValue = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == \"Bob\"\n assert candidate(stoneValue = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"Alice\"\n assert candidate(stoneValue = [1000, -500, 250, -125, 62, -31, 15, -7, 3, -1, 0, 1, -3, 7, -15, 31, -62, 125, -250, 500, -1000]) == \"Alice\"\n assert candidate(stoneValue = [-10, 100, -20, 200, -30, 300, -40, 400, -50, 500]) == \"Alice\"\n assert candidate(stoneValue = [5, 7, -3, 12, 15, -10, 8, 11, -2, 6, 14, 1, -5, 9, -7]) == \"Alice\"\n assert candidate(stoneValue = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20, 21, -22, 23, -24, 25]) == \"Alice\"\n assert candidate(stoneValue = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == \"Tie\"\n assert candidate(stoneValue = [-100, -200, -300, 400, 500, 600, -700, -800, 900, 1000]) == \"Alice\"\n assert candidate(stoneValue = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"Alice\"\n assert candidate(stoneValue = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == \"Alice\"\n assert candidate(stoneValue = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == \"Bob\"\n assert candidate(stoneValue = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == \"Alice\"\n assert candidate(stoneValue = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == \"Alice\"\n assert candidate(stoneValue = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89]) == \"Alice\"\n assert candidate(stoneValue = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100]) == \"Alice\"\n assert candidate(stoneValue = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == \"Alice\"\n assert candidate(stoneValue = [100, 200, 300, 400, -1000, 500, 600, 700, -800, 900, 1000]) == \"Alice\"\n assert candidate(stoneValue = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == \"Alice\"\n assert candidate(stoneValue = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000]) == \"Alice\"\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == \"Alice\"\n assert candidate(stoneValue = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100, 110, -120, 130, -140, 150, -160, 170, -180, 190, -200, 210, -220, 230, -240, 250]) == \"Alice\"\n assert candidate(stoneValue = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == \"Tie\"\n assert candidate(stoneValue = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"Tie\"\n assert candidate(stoneValue = [-5, 10, -15, 20, -25, 30, -35, 40, -45, 50]) == \"Alice\"\n assert candidate(stoneValue = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -110, -120, -130, -140, -150]) == \"Tie\"\n assert candidate(stoneValue = [1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"Alice\"\n assert candidate(stoneValue = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000]) == \"Alice\"\n assert candidate(stoneValue = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100, 110, -120, 130, -140, 150, -160, 170, -180, 190, -200]) == \"Alice\"\n assert candidate(stoneValue = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"Alice\"\n assert candidate(stoneValue = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -30]) == \"Alice\"\n assert candidate(stoneValue = [-10, 10, -20, 20, -30, 30, -40, 40, -50, 50]) == \"Tie\"\n assert candidate(stoneValue = [-50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50]) == \"Tie\"\n assert candidate(stoneValue = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20, 21, -22, 23, -24, 25, -26, 27, -28, 29, -30]) == \"Alice\"\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == \"Alice\"\n assert candidate(stoneValue = [5, -2, 4, -1, 3, -3, 2, 1, -5, 6, 7, -8, 9]) == \"Alice\"\n assert candidate(stoneValue = [500, 250, -100, 200, -150, 300, -50, 100, -200, 300, 500]) == \"Alice\"\n assert candidate(stoneValue = [5, -3, 2, 7, -8, 10, -15, 20, -25, 30]) == \"Alice\"\n assert candidate(stoneValue = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == \"Alice\"\n assert candidate(stoneValue = [-5, 10, 20, -15, 30, 25, -20, 40, -35, 50, -45, 60, -55]) == \"Alice\"\n assert candidate(stoneValue = [100, 200, 300, -100, -200, -300, 400, 500, 600, -400, -500, -600]) == \"Alice\"\n assert candidate(stoneValue = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -1000, -900, -800, -700, -600, -500, -400, -300, -200, -100]) == \"Tie\"\n assert candidate(stoneValue = [-50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50, 50, -50]) == \"Alice\"\n assert candidate(stoneValue = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"Tie\"\n assert candidate(stoneValue = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15]) == \"Alice\"\n assert candidate(stoneValue = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"Alice\"\n assert candidate(stoneValue = [1000, -500, 2000, -1000, 3000, -1500, 4000, -2000, 5000, -2500, 6000, -3000, 7000, -3500, 8000, -4000, 9000, -4500, 10000, -5000]) == \"Alice\"\n assert candidate(stoneValue = [5, -2, 3, 1, 4, -1, 7, -3, 2, 6, -5]) == \"Alice\"\n assert candidate(stoneValue = [-999, 1000, -999, 1000, -999, 1000, -999, 1000, -999, 1000]) == \"Alice\"\n assert candidate(stoneValue = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == \"Alice\"\n assert candidate(stoneValue = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == \"Alice\"\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == \"Alice\"\n"}, "metadata": {"canonical_parameter_names": ["stoneValue"], "leetcode_dataset_entry_point": "Solution().stoneGameIII", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string stoneGameIII(vector& stoneValue) {", "container": "Solution", "callable": "stoneGameIII", "parameters": [{"name": "stoneValue", "type": "vector&"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1408, "task_id": "string-matching-in-an-array", "difficulty": "Easy", "problem_description": "Given an array of string words, return all strings in words that are a substring of another word. You can return the answer in any order.\n \nExample 1:\n\nInput: words = [\"mass\",\"as\",\"hero\",\"superhero\"]\nOutput: [\"as\",\"hero\"]\nExplanation: \"as\" is substring of \"mass\" and \"hero\" is substring of \"superhero\".\n[\"hero\",\"as\"] is also a valid answer.\n\nExample 2:\n\nInput: words = [\"leetcode\",\"et\",\"code\"]\nOutput: [\"et\",\"code\"]\nExplanation: \"et\", \"code\" are substring of \"leetcode\".\n\nExample 3:\n\nInput: words = [\"blue\",\"green\",\"bu\"]\nOutput: []\nExplanation: No string of words is substring of another string.\n\n \nConstraints:\n\n1 <= words.length <= 100\n1 <= words[i].length <= 30\nwords[i] contains only lowercase English letters.\nAll the strings of words are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['leetcode', 'et', 'code']) == ['et', 'code']\n assert candidate(words = ['blue', 'green', 'bu']) == []\n assert candidate(words = ['mass', 'as', 'hero', 'superhero']) == ['as', 'hero']\n assert candidate(words = ['nested', 'nest', 'sted', 'stednested', 'nestedsted', 'st']) == ['nested', 'nest', 'sted', 'st']\n assert candidate(words = ['computer', 'com', 'puter', 'put', 'ter', 'er', 'r', 'software', 'soft', 'ware', 'awe', 'awe', 're']) == ['com', 'puter', 'put', 'ter', 'er', 'r', 'soft', 'ware', 'awe', 'awe', 're']\n assert candidate(words = ['apple', 'pineapple', 'banana', 'app', 'pine']) == ['apple', 'app', 'pine']\n assert candidate(words = ['apple', 'app', 'pineapple', 'pie', 'pine']) == ['apple', 'app', 'pine']\n assert candidate(words = ['hello', 'world', 'hello world', 'world hello', 'owor', 'dlrow', 'lohel']) == ['hello', 'world']\n assert candidate(words = ['abcdefgh', 'abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a']) == ['abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a']\n assert candidate(words = ['one', 'once', 'only', 'no', 'on', 'o', 'onceuponatime', 'time', 'upon']) == ['once', 'on', 'o', 'time', 'upon']\n assert candidate(words = ['interview', 'view', 'terview', 'enter', 'viewer', 'inter']) == ['view', 'terview', 'inter']\n assert candidate(words = ['hello', 'hell', 'ello', 'lo', 'll', 'he', 'oh', 'el', 'le', 'hellos', 'los']) == ['hello', 'hell', 'ello', 'lo', 'll', 'he', 'el', 'los']\n assert candidate(words = ['adventure', 'venture', 'adven', 'advenu', 'tu', 'tre', 'ven', 'ure', 'enture', 'venu']) == ['venture', 'adven', 'tu', 'ven', 'ure', 'enture', 'venu']\n assert candidate(words = ['abcdef', 'def', 'ghij', 'jkl', 'ghijkl', 'defgh']) == ['def', 'ghij', 'jkl']\n assert candidate(words = ['hello', 'world', 'hello_world', 'helloworld']) == ['hello', 'world']\n assert candidate(words = ['algorithm', 'algo', 'rhythm', 'thm', 'hythm', 'ythm', 'thm', 'hm', 'm', 'rythm']) == ['algo', 'thm', 'hythm', 'ythm', 'thm', 'hm', 'm']\n assert candidate(words = ['abc', 'bca', 'cab', 'abcd', 'bcda', 'cdab', 'dabc']) == ['abc']\n assert candidate(words = ['amazing', 'zing', 'zinga', 'zingalingo']) == ['zing', 'zinga']\n assert candidate(words = ['xyz', 'zyx', 'xyzz', 'zzxy', 'yxz', 'zyxz', 'xyzzyx']) == ['xyz', 'zyx', 'xyzz', 'yxz']\n assert candidate(words = ['algorithms', 'algo', 'rithm', 'log', 'thm', 'gms']) == ['algo', 'rithm', 'thm']\n assert candidate(words = ['extraterrestrial', 'extra', 'terrestrial', 'restrial', 'estrial', 'trial', 'rial', 'ial', 'al', 'l']) == ['extra', 'terrestrial', 'restrial', 'estrial', 'trial', 'rial', 'ial', 'al', 'l']\n assert candidate(words = ['substring', 'super', 'sub', 'superstring', 'string', 'ingsub']) == ['super', 'sub', 'string']\n assert candidate(words = ['a', 'b', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh']) == ['a', 'b', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg']\n assert candidate(words = ['unique', 'unicorn', 'unicore', 'uniques', 'unicorns', 'unicornicorns']) == ['unique', 'unicorn']\n assert candidate(words = ['programming', 'gram', 'gramming', 'pro', 'ming']) == ['gram', 'gramming', 'pro', 'ming']\n assert candidate(words = ['python', 'java', 'c', 'c++', 'javascript', 'typescript', 'script', 'type', 'java', 'script', 'scripting']) == ['java', 'c', 'script', 'type', 'java', 'script']\n assert candidate(words = ['one', 'two', 'three', 'onetwo', 'twothree', 'onetwothree', 'threeonetwo']) == ['one', 'two', 'three', 'onetwo', 'twothree']\n assert candidate(words = ['abc', 'bcd', 'abcd', 'ab', 'cde', 'def', 'abcdefg']) == ['abc', 'bcd', 'abcd', 'ab', 'cde', 'def']\n assert candidate(words = ['abcd', 'abcde', 'abcdef', 'def', 'cde', 'bcde']) == ['abcd', 'abcde', 'def', 'cde', 'bcde']\n assert candidate(words = ['substring', 'string', 'sub', 'str', 'st', 's']) == ['string', 'sub', 'str', 'st', 's']\n assert candidate(words = ['abc', 'def', 'abcdef', 'ghijkl', 'mnop', 'mnopqr', 'abcde']) == ['abc', 'def', 'mnop', 'abcde']\n assert candidate(words = ['python', 'java', 'javascript', 'pythonic', 'code', 'script']) == ['python', 'java', 'script']\n assert candidate(words = ['microcosm', 'micro', 'cosm', 'co', 'sm', 'microscopic', 'scop', 'scope', 'opic', 'pic']) == ['micro', 'cosm', 'co', 'sm', 'scop', 'opic', 'pic']\n assert candidate(words = ['elephant', 'elephantium', 'phant', 'phantom', 'ele', 'fantastic']) == ['elephant', 'phant', 'ele']\n assert candidate(words = ['incomprehensible', 'in', 'comprehensible', 'prehensible', 'prehens', 'hensible', 'ensible', 'sible', 'ible', 'ble']) == ['in', 'comprehensible', 'prehensible', 'prehens', 'hensible', 'ensible', 'sible', 'ible', 'ble']\n assert candidate(words = ['algorithm', 'log', 'arithm', 'rhythm', 'mthm', 'them']) == []\n assert candidate(words = ['repetition', 'petition', 'iteration', 'repeat', 'pet', 'tion', 'peti', 'petit', 'petiti', 'petitio']) == ['petition', 'pet', 'tion', 'peti', 'petit', 'petiti', 'petitio']\n assert candidate(words = ['substring', 'string', 'sub', 'substringing', 'ing']) == ['substring', 'string', 'sub', 'ing']\n assert candidate(words = ['quick', 'brown', 'fox', 'the', 'quickbrownfoxjumpsoverthelazydog']) == ['quick', 'brown', 'fox', 'the']\n assert candidate(words = ['substring', 'string', 'sub', 'ing', 'substr', 'str', 'ingstr', 'substrin']) == ['string', 'sub', 'ing', 'substr', 'str', 'substrin']\n assert candidate(words = ['hello', 'world', 'hel', 'lo', 'wor', 'rld', 'ldo']) == ['hel', 'lo', 'wor', 'rld']\n assert candidate(words = ['programming', 'gram', 'ming', 'pro', 'gramming']) == ['gram', 'ming', 'pro', 'gramming']\n assert candidate(words = ['aabbcc', 'bbaa', 'ccaa', 'aabb', 'bbcc', 'ccaabb', 'aabbccaa']) == ['aabbcc', 'ccaa', 'aabb', 'bbcc']\n assert candidate(words = ['tiny', 'tinier', 'tinytinier', 'tinytiny', 'tinieriny']) == ['tiny', 'tinier']\n assert candidate(words = ['apple', 'app', 'le', 'banana', 'nan', 'batman', 'man', 'at']) == ['app', 'le', 'nan', 'man', 'at']\n assert candidate(words = ['aabbcc', 'aabb', 'abbc', 'bbcc', 'abcc', 'aabc', 'bccc', 'ccaa', 'aacc', 'bbca']) == ['aabb', 'abbc', 'bbcc']\n assert candidate(words = ['random', 'rand', 'dom', 'ra', 'doma', 'mon', 'ndom', 'and', 'ran', 'domi']) == ['rand', 'dom', 'ra', 'ndom', 'and', 'ran']\n assert candidate(words = ['xylophone', 'xylo', 'phone', 'pho', 'ne', 'xy', 'lo', 'lopho', 'phone']) == ['xylo', 'phone', 'pho', 'ne', 'xy', 'lo', 'lopho', 'phone']\n assert candidate(words = ['algorithm', 'logarithm', 'rhythm', 'algorithmic', 'logarithmic', 'rhythmic']) == ['algorithm', 'logarithm', 'rhythm']\n assert candidate(words = ['abcd', 'abc', 'ab', 'a', 'bcde', 'cde', 'de', 'e']) == ['abc', 'ab', 'a', 'cde', 'de', 'e']\n assert candidate(words = ['substring', 'string', 'sub', 'str', 'ing', 'sun', 'set', 'net', 'get', 'ten']) == ['string', 'sub', 'str', 'ing']\n assert candidate(words = ['photography', 'photo', 'graphy', 'graph', 'graphy', 'photo', 'graphi', 'graphis', 'photo', 'photog']) == ['photo', 'graphy', 'graph', 'graphy', 'photo', 'graphi', 'photo', 'photog']\n assert candidate(words = ['subsequence', 'sequence', 'sub', 'ence', 'quen']) == ['sequence', 'sub', 'ence', 'quen']\n assert candidate(words = ['abcdefg', 'bcdef', 'cdefg', 'defgh', 'efghi', 'fghij', 'ghijk', 'hijkl', 'ijklm', 'jklmn']) == ['bcdef', 'cdefg']\n assert candidate(words = ['tiny', 'tinytiny', 'tinytinytiny', 'tinytinytinytiny', 'tinytinytinytinytiny']) == ['tiny', 'tinytiny', 'tinytinytiny', 'tinytinytinytiny']\n assert candidate(words = ['substring', 'substr', 'string', 'str', 'tri', 'ing', 'sub', 'subtr', 'ing', 'subtrin']) == ['substr', 'string', 'str', 'tri', 'ing', 'sub', 'subtr', 'ing']\n assert candidate(words = ['submarine', 'sub', 'marine', 'submar', 'in', 'a', 'mar', 'ne']) == ['sub', 'marine', 'submar', 'in', 'a', 'mar', 'ne']\n assert candidate(words = ['abcd', 'abc', 'ab', 'a', 'bcde', 'cde', 'de']) == ['abc', 'ab', 'a', 'cde', 'de']\n assert candidate(words = ['abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a', 'b', 'c', 'd', 'e', 'f']) == ['abcde', 'abcd', 'abc', 'ab', 'a', 'b', 'c', 'd', 'e', 'f']\n assert candidate(words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg']) == ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef']\n assert candidate(words = ['programming', 'gram', 'ming', 'pro', 'am', 'ing', 'gramming', 'program']) == ['gram', 'ming', 'pro', 'am', 'ing', 'gramming', 'program']\n assert candidate(words = ['hello', 'he', 'hell', 'lo', 'he', 'ello', 'hel', 'ell', 'llo', 'lo']) == ['he', 'hell', 'lo', 'he', 'ello', 'hel', 'ell', 'llo', 'lo']\n assert candidate(words = ['apple', 'plea', 'ple', 'applepie']) == ['apple', 'ple']\n assert candidate(words = ['fantastic', 'fant', 'ast', 'astic', 'tic']) == ['fant', 'ast', 'astic', 'tic']\n assert candidate(words = ['supercalifragilisticexpialidocious', 'cali', 'frag', 'listic', 'expiali', 'docious', 'super']) == ['cali', 'frag', 'listic', 'expiali', 'docious', 'super']\n assert candidate(words = ['subsequence', 'sequence', 'sub', 'seq', 'subseq', 'quen', 'ence', 'quence', 'suben', 'queseq']) == ['sequence', 'sub', 'seq', 'subseq', 'quen', 'ence', 'quence']\n assert candidate(words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh']) == ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg']\n assert candidate(words = ['abcdabcd', 'ab', 'abc', 'abcd', 'abcde', 'abcdef']) == ['ab', 'abc', 'abcd', 'abcde']\n assert candidate(words = ['banana', 'ana', 'nan', 'ban', 'an']) == ['ana', 'nan', 'ban', 'an']\n assert candidate(words = ['hello', 'world', 'hello world', 'helloworld', 'lowor', 'wor']) == ['hello', 'world', 'lowor', 'wor']\n assert candidate(words = ['programming', 'gram', 'ming', 'pro', 'gramming', 'program']) == ['gram', 'ming', 'pro', 'gramming', 'program']\n assert candidate(words = ['interdisciplinary', 'inter', 'disciplinary', 'disci', 'plinary', 'sci', 'sciency', 'interdisci', 'plin', 'sciencyplin']) == ['inter', 'disciplinary', 'disci', 'plinary', 'sci', 'sciency', 'interdisci', 'plin']\n assert candidate(words = ['abcdefg', 'abcde', 'abcd', 'abc', 'ab', 'a', 'abcdefgh', 'efg', 'hij', 'ijk']) == ['abcdefg', 'abcde', 'abcd', 'abc', 'ab', 'a', 'efg']\n assert candidate(words = ['tiny', 'tinytiny', 'tinytinytiny', 'tinytinytinytiny']) == ['tiny', 'tinytiny', 'tinytinytiny']\n assert candidate(words = ['overlap', 'lapping', 'lap', 'lappping', 'lapppinglap']) == ['lap', 'lappping']\n assert candidate(words = ['programming', 'program', 'ming', 'code', 'coding']) == ['program', 'ming']\n assert candidate(words = ['algorithm', 'algo', 'rhythm', 'rhythmic', 'algothm', 'rhyth', 'thm']) == ['algo', 'rhythm', 'rhyth', 'thm']\n assert candidate(words = ['substring', 'string', 'sub', 'substrings', 'str']) == ['substring', 'string', 'sub', 'str']\n assert candidate(words = ['abcdef', 'bcde', 'cde', 'de', 'e', 'f']) == ['bcde', 'cde', 'de', 'e', 'f']\n assert candidate(words = ['nested', 'nest', 'nestedword', 'word', 'edword', 'st', 'sted']) == ['nested', 'nest', 'word', 'edword', 'st', 'sted']\n assert candidate(words = ['photographically', 'photo', 'graphically', 'graphic', 'ically', 'ally', 'ly', 'y']) == ['photo', 'graphically', 'graphic', 'ically', 'ally', 'ly', 'y']\n assert candidate(words = ['xylophone', 'phone', 'lophone', 'xylo', 'loph', 'pho', 'hon', 'xyl', 'one', 'phe']) == ['phone', 'lophone', 'xylo', 'loph', 'pho', 'hon', 'xyl', 'one']\n assert candidate(words = ['programming', 'gram', 'ming', 'mingo', 'prog', 'ingram', 'program', 'gramming', 'programm', 'progr']) == ['gram', 'ming', 'prog', 'program', 'gramming', 'programm', 'progr']\n assert candidate(words = ['abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a', 'b', 'c', 'd', 'e', 'f', 'abcdefg', 'gh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz']) == ['abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a', 'b', 'c', 'd', 'e', 'f', 'gh']\n assert candidate(words = ['algorithm', 'log', 'rithm', 'algo', 'thm']) == ['rithm', 'algo', 'thm']\n assert candidate(words = ['unique', 'uni', 'ique', 'un', 'que', 'nique', 'niqe', 'neiq', 'uqei', 'inqeu']) == ['uni', 'ique', 'un', 'que', 'nique']\n assert candidate(words = ['programming', 'gram', 'pro', 'ming', 'ring']) == ['gram', 'pro', 'ming']\n assert candidate(words = ['water', 'watermelon', 'melon', 'wa', 'ter', 'melonade', 'ade']) == ['water', 'melon', 'wa', 'ter', 'ade']\n assert candidate(words = ['apple', 'pineapple', 'grape', 'pinegrape', 'grapefruit', 'pineapplegrape']) == ['apple', 'pineapple', 'grape']\n assert candidate(words = ['abc', 'def', 'abcd', 'abcde', 'abcdef']) == ['abc', 'def', 'abcd', 'abcde']\n assert candidate(words = ['supercalifragilisticexpialidocious', 'super', 'cali', 'fragi', 'listic', 'expiali', 'docious', 'fragilisticexpialidocious']) == ['super', 'cali', 'fragi', 'listic', 'expiali', 'docious', 'fragilisticexpialidocious']\n assert candidate(words = ['unbelievable', 'un', 'believe', 'able', 'e', 'a', 'i', 'o', 'u']) == ['un', 'able', 'e', 'a', 'i', 'u']\n assert candidate(words = ['encyclopedia', 'encyclop', 'yclopedia', 'cloped', 'lopedia', 'pedia', 'dia', 'dialect', 'logic', 'encyclopediaic']) == ['encyclopedia', 'encyclop', 'yclopedia', 'cloped', 'lopedia', 'pedia', 'dia']\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnop', 'qrstuvwxyz', 'mnopqrstu', 'vwxyz']) == ['abcdefghijklmnop', 'qrstuvwxyz', 'mnopqrstu', 'vwxyz']\n assert candidate(words = ['supercalifragilisticexpialidocious', 'fragilistic', 'expialidocious', 'docious', 'ious', 'ous', 'us', 's']) == ['fragilistic', 'expialidocious', 'docious', 'ious', 'ous', 'us', 's']\n assert candidate(words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef']) == ['a', 'ab', 'abc', 'abcd', 'abcde']\n assert candidate(words = ['algorithm', 'algo', 'rhythm', 'thm', 'rthm', 'hythmthm']) == ['algo', 'thm']\n"}, "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().stringMatching", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector stringMatching(vector& words) {", "container": "Solution", "callable": "stringMatching", "parameters": [{"name": "words", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1409, "task_id": "queries-on-a-permutation-with-key", "difficulty": "Medium", "problem_description": "Given the array queries of positive integers between 1 and m, you have to process all queries[i] (from i=0 to i=queries.length-1) according to the following rules:\n\nIn the beginning, you have the permutation P=[1,2,3,...,m].\nFor the current i, find the position of queries[i] in the permutation P (indexing from 0) and then move this at the beginning of the permutation P. Notice that the position of queries[i] in P is the result for queries[i].\n\nReturn an array containing the result for the given queries.\n \nExample 1:\n\nInput: queries = [3,1,2,1], m = 5\nOutput: [2,1,2,1] \nExplanation: The queries are processed as follow: \nFor i=0: queries[i]=3, P=[1,2,3,4,5], position of 3 in P is 2, then we move 3 to the beginning of P resulting in P=[3,1,2,4,5]. \nFor i=1: queries[i]=1, P=[3,1,2,4,5], position of 1 in P is 1, then we move 1 to the beginning of P resulting in P=[1,3,2,4,5]. \nFor i=2: queries[i]=2, P=[1,3,2,4,5], position of 2 in P is 2, then we move 2 to the beginning of P resulting in P=[2,1,3,4,5]. \nFor i=3: queries[i]=1, P=[2,1,3,4,5], position of 1 in P is 1, then we move 1 to the beginning of P resulting in P=[1,2,3,4,5]. \nTherefore, the array containing the result is [2,1,2,1]. \n\nExample 2:\n\nInput: queries = [4,1,2,2], m = 4\nOutput: [3,1,2,0]\n\nExample 3:\n\nInput: queries = [7,5,5,8,3], m = 8\nOutput: [6,5,0,7,5]\n\n \nConstraints:\n\n1 <= m <= 10^3\n1 <= queries.length <= m\n1 <= queries[i] <= m\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(queries = [3, 1, 2, 1],m = 5) == [2, 1, 2, 1]\n assert candidate(queries = [1, 2, 3],m = 3) == [0, 1, 2]\n assert candidate(queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 10) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(queries = [7, 5, 5, 8, 3],m = 8) == [6, 5, 0, 7, 5]\n assert candidate(queries = [1, 2, 3, 4, 5],m = 5) == [0, 1, 2, 3, 4]\n assert candidate(queries = [5, 4, 3, 2, 1],m = 5) == [4, 4, 4, 4, 4]\n assert candidate(queries = [4, 1, 2, 2],m = 4) == [3, 1, 2, 0]\n assert candidate(queries = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 5) == [0, 1, 2, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(queries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],m = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 1) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19],m = 20) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(queries = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 15) == [14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14]\n assert candidate(queries = [5, 3, 8, 6, 2, 7, 4, 1],m = 8) == [4, 3, 7, 6, 5, 7, 7, 7]\n assert candidate(queries = [100, 1, 100, 2, 100, 3, 100, 4, 100, 5, 100, 6, 100, 7, 100, 8, 100, 9, 100, 10],m = 100) == [99, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10]\n assert candidate(queries = [8, 7, 6, 5, 4, 3, 2, 1],m = 8) == [7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(queries = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],m = 10) == [9, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(queries = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],m = 7) == [6, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1],m = 5) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2],m = 20) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19]\n assert candidate(queries = [2, 3, 2, 1, 3, 2, 1, 3, 2, 1],m = 3) == [1, 2, 1, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(queries = [10, 1, 10, 2, 10, 3, 10, 4, 10, 5, 10, 6, 10, 7, 10, 8, 10, 9, 10, 10],m = 10) == [9, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 0]\n assert candidate(queries = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],m = 5) == [2, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [8, 3, 8, 5, 8, 3, 8, 5, 8, 3, 8, 5, 8, 3],m = 8) == [7, 3, 1, 5, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]\n assert candidate(queries = [3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1],m = 3) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(queries = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],m = 2) == [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [3, 2, 1, 2, 3, 1, 2, 3, 1, 2, 3],m = 3) == [2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(queries = [8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1],m = 8) == [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(queries = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 9) == [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],m = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9, 9, 9]\n assert candidate(queries = [10, 1, 10, 2, 10, 3, 10, 4, 10, 5],m = 10) == [9, 1, 1, 2, 1, 3, 1, 4, 1, 5]\n assert candidate(queries = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],m = 100) == [99, 99, 99, 99, 99, 99, 99, 99, 99, 99]\n assert candidate(queries = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 15) == [14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14]\n assert candidate(queries = [2, 4, 6, 8, 1, 3, 5, 7, 2, 4, 6, 8, 1, 3, 5, 7],m = 8) == [1, 3, 5, 7, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(queries = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],m = 7) == [6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9],m = 10) == [1, 3, 5, 7, 9, 5, 6, 7, 8, 9]\n assert candidate(queries = [8, 7, 6, 5, 4, 3, 2, 1],m = 8) == [7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20],m = 20) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 10) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(queries = [1, 5, 9, 3, 7, 2, 6, 4, 8, 10],m = 10) == [0, 4, 8, 4, 7, 5, 7, 7, 8, 9]\n assert candidate(queries = [100, 50, 25, 75, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 100) == [99, 50, 26, 75, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]\n assert candidate(queries = [2, 3, 2, 1, 4, 3, 2, 1],m = 4) == [1, 2, 1, 2, 3, 3, 3, 3]\n assert candidate(queries = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],m = 5) == [2, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],m = 6) == [5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],m = 5) == [4, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],m = 30) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]\n assert candidate(queries = [5, 3, 8, 9, 2, 10, 7, 1, 4, 6],m = 10) == [4, 3, 7, 8, 5, 9, 9, 7, 8, 9]\n assert candidate(queries = [1, 4, 3, 2, 5, 6, 7, 8, 9, 10],m = 10) == [0, 3, 3, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(queries = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 20) == [19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19]\n assert candidate(queries = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 10) == [9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(queries = [7, 3, 7, 3, 5, 3, 7],m = 7) == [6, 3, 1, 1, 5, 1, 2]\n assert candidate(queries = [1, 2, 3, 4, 5, 4, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1],m = 5) == [0, 1, 2, 3, 4, 1, 2, 3, 4, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(queries = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10) == [9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(queries = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6],m = 6) == [5, 5, 5, 5, 5, 5, 1, 2, 3, 4, 5]\n assert candidate(queries = [4, 2, 4, 3, 2, 4, 1],m = 5) == [3, 2, 1, 3, 2, 2, 3]\n assert candidate(queries = [10, 5, 1, 5, 10, 5, 1, 10, 10, 1, 5],m = 10) == [9, 5, 2, 1, 2, 1, 2, 2, 0, 1, 2]\n assert candidate(queries = [5, 3, 8, 6, 2, 7, 4, 1, 9, 10],m = 10) == [4, 3, 7, 6, 5, 7, 7, 7, 8, 9]\n assert candidate(queries = [5, 5, 5, 5, 5],m = 5) == [4, 0, 0, 0, 0]\n assert candidate(queries = [5, 3, 7, 1, 9, 2, 8, 4, 6],m = 10) == [4, 3, 6, 3, 8, 5, 8, 7, 8]\n assert candidate(queries = [8, 3, 1, 7, 10, 4, 6, 5, 9, 2],m = 10) == [7, 3, 2, 7, 9, 6, 8, 8, 9, 9]\n assert candidate(queries = [3, 5, 2, 8, 6, 7, 4, 1, 5, 3, 9, 2, 8, 6, 7, 4, 1],m = 9) == [2, 4, 3, 7, 6, 7, 7, 7, 6, 7, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(queries = [5, 2, 9, 1, 5, 3, 8, 4, 7, 6, 5, 2, 9, 1, 5],m = 10) == [4, 2, 8, 3, 3, 4, 8, 6, 8, 8, 5, 8, 8, 8, 3]\n assert candidate(queries = [5, 3, 7, 1, 4, 2, 8, 6],m = 8) == [4, 3, 6, 3, 5, 5, 7, 7]\n assert candidate(queries = [15, 8, 2, 7, 12, 14, 4, 1, 13, 6, 9, 11, 10, 5, 3],m = 15) == [14, 8, 3, 8, 12, 14, 8, 7, 14, 11, 12, 14, 14, 14, 14]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 15) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9]\n assert candidate(queries = [5, 3, 8, 2, 5, 3],m = 10) == [4, 3, 7, 4, 3, 3]\n assert candidate(queries = [7, 7, 7, 7, 7, 7, 7],m = 10) == [6, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 15) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(queries = [9, 1, 9, 2, 9, 3, 9, 4, 9, 5],m = 10) == [8, 1, 1, 2, 1, 3, 1, 4, 1, 5]\n assert candidate(queries = [8, 6, 4, 2, 1, 3, 5, 7],m = 8) == [7, 6, 5, 4, 4, 5, 6, 7]\n assert candidate(queries = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1],m = 6) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(queries = [2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(queries = [5, 3, 1, 4, 2, 5, 3, 1],m = 5) == [4, 3, 2, 4, 4, 4, 4, 4]\n assert candidate(queries = [1, 3, 2, 1, 2, 3, 1, 2, 3, 1],m = 3) == [0, 2, 2, 2, 1, 2, 2, 2, 2, 2]\n assert candidate(queries = [3, 4, 3, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1],m = 4) == [2, 3, 1, 3, 1, 2, 1, 2, 3, 1, 2, 3, 1, 2, 3]\n assert candidate(queries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 20) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],m = 5) == [4, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(queries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 1) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 20) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(queries = [3, 2, 3, 1, 2, 3, 2, 1, 3, 2, 1],m = 3) == [2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 2]\n assert candidate(queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],m = 25) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]\n assert candidate(queries = [2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],m = 3) == [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(queries = [1, 1, 1, 1, 1, 1, 1, 1],m = 1) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [7, 5, 5, 8, 3, 7, 5, 5, 8, 3, 7, 5, 5, 8, 3],m = 8) == [6, 5, 0, 7, 5, 3, 3, 0, 3, 3, 3, 3, 0, 3, 3]\n assert candidate(queries = [10, 1, 10, 2, 10, 3, 10, 4, 10, 5, 10, 6, 10, 7, 10, 8, 10, 9],m = 10) == [9, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9]\n assert candidate(queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],m = 20) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]\n assert candidate(queries = [5, 1, 5, 2, 5, 3, 5, 4, 5],m = 5) == [4, 1, 1, 2, 1, 3, 1, 4, 1]\n assert candidate(queries = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],m = 20) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19]\n assert candidate(queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(queries = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1],m = 10) == [8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 0, 8, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(queries = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],m = 5) == [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(queries = [7, 7, 7, 7, 7, 7, 7],m = 7) == [6, 0, 0, 0, 0, 0, 0]\n"}, "metadata": {"canonical_parameter_names": ["queries", "m"], "leetcode_dataset_entry_point": "Solution().processQueries", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector processQueries(vector& queries, int m) {", "container": "Solution", "callable": "processQueries", "parameters": [{"name": "queries", "type": "vector&"}, {"name": "m", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1410, "task_id": "html-entity-parser", "difficulty": "Medium", "problem_description": "HTML entity parser is the parser that takes HTML code as input and replace all the entities of the special characters by the characters itself.\nThe special characters and their entities for HTML are:\n\nQuotation Mark: the entity is " and symbol character is \".\nSingle Quote Mark: the entity is ' and symbol character is '.\nAmpersand: the entity is & and symbol character is &.\nGreater Than Sign: the entity is > and symbol character is >.\nLess Than Sign: the entity is < and symbol character is <.\nSlash: the entity is ⁄ and symbol character is /.\n\nGiven the input text string to the HTML parser, you have to implement the entity parser.\nReturn the text after replacing the entities by the special characters.\n \nExample 1:\n\nInput: text = \"& is an HTML entity but &ambassador; is not.\"\nOutput: \"& is an HTML entity but &ambassador; is not.\"\nExplanation: The parser will replace the & entity by &\n\nExample 2:\n\nInput: text = \"and I quote: "..."\"\nOutput: \"and I quote: \\\"...\\\"\"\n\n \nConstraints:\n\n1 <= text.length <= 105\nThe string may contain any possible characters out of all the 256 ASCII characters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(text = \"& is an HTML entity but &ambassador; is not.\") == \"& is an HTML entity but &ambassador; is not.\"\n assert candidate(text = \"and I quote: "..."\") == \"and I quote: \\\"...\\\"\"\n assert candidate(text = \"Stay home! Practice on Leetcode :)\") == \"Stay home! Practice on Leetcode :)\"\n assert candidate(text = \"x > y && x < y is always False\") == \"x > y && x < y is always False\"\n assert candidate(text = \"leetcode.com⁄problemset⁄all\") == \"leetcode.com/problemset/all\"\n"}, "metadata": {"canonical_parameter_names": ["text"], "leetcode_dataset_entry_point": "Solution().entityParser", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string entityParser(string text) {", "container": "Solution", "callable": "entityParser", "parameters": [{"name": "text", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1411, "task_id": "number-of-ways-to-paint-n-3-grid", "difficulty": "Hard", "problem_description": "You have a grid of size n x 3 and you want to paint each cell of the grid with exactly one of the three colors: Red, Yellow, or Green while making sure that no two adjacent cells have the same color (i.e., no two cells that share vertical or horizontal sides have the same color).\nGiven n the number of rows of the grid, return the number of ways you can paint this grid. As the answer may grow large, the answer must be computed modulo 109 + 7.\n \nExample 1:\n\n\nInput: n = 1\nOutput: 12\nExplanation: There are 12 possible way to paint the grid as shown.\n\nExample 2:\n\nInput: n = 5000\nOutput: 30228214\n\n \nConstraints:\n\nn == grid.length\n1 <= n <= 5000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 246\n assert candidate(n = 1000) == 650420578\n assert candidate(n = 100) == 905790447\n assert candidate(n = 2500) == 80958521\n assert candidate(n = 4) == 1122\n assert candidate(n = 4999) == 134620719\n assert candidate(n = 5000) == 30228214\n assert candidate(n = 2) == 54\n assert candidate(n = 1) == 12\n assert candidate(n = 500) == 350959293\n assert candidate(n = 50) == 151149117\n assert candidate(n = 10) == 10107954\n assert candidate(n = 5) == 5118\n assert candidate(n = 4000) == 685933196\n assert candidate(n = 12) == 210323922\n assert candidate(n = 2000) == 897054912\n assert candidate(n = 3750) == 477003884\n assert candidate(n = 3500) == 28484708\n assert candidate(n = 3000) == 313837042\n assert candidate(n = 30) == 462032897\n assert candidate(n = 16) == 62485141\n assert candidate(n = 10000) == 779575021\n assert candidate(n = 8) == 485778\n assert candidate(n = 250) == 601916395\n assert candidate(n = 999) == 672393158\n assert candidate(n = 32) == 554911778\n assert candidate(n = 20) == 690883140\n assert candidate(n = 11) == 46107966\n assert candidate(n = 15) == 963045241\n assert candidate(n = 200) == 693684710\n assert candidate(n = 1234) == 18988659\n assert candidate(n = 750) == 493513580\n assert candidate(n = 4500) == 471193061\n assert candidate(n = 6) == 23346\n assert candidate(n = 7) == 106494\n assert candidate(n = 25) == 676744457\n assert candidate(n = 1500) == 814277332\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().numOfWays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numOfWays(int n) {", "container": "Solution", "callable": "numOfWays", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1413, "task_id": "minimum-value-to-get-positive-step-by-step-sum", "difficulty": "Easy", "problem_description": "Given an array of integers nums, you start with an initial positive value startValue.\nIn each iteration, you calculate the step by step sum of startValue plus elements in nums (from left to right).\nReturn the minimum positive value of startValue such that the step by step sum is never less than 1.\n \nExample 1:\n\nInput: nums = [-3,2,-3,4,2]\nOutput: 5\nExplanation: If you choose startValue = 4, in the third iteration your step by step sum is less than 1.\nstep by step sum\nstartValue = 4 | startValue = 5 | nums\n (4 -3 ) = 1 | (5 -3 ) = 2 | -3\n (1 +2 ) = 3 | (2 +2 ) = 4 | 2\n (3 -3 ) = 0 | (4 -3 ) = 1 | -3\n (0 +4 ) = 4 | (1 +4 ) = 5 | 4\n (4 +2 ) = 6 | (5 +2 ) = 7 | 2\n\nExample 2:\n\nInput: nums = [1,2]\nOutput: 1\nExplanation: Minimum start value should be positive. \n\nExample 3:\n\nInput: nums = [1,-2,-3]\nOutput: 5\n\n \nConstraints:\n\n1 <= nums.length <= 100\n-100 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, 1, -1, 1]) == 2\n assert candidate(nums = [100, 100, 100]) == 1\n assert candidate(nums = [-3, 2, -3, 4, 2]) == 5\n assert candidate(nums = [1, -2, -3]) == 5\n assert candidate(nums = [-1]) == 2\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [100]) == 1\n assert candidate(nums = [-100, 100, -100, 100]) == 101\n assert candidate(nums = [50, 50, 50]) == 1\n assert candidate(nums = [-100, -50, -25, -12, -6, -3, -1]) == 198\n assert candidate(nums = [0, 0, 0]) == 1\n assert candidate(nums = [-1, -2, -3, -4]) == 11\n assert candidate(nums = [-100]) == 101\n assert candidate(nums = [1, 2]) == 1\n assert candidate(nums = [100, 50, 25, 12, 6, 3, 1]) == 1\n assert candidate(nums = [50, -50, 50, -50]) == 1\n assert candidate(nums = [-50, -50, -50]) == 151\n assert candidate(nums = [-1, 0, 1]) == 2\n assert candidate(nums = [10, 20, 30, 40]) == 1\n assert candidate(nums = [10, 20, -30, 40, -50, 60, -70, 80]) == 21\n assert candidate(nums = [5, -3, -4, 2, 0, 1, -2, -3, 4, 5]) == 5\n assert candidate(nums = [10, -5, -15, 20, -10, 5]) == 11\n assert candidate(nums = [0, -1, -2, -3, -4, -5, 6]) == 16\n assert candidate(nums = [-1, -1, -1, -1, -1, 10]) == 6\n assert candidate(nums = [100, -100, 100, -100, 100, -100]) == 1\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100]) == 51\n assert candidate(nums = [0, 0, 0, 0, 0, -1, 1]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, -150, 60]) == 1\n assert candidate(nums = [100, -50, 25, -12, 62, -31, 15, -7, 3, -1]) == 1\n assert candidate(nums = [5, -3, 2, -8, 6, -1, 4, -7]) == 5\n assert candidate(nums = [1, -100, 100, -200, 200, -300, 300]) == 300\n assert candidate(nums = [10, -20, 30, -40, 50, -60]) == 31\n assert candidate(nums = [100, -50, -50, 50, -25, 25, -12, 12]) == 1\n assert candidate(nums = [-99, -98, -97, -96, -95, -94, -93, -92, -91, -90]) == 946\n assert candidate(nums = [5, -15, 20, -25, 30, -35, 40]) == 21\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10]) == 11\n assert candidate(nums = [1, -100, 100, -100, 100, -100, 100, -100]) == 100\n assert candidate(nums = [-50, 50, -25, 25, -12, 12, -6, 6, -3, 3]) == 51\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 6\n assert candidate(nums = [-10, 20, -30, 40, -50, 60]) == 31\n assert candidate(nums = [-50, 50, -50, 50, -50, 50]) == 51\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 16\n assert candidate(nums = [-1, 0, 1, -2, 2, -3, 3]) == 4\n assert candidate(nums = [100, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 1\n assert candidate(nums = [10, -10, 10, -10, 10, -10, 10, -10, 10, -10]) == 1\n assert candidate(nums = [5, 5, 5, 5, -20, 5, 5, 5, 5]) == 1\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700]) == 301\n assert candidate(nums = [1, 2, 3, 4, 5, -15, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [5, -10, 15, -20, 25, -30, 35, -40, 45, -50]) == 26\n assert candidate(nums = [10, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, 10]) == 41\n assert candidate(nums = [5, -5, 10, -10, 15, -15, 20, -20, 25, -25]) == 1\n assert candidate(nums = [0, -1, 1, -1, 1, -1]) == 2\n assert candidate(nums = [-10, 0, 10, -20, 20, -30, 30]) == 31\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5]) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5, 15]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [-10, -20, -30, 40, 50, -15]) == 61\n assert candidate(nums = [0, 0, 0, 0, 0, 0, -1]) == 2\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6]) == 7\n assert candidate(nums = [-1, -2, -3, -4, -5, 15, -1, -1, -1, -1]) == 16\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 1\n assert candidate(nums = [-20, 10, 0, -10, 20, 0, -10, 0, 20]) == 21\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80]) == 41\n assert candidate(nums = [-50, -20, -30, 100, -10, 20]) == 101\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, -150]) == 1\n assert candidate(nums = [-50, 50, -50, 50, -50, 50, -50, 50, -50, 50]) == 51\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70]) == 31\n assert candidate(nums = [-10, -20, -30, -40, -50, 100]) == 151\n assert candidate(nums = [30, -10, 20, -15, 5, -5, 10, -10, 15, -20]) == 1\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 6\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == 1\n assert candidate(nums = [10, 20, 30, -50, 40, -10, -20, -30, 50]) == 11\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [3, -5, 2, -1, 4, -6]) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, -5, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1]) == 1\n assert candidate(nums = [0, -1, 1, -2, 2, -3, 3]) == 4\n assert candidate(nums = [-50, -50, -50, 50, 50]) == 151\n assert candidate(nums = [10, -1, -2, -3, -4, -5, -6, -7, -8, -9]) == 36\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [10, -1, 10, -1, 10, -1, 10, -1, 10, -1, 10, -1, 10, -1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, -15, 10, 20, -50, 100]) == 21\n assert candidate(nums = [-10, -20, -30, -40, -50]) == 151\n assert candidate(nums = [0, -1, 0, -2, 0, -3, 0, -4, 0, -5]) == 16\n assert candidate(nums = [-5, -5, -5, -5, 20, -5, -5, -5, -5]) == 21\n assert candidate(nums = [100, -50, 25, -75, 10, -10, 5, -5]) == 1\n assert candidate(nums = [100, -50, -50, -50, -50, 200]) == 101\n assert candidate(nums = [0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [100, -50, 25, -20, 10, -5, 1]) == 1\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 551\n assert candidate(nums = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 1]) == 46\n assert candidate(nums = [-5, -4, -3, -2, -1]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -55]) == 1\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minStartValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minStartValue(vector& nums) {", "container": "Solution", "callable": "minStartValue", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1414, "task_id": "find-the-minimum-number-of-fibonacci-numbers-whose-sum-is-k", "difficulty": "Medium", "problem_description": "Given an integer k, return the minimum number of Fibonacci numbers whose sum is equal to k. The same Fibonacci number can be used multiple times.\nThe Fibonacci numbers are defined as:\n\nF1 = 1\nF2 = 1\nFn = Fn-1 + Fn-2 for n > 2.\n\nIt is guaranteed that for the given constraints we can always find such Fibonacci numbers that sum up to k.\n \nExample 1:\n\nInput: k = 7\nOutput: 2 \nExplanation: The Fibonacci numbers are: 1, 1, 2, 3, 5, 8, 13, ... \nFor k = 7 we can use 2 + 5 = 7.\nExample 2:\n\nInput: k = 10\nOutput: 2 \nExplanation: For k = 10 we can use 2 + 8 = 10.\n\nExample 3:\n\nInput: k = 19\nOutput: 3 \nExplanation: For k = 19 we can use 1 + 5 + 13 = 19.\n\n \nConstraints:\n\n1 <= k <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(k = 433494437) == 1\n assert candidate(k = 377) == 1\n assert candidate(k = 6765) == 1\n assert candidate(k = 24157817) == 1\n assert candidate(k = 102334155) == 1\n assert candidate(k = 89) == 1\n assert candidate(k = 121393) == 1\n assert candidate(k = 500) == 3\n assert candidate(k = 514229) == 1\n assert candidate(k = 50) == 3\n assert candidate(k = 39088169) == 1\n assert candidate(k = 21) == 1\n assert candidate(k = 2584) == 1\n assert candidate(k = 2178309) == 1\n assert candidate(k = 100) == 3\n assert candidate(k = 46368) == 1\n assert candidate(k = 233) == 1\n assert candidate(k = 63245986) == 1\n assert candidate(k = 1000000000) == 14\n assert candidate(k = 7) == 2\n assert candidate(k = 13) == 1\n assert candidate(k = 144) == 1\n assert candidate(k = 701408733) == 1\n assert candidate(k = 55) == 1\n assert candidate(k = 5702887) == 1\n assert candidate(k = 196418) == 1\n assert candidate(k = 2) == 1\n assert candidate(k = 28657) == 1\n assert candidate(k = 14930352) == 1\n assert candidate(k = 4) == 2\n assert candidate(k = 4181) == 1\n assert candidate(k = 3524578) == 1\n assert candidate(k = 17711) == 1\n assert candidate(k = 34) == 1\n assert candidate(k = 10946) == 1\n assert candidate(k = 1) == 1\n assert candidate(k = 19) == 3\n assert candidate(k = 165580141) == 1\n assert candidate(k = 3) == 1\n assert candidate(k = 610) == 1\n assert candidate(k = 8) == 1\n assert candidate(k = 317811) == 1\n assert candidate(k = 1346269) == 1\n assert candidate(k = 10) == 2\n assert candidate(k = 9227465) == 1\n assert candidate(k = 832040) == 1\n assert candidate(k = 1597) == 1\n assert candidate(k = 1000000) == 5\n assert candidate(k = 75025) == 1\n assert candidate(k = 1000) == 2\n assert candidate(k = 267914296) == 1\n assert candidate(k = 5) == 1\n assert candidate(k = 987) == 1\n assert candidate(k = 35) == 2\n assert candidate(k = 123456789) == 12\n assert candidate(k = 1234567) == 10\n assert candidate(k = 863999999) == 13\n assert candidate(k = 12586269025) == 1\n assert candidate(k = 1134903170) == 1\n assert candidate(k = 555555555) == 11\n assert candidate(k = 2123366401) == 14\n assert candidate(k = 340513) == 7\n assert candidate(k = 1836311903) == 1\n assert candidate(k = 104941883) == 11\n assert candidate(k = 999999999) == 13\n assert candidate(k = 470001109) == 13\n assert candidate(k = 55555555) == 11\n assert candidate(k = 2971215073) == 1\n assert candidate(k = 123456) == 4\n assert candidate(k = 987654321) == 15\n"}, "metadata": {"canonical_parameter_names": ["k"], "leetcode_dataset_entry_point": "Solution().findMinFibonacciNumbers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int findMinFibonacciNumbers(int k) {", "container": "Solution", "callable": "findMinFibonacciNumbers", "parameters": [{"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1415, "task_id": "the-k-th-lexicographical-string-of-all-happy-strings-of-length-n", "difficulty": "Medium", "problem_description": "A happy string is a string that:\n\nconsists only of letters of the set ['a', 'b', 'c'].\ns[i] != s[i + 1] for all values of i from 1 to s.length - 1 (string is 1-indexed).\n\nFor example, strings \"abc\", \"ac\", \"b\" and \"abcbabcbcb\" are all happy strings and strings \"aa\", \"baa\" and \"ababbc\" are not happy strings.\nGiven two integers n and k, consider a list of all happy strings of length n sorted in lexicographical order.\nReturn the kth string of this list or return an empty string if there are less than k happy strings of length n.\n \nExample 1:\n\nInput: n = 1, k = 3\nOutput: \"c\"\nExplanation: The list [\"a\", \"b\", \"c\"] contains all happy strings of length 1. The third string is \"c\".\n\nExample 2:\n\nInput: n = 1, k = 4\nOutput: \"\"\nExplanation: There are only 3 happy strings of length 1.\n\nExample 3:\n\nInput: n = 3, k = 9\nOutput: \"cab\"\nExplanation: There are 12 different happy string of length 3 [\"aba\", \"abc\", \"aca\", \"acb\", \"bab\", \"bac\", \"bca\", \"bcb\", \"cab\", \"cac\", \"cba\", \"cbc\"]. You will find the 9th string = \"cab\"\n\n \nConstraints:\n\n1 <= n <= 10\n1 <= k <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,k = 101) == \"abacbabcab\"\n assert candidate(n = 5,k = 1) == \"ababa\"\n assert candidate(n = 10,k = 100) == \"abacbabacb\"\n assert candidate(n = 1,k = 4) == \"\"\n assert candidate(n = 2,k = 5) == \"ca\"\n assert candidate(n = 5,k = 25) == \"bcaba\"\n assert candidate(n = 5,k = 20) == \"babcb\"\n assert candidate(n = 1,k = 3) == \"c\"\n assert candidate(n = 3,k = 9) == \"cab\"\n assert candidate(n = 2,k = 6) == \"cb\"\n assert candidate(n = 4,k = 15) == \"bcba\"\n assert candidate(n = 2,k = 1) == \"ab\"\n assert candidate(n = 5,k = 15) == \"acbca\"\n assert candidate(n = 5,k = 30) == \"bcbac\"\n assert candidate(n = 3,k = 12) == \"cbc\"\n assert candidate(n = 2,k = 3) == \"ba\"\n assert candidate(n = 4,k = 20) == \"cacb\"\n assert candidate(n = 3,k = 1) == \"aba\"\n assert candidate(n = 4,k = 10) == \"babc\"\n assert candidate(n = 9,k = 30) == \"ababcbcac\"\n assert candidate(n = 9,k = 1024) == \"\"\n assert candidate(n = 8,k = 33) == \"abcababa\"\n assert candidate(n = 3,k = 13) == \"\"\n assert candidate(n = 7,k = 50) == \"acbabac\"\n assert candidate(n = 10,k = 1023) == \"bcbcbcbcba\"\n assert candidate(n = 7,k = 127) == \"bcbcbca\"\n assert candidate(n = 9,k = 300) == \"babcacacb\"\n assert candidate(n = 1,k = 1) == \"a\"\n assert candidate(n = 6,k = 123) == \"\"\n assert candidate(n = 7,k = 1) == \"abababa\"\n assert candidate(n = 7,k = 200) == \"\"\n assert candidate(n = 6,k = 27) == \"acbaca\"\n assert candidate(n = 9,k = 175) == \"acacacbca\"\n assert candidate(n = 10,k = 10) == \"abababcabc\"\n assert candidate(n = 10,k = 3) == \"ababababca\"\n assert candidate(n = 10,k = 1) == \"ababababab\"\n assert candidate(n = 9,k = 150) == \"acabcacac\"\n assert candidate(n = 4,k = 25) == \"\"\n assert candidate(n = 8,k = 150) == \"babcacac\"\n assert candidate(n = 2,k = 7) == \"\"\n assert candidate(n = 3,k = 15) == \"\"\n assert candidate(n = 6,k = 70) == \"cabcac\"\n assert candidate(n = 6,k = 30) == \"acbcac\"\n assert candidate(n = 9,k = 2048) == \"\"\n assert candidate(n = 7,k = 123) == \"bcbcaca\"\n assert candidate(n = 8,k = 512) == \"\"\n assert candidate(n = 7,k = 100) == \"bcabacb\"\n assert candidate(n = 10,k = 512) == \"acbcbcbcbc\"\n assert candidate(n = 5,k = 10) == \"acabc\"\n assert candidate(n = 10,k = 500) == \"acbcbcabcb\"\n assert candidate(n = 8,k = 256) == \"bcbcbcbc\"\n assert candidate(n = 8,k = 511) == \"\"\n assert candidate(n = 6,k = 64) == \"bcbcbc\"\n assert candidate(n = 8,k = 200) == \"bcabacbc\"\n assert candidate(n = 10,k = 2048) == \"\"\n assert candidate(n = 7,k = 85) == \"bacacab\"\n assert candidate(n = 8,k = 255) == \"bcbcbcba\"\n assert candidate(n = 10,k = 123) == \"abacbcbaca\"\n assert candidate(n = 7,k = 128) == \"bcbcbcb\"\n assert candidate(n = 8,k = 128) == \"acbcbcbc\"\n assert candidate(n = 5,k = 31) == \"bcbca\"\n assert candidate(n = 6,k = 42) == \"bacabc\"\n assert candidate(n = 10,k = 64) == \"ababcbcbcb\"\n assert candidate(n = 6,k = 63) == \"bcbcba\"\n assert candidate(n = 1,k = 2) == \"b\"\n assert candidate(n = 9,k = 100) == \"abcbabacb\"\n assert candidate(n = 9,k = 512) == \"bcbcbcbcb\"\n assert candidate(n = 5,k = 125) == \"\"\n assert candidate(n = 9,k = 1023) == \"\"\n assert candidate(n = 10,k = 125) == \"abacbcbcab\"\n assert candidate(n = 8,k = 100) == \"acbabacb\"\n assert candidate(n = 9,k = 50) == \"abacbabac\"\n assert candidate(n = 6,k = 5) == \"abacab\"\n assert candidate(n = 8,k = 64) == \"abcbcbcb\"\n assert candidate(n = 9,k = 500) == \"bcbcbabcb\"\n assert candidate(n = 9,k = 243) == \"acbcbabca\"\n assert candidate(n = 10,k = 200) == \"abcbabacbc\"\n assert candidate(n = 10,k = 1024) == \"bcbcbcbcbc\"\n"}, "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().getHappyString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string getHappyString(int n, int k) {", "container": "Solution", "callable": "getHappyString", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1416, "task_id": "restore-the-array", "difficulty": "Hard", "problem_description": "A program was supposed to print an array of integers. The program forgot to print whitespaces and the array is printed as a string of digits s and all we know is that all integers in the array were in the range [1, k] and there are no leading zeros in the array.\nGiven the string s and the integer k, return the number of the possible arrays that can be printed as s using the mentioned program. Since the answer may be very large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: s = \"1000\", k = 10000\nOutput: 1\nExplanation: The only possible array is [1000]\n\nExample 2:\n\nInput: s = \"1000\", k = 10\nOutput: 0\nExplanation: There cannot be an array that was printed this way and has all integer >= 1 and <= 10.\n\nExample 3:\n\nInput: s = \"1317\", k = 2000\nOutput: 8\nExplanation: Possible arrays are [1317],[131,7],[13,17],[1,317],[13,1,7],[1,31,7],[1,3,17],[1,3,1,7]\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists of only digits and does not contain leading zeros.\n1 <= k <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"237\",k = 50) == 3\n assert candidate(s = \"111111111111111111111\",k = 11) == 17711\n assert candidate(s = \"123123123\",k = 123) == 100\n assert candidate(s = \"1317\",k = 2000) == 8\n assert candidate(s = \"99999\",k = 99999) == 16\n assert candidate(s = \"1000\",k = 10) == 0\n assert candidate(s = \"1234567891011121314151617181920\",k = 20) == 1280\n assert candidate(s = \"1000\",k = 10000) == 1\n assert candidate(s = \"1111\",k = 1) == 1\n assert candidate(s = \"123456789\",k = 9) == 1\n assert candidate(s = \"11111111111111111111111111111111111111111111\",k = 11) == 134903163\n assert candidate(s = \"123123123123123123123123123123123123123123123123\",k = 321) == 171507379\n assert candidate(s = \"4294967294294967294294967294294967294294294967294\",k = 4294967294) == 849136492\n assert candidate(s = \"112233445566778899101011121314151617181920\",k = 100) == 17480761\n assert candidate(s = \"11111111111111111111\",k = 11) == 10946\n assert candidate(s = \"12345678910111213141516171819202122232425\",k = 25) == 129792\n assert candidate(s = \"1010101010101010101010101010101010101010\",k = 10) == 1\n assert candidate(s = \"1111111111111111111111111111111111111111111111111\",k = 11) == 586268941\n assert candidate(s = \"55555555555555555555\",k = 55) == 10946\n assert candidate(s = \"987654321098765432109876543210\",k = 987654321) == 64504063\n assert candidate(s = \"999999999999999999\",k = 1000000000) == 129792\n assert candidate(s = \"999999999999999999\",k = 999999999) == 129792\n assert candidate(s = \"1230123\",k = 123) == 8\n assert candidate(s = \"1\",k = 1) == 1\n assert candidate(s = \"101010101010101010\",k = 100) == 1\n assert candidate(s = \"111111111111111111111111111111111111111111111111\",k = 100) == 778742000\n assert candidate(s = \"9999999999999999999\",k = 999999999) == 259328\n assert candidate(s = \"123456789\",k = 999999999) == 256\n assert candidate(s = \"21474836472147483647214748364721474836472147483647\",k = 2147483647) == 80057812\n assert candidate(s = \"111111111111111111\",k = 11) == 4181\n assert candidate(s = \"102030405060708090\",k = 100) == 1\n assert candidate(s = \"311131\",k = 100) == 13\n assert candidate(s = \"123456789101112\",k = 15) == 10\n assert candidate(s = \"999999999\",k = 999999999) == 256\n assert candidate(s = \"12345678901234567890\",k = 123456789) == 125704\n assert candidate(s = \"123456789101112131415161718192021222324252627282930\",k = 30) == 2076672\n assert candidate(s = \"55555555555555555555555555555555555555555555\",k = 555) == 809181231\n assert candidate(s = \"111111111111111111111111111111111111\",k = 1) == 1\n assert candidate(s = \"11111111111111111111\",k = 10) == 1\n assert candidate(s = \"111111111111111111111111111111111111111111\",k = 111) == 641778114\n assert candidate(s = \"9876543210123456789876543210\",k = 2147483647) == 32657088\n assert candidate(s = \"321321321321321321321321321321321321321321\",k = 321) == 641778114\n assert candidate(s = \"429496729542949672954294967295\",k = 4294967295) == 527718016\n assert candidate(s = \"314159265358979323846264338327950288419716939937510\",k = 10000) == 578862353\n assert candidate(s = \"11111111111111111111111111111111111111111111\",k = 111) == 809181231\n assert candidate(s = \"123456789012345678901234567890\",k = 50000) == 23834271\n assert candidate(s = \"30303030303030303030\",k = 30) == 1\n assert candidate(s = \"9999999999999999999999999999999999999999\",k = 1000000000) == 707881333\n assert candidate(s = \"1111111111111111111\",k = 11) == 6765\n assert candidate(s = \"222222222222222222222222222222222222222222\",k = 22) == 433494437\n assert candidate(s = \"31415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679\",k = 1000000000) == 893659449\n assert candidate(s = \"10101010101010101010\",k = 101) == 1\n assert candidate(s = \"32791623145341\",k = 2000) == 3480\n assert candidate(s = \"123123123123123123123123\",k = 123) == 312500\n assert candidate(s = \"111213141516171819202122232425262728293031323334353637383940\",k = 40) == 287913465\n assert candidate(s = \"32767327673276732767\",k = 32767) == 338744\n assert candidate(s = \"1234567891011121314151617181920\",k = 5000) == 51814885\n assert candidate(s = \"123451234512345123451234512345123451234512345\",k = 50000) == 820858001\n assert candidate(s = \"2222222222222222222\",k = 2) == 1\n assert candidate(s = \"327683276832768\",k = 65536) == 12208\n assert candidate(s = \"987654321987654321987654321\",k = 987654321) == 65866496\n assert candidate(s = \"123456789101112131415161718192021\",k = 25) == 4992\n assert candidate(s = \"10101010101010101010101010101010101010101010\",k = 100) == 1\n assert candidate(s = \"111111111111111111111111111111111111\",k = 111) == 82876089\n assert candidate(s = \"112233445566778899\",k = 112233) == 105312\n assert candidate(s = \"1111111111111111111\",k = 1) == 1\n assert candidate(s = \"22222222222222222222\",k = 222) == 121415\n assert candidate(s = \"3034558\",k = 1000) == 20\n assert candidate(s = \"121314151617181920\",k = 20) == 256\n assert candidate(s = \"3030303030303030303\",k = 30) == 1\n assert candidate(s = \"99999999999999999999\",k = 999999999) == 518145\n assert candidate(s = \"1010101010101010101\",k = 101) == 2\n assert candidate(s = \"987654321987654321987654321987654321987654321\",k = 987654321) == 840181650\n assert candidate(s = \"12312312312312312312\",k = 123) == 31250\n assert candidate(s = \"1234567890\",k = 1000) == 125\n assert candidate(s = \"123123123123123123123123123123123123123123123123123\",k = 123) == 351558230\n assert candidate(s = \"9999999999999999999999999999999999999999\",k = 999999999) == 707881333\n assert candidate(s = \"333333333333\",k = 3333) == 1490\n assert candidate(s = \"555555555555555555555555555555555555555555555555\",k = 555) == 171507379\n assert candidate(s = \"111111111111111111111111111111\",k = 111) == 53798080\n assert candidate(s = \"12345678910111213141516171819202122232425262728293031323334353637383940\",k = 50) == 100424031\n assert candidate(s = \"1213141516171819202122232425262728293031323334353637383940\",k = 40) == 492437504\n assert candidate(s = \"1010101010101010101010101010101010101010101010101\",k = 10) == 1\n assert candidate(s = \"474747474747474747474747474747474747474747474747\",k = 4747) == 134502416\n assert candidate(s = \"1000000000000000000000000000000000000000000000000\",k = 1000000000) == 0\n assert candidate(s = \"22222222222222222222222222222222222222222\",k = 222) == 844048728\n assert candidate(s = \"999999999999999999999999999999999999999999999999\",k = 999) == 171507379\n assert candidate(s = \"5229458433423234234234\",k = 1000000) == 1825529\n assert candidate(s = \"112233445566778899\",k = 99) == 4181\n assert candidate(s = \"12345678910\",k = 10) == 1\n assert candidate(s = \"999999999999999999999999999999999999999999\",k = 999999999) == 634726928\n assert candidate(s = \"10101010101010101010\",k = 10) == 1\n assert candidate(s = \"999999999999999999999999999999999999999999\",k = 9) == 1\n assert candidate(s = \"12345123451234512345\",k = 5000) == 250625\n assert candidate(s = \"50505050505050505050\",k = 500) == 1\n assert candidate(s = \"12345678910\",k = 100) == 55\n assert candidate(s = \"123456789123456789123456789\",k = 10000) == 28074040\n assert candidate(s = \"1000000000100000000010000000001000000000\",k = 1000000000) == 1\n assert candidate(s = \"32791879\",k = 500) == 54\n assert candidate(s = \"222222222222222222222222222222222222222222222222\",k = 22) == 778742000\n assert candidate(s = \"987654321098765432109876543210987654321098765432109876543210\",k = 5000) == 712104623\n assert candidate(s = \"123456789\",k = 100) == 55\n assert candidate(s = \"987654321\",k = 100000) == 236\n assert candidate(s = \"33333333333333333333\",k = 3333) == 283953\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().numberOfArrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numberOfArrays(string s, int k) {", "container": "Solution", "callable": "numberOfArrays", "parameters": [{"name": "s", "type": "string"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1417, "task_id": "reformat-the-string", "difficulty": "Easy", "problem_description": "You are given an alphanumeric string s. (Alphanumeric string is a string consisting of lowercase English letters and digits).\nYou have to find a permutation of the string where no letter is followed by another letter and no digit is followed by another digit. That is, no two adjacent characters have the same type.\nReturn the reformatted string or return an empty string if it is impossible to reformat the string.\n \nExample 1:\n\nInput: s = \"a0b1c2\"\nOutput: \"0a1b2c\"\nExplanation: No two adjacent characters have the same type in \"0a1b2c\". \"a0b1c2\", \"0a1b2c\", \"0c2a1b\" are also valid permutations.\n\nExample 2:\n\nInput: s = \"leetcode\"\nOutput: \"\"\nExplanation: \"leetcode\" has only characters so we cannot separate them by digits.\n\nExample 3:\n\nInput: s = \"1229857369\"\nOutput: \"\"\nExplanation: \"1229857369\" has only digits so we cannot separate them by characters.\n\n \nConstraints:\n\n1 <= s.length <= 500\ns consists of only lowercase English letters and/or digits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"a1b1\") == \"a1b1\"\n assert candidate(s = \"1229857369\") == \"\"\n assert candidate(s = \"aa1\") == \"a1a\"\n assert candidate(s = \"abc123def456\") == \"a1b2c3d4e5f6\"\n assert candidate(s = \"0123456789abcdefghijklmnopqrstuvwxyz\") == \"\"\n assert candidate(s = \"111\") == \"\"\n assert candidate(s = \"ab123\") == \"1a2b3\"\n assert candidate(s = \"1a\") == \"a1\"\n assert candidate(s = \"aabbcc123\") == \"\"\n assert candidate(s = \"a\") == \"a\"\n assert candidate(s = \"1234\") == \"\"\n assert candidate(s = \"a0b1c2d3e4f5g6h7i8j9\") == \"a0b1c2d3e4f5g6h7i8j9\"\n assert candidate(s = \"ab12cd34\") == \"a1b2c3d4\"\n assert candidate(s = \"a1\") == \"a1\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0\") == \"a1b2c3d4e5f6g7h8i9j0\"\n assert candidate(s = \"1a2b3c4d\") == \"a1b2c3d4\"\n assert candidate(s = \"ab\") == \"\"\n assert candidate(s = \"a0b1c2\") == \"a0b1c2\"\n assert candidate(s = \"1a2b3c\") == \"a1b2c3\"\n assert candidate(s = \"a1b2c3\") == \"a1b2c3\"\n assert candidate(s = \"abcd1234\") == \"a1b2c3d4\"\n assert candidate(s = \"112233aabbcc\") == \"a1a1b2b2c3c3\"\n assert candidate(s = \"aaa\") == \"\"\n assert candidate(s = \"leetcode\") == \"\"\n assert candidate(s = \"a1b2c3d4\") == \"a1b2c3d4\"\n assert candidate(s = \"11a\") == \"1a1\"\n assert candidate(s = \"112233aabb\") == \"\"\n assert candidate(s = \"1a2b3c4d5e\") == \"a1b2c3d4e5\"\n assert candidate(s = \"abc\") == \"\"\n assert candidate(s = \"111222abc\") == \"\"\n assert candidate(s = \"12\") == \"\"\n assert candidate(s = \"abcd\") == \"\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz0123456789\") == \"\"\n assert candidate(s = \"1\") == \"1\"\n assert candidate(s = \"aab\") == \"\"\n assert candidate(s = \"123abc\") == \"a1b2c3\"\n assert candidate(s = \"aabbcc112233\") == \"a1a1b2b2c3c3\"\n assert candidate(s = \"0a0b0c0d\") == \"a0b0c0d0\"\n assert candidate(s = \"123\") == \"\"\n assert candidate(s = \"1a1b\") == \"a1b1\"\n assert candidate(s = \"c0d1e2f3\") == \"c0d1e2f3\"\n assert candidate(s = \"1234abcd\") == \"a1b2c3d4\"\n assert candidate(s = \"zzzz1111\") == \"z1z1z1z1\"\n assert candidate(s = \"9a8b7c6d5e4f3g2h1i0\") == \"9a8b7c6d5e4f3g2h1i0\"\n assert candidate(s = \"0z6y5x4w3v2u1t0s9r8q7p6o5n4m3l2k1j0i9h8g7f6e5d4c3b2a1\") == \"0z6y5x4w3v2u1t0s9r8q7p6o5n4m3l2k1j0i9h8g7f6e5d4c3b2a1\"\n assert candidate(s = \"0000000000aaaaaaaaaa\") == \"a0a0a0a0a0a0a0a0a0a0\"\n assert candidate(s = \"abcdefghij123456789\") == \"a1b2c3d4e5f6g7h8i9j\"\n assert candidate(s = \"0j9i8h7g6f5e4d3c2b1a\") == \"j0i9h8g7f6e5d4c3b2a1\"\n assert candidate(s = \"9876543210qwerty\") == \"\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\") == \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\"\n assert candidate(s = \"123abc456def789ghi0\") == \"1a2b3c4d5e6f7g8h9i0\"\n assert candidate(s = \"90ijkl5678efgh1234abcd\") == \"\"\n assert candidate(s = \"a1b1c1d1e1f1g1h1i1j1k1\") == \"a1b1c1d1e1f1g1h1i1j1k1\"\n assert candidate(s = \"1z1y1x1w1v1u1t1s1r1q1p1o1n1m1l1k1j1i1h1g1f1e1d1c1b1a1\") == \"1z1y1x1w1v1u1t1s1r1q1p1o1n1m1l1k1j1i1h1g1f1e1d1c1b1a1\"\n assert candidate(s = \"9876543210zyxcba\") == \"\"\n assert candidate(s = \"abcde12345fghij67890\") == \"a1b2c3d4e5f6g7h8i9j0\"\n assert candidate(s = \"a1a2a3a4a5b1b2b3b4b5c1c2c3c4c5\") == \"a1a2a3a4a5b1b2b3b4b5c1c2c3c4c5\"\n assert candidate(s = \"000aaa111bbb222ccc\") == \"a0a0a0b1b1b1c2c2c2\"\n assert candidate(s = \"1234567890abcdefghijklmnopqrstuvwxyz\") == \"\"\n assert candidate(s = \"0a1b2c3d4e5f6g7h8i9j\") == \"a0b1c2d3e4f5g6h7i8j9\"\n assert candidate(s = \"aabbccddeeff11223344\") == \"\"\n assert candidate(s = \"a0b0c0d0e0f0g0h0i0j0\") == \"a0b0c0d0e0f0g0h0i0j0\"\n assert candidate(s = \"1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s\") == \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9\"\n assert candidate(s = \"a1a1a1b2b2b2\") == \"a1a1a1b2b2b2\"\n assert candidate(s = \"9876543210zyxwvutsrqponmlkjihgfedcba\") == \"\"\n assert candidate(s = \"aabbccddeeff112233445566\") == \"a1a1b2b2c3c3d4d4e5e5f6f6\"\n assert candidate(s = \"abc123abc123abc123\") == \"a1b2c3a1b2c3a1b2c3\"\n assert candidate(s = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\"\n assert candidate(s = \"1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == \"1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\"\n assert candidate(s = \"mnbvcxzlkjhgfdsapoiuytrewq0987654321\") == \"\"\n assert candidate(s = \"1111aaaa\") == \"a1a1a1a1\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9\") == \"a1b2c3d4e5f6g7h8i9\"\n assert candidate(s = \"1a2b3c4d5e6f\") == \"a1b2c3d4e5f6\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j\") == \"a1b2c3d4e5f6g7h8i9j\"\n assert candidate(s = \"0123456789abcdefghij\") == \"a0b1c2d3e4f5g6h7i8j9\"\n assert candidate(s = \"0a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t\") == \"a0b1c2d3e4f5g6h7i8j9k0l1m2n3o4p5q6r7s8t9\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6\") == \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6\"\n assert candidate(s = \"123456789abcdefghij\") == \"a1b2c3d4e5f6g7h8i9j\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0p1234567890\") == \"\"\n assert candidate(s = \"abcd1234efgh5678ijkl0987\") == \"a1b2c3d4e5f6g7h8i0j9k8l7\"\n assert candidate(s = \"aaaaaaaaa11111111\") == \"a1a1a1a1a1a1a1a1a\"\n assert candidate(s = \"abcd0123efgh4567ijkl89\") == \"\"\n assert candidate(s = \"1234abcd5678abcd\") == \"a1b2c3d4a5b6c7d8\"\n assert candidate(s = \"0987654321abcdef\") == \"\"\n assert candidate(s = \"0a0b0c0d0e0f0g0h0i0j0\") == \"0a0b0c0d0e0f0g0h0i0j0\"\n assert candidate(s = \"12345abcde67890fghij\") == \"a1b2c3d4e5f6g7h8i9j0\"\n assert candidate(s = \"11223344556677889900\") == \"\"\n assert candidate(s = \"abcdefg123456\") == \"a1b2c3d4e5f6g\"\n assert candidate(s = \"abcdefghij0123456789\") == \"a0b1c2d3e4f5g6h7i8j9\"\n assert candidate(s = \"a0b1c2d3\") == \"a0b1c2d3\"\n assert candidate(s = \"0987654321jihgfedcba\") == \"j0i9h8g7f6e5d4c3b2a1\"\n assert candidate(s = \"abcdef123456\") == \"a1b2c3d4e5f6\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k\") == \"a1b2c3d4e5f6g7h8i9j0k\"\n assert candidate(s = \"0a0b0c0d0e0f0g0h0i0j0k0\") == \"0a0b0c0d0e0f0g0h0i0j0k0\"\n assert candidate(s = \"abc123def456ghi789j0\") == \"a1b2c3d4e5f6g7h8i9j0\"\n assert candidate(s = \"1234567890qwertyuiopasdfghjklzxcvbnm\") == \"\"\n assert candidate(s = \"123456abcdef\") == \"a1b2c3d4e5f6\"\n assert candidate(s = \"112233445566778899aabbccddeeffgghhii\") == \"a1a1b2b2c3c3d4d4e5e5f6f6g7g7h8h8i9i9\"\n assert candidate(s = \"abcd1234abcd5678\") == \"a1b2c3d4a5b6c7d8\"\n assert candidate(s = \"abcd1234abcd1234\") == \"a1b2c3d4a1b2c3d4\"\n assert candidate(s = \"9876543210\") == \"\"\n assert candidate(s = \"121212abcabc\") == \"a1b2c1a2b1c2\"\n assert candidate(s = \"a1a1a1a1a1122334455\") == \"\"\n assert candidate(s = \"a1b1c1d1e1f1g1h1i1j1\") == \"a1b1c1d1e1f1g1h1i1j1\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0p\") == \"z9y8x7w6v5u4t3s2r1q0p\"\n assert candidate(s = \"abc123def456ghi789\") == \"a1b2c3d4e5f6g7h8i9\"\n assert candidate(s = \"aaaaaaaaaabbbbbbbbccccccccdddddddd\") == \"\"\n assert candidate(s = \"0abcdefghij123456789\") == \"a0b1c2d3e4f5g6h7i8j9\"\n assert candidate(s = \"1a2a3a4a5a\") == \"a1a2a3a4a5\"\n assert candidate(s = \"abcdefghij1234567890\") == \"a1b2c3d4e5f6g7h8i9j0\"\n assert candidate(s = \"012345abcde67890fghij\") == \"0a1b2c3d4e5f6g7h8i9j0\"\n assert candidate(s = \"1a2b3c4d5\") == \"1a2b3c4d5\"\n assert candidate(s = \"1234abcd1234abcd\") == \"a1b2c3d4a1b2c3d4\"\n assert candidate(s = \"a1b2a1b2a1b2a1b2\") == \"a1b2a1b2a1b2a1b2\"\n assert candidate(s = \"000aaa111bbb222ccc333ddd\") == \"a0a0a0b1b1b1c2c2c2d3d3d3\"\n assert candidate(s = \"abcd1234efgh5678ijkl90\") == \"\"\n assert candidate(s = \"abcdefghij\") == \"\"\n assert candidate(s = \"abcdefghij12345678901\") == \"1a2b3c4d5e6f7g8h9i0j1\"\n assert candidate(s = \"aabbccddeeffgghhiijj\") == \"\"\n assert candidate(s = \"123abc456def789ghi0jkl\") == \"\"\n assert candidate(s = \"9a8b7c6d\") == \"a9b8c7d6\"\n assert candidate(s = \"1234567890\") == \"\"\n assert candidate(s = \"a1a2a3a4a5a6a7a8a9\") == \"a1a2a3a4a5a6a7a8a9\"\n assert candidate(s = \"a0b0c0d0e0f0g0h0i0j0k0l0m0n0o0p0q0r0s0t0u0v0w0x0y0z0\") == \"a0b0c0d0e0f0g0h0i0j0k0l0m0n0o0p0q0r0s0t0u0v0w0x0y0z0\"\n assert candidate(s = \"0u1v2w3x4y5z6a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\") == \"0u1v2w3x4y5z6a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\"\n assert candidate(s = \"1a2b3c4d5e6f7g8h9i0j\") == \"a1b2c3d4e5f6g7h8i9j0\"\n assert candidate(s = \"00112233445566778899\") == \"\"\n assert candidate(s = \"1234567890abcdefghij\") == \"a1b2c3d4e5f6g7h8i9j0\"\n assert candidate(s = \"11111111111111111111aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == \"\"\n assert candidate(s = \"xyz987uvw654tsr321\") == \"x9y8z7u6v5w4t3s2r1\"\n assert candidate(s = \"zzzzzzzzz99999999\") == \"z9z9z9z9z9z9z9z9z\"\n assert candidate(s = \"abc123\") == \"a1b2c3\"\n assert candidate(s = \"abcdef1234567890\") == \"\"\n assert candidate(s = \"1a2b3c4d5e6f7g8h9i\") == \"a1b2c3d4e5f6g7h8i9\"\n assert candidate(s = \"0000aaaa\") == \"a0a0a0a0\"\n assert candidate(s = \"654321fedcba\") == \"f6e5d4c3b2a1\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().reformat", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string reformat(string s) {", "container": "Solution", "callable": "reformat", "parameters": [{"name": "s", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1418, "task_id": "display-table-of-food-orders-in-a-restaurant", "difficulty": "Medium", "problem_description": "Given the array orders, which represents the orders that customers have done in a restaurant. More specifically orders[i]=[customerNamei,tableNumberi,foodItemi] where customerNamei is the name of the customer, tableNumberi is the table customer sit at, and foodItemi is the item customer orders.\\r\n\\r\nReturn the restaurant's “display table”. The “display table” is a table whose row entries denote how many of each food item each table ordered. The first column is the table number and the remaining columns correspond to each food item in alphabetical order. The first row should be a header whose first column is “Table”, followed by the names of the food items. Note that the customer names are not part of the table. Additionally, the rows should be sorted in numerically increasing order.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: orders = [[\"David\",\"3\",\"Ceviche\"],[\"Corina\",\"10\",\"Beef Burrito\"],[\"David\",\"3\",\"Fried Chicken\"],[\"Carla\",\"5\",\"Water\"],[\"Carla\",\"5\",\"Ceviche\"],[\"Rous\",\"3\",\"Ceviche\"]]\\r\nOutput: [[\"Table\",\"Beef Burrito\",\"Ceviche\",\"Fried Chicken\",\"Water\"],[\"3\",\"0\",\"2\",\"1\",\"0\"],[\"5\",\"0\",\"1\",\"0\",\"1\"],[\"10\",\"1\",\"0\",\"0\",\"0\"]] \\r\nExplanation:\\r\nThe displaying table looks like:\\r\nTable,Beef Burrito,Ceviche,Fried Chicken,Water\\r\n3 ,0 ,2 ,1 ,0\\r\n5 ,0 ,1 ,0 ,1\\r\n10 ,1 ,0 ,0 ,0\\r\nFor the table 3: David orders \"Ceviche\" and \"Fried Chicken\", and Rous orders \"Ceviche\".\\r\nFor the table 5: Carla orders \"Water\" and \"Ceviche\".\\r\nFor the table 10: Corina orders \"Beef Burrito\". \\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: orders = [[\"James\",\"12\",\"Fried Chicken\"],[\"Ratesh\",\"12\",\"Fried Chicken\"],[\"Amadeus\",\"12\",\"Fried Chicken\"],[\"Adam\",\"1\",\"Canadian Waffles\"],[\"Brianna\",\"1\",\"Canadian Waffles\"]]\\r\nOutput: [[\"Table\",\"Canadian Waffles\",\"Fried Chicken\"],[\"1\",\"2\",\"0\"],[\"12\",\"0\",\"3\"]] \\r\nExplanation: \\r\nFor the table 1: Adam and Brianna order \"Canadian Waffles\".\\r\nFor the table 12: James, Ratesh and Amadeus order \"Fried Chicken\".\\r\n\\r\n\\r\nExample 3:\\r\n\\r\n\\r\nInput: orders = [[\"Laura\",\"2\",\"Bean Burrito\"],[\"Jhon\",\"2\",\"Beef Burrito\"],[\"Melissa\",\"2\",\"Soda\"]]\\r\nOutput: [[\"Table\",\"Bean Burrito\",\"Beef Burrito\",\"Soda\"],[\"2\",\"1\",\"1\",\"1\"]]\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= orders.length <= 5 * 10^4\\r\n\torders[i].length == 3\\r\n\t1 <= customerNamei.length, foodItemi.length <= 20\\r\n\tcustomerNamei and foodItemi consist of lowercase and uppercase English letters and the space character.\\r\n\ttableNumberi is a valid integer between 1 and 500.\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(orders = [['Alice', '2', 'Veggie Delight'], ['Bob', '1', 'Salmon'], ['Charlie', '2', 'Salmon'], ['David', '3', 'Veggie Delight'], ['Eve', '3', 'Salmon']]) == [['Table', 'Salmon', 'Veggie Delight'], ['1', '1', '0'], ['2', '1', '1'], ['3', '1', '1']]\n assert candidate(orders = [['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight']]) == [['Table', 'Beef Burrito', 'Spring Roll', 'Veggie Delight'], ['1', '1', '1', '1'], ['2', '1', '0', '1']]\n assert candidate(orders = [['Laura', '2', 'Bean Burrito'], ['Jhon', '2', 'Beef Burrito'], ['Melissa', '2', 'Soda']]) == [['Table', 'Bean Burrito', 'Beef Burrito', 'Soda'], ['2', '1', '1', '1']]\n assert candidate(orders = [['David', '3', 'Ceviche'], ['Corina', '10', 'Beef Burrito'], ['David', '3', 'Fried Chicken'], ['Carla', '5', 'Water'], ['Carla', '5', 'Ceviche'], ['Rous', '3', 'Ceviche']]) == [['Table', 'Beef Burrito', 'Ceviche', 'Fried Chicken', 'Water'], ['3', '0', '2', '1', '0'], ['5', '0', '1', '0', '1'], ['10', '1', '0', '0', '0']]\n assert candidate(orders = [['James', '12', 'Fried Chicken'], ['Ratesh', '12', 'Fried Chicken'], ['Amadeus', '12', 'Fried Chicken'], ['Adam', '1', 'Canadian Waffles'], ['Brianna', '1', 'Canadian Waffles']]) == [['Table', 'Canadian Waffles', 'Fried Chicken'], ['1', '2', '0'], ['12', '0', '3']]\n assert candidate(orders = [['Sam', '2', 'Chocolate Cake'], ['Anna', '4', 'Fried Chicken'], ['Elsa', '4', 'Chocolate Cake'], ['Olaf', '2', 'Fried Chicken'], ['Kristoff', '4', 'Veggie Delight'], ['Sven', '2', 'Beef Burrito'], ['Hans', '4', 'Beef Burrito'], ['Kristoff', '2', 'Beef Burrito'], ['Anna', '1', 'Spring Roll'], ['Kristoff', '1', 'Fried Chicken'], ['Sven', '1', 'Chocolate Cake'], ['Olaf', '3', 'Veggie Delight'], ['Hans', '3', 'Beef Burrito'], ['Kristoff', '3', 'Beef Burrito'], ['Anna', '3', 'Chocolate Cake'], ['Elsa', '3', 'Spring Roll'], ['Olaf', '1', 'Veggie Delight'], ['Hans', '2', 'Fried Chicken']]) == [['Table', 'Beef Burrito', 'Chocolate Cake', 'Fried Chicken', 'Spring Roll', 'Veggie Delight'], ['1', '0', '1', '1', '1', '1'], ['2', '2', '1', '2', '0', '0'], ['3', '2', '1', '0', '1', '1'], ['4', '1', '1', '1', '0', '1']]\n assert candidate(orders = [['Ella', '1', 'Egg Muffin'], ['Nathan', '2', 'Bagel Sandwich'], ['Ella', '1', 'Egg Muffin'], ['Nathan', '2', 'Bagel Sandwich'], ['Ella', '1', 'Bagel Sandwich'], ['Nathan', '2', 'Egg Muffin'], ['Ella', '1', 'Tomato Juice'], ['Nathan', '2', 'Tomato Juice'], ['Ella', '1', 'Bagel Sandwich'], ['Nathan', '2', 'Egg Muffin'], ['Ella', '1', 'Tomato Juice'], ['Nathan', '2', 'Bagel Sandwich'], ['Ella', '1', 'Chicken Salad'], ['Nathan', '2', 'Chicken Salad'], ['Ella', '1', 'Tomato Juice'], ['Nathan', '2', 'Egg Muffin'], ['Ella', '1', 'Chicken Salad'], ['Nathan', '2', 'Bagel Sandwich'], ['Ella', '1', 'Tomato Juice'], ['Nathan', '2', 'Chicken Salad']]) == [['Table', 'Bagel Sandwich', 'Chicken Salad', 'Egg Muffin', 'Tomato Juice'], ['1', '2', '2', '2', '4'], ['2', '4', '2', '3', '1']]\n assert candidate(orders = [['Alice', '1', 'Beef Burrito'], ['Bob', '2', 'Chicken Curry'], ['Charlie', '3', 'Shrimp Fried Rice'], ['David', '4', 'Spicy Noodles'], ['Eve', '5', 'Vegetable Stir Fry'], ['Frank', '1', 'Beef Burrito'], ['Grace', '2', 'Chicken Curry'], ['Hank', '3', 'Shrimp Fried Rice'], ['Ivy', '4', 'Spicy Noodles'], ['Jack', '5', 'Vegetable Stir Fry'], ['Kathy', '1', 'Beef Burrito'], ['Leo', '2', 'Chicken Curry'], ['Mona', '3', 'Shrimp Fried Rice'], ['Nate', '4', 'Spicy Noodles'], ['Oscar', '5', 'Vegetable Stir Fry']]) == [['Table', 'Beef Burrito', 'Chicken Curry', 'Shrimp Fried Rice', 'Spicy Noodles', 'Vegetable Stir Fry'], ['1', '3', '0', '0', '0', '0'], ['2', '0', '3', '0', '0', '0'], ['3', '0', '0', '3', '0', '0'], ['4', '0', '0', '0', '3', '0'], ['5', '0', '0', '0', '0', '3']]\n assert candidate(orders = [['John', '1', 'Chocolate Cake'], ['Alice', '2', 'Vanilla Ice Cream'], ['Bob', '3', 'Strawberry Shake'], ['Charlie', '4', 'Chocolate Cake'], ['David', '5', 'Vanilla Ice Cream'], ['Eve', '6', 'Strawberry Shake'], ['Frank', '7', 'Chocolate Cake'], ['Grace', '8', 'Vanilla Ice Cream'], ['Hannah', '9', 'Strawberry Shake'], ['Ian', '10', 'Chocolate Cake'], ['Jack', '11', 'Vanilla Ice Cream'], ['Katherine', '12', 'Strawberry Shake'], ['Laura', '13', 'Chocolate Cake'], ['Michael', '14', 'Vanilla Ice Cream'], ['Nancy', '15', 'Strawberry Shake'], ['Oliver', '16', 'Chocolate Cake'], ['Penelope', '17', 'Vanilla Ice Cream'], ['Quinn', '18', 'Strawberry Shake'], ['Rachel', '19', 'Chocolate Cake'], ['Sam', '20', 'Vanilla Ice Cream'], ['Trent', '21', 'Strawberry Shake'], ['Uma', '22', 'Chocolate Cake'], ['Victor', '23', 'Vanilla Ice Cream'], ['Wendy', '24', 'Strawberry Shake'], ['Xander', '25', 'Chocolate Cake'], ['Yvonne', '26', 'Vanilla Ice Cream'], ['Zane', '27', 'Strawberry Shake']]) == [['Table', 'Chocolate Cake', 'Strawberry Shake', 'Vanilla Ice Cream'], ['1', '1', '0', '0'], ['2', '0', '0', '1'], ['3', '0', '1', '0'], ['4', '1', '0', '0'], ['5', '0', '0', '1'], ['6', '0', '1', '0'], ['7', '1', '0', '0'], ['8', '0', '0', '1'], ['9', '0', '1', '0'], ['10', '1', '0', '0'], ['11', '0', '0', '1'], ['12', '0', '1', '0'], ['13', '1', '0', '0'], ['14', '0', '0', '1'], ['15', '0', '1', '0'], ['16', '1', '0', '0'], ['17', '0', '0', '1'], ['18', '0', '1', '0'], ['19', '1', '0', '0'], ['20', '0', '0', '1'], ['21', '0', '1', '0'], ['22', '1', '0', '0'], ['23', '0', '0', '1'], ['24', '0', '1', '0'], ['25', '1', '0', '0'], ['26', '0', '0', '1'], ['27', '0', '1', '0']]\n assert candidate(orders = [['Laura', '10', 'Chocolate Cake'], ['Laura', '10', 'Chocolate Cake'], ['Laura', '10', 'Vanilla Ice Cream'], ['Laura', '20', 'Vanilla Ice Cream'], ['Laura', '20', 'Chocolate Cake'], ['Laura', '20', 'Chocolate Cake'], ['Laura', '30', 'Chocolate Cake'], ['Laura', '30', 'Vanilla Ice Cream'], ['Laura', '30', 'Vanilla Ice Cream'], ['Laura', '30', 'Vanilla Ice Cream']]) == [['Table', 'Chocolate Cake', 'Vanilla Ice Cream'], ['10', '2', '1'], ['20', '2', '1'], ['30', '1', '3']]\n assert candidate(orders = [['Zoe', '10', 'Ice Cream'], ['Chris', '15', 'Water'], ['Diana', '10', 'Ice Cream'], ['Eli', '20', 'Beef Burrito'], ['Finn', '15', 'Water'], ['George', '20', 'Beef Burrito'], ['Hannah', '10', 'Water'], ['Ian', '20', 'Ice Cream'], ['Jack', '15', 'Ice Cream'], ['Katie', '10', 'Beef Burrito'], ['Lucas', '20', 'Water'], ['Mia', '15', 'Ice Cream'], ['Noah', '10', 'Beef Burrito'], ['Oliver', '20', 'Water'], ['Penelope', '15', 'Ice Cream'], ['Quinn', '10', 'Beef Burrito'], ['Ryan', '20', 'Water'], ['Sophia', '15', 'Ice Cream'], ['Thomas', '10', 'Beef Burrito'], ['Uma', '20', 'Water'], ['Victor', '15', 'Ice Cream'], ['Will', '10', 'Beef Burrito'], ['Xander', '20', 'Water'], ['Yara', '15', 'Ice Cream'], ['Zane', '10', 'Beef Burrito']]) == [['Table', 'Beef Burrito', 'Ice Cream', 'Water'], ['10', '6', '2', '1'], ['15', '0', '6', '2'], ['20', '2', '1', '5']]\n assert candidate(orders = [['Emily', '1', 'Garden Salad'], ['Madison', '2', 'Grilled Cheese'], ['Emily', '3', 'Club Sandwich'], ['Madison', '1', 'Club Sandwich'], ['Emily', '2', 'Grilled Cheese'], ['Madison', '3', 'Garden Salad'], ['Avery', '1', 'Caesar Salad'], ['Chloe', '2', 'Chicken Salad'], ['Avery', '3', 'Grilled Cheese'], ['Chloe', '1', 'Club Sandwich'], ['Avery', '2', 'Garden Salad'], ['Chloe', '3', 'Caesar Salad'], ['Hannah', '1', 'Chicken Salad'], ['Ella', '2', 'Caesar Salad'], ['Hannah', '3', 'Grilled Cheese'], ['Ella', '1', 'Garden Salad'], ['Hannah', '2', 'Club Sandwich'], ['Ella', '3', 'Chicken Salad']]) == [['Table', 'Caesar Salad', 'Chicken Salad', 'Club Sandwich', 'Garden Salad', 'Grilled Cheese'], ['1', '1', '1', '2', '2', '0'], ['2', '1', '1', '1', '1', '2'], ['3', '1', '1', '1', '1', '2']]\n assert candidate(orders = [['Sophia', '15', 'Penne Arrabbiata'], ['Ava', '15', 'Margherita Pizza'], ['Mia', '15', 'Penne Arrabbiata'], ['Ella', '15', 'Margherita Pizza'], ['Olivia', '15', 'Margherita Pizza'], ['Sophia', '16', 'Caesar Salad'], ['Ava', '16', 'Caesar Salad'], ['Mia', '16', 'Penne Arrabbiata'], ['Ella', '16', 'Caesar Salad'], ['Olivia', '16', 'Penne Arrabbiata'], ['Sophia', '17', 'Tiramisu'], ['Ava', '17', 'Penne Arrabbiata'], ['Mia', '17', 'Caesar Salad'], ['Ella', '17', 'Tiramisu'], ['Olivia', '17', 'Margherita Pizza'], ['Sophia', '18', 'Vanilla Ice Cream'], ['Ava', '18', 'Tiramisu'], ['Mia', '18', 'Caesar Salad'], ['Ella', '18', 'Vanilla Ice Cream'], ['Olivia', '18', 'Margherita Pizza'], ['Sophia', '19', 'Penne Arrabbiata'], ['Ava', '19', 'Vanilla Ice Cream'], ['Mia', '19', 'Caesar Salad'], ['Ella', '19', 'Margherita Pizza'], ['Olivia', '19', 'Penne Arrabbiata']]) == [['Table', 'Caesar Salad', 'Margherita Pizza', 'Penne Arrabbiata', 'Tiramisu', 'Vanilla Ice Cream'], ['15', '0', '3', '2', '0', '0'], ['16', '3', '0', '2', '0', '0'], ['17', '1', '1', '1', '2', '0'], ['18', '1', '1', '0', '1', '2'], ['19', '1', '1', '2', '0', '1']]\n assert candidate(orders = [['Alice', '10', 'Beef Burrito'], ['Bob', '5', 'Spring Roll'], ['Charlie', '10', 'Spring Roll'], ['David', '3', 'Beef Burrito'], ['Eve', '3', 'Spring Roll'], ['Frank', '5', 'Veggie Delight'], ['Grace', '1', 'Beef Burrito'], ['Heidi', '5', 'Beef Burrito'], ['Ivy', '1', 'Spring Roll'], ['Jack', '3', 'Veggie Delight']]) == [['Table', 'Beef Burrito', 'Spring Roll', 'Veggie Delight'], ['1', '1', '1', '0'], ['3', '1', '1', '1'], ['5', '1', '1', '1'], ['10', '1', '1', '0']]\n assert candidate(orders = [['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight'], ['Jerry', '3', 'Spring Roll'], ['Anna', '3', 'Beef Burrito'], ['Tom', '3', 'Veggie Delight'], ['Jerry', '2', 'Spring Roll']]) == [['Table', 'Beef Burrito', 'Spring Roll', 'Veggie Delight'], ['1', '1', '1', '1'], ['2', '1', '1', '1'], ['3', '1', '1', '1']]\n assert candidate(orders = [['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight'], ['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight'], ['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight'], ['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight'], ['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight']]) == [['Table', 'Beef Burrito', 'Spring Roll', 'Veggie Delight'], ['1', '5', '5', '5'], ['2', '5', '0', '5']]\n assert candidate(orders = [['Zach', '1', 'Spaghetti Carbonara'], ['Kyle', '2', 'Margherita Pizza'], ['Zach', '3', 'Caesar Salad'], ['Kyle', '1', 'Caesar Salad'], ['Zach', '2', 'Margherita Pizza'], ['Kyle', '3', 'Spaghetti Carbonara'], ['Mia', '1', 'Lasagna'], ['Noah', '2', 'Caesar Salad'], ['Mia', '3', 'Margherita Pizza'], ['Noah', '1', 'Spaghetti Carbonara'], ['Mia', '2', 'Lasagna'], ['Noah', '3', 'Caesar Salad'], ['Isabella', '1', 'Margherita Pizza'], ['Oliver', '2', 'Spaghetti Carbonara'], ['Isabella', '3', 'Caesar Salad'], ['Oliver', '1', 'Lasagna'], ['Isabella', '2', 'Margherita Pizza'], ['Oliver', '3', 'Spaghetti Carbonara']]) == [['Table', 'Caesar Salad', 'Lasagna', 'Margherita Pizza', 'Spaghetti Carbonara'], ['1', '1', '2', '1', '2'], ['2', '1', '1', '3', '1'], ['3', '3', '0', '1', '2']]\n assert candidate(orders = [['Amy', '5', 'Taco'], ['Brian', '4', 'Taco'], ['Chris', '5', 'Grilled Cheese'], ['Dan', '4', 'Taco'], ['Eli', '6', 'Grilled Cheese'], ['Fiona', '4', 'Salad'], ['George', '6', 'Salad'], ['Hannah', '4', 'Grilled Cheese'], ['Ian', '5', 'Salad']]) == [['Table', 'Grilled Cheese', 'Salad', 'Taco'], ['4', '1', '1', '2'], ['5', '1', '1', '1'], ['6', '1', '1', '0']]\n assert candidate(orders = [['Zoe', '1', 'Chicken Curry'], ['Jackson', '1', 'Prawn Curry'], ['Ava', '2', 'Chicken Curry'], ['Noah', '2', 'Prawn Curry'], ['James', '2', 'Chicken Curry'], ['Sophia', '3', 'Chicken Curry'], ['Mia', '3', 'Prawn Curry'], ['Emma', '3', 'Chicken Curry'], ['Olivia', '3', 'Chicken Curry'], ['Jackson', '4', 'Chicken Curry'], ['Zoe', '4', 'Prawn Curry'], ['Ava', '4', 'Chicken Curry'], ['Noah', '4', 'Prawn Curry'], ['James', '4', 'Chicken Curry'], ['Sophia', '4', 'Chicken Curry'], ['Mia', '4', 'Prawn Curry'], ['Emma', '4', 'Chicken Curry'], ['Olivia', '4', 'Chicken Curry'], ['Jackson', '5', 'Chicken Curry'], ['Zoe', '5', 'Prawn Curry'], ['Ava', '5', 'Chicken Curry'], ['Noah', '5', 'Prawn Curry'], ['James', '5', 'Chicken Curry'], ['Sophia', '5', 'Chicken Curry'], ['Mia', '5', 'Prawn Curry'], ['Emma', '5', 'Chicken Curry'], ['Olivia', '5', 'Chicken Curry']]) == [['Table', 'Chicken Curry', 'Prawn Curry'], ['1', '1', '1'], ['2', '2', '1'], ['3', '3', '1'], ['4', '6', '3'], ['5', '6', '3']]\n assert candidate(orders = [['Sam', '10', 'Steak'], ['Alex', '20', 'Pasta'], ['Chris', '10', 'Salmon'], ['Rachel', '20', 'Steak'], ['Mike', '30', 'Lasagna'], ['Liz', '10', 'Pasta'], ['Jake', '20', 'Salmon'], ['Amy', '30', 'Steak'], ['Tom', '10', 'Lasagna'], ['Jessica', '20', 'Pasta'], ['Scott', '30', 'Salmon'], ['Melissa', '10', 'Steak'], ['Chris', '20', 'Lasagna'], ['Samantha', '30', 'Pasta'], ['Neil', '10', 'Salmon'], ['James', '20', 'Steak'], ['Ava', '30', 'Lasagna'], ['Eric', '10', 'Pasta'], ['Sophia', '20', 'Salmon'], ['Daniel', '30', 'Steak'], ['Ella', '10', 'Lasagna'], ['Andrew', '20', 'Pasta'], ['Isabella', '30', 'Salmon'], ['Matthew', '10', 'Steak'], ['Olivia', '20', 'Lasagna'], ['William', '30', 'Pasta'], ['Ava', '10', 'Salmon'], ['Mia', '20', 'Steak'], ['Elijah', '30', 'Lasagna'], ['Emma', '10', 'Pasta'], ['Ethan', '20', 'Salmon'], ['Alexander', '30', 'Steak'], ['Sophia', '10', 'Lasagna'], ['Benjamin', '20', 'Pasta'], ['Abigail', '30', 'Salmon'], ['Daniel', '10', 'Steak']]) == [['Table', 'Lasagna', 'Pasta', 'Salmon', 'Steak'], ['10', '3', '3', '3', '4'], ['20', '2', '4', '3', '3'], ['30', '3', '2', '3', '3']]\n assert candidate(orders = [['Michael', '1', 'Margherita Pizza'], ['Emily', '1', 'Caesar Salad'], ['John', '2', 'Margherita Pizza'], ['John', '2', 'Caesar Salad'], ['Sarah', '3', 'Caesar Salad'], ['David', '4', 'Margherita Pizza'], ['David', '4', 'Caesar Salad'], ['David', '4', 'Tiramisu']]) == [['Table', 'Caesar Salad', 'Margherita Pizza', 'Tiramisu'], ['1', '1', '1', '0'], ['2', '1', '1', '0'], ['3', '1', '0', '0'], ['4', '1', '1', '1']]\n assert candidate(orders = [['Anna', '300', 'Eggplant Parmesan'], ['Bob', '300', 'Lasagna'], ['Charlie', '300', 'Eggplant Parmesan'], ['David', '299', 'Lasagna'], ['Eve', '299', 'Eggplant Parmesan'], ['Frank', '298', 'Eggplant Parmesan'], ['Grace', '298', 'Lasagna'], ['Heidi', '298', 'Eggplant Parmesan'], ['Ian', '297', 'Lasagna'], ['Jenny', '297', 'Eggplant Parmesan'], ['Katie', '297', 'Lasagna'], ['Leo', '297', 'Eggplant Parmesan'], ['Mandy', '296', 'Eggplant Parmesan'], ['Neil', '296', 'Lasagna'], ['Oliver', '296', 'Eggplant Parmesan'], ['Paul', '295', 'Eggplant Parmesan'], ['Quincy', '295', 'Lasagna'], ['Rachel', '295', 'Eggplant Parmesan'], ['Steve', '295', 'Lasagna'], ['Tina', '294', 'Eggplant Parmesan'], ['Uma', '294', 'Lasagna'], ['Victor', '294', 'Eggplant Parmesan'], ['Wanda', '294', 'Lasagna'], ['Xander', '293', 'Eggplant Parmesan'], ['Yvonne', '293', 'Lasagna'], ['Zane', '293', 'Eggplant Parmesan'], ['Aaron', '292', 'Eggplant Parmesan'], ['Ben', '292', 'Lasagna'], ['Charlie', '292', 'Eggplant Parmesan'], ['David', '292', 'Lasagna'], ['Eve', '291', 'Eggplant Parmesan'], ['Frank', '291', 'Lasagna'], ['Grace', '291', 'Eggplant Parmesan'], ['Hannah', '291', 'Eggplant Parmesan'], ['Ian', '290', 'Eggplant Parmesan'], ['Jack', '290', 'Lasagna'], ['Karen', '289', 'Eggplant Parmesan'], ['Leo', '289', 'Lasagna'], ['Maggie', '288', 'Eggplant Parmesan'], ['Nancy', '288', 'Lasagna'], ['Oscar', '287', 'Eggplant Parmesan'], ['Paul', '287', 'Lasagna'], ['Quinn', '286', 'Eggplant Parmesan'], ['Rachel', '286', 'Lasagna'], ['Steve', '285', 'Eggplant Parmesan'], ['Tina', '285', 'Lasagna'], ['Uma', '284', 'Eggplant Parmesan'], ['Victor', '284', 'Lasagna'], ['Wanda', '283', 'Eggplant Parmesan'], ['Xander', '283', 'Lasagna'], ['Yvonne', '282', 'Eggplant Parmesan'], ['Zane', '282', 'Lasagna']]) == [['Table', 'Eggplant Parmesan', 'Lasagna'], ['282', '1', '1'], ['283', '1', '1'], ['284', '1', '1'], ['285', '1', '1'], ['286', '1', '1'], ['287', '1', '1'], ['288', '1', '1'], ['289', '1', '1'], ['290', '1', '1'], ['291', '3', '1'], ['292', '2', '2'], ['293', '2', '1'], ['294', '2', '2'], ['295', '2', '2'], ['296', '2', '1'], ['297', '2', '2'], ['298', '2', '1'], ['299', '1', '1'], ['300', '2', '1']]\n assert candidate(orders = [['Sarah', '1', 'Steak'], ['Jessica', '2', 'Pasta'], ['Sarah', '3', 'Sushi'], ['Jessica', '1', 'Sushi'], ['Sarah', '2', 'Pasta'], ['Jessica', '3', 'Steak'], ['Emma', '1', 'Veggie Soup'], ['Olivia', '2', 'Steak'], ['Emma', '3', 'Pasta'], ['Olivia', '1', 'Sushi'], ['Emma', '2', 'Veggie Soup'], ['Olivia', '3', 'Steak'], ['Ava', '1', 'Sushi'], ['Sophia', '2', 'Veggie Soup'], ['Ava', '3', 'Steak'], ['Sophia', '1', 'Pasta'], ['Ava', '2', 'Sushi'], ['Sophia', '3', 'Veggie Soup']]) == [['Table', 'Pasta', 'Steak', 'Sushi', 'Veggie Soup'], ['1', '1', '1', '3', '1'], ['2', '2', '1', '1', '2'], ['3', '1', '3', '1', '1']]\n assert candidate(orders = [['Amy', '100', 'Lasagna'], ['Ben', '150', 'Pasta'], ['Cathy', '100', 'Salad'], ['Dan', '200', 'Lasagna'], ['Eve', '150', 'Pasta'], ['Frank', '200', 'Salad'], ['Grace', '100', 'Pasta'], ['Hank', '150', 'Salad'], ['Ivy', '200', 'Pasta'], ['Jack', '100', 'Salad'], ['Kara', '150', 'Pasta'], ['Liam', '200', 'Lasagna'], ['Mia', '100', 'Pasta'], ['Noam', '150', 'Salad'], ['Olivia', '200', 'Pasta'], ['Paul', '100', 'Salad'], ['Quinn', '150', 'Pasta'], ['Remy', '200', 'Lasagna'], ['Sara', '100', 'Pasta'], ['Tom', '150', 'Salad'], ['Ula', '200', 'Pasta'], ['Victor', '100', 'Salad'], ['Will', '150', 'Pasta'], ['Xena', '200', 'Lasagna'], ['Yara', '100', 'Pasta'], ['Zane', '150', 'Salad']]) == [['Table', 'Lasagna', 'Pasta', 'Salad'], ['100', '1', '4', '4'], ['150', '0', '5', '4'], ['200', '4', '3', '1']]\n assert candidate(orders = [['Jack', '1', 'Steak'], ['Karen', '2', 'Sushi'], ['Leo', '1', 'Sushi'], ['Maggie', '3', 'Steak'], ['Nancy', '2', 'Salmon'], ['Oscar', '3', 'Salmon'], ['Paul', '1', 'Sushi'], ['Quinn', '3', 'Salmon'], ['Rachel', '2', 'Steak'], ['Steve', '1', 'Steak'], ['Tina', '2', 'Salmon'], ['Uma', '3', 'Steak'], ['Victor', '1', 'Sushi'], ['Wanda', '3', 'Salmon'], ['Xander', '2', 'Steak'], ['Yvonne', '1', 'Salmon'], ['Zane', '3', 'Steak']]) == [['Table', 'Salmon', 'Steak', 'Sushi'], ['1', '1', '2', '3'], ['2', '2', '2', '1'], ['3', '3', '3', '0']]\n assert candidate(orders = [['Michael', '10', 'Pasta'], ['Emily', '10', 'Spaghetti Carbonara'], ['Noah', '20', 'Pasta'], ['Olivia', '20', 'Caesar Salad'], ['Daniel', '10', 'Caesar Salad'], ['Ava', '30', 'Spaghetti Carbonara'], ['James', '30', 'Pasta'], ['Sophia', '40', 'Caesar Salad'], ['Benjamin', '40', 'Pasta'], ['Isabella', '10', 'Pasta']]) == [['Table', 'Caesar Salad', 'Pasta', 'Spaghetti Carbonara'], ['10', '1', '2', '1'], ['20', '1', '1', '0'], ['30', '0', '1', '1'], ['40', '1', '1', '0']]\n assert candidate(orders = [['Aaron', '10', 'Fajitas'], ['Ben', '10', 'Margherita Pizza'], ['Charlie', '10', 'Fajitas'], ['Dan', '9', 'Margherita Pizza'], ['Eve', '9', 'Fajitas'], ['Frank', '8', 'Spaghetti Carbonara'], ['Grace', '8', 'Margherita Pizza'], ['Heidi', '8', 'Spaghetti Carbonara'], ['Ian', '7', 'Fajitas'], ['Jenny', '7', 'Margherita Pizza'], ['Katie', '7', 'Spaghetti Carbonara'], ['Leo', '7', 'Margherita Pizza'], ['Mandy', '6', 'Fajitas'], ['Neil', '6', 'Spaghetti Carbonara'], ['Oliver', '6', 'Margherita Pizza'], ['Paul', '5', 'Fajitas'], ['Quincy', '5', 'Margherita Pizza'], ['Rachel', '5', 'Spaghetti Carbonara'], ['Steve', '5', 'Margherita Pizza'], ['Tina', '4', 'Fajitas'], ['Uma', '4', 'Margherita Pizza'], ['Victor', '4', 'Spaghetti Carbonara'], ['Wanda', '4', 'Margherita Pizza'], ['Xander', '3', 'Fajitas'], ['Yvonne', '3', 'Margherita Pizza'], ['Zane', '3', 'Spaghetti Carbonara'], ['Aaron', '2', 'Fajitas'], ['Ben', '2', 'Margherita Pizza'], ['Charlie', '2', 'Spaghetti Carbonara'], ['Dan', '2', 'Margherita Pizza'], ['Eve', '2', 'Fajitas'], ['Frank', '1', 'Spaghetti Carbonara'], ['Grace', '1', 'Margherita Pizza'], ['Heidi', '1', 'Fajitas'], ['Ian', '1', 'Margherita Pizza']]) == [['Table', 'Fajitas', 'Margherita Pizza', 'Spaghetti Carbonara'], ['1', '1', '2', '1'], ['2', '2', '2', '1'], ['3', '1', '1', '1'], ['4', '1', '2', '1'], ['5', '1', '2', '1'], ['6', '1', '1', '1'], ['7', '1', '2', '1'], ['8', '0', '1', '2'], ['9', '1', '1', '0'], ['10', '2', '1', '0']]\n assert candidate(orders = [['Alice', '100', 'Beef Burrito'], ['Bob', '200', 'Chicken Curry'], ['Charlie', '300', 'Shrimp Fried Rice'], ['David', '400', 'Spicy Noodles'], ['Eve', '500', 'Vegetable Stir Fry'], ['Frank', '100', 'Beef Burrito'], ['Grace', '200', 'Chicken Curry'], ['Hank', '300', 'Shrimp Fried Rice'], ['Ivy', '400', 'Spicy Noodles'], ['Jack', '500', 'Vegetable Stir Fry'], ['Kathy', '100', 'Beef Burrito'], ['Leo', '200', 'Chicken Curry'], ['Mona', '300', 'Shrimp Fried Rice'], ['Nate', '400', 'Spicy Noodles'], ['Oscar', '500', 'Vegetable Stir Fry'], ['Paul', '100', 'Beef Burrito'], ['Quinn', '200', 'Chicken Curry'], ['Ruth', '300', 'Shrimp Fried Rice'], ['Steve', '400', 'Spicy Noodles'], ['Tina', '500', 'Vegetable Stir Fry'], ['Uma', '100', 'Beef Burrito'], ['Vera', '200', 'Chicken Curry'], ['Will', '300', 'Shrimp Fried Rice'], ['Xander', '400', 'Spicy Noodles'], ['Yara', '500', 'Vegetable Stir Fry'], ['Zane', '100', 'Beef Burrito']]) == [['Table', 'Beef Burrito', 'Chicken Curry', 'Shrimp Fried Rice', 'Spicy Noodles', 'Vegetable Stir Fry'], ['100', '6', '0', '0', '0', '0'], ['200', '0', '5', '0', '0', '0'], ['300', '0', '0', '5', '0', '0'], ['400', '0', '0', '0', '5', '0'], ['500', '0', '0', '0', '0', '5']]\n assert candidate(orders = [['Amy', '1', 'Spring Roll'], ['Brian', '1', 'Spring Roll'], ['Cathy', '1', 'Spring Roll'], ['David', '1', 'Spring Roll'], ['Eva', '1', 'Spring Roll'], ['Frank', '1', 'Spring Roll'], ['Grace', '1', 'Spring Roll'], ['Henry', '1', 'Spring Roll'], ['Isabella', '1', 'Spring Roll'], ['Jack', '1', 'Spring Roll'], ['Katie', '1', 'Spring Roll'], ['Leo', '1', 'Spring Roll'], ['Mona', '1', 'Spring Roll'], ['Nathan', '1', 'Spring Roll'], ['Olivia', '1', 'Spring Roll'], ['Paul', '1', 'Spring Roll'], ['Quinn', '1', 'Spring Roll'], ['Ryan', '1', 'Spring Roll'], ['Sara', '1', 'Spring Roll'], ['Tina', '1', 'Spring Roll'], ['Uma', '1', 'Spring Roll'], ['Victor', '1', 'Spring Roll'], ['Wendy', '1', 'Spring Roll'], ['Xander', '1', 'Spring Roll'], ['Yara', '1', 'Spring Roll'], ['Zane', '1', 'Spring Roll']]) == [['Table', 'Spring Roll'], ['1', '26']]\n assert candidate(orders = [['Alice', '1', 'Pizza'], ['Bob', '2', 'Pasta'], ['Charlie', '3', 'Pizza'], ['David', '4', 'Salad'], ['Eve', '5', 'Burger'], ['Frank', '1', 'Pasta'], ['Grace', '2', 'Pizza'], ['Hannah', '3', 'Salad'], ['Ian', '4', 'Burger'], ['Jack', '5', 'Pizza']]) == [['Table', 'Burger', 'Pasta', 'Pizza', 'Salad'], ['1', '0', '1', '1', '0'], ['2', '0', '1', '1', '0'], ['3', '0', '0', '1', '1'], ['4', '1', '0', '0', '1'], ['5', '1', '0', '1', '0']]\n assert candidate(orders = [['Aaron', '1', 'Coffee'], ['Aaron', '1', 'Tea'], ['Aaron', '1', 'Juice'], ['Ben', '2', 'Coffee'], ['Ben', '2', 'Tea'], ['Charlie', '3', 'Tea'], ['Charlie', '3', 'Juice'], ['David', '4', 'Coffee'], ['David', '4', 'Tea'], ['David', '4', 'Juice'], ['Eve', '5', 'Coffee'], ['Eve', '5', 'Tea'], ['Eve', '5', 'Juice'], ['Frank', '6', 'Coffee'], ['Frank', '6', 'Tea'], ['Frank', '6', 'Juice'], ['Grace', '7', 'Coffee'], ['Grace', '7', 'Tea'], ['Grace', '7', 'Juice'], ['Hannah', '8', 'Coffee'], ['Hannah', '8', 'Tea'], ['Hannah', '8', 'Juice'], ['Ian', '9', 'Coffee'], ['Ian', '9', 'Tea'], ['Ian', '9', 'Juice'], ['Jack', '10', 'Coffee'], ['Jack', '10', 'Tea'], ['Jack', '10', 'Juice'], ['Katherine', '11', 'Coffee'], ['Katherine', '11', 'Tea'], ['Katherine', '11', 'Juice'], ['Laura', '12', 'Coffee'], ['Laura', '12', 'Tea'], ['Laura', '12', 'Juice'], ['Michael', '13', 'Coffee'], ['Michael', '13', 'Tea'], ['Michael', '13', 'Juice'], ['Nancy', '14', 'Coffee'], ['Nancy', '14', 'Tea'], ['Nancy', '14', 'Juice'], ['Oliver', '15', 'Coffee'], ['Oliver', '15', 'Tea'], ['Oliver', '15', 'Juice'], ['Penelope', '16', 'Coffee'], ['Penelope', '16', 'Tea'], ['Penelope', '16', 'Juice'], ['Quinn', '17', 'Coffee'], ['Quinn', '17', 'Tea'], ['Quinn', '17', 'Juice'], ['Rachel', '18', 'Coffee'], ['Rachel', '18', 'Tea'], ['Rachel', '18', 'Juice'], ['Sam', '19', 'Coffee'], ['Sam', '19', 'Tea'], ['Sam', '19', 'Juice'], ['Trent', '20', 'Coffee'], ['Trent', '20', 'Tea'], ['Trent', '20', 'Juice'], ['Uma', '21', 'Coffee'], ['Uma', '21', 'Tea'], ['Uma', '21', 'Juice'], ['Victor', '22', 'Coffee'], ['Victor', '22', 'Tea'], ['Victor', '22', 'Juice'], ['Wendy', '23', 'Coffee'], ['Wendy', '23', 'Tea'], ['Wendy', '23', 'Juice'], ['Xander', '24', 'Coffee'], ['Xander', '24', 'Tea'], ['Xander', '24', 'Juice'], ['Yvonne', '25', 'Coffee'], ['Yvonne', '25', 'Tea'], ['Yvonne', '25', 'Juice'], ['Zane', '26', 'Coffee'], ['Zane', '26', 'Tea'], ['Zane', '26', 'Juice']]) == [['Table', 'Coffee', 'Juice', 'Tea'], ['1', '1', '1', '1'], ['2', '1', '0', '1'], ['3', '0', '1', '1'], ['4', '1', '1', '1'], ['5', '1', '1', '1'], ['6', '1', '1', '1'], ['7', '1', '1', '1'], ['8', '1', '1', '1'], ['9', '1', '1', '1'], ['10', '1', '1', '1'], ['11', '1', '1', '1'], ['12', '1', '1', '1'], ['13', '1', '1', '1'], ['14', '1', '1', '1'], ['15', '1', '1', '1'], ['16', '1', '1', '1'], ['17', '1', '1', '1'], ['18', '1', '1', '1'], ['19', '1', '1', '1'], ['20', '1', '1', '1'], ['21', '1', '1', '1'], ['22', '1', '1', '1'], ['23', '1', '1', '1'], ['24', '1', '1', '1'], ['25', '1', '1', '1'], ['26', '1', '1', '1']]\n assert candidate(orders = [['William', '1', 'Steak'], ['Harper', '1', 'Mashed Potatoes'], ['Mason', '1', 'Steak'], ['Zoe', '1', 'Mashed Potatoes'], ['Ella', '1', 'Grilled Salmon'], ['Sebastian', '2', 'Steak'], ['Olivia', '2', 'Grilled Salmon'], ['Avery', '2', 'Steak'], ['Isabella', '2', 'Mashed Potatoes'], ['Grayson', '3', 'Grilled Salmon'], ['Scarlett', '3', 'Steak'], ['Sophia', '3', 'Mashed Potatoes'], ['Benjamin', '3', 'Grilled Salmon'], ['Ava', '4', 'Steak'], ['Evelyn', '4', 'Mashed Potatoes'], ['Daniel', '4', 'Grilled Salmon'], ['Amelia', '4', 'Steak'], ['Mia', '5', 'Mashed Potatoes'], ['Ella', '5', 'Steak'], ['Logan', '5', 'Grilled Salmon'], ['Abigail', '5', 'Steak'], ['James', '5', 'Mashed Potatoes'], ['Olivia', '5', 'Grilled Salmon'], ['Avery', '5', 'Steak'], ['Isabella', '5', 'Mashed Potatoes'], ['Mia', '5', 'Grilled Salmon'], ['Ella', '5', 'Steak'], ['Logan', '5', 'Mashed Potatoes']]) == [['Table', 'Grilled Salmon', 'Mashed Potatoes', 'Steak'], ['1', '1', '2', '2'], ['2', '1', '1', '2'], ['3', '2', '1', '1'], ['4', '1', '1', '2'], ['5', '3', '4', '4']]\n assert candidate(orders = [['Eli', '1', 'Pasta'], ['Nina', '2', 'Steak'], ['Eli', '2', 'Salmon'], ['Nina', '1', 'Salmon'], ['Eli', '1', 'Pasta'], ['Nina', '2', 'Pasta'], ['Eli', '2', 'Steak'], ['Nina', '1', 'Pasta'], ['Eli', '1', 'Steak'], ['Nina', '2', 'Salmon'], ['Eli', '2', 'Pasta'], ['Nina', '1', 'Steak'], ['Eli', '1', 'Salmon'], ['Nina', '2', 'Pasta']]) == [['Table', 'Pasta', 'Salmon', 'Steak'], ['1', '3', '2', '2'], ['2', '3', '2', '2']]\n assert candidate(orders = [['Alice', '2', 'Veggie Delight'], ['Bob', '1', 'Salmon'], ['Charlie', '2', 'Salmon'], ['David', '3', 'Veggie Delight'], ['Eve', '3', 'Salmon'], ['Alice', '1', 'Salmon'], ['Bob', '2', 'Veggie Delight'], ['Charlie', '3', 'Salmon'], ['David', '2', 'Veggie Delight'], ['Eve', '1', 'Salmon']]) == [['Table', 'Salmon', 'Veggie Delight'], ['1', '3', '0'], ['2', '1', '3'], ['3', '2', '1']]\n assert candidate(orders = [['Sarah', '1', 'Grilled Cheese'], ['Tom', '2', 'Grilled Cheese'], ['Sarah', '1', 'Caesar Salad'], ['Tom', '2', 'Caesar Salad'], ['Sarah', '1', 'Spaghetti'], ['Tom', '2', 'Spaghetti'], ['Sarah', '1', 'Steak'], ['Tom', '2', 'Steak'], ['Sarah', '1', 'Lasagna'], ['Tom', '2', 'Lasagna'], ['Sarah', '1', 'Pasta'], ['Tom', '2', 'Pasta'], ['Sarah', '1', 'Pizza'], ['Tom', '2', 'Pizza'], ['Sarah', '1', 'Fried Rice'], ['Tom', '2', 'Fried Rice'], ['Sarah', '1', 'Chicken Curry'], ['Tom', '2', 'Chicken Curry'], ['Sarah', '1', 'Fish and Chips'], ['Tom', '2', 'Fish and Chips'], ['Sarah', '1', 'Tacos'], ['Tom', '2', 'Tacos'], ['Sarah', '1', 'Burrito'], ['Tom', '2', 'Burrito'], ['Sarah', '1', 'Sushi'], ['Tom', '2', 'Sushi'], ['Sarah', '1', 'Ramen'], ['Tom', '2', 'Ramen'], ['Sarah', '1', 'Pho'], ['Tom', '2', 'Pho'], ['Sarah', '1', 'Dim Sum'], ['Tom', '2', 'Dim Sum']]) == [['Table', 'Burrito', 'Caesar Salad', 'Chicken Curry', 'Dim Sum', 'Fish and Chips', 'Fried Rice', 'Grilled Cheese', 'Lasagna', 'Pasta', 'Pho', 'Pizza', 'Ramen', 'Spaghetti', 'Steak', 'Sushi', 'Tacos'], ['1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1'], ['2', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1']]\n assert candidate(orders = [['Laura', '5', 'Bean Burrito'], ['Jhon', '5', 'Beef Burrito'], ['Melissa', '5', 'Soda'], ['Laura', '15', 'Bean Burrito'], ['Jhon', '15', 'Beef Burrito'], ['Melissa', '15', 'Soda'], ['Laura', '25', 'Bean Burrito'], ['Jhon', '25', 'Beef Burrito'], ['Melissa', '25', 'Soda'], ['Laura', '35', 'Bean Burrito'], ['Jhon', '35', 'Beef Burrito'], ['Melissa', '35', 'Soda']]) == [['Table', 'Bean Burrito', 'Beef Burrito', 'Soda'], ['5', '1', '1', '1'], ['15', '1', '1', '1'], ['25', '1', '1', '1'], ['35', '1', '1', '1']]\n assert candidate(orders = [['Laura', '1', 'Bean Burrito'], ['Jhon', '2', 'Beef Burrito'], ['Melissa', '2', 'Soda'], ['Chris', '3', 'Chocolate Cake'], ['Chris', '3', 'Soda'], ['Laura', '3', 'Beef Burrito'], ['Jhon', '1', 'Chocolate Cake'], ['Melissa', '1', 'Bean Burrito']]) == [['Table', 'Bean Burrito', 'Beef Burrito', 'Chocolate Cake', 'Soda'], ['1', '2', '0', '1', '0'], ['2', '0', '1', '0', '1'], ['3', '0', '1', '1', '1']]\n assert candidate(orders = [['Alice', '1', 'Burger'], ['Bob', '1', 'Pasta'], ['Charlie', '2', 'Burger'], ['David', '2', 'Pasta'], ['Eve', '3', 'Burger'], ['Frank', '3', 'Pasta'], ['Grace', '4', 'Burger'], ['Hannah', '4', 'Pasta'], ['Ian', '5', 'Burger'], ['Jack', '5', 'Pasta'], ['Karen', '6', 'Burger'], ['Leo', '6', 'Pasta'], ['Maggie', '7', 'Burger'], ['Nancy', '7', 'Pasta'], ['Oscar', '8', 'Burger'], ['Paul', '8', 'Pasta'], ['Quinn', '9', 'Burger'], ['Rachel', '9', 'Pasta'], ['Steve', '10', 'Burger'], ['Tina', '10', 'Pasta'], ['Uma', '11', 'Burger'], ['Victor', '11', 'Pasta'], ['Wanda', '12', 'Burger'], ['Xander', '12', 'Pasta'], ['Yvonne', '13', 'Burger'], ['Zane', '13', 'Pasta'], ['Aaron', '14', 'Burger'], ['Ben', '14', 'Pasta'], ['Charlie', '15', 'Burger'], ['David', '15', 'Pasta'], ['Eve', '16', 'Burger'], ['Frank', '16', 'Pasta'], ['Grace', '17', 'Burger'], ['Hannah', '17', 'Pasta'], ['Ian', '18', 'Burger'], ['Jack', '18', 'Pasta'], ['Karen', '19', 'Burger'], ['Leo', '19', 'Pasta'], ['Maggie', '20', 'Burger'], ['Nancy', '20', 'Pasta']]) == [['Table', 'Burger', 'Pasta'], ['1', '1', '1'], ['2', '1', '1'], ['3', '1', '1'], ['4', '1', '1'], ['5', '1', '1'], ['6', '1', '1'], ['7', '1', '1'], ['8', '1', '1'], ['9', '1', '1'], ['10', '1', '1'], ['11', '1', '1'], ['12', '1', '1'], ['13', '1', '1'], ['14', '1', '1'], ['15', '1', '1'], ['16', '1', '1'], ['17', '1', '1'], ['18', '1', '1'], ['19', '1', '1'], ['20', '1', '1']]\n assert candidate(orders = [['Daniel', '1', 'Sushi'], ['Julia', '2', 'Tempura'], ['Carlos', '1', 'Sashimi'], ['Sophie', '2', 'Sushi'], ['Christopher', '3', 'Sushi'], ['Mia', '3', 'Sashimi'], ['Nicole', '4', 'Tempura'], ['Alexander', '5', 'Sushi'], ['Oliver', '5', 'Sashimi'], ['Ella', '5', 'Tempura'], ['William', '6', 'Sushi'], ['Amelia', '6', 'Sashimi'], ['Ethan', '6', 'Tempura'], ['Grace', '7', 'Sushi'], ['Jack', '8', 'Tempura'], ['Hannah', '8', 'Sashimi']]) == [['Table', 'Sashimi', 'Sushi', 'Tempura'], ['1', '1', '1', '0'], ['2', '0', '1', '1'], ['3', '1', '1', '0'], ['4', '0', '0', '1'], ['5', '1', '1', '1'], ['6', '1', '1', '1'], ['7', '0', '1', '0'], ['8', '1', '0', '1']]\n assert candidate(orders = [['Michael', '5', 'Spaghetti'], ['John', '1', 'Chicken Wings'], ['Doe', '3', 'Nachos'], ['Michael', '1', 'Caesar Salad'], ['John', '5', 'Nachos'], ['Doe', '1', 'Caesar Salad'], ['Alice', '4', 'Veggie Platter'], ['Bob', '2', 'Caesar Salad'], ['Charlie', '2', 'Spaghetti'], ['David', '3', 'Chicken Wings'], ['Eve', '4', 'Nachos'], ['Frank', '5', 'Veggie Platter']]) == [['Table', 'Caesar Salad', 'Chicken Wings', 'Nachos', 'Spaghetti', 'Veggie Platter'], ['1', '2', '1', '0', '0', '0'], ['2', '1', '0', '0', '1', '0'], ['3', '0', '1', '1', '0', '0'], ['4', '0', '0', '1', '0', '1'], ['5', '0', '0', '1', '1', '1']]\n assert candidate(orders = [['Michael', '10', 'Tomato Soup'], ['Jessica', '10', 'Grilled Cheese'], ['Michael', '10', 'Tomato Soup'], ['Jessica', '10', 'Grilled Cheese'], ['Robert', '20', 'Chicken Salad'], ['Katherine', '20', 'Tomato Soup'], ['Robert', '20', 'Chicken Salad'], ['Katherine', '20', 'Tomato Soup'], ['Robert', '30', 'Grilled Cheese'], ['Katherine', '30', 'Chicken Salad'], ['Robert', '30', 'Grilled Cheese'], ['Katherine', '30', 'Chicken Salad'], ['Robert', '40', 'Tomato Soup'], ['Katherine', '40', 'Grilled Cheese'], ['Robert', '40', 'Tomato Soup'], ['Katherine', '40', 'Grilled Cheese']]) == [['Table', 'Chicken Salad', 'Grilled Cheese', 'Tomato Soup'], ['10', '0', '2', '2'], ['20', '2', '0', '2'], ['30', '2', '2', '0'], ['40', '0', '2', '2']]\n assert candidate(orders = [['Ella', '2', 'Grilled Cheese'], ['Ella', '2', 'Caesar Salad'], ['Finn', '2', 'Grilled Cheese'], ['Gwen', '3', 'Caesar Salad'], ['Hank', '4', 'Grilled Cheese'], ['Izzy', '4', 'Caesar Salad'], ['Jack', '4', 'Grilled Cheese'], ['Kai', '5', 'Caesar Salad'], ['Liam', '6', 'Grilled Cheese'], ['Mia', '6', 'Caesar Salad'], ['Nina', '7', 'Grilled Cheese'], ['Oscar', '7', 'Caesar Salad'], ['Paul', '8', 'Grilled Cheese'], ['Quinn', '8', 'Caesar Salad'], ['Ruth', '9', 'Grilled Cheese'], ['Sam', '9', 'Caesar Salad'], ['Tina', '10', 'Grilled Cheese'], ['Uma', '10', 'Caesar Salad'], ['Victor', '11', 'Grilled Cheese'], ['Wendy', '11', 'Caesar Salad'], ['Xander', '12', 'Grilled Cheese'], ['Yvonne', '12', 'Caesar Salad'], ['Zane', '13', 'Grilled Cheese'], ['Aaron', '13', 'Caesar Salad'], ['Ben', '14', 'Grilled Cheese'], ['Cathy', '14', 'Caesar Salad'], ['Dylan', '15', 'Grilled Cheese'], ['Eva', '15', 'Caesar Salad'], ['Frank', '16', 'Grilled Cheese'], ['Grace', '16', 'Caesar Salad'], ['Hannah', '17', 'Grilled Cheese'], ['Ian', '17', 'Caesar Salad'], ['Jack', '18', 'Grilled Cheese'], ['Kai', '18', 'Caesar Salad'], ['Liam', '19', 'Grilled Cheese'], ['Mia', '19', 'Caesar Salad'], ['Nina', '20', 'Grilled Cheese'], ['Oscar', '20', 'Caesar Salad'], ['Paul', '21', 'Grilled Cheese'], ['Quinn', '21', 'Caesar Salad'], ['Ruth', '22', 'Grilled Cheese'], ['Sam', '22', 'Caesar Salad'], ['Tina', '23', 'Grilled Cheese'], ['Uma', '23', 'Caesar Salad'], ['Victor', '24', 'Grilled Cheese'], ['Wendy', '24', 'Caesar Salad'], ['Xander', '25', 'Grilled Cheese'], ['Yvonne', '25', 'Caesar Salad'], ['Zane', '26', 'Grilled Cheese'], ['Aaron', '26', 'Caesar Salad'], ['Ben', '27', 'Grilled Cheese'], ['Cathy', '27', 'Caesar Salad'], ['Dylan', '28', 'Grilled Cheese'], ['Eva', '28', 'Caesar Salad'], ['Frank', '29', 'Grilled Cheese'], ['Grace', '29', 'Caesar Salad'], ['Hannah', '30', 'Grilled Cheese'], ['Ian', '30', 'Caesar Salad']]) == [['Table', 'Caesar Salad', 'Grilled Cheese'], ['2', '1', '2'], ['3', '1', '0'], ['4', '1', '2'], ['5', '1', '0'], ['6', '1', '1'], ['7', '1', '1'], ['8', '1', '1'], ['9', '1', '1'], ['10', '1', '1'], ['11', '1', '1'], ['12', '1', '1'], ['13', '1', '1'], ['14', '1', '1'], ['15', '1', '1'], ['16', '1', '1'], ['17', '1', '1'], ['18', '1', '1'], ['19', '1', '1'], ['20', '1', '1'], ['21', '1', '1'], ['22', '1', '1'], ['23', '1', '1'], ['24', '1', '1'], ['25', '1', '1'], ['26', '1', '1'], ['27', '1', '1'], ['28', '1', '1'], ['29', '1', '1'], ['30', '1', '1']]\n assert candidate(orders = [['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight'], ['Jerry', '3', 'Spring Roll'], ['Anna', '4', 'Pasta'], ['Tom', '5', 'Pizza'], ['Jerry', '6', 'Salad'], ['Anna', '7', 'Burger'], ['Tom', '8', 'Fried Chicken'], ['Jerry', '9', 'Water'], ['Anna', '10', 'Ceviche'], ['Tom', '11', 'Beef Burrito'], ['Jerry', '12', 'Veggie Delight'], ['Anna', '13', 'Pizza'], ['Tom', '14', 'Salad'], ['Jerry', '15', 'Burger'], ['Anna', '16', 'Fried Chicken'], ['Tom', '17', 'Water'], ['Jerry', '18', 'Ceviche'], ['Anna', '19', 'Beef Burrito'], ['Tom', '20', 'Veggie Delight']]) == [['Table', 'Beef Burrito', 'Burger', 'Ceviche', 'Fried Chicken', 'Pasta', 'Pizza', 'Salad', 'Spring Roll', 'Veggie Delight', 'Water'], ['1', '1', '0', '0', '0', '0', '0', '0', '1', '1', '0'], ['2', '1', '0', '0', '0', '0', '0', '0', '0', '1', '0'], ['3', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0'], ['4', '0', '0', '0', '0', '1', '0', '0', '0', '0', '0'], ['5', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0'], ['6', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0'], ['7', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0'], ['8', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0'], ['9', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1'], ['10', '0', '0', '1', '0', '0', '0', '0', '0', '0', '0'], ['11', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0'], ['12', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0'], ['13', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0'], ['14', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0'], ['15', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0'], ['16', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0'], ['17', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1'], ['18', '0', '0', '1', '0', '0', '0', '0', '0', '0', '0'], ['19', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0'], ['20', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0']]\n assert candidate(orders = [['Alice', '1', 'Beef Burrito'], ['Bob', '2', 'Chicken Curry'], ['Charlie', '3', 'Shrimp Fried Rice'], ['David', '4', 'Spicy Noodles'], ['Eve', '5', 'Vegetable Stir Fry'], ['Frank', '6', 'Beef Burrito'], ['Grace', '7', 'Chicken Curry'], ['Hank', '8', 'Shrimp Fried Rice'], ['Ivy', '9', 'Spicy Noodles'], ['Jack', '10', 'Vegetable Stir Fry'], ['Kathy', '1', 'Beef Burrito'], ['Leo', '2', 'Chicken Curry'], ['Mona', '3', 'Shrimp Fried Rice'], ['Nate', '4', 'Spicy Noodles'], ['Oscar', '5', 'Vegetable Stir Fry'], ['Paul', '6', 'Beef Burrito'], ['Quinn', '7', 'Chicken Curry'], ['Ruth', '8', 'Shrimp Fried Rice'], ['Steve', '9', 'Spicy Noodles'], ['Tina', '10', 'Vegetable Stir Fry']]) == [['Table', 'Beef Burrito', 'Chicken Curry', 'Shrimp Fried Rice', 'Spicy Noodles', 'Vegetable Stir Fry'], ['1', '2', '0', '0', '0', '0'], ['2', '0', '2', '0', '0', '0'], ['3', '0', '0', '2', '0', '0'], ['4', '0', '0', '0', '2', '0'], ['5', '0', '0', '0', '0', '2'], ['6', '2', '0', '0', '0', '0'], ['7', '0', '2', '0', '0', '0'], ['8', '0', '0', '2', '0', '0'], ['9', '0', '0', '0', '2', '0'], ['10', '0', '0', '0', '0', '2']]\n assert candidate(orders = [['John', '10', 'Lobster'], ['Paul', '12', 'Grilled Chicken'], ['John', '12', 'Lobster'], ['Paul', '10', 'Grilled Chicken'], ['John', '10', 'Grilled Chicken'], ['Paul', '12', 'Lobster'], ['John', '12', 'Grilled Chicken'], ['Paul', '10', 'Lobster'], ['John', '10', 'Lobster'], ['Paul', '12', 'Grilled Chicken']]) == [['Table', 'Grilled Chicken', 'Lobster'], ['10', '2', '3'], ['12', '3', '2']]\n assert candidate(orders = [['Emma', '5', 'Chicken Tikka Masala'], ['James', '5', 'Chicken Tikka Masala'], ['Oliver', '5', 'Chicken Tikka Masala'], ['Noah', '5', 'Chicken Tikka Masala'], ['Amelia', '5', 'Chicken Tikka Masala'], ['Olivia', '6', 'Chicken Tikka Masala'], ['Ava', '6', 'Chicken Tikka Masala'], ['Isabella', '6', 'Chicken Tikka Masala'], ['Sophia', '6', 'Chicken Tikka Masala'], ['Isaac', '6', 'Chicken Tikka Masala'], ['Oliver', '7', 'Chicken Tikka Masala'], ['Elijah', '7', 'Chicken Tikka Masala'], ['Noah', '7', 'Chicken Tikka Masala'], ['James', '7', 'Chicken Tikka Masala'], ['Olivia', '7', 'Chicken Tikka Masala'], ['Emma', '8', 'Chicken Tikka Masala'], ['Isabella', '8', 'Chicken Tikka Masala'], ['Amelia', '8', 'Chicken Tikka Masala'], ['Sophia', '8', 'Chicken Tikka Masala'], ['Isaac', '8', 'Chicken Tikka Masala'], ['Ava', '8', 'Chicken Tikka Masala'], ['Elijah', '8', 'Chicken Tikka Masala'], ['James', '8', 'Chicken Tikka Masala'], ['Oliver', '8', 'Chicken Tikka Masala'], ['Noah', '8', 'Chicken Tikka Masala'], ['Amelia', '8', 'Chicken Tikka Masala'], ['Olivia', '8', 'Chicken Tikka Masala']]) == [['Table', 'Chicken Tikka Masala'], ['5', '5'], ['6', '5'], ['7', '5'], ['8', '12']]\n assert candidate(orders = [['Will', '500', 'Mushroom Risotto'], ['Sam', '499', 'Steak'], ['Greg', '498', 'Salmon'], ['May', '497', 'Vegetable Lasagna'], ['Diana', '496', 'Mushroom Risotto'], ['Tom', '495', 'Steak'], ['Jenny', '494', 'Salmon'], ['Chris', '493', 'Vegetable Lasagna'], ['Lucas', '492', 'Mushroom Risotto'], ['Sarah', '491', 'Steak'], ['Joe', '490', 'Salmon'], ['Karen', '489', 'Vegetable Lasagna'], ['Matt', '488', 'Mushroom Risotto'], ['Lisa', '487', 'Steak'], ['Scott', '486', 'Salmon'], ['Rachel', '485', 'Vegetable Lasagna'], ['Mark', '484', 'Mushroom Risotto'], ['Beth', '483', 'Steak'], ['Dave', '482', 'Salmon'], ['Nancy', '481', 'Vegetable Lasagna'], ['Ken', '480', 'Mushroom Risotto'], ['Jan', '479', 'Steak'], ['Jill', '478', 'Salmon'], ['Gregory', '477', 'Vegetable Lasagna'], ['Christina', '476', 'Mushroom Risotto'], ['Kevin', '475', 'Steak'], ['Laura', '474', 'Salmon'], ['Megan', '473', 'Vegetable Lasagna'], ['Ryan', '472', 'Mushroom Risotto'], ['Amanda', '471', 'Steak'], ['Charles', '470', 'Salmon'], ['Rebecca', '469', 'Vegetable Lasagna'], ['Andrew', '468', 'Mushroom Risotto'], ['Jessica', '467', 'Steak'], ['Arthur', '466', 'Salmon'], ['Shirley', '465', 'Vegetable Lasagna'], ['Daniel', '464', 'Mushroom Risotto'], ['Emma', '463', 'Steak'], ['Christopher', '462', 'Salmon'], ['Nicole', '461', 'Vegetable Lasagna'], ['Scott', '460', 'Mushroom Risotto'], ['Melissa', '459', 'Steak'], ['Robert', '458', 'Salmon'], ['Michelle', '457', 'Vegetable Lasagna'], ['John', '456', 'Mushroom Risotto'], ['Brenda', '455', 'Steak'], ['Steve', '454', 'Salmon'], ['Anna', '453', 'Vegetable Lasagna']]) == [['Table', 'Mushroom Risotto', 'Salmon', 'Steak', 'Vegetable Lasagna'], ['453', '0', '0', '0', '1'], ['454', '0', '1', '0', '0'], ['455', '0', '0', '1', '0'], ['456', '1', '0', '0', '0'], ['457', '0', '0', '0', '1'], ['458', '0', '1', '0', '0'], ['459', '0', '0', '1', '0'], ['460', '1', '0', '0', '0'], ['461', '0', '0', '0', '1'], ['462', '0', '1', '0', '0'], ['463', '0', '0', '1', '0'], ['464', '1', '0', '0', '0'], ['465', '0', '0', '0', '1'], ['466', '0', '1', '0', '0'], ['467', '0', '0', '1', '0'], ['468', '1', '0', '0', '0'], ['469', '0', '0', '0', '1'], ['470', '0', '1', '0', '0'], ['471', '0', '0', '1', '0'], ['472', '1', '0', '0', '0'], ['473', '0', '0', '0', '1'], ['474', '0', '1', '0', '0'], ['475', '0', '0', '1', '0'], ['476', '1', '0', '0', '0'], ['477', '0', '0', '0', '1'], ['478', '0', '1', '0', '0'], ['479', '0', '0', '1', '0'], ['480', '1', '0', '0', '0'], ['481', '0', '0', '0', '1'], ['482', '0', '1', '0', '0'], ['483', '0', '0', '1', '0'], ['484', '1', '0', '0', '0'], ['485', '0', '0', '0', '1'], ['486', '0', '1', '0', '0'], ['487', '0', '0', '1', '0'], ['488', '1', '0', '0', '0'], ['489', '0', '0', '0', '1'], ['490', '0', '1', '0', '0'], ['491', '0', '0', '1', '0'], ['492', '1', '0', '0', '0'], ['493', '0', '0', '0', '1'], ['494', '0', '1', '0', '0'], ['495', '0', '0', '1', '0'], ['496', '1', '0', '0', '0'], ['497', '0', '0', '0', '1'], ['498', '0', '1', '0', '0'], ['499', '0', '0', '1', '0'], ['500', '1', '0', '0', '0']]\n assert candidate(orders = [['Alice', '1', 'Pizza'], ['Bob', '2', 'Burger'], ['Charlie', '3', 'Sushi'], ['David', '1', 'Salad'], ['Eve', '2', 'Pizza'], ['Frank', '3', 'Burger'], ['Grace', '1', 'Sushi'], ['Heidi', '2', 'Salad'], ['Ivy', '3', 'Pizza'], ['Jack', '1', 'Burger'], ['Kara', '2', 'Sushi'], ['Liam', '3', 'Salad'], ['Mia', '1', 'Pizza'], ['Nina', '2', 'Burger'], ['Oscar', '3', 'Sushi'], ['Paul', '1', 'Salad'], ['Quinn', '2', 'Pizza'], ['Rachel', '3', 'Burger'], ['Steve', '1', 'Sushi'], ['Tina', '2', 'Salad'], ['Uma', '3', 'Pizza'], ['Victor', '1', 'Burger'], ['Wendy', '2', 'Sushi'], ['Xavier', '3', 'Salad'], ['Yara', '1', 'Pizza'], ['Zane', '2', 'Burger']]) == [['Table', 'Burger', 'Pizza', 'Salad', 'Sushi'], ['1', '2', '3', '2', '2'], ['2', '3', '2', '2', '2'], ['3', '2', '2', '2', '2']]\n assert candidate(orders = [['Leo', '1', 'Fish and Chips'], ['Mia', '2', 'Fish and Chips'], ['Leo', '3', 'Caesar Salad'], ['Mia', '1', 'Caesar Salad'], ['Leo', '2', 'Fish and Chips'], ['Mia', '3', 'Caesar Salad'], ['Ava', '1', 'Club Sandwich'], ['Sophia', '2', 'Caesar Salad'], ['Ava', '3', 'Fish and Chips'], ['Sophia', '1', 'Club Sandwich'], ['Ava', '2', 'Caesar Salad'], ['Sophia', '3', 'Fish and Chips'], ['Isabella', '1', 'Fish and Chips'], ['Oliver', '2', 'Club Sandwich'], ['Isabella', '3', 'Caesar Salad'], ['Oliver', '1', 'Fish and Chips'], ['Isabella', '2', 'Caesar Salad'], ['Oliver', '3', 'Club Sandwich']]) == [['Table', 'Caesar Salad', 'Club Sandwich', 'Fish and Chips'], ['1', '1', '2', '3'], ['2', '3', '1', '2'], ['3', '3', '1', '2']]\n assert candidate(orders = [['David', '3', 'Ceviche'], ['Corina', '10', 'Beef Burrito'], ['David', '3', 'Fried Chicken'], ['Carla', '5', 'Water'], ['Carla', '5', 'Ceviche'], ['Rous', '3', 'Ceviche'], ['David', '5', 'Beef Burrito'], ['Carla', '3', 'Fried Chicken'], ['Rous', '5', 'Spring Roll']]) == [['Table', 'Beef Burrito', 'Ceviche', 'Fried Chicken', 'Spring Roll', 'Water'], ['3', '0', '2', '2', '0', '0'], ['5', '1', '1', '0', '1', '1'], ['10', '1', '0', '0', '0', '0']]\n assert candidate(orders = [['Alexander', '50', 'Fruit Salad'], ['Dominic', '51', 'Pancakes'], ['Alexander', '50', 'Fruit Salad'], ['Dominic', '51', 'Pancakes'], ['Elizabeth', '52', 'Tomato Soup'], ['Alexander', '50', 'Tomato Soup'], ['Dominic', '51', 'Tomato Soup'], ['Elizabeth', '52', 'Pancakes'], ['Alexander', '50', 'Pancakes'], ['Dominic', '51', 'Fruit Salad'], ['Elizabeth', '52', 'Fruit Salad'], ['Alexander', '50', 'Chicken Salad'], ['Dominic', '51', 'Chicken Salad'], ['Elizabeth', '52', 'Chicken Salad']]) == [['Table', 'Chicken Salad', 'Fruit Salad', 'Pancakes', 'Tomato Soup'], ['50', '1', '2', '1', '1'], ['51', '1', '1', '2', '1'], ['52', '1', '1', '1', '1']]\n assert candidate(orders = [['Anna', '1', 'Spring Roll'], ['Tom', '2', 'Beef Burrito'], ['Jerry', '1', 'Beef Burrito'], ['Anna', '2', 'Veggie Delight'], ['Tom', '1', 'Veggie Delight'], ['Bob', '3', 'Chicken Curry'], ['Charlie', '4', 'Shrimp Fried Rice'], ['David', '5', 'Spicy Noodles'], ['Eve', '6', 'Vegetable Stir Fry'], ['Frank', '1', 'Spring Roll'], ['Grace', '2', 'Beef Burrito'], ['Hank', '3', 'Chicken Curry'], ['Ivy', '4', 'Shrimp Fried Rice'], ['Jack', '5', 'Spicy Noodles'], ['Kathy', '6', 'Vegetable Stir Fry'], ['Leo', '1', 'Spring Roll'], ['Mona', '2', 'Beef Burrito'], ['Nate', '3', 'Chicken Curry'], ['Oscar', '4', 'Shrimp Fried Rice'], ['Paul', '5', 'Spicy Noodles'], ['Quinn', '6', 'Vegetable Stir Fry'], ['Ruth', '1', 'Spring Roll'], ['Steve', '2', 'Beef Burrito'], ['Tina', '3', 'Chicken Curry'], ['Uma', '4', 'Shrimp Fried Rice'], ['Vera', '5', 'Spicy Noodles'], ['Will', '6', 'Vegetable Stir Fry']]) == [['Table', 'Beef Burrito', 'Chicken Curry', 'Shrimp Fried Rice', 'Spicy Noodles', 'Spring Roll', 'Vegetable Stir Fry', 'Veggie Delight'], ['1', '1', '0', '0', '0', '4', '0', '1'], ['2', '4', '0', '0', '0', '0', '0', '1'], ['3', '0', '4', '0', '0', '0', '0', '0'], ['4', '0', '0', '4', '0', '0', '0', '0'], ['5', '0', '0', '0', '4', '0', '0', '0'], ['6', '0', '0', '0', '0', '0', '4', '0']]\n assert candidate(orders = [['Sarah', '101', 'Spaghetti Carbonara'], ['John', '202', 'Caesar Salad'], ['Sarah', '101', 'Caesar Salad'], ['Alice', '303', 'Grilled Salmon'], ['Bob', '202', 'Grilled Salmon'], ['Sarah', '101', 'Spaghetti Carbonara'], ['Alice', '303', 'Caesar Salad'], ['Bob', '202', 'Spaghetti Carbonara'], ['Charlie', '404', 'Grilled Salmon'], ['Charlie', '404', 'Caesar Salad'], ['Charlie', '404', 'Spaghetti Carbonara']]) == [['Table', 'Caesar Salad', 'Grilled Salmon', 'Spaghetti Carbonara'], ['101', '1', '0', '2'], ['202', '1', '1', '1'], ['303', '1', '1', '0'], ['404', '1', '1', '1']]\n"}, "metadata": {"canonical_parameter_names": ["orders"], "leetcode_dataset_entry_point": "Solution().displayTable", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector> displayTable(vector>& orders) {", "container": "Solution", "callable": "displayTable", "parameters": [{"name": "orders", "type": "vector>&"}], "return_type": "vector>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1419, "task_id": "minimum-number-of-frogs-croaking", "difficulty": "Medium", "problem_description": "You are given the string croakOfFrogs, which represents a combination of the string \"croak\" from different frogs, that is, multiple frogs can croak at the same time, so multiple \"croak\" are mixed.\nReturn the minimum number of different frogs to finish all the croaks in the given string.\nA valid \"croak\" means a frog is printing five letters 'c', 'r', 'o', 'a', and 'k' sequentially. The frogs have to print all five letters to finish a croak. If the given string is not a combination of a valid \"croak\" return -1.\n \nExample 1:\n\nInput: croakOfFrogs = \"croakcroak\"\nOutput: 1 \nExplanation: One frog yelling \"croak\" twice.\n\nExample 2:\n\nInput: croakOfFrogs = \"crcoakroak\"\nOutput: 2 \nExplanation: The minimum number of frogs is two. \nThe first frog could yell \"crcoakroak\".\nThe second frog could yell later \"crcoakroak\".\n\nExample 3:\n\nInput: croakOfFrogs = \"croakcrook\"\nOutput: -1\nExplanation: The given string is an invalid combination of \"croak\" from different frogs.\n\n \nConstraints:\n\n1 <= croakOfFrogs.length <= 105\ncroakOfFrogs is either 'c', 'r', 'o', 'a', or 'k'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(croakOfFrogs = \"croakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"croak\") == 1\n assert candidate(croakOfFrogs = \"cccrroooaaakkk\") == -1\n assert candidate(croakOfFrogs = \"crcoakroak\") == 2\n assert candidate(croakOfFrogs = \"crrcooakak\") == -1\n assert candidate(croakOfFrogs = \"k\") == -1\n assert candidate(croakOfFrogs = \"crocakroak\") == 2\n assert candidate(croakOfFrogs = \"ccccrrrrooooaaaakkkk\") == 4\n assert candidate(croakOfFrogs = \"crrrroooaaaakkk\") == -1\n assert candidate(croakOfFrogs = \"ccroooakk\") == -1\n assert candidate(croakOfFrogs = \"ccroakroak\") == 2\n assert candidate(croakOfFrogs = \"crrrroooookkkkaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrroooaaaaakkkkkk\") == -1\n assert candidate(croakOfFrogs = \"kakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakak\") == -1\n assert candidate(croakOfFrogs = \"ccccroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"kkkrrrooocccaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrroooaaaaakkkkk\") == -1\n assert candidate(croakOfFrogs = \"croakcrook\") == -1\n assert candidate(croakOfFrogs = \"crorocroakakak\") == -1\n assert candidate(croakOfFrogs = \"crocroak\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakcroakcroakcroakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"c\") == -1\n assert candidate(croakOfFrogs = \"crorocakak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrroooaaaakkk\") == -1\n assert candidate(croakOfFrogs = \"kroac\") == -1\n assert candidate(croakOfFrogs = \"crocak\") == -1\n assert candidate(croakOfFrogs = \"crcroaoakk\") == 2\n assert candidate(croakOfFrogs = \"kraoc\") == -1\n assert candidate(croakOfFrogs = \"ccccrrooookkkk\") == -1\n assert candidate(croakOfFrogs = \"\") == 0\n assert candidate(croakOfFrogs = \"ccrroookkaak\") == -1\n assert candidate(croakOfFrogs = \"crocroakakroak\") == -1\n assert candidate(croakOfFrogs = \"croakcroak\") == 1\n assert candidate(croakOfFrogs = \"ccccrrroooookkkkaaaaaaaaaaaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccccroooooorrrraaaaaakkkkk\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrrrrroooooooooookkkkkkkkaaaaaaaaaacrrrrrrroooooooooookkkkkkkkaaaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"croakccccrrroooookkkkroak\") == -1\n assert candidate(croakOfFrogs = \"crocroakcrocroakcroak\") == -1\n assert candidate(croakOfFrogs = \"cccrroooakkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"crocakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"croakccroakrrrooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccrrroooookkkk\") == -1\n assert candidate(croakOfFrogs = \"ccccrooookaaaakkkkk\") == -1\n assert candidate(croakOfFrogs = \"crocakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"croakkkkroakkkkroakkkk\") == -1\n assert candidate(croakOfFrogs = \"croakkkkkkkkkk\") == -1\n assert candidate(croakOfFrogs = \"crrrroookaaaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"ccccrrroooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"crcrooakakro\") == -1\n assert candidate(croakOfFrogs = \"crocakroakcroakcroakcroakcroak\") == 2\n assert candidate(croakOfFrogs = \"crocroakcroakccccrrroooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrooooookkkkkaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrrooooaaaakkkkccrrrrooooaaaakkkkccrrrrooooaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"crcrccrooaaakk\") == -1\n assert candidate(croakOfFrogs = \"cccrrooookkkkraaacroak\") == -1\n assert candidate(croakOfFrogs = \"croakccroakcroak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrroooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"crrroooookkkkaaaakkk\") == -1\n assert candidate(croakOfFrogs = \"cccrooookkkkrrrooookkkk\") == -1\n assert candidate(croakOfFrogs = \"crrrcroakroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"croakcroakccroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crocroakcroakcroakcroakcroakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crrroooookkkkkaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"crocroakcrocroakcrocroak\") == -1\n assert candidate(croakOfFrogs = \"croakkkkrooocrakcroak\") == -1\n assert candidate(croakOfFrogs = \"crcrooakrakok\") == -1\n assert candidate(croakOfFrogs = \"crocakrocakrocak\") == -1\n assert candidate(croakOfFrogs = \"croakcrocakcroakcrocakcrocak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrrooooaaaakkkkccccrrrrooooaaaakkkkccccrrrrooooaaaakkkkccccrrrrooooaaaakkkk\") == 4\n assert candidate(croakOfFrogs = \"croakkkkrooocrakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crcoakrcoak\") == -1\n assert candidate(croakOfFrogs = \"crrrrooooookkkkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccroooaaaaakkkakkkakkk\") == -1\n assert candidate(croakOfFrogs = \"ccccroooaaaaakkkakkk\") == -1\n assert candidate(croakOfFrogs = \"crorocokakak\") == -1\n assert candidate(croakOfFrogs = \"crrrrroooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"croakcrrooakroakroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crcrooakkaakrook\") == -1\n assert candidate(croakOfFrogs = \"crocakroakroakroakroakroakroakroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"crcrooakrakokcrcrooakrakokcrcrooakrakok\") == -1\n assert candidate(croakOfFrogs = \"ccccrooookaaaakkkkkkk\") == -1\n assert candidate(croakOfFrogs = \"ccrrroooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"croakccrookraaaakkk\") == -1\n assert candidate(croakOfFrogs = \"ccccccccrrrrrroooooookkkkkkkkkkkaaaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"crocroakkkk\") == -1\n assert candidate(croakOfFrogs = \"croakrcoakcroak\") == -1\n assert candidate(croakOfFrogs = \"croakkkkrooocrakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrooooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"crocrocrocrocroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"crrrroooookkkkaaaak\") == -1\n assert candidate(croakOfFrogs = \"croakkkkkkrrroooooooaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"crcoakroakcrcoakroak\") == 2\n assert candidate(croakOfFrogs = \"crocrocrocrocrocroakroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrroooookkkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"crocakroakcroakcroak\") == 2\n assert candidate(croakOfFrogs = \"crcrcooakokrakraokakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crrrroooookkkkaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"ccccroooaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"croakkkkkkkkkkroakroakroakcroak\") == -1\n assert candidate(croakOfFrogs = \"ccccccroooooorrrraaaaaakkkkkkk\") == -1\n assert candidate(croakOfFrogs = \"crcroakroakcrcoak\") == -1\n assert candidate(croakOfFrogs = \"ccrrroooookkkkaaaak\") == -1\n assert candidate(croakOfFrogs = \"crocroakcroakcroakcroakcroakcroakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crcoakrcoakrcoak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrooookkkkaaaakkkkroakroak\") == -1\n assert candidate(croakOfFrogs = \"ccccccccrrrrrrrrrrroooooooooookkkkkkkkaaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"ccrooakrkkaocroakcraok\") == -1\n assert candidate(croakOfFrogs = \"crcrooakrakokcrcrooakrakok\") == -1\n assert candidate(croakOfFrogs = \"crorarokkorakocraok\") == -1\n assert candidate(croakOfFrogs = \"croakroakroakcroakroakroakroakcroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrroooookkkkaaaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"cccrroooraaakk\") == -1\n assert candidate(croakOfFrogs = \"crocrocrocrocroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"crocroakcroakcroakcroakcroakcroakcroakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"ccccroooraaaakkkkk\") == -1\n assert candidate(croakOfFrogs = \"crocroakroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crocroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcrorocroak\") == -1\n assert candidate(croakOfFrogs = \"croakcroakroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crrrrroooookkkkaaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"ccccroooaarrrkkk\") == -1\n assert candidate(croakOfFrogs = \"ccccroooaaaaakkkaaa\") == -1\n assert candidate(croakOfFrogs = \"crrrrrrrrroooooooooookkkkkkkkaaaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakcroakcroakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"ccrroooaakkccrooakaakk\") == -1\n assert candidate(croakOfFrogs = \"ccrrroooookkkkaaaacccrrroooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccroakcroakcroakroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crcrooakakroccrooakakro\") == -1\n assert candidate(croakOfFrogs = \"croakcroakroakroakroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"ccroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"crocrokakakcroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"ccccrrrrooooaaaakkkkccccrrrrooooaaaakkkkccccrrrrooooaaaakkkk\") == 4\n assert candidate(croakOfFrogs = \"ccroakccroakccroak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrroooookkkkkk\") == -1\n assert candidate(croakOfFrogs = \"cccrroooookkkkaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"crrrroooookkkkac\") == -1\n assert candidate(croakOfFrogs = \"crorokokokakakc\") == -1\n assert candidate(croakOfFrogs = \"crocakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crrrooookkkkaaacrrrooookkkkaaa\") == -1\n assert candidate(croakOfFrogs = \"crocroakroakroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"ccrroookkaaa\") == -1\n assert candidate(croakOfFrogs = \"crrrooookkkk\") == -1\n assert candidate(croakOfFrogs = \"crocrokakakcroakroak\") == -1\n assert candidate(croakOfFrogs = \"ccrroooaakkccrooakaakkccrroooaakk\") == -1\n assert candidate(croakOfFrogs = \"ccccrrroooookkkkaaaacrrroooookkkkaaaacrrroooookkkkaaa\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakcroakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"crcrrooookkkaaa\") == -1\n assert candidate(croakOfFrogs = \"crocroakroakroakroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crocroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crrrcroakroakroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"crrroookkkkrrroooookkkk\") == -1\n assert candidate(croakOfFrogs = \"crrrooookkkkaaa\") == -1\n assert candidate(croakOfFrogs = \"crocrokrocroakakak\") == -1\n assert candidate(croakOfFrogs = \"crrookkcraaacroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crcrcooakokrakraokak\") == -1\n assert candidate(croakOfFrogs = \"crocroakcrocroakcrocroakcroak\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakccroooaakk\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrrrrrooooooookkkkkkkaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"croakcroakccroaaaakkk\") == -1\n assert candidate(croakOfFrogs = \"crocroakroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crocroakroakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crocroakroakroakroakroakroakroakroakroakroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crrroooookkkkaaaakkkkkkk\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrooookkkkaaakk\") == -1\n assert candidate(croakOfFrogs = \"crrcroakroakcroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrrroooookkkkaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"ccccrrroooookkkkaaaakkkk\") == -1\n assert candidate(croakOfFrogs = \"ccroakcroakcroakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"croakcrocakcroakcrocak\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrrooooaaaakkkkccccrrrrooooaaaakkkk\") == 4\n assert candidate(croakOfFrogs = \"croakcroakcrcoakroakcrocroak\") == -1\n assert candidate(croakOfFrogs = \"crcrooakakroccrooakakroccrooakakro\") == -1\n assert candidate(croakOfFrogs = \"crocakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"crocroakroakcroakcroakcroakcroak\") == -1\n assert candidate(croakOfFrogs = \"croakkkcroak\") == -1\n assert candidate(croakOfFrogs = \"ccroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"ccccrooorkkkaa\") == -1\n assert candidate(croakOfFrogs = \"crcrooakrakokcrcrooakrakokcrcrooakrakokcrcrooakrakok\") == -1\n assert candidate(croakOfFrogs = \"crcrooakrakokcrcrooakrakokcrcrooakrakokcrcrooakrakokcrcrooakrakok\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"cccroooraakk\") == -1\n assert candidate(croakOfFrogs = \"crrrooookkkkkaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrrroooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"crrroookkkkrrroooookkkkrrroooookkkk\") == -1\n assert candidate(croakOfFrogs = \"crocrocrocroakroakroakroak\") == -1\n assert candidate(croakOfFrogs = \"crocrocrocrocrocrocrocrocrocrocrocrocroak\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcroakcroakcroak\") == 1\n assert candidate(croakOfFrogs = \"crrrooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"crrrrroooookkkkaaaaacrrrrroooookkkkaaaa\") == -1\n assert candidate(croakOfFrogs = \"ccccrrrooookkkkaaaaaaaaaa\") == -1\n assert candidate(croakOfFrogs = \"cccroaaakkkkroooraak\") == -1\n assert candidate(croakOfFrogs = \"croakcroakcrocroakroak\") == -1\n assert candidate(croakOfFrogs = \"crcroakroakroakroakroakroak\") == -1\n"}, "metadata": {"canonical_parameter_names": ["croakOfFrogs"], "leetcode_dataset_entry_point": "Solution().minNumberOfFrogs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minNumberOfFrogs(string croakOfFrogs) {", "container": "Solution", "callable": "minNumberOfFrogs", "parameters": [{"name": "croakOfFrogs", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1420, "task_id": "build-array-where-you-can-find-the-maximum-exactly-k-comparisons", "difficulty": "Hard", "problem_description": "You are given three integers n, m and k. Consider the following algorithm to find the maximum element of an array of positive integers:\n\nYou should build the array arr which has the following properties:\n\narr has exactly n integers.\n1 <= arr[i] <= m where (0 <= i < n).\nAfter applying the mentioned algorithm to arr, the value search_cost is equal to k.\n\nReturn the number of ways to build the array arr under the mentioned conditions. As the answer may grow large, the answer must be computed modulo 109 + 7.\n \nExample 1:\n\nInput: n = 2, m = 3, k = 1\nOutput: 6\nExplanation: The possible arrays are [1, 1], [2, 1], [2, 2], [3, 1], [3, 2] [3, 3]\n\nExample 2:\n\nInput: n = 5, m = 2, k = 3\nOutput: 0\nExplanation: There are no possible arrays that satisfy the mentioned conditions.\n\nExample 3:\n\nInput: n = 9, m = 1, k = 1\nOutput: 1\nExplanation: The only possible array is [1, 1, 1, 1, 1, 1, 1, 1, 1]\n\n \nConstraints:\n\n1 <= n <= 50\n1 <= m <= 100\n0 <= k <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1,m = 1,k = 1) == 1\n assert candidate(n = 4,m = 5,k = 2) == 305\n assert candidate(n = 3,m = 3,k = 0) == 0\n assert candidate(n = 3,m = 5,k = 2) == 60\n assert candidate(n = 5,m = 2,k = 3) == 0\n assert candidate(n = 4,m = 4,k = 2) == 125\n assert candidate(n = 1,m = 1,k = 0) == 0\n assert candidate(n = 50,m = 100,k = 50) == 538992043\n assert candidate(n = 10,m = 10,k = 5) == 282622725\n assert candidate(n = 4,m = 4,k = 0) == 0\n assert candidate(n = 2,m = 3,k = 1) == 6\n assert candidate(n = 50,m = 100,k = 0) == 0\n assert candidate(n = 9,m = 1,k = 1) == 1\n assert candidate(n = 40,m = 30,k = 20) == 620836495\n assert candidate(n = 25,m = 10,k = 15) == 0\n assert candidate(n = 45,m = 5,k = 2) == 741424886\n assert candidate(n = 40,m = 20,k = 15) == 992287753\n assert candidate(n = 50,m = 50,k = 25) == 60065601\n assert candidate(n = 10,m = 4,k = 3) == 241950\n assert candidate(n = 25,m = 10,k = 5) == 513807183\n assert candidate(n = 10,m = 1,k = 0) == 0\n assert candidate(n = 20,m = 15,k = 19) == 0\n assert candidate(n = 10,m = 5,k = 4) == 595775\n assert candidate(n = 6,m = 3,k = 3) == 90\n assert candidate(n = 40,m = 15,k = 7) == 487352486\n assert candidate(n = 30,m = 10,k = 10) == 967895731\n assert candidate(n = 35,m = 50,k = 15) == 67294554\n assert candidate(n = 15,m = 3,k = 2) == 7174452\n assert candidate(n = 25,m = 5,k = 5) == 957053963\n assert candidate(n = 50,m = 100,k = 25) == 34549172\n assert candidate(n = 35,m = 25,k = 5) == 706635531\n assert candidate(n = 50,m = 50,k = 50) == 1\n assert candidate(n = 30,m = 30,k = 15) == 153434023\n assert candidate(n = 5,m = 5,k = 3) == 585\n assert candidate(n = 15,m = 8,k = 4) == 997233503\n assert candidate(n = 25,m = 2,k = 1) == 16777217\n assert candidate(n = 35,m = 1,k = 1) == 1\n assert candidate(n = 15,m = 7,k = 5) == 128631420\n assert candidate(n = 35,m = 50,k = 20) == 604238599\n assert candidate(n = 30,m = 20,k = 10) == 91721467\n assert candidate(n = 15,m = 30,k = 7) == 115201714\n assert candidate(n = 25,m = 40,k = 9) == 701520657\n assert candidate(n = 40,m = 25,k = 6) == 775163810\n assert candidate(n = 40,m = 25,k = 20) == 121510237\n assert candidate(n = 5,m = 100,k = 3) == 874379186\n assert candidate(n = 42,m = 50,k = 15) == 300194714\n assert candidate(n = 15,m = 15,k = 7) == 687790825\n assert candidate(n = 30,m = 50,k = 10) == 467663134\n assert candidate(n = 45,m = 50,k = 18) == 362047302\n assert candidate(n = 20,m = 15,k = 10) == 836223400\n assert candidate(n = 5,m = 10,k = 3) == 24420\n assert candidate(n = 35,m = 40,k = 25) == 920448080\n assert candidate(n = 10,m = 10,k = 10) == 1\n assert candidate(n = 20,m = 2,k = 0) == 0\n assert candidate(n = 15,m = 1,k = 0) == 0\n assert candidate(n = 7,m = 6,k = 4) == 15435\n assert candidate(n = 20,m = 15,k = 5) == 290343834\n assert candidate(n = 40,m = 20,k = 20) == 494331990\n assert candidate(n = 10,m = 10,k = 3) == 141166029\n assert candidate(n = 30,m = 100,k = 29) == 66522256\n assert candidate(n = 45,m = 5,k = 10) == 0\n assert candidate(n = 5,m = 4,k = 2) == 500\n assert candidate(n = 50,m = 100,k = 10) == 329962470\n assert candidate(n = 50,m = 100,k = 20) == 90726602\n assert candidate(n = 20,m = 5,k = 5) == 206085257\n assert candidate(n = 45,m = 10,k = 5) == 505926106\n assert candidate(n = 45,m = 40,k = 25) == 391896760\n assert candidate(n = 25,m = 20,k = 4) == 983809007\n assert candidate(n = 50,m = 100,k = 30) == 724411167\n assert candidate(n = 30,m = 3,k = 0) == 0\n assert candidate(n = 20,m = 20,k = 10) == 802034327\n assert candidate(n = 10,m = 5,k = 3) == 2604825\n assert candidate(n = 10,m = 7,k = 3) == 84246120\n assert candidate(n = 30,m = 15,k = 10) == 934932290\n assert candidate(n = 5,m = 3,k = 2) == 120\n assert candidate(n = 50,m = 1,k = 1) == 1\n assert candidate(n = 40,m = 20,k = 1) == 615177897\n assert candidate(n = 15,m = 5,k = 4) == 319448936\n assert candidate(n = 50,m = 1,k = 0) == 0\n assert candidate(n = 35,m = 7,k = 7) == 888706682\n assert candidate(n = 50,m = 10,k = 0) == 0\n assert candidate(n = 20,m = 15,k = 4) == 581619126\n assert candidate(n = 8,m = 8,k = 4) == 1511559\n assert candidate(n = 25,m = 50,k = 15) == 576291422\n assert candidate(n = 25,m = 20,k = 6) == 286391446\n assert candidate(n = 40,m = 10,k = 5) == 403011874\n assert candidate(n = 30,m = 100,k = 10) == 182325231\n assert candidate(n = 30,m = 20,k = 6) == 661827822\n assert candidate(n = 40,m = 40,k = 20) == 387728551\n assert candidate(n = 45,m = 5,k = 0) == 0\n assert candidate(n = 45,m = 30,k = 8) == 208992079\n assert candidate(n = 20,m = 10,k = 5) == 650197027\n assert candidate(n = 15,m = 15,k = 15) == 1\n assert candidate(n = 20,m = 5,k = 3) == 982515902\n assert candidate(n = 40,m = 20,k = 10) == 728982973\n assert candidate(n = 45,m = 9,k = 9) == 102251773\n assert candidate(n = 45,m = 5,k = 1) == 675218148\n assert candidate(n = 30,m = 10,k = 15) == 0\n assert candidate(n = 15,m = 10,k = 5) == 483153304\n assert candidate(n = 45,m = 90,k = 40) == 920197928\n assert candidate(n = 7,m = 7,k = 5) == 5320\n assert candidate(n = 20,m = 50,k = 5) == 46582970\n assert candidate(n = 40,m = 15,k = 15) == 696143324\n assert candidate(n = 25,m = 25,k = 10) == 458548979\n assert candidate(n = 35,m = 15,k = 25) == 0\n assert candidate(n = 45,m = 25,k = 20) == 820427360\n assert candidate(n = 40,m = 25,k = 0) == 0\n assert candidate(n = 20,m = 3,k = 2) == 743392192\n assert candidate(n = 30,m = 20,k = 15) == 845454640\n"}, "metadata": {"canonical_parameter_names": ["n", "m", "k"], "leetcode_dataset_entry_point": "Solution().numOfArrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numOfArrays(int n, int m, int k) {", "container": "Solution", "callable": "numOfArrays", "parameters": [{"name": "n", "type": "int"}, {"name": "m", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1422, "task_id": "maximum-score-after-splitting-a-string", "difficulty": "Easy", "problem_description": "Given a string s of zeros and ones, return the maximum score after splitting the string into two non-empty substrings (i.e. left substring and right substring).\nThe score after splitting a string is the number of zeros in the left substring plus the number of ones in the right substring.\n \nExample 1:\n\nInput: s = \"011101\"\nOutput: 5 \nExplanation: \nAll possible ways of splitting s into two non-empty substrings are:\nleft = \"0\" and right = \"11101\", score = 1 + 4 = 5 \nleft = \"01\" and right = \"1101\", score = 1 + 3 = 4 \nleft = \"011\" and right = \"101\", score = 1 + 2 = 3 \nleft = \"0111\" and right = \"01\", score = 1 + 1 = 2 \nleft = \"01110\" and right = \"1\", score = 2 + 1 = 3\n\nExample 2:\n\nInput: s = \"00111\"\nOutput: 5\nExplanation: When left = \"00\" and right = \"111\", we get the maximum score = 2 + 3 = 5\n\nExample 3:\n\nInput: s = \"1111\"\nOutput: 3\n\n \nConstraints:\n\n2 <= s.length <= 500\nThe string s consists of characters '0' and '1' only.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1111\") == 3\n assert candidate(s = \"00111\") == 5\n assert candidate(s = \"100100\") == 3\n assert candidate(s = \"110011\") == 4\n assert candidate(s = \"001001\") == 5\n assert candidate(s = \"11110000\") == 3\n assert candidate(s = \"0000\") == 3\n assert candidate(s = \"111000\") == 2\n assert candidate(s = \"1001001\") == 5\n assert candidate(s = \"1100\") == 1\n assert candidate(s = \"100001\") == 5\n assert candidate(s = \"00001111\") == 8\n assert candidate(s = \"000111\") == 6\n assert candidate(s = \"1001001001\") == 7\n assert candidate(s = \"001100\") == 4\n assert candidate(s = \"01010101\") == 5\n assert candidate(s = \"010101\") == 4\n assert candidate(s = \"101010\") == 3\n assert candidate(s = \"11001100\") == 4\n assert candidate(s = \"011101\") == 5\n assert candidate(s = \"000111000111000111000\") == 12\n assert candidate(s = \"101010101010101010\") == 9\n assert candidate(s = \"00000000000000000000000001\") == 26\n assert candidate(s = \"1000000000000000001\") == 18\n assert candidate(s = \"000000111111000000111111\") == 18\n assert candidate(s = \"01010101010101010101010101010101010101010\") == 21\n assert candidate(s = \"1000100010001\") == 10\n assert candidate(s = \"11111111110000000001111111111100000000\") == 20\n assert candidate(s = \"0110110110110110110110110110\") == 19\n assert candidate(s = \"0000000011111111111111\") == 22\n assert candidate(s = \"000011110000111100001111000011110000111100001111\") == 28\n assert candidate(s = \"1111111110\") == 8\n assert candidate(s = \"111110000011111000001111100000\") == 15\n assert candidate(s = \"10000000001111111111000000001111111111\") == 29\n assert candidate(s = \"010101010101010101010101\") == 13\n assert candidate(s = \"0110110110\") == 7\n assert candidate(s = \"10101010101010101010101010\") == 13\n assert candidate(s = \"00000000000000001111111111111111\") == 32\n assert candidate(s = \"111000111000111\") == 9\n assert candidate(s = \"111111111111111110\") == 16\n assert candidate(s = \"10011111000111\") == 10\n assert candidate(s = \"000111000111000111\") == 12\n assert candidate(s = \"101010101010101010101010\") == 12\n assert candidate(s = \"1010101010\") == 5\n assert candidate(s = \"010010010010010\") == 10\n assert candidate(s = \"0000000000\") == 9\n assert candidate(s = \"0000000000000000\") == 15\n assert candidate(s = \"1010101010101010\") == 8\n assert candidate(s = \"111100001111000011110000111100001111\") == 20\n assert candidate(s = \"111111000000111111000000\") == 12\n assert candidate(s = \"111100001111000011110000\") == 12\n assert candidate(s = \"000000000000001\") == 15\n assert candidate(s = \"011101110111011101\") == 14\n assert candidate(s = \"111100000000\") == 7\n assert candidate(s = \"101010010101001010100101010010101\") == 19\n assert candidate(s = \"11111000001111100000\") == 10\n assert candidate(s = \"000011110000111100001111000011110000\") == 20\n assert candidate(s = \"1111110000000001\") == 10\n assert candidate(s = \"111111100000001111111100000000111111\") == 21\n assert candidate(s = \"110011001100110011001100110011001100110011001100110011001100110011001100\") == 36\n assert candidate(s = \"010101010101010101010101010\") == 14\n assert candidate(s = \"000000011111110000000011111111000000\") == 23\n assert candidate(s = \"0110110110110110\") == 11\n assert candidate(s = \"0000000001\") == 10\n assert candidate(s = \"11111111111111111110000000000000000\") == 18\n assert candidate(s = \"010100101001010010100101001\") == 17\n assert candidate(s = \"000001111111111111\") == 18\n assert candidate(s = \"101010101010\") == 6\n assert candidate(s = \"0001111000\") == 7\n assert candidate(s = \"1001001001001001001001001001001001001001001001\") == 31\n assert candidate(s = \"0000011111\") == 10\n assert candidate(s = \"11111111111111111111\") == 19\n assert candidate(s = \"1000000000\") == 8\n assert candidate(s = \"1111111111111111\") == 15\n assert candidate(s = \"000111000111000\") == 9\n assert candidate(s = \"0110110110110110110110110110110110110110110110\") == 31\n assert candidate(s = \"110001010101101010010101011110000101010101\") == 22\n assert candidate(s = \"111001010101010\") == 7\n assert candidate(s = \"01000110011001100110\") == 12\n assert candidate(s = \"101010101010101010101010101010101010101\") == 20\n assert candidate(s = \"0000001111111111\") == 16\n assert candidate(s = \"000111111110000\") == 11\n assert candidate(s = \"00000000001111111111\") == 20\n assert candidate(s = \"100100100100100100100100100100100100\") == 23\n assert candidate(s = \"00000000000000000001111111111111111\") == 35\n assert candidate(s = \"111111111111111111111111111111111111111111111\") == 44\n assert candidate(s = \"111000111000111000111\") == 12\n assert candidate(s = \"11001100110011001100\") == 10\n assert candidate(s = \"11111111110000000000\") == 9\n assert candidate(s = \"11100011100011100011\") == 11\n assert candidate(s = \"01010101010101010101010101010101\") == 17\n assert candidate(s = \"0000000001111111110000000001111111110000000000111111111\") == 37\n assert candidate(s = \"0101010101010101010101010101010101010101\") == 21\n assert candidate(s = \"10010010010010010010\") == 13\n assert candidate(s = \"1010101010101010101010101010\") == 14\n assert candidate(s = \"00000000000000000000000000000000000000000000\") == 43\n assert candidate(s = \"111000111000\") == 6\n assert candidate(s = \"111000011111100\") == 10\n assert candidate(s = \"1000000000000000\") == 14\n assert candidate(s = \"000011111111\") == 12\n assert candidate(s = \"1100110011001100110011001100\") == 14\n assert candidate(s = \"0100101010101010\") == 9\n assert candidate(s = \"0101010101010101\") == 9\n assert candidate(s = \"1111111111111101\") == 14\n assert candidate(s = \"0101010101010101010\") == 10\n assert candidate(s = \"00010001000100010001\") == 16\n assert candidate(s = \"000011110000111100001111\") == 16\n assert candidate(s = \"0000111000111000\") == 10\n assert candidate(s = \"0101010101\") == 6\n assert candidate(s = \"11111111111111111111111110\") == 24\n assert candidate(s = \"00110011001100110011\") == 12\n assert candidate(s = \"0111111111000000\") == 10\n assert candidate(s = \"00000000000000000000\") == 19\n assert candidate(s = \"1111000011110000\") == 8\n assert candidate(s = \"10101010101010101010101010101010\") == 16\n assert candidate(s = \"1111100000\") == 4\n assert candidate(s = \"1111000000001111000000001111000000001111000000001111\") == 36\n assert candidate(s = \"0000000000000001\") == 16\n assert candidate(s = \"01010101010101\") == 8\n assert candidate(s = \"1101101101\") == 6\n assert candidate(s = \"1010101010101010101010101010101010101010\") == 20\n assert candidate(s = \"1111111111\") == 9\n assert candidate(s = \"111110000011111\") == 10\n assert candidate(s = \"00011100011100011100\") == 12\n assert candidate(s = \"11101110111011101110\") == 14\n assert candidate(s = \"000100010001000100\") == 13\n assert candidate(s = \"01010101010101010101\") == 11\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101010101010101010101\") == 36\n assert candidate(s = \"1001001001001001001001001001\") == 19\n assert candidate(s = \"000001111100000111110000011111\") == 20\n assert candidate(s = \"0010100101001010010100101001010010\") == 21\n assert candidate(s = \"010101010101010\") == 8\n assert candidate(s = \"00011110001111\") == 11\n assert candidate(s = \"01101101101101101101\") == 14\n assert candidate(s = \"10101010101010101010\") == 10\n assert candidate(s = \"11111111111111110000000000000000\") == 15\n assert candidate(s = \"0001100110\") == 7\n assert candidate(s = \"0000000000011111111111\") == 22\n assert candidate(s = \"11111111111111110000000000\") == 15\n assert candidate(s = \"001100110011001100110011001100\") == 16\n assert candidate(s = \"001100110011\") == 8\n assert candidate(s = \"0111000001\") == 7\n assert candidate(s = \"0000111100001111\") == 12\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxScore(string s) {", "container": "Solution", "callable": "maxScore", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1423, "task_id": "maximum-points-you-can-obtain-from-cards", "difficulty": "Medium", "problem_description": "There are several cards arranged in a row, and each card has an associated number of points. The points are given in the integer array cardPoints.\nIn one step, you can take one card from the beginning or from the end of the row. You have to take exactly k cards.\nYour score is the sum of the points of the cards you have taken.\nGiven the integer array cardPoints and the integer k, return the maximum score you can obtain.\n \nExample 1:\n\nInput: cardPoints = [1,2,3,4,5,6,1], k = 3\nOutput: 12\nExplanation: After the first step, your score will always be 1. However, choosing the rightmost card first will maximize your total score. The optimal strategy is to take the three cards on the right, giving a final score of 1 + 6 + 5 = 12.\n\nExample 2:\n\nInput: cardPoints = [2,2,2], k = 2\nOutput: 4\nExplanation: Regardless of which two cards you take, your score will always be 4.\n\nExample 3:\n\nInput: cardPoints = [9,7,7,9,7,7,9], k = 7\nOutput: 55\nExplanation: You have to take all the cards. Your score is the sum of points of all cards.\n\n \nConstraints:\n\n1 <= cardPoints.length <= 105\n1 <= cardPoints[i] <= 104\n1 <= k <= cardPoints.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(cardPoints = [5, 2, 1, 2, 5],k = 3) == 12\n assert candidate(cardPoints = [9, 7, 7, 9, 7, 7, 9],k = 7) == 55\n assert candidate(cardPoints = [1, 1000, 1],k = 1) == 1\n assert candidate(cardPoints = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 40\n assert candidate(cardPoints = [2, 2, 2],k = 2) == 4\n assert candidate(cardPoints = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 34\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 1],k = 3) == 12\n assert candidate(cardPoints = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 90\n assert candidate(cardPoints = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],k = 5) == 5000\n assert candidate(cardPoints = [100, 400, 300, 100, 200, 500, 600, 300, 400],k = 4) == 1800\n assert candidate(cardPoints = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 10) == 1111111111\n assert candidate(cardPoints = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 10) == 300\n assert candidate(cardPoints = [5, 2, 1, 2, 5, 5, 5, 5, 5, 2, 1, 2, 5],k = 8) == 30\n assert candidate(cardPoints = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 10) == 100000\n assert candidate(cardPoints = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 155\n assert candidate(cardPoints = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 50\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 195\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 19\n assert candidate(cardPoints = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 5) == 50000\n assert candidate(cardPoints = [3, 1, 2, 7, 4, 5, 6],k = 3) == 15\n assert candidate(cardPoints = [10, 1, 1, 10, 1, 1, 10, 1, 1],k = 3) == 12\n assert candidate(cardPoints = [5, 1, 1, 2, 4, 2, 2, 5, 5, 4],k = 5) == 21\n assert candidate(cardPoints = [8, 9, 10, 4, 10, 1, 1, 1, 5, 9],k = 4) == 36\n assert candidate(cardPoints = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500],k = 10) == 5000\n assert candidate(cardPoints = [5, 1, 1, 2, 4, 2, 2, 5, 5, 5],k = 3) == 15\n assert candidate(cardPoints = [5, 6, 4, 2, 7, 8, 3, 1, 9],k = 4) == 24\n assert candidate(cardPoints = [1000, 100, 10, 1, 10000, 1000, 100, 10],k = 4) == 11110\n assert candidate(cardPoints = [1, 2, 100, 3, 4, 100, 5, 6, 100, 7, 8, 100, 9, 10, 100, 11, 12, 100, 13, 14],k = 7) == 260\n assert candidate(cardPoints = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 34\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 90\n assert candidate(cardPoints = [5, 3, 8, 7, 6, 2, 9, 1, 4, 10],k = 4) == 26\n assert candidate(cardPoints = [10, 4, 5, 1, 7, 12, 3, 8, 6],k = 4) == 29\n assert candidate(cardPoints = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 10\n assert candidate(cardPoints = [5, 9, 3, 4, 6, 7, 2, 8, 1, 0],k = 5) == 27\n assert candidate(cardPoints = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 10\n assert candidate(cardPoints = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],k = 6) == 39\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 195\n assert candidate(cardPoints = [5, 2, 1, 3, 4, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1],k = 8) == 51\n assert candidate(cardPoints = [10000, 10000, 10000, 10000, 10000],k = 5) == 50000\n assert candidate(cardPoints = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 20) == 20\n assert candidate(cardPoints = [8, 9, 10, 4, 10, 4, 2, 2, 10, 10, 8, 6, 5, 1, 5, 9, 1, 6, 10, 8],k = 6) == 51\n assert candidate(cardPoints = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 5) == 15\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 7) == 49\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 3) == 57\n assert candidate(cardPoints = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 1550\n assert candidate(cardPoints = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3],k = 10) == 20\n assert candidate(cardPoints = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 25\n assert candidate(cardPoints = [10000, 1, 10000, 1, 10000, 1],k = 3) == 20001\n assert candidate(cardPoints = [100, 40, 17, 9, 73, 75, 36, 21, 14, 92, 58],k = 5) == 307\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 34\n assert candidate(cardPoints = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 15) == 23\n assert candidate(cardPoints = [8, 9, 7, 6, 5, 4, 3, 2, 1],k = 3) == 24\n assert candidate(cardPoints = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 18) == 90\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],k = 20) == 810\n assert candidate(cardPoints = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 6) == 84\n assert candidate(cardPoints = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991],k = 5) == 49990\n assert candidate(cardPoints = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41],k = 15) == 405\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 84\n assert candidate(cardPoints = [2, 3, 1, 2, 4, 3, 1, 5, 4],k = 5) == 17\n assert candidate(cardPoints = [5, 1, 1, 2, 4, 2, 2, 5, 5, 1],k = 3) == 11\n assert candidate(cardPoints = [5, 3, 1, 2, 6, 4, 8, 9, 10, 7, 2, 1, 3, 4, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 193\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 19) == 209\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 40\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 155\n assert candidate(cardPoints = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 400\n assert candidate(cardPoints = [3, 2, 6, 7, 5, 4, 8, 1, 9],k = 4) == 22\n assert candidate(cardPoints = [3, 2, 7, 4, 1],k = 2) == 5\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 15) == 345\n assert candidate(cardPoints = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 155\n assert candidate(cardPoints = [3, 1, 3, 100, 100, 100, 3, 1, 3],k = 5) == 207\n assert candidate(cardPoints = [3, 1, 5, 9, 2, 6, 5, 3, 5, 9],k = 5) == 28\n assert candidate(cardPoints = [5, 2, 1, 7, 3, 4, 6],k = 4) == 20\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 20) == 210\n assert candidate(cardPoints = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 3) == 270\n assert candidate(cardPoints = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 55\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 27\n assert candidate(cardPoints = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],k = 15) == 3450\n assert candidate(cardPoints = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 65\n"}, "metadata": {"canonical_parameter_names": ["cardPoints", "k"], "leetcode_dataset_entry_point": "Solution().maxScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxScore(vector& cardPoints, int k) {", "container": "Solution", "callable": "maxScore", "parameters": [{"name": "cardPoints", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1424, "task_id": "diagonal-traverse-ii", "difficulty": "Medium", "problem_description": "Given a 2D integer array nums, return all elements of nums in diagonal order as shown in the below images.\n \nExample 1:\n\n\nInput: nums = [[1,2,3],[4,5,6],[7,8,9]]\nOutput: [1,4,2,7,5,3,8,6,9]\n\nExample 2:\n\n\nInput: nums = [[1,2,3,4,5],[6,7],[8],[9,10,11],[12,13,14,15,16]]\nOutput: [1,6,2,8,7,3,9,4,12,10,5,13,11,14,15,16]\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i].length <= 105\n1 <= sum(nums[i].length) <= 105\n1 <= nums[i][j] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [[1]]) == [1]\n assert candidate(nums = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == [1, 4, 2, 7, 5, 3, 8, 6, 9]\n assert candidate(nums = [[1, 2, 3], [4, 5], [6]]) == [1, 4, 2, 6, 5, 3]\n assert candidate(nums = [[1, 2, 3, 4, 5], [6, 7], [8], [9, 10, 11], [12, 13, 14, 15, 16]]) == [1, 6, 2, 8, 7, 3, 9, 4, 12, 10, 5, 13, 11, 14, 15, 16]\n assert candidate(nums = [[1, 2], [3, 4], [5, 6]]) == [1, 3, 2, 5, 4, 6]\n assert candidate(nums = [[1, 2, 3], [4], [5, 6, 7], [8, 9]]) == [1, 4, 2, 5, 3, 8, 6, 9, 7]\n assert candidate(nums = [[1, 2], [3, 4, 5], [6, 7, 8, 9]]) == [1, 3, 2, 6, 4, 7, 5, 8, 9]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25, 26], [27, 28, 29, 30, 31], [32, 33, 34], [35, 36], [37]]) == [1, 11, 2, 20, 12, 3, 27, 21, 13, 4, 32, 28, 22, 14, 5, 35, 33, 29, 23, 15, 6, 37, 36, 34, 30, 24, 16, 7, 31, 25, 17, 8, 26, 18, 9, 19, 10]\n assert candidate(nums = [[100, 200], [300, 400, 500, 600], [700], [800, 900, 1000, 1100, 1200, 1300], [1400, 1500]]) == [100, 300, 200, 700, 400, 800, 500, 1400, 900, 600, 1500, 1000, 1100, 1200, 1300]\n assert candidate(nums = [[1, 2, 3, 4], [5, 6, 7], [8], [9, 10, 11, 12], [13, 14], [15, 16, 17, 18, 19, 20]]) == [1, 5, 2, 8, 6, 3, 9, 7, 4, 13, 10, 15, 14, 11, 16, 12, 17, 18, 19, 20]\n assert candidate(nums = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36], [37, 38, 39, 40], [41, 42], [43], [44, 45, 46], [47, 48, 49, 50, 51]]) == [1, 21, 2, 31, 22, 3, 37, 32, 23, 4, 41, 38, 33, 24, 5, 43, 42, 39, 34, 25, 6, 44, 40, 35, 26, 7, 47, 45, 36, 27, 8, 48, 46, 28, 9, 49, 29, 10, 50, 30, 11, 51, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [[1, 2], [3, 4, 5], [6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27]]) == [1, 3, 2, 6, 4, 10, 7, 5, 15, 11, 8, 21, 16, 12, 9, 22, 17, 13, 23, 18, 14, 24, 19, 25, 20, 26, 27]\n assert candidate(nums = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18], [19, 20], [21], [22, 23, 24], [25, 26, 27, 28]]) == [1, 11, 2, 16, 12, 3, 19, 17, 13, 4, 21, 20, 18, 14, 5, 22, 15, 6, 25, 23, 7, 26, 24, 8, 27, 9, 28, 10]\n assert candidate(nums = [[1], [2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25], [26, 27, 28, 29, 30, 31], [32, 33, 34, 35, 36, 37, 38, 39, 40]]) == [1, 2, 11, 3, 26, 12, 4, 32, 27, 13, 5, 33, 28, 14, 6, 34, 29, 15, 7, 35, 30, 16, 8, 36, 31, 17, 9, 37, 18, 10, 38, 19, 39, 20, 40, 21, 22, 23, 24, 25]\n assert candidate(nums = [[1], [2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35, 36]]) == [1, 2, 4, 3, 7, 5, 11, 8, 6, 16, 12, 9, 22, 17, 13, 10, 29, 23, 18, 14, 30, 24, 19, 15, 31, 25, 20, 32, 26, 21, 33, 27, 34, 28, 35, 36]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25, 26, 27], [28, 29, 30, 31, 32, 33], [34, 35, 36, 37, 38], [39, 40, 41, 42], [43, 44, 45], [46, 47], [48, 49], [50]]) == [1, 11, 2, 20, 12, 3, 28, 21, 13, 4, 34, 29, 22, 14, 5, 39, 35, 30, 23, 15, 6, 43, 40, 36, 31, 24, 16, 7, 46, 44, 41, 37, 32, 25, 17, 8, 48, 47, 45, 42, 38, 33, 26, 18, 9, 50, 49, 27, 19, 10]\n assert candidate(nums = [[1], [2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12, 13], [14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25, 26], [27, 28, 29, 30, 31, 32, 33, 34], [35, 36, 37, 38, 39, 40, 41, 42, 43]]) == [1, 2, 5, 3, 9, 6, 4, 14, 10, 7, 20, 15, 11, 8, 27, 21, 16, 12, 35, 28, 22, 17, 13, 36, 29, 23, 18, 37, 30, 24, 19, 38, 31, 25, 39, 32, 26, 40, 33, 41, 34, 42, 43]\n assert candidate(nums = [[1, 2, 3, 4], [5, 6], [7, 8, 9], [10], [11, 12, 13, 14, 15], [16, 17, 18], [19, 20], [21, 22, 23, 24], [25, 26, 27], [28, 29, 30]]) == [1, 5, 2, 7, 6, 3, 10, 8, 4, 11, 9, 16, 12, 19, 17, 13, 21, 20, 18, 14, 25, 22, 15, 28, 26, 23, 29, 27, 24, 30]\n assert candidate(nums = [[1, 2, 3, 4, 5], [6, 7, 8], [9, 10], [11], [12, 13, 14, 15, 16, 17], [18, 19, 20, 21], [22]]) == [1, 6, 2, 9, 7, 3, 11, 10, 8, 4, 12, 5, 18, 13, 22, 19, 14, 20, 15, 21, 16, 17]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25, 26], [27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37], [38, 39, 40, 41], [42, 43, 44], [45, 46], [47]]) == [1, 11, 2, 20, 12, 3, 27, 21, 13, 4, 33, 28, 22, 14, 5, 38, 34, 29, 23, 15, 6, 42, 39, 35, 30, 24, 16, 7, 45, 43, 40, 36, 31, 25, 17, 8, 47, 46, 44, 41, 37, 32, 26, 18, 9, 19, 10]\n assert candidate(nums = [[1, 2, 3], [4, 5, 6, 7, 8, 9, 10], [11, 12, 13], [14, 15, 16, 17, 18, 19, 20, 21, 22]]) == [1, 4, 2, 11, 5, 3, 14, 12, 6, 15, 13, 7, 16, 8, 17, 9, 18, 10, 19, 20, 21, 22]\n assert candidate(nums = [[1, 2], [3, 4, 5, 6, 7], [8, 9, 10], [11, 12], [13], [14, 15, 16, 17], [18, 19, 20], [21, 22], [23], [24, 25, 26, 27, 28]]) == [1, 3, 2, 8, 4, 11, 9, 5, 13, 12, 10, 6, 14, 7, 18, 15, 21, 19, 16, 23, 22, 20, 17, 24, 25, 26, 27, 28]\n assert candidate(nums = [[1], [2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 21]]) == [1, 2, 4, 3, 7, 5, 11, 8, 6, 16, 12, 9, 17, 13, 10, 18, 14, 19, 15, 20, 21]\n assert candidate(nums = [[1, 2, 3], [4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24, 25, 26, 27], [28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43]]) == [1, 4, 2, 9, 5, 3, 19, 10, 6, 28, 20, 11, 7, 29, 21, 12, 8, 30, 22, 13, 31, 23, 14, 32, 24, 15, 33, 25, 16, 34, 26, 17, 35, 27, 18, 36, 37, 38, 39, 40, 41, 42, 43]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25, 26], [27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37], [38, 39, 40, 41], [42, 43, 44], [45, 46], [47], [48]]) == [1, 11, 2, 20, 12, 3, 27, 21, 13, 4, 33, 28, 22, 14, 5, 38, 34, 29, 23, 15, 6, 42, 39, 35, 30, 24, 16, 7, 45, 43, 40, 36, 31, 25, 17, 8, 47, 46, 44, 41, 37, 32, 26, 18, 9, 48, 19, 10]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6], [7, 8, 9], [10, 11], [12, 13, 14, 15], [16, 17, 18, 19, 20]]) == [1, 7, 2, 10, 8, 3, 12, 11, 9, 4, 16, 13, 5, 17, 14, 6, 18, 15, 19, 20]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]\n assert candidate(nums = [[1], [2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13], [14, 15], [16]]) == [1, 2, 4, 3, 7, 5, 11, 8, 6, 14, 12, 9, 16, 15, 13, 10]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24], [25, 26, 27], [28, 29, 30, 31, 32, 33, 34, 35, 36]]) == [1, 11, 2, 20, 12, 3, 25, 21, 13, 4, 28, 26, 22, 14, 5, 29, 27, 23, 15, 6, 30, 24, 16, 7, 31, 17, 8, 32, 18, 9, 33, 19, 10, 34, 35, 36]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6], [7, 8], [9, 10, 11], [12, 13, 14], [15], [16, 17, 18, 19]]) == [1, 7, 2, 9, 8, 3, 12, 10, 4, 15, 13, 11, 5, 16, 14, 6, 17, 18, 19]\n assert candidate(nums = [[1, 2, 3, 4], [5, 6, 7], [8], [9, 10, 11, 12], [13, 14]]) == [1, 5, 2, 8, 6, 3, 9, 7, 4, 13, 10, 14, 11, 12]\n assert candidate(nums = [[1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19], [20, 21], [22]]) == [1, 4, 2, 8, 5, 3, 13, 9, 6, 17, 14, 10, 7, 20, 18, 15, 11, 22, 21, 19, 16, 12]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6], [7, 8, 9], [10, 11, 12, 13], [14, 15], [16]]) == [1, 7, 2, 10, 8, 3, 14, 11, 9, 4, 16, 15, 12, 5, 13, 6]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28], [29, 30, 31], [32, 33], [34], [35, 36, 37], [38, 39, 40, 41, 42]]) == [1, 11, 2, 19, 12, 3, 25, 20, 13, 4, 29, 26, 21, 14, 5, 32, 30, 27, 22, 15, 6, 34, 33, 31, 28, 23, 16, 7, 35, 24, 17, 8, 38, 36, 18, 9, 39, 37, 10, 40, 41, 42]\n assert candidate(nums = [[1, 2, 3], [4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28, 29], [30, 31, 32, 33, 34, 35, 36, 37, 38]]) == [1, 4, 2, 9, 5, 3, 15, 10, 6, 22, 16, 11, 7, 30, 23, 17, 12, 8, 31, 24, 18, 13, 32, 25, 19, 14, 33, 26, 20, 34, 27, 21, 35, 28, 36, 29, 37, 38]\n assert candidate(nums = [[1], [2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12, 13], [14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25, 26], [27, 28, 29, 30, 31, 32, 33, 34]]) == [1, 2, 5, 3, 9, 6, 4, 14, 10, 7, 20, 15, 11, 8, 27, 21, 16, 12, 28, 22, 17, 13, 29, 23, 18, 30, 24, 19, 31, 25, 32, 26, 33, 34]\n assert candidate(nums = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29], [30, 31, 32, 33], [34, 35, 36], [37, 38], [39]]) == [1, 6, 2, 12, 7, 3, 19, 13, 8, 4, 25, 20, 14, 9, 5, 30, 26, 21, 15, 10, 34, 31, 27, 22, 16, 11, 37, 35, 32, 28, 23, 17, 39, 38, 36, 33, 29, 24, 18]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55]\n assert candidate(nums = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25, 26], [27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == [1, 11, 2, 20, 12, 3, 27, 21, 13, 4, 28, 22, 14, 5, 29, 23, 15, 6, 30, 24, 16, 7, 31, 25, 17, 8, 32, 26, 18, 9, 33, 19, 10, 34, 35, 36, 37, 38, 39, 40]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10], [11, 12, 13], [14, 15], [16], [17, 18, 19, 20]]) == [1, 7, 2, 11, 8, 3, 14, 12, 9, 4, 16, 15, 13, 10, 5, 17, 6, 18, 19, 20]\n assert candidate(nums = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25], [26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]]) == [1, 26, 2, 27, 3, 28, 4, 29, 5, 30, 6, 31, 7, 32, 8, 33, 9, 34, 10, 35, 11, 36, 12, 37, 13, 38, 14, 39, 15, 40, 16, 41, 17, 42, 18, 43, 19, 44, 20, 45, 21, 46, 22, 47, 23, 48, 24, 49, 25, 50]\n assert candidate(nums = [[1, 2, 3], [4, 5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16], [17, 18, 19, 20], [21]]) == [1, 4, 2, 10, 5, 3, 15, 11, 6, 17, 16, 12, 7, 21, 18, 13, 8, 19, 14, 9, 20]\n assert candidate(nums = [[1, 2, 3, 4, 5], [6, 7, 8], [9, 10], [11], [12, 13, 14, 15], [16, 17, 18], [19], [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]]) == [1, 6, 2, 9, 7, 3, 11, 10, 8, 4, 12, 5, 16, 13, 19, 17, 14, 20, 18, 15, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(nums = [[1, 2, 3, 4, 5], [6, 7, 8, 9], [10, 11, 12], [13, 14], [15], [16, 17, 18, 19, 20]]) == [1, 6, 2, 10, 7, 3, 13, 11, 8, 4, 15, 14, 12, 9, 5, 16, 17, 18, 19, 20]\n assert candidate(nums = [[1], [2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14, 15]]) == [1, 2, 4, 3, 7, 5, 11, 8, 6, 12, 9, 13, 10, 14, 15]\n assert candidate(nums = [[1, 2], [3, 4, 5], [6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20]]) == [1, 3, 2, 6, 4, 10, 7, 5, 15, 11, 8, 16, 12, 9, 17, 13, 18, 14, 19, 20]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29], [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41], [42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52], [53, 54, 55, 56, 57, 58, 59, 60, 61, 62], [63, 64, 65, 66, 67, 68, 69, 70, 71], [72, 73, 74, 75, 76, 77, 78], [79, 80, 81, 82, 83, 84], [85, 86, 87, 88, 89], [90, 91, 92, 93], [94, 95, 96], [97, 98], [99]]) == [1, 16, 2, 30, 17, 3, 42, 31, 18, 4, 53, 43, 32, 19, 5, 63, 54, 44, 33, 20, 6, 72, 64, 55, 45, 34, 21, 7, 79, 73, 65, 56, 46, 35, 22, 8, 85, 80, 74, 66, 57, 47, 36, 23, 9, 90, 86, 81, 75, 67, 58, 48, 37, 24, 10, 94, 91, 87, 82, 76, 68, 59, 49, 38, 25, 11, 97, 95, 92, 88, 83, 77, 69, 60, 50, 39, 26, 12, 99, 98, 96, 93, 89, 84, 78, 70, 61, 51, 40, 27, 13, 71, 62, 52, 41, 28, 14, 29, 15]\n assert candidate(nums = [[1, 2, 3, 4, 5], [6, 7, 8, 9], [10, 11, 12], [13, 14], [15]]) == [1, 6, 2, 10, 7, 3, 13, 11, 8, 4, 15, 14, 12, 9, 5]\n assert candidate(nums = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20], [21], [22], [23], [24], [25]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(nums = [[1, 2, 3, 4], [5, 6, 7], [8, 9], [10], [11, 12, 13, 14, 15], [16, 17, 18, 19]]) == [1, 5, 2, 8, 6, 3, 10, 9, 7, 4, 11, 16, 12, 17, 13, 18, 14, 19, 15]\n assert candidate(nums = [[1], [2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28]]) == [1, 2, 4, 3, 7, 5, 11, 8, 6, 16, 12, 9, 22, 17, 13, 10, 23, 18, 14, 24, 19, 15, 25, 20, 26, 21, 27, 28]\n assert candidate(nums = [[1, 2], [3], [4, 5, 6, 7], [8, 9], [10, 11, 12], [13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23]]) == [1, 3, 2, 4, 8, 5, 10, 9, 6, 13, 11, 7, 18, 14, 12, 19, 15, 20, 16, 21, 17, 22, 23]\n assert candidate(nums = [[1, 2, 3, 4], [5, 6, 7], [8, 9], [10], [11, 12, 13, 14], [15, 16]]) == [1, 5, 2, 8, 6, 3, 10, 9, 7, 4, 11, 15, 12, 16, 13, 14]\n assert candidate(nums = [[1], [2, 3, 4], [5, 6], [7, 8, 9, 10], [11, 12, 13], [14, 15, 16, 17, 18]]) == [1, 2, 5, 3, 7, 6, 4, 11, 8, 14, 12, 9, 15, 13, 10, 16, 17, 18]\n assert candidate(nums = [[1, 2, 3, 4, 5], [6, 7, 8, 9], [10, 11, 12], [13, 14], [15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == [1, 6, 2, 10, 7, 3, 13, 11, 8, 4, 15, 14, 12, 9, 5, 16, 21, 17, 22, 18, 23, 19, 24, 20, 25]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28], [29, 30, 31], [32, 33], [34]]) == [1, 11, 2, 19, 12, 3, 25, 20, 13, 4, 29, 26, 21, 14, 5, 32, 30, 27, 22, 15, 6, 34, 33, 31, 28, 23, 16, 7, 24, 17, 8, 18, 9, 10]\n assert candidate(nums = [[100, 200, 300], [400, 500], [600], [700, 800, 900, 1000], [1100, 1200, 1300], [1400, 1500, 1600, 1700, 1800]]) == [100, 400, 200, 600, 500, 300, 700, 1100, 800, 1400, 1200, 900, 1500, 1300, 1000, 1600, 1700, 1800]\n assert candidate(nums = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [[1, 2, 3, 4], [5, 6, 7], [8, 9], [10]]) == [1, 5, 2, 8, 6, 3, 10, 9, 7, 4]\n assert candidate(nums = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30], [31, 32, 33, 34, 35], [36, 37, 38, 39, 40], [41, 42, 43, 44, 45]]) == [1, 6, 2, 11, 7, 3, 16, 12, 8, 4, 21, 17, 13, 9, 5, 26, 22, 18, 14, 10, 31, 27, 23, 19, 15, 36, 32, 28, 24, 20, 41, 37, 33, 29, 25, 42, 38, 34, 30, 43, 39, 35, 44, 40, 45]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21], [22, 23, 24, 25], [26, 27], [28]]) == [1, 10, 2, 17, 11, 3, 22, 18, 12, 4, 26, 23, 19, 13, 5, 28, 27, 24, 20, 14, 6, 25, 21, 15, 7, 16, 8, 9]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45]]) == [1, 16, 2, 31, 17, 3, 32, 18, 4, 33, 19, 5, 34, 20, 6, 35, 21, 7, 36, 22, 8, 37, 23, 9, 38, 24, 10, 39, 25, 11, 40, 26, 12, 41, 27, 13, 42, 28, 14, 43, 29, 15, 44, 30, 45]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == [1, 21, 2, 22, 3, 23, 4, 24, 5, 25, 6, 26, 7, 27, 8, 28, 9, 29, 10, 30, 11, 31, 12, 32, 13, 33, 14, 34, 15, 35, 16, 36, 17, 37, 18, 38, 19, 39, 20, 40]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25, 26, 27], [28, 29, 30, 31, 32, 33, 34], [35, 36, 37, 38, 39, 40]]) == [1, 11, 2, 20, 12, 3, 28, 21, 13, 4, 35, 29, 22, 14, 5, 36, 30, 23, 15, 6, 37, 31, 24, 16, 7, 38, 32, 25, 17, 8, 39, 33, 26, 18, 9, 40, 34, 27, 19, 10]\n assert candidate(nums = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27], [28, 29, 30, 31, 32], [33, 34, 35, 36], [37, 38, 39], [40, 41], [42], [43]]) == [1, 12, 2, 21, 13, 3, 28, 22, 14, 4, 33, 29, 23, 15, 5, 37, 34, 30, 24, 16, 6, 40, 38, 35, 31, 25, 17, 7, 42, 41, 39, 36, 32, 26, 18, 8, 43, 27, 19, 9, 20, 10, 11]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findDiagonalOrder", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector findDiagonalOrder(vector>& nums) {", "container": "Solution", "callable": "findDiagonalOrder", "parameters": [{"name": "nums", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1425, "task_id": "constrained-subsequence-sum", "difficulty": "Hard", "problem_description": "Given an integer array nums and an integer k, return the maximum sum of a non-empty subsequence of that array such that for every two consecutive integers in the subsequence, nums[i] and nums[j], where i < j, the condition j - i <= k is satisfied.\nA subsequence of an array is obtained by deleting some number of elements (can be zero) from the array, leaving the remaining elements in their original order.\n \nExample 1:\n\nInput: nums = [10,2,-10,5,20], k = 2\nOutput: 37\nExplanation: The subsequence is [10, 2, 5, 20].\n\nExample 2:\n\nInput: nums = [-1,-2,-3], k = 1\nOutput: -1\nExplanation: The subsequence must be non-empty, so we choose the largest number.\n\nExample 3:\n\nInput: nums = [10,-2,-10,-5,20], k = 2\nOutput: 23\nExplanation: The subsequence is [10, -2, -5, 20].\n\n \nConstraints:\n\n1 <= k <= nums.length <= 105\n-104 <= nums[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 7, -3, 5],k = 1) == 14\n assert candidate(nums = [10, 2, -10, 5, 20],k = 2) == 37\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 15\n assert candidate(nums = [3, -1, 4, -2, 2, 1],k = 2) == 10\n assert candidate(nums = [-1, -2, -3, -4, -5],k = 4) == -1\n assert candidate(nums = [5, -1, 5],k = 2) == 10\n assert candidate(nums = [-1, -2, -3],k = 1) == -1\n assert candidate(nums = [5, 4, 3, 2, 1],k = 5) == 15\n assert candidate(nums = [5, 3, -5, -10, -3, 7],k = 4) == 15\n assert candidate(nums = [1, -1, 5, -2, 3],k = 3) == 9\n assert candidate(nums = [10, -2, -10, -5, 20],k = 2) == 23\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 2) == 15\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],k = 2) == 150\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 55\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20],k = 5) == -1\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70],k = 1) == -10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 20) == 20\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],k = 4) == 150\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 10) == 55\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 5) == -1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 15) == 5500\n assert candidate(nums = [1000, -500, 200, -300, 400, -200, 600, -100, 700, -300],k = 5) == 2900\n assert candidate(nums = [10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000],k = 4) == 50000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 55\n assert candidate(nums = [-10, -3, -5, -1, -6, -2, -4, -8, -9],k = 2) == -1\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981],k = 5) == 19810\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1],k = 2) == 8\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 3) == 0\n assert candidate(nums = [10, -2, 3, 5, -1, 2, 0, 8, -5, 10],k = 4) == 38\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == 0\n assert candidate(nums = [100, -100, 100, -100, 100, -100, 100, -100, 100, -100],k = 2) == 500\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 0\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 1) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 55\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 7) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 55\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 550\n assert candidate(nums = [100, -200, 300, -400, 500, 600, -700, 800, -900, 1000],k = 3) == 3300\n assert candidate(nums = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000, -5000],k = 2) == 15000\n assert candidate(nums = [1, 2, 3, -4, 5, 6, -7, 8, 9, -10],k = 3) == 34\n assert candidate(nums = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],k = 7) == 400\n assert candidate(nums = [-1000, -2000, -3000, -4000, -5000, 5000, 4000, 3000, 2000, 1000],k = 4) == 15000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 20) == 210\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9],k = 4) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 1) == 550\n assert candidate(nums = [5, 2, 3, 1, 6, 4, 7, 8, 9, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 65\n assert candidate(nums = [100, -300, 200, 50, -150, 400, 300],k = 3) == 1050\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1],k = 3) == 30\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500],k = 5) == 1500\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 8) == 400\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 1) == -1\n assert candidate(nums = [-10, 2, -3, -4, 5, 6, -1, 2, 3, -10, 100, -200, 300],k = 4) == 418\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],k = 5) == 15\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15],k = 6) == 64\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1],k = 2) == 5\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5],k = 15) == 50\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, -5000, -4000, -3000, -2000, -1000],k = 5) == 15000\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],k = 7) == 8000\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5],k = 5) == 50\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],k = 4) == 1045\n assert candidate(nums = [100, 200, 300, 400, 500, -100, -200, -300, -400, -500, 600, 700, 800, 900, 1000],k = 7) == 5500\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 1) == 50\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 2) == -1\n assert candidate(nums = [0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19],k = 9) == 90\n assert candidate(nums = [100, -50, 200, -250, 300, -350, 400, -450, 500],k = 5) == 1500\n assert candidate(nums = [1, -2, 3, 5, -1, 2, 4, -3, 7],k = 3) == 22\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 2) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -100, -90, -80, -70, -60, -50, -40, -30, -20, -10],k = 6) == 550\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 10) == 55\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 1) == 5500\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],k = 5) == 105\n assert candidate(nums = [3, -1, 4, -1, 5, -9, 2, 6, -5, 3, 5, -7, 8, -2, 6],k = 5) == 42\n assert candidate(nums = [100, 50, 20, 10, -10, -20, -50, -100, 30, 40],k = 4) == 240\n assert candidate(nums = [-10, 2, -3, 4, -1, 5, -6, 7, -8, 9],k = 4) == 27\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 7) == 325\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 2100\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 5) == 6\n assert candidate(nums = [10, -2, -10, 5, 20, -30, 40, -50, 60, -70],k = 3) == 135\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80, 90, -90, 100, -100],k = 7) == 550\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91],k = 5) == -91\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],k = 3) == -1\n assert candidate(nums = [1, 2, 3, -6, 4, 5, -7, 6, 7, -8, 8, 9],k = 3) == 45\n assert candidate(nums = [1, -100, 1000, -10000, 100000, -1000000, 10000000, -100000000, 1000000000],k = 2) == 1010101001\n assert candidate(nums = [3, -2, 5, -1, 6, 2, -5, 10],k = 3) == 26\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100, 110, -120],k = 6) == 360\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 55\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 3) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 1) == 1\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000],k = 4) == 2500\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 12, -12, 6, -6, 3, -3, 1, -1],k = 6) == 197\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 2) == 5\n assert candidate(nums = [3, -1, -10, 4, 13, -5, 12, -3, 15, -10, 7, 8],k = 3) == 62\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 1) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 210\n assert candidate(nums = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000],k = 3) == 15000\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000],k = 5) == 2500\n assert candidate(nums = [10, 20, 30, 40, 50, -1, -2, -3, -4, -5, 60, 70, 80, 90, 100],k = 10) == 550\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20],k = 10) == 100\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],k = 4) == -10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 210\n assert candidate(nums = [-10000, -9000, -8000, -7000, -6000, -5000, -4000, -3000, -2000, -1000],k = 2) == -1000\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15],k = 7) == 64\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 3) == 55\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1],k = 4) == -1\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 120\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 3) == 0\n assert candidate(nums = [10, -5, 20, -10, 5, 15, -3],k = 3) == 50\n assert candidate(nums = [-5, -5, -5, -5, -5, -5, -5, -5, -5, -5],k = 1) == -5\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 0\n assert candidate(nums = [-1, 3, -2, 5, -6, 4, 2, -3, 5, -4],k = 3) == 19\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().constrainedSubsetSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int constrainedSubsetSum(vector& nums, int k) {", "container": "Solution", "callable": "constrainedSubsetSum", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1431, "task_id": "kids-with-the-greatest-number-of-candies", "difficulty": "Easy", "problem_description": "There are n kids with candies. You are given an integer array candies, where each candies[i] represents the number of candies the ith kid has, and an integer extraCandies, denoting the number of extra candies that you have.\nReturn a boolean array result of length n, where result[i] is true if, after giving the ith kid all the extraCandies, they will have the greatest number of candies among all the kids, or false otherwise.\nNote that multiple kids can have the greatest number of candies.\n \nExample 1:\n\nInput: candies = [2,3,5,1,3], extraCandies = 3\nOutput: [true,true,true,false,true] \nExplanation: If you give all extraCandies to:\n- Kid 1, they will have 2 + 3 = 5 candies, which is the greatest among the kids.\n- Kid 2, they will have 3 + 3 = 6 candies, which is the greatest among the kids.\n- Kid 3, they will have 5 + 3 = 8 candies, which is the greatest among the kids.\n- Kid 4, they will have 1 + 3 = 4 candies, which is not the greatest among the kids.\n- Kid 5, they will have 3 + 3 = 6 candies, which is the greatest among the kids.\n\nExample 2:\n\nInput: candies = [4,2,1,1,2], extraCandies = 1\nOutput: [true,false,false,false,false] \nExplanation: There is only 1 extra candy.\nKid 1 will always have the greatest number of candies, even if a different kid is given the extra candy.\n\nExample 3:\n\nInput: candies = [12,1,12], extraCandies = 10\nOutput: [true,false,true]\n\n \nConstraints:\n\nn == candies.length\n2 <= n <= 100\n1 <= candies[i] <= 100\n1 <= extraCandies <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(candies = [4, 2, 1, 1, 2],extraCandies = 1) == [True, False, False, False, False]\n assert candidate(candies = [12, 1, 12],extraCandies = 10) == [True, False, True]\n assert candidate(candies = [50, 50, 50, 50, 50],extraCandies = 50) == [True, True, True, True, True]\n assert candidate(candies = [1, 2, 3, 4, 5],extraCandies = 2) == [False, False, True, True, True]\n assert candidate(candies = [2, 3, 5, 1, 3],extraCandies = 3) == [True, True, True, False, True]\n assert candidate(candies = [1, 2, 3, 4, 5],extraCandies = 0) == [False, False, False, False, True]\n assert candidate(candies = [5, 8, 7],extraCandies = 5) == [True, True, True]\n assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],extraCandies = 10) == [False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25],extraCandies = 25) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [90, 80, 70, 60, 50, 40, 30, 20, 10, 0],extraCandies = 15) == [True, True, False, False, False, False, False, False, False, False]\n assert candidate(candies = [98, 99, 100, 101, 102],extraCandies = 3) == [False, True, True, True, True]\n assert candidate(candies = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],extraCandies = 10) == [False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True]\n assert candidate(candies = [50, 40, 30, 20, 10],extraCandies = 20) == [True, True, True, False, False]\n assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],extraCandies = 5) == [False, False, False, False, True, True, True, True, True, True]\n assert candidate(candies = [5, 5, 5, 5, 5],extraCandies = 5) == [True, True, True, True, True]\n assert candidate(candies = [5, 5, 5, 5, 5],extraCandies = 1) == [True, True, True, True, True]\n assert candidate(candies = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],extraCandies = 50) == [False, True, False, True, False, True, False, True, False, True]\n assert candidate(candies = [10, 20, 30, 40, 50],extraCandies = 20) == [False, False, True, True, True]\n assert candidate(candies = [90, 90, 90, 90, 90, 90, 90, 90, 90, 90],extraCandies = 10) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25],extraCandies = 24) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 100],extraCandies = 50) == [False, False, False, False, False, False, False, False, False, True]\n assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],extraCandies = 1) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],extraCandies = 50) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [50, 50, 50, 50, 50],extraCandies = 10) == [True, True, True, True, True]\n assert candidate(candies = [90, 80, 70, 60, 50, 40, 30, 20, 10],extraCandies = 10) == [True, True, False, False, False, False, False, False, False]\n assert candidate(candies = [100, 1, 99, 2, 98, 3, 97, 4, 96, 5],extraCandies = 50) == [True, False, True, False, True, False, True, False, True, False]\n assert candidate(candies = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],extraCandies = 10) == [False, False, False, False, True, True, True, True, True, True]\n assert candidate(candies = [50, 40, 30, 20, 10, 0],extraCandies = 10) == [True, True, False, False, False, False]\n assert candidate(candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],extraCandies = 40) == [False, False, False, False, False, True, True, True, True, True]\n assert candidate(candies = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25],extraCandies = 25) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [23, 45, 12, 67, 34, 89, 10, 56],extraCandies = 20) == [False, False, False, False, False, True, False, False]\n assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],extraCandies = 1) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],extraCandies = 9) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [1, 1, 1, 1, 1, 1, 1, 1, 1, 100],extraCandies = 99) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],extraCandies = 5) == [True, True, True, True, True, True, False, False, False, False]\n assert candidate(candies = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],extraCandies = 5) == [False, False, False, False, False, False, False, True, True, True]\n assert candidate(candies = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],extraCandies = 25) == [False, False, False, False, True, True, True, True, True, True]\n assert candidate(candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],extraCandies = 50) == [False, False, False, False, True, True, True, True, True, True]\n assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],extraCandies = 5) == [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True]\n assert candidate(candies = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80],extraCandies = 10) == [True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False]\n assert candidate(candies = [10, 20, 30, 40, 50],extraCandies = 15) == [False, False, False, True, True]\n assert candidate(candies = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],extraCandies = 25) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],extraCandies = 255) == [False, False, False, False, False, False, False, False, False, True]\n assert candidate(candies = [90, 80, 70, 60, 50, 40, 30, 20, 10],extraCandies = 15) == [True, True, False, False, False, False, False, False, False]\n assert candidate(candies = [30, 40, 20, 50, 10],extraCandies = 10) == [False, True, False, True, False]\n assert candidate(candies = [1, 50, 25, 75, 35],extraCandies = 25) == [False, True, False, True, False]\n assert candidate(candies = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5],extraCandies = 7) == [True, False, True, False, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],extraCandies = 10) == [True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False]\n assert candidate(candies = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9],extraCandies = 50) == [True, False, False, False, False, False, False, False, False, False]\n assert candidate(candies = [50, 20, 20, 10, 30],extraCandies = 20) == [True, False, False, False, True]\n assert candidate(candies = [10, 20, 30, 40, 50],extraCandies = 25) == [False, False, True, True, True]\n assert candidate(candies = [50, 40, 30, 20, 10],extraCandies = 10) == [True, True, False, False, False]\n assert candidate(candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],extraCandies = 80) == [False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [50, 25, 75, 25, 50, 100, 75, 50, 25, 75],extraCandies = 25) == [False, False, True, False, False, True, True, False, False, True]\n assert candidate(candies = [90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],extraCandies = 9) == [False, True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100],extraCandies = 99) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],extraCandies = 1) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [50, 40, 30, 20, 10],extraCandies = 25) == [True, True, True, False, False]\n assert candidate(candies = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],extraCandies = 25) == [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [50, 10, 20, 30, 40],extraCandies = 20) == [True, False, False, True, True]\n assert candidate(candies = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],extraCandies = 5) == [True, True, True, True, True, True, False, False, False, False]\n assert candidate(candies = [99, 1, 98, 2, 97, 3, 96, 4, 95, 5],extraCandies = 50) == [True, False, True, False, True, False, True, False, True, False]\n assert candidate(candies = [80, 80, 80, 80, 80],extraCandies = 20) == [True, True, True, True, True]\n assert candidate(candies = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9],extraCandies = 90) == [True, False, False, False, False, False, False, False, False, False]\n assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],extraCandies = 4) == [False, False, False, False, False, True, True, True, True, True]\n assert candidate(candies = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8],extraCandies = 0) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [50, 40, 30, 20, 10],extraCandies = 30) == [True, True, True, True, False]\n assert candidate(candies = [100, 100, 100, 100, 100],extraCandies = 50) == [True, True, True, True, True]\n assert candidate(candies = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],extraCandies = 15) == [False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True]\n assert candidate(candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],extraCandies = 10) == [False, False, False, False, False, False, False, False, True, True]\n assert candidate(candies = [3, 3, 3, 3, 3],extraCandies = 3) == [True, True, True, True, True]\n assert candidate(candies = [7, 5, 9, 10, 2],extraCandies = 5) == [True, True, True, True, False]\n assert candidate(candies = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],extraCandies = 10) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],extraCandies = 50) == [False, False, False, False, True, True, True, True, True, True]\n assert candidate(candies = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],extraCandies = 49) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],extraCandies = 45) == [False, False, False, False, False, True, True, True, True, True]\n assert candidate(candies = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],extraCandies = 1) == [True, True, False, False, False, False, False, False, False, False]\n assert candidate(candies = [20, 15, 20, 10, 30],extraCandies = 10) == [True, False, True, False, True]\n assert candidate(candies = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],extraCandies = 10) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candies = [10, 10, 10, 10, 10],extraCandies = 1) == [True, True, True, True, True]\n assert candidate(candies = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],extraCandies = 8) == [False, False, False, False, False, True, True, True, True, True]\n"}, "metadata": {"canonical_parameter_names": ["candies", "extraCandies"], "leetcode_dataset_entry_point": "Solution().kidsWithCandies", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector kidsWithCandies(vector& candies, int extraCandies) {", "container": "Solution", "callable": "kidsWithCandies", "parameters": [{"name": "candies", "type": "vector&"}, {"name": "extraCandies", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1432, "task_id": "max-difference-you-can-get-from-changing-an-integer", "difficulty": "Medium", "problem_description": "You are given an integer num. You will apply the following steps exactly two times:\n\nPick a digit x (0 <= x <= 9).\nPick another digit y (0 <= y <= 9). The digit y can be equal to x.\nReplace all the occurrences of x in the decimal representation of num by y.\nThe new integer cannot have any leading zeros, also the new integer cannot be 0.\n\nLet a and b be the results of applying the operations to num the first and second times, respectively.\nReturn the max difference between a and b.\n \nExample 1:\n\nInput: num = 555\nOutput: 888\nExplanation: The first time pick x = 5 and y = 9 and store the new integer in a.\nThe second time pick x = 5 and y = 1 and store the new integer in b.\nWe have now a = 999 and b = 111 and max difference = 888\n\nExample 2:\n\nInput: num = 9\nOutput: 8\nExplanation: The first time pick x = 9 and y = 9 and store the new integer in a.\nThe second time pick x = 9 and y = 1 and store the new integer in b.\nWe have now a = 9 and b = 1 and max difference = 8\n\n \nConstraints:\n\n1 <= num <= 108\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = 1001100) == 8008800\n assert candidate(num = 9) == 8\n assert candidate(num = 98789) == 81018\n assert candidate(num = 123456) == 820000\n assert candidate(num = 987654321) == 810000000\n assert candidate(num = 1000000) == 8000000\n assert candidate(num = 1221) == 8228\n assert candidate(num = 123456789) == 820000000\n assert candidate(num = 1111111) == 8888888\n assert candidate(num = 987789) == 810018\n assert candidate(num = 1001001) == 8008008\n assert candidate(num = 12321) == 82028\n assert candidate(num = 555) == 888\n assert candidate(num = 9999999) == 8888888\n assert candidate(num = 123321) == 820028\n assert candidate(num = 99100099) == 88800088\n assert candidate(num = 543212345) == 800000008\n assert candidate(num = 599599599) == 800800800\n assert candidate(num = 100000000) == 800000000\n assert candidate(num = 12212212) == 82282282\n assert candidate(num = 8877665544332211) == 8800000000000000\n assert candidate(num = 109080706) == 809000000\n assert candidate(num = 888888888) == 888888888\n assert candidate(num = 890123456) == 800000000\n assert candidate(num = 543210987) == 800000000\n assert candidate(num = 111000111) == 888000888\n assert candidate(num = 98765432109876543210) == 81000000008100000000\n assert candidate(num = 10000000) == 80000000\n assert candidate(num = 90000009) == 89999998\n assert candidate(num = 1234321) == 8200028\n assert candidate(num = 999111111) == 888888888\n assert candidate(num = 110101010) == 880808080\n assert candidate(num = 20202020) == 80808080\n assert candidate(num = 567890123) == 800000000\n assert candidate(num = 5566778899) == 8800000000\n assert candidate(num = 909090909) == 898989898\n assert candidate(num = 44440000) == 88880000\n assert candidate(num = 3330333) == 8880888\n assert candidate(num = 10000001) == 80000008\n assert candidate(num = 111222333) == 888222000\n assert candidate(num = 9876543210) == 8100000000\n assert candidate(num = 9191919) == 8888888\n assert candidate(num = 98709870987) == 81008100810\n assert candidate(num = 334455667788) == 880000000000\n assert candidate(num = 122121) == 822828\n assert candidate(num = 8998) == 8008\n assert candidate(num = 77777777) == 88888888\n assert candidate(num = 88888888) == 88888888\n assert candidate(num = 19000000) == 89000000\n assert candidate(num = 200200200) == 800800800\n assert candidate(num = 1919191) == 8989898\n assert candidate(num = 918273645) == 880000000\n assert candidate(num = 100000001) == 800000008\n assert candidate(num = 11001100) == 88008800\n assert candidate(num = 59595959) == 80808080\n assert candidate(num = 209209209) == 800800800\n assert candidate(num = 1100110011) == 8800880088\n assert candidate(num = 333222111) == 888000000\n assert candidate(num = 999000) == 888999\n assert candidate(num = 90000000) == 89999999\n assert candidate(num = 1098765432) == 8090000000\n assert candidate(num = 101010101) == 808080808\n assert candidate(num = 57575757) == 80808080\n assert candidate(num = 123123123) == 820820820\n assert candidate(num = 777770777) == 888880888\n assert candidate(num = 123212321) == 820282028\n assert candidate(num = 90009) == 89998\n assert candidate(num = 1122334455) == 8822000000\n assert candidate(num = 100100100) == 800800800\n assert candidate(num = 99999999) == 88888888\n assert candidate(num = 100000) == 800000\n assert candidate(num = 109090909) == 809090909\n assert candidate(num = 999999999) == 888888888\n assert candidate(num = 1000100) == 8000800\n assert candidate(num = 19191919) == 89898989\n assert candidate(num = 202020202) == 808080808\n assert candidate(num = 1000001) == 8000008\n assert candidate(num = 44444444) == 88888888\n assert candidate(num = 8880888) == 8880888\n assert candidate(num = 191919191) == 898989898\n assert candidate(num = 1230123) == 8200820\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().maxDiff", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxDiff(int num) {", "container": "Solution", "callable": "maxDiff", "parameters": [{"name": "num", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1433, "task_id": "check-if-a-string-can-break-another-string", "difficulty": "Medium", "problem_description": "Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa. In other words s2 can break s1 or vice-versa.\nA string x can break string y (both of size n) if x[i] >= y[i] (in alphabetical order) for all i between 0 and n-1.\n \nExample 1:\n\nInput: s1 = \"abc\", s2 = \"xya\"\nOutput: true\nExplanation: \"ayx\" is a permutation of s2=\"xya\" which can break to string \"abc\" which is a permutation of s1=\"abc\".\n\nExample 2:\n\nInput: s1 = \"abe\", s2 = \"acd\"\nOutput: false \nExplanation: All permutations for s1=\"abe\" are: \"abe\", \"aeb\", \"bae\", \"bea\", \"eab\" and \"eba\" and all permutation for s2=\"acd\" are: \"acd\", \"adc\", \"cad\", \"cda\", \"dac\" and \"dca\". However, there is not any permutation from s1 which can break some permutation from s2 and vice-versa.\n\nExample 3:\n\nInput: s1 = \"leetcodee\", s2 = \"interview\"\nOutput: true\n\n \nConstraints:\n\ns1.length == n\ns2.length == n\n1 <= n <= 10^5\nAll strings consist of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s1 = \"same\",s2 = \"same\") == True\n assert candidate(s1 = \"abc\",s2 = \"bca\") == True\n assert candidate(s1 = \"hello\",s2 = \"bello\") == True\n assert candidate(s1 = \"aazz\",s2 = \"zzaa\") == True\n assert candidate(s1 = \"abac\",s2 = \"baca\") == True\n assert candidate(s1 = \"xyz\",s2 = \"wvu\") == True\n assert candidate(s1 = \"abc\",s2 = \"xya\") == True\n assert candidate(s1 = \"aabbcc\",s2 = \"abcabc\") == True\n assert candidate(s1 = \"pqrs\",s2 = \"rstu\") == True\n assert candidate(s1 = \"zyx\",s2 = \"wvu\") == True\n assert candidate(s1 = \"abcd\",s2 = \"adcb\") == True\n assert candidate(s1 = \"aaa\",s2 = \"bbb\") == True\n assert candidate(s1 = \"abcd\",s2 = \"dcba\") == True\n assert candidate(s1 = \"abe\",s2 = \"acd\") == False\n assert candidate(s1 = \"leetcodee\",s2 = \"interview\") == True\n assert candidate(s1 = \"python\",s2 = \"typhon\") == True\n assert candidate(s1 = \"abcdxyz\",s2 = \"zyxwvut\") == True\n assert candidate(s1 = \"zzzz\",s2 = \"zzzz\") == True\n assert candidate(s1 = \"xyz\",s2 = \"zyx\") == True\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"zzyyxxwwvvuuttrrssqqpponnmlkkjjiihhggeeffddaabbcc\") == True\n assert candidate(s1 = \"abcdefghijklmnopqrstuvwxyz\",s2 = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(s1 = \"algorithm\",s2 = \"logarithm\") == True\n assert candidate(s1 = \"longerstringwithvariouscharacters\",s2 = \"variouscharacterswithlongerstring\") == True\n assert candidate(s1 = \"zzzzzz\",s2 = \"aaaaaa\") == True\n assert candidate(s1 = \"unbreakable\",s2 = \"rebreakable\") == True\n assert candidate(s1 = \"abcdabcdabcd\",s2 = \"ddddcccbbbbaaa\") == True\n assert candidate(s1 = \"aabbcc\",s2 = \"ccbbaa\") == True\n assert candidate(s1 = \"mississippi\",s2 = \"pippiimissi\") == True\n assert candidate(s1 = \"almostsame\",s2 = \"almostsane\") == True\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"zzzzyyxwwvvuutssrrqqponnmmllkkjjiihhggeeffdccbaaab\") == False\n assert candidate(s1 = \"racecar\",s2 = \"carrace\") == True\n assert candidate(s1 = \"thisisaverylongstringthatneedstobecomparesothattwostingsareofthesamelength\",s2 = \"somuchlongeranddifferentsomenecessarypaddingletterssotheyareofthesame\") == False\n assert candidate(s1 = \"abacabadabacaba\",s2 = \"zyzxzyzyzxzyzyz\") == True\n assert candidate(s1 = \"abracadabra\",s2 = \"cadabrabara\") == True\n assert candidate(s1 = \"zyxwvutsrqponmlkjihgfedcba\",s2 = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(s1 = \"abcdefghijk\",s2 = \"fghijklmno\") == True\n assert candidate(s1 = \"abracadabra\",s2 = \"alakazamazam\") == False\n assert candidate(s1 = \"randomstringhere\",s2 = \"somestringrandom\") == True\n assert candidate(s1 = \"uniquechars\",s2 = \"distinctset\") == False\n assert candidate(s1 = \"aazzzzzzzzzzzzzzzz\",s2 = \"zzzzzzzzzzzzzzaa\") == True\n assert candidate(s1 = \"zzzzzzzz\",s2 = \"zzzzzzzz\") == True\n assert candidate(s1 = \"aabbbccc\",s2 = \"bbbcccaaa\") == True\n assert candidate(s1 = \"zzzzzzzzzz\",s2 = \"zzzzzzzzzz\") == True\n assert candidate(s1 = \"complex\",s2 = \"lexicom\") == True\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"zzyyxxwwvvuuttssrrqqppoonnmlkkjjiihhggffeeddccbbaa\") == True\n assert candidate(s1 = \"abcdxyzabcdxyz\",s2 = \"xyzabcdxyzabcd\") == True\n assert candidate(s1 = \"abcdefgh\",s2 = \"hgfedcba\") == True\n assert candidate(s1 = \"pppppppppp\",s2 = \"qqqqqqqqqq\") == True\n assert candidate(s1 = \"abcdefghij\",s2 = \"fedcbaghij\") == True\n assert candidate(s1 = \"aaaaabbbbcccccddeeefffffgggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxxxyyyyyzzzzz\",s2 = \"zzzzzyyyyyxxxwwwvvvuuutttsssrqqppoonnmlkkkjjjiiihgggfffffeeedddccccbbbaaaa\") == True\n assert candidate(s1 = \"programming\",s2 = \"gnimmargorp\") == True\n assert candidate(s1 = \"permutation\",s2 = \"reupmttinao\") == True\n assert candidate(s1 = \"mississippi\",s2 = \"pppnnnnmsssssiiii\") == True\n assert candidate(s1 = \"aabbccddeeffgghhii\",s2 = \"iihhggeeffddccbbaa\") == True\n assert candidate(s1 = \"abcdefghijk\",s2 = \"jihgfedcbaa\") == True\n assert candidate(s1 = \"xyzzzz\",s2 = \"zzzzxy\") == True\n assert candidate(s1 = \"medium\",s2 = \"median\") == True\n assert candidate(s1 = \"mnopqr\",s2 = \"qrstuv\") == True\n assert candidate(s1 = \"xyzyzyzyzyzyzyzyz\",s2 = \"zyxzyxzyxzyxzyxzy\") == True\n assert candidate(s1 = \"abcdefghijklnopqrstuvwxyz\",s2 = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(s1 = \"aaaabbbbccccdddd\",s2 = \"ddddccccbbbbaaaa\") == True\n assert candidate(s1 = \"thisisalongstring\",s2 = \"stringlongthisisalo\") == True\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"abcdefghijklmnopqrstuvwxyzzzyxwvutsrqponmlkjihgfedcbaaabb\") == True\n assert candidate(s1 = \"algorithm\",s2 = \"thmalogri\") == True\n assert candidate(s1 = \"xyzz\",s2 = \"yyzz\") == True\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"zzzzyyxwwvvuttsrrqqponnmlkkjjiihhggffeeeeddccbbaa\") == False\n assert candidate(s1 = \"aabbcc\",s2 = \"bbccaa\") == True\n assert candidate(s1 = \"aaaaabbbbbcccccc\",s2 = \"bbbbbaaaaacccccb\") == True\n assert candidate(s1 = \"abcdefghijklmnop\",s2 = \"ponmlkjihgfedcba\") == True\n assert candidate(s1 = \"mississippi\",s2 = \"ppssiiimmm\") == False\n assert candidate(s1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",s2 = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == True\n assert candidate(s1 = \"abacabadabacaba\",s2 = \"zxyzyxzyxzyxzyxzyx\") == True\n assert candidate(s1 = \"abcdef\",s2 = \"ghijkl\") == True\n assert candidate(s1 = \"aabbbcccddddeeeeffffgggghhhhiiiiiijjjjjjkkkkkkllllllmmmmmmmnnnnnnnooooooooppppppppqqqqqqqqrrrrrrrrssssssssstttttttttuuuuuuuuuvvvvvvvvvwwwwwwwwwxxxxxxxxxyyyyyyyyyzzzzzzzzz\",s2 = \"zzzzzzzzzyyyyyyyyyxxxxxxxxxwwwwwwwwwvvvvvvvvvuuuuuuuuutttttttttssssssssrrrrrrrrqqqqqqqqppppppppooooooonnnnnnnmmmmmmmllllllkkkkkkjjjjjjiiiiiiggggffffeeeeeeeeeddddddccccbbbaaa\") == True\n assert candidate(s1 = \"aaaabbbbcccc\",s2 = \"ccccbbbbaaaa\") == True\n assert candidate(s1 = \"aabcc\",s2 = \"bbdda\") == True\n assert candidate(s1 = \"congratulations\",s2 = \"stucgnioalort\") == True\n assert candidate(s1 = \"abcdabcdabcd\",s2 = \"dcbaabcddcba\") == True\n assert candidate(s1 = \"permutation\",s2 = \"nutationspr\") == True\n assert candidate(s1 = \"abcdefghijklmnopqrstuvwxyzz\",s2 = \"zzzzzyzyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(s1 = \"aaaaaaab\",s2 = \"baaaaaaa\") == True\n assert candidate(s1 = \"equalstring\",s2 = \"equalstring\") == True\n assert candidate(s1 = \"abcdefghijk\",s2 = \"zyxwvutsrqz\") == True\n assert candidate(s1 = \"aaaaaa\",s2 = \"bbbbbb\") == True\n assert candidate(s1 = \"abcdabcd\",s2 = \"dcbaabcd\") == True\n assert candidate(s1 = \"abcdefghij\",s2 = \"jihgfedcba\") == True\n assert candidate(s1 = \"abcdabcdabcdabcdabcd\",s2 = \"dcbaabdcbaabdcbaabdcba\") == True\n assert candidate(s1 = \"optimization\",s2 = \"nttimzpiaoos\") == True\n assert candidate(s1 = \"optimization\",s2 = \"izationoptim\") == True\n assert candidate(s1 = \"abcdefghij\",s2 = \"abcdefghij\") == True\n assert candidate(s1 = \"leetcodeleetcode\",s2 = \"interviewinterview\") == True\n assert candidate(s1 = \"qwertypoiuytrewq\",s2 = \"mnbvcxzlkjhgfd\") == False\n assert candidate(s1 = \"abacabadabacaba\",s2 = \"zyxzyxzyxzyxzyx\") == True\n assert candidate(s1 = \"mississippi\",s2 = \"pississippi\") == True\n assert candidate(s1 = \"aaaaaaaaaabbbbbbbbbbcccccccccc\",s2 = \"ccccccccccbbbbbbbbbbaaaaaaaaaa\") == True\n assert candidate(s1 = \"longerstringexample\",s2 = \"examplelongerstring\") == True\n assert candidate(s1 = \"abacabacabacabac\",s2 = \"zyxzyxzyxzyxzyxzyx\") == True\n assert candidate(s1 = \"abcabcabc\",s2 = \"xyzxyzxyz\") == True\n assert candidate(s1 = \"pqrstuvw\",s2 = \"qrstuvwp\") == True\n assert candidate(s1 = \"abcdef\",s2 = \"fedcba\") == True\n assert candidate(s1 = \"pqrsrpqrsrpqrsr\",s2 = \"zyxwzyxwzyxwzyx\") == True\n assert candidate(s1 = \"abcde\",s2 = \"edcba\") == True\n assert candidate(s1 = \"abcdefghijklnmopqrstuvwxyz\",s2 = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(s1 = \"abcdefghijabcdefghijabcdefghij\",s2 = \"zyxwvutsrqzyxwvutsrqzyxwvutsrq\") == True\n assert candidate(s1 = \"interview\",s2 = \"terviewin\") == True\n assert candidate(s1 = \"mnopqr\",s2 = \"rstuvw\") == True\n assert candidate(s1 = \"abacabadabacaba\",s2 = \"zzzzzzzzzzzzzzz\") == True\n assert candidate(s1 = \"break\",s2 = \"maker\") == True\n assert candidate(s1 = \"qrstuv\",s2 = \"vwxyza\") == False\n assert candidate(s1 = \"permutation\",s2 = \"interwoven\") == True\n assert candidate(s1 = \"abcdxyz\",s2 = \"zyxcbaa\") == True\n assert candidate(s1 = \"zzzzz\",s2 = \"aaaaa\") == True\n assert candidate(s1 = \"aabbbccc\",s2 = \"cccbbbaa\") == True\n assert candidate(s1 = \"abcdefg\",s2 = \"ghijklm\") == True\n assert candidate(s1 = \"leetcode\",s2 = \"docodele\") == True\n assert candidate(s1 = \"xyzz\",s2 = \"wxyz\") == True\n assert candidate(s1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",s2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(s1 = \"zzzzzzzzzzzzzzzzzz\",s2 = \"aaaaaaaaaaaaaaaaaa\") == True\n assert candidate(s1 = \"banana\",s2 = \"anabna\") == True\n assert candidate(s1 = \"mississippi\",s2 = \"ppissimiss\") == True\n"}, "metadata": {"canonical_parameter_names": ["s1", "s2"], "leetcode_dataset_entry_point": "Solution().checkIfCanBreak", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool checkIfCanBreak(string s1, string s2) {", "container": "Solution", "callable": "checkIfCanBreak", "parameters": [{"name": "s1", "type": "string"}, {"name": "s2", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1434, "task_id": "number-of-ways-to-wear-different-hats-to-each-other", "difficulty": "Hard", "problem_description": "There are n people and 40 types of hats labeled from 1 to 40.\nGiven a 2D integer array hats, where hats[i] is a list of all hats preferred by the ith person.\nReturn the number of ways that n people can wear different hats from each other.\nSince the answer may be too large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: hats = [[3,4],[4,5],[5]]\nOutput: 1\nExplanation: There is only one way to choose hats given the conditions. \nFirst person choose hat 3, Second person choose hat 4 and last one hat 5.\n\nExample 2:\n\nInput: hats = [[3,5,1],[3,5]]\nOutput: 4\nExplanation: There are 4 ways to choose hats:\n(3,5), (5,3), (1,3) and (1,5)\n\nExample 3:\n\nInput: hats = [[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]]\nOutput: 24\nExplanation: Each person can choose hats labeled from 1 to 4.\nNumber of Permutations of (1,2,3,4) = 24.\n\n \nConstraints:\n\nn == hats.length\n1 <= n <= 10\n1 <= hats[i].length <= 40\n1 <= hats[i][j] <= 40\nhats[i] contains a list of unique integers.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(hats = [[1, 2], [3, 4], [5, 6]]) == 8\n assert candidate(hats = [[10, 20, 30], [20, 30, 40], [30, 40, 50], [40, 50, 60]]) == 26\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 40\n assert candidate(hats = [[1, 2], [3, 4], [5, 6], [7, 8]]) == 16\n assert candidate(hats = [[10, 20, 30], [20, 30, 40], [30, 40, 50]]) == 14\n assert candidate(hats = [[1], [1, 2], [1, 2, 3], [1, 2, 3, 4]]) == 1\n assert candidate(hats = [[1, 2], [2, 3], [3, 4]]) == 4\n assert candidate(hats = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10]]) == 25\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == 100\n assert candidate(hats = [[1], [2], [3], [4], [5]]) == 1\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 90\n assert candidate(hats = [[1], [1], [1], [1], [1], [1], [1], [1], [1], [1]]) == 0\n assert candidate(hats = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]]) == 26\n assert candidate(hats = [[3], [5], [1], [2]]) == 1\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 90\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 10000\n assert candidate(hats = [[3, 5, 1], [3, 5]]) == 4\n assert candidate(hats = [[3, 4], [4, 5], [5]]) == 1\n assert candidate(hats = [[1, 2, 3], [2, 3, 4], [3, 4, 5]]) == 14\n assert candidate(hats = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29]]) == 625\n assert candidate(hats = [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]]) == 24\n assert candidate(hats = [[1, 4, 7, 10, 13], [2, 5, 8, 11, 14], [3, 6, 9, 12, 15], [1, 5, 9, 13, 17], [2, 6, 10, 14, 18], [3, 7, 11, 15, 19], [4, 8, 12, 16, 20]]) == 38130\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 2250\n assert candidate(hats = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]]) == 7600\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 90000\n assert candidate(hats = [[3, 4, 5], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]]) == 20\n assert candidate(hats = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 1024\n assert candidate(hats = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9], [6, 7, 8, 9, 10]]) == 2108\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 10000\n assert candidate(hats = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]) == 0\n assert candidate(hats = [[3, 4, 5, 6, 7, 8, 9, 10], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == 9580\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 40\n assert candidate(hats = [[3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == 28196\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 2193360\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 30240\n assert candidate(hats = [[1, 5, 9, 13, 17, 21, 25, 29, 33, 37], [2, 6, 10, 14, 18, 22, 26, 30, 34, 38], [3, 7, 11, 15, 19, 23, 27, 31, 35, 39], [4, 8, 12, 16, 20, 24, 28, 32, 36, 40]]) == 10000\n assert candidate(hats = [[1], [2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35, 36], [37, 38, 39, 40, 1, 2, 3, 4], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]) == 1712256\n assert candidate(hats = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]) == 0\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 720\n assert candidate(hats = [[3, 5, 10], [3, 7, 11], [5, 9, 12], [8, 11, 15], [10, 13, 17]]) == 141\n assert candidate(hats = [[3, 4, 5, 6], [1, 2, 3, 4], [2, 3, 4, 5, 6, 7, 8], [4, 5, 6, 7, 8, 9]]) == 315\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]]) == 11400\n assert candidate(hats = [[1, 40], [2, 39], [3, 38], [4, 37], [5, 36], [6, 35], [7, 34], [8, 33], [9, 32], [10, 31], [11, 30], [12, 29], [13, 28], [14, 27], [15, 26], [16, 25], [17, 24], [18, 23], [19, 22], [20, 21]]) == 1048576\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]]) == 900\n assert candidate(hats = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [12, 14, 16, 18, 20], [21, 23, 25, 27, 29]]) == 3125\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 144400\n assert candidate(hats = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20]]) == 1\n assert candidate(hats = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 11], [10, 11, 12]]) == 596\n assert candidate(hats = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == 243\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 400\n assert candidate(hats = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [1, 6, 11, 16, 21], [2, 7, 12, 17, 22], [3, 8, 13, 18, 23], [4, 9, 14, 19, 24], [5, 10, 15, 20, 25]]) == 473100\n assert candidate(hats = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9], [9, 10, 1], [1, 3, 5], [5, 7, 9], [9, 11, 13], [13, 15, 17], [17, 19, 21]]) == 2723\n assert candidate(hats = [[1], [1, 2], [1, 2, 3], [1, 2, 3, 4], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 1\n assert candidate(hats = [[1, 10, 19, 28, 37], [2, 11, 20, 29, 38], [3, 12, 21, 30, 39], [4, 13, 22, 31, 40], [5, 14, 23, 32], [6, 15, 24, 33], [7, 16, 25, 34], [8, 17, 26, 35], [9, 18, 27, 36]]) == 640000\n assert candidate(hats = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]) == 120\n assert candidate(hats = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) == 1\n assert candidate(hats = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30], [31, 32, 33, 34, 35], [36, 37, 38, 39, 40]]) == 390625\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]]) == 1000\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 300\n assert candidate(hats = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 4, 7, 10], [2, 5, 8], [3, 6, 9]]) == 416\n assert candidate(hats = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21], [22, 23, 24], [25, 26, 27], [28, 29, 30]]) == 59049\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 3628800\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]]) == 308055528\n assert candidate(hats = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]) == 738\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 1560\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 720\n assert candidate(hats = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 3125\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 30240\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == 880\n assert candidate(hats = [[3, 5, 1], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21], [21, 23], [23, 25], [25, 27], [27, 29], [29, 31], [31, 33], [33, 35], [35, 37], [37, 39], [39, 40]]) == 22\n assert candidate(hats = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]]) == 400\n assert candidate(hats = [[10, 20, 30, 40], [11, 21, 31, 41], [12, 22, 32, 42], [13, 23, 33, 43], [14, 24, 34, 44], [15, 25, 35, 45], [16, 26, 36, 46], [17, 27, 37, 47], [18, 28, 38, 48], [19, 29, 39, 49]]) == 1048576\n assert candidate(hats = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]]) == 400\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]) == 40688\n assert candidate(hats = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21], [22, 23, 24], [25, 26, 27], [28, 29, 30], [31, 32, 33], [34, 35, 36], [37, 38, 39], [40]]) == 1594323\n assert candidate(hats = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10]]) == 221\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13]]) == 5766\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 400\n assert candidate(hats = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == 7600\n assert candidate(hats = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30], [31, 32, 33, 34, 35], [36, 37, 38, 39, 40]]) == 390625\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 5040\n assert candidate(hats = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == 1560\n assert candidate(hats = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 11], [10, 11, 12]]) == 596\n"}, "metadata": {"canonical_parameter_names": ["hats"], "leetcode_dataset_entry_point": "Solution().numberWays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numberWays(vector>& hats) {", "container": "Solution", "callable": "numberWays", "parameters": [{"name": "hats", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1436, "task_id": "destination-city", "difficulty": "Easy", "problem_description": "You are given the array paths, where paths[i] = [cityAi, cityBi] means there exists a direct path going from cityAi to cityBi. Return the destination city, that is, the city without any path outgoing to another city.\nIt is guaranteed that the graph of paths forms a line without any loop, therefore, there will be exactly one destination city.\n \nExample 1:\n\nInput: paths = [[\"London\",\"New York\"],[\"New York\",\"Lima\"],[\"Lima\",\"Sao Paulo\"]]\nOutput: \"Sao Paulo\" \nExplanation: Starting at \"London\" city you will reach \"Sao Paulo\" city which is the destination city. Your trip consist of: \"London\" -> \"New York\" -> \"Lima\" -> \"Sao Paulo\".\n\nExample 2:\n\nInput: paths = [[\"B\",\"C\"],[\"D\",\"B\"],[\"C\",\"A\"]]\nOutput: \"A\"\nExplanation: All possible trips are: \n\"D\" -> \"B\" -> \"C\" -> \"A\". \n\"B\" -> \"C\" -> \"A\". \n\"C\" -> \"A\". \n\"A\". \nClearly the destination city is \"A\".\n\nExample 3:\n\nInput: paths = [[\"A\",\"Z\"]]\nOutput: \"Z\"\n\n \nConstraints:\n\n1 <= paths.length <= 100\npaths[i].length == 2\n1 <= cityAi.length, cityBi.length <= 10\ncityAi != cityBi\nAll strings consist of lowercase and uppercase English letters and the space character.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(paths = [['X', 'Y'], ['Y', 'Z'], ['Z', 'W']]) == \"W\"\n assert candidate(paths = [['Chicago', 'Los Angeles'], ['New York', 'Chicago']]) == \"Los Angeles\"\n assert candidate(paths = [['Chicago', 'Los Angeles'], ['Los Angeles', 'Las Vegas']]) == \"Las Vegas\"\n assert candidate(paths = [['Paris', 'Berlin'], ['Berlin', 'Madrid'], ['Madrid', 'Rome']]) == \"Rome\"\n assert candidate(paths = [['B', 'C'], ['D', 'B'], ['C', 'A']]) == \"A\"\n assert candidate(paths = [['Paris', 'Berlin'], ['Berlin', 'Madrid']]) == \"Madrid\"\n assert candidate(paths = [['A', 'Z']]) == \"Z\"\n assert candidate(paths = [['Chicago', 'Los Angeles'], ['Miami', 'Chicago'], ['Los Angeles', 'New York']]) == \"New York\"\n assert candidate(paths = [['London', 'New York'], ['New York', 'Lima'], ['Lima', 'Sao Paulo']]) == \"Sao Paulo\"\n assert candidate(paths = [['Boston', 'New York'], ['New York', 'Philadelphia'], ['Philadelphia', 'Washington'], ['Washington', 'Baltimore'], ['Baltimore', 'Annapolis']]) == \"Annapolis\"\n assert candidate(paths = [['Alpha', 'Beta'], ['Beta', 'Gamma'], ['Gamma', 'Delta'], ['Delta', 'Epsilon'], ['Epsilon', 'Zeta'], ['Zeta', 'Eta']]) == \"Eta\"\n assert candidate(paths = [['Newark', 'Boston'], ['Boston', 'Philadelphia'], ['Philadelphia', 'New York'], ['New York', 'Washington DC'], ['Washington DC', 'Miami'], ['Miami', 'Orlando'], ['Orlando', 'Jacksonville'], ['Jacksonville', 'Atlanta']]) == \"Atlanta\"\n assert candidate(paths = [['A', 'B'], ['B', 'C'], ['C', 'D'], ['D', 'E'], ['E', 'F'], ['F', 'G'], ['G', 'H'], ['H', 'I'], ['I', 'J'], ['J', 'K']]) == \"K\"\n assert candidate(paths = [['Berlin', 'Hamburg'], ['Hamburg', 'Copenhagen'], ['Copenhagen', 'Stockholm'], ['Stockholm', 'Oslo'], ['Oslo', 'Trondheim']]) == \"Trondheim\"\n assert candidate(paths = [['New York', 'Boston'], ['Boston', 'Chicago'], ['Chicago', 'Denver'], ['Denver', 'Seattle'], ['Seattle', 'San Francisco'], ['San Francisco', 'Los Angeles']]) == \"Los Angeles\"\n assert candidate(paths = [['San Francisco', 'Los Angeles'], ['Los Angeles', 'San Diego'], ['San Diego', 'Phoenix'], ['Phoenix', 'Las Vegas']]) == \"Las Vegas\"\n assert candidate(paths = [['Alpha', 'Beta'], ['Gamma', 'Delta'], ['Delta', 'Epsilon'], ['Epsilon', 'Zeta'], ['Zeta', 'Eta'], ['Eta', 'Theta']]) == \"Beta\"\n assert candidate(paths = [['Mars', 'Venus'], ['Venus', 'Earth'], ['Earth', 'Mars2'], ['Mars2', 'Jupiter'], ['Jupiter', 'Saturn'], ['Saturn', 'Uranus'], ['Uranus', 'Neptune']]) == \"Neptune\"\n assert candidate(paths = [['Berlin', 'Hamburg'], ['Hamburg', 'Munich'], ['Munich', 'Stuttgart'], ['Stuttgart', 'Frankfurt'], ['Frankfurt', 'Düsseldorf'], ['Düsseldorf', 'Cologne'], ['Cologne', 'Dortmund'], ['Dortmund', 'Wuppertal']]) == \"Wuppertal\"\n assert candidate(paths = [['Vienna', 'Bratislava'], ['Bratislava', 'Budapest'], ['Budapest', 'Belgrade'], ['Belgrade', 'Sofia'], ['Sofia', 'Athens'], ['Athens', 'Thessaloniki'], ['Thessaloniki', 'Skopje'], ['Skopje', 'Zagreb'], ['Zagreb', 'Ljubljana'], ['Ljubljana', 'Maribor']]) == \"Maribor\"\n assert candidate(paths = [['Delhi', 'Agra'], ['Agra', 'Jaipur'], ['Jaipur', 'Jodhpur'], ['Jodhpur', 'Jaisalmer'], ['Jaisalmer', 'Bikaner'], ['Bikaner', 'Ajmer'], ['Ajmer', 'Udaipur'], ['Udaipur', 'Rajkot'], ['Rajkot', 'Surat']]) == \"Surat\"\n assert candidate(paths = [['Beijing', 'Tokyo'], ['Tokyo', 'Seoul'], ['Seoul', 'Osaka'], ['Osaka', 'Fukuoka'], ['Fukuoka', 'Nagoya'], ['Nagoya', 'Kyoto'], ['Kyoto', 'Sapporo']]) == \"Sapporo\"\n assert candidate(paths = [['X', 'Y'], ['Y', 'Z'], ['Z', 'W'], ['W', 'V'], ['V', 'U'], ['U', 'T'], ['T', 'S'], ['S', 'R'], ['R', 'Q']]) == \"Q\"\n assert candidate(paths = [['Atlanta', 'Charlotte'], ['Charlotte', 'Miami'], ['Miami', 'Tampa'], ['Tampa', 'Orlando'], ['Orlando', 'Fort Lauderdale'], ['Fort Lauderdale', 'Key West']]) == \"Key West\"\n assert candidate(paths = [['San Francisco', 'Los Angeles'], ['Los Angeles', 'Las Vegas'], ['Las Vegas', 'Seattle'], ['Seattle', 'Portland']]) == \"Portland\"\n assert candidate(paths = [['San Francisco', 'Seattle'], ['Seattle', 'Denver'], ['Denver', 'Austin'], ['Austin', 'Houston']]) == \"Houston\"\n assert candidate(paths = [['Casablanca', 'Tangier'], ['Tangier', 'Fes'], ['Fes', 'Meknes'], ['Meknes', 'Fez'], ['Fez', 'Rabat'], ['Rabat', 'Agadir'], ['Agadir', 'Essaouira'], ['Essaouira', 'Marrakesh']]) == \"Marrakesh\"\n assert candidate(paths = [['Chicago', 'Milwaukee'], ['Milwaukee', 'Des Moines'], ['Des Moines', 'Omaha'], ['Omaha', 'Denver'], ['Denver', 'Albuquerque'], ['Albuquerque', 'El Paso'], ['El Paso', 'Las Vegas'], ['Las Vegas', 'Los Angeles']]) == \"Los Angeles\"\n assert candidate(paths = [['Toronto', 'Ottawa'], ['Ottawa', 'Montreal'], ['Montreal', 'Quebec'], ['Quebec', 'Halifax'], ['Halifax', \"St. John's\"], [\"St. John's\", 'Gander']]) == \"Gander\"\n assert candidate(paths = [['Rome', 'Florence'], ['Florence', 'Venice'], ['Venice', 'Milan'], ['Milan', 'Turin'], ['Turin', 'Genoa'], ['Genoa', 'Pisa'], ['Pisa', 'Lyon']]) == \"Lyon\"\n assert candidate(paths = [['Miami', 'Los Angeles'], ['Los Angeles', 'Seattle'], ['Seattle', 'Portland'], ['Portland', 'Vancouver'], ['Vancouver', 'Calgary'], ['Calgary', 'Edmonton'], ['Edmonton', 'Winnipeg']]) == \"Winnipeg\"\n assert candidate(paths = [['Paris', 'Lyon'], ['Lyon', 'Lyon'], ['Lyon', 'Marseille'], ['Marseille', 'Toulouse'], ['Toulouse', 'Nice']]) == \"Nice\"\n assert candidate(paths = [['Sydney', 'Melbourne'], ['Melbourne', 'Brisbane'], ['Brisbane', 'Adelaide'], ['Adelaide', 'Perth'], ['Perth', 'Alice Springs'], ['Alice Springs', 'Cairns']]) == \"Cairns\"\n assert candidate(paths = [['Berlin', 'Hamburg'], ['Hamburg', 'Munich'], ['Munich', 'Frankfurt'], ['Frankfurt', 'Stuttgart'], ['Stuttgart', 'Dortmund'], ['Dortmund', 'Cologne']]) == \"Cologne\"\n assert candidate(paths = [['First', 'Second'], ['Second', 'Third'], ['Third', 'Fourth'], ['Fourth', 'Fifth'], ['Fifth', 'Sixth'], ['Sixth', 'Seventh'], ['Seventh', 'Eighth'], ['Eighth', 'Ninth'], ['Ninth', 'Tenth'], ['Tenth', 'Eleventh'], ['Eleventh', 'Twelfth'], ['Twelfth', 'Thirteenth'], ['Thirteenth', 'Fourteenth'], ['Fourteenth', 'Fifteenth'], ['Fifteenth', 'Sixteenth'], ['Sixteenth', 'Seventeenth'], ['Seventeenth', 'Eighteenth'], ['Eighteenth', 'Nineteenth'], ['Nineteenth', 'Twentieth'], ['Twentieth', 'TwentyFirst'], ['TwentyFirst', 'TwentySecond'], ['TwentySecond', 'TwentyThird'], ['TwentyThird', 'TwentyFourth'], ['TwentyFourth', 'TwentyFifth']]) == \"TwentyFifth\"\n assert candidate(paths = [['New York', 'Chicago'], ['Chicago', 'Denver'], ['Denver', 'Phoenix'], ['Phoenix', 'Los Angeles'], ['Los Angeles', 'San Francisco']]) == \"San Francisco\"\n assert candidate(paths = [['Oslo', 'Stockholm'], ['Stockholm', 'Helsinki'], ['Helsinki', 'Riga'], ['Riga', 'Vilnius'], ['Vilnius', 'Warsaw'], ['Warsaw', 'Krakow'], ['Krakow', 'Berlin'], ['Berlin', 'Hamburg']]) == \"Hamburg\"\n assert candidate(paths = [['Istanbul', 'Ankara'], ['Ankara', 'Eskisehir'], ['Eskisehir', 'Konya'], ['Konya', 'Gaziantep'], ['Gaziantep', 'Sanliurfa'], ['Sanliurfa', 'Mardin'], ['Mardin', 'Diyarbakir'], ['Diyarbakir', 'Siirt'], ['Siirt', 'Elazig'], ['Elazig', 'Malatya']]) == \"Malatya\"\n assert candidate(paths = [['Vienna', 'Innsbruck'], ['Innsbruck', 'Graz'], ['Graz', 'Linz'], ['Linz', 'Salzburg'], ['Salzburg', 'Wien'], ['Wien', 'Graz'], ['Graz', 'Ljubljana'], ['Ljubljana', 'Zagreb'], ['Zagreb', 'Belgrade'], ['Belgrade', 'Sofia'], ['Sofia', 'Bucharest'], ['Bucharest', 'Bucuresti']]) == \"Bucuresti\"\n assert candidate(paths = [['Vancouver', 'Calgary'], ['Calgary', 'Edmonton'], ['Edmonton', 'Winnipeg'], ['Winnipeg', 'Thunder Bay'], ['Thunder Bay', 'Toronto'], ['Toronto', 'Ottawa'], ['Ottawa', 'Quebec City'], ['Quebec City', 'Montreal']]) == \"Montreal\"\n assert candidate(paths = [['Tokyo', 'Osaka'], ['Osaka', 'Kyoto'], ['Kyoto', 'Nagoya'], ['Nagoya', 'Fukuoka'], ['Fukuoka', 'Sapporo']]) == \"Sapporo\"\n assert candidate(paths = [['New York', 'Boston'], ['Boston', 'Chicago'], ['Chicago', 'Houston'], ['Houston', 'Miami'], ['Miami', 'Orlando']]) == \"Orlando\"\n assert candidate(paths = [['Lagos', 'Kano'], ['Kano', 'Ilorin'], ['Ilorin', 'Ibadan'], ['Ibadan', 'Osogbo'], ['Osogbo', 'Akure'], ['Akure', 'Ondo'], ['Ondo', 'Port Harcourt'], ['Port Harcourt', 'Calabar'], ['Calabar', 'Cross River']]) == \"Cross River\"\n assert candidate(paths = [['Miami', 'Orlando'], ['Orlando', 'Atlanta'], ['Atlanta', 'Chicago'], ['Chicago', 'Denver'], ['Denver', 'Las Vegas'], ['Las Vegas', 'Seattle']]) == \"Seattle\"\n assert candidate(paths = [['Hyderabad', 'Bangalore'], ['Bangalore', 'Mysuru'], ['Mysuru', 'Mangalore'], ['Mangalore', 'Udupi'], ['Udupi', 'Karwar']]) == \"Karwar\"\n assert candidate(paths = [['Mumbai', 'Delhi'], ['Delhi', 'Chennai'], ['Chennai', 'Bangalore'], ['Bangalore', 'Hyderabad'], ['Hyderabad', 'Ahmedabad'], ['Ahmedabad', 'Kolkata']]) == \"Kolkata\"\n assert candidate(paths = [['Vienna', 'Salzburg'], ['Salzburg', 'Innsbruck'], ['Innsbruck', 'Linz'], ['Linz', 'Graz'], ['Graz', 'Steyr'], ['Steyr', 'Klagenfurt']]) == \"Klagenfurt\"\n assert candidate(paths = [['M', 'N'], ['O', 'M'], ['P', 'O'], ['Q', 'P'], ['R', 'Q'], ['S', 'R'], ['T', 'S']]) == \"N\"\n assert candidate(paths = [['Houston', 'Dallas'], ['Dallas', 'San Antonio'], ['San Antonio', 'El Paso'], ['El Paso', 'Las Vegas'], ['Las Vegas', 'Los Angeles'], ['Los Angeles', 'Sacramento']]) == \"Sacramento\"\n assert candidate(paths = [['Lisbon', 'Porto'], ['Porto', 'Braga'], ['Braga', 'Guimaraes'], ['Guimaraes', 'Vila Real'], ['Vila Real', 'Braganca'], ['Braganca', 'Viseu'], ['Viseu', 'Guarda'], ['Guarda', 'Castelo Branco'], ['Castelo Branco', 'Coimbra'], ['Coimbra', 'Leiria'], ['Leiria', 'Faro'], ['Faro', 'Evora']]) == \"Evora\"\n assert candidate(paths = [['Sydney', 'Melbourne'], ['Melbourne', 'Brisbane'], ['Brisbane', 'Perth'], ['Perth', 'Adelaide'], ['Adelaide', 'Darwin']]) == \"Darwin\"\n assert candidate(paths = [['Berlin', 'Hamburg'], ['Hamburg', 'Frankfurt'], ['Frankfurt', 'Munich'], ['Munich', 'Stuttgart'], ['Stuttgart', 'Zurich'], ['Zurich', 'Geneva'], ['Geneva', 'Lyon']]) == \"Lyon\"\n assert candidate(paths = [['Origin', 'FirstStop'], ['FirstStop', 'SecondStop'], ['SecondStop', 'ThirdStop'], ['ThirdStop', 'FourthStop'], ['FourthStop', 'FifthStop'], ['FifthStop', 'SixthStop'], ['SixthStop', 'SeventhStop'], ['SeventhStop', 'EighthStop'], ['EighthStop', 'NinthStop'], ['NinthStop', 'TenthStop'], ['TenthStop', 'EleventhStop'], ['EleventhStop', 'TwelfthStop'], ['TwelfthStop', 'ThirteenthStop'], ['ThirteenthStop', 'FourteenthStop'], ['FourteenthStop', 'FifteenthStop'], ['FifteenthStop', 'SixteenthStop'], ['SixteenthStop', 'SeventeenthStop'], ['SeventeenthStop', 'EighteenthStop'], ['EighteenthStop', 'NineteenthStop'], ['NineteenthStop', 'TwentiethStop'], ['TwentiethStop', 'TwentyFirstStop'], ['TwentyFirstStop', 'TwentySecondStop'], ['TwentySecondStop', 'TwentyThirdStop'], ['TwentyThirdStop', 'TwentyFourthStop'], ['TwentyFourthStop', 'TwentyFifthStop'], ['TwentyFifthStop', 'Destination']]) == \"Destination\"\n assert candidate(paths = [['Sydney', 'Melbourne'], ['Melbourne', 'Brisbane'], ['Brisbane', 'Perth'], ['Perth', 'Adelaide'], ['Adelaide', 'Darwin'], ['Darwin', 'Canberra']]) == \"Canberra\"\n assert candidate(paths = [['Paris', 'Berlin'], ['Berlin', 'Vienna'], ['Vienna', 'Budapest'], ['Budapest', 'Prague'], ['Prague', 'Warsaw'], ['Warsaw', 'Krakow']]) == \"Krakow\"\n assert candidate(paths = [['San Francisco', 'Los Angeles'], ['Los Angeles', 'Phoenix'], ['Phoenix', 'Denver'], ['Denver', 'Chicago']]) == \"Chicago\"\n assert candidate(paths = [['Vienna', 'Prague'], ['Prague', 'Bratislava'], ['Bratislava', 'Budapest'], ['Budapest', 'Belgrade'], ['Belgrade', 'Sofia'], ['Sofia', 'Istanbul'], ['Istanbul', 'Athens'], ['Athens', 'Delhi'], ['Delhi', 'Mumbai']]) == \"Mumbai\"\n assert candidate(paths = [['Toronto', 'Ottawa'], ['Ottawa', 'Montreal'], ['Montreal', 'Quebec City'], ['Quebec City', \"St. John's\"]]) == \"St. John's\"\n assert candidate(paths = [['Alpha', 'Beta'], ['Gamma', 'Alpha'], ['Delta', 'Gamma'], ['Epsilon', 'Delta'], ['Zeta', 'Epsilon']]) == \"Beta\"\n assert candidate(paths = [['Tokyo', 'Osaka'], ['Osaka', 'Kyoto'], ['Kyoto', 'Fukuoka'], ['Fukuoka', 'Sapporo'], ['Sapporo', 'Hokkaido'], ['Hokkaido', 'Nagoya'], ['Nagoya', 'Yokohama']]) == \"Yokohama\"\n assert candidate(paths = [['Seattle', 'Portland'], ['Portland', 'Eugene'], ['Eugene', 'Bend'], ['Bend', 'Medford'], ['Medford', 'Ashland'], ['Ashland', 'Crater Lake']]) == \"Crater Lake\"\n assert candidate(paths = [['San Francisco', 'San Jose'], ['San Jose', 'San Diego'], ['San Diego', 'Los Angeles'], ['Los Angeles', 'Las Vegas'], ['Las Vegas', 'Reno'], ['Reno', 'Salt Lake City'], ['Salt Lake City', 'Denver'], ['Denver', 'Kansas City'], ['Kansas City', 'Omaha'], ['Omaha', 'Chicago'], ['Chicago', 'Milwaukee'], ['Milwaukee', 'Madison'], ['Madison', 'Green Bay']]) == \"Green Bay\"\n assert candidate(paths = [['NodeA', 'NodeB'], ['NodeB', 'NodeC'], ['NodeC', 'NodeD'], ['NodeD', 'NodeE'], ['NodeE', 'NodeF'], ['NodeF', 'NodeG'], ['NodeG', 'NodeH'], ['NodeH', 'NodeI'], ['NodeI', 'NodeJ'], ['NodeJ', 'NodeK'], ['NodeK', 'NodeL'], ['NodeL', 'NodeM'], ['NodeM', 'NodeN'], ['NodeN', 'NodeO'], ['NodeO', 'NodeP'], ['NodeP', 'NodeQ'], ['NodeQ', 'NodeR'], ['NodeR', 'NodeS'], ['NodeS', 'NodeT']]) == \"NodeT\"\n assert candidate(paths = [['Oslo', 'Helsinki'], ['Helsinki', 'Stockholm'], ['Stockholm', 'Reykjavik'], ['Reykjavik', 'Vilnius'], ['Vilnius', 'Riga']]) == \"Riga\"\n assert candidate(paths = [['A', 'B'], ['B', 'C'], ['C', 'D'], ['D', 'E'], ['E', 'F'], ['F', 'G'], ['G', 'H']]) == \"H\"\n assert candidate(paths = [['Start', 'Middle'], ['Middle', 'End1'], ['End1', 'End2'], ['End2', 'End3'], ['End3', 'End4'], ['End4', 'FinalDestination']]) == \"FinalDestination\"\n assert candidate(paths = [['Doha', 'Abu Dhabi'], ['Abu Dhabi', 'Masqat'], ['Masqat', 'Dubai'], ['Dubai', 'Sharjah'], ['Sharjah', 'Ras Al Khaimah'], ['Ras Al Khaimah', 'Fujairah']]) == \"Fujairah\"\n assert candidate(paths = [['Sydney', 'Melbourne'], ['Melbourne', 'Brisbane'], ['Brisbane', 'Perth'], ['Perth', 'Adelaide'], ['Adelaide', 'Gold Coast'], ['Gold Coast', 'Darwin'], ['Darwin', 'Alice Springs'], ['Alice Springs', 'Uluru']]) == \"Uluru\"\n assert candidate(paths = [['Los Angeles', 'San Diego'], ['San Diego', 'San Jose'], ['San Jose', 'Sacramento'], ['Sacramento', 'Reno'], ['Reno', 'Salt Lake City'], ['Salt Lake City', 'Boise'], ['Boise', 'Spokane']]) == \"Spokane\"\n assert candidate(paths = [['New Delhi', 'Bangalore'], ['Bangalore', 'Chennai'], ['Chennai', 'Hyderabad'], ['Hyderabad', 'Mumbai'], ['Mumbai', 'Pune'], ['Pune', 'Kochi'], ['Kochi', 'Trivandrum']]) == \"Trivandrum\"\n assert candidate(paths = [['Sydney', 'Melbourne'], ['Melbourne', 'Brisbane'], ['Brisbane', 'Perth'], ['Perth', 'Adelaide'], ['Adelaide', 'Alice Springs']]) == \"Alice Springs\"\n assert candidate(paths = [['Tokyo', 'Osaka'], ['Osaka', 'Kyoto'], ['Kyoto', 'Nagoya'], ['Nagoya', 'Fukuoka'], ['Fukuoka', 'Sapporo'], ['Sapporo', 'Hokkaido']]) == \"Hokkaido\"\n assert candidate(paths = [['Cairo', 'Luxor'], ['Luxor', 'Aswan'], ['Aswan', 'Assiut'], ['Assiut', 'Ismailia'], ['Ismailia', 'Suez'], ['Suez', 'Port Said'], ['Port Said', 'Alexandria'], ['Alexandria', 'Damietta'], ['Damietta', 'Mansoura'], ['Mansoura', 'Tanta'], ['Tanta', 'Qena']]) == \"Qena\"\n assert candidate(paths = [['Kuala Lumpur', 'George Town'], ['George Town', 'Ipoh'], ['Ipoh', 'Perak'], ['Perak', 'Klang'], ['Klang', 'Petaling Jaya']]) == \"Petaling Jaya\"\n"}, "metadata": {"canonical_parameter_names": ["paths"], "leetcode_dataset_entry_point": "Solution().destCity", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string destCity(vector>& paths) {", "container": "Solution", "callable": "destCity", "parameters": [{"name": "paths", "type": "vector>&"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1437, "task_id": "check-if-all-1s-are-at-least-length-k-places-away", "difficulty": "Easy", "problem_description": "Given an binary array nums and an integer k, return true if all 1's are at least k places away from each other, otherwise return false.\n \nExample 1:\n\n\nInput: nums = [1,0,0,0,1,0,0,1], k = 2\nOutput: true\nExplanation: Each of the 1s are at least 2 places away from each other.\n\nExample 2:\n\n\nInput: nums = [1,0,0,1,0,1], k = 2\nOutput: false\nExplanation: The second 1 and third 1 are only one apart from each other.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= k <= nums.length\nnums[i] is 0 or 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 0, 0, 0, 0],k = 1) == False\n assert candidate(nums = [0, 1, 0, 1, 0, 1],k = 1) == True\n assert candidate(nums = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0],k = 2) == True\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 0, 0, 1],k = 1) == False\n assert candidate(nums = [1, 1, 1, 1, 1],k = 0) == True\n assert candidate(nums = [1],k = 1) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 1],k = 2) == True\n assert candidate(nums = [0, 0, 0, 0, 0],k = 1) == True\n assert candidate(nums = [1],k = 0) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 10) == False\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1],k = 1) == True\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1],k = 0) == True\n assert candidate(nums = [0, 0, 0, 0, 0],k = 3) == True\n assert candidate(nums = [1, 1, 0, 1],k = 0) == True\n assert candidate(nums = [1, 0, 0, 1, 0, 1],k = 2) == False\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1],k = 5) == True\n assert candidate(nums = [0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 4) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 4) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 150) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1],k = 5) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 3) == False\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 5) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 15) == True\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 1) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 4) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 20) == True\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 1) == False\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 70) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 4) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 4) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 10) == True\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 1) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 15) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 15) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 100) == True\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 20) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 20) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 60) == True\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1],k = 5) == False\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 2) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 10) == False\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == True\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 1) == True\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 0) == True\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 1) == False\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 0) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 4) == True\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 10) == True\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 30) == True\n assert candidate(nums = [1, 0, 1, 0, 0, 1, 0, 0, 0, 1],k = 1) == True\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 2) == False\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 5) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 4) == False\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 10) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1],k = 6) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 40) == True\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == False\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 19) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 50) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 9) == True\n assert candidate(nums = [1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1],k = 2) == False\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 5) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],k = 7) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 20) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 30) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 0) == True\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 25) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 5) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 10) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 30) == False\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 1) == False\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 10) == True\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == False\n assert candidate(nums = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 4) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1],k = 3) == True\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 10) == True\n assert candidate(nums = [0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 20) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 5) == False\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 2) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 9) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 18) == True\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 1) == True\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 2) == True\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().kLengthApart", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool kLengthApart(vector& nums, int k) {", "container": "Solution", "callable": "kLengthApart", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1438, "task_id": "longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit", "difficulty": "Medium", "problem_description": "Given an array of integers nums and an integer limit, return the size of the longest non-empty subarray such that the absolute difference between any two elements of this subarray is less than or equal to limit.\n \nExample 1:\n\nInput: nums = [8,2,4,7], limit = 4\nOutput: 2 \nExplanation: All subarrays are: \n[8] with maximum absolute diff |8-8| = 0 <= 4.\n[8,2] with maximum absolute diff |8-2| = 6 > 4. \n[8,2,4] with maximum absolute diff |8-2| = 6 > 4.\n[8,2,4,7] with maximum absolute diff |8-2| = 6 > 4.\n[2] with maximum absolute diff |2-2| = 0 <= 4.\n[2,4] with maximum absolute diff |2-4| = 2 <= 4.\n[2,4,7] with maximum absolute diff |2-7| = 5 > 4.\n[4] with maximum absolute diff |4-4| = 0 <= 4.\n[4,7] with maximum absolute diff |4-7| = 3 <= 4.\n[7] with maximum absolute diff |7-7| = 0 <= 4. \nTherefore, the size of the longest subarray is 2.\n\nExample 2:\n\nInput: nums = [10,1,2,4,7,2], limit = 5\nOutput: 4 \nExplanation: The subarray [2,4,7,2] is the longest since the maximum absolute diff is |2-7| = 5 <= 5.\n\nExample 3:\n\nInput: nums = [4,2,2,2,4,4,2,2], limit = 0\nOutput: 3\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 109\n0 <= limit <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 6, 8, 9, 10],limit = 2) == 3\n assert candidate(nums = [100, 101, 102, 103, 104],limit = 3) == 4\n assert candidate(nums = [4, 2, 2, 2, 4, 4, 2, 2],limit = 0) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 2) == 3\n assert candidate(nums = [1, 2],limit = 1) == 2\n assert candidate(nums = [1],limit = 1) == 1\n assert candidate(nums = [1, 3, 6, 8, 10, 15],limit = 2) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5],limit = 0) == 7\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 4) == 5\n assert candidate(nums = [1, 5, 6, 7, 8, 10],limit = 3) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 9) == 10\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 3) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 5) == 6\n assert candidate(nums = [1, 3, 6, 8, 9, 10],limit = 1) == 2\n assert candidate(nums = [5, 5, 5, 5, 5],limit = 0) == 5\n assert candidate(nums = [10, 1, 2, 4, 7, 2],limit = 5) == 4\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 0) == 1\n assert candidate(nums = [8, 2, 4, 7],limit = 4) == 2\n assert candidate(nums = [5, 5, 5, 5, 5],limit = 10) == 5\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 2) == 3\n assert candidate(nums = [1, 5, 6, 7, 8, 10, 6, 5, 6],limit = 4) == 5\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4],limit = 3) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],limit = 3) == 4\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14],limit = 4) == 10\n assert candidate(nums = [5, 1, 4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 3) == 6\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0],limit = 10) == 2\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15],limit = 2) == 5\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],limit = 3) == 4\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1],limit = 99) == 10\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 5) == 12\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5],limit = 2) == 6\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3],limit = 2) == 15\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 5) == 10\n assert candidate(nums = [2, 2, 2, 1, 1, 1, 3, 3, 3, 4, 4, 4, 5, 5, 5],limit = 1) == 6\n assert candidate(nums = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3],limit = 2) == 20\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],limit = 2) == 6\n assert candidate(nums = [21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],limit = 4) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],limit = 15) == 16\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],limit = 50) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],limit = 20) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 3) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 0) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 0) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],limit = 5) == 6\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],limit = 9) == 10\n assert candidate(nums = [8, 2, 4, 7, 1, 3, 6, 5, 9, 11, 10],limit = 4) == 3\n assert candidate(nums = [25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],limit = 6) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],limit = 10) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],limit = 4) == 5\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10],limit = 9) == 12\n assert candidate(nums = [10, 1, 2, 4, 7, 2, 9, 3, 5, 6],limit = 5) == 4\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],limit = 5) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],limit = 2) == 2\n assert candidate(nums = [5, 8, 8, 8, 8, 5, 5, 5, 5, 8, 8, 8, 5, 5],limit = 3) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 0) == 1\n assert candidate(nums = [10, 10, 10, 10, 1, 1, 1, 1, 10, 10, 10, 10, 1, 1, 1, 1],limit = 9) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],limit = 1) == 2\n assert candidate(nums = [5, 1, 3, 5, 9, 11, 9, 7, 5, 3, 1],limit = 2) == 3\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],limit = 1000000000) == 10\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],limit = 5) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],limit = 8) == 5\n assert candidate(nums = [5, 9, 1, 3, 7, 6, 2, 8, 4, 10],limit = 3) == 2\n assert candidate(nums = [10, 1, 2, 4, 7, 2, 10, 1, 2, 4, 7, 2, 10, 1, 2, 4, 7, 2, 10, 1, 2, 4, 7, 2],limit = 5) == 4\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],limit = 2) == 3\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],limit = 10) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 0) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],limit = 10) == 6\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],limit = 2) == 12\n assert candidate(nums = [1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000],limit = 999999999) == 8\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],limit = 0) == 20\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],limit = 3) == 4\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],limit = 1) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],limit = 5) == 6\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],limit = 2) == 15\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],limit = 0) == 15\n assert candidate(nums = [1, 1000000000, 1, 1000000000, 1, 1000000000],limit = 999999999) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],limit = 50) == 6\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],limit = 4) == 9\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 2) == 3\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],limit = 100) == 2\n assert candidate(nums = [7, 7, 7, 1, 1, 1, 7, 7, 7, 1, 1, 1, 7, 7, 7],limit = 6) == 15\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],limit = 3) == 8\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],limit = 10) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],limit = 10) == 6\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8],limit = 0) == 10\n assert candidate(nums = [1000000000, 999999999, 1000000000, 999999999, 1000000000, 999999999],limit = 1) == 6\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],limit = 100) == 2\n assert candidate(nums = [100, 100, 100, 100, 101, 102, 103, 104, 105],limit = 5) == 9\n assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 8, 12, 9, 13, 10, 14],limit = 5) == 6\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],limit = 7) == 8\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10],limit = 9) == 18\n assert candidate(nums = [8, 6, 5, 7, 2, 3, 10, 12, 15, 1],limit = 5) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],limit = 4) == 3\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],limit = 9) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],limit = 5) == 6\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],limit = 0) == 30\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],limit = 100) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],limit = 2) == 3\n assert candidate(nums = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],limit = 4) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 0) == 10\n assert candidate(nums = [8, 2, 4, 7, 10, 15, 1, 3, 6, 9],limit = 5) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],limit = 4) == 5\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1],limit = 3) == 10\n assert candidate(nums = [2, 3, 1, 1, 5, 7, 5, 10, 12, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],limit = 5) == 13\n assert candidate(nums = [1, 3, 3, 1, 2, 3, 2, 1, 1, 2, 3, 3, 2, 1, 1, 2, 3, 3, 2, 1],limit = 2) == 20\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],limit = 1) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],limit = 6) == 4\n assert candidate(nums = [5, 2, 3, 4, 1, 5, 2],limit = 3) == 4\n assert candidate(nums = [4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1],limit = 0) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 0) == 69\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 2) == 3\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],limit = 1) == 30\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2],limit = 1) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],limit = 5) == 6\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],limit = 1) == 9\n assert candidate(nums = [10, 15, 10, 20, 15, 10, 25, 30, 25],limit = 5) == 3\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1],limit = 4) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 5) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],limit = 2) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],limit = 4) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],limit = 5) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],limit = 1) == 2\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],limit = 1) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5],limit = 0) == 8\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],limit = 3) == 10\n assert candidate(nums = [100, 1, 2, 3, 4, 100, 2, 3, 4, 100],limit = 99) == 10\n assert candidate(nums = [1, 3, 5, 7, 9],limit = 6) == 4\n assert candidate(nums = [1, 2, 3, 1, 5, 6, 7, 8, 9, 10],limit = 2) == 4\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1],limit = 2) == 10\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],limit = 1) == 10\n assert candidate(nums = [1, 3, 6, 8, 9, 10, 12, 15],limit = 3) == 3\n assert candidate(nums = [5, 4, 3, 2, 1],limit = 4) == 5\n assert candidate(nums = [1, 2, 3, 1, 5],limit = 2) == 4\n assert candidate(nums = [100, 1, 101, 2, 102, 3, 103, 4],limit = 3) == 1\n assert candidate(nums = [1000000000, 1, 1000000000, 1],limit = 1) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5],limit = 0) == 6\n assert candidate(nums = [100, 1, 2, 3, 4, 100, 101],limit = 3) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 3) == 4\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 3) == 4\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2],limit = 0) == 9\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 9) == 10\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 10) == 5\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5],limit = 3) == 4\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 1) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 1) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],limit = 3) == 4\n assert candidate(nums = [10, 20, 30, 40, 50],limit = 10) == 2\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 5) == 5\n assert candidate(nums = [1, 5, 6, 7, 8, 8, 9, 10, 10, 10],limit = 2) == 6\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 1) == 2\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3],limit = 1) == 2\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 3) == 4\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1],limit = 1) == 9\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 1) == 2\n assert candidate(nums = [10, 20, 30, 40, 50],limit = 15) == 2\n assert candidate(nums = [1, 5, 6, 7, 8, 8, 9, 10, 11, 12, 13],limit = 4) == 6\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],limit = 1) == 2\n assert candidate(nums = [100, 1, 101, 2, 102, 3, 103, 4, 104, 5],limit = 100) == 4\n assert candidate(nums = [1000000000, 1000000000, 1000000000],limit = 0) == 3\n assert candidate(nums = [1],limit = 10) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 0) == 1\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],limit = 0) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1],limit = 2) == 5\n assert candidate(nums = [1, 5, 6, 7, 8, 8, 9, 10],limit = 4) == 6\n assert candidate(nums = [1000000000, 1, 1000000000, 1, 1000000000],limit = 999999999) == 5\n assert candidate(nums = [1, 5, 6, 7, 8, 9],limit = 2) == 3\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1000000000],limit = 1000000000) == 11\n assert candidate(nums = [1, 3, 6, 8, 9, 10],limit = 4) == 4\n assert candidate(nums = [1, 3, 6, 8, 9, 10],limit = 5) == 4\n assert candidate(nums = [1, 2, 3],limit = 10) == 3\n assert candidate(nums = [1, 3, 5, 7, 9],limit = 2) == 2\n assert candidate(nums = [1, 5, 6, 7, 8, 10],limit = 4) == 4\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 2) == 3\n assert candidate(nums = [1, 3, 6, 8, 10],limit = 2) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 1) == 2\n assert candidate(nums = [1, 3, 6, 8, 10, 15],limit = 5) == 3\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 5) == 6\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],limit = 10) == 10\n assert candidate(nums = [1, 3, 6, 2, 7, 8, 4, 5, 9],limit = 3) == 2\n assert candidate(nums = [1, 3, 6, 8, 9, 10],limit = 3) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1],limit = 3) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 0) == 20\n assert candidate(nums = [1],limit = 0) == 1\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3],limit = 2) == 9\n"}, "metadata": {"canonical_parameter_names": ["nums", "limit"], "leetcode_dataset_entry_point": "Solution().longestSubarray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int longestSubarray(vector& nums, int limit) {", "container": "Solution", "callable": "longestSubarray", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "limit", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1439, "task_id": "find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows", "difficulty": "Hard", "problem_description": "You are given an m x n matrix mat that has its rows sorted in non-decreasing order and an integer k.\nYou are allowed to choose exactly one element from each row to form an array.\nReturn the kth smallest array sum among all possible arrays.\n \nExample 1:\n\nInput: mat = [[1,3,11],[2,4,6]], k = 5\nOutput: 7\nExplanation: Choosing one element from each row, the first k smallest sum are:\n[1,2], [1,4], [3,2], [3,4], [1,6]. Where the 5th sum is 7.\n\nExample 2:\n\nInput: mat = [[1,3,11],[2,4,6]], k = 9\nOutput: 17\n\nExample 3:\n\nInput: mat = [[1,10,10],[1,4,5],[2,3,6]], k = 7\nOutput: 9\nExplanation: Choosing one element from each row, the first k smallest sum are:\n[1,1,2], [1,1,3], [1,4,2], [1,4,3], [1,1,6], [1,5,2], [1,5,3]. Where the 7th sum is 9. \n\n \nConstraints:\n\nm == mat.length\nn == mat.length[i]\n1 <= m, n <= 40\n1 <= mat[i][j] <= 5000\n1 <= k <= min(200, nm)\nmat[i] is a non-decreasing array.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1, 10, 10], [1, 4, 5], [2, 3, 6]],k = 7) == 9\n assert candidate(mat = [[1, 2, 3], [4, 5, 6]],k = 9) == 9\n assert candidate(mat = [[1, 3, 11], [2, 4, 6]],k = 5) == 7\n assert candidate(mat = [[1, 3, 11], [2, 4, 6]],k = 9) == 17\n assert candidate(mat = [[1, 2, 3], [4, 5, 6]],k = 1) == 5\n assert candidate(mat = [[1, 5, 9], [10, 11, 13], [12, 13, 15]],k = 8) == 27\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]],k = 100) == 69\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 100) == 4\n assert candidate(mat = [[1, 7, 10, 15], [2, 8, 12, 16], [3, 9, 13, 17], [4, 10, 14, 18]],k = 15) == 22\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]],k = 100) == 68\n assert candidate(mat = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4], [5, 5, 5, 5]],k = 160) == 15\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],k = 180) == 42\n assert candidate(mat = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]],k = 200) == 24\n assert candidate(mat = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],k = 100) == 33\n assert candidate(mat = [[500, 1000, 1500], [550, 1050, 1550], [600, 1100, 1600], [650, 1150, 1650]],k = 10) == 3300\n assert candidate(mat = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]],k = 200) == 10\n assert candidate(mat = [[1, 2, 3, 4, 5], [10, 11, 12, 13, 14], [20, 21, 22, 23, 24], [30, 31, 32, 33, 34]],k = 50) == 65\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11]],k = 100) == 22\n assert candidate(mat = [[10, 20, 30], [15, 25, 35], [20, 30, 40], [25, 35, 45], [30, 40, 50]],k = 50) == 130\n assert candidate(mat = [[5, 10, 15], [6, 11, 16], [7, 12, 17], [8, 13, 18]],k = 25) == 41\n assert candidate(mat = [[5, 10, 15, 20, 25], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19]],k = 100) == 32\n assert candidate(mat = [[100, 200, 300, 400, 500], [101, 201, 301, 401, 501], [102, 202, 302, 402, 502], [103, 203, 303, 403, 503]],k = 20) == 706\n assert candidate(mat = [[1, 100, 200], [5, 150, 250], [9, 190, 290], [13, 230, 330]],k = 80) == 970\n assert candidate(mat = [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [3, 5, 7, 9, 11, 13], [4, 6, 8, 10, 12, 14]],k = 50) == 18\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]],k = 150) == 27\n assert candidate(mat = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41], [6, 16, 26, 36, 46]],k = 50) == 62\n assert candidate(mat = [[5, 8, 12, 18], [1, 3, 7, 11], [2, 4, 6, 10], [9, 13, 15, 17]],k = 100) == 33\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]],k = 250) == 61\n assert candidate(mat = [[1, 2, 3, 4, 5], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19]],k = 50) == 35\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24]],k = 150) == 46\n assert candidate(mat = [[1, 5, 9, 12], [2, 6, 10, 13], [3, 7, 11, 14], [4, 8, 15, 16]],k = 15) == 21\n assert candidate(mat = [[5, 10, 15, 20], [25, 30, 35, 40], [45, 50, 55, 60]],k = 15) == 90\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13]],k = 150) == 16\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],k = 30) == 25\n assert candidate(mat = [[5, 9, 14], [4, 12, 18], [2, 8, 10], [1, 3, 6]],k = 25) == 26\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],k = 50) == 102\n assert candidate(mat = [[100, 200, 300, 400, 500], [50, 100, 150, 200, 250], [25, 50, 75, 100, 125], [1, 2, 3, 4, 5]],k = 80) == 328\n assert candidate(mat = [[10, 20, 30, 40, 50], [11, 22, 33, 44, 55], [12, 24, 36, 48, 60], [13, 26, 39, 52, 65]],k = 100) == 104\n assert candidate(mat = [[500, 1000, 1500], [100, 200, 300], [250, 500, 750], [50, 100, 150], [200, 400, 600]],k = 60) == 1800\n assert candidate(mat = [[1, 10, 100], [1, 4, 50], [2, 3, 60]],k = 20) == 107\n assert candidate(mat = [[1, 3, 5, 7, 9], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29], [31, 33, 35, 37, 39]],k = 175) == 76\n assert candidate(mat = [[2, 4, 6, 8, 10], [12, 14, 16, 18, 20], [22, 24, 26, 28, 30], [32, 34, 36, 38, 40]],k = 30) == 74\n assert candidate(mat = [[2, 6, 10, 14], [1, 5, 9, 13], [3, 7, 11, 15], [4, 8, 12, 16]],k = 15) == 18\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],k = 50) == 4\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],k = 50) == 38\n assert candidate(mat = [[1, 1000, 2000, 3000, 4000], [2, 2000, 3000, 4000, 5000], [3, 3000, 4000, 5000, 6000], [4, 4000, 5000, 6000, 7000]],k = 120) == 9005\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],k = 300) == 11\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],k = 199) == 10\n assert candidate(mat = [[1, 1, 1, 1], [1, 2, 2, 2], [1, 2, 3, 3], [1, 2, 3, 4]],k = 20) == 5\n assert candidate(mat = [[1, 1000, 5000], [500, 2000, 4000], [100, 3000, 4500], [200, 2500, 3500]],k = 100) == 17000\n assert candidate(mat = [[1, 5, 9, 13], [2, 6, 10, 14], [3, 7, 11, 15], [4, 8, 12, 16], [5, 9, 13, 17]],k = 200) == 35\n assert candidate(mat = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]],k = 120) == 16\n assert candidate(mat = [[1, 3, 5, 7, 9, 11, 13], [2, 4, 6, 8, 10, 12, 14], [3, 5, 7, 9, 11, 13, 15], [4, 6, 8, 10, 12, 14, 16]],k = 70) == 18\n assert candidate(mat = [[1000, 2000, 3000, 4000], [500, 1500, 2500, 3500], [100, 1100, 2100, 3100], [50, 1050, 2050, 3050]],k = 10) == 3650\n assert candidate(mat = [[100, 200, 300, 400, 500], [600, 700, 800, 900, 1000], [1100, 1200, 1300, 1400, 1500]],k = 18) == 2100\n assert candidate(mat = [[1, 4, 7, 10], [2, 5, 8, 11], [3, 6, 9, 12]],k = 60) == 27\n assert candidate(mat = [[100, 200, 300], [50, 150, 250], [10, 110, 210], [5, 105, 205], [1, 101, 201]],k = 80) == 566\n assert candidate(mat = [[1, 1000, 2000, 3000], [2, 2000, 3000, 4000], [3, 3000, 4000, 5000], [4, 4000, 5000, 6000]],k = 160) == 12001\n assert candidate(mat = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [4, 4, 4, 4, 4], [5, 5, 5, 5, 5]],k = 125) == 15\n assert candidate(mat = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7]],k = 10) == 8\n assert candidate(mat = [[1, 3, 5, 7, 9, 11, 13], [2, 4, 6, 8, 10, 12, 14], [15, 17, 19, 21, 23, 25, 27], [29, 31, 33, 35, 37, 39, 41]],k = 180) == 59\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],k = 150) == 11\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30]],k = 120) == 69\n assert candidate(mat = [[1, 7, 12, 22], [5, 8, 9, 13], [6, 12, 15, 18]],k = 15) == 24\n assert candidate(mat = [[3, 6, 9, 12], [2, 5, 8, 11], [1, 4, 7, 10]],k = 24) == 18\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],k = 60) == 39\n assert candidate(mat = [[5, 10, 15, 20, 25], [6, 11, 16, 21, 26], [7, 12, 17, 22, 27], [8, 13, 18, 23, 28], [9, 14, 19, 24, 29]],k = 50) == 50\n assert candidate(mat = [[1, 5, 9, 13, 17], [2, 6, 10, 14, 18], [3, 7, 11, 15, 19], [4, 8, 12, 16, 20]],k = 150) == 34\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],k = 120) == 40\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 6, 9, 12, 15]],k = 60) == 20\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]],k = 100) == 55\n assert candidate(mat = [[1, 100, 500, 1000], [2, 200, 600, 1100], [3, 300, 700, 1200], [4, 400, 800, 1300]],k = 120) == 1904\n assert candidate(mat = [[10, 20, 30, 40], [11, 22, 33, 44], [12, 24, 36, 48], [13, 26, 39, 52]],k = 150) == 121\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]],k = 150) == 60\n assert candidate(mat = [[1, 3, 7, 9], [2, 4, 6, 8], [0, 5, 10, 12], [1, 6, 11, 13]],k = 20) == 13\n assert candidate(mat = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]],k = 32) == 30\n assert candidate(mat = [[1, 2, 3, 4, 5], [5, 6, 7, 8, 9], [9, 10, 11, 12, 13]],k = 50) == 20\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]],k = 100) == 59\n assert candidate(mat = [[1, 3, 5, 7, 9, 11, 13, 15], [2, 4, 6, 8, 10, 12, 14, 16], [3, 5, 7, 9, 11, 13, 15, 17], [4, 6, 8, 10, 12, 14, 16, 18]],k = 100) == 20\n assert candidate(mat = [[5, 10, 15, 20, 25], [4, 9, 14, 19, 24], [3, 8, 13, 18, 23], [2, 7, 12, 17, 22], [1, 6, 11, 16, 21]],k = 50) == 30\n assert candidate(mat = [[1, 100, 200, 300, 400], [2, 200, 300, 400, 500], [3, 300, 400, 500, 600], [4, 400, 500, 600, 700], [5, 500, 600, 700, 800]],k = 150) == 910\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],k = 200) == 41\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 100) == 5\n assert candidate(mat = [[1, 100, 1000], [2, 200, 2000], [3, 300, 3000]],k = 20) == 3201\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],k = 200) == 42\n"}, "metadata": {"canonical_parameter_names": ["mat", "k"], "leetcode_dataset_entry_point": "Solution().kthSmallest", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int kthSmallest(vector>& mat, int k) {", "container": "Solution", "callable": "kthSmallest", "parameters": [{"name": "mat", "type": "vector>&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1441, "task_id": "build-an-array-with-stack-operations", "difficulty": "Medium", "problem_description": "You are given an integer array target and an integer n.\nYou have an empty stack with the two following operations:\n\n\"Push\": pushes an integer to the top of the stack.\n\"Pop\": removes the integer on the top of the stack.\n\nYou also have a stream of the integers in the range [1, n].\nUse the two stack operations to make the numbers in the stack (from the bottom to the top) equal to target. You should follow the following rules:\n\nIf the stream of the integers is not empty, pick the next integer from the stream and push it to the top of the stack.\nIf the stack is not empty, pop the integer at the top of the stack.\nIf, at any moment, the elements in the stack (from the bottom to the top) are equal to target, do not read new integers from the stream and do not do more operations on the stack.\n\nReturn the stack operations needed to build target following the mentioned rules. If there are multiple valid answers, return any of them.\n \nExample 1:\n\nInput: target = [1,3], n = 3\nOutput: [\"Push\",\"Push\",\"Pop\",\"Push\"]\nExplanation: Initially the stack s is empty. The last element is the top of the stack.\nRead 1 from the stream and push it to the stack. s = [1].\nRead 2 from the stream and push it to the stack. s = [1,2].\nPop the integer on the top of the stack. s = [1].\nRead 3 from the stream and push it to the stack. s = [1,3].\n\nExample 2:\n\nInput: target = [1,2,3], n = 3\nOutput: [\"Push\",\"Push\",\"Push\"]\nExplanation: Initially the stack s is empty. The last element is the top of the stack.\nRead 1 from the stream and push it to the stack. s = [1].\nRead 2 from the stream and push it to the stack. s = [1,2].\nRead 3 from the stream and push it to the stack. s = [1,2,3].\n\nExample 3:\n\nInput: target = [1,2], n = 4\nOutput: [\"Push\",\"Push\"]\nExplanation: Initially the stack s is empty. The last element is the top of the stack.\nRead 1 from the stream and push it to the stack. s = [1].\nRead 2 from the stream and push it to the stack. s = [1,2].\nSince the stack (from the bottom to the top) is equal to target, we stop the stack operations.\nThe answers that read integer 3 from the stream are not accepted.\n\n \nConstraints:\n\n1 <= target.length <= 100\n1 <= n <= 100\n1 <= target[i] <= n\ntarget is strictly increasing.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = [3, 4, 5],n = 5) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push']\n assert candidate(target = [3, 4, 6],n = 7) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [5],n = 10) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 5, 7, 9],n = 10) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 7, 9],n = 10) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 2],n = 4) == ['Push', 'Push']\n assert candidate(target = [1, 2, 3, 4, 5],n = 5) == ['Push', 'Push', 'Push', 'Push', 'Push']\n assert candidate(target = [2, 3, 5],n = 5) == ['Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 3, 4],n = 5) == ['Push', 'Pop', 'Push', 'Push', 'Push']\n assert candidate(target = [2, 4, 6, 8],n = 10) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 3, 4],n = 4) == ['Push', 'Pop', 'Push', 'Push', 'Push']\n assert candidate(target = [1],n = 1) == ['Push']\n assert candidate(target = [1, 2, 3],n = 3) == ['Push', 'Push', 'Push']\n assert candidate(target = [4, 5, 6],n = 6) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push']\n assert candidate(target = [1, 3, 5],n = 5) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 6, 7, 8],n = 10) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Push']\n assert candidate(target = [1, 3],n = 3) == ['Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [10],n = 10) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 6],n = 7) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 6, 7, 10],n = 10) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 6, 7, 8, 9, 10],n = 10) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Push', 'Push', 'Push']\n assert candidate(target = [1, 4, 6, 9],n = 10) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 9, 13, 17, 21],n = 30) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 2, 4, 8, 16],n = 20) == ['Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 6, 9, 12, 15, 18],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 2, 4, 5, 7, 8, 10],n = 12) == ['Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],n = 20) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 10, 15, 20, 25, 30, 35, 40, 45],n = 50) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 9, 11, 13, 15],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [4, 8, 16, 32, 64],n = 100) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [6, 8, 10, 12, 14],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 6, 10, 14, 18],n = 20) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 4, 8, 16, 32, 64, 128],n = 150) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],n = 50) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 7, 8, 10],n = 12) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 3, 5, 7, 9, 11],n = 15) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 2, 3, 5, 6, 8, 9, 11, 12, 14, 15],n = 20) == ['Push', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [2, 4, 6, 8, 10, 12, 14, 16],n = 20) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 6, 7, 9],n = 10) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 7, 11, 13, 15],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 5, 8, 11, 14, 17],n = 20) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 7, 10, 13, 16, 19, 22, 25],n = 30) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [10, 20, 30, 40],n = 50) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [7, 14, 21, 28],n = 35) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 6, 9, 12, 15, 18, 21],n = 25) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 7, 10, 13],n = 15) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 8, 11, 14],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 7, 11, 15, 19, 23, 27, 31, 35],n = 40) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [10, 20, 30],n = 30) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [7, 8, 9, 10, 11, 12, 13, 14, 15],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Push', 'Push', 'Push', 'Push', 'Push', 'Push']\n assert candidate(target = [3, 7, 10, 11],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [10, 12, 15, 19, 20],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [3, 5, 7, 9, 11, 13, 15],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 5, 10, 15, 20, 25, 30],n = 30) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 5, 10, 15, 20, 25, 30, 35],n = 40) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [4, 7, 10, 13, 16, 19],n = 25) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 8, 9, 11],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 2, 3, 5, 6, 7, 9, 10],n = 10) == ['Push', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [2, 5, 6, 8, 11, 12],n = 15) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [1, 2, 3, 5, 6, 7, 9, 10],n = 10) == ['Push', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [1, 2, 5, 7, 11, 13],n = 20) == ['Push', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [10, 20, 30, 40, 50],n = 55) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [7, 14, 21, 28],n = 35) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],n = 20) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 6, 8],n = 10) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [7, 11, 13, 17, 19],n = 25) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 4, 6, 8, 10, 12],n = 15) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],n = 25) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [7, 14, 21, 28, 35, 42],n = 42) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],n = 20) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13],n = 15) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 7, 10, 13],n = 13) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 5, 9, 13, 17, 21],n = 25) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 7, 11],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],n = 25) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 7, 11, 13],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 7, 11, 15, 19],n = 25) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [7, 14, 21, 28],n = 30) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 5, 8, 11, 14, 17, 20],n = 20) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 7, 9, 10],n = 12) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [3, 6, 8, 10],n = 12) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [6, 12, 18, 24, 30],n = 35) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 6],n = 10) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 3, 4, 7, 10, 12],n = 20) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 6, 9, 12],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 5, 7, 10, 13],n = 20) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 6, 9, 12, 15, 18],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 5, 8, 11, 14, 17, 20],n = 25) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 6, 10, 14, 18],n = 25) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [10, 15, 20, 25],n = 30) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 6, 9, 12, 15, 18, 21, 24],n = 30) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 4, 7, 10],n = 10) == ['Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [5, 7, 10],n = 10) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 5, 7, 10],n = 12) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [10, 12, 14],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [10, 20, 30, 40, 50],n = 50) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [7, 8, 10, 12],n = 12) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 3, 6, 8, 10],n = 12) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14],n = 15) == ['Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [11, 22, 33, 44, 55, 66, 77, 88, 99],n = 100) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 5, 7, 9, 10],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [5, 7, 9, 10],n = 10) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [1, 3, 5, 7, 9, 11],n = 15) == ['Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 5, 7, 9, 11],n = 12) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [10, 20, 30, 40, 50],n = 50) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [3, 5, 7, 8, 10],n = 15) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Pop', 'Push']\n assert candidate(target = [4, 8, 12, 16, 20, 24, 28],n = 30) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [6, 7, 8, 10, 12, 14, 15],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Push']\n assert candidate(target = [2, 6, 10, 14, 18],n = 25) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 5, 9, 13, 17],n = 20) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [2, 6, 10, 14, 18, 22, 26],n = 30) == ['Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push']\n assert candidate(target = [10, 11, 12],n = 20) == ['Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Pop', 'Push', 'Push', 'Push']\n"}, "metadata": {"canonical_parameter_names": ["target", "n"], "leetcode_dataset_entry_point": "Solution().buildArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector buildArray(vector& target, int n) {", "container": "Solution", "callable": "buildArray", "parameters": [{"name": "target", "type": "vector&"}, {"name": "n", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1442, "task_id": "count-triplets-that-can-form-two-arrays-of-equal-xor", "difficulty": "Medium", "problem_description": "Given an array of integers arr.\nWe want to select three indices i, j and k where (0 <= i < j <= k < arr.length).\nLet's define a and b as follows:\n\na = arr[i] ^ arr[i + 1] ^ ... ^ arr[j - 1]\nb = arr[j] ^ arr[j + 1] ^ ... ^ arr[k]\n\nNote that ^ denotes the bitwise-xor operation.\nReturn the number of triplets (i, j and k) Where a == b.\n \nExample 1:\n\nInput: arr = [2,3,1,6,7]\nOutput: 4\nExplanation: The triplets are (0,1,2), (0,2,2), (2,3,4) and (2,4,4)\n\nExample 2:\n\nInput: arr = [1,1,1,1,1]\nOutput: 10\n\n \nConstraints:\n\n1 <= arr.length <= 300\n1 <= arr[i] <= 108\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 3, 4, 1, 5, 6, 7, 8, 9]) == 17\n assert candidate(arr = [5, 5, 5, 5, 5, 5]) == 19\n assert candidate(arr = [8, 12, 3, 10]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 24\n assert candidate(arr = [3, 3, 3, 3, 3, 3]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5]) == 5\n assert candidate(arr = [2, 3, 1, 6, 7]) == 4\n assert candidate(arr = [2, 3, 4, 5, 6, 7]) == 6\n assert candidate(arr = [5, 3, 0, 1, 4]) == 0\n assert candidate(arr = [8, 1, 6, 2, 1]) == 0\n assert candidate(arr = [5, 1, 4, 1, 5]) == 4\n assert candidate(arr = [1, 1, 1, 1, 1]) == 10\n assert candidate(arr = [7, 11, 1, 2, 9, 5]) == 0\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 285\n assert candidate(arr = [1023, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 10\n assert candidate(arr = [100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000]) == 0\n assert candidate(arr = [15, 3, 9, 7, 11, 6, 2, 8, 14, 5]) == 8\n assert candidate(arr = [123456789, 987654321, 135792468, 246813579, 111222333, 333222111]) == 0\n assert candidate(arr = [256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(arr = [7, 5, 3, 2, 6, 8, 4, 3, 5, 2, 9, 1, 5]) == 21\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 245\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0]) == 13\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 47\n assert candidate(arr = [29, 17, 23, 29, 17, 23, 29, 17, 23, 29, 17, 23, 29]) == 62\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2255\n assert candidate(arr = [31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2]) == 41\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 62790\n assert candidate(arr = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43]) == 0\n assert candidate(arr = [123456789, 987654321, 1122334455, 5544332211, 9988776655]) == 0\n assert candidate(arr = [2, 5, 3, 2, 1, 4, 7, 8, 9, 6]) == 8\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 2870\n assert candidate(arr = [15, 13, 14, 11, 8, 7, 5, 2, 3, 4]) == 19\n assert candidate(arr = [100000000, 90000000, 80000000, 70000000, 60000000, 50000000, 40000000, 30000000, 20000000, 10000000]) == 0\n assert candidate(arr = [23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101]) == 0\n assert candidate(arr = [255, 128, 64, 32, 16, 8, 4, 2, 1, 255, 128, 64, 32, 16, 8, 4, 2, 1]) == 97\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 100\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0, 1, 2, 4, 8, 16, 32, 64, 128]) == 72\n assert candidate(arr = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 665\n assert candidate(arr = [23, 45, 67, 89, 12, 34, 56, 78, 90, 11, 22, 33, 44, 55, 66, 77, 88, 99, 10, 20]) == 0\n assert candidate(arr = [100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000, 100000000]) == 2736\n assert candidate(arr = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == 0\n assert candidate(arr = [100, 200, 300, 100, 200, 300, 100, 200]) == 15\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 2255\n assert candidate(arr = [10, 15, 3, 7, 8, 5, 2, 1]) == 0\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 265\n assert candidate(arr = [1, 3, 2, 3, 1, 5, 7, 5, 7, 9, 11, 9, 11, 13, 15]) == 97\n assert candidate(arr = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233]) == 25\n assert candidate(arr = [300, 200, 100, 50, 25, 12, 6, 3, 1, 0, 1, 3, 6, 12, 25, 50, 100, 200, 300]) == 90\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2736\n assert candidate(arr = [13, 17, 11, 14, 13, 14, 12, 11, 17, 13, 15, 16, 18, 14, 12, 15]) == 11\n assert candidate(arr = [12, 34, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90]) == 54\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 390\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 100\n assert candidate(arr = [15, 9, 8, 3, 6, 1, 1, 1, 1, 2]) == 6\n assert candidate(arr = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 2255\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 670\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1156\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 2\n assert candidate(arr = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930, 313233, 343536, 373839, 404142, 434445, 464748, 495051, 525354, 555657, 585960, 616263, 646566, 676869, 707172, 737475, 767778, 798081, 828384, 858687, 888990, 919293]) == 0\n assert candidate(arr = [256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 0\n assert candidate(arr = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 344\n assert candidate(arr = [23, 35, 47, 59, 71, 83, 95, 107, 119, 131, 143, 155, 167, 179, 191]) == 13\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824]) == 0\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 385\n assert candidate(arr = [100000000, 99999999, 99999998, 99999997, 99999996, 99999995, 99999994, 99999993, 99999992, 99999991]) == 16\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 24\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 104\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 190\n assert candidate(arr = [99999999, 88888888, 77777777, 66666666, 55555555, 44444444, 33333333, 22222222, 11111111, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 24\n assert candidate(arr = [100000000, 99999999, 100000000, 99999999, 100000000, 99999999, 100000000]) == 12\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 8\n assert candidate(arr = [123, 456, 789, 101, 202, 303, 404, 505, 606]) == 0\n assert candidate(arr = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == 110\n assert candidate(arr = [1, 3, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == 384\n assert candidate(arr = [100000000, 100000000, 100000000, 100000000, 100000000, 100000000]) == 19\n assert candidate(arr = [123456789, 987654321, 135792468, 246813579, 111222333]) == 0\n assert candidate(arr = [123456789, 987654321, 1122334455, 5544332211, 123123123, 987987987]) == 0\n assert candidate(arr = [101, 203, 307, 409, 511, 613, 719, 821, 923, 1027, 1131, 1237, 1349, 1451, 1553, 1657, 1763, 1867, 1979, 2083]) == 0\n assert candidate(arr = [256, 128, 64, 32, 16, 8, 4, 2, 1, 0]) == 0\n assert candidate(arr = [5, 3, 8, 6, 2, 7, 4, 1, 9]) == 3\n assert candidate(arr = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 1127\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 670\n assert candidate(arr = [255, 128, 64, 32, 16, 8, 4, 2, 1, 0]) == 17\n assert candidate(arr = [17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 136\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 34\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 0\n assert candidate(arr = [17, 17, 34, 34, 68, 68, 136, 136, 272, 272, 544, 544]) == 91\n assert candidate(arr = [256, 128, 64, 32, 16, 8, 4, 2, 1, 2, 4, 8, 16, 32, 64, 128, 256]) == 0\n assert candidate(arr = [8, 15, 17, 4, 3, 10, 12, 7, 6, 9, 11, 5, 2, 14, 13, 1, 0, 16, 32, 64, 128, 256]) == 45\n assert candidate(arr = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 0\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 5\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().countTriplets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countTriplets(vector& arr) {", "container": "Solution", "callable": "countTriplets", "parameters": [{"name": "arr", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1444, "task_id": "number-of-ways-of-cutting-a-pizza", "difficulty": "Hard", "problem_description": "Given a rectangular pizza represented as a rows x cols matrix containing the following characters: 'A' (an apple) and '.' (empty cell) and given the integer k. You have to cut the pizza into k pieces using k-1 cuts. \nFor each cut you choose the direction: vertical or horizontal, then you choose a cut position at the cell boundary and cut the pizza into two pieces. If you cut the pizza vertically, give the left part of the pizza to a person. If you cut the pizza horizontally, give the upper part of the pizza to a person. Give the last piece of pizza to the last person.\nReturn the number of ways of cutting the pizza such that each piece contains at least one apple. Since the answer can be a huge number, return this modulo 10^9 + 7.\n \nExample 1:\n\n\nInput: pizza = [\"A..\",\"AAA\",\"...\"], k = 3\nOutput: 3 \nExplanation: The figure above shows the three ways to cut the pizza. Note that pieces must contain at least one apple.\n\nExample 2:\n\nInput: pizza = [\"A..\",\"AA.\",\"...\"], k = 3\nOutput: 1\n\nExample 3:\n\nInput: pizza = [\"A..\",\"A..\",\"...\"], k = 1\nOutput: 1\n\n \nConstraints:\n\n1 <= rows, cols <= 50\nrows == pizza.length\ncols == pizza[i].length\n1 <= k <= 10\npizza consists of characters 'A' and '.' only.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(pizza = ['A', 'A', 'A'],k = 3) == 1\n assert candidate(pizza = ['AA', 'AA'],k = 2) == 2\n assert candidate(pizza = ['A.A', 'A.A', 'A.A'],k = 4) == 6\n assert candidate(pizza = ['A.A', 'A.A', 'A.A'],k = 5) == 0\n assert candidate(pizza = ['...', '...', '...', '...', '...', '...', 'AAA'],k = 4) == 0\n assert candidate(pizza = ['AAA', '...', 'AAA'],k = 2) == 4\n assert candidate(pizza = ['A..', 'A..', '...'],k = 1) == 1\n assert candidate(pizza = ['AAA', 'AAA', 'AAA'],k = 4) == 12\n assert candidate(pizza = ['AA.', 'AA.', '..A'],k = 2) == 4\n assert candidate(pizza = ['AAA', 'AAA', 'AAA'],k = 2) == 4\n assert candidate(pizza = ['A..', 'AA.', '...'],k = 3) == 1\n assert candidate(pizza = ['A.A', '.A.', 'A.A'],k = 2) == 4\n assert candidate(pizza = ['A..', 'A..'],k = 2) == 1\n assert candidate(pizza = ['A.A', 'A.A'],k = 2) == 3\n assert candidate(pizza = ['...', '...', '...'],k = 1) == 0\n assert candidate(pizza = ['A..', 'AAA', '...'],k = 3) == 3\n assert candidate(pizza = ['AAAAA', 'AA.AA', 'AA.AA', 'AA.AA', 'AAAAA'],k = 5) == 346\n assert candidate(pizza = ['AAAA', 'A.AA', 'AA.A', 'AAAA'],k = 4) == 56\n assert candidate(pizza = ['A.A.A', 'A....', 'A.A.A'],k = 3) == 21\n assert candidate(pizza = ['A.A', 'A.A', 'A.A'],k = 3) == 9\n assert candidate(pizza = ['A...A', '.....', 'A...A', '.....', 'A...A'],k = 3) == 36\n assert candidate(pizza = ['...A', '...A', '...A'],k = 2) == 2\n assert candidate(pizza = ['A...', '....', '....', 'A...'],k = 2) == 3\n assert candidate(pizza = ['A...A', '.A.A.', 'A...A', '.A.A.', 'A...A'],k = 5) == 198\n assert candidate(pizza = ['A.A', '.A.', 'A.A'],k = 3) == 10\n assert candidate(pizza = ['A.A', '.A.', 'A.A', '.A.', 'A.A'],k = 3) == 23\n assert candidate(pizza = ['A..A.', 'A..A.', 'A..A.', 'A..A.', 'A..A.'],k = 3) == 30\n assert candidate(pizza = ['AAAAAA', 'A...A.', 'A...A.', 'A...A.', 'AAAAAA'],k = 4) == 212\n assert candidate(pizza = ['AAAAA', '.....', 'AAAAA', '.....', 'AAAAA'],k = 3) == 42\n assert candidate(pizza = ['A...A', '.....', '.....', 'A...A'],k = 3) == 24\n assert candidate(pizza = ['A.A.A.A.A', '.A.A.A.A.', 'A.A.A.A.A', '.A.A.A.A.', 'A.A.A.A.A'],k = 5) == 1955\n assert candidate(pizza = ['AAAA', 'AAAA', 'AAAA', 'AAAA'],k = 5) == 78\n assert candidate(pizza = ['A.A.A', 'A.A.A', 'A.A.A'],k = 2) == 6\n assert candidate(pizza = ['A.A.A', 'A.A.A', 'A.A.A'],k = 3) == 21\n assert candidate(pizza = ['A.A.A.A', 'A.A.A.A', 'A.A.A.A'],k = 4) == 98\n assert candidate(pizza = ['AAAA', 'AAAA', 'AAAA'],k = 3) == 16\n assert candidate(pizza = ['A', 'A', 'A', 'A', 'A'],k = 3) == 6\n assert candidate(pizza = ['A..', '...', 'A..', '...', 'A..'],k = 3) == 4\n assert candidate(pizza = ['AA.AA', 'A...A', 'A...A', 'AA.AA'],k = 3) == 32\n assert candidate(pizza = ['A.....A', 'A.....A', 'A.....A', 'A.....A', 'A.....A'],k = 2) == 10\n assert candidate(pizza = ['AA.', 'A..', '.AA'],k = 2) == 4\n assert candidate(pizza = ['A.A.A', 'A...A', 'A.A.A'],k = 3) == 21\n assert candidate(pizza = ['A....A', '......', '......', 'A....A'],k = 4) == 0\n assert candidate(pizza = ['AAA..', 'AAA..', 'AAA..'],k = 3) == 10\n assert candidate(pizza = ['...A', '...A', 'A...', 'A...'],k = 2) == 6\n assert candidate(pizza = ['A.A.A', 'A.A.A', 'A.A.A', 'A.A.A', 'A.A.A'],k = 4) == 124\n assert candidate(pizza = ['A....', '.....', '.....', '.....', 'A....'],k = 2) == 4\n assert candidate(pizza = ['A...', '.A..', '..A.', '...A'],k = 4) == 8\n assert candidate(pizza = ['.A.A.', 'A.A.A', '.A.A.', 'A.A.A', '.A.A.'],k = 6) == 256\n assert candidate(pizza = ['AAAAA', 'A...A', 'A...A', 'A...A', 'AAAAA'],k = 5) == 346\n assert candidate(pizza = ['A....', '.....', '.....', '.....', '.....'],k = 4) == 0\n assert candidate(pizza = ['A.A.A.A', '.A.A.A.', 'A.A.A.A'],k = 3) == 40\n assert candidate(pizza = ['A.A.A.A', 'A.A.A.A', 'A.A.A.A', 'A.A.A.A', 'A.A.A.A', 'A.A.A.A', 'A.A.A.A', 'A.A.A.A'],k = 8) == 15387\n assert candidate(pizza = ['A...', '.A.A', '....', 'A...'],k = 2) == 6\n assert candidate(pizza = ['A.A.A.A', '.A.A.', 'A.A.A.A', '.A.A.', 'A.A.A.A'],k = 6) == 0\n assert candidate(pizza = ['........', '...A....', '........', '........', '........', '........', '........', '........'],k = 2) == 0\n assert candidate(pizza = ['.A..A.', 'A..A..', '.A..A.', 'A..A..', '.A..A.'],k = 3) == 42\n assert candidate(pizza = ['A..A', '....', 'A..A', '....'],k = 3) == 12\n assert candidate(pizza = ['A.A.A', '.A.A.', 'A.A.A'],k = 3) == 23\n assert candidate(pizza = ['A.A.A.A', '.A.A.A.', 'A.A.A.A', '.A.A.A.'],k = 3) == 51\n assert candidate(pizza = ['AAAAA', 'A...A', 'A...A', 'A...A', 'AAAAA'],k = 4) == 152\n assert candidate(pizza = ['A......', 'A......', 'A......', '.......', '.......', '.......'],k = 2) == 2\n assert candidate(pizza = ['A.A', 'A.A', 'A.A', 'A.A', 'A.A'],k = 4) == 40\n assert candidate(pizza = ['A.A.A', 'A...A', 'A...A', 'A...A', 'A.A.A'],k = 5) == 209\n assert candidate(pizza = ['AAAAA', 'AAAAA', '.....', '.....', '.....'],k = 3) == 14\n assert candidate(pizza = ['A.A.A', '.A.A.', 'A.A.A'],k = 4) == 46\n assert candidate(pizza = ['A.A.A', '.....', 'A.A.A', '.....', 'A.A.A'],k = 5) == 96\n assert candidate(pizza = ['A.A.A.A', '.A.A.A.', 'A.A.A.A', '.A.A.A.', 'A.A.A.A', '.A.A.A.', 'A.A.A.A', '.A.A.A.'],k = 6) == 8692\n assert candidate(pizza = ['A.A..', '.A.A.', '..A.A'],k = 3) == 17\n assert candidate(pizza = ['A....', '.A...', '..A..'],k = 3) == 4\n assert candidate(pizza = ['A....', '..A..', '....A', '.....', '.....'],k = 4) == 0\n assert candidate(pizza = ['A.A.A.A', '.....', 'A.A.A.A', '.....', 'A.A.A.A'],k = 5) == 0\n"}, "metadata": {"canonical_parameter_names": ["pizza", "k"], "leetcode_dataset_entry_point": "Solution().ways", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int ways(vector& pizza, int k) {", "container": "Solution", "callable": "ways", "parameters": [{"name": "pizza", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1446, "task_id": "consecutive-characters", "difficulty": "Easy", "problem_description": "The power of the string is the maximum length of a non-empty substring that contains only one unique character.\nGiven a string s, return the power of s.\n \nExample 1:\n\nInput: s = \"leetcode\"\nOutput: 2\nExplanation: The substring \"ee\" is of length 2 with the character 'e' only.\n\nExample 2:\n\nInput: s = \"abbcccddddeeeeedcba\"\nOutput: 5\nExplanation: The substring \"eeeee\" is of length 5 with the character 'e' only.\n\n \nConstraints:\n\n1 <= s.length <= 500\ns consists of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 1\n assert candidate(s = \"tourist\") == 1\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"aabbbbccc\") == 4\n assert candidate(s = \"cccccaaaa\") == 5\n assert candidate(s = \"bbaaaaacccddddeeeefffggghhhiiijjjkkkllmmnnnooopppqqrrssttuuvvwwwxxxyyyzzz\") == 5\n assert candidate(s = \"leetcode\") == 2\n assert candidate(s = \"zzzzzzzzzz\") == 10\n assert candidate(s = \"hooray\") == 2\n assert candidate(s = \"ccbccbbbaaaa\") == 4\n assert candidate(s = \"triplepilloooooo\") == 6\n assert candidate(s = \"aabbbcccccdd\") == 5\n assert candidate(s = \"abcd\") == 1\n assert candidate(s = \"ccbccbb\") == 2\n assert candidate(s = \"aabbcc\") == 2\n assert candidate(s = \"cc\") == 2\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 2\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(s = \"abbcccddddeeeeedcba\") == 5\n assert candidate(s = \"abcdeffffffffghijklmnopqrstuvwxyz\") == 8\n assert candidate(s = \"aaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaab\") == 4\n assert candidate(s = \"pppppqqqqqrrrrrsssss\") == 5\n assert candidate(s = \"aaabbaaabbbaaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbaa\") == 4\n assert candidate(s = \"ababababababababababab\") == 1\n assert candidate(s = \"aaaaaaaaaaa\") == 11\n assert candidate(s = \"mmmmmmnnnnnnooooooppppppqqqqqqrrrrrrssssssttttttuuuuuuvvvvvvwwwwwwxxxxxxxxxyyyyyyzzzzzz\") == 9\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhiiijjjkkklllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 28\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 96\n assert candidate(s = \"aaaaaaabbbbbbcccccc\") == 7\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 1\n assert candidate(s = \"abcdefffffffffghijklmnopqrstuvwxyz\") == 9\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz\") == 4\n assert candidate(s = \"abacabadabacaba\") == 1\n assert candidate(s = \"aabbbccccdddddeeeeeeeeefffffffffggggggggggg\") == 11\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 188\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 1\n assert candidate(s = \"abcdddddddddddabcdddddddddddabcddddddddddd\") == 11\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbcccccccccc\") == 10\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 88\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 1\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 202\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\") == 180\n assert candidate(s = \"aabaaaaccaaaaabbb\") == 5\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == 10\n assert candidate(s = \"mnopqrstuvwxyzaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbccccccccccccccccccdddddddddddddddddddd\") == 26\n assert candidate(s = \"aabcccccaaaaddddddeeeeffffggggghhhhiiiiijjjjjkkkkklllllmmmmmnnnnnooooo\") == 6\n assert candidate(s = \"zzzzzyyyyyzzzzzzzzz\") == 9\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 1\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 1\n assert candidate(s = \"aabbaabbccbbccddeeffggffhhiiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 3\n assert candidate(s = \"aabbccddeeeefffbbbccc\") == 4\n assert candidate(s = \"aabbaaabbbaaaabbbaaabbaaaabbbaaaabbbaaabbaaaabbbaaaabbbaaabbaaaabbbaaaabbbaaabbaaaabbbaaaabbbaaabbaaaabbbaaaabbbaaabbaaaabbbaaaabbbaaabbaaaabbbaaaabbbaaabbaaaabbbaaaa\") == 4\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 152\n assert candidate(s = \"aaaaabbbbbccccccdddddeeeeeeffffffgggggghhhhhiiiiiijjjjjkkkkklllllmmmmmnnnnnooooo\") == 6\n assert candidate(s = \"abcabcabcabcabcabc\") == 1\n assert candidate(s = \"abccbaabccbaabccbaabccbaabccbaabccbaabccbaabccba\") == 2\n assert candidate(s = \"aabbbcccdddeeefffggghhh\") == 3\n assert candidate(s = \"zzzzzyyyyxxwwwwvvvuuutttsssrqqpponnmmllkkjjiihhggffeeddccbbaa\") == 5\n assert candidate(s = \"aaabbbcccddddeeeeffffggggg\") == 5\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 51\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 34\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzz\") == 6\n assert candidate(s = \"pppppaaaabbbbccccdddddeeeeeeeeeffffffggggggggggghhhhhhhhhiiiiiiiijjjjjjjkkkkkkllllllmmmmmmnnnnnoooooopppppqqqqrrrrsssttttuuuuuuuuuuuuvvvvvvvvvvvvvvvwwwwwwwwwwwxxxxxyyyyyyyyyyyyyzzzzzzzzzzzzzzzzz\") == 17\n assert candidate(s = \"aabbbccccdddddeeeee\") == 5\n assert candidate(s = \"abcabcabcabcabc\") == 1\n assert candidate(s = \"sssssssqqqqqqqqqqppppppooooonnnnnnmmmmmmm\") == 10\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababababab\") == 1\n assert candidate(s = \"mnonononoqpqrstuvwxyzzzzzzzz\") == 8\n assert candidate(s = \"aabbccddeeffaabbccddeeff\") == 2\n assert candidate(s = \"aabbbcccddddeeeeeffffffggggg\") == 6\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxPower", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxPower(string s) {", "container": "Solution", "callable": "maxPower", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1447, "task_id": "simplified-fractions", "difficulty": "Medium", "problem_description": "Given an integer n, return a list of all simplified fractions between 0 and 1 (exclusive) such that the denominator is less-than-or-equal-to n. You can return the answer in any order.\n \nExample 1:\n\nInput: n = 2\nOutput: [\"1/2\"]\nExplanation: \"1/2\" is the only unique fraction with a denominator less-than-or-equal-to 2.\n\nExample 2:\n\nInput: n = 3\nOutput: [\"1/2\",\"1/3\",\"2/3\"]\n\nExample 3:\n\nInput: n = 4\nOutput: [\"1/2\",\"1/3\",\"1/4\",\"2/3\",\"3/4\"]\nExplanation: \"2/4\" is not a simplified fraction because it can be simplified to \"1/2\".\n\n \nConstraints:\n\n1 <= n <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == ['1/2', '1/3', '2/3']\n assert candidate(n = 4) == ['1/2', '1/3', '1/4', '2/3', '3/4']\n assert candidate(n = 2) == ['1/2']\n assert candidate(n = 20) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '6/7', '6/11', '6/13', '6/17', '6/19', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '10/11', '10/13', '10/17', '10/19', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '12/13', '12/17', '12/19', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '14/15', '14/17', '14/19', '15/16', '15/17', '15/19', '16/17', '16/19', '17/18', '17/19', '17/20', '18/19', '19/20']\n assert candidate(n = 100) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '1/26', '1/27', '1/28', '1/29', '1/30', '1/31', '1/32', '1/33', '1/34', '1/35', '1/36', '1/37', '1/38', '1/39', '1/40', '1/41', '1/42', '1/43', '1/44', '1/45', '1/46', '1/47', '1/48', '1/49', '1/50', '1/51', '1/52', '1/53', '1/54', '1/55', '1/56', '1/57', '1/58', '1/59', '1/60', '1/61', '1/62', '1/63', '1/64', '1/65', '1/66', '1/67', '1/68', '1/69', '1/70', '1/71', '1/72', '1/73', '1/74', '1/75', '1/76', '1/77', '1/78', '1/79', '1/80', '1/81', '1/82', '1/83', '1/84', '1/85', '1/86', '1/87', '1/88', '1/89', '1/90', '1/91', '1/92', '1/93', '1/94', '1/95', '1/96', '1/97', '1/98', '1/99', '1/100', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '2/61', '2/63', '2/65', '2/67', '2/69', '2/71', '2/73', '2/75', '2/77', '2/79', '2/81', '2/83', '2/85', '2/87', '2/89', '2/91', '2/93', '2/95', '2/97', '2/99', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '3/61', '3/62', '3/64', '3/65', '3/67', '3/68', '3/70', '3/71', '3/73', '3/74', '3/76', '3/77', '3/79', '3/80', '3/82', '3/83', '3/85', '3/86', '3/88', '3/89', '3/91', '3/92', '3/94', '3/95', '3/97', '3/98', '3/100', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '4/61', '4/63', '4/65', '4/67', '4/69', '4/71', '4/73', '4/75', '4/77', '4/79', '4/81', '4/83', '4/85', '4/87', '4/89', '4/91', '4/93', '4/95', '4/97', '4/99', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '5/61', '5/62', '5/63', '5/64', '5/66', '5/67', '5/68', '5/69', '5/71', '5/72', '5/73', '5/74', '5/76', '5/77', '5/78', '5/79', '5/81', '5/82', '5/83', '5/84', '5/86', '5/87', '5/88', '5/89', '5/91', '5/92', '5/93', '5/94', '5/96', '5/97', '5/98', '5/99', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '6/61', '6/65', '6/67', '6/71', '6/73', '6/77', '6/79', '6/83', '6/85', '6/89', '6/91', '6/95', '6/97', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '7/61', '7/62', '7/64', '7/65', '7/66', '7/67', '7/68', '7/69', '7/71', '7/72', '7/73', '7/74', '7/75', '7/76', '7/78', '7/79', '7/80', '7/81', '7/82', '7/83', '7/85', '7/86', '7/87', '7/88', '7/89', '7/90', '7/92', '7/93', '7/94', '7/95', '7/96', '7/97', '7/99', '7/100', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '8/61', '8/63', '8/65', '8/67', '8/69', '8/71', '8/73', '8/75', '8/77', '8/79', '8/81', '8/83', '8/85', '8/87', '8/89', '8/91', '8/93', '8/95', '8/97', '8/99', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '9/61', '9/62', '9/64', '9/65', '9/67', '9/68', '9/70', '9/71', '9/73', '9/74', '9/76', '9/77', '9/79', '9/80', '9/82', '9/83', '9/85', '9/86', '9/88', '9/89', '9/91', '9/92', '9/94', '9/95', '9/97', '9/98', '9/100', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '10/61', '10/63', '10/67', '10/69', '10/71', '10/73', '10/77', '10/79', '10/81', '10/83', '10/87', '10/89', '10/91', '10/93', '10/97', '10/99', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '11/61', '11/62', '11/63', '11/64', '11/65', '11/67', '11/68', '11/69', '11/70', '11/71', '11/72', '11/73', '11/74', '11/75', '11/76', '11/78', '11/79', '11/80', '11/81', '11/82', '11/83', '11/84', '11/85', '11/86', '11/87', '11/89', '11/90', '11/91', '11/92', '11/93', '11/94', '11/95', '11/96', '11/97', '11/98', '11/100', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '12/61', '12/65', '12/67', '12/71', '12/73', '12/77', '12/79', '12/83', '12/85', '12/89', '12/91', '12/95', '12/97', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '13/61', '13/62', '13/63', '13/64', '13/66', '13/67', '13/68', '13/69', '13/70', '13/71', '13/72', '13/73', '13/74', '13/75', '13/76', '13/77', '13/79', '13/80', '13/81', '13/82', '13/83', '13/84', '13/85', '13/86', '13/87', '13/88', '13/89', '13/90', '13/92', '13/93', '13/94', '13/95', '13/96', '13/97', '13/98', '13/99', '13/100', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '14/61', '14/65', '14/67', '14/69', '14/71', '14/73', '14/75', '14/79', '14/81', '14/83', '14/85', '14/87', '14/89', '14/93', '14/95', '14/97', '14/99', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '15/61', '15/62', '15/64', '15/67', '15/68', '15/71', '15/73', '15/74', '15/76', '15/77', '15/79', '15/82', '15/83', '15/86', '15/88', '15/89', '15/91', '15/92', '15/94', '15/97', '15/98', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '16/61', '16/63', '16/65', '16/67', '16/69', '16/71', '16/73', '16/75', '16/77', '16/79', '16/81', '16/83', '16/85', '16/87', '16/89', '16/91', '16/93', '16/95', '16/97', '16/99', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '17/61', '17/62', '17/63', '17/64', '17/65', '17/66', '17/67', '17/69', '17/70', '17/71', '17/72', '17/73', '17/74', '17/75', '17/76', '17/77', '17/78', '17/79', '17/80', '17/81', '17/82', '17/83', '17/84', '17/86', '17/87', '17/88', '17/89', '17/90', '17/91', '17/92', '17/93', '17/94', '17/95', '17/96', '17/97', '17/98', '17/99', '17/100', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '18/61', '18/65', '18/67', '18/71', '18/73', '18/77', '18/79', '18/83', '18/85', '18/89', '18/91', '18/95', '18/97', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '19/61', '19/62', '19/63', '19/64', '19/65', '19/66', '19/67', '19/68', '19/69', '19/70', '19/71', '19/72', '19/73', '19/74', '19/75', '19/77', '19/78', '19/79', '19/80', '19/81', '19/82', '19/83', '19/84', '19/85', '19/86', '19/87', '19/88', '19/89', '19/90', '19/91', '19/92', '19/93', '19/94', '19/96', '19/97', '19/98', '19/99', '19/100', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '20/61', '20/63', '20/67', '20/69', '20/71', '20/73', '20/77', '20/79', '20/81', '20/83', '20/87', '20/89', '20/91', '20/93', '20/97', '20/99', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '21/61', '21/62', '21/64', '21/65', '21/67', '21/68', '21/71', '21/73', '21/74', '21/76', '21/79', '21/80', '21/82', '21/83', '21/85', '21/86', '21/88', '21/89', '21/92', '21/94', '21/95', '21/97', '21/100', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '22/61', '22/63', '22/65', '22/67', '22/69', '22/71', '22/73', '22/75', '22/79', '22/81', '22/83', '22/85', '22/87', '22/89', '22/91', '22/93', '22/95', '22/97', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '23/61', '23/62', '23/63', '23/64', '23/65', '23/66', '23/67', '23/68', '23/70', '23/71', '23/72', '23/73', '23/74', '23/75', '23/76', '23/77', '23/78', '23/79', '23/80', '23/81', '23/82', '23/83', '23/84', '23/85', '23/86', '23/87', '23/88', '23/89', '23/90', '23/91', '23/93', '23/94', '23/95', '23/96', '23/97', '23/98', '23/99', '23/100', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '24/61', '24/65', '24/67', '24/71', '24/73', '24/77', '24/79', '24/83', '24/85', '24/89', '24/91', '24/95', '24/97', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '25/61', '25/62', '25/63', '25/64', '25/66', '25/67', '25/68', '25/69', '25/71', '25/72', '25/73', '25/74', '25/76', '25/77', '25/78', '25/79', '25/81', '25/82', '25/83', '25/84', '25/86', '25/87', '25/88', '25/89', '25/91', '25/92', '25/93', '25/94', '25/96', '25/97', '25/98', '25/99', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '26/61', '26/63', '26/67', '26/69', '26/71', '26/73', '26/75', '26/77', '26/79', '26/81', '26/83', '26/85', '26/87', '26/89', '26/93', '26/95', '26/97', '26/99', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '27/61', '27/62', '27/64', '27/65', '27/67', '27/68', '27/70', '27/71', '27/73', '27/74', '27/76', '27/77', '27/79', '27/80', '27/82', '27/83', '27/85', '27/86', '27/88', '27/89', '27/91', '27/92', '27/94', '27/95', '27/97', '27/98', '27/100', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '28/61', '28/65', '28/67', '28/69', '28/71', '28/73', '28/75', '28/79', '28/81', '28/83', '28/85', '28/87', '28/89', '28/93', '28/95', '28/97', '28/99', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '29/61', '29/62', '29/63', '29/64', '29/65', '29/66', '29/67', '29/68', '29/69', '29/70', '29/71', '29/72', '29/73', '29/74', '29/75', '29/76', '29/77', '29/78', '29/79', '29/80', '29/81', '29/82', '29/83', '29/84', '29/85', '29/86', '29/88', '29/89', '29/90', '29/91', '29/92', '29/93', '29/94', '29/95', '29/96', '29/97', '29/98', '29/99', '29/100', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '30/61', '30/67', '30/71', '30/73', '30/77', '30/79', '30/83', '30/89', '30/91', '30/97', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '31/61', '31/63', '31/64', '31/65', '31/66', '31/67', '31/68', '31/69', '31/70', '31/71', '31/72', '31/73', '31/74', '31/75', '31/76', '31/77', '31/78', '31/79', '31/80', '31/81', '31/82', '31/83', '31/84', '31/85', '31/86', '31/87', '31/88', '31/89', '31/90', '31/91', '31/92', '31/94', '31/95', '31/96', '31/97', '31/98', '31/99', '31/100', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '32/61', '32/63', '32/65', '32/67', '32/69', '32/71', '32/73', '32/75', '32/77', '32/79', '32/81', '32/83', '32/85', '32/87', '32/89', '32/91', '32/93', '32/95', '32/97', '32/99', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '33/61', '33/62', '33/64', '33/65', '33/67', '33/68', '33/70', '33/71', '33/73', '33/74', '33/76', '33/79', '33/80', '33/82', '33/83', '33/85', '33/86', '33/89', '33/91', '33/92', '33/94', '33/95', '33/97', '33/98', '33/100', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '34/61', '34/63', '34/65', '34/67', '34/69', '34/71', '34/73', '34/75', '34/77', '34/79', '34/81', '34/83', '34/87', '34/89', '34/91', '34/93', '34/95', '34/97', '34/99', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '35/61', '35/62', '35/64', '35/66', '35/67', '35/68', '35/69', '35/71', '35/72', '35/73', '35/74', '35/76', '35/78', '35/79', '35/81', '35/82', '35/83', '35/86', '35/87', '35/88', '35/89', '35/92', '35/93', '35/94', '35/96', '35/97', '35/99', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '36/61', '36/65', '36/67', '36/71', '36/73', '36/77', '36/79', '36/83', '36/85', '36/89', '36/91', '36/95', '36/97', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '37/61', '37/62', '37/63', '37/64', '37/65', '37/66', '37/67', '37/68', '37/69', '37/70', '37/71', '37/72', '37/73', '37/75', '37/76', '37/77', '37/78', '37/79', '37/80', '37/81', '37/82', '37/83', '37/84', '37/85', '37/86', '37/87', '37/88', '37/89', '37/90', '37/91', '37/92', '37/93', '37/94', '37/95', '37/96', '37/97', '37/98', '37/99', '37/100', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '38/61', '38/63', '38/65', '38/67', '38/69', '38/71', '38/73', '38/75', '38/77', '38/79', '38/81', '38/83', '38/85', '38/87', '38/89', '38/91', '38/93', '38/97', '38/99', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '39/61', '39/62', '39/64', '39/67', '39/68', '39/70', '39/71', '39/73', '39/74', '39/76', '39/77', '39/79', '39/80', '39/82', '39/83', '39/85', '39/86', '39/88', '39/89', '39/92', '39/94', '39/95', '39/97', '39/98', '39/100', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '40/61', '40/63', '40/67', '40/69', '40/71', '40/73', '40/77', '40/79', '40/81', '40/83', '40/87', '40/89', '40/91', '40/93', '40/97', '40/99', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '41/61', '41/62', '41/63', '41/64', '41/65', '41/66', '41/67', '41/68', '41/69', '41/70', '41/71', '41/72', '41/73', '41/74', '41/75', '41/76', '41/77', '41/78', '41/79', '41/80', '41/81', '41/83', '41/84', '41/85', '41/86', '41/87', '41/88', '41/89', '41/90', '41/91', '41/92', '41/93', '41/94', '41/95', '41/96', '41/97', '41/98', '41/99', '41/100', '42/43', '42/47', '42/53', '42/55', '42/59', '42/61', '42/65', '42/67', '42/71', '42/73', '42/79', '42/83', '42/85', '42/89', '42/95', '42/97', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '43/61', '43/62', '43/63', '43/64', '43/65', '43/66', '43/67', '43/68', '43/69', '43/70', '43/71', '43/72', '43/73', '43/74', '43/75', '43/76', '43/77', '43/78', '43/79', '43/80', '43/81', '43/82', '43/83', '43/84', '43/85', '43/87', '43/88', '43/89', '43/90', '43/91', '43/92', '43/93', '43/94', '43/95', '43/96', '43/97', '43/98', '43/99', '43/100', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '44/61', '44/63', '44/65', '44/67', '44/69', '44/71', '44/73', '44/75', '44/79', '44/81', '44/83', '44/85', '44/87', '44/89', '44/91', '44/93', '44/95', '44/97', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '45/61', '45/62', '45/64', '45/67', '45/68', '45/71', '45/73', '45/74', '45/76', '45/77', '45/79', '45/82', '45/83', '45/86', '45/88', '45/89', '45/91', '45/92', '45/94', '45/97', '45/98', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '46/61', '46/63', '46/65', '46/67', '46/71', '46/73', '46/75', '46/77', '46/79', '46/81', '46/83', '46/85', '46/87', '46/89', '46/91', '46/93', '46/95', '46/97', '46/99', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '47/61', '47/62', '47/63', '47/64', '47/65', '47/66', '47/67', '47/68', '47/69', '47/70', '47/71', '47/72', '47/73', '47/74', '47/75', '47/76', '47/77', '47/78', '47/79', '47/80', '47/81', '47/82', '47/83', '47/84', '47/85', '47/86', '47/87', '47/88', '47/89', '47/90', '47/91', '47/92', '47/93', '47/95', '47/96', '47/97', '47/98', '47/99', '47/100', '48/49', '48/53', '48/55', '48/59', '48/61', '48/65', '48/67', '48/71', '48/73', '48/77', '48/79', '48/83', '48/85', '48/89', '48/91', '48/95', '48/97', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '49/61', '49/62', '49/64', '49/65', '49/66', '49/67', '49/68', '49/69', '49/71', '49/72', '49/73', '49/74', '49/75', '49/76', '49/78', '49/79', '49/80', '49/81', '49/82', '49/83', '49/85', '49/86', '49/87', '49/88', '49/89', '49/90', '49/92', '49/93', '49/94', '49/95', '49/96', '49/97', '49/99', '49/100', '50/51', '50/53', '50/57', '50/59', '50/61', '50/63', '50/67', '50/69', '50/71', '50/73', '50/77', '50/79', '50/81', '50/83', '50/87', '50/89', '50/91', '50/93', '50/97', '50/99', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '51/61', '51/62', '51/64', '51/65', '51/67', '51/70', '51/71', '51/73', '51/74', '51/76', '51/77', '51/79', '51/80', '51/82', '51/83', '51/86', '51/88', '51/89', '51/91', '51/92', '51/94', '51/95', '51/97', '51/98', '51/100', '52/53', '52/55', '52/57', '52/59', '52/61', '52/63', '52/67', '52/69', '52/71', '52/73', '52/75', '52/77', '52/79', '52/81', '52/83', '52/85', '52/87', '52/89', '52/93', '52/95', '52/97', '52/99', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '53/61', '53/62', '53/63', '53/64', '53/65', '53/66', '53/67', '53/68', '53/69', '53/70', '53/71', '53/72', '53/73', '53/74', '53/75', '53/76', '53/77', '53/78', '53/79', '53/80', '53/81', '53/82', '53/83', '53/84', '53/85', '53/86', '53/87', '53/88', '53/89', '53/90', '53/91', '53/92', '53/93', '53/94', '53/95', '53/96', '53/97', '53/98', '53/99', '53/100', '54/55', '54/59', '54/61', '54/65', '54/67', '54/71', '54/73', '54/77', '54/79', '54/83', '54/85', '54/89', '54/91', '54/95', '54/97', '55/56', '55/57', '55/58', '55/59', '55/61', '55/62', '55/63', '55/64', '55/67', '55/68', '55/69', '55/71', '55/72', '55/73', '55/74', '55/76', '55/78', '55/79', '55/81', '55/82', '55/83', '55/84', '55/86', '55/87', '55/89', '55/91', '55/92', '55/93', '55/94', '55/96', '55/97', '55/98', '56/57', '56/59', '56/61', '56/65', '56/67', '56/69', '56/71', '56/73', '56/75', '56/79', '56/81', '56/83', '56/85', '56/87', '56/89', '56/93', '56/95', '56/97', '56/99', '57/58', '57/59', '57/61', '57/62', '57/64', '57/65', '57/67', '57/68', '57/70', '57/71', '57/73', '57/74', '57/77', '57/79', '57/80', '57/82', '57/83', '57/85', '57/86', '57/88', '57/89', '57/91', '57/92', '57/94', '57/97', '57/98', '57/100', '58/59', '58/61', '58/63', '58/65', '58/67', '58/69', '58/71', '58/73', '58/75', '58/77', '58/79', '58/81', '58/83', '58/85', '58/89', '58/91', '58/93', '58/95', '58/97', '58/99', '59/60', '59/61', '59/62', '59/63', '59/64', '59/65', '59/66', '59/67', '59/68', '59/69', '59/70', '59/71', '59/72', '59/73', '59/74', '59/75', '59/76', '59/77', '59/78', '59/79', '59/80', '59/81', '59/82', '59/83', '59/84', '59/85', '59/86', '59/87', '59/88', '59/89', '59/90', '59/91', '59/92', '59/93', '59/94', '59/95', '59/96', '59/97', '59/98', '59/99', '59/100', '60/61', '60/67', '60/71', '60/73', '60/77', '60/79', '60/83', '60/89', '60/91', '60/97', '61/62', '61/63', '61/64', '61/65', '61/66', '61/67', '61/68', '61/69', '61/70', '61/71', '61/72', '61/73', '61/74', '61/75', '61/76', '61/77', '61/78', '61/79', '61/80', '61/81', '61/82', '61/83', '61/84', '61/85', '61/86', '61/87', '61/88', '61/89', '61/90', '61/91', '61/92', '61/93', '61/94', '61/95', '61/96', '61/97', '61/98', '61/99', '61/100', '62/63', '62/65', '62/67', '62/69', '62/71', '62/73', '62/75', '62/77', '62/79', '62/81', '62/83', '62/85', '62/87', '62/89', '62/91', '62/95', '62/97', '62/99', '63/64', '63/65', '63/67', '63/68', '63/71', '63/73', '63/74', '63/76', '63/79', '63/80', '63/82', '63/83', '63/85', '63/86', '63/88', '63/89', '63/92', '63/94', '63/95', '63/97', '63/100', '64/65', '64/67', '64/69', '64/71', '64/73', '64/75', '64/77', '64/79', '64/81', '64/83', '64/85', '64/87', '64/89', '64/91', '64/93', '64/95', '64/97', '64/99', '65/66', '65/67', '65/68', '65/69', '65/71', '65/72', '65/73', '65/74', '65/76', '65/77', '65/79', '65/81', '65/82', '65/83', '65/84', '65/86', '65/87', '65/88', '65/89', '65/92', '65/93', '65/94', '65/96', '65/97', '65/98', '65/99', '66/67', '66/71', '66/73', '66/79', '66/83', '66/85', '66/89', '66/91', '66/95', '66/97', '67/68', '67/69', '67/70', '67/71', '67/72', '67/73', '67/74', '67/75', '67/76', '67/77', '67/78', '67/79', '67/80', '67/81', '67/82', '67/83', '67/84', '67/85', '67/86', '67/87', '67/88', '67/89', '67/90', '67/91', '67/92', '67/93', '67/94', '67/95', '67/96', '67/97', '67/98', '67/99', '67/100', '68/69', '68/71', '68/73', '68/75', '68/77', '68/79', '68/81', '68/83', '68/87', '68/89', '68/91', '68/93', '68/95', '68/97', '68/99', '69/70', '69/71', '69/73', '69/74', '69/76', '69/77', '69/79', '69/80', '69/82', '69/83', '69/85', '69/86', '69/88', '69/89', '69/91', '69/94', '69/95', '69/97', '69/98', '69/100', '70/71', '70/73', '70/79', '70/81', '70/83', '70/87', '70/89', '70/93', '70/97', '70/99', '71/72', '71/73', '71/74', '71/75', '71/76', '71/77', '71/78', '71/79', '71/80', '71/81', '71/82', '71/83', '71/84', '71/85', '71/86', '71/87', '71/88', '71/89', '71/90', '71/91', '71/92', '71/93', '71/94', '71/95', '71/96', '71/97', '71/98', '71/99', '71/100', '72/73', '72/77', '72/79', '72/83', '72/85', '72/89', '72/91', '72/95', '72/97', '73/74', '73/75', '73/76', '73/77', '73/78', '73/79', '73/80', '73/81', '73/82', '73/83', '73/84', '73/85', '73/86', '73/87', '73/88', '73/89', '73/90', '73/91', '73/92', '73/93', '73/94', '73/95', '73/96', '73/97', '73/98', '73/99', '73/100', '74/75', '74/77', '74/79', '74/81', '74/83', '74/85', '74/87', '74/89', '74/91', '74/93', '74/95', '74/97', '74/99', '75/76', '75/77', '75/79', '75/82', '75/83', '75/86', '75/88', '75/89', '75/91', '75/92', '75/94', '75/97', '75/98', '76/77', '76/79', '76/81', '76/83', '76/85', '76/87', '76/89', '76/91', '76/93', '76/97', '76/99', '77/78', '77/79', '77/80', '77/81', '77/82', '77/83', '77/85', '77/86', '77/87', '77/89', '77/90', '77/92', '77/93', '77/94', '77/95', '77/96', '77/97', '77/100', '78/79', '78/83', '78/85', '78/89', '78/95', '78/97', '79/80', '79/81', '79/82', '79/83', '79/84', '79/85', '79/86', '79/87', '79/88', '79/89', '79/90', '79/91', '79/92', '79/93', '79/94', '79/95', '79/96', '79/97', '79/98', '79/99', '79/100', '80/81', '80/83', '80/87', '80/89', '80/91', '80/93', '80/97', '80/99', '81/82', '81/83', '81/85', '81/86', '81/88', '81/89', '81/91', '81/92', '81/94', '81/95', '81/97', '81/98', '81/100', '82/83', '82/85', '82/87', '82/89', '82/91', '82/93', '82/95', '82/97', '82/99', '83/84', '83/85', '83/86', '83/87', '83/88', '83/89', '83/90', '83/91', '83/92', '83/93', '83/94', '83/95', '83/96', '83/97', '83/98', '83/99', '83/100', '84/85', '84/89', '84/95', '84/97', '85/86', '85/87', '85/88', '85/89', '85/91', '85/92', '85/93', '85/94', '85/96', '85/97', '85/98', '85/99', '86/87', '86/89', '86/91', '86/93', '86/95', '86/97', '86/99', '87/88', '87/89', '87/91', '87/92', '87/94', '87/95', '87/97', '87/98', '87/100', '88/89', '88/91', '88/93', '88/95', '88/97', '89/90', '89/91', '89/92', '89/93', '89/94', '89/95', '89/96', '89/97', '89/98', '89/99', '89/100', '90/91', '90/97', '91/92', '91/93', '91/94', '91/95', '91/96', '91/97', '91/99', '91/100', '92/93', '92/95', '92/97', '92/99', '93/94', '93/95', '93/97', '93/98', '93/100', '94/95', '94/97', '94/99', '95/96', '95/97', '95/98', '95/99', '96/97', '97/98', '97/99', '97/100', '98/99', '99/100']\n assert candidate(n = 50) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '1/26', '1/27', '1/28', '1/29', '1/30', '1/31', '1/32', '1/33', '1/34', '1/35', '1/36', '1/37', '1/38', '1/39', '1/40', '1/41', '1/42', '1/43', '1/44', '1/45', '1/46', '1/47', '1/48', '1/49', '1/50', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '36/37', '36/41', '36/43', '36/47', '36/49', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '40/41', '40/43', '40/47', '40/49', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '42/43', '42/47', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '44/45', '44/47', '44/49', '45/46', '45/47', '45/49', '46/47', '46/49', '47/48', '47/49', '47/50', '48/49', '49/50']\n assert candidate(n = 10) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '2/3', '2/5', '2/7', '2/9', '3/4', '3/5', '3/7', '3/8', '3/10', '4/5', '4/7', '4/9', '5/6', '5/7', '5/8', '5/9', '6/7', '7/8', '7/9', '7/10', '8/9', '9/10']\n assert candidate(n = 5) == ['1/2', '1/3', '1/4', '1/5', '2/3', '2/5', '3/4', '3/5', '4/5']\n assert candidate(n = 97) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '1/26', '1/27', '1/28', '1/29', '1/30', '1/31', '1/32', '1/33', '1/34', '1/35', '1/36', '1/37', '1/38', '1/39', '1/40', '1/41', '1/42', '1/43', '1/44', '1/45', '1/46', '1/47', '1/48', '1/49', '1/50', '1/51', '1/52', '1/53', '1/54', '1/55', '1/56', '1/57', '1/58', '1/59', '1/60', '1/61', '1/62', '1/63', '1/64', '1/65', '1/66', '1/67', '1/68', '1/69', '1/70', '1/71', '1/72', '1/73', '1/74', '1/75', '1/76', '1/77', '1/78', '1/79', '1/80', '1/81', '1/82', '1/83', '1/84', '1/85', '1/86', '1/87', '1/88', '1/89', '1/90', '1/91', '1/92', '1/93', '1/94', '1/95', '1/96', '1/97', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '2/61', '2/63', '2/65', '2/67', '2/69', '2/71', '2/73', '2/75', '2/77', '2/79', '2/81', '2/83', '2/85', '2/87', '2/89', '2/91', '2/93', '2/95', '2/97', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '3/61', '3/62', '3/64', '3/65', '3/67', '3/68', '3/70', '3/71', '3/73', '3/74', '3/76', '3/77', '3/79', '3/80', '3/82', '3/83', '3/85', '3/86', '3/88', '3/89', '3/91', '3/92', '3/94', '3/95', '3/97', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '4/61', '4/63', '4/65', '4/67', '4/69', '4/71', '4/73', '4/75', '4/77', '4/79', '4/81', '4/83', '4/85', '4/87', '4/89', '4/91', '4/93', '4/95', '4/97', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '5/61', '5/62', '5/63', '5/64', '5/66', '5/67', '5/68', '5/69', '5/71', '5/72', '5/73', '5/74', '5/76', '5/77', '5/78', '5/79', '5/81', '5/82', '5/83', '5/84', '5/86', '5/87', '5/88', '5/89', '5/91', '5/92', '5/93', '5/94', '5/96', '5/97', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '6/61', '6/65', '6/67', '6/71', '6/73', '6/77', '6/79', '6/83', '6/85', '6/89', '6/91', '6/95', '6/97', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '7/61', '7/62', '7/64', '7/65', '7/66', '7/67', '7/68', '7/69', '7/71', '7/72', '7/73', '7/74', '7/75', '7/76', '7/78', '7/79', '7/80', '7/81', '7/82', '7/83', '7/85', '7/86', '7/87', '7/88', '7/89', '7/90', '7/92', '7/93', '7/94', '7/95', '7/96', '7/97', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '8/61', '8/63', '8/65', '8/67', '8/69', '8/71', '8/73', '8/75', '8/77', '8/79', '8/81', '8/83', '8/85', '8/87', '8/89', '8/91', '8/93', '8/95', '8/97', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '9/61', '9/62', '9/64', '9/65', '9/67', '9/68', '9/70', '9/71', '9/73', '9/74', '9/76', '9/77', '9/79', '9/80', '9/82', '9/83', '9/85', '9/86', '9/88', '9/89', '9/91', '9/92', '9/94', '9/95', '9/97', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '10/61', '10/63', '10/67', '10/69', '10/71', '10/73', '10/77', '10/79', '10/81', '10/83', '10/87', '10/89', '10/91', '10/93', '10/97', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '11/61', '11/62', '11/63', '11/64', '11/65', '11/67', '11/68', '11/69', '11/70', '11/71', '11/72', '11/73', '11/74', '11/75', '11/76', '11/78', '11/79', '11/80', '11/81', '11/82', '11/83', '11/84', '11/85', '11/86', '11/87', '11/89', '11/90', '11/91', '11/92', '11/93', '11/94', '11/95', '11/96', '11/97', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '12/61', '12/65', '12/67', '12/71', '12/73', '12/77', '12/79', '12/83', '12/85', '12/89', '12/91', '12/95', '12/97', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '13/61', '13/62', '13/63', '13/64', '13/66', '13/67', '13/68', '13/69', '13/70', '13/71', '13/72', '13/73', '13/74', '13/75', '13/76', '13/77', '13/79', '13/80', '13/81', '13/82', '13/83', '13/84', '13/85', '13/86', '13/87', '13/88', '13/89', '13/90', '13/92', '13/93', '13/94', '13/95', '13/96', '13/97', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '14/61', '14/65', '14/67', '14/69', '14/71', '14/73', '14/75', '14/79', '14/81', '14/83', '14/85', '14/87', '14/89', '14/93', '14/95', '14/97', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '15/61', '15/62', '15/64', '15/67', '15/68', '15/71', '15/73', '15/74', '15/76', '15/77', '15/79', '15/82', '15/83', '15/86', '15/88', '15/89', '15/91', '15/92', '15/94', '15/97', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '16/61', '16/63', '16/65', '16/67', '16/69', '16/71', '16/73', '16/75', '16/77', '16/79', '16/81', '16/83', '16/85', '16/87', '16/89', '16/91', '16/93', '16/95', '16/97', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '17/61', '17/62', '17/63', '17/64', '17/65', '17/66', '17/67', '17/69', '17/70', '17/71', '17/72', '17/73', '17/74', '17/75', '17/76', '17/77', '17/78', '17/79', '17/80', '17/81', '17/82', '17/83', '17/84', '17/86', '17/87', '17/88', '17/89', '17/90', '17/91', '17/92', '17/93', '17/94', '17/95', '17/96', '17/97', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '18/61', '18/65', '18/67', '18/71', '18/73', '18/77', '18/79', '18/83', '18/85', '18/89', '18/91', '18/95', '18/97', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '19/61', '19/62', '19/63', '19/64', '19/65', '19/66', '19/67', '19/68', '19/69', '19/70', '19/71', '19/72', '19/73', '19/74', '19/75', '19/77', '19/78', '19/79', '19/80', '19/81', '19/82', '19/83', '19/84', '19/85', '19/86', '19/87', '19/88', '19/89', '19/90', '19/91', '19/92', '19/93', '19/94', '19/96', '19/97', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '20/61', '20/63', '20/67', '20/69', '20/71', '20/73', '20/77', '20/79', '20/81', '20/83', '20/87', '20/89', '20/91', '20/93', '20/97', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '21/61', '21/62', '21/64', '21/65', '21/67', '21/68', '21/71', '21/73', '21/74', '21/76', '21/79', '21/80', '21/82', '21/83', '21/85', '21/86', '21/88', '21/89', '21/92', '21/94', '21/95', '21/97', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '22/61', '22/63', '22/65', '22/67', '22/69', '22/71', '22/73', '22/75', '22/79', '22/81', '22/83', '22/85', '22/87', '22/89', '22/91', '22/93', '22/95', '22/97', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '23/61', '23/62', '23/63', '23/64', '23/65', '23/66', '23/67', '23/68', '23/70', '23/71', '23/72', '23/73', '23/74', '23/75', '23/76', '23/77', '23/78', '23/79', '23/80', '23/81', '23/82', '23/83', '23/84', '23/85', '23/86', '23/87', '23/88', '23/89', '23/90', '23/91', '23/93', '23/94', '23/95', '23/96', '23/97', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '24/61', '24/65', '24/67', '24/71', '24/73', '24/77', '24/79', '24/83', '24/85', '24/89', '24/91', '24/95', '24/97', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '25/61', '25/62', '25/63', '25/64', '25/66', '25/67', '25/68', '25/69', '25/71', '25/72', '25/73', '25/74', '25/76', '25/77', '25/78', '25/79', '25/81', '25/82', '25/83', '25/84', '25/86', '25/87', '25/88', '25/89', '25/91', '25/92', '25/93', '25/94', '25/96', '25/97', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '26/61', '26/63', '26/67', '26/69', '26/71', '26/73', '26/75', '26/77', '26/79', '26/81', '26/83', '26/85', '26/87', '26/89', '26/93', '26/95', '26/97', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '27/61', '27/62', '27/64', '27/65', '27/67', '27/68', '27/70', '27/71', '27/73', '27/74', '27/76', '27/77', '27/79', '27/80', '27/82', '27/83', '27/85', '27/86', '27/88', '27/89', '27/91', '27/92', '27/94', '27/95', '27/97', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '28/61', '28/65', '28/67', '28/69', '28/71', '28/73', '28/75', '28/79', '28/81', '28/83', '28/85', '28/87', '28/89', '28/93', '28/95', '28/97', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '29/61', '29/62', '29/63', '29/64', '29/65', '29/66', '29/67', '29/68', '29/69', '29/70', '29/71', '29/72', '29/73', '29/74', '29/75', '29/76', '29/77', '29/78', '29/79', '29/80', '29/81', '29/82', '29/83', '29/84', '29/85', '29/86', '29/88', '29/89', '29/90', '29/91', '29/92', '29/93', '29/94', '29/95', '29/96', '29/97', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '30/61', '30/67', '30/71', '30/73', '30/77', '30/79', '30/83', '30/89', '30/91', '30/97', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '31/61', '31/63', '31/64', '31/65', '31/66', '31/67', '31/68', '31/69', '31/70', '31/71', '31/72', '31/73', '31/74', '31/75', '31/76', '31/77', '31/78', '31/79', '31/80', '31/81', '31/82', '31/83', '31/84', '31/85', '31/86', '31/87', '31/88', '31/89', '31/90', '31/91', '31/92', '31/94', '31/95', '31/96', '31/97', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '32/61', '32/63', '32/65', '32/67', '32/69', '32/71', '32/73', '32/75', '32/77', '32/79', '32/81', '32/83', '32/85', '32/87', '32/89', '32/91', '32/93', '32/95', '32/97', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '33/61', '33/62', '33/64', '33/65', '33/67', '33/68', '33/70', '33/71', '33/73', '33/74', '33/76', '33/79', '33/80', '33/82', '33/83', '33/85', '33/86', '33/89', '33/91', '33/92', '33/94', '33/95', '33/97', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '34/61', '34/63', '34/65', '34/67', '34/69', '34/71', '34/73', '34/75', '34/77', '34/79', '34/81', '34/83', '34/87', '34/89', '34/91', '34/93', '34/95', '34/97', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '35/61', '35/62', '35/64', '35/66', '35/67', '35/68', '35/69', '35/71', '35/72', '35/73', '35/74', '35/76', '35/78', '35/79', '35/81', '35/82', '35/83', '35/86', '35/87', '35/88', '35/89', '35/92', '35/93', '35/94', '35/96', '35/97', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '36/61', '36/65', '36/67', '36/71', '36/73', '36/77', '36/79', '36/83', '36/85', '36/89', '36/91', '36/95', '36/97', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '37/61', '37/62', '37/63', '37/64', '37/65', '37/66', '37/67', '37/68', '37/69', '37/70', '37/71', '37/72', '37/73', '37/75', '37/76', '37/77', '37/78', '37/79', '37/80', '37/81', '37/82', '37/83', '37/84', '37/85', '37/86', '37/87', '37/88', '37/89', '37/90', '37/91', '37/92', '37/93', '37/94', '37/95', '37/96', '37/97', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '38/61', '38/63', '38/65', '38/67', '38/69', '38/71', '38/73', '38/75', '38/77', '38/79', '38/81', '38/83', '38/85', '38/87', '38/89', '38/91', '38/93', '38/97', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '39/61', '39/62', '39/64', '39/67', '39/68', '39/70', '39/71', '39/73', '39/74', '39/76', '39/77', '39/79', '39/80', '39/82', '39/83', '39/85', '39/86', '39/88', '39/89', '39/92', '39/94', '39/95', '39/97', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '40/61', '40/63', '40/67', '40/69', '40/71', '40/73', '40/77', '40/79', '40/81', '40/83', '40/87', '40/89', '40/91', '40/93', '40/97', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '41/61', '41/62', '41/63', '41/64', '41/65', '41/66', '41/67', '41/68', '41/69', '41/70', '41/71', '41/72', '41/73', '41/74', '41/75', '41/76', '41/77', '41/78', '41/79', '41/80', '41/81', '41/83', '41/84', '41/85', '41/86', '41/87', '41/88', '41/89', '41/90', '41/91', '41/92', '41/93', '41/94', '41/95', '41/96', '41/97', '42/43', '42/47', '42/53', '42/55', '42/59', '42/61', '42/65', '42/67', '42/71', '42/73', '42/79', '42/83', '42/85', '42/89', '42/95', '42/97', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '43/61', '43/62', '43/63', '43/64', '43/65', '43/66', '43/67', '43/68', '43/69', '43/70', '43/71', '43/72', '43/73', '43/74', '43/75', '43/76', '43/77', '43/78', '43/79', '43/80', '43/81', '43/82', '43/83', '43/84', '43/85', '43/87', '43/88', '43/89', '43/90', '43/91', '43/92', '43/93', '43/94', '43/95', '43/96', '43/97', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '44/61', '44/63', '44/65', '44/67', '44/69', '44/71', '44/73', '44/75', '44/79', '44/81', '44/83', '44/85', '44/87', '44/89', '44/91', '44/93', '44/95', '44/97', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '45/61', '45/62', '45/64', '45/67', '45/68', '45/71', '45/73', '45/74', '45/76', '45/77', '45/79', '45/82', '45/83', '45/86', '45/88', '45/89', '45/91', '45/92', '45/94', '45/97', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '46/61', '46/63', '46/65', '46/67', '46/71', '46/73', '46/75', '46/77', '46/79', '46/81', '46/83', '46/85', '46/87', '46/89', '46/91', '46/93', '46/95', '46/97', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '47/61', '47/62', '47/63', '47/64', '47/65', '47/66', '47/67', '47/68', '47/69', '47/70', '47/71', '47/72', '47/73', '47/74', '47/75', '47/76', '47/77', '47/78', '47/79', '47/80', '47/81', '47/82', '47/83', '47/84', '47/85', '47/86', '47/87', '47/88', '47/89', '47/90', '47/91', '47/92', '47/93', '47/95', '47/96', '47/97', '48/49', '48/53', '48/55', '48/59', '48/61', '48/65', '48/67', '48/71', '48/73', '48/77', '48/79', '48/83', '48/85', '48/89', '48/91', '48/95', '48/97', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '49/61', '49/62', '49/64', '49/65', '49/66', '49/67', '49/68', '49/69', '49/71', '49/72', '49/73', '49/74', '49/75', '49/76', '49/78', '49/79', '49/80', '49/81', '49/82', '49/83', '49/85', '49/86', '49/87', '49/88', '49/89', '49/90', '49/92', '49/93', '49/94', '49/95', '49/96', '49/97', '50/51', '50/53', '50/57', '50/59', '50/61', '50/63', '50/67', '50/69', '50/71', '50/73', '50/77', '50/79', '50/81', '50/83', '50/87', '50/89', '50/91', '50/93', '50/97', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '51/61', '51/62', '51/64', '51/65', '51/67', '51/70', '51/71', '51/73', '51/74', '51/76', '51/77', '51/79', '51/80', '51/82', '51/83', '51/86', '51/88', '51/89', '51/91', '51/92', '51/94', '51/95', '51/97', '52/53', '52/55', '52/57', '52/59', '52/61', '52/63', '52/67', '52/69', '52/71', '52/73', '52/75', '52/77', '52/79', '52/81', '52/83', '52/85', '52/87', '52/89', '52/93', '52/95', '52/97', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '53/61', '53/62', '53/63', '53/64', '53/65', '53/66', '53/67', '53/68', '53/69', '53/70', '53/71', '53/72', '53/73', '53/74', '53/75', '53/76', '53/77', '53/78', '53/79', '53/80', '53/81', '53/82', '53/83', '53/84', '53/85', '53/86', '53/87', '53/88', '53/89', '53/90', '53/91', '53/92', '53/93', '53/94', '53/95', '53/96', '53/97', '54/55', '54/59', '54/61', '54/65', '54/67', '54/71', '54/73', '54/77', '54/79', '54/83', '54/85', '54/89', '54/91', '54/95', '54/97', '55/56', '55/57', '55/58', '55/59', '55/61', '55/62', '55/63', '55/64', '55/67', '55/68', '55/69', '55/71', '55/72', '55/73', '55/74', '55/76', '55/78', '55/79', '55/81', '55/82', '55/83', '55/84', '55/86', '55/87', '55/89', '55/91', '55/92', '55/93', '55/94', '55/96', '55/97', '56/57', '56/59', '56/61', '56/65', '56/67', '56/69', '56/71', '56/73', '56/75', '56/79', '56/81', '56/83', '56/85', '56/87', '56/89', '56/93', '56/95', '56/97', '57/58', '57/59', '57/61', '57/62', '57/64', '57/65', '57/67', '57/68', '57/70', '57/71', '57/73', '57/74', '57/77', '57/79', '57/80', '57/82', '57/83', '57/85', '57/86', '57/88', '57/89', '57/91', '57/92', '57/94', '57/97', '58/59', '58/61', '58/63', '58/65', '58/67', '58/69', '58/71', '58/73', '58/75', '58/77', '58/79', '58/81', '58/83', '58/85', '58/89', '58/91', '58/93', '58/95', '58/97', '59/60', '59/61', '59/62', '59/63', '59/64', '59/65', '59/66', '59/67', '59/68', '59/69', '59/70', '59/71', '59/72', '59/73', '59/74', '59/75', '59/76', '59/77', '59/78', '59/79', '59/80', '59/81', '59/82', '59/83', '59/84', '59/85', '59/86', '59/87', '59/88', '59/89', '59/90', '59/91', '59/92', '59/93', '59/94', '59/95', '59/96', '59/97', '60/61', '60/67', '60/71', '60/73', '60/77', '60/79', '60/83', '60/89', '60/91', '60/97', '61/62', '61/63', '61/64', '61/65', '61/66', '61/67', '61/68', '61/69', '61/70', '61/71', '61/72', '61/73', '61/74', '61/75', '61/76', '61/77', '61/78', '61/79', '61/80', '61/81', '61/82', '61/83', '61/84', '61/85', '61/86', '61/87', '61/88', '61/89', '61/90', '61/91', '61/92', '61/93', '61/94', '61/95', '61/96', '61/97', '62/63', '62/65', '62/67', '62/69', '62/71', '62/73', '62/75', '62/77', '62/79', '62/81', '62/83', '62/85', '62/87', '62/89', '62/91', '62/95', '62/97', '63/64', '63/65', '63/67', '63/68', '63/71', '63/73', '63/74', '63/76', '63/79', '63/80', '63/82', '63/83', '63/85', '63/86', '63/88', '63/89', '63/92', '63/94', '63/95', '63/97', '64/65', '64/67', '64/69', '64/71', '64/73', '64/75', '64/77', '64/79', '64/81', '64/83', '64/85', '64/87', '64/89', '64/91', '64/93', '64/95', '64/97', '65/66', '65/67', '65/68', '65/69', '65/71', '65/72', '65/73', '65/74', '65/76', '65/77', '65/79', '65/81', '65/82', '65/83', '65/84', '65/86', '65/87', '65/88', '65/89', '65/92', '65/93', '65/94', '65/96', '65/97', '66/67', '66/71', '66/73', '66/79', '66/83', '66/85', '66/89', '66/91', '66/95', '66/97', '67/68', '67/69', '67/70', '67/71', '67/72', '67/73', '67/74', '67/75', '67/76', '67/77', '67/78', '67/79', '67/80', '67/81', '67/82', '67/83', '67/84', '67/85', '67/86', '67/87', '67/88', '67/89', '67/90', '67/91', '67/92', '67/93', '67/94', '67/95', '67/96', '67/97', '68/69', '68/71', '68/73', '68/75', '68/77', '68/79', '68/81', '68/83', '68/87', '68/89', '68/91', '68/93', '68/95', '68/97', '69/70', '69/71', '69/73', '69/74', '69/76', '69/77', '69/79', '69/80', '69/82', '69/83', '69/85', '69/86', '69/88', '69/89', '69/91', '69/94', '69/95', '69/97', '70/71', '70/73', '70/79', '70/81', '70/83', '70/87', '70/89', '70/93', '70/97', '71/72', '71/73', '71/74', '71/75', '71/76', '71/77', '71/78', '71/79', '71/80', '71/81', '71/82', '71/83', '71/84', '71/85', '71/86', '71/87', '71/88', '71/89', '71/90', '71/91', '71/92', '71/93', '71/94', '71/95', '71/96', '71/97', '72/73', '72/77', '72/79', '72/83', '72/85', '72/89', '72/91', '72/95', '72/97', '73/74', '73/75', '73/76', '73/77', '73/78', '73/79', '73/80', '73/81', '73/82', '73/83', '73/84', '73/85', '73/86', '73/87', '73/88', '73/89', '73/90', '73/91', '73/92', '73/93', '73/94', '73/95', '73/96', '73/97', '74/75', '74/77', '74/79', '74/81', '74/83', '74/85', '74/87', '74/89', '74/91', '74/93', '74/95', '74/97', '75/76', '75/77', '75/79', '75/82', '75/83', '75/86', '75/88', '75/89', '75/91', '75/92', '75/94', '75/97', '76/77', '76/79', '76/81', '76/83', '76/85', '76/87', '76/89', '76/91', '76/93', '76/97', '77/78', '77/79', '77/80', '77/81', '77/82', '77/83', '77/85', '77/86', '77/87', '77/89', '77/90', '77/92', '77/93', '77/94', '77/95', '77/96', '77/97', '78/79', '78/83', '78/85', '78/89', '78/95', '78/97', '79/80', '79/81', '79/82', '79/83', '79/84', '79/85', '79/86', '79/87', '79/88', '79/89', '79/90', '79/91', '79/92', '79/93', '79/94', '79/95', '79/96', '79/97', '80/81', '80/83', '80/87', '80/89', '80/91', '80/93', '80/97', '81/82', '81/83', '81/85', '81/86', '81/88', '81/89', '81/91', '81/92', '81/94', '81/95', '81/97', '82/83', '82/85', '82/87', '82/89', '82/91', '82/93', '82/95', '82/97', '83/84', '83/85', '83/86', '83/87', '83/88', '83/89', '83/90', '83/91', '83/92', '83/93', '83/94', '83/95', '83/96', '83/97', '84/85', '84/89', '84/95', '84/97', '85/86', '85/87', '85/88', '85/89', '85/91', '85/92', '85/93', '85/94', '85/96', '85/97', '86/87', '86/89', '86/91', '86/93', '86/95', '86/97', '87/88', '87/89', '87/91', '87/92', '87/94', '87/95', '87/97', '88/89', '88/91', '88/93', '88/95', '88/97', '89/90', '89/91', '89/92', '89/93', '89/94', '89/95', '89/96', '89/97', '90/91', '90/97', '91/92', '91/93', '91/94', '91/95', '91/96', '91/97', '92/93', '92/95', '92/97', '93/94', '93/95', '93/97', '94/95', '94/97', '95/96', '95/97', '96/97']\n assert candidate(n = 60) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '1/26', '1/27', '1/28', '1/29', '1/30', '1/31', '1/32', '1/33', '1/34', '1/35', '1/36', '1/37', '1/38', '1/39', '1/40', '1/41', '1/42', '1/43', '1/44', '1/45', '1/46', '1/47', '1/48', '1/49', '1/50', '1/51', '1/52', '1/53', '1/54', '1/55', '1/56', '1/57', '1/58', '1/59', '1/60', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '42/43', '42/47', '42/53', '42/55', '42/59', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '48/49', '48/53', '48/55', '48/59', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '50/51', '50/53', '50/57', '50/59', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '52/53', '52/55', '52/57', '52/59', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '54/55', '54/59', '55/56', '55/57', '55/58', '55/59', '56/57', '56/59', '57/58', '57/59', '58/59', '59/60']\n assert candidate(n = 30) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '1/26', '1/27', '1/28', '1/29', '1/30', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '18/19', '18/23', '18/25', '18/29', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '20/21', '20/23', '20/27', '20/29', '21/22', '21/23', '21/25', '21/26', '21/29', '22/23', '22/25', '22/27', '22/29', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '24/25', '24/29', '25/26', '25/27', '25/28', '25/29', '26/27', '26/29', '27/28', '27/29', '28/29', '29/30']\n assert candidate(n = 99) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '1/26', '1/27', '1/28', '1/29', '1/30', '1/31', '1/32', '1/33', '1/34', '1/35', '1/36', '1/37', '1/38', '1/39', '1/40', '1/41', '1/42', '1/43', '1/44', '1/45', '1/46', '1/47', '1/48', '1/49', '1/50', '1/51', '1/52', '1/53', '1/54', '1/55', '1/56', '1/57', '1/58', '1/59', '1/60', '1/61', '1/62', '1/63', '1/64', '1/65', '1/66', '1/67', '1/68', '1/69', '1/70', '1/71', '1/72', '1/73', '1/74', '1/75', '1/76', '1/77', '1/78', '1/79', '1/80', '1/81', '1/82', '1/83', '1/84', '1/85', '1/86', '1/87', '1/88', '1/89', '1/90', '1/91', '1/92', '1/93', '1/94', '1/95', '1/96', '1/97', '1/98', '1/99', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '2/61', '2/63', '2/65', '2/67', '2/69', '2/71', '2/73', '2/75', '2/77', '2/79', '2/81', '2/83', '2/85', '2/87', '2/89', '2/91', '2/93', '2/95', '2/97', '2/99', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '3/61', '3/62', '3/64', '3/65', '3/67', '3/68', '3/70', '3/71', '3/73', '3/74', '3/76', '3/77', '3/79', '3/80', '3/82', '3/83', '3/85', '3/86', '3/88', '3/89', '3/91', '3/92', '3/94', '3/95', '3/97', '3/98', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '4/61', '4/63', '4/65', '4/67', '4/69', '4/71', '4/73', '4/75', '4/77', '4/79', '4/81', '4/83', '4/85', '4/87', '4/89', '4/91', '4/93', '4/95', '4/97', '4/99', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '5/61', '5/62', '5/63', '5/64', '5/66', '5/67', '5/68', '5/69', '5/71', '5/72', '5/73', '5/74', '5/76', '5/77', '5/78', '5/79', '5/81', '5/82', '5/83', '5/84', '5/86', '5/87', '5/88', '5/89', '5/91', '5/92', '5/93', '5/94', '5/96', '5/97', '5/98', '5/99', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '6/61', '6/65', '6/67', '6/71', '6/73', '6/77', '6/79', '6/83', '6/85', '6/89', '6/91', '6/95', '6/97', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '7/61', '7/62', '7/64', '7/65', '7/66', '7/67', '7/68', '7/69', '7/71', '7/72', '7/73', '7/74', '7/75', '7/76', '7/78', '7/79', '7/80', '7/81', '7/82', '7/83', '7/85', '7/86', '7/87', '7/88', '7/89', '7/90', '7/92', '7/93', '7/94', '7/95', '7/96', '7/97', '7/99', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '8/61', '8/63', '8/65', '8/67', '8/69', '8/71', '8/73', '8/75', '8/77', '8/79', '8/81', '8/83', '8/85', '8/87', '8/89', '8/91', '8/93', '8/95', '8/97', '8/99', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '9/61', '9/62', '9/64', '9/65', '9/67', '9/68', '9/70', '9/71', '9/73', '9/74', '9/76', '9/77', '9/79', '9/80', '9/82', '9/83', '9/85', '9/86', '9/88', '9/89', '9/91', '9/92', '9/94', '9/95', '9/97', '9/98', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '10/61', '10/63', '10/67', '10/69', '10/71', '10/73', '10/77', '10/79', '10/81', '10/83', '10/87', '10/89', '10/91', '10/93', '10/97', '10/99', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '11/61', '11/62', '11/63', '11/64', '11/65', '11/67', '11/68', '11/69', '11/70', '11/71', '11/72', '11/73', '11/74', '11/75', '11/76', '11/78', '11/79', '11/80', '11/81', '11/82', '11/83', '11/84', '11/85', '11/86', '11/87', '11/89', '11/90', '11/91', '11/92', '11/93', '11/94', '11/95', '11/96', '11/97', '11/98', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '12/61', '12/65', '12/67', '12/71', '12/73', '12/77', '12/79', '12/83', '12/85', '12/89', '12/91', '12/95', '12/97', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '13/61', '13/62', '13/63', '13/64', '13/66', '13/67', '13/68', '13/69', '13/70', '13/71', '13/72', '13/73', '13/74', '13/75', '13/76', '13/77', '13/79', '13/80', '13/81', '13/82', '13/83', '13/84', '13/85', '13/86', '13/87', '13/88', '13/89', '13/90', '13/92', '13/93', '13/94', '13/95', '13/96', '13/97', '13/98', '13/99', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '14/61', '14/65', '14/67', '14/69', '14/71', '14/73', '14/75', '14/79', '14/81', '14/83', '14/85', '14/87', '14/89', '14/93', '14/95', '14/97', '14/99', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '15/61', '15/62', '15/64', '15/67', '15/68', '15/71', '15/73', '15/74', '15/76', '15/77', '15/79', '15/82', '15/83', '15/86', '15/88', '15/89', '15/91', '15/92', '15/94', '15/97', '15/98', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '16/61', '16/63', '16/65', '16/67', '16/69', '16/71', '16/73', '16/75', '16/77', '16/79', '16/81', '16/83', '16/85', '16/87', '16/89', '16/91', '16/93', '16/95', '16/97', '16/99', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '17/61', '17/62', '17/63', '17/64', '17/65', '17/66', '17/67', '17/69', '17/70', '17/71', '17/72', '17/73', '17/74', '17/75', '17/76', '17/77', '17/78', '17/79', '17/80', '17/81', '17/82', '17/83', '17/84', '17/86', '17/87', '17/88', '17/89', '17/90', '17/91', '17/92', '17/93', '17/94', '17/95', '17/96', '17/97', '17/98', '17/99', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '18/61', '18/65', '18/67', '18/71', '18/73', '18/77', '18/79', '18/83', '18/85', '18/89', '18/91', '18/95', '18/97', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '19/61', '19/62', '19/63', '19/64', '19/65', '19/66', '19/67', '19/68', '19/69', '19/70', '19/71', '19/72', '19/73', '19/74', '19/75', '19/77', '19/78', '19/79', '19/80', '19/81', '19/82', '19/83', '19/84', '19/85', '19/86', '19/87', '19/88', '19/89', '19/90', '19/91', '19/92', '19/93', '19/94', '19/96', '19/97', '19/98', '19/99', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '20/61', '20/63', '20/67', '20/69', '20/71', '20/73', '20/77', '20/79', '20/81', '20/83', '20/87', '20/89', '20/91', '20/93', '20/97', '20/99', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '21/61', '21/62', '21/64', '21/65', '21/67', '21/68', '21/71', '21/73', '21/74', '21/76', '21/79', '21/80', '21/82', '21/83', '21/85', '21/86', '21/88', '21/89', '21/92', '21/94', '21/95', '21/97', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '22/61', '22/63', '22/65', '22/67', '22/69', '22/71', '22/73', '22/75', '22/79', '22/81', '22/83', '22/85', '22/87', '22/89', '22/91', '22/93', '22/95', '22/97', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '23/61', '23/62', '23/63', '23/64', '23/65', '23/66', '23/67', '23/68', '23/70', '23/71', '23/72', '23/73', '23/74', '23/75', '23/76', '23/77', '23/78', '23/79', '23/80', '23/81', '23/82', '23/83', '23/84', '23/85', '23/86', '23/87', '23/88', '23/89', '23/90', '23/91', '23/93', '23/94', '23/95', '23/96', '23/97', '23/98', '23/99', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '24/61', '24/65', '24/67', '24/71', '24/73', '24/77', '24/79', '24/83', '24/85', '24/89', '24/91', '24/95', '24/97', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '25/61', '25/62', '25/63', '25/64', '25/66', '25/67', '25/68', '25/69', '25/71', '25/72', '25/73', '25/74', '25/76', '25/77', '25/78', '25/79', '25/81', '25/82', '25/83', '25/84', '25/86', '25/87', '25/88', '25/89', '25/91', '25/92', '25/93', '25/94', '25/96', '25/97', '25/98', '25/99', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '26/61', '26/63', '26/67', '26/69', '26/71', '26/73', '26/75', '26/77', '26/79', '26/81', '26/83', '26/85', '26/87', '26/89', '26/93', '26/95', '26/97', '26/99', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '27/61', '27/62', '27/64', '27/65', '27/67', '27/68', '27/70', '27/71', '27/73', '27/74', '27/76', '27/77', '27/79', '27/80', '27/82', '27/83', '27/85', '27/86', '27/88', '27/89', '27/91', '27/92', '27/94', '27/95', '27/97', '27/98', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '28/61', '28/65', '28/67', '28/69', '28/71', '28/73', '28/75', '28/79', '28/81', '28/83', '28/85', '28/87', '28/89', '28/93', '28/95', '28/97', '28/99', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '29/61', '29/62', '29/63', '29/64', '29/65', '29/66', '29/67', '29/68', '29/69', '29/70', '29/71', '29/72', '29/73', '29/74', '29/75', '29/76', '29/77', '29/78', '29/79', '29/80', '29/81', '29/82', '29/83', '29/84', '29/85', '29/86', '29/88', '29/89', '29/90', '29/91', '29/92', '29/93', '29/94', '29/95', '29/96', '29/97', '29/98', '29/99', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '30/61', '30/67', '30/71', '30/73', '30/77', '30/79', '30/83', '30/89', '30/91', '30/97', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '31/61', '31/63', '31/64', '31/65', '31/66', '31/67', '31/68', '31/69', '31/70', '31/71', '31/72', '31/73', '31/74', '31/75', '31/76', '31/77', '31/78', '31/79', '31/80', '31/81', '31/82', '31/83', '31/84', '31/85', '31/86', '31/87', '31/88', '31/89', '31/90', '31/91', '31/92', '31/94', '31/95', '31/96', '31/97', '31/98', '31/99', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '32/61', '32/63', '32/65', '32/67', '32/69', '32/71', '32/73', '32/75', '32/77', '32/79', '32/81', '32/83', '32/85', '32/87', '32/89', '32/91', '32/93', '32/95', '32/97', '32/99', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '33/61', '33/62', '33/64', '33/65', '33/67', '33/68', '33/70', '33/71', '33/73', '33/74', '33/76', '33/79', '33/80', '33/82', '33/83', '33/85', '33/86', '33/89', '33/91', '33/92', '33/94', '33/95', '33/97', '33/98', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '34/61', '34/63', '34/65', '34/67', '34/69', '34/71', '34/73', '34/75', '34/77', '34/79', '34/81', '34/83', '34/87', '34/89', '34/91', '34/93', '34/95', '34/97', '34/99', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '35/61', '35/62', '35/64', '35/66', '35/67', '35/68', '35/69', '35/71', '35/72', '35/73', '35/74', '35/76', '35/78', '35/79', '35/81', '35/82', '35/83', '35/86', '35/87', '35/88', '35/89', '35/92', '35/93', '35/94', '35/96', '35/97', '35/99', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '36/61', '36/65', '36/67', '36/71', '36/73', '36/77', '36/79', '36/83', '36/85', '36/89', '36/91', '36/95', '36/97', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '37/61', '37/62', '37/63', '37/64', '37/65', '37/66', '37/67', '37/68', '37/69', '37/70', '37/71', '37/72', '37/73', '37/75', '37/76', '37/77', '37/78', '37/79', '37/80', '37/81', '37/82', '37/83', '37/84', '37/85', '37/86', '37/87', '37/88', '37/89', '37/90', '37/91', '37/92', '37/93', '37/94', '37/95', '37/96', '37/97', '37/98', '37/99', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '38/61', '38/63', '38/65', '38/67', '38/69', '38/71', '38/73', '38/75', '38/77', '38/79', '38/81', '38/83', '38/85', '38/87', '38/89', '38/91', '38/93', '38/97', '38/99', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '39/61', '39/62', '39/64', '39/67', '39/68', '39/70', '39/71', '39/73', '39/74', '39/76', '39/77', '39/79', '39/80', '39/82', '39/83', '39/85', '39/86', '39/88', '39/89', '39/92', '39/94', '39/95', '39/97', '39/98', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '40/61', '40/63', '40/67', '40/69', '40/71', '40/73', '40/77', '40/79', '40/81', '40/83', '40/87', '40/89', '40/91', '40/93', '40/97', '40/99', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '41/61', '41/62', '41/63', '41/64', '41/65', '41/66', '41/67', '41/68', '41/69', '41/70', '41/71', '41/72', '41/73', '41/74', '41/75', '41/76', '41/77', '41/78', '41/79', '41/80', '41/81', '41/83', '41/84', '41/85', '41/86', '41/87', '41/88', '41/89', '41/90', '41/91', '41/92', '41/93', '41/94', '41/95', '41/96', '41/97', '41/98', '41/99', '42/43', '42/47', '42/53', '42/55', '42/59', '42/61', '42/65', '42/67', '42/71', '42/73', '42/79', '42/83', '42/85', '42/89', '42/95', '42/97', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '43/61', '43/62', '43/63', '43/64', '43/65', '43/66', '43/67', '43/68', '43/69', '43/70', '43/71', '43/72', '43/73', '43/74', '43/75', '43/76', '43/77', '43/78', '43/79', '43/80', '43/81', '43/82', '43/83', '43/84', '43/85', '43/87', '43/88', '43/89', '43/90', '43/91', '43/92', '43/93', '43/94', '43/95', '43/96', '43/97', '43/98', '43/99', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '44/61', '44/63', '44/65', '44/67', '44/69', '44/71', '44/73', '44/75', '44/79', '44/81', '44/83', '44/85', '44/87', '44/89', '44/91', '44/93', '44/95', '44/97', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '45/61', '45/62', '45/64', '45/67', '45/68', '45/71', '45/73', '45/74', '45/76', '45/77', '45/79', '45/82', '45/83', '45/86', '45/88', '45/89', '45/91', '45/92', '45/94', '45/97', '45/98', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '46/61', '46/63', '46/65', '46/67', '46/71', '46/73', '46/75', '46/77', '46/79', '46/81', '46/83', '46/85', '46/87', '46/89', '46/91', '46/93', '46/95', '46/97', '46/99', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '47/61', '47/62', '47/63', '47/64', '47/65', '47/66', '47/67', '47/68', '47/69', '47/70', '47/71', '47/72', '47/73', '47/74', '47/75', '47/76', '47/77', '47/78', '47/79', '47/80', '47/81', '47/82', '47/83', '47/84', '47/85', '47/86', '47/87', '47/88', '47/89', '47/90', '47/91', '47/92', '47/93', '47/95', '47/96', '47/97', '47/98', '47/99', '48/49', '48/53', '48/55', '48/59', '48/61', '48/65', '48/67', '48/71', '48/73', '48/77', '48/79', '48/83', '48/85', '48/89', '48/91', '48/95', '48/97', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '49/61', '49/62', '49/64', '49/65', '49/66', '49/67', '49/68', '49/69', '49/71', '49/72', '49/73', '49/74', '49/75', '49/76', '49/78', '49/79', '49/80', '49/81', '49/82', '49/83', '49/85', '49/86', '49/87', '49/88', '49/89', '49/90', '49/92', '49/93', '49/94', '49/95', '49/96', '49/97', '49/99', '50/51', '50/53', '50/57', '50/59', '50/61', '50/63', '50/67', '50/69', '50/71', '50/73', '50/77', '50/79', '50/81', '50/83', '50/87', '50/89', '50/91', '50/93', '50/97', '50/99', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '51/61', '51/62', '51/64', '51/65', '51/67', '51/70', '51/71', '51/73', '51/74', '51/76', '51/77', '51/79', '51/80', '51/82', '51/83', '51/86', '51/88', '51/89', '51/91', '51/92', '51/94', '51/95', '51/97', '51/98', '52/53', '52/55', '52/57', '52/59', '52/61', '52/63', '52/67', '52/69', '52/71', '52/73', '52/75', '52/77', '52/79', '52/81', '52/83', '52/85', '52/87', '52/89', '52/93', '52/95', '52/97', '52/99', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '53/61', '53/62', '53/63', '53/64', '53/65', '53/66', '53/67', '53/68', '53/69', '53/70', '53/71', '53/72', '53/73', '53/74', '53/75', '53/76', '53/77', '53/78', '53/79', '53/80', '53/81', '53/82', '53/83', '53/84', '53/85', '53/86', '53/87', '53/88', '53/89', '53/90', '53/91', '53/92', '53/93', '53/94', '53/95', '53/96', '53/97', '53/98', '53/99', '54/55', '54/59', '54/61', '54/65', '54/67', '54/71', '54/73', '54/77', '54/79', '54/83', '54/85', '54/89', '54/91', '54/95', '54/97', '55/56', '55/57', '55/58', '55/59', '55/61', '55/62', '55/63', '55/64', '55/67', '55/68', '55/69', '55/71', '55/72', '55/73', '55/74', '55/76', '55/78', '55/79', '55/81', '55/82', '55/83', '55/84', '55/86', '55/87', '55/89', '55/91', '55/92', '55/93', '55/94', '55/96', '55/97', '55/98', '56/57', '56/59', '56/61', '56/65', '56/67', '56/69', '56/71', '56/73', '56/75', '56/79', '56/81', '56/83', '56/85', '56/87', '56/89', '56/93', '56/95', '56/97', '56/99', '57/58', '57/59', '57/61', '57/62', '57/64', '57/65', '57/67', '57/68', '57/70', '57/71', '57/73', '57/74', '57/77', '57/79', '57/80', '57/82', '57/83', '57/85', '57/86', '57/88', '57/89', '57/91', '57/92', '57/94', '57/97', '57/98', '58/59', '58/61', '58/63', '58/65', '58/67', '58/69', '58/71', '58/73', '58/75', '58/77', '58/79', '58/81', '58/83', '58/85', '58/89', '58/91', '58/93', '58/95', '58/97', '58/99', '59/60', '59/61', '59/62', '59/63', '59/64', '59/65', '59/66', '59/67', '59/68', '59/69', '59/70', '59/71', '59/72', '59/73', '59/74', '59/75', '59/76', '59/77', '59/78', '59/79', '59/80', '59/81', '59/82', '59/83', '59/84', '59/85', '59/86', '59/87', '59/88', '59/89', '59/90', '59/91', '59/92', '59/93', '59/94', '59/95', '59/96', '59/97', '59/98', '59/99', '60/61', '60/67', '60/71', '60/73', '60/77', '60/79', '60/83', '60/89', '60/91', '60/97', '61/62', '61/63', '61/64', '61/65', '61/66', '61/67', '61/68', '61/69', '61/70', '61/71', '61/72', '61/73', '61/74', '61/75', '61/76', '61/77', '61/78', '61/79', '61/80', '61/81', '61/82', '61/83', '61/84', '61/85', '61/86', '61/87', '61/88', '61/89', '61/90', '61/91', '61/92', '61/93', '61/94', '61/95', '61/96', '61/97', '61/98', '61/99', '62/63', '62/65', '62/67', '62/69', '62/71', '62/73', '62/75', '62/77', '62/79', '62/81', '62/83', '62/85', '62/87', '62/89', '62/91', '62/95', '62/97', '62/99', '63/64', '63/65', '63/67', '63/68', '63/71', '63/73', '63/74', '63/76', '63/79', '63/80', '63/82', '63/83', '63/85', '63/86', '63/88', '63/89', '63/92', '63/94', '63/95', '63/97', '64/65', '64/67', '64/69', '64/71', '64/73', '64/75', '64/77', '64/79', '64/81', '64/83', '64/85', '64/87', '64/89', '64/91', '64/93', '64/95', '64/97', '64/99', '65/66', '65/67', '65/68', '65/69', '65/71', '65/72', '65/73', '65/74', '65/76', '65/77', '65/79', '65/81', '65/82', '65/83', '65/84', '65/86', '65/87', '65/88', '65/89', '65/92', '65/93', '65/94', '65/96', '65/97', '65/98', '65/99', '66/67', '66/71', '66/73', '66/79', '66/83', '66/85', '66/89', '66/91', '66/95', '66/97', '67/68', '67/69', '67/70', '67/71', '67/72', '67/73', '67/74', '67/75', '67/76', '67/77', '67/78', '67/79', '67/80', '67/81', '67/82', '67/83', '67/84', '67/85', '67/86', '67/87', '67/88', '67/89', '67/90', '67/91', '67/92', '67/93', '67/94', '67/95', '67/96', '67/97', '67/98', '67/99', '68/69', '68/71', '68/73', '68/75', '68/77', '68/79', '68/81', '68/83', '68/87', '68/89', '68/91', '68/93', '68/95', '68/97', '68/99', '69/70', '69/71', '69/73', '69/74', '69/76', '69/77', '69/79', '69/80', '69/82', '69/83', '69/85', '69/86', '69/88', '69/89', '69/91', '69/94', '69/95', '69/97', '69/98', '70/71', '70/73', '70/79', '70/81', '70/83', '70/87', '70/89', '70/93', '70/97', '70/99', '71/72', '71/73', '71/74', '71/75', '71/76', '71/77', '71/78', '71/79', '71/80', '71/81', '71/82', '71/83', '71/84', '71/85', '71/86', '71/87', '71/88', '71/89', '71/90', '71/91', '71/92', '71/93', '71/94', '71/95', '71/96', '71/97', '71/98', '71/99', '72/73', '72/77', '72/79', '72/83', '72/85', '72/89', '72/91', '72/95', '72/97', '73/74', '73/75', '73/76', '73/77', '73/78', '73/79', '73/80', '73/81', '73/82', '73/83', '73/84', '73/85', '73/86', '73/87', '73/88', '73/89', '73/90', '73/91', '73/92', '73/93', '73/94', '73/95', '73/96', '73/97', '73/98', '73/99', '74/75', '74/77', '74/79', '74/81', '74/83', '74/85', '74/87', '74/89', '74/91', '74/93', '74/95', '74/97', '74/99', '75/76', '75/77', '75/79', '75/82', '75/83', '75/86', '75/88', '75/89', '75/91', '75/92', '75/94', '75/97', '75/98', '76/77', '76/79', '76/81', '76/83', '76/85', '76/87', '76/89', '76/91', '76/93', '76/97', '76/99', '77/78', '77/79', '77/80', '77/81', '77/82', '77/83', '77/85', '77/86', '77/87', '77/89', '77/90', '77/92', '77/93', '77/94', '77/95', '77/96', '77/97', '78/79', '78/83', '78/85', '78/89', '78/95', '78/97', '79/80', '79/81', '79/82', '79/83', '79/84', '79/85', '79/86', '79/87', '79/88', '79/89', '79/90', '79/91', '79/92', '79/93', '79/94', '79/95', '79/96', '79/97', '79/98', '79/99', '80/81', '80/83', '80/87', '80/89', '80/91', '80/93', '80/97', '80/99', '81/82', '81/83', '81/85', '81/86', '81/88', '81/89', '81/91', '81/92', '81/94', '81/95', '81/97', '81/98', '82/83', '82/85', '82/87', '82/89', '82/91', '82/93', '82/95', '82/97', '82/99', '83/84', '83/85', '83/86', '83/87', '83/88', '83/89', '83/90', '83/91', '83/92', '83/93', '83/94', '83/95', '83/96', '83/97', '83/98', '83/99', '84/85', '84/89', '84/95', '84/97', '85/86', '85/87', '85/88', '85/89', '85/91', '85/92', '85/93', '85/94', '85/96', '85/97', '85/98', '85/99', '86/87', '86/89', '86/91', '86/93', '86/95', '86/97', '86/99', '87/88', '87/89', '87/91', '87/92', '87/94', '87/95', '87/97', '87/98', '88/89', '88/91', '88/93', '88/95', '88/97', '89/90', '89/91', '89/92', '89/93', '89/94', '89/95', '89/96', '89/97', '89/98', '89/99', '90/91', '90/97', '91/92', '91/93', '91/94', '91/95', '91/96', '91/97', '91/99', '92/93', '92/95', '92/97', '92/99', '93/94', '93/95', '93/97', '93/98', '94/95', '94/97', '94/99', '95/96', '95/97', '95/98', '95/99', '96/97', '97/98', '97/99', '98/99']\n assert candidate(n = 80) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '1/26', '1/27', '1/28', '1/29', '1/30', '1/31', '1/32', '1/33', '1/34', '1/35', '1/36', '1/37', '1/38', '1/39', '1/40', '1/41', '1/42', '1/43', '1/44', '1/45', '1/46', '1/47', '1/48', '1/49', '1/50', '1/51', '1/52', '1/53', '1/54', '1/55', '1/56', '1/57', '1/58', '1/59', '1/60', '1/61', '1/62', '1/63', '1/64', '1/65', '1/66', '1/67', '1/68', '1/69', '1/70', '1/71', '1/72', '1/73', '1/74', '1/75', '1/76', '1/77', '1/78', '1/79', '1/80', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '2/61', '2/63', '2/65', '2/67', '2/69', '2/71', '2/73', '2/75', '2/77', '2/79', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '3/61', '3/62', '3/64', '3/65', '3/67', '3/68', '3/70', '3/71', '3/73', '3/74', '3/76', '3/77', '3/79', '3/80', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '4/61', '4/63', '4/65', '4/67', '4/69', '4/71', '4/73', '4/75', '4/77', '4/79', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '5/61', '5/62', '5/63', '5/64', '5/66', '5/67', '5/68', '5/69', '5/71', '5/72', '5/73', '5/74', '5/76', '5/77', '5/78', '5/79', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '6/61', '6/65', '6/67', '6/71', '6/73', '6/77', '6/79', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '7/61', '7/62', '7/64', '7/65', '7/66', '7/67', '7/68', '7/69', '7/71', '7/72', '7/73', '7/74', '7/75', '7/76', '7/78', '7/79', '7/80', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '8/61', '8/63', '8/65', '8/67', '8/69', '8/71', '8/73', '8/75', '8/77', '8/79', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '9/61', '9/62', '9/64', '9/65', '9/67', '9/68', '9/70', '9/71', '9/73', '9/74', '9/76', '9/77', '9/79', '9/80', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '10/61', '10/63', '10/67', '10/69', '10/71', '10/73', '10/77', '10/79', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '11/61', '11/62', '11/63', '11/64', '11/65', '11/67', '11/68', '11/69', '11/70', '11/71', '11/72', '11/73', '11/74', '11/75', '11/76', '11/78', '11/79', '11/80', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '12/61', '12/65', '12/67', '12/71', '12/73', '12/77', '12/79', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '13/61', '13/62', '13/63', '13/64', '13/66', '13/67', '13/68', '13/69', '13/70', '13/71', '13/72', '13/73', '13/74', '13/75', '13/76', '13/77', '13/79', '13/80', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '14/61', '14/65', '14/67', '14/69', '14/71', '14/73', '14/75', '14/79', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '15/61', '15/62', '15/64', '15/67', '15/68', '15/71', '15/73', '15/74', '15/76', '15/77', '15/79', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '16/61', '16/63', '16/65', '16/67', '16/69', '16/71', '16/73', '16/75', '16/77', '16/79', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '17/61', '17/62', '17/63', '17/64', '17/65', '17/66', '17/67', '17/69', '17/70', '17/71', '17/72', '17/73', '17/74', '17/75', '17/76', '17/77', '17/78', '17/79', '17/80', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '18/61', '18/65', '18/67', '18/71', '18/73', '18/77', '18/79', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '19/61', '19/62', '19/63', '19/64', '19/65', '19/66', '19/67', '19/68', '19/69', '19/70', '19/71', '19/72', '19/73', '19/74', '19/75', '19/77', '19/78', '19/79', '19/80', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '20/61', '20/63', '20/67', '20/69', '20/71', '20/73', '20/77', '20/79', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '21/61', '21/62', '21/64', '21/65', '21/67', '21/68', '21/71', '21/73', '21/74', '21/76', '21/79', '21/80', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '22/61', '22/63', '22/65', '22/67', '22/69', '22/71', '22/73', '22/75', '22/79', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '23/61', '23/62', '23/63', '23/64', '23/65', '23/66', '23/67', '23/68', '23/70', '23/71', '23/72', '23/73', '23/74', '23/75', '23/76', '23/77', '23/78', '23/79', '23/80', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '24/61', '24/65', '24/67', '24/71', '24/73', '24/77', '24/79', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '25/61', '25/62', '25/63', '25/64', '25/66', '25/67', '25/68', '25/69', '25/71', '25/72', '25/73', '25/74', '25/76', '25/77', '25/78', '25/79', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '26/61', '26/63', '26/67', '26/69', '26/71', '26/73', '26/75', '26/77', '26/79', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '27/61', '27/62', '27/64', '27/65', '27/67', '27/68', '27/70', '27/71', '27/73', '27/74', '27/76', '27/77', '27/79', '27/80', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '28/61', '28/65', '28/67', '28/69', '28/71', '28/73', '28/75', '28/79', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '29/61', '29/62', '29/63', '29/64', '29/65', '29/66', '29/67', '29/68', '29/69', '29/70', '29/71', '29/72', '29/73', '29/74', '29/75', '29/76', '29/77', '29/78', '29/79', '29/80', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '30/61', '30/67', '30/71', '30/73', '30/77', '30/79', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '31/61', '31/63', '31/64', '31/65', '31/66', '31/67', '31/68', '31/69', '31/70', '31/71', '31/72', '31/73', '31/74', '31/75', '31/76', '31/77', '31/78', '31/79', '31/80', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '32/61', '32/63', '32/65', '32/67', '32/69', '32/71', '32/73', '32/75', '32/77', '32/79', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '33/61', '33/62', '33/64', '33/65', '33/67', '33/68', '33/70', '33/71', '33/73', '33/74', '33/76', '33/79', '33/80', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '34/61', '34/63', '34/65', '34/67', '34/69', '34/71', '34/73', '34/75', '34/77', '34/79', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '35/61', '35/62', '35/64', '35/66', '35/67', '35/68', '35/69', '35/71', '35/72', '35/73', '35/74', '35/76', '35/78', '35/79', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '36/61', '36/65', '36/67', '36/71', '36/73', '36/77', '36/79', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '37/61', '37/62', '37/63', '37/64', '37/65', '37/66', '37/67', '37/68', '37/69', '37/70', '37/71', '37/72', '37/73', '37/75', '37/76', '37/77', '37/78', '37/79', '37/80', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '38/61', '38/63', '38/65', '38/67', '38/69', '38/71', '38/73', '38/75', '38/77', '38/79', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '39/61', '39/62', '39/64', '39/67', '39/68', '39/70', '39/71', '39/73', '39/74', '39/76', '39/77', '39/79', '39/80', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '40/61', '40/63', '40/67', '40/69', '40/71', '40/73', '40/77', '40/79', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '41/61', '41/62', '41/63', '41/64', '41/65', '41/66', '41/67', '41/68', '41/69', '41/70', '41/71', '41/72', '41/73', '41/74', '41/75', '41/76', '41/77', '41/78', '41/79', '41/80', '42/43', '42/47', '42/53', '42/55', '42/59', '42/61', '42/65', '42/67', '42/71', '42/73', '42/79', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '43/61', '43/62', '43/63', '43/64', '43/65', '43/66', '43/67', '43/68', '43/69', '43/70', '43/71', '43/72', '43/73', '43/74', '43/75', '43/76', '43/77', '43/78', '43/79', '43/80', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '44/61', '44/63', '44/65', '44/67', '44/69', '44/71', '44/73', '44/75', '44/79', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '45/61', '45/62', '45/64', '45/67', '45/68', '45/71', '45/73', '45/74', '45/76', '45/77', '45/79', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '46/61', '46/63', '46/65', '46/67', '46/71', '46/73', '46/75', '46/77', '46/79', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '47/61', '47/62', '47/63', '47/64', '47/65', '47/66', '47/67', '47/68', '47/69', '47/70', '47/71', '47/72', '47/73', '47/74', '47/75', '47/76', '47/77', '47/78', '47/79', '47/80', '48/49', '48/53', '48/55', '48/59', '48/61', '48/65', '48/67', '48/71', '48/73', '48/77', '48/79', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '49/61', '49/62', '49/64', '49/65', '49/66', '49/67', '49/68', '49/69', '49/71', '49/72', '49/73', '49/74', '49/75', '49/76', '49/78', '49/79', '49/80', '50/51', '50/53', '50/57', '50/59', '50/61', '50/63', '50/67', '50/69', '50/71', '50/73', '50/77', '50/79', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '51/61', '51/62', '51/64', '51/65', '51/67', '51/70', '51/71', '51/73', '51/74', '51/76', '51/77', '51/79', '51/80', '52/53', '52/55', '52/57', '52/59', '52/61', '52/63', '52/67', '52/69', '52/71', '52/73', '52/75', '52/77', '52/79', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '53/61', '53/62', '53/63', '53/64', '53/65', '53/66', '53/67', '53/68', '53/69', '53/70', '53/71', '53/72', '53/73', '53/74', '53/75', '53/76', '53/77', '53/78', '53/79', '53/80', '54/55', '54/59', '54/61', '54/65', '54/67', '54/71', '54/73', '54/77', '54/79', '55/56', '55/57', '55/58', '55/59', '55/61', '55/62', '55/63', '55/64', '55/67', '55/68', '55/69', '55/71', '55/72', '55/73', '55/74', '55/76', '55/78', '55/79', '56/57', '56/59', '56/61', '56/65', '56/67', '56/69', '56/71', '56/73', '56/75', '56/79', '57/58', '57/59', '57/61', '57/62', '57/64', '57/65', '57/67', '57/68', '57/70', '57/71', '57/73', '57/74', '57/77', '57/79', '57/80', '58/59', '58/61', '58/63', '58/65', '58/67', '58/69', '58/71', '58/73', '58/75', '58/77', '58/79', '59/60', '59/61', '59/62', '59/63', '59/64', '59/65', '59/66', '59/67', '59/68', '59/69', '59/70', '59/71', '59/72', '59/73', '59/74', '59/75', '59/76', '59/77', '59/78', '59/79', '59/80', '60/61', '60/67', '60/71', '60/73', '60/77', '60/79', '61/62', '61/63', '61/64', '61/65', '61/66', '61/67', '61/68', '61/69', '61/70', '61/71', '61/72', '61/73', '61/74', '61/75', '61/76', '61/77', '61/78', '61/79', '61/80', '62/63', '62/65', '62/67', '62/69', '62/71', '62/73', '62/75', '62/77', '62/79', '63/64', '63/65', '63/67', '63/68', '63/71', '63/73', '63/74', '63/76', '63/79', '63/80', '64/65', '64/67', '64/69', '64/71', '64/73', '64/75', '64/77', '64/79', '65/66', '65/67', '65/68', '65/69', '65/71', '65/72', '65/73', '65/74', '65/76', '65/77', '65/79', '66/67', '66/71', '66/73', '66/79', '67/68', '67/69', '67/70', '67/71', '67/72', '67/73', '67/74', '67/75', '67/76', '67/77', '67/78', '67/79', '67/80', '68/69', '68/71', '68/73', '68/75', '68/77', '68/79', '69/70', '69/71', '69/73', '69/74', '69/76', '69/77', '69/79', '69/80', '70/71', '70/73', '70/79', '71/72', '71/73', '71/74', '71/75', '71/76', '71/77', '71/78', '71/79', '71/80', '72/73', '72/77', '72/79', '73/74', '73/75', '73/76', '73/77', '73/78', '73/79', '73/80', '74/75', '74/77', '74/79', '75/76', '75/77', '75/79', '76/77', '76/79', '77/78', '77/79', '77/80', '78/79', '79/80']\n assert candidate(n = 8) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '2/3', '2/5', '2/7', '3/4', '3/5', '3/7', '3/8', '4/5', '4/7', '5/6', '5/7', '5/8', '6/7', '7/8']\n assert candidate(n = 75) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '1/26', '1/27', '1/28', '1/29', '1/30', '1/31', '1/32', '1/33', '1/34', '1/35', '1/36', '1/37', '1/38', '1/39', '1/40', '1/41', '1/42', '1/43', '1/44', '1/45', '1/46', '1/47', '1/48', '1/49', '1/50', '1/51', '1/52', '1/53', '1/54', '1/55', '1/56', '1/57', '1/58', '1/59', '1/60', '1/61', '1/62', '1/63', '1/64', '1/65', '1/66', '1/67', '1/68', '1/69', '1/70', '1/71', '1/72', '1/73', '1/74', '1/75', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '2/61', '2/63', '2/65', '2/67', '2/69', '2/71', '2/73', '2/75', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '3/61', '3/62', '3/64', '3/65', '3/67', '3/68', '3/70', '3/71', '3/73', '3/74', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '4/61', '4/63', '4/65', '4/67', '4/69', '4/71', '4/73', '4/75', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '5/61', '5/62', '5/63', '5/64', '5/66', '5/67', '5/68', '5/69', '5/71', '5/72', '5/73', '5/74', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '6/61', '6/65', '6/67', '6/71', '6/73', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '7/61', '7/62', '7/64', '7/65', '7/66', '7/67', '7/68', '7/69', '7/71', '7/72', '7/73', '7/74', '7/75', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '8/61', '8/63', '8/65', '8/67', '8/69', '8/71', '8/73', '8/75', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '9/61', '9/62', '9/64', '9/65', '9/67', '9/68', '9/70', '9/71', '9/73', '9/74', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '10/61', '10/63', '10/67', '10/69', '10/71', '10/73', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '11/61', '11/62', '11/63', '11/64', '11/65', '11/67', '11/68', '11/69', '11/70', '11/71', '11/72', '11/73', '11/74', '11/75', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '12/61', '12/65', '12/67', '12/71', '12/73', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '13/61', '13/62', '13/63', '13/64', '13/66', '13/67', '13/68', '13/69', '13/70', '13/71', '13/72', '13/73', '13/74', '13/75', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '14/61', '14/65', '14/67', '14/69', '14/71', '14/73', '14/75', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '15/61', '15/62', '15/64', '15/67', '15/68', '15/71', '15/73', '15/74', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '16/61', '16/63', '16/65', '16/67', '16/69', '16/71', '16/73', '16/75', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '17/61', '17/62', '17/63', '17/64', '17/65', '17/66', '17/67', '17/69', '17/70', '17/71', '17/72', '17/73', '17/74', '17/75', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '18/61', '18/65', '18/67', '18/71', '18/73', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '19/61', '19/62', '19/63', '19/64', '19/65', '19/66', '19/67', '19/68', '19/69', '19/70', '19/71', '19/72', '19/73', '19/74', '19/75', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '20/61', '20/63', '20/67', '20/69', '20/71', '20/73', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '21/61', '21/62', '21/64', '21/65', '21/67', '21/68', '21/71', '21/73', '21/74', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '22/61', '22/63', '22/65', '22/67', '22/69', '22/71', '22/73', '22/75', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '23/61', '23/62', '23/63', '23/64', '23/65', '23/66', '23/67', '23/68', '23/70', '23/71', '23/72', '23/73', '23/74', '23/75', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '24/61', '24/65', '24/67', '24/71', '24/73', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '25/61', '25/62', '25/63', '25/64', '25/66', '25/67', '25/68', '25/69', '25/71', '25/72', '25/73', '25/74', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '26/61', '26/63', '26/67', '26/69', '26/71', '26/73', '26/75', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '27/61', '27/62', '27/64', '27/65', '27/67', '27/68', '27/70', '27/71', '27/73', '27/74', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '28/61', '28/65', '28/67', '28/69', '28/71', '28/73', '28/75', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '29/61', '29/62', '29/63', '29/64', '29/65', '29/66', '29/67', '29/68', '29/69', '29/70', '29/71', '29/72', '29/73', '29/74', '29/75', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '30/61', '30/67', '30/71', '30/73', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '31/61', '31/63', '31/64', '31/65', '31/66', '31/67', '31/68', '31/69', '31/70', '31/71', '31/72', '31/73', '31/74', '31/75', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '32/61', '32/63', '32/65', '32/67', '32/69', '32/71', '32/73', '32/75', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '33/61', '33/62', '33/64', '33/65', '33/67', '33/68', '33/70', '33/71', '33/73', '33/74', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '34/61', '34/63', '34/65', '34/67', '34/69', '34/71', '34/73', '34/75', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '35/61', '35/62', '35/64', '35/66', '35/67', '35/68', '35/69', '35/71', '35/72', '35/73', '35/74', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '36/61', '36/65', '36/67', '36/71', '36/73', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '37/61', '37/62', '37/63', '37/64', '37/65', '37/66', '37/67', '37/68', '37/69', '37/70', '37/71', '37/72', '37/73', '37/75', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '38/61', '38/63', '38/65', '38/67', '38/69', '38/71', '38/73', '38/75', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '39/61', '39/62', '39/64', '39/67', '39/68', '39/70', '39/71', '39/73', '39/74', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '40/61', '40/63', '40/67', '40/69', '40/71', '40/73', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '41/61', '41/62', '41/63', '41/64', '41/65', '41/66', '41/67', '41/68', '41/69', '41/70', '41/71', '41/72', '41/73', '41/74', '41/75', '42/43', '42/47', '42/53', '42/55', '42/59', '42/61', '42/65', '42/67', '42/71', '42/73', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '43/61', '43/62', '43/63', '43/64', '43/65', '43/66', '43/67', '43/68', '43/69', '43/70', '43/71', '43/72', '43/73', '43/74', '43/75', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '44/61', '44/63', '44/65', '44/67', '44/69', '44/71', '44/73', '44/75', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '45/61', '45/62', '45/64', '45/67', '45/68', '45/71', '45/73', '45/74', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '46/61', '46/63', '46/65', '46/67', '46/71', '46/73', '46/75', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '47/61', '47/62', '47/63', '47/64', '47/65', '47/66', '47/67', '47/68', '47/69', '47/70', '47/71', '47/72', '47/73', '47/74', '47/75', '48/49', '48/53', '48/55', '48/59', '48/61', '48/65', '48/67', '48/71', '48/73', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '49/61', '49/62', '49/64', '49/65', '49/66', '49/67', '49/68', '49/69', '49/71', '49/72', '49/73', '49/74', '49/75', '50/51', '50/53', '50/57', '50/59', '50/61', '50/63', '50/67', '50/69', '50/71', '50/73', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '51/61', '51/62', '51/64', '51/65', '51/67', '51/70', '51/71', '51/73', '51/74', '52/53', '52/55', '52/57', '52/59', '52/61', '52/63', '52/67', '52/69', '52/71', '52/73', '52/75', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '53/61', '53/62', '53/63', '53/64', '53/65', '53/66', '53/67', '53/68', '53/69', '53/70', '53/71', '53/72', '53/73', '53/74', '53/75', '54/55', '54/59', '54/61', '54/65', '54/67', '54/71', '54/73', '55/56', '55/57', '55/58', '55/59', '55/61', '55/62', '55/63', '55/64', '55/67', '55/68', '55/69', '55/71', '55/72', '55/73', '55/74', '56/57', '56/59', '56/61', '56/65', '56/67', '56/69', '56/71', '56/73', '56/75', '57/58', '57/59', '57/61', '57/62', '57/64', '57/65', '57/67', '57/68', '57/70', '57/71', '57/73', '57/74', '58/59', '58/61', '58/63', '58/65', '58/67', '58/69', '58/71', '58/73', '58/75', '59/60', '59/61', '59/62', '59/63', '59/64', '59/65', '59/66', '59/67', '59/68', '59/69', '59/70', '59/71', '59/72', '59/73', '59/74', '59/75', '60/61', '60/67', '60/71', '60/73', '61/62', '61/63', '61/64', '61/65', '61/66', '61/67', '61/68', '61/69', '61/70', '61/71', '61/72', '61/73', '61/74', '61/75', '62/63', '62/65', '62/67', '62/69', '62/71', '62/73', '62/75', '63/64', '63/65', '63/67', '63/68', '63/71', '63/73', '63/74', '64/65', '64/67', '64/69', '64/71', '64/73', '64/75', '65/66', '65/67', '65/68', '65/69', '65/71', '65/72', '65/73', '65/74', '66/67', '66/71', '66/73', '67/68', '67/69', '67/70', '67/71', '67/72', '67/73', '67/74', '67/75', '68/69', '68/71', '68/73', '68/75', '69/70', '69/71', '69/73', '69/74', '70/71', '70/73', '71/72', '71/73', '71/74', '71/75', '72/73', '73/74', '73/75', '74/75']\n assert candidate(n = 81) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '1/26', '1/27', '1/28', '1/29', '1/30', '1/31', '1/32', '1/33', '1/34', '1/35', '1/36', '1/37', '1/38', '1/39', '1/40', '1/41', '1/42', '1/43', '1/44', '1/45', '1/46', '1/47', '1/48', '1/49', '1/50', '1/51', '1/52', '1/53', '1/54', '1/55', '1/56', '1/57', '1/58', '1/59', '1/60', '1/61', '1/62', '1/63', '1/64', '1/65', '1/66', '1/67', '1/68', '1/69', '1/70', '1/71', '1/72', '1/73', '1/74', '1/75', '1/76', '1/77', '1/78', '1/79', '1/80', '1/81', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '2/61', '2/63', '2/65', '2/67', '2/69', '2/71', '2/73', '2/75', '2/77', '2/79', '2/81', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '3/61', '3/62', '3/64', '3/65', '3/67', '3/68', '3/70', '3/71', '3/73', '3/74', '3/76', '3/77', '3/79', '3/80', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '4/61', '4/63', '4/65', '4/67', '4/69', '4/71', '4/73', '4/75', '4/77', '4/79', '4/81', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '5/61', '5/62', '5/63', '5/64', '5/66', '5/67', '5/68', '5/69', '5/71', '5/72', '5/73', '5/74', '5/76', '5/77', '5/78', '5/79', '5/81', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '6/61', '6/65', '6/67', '6/71', '6/73', '6/77', '6/79', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '7/61', '7/62', '7/64', '7/65', '7/66', '7/67', '7/68', '7/69', '7/71', '7/72', '7/73', '7/74', '7/75', '7/76', '7/78', '7/79', '7/80', '7/81', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '8/61', '8/63', '8/65', '8/67', '8/69', '8/71', '8/73', '8/75', '8/77', '8/79', '8/81', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '9/61', '9/62', '9/64', '9/65', '9/67', '9/68', '9/70', '9/71', '9/73', '9/74', '9/76', '9/77', '9/79', '9/80', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '10/61', '10/63', '10/67', '10/69', '10/71', '10/73', '10/77', '10/79', '10/81', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '11/61', '11/62', '11/63', '11/64', '11/65', '11/67', '11/68', '11/69', '11/70', '11/71', '11/72', '11/73', '11/74', '11/75', '11/76', '11/78', '11/79', '11/80', '11/81', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '12/61', '12/65', '12/67', '12/71', '12/73', '12/77', '12/79', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '13/61', '13/62', '13/63', '13/64', '13/66', '13/67', '13/68', '13/69', '13/70', '13/71', '13/72', '13/73', '13/74', '13/75', '13/76', '13/77', '13/79', '13/80', '13/81', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '14/61', '14/65', '14/67', '14/69', '14/71', '14/73', '14/75', '14/79', '14/81', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '15/61', '15/62', '15/64', '15/67', '15/68', '15/71', '15/73', '15/74', '15/76', '15/77', '15/79', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '16/61', '16/63', '16/65', '16/67', '16/69', '16/71', '16/73', '16/75', '16/77', '16/79', '16/81', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '17/61', '17/62', '17/63', '17/64', '17/65', '17/66', '17/67', '17/69', '17/70', '17/71', '17/72', '17/73', '17/74', '17/75', '17/76', '17/77', '17/78', '17/79', '17/80', '17/81', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '18/61', '18/65', '18/67', '18/71', '18/73', '18/77', '18/79', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '19/61', '19/62', '19/63', '19/64', '19/65', '19/66', '19/67', '19/68', '19/69', '19/70', '19/71', '19/72', '19/73', '19/74', '19/75', '19/77', '19/78', '19/79', '19/80', '19/81', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '20/61', '20/63', '20/67', '20/69', '20/71', '20/73', '20/77', '20/79', '20/81', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '21/61', '21/62', '21/64', '21/65', '21/67', '21/68', '21/71', '21/73', '21/74', '21/76', '21/79', '21/80', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '22/61', '22/63', '22/65', '22/67', '22/69', '22/71', '22/73', '22/75', '22/79', '22/81', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '23/61', '23/62', '23/63', '23/64', '23/65', '23/66', '23/67', '23/68', '23/70', '23/71', '23/72', '23/73', '23/74', '23/75', '23/76', '23/77', '23/78', '23/79', '23/80', '23/81', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '24/61', '24/65', '24/67', '24/71', '24/73', '24/77', '24/79', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '25/61', '25/62', '25/63', '25/64', '25/66', '25/67', '25/68', '25/69', '25/71', '25/72', '25/73', '25/74', '25/76', '25/77', '25/78', '25/79', '25/81', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '26/61', '26/63', '26/67', '26/69', '26/71', '26/73', '26/75', '26/77', '26/79', '26/81', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '27/61', '27/62', '27/64', '27/65', '27/67', '27/68', '27/70', '27/71', '27/73', '27/74', '27/76', '27/77', '27/79', '27/80', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '28/61', '28/65', '28/67', '28/69', '28/71', '28/73', '28/75', '28/79', '28/81', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '29/61', '29/62', '29/63', '29/64', '29/65', '29/66', '29/67', '29/68', '29/69', '29/70', '29/71', '29/72', '29/73', '29/74', '29/75', '29/76', '29/77', '29/78', '29/79', '29/80', '29/81', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '30/61', '30/67', '30/71', '30/73', '30/77', '30/79', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '31/61', '31/63', '31/64', '31/65', '31/66', '31/67', '31/68', '31/69', '31/70', '31/71', '31/72', '31/73', '31/74', '31/75', '31/76', '31/77', '31/78', '31/79', '31/80', '31/81', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '32/61', '32/63', '32/65', '32/67', '32/69', '32/71', '32/73', '32/75', '32/77', '32/79', '32/81', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '33/61', '33/62', '33/64', '33/65', '33/67', '33/68', '33/70', '33/71', '33/73', '33/74', '33/76', '33/79', '33/80', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '34/61', '34/63', '34/65', '34/67', '34/69', '34/71', '34/73', '34/75', '34/77', '34/79', '34/81', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '35/61', '35/62', '35/64', '35/66', '35/67', '35/68', '35/69', '35/71', '35/72', '35/73', '35/74', '35/76', '35/78', '35/79', '35/81', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '36/61', '36/65', '36/67', '36/71', '36/73', '36/77', '36/79', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '37/61', '37/62', '37/63', '37/64', '37/65', '37/66', '37/67', '37/68', '37/69', '37/70', '37/71', '37/72', '37/73', '37/75', '37/76', '37/77', '37/78', '37/79', '37/80', '37/81', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '38/61', '38/63', '38/65', '38/67', '38/69', '38/71', '38/73', '38/75', '38/77', '38/79', '38/81', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '39/61', '39/62', '39/64', '39/67', '39/68', '39/70', '39/71', '39/73', '39/74', '39/76', '39/77', '39/79', '39/80', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '40/61', '40/63', '40/67', '40/69', '40/71', '40/73', '40/77', '40/79', '40/81', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '41/61', '41/62', '41/63', '41/64', '41/65', '41/66', '41/67', '41/68', '41/69', '41/70', '41/71', '41/72', '41/73', '41/74', '41/75', '41/76', '41/77', '41/78', '41/79', '41/80', '41/81', '42/43', '42/47', '42/53', '42/55', '42/59', '42/61', '42/65', '42/67', '42/71', '42/73', '42/79', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '43/61', '43/62', '43/63', '43/64', '43/65', '43/66', '43/67', '43/68', '43/69', '43/70', '43/71', '43/72', '43/73', '43/74', '43/75', '43/76', '43/77', '43/78', '43/79', '43/80', '43/81', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '44/61', '44/63', '44/65', '44/67', '44/69', '44/71', '44/73', '44/75', '44/79', '44/81', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '45/61', '45/62', '45/64', '45/67', '45/68', '45/71', '45/73', '45/74', '45/76', '45/77', '45/79', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '46/61', '46/63', '46/65', '46/67', '46/71', '46/73', '46/75', '46/77', '46/79', '46/81', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '47/61', '47/62', '47/63', '47/64', '47/65', '47/66', '47/67', '47/68', '47/69', '47/70', '47/71', '47/72', '47/73', '47/74', '47/75', '47/76', '47/77', '47/78', '47/79', '47/80', '47/81', '48/49', '48/53', '48/55', '48/59', '48/61', '48/65', '48/67', '48/71', '48/73', '48/77', '48/79', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '49/61', '49/62', '49/64', '49/65', '49/66', '49/67', '49/68', '49/69', '49/71', '49/72', '49/73', '49/74', '49/75', '49/76', '49/78', '49/79', '49/80', '49/81', '50/51', '50/53', '50/57', '50/59', '50/61', '50/63', '50/67', '50/69', '50/71', '50/73', '50/77', '50/79', '50/81', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '51/61', '51/62', '51/64', '51/65', '51/67', '51/70', '51/71', '51/73', '51/74', '51/76', '51/77', '51/79', '51/80', '52/53', '52/55', '52/57', '52/59', '52/61', '52/63', '52/67', '52/69', '52/71', '52/73', '52/75', '52/77', '52/79', '52/81', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '53/61', '53/62', '53/63', '53/64', '53/65', '53/66', '53/67', '53/68', '53/69', '53/70', '53/71', '53/72', '53/73', '53/74', '53/75', '53/76', '53/77', '53/78', '53/79', '53/80', '53/81', '54/55', '54/59', '54/61', '54/65', '54/67', '54/71', '54/73', '54/77', '54/79', '55/56', '55/57', '55/58', '55/59', '55/61', '55/62', '55/63', '55/64', '55/67', '55/68', '55/69', '55/71', '55/72', '55/73', '55/74', '55/76', '55/78', '55/79', '55/81', '56/57', '56/59', '56/61', '56/65', '56/67', '56/69', '56/71', '56/73', '56/75', '56/79', '56/81', '57/58', '57/59', '57/61', '57/62', '57/64', '57/65', '57/67', '57/68', '57/70', '57/71', '57/73', '57/74', '57/77', '57/79', '57/80', '58/59', '58/61', '58/63', '58/65', '58/67', '58/69', '58/71', '58/73', '58/75', '58/77', '58/79', '58/81', '59/60', '59/61', '59/62', '59/63', '59/64', '59/65', '59/66', '59/67', '59/68', '59/69', '59/70', '59/71', '59/72', '59/73', '59/74', '59/75', '59/76', '59/77', '59/78', '59/79', '59/80', '59/81', '60/61', '60/67', '60/71', '60/73', '60/77', '60/79', '61/62', '61/63', '61/64', '61/65', '61/66', '61/67', '61/68', '61/69', '61/70', '61/71', '61/72', '61/73', '61/74', '61/75', '61/76', '61/77', '61/78', '61/79', '61/80', '61/81', '62/63', '62/65', '62/67', '62/69', '62/71', '62/73', '62/75', '62/77', '62/79', '62/81', '63/64', '63/65', '63/67', '63/68', '63/71', '63/73', '63/74', '63/76', '63/79', '63/80', '64/65', '64/67', '64/69', '64/71', '64/73', '64/75', '64/77', '64/79', '64/81', '65/66', '65/67', '65/68', '65/69', '65/71', '65/72', '65/73', '65/74', '65/76', '65/77', '65/79', '65/81', '66/67', '66/71', '66/73', '66/79', '67/68', '67/69', '67/70', '67/71', '67/72', '67/73', '67/74', '67/75', '67/76', '67/77', '67/78', '67/79', '67/80', '67/81', '68/69', '68/71', '68/73', '68/75', '68/77', '68/79', '68/81', '69/70', '69/71', '69/73', '69/74', '69/76', '69/77', '69/79', '69/80', '70/71', '70/73', '70/79', '70/81', '71/72', '71/73', '71/74', '71/75', '71/76', '71/77', '71/78', '71/79', '71/80', '71/81', '72/73', '72/77', '72/79', '73/74', '73/75', '73/76', '73/77', '73/78', '73/79', '73/80', '73/81', '74/75', '74/77', '74/79', '74/81', '75/76', '75/77', '75/79', '76/77', '76/79', '76/81', '77/78', '77/79', '77/80', '77/81', '78/79', '79/80', '79/81', '80/81']\n assert candidate(n = 15) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '6/7', '6/11', '6/13', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '8/9', '8/11', '8/13', '8/15', '9/10', '9/11', '9/13', '9/14', '10/11', '10/13', '11/12', '11/13', '11/14', '11/15', '12/13', '13/14', '13/15', '14/15']\n assert candidate(n = 85) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '1/26', '1/27', '1/28', '1/29', '1/30', '1/31', '1/32', '1/33', '1/34', '1/35', '1/36', '1/37', '1/38', '1/39', '1/40', '1/41', '1/42', '1/43', '1/44', '1/45', '1/46', '1/47', '1/48', '1/49', '1/50', '1/51', '1/52', '1/53', '1/54', '1/55', '1/56', '1/57', '1/58', '1/59', '1/60', '1/61', '1/62', '1/63', '1/64', '1/65', '1/66', '1/67', '1/68', '1/69', '1/70', '1/71', '1/72', '1/73', '1/74', '1/75', '1/76', '1/77', '1/78', '1/79', '1/80', '1/81', '1/82', '1/83', '1/84', '1/85', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '2/61', '2/63', '2/65', '2/67', '2/69', '2/71', '2/73', '2/75', '2/77', '2/79', '2/81', '2/83', '2/85', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '3/61', '3/62', '3/64', '3/65', '3/67', '3/68', '3/70', '3/71', '3/73', '3/74', '3/76', '3/77', '3/79', '3/80', '3/82', '3/83', '3/85', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '4/61', '4/63', '4/65', '4/67', '4/69', '4/71', '4/73', '4/75', '4/77', '4/79', '4/81', '4/83', '4/85', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '5/61', '5/62', '5/63', '5/64', '5/66', '5/67', '5/68', '5/69', '5/71', '5/72', '5/73', '5/74', '5/76', '5/77', '5/78', '5/79', '5/81', '5/82', '5/83', '5/84', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '6/61', '6/65', '6/67', '6/71', '6/73', '6/77', '6/79', '6/83', '6/85', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '7/61', '7/62', '7/64', '7/65', '7/66', '7/67', '7/68', '7/69', '7/71', '7/72', '7/73', '7/74', '7/75', '7/76', '7/78', '7/79', '7/80', '7/81', '7/82', '7/83', '7/85', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '8/61', '8/63', '8/65', '8/67', '8/69', '8/71', '8/73', '8/75', '8/77', '8/79', '8/81', '8/83', '8/85', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '9/61', '9/62', '9/64', '9/65', '9/67', '9/68', '9/70', '9/71', '9/73', '9/74', '9/76', '9/77', '9/79', '9/80', '9/82', '9/83', '9/85', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '10/61', '10/63', '10/67', '10/69', '10/71', '10/73', '10/77', '10/79', '10/81', '10/83', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '11/61', '11/62', '11/63', '11/64', '11/65', '11/67', '11/68', '11/69', '11/70', '11/71', '11/72', '11/73', '11/74', '11/75', '11/76', '11/78', '11/79', '11/80', '11/81', '11/82', '11/83', '11/84', '11/85', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '12/61', '12/65', '12/67', '12/71', '12/73', '12/77', '12/79', '12/83', '12/85', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '13/61', '13/62', '13/63', '13/64', '13/66', '13/67', '13/68', '13/69', '13/70', '13/71', '13/72', '13/73', '13/74', '13/75', '13/76', '13/77', '13/79', '13/80', '13/81', '13/82', '13/83', '13/84', '13/85', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '14/61', '14/65', '14/67', '14/69', '14/71', '14/73', '14/75', '14/79', '14/81', '14/83', '14/85', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '15/61', '15/62', '15/64', '15/67', '15/68', '15/71', '15/73', '15/74', '15/76', '15/77', '15/79', '15/82', '15/83', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '16/61', '16/63', '16/65', '16/67', '16/69', '16/71', '16/73', '16/75', '16/77', '16/79', '16/81', '16/83', '16/85', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '17/61', '17/62', '17/63', '17/64', '17/65', '17/66', '17/67', '17/69', '17/70', '17/71', '17/72', '17/73', '17/74', '17/75', '17/76', '17/77', '17/78', '17/79', '17/80', '17/81', '17/82', '17/83', '17/84', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '18/61', '18/65', '18/67', '18/71', '18/73', '18/77', '18/79', '18/83', '18/85', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '19/61', '19/62', '19/63', '19/64', '19/65', '19/66', '19/67', '19/68', '19/69', '19/70', '19/71', '19/72', '19/73', '19/74', '19/75', '19/77', '19/78', '19/79', '19/80', '19/81', '19/82', '19/83', '19/84', '19/85', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '20/61', '20/63', '20/67', '20/69', '20/71', '20/73', '20/77', '20/79', '20/81', '20/83', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '21/61', '21/62', '21/64', '21/65', '21/67', '21/68', '21/71', '21/73', '21/74', '21/76', '21/79', '21/80', '21/82', '21/83', '21/85', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '22/61', '22/63', '22/65', '22/67', '22/69', '22/71', '22/73', '22/75', '22/79', '22/81', '22/83', '22/85', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '23/61', '23/62', '23/63', '23/64', '23/65', '23/66', '23/67', '23/68', '23/70', '23/71', '23/72', '23/73', '23/74', '23/75', '23/76', '23/77', '23/78', '23/79', '23/80', '23/81', '23/82', '23/83', '23/84', '23/85', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '24/61', '24/65', '24/67', '24/71', '24/73', '24/77', '24/79', '24/83', '24/85', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '25/61', '25/62', '25/63', '25/64', '25/66', '25/67', '25/68', '25/69', '25/71', '25/72', '25/73', '25/74', '25/76', '25/77', '25/78', '25/79', '25/81', '25/82', '25/83', '25/84', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '26/61', '26/63', '26/67', '26/69', '26/71', '26/73', '26/75', '26/77', '26/79', '26/81', '26/83', '26/85', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '27/61', '27/62', '27/64', '27/65', '27/67', '27/68', '27/70', '27/71', '27/73', '27/74', '27/76', '27/77', '27/79', '27/80', '27/82', '27/83', '27/85', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '28/61', '28/65', '28/67', '28/69', '28/71', '28/73', '28/75', '28/79', '28/81', '28/83', '28/85', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '29/61', '29/62', '29/63', '29/64', '29/65', '29/66', '29/67', '29/68', '29/69', '29/70', '29/71', '29/72', '29/73', '29/74', '29/75', '29/76', '29/77', '29/78', '29/79', '29/80', '29/81', '29/82', '29/83', '29/84', '29/85', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '30/61', '30/67', '30/71', '30/73', '30/77', '30/79', '30/83', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '31/61', '31/63', '31/64', '31/65', '31/66', '31/67', '31/68', '31/69', '31/70', '31/71', '31/72', '31/73', '31/74', '31/75', '31/76', '31/77', '31/78', '31/79', '31/80', '31/81', '31/82', '31/83', '31/84', '31/85', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '32/61', '32/63', '32/65', '32/67', '32/69', '32/71', '32/73', '32/75', '32/77', '32/79', '32/81', '32/83', '32/85', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '33/61', '33/62', '33/64', '33/65', '33/67', '33/68', '33/70', '33/71', '33/73', '33/74', '33/76', '33/79', '33/80', '33/82', '33/83', '33/85', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '34/61', '34/63', '34/65', '34/67', '34/69', '34/71', '34/73', '34/75', '34/77', '34/79', '34/81', '34/83', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '35/61', '35/62', '35/64', '35/66', '35/67', '35/68', '35/69', '35/71', '35/72', '35/73', '35/74', '35/76', '35/78', '35/79', '35/81', '35/82', '35/83', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '36/61', '36/65', '36/67', '36/71', '36/73', '36/77', '36/79', '36/83', '36/85', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '37/61', '37/62', '37/63', '37/64', '37/65', '37/66', '37/67', '37/68', '37/69', '37/70', '37/71', '37/72', '37/73', '37/75', '37/76', '37/77', '37/78', '37/79', '37/80', '37/81', '37/82', '37/83', '37/84', '37/85', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '38/61', '38/63', '38/65', '38/67', '38/69', '38/71', '38/73', '38/75', '38/77', '38/79', '38/81', '38/83', '38/85', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '39/61', '39/62', '39/64', '39/67', '39/68', '39/70', '39/71', '39/73', '39/74', '39/76', '39/77', '39/79', '39/80', '39/82', '39/83', '39/85', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '40/61', '40/63', '40/67', '40/69', '40/71', '40/73', '40/77', '40/79', '40/81', '40/83', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '41/61', '41/62', '41/63', '41/64', '41/65', '41/66', '41/67', '41/68', '41/69', '41/70', '41/71', '41/72', '41/73', '41/74', '41/75', '41/76', '41/77', '41/78', '41/79', '41/80', '41/81', '41/83', '41/84', '41/85', '42/43', '42/47', '42/53', '42/55', '42/59', '42/61', '42/65', '42/67', '42/71', '42/73', '42/79', '42/83', '42/85', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '43/61', '43/62', '43/63', '43/64', '43/65', '43/66', '43/67', '43/68', '43/69', '43/70', '43/71', '43/72', '43/73', '43/74', '43/75', '43/76', '43/77', '43/78', '43/79', '43/80', '43/81', '43/82', '43/83', '43/84', '43/85', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '44/61', '44/63', '44/65', '44/67', '44/69', '44/71', '44/73', '44/75', '44/79', '44/81', '44/83', '44/85', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '45/61', '45/62', '45/64', '45/67', '45/68', '45/71', '45/73', '45/74', '45/76', '45/77', '45/79', '45/82', '45/83', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '46/61', '46/63', '46/65', '46/67', '46/71', '46/73', '46/75', '46/77', '46/79', '46/81', '46/83', '46/85', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '47/61', '47/62', '47/63', '47/64', '47/65', '47/66', '47/67', '47/68', '47/69', '47/70', '47/71', '47/72', '47/73', '47/74', '47/75', '47/76', '47/77', '47/78', '47/79', '47/80', '47/81', '47/82', '47/83', '47/84', '47/85', '48/49', '48/53', '48/55', '48/59', '48/61', '48/65', '48/67', '48/71', '48/73', '48/77', '48/79', '48/83', '48/85', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '49/61', '49/62', '49/64', '49/65', '49/66', '49/67', '49/68', '49/69', '49/71', '49/72', '49/73', '49/74', '49/75', '49/76', '49/78', '49/79', '49/80', '49/81', '49/82', '49/83', '49/85', '50/51', '50/53', '50/57', '50/59', '50/61', '50/63', '50/67', '50/69', '50/71', '50/73', '50/77', '50/79', '50/81', '50/83', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '51/61', '51/62', '51/64', '51/65', '51/67', '51/70', '51/71', '51/73', '51/74', '51/76', '51/77', '51/79', '51/80', '51/82', '51/83', '52/53', '52/55', '52/57', '52/59', '52/61', '52/63', '52/67', '52/69', '52/71', '52/73', '52/75', '52/77', '52/79', '52/81', '52/83', '52/85', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '53/61', '53/62', '53/63', '53/64', '53/65', '53/66', '53/67', '53/68', '53/69', '53/70', '53/71', '53/72', '53/73', '53/74', '53/75', '53/76', '53/77', '53/78', '53/79', '53/80', '53/81', '53/82', '53/83', '53/84', '53/85', '54/55', '54/59', '54/61', '54/65', '54/67', '54/71', '54/73', '54/77', '54/79', '54/83', '54/85', '55/56', '55/57', '55/58', '55/59', '55/61', '55/62', '55/63', '55/64', '55/67', '55/68', '55/69', '55/71', '55/72', '55/73', '55/74', '55/76', '55/78', '55/79', '55/81', '55/82', '55/83', '55/84', '56/57', '56/59', '56/61', '56/65', '56/67', '56/69', '56/71', '56/73', '56/75', '56/79', '56/81', '56/83', '56/85', '57/58', '57/59', '57/61', '57/62', '57/64', '57/65', '57/67', '57/68', '57/70', '57/71', '57/73', '57/74', '57/77', '57/79', '57/80', '57/82', '57/83', '57/85', '58/59', '58/61', '58/63', '58/65', '58/67', '58/69', '58/71', '58/73', '58/75', '58/77', '58/79', '58/81', '58/83', '58/85', '59/60', '59/61', '59/62', '59/63', '59/64', '59/65', '59/66', '59/67', '59/68', '59/69', '59/70', '59/71', '59/72', '59/73', '59/74', '59/75', '59/76', '59/77', '59/78', '59/79', '59/80', '59/81', '59/82', '59/83', '59/84', '59/85', '60/61', '60/67', '60/71', '60/73', '60/77', '60/79', '60/83', '61/62', '61/63', '61/64', '61/65', '61/66', '61/67', '61/68', '61/69', '61/70', '61/71', '61/72', '61/73', '61/74', '61/75', '61/76', '61/77', '61/78', '61/79', '61/80', '61/81', '61/82', '61/83', '61/84', '61/85', '62/63', '62/65', '62/67', '62/69', '62/71', '62/73', '62/75', '62/77', '62/79', '62/81', '62/83', '62/85', '63/64', '63/65', '63/67', '63/68', '63/71', '63/73', '63/74', '63/76', '63/79', '63/80', '63/82', '63/83', '63/85', '64/65', '64/67', '64/69', '64/71', '64/73', '64/75', '64/77', '64/79', '64/81', '64/83', '64/85', '65/66', '65/67', '65/68', '65/69', '65/71', '65/72', '65/73', '65/74', '65/76', '65/77', '65/79', '65/81', '65/82', '65/83', '65/84', '66/67', '66/71', '66/73', '66/79', '66/83', '66/85', '67/68', '67/69', '67/70', '67/71', '67/72', '67/73', '67/74', '67/75', '67/76', '67/77', '67/78', '67/79', '67/80', '67/81', '67/82', '67/83', '67/84', '67/85', '68/69', '68/71', '68/73', '68/75', '68/77', '68/79', '68/81', '68/83', '69/70', '69/71', '69/73', '69/74', '69/76', '69/77', '69/79', '69/80', '69/82', '69/83', '69/85', '70/71', '70/73', '70/79', '70/81', '70/83', '71/72', '71/73', '71/74', '71/75', '71/76', '71/77', '71/78', '71/79', '71/80', '71/81', '71/82', '71/83', '71/84', '71/85', '72/73', '72/77', '72/79', '72/83', '72/85', '73/74', '73/75', '73/76', '73/77', '73/78', '73/79', '73/80', '73/81', '73/82', '73/83', '73/84', '73/85', '74/75', '74/77', '74/79', '74/81', '74/83', '74/85', '75/76', '75/77', '75/79', '75/82', '75/83', '76/77', '76/79', '76/81', '76/83', '76/85', '77/78', '77/79', '77/80', '77/81', '77/82', '77/83', '77/85', '78/79', '78/83', '78/85', '79/80', '79/81', '79/82', '79/83', '79/84', '79/85', '80/81', '80/83', '81/82', '81/83', '81/85', '82/83', '82/85', '83/84', '83/85', '84/85']\n assert candidate(n = 1) == []\n assert candidate(n = 55) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '1/26', '1/27', '1/28', '1/29', '1/30', '1/31', '1/32', '1/33', '1/34', '1/35', '1/36', '1/37', '1/38', '1/39', '1/40', '1/41', '1/42', '1/43', '1/44', '1/45', '1/46', '1/47', '1/48', '1/49', '1/50', '1/51', '1/52', '1/53', '1/54', '1/55', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '42/43', '42/47', '42/53', '42/55', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '44/45', '44/47', '44/49', '44/51', '44/53', '45/46', '45/47', '45/49', '45/52', '45/53', '46/47', '46/49', '46/51', '46/53', '46/55', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '48/49', '48/53', '48/55', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '50/51', '50/53', '51/52', '51/53', '51/55', '52/53', '52/55', '53/54', '53/55', '54/55']\n assert candidate(n = 90) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '1/26', '1/27', '1/28', '1/29', '1/30', '1/31', '1/32', '1/33', '1/34', '1/35', '1/36', '1/37', '1/38', '1/39', '1/40', '1/41', '1/42', '1/43', '1/44', '1/45', '1/46', '1/47', '1/48', '1/49', '1/50', '1/51', '1/52', '1/53', '1/54', '1/55', '1/56', '1/57', '1/58', '1/59', '1/60', '1/61', '1/62', '1/63', '1/64', '1/65', '1/66', '1/67', '1/68', '1/69', '1/70', '1/71', '1/72', '1/73', '1/74', '1/75', '1/76', '1/77', '1/78', '1/79', '1/80', '1/81', '1/82', '1/83', '1/84', '1/85', '1/86', '1/87', '1/88', '1/89', '1/90', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '2/27', '2/29', '2/31', '2/33', '2/35', '2/37', '2/39', '2/41', '2/43', '2/45', '2/47', '2/49', '2/51', '2/53', '2/55', '2/57', '2/59', '2/61', '2/63', '2/65', '2/67', '2/69', '2/71', '2/73', '2/75', '2/77', '2/79', '2/81', '2/83', '2/85', '2/87', '2/89', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '3/26', '3/28', '3/29', '3/31', '3/32', '3/34', '3/35', '3/37', '3/38', '3/40', '3/41', '3/43', '3/44', '3/46', '3/47', '3/49', '3/50', '3/52', '3/53', '3/55', '3/56', '3/58', '3/59', '3/61', '3/62', '3/64', '3/65', '3/67', '3/68', '3/70', '3/71', '3/73', '3/74', '3/76', '3/77', '3/79', '3/80', '3/82', '3/83', '3/85', '3/86', '3/88', '3/89', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '4/27', '4/29', '4/31', '4/33', '4/35', '4/37', '4/39', '4/41', '4/43', '4/45', '4/47', '4/49', '4/51', '4/53', '4/55', '4/57', '4/59', '4/61', '4/63', '4/65', '4/67', '4/69', '4/71', '4/73', '4/75', '4/77', '4/79', '4/81', '4/83', '4/85', '4/87', '4/89', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '5/26', '5/27', '5/28', '5/29', '5/31', '5/32', '5/33', '5/34', '5/36', '5/37', '5/38', '5/39', '5/41', '5/42', '5/43', '5/44', '5/46', '5/47', '5/48', '5/49', '5/51', '5/52', '5/53', '5/54', '5/56', '5/57', '5/58', '5/59', '5/61', '5/62', '5/63', '5/64', '5/66', '5/67', '5/68', '5/69', '5/71', '5/72', '5/73', '5/74', '5/76', '5/77', '5/78', '5/79', '5/81', '5/82', '5/83', '5/84', '5/86', '5/87', '5/88', '5/89', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '6/29', '6/31', '6/35', '6/37', '6/41', '6/43', '6/47', '6/49', '6/53', '6/55', '6/59', '6/61', '6/65', '6/67', '6/71', '6/73', '6/77', '6/79', '6/83', '6/85', '6/89', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '7/26', '7/27', '7/29', '7/30', '7/31', '7/32', '7/33', '7/34', '7/36', '7/37', '7/38', '7/39', '7/40', '7/41', '7/43', '7/44', '7/45', '7/46', '7/47', '7/48', '7/50', '7/51', '7/52', '7/53', '7/54', '7/55', '7/57', '7/58', '7/59', '7/60', '7/61', '7/62', '7/64', '7/65', '7/66', '7/67', '7/68', '7/69', '7/71', '7/72', '7/73', '7/74', '7/75', '7/76', '7/78', '7/79', '7/80', '7/81', '7/82', '7/83', '7/85', '7/86', '7/87', '7/88', '7/89', '7/90', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '8/27', '8/29', '8/31', '8/33', '8/35', '8/37', '8/39', '8/41', '8/43', '8/45', '8/47', '8/49', '8/51', '8/53', '8/55', '8/57', '8/59', '8/61', '8/63', '8/65', '8/67', '8/69', '8/71', '8/73', '8/75', '8/77', '8/79', '8/81', '8/83', '8/85', '8/87', '8/89', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '9/26', '9/28', '9/29', '9/31', '9/32', '9/34', '9/35', '9/37', '9/38', '9/40', '9/41', '9/43', '9/44', '9/46', '9/47', '9/49', '9/50', '9/52', '9/53', '9/55', '9/56', '9/58', '9/59', '9/61', '9/62', '9/64', '9/65', '9/67', '9/68', '9/70', '9/71', '9/73', '9/74', '9/76', '9/77', '9/79', '9/80', '9/82', '9/83', '9/85', '9/86', '9/88', '9/89', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '10/27', '10/29', '10/31', '10/33', '10/37', '10/39', '10/41', '10/43', '10/47', '10/49', '10/51', '10/53', '10/57', '10/59', '10/61', '10/63', '10/67', '10/69', '10/71', '10/73', '10/77', '10/79', '10/81', '10/83', '10/87', '10/89', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '11/26', '11/27', '11/28', '11/29', '11/30', '11/31', '11/32', '11/34', '11/35', '11/36', '11/37', '11/38', '11/39', '11/40', '11/41', '11/42', '11/43', '11/45', '11/46', '11/47', '11/48', '11/49', '11/50', '11/51', '11/52', '11/53', '11/54', '11/56', '11/57', '11/58', '11/59', '11/60', '11/61', '11/62', '11/63', '11/64', '11/65', '11/67', '11/68', '11/69', '11/70', '11/71', '11/72', '11/73', '11/74', '11/75', '11/76', '11/78', '11/79', '11/80', '11/81', '11/82', '11/83', '11/84', '11/85', '11/86', '11/87', '11/89', '11/90', '12/13', '12/17', '12/19', '12/23', '12/25', '12/29', '12/31', '12/35', '12/37', '12/41', '12/43', '12/47', '12/49', '12/53', '12/55', '12/59', '12/61', '12/65', '12/67', '12/71', '12/73', '12/77', '12/79', '12/83', '12/85', '12/89', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '13/27', '13/28', '13/29', '13/30', '13/31', '13/32', '13/33', '13/34', '13/35', '13/36', '13/37', '13/38', '13/40', '13/41', '13/42', '13/43', '13/44', '13/45', '13/46', '13/47', '13/48', '13/49', '13/50', '13/51', '13/53', '13/54', '13/55', '13/56', '13/57', '13/58', '13/59', '13/60', '13/61', '13/62', '13/63', '13/64', '13/66', '13/67', '13/68', '13/69', '13/70', '13/71', '13/72', '13/73', '13/74', '13/75', '13/76', '13/77', '13/79', '13/80', '13/81', '13/82', '13/83', '13/84', '13/85', '13/86', '13/87', '13/88', '13/89', '13/90', '14/15', '14/17', '14/19', '14/23', '14/25', '14/27', '14/29', '14/31', '14/33', '14/37', '14/39', '14/41', '14/43', '14/45', '14/47', '14/51', '14/53', '14/55', '14/57', '14/59', '14/61', '14/65', '14/67', '14/69', '14/71', '14/73', '14/75', '14/79', '14/81', '14/83', '14/85', '14/87', '14/89', '15/16', '15/17', '15/19', '15/22', '15/23', '15/26', '15/28', '15/29', '15/31', '15/32', '15/34', '15/37', '15/38', '15/41', '15/43', '15/44', '15/46', '15/47', '15/49', '15/52', '15/53', '15/56', '15/58', '15/59', '15/61', '15/62', '15/64', '15/67', '15/68', '15/71', '15/73', '15/74', '15/76', '15/77', '15/79', '15/82', '15/83', '15/86', '15/88', '15/89', '16/17', '16/19', '16/21', '16/23', '16/25', '16/27', '16/29', '16/31', '16/33', '16/35', '16/37', '16/39', '16/41', '16/43', '16/45', '16/47', '16/49', '16/51', '16/53', '16/55', '16/57', '16/59', '16/61', '16/63', '16/65', '16/67', '16/69', '16/71', '16/73', '16/75', '16/77', '16/79', '16/81', '16/83', '16/85', '16/87', '16/89', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '17/26', '17/27', '17/28', '17/29', '17/30', '17/31', '17/32', '17/33', '17/35', '17/36', '17/37', '17/38', '17/39', '17/40', '17/41', '17/42', '17/43', '17/44', '17/45', '17/46', '17/47', '17/48', '17/49', '17/50', '17/52', '17/53', '17/54', '17/55', '17/56', '17/57', '17/58', '17/59', '17/60', '17/61', '17/62', '17/63', '17/64', '17/65', '17/66', '17/67', '17/69', '17/70', '17/71', '17/72', '17/73', '17/74', '17/75', '17/76', '17/77', '17/78', '17/79', '17/80', '17/81', '17/82', '17/83', '17/84', '17/86', '17/87', '17/88', '17/89', '17/90', '18/19', '18/23', '18/25', '18/29', '18/31', '18/35', '18/37', '18/41', '18/43', '18/47', '18/49', '18/53', '18/55', '18/59', '18/61', '18/65', '18/67', '18/71', '18/73', '18/77', '18/79', '18/83', '18/85', '18/89', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '19/26', '19/27', '19/28', '19/29', '19/30', '19/31', '19/32', '19/33', '19/34', '19/35', '19/36', '19/37', '19/39', '19/40', '19/41', '19/42', '19/43', '19/44', '19/45', '19/46', '19/47', '19/48', '19/49', '19/50', '19/51', '19/52', '19/53', '19/54', '19/55', '19/56', '19/58', '19/59', '19/60', '19/61', '19/62', '19/63', '19/64', '19/65', '19/66', '19/67', '19/68', '19/69', '19/70', '19/71', '19/72', '19/73', '19/74', '19/75', '19/77', '19/78', '19/79', '19/80', '19/81', '19/82', '19/83', '19/84', '19/85', '19/86', '19/87', '19/88', '19/89', '19/90', '20/21', '20/23', '20/27', '20/29', '20/31', '20/33', '20/37', '20/39', '20/41', '20/43', '20/47', '20/49', '20/51', '20/53', '20/57', '20/59', '20/61', '20/63', '20/67', '20/69', '20/71', '20/73', '20/77', '20/79', '20/81', '20/83', '20/87', '20/89', '21/22', '21/23', '21/25', '21/26', '21/29', '21/31', '21/32', '21/34', '21/37', '21/38', '21/40', '21/41', '21/43', '21/44', '21/46', '21/47', '21/50', '21/52', '21/53', '21/55', '21/58', '21/59', '21/61', '21/62', '21/64', '21/65', '21/67', '21/68', '21/71', '21/73', '21/74', '21/76', '21/79', '21/80', '21/82', '21/83', '21/85', '21/86', '21/88', '21/89', '22/23', '22/25', '22/27', '22/29', '22/31', '22/35', '22/37', '22/39', '22/41', '22/43', '22/45', '22/47', '22/49', '22/51', '22/53', '22/57', '22/59', '22/61', '22/63', '22/65', '22/67', '22/69', '22/71', '22/73', '22/75', '22/79', '22/81', '22/83', '22/85', '22/87', '22/89', '23/24', '23/25', '23/26', '23/27', '23/28', '23/29', '23/30', '23/31', '23/32', '23/33', '23/34', '23/35', '23/36', '23/37', '23/38', '23/39', '23/40', '23/41', '23/42', '23/43', '23/44', '23/45', '23/47', '23/48', '23/49', '23/50', '23/51', '23/52', '23/53', '23/54', '23/55', '23/56', '23/57', '23/58', '23/59', '23/60', '23/61', '23/62', '23/63', '23/64', '23/65', '23/66', '23/67', '23/68', '23/70', '23/71', '23/72', '23/73', '23/74', '23/75', '23/76', '23/77', '23/78', '23/79', '23/80', '23/81', '23/82', '23/83', '23/84', '23/85', '23/86', '23/87', '23/88', '23/89', '23/90', '24/25', '24/29', '24/31', '24/35', '24/37', '24/41', '24/43', '24/47', '24/49', '24/53', '24/55', '24/59', '24/61', '24/65', '24/67', '24/71', '24/73', '24/77', '24/79', '24/83', '24/85', '24/89', '25/26', '25/27', '25/28', '25/29', '25/31', '25/32', '25/33', '25/34', '25/36', '25/37', '25/38', '25/39', '25/41', '25/42', '25/43', '25/44', '25/46', '25/47', '25/48', '25/49', '25/51', '25/52', '25/53', '25/54', '25/56', '25/57', '25/58', '25/59', '25/61', '25/62', '25/63', '25/64', '25/66', '25/67', '25/68', '25/69', '25/71', '25/72', '25/73', '25/74', '25/76', '25/77', '25/78', '25/79', '25/81', '25/82', '25/83', '25/84', '25/86', '25/87', '25/88', '25/89', '26/27', '26/29', '26/31', '26/33', '26/35', '26/37', '26/41', '26/43', '26/45', '26/47', '26/49', '26/51', '26/53', '26/55', '26/57', '26/59', '26/61', '26/63', '26/67', '26/69', '26/71', '26/73', '26/75', '26/77', '26/79', '26/81', '26/83', '26/85', '26/87', '26/89', '27/28', '27/29', '27/31', '27/32', '27/34', '27/35', '27/37', '27/38', '27/40', '27/41', '27/43', '27/44', '27/46', '27/47', '27/49', '27/50', '27/52', '27/53', '27/55', '27/56', '27/58', '27/59', '27/61', '27/62', '27/64', '27/65', '27/67', '27/68', '27/70', '27/71', '27/73', '27/74', '27/76', '27/77', '27/79', '27/80', '27/82', '27/83', '27/85', '27/86', '27/88', '27/89', '28/29', '28/31', '28/33', '28/37', '28/39', '28/41', '28/43', '28/45', '28/47', '28/51', '28/53', '28/55', '28/57', '28/59', '28/61', '28/65', '28/67', '28/69', '28/71', '28/73', '28/75', '28/79', '28/81', '28/83', '28/85', '28/87', '28/89', '29/30', '29/31', '29/32', '29/33', '29/34', '29/35', '29/36', '29/37', '29/38', '29/39', '29/40', '29/41', '29/42', '29/43', '29/44', '29/45', '29/46', '29/47', '29/48', '29/49', '29/50', '29/51', '29/52', '29/53', '29/54', '29/55', '29/56', '29/57', '29/59', '29/60', '29/61', '29/62', '29/63', '29/64', '29/65', '29/66', '29/67', '29/68', '29/69', '29/70', '29/71', '29/72', '29/73', '29/74', '29/75', '29/76', '29/77', '29/78', '29/79', '29/80', '29/81', '29/82', '29/83', '29/84', '29/85', '29/86', '29/88', '29/89', '29/90', '30/31', '30/37', '30/41', '30/43', '30/47', '30/49', '30/53', '30/59', '30/61', '30/67', '30/71', '30/73', '30/77', '30/79', '30/83', '30/89', '31/32', '31/33', '31/34', '31/35', '31/36', '31/37', '31/38', '31/39', '31/40', '31/41', '31/42', '31/43', '31/44', '31/45', '31/46', '31/47', '31/48', '31/49', '31/50', '31/51', '31/52', '31/53', '31/54', '31/55', '31/56', '31/57', '31/58', '31/59', '31/60', '31/61', '31/63', '31/64', '31/65', '31/66', '31/67', '31/68', '31/69', '31/70', '31/71', '31/72', '31/73', '31/74', '31/75', '31/76', '31/77', '31/78', '31/79', '31/80', '31/81', '31/82', '31/83', '31/84', '31/85', '31/86', '31/87', '31/88', '31/89', '31/90', '32/33', '32/35', '32/37', '32/39', '32/41', '32/43', '32/45', '32/47', '32/49', '32/51', '32/53', '32/55', '32/57', '32/59', '32/61', '32/63', '32/65', '32/67', '32/69', '32/71', '32/73', '32/75', '32/77', '32/79', '32/81', '32/83', '32/85', '32/87', '32/89', '33/34', '33/35', '33/37', '33/38', '33/40', '33/41', '33/43', '33/46', '33/47', '33/49', '33/50', '33/52', '33/53', '33/56', '33/58', '33/59', '33/61', '33/62', '33/64', '33/65', '33/67', '33/68', '33/70', '33/71', '33/73', '33/74', '33/76', '33/79', '33/80', '33/82', '33/83', '33/85', '33/86', '33/89', '34/35', '34/37', '34/39', '34/41', '34/43', '34/45', '34/47', '34/49', '34/53', '34/55', '34/57', '34/59', '34/61', '34/63', '34/65', '34/67', '34/69', '34/71', '34/73', '34/75', '34/77', '34/79', '34/81', '34/83', '34/87', '34/89', '35/36', '35/37', '35/38', '35/39', '35/41', '35/43', '35/44', '35/46', '35/47', '35/48', '35/51', '35/52', '35/53', '35/54', '35/57', '35/58', '35/59', '35/61', '35/62', '35/64', '35/66', '35/67', '35/68', '35/69', '35/71', '35/72', '35/73', '35/74', '35/76', '35/78', '35/79', '35/81', '35/82', '35/83', '35/86', '35/87', '35/88', '35/89', '36/37', '36/41', '36/43', '36/47', '36/49', '36/53', '36/55', '36/59', '36/61', '36/65', '36/67', '36/71', '36/73', '36/77', '36/79', '36/83', '36/85', '36/89', '37/38', '37/39', '37/40', '37/41', '37/42', '37/43', '37/44', '37/45', '37/46', '37/47', '37/48', '37/49', '37/50', '37/51', '37/52', '37/53', '37/54', '37/55', '37/56', '37/57', '37/58', '37/59', '37/60', '37/61', '37/62', '37/63', '37/64', '37/65', '37/66', '37/67', '37/68', '37/69', '37/70', '37/71', '37/72', '37/73', '37/75', '37/76', '37/77', '37/78', '37/79', '37/80', '37/81', '37/82', '37/83', '37/84', '37/85', '37/86', '37/87', '37/88', '37/89', '37/90', '38/39', '38/41', '38/43', '38/45', '38/47', '38/49', '38/51', '38/53', '38/55', '38/59', '38/61', '38/63', '38/65', '38/67', '38/69', '38/71', '38/73', '38/75', '38/77', '38/79', '38/81', '38/83', '38/85', '38/87', '38/89', '39/40', '39/41', '39/43', '39/44', '39/46', '39/47', '39/49', '39/50', '39/53', '39/55', '39/56', '39/58', '39/59', '39/61', '39/62', '39/64', '39/67', '39/68', '39/70', '39/71', '39/73', '39/74', '39/76', '39/77', '39/79', '39/80', '39/82', '39/83', '39/85', '39/86', '39/88', '39/89', '40/41', '40/43', '40/47', '40/49', '40/51', '40/53', '40/57', '40/59', '40/61', '40/63', '40/67', '40/69', '40/71', '40/73', '40/77', '40/79', '40/81', '40/83', '40/87', '40/89', '41/42', '41/43', '41/44', '41/45', '41/46', '41/47', '41/48', '41/49', '41/50', '41/51', '41/52', '41/53', '41/54', '41/55', '41/56', '41/57', '41/58', '41/59', '41/60', '41/61', '41/62', '41/63', '41/64', '41/65', '41/66', '41/67', '41/68', '41/69', '41/70', '41/71', '41/72', '41/73', '41/74', '41/75', '41/76', '41/77', '41/78', '41/79', '41/80', '41/81', '41/83', '41/84', '41/85', '41/86', '41/87', '41/88', '41/89', '41/90', '42/43', '42/47', '42/53', '42/55', '42/59', '42/61', '42/65', '42/67', '42/71', '42/73', '42/79', '42/83', '42/85', '42/89', '43/44', '43/45', '43/46', '43/47', '43/48', '43/49', '43/50', '43/51', '43/52', '43/53', '43/54', '43/55', '43/56', '43/57', '43/58', '43/59', '43/60', '43/61', '43/62', '43/63', '43/64', '43/65', '43/66', '43/67', '43/68', '43/69', '43/70', '43/71', '43/72', '43/73', '43/74', '43/75', '43/76', '43/77', '43/78', '43/79', '43/80', '43/81', '43/82', '43/83', '43/84', '43/85', '43/87', '43/88', '43/89', '43/90', '44/45', '44/47', '44/49', '44/51', '44/53', '44/57', '44/59', '44/61', '44/63', '44/65', '44/67', '44/69', '44/71', '44/73', '44/75', '44/79', '44/81', '44/83', '44/85', '44/87', '44/89', '45/46', '45/47', '45/49', '45/52', '45/53', '45/56', '45/58', '45/59', '45/61', '45/62', '45/64', '45/67', '45/68', '45/71', '45/73', '45/74', '45/76', '45/77', '45/79', '45/82', '45/83', '45/86', '45/88', '45/89', '46/47', '46/49', '46/51', '46/53', '46/55', '46/57', '46/59', '46/61', '46/63', '46/65', '46/67', '46/71', '46/73', '46/75', '46/77', '46/79', '46/81', '46/83', '46/85', '46/87', '46/89', '47/48', '47/49', '47/50', '47/51', '47/52', '47/53', '47/54', '47/55', '47/56', '47/57', '47/58', '47/59', '47/60', '47/61', '47/62', '47/63', '47/64', '47/65', '47/66', '47/67', '47/68', '47/69', '47/70', '47/71', '47/72', '47/73', '47/74', '47/75', '47/76', '47/77', '47/78', '47/79', '47/80', '47/81', '47/82', '47/83', '47/84', '47/85', '47/86', '47/87', '47/88', '47/89', '47/90', '48/49', '48/53', '48/55', '48/59', '48/61', '48/65', '48/67', '48/71', '48/73', '48/77', '48/79', '48/83', '48/85', '48/89', '49/50', '49/51', '49/52', '49/53', '49/54', '49/55', '49/57', '49/58', '49/59', '49/60', '49/61', '49/62', '49/64', '49/65', '49/66', '49/67', '49/68', '49/69', '49/71', '49/72', '49/73', '49/74', '49/75', '49/76', '49/78', '49/79', '49/80', '49/81', '49/82', '49/83', '49/85', '49/86', '49/87', '49/88', '49/89', '49/90', '50/51', '50/53', '50/57', '50/59', '50/61', '50/63', '50/67', '50/69', '50/71', '50/73', '50/77', '50/79', '50/81', '50/83', '50/87', '50/89', '51/52', '51/53', '51/55', '51/56', '51/58', '51/59', '51/61', '51/62', '51/64', '51/65', '51/67', '51/70', '51/71', '51/73', '51/74', '51/76', '51/77', '51/79', '51/80', '51/82', '51/83', '51/86', '51/88', '51/89', '52/53', '52/55', '52/57', '52/59', '52/61', '52/63', '52/67', '52/69', '52/71', '52/73', '52/75', '52/77', '52/79', '52/81', '52/83', '52/85', '52/87', '52/89', '53/54', '53/55', '53/56', '53/57', '53/58', '53/59', '53/60', '53/61', '53/62', '53/63', '53/64', '53/65', '53/66', '53/67', '53/68', '53/69', '53/70', '53/71', '53/72', '53/73', '53/74', '53/75', '53/76', '53/77', '53/78', '53/79', '53/80', '53/81', '53/82', '53/83', '53/84', '53/85', '53/86', '53/87', '53/88', '53/89', '53/90', '54/55', '54/59', '54/61', '54/65', '54/67', '54/71', '54/73', '54/77', '54/79', '54/83', '54/85', '54/89', '55/56', '55/57', '55/58', '55/59', '55/61', '55/62', '55/63', '55/64', '55/67', '55/68', '55/69', '55/71', '55/72', '55/73', '55/74', '55/76', '55/78', '55/79', '55/81', '55/82', '55/83', '55/84', '55/86', '55/87', '55/89', '56/57', '56/59', '56/61', '56/65', '56/67', '56/69', '56/71', '56/73', '56/75', '56/79', '56/81', '56/83', '56/85', '56/87', '56/89', '57/58', '57/59', '57/61', '57/62', '57/64', '57/65', '57/67', '57/68', '57/70', '57/71', '57/73', '57/74', '57/77', '57/79', '57/80', '57/82', '57/83', '57/85', '57/86', '57/88', '57/89', '58/59', '58/61', '58/63', '58/65', '58/67', '58/69', '58/71', '58/73', '58/75', '58/77', '58/79', '58/81', '58/83', '58/85', '58/89', '59/60', '59/61', '59/62', '59/63', '59/64', '59/65', '59/66', '59/67', '59/68', '59/69', '59/70', '59/71', '59/72', '59/73', '59/74', '59/75', '59/76', '59/77', '59/78', '59/79', '59/80', '59/81', '59/82', '59/83', '59/84', '59/85', '59/86', '59/87', '59/88', '59/89', '59/90', '60/61', '60/67', '60/71', '60/73', '60/77', '60/79', '60/83', '60/89', '61/62', '61/63', '61/64', '61/65', '61/66', '61/67', '61/68', '61/69', '61/70', '61/71', '61/72', '61/73', '61/74', '61/75', '61/76', '61/77', '61/78', '61/79', '61/80', '61/81', '61/82', '61/83', '61/84', '61/85', '61/86', '61/87', '61/88', '61/89', '61/90', '62/63', '62/65', '62/67', '62/69', '62/71', '62/73', '62/75', '62/77', '62/79', '62/81', '62/83', '62/85', '62/87', '62/89', '63/64', '63/65', '63/67', '63/68', '63/71', '63/73', '63/74', '63/76', '63/79', '63/80', '63/82', '63/83', '63/85', '63/86', '63/88', '63/89', '64/65', '64/67', '64/69', '64/71', '64/73', '64/75', '64/77', '64/79', '64/81', '64/83', '64/85', '64/87', '64/89', '65/66', '65/67', '65/68', '65/69', '65/71', '65/72', '65/73', '65/74', '65/76', '65/77', '65/79', '65/81', '65/82', '65/83', '65/84', '65/86', '65/87', '65/88', '65/89', '66/67', '66/71', '66/73', '66/79', '66/83', '66/85', '66/89', '67/68', '67/69', '67/70', '67/71', '67/72', '67/73', '67/74', '67/75', '67/76', '67/77', '67/78', '67/79', '67/80', '67/81', '67/82', '67/83', '67/84', '67/85', '67/86', '67/87', '67/88', '67/89', '67/90', '68/69', '68/71', '68/73', '68/75', '68/77', '68/79', '68/81', '68/83', '68/87', '68/89', '69/70', '69/71', '69/73', '69/74', '69/76', '69/77', '69/79', '69/80', '69/82', '69/83', '69/85', '69/86', '69/88', '69/89', '70/71', '70/73', '70/79', '70/81', '70/83', '70/87', '70/89', '71/72', '71/73', '71/74', '71/75', '71/76', '71/77', '71/78', '71/79', '71/80', '71/81', '71/82', '71/83', '71/84', '71/85', '71/86', '71/87', '71/88', '71/89', '71/90', '72/73', '72/77', '72/79', '72/83', '72/85', '72/89', '73/74', '73/75', '73/76', '73/77', '73/78', '73/79', '73/80', '73/81', '73/82', '73/83', '73/84', '73/85', '73/86', '73/87', '73/88', '73/89', '73/90', '74/75', '74/77', '74/79', '74/81', '74/83', '74/85', '74/87', '74/89', '75/76', '75/77', '75/79', '75/82', '75/83', '75/86', '75/88', '75/89', '76/77', '76/79', '76/81', '76/83', '76/85', '76/87', '76/89', '77/78', '77/79', '77/80', '77/81', '77/82', '77/83', '77/85', '77/86', '77/87', '77/89', '77/90', '78/79', '78/83', '78/85', '78/89', '79/80', '79/81', '79/82', '79/83', '79/84', '79/85', '79/86', '79/87', '79/88', '79/89', '79/90', '80/81', '80/83', '80/87', '80/89', '81/82', '81/83', '81/85', '81/86', '81/88', '81/89', '82/83', '82/85', '82/87', '82/89', '83/84', '83/85', '83/86', '83/87', '83/88', '83/89', '83/90', '84/85', '84/89', '85/86', '85/87', '85/88', '85/89', '86/87', '86/89', '87/88', '87/89', '88/89', '89/90']\n assert candidate(n = 25) == ['1/2', '1/3', '1/4', '1/5', '1/6', '1/7', '1/8', '1/9', '1/10', '1/11', '1/12', '1/13', '1/14', '1/15', '1/16', '1/17', '1/18', '1/19', '1/20', '1/21', '1/22', '1/23', '1/24', '1/25', '2/3', '2/5', '2/7', '2/9', '2/11', '2/13', '2/15', '2/17', '2/19', '2/21', '2/23', '2/25', '3/4', '3/5', '3/7', '3/8', '3/10', '3/11', '3/13', '3/14', '3/16', '3/17', '3/19', '3/20', '3/22', '3/23', '3/25', '4/5', '4/7', '4/9', '4/11', '4/13', '4/15', '4/17', '4/19', '4/21', '4/23', '4/25', '5/6', '5/7', '5/8', '5/9', '5/11', '5/12', '5/13', '5/14', '5/16', '5/17', '5/18', '5/19', '5/21', '5/22', '5/23', '5/24', '6/7', '6/11', '6/13', '6/17', '6/19', '6/23', '6/25', '7/8', '7/9', '7/10', '7/11', '7/12', '7/13', '7/15', '7/16', '7/17', '7/18', '7/19', '7/20', '7/22', '7/23', '7/24', '7/25', '8/9', '8/11', '8/13', '8/15', '8/17', '8/19', '8/21', '8/23', '8/25', '9/10', '9/11', '9/13', '9/14', '9/16', '9/17', '9/19', '9/20', '9/22', '9/23', '9/25', '10/11', '10/13', '10/17', '10/19', '10/21', '10/23', '11/12', '11/13', '11/14', '11/15', '11/16', '11/17', '11/18', '11/19', '11/20', '11/21', '11/23', '11/24', '11/25', '12/13', '12/17', '12/19', '12/23', '12/25', '13/14', '13/15', '13/16', '13/17', '13/18', '13/19', '13/20', '13/21', '13/22', '13/23', '13/24', '13/25', '14/15', '14/17', '14/19', '14/23', '14/25', '15/16', '15/17', '15/19', '15/22', '15/23', '16/17', '16/19', '16/21', '16/23', '16/25', '17/18', '17/19', '17/20', '17/21', '17/22', '17/23', '17/24', '17/25', '18/19', '18/23', '18/25', '19/20', '19/21', '19/22', '19/23', '19/24', '19/25', '20/21', '20/23', '21/22', '21/23', '21/25', '22/23', '22/25', '23/24', '23/25', '24/25']\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().simplifiedFractions", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector simplifiedFractions(int n) {", "container": "Solution", "callable": "simplifiedFractions", "parameters": [{"name": "n", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1448, "task_id": "count-good-nodes-in-binary-tree", "difficulty": "Medium", "problem_description": "Given a binary tree root, a node X in the tree is named good if in the path from root to X there are no nodes with a value greater than X.\\r\n\\r\nReturn the number of good nodes in the binary tree.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\n\\r\n\\r\nInput: root = [3,1,4,3,null,1,5]\\r\nOutput: 4\\r\nExplanation: Nodes in blue are good.\\r\nRoot Node (3) is always a good node.\\r\nNode 4 -> (3,4) is the maximum value in the path starting from the root.\\r\nNode 5 -> (3,4,5) is the maximum value in the path\\r\nNode 3 -> (3,1,3) is the maximum value in the path.\\r\n\\r\nExample 2:\\r\n\\r\n\\r\n\\r\n\\r\nInput: root = [3,3,null,4,2]\\r\nOutput: 3\\r\nExplanation: Node 2 -> (3, 3, 2) is not good, because \"3\" is higher than it.\\r\n\\r\nExample 3:\\r\n\\r\n\\r\nInput: root = [1]\\r\nOutput: 1\\r\nExplanation: Root is considered as good.\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\tThe number of nodes in the binary tree is in the range [1, 10^5].\\r\n\tEach node's value is between [-10^4, 10^4].\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([3, 1, 4, 3, None, 1, 5])) == 4\n assert candidate(root = tree_node([-10, -20, -5, -15, -30])) == 2\n assert candidate(root = tree_node([5, 10, 20, 15, 25])) == 5\n assert candidate(root = tree_node([-10, None, -20, None, -30])) == 1\n assert candidate(root = tree_node([3, 3, None, 4, 2])) == 3\n assert candidate(root = tree_node([5, 4, 6, 3, 8, 5, 7])) == 4\n assert candidate(root = tree_node([5, 3, 6, 2, 4, None, 7])) == 3\n assert candidate(root = tree_node([-10000, -5000, -2500])) == 3\n assert candidate(root = tree_node([1])) == 1\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5])) == 5\n assert candidate(root = tree_node([20, 10, 25, 5, 15, 22, 30, 2, 7, 12, 18, 21, 24, 28, 32])) == 4\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10])) == 10\n assert candidate(root = tree_node([5, 3, 6, 2, 4, None, 7, 1, None, None, None, None, 8])) == 4\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])) == 25\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, None, None, None, 8, 9, 10, 11])) == 11\n assert candidate(root = tree_node([7, 6, 8, 5, None, 9, 10, 4, None, None, None, 1, 11, None, 12])) == 6\n assert candidate(root = tree_node([3, 1, 4, 3, None, 1, 5, 2, None, None, 3, None, None, 1, 6])) == 5\n assert candidate(root = tree_node([1, 2, 2, 2, 3, None, None, 4, None, 5, 6])) == 8\n assert candidate(root = tree_node([5, 3, 6, 2, 4, None, 8, 1, None, None, None, 7, 9])) == 4\n assert candidate(root = tree_node([-10, -20, -30, -40, -50, None, -60])) == 1\n assert candidate(root = tree_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])) == 10\n assert candidate(root = tree_node([15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == 1\n assert candidate(root = tree_node([1, 3, 2, 5, 3, None, 9, 4, None, 6, None, 7, 8, 10, 11])) == 9\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18])) == 3\n assert candidate(root = tree_node([4, 2, 6, 1, 3, 5, 7, -2, None, None, None, None, None, None, -3])) == 3\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 13, 18, 23, 27, 33, 37])) == 4\n assert candidate(root = tree_node([5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5])) == 52\n assert candidate(root = tree_node([-5, -4, -3, -6, -2, -4, -2, -8, -1, -3, -1, -5, -1, -7, -1])) == 9\n assert candidate(root = tree_node([100, 50, 200, 25, 75, 150, 250, 10, 30, 60, 80, 125, 175, 225, 275])) == 4\n assert candidate(root = tree_node([5, 3, 6, 2, 4, 7, 8, 1, 9, None, None, None, None, None, None, None, None])) == 5\n assert candidate(root = tree_node([50, 25, 75, 10, 30, 60, 80, None, 20, 28, 35, None, 55, 70, None, 15, None, 22, 26, 29, 33, 38, 52, 57, 72, None, 13, 17, None, None, 21, None, 24, 27, None, None, 31, 36, None, None, 51, 54, 56, 58, 71, None, None, None, 12, None, None, None, 16, None, 19, None, None, 23, None, None, 32, None, 34, 37, None, 50, None, 53, None, 59, None, 69, 73, None, None, 11, None, 14, None, 18, None, 21, None, None, 25, None, 30, None, None, None, None, None, 49, None, 52, None, 68, None, 72, None, 10, None, 13, None, None, None, 17, None, 19, None, None, 25, None, 29, None, 33, None, None, 48, None, None, 51, None, 67, None, 71, None, None, None, None, 9, None, 12, None, None, None, 16, None, 18, None, None, 24, None, None, 28, None, None, 32, None, 34, None, None, 47, None, None, 50, None, 66, None, 70, None, None, None, None, 8, None, 11, None, None, None, 15, None, None, None, 17, None, 19, None, None, 23, None, None, 27, None, None, 31, None, 34, None, None, 46, None, None, 49, None, 65, None, 69, None, None, None, None, 7, None, 10, None, None, None, 14, None, None, None, 17, None, 19, None, None, 23, None, None, 27, None, None, 31, None, 33, None, None, 45, None, None, 48, None, 64, None, 68, None, None, None, None, 6, None, 9, None, None, None, 13, None, None, None, 16, None, 18, None, None, 22, None, None, 26, None, None, 30, None, 33, None, None, 44, None, None, 47, None, 63, None, 67, None, None, None, None, 5, None, 8, None, None, None, 12, None, None, None, 15, None, None, None, 17, None, 19, None, None, 22, None, None, 26, None, None, 30, None, 32, None, None, 43, None, None, 46, None, 62, None, 66, None, None, None, None, 4, None, 7, None, None, None, 11, None, None, None, 14, None, None, None, 16, None, 18, None, None, 21, None, None, 25, None, None, 29, None, 32, None, None, 42, None, None, 45, None, 61, None, 65, None, None, None, None, 3, None, 6, None, None, None, 10, None, None, None, 13, None, None, None, 15, None, None, None, 18, None, 20, None, None, 24, None, None, 28, None, 31, None, 33, None, None, 41, None, None, 44, None, 60, None, 64, None, None, None, None, 2, None, 5, None, None, None, 9, None, None, None, 12, None, None, None, 14, None, None, None, 17, None, 19, None, None, 23, None, None, 27, None, None, 31, None, 33, None, None, 40, None, None, 43, None, 59, None, 63, None, None, None, None, 1, None, 4, None, None, None, 8, None, None, None, 11, None, None, None, 13, None, None, None, 16, None, 18, None, None, 22, None, None, 26, None, None, 30, None, 32, None, None, 39, None, None, 42, None, 58, None, 62, None, None, None, None])) == 10\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 13, 18, 1, 4, 6, 8, 12, 14, 17, 20])) == 4\n assert candidate(root = tree_node([8, 3, 10, 1, 6, None, 14, None, None, 4, 7, 13])) == 3\n assert candidate(root = tree_node([8, 5, 9, 7, 6, 12, None, None, None, None, 15, None, 18])) == 5\n assert candidate(root = tree_node([8, 3, 10, 1, 6, None, 14, None, None, 4, 7, 12, 16])) == 4\n assert candidate(root = tree_node([1, None, 2, None, None, 3, None, None, None, None, 4, None, None, None, None, 5])) == 2\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, 1, None, 6])) == 3\n assert candidate(root = tree_node([100, -20, -30, -40, -50, -60, -70, -80, -90, -100, 101, 102, 103, 104, 105])) == 6\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9])) == 9\n assert candidate(root = tree_node([100, -50, 50, -100, 0, 25, 75, -200, -100, -75, -25, 0, 100, 150, 200])) == 4\n assert candidate(root = tree_node([20, 10, 20, 5, 15, 15, 25, 3, 7, 12, 18, 22, 30])) == 5\n assert candidate(root = tree_node([5, 1, 6, 0, 2, 5, 8, -1, None, None, 3, None, 4, 7, 9])) == 4\n assert candidate(root = tree_node([1, 3, 2, 5, 3, None, 9, 2, None, 8, None, None, None, None, 4])) == 7\n assert candidate(root = tree_node([5, 4, 8, 11, None, 13, 4, 7, 2, None, None, None, 1])) == 4\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, None, 6, 7, None, None, 8, 9, None, None, 10, 11, None, None, None, None, 12, 13, None, None, None, None, None, 14, 15])) == 13\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180])) == 4\n assert candidate(root = tree_node([3, 1, 4, 3, None, 1, 5, 2, None, None, None, None, None, 6, None])) == 5\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 6, 7, 8, None, 9, None, 10, 11, 12])) == 12\n assert candidate(root = tree_node([-10, None, -5, -6, None, -8, None, -7])) == 2\n assert candidate(root = tree_node([15, 10, 20, 8, 12, 16, 25, None, None, None, None, None, 19, 22, 30])) == 4\n assert candidate(root = tree_node([3, 2, 4, None, None, 3, 5, None, None, 2, None, None, None, 6])) == 3\n assert candidate(root = tree_node([20, 10, 25, 5, 15, 22, 30, None, None, None, None, 21, 27, 28, 35])) == 5\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, 2, 8])) == 3\n assert candidate(root = tree_node([-10, 9, 20, None, None, 15, 7, None, None, None, 12])) == 3\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9])) == 9\n assert candidate(root = tree_node([1, 2, 3, None, 5, None, 4, None, None, None, 6])) == 6\n assert candidate(root = tree_node([7, 3, 15, 1, 5, 10, 20, -1, 2, None, 6, 8, 12, 18, 25])) == 4\n assert candidate(root = tree_node([5, 4, 6, 3, 7, None, None, 2, None, None, None, None, None, 8])) == 3\n assert candidate(root = tree_node([10, 10, 10, 10, 10, None, None, 10, 10])) == 7\n assert candidate(root = tree_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, None, None, None, None, None, None, None, None, None])) == 1\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180])) == 4\n assert candidate(root = tree_node([5, 3, 6, 2, 4, None, 7, 1, None, 3, 4])) == 3\n assert candidate(root = tree_node([1, -10, -5, 6, 5, None, -8, 3, 12, -9, None, None, -3, None, None, None, None])) == 4\n assert candidate(root = tree_node([-1, -2, -3, -4, -5, None, None, -6, -7])) == 1\n assert candidate(root = tree_node([5, 1, 4, 2, 3, None, None, None, None, 4, 5])) == 2\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == 20\n assert candidate(root = tree_node([-10, -20, -30, -40, -50, -60, -70, -80, -90, -100])) == 1\n assert candidate(root = tree_node([5, 4, 6, 3, None, None, 7, 2, None, None, None, 8])) == 4\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 13, 18, 1, None, 6, None, 14, None, None, None, 8])) == 3\n assert candidate(root = tree_node([-10, -5, 20, None, 0, 15, 25, -8, None, None, 5, None, None, None, None])) == 5\n assert candidate(root = tree_node([1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5])) == 30\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == 15\n assert candidate(root = tree_node([5, 4, 6, 3, 8, 5, 7, 2, 9, 10, None, None, 11, 12, 13])) == 9\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 40, 60, 80, 110, 140, 160, 180])) == 4\n assert candidate(root = tree_node([1, 3, 2, 5, 3, None, 9, 2, 8, 2, None, None, None, None, 4, 4, None, None, 5])) == 8\n assert candidate(root = tree_node([7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7])) == 15\n assert candidate(root = tree_node([1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4])) == 15\n assert candidate(root = tree_node([8, 3, 10, 1, 6, 9, 14, None, 2, 4, 7, None, 11, 13, 15])) == 5\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11])) == 11\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 18, 1, 6, 8, 11, 13, 17, 19, 20])) == 7\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 20, 1, 4, 6, 8, 11, 13, 18, 25])) == 4\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == 15\n assert candidate(root = tree_node([-1, -2, -3, -4, -5, -6, -7, -8, -9])) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11])) == 11\n"}, "metadata": {"canonical_parameter_names": ["root"], "leetcode_dataset_entry_point": "Solution().goodNodes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int goodNodes(TreeNode* root) {", "container": "Solution", "callable": "goodNodes", "parameters": [{"name": "root", "type": "TreeNode*"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1449, "task_id": "form-largest-integer-with-digits-that-add-up-to-target", "difficulty": "Hard", "problem_description": "Given an array of integers cost and an integer target, return the maximum integer you can paint under the following rules:\n\nThe cost of painting a digit (i + 1) is given by cost[i] (0-indexed).\nThe total cost used must be equal to target.\nThe integer does not have 0 digits.\n\nSince the answer may be very large, return it as a string. If there is no way to paint any integer given the condition, return \"0\".\n \nExample 1:\n\nInput: cost = [4,3,2,5,6,7,2,5,5], target = 9\nOutput: \"7772\"\nExplanation: The cost to paint the digit '7' is 2, and the digit '2' is 3. Then cost(\"7772\") = 2*3+ 3*1 = 9. You could also paint \"977\", but \"7772\" is the largest number.\nDigit cost\n 1 -> 4\n 2 -> 3\n 3 -> 2\n 4 -> 5\n 5 -> 6\n 6 -> 7\n 7 -> 2\n 8 -> 5\n 9 -> 5\n\nExample 2:\n\nInput: cost = [7,6,5,5,5,6,8,7,8], target = 12\nOutput: \"85\"\nExplanation: The cost to paint the digit '8' is 7, and the digit '5' is 5. Then cost(\"85\") = 7 + 5 = 12.\n\nExample 3:\n\nInput: cost = [2,4,6,2,4,6,4,4,4], target = 5\nOutput: \"0\"\nExplanation: It is impossible to paint any integer with total cost equal to target.\n\n \nConstraints:\n\ncost.length == 9\n1 <= cost[i], target <= 5000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(cost = [5, 3, 7, 5, 2, 6, 8, 9, 1],target = 10) == \"9999999999\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 20) == \"99999999999999999999\"\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5],target = 25) == \"99999\"\n assert candidate(cost = [2, 4, 6, 2, 4, 6, 4, 4, 4],target = 5) == \"0\"\n assert candidate(cost = [7, 6, 5, 5, 5, 6, 8, 7, 8],target = 12) == \"85\"\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5],target = 15) == \"999\"\n assert candidate(cost = [10, 9, 8, 7, 6, 5, 4, 3, 2],target = 45) == \"9999999999999999999998\"\n assert candidate(cost = [9, 9, 9, 9, 9, 9, 9, 9, 9],target = 5) == \"0\"\n assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1],target = 9) == \"999999999\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 15) == \"999999999999999\"\n assert candidate(cost = [3, 3, 3, 3, 3, 3, 3, 3, 3],target = 18) == \"999999\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 10) == \"1111111111\"\n assert candidate(cost = [10, 9, 8, 7, 6, 5, 4, 3, 2],target = 30) == \"999999999999999\"\n assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1],target = 4) == \"9999\"\n assert candidate(cost = [4, 3, 2, 5, 6, 7, 2, 5, 5],target = 9) == \"7772\"\n assert candidate(cost = [7, 3, 2, 1, 5, 8, 4, 6, 9],target = 36) == \"444444444444444444444444444444444444\"\n assert candidate(cost = [5, 3, 9, 1, 7, 6, 2, 8, 4],target = 30) == \"444444444444444444444444444444\"\n assert candidate(cost = [4, 4, 4, 4, 4, 4, 4, 4, 4],target = 200) == \"99999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [8, 7, 6, 5, 4, 3, 2, 1, 9],target = 50) == \"88888888888888888888888888888888888888888888888888\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 35) == \"99999999999999999999999999999999999\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 45) == \"111111111111111111111111111111111111111111111\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 100) == \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 15) == \"111111111111111\"\n assert candidate(cost = [8, 5, 2, 6, 4, 3, 9, 7, 1],target = 50) == \"99999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [1, 2, 1, 2, 1, 2, 1, 2, 1],target = 50) == \"99999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90],target = 450) == \"111111111111111111111111111111111111111111111\"\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5],target = 30) == \"999999\"\n assert candidate(cost = [5, 4, 3, 2, 1, 9, 8, 7, 6],target = 30) == \"555555555555555555555555555555\"\n assert candidate(cost = [4, 5, 6, 1, 2, 3, 7, 8, 9],target = 24) == \"444444444444444444444444\"\n assert candidate(cost = [2, 3, 2, 2, 3, 3, 2, 3, 2],target = 18) == \"999999999\"\n assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1],target = 20) == \"99999999999999999999\"\n assert candidate(cost = [1, 1, 2, 3, 5, 8, 13, 21, 34],target = 50) == \"22222222222222222222222222222222222222222222222222\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 45) == \"999999999999999999999999999999999999999999999\"\n assert candidate(cost = [5, 9, 2, 7, 3, 6, 8, 1, 4],target = 150) == \"888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888\"\n assert candidate(cost = [5, 4, 3, 2, 1, 2, 3, 4, 5],target = 30) == \"555555555555555555555555555555\"\n assert candidate(cost = [100, 200, 300, 400, 500, 600, 700, 800, 900],target = 1800) == \"111111111111111111\"\n assert candidate(cost = [1, 9, 1, 9, 1, 9, 1, 9, 1],target = 45) == \"999999999999999999999999999999999999999999999\"\n assert candidate(cost = [2, 3, 4, 5, 6, 7, 8, 9, 10],target = 25) == \"211111111111\"\n assert candidate(cost = [100, 200, 300, 400, 500, 600, 700, 800, 900],target = 4500) == \"111111111111111111111111111111111111111111111\"\n assert candidate(cost = [4, 3, 2, 5, 6, 7, 2, 5, 5],target = 20) == \"7777777777\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 5000) == \"99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [1, 3, 5, 7, 9, 11, 13, 15, 17],target = 50) == \"11111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90],target = 250) == \"1111111111111111111111111\"\n assert candidate(cost = [8, 8, 8, 8, 8, 8, 8, 8, 8],target = 72) == \"999999999\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 50) == \"11111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [4, 4, 4, 4, 4, 4, 4, 4, 4],target = 36) == \"999999999\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 45) == \"111111111111111111111111111111111111111111111\"\n assert candidate(cost = [10, 11, 12, 13, 14, 15, 16, 17, 18],target = 150) == \"111111111111111\"\n assert candidate(cost = [1, 2, 3, 1, 2, 3, 1, 2, 3],target = 20) == \"77777777777777777777\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 100) == \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 2500) == \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [3, 1, 4, 1, 5, 9, 2, 6, 5],target = 50) == \"44444444444444444444444444444444444444444444444444\"\n assert candidate(cost = [9, 18, 27, 36, 45, 54, 63, 72, 81],target = 162) == \"111111111111111111\"\n assert candidate(cost = [3, 3, 2, 1, 4, 5, 6, 7, 8],target = 25) == \"4444444444444444444444444\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 30) == \"999999999999999999999999999999\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 500) == \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [10, 9, 8, 7, 6, 5, 4, 3, 2],target = 20) == \"9999999999\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 1500) == \"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [7, 6, 5, 5, 5, 6, 8, 7, 8],target = 24) == \"9655\"\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90],target = 300) == \"111111111111111111111111111111\"\n assert candidate(cost = [10, 10, 10, 10, 10, 10, 10, 10, 10],target = 45) == \"0\"\n assert candidate(cost = [4, 3, 2, 5, 6, 7, 2, 5, 5],target = 18) == \"777777777\"\n assert candidate(cost = [2, 3, 4, 5, 6, 7, 8, 9, 10],target = 55) == \"211111111111111111111111111\"\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5],target = 30) == \"999999\"\n assert candidate(cost = [2, 3, 4, 5, 6, 7, 8, 9, 10],target = 50) == \"1111111111111111111111111\"\n assert candidate(cost = [7, 3, 3, 6, 2, 5, 5, 5, 5],target = 25) == \"555555555553\"\n assert candidate(cost = [9, 9, 9, 9, 9, 9, 9, 9, 9],target = 27) == \"999\"\n assert candidate(cost = [1, 3, 1, 3, 1, 3, 1, 3, 1],target = 15) == \"999999999999999\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 20) == \"11111111111111111111\"\n assert candidate(cost = [2, 3, 5, 7, 11, 13, 17, 19, 23],target = 50) == \"1111111111111111111111111\"\n assert candidate(cost = [4, 3, 2, 5, 6, 7, 2, 5, 5],target = 20) == \"7777777777\"\n assert candidate(cost = [1, 1, 2, 2, 3, 3, 4, 4, 5],target = 20) == \"22222222222222222222\"\n assert candidate(cost = [3, 1, 4, 1, 5, 9, 2, 6, 5],target = 30) == \"444444444444444444444444444444\"\n assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1],target = 1000) == \"9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [10, 9, 8, 7, 6, 5, 4, 3, 2],target = 60) == \"999999999999999999999999999999\"\n assert candidate(cost = [3, 5, 7, 9, 11, 13, 15, 17, 19],target = 50) == \"2111111111111111\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 100) == \"9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5],target = 27) == \"0\"\n assert candidate(cost = [2, 2, 2, 2, 2, 2, 2, 2, 2],target = 1000) == \"99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [2, 2, 2, 2, 2, 2, 2, 2, 2],target = 18) == \"999999999\"\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 5],target = 25) == \"99999\"\n assert candidate(cost = [1, 3, 1, 3, 1, 3, 1, 3, 1],target = 25) == \"9999999999999999999999999\"\n assert candidate(cost = [1, 2, 1, 2, 1, 2, 1, 2, 1],target = 10) == \"9999999999\"\n assert candidate(cost = [2, 3, 5, 7, 11, 13, 17, 19, 23],target = 100) == \"11111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [2, 2, 2, 2, 2, 2, 2, 2, 2],target = 3000) == \"999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [5, 6, 7, 8, 9, 10, 11, 12, 13],target = 30) == \"111111\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 99) == \"999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [1, 2, 2, 1, 1, 2, 2, 1, 1],target = 10) == \"9999999999\"\n assert candidate(cost = [2, 3, 3, 4, 4, 4, 5, 5, 5],target = 36) == \"111111111111111111\"\n assert candidate(cost = [2, 2, 2, 2, 2, 2, 2, 2, 2],target = 25) == \"0\"\n assert candidate(cost = [1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5000) == \"99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90],target = 100) == \"1111111111\"\n assert candidate(cost = [2, 4, 6, 8, 10, 12, 14, 16, 18],target = 5000) == \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [50, 50, 50, 50, 50, 50, 50, 50, 50],target = 100) == \"99\"\n assert candidate(cost = [100, 200, 300, 400, 500, 600, 700, 800, 900],target = 2700) == \"111111111111111111111111111\"\n assert candidate(cost = [5, 3, 5, 3, 5, 3, 5, 3, 5],target = 20) == \"988888\"\n assert candidate(cost = [20, 19, 18, 17, 16, 15, 14, 13, 12],target = 100) == \"99999995\"\n assert candidate(cost = [2, 3, 4, 5, 6, 7, 8, 9, 10],target = 45) == \"2111111111111111111111\"\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90],target = 1000) == \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(cost = [3, 2, 5, 7, 9, 4, 8, 6, 1],target = 15) == \"999999999999999\"\n assert candidate(cost = [3, 5, 2, 3, 9, 7, 5, 4, 2],target = 15) == \"9999994\"\n assert candidate(cost = [10, 20, 30, 40, 50, 60, 70, 80, 90],target = 450) == \"111111111111111111111111111111111111111111111\"\n assert candidate(cost = [3, 3, 3, 3, 3, 3, 3, 3, 3],target = 27) == \"999999999\"\n assert candidate(cost = [3, 1, 4, 1, 5, 9, 2, 6, 5],target = 27) == \"444444444444444444444444444\"\n assert candidate(cost = [3, 3, 3, 3, 3, 3, 3, 3, 3],target = 81) == \"999999999999999999999999999\"\n assert candidate(cost = [5, 5, 5, 5, 5, 5, 5, 5, 1],target = 30) == \"999999999999999999999999999999\"\n assert candidate(cost = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = 30) == \"111111111111111111111111111111\"\n assert candidate(cost = [1, 3, 2, 1, 2, 1, 3, 2, 1],target = 50) == \"99999999999999999999999999999999999999999999999999\"\n assert candidate(cost = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 45) == \"999999999999999999999999999999999999999999999\"\n assert candidate(cost = [5, 6, 7, 8, 9, 10, 11, 12, 13],target = 100) == \"11111111111111111111\"\n"}, "metadata": {"canonical_parameter_names": ["cost", "target"], "leetcode_dataset_entry_point": "Solution().largestNumber", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string largestNumber(vector& cost, int target) {", "container": "Solution", "callable": "largestNumber", "parameters": [{"name": "cost", "type": "vector&"}, {"name": "target", "type": "int"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1450, "task_id": "number-of-students-doing-homework-at-a-given-time", "difficulty": "Easy", "problem_description": "Given two integer arrays startTime and endTime and given an integer queryTime.\nThe ith student started doing their homework at the time startTime[i] and finished it at time endTime[i].\nReturn the number of students doing their homework at time queryTime. More formally, return the number of students where queryTime lays in the interval [startTime[i], endTime[i]] inclusive.\n \nExample 1:\n\nInput: startTime = [1,2,3], endTime = [3,2,7], queryTime = 4\nOutput: 1\nExplanation: We have 3 students where:\nThe first student started doing homework at time 1 and finished at time 3 and wasn't doing anything at time 4.\nThe second student started doing homework at time 2 and finished at time 2 and also wasn't doing anything at time 4.\nThe third student started doing homework at time 3 and finished at time 7 and was the only student doing homework at time 4.\n\nExample 2:\n\nInput: startTime = [4], endTime = [4], queryTime = 4\nOutput: 1\nExplanation: The only student was doing their homework at the queryTime.\n\n \nConstraints:\n\nstartTime.length == endTime.length\n1 <= startTime.length <= 100\n1 <= startTime[i] <= endTime[i] <= 1000\n1 <= queryTime <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(startTime = [9, 8, 7, 6],endTime = [10, 9, 8, 7],queryTime = 8) == 2\n assert candidate(startTime = [1, 2, 3, 4, 5],endTime = [5, 4, 3, 2, 1],queryTime = 3) == 3\n assert candidate(startTime = [5, 5, 5, 5],endTime = [10, 10, 10, 10],queryTime = 7) == 4\n assert candidate(startTime = [9, 8, 7, 6, 5, 4, 3, 2, 1],endTime = [10, 9, 8, 7, 6, 5, 4, 3, 2],queryTime = 5) == 2\n assert candidate(startTime = [4],endTime = [4],queryTime = 4) == 1\n assert candidate(startTime = [1, 2, 3],endTime = [3, 2, 7],queryTime = 4) == 1\n assert candidate(startTime = [100, 200, 300],endTime = [150, 250, 350],queryTime = 225) == 1\n assert candidate(startTime = [1, 3, 6, 7, 9],endTime = [2, 5, 8, 10, 12],queryTime = 6) == 1\n assert candidate(startTime = [9, 8, 7, 6, 5, 4, 3, 2, 1],endTime = [10, 9, 8, 7, 6, 5, 4, 3, 2],queryTime = 6) == 2\n assert candidate(startTime = [1, 1, 1, 1],endTime = [2, 2, 2, 2],queryTime = 1) == 4\n assert candidate(startTime = [1, 3, 5, 7],endTime = [2, 4, 6, 8],queryTime = 5) == 1\n assert candidate(startTime = [10, 20, 30],endTime = [15, 25, 35],queryTime = 22) == 1\n assert candidate(startTime = [5, 5, 5, 5],endTime = [6, 6, 6, 6],queryTime = 5) == 4\n assert candidate(startTime = [100, 200, 300],endTime = [150, 250, 350],queryTime = 225) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1],endTime = [2, 2, 2, 2, 2],queryTime = 1) == 5\n assert candidate(startTime = [100, 200, 300, 400],endTime = [199, 299, 399, 499],queryTime = 250) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queryTime = 500) == 6\n assert candidate(startTime = [500, 550, 600, 650, 700, 750, 800, 850, 900, 950],endTime = [550, 600, 650, 700, 750, 800, 850, 900, 950, 1000],queryTime = 725) == 1\n assert candidate(startTime = [10, 15, 20, 25, 30, 35, 40, 45, 50],endTime = [14, 19, 24, 29, 34, 39, 44, 49, 54],queryTime = 22) == 1\n assert candidate(startTime = [50, 100, 150, 200, 250],endTime = [75, 125, 175, 225, 275],queryTime = 100) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1, 1],endTime = [10, 20, 30, 40, 50, 60],queryTime = 5) == 6\n assert candidate(startTime = [250, 500, 750],endTime = [260, 510, 760],queryTime = 255) == 1\n assert candidate(startTime = [300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],endTime = [350, 450, 550, 650, 750, 850, 950, 1050, 1150, 1250],queryTime = 625) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5],endTime = [5, 4, 3, 2, 1],queryTime = 3) == 3\n assert candidate(startTime = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],endTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queryTime = 55) == 5\n assert candidate(startTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],endTime = [19, 29, 39, 49, 59, 69, 79, 89, 99, 109],queryTime = 55) == 1\n assert candidate(startTime = [10, 20, 30, 40, 50],endTime = [15, 25, 35, 45, 55],queryTime = 28) == 0\n assert candidate(startTime = [1, 3, 5, 7, 9],endTime = [10, 8, 6, 4, 2],queryTime = 5) == 3\n assert candidate(startTime = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],endTime = [55, 105, 155, 205, 255, 305, 355, 405, 455, 505],queryTime = 102) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1],endTime = [5, 5, 5, 5, 5],queryTime = 3) == 5\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queryTime = 5) == 5\n assert candidate(startTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],endTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queryTime = 10) == 1\n assert candidate(startTime = [1, 10, 20, 30, 40, 50],endTime = [10, 20, 30, 40, 50, 60],queryTime = 55) == 1\n assert candidate(startTime = [10, 20, 30, 40, 50],endTime = [15, 25, 35, 45, 55],queryTime = 33) == 1\n assert candidate(startTime = [300, 300, 300, 300],endTime = [600, 600, 600, 600],queryTime = 400) == 4\n assert candidate(startTime = [10, 20, 30, 40, 50],endTime = [10, 20, 30, 40, 50],queryTime = 10) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5],endTime = [10, 11, 12, 13, 14],queryTime = 8) == 5\n assert candidate(startTime = [1, 1, 1, 1, 1, 1],endTime = [6, 7, 8, 9, 10, 11],queryTime = 5) == 6\n assert candidate(startTime = [1, 1, 1, 1],endTime = [1000, 1000, 1000, 1000],queryTime = 500) == 4\n assert candidate(startTime = [5, 10, 15, 20, 25],endTime = [14, 19, 24, 29, 34],queryTime = 22) == 2\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queryTime = 6) == 5\n assert candidate(startTime = [100, 200, 300, 400],endTime = [150, 250, 350, 450],queryTime = 225) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5],endTime = [10, 20, 30, 40, 50],queryTime = 1) == 1\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [150, 250, 350, 450, 550],queryTime = 225) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],endTime = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],queryTime = 5) == 10\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11],queryTime = 10) == 2\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [100, 200, 300, 400, 500],queryTime = 100) == 1\n assert candidate(startTime = [10, 20, 30, 40],endTime = [100, 200, 300, 400],queryTime = 150) == 3\n assert candidate(startTime = [900, 905, 910, 915],endTime = [909, 914, 919, 924],queryTime = 907) == 2\n assert candidate(startTime = [1, 3, 6, 8, 10],endTime = [2, 5, 7, 10, 12],queryTime = 4) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1],endTime = [1, 1, 1, 1, 1],queryTime = 1) == 5\n assert candidate(startTime = [2, 2, 2, 2, 2],endTime = [10, 10, 10, 10, 10],queryTime = 6) == 5\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [200, 300, 400, 500, 600],queryTime = 350) == 1\n assert candidate(startTime = [1, 3, 5, 7, 9],endTime = [2, 4, 6, 8, 10],queryTime = 5) == 1\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [150, 250, 350, 450, 550],queryTime = 275) == 0\n assert candidate(startTime = [100, 200, 300, 400],endTime = [101, 201, 301, 401],queryTime = 200) == 1\n assert candidate(startTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],endTime = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],queryTime = 63) == 1\n assert candidate(startTime = [100, 150, 200, 250],endTime = [149, 199, 249, 299],queryTime = 175) == 1\n assert candidate(startTime = [50, 100, 150, 200, 250],endTime = [99, 199, 299, 399, 499],queryTime = 100) == 1\n assert candidate(startTime = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],endTime = [14, 24, 34, 44, 54, 64, 74, 84, 94, 104],queryTime = 100) == 1\n assert candidate(startTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],endTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queryTime = 50) == 6\n assert candidate(startTime = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],endTime = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],queryTime = 10) == 1\n assert candidate(startTime = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],endTime = [110, 210, 310, 410, 510, 610, 710, 810, 910, 1010],queryTime = 305) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queryTime = 5) == 1\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [500, 400, 300, 200, 100],queryTime = 300) == 3\n assert candidate(startTime = [1, 2, 3, 4, 5],endTime = [10, 9, 8, 7, 6],queryTime = 6) == 5\n assert candidate(startTime = [200, 200, 300, 300],endTime = [200, 400, 400, 500],queryTime = 200) == 2\n assert candidate(startTime = [10, 10, 10, 10, 10],endTime = [15, 15, 15, 15, 15],queryTime = 12) == 5\n assert candidate(startTime = [1, 10, 20, 30, 40, 50],endTime = [10, 20, 30, 40, 50, 60],queryTime = 25) == 1\n assert candidate(startTime = [999, 998, 997, 996, 995],endTime = [1000, 1000, 1000, 1000, 1000],queryTime = 999) == 5\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [150, 250, 350, 450, 550],queryTime = 325) == 1\n assert candidate(startTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],endTime = [90, 80, 70, 60, 50, 40, 30, 20, 10, 0],queryTime = 55) == 4\n assert candidate(startTime = [1, 1, 1, 1, 1],endTime = [1000, 1000, 1000, 1000, 1000],queryTime = 500) == 5\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [200, 300, 400, 500, 600],queryTime = 250) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5],endTime = [5, 10, 15, 20, 25],queryTime = 3) == 3\n assert candidate(startTime = [9, 10, 11, 12, 13],endTime = [10, 12, 14, 16, 18],queryTime = 12) == 3\n assert candidate(startTime = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],endTime = [101, 201, 301, 401, 501, 601, 701, 801, 901, 1001],queryTime = 500) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5],endTime = [10, 20, 30, 40, 50],queryTime = 25) == 3\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [199, 299, 399, 499, 599],queryTime = 450) == 1\n assert candidate(startTime = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29],endTime = [4, 7, 10, 13, 16, 19, 22, 25, 28, 31],queryTime = 15) == 1\n assert candidate(startTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],endTime = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],queryTime = 55) == 1\n assert candidate(startTime = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],endTime = [1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],queryTime = 1500) == 6\n assert candidate(startTime = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],endTime = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],queryTime = 550) == 5\n assert candidate(startTime = [10, 20, 30, 40, 50],endTime = [100, 110, 120, 130, 140],queryTime = 60) == 5\n assert candidate(startTime = [1, 3, 5, 7, 9, 11],endTime = [2, 4, 6, 8, 10, 12],queryTime = 6) == 1\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [150, 250, 350, 450, 550],queryTime = 400) == 1\n assert candidate(startTime = [500, 501, 502, 503, 504, 505],endTime = [500, 501, 502, 503, 504, 505],queryTime = 505) == 1\n assert candidate(startTime = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],endTime = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],queryTime = 7) == 10\n assert candidate(startTime = [500, 600, 700, 800],endTime = [599, 699, 799, 899],queryTime = 750) == 1\n assert candidate(startTime = [1, 100, 200, 300, 400],endTime = [100, 200, 300, 400, 500],queryTime = 150) == 1\n assert candidate(startTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],endTime = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queryTime = 15) == 6\n assert candidate(startTime = [500, 550, 600, 650],endTime = [501, 551, 601, 651],queryTime = 550) == 1\n assert candidate(startTime = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],endTime = [5, 6, 6, 7, 7, 8, 8, 9, 9, 10],queryTime = 6) == 9\n assert candidate(startTime = [100, 200, 300, 400, 500],endTime = [1000, 1000, 1000, 1000, 1000],queryTime = 500) == 5\n assert candidate(startTime = [10, 20, 30, 40],endTime = [15, 25, 35, 45],queryTime = 22) == 1\n"}, "metadata": {"canonical_parameter_names": ["startTime", "endTime", "queryTime"], "leetcode_dataset_entry_point": "Solution().busyStudent", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int busyStudent(vector& startTime, vector& endTime, int queryTime) {", "container": "Solution", "callable": "busyStudent", "parameters": [{"name": "startTime", "type": "vector&"}, {"name": "endTime", "type": "vector&"}, {"name": "queryTime", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1451, "task_id": "rearrange-words-in-a-sentence", "difficulty": "Medium", "problem_description": "Given a sentence text (A sentence is a string of space-separated words) in the following format:\n\nFirst letter is in upper case.\nEach word in text are separated by a single space.\n\nYour task is to rearrange the words in text such that all words are rearranged in an increasing order of their lengths. If two words have the same length, arrange them in their original order.\nReturn the new text following the format shown above.\n \nExample 1:\n\nInput: text = \"Leetcode is cool\"\nOutput: \"Is cool leetcode\"\nExplanation: There are 3 words, \"Leetcode\" of length 8, \"is\" of length 2 and \"cool\" of length 4.\nOutput is ordered by length and the new first word starts with capital letter.\n\nExample 2:\n\nInput: text = \"Keep calm and code on\"\nOutput: \"On and keep calm code\"\nExplanation: Output is ordered as follows:\n\"On\" 2 letters.\n\"and\" 3 letters.\n\"keep\" 4 letters in case of tie order by position in original text.\n\"calm\" 4 letters.\n\"code\" 4 letters.\n\nExample 3:\n\nInput: text = \"To be or not to be\"\nOutput: \"To be or to be not\"\n\n \nConstraints:\n\ntext begins with a capital letter and then contains lowercase letters and single space between words.\n1 <= text.length <= 10^5\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(text = \"A quick brown fox jumps over the lazy dog\") == \"A fox the dog over lazy quick brown jumps\"\n assert candidate(text = \"This is a simple test case\") == \"A is this test case simple\"\n assert candidate(text = \"The weather is sunny\") == \"Is the sunny weather\"\n assert candidate(text = \"A\") == \"A\"\n assert candidate(text = \"A B C D E\") == \"A B C D E\"\n assert candidate(text = \"Pack my box with five dozen liquor jugs\") == \"My box pack with five jugs dozen liquor\"\n assert candidate(text = \"Sorting words by length is fun\") == \"By is fun words length sorting\"\n assert candidate(text = \"I love programming in Python\") == \"I in love Python programming\"\n assert candidate(text = \"How vexingly quick daft zebras jump\") == \"How daft jump quick zebras vexingly\"\n assert candidate(text = \"Every good boy does fine\") == \"Boy good does fine every\"\n assert candidate(text = \"To be or not to be\") == \"To be or to be not\"\n assert candidate(text = \"Leetcode is cool\") == \"Is cool leetcode\"\n assert candidate(text = \"The quick brown fox jumps over the lazy dog\") == \"The fox the dog over lazy quick brown jumps\"\n assert candidate(text = \"This is a test sentence with various word lengths\") == \"A is this test with word various lengths sentence\"\n assert candidate(text = \"Keep calm and code on\") == \"On and keep calm code\"\n assert candidate(text = \"This is a test sentence for the function\") == \"A is for the this test sentence function\"\n assert candidate(text = \"In computer science algorithms often require creative solutions\") == \"In often science require computer creative solutions algorithms\"\n assert candidate(text = \"Silent nights filled with the promise of new beginnings\") == \"Of the new with silent nights filled promise beginnings\"\n assert candidate(text = \"Beautiful sentences flow rhythmically and gracefully\") == \"And flow beautiful sentences gracefully rhythmically\"\n assert candidate(text = \"Health and happiness are the most valuable possessions\") == \"And are the most health valuable happiness possessions\"\n assert candidate(text = \"Exploring the mysteries of the universe is a lifelong journey\") == \"A of is the the journey universe lifelong exploring mysteries\"\n assert candidate(text = \"Understanding these concepts is crucial for programming\") == \"Is for these crucial concepts programming understanding\"\n assert candidate(text = \"Repeating words like test test test should stay in order\") == \"In like test test test stay words order should repeating\"\n assert candidate(text = \"Programming challenges are a great way to improve your skills\") == \"A to are way your great skills improve challenges programming\"\n assert candidate(text = \"The smallest words often hide the deepest meanings\") == \"The the hide words often deepest smallest meanings\"\n assert candidate(text = \"You are never too old to set another goal or to dream a new dream\") == \"A to or to you are too old set new goal never dream dream another\"\n assert candidate(text = \"Sorting algorithms like quicksort and mergesort\") == \"And like sorting quicksort mergesort algorithms\"\n assert candidate(text = \"Learning never stops no matter how much one knows\") == \"No how one much never stops knows matter learning\"\n assert candidate(text = \"Despite its simplicity Unix is a powerful and flexible operating system\") == \"A is its and Unix system despite powerful flexible operating simplicity\"\n assert candidate(text = \"A journey of a thousand miles begins with a single step\") == \"A a a of with step miles begins single journey thousand\"\n assert candidate(text = \"Problem-solving skills are highly valued in the tech industry\") == \"In are the tech skills highly valued industry problem-solving\"\n assert candidate(text = \"Complexity arises when multiple words share the same length\") == \"The when same words share arises length multiple complexity\"\n assert candidate(text = \"In the midst of winter I found there was, within me, an invincible summer\") == \"I in of an the me, was, midst found there winter within summer invincible\"\n assert candidate(text = \"Happiness is not something ready made. It comes from your own actions\") == \"Is It not own from your ready made. comes actions happiness something\"\n assert candidate(text = \"Small steps lead to big progress\") == \"To big lead small steps progress\"\n assert candidate(text = \"With unwavering determination, she embarked on the perilous journey\") == \"On she the with journey embarked perilous unwavering determination,\"\n assert candidate(text = \"BeautifulSoup lxml html parser are widely used for web scraping\") == \"Are for web lxml html used parser widely scraping beautifulsoup\"\n assert candidate(text = \"Sorting words by length while maintaining original order\") == \"By words while order length sorting original maintaining\"\n assert candidate(text = \"We may encounter many defeats but we must not be defeated\") == \"We we be may but not many must defeats defeated encounter\"\n assert candidate(text = \"To achieve great things, we must not only act, but also dream; not only plan, but also believe\") == \"To we not but not but must only act, also only also great plan, dream; achieve things, believe\"\n assert candidate(text = \"A beautiful butterfly gracefully flutters among the colorful flowers\") == \"A the among flowers flutters colorful beautiful butterfly gracefully\"\n assert candidate(text = \"The greatest glory in living lies not in never falling, but in rising every time we fall\") == \"In in in we the not but lies time fall glory never every living rising greatest falling,\"\n assert candidate(text = \"The only way to do great work is to love what you do\") == \"To do is to do the way you only work love what great\"\n assert candidate(text = \"Innovative solutions can be achieved through collaborative efforts\") == \"Be can through efforts achieved solutions innovative collaborative\"\n assert candidate(text = \"Documentation plays a vital role in software development\") == \"A in role plays vital software development documentation\"\n assert candidate(text = \"In the heart of the city stood a magnificent gothic cathedral\") == \"A in of the the city heart stood gothic cathedral magnificent\"\n assert candidate(text = \"In the realm of competitive programming challenges are vast\") == \"In of the are vast realm challenges competitive programming\"\n assert candidate(text = \"In the heart of the city, amidst towering skyscrapers, lies a hidden gem\") == \"A in of the the gem lies heart city, amidst hidden towering skyscrapers,\"\n assert candidate(text = \"Continuous integration and deployment practices improve software quality\") == \"And improve quality software practices continuous deployment integration\"\n assert candidate(text = \"When words are of equal length they should remain in order\") == \"Of in are when they words equal order length should remain\"\n assert candidate(text = \"Understanding the nuances of human behavior is crucial\") == \"Of is the human nuances crucial behavior understanding\"\n assert candidate(text = \"Sometimes simplicity is the ultimate sophistication\") == \"Is the ultimate sometimes simplicity sophistication\"\n assert candidate(text = \"Beautiful scenery can uplift one's spirits\") == \"Can one's uplift scenery spirits beautiful\"\n assert candidate(text = \"If you want to live a happy life, tie it to a goal, not to people or things\") == \"A a if to it to to or you tie not want live happy life, goal, people things\"\n assert candidate(text = \"Consistency is the key to achieving long-term success\") == \"Is to the key success achieving long-term consistency\"\n assert candidate(text = \"The rapid expansion of cloud computing services has transformed many industries\") == \"Of the has many rapid cloud services expansion computing industries transformed\"\n assert candidate(text = \"Data structures and algorithms form the backbone of software\") == \"Of and the data form backbone software structures algorithms\"\n assert candidate(text = \"When faced with difficult problems persistence is key\") == \"Is key when with faced problems difficult persistence\"\n assert candidate(text = \"The sound of crashing waves soothed his restless mind\") == \"Of the his mind sound waves soothed crashing restless\"\n assert candidate(text = \"Effective communication skills are crucial in software engineering\") == \"In are skills crucial software effective engineering communication\"\n assert candidate(text = \"Can you solve this complex rearrangement problem\") == \"Can you this solve complex problem rearrangement\"\n assert candidate(text = \"Keep smiling because life is a beautiful journey not a destination\") == \"A a is not keep life smiling because journey beautiful destination\"\n assert candidate(text = \"Given a string containing multiple words of different lengths\") == \"A of given words string lengths multiple different containing\"\n assert candidate(text = \"A quick brown fox jumps over the lazy dog in an unexpected manner\") == \"A in an fox the dog over lazy quick brown jumps manner unexpected\"\n assert candidate(text = \"Programming challenges often require deep understanding and patience\") == \"And deep often require patience challenges programming understanding\"\n assert candidate(text = \"Adapting to new technologies and methodologies is important\") == \"To is new and adapting important technologies methodologies\"\n assert candidate(text = \"Handling edge cases is important for robust code\") == \"Is for edge code cases robust handling important\"\n assert candidate(text = \"Understanding data structures is crucial for computer scientists\") == \"Is for data crucial computer structures scientists understanding\"\n assert candidate(text = \"Programming challenges are intellectually stimulating\") == \"Are challenges programming stimulating intellectually\"\n assert candidate(text = \"Efficient algorithms can significantly reduce computation time\") == \"Can time reduce efficient algorithms computation significantly\"\n assert candidate(text = \"Believe you can and you're halfway there\") == \"You can and there you're believe halfway\"\n assert candidate(text = \"Actions speak louder than words\") == \"Than speak words louder actions\"\n assert candidate(text = \"Complex algorithms often require sophisticated data structures\") == \"Data often complex require algorithms structures sophisticated\"\n assert candidate(text = \"Python programming language is powerful and versatile\") == \"Is and python language powerful versatile programming\"\n assert candidate(text = \"In the realm of possibilities, anything is achievable\") == \"In of is the realm anything achievable possibilities,\"\n assert candidate(text = \"Learning to code is one of the most empowering experiences\") == \"To is of one the code most learning empowering experiences\"\n assert candidate(text = \"Crafting intricate designs in wood requires both skill and creativity\") == \"In and wood both skill designs crafting requires intricate creativity\"\n assert candidate(text = \"Despite the odds being stacked against him, he never gave up hope\") == \"He up the odds him, gave hope being never despite stacked against\"\n assert candidate(text = \"Those who dare to fail miserably can achieve greatly\") == \"To who can dare fail those achieve greatly miserably\"\n assert candidate(text = \"May the Force be with you\") == \"Be may the you with Force\"\n assert candidate(text = \"Every problem has a unique solution waiting to be discovered\") == \"A to be has every unique problem waiting solution discovered\"\n assert candidate(text = \"Consider various scenarios when testing your solution\") == \"When your various testing consider solution scenarios\"\n assert candidate(text = \"Despite the harsh conditions, the resilient hikers forged ahead\") == \"The the harsh ahead hikers forged despite resilient conditions,\"\n assert candidate(text = \"The ancient ruins whispered tales of forgotten civilizations\") == \"Of the ruins tales ancient whispered forgotten civilizations\"\n assert candidate(text = \"Python programming can be quite challenging indeed\") == \"Be can quite python indeed programming challenging\"\n assert candidate(text = \"Resilience and determination are the keys to success\") == \"To and are the keys success resilience determination\"\n assert candidate(text = \"A very very long sentence that needs to be properly rearranged\") == \"A to be very very long that needs sentence properly rearranged\"\n assert candidate(text = \"When sorting algorithms fail gracefully\") == \"When fail sorting algorithms gracefully\"\n assert candidate(text = \"Adventure and exploration are essential for personal growth\") == \"And are for growth personal adventure essential exploration\"\n assert candidate(text = \"Python Java JavaScript and C are popular programming languages\") == \"C and are Java python popular languages JavaScript programming\"\n assert candidate(text = \"Algorithms and data structures are fundamental to computer science\") == \"To and are data science computer algorithms structures fundamental\"\n assert candidate(text = \"In the heart of autumn leaves change their colors\") == \"In of the heart their autumn leaves change colors\"\n assert candidate(text = \"If life were predictable it would cease to be life, and be without flavor\") == \"If it to be be and life were would cease life, flavor without predictable\"\n assert candidate(text = \"A storm of emotions surged through her heart\") == \"A of her storm heart surged through emotions\"\n assert candidate(text = \"Continuous improvement is the hallmark of excellence\") == \"Is of the hallmark continuous excellence improvement\"\n assert candidate(text = \"The rain in Spain stays mainly in the plain\") == \"In in the the rain Spain stays plain mainly\"\n assert candidate(text = \"Do not watch the clock; do what it does. Keep going\") == \"Do do it not the what Keep watch does. going clock;\"\n assert candidate(text = \"The rapid expansion of artificial intelligence is fascinating\") == \"Of is the rapid expansion artificial fascinating intelligence\"\n assert candidate(text = \"An extraordinary journey through the magical lands\") == \"An the lands journey through magical extraordinary\"\n assert candidate(text = \"The early morning light illuminated the dew-kissed grass\") == \"The the early light grass morning dew-kissed illuminated\"\n assert candidate(text = \"Python is an interpreted high level programming language\") == \"Is an high level python language interpreted programming\"\n assert candidate(text = \"Understanding the intricacies of quantum mechanics requires patience\") == \"Of the quantum requires patience mechanics intricacies understanding\"\n assert candidate(text = \"A bird in the hand is worth two in the bush\") == \"A in is in the two the bird hand bush worth\"\n assert candidate(text = \"XMLHttpRequest allows clients to send and receive data asynchronously without reloading the web page\") == \"To and the web send data page allows clients receive without reloading xmlhttprequest asynchronously\"\n assert candidate(text = \"An overwhelming sense of serenity filled the quaint village\") == \"An of the sense filled quaint village serenity overwhelming\"\n assert candidate(text = \"Beautiful minds think in unpredictable ways\") == \"In ways minds think beautiful unpredictable\"\n assert candidate(text = \"Artificial intelligence and machine learning are transforming industries\") == \"And are machine learning artificial industries intelligence transforming\"\n assert candidate(text = \"It is during our darkest moments that we must focus the light\") == \"It is we our the that must focus light during darkest moments\"\n assert candidate(text = \"Do what you can with all you have, wherever you are\") == \"Do you can all you you are what with have, wherever\"\n assert candidate(text = \"Python is an interpreted high-level general-purpose programming language\") == \"Is an python language high-level interpreted programming general-purpose\"\n assert candidate(text = \"Sometimes life gives you lemons and you make lemonade\") == \"You and you life make gives lemons lemonade sometimes\"\n assert candidate(text = \"Creativity is the key to solving complex problems\") == \"Is to the key solving complex problems creativity\"\n assert candidate(text = \"Even seemingly simple tasks can be complex\") == \"Be can even tasks simple complex seemingly\"\n assert candidate(text = \"Data structures like arrays and linked lists\") == \"And data like lists arrays linked structures\"\n assert candidate(text = \"In computer science algorithms are fundamental\") == \"In are science computer algorithms fundamental\"\n assert candidate(text = \"Wherever you go, go with all your heart\") == \"Go you go, all with your heart wherever\"\n assert candidate(text = \"The magic of books lies in the stories they hold\") == \"Of in the the lies they hold magic books stories\"\n assert candidate(text = \"The children laughed joyfully in the sunlit playground\") == \"In the the sunlit laughed children joyfully playground\"\n assert candidate(text = \"The best time to plant a tree was 20 years ago. The second best time is now\") == \"A to 20 is the was The now best time tree ago. best time plant years second\"\n assert candidate(text = \"This is a test to see if the function handles ties correctly\") == \"A is to if see the this test ties handles function correctly\"\n assert candidate(text = \"Nature's beauty is a constant source of inspiration\") == \"A is of beauty source nature's constant inspiration\"\n assert candidate(text = \"Despite its simplicity quicksort is incredibly effective\") == \"Is its despite quicksort effective simplicity incredibly\"\n assert candidate(text = \"Programming challenges are a great way to improve skills\") == \"A to are way great skills improve challenges programming\"\n assert candidate(text = \"Check if the function can handle sentences with repeated words\") == \"If the can with check words handle function repeated sentences\"\n assert candidate(text = \"In every day, there are 1440 minutes, 86400 seconds and 5184000 milliseconds, so live every second\") == \"In so are and day, 1440 live every there 86400 every second seconds 5184000 minutes, milliseconds,\"\n assert candidate(text = \"Somebody once told me the world is gonna roll me\") == \"Me is me the once told roll world gonna somebody\"\n assert candidate(text = \"Many software projects involve working with multiple programming languages\") == \"Many with involve working software projects multiple languages programming\"\n assert candidate(text = \"Version control systems are essential for software development\") == \"Are for version control systems software essential development\"\n assert candidate(text = \"Writing clean and maintainable code is beneficial\") == \"Is and code clean writing beneficial maintainable\"\n assert candidate(text = \"Understanding the complexities of software development requires patience\") == \"Of the software requires patience development complexities understanding\"\n assert candidate(text = \"Debugging is twice as hard as writing the code in the first place\") == \"Is as as in the the hard code twice first place writing debugging\"\n assert candidate(text = \"Handling large datasets efficiently is a common requirement\") == \"A is large common handling datasets efficiently requirement\"\n assert candidate(text = \"Sometimes simple sentences are the most powerful\") == \"Are the most simple powerful sometimes sentences\"\n assert candidate(text = \"Algorithms data structures and programming languages\") == \"And data languages algorithms structures programming\"\n assert candidate(text = \"Some programmers prefer to use snake_case others CamelCase\") == \"To use some prefer others CamelCase snake_case programmers\"\n assert candidate(text = \"Exploring new cultures broadens one's horizons immensely\") == \"New one's cultures broadens horizons exploring immensely\"\n assert candidate(text = \"This is a simple example to demonstrate the functionality\") == \"A is to the this simple example demonstrate functionality\"\n assert candidate(text = \"Efficient algorithms can significantly reduce processing time\") == \"Can time reduce efficient algorithms processing significantly\"\n assert candidate(text = \"Python programming challenges are incredibly rewarding\") == \"Are python rewarding challenges incredibly programming\"\n assert candidate(text = \"Do not judge each day by the harvest you reap but by the seeds that you plant\") == \"Do by by not day the you but the you each reap that judge seeds plant harvest\"\n assert candidate(text = \"The quick movement of the enemy will jeopardize six gunboats\") == \"Of the the six will quick enemy movement gunboats jeopardize\"\n assert candidate(text = \"Contrary to popular belief Lorem Ipsum is not simply random text\") == \"To is not text Lorem Ipsum belief simply random popular contrary\"\n assert candidate(text = \"Every small victory is a stepping stone to greatness\") == \"A is to every small stone victory stepping greatness\"\n assert candidate(text = \"A mix of long and short words challenges the function greatly\") == \"A of mix and the long short words greatly function challenges\"\n assert candidate(text = \"Innovative solutions require creative thinking processes\") == \"Require creative thinking solutions processes innovative\"\n assert candidate(text = \"Consistency is the bridge between goals and accomplishment\") == \"Is the and goals bridge between consistency accomplishment\"\n assert candidate(text = \"An apple a day keeps the doctor away\") == \"A an day the away apple keeps doctor\"\n assert candidate(text = \"The scent of blooming roses filled the tranquil garden\") == \"Of the the scent roses filled garden blooming tranquil\"\n assert candidate(text = \"In the end we will remember not the words of our enemies but the silence of our friends\") == \"In we of of the end not the our but the our will words enemies silence friends remember\"\n assert candidate(text = \"Edge cases like very long words or many short ones\") == \"Or edge like very long many ones cases words short\"\n assert candidate(text = \"The future belongs to those who believe in the beauty of their dreams\") == \"To in of the who the those their future beauty dreams belongs believe\"\n assert candidate(text = \"Innovative solutions drive technological advancement\") == \"Drive solutions innovative advancement technological\"\n"}, "metadata": {"canonical_parameter_names": ["text"], "leetcode_dataset_entry_point": "Solution().arrangeWords", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string arrangeWords(string text) {", "container": "Solution", "callable": "arrangeWords", "parameters": [{"name": "text", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1452, "task_id": "people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list", "difficulty": "Medium", "problem_description": "Given the array favoriteCompanies where favoriteCompanies[i] is the list of favorites companies for the ith person (indexed from 0).\nReturn the indices of people whose list of favorite companies is not a subset of any other list of favorites companies. You must return the indices in increasing order.\n \nExample 1:\n\nInput: favoriteCompanies = [[\"leetcode\",\"google\",\"facebook\"],[\"google\",\"microsoft\"],[\"google\",\"facebook\"],[\"google\"],[\"amazon\"]]\nOutput: [0,1,4] \nExplanation: \nPerson with index=2 has favoriteCompanies[2]=[\"google\",\"facebook\"] which is a subset of favoriteCompanies[0]=[\"leetcode\",\"google\",\"facebook\"] corresponding to the person with index 0. \nPerson with index=3 has favoriteCompanies[3]=[\"google\"] which is a subset of favoriteCompanies[0]=[\"leetcode\",\"google\",\"facebook\"] and favoriteCompanies[1]=[\"google\",\"microsoft\"]. \nOther lists of favorite companies are not a subset of another list, therefore, the answer is [0,1,4].\n\nExample 2:\n\nInput: favoriteCompanies = [[\"leetcode\",\"google\",\"facebook\"],[\"leetcode\",\"amazon\"],[\"facebook\",\"google\"]]\nOutput: [0,1] \nExplanation: In this case favoriteCompanies[2]=[\"facebook\",\"google\"] is a subset of favoriteCompanies[0]=[\"leetcode\",\"google\",\"facebook\"], therefore, the answer is [0,1].\n\nExample 3:\n\nInput: favoriteCompanies = [[\"leetcode\"],[\"google\"],[\"facebook\"],[\"amazon\"]]\nOutput: [0,1,2,3]\n\n \nConstraints:\n\n1 <= favoriteCompanies.length <= 100\n1 <= favoriteCompanies[i].length <= 500\n1 <= favoriteCompanies[i][j].length <= 20\nAll strings in favoriteCompanies[i] are distinct.\nAll lists of favorite companies are distinct, that is, If we sort alphabetically each list then favoriteCompanies[i] != favoriteCompanies[j].\nAll strings consist of lowercase English letters only.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(favoriteCompanies = [['leetcode'], ['google'], ['facebook'], ['amazon']]) == [0, 1, 2, 3]\n assert candidate(favoriteCompanies = [['apple'], ['apple', 'google'], ['google', 'facebook'], ['apple', 'facebook', 'google']]) == [3]\n assert candidate(favoriteCompanies = [['tech', 'innovation'], ['startup', 'tech'], ['innovation', 'startup', 'tech']]) == [2]\n assert candidate(favoriteCompanies = [['leetcode', 'google', 'facebook'], ['leetcode', 'amazon'], ['facebook', 'google']]) == [0, 1]\n assert candidate(favoriteCompanies = [['apple'], ['apple', 'google'], ['google', 'facebook'], ['facebook', 'microsoft']]) == [1, 2, 3]\n assert candidate(favoriteCompanies = [['leetcode', 'google', 'facebook'], ['google', 'microsoft'], ['google', 'facebook'], ['google'], ['amazon']]) == [0, 1, 4]\n assert candidate(favoriteCompanies = [['apple', 'microsoft'], ['google'], ['apple', 'google', 'microsoft'], ['google', 'microsoft']]) == [2]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry'], ['banana'], ['apple', 'banana']]) == [0]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana'], ['apple', 'orange'], ['banana', 'orange'], ['apple']]) == [0, 2, 3]\n assert candidate(favoriteCompanies = [['apple'], ['banana'], ['cherry'], ['date'], ['elderberry']]) == [0, 1, 2, 3, 4]\n assert candidate(favoriteCompanies = [['apple', 'google'], ['google'], ['apple', 'microsoft'], ['facebook']]) == [0, 2, 3]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana', 'cherry', 'date'], ['apple', 'cherry', 'date'], ['banana', 'date'], ['apple', 'banana', 'cherry']]) == [1, 2, 4]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry', 'date'], ['apple', 'cherry', 'date', 'fig'], ['banana', 'date', 'fig', 'grape'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape', 'kiwi']]) == [4]\n assert candidate(favoriteCompanies = [['google', 'amazon', 'facebook'], ['google', 'facebook'], ['facebook'], ['google'], ['amazon'], ['google', 'amazon'], ['amazon', 'facebook'], ['google', 'amazon', 'facebook']]) == []\n assert candidate(favoriteCompanies = [['amazon', 'apple', 'facebook', 'google', 'microsoft'], ['google'], ['amazon', 'facebook'], ['apple', 'google', 'microsoft'], ['amazon', 'google', 'microsoft', 'apple', 'facebook']]) == []\n assert candidate(favoriteCompanies = [['airbnb', 'expedia', 'booking'], ['expedia', 'tripadvisor', 'kayak'], ['booking', 'tripadvisor', 'kayak'], ['airbnb', 'tripadvisor', 'kayak'], ['expedia', 'booking', 'tripadvisor'], ['airbnb', 'expedia', 'booking', 'tripadvisor', 'kayak']]) == [5]\n assert candidate(favoriteCompanies = [['apple', 'microsoft', 'amazon'], ['google', 'facebook', 'apple'], ['amazon', 'google', 'microsoft', 'facebook'], ['google'], ['microsoft', 'facebook']]) == [0, 1, 2]\n assert candidate(favoriteCompanies = [['leetcode', 'google'], ['google'], ['google', 'facebook'], ['google', 'facebook', 'microsoft'], ['google', 'facebook', 'microsoft', 'amazon'], ['amazon'], ['amazon', 'google'], ['amazon', 'facebook'], ['amazon', 'microsoft'], ['amazon', 'google', 'facebook', 'microsoft']]) == [0]\n assert candidate(favoriteCompanies = [['linkedin', 'facebook', 'twitter'], ['linkedin', 'google', 'instagram'], ['facebook', 'instagram'], ['google', 'twitter'], ['facebook'], ['google'], ['twitter'], ['instagram'], ['linkedin'], ['facebook', 'google', 'instagram', 'twitter', 'linkedin']]) == [9]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry'], ['cherry', 'date'], ['apple', 'banana', 'cherry', 'date'], ['banana', 'date', 'apple'], ['apple', 'banana']]) == [3]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana', 'cherry'], ['cherry', 'date'], ['date', 'fig'], ['fig', 'grape'], ['grape', 'honeydew'], ['honeydew', 'kiwi'], ['kiwi', 'lemon'], ['lemon', 'mango'], ['mango', 'nectarine'], ['nectarine', 'orange'], ['orange', 'papaya'], ['papaya', 'quince'], ['quince', 'raspberry'], ['raspberry', 'strawberry'], ['strawberry', 'tangerine'], ['tangerine', 'ugli'], ['ugli', 'vanilla'], ['vanilla', 'watermelon'], ['watermelon', 'xigua'], ['xigua', 'yam'], ['yam', 'zucchini'], ['apple', 'banana', 'cherry'], ['banana', 'cherry', 'date'], ['cherry', 'date', 'fig'], ['date', 'fig', 'grape'], ['fig', 'grape', 'honeydew'], ['honeydew', 'kiwi', 'lemon'], ['kiwi', 'lemon', 'mango'], ['lemon', 'mango', 'nectarine'], ['mango', 'nectarine', 'orange'], ['nectarine', 'orange', 'papaya'], ['orange', 'papaya', 'quince'], ['papaya', 'quince', 'raspberry'], ['quince', 'raspberry', 'strawberry'], ['raspberry', 'strawberry', 'tangerine'], ['strawberry', 'tangerine', 'ugli'], ['tangerine', 'ugli', 'vanilla'], ['ugli', 'vanilla', 'watermelon'], ['vanilla', 'watermelon', 'xigua'], ['watermelon', 'xigua', 'yam'], ['xigua', 'yam', 'zucchini']]) == [22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41]\n assert candidate(favoriteCompanies = [['a', 'b', 'c', 'd', 'e'], ['f', 'g', 'h', 'i', 'j'], ['a', 'b', 'c', 'd'], ['b', 'c', 'd', 'e'], ['a', 'b', 'c'], ['a', 'b'], ['a'], ['b'], ['c'], ['d'], ['e'], ['f'], ['g'], ['h'], ['i'], ['j']]) == [0, 1]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry'], ['cherry'], ['apple', 'cherry'], ['banana', 'cherry', 'date', 'fig'], ['date', 'fig']]) == [0, 4]\n assert candidate(favoriteCompanies = [['uber', 'lyft', 'careem'], ['careem', 'grab', 'gojek'], ['grab', 'uber', 'gojek'], ['gojek', 'grab'], ['careem', 'uber', 'lyft', 'grab', 'gojek']]) == [4]\n assert candidate(favoriteCompanies = [['amazon', 'apple', 'google'], ['google', 'microsoft'], ['facebook', 'google'], ['amazon', 'google', 'facebook'], ['microsoft', 'amazon'], ['amazon', 'facebook', 'google', 'microsoft'], ['apple', 'google', 'facebook']]) == [0, 5, 6]\n assert candidate(favoriteCompanies = [['tech', 'science', 'arts'], ['science', 'arts', 'literature'], ['tech', 'science'], ['science'], ['tech'], ['arts'], ['literature'], ['arts', 'literature'], ['tech', 'arts', 'literature'], ['tech', 'science', 'literature']]) == [0, 1, 8, 9]\n assert candidate(favoriteCompanies = [['tesla', 'toyota', 'ford'], ['toyota', 'ford', 'gm'], ['tesla', 'toyota', 'gm'], ['ford', 'gm'], ['tesla', 'toyota', 'ford', 'gm'], ['tesla', 'gm']]) == [4]\n assert candidate(favoriteCompanies = [['p', 'q', 'r'], ['q', 'r', 's'], ['r', 's', 't'], ['s', 't', 'u'], ['t', 'u', 'v'], ['u', 'v', 'w'], ['v', 'w', 'x'], ['w', 'x', 'y'], ['x', 'y', 'z'], ['y', 'z', 'p'], ['z', 'p', 'q'], ['p', 'q', 'r', 's'], ['q', 'r', 's', 't'], ['r', 's', 't', 'u'], ['s', 't', 'u', 'v'], ['t', 'u', 'v', 'w'], ['u', 'v', 'w', 'x'], ['v', 'w', 'x', 'y'], ['w', 'x', 'y', 'z'], ['x', 'y', 'z', 'p']]) == [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(favoriteCompanies = [['leetcode'], ['google'], ['facebook'], ['amazon'], ['apple'], ['twitter'], ['youtube'], ['instagram'], ['snapchat'], ['linkedin']]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(favoriteCompanies = [['leetcode', 'google', 'facebook', 'amazon'], ['google', 'facebook', 'microsoft'], ['google', 'amazon'], ['amazon'], ['google'], ['facebook']]) == [0, 1]\n assert candidate(favoriteCompanies = [['netflix', 'amazon', 'hulu'], ['amazon', 'hbo', 'crunchyroll'], ['netflix', 'hbo', 'crunchyroll'], ['hulu', 'hbo', 'crunchyroll'], ['netflix', 'amazon', 'hbo', 'crunchyroll'], ['amazon', 'hbo']]) == [0, 3, 4]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry', 'date'], ['date', 'fig', 'grape', 'honeydew'], ['honeydew', 'kiwi', 'lemon', 'mango'], ['mango', 'nectarine', 'orange', 'papaya'], ['papaya', 'quince', 'raspberry', 'strawberry'], ['strawberry', 'tangerine', 'ugli', 'vanilla'], ['vanilla', 'watermelon', 'xigua', 'yam'], ['yam', 'zucchini', 'blueberry', 'blackberry'], ['blueberry', 'blackberry', 'cranberry', 'elderberry'], ['elderberry', 'fig', 'grape', 'honeydew'], ['honeydew', 'kiwi', 'lemon', 'mango'], ['mango', 'nectarine', 'orange', 'papaya'], ['papaya', 'quince', 'raspberry', 'strawberry'], ['strawberry', 'tangerine', 'ugli', 'vanilla'], ['vanilla', 'watermelon', 'xigua', 'yam'], ['yam', 'zucchini', 'blueberry', 'blackberry'], ['blueberry', 'blackberry', 'cranberry', 'elderberry'], ['elderberry', 'fig', 'grape', 'honeydew'], ['honeydew', 'kiwi', 'lemon', 'mango'], ['mango', 'nectarine', 'orange', 'papaya']]) == [0, 1]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana', 'cherry', 'date'], ['cherry', 'date', 'fig'], ['date', 'fig', 'grape'], ['fig', 'grape', 'apple'], ['grape', 'apple', 'banana'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape']]) == [6]\n assert candidate(favoriteCompanies = [['microsoft', 'apple', 'google', 'facebook'], ['google', 'microsoft'], ['facebook', 'apple'], ['apple', 'google', 'facebook'], ['microsoft', 'apple'], ['google', 'amazon'], ['amazon', 'facebook'], ['microsoft', 'google', 'facebook']]) == [0, 5, 6]\n assert candidate(favoriteCompanies = [['twitter'], ['twitter', 'instagram'], ['twitter', 'facebook'], ['instagram', 'facebook'], ['twitter', 'instagram', 'facebook'], ['twitter', 'google'], ['google', 'facebook'], ['instagram', 'google'], ['twitter', 'instagram', 'google', 'facebook']]) == [8]\n assert candidate(favoriteCompanies = [['leetcode'], ['leetcode', 'google'], ['google', 'facebook'], ['leetcode', 'facebook'], ['facebook', 'amazon'], ['google', 'amazon', 'facebook'], ['leetcode', 'amazon', 'google', 'facebook']]) == [6]\n assert candidate(favoriteCompanies = [['apple'], ['banana'], ['cherry'], ['date'], ['fig'], ['grape'], ['kiwi'], ['lemon'], ['mango'], ['orange']]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(favoriteCompanies = [['google', 'apple'], ['google', 'apple', 'facebook'], ['google', 'facebook'], ['apple', 'facebook', 'microsoft'], ['google', 'microsoft'], ['apple', 'microsoft'], ['google', 'amazon'], ['apple', 'amazon'], ['facebook', 'amazon'], ['google', 'facebook', 'amazon', 'apple', 'microsoft']]) == [9]\n assert candidate(favoriteCompanies = [['spotify', 'apple', 'google'], ['apple', 'google', 'amazon'], ['google', 'microsoft', 'apple'], ['facebook', 'google', 'amazon'], ['twitter', 'google', 'apple'], ['spotify', 'google', 'microsoft'], ['apple', 'google', 'facebook'], ['google', 'amazon', 'microsoft'], ['twitter', 'facebook', 'microsoft'], ['google', 'apple', 'facebook', 'microsoft', 'amazon', 'twitter', 'spotify']]) == [9]\n assert candidate(favoriteCompanies = [['google', 'facebook', 'amazon', 'apple', 'microsoft'], ['google', 'facebook'], ['google', 'amazon'], ['google', 'apple'], ['google', 'microsoft'], ['facebook', 'amazon'], ['facebook', 'apple'], ['facebook', 'microsoft'], ['amazon', 'apple'], ['amazon', 'microsoft'], ['apple', 'microsoft'], ['google'], ['facebook'], ['amazon'], ['apple'], ['microsoft']]) == [0]\n assert candidate(favoriteCompanies = [['a', 'b', 'c', 'd', 'e'], ['b', 'c', 'd'], ['d', 'e'], ['e', 'a'], ['a', 'b'], ['c', 'd', 'e'], ['a', 'b', 'c'], ['b', 'c'], ['c', 'd'], ['d', 'e'], ['e', 'a'], ['a', 'b']]) == [0]\n assert candidate(favoriteCompanies = [['tech1', 'tech2', 'tech3', 'tech4'], ['tech2', 'tech3'], ['tech3', 'tech4'], ['tech4', 'tech1'], ['tech1', 'tech2'], ['tech2', 'tech3', 'tech4'], ['tech3', 'tech4', 'tech1'], ['tech4', 'tech1', 'tech2'], ['tech1', 'tech2', 'tech3']]) == [0]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['apple', 'banana'], ['banana', 'cherry'], ['apple', 'cherry'], ['date', 'fig', 'grape']]) == [0, 4]\n assert candidate(favoriteCompanies = [['x', 'y', 'z', 'w', 'v'], ['y', 'z'], ['z', 'w'], ['w', 'v'], ['v', 'x'], ['x', 'y'], ['y', 'z', 'w'], ['z', 'w', 'v'], ['w', 'v', 'x'], ['v', 'x', 'y'], ['x', 'y', 'z']]) == [0]\n assert candidate(favoriteCompanies = [['spotify', 'apple', 'deez', 'pandora'], ['apple', 'soundcloud', 'tidal'], ['deez', 'pandora', 'soundcloud'], ['spotify', 'soundcloud', 'tidal'], ['spotify', 'apple', 'deez', 'pandora', 'soundcloud', 'tidal']]) == [4]\n assert candidate(favoriteCompanies = [['uber', 'lyft', 'grubhub'], ['grubhub', 'doorDash', 'postmates'], ['lyft', 'postmates', 'uber'], ['uber', 'lyft', 'grubhub', 'doorDash', 'postmates'], ['postmates', 'grubhub'], ['uber', 'grubhub', 'doorDash'], ['grubhub', 'lyft', 'uber', 'postmates'], ['doorDash', 'lyft']]) == [3]\n assert candidate(favoriteCompanies = [['pinterest', 'quora', 'reddit'], ['quora', 'snapchat', 'twitter'], ['facebook', 'google', 'instagram'], ['linkedin', 'pinterest', 'quora', 'reddit'], ['facebook', 'google', 'instagram', 'linkedin', 'pinterest'], ['pinterest', 'quora', 'reddit', 'snapchat', 'twitter'], ['instagram', 'linkedin', 'pinterest', 'quora', 'reddit']]) == [4, 5, 6]\n assert candidate(favoriteCompanies = [['tech1', 'tech2', 'tech3', 'tech4'], ['tech1', 'tech2'], ['tech2', 'tech3'], ['tech3', 'tech4'], ['tech4', 'tech1'], ['tech2', 'tech4'], ['tech1', 'tech3'], ['tech1', 'tech2', 'tech3'], ['tech2', 'tech3', 'tech4'], ['tech1', 'tech2', 'tech4']]) == [0]\n assert candidate(favoriteCompanies = [['techcrunch', 'theverge'], ['theverge', 'recode'], ['techcrunch', 'recode', 'theverge'], ['theverge', 'cnet'], ['recode', 'cnet', 'theverge'], ['techcrunch', 'cnet'], ['recode', 'cnet'], ['techcrunch', 'recode', 'theverge', 'cnet'], ['cnet', 'theverge'], ['recode', 'theverge', 'cnet'], ['techcrunch', 'theverge', 'cnet', 'recode'], ['cnet'], ['techcrunch'], ['recode']]) == []\n assert candidate(favoriteCompanies = [['xbox', 'playstation', 'nintendo'], ['nintendo', 'sega'], ['playstation', 'nintendo', 'sega'], ['xbox', 'nintendo'], ['playstation', 'sega'], ['xbox', 'playstation', 'nintendo', 'sega'], ['xbox', 'playstation'], ['nintendo']]) == [5]\n assert candidate(favoriteCompanies = [['microsoft', 'amazon', 'google'], ['google'], ['amazon'], ['microsoft'], ['google', 'amazon'], ['google', 'microsoft'], ['microsoft', 'amazon'], ['amazon', 'google'], ['google', 'microsoft', 'amazon'], ['google', 'microsoft', 'amazon', 'facebook']]) == [9]\n assert candidate(favoriteCompanies = [['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'], ['b', 'c'], ['c', 'd', 'e'], ['d', 'e', 'f'], ['e', 'f', 'g'], ['f', 'g', 'h'], ['g', 'h'], ['h']]) == [0]\n assert candidate(favoriteCompanies = [['amazon', 'ebay', 'google'], ['google', 'microsoft'], ['ebay', 'microsoft'], ['amazon', 'microsoft'], ['amazon', 'ebay', 'google', 'microsoft']]) == [4]\n assert candidate(favoriteCompanies = [['ibm', 'apple', 'microsoft'], ['apple', 'google', 'amazon'], ['ibm', 'google', 'amazon'], ['microsoft', 'amazon'], ['ibm', 'apple', 'google', 'amazon'], ['apple', 'microsoft', 'google'], ['ibm', 'google']]) == [0, 3, 4, 5]\n assert candidate(favoriteCompanies = [['facebook', 'instagram'], ['instagram', 'snapchat'], ['facebook', 'snapchat'], ['facebook', 'instagram', 'snapchat'], ['facebook'], ['snapchat'], ['instagram']]) == [3]\n assert candidate(favoriteCompanies = [['amazon', 'google', 'apple'], ['google', 'facebook', 'microsoft'], ['amazon', 'facebook', 'apple'], ['google', 'amazon', 'facebook', 'microsoft'], ['google', 'apple']]) == [0, 2, 3]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana', 'cherry'], ['cherry', 'date'], ['date', 'elderberry'], ['elderberry', 'fig'], ['fig', 'grape'], ['grape', 'honeydew'], ['honeydew', 'apple']]) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana', 'cherry', 'date'], ['apple', 'cherry', 'date'], ['banana', 'date'], ['apple', 'banana', 'cherry'], ['apple', 'banana', 'cherry', 'date'], ['apple', 'banana', 'cherry', 'date', 'fig']]) == [6]\n assert candidate(favoriteCompanies = [['apple'], ['banana'], ['cherry'], ['date'], ['elderberry'], ['fig'], ['grape'], ['honeydew'], ['kiwi'], ['lemon'], ['mango'], ['nectarine'], ['orange'], ['papaya'], ['quince'], ['raspberry'], ['strawberry'], ['tangerine'], ['ugli'], ['vanilla'], ['watermelon'], ['xigua'], ['yam'], ['zucchini']]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'date', 'elderberry'], ['apple', 'banana', 'cherry', 'date', 'elderberry'], ['cherry', 'date'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape']]) == [2, 4]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry', 'date'], ['apple', 'cherry', 'date'], ['cherry', 'date', 'fig'], ['apple', 'banana', 'date', 'fig'], ['banana', 'date', 'fig', 'grape'], ['apple', 'cherry', 'fig', 'grape'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape'], ['banana', 'cherry', 'date', 'fig', 'grape', 'honeydew'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape', 'honeydew'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape', 'honeydew', 'kiwi'], ['banana', 'cherry', 'date', 'fig', 'grape', 'honeydew', 'kiwi'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape', 'honeydew', 'kiwi', 'lemon'], ['banana', 'cherry', 'date', 'fig', 'grape', 'honeydew', 'kiwi', 'lemon', 'mango'], ['apple', 'banana', 'cherry', 'date', 'fig', 'grape', 'honeydew', 'kiwi', 'lemon', 'mango'], ['banana', 'cherry', 'date', 'fig', 'grape', 'honeydew', 'kiwi', 'lemon', 'mango', 'nectarine']]) == [14, 15]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry', 'date'], ['apple', 'cherry', 'date'], ['banana', 'date'], ['apple', 'banana', 'cherry'], ['apple', 'banana'], ['banana', 'cherry'], ['cherry', 'date'], ['apple', 'date'], ['date']]) == [1, 2]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['cherry', 'date'], ['apple', 'banana'], ['banana', 'cherry', 'date'], ['apple', 'banana', 'cherry', 'date']]) == [4]\n assert candidate(favoriteCompanies = [['a', 'b', 'c', 'd', 'e'], ['a', 'b'], ['b', 'c'], ['c', 'd'], ['d', 'e'], ['e', 'a'], ['a', 'c'], ['b', 'd'], ['c', 'e'], ['d', 'a'], ['e', 'b'], ['a', 'b', 'c'], ['b', 'c', 'd'], ['c', 'd', 'e'], ['d', 'e', 'a'], ['e', 'a', 'b']]) == [0]\n assert candidate(favoriteCompanies = [['company1'], ['company2'], ['company3'], ['company4'], ['company5'], ['company6'], ['company7'], ['company8'], ['company9'], ['company10'], ['company11'], ['company12'], ['company13'], ['company14'], ['company15'], ['company16'], ['company17'], ['company18'], ['company19'], ['company20'], ['company21'], ['company22'], ['company23'], ['company24'], ['company25'], ['company26'], ['company27'], ['company28'], ['company29'], ['company30']]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]\n assert candidate(favoriteCompanies = [['apple', 'banana'], ['banana', 'cherry'], ['cherry', 'date'], ['date', 'fig'], ['fig', 'grape'], ['grape', 'honeydew'], ['honeydew', 'kiwi'], ['kiwi', 'lemon'], ['lemon', 'mango'], ['mango', 'nectarine'], ['nectarine', 'orange'], ['orange', 'papaya'], ['papaya', 'quince'], ['quince', 'raspberry'], ['raspberry', 'strawberry'], ['strawberry', 'tangerine'], ['tangerine', 'ugli'], ['ugli', 'vanilla'], ['vanilla', 'watermelon'], ['watermelon', 'xigua'], ['xigua', 'yam'], ['yam', 'zucchini']]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]\n assert candidate(favoriteCompanies = [['one', 'two', 'three'], ['two', 'three', 'four'], ['three', 'four', 'five'], ['four', 'five', 'six'], ['five', 'six', 'seven'], ['six', 'seven', 'eight'], ['seven', 'eight', 'nine'], ['eight', 'nine', 'ten'], ['nine', 'ten', 'one'], ['ten', 'one', 'two']]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(favoriteCompanies = [['honda', 'toyota', 'mazda'], ['toyota', 'nissan', 'mitsubishi'], ['honda', 'toyota', 'nissan', 'mitsubishi'], ['mazda', 'nissan', 'mitsubishi'], ['honda', 'toyota', 'mazda', 'nissan', 'mitsubishi']]) == [4]\n assert candidate(favoriteCompanies = [['amazon', 'apple', 'facebook', 'google'], ['apple', 'facebook'], ['amazon', 'google'], ['facebook', 'google'], ['amazon', 'facebook', 'google'], ['apple', 'google']]) == [0]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry', 'date', 'elderberry'], ['banana', 'cherry', 'date', 'fig'], ['apple', 'banana', 'date', 'fig', 'grape'], ['cherry', 'date', 'fig', 'grape', 'honeydew'], ['apple', 'cherry', 'fig', 'grape', 'honeydew'], ['banana', 'cherry', 'grape', 'honeydew']]) == [0, 1, 2, 3, 4, 5]\n assert candidate(favoriteCompanies = [['alibaba', 'tencent', 'jd'], ['tencent', 'xiami', 'sina'], ['jd', 'xiami', 'sina'], ['alibaba', 'tencent', 'jd', 'sina'], ['xiami', 'sina'], ['alibaba', 'jd']]) == [1, 2, 3]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry', 'date'], ['banana', 'cherry'], ['apple', 'cherry', 'date'], ['cherry', 'date'], ['apple', 'banana', 'cherry'], ['banana', 'date'], ['apple', 'banana', 'cherry', 'date', 'elderberry'], ['banana', 'cherry', 'date', 'fig'], ['apple', 'banana', 'date', 'fig', 'grape'], ['cherry', 'date', 'fig', 'grape', 'honeydew'], ['apple', 'cherry', 'fig', 'grape', 'honeydew'], ['banana', 'cherry', 'grape', 'honeydew']]) == [6, 7, 8, 9, 10, 11]\n assert candidate(favoriteCompanies = [['google'], ['google', 'facebook'], ['google', 'facebook', 'amazon'], ['google', 'facebook', 'amazon', 'apple'], ['google', 'facebook', 'amazon', 'apple', 'microsoft'], ['google', 'facebook', 'amazon', 'apple', 'microsoft', 'netflix'], ['google', 'facebook', 'amazon', 'apple', 'microsoft', 'netflix', 'spotify']]) == [6]\n assert candidate(favoriteCompanies = [['microsoft', 'google'], ['google', 'facebook'], ['leetcode', 'google', 'facebook'], ['google'], ['amazon'], ['microsoft', 'amazon'], ['amazon', 'google']]) == [0, 2, 5, 6]\n assert candidate(favoriteCompanies = [['apple', 'google', 'facebook', 'microsoft'], ['google', 'facebook', 'microsoft'], ['apple', 'facebook', 'microsoft'], ['apple', 'google', 'microsoft'], ['apple', 'google', 'facebook'], ['facebook', 'microsoft'], ['google', 'microsoft'], ['apple', 'microsoft'], ['apple', 'google'], ['apple', 'facebook']]) == [0]\n assert candidate(favoriteCompanies = [['netflix', 'hulu'], ['hulu', 'crunchyroll'], ['netflix', 'crunchyroll'], ['netflix', 'hulu', 'crunchyroll'], ['netflix', 'hulu', 'crunchyroll', 'disney'], ['disney'], ['netflix'], ['hulu'], ['crunchyroll'], ['netflix', 'hulu', 'disney'], ['hulu', 'crunchyroll', 'disney'], ['netflix', 'crunchyroll', 'disney']]) == [4]\n assert candidate(favoriteCompanies = [['google', 'amazon', 'facebook'], ['google', 'amazon'], ['google'], ['amazon'], ['facebook'], ['google', 'facebook'], ['amazon', 'facebook']]) == [0]\n assert candidate(favoriteCompanies = [['apple', 'banana', 'cherry'], ['banana', 'cherry'], ['apple', 'cherry'], ['cherry'], ['apple', 'banana'], ['banana']]) == [0]\n assert candidate(favoriteCompanies = [['apple', 'microsoft', 'google'], ['amazon', 'apple', 'microsoft'], ['apple', 'google'], ['google', 'microsoft'], ['facebook', 'google', 'microsoft', 'amazon'], ['apple', 'banana', 'cherry']]) == [0, 1, 4, 5]\n"}, "metadata": {"canonical_parameter_names": ["favoriteCompanies"], "leetcode_dataset_entry_point": "Solution().peopleIndexes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector peopleIndexes(vector>& favoriteCompanies) {", "container": "Solution", "callable": "peopleIndexes", "parameters": [{"name": "favoriteCompanies", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1453, "task_id": "maximum-number-of-darts-inside-of-a-circular-dartboard", "difficulty": "Hard", "problem_description": "Alice is throwing n darts on a very large wall. You are given an array darts where darts[i] = [xi, yi] is the position of the ith dart that Alice threw on the wall.\nBob knows the positions of the n darts on the wall. He wants to place a dartboard of radius r on the wall so that the maximum number of darts that Alice throws lie on the dartboard.\nGiven the integer r, return the maximum number of darts that can lie on the dartboard.\n \nExample 1:\n\n\nInput: darts = [[-2,0],[2,0],[0,2],[0,-2]], r = 2\nOutput: 4\nExplanation: Circle dartboard with center in (0,0) and radius = 2 contain all points.\n\nExample 2:\n\n\nInput: darts = [[-3,0],[3,0],[2,6],[5,4],[0,9],[7,8]], r = 5\nOutput: 5\nExplanation: Circle dartboard with center in (0,4) and radius = 5 contain all points except the point (7,8).\n\n \nConstraints:\n\n1 <= darts.length <= 100\ndarts[i].length == 2\n-104 <= xi, yi <= 104\nAll the darts are unique\n1 <= r <= 5000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(darts = [[100, 100], [-100, -100], [0, 0]],r = 150) == 3\n assert candidate(darts = [[-5000, -5000], [5000, 5000], [-5000, 5000], [5000, -5000]],r = 7071) == 2\n assert candidate(darts = [[0, 0], [0, 1], [0, 2], [0, 3]],r = 1) == 3\n assert candidate(darts = [[-3, 0], [3, 0], [2, 6], [5, 4], [0, 9], [7, 8]],r = 5) == 5\n assert candidate(darts = [[-10000, 10000], [10000, -10000]],r = 5000) == 1\n assert candidate(darts = [[-1, -1], [1, 1], [-1, 1], [1, -1]],r = 2) == 4\n assert candidate(darts = [[-2, 2], [-3, 3], [-1, 1], [0, 0]],r = 2) == 3\n assert candidate(darts = [[1, 1], [2, 2], [3, 3]],r = 1) == 2\n assert candidate(darts = [[0, 0], [1, 1], [1.4, 1.4]],r = 1) == 3\n assert candidate(darts = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]],r = 2) == 3\n assert candidate(darts = [[0, 0], [10000, 0], [0, 10000], [10000, 10000]],r = 5000) == 2\n assert candidate(darts = [[1, 1], [2, 2], [3, 3], [4, 4]],r = 2) == 3\n assert candidate(darts = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0]],r = 1) == 3\n assert candidate(darts = [[1, 1], [2, 2], [3, 3], [4, 4]],r = 1) == 2\n assert candidate(darts = [[1000, -1000], [-1000, 1000], [0, 0]],r = 1500) == 3\n assert candidate(darts = [[-5, 0], [5, 0], [0, 5], [0, -5]],r = 5) == 4\n assert candidate(darts = [[0, 0], [10, 0], [0, 10], [10, 10]],r = 7) == 2\n assert candidate(darts = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4]],r = 1) == 3\n assert candidate(darts = [[-5, -5], [5, 5], [-5, 5], [5, -5]],r = 7) == 2\n assert candidate(darts = [[1, 1], [2, 2], [3, 3], [4, 4]],r = 3) == 4\n assert candidate(darts = [[-1, 0], [0, 1], [1, 0], [0, -1]],r = 1) == 4\n assert candidate(darts = [[0, 0], [1, 0], [2, 0], [3, 0]],r = 1) == 3\n assert candidate(darts = [[0, 0], [1, 1], [1, -1], [-1, 1], [-1, -1]],r = 2) == 5\n assert candidate(darts = [[10, 10], [11, 11], [12, 12], [13, 13], [14, 14]],r = 1) == 2\n assert candidate(darts = [[-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2]],r = 1) == 2\n assert candidate(darts = [[0, 0], [0, 1], [1, 0], [1, 1]],r = 1) == 4\n assert candidate(darts = [[0, 0], [1, 0], [0, 1]],r = 1) == 3\n assert candidate(darts = [[-2, 0], [2, 0], [0, 2], [0, -2]],r = 2) == 4\n assert candidate(darts = [[1, 2], [2, 3], [3, 4], [4, 5]],r = 1) == 2\n assert candidate(darts = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],r = 1) == 2\n assert candidate(darts = [[-5000, 0], [5000, 0], [0, -5000], [0, 5000], [2500, 2500]],r = 5000) == 5\n assert candidate(darts = [[-2, -2], [-2, 0], [-2, 2], [0, -2], [0, 0], [0, 2], [2, -2], [2, 0], [2, 2]],r = 2) == 5\n assert candidate(darts = [[-200, 200], [-100, 100], [-50, 50], [0, 0], [50, -50], [100, -100], [200, -200], [50, 150], [150, 50], [-150, -50], [-50, -150]],r = 150) == 7\n assert candidate(darts = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10]],r = 5) == 2\n assert candidate(darts = [[-10000, 10000], [10000, -10000], [0, 0], [5000, 5000], [-5000, -5000]],r = 5000) == 2\n assert candidate(darts = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],r = 5) == 4\n assert candidate(darts = [[-1, 0], [1, 0], [0, -1], [0, 1], [0.5, 0.5], [-0.5, -0.5], [0.5, -0.5], [-0.5, 0.5]],r = 1) == 8\n assert candidate(darts = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0]],r = 2) == 5\n assert candidate(darts = [[-2, 2], [-2, -2], [2, 2], [2, -2], [0, 0], [0, 4], [4, 0], [4, 4]],r = 4) == 7\n assert candidate(darts = [[100, 100], [200, 200], [150, 150], [50, 50], [300, 300]],r = 150) == 4\n assert candidate(darts = [[1, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15]],r = 5) == 4\n assert candidate(darts = [[1, 1], [1, 3], [3, 1], [3, 3], [5, 5], [5, 7], [7, 5], [7, 7], [9, 9], [9, 11]],r = 2.83) == 5\n assert candidate(darts = [[-5000, -5000], [-5000, 5000], [5000, 5000], [5000, -5000], [0, 0]],r = 7071) == 3\n assert candidate(darts = [[0, 0], [10, 0], [20, 0], [30, 0], [40, 0], [50, 0], [60, 0], [70, 0], [80, 0], [90, 0]],r = 10) == 3\n assert candidate(darts = [[-1000, -1000], [1000, 1000], [1000, -1000], [-1000, 1000], [0, 0]],r = 1414) == 3\n assert candidate(darts = [[100, 200], [300, 400], [500, 600], [700, 800], [900, 1000], [1100, 1200], [1300, 1400], [1500, 1600], [1700, 1800], [1900, 2000]],r = 500) == 4\n assert candidate(darts = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700]],r = 150) == 3\n assert candidate(darts = [[0, 0], [5000, 0], [0, 5000], [5000, 5000], [2500, 2500]],r = 3000) == 3\n assert candidate(darts = [[-10, -10], [-9, -9], [-8, -8], [-7, -7], [-6, -6], [-5, -5], [-4, -4], [-3, -3], [-2, -2], [-1, -1]],r = 4) == 6\n assert candidate(darts = [[-1000, -1000], [-1000, 1000], [1000, -1000], [1000, 1000], [0, 0]],r = 1500) == 5\n assert candidate(darts = [[-500, -500], [-250, -250], [0, 0], [250, 250], [500, 500], [-500, 500], [500, -500]],r = 500) == 4\n assert candidate(darts = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10]],r = 4) == 9\n assert candidate(darts = [[0, 0], [0, 2], [2, 0], [2, 2], [1, 1], [1, 3], [3, 1], [3, 3]],r = 2) == 7\n assert candidate(darts = [[0, 0], [100, 0], [200, 0], [300, 0], [400, 0], [500, 0], [600, 0], [700, 0], [800, 0], [900, 0]],r = 150) == 4\n assert candidate(darts = [[0, 0], [1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20]],r = 5) == 5\n assert candidate(darts = [[0, 0], [10, 0], [5, 5]],r = 10) == 3\n assert candidate(darts = [[100, 100], [200, 100], [100, 200], [200, 200], [150, 150], [125, 125], [175, 175]],r = 50) == 4\n assert candidate(darts = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],r = 2) == 3\n assert candidate(darts = [[0, 0], [50, 0], [100, 0], [150, 0], [200, 0], [250, 0], [300, 0], [350, 0], [400, 0], [450, 0], [500, 0]],r = 200) == 9\n assert candidate(darts = [[100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [100, 200], [200, 300]],r = 100) == 5\n assert candidate(darts = [[1000, 1000], [2000, 2000], [3000, 3000], [4000, 4000], [5000, 5000]],r = 5000) == 5\n assert candidate(darts = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],r = 1) == 2\n assert candidate(darts = [[0, 0], [1, 0], [0, 1], [1, 1], [0.5, 0.5]],r = 1) == 5\n assert candidate(darts = [[-1, -1], [-1, 1], [1, -1], [1, 1], [0, 0]],r = 1) == 3\n assert candidate(darts = [[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]],r = 2) == 3\n assert candidate(darts = [[0, 0], [10, 0], [20, 0], [30, 0], [40, 0]],r = 10) == 3\n assert candidate(darts = [[-2000, -2000], [-1000, -1000], [0, 0], [1000, 1000], [2000, 2000], [1000, 0], [0, 1000]],r = 1414) == 4\n assert candidate(darts = [[-5000, -5000], [-4000, -4000], [-4500, -4500], [-3000, -3000], [-5500, -5500]],r = 1000) == 3\n assert candidate(darts = [[-1, -1], [0, -1], [1, -1], [-1, 0], [0, 0], [1, 0], [-1, 1], [0, 1], [1, 1]],r = 1) == 5\n assert candidate(darts = [[-10, -10], [-5, -5], [0, 0], [5, 5], [10, 10]],r = 8) == 3\n assert candidate(darts = [[-100, -100], [-100, 100], [100, -100], [100, 100], [0, 0]],r = 150) == 5\n assert candidate(darts = [[-1, -2], [-2, -4], [-3, -6], [-4, -8], [-5, -10], [-6, -12], [-7, -14]],r = 3) == 3\n assert candidate(darts = [[-1000, 0], [0, -1000], [1000, 0], [0, 1000], [500, 500], [-500, 500], [500, -500], [-500, -500]],r = 1000) == 8\n assert candidate(darts = [[-1000, -1000], [-1000, 1000], [1000, 1000], [1000, -1000], [0, 0], [500, 500]],r = 1000) == 4\n assert candidate(darts = [[-10, 0], [0, -10], [10, 0], [0, 10], [0, 0], [5, 5], [-5, -5], [-5, 5], [5, -5]],r = 15) == 9\n assert candidate(darts = [[-10, -10], [-10, 0], [-10, 10], [0, -10], [0, 0], [0, 10], [10, -10], [10, 0], [10, 10]],r = 15) == 9\n assert candidate(darts = [[-10, 0], [10, 0], [0, -10], [0, 10], [5, 5], [-5, -5]],r = 10) == 6\n assert candidate(darts = [[10, 10], [10, 20], [20, 10], [20, 20], [15, 15], [0, 0]],r = 10) == 5\n assert candidate(darts = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90]],r = 50) == 8\n assert candidate(darts = [[0, 0], [0, 100], [0, 200], [0, 300], [0, 400], [0, 500], [0, 600], [0, 700], [0, 800], [0, 900]],r = 150) == 4\n assert candidate(darts = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],r = 15) == 3\n assert candidate(darts = [[10, 10], [10, 20], [20, 10], [20, 20], [30, 30], [40, 40], [50, 50]],r = 15) == 5\n assert candidate(darts = [[-2000, -2000], [-2000, 2000], [2000, -2000], [2000, 2000], [0, 0]],r = 2500) == 3\n assert candidate(darts = [[-5000, 0], [5000, 0], [0, 5000], [0, -5000]],r = 5000) == 4\n assert candidate(darts = [[-2, -2], [-2, 2], [2, -2], [2, 2], [0, 0], [-1, 1], [1, -1], [-1, -1], [1, 1]],r = 3) == 9\n assert candidate(darts = [[1, 1], [1, 5], [5, 5], [5, 1], [3, 3], [2, 2], [4, 4], [2, 3], [3, 2], [4, 3], [3, 4]],r = 2) == 8\n assert candidate(darts = [[-500, 0], [-400, 0], [-300, 0], [-200, 0], [-100, 0], [0, 0], [100, 0], [200, 0], [300, 0], [400, 0]],r = 100) == 3\n assert candidate(darts = [[-5000, -5000], [5000, 5000], [0, 0], [1000, 1000], [-1000, -1000]],r = 6000) == 4\n assert candidate(darts = [[-10, 10], [10, -10], [-10, -10], [10, 10], [0, 0]],r = 20) == 5\n assert candidate(darts = [[1000, 1000], [1500, 1000], [1000, 1500], [1500, 1500], [2500, 2500]],r = 1000) == 4\n assert candidate(darts = [[-1000, 1000], [-500, 500], [0, 0], [500, -500], [1000, -1000]],r = 1500) == 5\n assert candidate(darts = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900], [1000, 1000]],r = 150) == 3\n assert candidate(darts = [[5, 5], [10, 5], [15, 5], [20, 5], [25, 5], [5, 10], [10, 10], [15, 10], [20, 10], [25, 10]],r = 5) == 4\n assert candidate(darts = [[-20, 20], [-20, -20], [20, 20], [20, -20], [0, 0], [0, 40], [40, 0], [40, 40], [50, 50]],r = 50) == 9\n assert candidate(darts = [[1, 1], [2, 1], [3, 1], [4, 1], [1, 2], [2, 2], [3, 2], [4, 2], [1, 3], [2, 3], [3, 3], [4, 3]],r = 1) == 5\n assert candidate(darts = [[1000, 1000], [2000, 2000], [3000, 3000], [4000, 4000], [5000, 5000]],r = 1000) == 2\n assert candidate(darts = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]],r = 5) == 4\n assert candidate(darts = [[-5000, 5000], [5000, -5000], [-5000, -5000], [5000, 5000], [0, 0]],r = 5000) == 3\n assert candidate(darts = [[0, 0], [100, 0], [200, 0], [300, 0], [400, 0], [500, 0], [600, 0], [700, 0], [800, 0], [900, 0]],r = 100) == 3\n assert candidate(darts = [[1000, -1000], [1500, -1000], [2000, -1000], [1000, -1500], [1000, -2000]],r = 500) == 3\n assert candidate(darts = [[1000, 1000], [1001, 1001], [1002, 1002], [1003, 1003], [1004, 1004], [1005, 1005], [1006, 1006], [1007, 1007], [1008, 1008], [1009, 1009]],r = 1) == 2\n assert candidate(darts = [[1, 1], [1, 4], [4, 1], [4, 4], [2, 2], [3, 3]],r = 2) == 4\n assert candidate(darts = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],r = 3) == 7\n assert candidate(darts = [[-5000, -5000], [5000, 5000], [0, 0], [1, 1]],r = 5000) == 3\n assert candidate(darts = [[0, 0], [0, 10], [10, 0], [10, 10]],r = 7) == 2\n assert candidate(darts = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],r = 2) == 3\n assert candidate(darts = [[0, 0], [10000, 10000], [-10000, -10000], [5000, -5000], [-5000, 5000]],r = 14142) == 4\n assert candidate(darts = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],r = 1) == 1\n assert candidate(darts = [[-1000, 1000], [1000, -1000], [500, 500], [-500, -500]],r = 1000) == 3\n assert candidate(darts = [[1, 1], [1, 3], [3, 1], [3, 3], [2, 2], [4, 4], [4, 5], [5, 4]],r = 1) == 3\n assert candidate(darts = [[-5000, -5000], [-4000, -4000], [-3000, -3000], [-2000, -2000], [-1000, -1000]],r = 1000) == 2\n assert candidate(darts = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0]],r = 2) == 5\n assert candidate(darts = [[-5, -5], [0, 0], [5, 5], [10, 10], [15, 15]],r = 7) == 2\n assert candidate(darts = [[-100, -100], [100, 100], [-100, 100], [100, -100], [0, 0]],r = 150) == 5\n assert candidate(darts = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],r = 1) == 5\n assert candidate(darts = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700]],r = 100) == 2\n assert candidate(darts = [[100, 100], [101, 100], [102, 102], [102, 101], [101, 102]],r = 2) == 5\n assert candidate(darts = [[0, 0], [5, 0], [5, 5], [0, 5], [2.5, 2.5]],r = 3) == 3\n assert candidate(darts = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [2, 3], [3, 2], [3, 3]],r = 1) == 4\n assert candidate(darts = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14]],r = 3) == 3\n assert candidate(darts = [[-1000, 1000], [-900, 1100], [-800, 1200], [-700, 1300], [-600, 1400], [-500, 1500], [-400, 1600], [-300, 1700]],r = 200) == 3\n assert candidate(darts = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]],r = 50) == 4\n assert candidate(darts = [[-2000, -2000], [2000, 2000], [0, 0], [1000, -1000], [-1000, 1000]],r = 2500) == 4\n assert candidate(darts = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600]],r = 100) == 2\n assert candidate(darts = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],r = 1.5) == 3\n assert candidate(darts = [[500, 500], [500, 600], [600, 500], [600, 600], [300, 300], [300, 400], [400, 300], [400, 400]],r = 141) == 4\n assert candidate(darts = [[-5, 5], [5, 5], [5, -5], [-5, -5], [0, 0]],r = 5) == 3\n assert candidate(darts = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],r = 2) == 3\n assert candidate(darts = [[1, 1], [2, 1], [1, 2], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]],r = 1) == 4\n assert candidate(darts = [[0, 0], [0, 1], [1, 0], [1, 1], [0, 2], [1, 2], [2, 0], [2, 1], [2, 2]],r = 1.5) == 9\n"}, "metadata": {"canonical_parameter_names": ["darts", "r"], "leetcode_dataset_entry_point": "Solution().numPoints", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numPoints(vector>& darts, int r) {", "container": "Solution", "callable": "numPoints", "parameters": [{"name": "darts", "type": "vector>&"}, {"name": "r", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1455, "task_id": "check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence", "difficulty": "Easy", "problem_description": "Given a sentence that consists of some words separated by a single space, and a searchWord, check if searchWord is a prefix of any word in sentence.\nReturn the index of the word in sentence (1-indexed) where searchWord is a prefix of this word. If searchWord is a prefix of more than one word, return the index of the first word (minimum index). If there is no such word return -1.\nA prefix of a string s is any leading contiguous substring of s.\n \nExample 1:\n\nInput: sentence = \"i love eating burger\", searchWord = \"burg\"\nOutput: 4\nExplanation: \"burg\" is prefix of \"burger\" which is the 4th word in the sentence.\n\nExample 2:\n\nInput: sentence = \"this problem is an easy problem\", searchWord = \"pro\"\nOutput: 2\nExplanation: \"pro\" is prefix of \"problem\" which is the 2nd and the 6th word in the sentence, but we return 2 as it's the minimal index.\n\nExample 3:\n\nInput: sentence = \"i am tired\", searchWord = \"you\"\nOutput: -1\nExplanation: \"you\" is not a prefix of any word in the sentence.\n\n \nConstraints:\n\n1 <= sentence.length <= 100\n1 <= searchWord.length <= 10\nsentence consists of lowercase English letters and spaces.\nsearchWord consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(sentence = \"a ab abc abd\",searchWord = \"a\") == 1\n assert candidate(sentence = \"abcde fghij klmno\",searchWord = \"mnop\") == -1\n assert candidate(sentence = \"find prefix quickly\",searchWord = \"qui\") == 3\n assert candidate(sentence = \"prefix test\",searchWord = \"prefix\") == 1\n assert candidate(sentence = \"prefix test\",searchWord = \"testprefix\") == -1\n assert candidate(sentence = \"hello world\",searchWord = \"he\") == 1\n assert candidate(sentence = \"a aa aaa aaaa\",searchWord = \"aaaa\") == 4\n assert candidate(sentence = \"coding in python is fun\",searchWord = \"py\") == 3\n assert candidate(sentence = \"i love eating burger\",searchWord = \"burg\") == 4\n assert candidate(sentence = \"prefix prefixation prefixed pre\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"i am tired\",searchWord = \"you\") == -1\n assert candidate(sentence = \"example test case\",searchWord = \"exa\") == 1\n assert candidate(sentence = \"start end\",searchWord = \"sta\") == 1\n assert candidate(sentence = \"no match here\",searchWord = \"none\") == -1\n assert candidate(sentence = \"the quick brown fox jumps over the lazy dog\",searchWord = \"qui\") == 2\n assert candidate(sentence = \"coding in python\",searchWord = \"py\") == 3\n assert candidate(sentence = \"prefix test\",searchWord = \"fix\") == -1\n assert candidate(sentence = \"prefix test\",searchWord = \"test\") == 2\n assert candidate(sentence = \"abc def ghi\",searchWord = \"def\") == 2\n assert candidate(sentence = \"no matches here\",searchWord = \"match\") == 2\n assert candidate(sentence = \"all words unique\",searchWord = \"word\") == 2\n assert candidate(sentence = \"a aa aaa aaaa\",searchWord = \"aaa\") == 3\n assert candidate(sentence = \"a aa aaa aaaa\",searchWord = \"a\") == 1\n assert candidate(sentence = \"unique words only here\",searchWord = \"word\") == 2\n assert candidate(sentence = \"prefix prefix prefix\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"one two three\",searchWord = \"four\") == -1\n assert candidate(sentence = \"prefix test\",searchWord = \"tes\") == 2\n assert candidate(sentence = \"a aa aaa aaaa\",searchWord = \"aa\") == 2\n assert candidate(sentence = \"make america great again\",searchWord = \"am\") == 2\n assert candidate(sentence = \"prefix is the start\",searchWord = \"start\") == 4\n assert candidate(sentence = \"a b c d e f g\",searchWord = \"g\") == 7\n assert candidate(sentence = \"find the prefix\",searchWord = \"pre\") == 3\n assert candidate(sentence = \"this problem is an easy problem\",searchWord = \"pro\") == 2\n assert candidate(sentence = \"last word match\",searchWord = \"match\") == 3\n assert candidate(sentence = \"prefix test\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"a ab abc abcd abcde\",searchWord = \"abc\") == 3\n assert candidate(sentence = \"mississippi missouri\",searchWord = \"miss\") == 1\n assert candidate(sentence = \"a aa aaa aaaa\",searchWord = \"aaaaa\") == -1\n assert candidate(sentence = \"multiple matches match matcher matching\",searchWord = \"mat\") == 2\n assert candidate(sentence = \"introduction to the world of algorithms and datastructures\",searchWord = \"data\") == 8\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyz\",searchWord = \"abc\") == 1\n assert candidate(sentence = \"mississippi missouri missing\",searchWord = \"miss\") == 1\n assert candidate(sentence = \"prefix is present in the prefix\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"unique words only unique\",searchWord = \"uniq\") == 1\n assert candidate(sentence = \"look at these examples\",searchWord = \"these\") == 3\n assert candidate(sentence = \"unique words only here\",searchWord = \"only\") == 3\n assert candidate(sentence = \"prefix suffix prefixsuffix\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"testing for edge cases with different words\",searchWord = \"dif\") == 6\n assert candidate(sentence = \"python java c++ c#\",searchWord = \"c\") == 3\n assert candidate(sentence = \"one two three four five six seven eight nine ten\",searchWord = \"ten\") == 10\n assert candidate(sentence = \"aaaaa aaaaa aaaaa aaaaa\",searchWord = \"aaaa\") == 1\n assert candidate(sentence = \"algorithm datastructure code compiler bytecode\",searchWord = \"byte\") == 5\n assert candidate(sentence = \"finding exact match in the sentence\",searchWord = \"exac\") == 2\n assert candidate(sentence = \"hello world from the other side\",searchWord = \"from\") == 3\n assert candidate(sentence = \"singleword\",searchWord = \"single\") == 1\n assert candidate(sentence = \"this is a very very long sentence to test the code properly\",searchWord = \"very\") == 4\n assert candidate(sentence = \"multiple occurrences of the same prefix\",searchWord = \"same\") == 5\n assert candidate(sentence = \"prefix testing with prefix prefix prefix\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"overlap overlapping overlapped overlap\",searchWord = \"overl\") == 1\n assert candidate(sentence = \"find the correct index\",searchWord = \"cor\") == 3\n assert candidate(sentence = \"python programming is powerful\",searchWord = \"pro\") == 2\n assert candidate(sentence = \"boundary conditions need testing\",searchWord = \"test\") == 4\n assert candidate(sentence = \"algorithm and data structures are important\",searchWord = \"and\") == 2\n assert candidate(sentence = \"substring matching problem\",searchWord = \"match\") == 2\n assert candidate(sentence = \"pneumonoultramicroscopicsilicovolcanoconiosis pneumonoultramicroscopicsilicovolcanoconiosis\",searchWord = \"pneumono\") == 1\n assert candidate(sentence = \"hello world hello universe\",searchWord = \"he\") == 1\n assert candidate(sentence = \"algorithm datastructure programming language compiler\",searchWord = \"pro\") == 3\n assert candidate(sentence = \"uniquewordsinthesentence\",searchWord = \"words\") == -1\n assert candidate(sentence = \"prefixprefixprefixprefix\",searchWord = \"pref\") == 1\n assert candidate(sentence = \"quick brown fox jumps over the lazy dog\",searchWord = \"qu\") == 1\n assert candidate(sentence = \"continuous conversation connection component\",searchWord = \"con\") == 1\n assert candidate(sentence = \"small big medium small\",searchWord = \"sm\") == 1\n assert candidate(sentence = \"algorithm and data structures\",searchWord = \"alg\") == 1\n assert candidate(sentence = \"prefix problem prefixing prefixer\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"short longword reallylongword evenlongerword\",searchWord = \"long\") == 2\n assert candidate(sentence = \"binary search quicksort mergesort heapsort\",searchWord = \"sort\") == -1\n assert candidate(sentence = \"one two three four five six seven eight nine ten\",searchWord = \"fi\") == 5\n assert candidate(sentence = \"aaaaa aaaa aa a\",searchWord = \"a\") == 1\n assert candidate(sentence = \"prefix search in a list of words\",searchWord = \"sea\") == 2\n assert candidate(sentence = \"testing boundary conditions\",searchWord = \"boundary\") == 2\n assert candidate(sentence = \"testing edgecases with variouslengthwords\",searchWord = \"var\") == 4\n assert candidate(sentence = \"very very long sentence with many words to test the function\",searchWord = \"very\") == 1\n assert candidate(sentence = \"repeated repeated repeated\",searchWord = \"rep\") == 1\n assert candidate(sentence = \"searching for a longprefixword\",searchWord = \"longprefix\") == 4\n assert candidate(sentence = \"an apple a day keeps the doctor away\",searchWord = \"app\") == 2\n assert candidate(sentence = \"sun moon stars planets galaxies blackholes nebulas\",searchWord = \"black\") == 6\n assert candidate(sentence = \"every good boy does fine great boys deserve fine gifts\",searchWord = \"fi\") == 5\n assert candidate(sentence = \"abcdefgh abcdefghij abcdefghijk abcdefghijkl\",searchWord = \"abcdefg\") == 1\n assert candidate(sentence = \"another example to check\",searchWord = \"to\") == 3\n assert candidate(sentence = \"this is a simple test to check for prefix matching\",searchWord = \"tes\") == 5\n assert candidate(sentence = \"searching for exact prefix\",searchWord = \"sea\") == 1\n assert candidate(sentence = \"prefix prefix prefix prefix\",searchWord = \"pref\") == 1\n assert candidate(sentence = \"this is a simple sentence for testing\",searchWord = \"simple\") == 4\n assert candidate(sentence = \"hiddenprefixword is here\",searchWord = \"hidden\") == 1\n assert candidate(sentence = \"banana apple banana apple banana\",searchWord = \"ba\") == 1\n assert candidate(sentence = \"words with multiple spaces\",searchWord = \"mul\") == 3\n assert candidate(sentence = \"algorithm datastructure programming language\",searchWord = \"pro\") == 3\n assert candidate(sentence = \"prefixprefixprefixprefixprefix\",searchWord = \"prefix\") == 1\n assert candidate(sentence = \"prefix prefix prefix prefix prefix\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"complex problem requiring careful thought\",searchWord = \"com\") == 1\n assert candidate(sentence = \"random words with no match\",searchWord = \"nomatch\") == -1\n assert candidate(sentence = \"python programming py pyth pytho\",searchWord = \"py\") == 1\n assert candidate(sentence = \"abcd efgh ijkl mnop qrst uvwx yz\",searchWord = \"yz\") == 7\n assert candidate(sentence = \"findingprefixsinthesentence\",searchWord = \"finding\") == 1\n assert candidate(sentence = \"prefix matching is important for search engines\",searchWord = \"search\") == 6\n assert candidate(sentence = \"abcdefghij abcdefghij abcdefghij\",searchWord = \"abcdefghijk\") == -1\n assert candidate(sentence = \"abracadabra abracadabra abracadabra\",searchWord = \"abra\") == 1\n assert candidate(sentence = \"nonmatchingprefix prefix\",searchWord = \"non\") == 1\n assert candidate(sentence = \"finding the first occurrence firstness\",searchWord = \"fir\") == 3\n assert candidate(sentence = \"prefix matching problem prefixing preposition\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"none of these should match\",searchWord = \"non\") == 1\n assert candidate(sentence = \"prefix prefixing prefixation prefixed\",searchWord = \"prefix\") == 1\n assert candidate(sentence = \"multiple occurrences of a word word\",searchWord = \"word\") == 5\n assert candidate(sentence = \"all words are different\",searchWord = \"dif\") == 4\n assert candidate(sentence = \"prefixes are important in computer science\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"mismatch mismatching mismatches\",searchWord = \"mis\") == 1\n assert candidate(sentence = \"the quick brown fox jumps over the lazy dog\",searchWord = \"do\") == 9\n assert candidate(sentence = \"xy xxy xxxy xxxxy xxxxyy xxxxyyy\",searchWord = \"xxxxy\") == 4\n assert candidate(sentence = \"the quick brown fox jumps over the lazy dog\",searchWord = \"dog\") == 9\n assert candidate(sentence = \"repeated repeated repeated repeated\",searchWord = \"repeat\") == 1\n assert candidate(sentence = \"quick brown fox jumps over lazy dog\",searchWord = \"quic\") == 1\n assert candidate(sentence = \"prefixprefixprefix prefixprefix prefix pre prefixing\",searchWord = \"prefixp\") == 1\n assert candidate(sentence = \"ab ac ad ae af ag ah ai aj\",searchWord = \"a\") == 1\n assert candidate(sentence = \"this is a simple test case\",searchWord = \"sim\") == 4\n assert candidate(sentence = \"prefixprefix prefixprefixer prefixprefixing\",searchWord = \"prefixpre\") == 1\n assert candidate(sentence = \"unique words with no match\",searchWord = \"xyz\") == -1\n assert candidate(sentence = \"abracadabra abracadabra abracadabra\",searchWord = \"abrac\") == 1\n assert candidate(sentence = \"continuous integration and continuous delivery\",searchWord = \"cont\") == 1\n assert candidate(sentence = \"searching for the prefix within\",searchWord = \"with\") == 5\n assert candidate(sentence = \"consecutive words with same start\",searchWord = \"con\") == 1\n assert candidate(sentence = \"short long longer longest\",searchWord = \"long\") == 2\n assert candidate(sentence = \"consistent consistent consistency consistently\",searchWord = \"consist\") == 1\n assert candidate(sentence = \"a short simple sentence\",searchWord = \"shor\") == 2\n assert candidate(sentence = \"searching for a unique prefix\",searchWord = \"uniq\") == 4\n assert candidate(sentence = \"a quick brown fox jumps over the lazy dog\",searchWord = \"fox\") == 4\n assert candidate(sentence = \"programming is fun and educational\",searchWord = \"edu\") == 5\n assert candidate(sentence = \"finding the veryfirst occurrence\",searchWord = \"ver\") == 3\n assert candidate(sentence = \"the quick brown fox jumps over the lazy dog\",searchWord = \"qu\") == 2\n assert candidate(sentence = \"prefix prefixing prefixed\",searchWord = \"prefix\") == 1\n assert candidate(sentence = \"boundary conditions are tricky\",searchWord = \"tri\") == 4\n assert candidate(sentence = \"complexity of the problem\",searchWord = \"com\") == 1\n assert candidate(sentence = \"a aa aaa aaaa aaaaa aaaaaa\",searchWord = \"aaaa\") == 4\n assert candidate(sentence = \"searching for a specific word\",searchWord = \"spec\") == 4\n assert candidate(sentence = \"multiple occurrences of the same prefix prefix prefix\",searchWord = \"pre\") == 6\n assert candidate(sentence = \"ab abc abcd abcde abcdef abcdefg abcdefgh abcdefghi abcdefghij\",searchWord = \"abcde\") == 4\n assert candidate(sentence = \"partial match is not allowed\",searchWord = \"parti\") == 1\n assert candidate(sentence = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",searchWord = \"z\") == 26\n assert candidate(sentence = \"one two three four five six seven eight nine ten\",searchWord = \"nine\") == 9\n assert candidate(sentence = \"prefixes prefixing prefix pre prefixed\",searchWord = \"pref\") == 1\n assert candidate(sentence = \"prefix prefixing prefixed pre prefixable\",searchWord = \"pre\") == 1\n assert candidate(sentence = \"a a aa aa aaa\",searchWord = \"aaa\") == 5\n assert candidate(sentence = \"looking for a specific starting sequence\",searchWord = \"spe\") == 4\n assert candidate(sentence = \"alibaba cloud offers many products like ecs ec2 s3\",searchWord = \"ec\") == 7\n assert candidate(sentence = \"algorithm data structure and algorithm\",searchWord = \"algo\") == 1\n assert candidate(sentence = \"overlapwording overlapword overlap\",searchWord = \"overlap\") == 1\n assert candidate(sentence = \"the quick brown fox jumps over the lazy dog\",searchWord = \"the\") == 1\n assert candidate(sentence = \"prefix prefix prefix\",searchWord = \"prefix\") == 1\n assert candidate(sentence = \"prefix prefix prefix prefix\",searchWord = \"prefix\") == 1\n assert candidate(sentence = \"shorter is better\",searchWord = \"short\") == 1\n assert candidate(sentence = \"algorithms and data structures\",searchWord = \"and\") == 2\n assert candidate(sentence = \"interview question with multiple prefixes prefix\",searchWord = \"pre\") == 5\n assert candidate(sentence = \"banana bandana band breadth\",searchWord = \"ban\") == 1\n assert candidate(sentence = \"algorithms and data structures are fundamental\",searchWord = \"data\") == 3\n assert candidate(sentence = \"practice makes perfect in programming\",searchWord = \"per\") == 3\n assert candidate(sentence = \"verylongwordthatwilltesttheboundariesofthisfunction\",searchWord = \"verylong\") == 1\n assert candidate(sentence = \"longerprefix longerpre long pre\",searchWord = \"longerpre\") == 1\n assert candidate(sentence = \"this is a simple sentence with repeated words repeated words\",searchWord = \"repe\") == 7\n assert candidate(sentence = \"a quick brown fox jumps over the lazy dog\",searchWord = \"do\") == 9\n assert candidate(sentence = \"multiple occurrences of words words\",searchWord = \"words\") == 4\n assert candidate(sentence = \"double double double trouble\",searchWord = \"double\") == 1\n assert candidate(sentence = \"complicated complex complication\",searchWord = \"comp\") == 1\n assert candidate(sentence = \"banana bandana bandanna banana bandana\",searchWord = \"band\") == 2\n"}, "metadata": {"canonical_parameter_names": ["sentence", "searchWord"], "leetcode_dataset_entry_point": "Solution().isPrefixOfWord", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int isPrefixOfWord(string sentence, string searchWord) {", "container": "Solution", "callable": "isPrefixOfWord", "parameters": [{"name": "sentence", "type": "string"}, {"name": "searchWord", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1456, "task_id": "maximum-number-of-vowels-in-a-substring-of-given-length", "difficulty": "Medium", "problem_description": "Given a string s and an integer k, return the maximum number of vowel letters in any substring of s with length k.\nVowel letters in English are 'a', 'e', 'i', 'o', and 'u'.\n \nExample 1:\n\nInput: s = \"abciiidef\", k = 3\nOutput: 3\nExplanation: The substring \"iii\" contains 3 vowel letters.\n\nExample 2:\n\nInput: s = \"aeiou\", k = 2\nOutput: 2\nExplanation: Any substring of length 2 contains 2 vowels.\n\nExample 3:\n\nInput: s = \"leetcode\", k = 3\nOutput: 2\nExplanation: \"lee\", \"eet\" and \"ode\" contain 2 vowels.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists of lowercase English letters.\n1 <= k <= s.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aooiiieeec\",k = 6) == 6\n assert candidate(s = \"a\",k = 1) == 1\n assert candidate(s = \"happy\",k = 2) == 1\n assert candidate(s = \"rhythms\",k = 5) == 0\n assert candidate(s = \"fluffy\",k = 2) == 1\n assert candidate(s = \"leetcode\",k = 3) == 2\n assert candidate(s = \"aeiou\",k = 2) == 2\n assert candidate(s = \"beautiful\",k = 4) == 3\n assert candidate(s = \"rhythms\",k = 4) == 0\n assert candidate(s = \"bbbb\",k = 2) == 0\n assert candidate(s = \"aaaaaa\",k = 5) == 5\n assert candidate(s = \"abciiidef\",k = 3) == 3\n assert candidate(s = \"aabbccddeeff\",k = 4) == 2\n assert candidate(s = \"quartz\",k = 3) == 2\n assert candidate(s = \"uuuuuuuuuuuuuuuuuuuuuuuuuu\",k = 5) == 5\n assert candidate(s = \"eiuaooeiuaooeiuaooeiuaoo\",k = 8) == 8\n assert candidate(s = \"bcdfghjklmnpqrstvwxyz\",k = 3) == 0\n assert candidate(s = \"understanding\",k = 4) == 2\n assert candidate(s = \"abacabadabacaba\",k = 5) == 3\n assert candidate(s = \"uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu\",k = 100) == 50\n assert candidate(s = \"aeiouaeiou\",k = 1) == 1\n assert candidate(s = \"bbbbbbaaaaa\",k = 5) == 5\n assert candidate(s = \"bbaeixixixixxxeiiixieeiix\",k = 15) == 10\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 50) == 0\n assert candidate(s = \"uoieaouieaouieaouieaouieaouieao\",k = 15) == 15\n assert candidate(s = \"mississippi\",k = 4) == 2\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiouaeiou\",k = 20) == 20\n assert candidate(s = \"iouaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",k = 50) == 50\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 12) == 4\n assert candidate(s = \"xyzvowelsabcdefg\",k = 5) == 2\n assert candidate(s = \"leetcodeisawesome\",k = 5) == 3\n assert candidate(s = \"lovelaceeinstein\",k = 7) == 5\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 13) == 3\n assert candidate(s = \"thisisaverylongstringwithsomevowelsinside\",k = 20) == 8\n assert candidate(s = \"aaaaaaaabbbbbbbbcccccccc\",k = 12) == 8\n assert candidate(s = \"bbaeiooacaioiiceiue\",k = 11) == 10\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 20) == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 26) == 6\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiou\",k = 10) == 10\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzz\",k = 20) == 0\n assert candidate(s = \"uvvwxyz\",k = 3) == 1\n assert candidate(s = \"abcdeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\",k = 15) == 15\n assert candidate(s = \"uoieaouieaouieaouieaouieaouiea\",k = 7) == 7\n assert candidate(s = \"mnoabcdeioufghijkl\",k = 7) == 4\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 15) == 4\n assert candidate(s = \"leetcodeisaverygoodplatform\",k = 10) == 6\n assert candidate(s = \"ababababab\",k = 5) == 3\n assert candidate(s = \"uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu\",k = 30) == 30\n assert candidate(s = \"bcdafg\",k = 6) == 1\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaa\",k = 10) == 10\n assert candidate(s = \"bcdfghjklmnpqrstvwxyz\",k = 1) == 0\n assert candidate(s = \"thisisaverylongstringwithseveralvowelsinside\",k = 15) == 6\n assert candidate(s = \"aiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioieiaioiei\",k = 20) == 20\n assert candidate(s = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\",k = 15) == 15\n assert candidate(s = \"uoieaouioeaouioeaouioe\",k = 12) == 12\n assert candidate(s = \"aeiouaeiouaeiouaeiou\",k = 7) == 7\n assert candidate(s = \"bcbcbcbcbcbcbcbcbcbcbcbc\",k = 7) == 0\n assert candidate(s = \"uqeiouqeiouqeiouqeiouqeiouqe\",k = 11) == 9\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 10) == 3\n assert candidate(s = \"qqqwwweee\",k = 4) == 3\n assert candidate(s = \"bbaeixoubb\",k = 5) == 4\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 26) == 5\n assert candidate(s = \"aeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeiioooooooouuuuuuuuuuuaaaaaaaa\",k = 25) == 25\n assert candidate(s = \"bvflkqmbvkjgnqmfqlqjflvngqnvfkvnqjvfbvmqjbfvmlkjbfnvqjgbfnvqjbngfjkqnvbmfkqjbgfnjkbv\",k = 10) == 0\n assert candidate(s = \"vowelsarebeautiful\",k = 10) == 6\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",k = 15) == 0\n assert candidate(s = \"bcbcbcbcbcbaaaaaa\",k = 10) == 6\n assert candidate(s = \"aeiaaioaaaaeiiiiiiooooaauuaeiu\",k = 15) == 15\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyz\",k = 8) == 0\n assert candidate(s = \"thisisaverylongstringwithlotsofvowelsandconsonants\",k = 18) == 7\n assert candidate(s = \"environmentally\",k = 10) == 4\n assert candidate(s = \"leetcodeisacommunityforcoders\",k = 8) == 5\n assert candidate(s = \"leetcodeisfun\",k = 7) == 4\n assert candidate(s = \"leetcodeisawesome\",k = 7) == 4\n assert candidate(s = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc\",k = 10) == 0\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiii\",k = 5) == 3\n assert candidate(s = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbc\",k = 3) == 0\n assert candidate(s = \"uoieaooooieau\",k = 7) == 7\n assert candidate(s = \"abecidofugihanukleomnonuopqrstuvwxyz\",k = 20) == 10\n assert candidate(s = \"aeiaaioaaaaeiiiiouuuu\",k = 12) == 12\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().maxVowels", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxVowels(string s, int k) {", "container": "Solution", "callable": "maxVowels", "parameters": [{"name": "s", "type": "string"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1458, "task_id": "max-dot-product-of-two-subsequences", "difficulty": "Hard", "problem_description": "Given two arrays nums1 and nums2.\nReturn the maximum dot product between non-empty subsequences of nums1 and nums2 with the same length.\nA subsequence of a array is a new array which is formed from the original array by deleting some (can be none) of the characters without disturbing the relative positions of the remaining characters. (ie, [2,3,5] is a subsequence of [1,2,3,4,5] while [1,5,3] is not).\n \nExample 1:\n\nInput: nums1 = [2,1,-2,5], nums2 = [3,0,-6]\nOutput: 18\nExplanation: Take subsequence [2,-2] from nums1 and subsequence [3,-6] from nums2.\nTheir dot product is (2*3 + (-2)*(-6)) = 18.\nExample 2:\n\nInput: nums1 = [3,-2], nums2 = [2,-6,7]\nOutput: 21\nExplanation: Take subsequence [3] from nums1 and subsequence [7] from nums2.\nTheir dot product is (3*7) = 21.\nExample 3:\n\nInput: nums1 = [-1,-1], nums2 = [1,1]\nOutput: -1\nExplanation: Take subsequence [-1] from nums1 and subsequence [1] from nums2.\nTheir dot product is -1.\n \nConstraints:\n\n1 <= nums1.length, nums2.length <= 500\n-1000 <= nums1[i], nums2[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-1, 0, 1]) == 2\n assert candidate(nums1 = [2, 1, -2, 5],nums2 = [3, 0, -6]) == 18\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5]) == 46\n assert candidate(nums1 = [1, 3, -5, 4],nums2 = [-2, -4, 0, 3]) == 32\n assert candidate(nums1 = [-1, -1],nums2 = [1, 1]) == -1\n assert candidate(nums1 = [1000, -1000],nums2 = [-1000, 1000]) == 1000000\n assert candidate(nums1 = [-1000, 1000],nums2 = [-1000, 1000]) == 2000000\n assert candidate(nums1 = [5, 4, -3],nums2 = [4, -1, -2]) == 26\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 46\n assert candidate(nums1 = [1000],nums2 = [-1000]) == -1000000\n assert candidate(nums1 = [0, 1, 2, 3, 4],nums2 = [5, 6, 7, 8, 9]) == 80\n assert candidate(nums1 = [-1000],nums2 = [1000]) == -1000000\n assert candidate(nums1 = [3, -2],nums2 = [2, -6, 7]) == 21\n assert candidate(nums1 = [1, 2, 3, 4],nums2 = [-3, -2, -1, 0]) == 0\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5]) == 46\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 46\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 2, 1]) == 12\n assert candidate(nums1 = [1, 2, 3],nums2 = [-5, -4, -3]) == -3\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6]) == 32\n assert candidate(nums1 = [5, 4, 3],nums2 = [1, 2, 3]) == 22\n assert candidate(nums1 = [5, 5, 2, 1, 5],nums2 = [1, 2, 4, 2, 5]) == 59\n assert candidate(nums1 = [1],nums2 = [1]) == 1\n assert candidate(nums1 = [-5, -4, -3, -2, -1],nums2 = [-1, -2, -3, -4, -5]) == 46\n assert candidate(nums1 = [0, 0, 0],nums2 = [0, 0, 0]) == 0\n assert candidate(nums1 = [-5, -4, -3, -2, -1],nums2 = [1, 2, 3, 4, 5]) == -1\n assert candidate(nums1 = [999, -999, 999, -999, 999],nums2 = [-999, 999, -999, 999, -999]) == 3992004\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums1 = [5, 2, -4, 7, -8],nums2 = [3, -1, 6, -3, 2]) == 85\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [1, 2, 3, 4]) == 0\n assert candidate(nums1 = [1, -1, 1, -1, 1, -1],nums2 = [-1, 1, -1, 1, -1, 1]) == 5\n assert candidate(nums1 = [1, -1, 1, -1, 1],nums2 = [1, -1, 1, -1, 1]) == 5\n assert candidate(nums1 = [5, 3, -4, 2, 1],nums2 = [-2, 6, 3, -5, 4]) == 67\n assert candidate(nums1 = [5, 3, -2, 4],nums2 = [1, 2, 3, 4, 5]) == 47\n assert candidate(nums1 = [100, -100, 200, -200, 300],nums2 = [1, -1, 2, -2, 3]) == 1900\n assert candidate(nums1 = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],nums2 = [-5, 5, -4, 4, -3, 3, -2, 2, -1, 1]) == 90\n assert candidate(nums1 = [100, -100, 200, -200],nums2 = [-100, 100, -200, 200]) == 70000\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [-1, -2, -3, -4, -5]) == -10\n assert candidate(nums1 = [-10, -20, -30, -40, -50],nums2 = [1, 2, 3, 4, 5]) == -10\n assert candidate(nums1 = [999, 1000, -999, -1000],nums2 = [-999, 999, -1000, 1000]) == 1999000\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == -100\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [-10, -20, -30, -40, -50]) == -100\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 320\n assert candidate(nums1 = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],nums2 = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 81\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5]) == 125\n assert candidate(nums1 = [5, -10, 15, -20, 25],nums2 = [-5, 10, -15, 20]) == 1000\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == 46\n assert candidate(nums1 = [100, -100, 200, -200, 300, -300],nums2 = [10, -10, 20, -20, 30, -30]) == 28000\n assert candidate(nums1 = [0, 1, -1, 2, -2, 3, -3],nums2 = [3, -3, 2, -2, 1, -1, 0]) == 24\n assert candidate(nums1 = [5, -3, 10, 2, -7],nums2 = [8, 4, -2, 6, 1]) == 108\n assert candidate(nums1 = [-500, -400, -300, -200, -100],nums2 = [100, 200, 300, 400, 500]) == -10000\n assert candidate(nums1 = [-5, -3, -2, -4],nums2 = [-1, -2, -3, -4, -5]) == 47\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1029\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 74\n assert candidate(nums1 = [100, 0, 200, 0, 300, 0, 400, 0, 500, 0],nums2 = [0, 500, 0, 400, 0, 300, 0, 200, 0, 100]) == 460000\n assert candidate(nums1 = [2, 4, 6, 8, 10],nums2 = [1, 3, 5, 7, 9]) == 190\n assert candidate(nums1 = [10, -10, 20, -20, 30],nums2 = [30, -30, 20, -20, 10]) == 1800\n assert candidate(nums1 = [-1, 0, 1, 0, -1],nums2 = [-1, 0, 1, 0, -1]) == 3\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [-1, -2, -3, -4, -5]) == -1\n assert candidate(nums1 = [5, -3, 8, -1, 7],nums2 = [-2, 4, 1, -5, 3]) == 64\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3]) == 56\n assert candidate(nums1 = [-1, -2, -3, -4, -5],nums2 = [5, 4, 3, 2, 1]) == -1\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [-100, -200, -300, -400, -500]) == -10000\n assert candidate(nums1 = [1000, 900, 800, 700, 600],nums2 = [10, 20, 30, 40, 50]) == 114000\n assert candidate(nums1 = [5, -3, 2, 1, 6],nums2 = [-1, 2, -3, 4, 5]) == 57\n assert candidate(nums1 = [1, 2, 3],nums2 = [100, 200, 300, 400, 500]) == 2600\n assert candidate(nums1 = [-1, -2, -3, -4, -5],nums2 = [-5, -4, -3, -2, -1]) == 46\n assert candidate(nums1 = [-5, -4, -3, -2, -1],nums2 = [1, 2, 3, 4, 5]) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == -1\n assert candidate(nums1 = [1, -2, 3, -4, 5],nums2 = [-5, 4, -3, 2, -1]) == 44\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 385\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [1, 2, 3]) == 2600\n assert candidate(nums1 = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],nums2 = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 38500\n assert candidate(nums1 = [999, -999, 888, -888, 777, -777],nums2 = [-666, 666, -555, 555, -444, 444, -333, 333]) == 2710620\n assert candidate(nums1 = [1, -1, 1, -1, 1],nums2 = [-1, 1, -1, 1, -1]) == 4\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45]) == 4750\n assert candidate(nums1 = [1000, 999, 998, 997, 996],nums2 = [1, 2, 3, 4, 5]) == 14960\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [100, 200, 300]) == 2200\n assert candidate(nums1 = [100, -100, 200, -200],nums2 = [300, -300, 400, -400]) == 220000\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6, 7, 8, 9, 10, 11, 12]) == 68\n assert candidate(nums1 = [1, 2, 3],nums2 = [-1, -2, -3, 4, 5]) == 23\n assert candidate(nums1 = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums1 = [5, -3, 8, 1],nums2 = [-7, 4, 6, -2]) == 69\n assert candidate(nums1 = [1, 3, -5, 7, -9],nums2 = [-9, 7, -5, 3, 1]) == 139\n assert candidate(nums1 = [1, 3, -5, 7, -9, 11],nums2 = [11, -9, 7, -5, 3, -1]) == 235\n assert candidate(nums1 = [1, 3, -5, 7, -9],nums2 = [-2, 4, -6, 8, -10]) == 188\n assert candidate(nums1 = [10, 20, 30],nums2 = [30, 20, 10]) == 1200\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3850\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == 190\n assert candidate(nums1 = [-5, -5, -5, -5, -5],nums2 = [-5, -5, -5, -5, -5]) == 125\n assert candidate(nums1 = [1, 0, -1, 0, 1],nums2 = [0, 1, 0, -1, 0]) == 2\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [500, 400, 300, 200, 100]) == 460000\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5]) == 55\n assert candidate(nums1 = [-1, -2, -3, -4, -5],nums2 = [1, 2, 3, 4, 5]) == -1\n assert candidate(nums1 = [-50, -40, -30, -20, -10],nums2 = [-10, -20, -30, -40, -50]) == 4600\n assert candidate(nums1 = [1, -1, 2, -2, 3, -3],nums2 = [-1, 1, -2, 2, -3, 3]) == 22\n assert candidate(nums1 = [100, 200, 300],nums2 = [1, 2, 3, 4, 5]) == 2600\n assert candidate(nums1 = [0, 0, 0, 0],nums2 = [0, 0, 0, 0]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [-1, -1, -1, -1, -1]) == -1\n assert candidate(nums1 = [1, -1, 2, -2, 3, -3],nums2 = [3, -3, 2, -2, 1, -1]) == 24\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [-1, -2, -3, -4, -5]) == -1\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [10]) == 1000\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [-50, -40, -30, -20, -10]) == -100\n assert candidate(nums1 = [-10, -20, -30, -40, -50],nums2 = [10, 20, 30, 40, 50]) == -100\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 40, 30, 20, 10]) == 4600\n assert candidate(nums1 = [1, 0, -1, 0, 1],nums2 = [1, 0, -1, 0, 1]) == 3\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13],nums2 = [2, 4, 6, 8, 10, 12, 14]) == 504\n assert candidate(nums1 = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [-1, -1, -1, -1, -1]) == -1\n assert candidate(nums1 = [-1, 0, 1, -2, 0, 2],nums2 = [2, 0, -2, 0, 1, -1]) == 8\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().maxDotProduct", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxDotProduct(vector& nums1, vector& nums2) {", "container": "Solution", "callable": "maxDotProduct", "parameters": [{"name": "nums1", "type": "vector&"}, {"name": "nums2", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1460, "task_id": "make-two-arrays-equal-by-reversing-subarrays", "difficulty": "Easy", "problem_description": "You are given two integer arrays of equal length target and arr. In one step, you can select any non-empty subarray of arr and reverse it. You are allowed to make any number of steps.\nReturn true if you can make arr equal to target or false otherwise.\n \nExample 1:\n\nInput: target = [1,2,3,4], arr = [2,4,1,3]\nOutput: true\nExplanation: You can follow the next steps to convert arr to target:\n1- Reverse subarray [2,4,1], arr becomes [1,4,2,3]\n2- Reverse subarray [4,2], arr becomes [1,2,4,3]\n3- Reverse subarray [4,3], arr becomes [1,2,3,4]\nThere are multiple ways to convert arr to target, this is not the only way to do so.\n\nExample 2:\n\nInput: target = [7], arr = [7]\nOutput: true\nExplanation: arr is equal to target without any reverses.\n\nExample 3:\n\nInput: target = [3,7,9], arr = [3,7,11]\nOutput: false\nExplanation: arr does not have value 9 and it can never be converted to target.\n\n \nConstraints:\n\ntarget.length == arr.length\n1 <= target.length <= 1000\n1 <= target[i] <= 1000\n1 <= arr[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = [4, 3, 2, 1],arr = [1, 2, 3, 4]) == True\n assert candidate(target = [5, 6, 7, 8],arr = [8, 7, 6, 5]) == True\n assert candidate(target = [1, 1, 1, 1],arr = [1, 1, 1, 1]) == True\n assert candidate(target = [1, 3, 5, 7],arr = [7, 5, 3, 1]) == True\n assert candidate(target = [1000, 1000, 1000],arr = [1000, 1000, 1000]) == True\n assert candidate(target = [10, 20, 30, 40],arr = [40, 30, 20, 10]) == True\n assert candidate(target = [1, 2, 3],arr = [3, 2, 1]) == True\n assert candidate(target = [5, 4, 3, 2, 1],arr = [1, 2, 3, 4, 5]) == True\n assert candidate(target = [1, 2, 3, 4, 5],arr = [5, 4, 3, 2, 1]) == True\n assert candidate(target = [10, 20, 30],arr = [30, 20, 10]) == True\n assert candidate(target = [5, 1, 3, 2],arr = [2, 1, 3, 5]) == True\n assert candidate(target = [1000, 1, 1000],arr = [1, 1000, 1000]) == True\n assert candidate(target = [1, 2, 2, 3],arr = [2, 1, 3, 2]) == True\n assert candidate(target = [10, 20, 30, 40, 50],arr = [50, 40, 30, 20, 10]) == True\n assert candidate(target = [1, 3, 5, 7, 9],arr = [9, 7, 5, 3, 1]) == True\n assert candidate(target = [3, 7, 9],arr = [3, 7, 11]) == False\n assert candidate(target = [5, 3, 1],arr = [1, 3, 5]) == True\n assert candidate(target = [1, 2, 3, 4],arr = [2, 4, 1, 3]) == True\n assert candidate(target = [1, 2, 2, 3],arr = [3, 2, 2, 1]) == True\n assert candidate(target = [4, 4, 4, 4],arr = [4, 4, 4, 4]) == True\n assert candidate(target = [1000, 1, 1000, 1],arr = [1, 1000, 1, 1000]) == True\n assert candidate(target = [10, 9, 8, 7],arr = [7, 8, 9, 10]) == True\n assert candidate(target = [1, 3, 2],arr = [2, 1, 3]) == True\n assert candidate(target = [1, 2, 3],arr = [4, 5, 6]) == False\n assert candidate(target = [7],arr = [7]) == True\n assert candidate(target = [999, 998, 997],arr = [997, 998, 999]) == True\n assert candidate(target = [5, 6, 7],arr = [7, 6, 5]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(target = [10, 20, 30, 40, 50],arr = [50, 40, 30, 20, 10]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == True\n assert candidate(target = [5, 5, 5, 5, 5],arr = [5, 5, 5, 5, 5]) == True\n assert candidate(target = [1, 1, 2, 2, 3, 3],arr = [3, 2, 1, 3, 1, 2]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == True\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],arr = [6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == True\n assert candidate(target = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991],arr = [991, 992, 993, 994, 995, 996, 997, 998, 999, 1000]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [500, 400, 300, 200, 100],arr = [100, 200, 300, 400, 500]) == True\n assert candidate(target = [5, 5, 5, 5, 5],arr = [5, 5, 5, 5, 5]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 2, 3, 4, 5, 6, 7, 8, 10, 9]) == True\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 2, 8, 4, 6, 5, 9, 7, 3, 1]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == False\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2]) == True\n assert candidate(target = [5, 10, 15, 20, 25],arr = [25, 20, 15, 10, 5]) == True\n assert candidate(target = [250, 200, 150, 100, 50, 0, -50, -100, -150, -200, -250],arr = [-250, -200, -150, -100, -50, 0, 50, 100, 150, 200, 250]) == True\n assert candidate(target = [1, 2, 2, 3, 3, 4, 4],arr = [4, 4, 3, 3, 2, 2, 1]) == True\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17]) == False\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 1]) == False\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [999, 1000, 999, 1000, 999, 1000, 999, 1000],arr = [1000, 999, 1000, 999, 1000, 999, 1000, 999]) == True\n assert candidate(target = [4, 4, 4, 4, 4, 4, 4],arr = [4, 4, 4, 4, 4, 4, 4]) == True\n assert candidate(target = [5, 1, 4, 3, 2],arr = [2, 3, 1, 5, 4]) == True\n assert candidate(target = [5, 3, 1, 4, 2],arr = [2, 1, 4, 3, 5]) == True\n assert candidate(target = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 1, 2, 3]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 1, 2]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 1, 2, 3, 4, 5]) == True\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(target = [3, 3, 3, 3, 3],arr = [3, 3, 3, 3, 3]) == True\n assert candidate(target = [1000, 500, 250, 125],arr = [125, 250, 500, 1000]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [1, 1, 1, 2, 2, 2, 3, 3, 3],arr = [3, 2, 1, 3, 2, 1, 3, 2, 1]) == True\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]) == True\n assert candidate(target = [100, 200, 100, 200, 100],arr = [200, 100, 200, 100, 200]) == False\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],arr = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],arr = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [5, 5, 5, 5, 5, 5],arr = [5, 5, 5, 5, 5, 5]) == True\n assert candidate(target = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(target = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5],arr = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],arr = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 1, 2, 3, 4]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 2, 3, 1]) == True\n assert candidate(target = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1]) == False\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [100, 200, 300, 400, 500],arr = [500, 400, 300, 200, 100]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(target = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 2, 1]) == True\n assert candidate(target = [1000, 500, 1000, 500, 1000, 500, 1000, 500, 1000, 500],arr = [500, 1000, 500, 1000, 500, 1000, 500, 1000, 500, 1000]) == True\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],arr = [21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == True\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [7, 8, 9, 10, 11],arr = [11, 10, 9, 8, 7]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],arr = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [1, 2, 2, 1, 3, 3, 4, 4, 5, 5],arr = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == True\n assert candidate(target = [1, 3, 5, 7, 9],arr = [9, 7, 5, 3, 1]) == True\n assert candidate(target = [234, 234, 234, 234, 234, 234, 234, 234, 234, 234],arr = [234, 234, 234, 234, 234, 234, 234, 234, 234, 234]) == True\n assert candidate(target = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],arr = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(target = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(target = [1000, 999, 998, 997, 996],arr = [996, 997, 998, 999, 1000]) == True\n assert candidate(target = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 11]) == False\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 2, 3, 10, 9, 8, 7, 6, 5, 4]) == True\n assert candidate(target = [300, 200, 100, 400, 500, 600, 700, 800, 900, 1000],arr = [1000, 900, 800, 700, 600, 500, 400, 100, 200, 300]) == True\n assert candidate(target = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16],arr = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7]) == True\n assert candidate(target = [1, 2, 3, 4, 5],arr = [5, 4, 3, 2, 1]) == True\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [3, 2, 1, 6, 5, 4, 9, 8, 7, 10]) == True\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],arr = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 11]) == False\n assert candidate(target = [10, 20, 30, 40, 50],arr = [50, 10, 30, 20, 40]) == True\n assert candidate(target = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],arr = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == True\n assert candidate(target = [1000, 999, 998, 997, 996, 995],arr = [995, 996, 997, 998, 999, 1000]) == True\n assert candidate(target = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],arr = [4, 4, 3, 3, 4, 3, 2, 1, 2, 4]) == True\n assert candidate(target = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9],arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8]) == False\n assert candidate(target = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16],arr = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],arr = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],arr = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == True\n assert candidate(target = [5, 3, 4, 1, 2],arr = [2, 1, 4, 3, 5]) == True\n assert candidate(target = [1, 1, 1, 1, 1],arr = [1, 1, 1, 1, 1]) == True\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [10, 20, 30, 40, 50, 60, 70, 100, 90, 80]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2]) == False\n assert candidate(target = [1, 3, 2, 4, 5],arr = [2, 1, 4, 5, 3]) == True\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(target = [1, 2, 3, 4, 3, 2, 1],arr = [1, 2, 3, 4, 3, 2, 1]) == True\n assert candidate(target = [200, 300, 100, 400, 500, 600],arr = [100, 200, 300, 400, 500, 600]) == True\n assert candidate(target = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],arr = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1]) == True\n assert candidate(target = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9],arr = [9, 5, 3, 5, 2, 6, 9, 5, 1, 4, 1, 3]) == True\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4],arr = [4, 4, 3, 3, 2, 2, 1, 1]) == True\n assert candidate(target = [1, 1, 2, 2, 3, 3],arr = [3, 3, 2, 2, 1, 1]) == True\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n"}, "metadata": {"canonical_parameter_names": ["target", "arr"], "leetcode_dataset_entry_point": "Solution().canBeEqual", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool canBeEqual(vector& target, vector& arr) {", "container": "Solution", "callable": "canBeEqual", "parameters": [{"name": "target", "type": "vector&"}, {"name": "arr", "type": "vector&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1461, "task_id": "check-if-a-string-contains-all-binary-codes-of-size-k", "difficulty": "Medium", "problem_description": "Given a binary string s and an integer k, return true if every binary code of length k is a substring of s. Otherwise, return false.\n \nExample 1:\n\nInput: s = \"00110110\", k = 2\nOutput: true\nExplanation: The binary codes of length 2 are \"00\", \"01\", \"10\" and \"11\". They can be all found as substrings at indices 0, 1, 3 and 2 respectively.\n\nExample 2:\n\nInput: s = \"0110\", k = 1\nOutput: true\nExplanation: The binary codes of length 1 are \"0\" and \"1\", it is clear that both exist as a substring. \n\nExample 3:\n\nInput: s = \"0110\", k = 2\nOutput: false\nExplanation: The binary code \"00\" is of length 2 and does not exist in the array.\n\n \nConstraints:\n\n1 <= s.length <= 5 * 105\ns[i] is either '0' or '1'.\n1 <= k <= 20\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1010101010\",k = 5) == False\n assert candidate(s = \"1010101010\",k = 3) == False\n assert candidate(s = \"0000000\",k = 3) == False\n assert candidate(s = \"00110110\",k = 2) == True\n assert candidate(s = \"00000000\",k = 4) == False\n assert candidate(s = \"11110000\",k = 3) == False\n assert candidate(s = \"1111111\",k = 2) == False\n assert candidate(s = \"0110\",k = 2) == False\n assert candidate(s = \"0110\",k = 1) == True\n assert candidate(s = \"00001111000011110000111100001111000011110000111100\",k = 8) == False\n assert candidate(s = \"0110011001100110011001100110\",k = 5) == False\n assert candidate(s = \"0100100100100100100100100100\",k = 7) == False\n assert candidate(s = \"10100101101001011010\",k = 4) == False\n assert candidate(s = \"11001100110011001100\",k = 5) == False\n assert candidate(s = \"01101101101101101101\",k = 4) == False\n assert candidate(s = \"01010101010101010101\",k = 7) == False\n assert candidate(s = \"1010101010101010101010101010101010101010\",k = 10) == False\n assert candidate(s = \"11111111111111111111111111111111111111111111111111\",k = 15) == False\n assert candidate(s = \"0001010111001100101010110111\",k = 4) == False\n assert candidate(s = \"1100110011001100110011001100\",k = 8) == False\n assert candidate(s = \"1010010100101001010010100101001010010100101001\",k = 6) == False\n assert candidate(s = \"101010101010101010101010101010101010101010101010\",k = 7) == False\n assert candidate(s = \"10101010101010101010101010101010\",k = 10) == False\n assert candidate(s = \"010101010101010101010101010101010101010101010101\",k = 5) == False\n assert candidate(s = \"01010101010101010101010101010101010101010101010101\",k = 6) == False\n assert candidate(s = \"1001001001001001001001001001001001001001001001\",k = 7) == False\n assert candidate(s = \"01001100111000011001\",k = 3) == False\n assert candidate(s = \"0101010101010101010101010101\",k = 3) == False\n assert candidate(s = \"110011001100\",k = 4) == False\n assert candidate(s = \"1001101001101001101001101001101001101001\",k = 6) == False\n assert candidate(s = \"00010010100101110110\",k = 3) == True\n assert candidate(s = \"0101010101010101010101010101010101010101\",k = 3) == False\n assert candidate(s = \"1100101001110010110011000111001111001111110011111100\",k = 8) == False\n assert candidate(s = \"100110101110100011001010001110001001\",k = 8) == False\n assert candidate(s = \"0000000000000000000000000000000000000000\",k = 10) == False\n assert candidate(s = \"00000000000000000000000000000000000000000000000000000000000000000000000000000000\",k = 15) == False\n assert candidate(s = \"00000000000000000000000000000000000000000000000000\",k = 10) == False\n assert candidate(s = \"1001001001001001001001001001001001001001\",k = 4) == False\n assert candidate(s = \"0101010101010101\",k = 5) == False\n assert candidate(s = \"00101011110100101010100101010010101010\",k = 5) == False\n assert candidate(s = \"11111111111111111111\",k = 10) == False\n assert candidate(s = \"00101110011011001011\",k = 3) == False\n assert candidate(s = \"11100100110101110100010111010010100011000101110001011101001010001011101000101110100\",k = 5) == False\n assert candidate(s = \"1101010101101010101\",k = 5) == False\n assert candidate(s = \"000000000111111111000000001111111100000000\",k = 8) == False\n assert candidate(s = \"110010011110000110\",k = 3) == False\n assert candidate(s = \"110010110110011010001011\",k = 3) == False\n assert candidate(s = \"1111111111111111111111111111\",k = 5) == False\n assert candidate(s = \"1111111110000000001111111110000000011111\",k = 9) == False\n assert candidate(s = \"0011001100110011001100110011\",k = 6) == False\n assert candidate(s = \"1010001110011101001010101010101010101010101010101010\",k = 5) == False\n assert candidate(s = \"1110010011010111010001011101001010001100010111000101110100101000101110100010111010010100100010001000100010001000100010001000100010001000100010001000100\",k = 10) == False\n assert candidate(s = \"0011001100110011001100110011\",k = 7) == False\n assert candidate(s = \"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",k = 20) == False\n assert candidate(s = \"00001111000011110000\",k = 4) == False\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111\",k = 10) == False\n assert candidate(s = \"0110100111000101000110110001101101101001010111011100011111000011011111010011101001110\",k = 19) == False\n assert candidate(s = \"0110100101101001011010010110100101101001\",k = 5) == False\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\",k = 9) == False\n assert candidate(s = \"11110000111100001111000011110000\",k = 4) == False\n assert candidate(s = \"1111111111\",k = 2) == False\n assert candidate(s = \"101010101010101010101010101010101010101010101010\",k = 6) == False\n assert candidate(s = \"1010101010101010101010101010\",k = 5) == False\n assert candidate(s = \"00010110111100010111\",k = 4) == False\n assert candidate(s = \"0001110001110001110001110001110001110001\",k = 4) == False\n assert candidate(s = \"11111111111111111111\",k = 19) == False\n assert candidate(s = \"01001001001001001001001001001001\",k = 4) == False\n assert candidate(s = \"11001100110011001100\",k = 6) == False\n assert candidate(s = \"0110110110110110110110110110110110110110\",k = 6) == False\n assert candidate(s = \"11101011110001011010\",k = 4) == False\n assert candidate(s = \"10000011110000111110001101110011100110011111110000001001001011000110010011001011110101\",k = 15) == False\n assert candidate(s = \"01101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\",k = 12) == False\n assert candidate(s = \"0001010001010110001010001010101010101010101010101010\",k = 7) == False\n assert candidate(s = \"0001011000110000111110101011011110011110101001101100100100011111100100000011111010101101110001101010110111010010101110100011011101001101110100\",k = 7) == False\n assert candidate(s = \"1111111111111111111111111111111111111111111111\",k = 20) == False\n assert candidate(s = \"10000000001\",k = 5) == False\n assert candidate(s = \"10010010010010010010\",k = 5) == False\n assert candidate(s = \"0100101011100111001010110111110000001111001110\",k = 5) == False\n assert candidate(s = \"1100101011100010011000011111000000111111\",k = 5) == False\n assert candidate(s = \"10101010101010101010101010\",k = 6) == False\n assert candidate(s = \"01010101010101010101\",k = 5) == False\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101010\",k = 10) == False\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010101010101010101010101010101\",k = 12) == False\n assert candidate(s = \"110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100\",k = 15) == False\n assert candidate(s = \"1111111111111111111111111111111111111111\",k = 15) == False\n assert candidate(s = \"1111000011110000\",k = 6) == False\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\",k = 8) == False\n assert candidate(s = \"01010101010101010101\",k = 6) == False\n assert candidate(s = \"10010010010010010010010010010010010010010010010010\",k = 7) == False\n assert candidate(s = \"00110011001100110011001100110011001100110011001100\",k = 4) == False\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101\",k = 6) == False\n assert candidate(s = \"10101010101010101010101010101010101010101010101010\",k = 5) == False\n assert candidate(s = \"1110001110001110001110001110001110001110\",k = 7) == False\n assert candidate(s = \"00000000000000000000\",k = 2) == False\n assert candidate(s = \"10101010101010101010\",k = 6) == False\n assert candidate(s = \"00000000000000000000\",k = 5) == False\n assert candidate(s = \"1000100010001000100010001000\",k = 4) == False\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001001001001001001001001001001\",k = 18) == False\n assert candidate(s = \"0000000000000000000000000000000000000000000000\",k = 20) == False\n assert candidate(s = \"11111111111111111111\",k = 5) == False\n assert candidate(s = \"01100110011001100110011001100110011001100110011001100110\",k = 9) == False\n assert candidate(s = \"1100011001110100101000101101010001101110100110\",k = 7) == False\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().hasAllCodes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool hasAllCodes(string s, int k) {", "container": "Solution", "callable": "hasAllCodes", "parameters": [{"name": "s", "type": "string"}, {"name": "k", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1462, "task_id": "course-schedule-iv", "difficulty": "Medium", "problem_description": "There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take course ai first if you want to take course bi.\n\nFor example, the pair [0, 1] indicates that you have to take course 0 before you can take course 1.\n\nPrerequisites can also be indirect. If course a is a prerequisite of course b, and course b is a prerequisite of course c, then course a is a prerequisite of course c.\nYou are also given an array queries where queries[j] = [uj, vj]. For the jth query, you should answer whether course uj is a prerequisite of course vj or not.\nReturn a boolean array answer, where answer[j] is the answer to the jth query.\n \nExample 1:\n\n\nInput: numCourses = 2, prerequisites = [[1,0]], queries = [[0,1],[1,0]]\nOutput: [false,true]\nExplanation: The pair [1, 0] indicates that you have to take course 1 before you can take course 0.\nCourse 0 is not a prerequisite of course 1, but the opposite is true.\n\nExample 2:\n\nInput: numCourses = 2, prerequisites = [], queries = [[1,0],[0,1]]\nOutput: [false,false]\nExplanation: There are no prerequisites, and each course is independent.\n\nExample 3:\n\n\nInput: numCourses = 3, prerequisites = [[1,2],[1,0],[2,0]], queries = [[1,0],[1,2]]\nOutput: [true,true]\n\n \nConstraints:\n\n2 <= numCourses <= 100\n0 <= prerequisites.length <= (numCourses * (numCourses - 1) / 2)\nprerequisites[i].length == 2\n0 <= ai, bi <= numCourses - 1\nai != bi\nAll the pairs [ai, bi] are unique.\nThe prerequisites graph has no cycles.\n1 <= queries.length <= 104\n0 <= ui, vi <= numCourses - 1\nui != vi\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 4], [4, 0]]) == [True, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 3], [1, 3], [0, 2]]) == [True, True, True]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 4]],queries = [[0, 3], [1, 4], [2, 3]]) == [True, True, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2]],queries = [[0, 2], [2, 0]]) == [True, False]\n assert candidate(numCourses = 2,prerequisites = [],queries = [[1, 0], [0, 1]]) == [False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4]],queries = [[0, 3], [0, 4], [3, 4]]) == [True, True, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4]],queries = [[0, 3], [0, 4], [1, 4], [2, 3]]) == [True, True, True, True]\n assert candidate(numCourses = 3,prerequisites = [[1, 2], [1, 0], [2, 0]],queries = [[1, 0], [1, 2]]) == [True, True]\n assert candidate(numCourses = 2,prerequisites = [[1, 0]],queries = [[0, 1], [1, 0]]) == [False, True]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 3], [1, 2], [2, 0], [3, 0]]) == [True, True, False, False]\n assert candidate(numCourses = 9,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8]],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 5], [0, 4], [1, 2]]) == [True, True, True, False, False, True, False]\n assert candidate(numCourses = 15,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],queries = [[0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [1, 11], [1, 12], [2, 7], [2, 8]]) == [True, True, True, True, True, True, True, True, False, False, False, False]\n assert candidate(numCourses = 15,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7]]) == [True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 7], [6, 7]],queries = [[0, 7], [1, 5], [2, 4], [3, 6], [5, 7]]) == [True, False, False, False, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4]]) == [True, True, True, True, True, False]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 3], [1, 2]]) == [True, True, False, False, False, True, False]\n assert candidate(numCourses = 12,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 8], [4, 9], [5, 10], [5, 11], [6, 10], [6, 11], [7, 11], [8, 11], [9, 11]],queries = [[0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [1, 10], [1, 11], [2, 10], [2, 11], [3, 11], [4, 11]]) == [True, True, True, True, True, False, True, True, True, True, True]\n assert candidate(numCourses = 9,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 7], [4, 8]],queries = [[0, 7], [0, 8], [1, 7], [1, 8], [2, 7], [2, 8], [0, 3], [0, 4]]) == [True, True, True, True, False, False, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9]],queries = [[0, 9], [1, 9], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9]]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 9,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 7], [5, 7], [6, 8]],queries = [[0, 7], [0, 8], [1, 5], [1, 6], [2, 7], [2, 8], [3, 7], [3, 8], [4, 7], [5, 7], [6, 8]]) == [True, True, False, False, True, True, True, True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],queries = [[0, 9], [1, 9], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9]]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [1, 4], [2, 3], [0, 2]]) == [True, True, True, True]\n assert candidate(numCourses = 12,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11]],queries = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [0, 5], [1, 2]]) == [True, False, False, True, False, False, True, False]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [3, 6], [4, 6], [5, 6]],queries = [[0, 6], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [1, 5], [0, 4], [0, 3]]) == [True, True, True, True, True, True, False, True, True]\n assert candidate(numCourses = 9,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8]],queries = [[0, 3], [0, 7], [1, 8], [2, 6], [3, 5]]) == [True, True, True, True, False]\n assert candidate(numCourses = 9,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8]],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4], [5, 3], [6, 2], [7, 1], [8, 0]]) == [True, True, True, True, True, False, False, False, False]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4], [4, 5], [5, 6]],queries = [[0, 3], [1, 5], [2, 6], [3, 6]]) == [True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [True, True, True, True, True]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 4], [2, 5], [4, 6], [5, 6]],queries = [[0, 6], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [1, 5]]) == [True, True, True, False, True, True, False]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 3]]) == [True, True, True, True, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 5], [4, 5]],queries = [[0, 5], [1, 4], [2, 4], [3, 5], [1, 3], [2, 3]]) == [True, True, True, True, True, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],queries = [[0, 3], [0, 4], [0, 5], [1, 2], [1, 5], [2, 3], [2, 4]]) == [True, True, True, False, False, False, False]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 5], [3, 6], [4, 6], [5, 6], [6, 7]],queries = [[0, 3], [0, 4], [0, 5], [1, 6], [1, 7], [2, 6], [2, 7]]) == [True, True, True, True, True, True, True]\n assert candidate(numCourses = 8,prerequisites = [[0, 2], [1, 2], [2, 3], [3, 5], [3, 6], [6, 7], [7, 5]],queries = [[0, 5], [0, 7], [1, 5], [1, 7], [2, 5], [2, 7], [3, 7]]) == [True, True, True, True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 8], [6, 8], [7, 9], [8, 9]],queries = [[0, 9], [1, 9], [2, 9], [0, 8], [0, 7], [0, 6], [0, 5], [0, 4], [0, 3], [0, 2], [0, 1], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [2, 7], [2, 6], [2, 5], [3, 6], [3, 5], [4, 6], [4, 5]]) == [True, True, True, True, True, True, True, True, True, True, True, False, True, False, False, True, False, True, True, False, False, False, False]\n assert candidate(numCourses = 12,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 10], [8, 11]],queries = [[0, 10], [0, 11], [1, 10], [1, 11], [2, 10], [2, 11], [3, 10], [3, 11], [4, 10], [4, 11]]) == [True, True, True, True, True, True, True, True, False, False]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [4, 3]]) == [True, True, True, True, False]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [1, 4], [2, 3], [0, 2], [3, 5]]) == [True, True, True, True, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [1, 5], [2, 5], [0, 4], [1, 4], [2, 4]]) == [True, True, True, True, True, True]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [0, 7], [1, 6], [2, 5], [3, 4]],queries = [[0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 4], [3, 5], [3, 6], [3, 7], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],queries = [[0, 3], [0, 4], [0, 5], [0, 6], [1, 5], [1, 6]]) == [True, True, True, True, False, False]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [0, 2], [1, 3]]) == [True, True, True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 6]]) == [True, True, True, True, False]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],queries = [[0, 7], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7]]) == [True, True, True, True, True, True]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 5], [4, 5], [5, 6]],queries = [[0, 3], [0, 4], [0, 5], [0, 6], [1, 5], [1, 6], [2, 5], [2, 6], [3, 6], [4, 6]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 11,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],queries = [[0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == [True, True, True, True, True, True, False, False, False, False]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [0, 4], [1, 4], [2, 5]]) == [True, True, True, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [0, 2], [2, 4], [3, 4], [4, 5]],queries = [[0, 5], [2, 5], [3, 5], [0, 3], [5, 0]]) == [True, True, True, False, False]\n assert candidate(numCourses = 15,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [0, 10], [10, 0]]) == [True, True, True, True, True, True, True, True, False]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [1, 2], [3, 4], [5, 6], [7, 8]],queries = [[0, 9], [2, 8], [4, 7], [6, 5], [0, 8]]) == [True, True, True, False, True]\n assert candidate(numCourses = 9,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 8], [6, 8]],queries = [[0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [1, 5], [1, 6], [1, 7], [1, 8], [2, 3], [2, 4], [2, 7], [2, 8], [3, 8], [4, 8], [5, 6], [6, 7]]) == [True, True, True, True, True, True, False, False, True, True, False, False, False, True, False, True, False, False]\n assert candidate(numCourses = 8,prerequisites = [[0, 2], [1, 2], [2, 3], [2, 4], [3, 5], [4, 5], [5, 6], [5, 7]],queries = [[0, 5], [0, 6], [0, 7], [1, 5], [1, 6], [1, 7], [2, 6], [2, 7], [3, 6], [3, 7], [4, 6], [4, 7]]) == [True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [1, 5], [2, 5], [0, 4]]) == [True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],queries = [[0, 9], [0, 8], [1, 7], [2, 6], [3, 5]]) == [True, True, True, False, False]\n assert candidate(numCourses = 12,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11]],queries = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [0, 7], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4]]) == [True, True, True, True, True, True, True, True, True, True, True, False]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 4], [3, 5], [3, 6], [4, 5], [4, 6], [5, 6]],queries = [[0, 5], [0, 6], [1, 5], [1, 6], [2, 5], [2, 6], [3, 6]]) == [True, True, True, True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],queries = [[0, 9], [0, 8], [1, 6], [3, 9], [5, 4]]) == [True, True, True, True, False]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 3], [1, 4], [2, 5]],queries = [[0, 6], [1, 5], [2, 4], [0, 5], [3, 4], [0, 4], [4, 6], [1, 3]]) == [True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 15,prerequisites = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11], [4, 12], [5, 13], [5, 14]],queries = [[0, 13], [0, 14], [1, 13], [1, 14], [2, 13], [2, 14], [3, 13], [3, 14], [4, 13], [4, 14]]) == [True, True, True, True, False, False, False, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 4], [1, 2], [1, 3], [2, 4], [3, 4]],queries = [[0, 2], [0, 3], [1, 4], [2, 3], [3, 2]]) == [True, True, True, False, False]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9]],queries = [[0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [1, 9], [2, 9], [3, 5], [3, 6], [4, 7]]) == [True, True, True, True, True, False, False, False, False, False]\n assert candidate(numCourses = 12,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11]],queries = [[0, 11], [1, 11], [2, 11], [3, 11], [4, 11], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11]]) == [True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 9], [6, 9]],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [True, True, False, False, False]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [1, 2], [2, 3], [0, 4], [4, 5], [5, 6], [6, 7], [2, 6]],queries = [[0, 7], [1, 6], [2, 5], [3, 4]]) == [True, True, False, False]\n assert candidate(numCourses = 15,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 8], [4, 9], [5, 10], [5, 11], [6, 11], [6, 12], [7, 13], [8, 13], [9, 13], [10, 14], [11, 14], [12, 14]],queries = [[0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14]]) == [True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 12,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],queries = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [True, True, True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 8], [1, 7], [2, 6], [3, 5], [0, 7], [1, 6], [2, 5], [3, 4]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 4], [5, 6]],queries = [[0, 4], [0, 5], [0, 6], [1, 3], [1, 5], [1, 6], [2, 5], [2, 6], [3, 5], [4, 6]]) == [True, True, True, True, False, False, True, True, False, False]\n assert candidate(numCourses = 10,prerequisites = [[0, 2], [1, 2], [2, 3], [2, 4], [3, 5], [4, 5], [5, 6], [5, 7], [6, 8], [7, 9]],queries = [[0, 5], [1, 6], [2, 8], [3, 9], [4, 7], [5, 8]]) == [True, True, True, True, True, True]\n assert candidate(numCourses = 7,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],queries = [[0, 3], [0, 5], [1, 6], [3, 5], [4, 6]]) == [True, True, False, False, False]\n assert candidate(numCourses = 12,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],queries = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 8], [1, 7], [2, 6], [3, 5], [0, 7], [1, 6], [2, 5], [3, 4]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 10,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],queries = [[0, 9], [1, 9], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9]]) == [True, True, True, True, True, True, True, True]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 7], [6, 7]],queries = [[0, 7], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7]]) == [True, True, True, True, True, True, True]\n assert candidate(numCourses = 3,prerequisites = [[1, 2]],queries = [[0, 2], [1, 0], [2, 0]]) == [False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 3], [3, 0], [1, 2]]) == [True, False, True]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4]],queries = [[0, 3], [0, 4], [1, 2], [3, 4]]) == [True, True, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [0, 3], [3, 4], [1, 4]],queries = [[0, 2], [2, 0], [0, 4], [4, 0]]) == [True, False, True, False]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [5, 0], [1, 4], [4, 1]]) == [True, False, True, False]\n assert candidate(numCourses = 3,prerequisites = [],queries = [[0, 1], [1, 0], [0, 2], [2, 0]]) == [False, False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [2, 0]],queries = [[0, 1], [2, 1], [1, 2]]) == [False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]],queries = [[0, 1], [0, 2], [1, 3], [2, 3]]) == [False, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[1, 0], [0, 2], [2, 3], [3, 4]],queries = [[1, 4], [0, 4], [0, 3], [0, 2]]) == [True, True, True, True]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [0, 2]],queries = [[0, 1], [1, 2], [0, 2], [3, 0]]) == [True, True, True, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 2]],queries = [[0, 1], [1, 0], [0, 2], [2, 0]]) == [False, False, False, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5]],queries = [[1, 5], [1, 4], [2, 5], [3, 5], [4, 5]]) == [True, True, True, True, True]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [2, 3]],queries = [[0, 3], [1, 3], [0, 2]]) == [False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]],queries = [[0, 1], [0, 2], [0, 3], [1, 3], [2, 3]]) == [False, False, False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 3], [1, 2]]) == [True, True]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 4], [4, 0], [1, 3], [3, 1]]) == [True, False, True, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 3], [1, 3], [2, 3], [3, 0]]) == [True, True, True, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 4], [2, 4], [3, 5], [4, 5]],queries = [[1, 5], [2, 5], [3, 4]]) == [True, True, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 4], [4, 0], [1, 3]]) == [True, False, True]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [5, 3]],queries = [[5, 0], [5, 1], [4, 2], [4, 3], [2, 1]]) == [True, True, False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[0, 1]],queries = [[0, 1], [1, 0], [1, 2]]) == [True, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [0, 2], [1, 3], [2, 3]],queries = [[0, 3], [3, 0], [1, 2], [2, 1]]) == [True, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4]],queries = [[0, 3], [0, 4], [1, 2]]) == [True, True, False]\n assert candidate(numCourses = 4,prerequisites = [],queries = [[0, 1], [1, 2], [2, 3], [3, 0]]) == [False, False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [2, 3]],queries = [[0, 2], [1, 3], [0, 3], [2, 1]]) == [False, False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 3], [0, 2], [1, 3], [2, 0]]) == [True, True, True, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [5, 3]],queries = [[0, 1], [0, 3], [0, 5], [1, 2], [2, 3], [3, 4]]) == [False, False, False, False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 1]],queries = [[0, 3], [1, 3], [2, 3]]) == [False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0]],queries = [[0, 1], [1, 0], [1, 2], [0, 2]]) == [False, True, False, False]\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]],queries = [[0, 1], [1, 3], [0, 3]]) == [False, False, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 2], [2, 3], [3, 4], [4, 5]],queries = [[1, 5], [2, 4], [3, 5], [0, 5]]) == [True, True, True, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 2]],queries = [[0, 1], [1, 0], [2, 0]]) == [False, False, False]\n assert candidate(numCourses = 4,prerequisites = [],queries = [[0, 1], [1, 0], [2, 3], [3, 2]]) == [False, False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [0, 2]],queries = [[0, 1], [1, 2], [0, 2], [2, 0], [1, 0], [2, 1]]) == [True, True, True, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[1, 2], [2, 3], [3, 4], [1, 3], [1, 4]],queries = [[0, 1], [1, 0], [2, 4]]) == [False, False, True]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [2, 3]],queries = [[0, 1], [1, 2], [2, 3], [3, 0]]) == [True, False, True, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [1, 2]],queries = [[0, 1], [1, 2], [0, 2]]) == [False, True, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 1], [3, 2], [4, 3], [5, 4]],queries = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5]]) == [False, False, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]],queries = [[0, 3], [1, 3], [2, 3]]) == [False, False, False]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [1, 3], [2, 4], [3, 4], [4, 5]],queries = [[0, 5], [1, 5], [2, 5]]) == [True, True, True]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 4], [2, 4], [3, 4]],queries = [[0, 4], [1, 4], [2, 4], [3, 4], [4, 0]]) == [True, True, True, True, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 4], [4, 0], [1, 3], [3, 0]]) == [True, False, True, False]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [5, 0], [2, 3], [3, 2]]) == [True, False, True, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 2], [5, 3], [5, 4]],queries = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5]]) == [False, False, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 1], [0, 4], [1, 3], [2, 4], [4, 0]]) == [True, True, True, True, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2]],queries = [[0, 5], [1, 4], [2, 5], [0, 3], [3, 2]]) == [False, False, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 4], [1, 4], [0, 3], [1, 3], [0, 2], [1, 2], [2, 4], [0, 1], [2, 3], [4, 0]]) == [True, True, True, True, True, True, True, True, True, False]\n assert candidate(numCourses = 3,prerequisites = [[0, 1]],queries = [[0, 1], [1, 0], [0, 2], [2, 0]]) == [True, False, False, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2]],queries = [[0, 1], [0, 2], [1, 2], [2, 3], [3, 4], [4, 5]]) == [False, False, False, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 4], [4, 0], [2, 3]]) == [True, False, True]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 3], [3, 0], [1, 2], [0, 2]]) == [True, False, True, True]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [0, 2], [1, 3], [2, 3]],queries = [[0, 3], [1, 3], [2, 3], [3, 0]]) == [True, True, True, False]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [2, 5]]) == [True, True]\n assert candidate(numCourses = 3,prerequisites = [],queries = [[1, 0], [0, 1], [2, 1]]) == [False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0]],queries = [[0, 1], [2, 0], [1, 2]]) == [False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [2, 0]],queries = [[0, 1], [1, 0], [1, 2], [2, 1], [2, 0]]) == [False, True, False, False, True]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [1, 2]],queries = [[0, 1], [1, 0], [0, 2], [2, 0]]) == [False, True, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [0, 3], [3, 2]],queries = [[0, 2], [1, 3], [2, 0], [0, 1]]) == [True, False, False, True]\n assert candidate(numCourses = 6,prerequisites = [[1, 2], [1, 4], [1, 5], [2, 3], [3, 4], [3, 5]],queries = [[1, 3], [1, 4], [2, 5], [3, 1]]) == [True, True, True, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 2], [1, 3], [2, 4], [3, 5]],queries = [[1, 4], [2, 5], [3, 4], [0, 5]]) == [True, False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [1, 2]],queries = [[0, 1], [1, 2], [2, 0]]) == [False, True, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [3, 4]],queries = [[0, 2], [3, 4]]) == [True, True]\n assert candidate(numCourses = 3,prerequisites = [],queries = [[0, 1], [1, 0], [1, 2], [2, 1]]) == [False, False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 2], [0, 2]],queries = [[0, 1], [1, 0], [0, 2], [2, 0]]) == [False, False, True, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 2], [5, 3]],queries = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5]]) == [False, False, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 4], [4, 0], [1, 3], [2, 4]]) == [True, False, True, True]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2], [4, 3], [5, 4]],queries = [[0, 5], [1, 5], [2, 5], [3, 5]]) == [False, False, False, False]\n assert candidate(numCourses = 7,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 2], [5, 3], [6, 4], [6, 5]],queries = [[0, 6], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6]]) == [False, False, False, False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0]],queries = [[2, 0], [2, 1]]) == [False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [1, 2]],queries = [[0, 1], [1, 0], [0, 2]]) == [False, True, False]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [2, 3], [1, 3], [2, 4], [3, 5]],queries = [[0, 3], [2, 5], [0, 5], [1, 2]]) == [True, True, True, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4]],queries = [[0, 4], [1, 4], [2, 4]]) == [True, True, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],queries = [[0, 3], [0, 4], [1, 5], [2, 3]]) == [True, True, False, False]\n assert candidate(numCourses = 5,prerequisites = [[1, 2], [2, 3], [3, 4], [4, 0]],queries = [[1, 4], [4, 1], [0, 3], [3, 2]]) == [True, False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 2], [2, 0]],queries = [[1, 0], [2, 0], [0, 1]]) == [True, True, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 2]],queries = [[0, 1], [0, 2], [1, 0]]) == [False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0]],queries = [[0, 1], [1, 0]]) == [False, True]\n assert candidate(numCourses = 3,prerequisites = [[0, 1], [0, 2]],queries = [[0, 1], [1, 0], [1, 2], [2, 1], [2, 0], [0, 2]]) == [True, False, False, False, False, True]\n assert candidate(numCourses = 4,prerequisites = [],queries = [[0, 1], [1, 0], [1, 2], [2, 1]]) == [False, False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]],queries = [[0, 1], [1, 3], [0, 3], [3, 0]]) == [False, False, False, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],queries = [[0, 5], [1, 4], [2, 3], [0, 2], [3, 1]]) == [True, True, True, True, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 2]],queries = [[0, 2], [1, 0], [2, 1]]) == [False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [0, 2], [1, 3], [2, 3]],queries = [[1, 3], [2, 3], [3, 0], [3, 1]]) == [True, True, False, False]\n assert candidate(numCourses = 8,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],queries = [[0, 7], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7]]) == [True, True, True, True, True, True, True]\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]],queries = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 0]]) == [False, False, False, False, True]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 4], [2, 4], [3, 4]],queries = [[0, 4], [1, 2], [2, 0], [3, 1]]) == [True, False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]],queries = [[0, 1], [0, 2], [1, 2], [2, 3], [3, 0]]) == [False, False, False, False, True]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4]],queries = [[0, 3], [0, 4]]) == [True, True]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 4]],queries = [[0, 4], [0, 3], [1, 4], [2, 3], [3, 4]]) == [True, True, True, False, False]\n assert candidate(numCourses = 3,prerequisites = [],queries = [[0, 1], [1, 2], [2, 0]]) == [False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 2], [1, 0]],queries = [[0, 1], [1, 0], [2, 0]]) == [False, True, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [2, 1]],queries = [[0, 1], [1, 2], [0, 2]]) == [False, False, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [1, 2]],queries = [[0, 1], [1, 2]]) == [False, True]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [3, 2]],queries = [[0, 1], [1, 3], [2, 3], [3, 0]]) == [False, False, False, True]\n assert candidate(numCourses = 4,prerequisites = [[1, 0], [2, 0], [3, 0]],queries = [[0, 1], [0, 2], [0, 3], [1, 2]]) == [False, False, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [2, 3], [2, 4]],queries = [[0, 3], [0, 4], [1, 4], [2, 0]]) == [True, True, False, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 2], [1, 3], [2, 4], [3, 5]],queries = [[1, 4], [4, 1], [1, 5], [5, 1]]) == [True, False, True, False]\n assert candidate(numCourses = 3,prerequisites = [[1, 0], [1, 2]],queries = [[0, 1], [1, 0], [1, 2]]) == [False, True, True]\n assert candidate(numCourses = 3,prerequisites = [],queries = [[0, 1], [1, 0], [1, 2]]) == [False, False, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 1], [1, 3], [0, 3]]) == [True, True, True]\n assert candidate(numCourses = 6,prerequisites = [[0, 1], [2, 3], [4, 5]],queries = [[0, 1], [2, 3], [4, 5], [3, 4]]) == [True, True, True, False]\n assert candidate(numCourses = 3,prerequisites = [],queries = [[0, 1], [1, 0], [2, 1]]) == [False, False, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 2], [5, 3], [5, 4]],queries = [[0, 5], [1, 5], [2, 5], [3, 5]]) == [False, False, False, False]\n assert candidate(numCourses = 6,prerequisites = [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2]],queries = [[3, 0], [5, 0], [4, 2], [1, 2]]) == [True, True, False, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [0, 2], [1, 3], [2, 3], [1, 4], [2, 4]],queries = [[0, 4], [1, 4], [2, 3], [3, 4]]) == [True, True, True, False]\n assert candidate(numCourses = 4,prerequisites = [[2, 0], [1, 0], [3, 1], [3, 2]],queries = [[0, 1], [2, 0], [0, 3], [3, 0], [2, 3]]) == [False, True, False, True, False]\n assert candidate(numCourses = 4,prerequisites = [[0, 1], [1, 2], [2, 3]],queries = [[0, 3], [1, 3], [0, 2], [3, 0]]) == [True, True, True, False]\n assert candidate(numCourses = 5,prerequisites = [[0, 1], [1, 2], [2, 3], [3, 4]],queries = [[0, 1], [1, 3], [0, 4], [2, 3], [4, 2]]) == [True, True, True, True, False]\n"}, "metadata": {"canonical_parameter_names": ["numCourses", "prerequisites", "queries"], "leetcode_dataset_entry_point": "Solution().checkIfPrerequisite", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector checkIfPrerequisite(int numCourses, vector>& prerequisites, vector>& queries) {", "container": "Solution", "callable": "checkIfPrerequisite", "parameters": [{"name": "numCourses", "type": "int"}, {"name": "prerequisites", "type": "vector>&"}, {"name": "queries", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1463, "task_id": "cherry-pickup-ii", "difficulty": "Hard", "problem_description": "You are given a rows x cols matrix grid representing a field of cherries where grid[i][j] represents the number of cherries that you can collect from the (i, j) cell.\nYou have two robots that can collect cherries for you:\n\nRobot #1 is located at the top-left corner (0, 0), and\nRobot #2 is located at the top-right corner (0, cols - 1).\n\nReturn the maximum number of cherries collection using both robots by following the rules below:\n\nFrom a cell (i, j), robots can move to cell (i + 1, j - 1), (i + 1, j), or (i + 1, j + 1).\nWhen any robot passes through a cell, It picks up all cherries, and the cell becomes an empty cell.\nWhen both robots stay in the same cell, only one takes the cherries.\nBoth robots cannot move outside of the grid at any moment.\nBoth robots should reach the bottom row in grid.\n\n \nExample 1:\n\n\nInput: grid = [[3,1,1],[2,5,1],[1,5,5],[2,1,1]]\nOutput: 24\nExplanation: Path of robot #1 and #2 are described in color green and blue respectively.\nCherries taken by Robot #1, (3 + 2 + 5 + 2) = 12.\nCherries taken by Robot #2, (1 + 5 + 5 + 1) = 12.\nTotal of cherries: 12 + 12 = 24.\n\nExample 2:\n\n\nInput: grid = [[1,0,0,0,0,0,1],[2,0,0,0,0,3,0],[2,0,9,0,0,0,0],[0,3,0,5,4,0,0],[1,0,2,3,0,0,6]]\nOutput: 28\nExplanation: Path of robot #1 and #2 are described in color green and blue respectively.\nCherries taken by Robot #1, (1 + 9 + 5 + 2) = 17.\nCherries taken by Robot #2, (1 + 3 + 4 + 3) = 11.\nTotal of cherries: 17 + 11 = 28.\n\n \nConstraints:\n\nrows == grid.length\ncols == grid[i].length\n2 <= rows, cols <= 70\n0 <= grid[i][j] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 2, 3], [0, 1, 0], [3, 0, 1], [1, 2, 3]]) == 14\n assert candidate(grid = [[5, 0, 0, 5], [0, 4, 4, 0], [0, 4, 4, 0], [5, 0, 0, 5]]) == 36\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 10\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == 6\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 3, 1], [2, 1, 4, 3, 2], [3, 2, 1, 4, 3]]) == 35\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0]]) == 7\n assert candidate(grid = [[2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2]]) == 16\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 6\n assert candidate(grid = [[10, 0, 0, 10], [0, 0, 0, 0], [0, 10, 10, 0], [10, 0, 0, 10]]) == 60\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 10\n assert candidate(grid = [[3, 1, 1], [2, 5, 1], [1, 5, 5], [2, 1, 1]]) == 24\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1], [2, 0, 0, 0, 0, 3, 0], [2, 0, 9, 0, 0, 0, 0], [0, 3, 0, 5, 4, 0, 0], [1, 0, 2, 3, 0, 0, 6]]) == 28\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 32\n assert candidate(grid = [[1, 1], [1, 1]]) == 4\n assert candidate(grid = [[10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10]]) == 120\n assert candidate(grid = [[0, 1, 0, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 0], [1, 0, 0, 1, 0, 0, 1], [0, 1, 0, 0, 0, 1, 0]]) == 4\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 16\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 100, 0, 0, 100, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 100, 0, 0, 100, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 400\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 159\n assert candidate(grid = [[10, 20, 30], [20, 30, 40], [30, 40, 50], [40, 50, 60], [50, 60, 70]]) == 440\n assert candidate(grid = [[5, 5, 5], [5, 0, 5], [5, 5, 5]]) == 30\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 2, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 1]]) == 18\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 1, 0], [1, 0, 0, 0, 0, 0, 1, 0, 0]]) == 13\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 10, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 1]]) == 26\n assert candidate(grid = [[5, 3, 2, 1, 4, 0], [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11], [0, 2, 4, 6, 8, 10]]) == 55\n assert candidate(grid = [[100, 0, 0, 0, 0, 0, 100], [0, 90, 0, 0, 0, 90, 0], [0, 0, 80, 0, 80, 0, 0], [0, 0, 0, 70, 0, 0, 0], [0, 0, 0, 0, 60, 0, 0], [0, 0, 0, 0, 0, 50, 0], [0, 0, 0, 0, 0, 0, 40]]) == 760\n assert candidate(grid = [[2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2]]) == 23\n assert candidate(grid = [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 9\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 3, 1], [2, 4, 6, 4, 2], [3, 5, 7, 5, 3]]) == 43\n assert candidate(grid = [[3, 0, 0, 2, 1, 0, 1], [0, 4, 3, 0, 0, 0, 0], [2, 1, 5, 0, 1, 0, 1], [0, 0, 0, 5, 0, 0, 0], [1, 2, 3, 0, 1, 2, 1], [0, 0, 0, 0, 0, 0, 5], [0, 3, 4, 3, 0, 0, 2]]) == 35\n assert candidate(grid = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 8\n assert candidate(grid = [[10, 15, 10], [15, 0, 15], [10, 15, 10], [15, 0, 15]]) == 105\n assert candidate(grid = [[10, 0, 0, 0, 10], [0, 10, 0, 10, 0], [0, 0, 10, 0, 0], [0, 10, 0, 10, 0], [10, 0, 0, 0, 10]]) == 90\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 8, 6, 4, 2], [3, 6, 9, 12, 15, 12, 9, 6, 3], [4, 8, 12, 16, 20, 16, 12, 8, 4], [5, 10, 15, 20, 25, 20, 15, 10, 5]]) == 154\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 13\n assert candidate(grid = [[0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [1, 0, 0, 0, 0, 0, 1], [0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0]]) == 7\n assert candidate(grid = [[50, 100, 50], [100, 50, 100], [50, 100, 50], [100, 50, 100]]) == 650\n assert candidate(grid = [[0, 0, 0, 0], [0, 100, 100, 0], [0, 100, 100, 0], [0, 0, 0, 0]]) == 400\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15], [15, 13, 11, 9, 7, 5, 3, 1], [1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15], [15, 13, 11, 9, 7, 5, 3, 1]]) == 111\n assert candidate(grid = [[0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0]]) == 7\n assert candidate(grid = [[0, 0, 0, 0, 50], [0, 0, 50, 0, 0], [50, 0, 0, 0, 0], [0, 50, 0, 50, 0]]) == 200\n assert candidate(grid = [[3, 1, 2, 1, 3], [2, 1, 3, 1, 2], [1, 2, 1, 2, 1], [3, 1, 2, 1, 3], [2, 1, 3, 1, 2]]) == 24\n assert candidate(grid = [[10, 20, 30, 40, 50, 60], [60, 50, 40, 30, 20, 10], [10, 30, 50, 70, 90, 110], [110, 90, 70, 50, 30, 10]]) == 430\n assert candidate(grid = [[100, 0, 0, 0, 100], [0, 50, 50, 0, 0], [0, 0, 0, 50, 50], [50, 50, 0, 0, 0], [0, 0, 100, 0, 0]]) == 450\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 1]]) == 14\n assert candidate(grid = [[3, 0, 0, 0, 0, 0, 0, 4], [0, 2, 0, 0, 0, 0, 5, 0], [0, 0, 1, 0, 0, 6, 0, 0], [0, 0, 0, 7, 8, 0, 0, 0], [0, 0, 9, 0, 0, 10, 0, 0], [0, 11, 0, 0, 0, 0, 12, 0], [13, 0, 0, 0, 0, 0, 0, 14]]) == 105\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0], [0, 0, 0, 10, 0, 10, 0, 10, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0]]) == 21\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0]]) == 5\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 20\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [100, 100, 100, 100, 100, 100, 100, 100, 100]]) == 200\n assert candidate(grid = [[10, 0, 0, 0, 0, 0, 10], [0, 1, 0, 1, 0, 1, 0], [1, 0, 9, 0, 9, 0, 1], [0, 3, 0, 5, 0, 3, 0], [1, 0, 2, 3, 0, 2, 1]]) == 53\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]]) == 67\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 2, 2, 2, 2, 2, 1, 0], [0, 1, 2, 3, 3, 3, 2, 1, 0], [0, 1, 2, 3, 4, 3, 2, 1, 0], [0, 1, 2, 3, 3, 3, 2, 1, 0], [0, 1, 2, 2, 2, 2, 2, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 31\n assert candidate(grid = [[5, 0, 0, 0, 0, 0, 0, 0, 5], [0, 5, 0, 0, 0, 0, 0, 5, 0], [0, 0, 5, 0, 0, 0, 5, 0, 0], [0, 0, 0, 5, 0, 5, 0, 0, 0], [0, 0, 0, 0, 10, 0, 0, 0, 0], [0, 0, 0, 5, 0, 5, 0, 0, 0], [0, 0, 5, 0, 0, 0, 5, 0, 0], [0, 5, 0, 0, 0, 0, 0, 5, 0], [5, 0, 0, 0, 0, 0, 0, 0, 5]]) == 90\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 18\n assert candidate(grid = [[3, 0, 0, 0, 0, 0, 3], [0, 2, 0, 0, 0, 2, 0], [0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 5, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0], [0, 2, 0, 0, 0, 2, 0], [3, 0, 0, 0, 0, 0, 3]]) == 29\n assert candidate(grid = [[30, 10, 0, 10, 30], [10, 20, 0, 20, 10], [0, 0, 30, 0, 0], [10, 20, 0, 20, 10], [30, 10, 0, 10, 30]]) == 230\n assert candidate(grid = [[10, 0, 0, 10, 0], [0, 10, 0, 10, 0], [0, 0, 10, 0, 0], [0, 10, 0, 10, 0], [10, 0, 0, 10, 0]]) == 80\n assert candidate(grid = [[10, 0, 0, 0, 0, 0, 10], [0, 20, 0, 0, 0, 20, 0], [0, 0, 30, 0, 30, 0, 0], [0, 0, 0, 40, 0, 0, 0], [0, 0, 30, 0, 30, 0, 0], [0, 20, 0, 0, 0, 20, 0], [10, 0, 0, 0, 0, 0, 10]]) == 280\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 30\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 8, 9]]) == 52\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 1]]) == 14\n assert candidate(grid = [[10, 0, 0, 0, 0, 0, 10], [0, 10, 0, 0, 0, 10, 0], [0, 0, 10, 0, 10, 0, 0], [0, 0, 0, 20, 0, 0, 0], [10, 0, 0, 0, 0, 0, 10]]) == 90\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 26\n assert candidate(grid = [[10, 0, 0, 10], [0, 20, 20, 0], [0, 20, 20, 0], [10, 0, 0, 10]]) == 120\n assert candidate(grid = [[0, 1, 0, 0, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 6\n assert candidate(grid = [[10, 0, 0, 0, 0, 0, 0, 0, 0, 10], [0, 10, 0, 0, 0, 0, 0, 0, 10, 0], [0, 0, 10, 0, 0, 0, 0, 10, 0, 0], [0, 0, 0, 10, 0, 0, 10, 0, 0, 0], [0, 0, 0, 0, 10, 10, 0, 0, 0, 0], [0, 0, 0, 10, 0, 0, 10, 0, 0, 0], [0, 0, 10, 0, 0, 0, 0, 10, 0, 0], [0, 10, 0, 0, 0, 0, 0, 0, 10, 0], [10, 0, 0, 0, 0, 0, 0, 0, 0, 10]]) == 180\n assert candidate(grid = [[5, 1, 1, 1], [1, 1, 1, 5], [1, 1, 1, 1], [1, 1, 1, 1]]) == 16\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 2, 0, 0, 0, 0, 2, 0, 0], [0, 0, 0, 3, 0, 0, 3, 0, 0, 0], [0, 0, 0, 0, 4, 4, 0, 0, 0, 0], [0, 0, 0, 0, 4, 4, 0, 0, 0, 0], [0, 0, 0, 3, 0, 0, 3, 0, 0, 0], [0, 0, 2, 0, 0, 0, 0, 2, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 40\n assert candidate(grid = [[5, 0, 0, 5, 0, 0, 5], [0, 5, 5, 0, 5, 5, 0], [5, 0, 5, 0, 5, 0, 5], [0, 5, 0, 5, 0, 5, 0], [5, 5, 5, 5, 5, 5, 5], [0, 0, 0, 0, 0, 0, 0]]) == 50\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 4, 3, 2], [1, 2, 3, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 45\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 5, 0, 0, 0, 0, 0, 5, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]]) == 22\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 4, 4, 4, 4, 4, 4, 4, 5], [5, 4, 3, 3, 3, 3, 3, 4, 5], [5, 4, 3, 2, 2, 2, 3, 4, 5], [5, 4, 3, 2, 1, 2, 3, 4, 5], [5, 4, 3, 2, 2, 2, 3, 4, 5], [5, 4, 3, 3, 3, 3, 3, 4, 5], [5, 4, 4, 4, 4, 4, 4, 4, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 90\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().cherryPickup", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int cherryPickup(vector>& grid) {", "container": "Solution", "callable": "cherryPickup", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1464, "task_id": "maximum-product-of-two-elements-in-an-array", "difficulty": "Easy", "problem_description": "Given the array of integers nums, you will choose two different indices i and j of that array. Return the maximum value of (nums[i]-1)*(nums[j]-1).\n \nExample 1:\n\nInput: nums = [3,4,5,2]\nOutput: 12 \nExplanation: If you choose the indices i=1 and j=2 (indexed from 0), you will get the maximum value, that is, (nums[1]-1)*(nums[2]-1) = (4-1)*(5-1) = 3*4 = 12. \n\nExample 2:\n\nInput: nums = [1,5,4,5]\nOutput: 16\nExplanation: Choosing the indices i=1 and j=3 (indexed from 0), you will get the maximum value of (5-1)*(5-1) = 16.\n\nExample 3:\n\nInput: nums = [3,7]\nOutput: 12\n\n \nConstraints:\n\n2 <= nums.length <= 500\n1 <= nums[i] <= 10^3\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 10, 10, 10]) == 81\n assert candidate(nums = [2, 3, 5, 7, 11, 13]) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 72\n assert candidate(nums = [1, 1000, 2, 999, 3, 998]) == 997002\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10]) == 72\n assert candidate(nums = [10, 20, 30, 40, 50]) == 1911\n assert candidate(nums = [5, 6, 7, 8, 9]) == 56\n assert candidate(nums = [5, 5, 5, 5]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5]) == 12\n assert candidate(nums = [500, 500, 500, 500, 500]) == 249001\n assert candidate(nums = [999, 1000]) == 997002\n assert candidate(nums = [1, 5, 4, 5]) == 16\n assert candidate(nums = [10, 2, 3, 8]) == 63\n assert candidate(nums = [1, 1000, 1, 1000]) == 998001\n assert candidate(nums = [2, 3, 100, 101, 99]) == 9900\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 616\n assert candidate(nums = [100, 100]) == 9801\n assert candidate(nums = [500, 500, 1, 1]) == 249001\n assert candidate(nums = [3, 7]) == 12\n assert candidate(nums = [3, 4, 5, 2]) == 12\n assert candidate(nums = [500, 500, 499, 499, 498, 498, 497, 497, 496, 496]) == 249001\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127]) == 14112\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 898101\n assert candidate(nums = [500, 500, 500, 500, 499, 499, 499, 499, 498, 498]) == 249001\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420]) == 157963\n assert candidate(nums = [500, 250, 125, 625, 312, 156, 78, 39, 19, 9, 4, 2]) == 311376\n assert candidate(nums = [500, 400, 300, 200, 100, 50, 40, 30, 20, 10]) == 199101\n assert candidate(nums = [100, 200, 300, 400, 500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1, 1, 1, 1, 1, 1]) == 199101\n assert candidate(nums = [333, 666, 999, 334, 667, 998, 335, 668, 997]) == 995006\n assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8]) == 997002\n assert candidate(nums = [1000, 999, 998, 997, 996]) == 997002\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 1000]) == 997002\n assert candidate(nums = [300, 301, 302, 303, 304, 305, 306, 307, 308, 309]) == 94556\n assert candidate(nums = [1000, 1000, 999, 999, 998, 998, 997, 997]) == 998001\n assert candidate(nums = [300, 300, 300, 300, 300, 300, 299, 299, 299, 299]) == 89401\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 754\n assert candidate(nums = [500, 500, 450, 450, 400, 400, 350, 350, 300, 300]) == 249001\n assert candidate(nums = [250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265]) == 69432\n assert candidate(nums = [1000, 1000, 999, 999, 998, 998, 997, 997, 996, 996]) == 998001\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1000, 1000, 1000, 1000, 1000]) == 998001\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 1932\n assert candidate(nums = [500, 450, 400, 350, 300, 250, 200, 150, 100, 50]) == 224051\n assert candidate(nums = [500, 499, 498, 497, 496, 495, 494, 493, 492, 491]) == 248502\n assert candidate(nums = [1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 17982\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 4620\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4]) == 6\n assert candidate(nums = [300, 300, 300, 300, 300, 300, 300, 300, 300, 1]) == 89401\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 9702\n assert candidate(nums = [23, 45, 67, 89, 12, 34, 56, 78]) == 6776\n assert candidate(nums = [100, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 99]) == 9702\n assert candidate(nums = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 249001\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == 997002\n assert candidate(nums = [999, 999, 999, 999, 999, 999, 999, 999, 999, 1000]) == 997002\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 8811\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == 995006\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1000]) == 0\n assert candidate(nums = [1, 1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == 498501\n assert candidate(nums = [500, 500, 500, 1, 2, 3, 4, 5]) == 249001\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 288\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 0\n assert candidate(nums = [999, 1, 999, 2, 999, 3, 999, 4, 999, 5]) == 996004\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 182\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 72\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 616\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 37611\n assert candidate(nums = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509]) == 257556\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 323\n assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996]) == 997002\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 12971\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985]) == 997002\n assert candidate(nums = [500, 501, 499, 502, 498, 503, 497, 504, 496, 505]) == 253512\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109]) == 11556\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 342\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 100]) == 4851\n assert candidate(nums = [1000, 999, 998, 1, 2, 3]) == 997002\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990]) == 995006\n assert candidate(nums = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 998001\n assert candidate(nums = [1, 10, 100, 1000, 100, 10, 1]) == 98901\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 1368\n assert candidate(nums = [333, 666, 999, 222, 555, 888, 111, 444, 777, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 885226\n assert candidate(nums = [500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4]) == 199101\n assert candidate(nums = [3, 3, 3, 3, 3, 1000, 1000, 1000, 1000, 1000]) == 998001\n assert candidate(nums = [1, 2, 3, 1000, 4, 5, 6, 7, 8, 9]) == 7992\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 8811\n assert candidate(nums = [999, 999, 998, 998, 997, 997, 996, 996, 995, 995]) == 996004\n assert candidate(nums = [999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 1000]) == 997002\n assert candidate(nums = [999, 1000, 1, 2, 3, 4, 5, 6, 7, 8]) == 997002\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 81\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1000]) == 8991\n assert candidate(nums = [250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269]) == 71556\n assert candidate(nums = [1, 2, 3, 4, 5, 1000, 1001, 1002, 1003, 1004]) == 1005006\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 20711\n assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 25\n assert candidate(nums = [1000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 7992\n assert candidate(nums = [999, 1000, 998, 1000, 997]) == 998001\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxProduct", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxProduct(vector& nums) {", "container": "Solution", "callable": "maxProduct", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1465, "task_id": "maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts", "difficulty": "Medium", "problem_description": "You are given a rectangular cake of size h x w and two arrays of integers horizontalCuts and verticalCuts where:\n\nhorizontalCuts[i] is the distance from the top of the rectangular cake to the ith horizontal cut and similarly, and\nverticalCuts[j] is the distance from the left of the rectangular cake to the jth vertical cut.\n\nReturn the maximum area of a piece of cake after you cut at each horizontal and vertical position provided in the arrays horizontalCuts and verticalCuts. Since the answer can be a large number, return this modulo 109 + 7.\n \nExample 1:\n\n\nInput: h = 5, w = 4, horizontalCuts = [1,2,4], verticalCuts = [1,3]\nOutput: 4 \nExplanation: The figure above represents the given rectangular cake. Red lines are the horizontal and vertical cuts. After you cut the cake, the green piece of cake has the maximum area.\n\nExample 2:\n\n\nInput: h = 5, w = 4, horizontalCuts = [3,1], verticalCuts = [1]\nOutput: 6\nExplanation: The figure above represents the given rectangular cake. Red lines are the horizontal and vertical cuts. After you cut the cake, the green and yellow pieces of cake have the maximum area.\n\nExample 3:\n\nInput: h = 5, w = 4, horizontalCuts = [3], verticalCuts = [3]\nOutput: 9\n\n \nConstraints:\n\n2 <= h, w <= 109\n1 <= horizontalCuts.length <= min(h - 1, 105)\n1 <= verticalCuts.length <= min(w - 1, 105)\n1 <= horizontalCuts[i] < h\n1 <= verticalCuts[i] < w\nAll the elements in horizontalCuts are distinct.\nAll the elements in verticalCuts are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(h = 10,w = 10,horizontalCuts = [2, 5, 7],verticalCuts = [2, 5, 7]) == 9\n assert candidate(h = 5,w = 4,horizontalCuts = [3, 1],verticalCuts = [1]) == 6\n assert candidate(h = 5,w = 4,horizontalCuts = [1, 2, 4],verticalCuts = [1, 3]) == 4\n assert candidate(h = 10,w = 10,horizontalCuts = [2, 5, 7],verticalCuts = [3, 6, 9]) == 9\n assert candidate(h = 10,w = 10,horizontalCuts = [2, 4, 6, 8],verticalCuts = [2, 4, 6, 8]) == 4\n assert candidate(h = 1000000000,w = 1000000000,horizontalCuts = [1, 500000000],verticalCuts = [1, 500000000]) == 250000014\n assert candidate(h = 1000000000,w = 1000000000,horizontalCuts = [1, 999999999],verticalCuts = [1, 999999999]) == 81\n assert candidate(h = 5,w = 4,horizontalCuts = [3],verticalCuts = [3]) == 9\n assert candidate(h = 7,w = 7,horizontalCuts = [1, 2, 3, 4, 5, 6],verticalCuts = [1, 2, 3, 4, 5, 6]) == 1\n assert candidate(h = 6,w = 4,horizontalCuts = [1, 2, 5],verticalCuts = [1, 3]) == 6\n assert candidate(h = 10,w = 10,horizontalCuts = [2, 5, 7],verticalCuts = [3, 6, 8]) == 9\n assert candidate(h = 1000000000,w = 1000000000,horizontalCuts = [500000000],verticalCuts = [500000000]) == 250000014\n assert candidate(h = 6,w = 6,horizontalCuts = [1, 2, 3, 4, 5],verticalCuts = [1, 2, 3, 4, 5]) == 1\n assert candidate(h = 600,w = 800,horizontalCuts = [100, 200, 300, 400, 500],verticalCuts = [120, 240, 360, 480, 600, 720]) == 12000\n assert candidate(h = 100,w = 200,horizontalCuts = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],verticalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 100\n assert candidate(h = 1000000000,w = 1000000000,horizontalCuts = [1, 2, 999999998, 999999999],verticalCuts = [1, 2, 999999998, 999999999]) == 121\n assert candidate(h = 50000,w = 100000,horizontalCuts = [25000, 37500],verticalCuts = [50000]) == 249999993\n assert candidate(h = 200,w = 150,horizontalCuts = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190],verticalCuts = [15, 45, 75, 105, 135]) == 600\n assert candidate(h = 7,w = 13,horizontalCuts = [1, 3, 5],verticalCuts = [2, 4, 6, 8, 10, 12]) == 4\n assert candidate(h = 100,w = 200,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 100\n assert candidate(h = 999999999,w = 999999999,horizontalCuts = [500000000, 250000000, 750000000, 100000000],verticalCuts = [500000000, 250000000, 750000000, 100000000]) == 562500007\n assert candidate(h = 100,w = 50,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCuts = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == 50\n assert candidate(h = 500,w = 400,horizontalCuts = [100, 200, 300],verticalCuts = [80, 160, 240, 320]) == 16000\n assert candidate(h = 100,w = 100,horizontalCuts = [10, 30, 50, 70, 90],verticalCuts = [20, 40, 60, 80]) == 400\n assert candidate(h = 1000000000,w = 1000000000,horizontalCuts = [100, 200, 300, 400, 500],verticalCuts = [150, 250, 350, 450, 550]) == 282399\n assert candidate(h = 1000,w = 1000,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 828100\n assert candidate(h = 1000,w = 1000,horizontalCuts = [250, 500, 750],verticalCuts = [250, 500, 750]) == 62500\n assert candidate(h = 1000,w = 1000,horizontalCuts = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95],verticalCuts = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95]) == 819025\n assert candidate(h = 8,w = 12,horizontalCuts = [2, 3, 5, 7],verticalCuts = [2, 4, 6, 8, 10]) == 4\n assert candidate(h = 8,w = 8,horizontalCuts = [2, 4, 6],verticalCuts = [2, 4, 6]) == 4\n assert candidate(h = 1000,w = 1000,horizontalCuts = [1, 2, 3, 997, 998, 999],verticalCuts = [1, 2, 3, 997, 998, 999]) == 988036\n assert candidate(h = 500,w = 500,horizontalCuts = [25, 125, 225, 325, 425],verticalCuts = [25, 125, 225, 325, 425]) == 10000\n assert candidate(h = 50,w = 60,horizontalCuts = [10, 20, 30, 40],verticalCuts = [12, 24, 36, 48]) == 120\n assert candidate(h = 1000,w = 500,horizontalCuts = [200, 400, 600, 800],verticalCuts = [100, 200, 300, 400]) == 20000\n assert candidate(h = 50000,w = 30000,horizontalCuts = [10000, 20000, 30000, 40000],verticalCuts = [5000, 10000, 15000, 25000, 28000]) == 100000000\n assert candidate(h = 1000000,w = 1000000,horizontalCuts = [1, 999999],verticalCuts = [1, 999999]) == 995993011\n assert candidate(h = 200,w = 300,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],verticalCuts = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285]) == 150\n assert candidate(h = 100,w = 100,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCuts = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 100\n assert candidate(h = 500,w = 300,horizontalCuts = [50, 100, 150, 200, 250, 450],verticalCuts = [30, 60, 90, 120, 150, 180, 210, 240, 270]) == 6000\n assert candidate(h = 1000,w = 1000,horizontalCuts = [100, 200, 300, 400, 500, 600, 700, 800, 900],verticalCuts = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == 10000\n assert candidate(h = 50,w = 50,horizontalCuts = [25],verticalCuts = [25]) == 625\n assert candidate(h = 30,w = 40,horizontalCuts = [5, 15, 25],verticalCuts = [8, 16, 24, 32]) == 80\n assert candidate(h = 100,w = 150,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCuts = [15, 30, 45, 60, 75, 90, 120, 135]) == 300\n assert candidate(h = 150,w = 200,horizontalCuts = [25, 50, 75, 100, 125],verticalCuts = [30, 60, 90, 120, 150, 180]) == 750\n assert candidate(h = 100000,w = 50000,horizontalCuts = [50000],verticalCuts = [25000, 37500]) == 249999993\n assert candidate(h = 1000,w = 1000,horizontalCuts = [100, 200, 300, 400, 500, 600, 700, 800, 900],verticalCuts = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == 10000\n assert candidate(h = 1000,w = 500,horizontalCuts = [10, 20, 30, 40, 50],verticalCuts = [25, 50, 75, 100, 125]) == 356250\n assert candidate(h = 2000,w = 3000,horizontalCuts = [500, 1000, 1500],verticalCuts = [750, 1500, 2250]) == 375000\n assert candidate(h = 1000000,w = 1000000,horizontalCuts = [500000],verticalCuts = [500000]) == 999998257\n assert candidate(h = 40,w = 50,horizontalCuts = [8, 16, 24, 32, 40],verticalCuts = [10, 20, 30, 40, 50]) == 80\n assert candidate(h = 15,w = 20,horizontalCuts = [1, 3, 5, 7, 9, 11, 13],verticalCuts = [2, 4, 6, 8, 10, 12, 14, 16, 18]) == 4\n assert candidate(h = 10,w = 10,horizontalCuts = [1, 2, 3, 4, 5, 6, 7, 8, 9],verticalCuts = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(h = 100,w = 100,horizontalCuts = [1, 99],verticalCuts = [1, 99]) == 9604\n assert candidate(h = 500000000,w = 300000000,horizontalCuts = [100000000, 200000000, 300000000, 400000000],verticalCuts = [50000000, 150000000, 250000000]) == 930000007\n assert candidate(h = 1000,w = 2000,horizontalCuts = [250, 500, 750],verticalCuts = [500, 1000, 1500]) == 125000\n assert candidate(h = 100,w = 200,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCuts = [20, 40, 60, 80, 100, 120, 140, 160, 180]) == 200\n assert candidate(h = 800,w = 600,horizontalCuts = [50, 100, 200, 300, 400, 500, 600, 700],verticalCuts = [50, 100, 200, 300, 400, 500, 600]) == 10000\n assert candidate(h = 10,w = 10,horizontalCuts = [1, 2, 3, 4, 5, 6, 7, 8, 9],verticalCuts = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(h = 100000,w = 100000,horizontalCuts = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],verticalCuts = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 99999944\n assert candidate(h = 20,w = 30,horizontalCuts = [3, 6, 9, 12, 15, 18],verticalCuts = [4, 8, 12, 16, 24, 28]) == 24\n assert candidate(h = 800,w = 600,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],verticalCuts = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == 315000\n assert candidate(h = 1000000000,w = 1000000000,horizontalCuts = [1, 500000000, 999999999],verticalCuts = [1, 500000000, 999999999]) == 250000022\n assert candidate(h = 999999999,w = 999999999,horizontalCuts = [1, 2, 3, 4, 5],verticalCuts = [1, 2, 3, 4, 5]) == 169\n assert candidate(h = 800,w = 600,horizontalCuts = [50, 150, 250, 350, 450, 550, 650, 750],verticalCuts = [30, 130, 230, 330, 430, 530, 590]) == 10000\n assert candidate(h = 200,w = 100,horizontalCuts = [20, 180],verticalCuts = [10, 90]) == 12800\n assert candidate(h = 150,w = 200,horizontalCuts = [10, 30, 50, 70, 90, 110, 130, 140],verticalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 200\n assert candidate(h = 999,w = 999,horizontalCuts = [1, 998],verticalCuts = [1, 998]) == 994009\n assert candidate(h = 200,w = 200,horizontalCuts = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190],verticalCuts = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190]) == 400\n assert candidate(h = 1000000,w = 1000000,horizontalCuts = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000],verticalCuts = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000]) == 999999937\n assert candidate(h = 999999999,w = 999999999,horizontalCuts = [500000000],verticalCuts = [500000000]) == 250000014\n assert candidate(h = 1000000000,w = 1000000000,horizontalCuts = [1, 2, 3, 4, 5],verticalCuts = [1, 2, 3, 4, 5]) == 144\n assert candidate(h = 999999,w = 999999,horizontalCuts = [1, 999998],verticalCuts = [1, 999998]) == 993993016\n assert candidate(h = 500,w = 600,horizontalCuts = [100, 200, 300, 400],verticalCuts = [150, 250, 350, 450, 550]) == 15000\n assert candidate(h = 500000000,w = 500000000,horizontalCuts = [125000000, 250000000, 375000000, 500000000],verticalCuts = [125000000, 250000000, 375000000, 500000000]) == 890625007\n assert candidate(h = 10000,w = 10000,horizontalCuts = [2500, 5000, 7500],verticalCuts = [2500, 5000, 7500]) == 6250000\n assert candidate(h = 30,w = 20,horizontalCuts = [2, 5, 8, 12, 16, 25],verticalCuts = [2, 4, 6, 10, 14]) == 54\n assert candidate(h = 800,w = 600,horizontalCuts = [100, 300, 500, 700],verticalCuts = [150, 300, 450, 600]) == 30000\n assert candidate(h = 100,w = 200,horizontalCuts = [10, 90],verticalCuts = [20, 180]) == 12800\n assert candidate(h = 1000,w = 1500,horizontalCuts = [100, 200, 300, 400, 500, 600, 700, 800, 900],verticalCuts = [150, 300, 450, 600, 750, 900, 1200, 1350]) == 30000\n assert candidate(h = 700,w = 500,horizontalCuts = [50, 100, 200, 300, 400, 500, 600, 650, 700],verticalCuts = [50, 100, 200, 300, 400, 500]) == 10000\n assert candidate(h = 25,w = 30,horizontalCuts = [5, 10, 15, 20],verticalCuts = [5, 10, 15, 20, 25]) == 25\n assert candidate(h = 50,w = 50,horizontalCuts = [1, 5, 10, 25, 49],verticalCuts = [2, 10, 20, 30, 45]) == 360\n assert candidate(h = 1000,w = 1000,horizontalCuts = [10, 100, 200, 300, 400, 500, 600, 700, 800, 900],verticalCuts = [10, 100, 200, 300, 400, 500, 600, 700, 800, 900]) == 10000\n assert candidate(h = 20,w = 15,horizontalCuts = [1, 5, 10, 15],verticalCuts = [2, 6, 10, 14]) == 20\n assert candidate(h = 60,w = 70,horizontalCuts = [10, 20, 30, 40, 50],verticalCuts = [14, 28, 42, 56, 70]) == 140\n assert candidate(h = 500,w = 500,horizontalCuts = [100, 150, 200, 250, 300, 350, 400, 450],verticalCuts = [100, 150, 200, 250, 300, 350, 400, 450]) == 10000\n assert candidate(h = 100,w = 100,horizontalCuts = [1, 50, 99],verticalCuts = [1, 50, 99]) == 2401\n assert candidate(h = 50,w = 200,horizontalCuts = [5, 15, 25, 35, 45],verticalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 100\n assert candidate(h = 100,w = 100,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCuts = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 100\n assert candidate(h = 70,w = 80,horizontalCuts = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],verticalCuts = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80]) == 56\n assert candidate(h = 300,w = 300,horizontalCuts = [50, 100, 150, 200, 250],verticalCuts = [50, 100, 150, 200, 250]) == 2500\n assert candidate(h = 100,w = 100,horizontalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90],verticalCuts = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 100\n"}, "metadata": {"canonical_parameter_names": ["h", "w", "horizontalCuts", "verticalCuts"], "leetcode_dataset_entry_point": "Solution().maxArea", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxArea(int h, int w, vector& horizontalCuts, vector& verticalCuts) {", "container": "Solution", "callable": "maxArea", "parameters": [{"name": "h", "type": "int"}, {"name": "w", "type": "int"}, {"name": "horizontalCuts", "type": "vector&"}, {"name": "verticalCuts", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1466, "task_id": "reorder-routes-to-make-all-paths-lead-to-the-city-zero", "difficulty": "Medium", "problem_description": "There are n cities numbered from 0 to n - 1 and n - 1 roads such that there is only one way to travel between two different cities (this network form a tree). Last year, The ministry of transport decided to orient the roads in one direction because they are too narrow.\nRoads are represented by connections where connections[i] = [ai, bi] represents a road from city ai to city bi.\nThis year, there will be a big event in the capital (city 0), and many people want to travel to this city.\nYour task consists of reorienting some roads such that each city can visit the city 0. Return the minimum number of edges changed.\nIt's guaranteed that each city can reach city 0 after reorder.\n \nExample 1:\n\n\nInput: n = 6, connections = [[0,1],[1,3],[2,3],[4,0],[4,5]]\nOutput: 3\nExplanation: Change the direction of edges show in red such that each node can reach the node 0 (capital).\n\nExample 2:\n\n\nInput: n = 5, connections = [[1,0],[1,2],[3,2],[3,4]]\nOutput: 2\nExplanation: Change the direction of edges show in red such that each node can reach the node 0 (capital).\n\nExample 3:\n\nInput: n = 3, connections = [[1,0],[2,0]]\nOutput: 0\n\n \nConstraints:\n\n2 <= n <= 5 * 104\nconnections.length == n - 1\nconnections[i].length == 2\n0 <= ai, bi <= n - 1\nai != bi\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 7,connections = [[1, 0], [2, 0], [3, 1], [4, 0], [5, 0], [6, 4]]) == 0\n assert candidate(n = 6,connections = [[0, 1], [1, 3], [2, 3], [4, 0], [4, 5]]) == 3\n assert candidate(n = 5,connections = [[1, 0], [1, 2], [3, 2], [3, 4]]) == 2\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [1, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 9\n assert candidate(n = 7,connections = [[0, 1], [0, 2], [3, 2], [4, 2], [5, 4], [6, 4]]) == 2\n assert candidate(n = 4,connections = [[2, 0], [3, 0], [1, 2]]) == 0\n assert candidate(n = 10,connections = [[0, 1], [2, 0], [3, 2], [4, 2], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8]]) == 1\n assert candidate(n = 7,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == 6\n assert candidate(n = 3,connections = [[1, 0], [2, 0]]) == 0\n assert candidate(n = 7,connections = [[0, 1], [0, 2], [3, 2], [4, 3], [5, 4], [6, 5]]) == 2\n assert candidate(n = 7,connections = [[1, 0], [2, 0], [3, 1], [4, 1], [5, 2], [6, 2]]) == 0\n assert candidate(n = 20,connections = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19]]) == 19\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 11\n assert candidate(n = 30,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29]]) == 29\n assert candidate(n = 11,connections = [[0, 1], [1, 2], [2, 3], [0, 4], [4, 5], [5, 6], [6, 7], [0, 8], [8, 9], [9, 10]]) == 10\n assert candidate(n = 12,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [9, 10], [10, 11]]) == 11\n assert candidate(n = 18,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17]]) == 17\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 9\n assert candidate(n = 15,connections = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [13, 14]]) == 14\n assert candidate(n = 11,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 10\n assert candidate(n = 11,connections = [[0, 1], [0, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [5, 10]]) == 10\n assert candidate(n = 15,connections = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14]]) == 14\n assert candidate(n = 13,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12]]) == 12\n assert candidate(n = 18,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17]]) == 17\n assert candidate(n = 15,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14]]) == 14\n assert candidate(n = 16,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [8, 15]]) == 15\n assert candidate(n = 16,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15]]) == 15\n assert candidate(n = 9,connections = [[0, 1], [0, 2], [0, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8]]) == 8\n assert candidate(n = 8,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [7, 5]]) == 6\n assert candidate(n = 12,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11]]) == 11\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [1, 3], [3, 4], [3, 5], [4, 6], [4, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 11\n assert candidate(n = 20,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]]) == 19\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9]]) == 9\n assert candidate(n = 10,connections = [[9, 0], [7, 6], [3, 2], [4, 2], [6, 3], [0, 5], [8, 0], [0, 9]]) == 2\n assert candidate(n = 12,connections = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11]]) == 11\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11]]) == 11\n assert candidate(n = 10,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 9\n assert candidate(n = 14,connections = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13]]) == 13\n assert candidate(n = 20,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [0, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 19\n assert candidate(n = 12,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11]]) == 11\n assert candidate(n = 14,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [12, 13]]) == 13\n assert candidate(n = 9,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 8\n assert candidate(n = 8,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 7\n assert candidate(n = 20,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 16], [9, 17], [10, 18], [11, 19]]) == 19\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [6, 9]]) == 9\n assert candidate(n = 9,connections = [[0, 1], [1, 2], [0, 3], [3, 4], [2, 5], [5, 6], [4, 7], [7, 8]]) == 8\n assert candidate(n = 18,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 16], [9, 17]]) == 17\n assert candidate(n = 13,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11], [11, 12]]) == 12\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [8, 9]]) == 9\n assert candidate(n = 25,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24]]) == 24\n assert candidate(n = 18,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [1, 15], [15, 16], [16, 17]]) == 17\n assert candidate(n = 21,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20]]) == 20\n assert candidate(n = 12,connections = [[0, 1], [1, 2], [2, 3], [0, 4], [4, 5], [5, 6], [2, 7], [7, 8], [8, 9], [0, 10], [10, 11]]) == 11\n assert candidate(n = 15,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == 14\n assert candidate(n = 15,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 14\n assert candidate(n = 14,connections = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]]) == 13\n assert candidate(n = 10,connections = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == 9\n"}, "metadata": {"canonical_parameter_names": ["n", "connections"], "leetcode_dataset_entry_point": "Solution().minReorder", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minReorder(int n, vector>& connections) {", "container": "Solution", "callable": "minReorder", "parameters": [{"name": "n", "type": "int"}, {"name": "connections", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1467, "task_id": "probability-of-a-two-boxes-having-the-same-number-of-distinct-balls", "difficulty": "Hard", "problem_description": "Given 2n balls of k distinct colors. You will be given an integer array balls of size k where balls[i] is the number of balls of color i.\nAll the balls will be shuffled uniformly at random, then we will distribute the first n balls to the first box and the remaining n balls to the other box (Please read the explanation of the second example carefully).\nPlease note that the two boxes are considered different. For example, if we have two balls of colors a and b, and two boxes [] and (), then the distribution [a] (b) is considered different than the distribution [b] (a) (Please read the explanation of the first example carefully).\nReturn the probability that the two boxes have the same number of distinct balls. Answers within 10-5 of the actual value will be accepted as correct.\n \nExample 1:\n\nInput: balls = [1,1]\nOutput: 1.00000\nExplanation: Only 2 ways to divide the balls equally:\n- A ball of color 1 to box 1 and a ball of color 2 to box 2\n- A ball of color 2 to box 1 and a ball of color 1 to box 2\nIn both ways, the number of distinct colors in each box is equal. The probability is 2/2 = 1\n\nExample 2:\n\nInput: balls = [2,1,1]\nOutput: 0.66667\nExplanation: We have the set of balls [1, 1, 2, 3]\nThis set of balls will be shuffled randomly and we may have one of the 12 distinct shuffles with equal probability (i.e. 1/12):\n[1,1 / 2,3], [1,1 / 3,2], [1,2 / 1,3], [1,2 / 3,1], [1,3 / 1,2], [1,3 / 2,1], [2,1 / 1,3], [2,1 / 3,1], [2,3 / 1,1], [3,1 / 1,2], [3,1 / 2,1], [3,2 / 1,1]\nAfter that, we add the first two balls to the first box and the second two balls to the second box.\nWe can see that 8 of these 12 possible random distributions have the same number of distinct colors of balls in each box.\nProbability is 8/12 = 0.66667\n\nExample 3:\n\nInput: balls = [1,2,1,2]\nOutput: 0.60000\nExplanation: The set of balls is [1, 2, 2, 3, 4, 4]. It is hard to display all the 180 possible random shuffles of this set but it is easy to check that 108 of them will have the same number of distinct colors in each box.\nProbability = 108 / 180 = 0.6\n\n \nConstraints:\n\n1 <= balls.length <= 8\n1 <= balls[i] <= 6\nsum(balls) is even.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(balls = [6, 6]) == 1.0\n assert candidate(balls = [4, 4, 4, 4]) == 0.820979020979021\n assert candidate(balls = [2, 1, 1]) == 0.6666666666666666\n assert candidate(balls = [1, 2, 2, 2, 2, 2, 2]) == 0.8571428571428571\n assert candidate(balls = [1, 2, 1, 2]) == 0.6\n assert candidate(balls = [2, 2, 2, 2]) == 1.0\n assert candidate(balls = [6, 1]) == 0.0\n assert candidate(balls = [6]) == 1.0\n assert candidate(balls = [3, 3]) == 1.0\n assert candidate(balls = [1, 2, 3, 4, 5, 6]) == 0.5375089306977852\n assert candidate(balls = [2, 2, 2]) == 1.0\n assert candidate(balls = [1, 1, 1, 1, 1, 1, 1, 1]) == 1.0\n assert candidate(balls = [2, 1, 1, 1, 1]) == 0.6\n assert candidate(balls = [1, 1]) == 1.0\n assert candidate(balls = [3, 2, 1]) == 0.3\n assert candidate(balls = [1, 2, 3]) == 0.3\n assert candidate(balls = [6, 6, 6, 6, 6, 6, 6, 6]) == 0.8557108876701283\n assert candidate(balls = [1, 1, 1, 1]) == 1.0\n assert candidate(balls = [1, 1, 2, 2, 3, 3]) == 0.38311688311688313\n assert candidate(balls = [4, 2]) == 0.6\n assert candidate(balls = [5, 5, 1, 1, 1]) == 0.032467532467532464\n assert candidate(balls = [4, 3, 2, 1]) == 0.30952380952380953\n assert candidate(balls = [5, 5, 1, 1]) == 0.5454545454545454\n assert candidate(balls = [1, 2, 3, 4]) == 0.30952380952380953\n assert candidate(balls = [6, 2, 2, 2]) == 0.4329004329004329\n assert candidate(balls = [6, 4, 2, 2, 2]) == 0.40792540792540793\n assert candidate(balls = [2, 2, 2, 1, 1]) == 0.5714285714285714\n assert candidate(balls = [5, 1, 1, 1, 1]) == 0.8571428571428571\n assert candidate(balls = [4, 4, 1]) == 0.11428571428571428\n assert candidate(balls = [2, 2, 2, 2, 2, 2]) == 1.0\n assert candidate(balls = [6, 6]) == 1.0\n assert candidate(balls = [6, 1, 1, 1]) == 0.0\n assert candidate(balls = [3, 2, 1, 1, 1]) == 0.2571428571428571\n assert candidate(balls = [3, 3, 3, 1]) == 0.21428571428571427\n assert candidate(balls = [3, 2, 2, 1]) == 0.37142857142857144\n assert candidate(balls = [1, 1, 1, 1, 1, 1]) == 1.0\n assert candidate(balls = [1, 1, 1, 1, 1, 1]) == 1.0\n assert candidate(balls = [5, 4, 3, 2, 1]) == 0.5474941724941725\n assert candidate(balls = [2, 2, 2, 2, 1]) == 0.8\n assert candidate(balls = [6, 6, 6]) == 0.9777869189633895\n assert candidate(balls = [1, 2, 3, 4]) == 0.30952380952380953\n assert candidate(balls = [4, 2, 1]) == 0.5\n assert candidate(balls = [1, 2, 2, 1, 1]) == 0.6\n assert candidate(balls = [3, 2, 2, 1, 1, 1]) == 0.30952380952380953\n assert candidate(balls = [5, 3, 2]) == 0.5555555555555556\n assert candidate(balls = [6, 1, 1]) == 0.5714285714285714\n assert candidate(balls = [5, 3, 1]) == 0.21428571428571427\n assert candidate(balls = [4, 2, 1, 1]) == 0.34285714285714286\n assert candidate(balls = [3, 2, 1, 1]) == 0.7\n assert candidate(balls = [5, 3, 3]) == 1.3531746031746033\n assert candidate(balls = [6, 3, 3]) == 0.7251082251082251\n assert candidate(balls = [5, 1, 1]) == 1.0\n assert candidate(balls = [4, 2, 2]) == 0.5142857142857142\n assert candidate(balls = [3, 3, 1, 1]) == 0.5714285714285714\n assert candidate(balls = [3, 3, 3, 3, 3, 3]) == 0.6334841628959276\n assert candidate(balls = [4, 3, 2, 1]) == 0.30952380952380953\n assert candidate(balls = [2, 3, 2, 1]) == 0.37142857142857144\n assert candidate(balls = [2, 2, 2, 2]) == 1.0\n assert candidate(balls = [4, 2, 2, 1]) == 0.5857142857142857\n assert candidate(balls = [4, 4, 4, 2]) == 0.5664335664335665\n assert candidate(balls = [1, 2, 2, 3, 3]) == 0.6507936507936508\n assert candidate(balls = [2, 2, 1, 1, 1, 1]) == 0.5142857142857142\n assert candidate(balls = [1, 1, 1, 1, 1, 1, 1, 1]) == 1.0\n assert candidate(balls = [3, 2, 2]) == 1.1\n assert candidate(balls = [6, 2, 1, 1]) == 0.31746031746031744\n assert candidate(balls = [5, 5, 5]) == 1.7657342657342658\n assert candidate(balls = [4, 3, 1]) == 0.11428571428571428\n assert candidate(balls = [5, 1, 1, 1, 1, 1]) == 0.0\n assert candidate(balls = [4, 4, 1, 1]) == 0.5555555555555556\n assert candidate(balls = [6, 2, 2]) == 0.47619047619047616\n assert candidate(balls = [1, 3, 3, 1]) == 0.5714285714285714\n assert candidate(balls = [5, 1, 1, 1]) == 0.0\n assert candidate(balls = [3, 3, 1, 1]) == 0.5714285714285714\n assert candidate(balls = [3, 3, 3, 3]) == 0.7662337662337663\n assert candidate(balls = [6, 1, 1, 1, 1, 1, 1, 1]) == 0.0\n assert candidate(balls = [3, 3, 3, 3]) == 0.7662337662337663\n assert candidate(balls = [6, 2, 1, 1, 1]) == 0.4166666666666667\n assert candidate(balls = [4, 2]) == 0.6\n assert candidate(balls = [5, 1, 1, 1]) == 0.0\n assert candidate(balls = [4, 2, 2]) == 0.5142857142857142\n assert candidate(balls = [2, 2, 1, 1, 1, 1]) == 0.5142857142857142\n assert candidate(balls = [4, 4, 4, 4]) == 0.820979020979021\n assert candidate(balls = [1, 1, 2, 2, 3, 3]) == 0.38311688311688313\n assert candidate(balls = [4, 4, 2, 2]) == 0.5238095238095238\n assert candidate(balls = [6, 1, 1]) == 0.5714285714285714\n assert candidate(balls = [4, 4, 1]) == 0.11428571428571428\n assert candidate(balls = [6, 6, 1, 1]) == 0.5384615384615384\n assert candidate(balls = [4, 4, 2]) == 0.6190476190476191\n assert candidate(balls = [6, 2, 2, 2, 2, 2, 2]) == 0.38009049773755654\n assert candidate(balls = [4, 4, 3, 2, 1]) == 0.30186480186480186\n assert candidate(balls = [3, 2, 1, 1, 1]) == 0.2571428571428571\n assert candidate(balls = [4, 4, 4]) == 0.8961038961038961\n assert candidate(balls = [6, 1, 1, 1]) == 0.0\n assert candidate(balls = [2, 2, 2, 2, 2, 2]) == 1.0\n assert candidate(balls = [6, 1, 1, 1, 1, 1]) == 0.0\n assert candidate(balls = [6, 3, 1, 1, 1, 1]) == 0.6818181818181818\n assert candidate(balls = [1, 2, 3, 2]) == 0.37142857142857144\n assert candidate(balls = [5, 2, 2, 1]) == 0.31746031746031744\n assert candidate(balls = [3, 2, 1]) == 0.3\n assert candidate(balls = [3, 2, 1, 1, 1, 1]) == 0.6\n assert candidate(balls = [2, 2, 2, 1, 1]) == 0.5714285714285714\n assert candidate(balls = [3, 2, 2, 1]) == 0.37142857142857144\n"}, "metadata": {"canonical_parameter_names": ["balls"], "leetcode_dataset_entry_point": "Solution().getProbability", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "double getProbability(vector& balls) {", "container": "Solution", "callable": "getProbability", "parameters": [{"name": "balls", "type": "vector&"}], "return_type": "double", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1470, "task_id": "shuffle-the-array", "difficulty": "Easy", "problem_description": "Given the array nums consisting of 2n elements in the form [x1,x2,...,xn,y1,y2,...,yn].\\r\n\\r\nReturn the array in the form [x1,y1,x2,y2,...,xn,yn].\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: nums = [2,5,1,3,4,7], n = 3\\r\nOutput: [2,3,5,4,1,7] \\r\nExplanation: Since x1=2, x2=5, x3=1, y1=3, y2=4, y3=7 then the answer is [2,3,5,4,1,7].\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: nums = [1,2,3,4,4,3,2,1], n = 4\\r\nOutput: [1,4,2,3,3,2,4,1]\\r\n\\r\n\\r\nExample 3:\\r\n\\r\n\\r\nInput: nums = [1,1,2,2], n = 2\\r\nOutput: [1,2,1,2]\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= n <= 500\\r\n\tnums.length == 2n\\r\n\t1 <= nums[i] <= 10^3\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],n = 6) == [5, 11, 6, 12, 7, 13, 8, 14, 9, 15, 10, 16]\n assert candidate(nums = [2, 5, 1, 3, 4, 7],n = 3) == [2, 3, 5, 4, 1, 7]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80],n = 4) == [10, 50, 20, 60, 30, 70, 40, 80]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],n = 5) == [9, 4, 8, 3, 7, 2, 6, 1, 5, 0]\n assert candidate(nums = [7, 11, 3, 4, 8, 10],n = 3) == [7, 4, 11, 8, 3, 10]\n assert candidate(nums = [6, 2, 3, 4, 5, 1],n = 3) == [6, 4, 2, 5, 3, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],n = 8) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],n = 6) == [1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12]\n assert candidate(nums = [5, 3, 2, 4, 1, 6],n = 3) == [5, 4, 3, 1, 2, 6]\n assert candidate(nums = [1, 1, 2, 2],n = 2) == [1, 2, 1, 2]\n assert candidate(nums = [10, 20, 30, 40, 50, 60],n = 3) == [10, 40, 20, 50, 30, 60]\n assert candidate(nums = [100, 200, 101, 201, 102, 202, 103, 203],n = 4) == [100, 102, 200, 202, 101, 103, 201, 203]\n assert candidate(nums = [100, 200, 101, 201, 102, 202],n = 3) == [100, 201, 200, 102, 101, 202]\n assert candidate(nums = [999, 888, 777, 666, 555, 444, 333, 222, 111, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],n = 10) == [999, 2, 888, 3, 777, 4, 666, 5, 555, 6, 444, 7, 333, 8, 222, 9, 111, 10, 1, 11]\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14],n = 4) == [7, 11, 8, 12, 9, 13, 10, 14]\n assert candidate(nums = [1, 2, 3, 4, 4, 3, 2, 1],n = 4) == [1, 4, 2, 3, 3, 2, 4, 1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 30],n = 8) == [1, 17, 3, 19, 5, 21, 7, 23, 9, 25, 11, 27, 13, 29, 15, 30]\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34],n = 17) == [5, 22, 6, 23, 7, 24, 8, 25, 9, 26, 10, 27, 11, 28, 12, 29, 13, 30, 14, 31, 15, 32, 16, 33, 17, 34]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20],n = 20) == [1, 11, 1, 11, 2, 12, 2, 12, 3, 13, 3, 13, 4, 14, 4, 14, 5, 15, 5, 15, 6, 16, 6, 16, 7, 17, 7, 17, 8, 18, 8, 18, 9, 19, 9, 19, 10, 20, 10, 20]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600],n = 8) == [100, 900, 200, 1000, 300, 1100, 400, 1200, 500, 1300, 600, 1400, 700, 1500, 800, 1600]\n assert candidate(nums = [500, 1, 499, 2, 498, 3, 497, 4, 496, 5, 495, 6, 494, 7, 493, 8, 492, 9, 491, 10, 490, 11, 489, 12, 488, 13, 487, 14, 486, 15, 485, 16, 484, 17, 483, 18, 482, 19, 481, 20],n = 25) == [500, 13, 1, 487, 499, 14, 2, 486, 498, 15, 3, 485, 497, 16, 4, 484, 496, 17, 5, 483, 495, 18, 6, 482, 494, 19, 7, 481, 493, 20]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],n = 15) == [1, 6, 1, 6, 1, 6, 2, 7, 2, 7, 2, 7, 3, 8, 3, 8, 3, 8, 4, 9, 4, 9, 4, 9, 5, 10, 5, 10, 5, 10]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500],n = 25) == [10, 260, 20, 270, 30, 280, 40, 290, 50, 300, 60, 310, 70, 320, 80, 330, 90, 340, 100, 350, 110, 360, 120, 370, 130, 380, 140, 390, 150, 400, 160, 410, 170, 420, 180, 430, 190, 440, 200, 450, 210, 460, 220, 470, 230, 480, 240, 490, 250, 500]\n assert candidate(nums = [999, 888, 777, 666, 555, 444, 333, 222, 111, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],n = 10) == [999, 2, 888, 3, 777, 4, 666, 5, 555, 6, 444, 7, 333, 8, 222, 9, 111, 10]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60],n = 15) == [2, 32, 4, 34, 6, 36, 8, 38, 10, 40, 12, 42, 14, 44, 16, 46, 18, 48, 20, 50, 22, 52, 24, 54, 26, 56, 28, 58, 30, 60]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],n = 10) == [5, 55, 10, 60, 15, 65, 20, 70, 25, 75, 30, 80, 35, 85, 40, 90, 45, 95, 50, 100]\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971],n = 15) == [1000, 985, 999, 984, 998, 983, 997, 982, 996, 981, 995, 980, 994, 979, 993, 978, 992, 977, 991, 976, 990, 975, 989, 974, 988, 973, 987, 972, 986, 971]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],n = 10) == [9, 11, 8, 12, 7, 13, 6, 14, 5, 15, 4, 16, 3, 17, 2, 18, 1, 19, 10, 20]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11],n = 10) == [10, 20, 9, 19, 8, 18, 7, 17, 6, 16, 5, 15, 4, 14, 3, 13, 2, 12, 1, 11]\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515, 1616, 1717, 1818, 1919, 2020],n = 10) == [101, 1111, 202, 1212, 303, 1313, 404, 1414, 505, 1515, 606, 1616, 707, 1717, 808, 1818, 909, 1919, 1010, 2020]\n assert candidate(nums = [99, 100, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60],n = 32) == [99, 68, 100, 67, 98, 66, 97, 65, 96, 64, 95, 63, 94, 62, 93, 61, 92, 60]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],n = 25) == [1, 26, 2, 27, 3, 28, 4, 29, 5, 30, 6, 31, 7, 32, 8, 33, 9, 34, 10, 35, 11, 36, 12, 37, 13, 38, 14, 39, 15, 40, 16, 41, 17, 42, 18, 43, 19, 44, 20, 45, 21, 46, 22, 47, 23, 48, 24, 49, 25, 50]\n assert candidate(nums = [300, 299, 298, 297, 296, 295, 294, 293, 292, 291, 290, 289, 288, 287, 286, 285, 284, 283, 282, 281, 280, 279, 278, 277, 276, 275, 274, 273, 272, 271, 270, 269, 268, 267, 266, 265, 264, 263, 262, 261, 260, 259, 258, 257, 256, 255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, 239, 238, 237, 236, 235, 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 215, 214, 213, 212, 211, 210],n = 25) == [300, 275, 299, 274, 298, 273, 297, 272, 296, 271, 295, 270, 294, 269, 293, 268, 292, 267, 291, 266, 290, 265, 289, 264, 288, 263, 287, 262, 286, 261, 285, 260, 284, 259, 283, 258, 282, 257, 281, 256, 280, 255, 279, 254, 278, 253, 277, 252, 276, 251]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],n = 15) == [100, 6, 200, 7, 300, 8, 400, 9, 500, 10, 600, 11, 700, 12, 800, 13, 900, 14, 1000, 15, 1, 16, 2, 17, 3, 18, 4, 19, 5, 20]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200],n = 17) == [5, 90, 10, 95, 15, 100, 20, 105, 25, 110, 30, 115, 35, 120, 40, 125, 45, 130, 50, 135, 55, 140, 60, 145, 65, 150, 70, 155, 75, 160, 80, 165, 85, 170]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32],n = 16) == [1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23, 8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29, 14, 30, 15, 31, 16, 32]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],n = 10) == [5, 55, 10, 60, 15, 65, 20, 70, 25, 75, 30, 80, 35, 85, 40, 90, 45, 95, 50, 100]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150],n = 15) == [5, 80, 10, 85, 15, 90, 20, 95, 25, 100, 30, 105, 35, 110, 40, 115, 45, 120, 50, 125, 55, 130, 60, 135, 65, 140, 70, 145, 75, 150]\n assert candidate(nums = [123, 456, 789, 1011, 1213, 1415, 1617, 1819, 2021, 2223, 2425, 2627, 2829, 3031, 3233, 3435, 3637, 3839, 4041, 4243, 4445, 4647, 4849, 5051, 5253, 5455, 5657, 5859, 6061, 6263, 6465, 6667, 6869, 7071, 7273, 7475, 7677, 7879, 8081, 8283, 8485, 8687, 8889, 9091, 9293, 9495, 9697, 9899],n = 25) == [123, 5455, 456, 5657, 789, 5859, 1011, 6061, 1213, 6263, 1415, 6465, 1617, 6667, 1819, 6869, 2021, 7071, 2223, 7273, 2425, 7475, 2627, 7677, 2829, 7879, 3031, 8081, 3233, 8283, 3435, 8485, 3637, 8687, 3839, 8889, 4041, 9091, 4243, 9293, 4445, 9495, 4647, 9697, 4849, 9899]\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42],n = 8) == [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],n = 30) == [10, 1, 20, 2, 30, 3, 40, 4, 50, 5, 60, 6, 70, 7, 80, 8, 90, 9, 100, 10, 110, 11, 120, 12, 130, 13, 140, 14, 150, 15, 160, 16, 170, 17, 180, 18, 190, 19, 200, 20, 210, 21, 220, 22, 230, 23, 240, 24, 250, 25, 260, 26, 270, 27, 280, 28, 290, 29, 300, 30]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],n = 10) == [10, 110, 20, 120, 30, 130, 40, 140, 50, 150, 60, 160, 70, 170, 80, 180, 90, 190, 100, 200]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160],n = 8) == [10, 90, 20, 100, 30, 110, 40, 120, 50, 130, 60, 140, 70, 150, 80, 160]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100],n = 50) == [1, 51, 2, 52, 3, 53, 4, 54, 5, 55, 6, 56, 7, 57, 8, 58, 9, 59, 10, 60, 11, 61, 12, 62, 13, 63, 14, 64, 15, 65, 16, 66, 17, 67, 18, 68, 19, 69, 20, 70, 21, 71, 22, 72, 23, 73, 24, 74, 25, 75, 26, 76, 27, 77, 28, 78, 29, 79, 30, 80, 31, 81, 32, 82, 33, 83, 34, 84, 35, 85, 36, 86, 37, 87, 38, 88, 39, 89, 40, 90, 41, 91, 42, 92, 43, 93, 44, 94, 45, 95, 46, 96, 47, 97, 48, 98, 49, 99, 50, 1000]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],n = 10) == [1, 6, 1, 6, 2, 7, 2, 7, 3, 8, 3, 8, 4, 9, 4, 9, 5, 10, 5, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150],n = 75) == [1, 76, 2, 77, 3, 78, 4, 79, 5, 80, 6, 81, 7, 82, 8, 83, 9, 84, 10, 85, 11, 86, 12, 87, 13, 88, 14, 89, 15, 90, 16, 91, 17, 92, 18, 93, 19, 94, 20, 95, 21, 96, 22, 97, 23, 98, 24, 99, 25, 100, 26, 101, 27, 102, 28, 103, 29, 104, 30, 105, 31, 106, 32, 107, 33, 108, 34, 109, 35, 110, 36, 111, 37, 112, 38, 113, 39, 114, 40, 115, 41, 116, 42, 117, 43, 118, 44, 119, 45, 120, 46, 121, 47, 122, 48, 123, 49, 124, 50, 125, 51, 126, 52, 127, 53, 128, 54, 129, 55, 130, 56, 131, 57, 132, 58, 133, 59, 134, 60, 135, 61, 136, 62, 137, 63, 138, 64, 139, 65, 140, 66, 141, 67, 142, 68, 143, 69, 144, 70, 145, 71, 146, 72, 147, 73, 148, 74, 149, 75, 150]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7, 5, 1, 0, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 8, 9, 9, 8, 6, 2, 8, 0, 3, 4, 8, 2, 5, 3, 4, 2, 1, 1, 7, 0, 6, 7, 9],n = 50) == [3, 0, 1, 5, 4, 8, 1, 2, 5, 0, 9, 9, 2, 7, 6, 4, 5, 9, 3, 4, 5, 4, 8, 5, 9, 9, 7, 2, 9, 3, 3, 0, 2, 7, 3, 8, 8, 1, 4, 6, 6, 4, 2, 0, 6, 6, 4, 2, 3, 8, 3, 6, 8, 2, 3, 0, 2, 8, 7, 9, 9, 9, 5, 8, 0, 6, 2, 2, 8, 8, 8, 0, 4, 3, 1, 4, 9, 8, 7, 2, 1, 5, 6, 3, 9, 4, 3, 2, 9, 1, 9, 1, 3, 7, 7, 0, 5, 6, 1, 7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],n = 50) == [1, 51, 2, 52, 3, 53, 4, 54, 5, 55, 6, 56, 7, 57, 8, 58, 9, 59, 10, 60, 11, 61, 12, 62, 13, 63, 14, 64, 15, 65, 16, 66, 17, 67, 18, 68, 19, 69, 20, 70, 21, 71, 22, 72, 23, 73, 24, 74, 25, 75, 26, 76, 27, 77, 28, 78, 29, 79, 30, 80, 31, 81, 32, 82, 33, 83, 34, 84, 35, 85, 36, 86, 37, 87, 38, 88, 39, 89, 40, 90, 41, 91, 42, 92, 43, 93, 44, 94, 45, 95, 46, 96, 47, 97, 48, 98, 49, 99, 50, 100]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],n = 50) == [1, 51, 2, 52, 3, 53, 4, 54, 5, 55, 6, 56, 7, 57, 8, 58, 9, 59, 10, 60, 11, 61, 12, 62, 13, 63, 14, 64, 15, 65, 16, 66, 17, 67, 18, 68, 19, 69, 20, 70, 21, 71, 22, 72, 23, 73, 24, 74, 25, 75, 26, 76, 27, 77, 28, 78, 29, 79, 30, 80, 31, 81, 32, 82, 33, 83, 34, 84, 35, 85, 36, 86, 37, 87, 38, 88, 39, 89, 40, 90, 41, 91, 42, 92, 43, 93, 44, 94, 45, 95, 46, 96, 47, 97, 48, 98, 49, 99, 50, 100]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],n = 12) == [1, 25, 3, 27, 5, 29, 7, 31, 9, 33, 11, 35, 13, 37, 15, 39, 17, 41, 19, 43, 21, 45, 23, 47]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],n = 15) == [10, 160, 20, 170, 30, 180, 40, 190, 50, 200, 60, 210, 70, 220, 80, 230, 90, 240, 100, 250, 110, 260, 120, 270, 130, 280, 140, 290, 150, 300]\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515, 1616],n = 8) == [101, 909, 202, 1010, 303, 1111, 404, 1212, 505, 1313, 606, 1414, 707, 1515, 808, 1616]\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],n = 8) == [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]\n assert candidate(nums = [1, 100, 2, 101, 3, 102, 4, 103, 5, 104, 6, 105, 7, 106, 8, 107, 9, 108, 10, 109, 11, 110, 12, 111, 13, 112, 14, 113, 15, 114, 16, 115, 17, 116, 18, 117, 19, 118, 20, 119, 21, 120, 22, 121, 23, 122, 24, 123, 25, 124, 26, 125, 27, 126, 28, 127, 29, 128, 30, 129],n = 15) == [1, 107, 100, 9, 2, 108, 101, 10, 3, 109, 102, 11, 4, 110, 103, 12, 5, 111, 104, 13, 6, 112, 105, 14, 7, 113, 106, 15, 8, 114]\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970, 969, 968, 967, 966, 965, 964, 963, 962, 961, 960, 959, 958, 957, 956, 955, 954, 953, 952, 951, 950, 949, 948, 947, 946, 945, 944, 943, 942, 941, 940, 939, 938, 937, 936, 935, 934, 933, 932, 931, 930],n = 25) == [1000, 975, 999, 974, 998, 973, 997, 972, 996, 971, 995, 970, 994, 969, 993, 968, 992, 967, 991, 966, 990, 965, 989, 964, 988, 963, 987, 962, 986, 961, 985, 960, 984, 959, 983, 958, 982, 957, 981, 956, 980, 955, 979, 954, 978, 953, 977, 952, 976, 951]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],n = 20) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]\n assert candidate(nums = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410],n = 10) == [101, 201, 102, 202, 103, 203, 104, 204, 105, 205, 106, 206, 107, 207, 108, 208, 109, 209, 110, 210]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225, 235, 245, 255, 265, 275, 285, 295, 305, 315, 325, 335, 345, 355, 365, 375, 385, 395, 400],n = 20) == [5, 205, 15, 215, 25, 225, 35, 235, 45, 245, 55, 255, 65, 265, 75, 275, 85, 285, 95, 295, 105, 305, 115, 315, 125, 325, 135, 335, 145, 345, 155, 355, 165, 365, 175, 375, 185, 385, 195, 395]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160],n = 8) == [10, 90, 20, 100, 30, 110, 40, 120, 50, 130, 60, 140, 70, 150, 80, 160]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],n = 16) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],n = 15) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],n = 20) == [5, 25, 6, 26, 7, 27, 8, 28, 9, 29, 10, 30, 11, 31, 12, 32, 13, 33, 14, 34, 15, 35, 16, 36, 17, 37, 18, 38, 19, 39, 20, 40]\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970, 969, 968, 967, 966, 965, 964, 963, 962, 961, 960, 959, 958, 957, 956, 955, 954, 953, 952, 951, 950, 949, 948, 947, 946, 945, 944, 943, 942, 941, 940, 939, 938, 937, 936, 935, 934, 933, 932, 931, 930, 929, 928, 927, 926, 925, 924, 923, 922, 921, 920, 919, 918, 917, 916, 915, 914, 913, 912, 911, 910],n = 50) == [999, 949, 998, 948, 997, 947, 996, 946, 995, 945, 994, 944, 993, 943, 992, 942, 991, 941, 990, 940, 989, 939, 988, 938, 987, 937, 986, 936, 985, 935, 984, 934, 983, 933, 982, 932, 981, 931, 980, 930, 979, 929, 978, 928, 977, 927, 976, 926, 975, 925, 974, 924, 973, 923, 972, 922, 971, 921, 970, 920, 969, 919, 968, 918, 967, 917, 966, 916, 965, 915, 964, 914, 963, 913, 962, 912, 961, 911, 960, 910]\n assert candidate(nums = [1, 1001, 2, 1002, 3, 1003, 4, 1004, 5, 1005, 6, 1006, 7, 1007, 8, 1008, 9, 1009, 10, 1010, 11, 1011, 12, 1012, 13, 1013, 14, 1014, 15, 1015, 16, 1016, 17, 1017, 18, 1018, 19, 1019, 20, 1020, 21, 1021, 22, 1022, 23, 1023, 24, 1024, 25, 1025, 26, 1026, 27, 1027, 28, 1028, 29, 1029, 30, 1030, 31, 1031, 32, 1032, 33, 1033, 34, 1034, 35, 1035, 36, 1036, 37, 1037, 38, 1038, 39, 1039, 40, 1040, 41, 1041, 42, 1042, 43, 1043, 44, 1044, 45, 1045, 46, 1046, 47, 1047, 48, 1048, 49, 1049, 50, 1050],n = 25) == [1, 1013, 1001, 14, 2, 1014, 1002, 15, 3, 1015, 1003, 16, 4, 1016, 1004, 17, 5, 1017, 1005, 18, 6, 1018, 1006, 19, 7, 1019, 1007, 20, 8, 1020, 1008, 21, 9, 1021, 1009, 22, 10, 1022, 1010, 23, 11, 1023, 1011, 24, 12, 1024, 1012, 25, 13, 1025]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24],n = 10) == [1, 6, 3, 8, 5, 10, 7, 12, 9, 14, 11, 16, 13, 18, 15, 20, 2, 22, 4, 24]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600],n = 8) == [100, 900, 200, 1000, 300, 1100, 400, 1200, 500, 1300, 600, 1400, 700, 1500, 800, 1600]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30],n = 30) == [1, 16, 1, 16, 2, 17, 2, 17, 3, 18, 3, 18, 4, 19, 4, 19, 5, 20, 5, 20, 6, 21, 6, 21, 7, 22, 7, 22, 8, 23, 8, 23, 9, 24, 9, 24, 10, 25, 10, 25, 11, 26, 11, 26, 12, 27, 12, 27, 13, 28, 13, 28, 14, 29, 14, 29, 15, 30, 15, 30]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225, 235, 245, 255, 265, 275, 285, 295],n = 15) == [5, 155, 15, 165, 25, 175, 35, 185, 45, 195, 55, 205, 65, 215, 75, 225, 85, 235, 95, 245, 105, 255, 115, 265, 125, 275, 135, 285, 145, 295]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000, 3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000, 4100, 4200, 4300, 4400, 4500, 4600, 4700, 4800, 4900, 5000, 5100, 5200, 5300, 5400, 5500, 5600, 5700, 5800, 5900, 6000, 6100, 6200, 6300, 6400, 6500, 6600, 6700, 6800, 6900, 7000, 7100, 7200, 7300, 7400, 7500, 7600, 7700, 7800, 7900, 8000, 8100, 8200, 8300, 8400, 8500, 8600, 8700, 8800, 8900, 9000, 9100, 9200, 9300, 9400, 9500, 9600, 9700, 9800, 9900, 10000],n = 50) == [100, 5100, 200, 5200, 300, 5300, 400, 5400, 500, 5500, 600, 5600, 700, 5700, 800, 5800, 900, 5900, 1000, 6000, 1100, 6100, 1200, 6200, 1300, 6300, 1400, 6400, 1500, 6500, 1600, 6600, 1700, 6700, 1800, 6800, 1900, 6900, 2000, 7000, 2100, 7100, 2200, 7200, 2300, 7300, 2400, 7400, 2500, 7500, 2600, 7600, 2700, 7700, 2800, 7800, 2900, 7900, 3000, 8000, 3100, 8100, 3200, 8200, 3300, 8300, 3400, 8400, 3500, 8500, 3600, 8600, 3700, 8700, 3800, 8800, 3900, 8900, 4000, 9000, 4100, 9100, 4200, 9200, 4300, 9300, 4400, 9400, 4500, 9500, 4600, 9600, 4700, 9700, 4800, 9800, 4900, 9900, 5000, 10000]\n assert candidate(nums = [1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],n = 50) == [1001, 1051, 1002, 1052, 1003, 1053, 1004, 1054, 1005, 1055, 1006, 1056, 1007, 1057, 1008, 1058, 1009, 1059, 1010, 1060, 1011, 1061, 1012, 1062, 1013, 1063, 1014, 1064, 1015, 1065, 1016, 1066, 1017, 1067, 1018, 1068, 1019, 1069, 1020, 1070, 1021, 1071, 1022, 1072, 1023, 1073, 1024, 1074, 1025, 1075, 1026, 1076, 1027, 1077, 1028, 1078, 1029, 1079, 1030, 1080, 1031, 1081, 1032, 1082, 1033, 1083, 1034, 1084, 1035, 1085, 1036, 1086, 1037, 1087, 1038, 1088, 1039, 1089, 1040, 1090, 1041, 1091, 1042, 1092, 1043, 1093, 1044, 1094, 1045, 1095, 1046, 1096, 1047, 1097, 1048, 1098, 1049, 1099, 1050, 1100]\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970, 969, 968, 967, 966, 965, 964, 963, 962, 961, 960, 959, 958, 957, 956, 955, 954, 953, 952, 951, 950, 949, 948, 947, 946, 945, 944, 943, 942, 941, 940, 939, 938, 937, 936, 935, 934, 933, 932, 931, 930],n = 50) == [999, 949, 998, 948, 997, 947, 996, 946, 995, 945, 994, 944, 993, 943, 992, 942, 991, 941, 990, 940, 989, 939, 988, 938, 987, 937, 986, 936, 985, 935, 984, 934, 983, 933, 982, 932, 981, 931, 980, 930]\n"}, "metadata": {"canonical_parameter_names": ["nums", "n"], "leetcode_dataset_entry_point": "Solution().shuffle", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector shuffle(vector& nums, int n) {", "container": "Solution", "callable": "shuffle", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "n", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1471, "task_id": "the-k-strongest-values-in-an-array", "difficulty": "Medium", "problem_description": "Given an array of integers arr and an integer k.\nA value arr[i] is said to be stronger than a value arr[j] if |arr[i] - m| > |arr[j] - m| where m is the centre of the array.\nIf |arr[i] - m| == |arr[j] - m|, then arr[i] is said to be stronger than arr[j] if arr[i] > arr[j].\nReturn a list of the strongest k values in the array. return the answer in any arbitrary order.\nThe centre is the middle value in an ordered integer list. More formally, if the length of the list is n, the centre is the element in position ((n - 1) / 2) in the sorted list (0-indexed).\n\nFor arr = [6, -3, 7, 2, 11], n = 5 and the centre is obtained by sorting the array arr = [-3, 2, 6, 7, 11] and the centre is arr[m] where m = ((5 - 1) / 2) = 2. The centre is 6.\nFor arr = [-7, 22, 17, 3], n = 4 and the centre is obtained by sorting the array arr = [-7, 3, 17, 22] and the centre is arr[m] where m = ((4 - 1) / 2) = 1. The centre is 3.\n\n\n\n \n\n\n \n\n \n \n\n\n\n\n\n \nExample 1:\n\nInput: arr = [1,2,3,4,5], k = 2\nOutput: [5,1]\nExplanation: Centre is 3, the elements of the array sorted by the strongest are [5,1,4,2,3]. The strongest 2 elements are [5, 1]. [1, 5] is also accepted answer.\nPlease note that although |5 - 3| == |1 - 3| but 5 is stronger than 1 because 5 > 1.\n\nExample 2:\n\nInput: arr = [1,1,3,5,5], k = 2\nOutput: [5,5]\nExplanation: Centre is 3, the elements of the array sorted by the strongest are [5,5,1,1,3]. The strongest 2 elements are [5, 5].\n\nExample 3:\n\nInput: arr = [6,7,11,7,6,8], k = 5\nOutput: [11,8,6,6,7]\nExplanation: Centre is 7, the elements of the array sorted by the strongest are [11,8,6,6,7,7].\nAny permutation of [11,8,6,6,7] is accepted.\n\n \nConstraints:\n\n1 <= arr.length <= 105\n-105 <= arr[i] <= 105\n1 <= k <= arr.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 2, 3, 4, 5],k = 2) == [5, 1]\n assert candidate(arr = [100000, -100000, 50000, -50000, 0],k = 3) == [100000, -100000, 50000]\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 3) == [9, 8, 0]\n assert candidate(arr = [1, 1, 3, 5, 5],k = 2) == [5, 5]\n assert candidate(arr = [1, 3, 2, 4, 5],k = 3) == [5, 1, 4]\n assert candidate(arr = [-100000, 100000],k = 1) == [100000]\n assert candidate(arr = [6, -3, 7, 2, 11],k = 4) == [-3, 11, 2, 7]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == [10, 9, 1, 8]\n assert candidate(arr = [-7, 22, 17, 3],k = 2) == [22, 17]\n assert candidate(arr = [6, 7, 11, 7, 6, 8],k = 5) == [11, 8, 6, 6, 7]\n assert candidate(arr = [5, 3, 1, 2, 4],k = 3) == [5, 1, 4]\n assert candidate(arr = [0, 0, 0, 0, 0],k = 1) == [0]\n assert candidate(arr = [-7, 22, 17, 3],k = 3) == [22, 17, -7]\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == [10, 9, 1]\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],k = 6) == [-1, -15, -2, -14, -3, -13]\n assert candidate(arr = [-99999, -99998, -99997, -99996, -99995, -99994, -99993, -99992, -99991, -99990],k = 5) == [-99990, -99991, -99999, -99992, -99998]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],k = 7) == [110, 10, 100, 20, 90, 30, 80]\n assert candidate(arr = [-5, 5, -10, 10, -15, 15, -20, 20, -25, 25, -30, 30, -35, 35],k = 6) == [35, 30, 25, -35, 20, -30]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 3) == [1, 1, 1]\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 5) == [-1, -2, -10, -3, -9]\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 4) == [-1, -2, -10, -3]\n assert candidate(arr = [1, 2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10],k = 10) == [1, 10, 10, 10, 2, 2, 9, 9, 3, 8]\n assert candidate(arr = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91],k = 8) == [100, 99, 98, 97, 96, 95, 94, 93]\n assert candidate(arr = [-5, -3, -1, 1, 3, 5, -4, -2, 0, 2, 4, 6],k = 5) == [6, 5, -5, 4, -4]\n assert candidate(arr = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],k = 7) == [10000, 9000, 1000, 8000, 2000, 7000, 3000]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(arr = [-10, -5, 0, 5, 10, 15],k = 3) == [15, 10, -10]\n assert candidate(arr = [1, 3, 2, 4, 6, 5, 7, 8, 10, 9, 11],k = 8) == [11, 1, 10, 2, 9, 3, 8, 4]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == [100, 90, 10, 80, 20]\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 6) == [100, 90, 10, 80, 20, 70]\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 8) == [29, 1, 27, 3, 25, 5, 23, 7]\n assert candidate(arr = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],k = 3) == [1000, 900, 100]\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],k = 10) == [1000, 900, 800, -1000, 700, -900, 600, -800, 500, -700]\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5) == [1000, 900, 100, 800, 200]\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9],k = 10) == [9, -9, 8, -8, 7, -7, 6, -6, 5, -5]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130],k = 8) == [130, 10, 120, 20, 110, 30, 100, 40]\n assert candidate(arr = [1000, -1000, 500, -500, 250, -250, 750, -750, 375, -375],k = 5) == [1000, 750, 500, -1000, 375]\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == [5, 5, 5, 5, 5]\n assert candidate(arr = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000],k = 6) == [13000, 1000, 12000, 2000, 11000, 3000]\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == [5, 5, 5]\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(arr = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 5) == [100000, 99999, 99991, 99998, 99992]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 6) == [19, 17, 1, 15, 3, 13]\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],k = 8) == [99, 98, 90, 97, 91, 96, 92, 95]\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 8) == [1, 2, 2, 5, 5, 5, 5, 5]\n assert candidate(arr = [100000, -100000, 50000, -50000, 25000, -25000, 12500, -12500, 6250, -6250],k = 7) == [100000, -100000, 50000, -50000, 25000, 12500, -25000]\n assert candidate(arr = [-10, -20, 15, 10, 0, 5, -5],k = 4) == [-20, 15, 10, -10]\n assert candidate(arr = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5],k = 4) == [5, 4, 3, -5]\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],k = 9) == [5, 5, 5, 1, 1, 1, 4, 4, 4]\n assert candidate(arr = [-1000, -2000, -3000, -4000, -5000, -6000, -7000, -8000, -9000, -10000, -11000, -12000, -13000],k = 7) == [-1000, -13000, -2000, -12000, -3000, -11000, -4000]\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(arr = [1, 10, 100, 1000, 10000, 100000, -1, -10, -100, -1000, -10000, -100000],k = 6) == [100000, -100000, 10000, -10000, 1000, -1000]\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6) == [10, 9, 1, 8, 2, 7]\n assert candidate(arr = [-500, -300, -100, 100, 300, 500, 700, 900, 1100, 1300],k = 8) == [1300, 1100, -500, 900, -300, 700, -100, 500]\n assert candidate(arr = [-5, -5, -5, -5, -5, 5, 5, 5, 5, 5],k = 8) == [5, 5, 5, 5, 5, -5, -5, -5]\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 7) == [-1, -2, -10, -3, -9, -4, -8]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == [20, 19, 1, 18, 2, 17, 3, 16, 4, 15]\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == [19, 17, 1, 15, 3]\n assert candidate(arr = [23, 45, 12, 67, 34, 89, 90, 21, 56, 78, 9, 34, 56, 78, 90],k = 10) == [9, 12, 21, 90, 90, 89, 23, 78, 78, 34]\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 7) == [1000, 900, 100, 800, 200, 700, 300]\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == [5, 5, 5, 5]\n assert candidate(arr = [-10, -5, 0, 5, 10, 15, 20, 25, 30],k = 5) == [30, -10, 25, -5, 20]\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [0, 0, 0, 0, 0]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == [15, 1, 14, 2, 13, 3, 12]\n assert candidate(arr = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],k = 8) == [39, 37, 1, 35, 3, 33, 5, 31]\n assert candidate(arr = [9, 3, 7, -1, 2, 5, 8, -4, 6],k = 5) == [-4, -1, 9, 8, 2]\n assert candidate(arr = [-100, 100, -50, 50, 0],k = 3) == [100, -100, 50]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 10) == [150, 10, 140, 20, 130, 30, 120, 40, 110, 50]\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 7) == [29, 1, 27, 3, 25, 5, 23]\n assert candidate(arr = [-20, -15, -10, -5, 0, 5, 10, 15, 20, 25, 30, 35, 40],k = 6) == [40, -20, 35, -15, 30, -10]\n assert candidate(arr = [-50, -40, -30, -20, -10, 10, 20, 30, 40, 50],k = 6) == [50, 40, 30, -50, 20, -40]\n assert candidate(arr = [10, -20, 30, -40, 50, -60, 70],k = 5) == [-60, 70, -40, 50, -20]\n assert candidate(arr = [-1, -2, -3, -4, -5, 5, 4, 3, 2, 1],k = 5) == [5, 4, 3, -5, 2]\n assert candidate(arr = [5, 3, 1, 2, 4, 6, 8, 7, 9, 10],k = 4) == [10, 9, 1, 8]\n assert candidate(arr = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5],k = 6) == [5, 4, 3, -5, 2, -4]\n assert candidate(arr = [100000, -100000, 99999, -99999, 0, 1, -1],k = 4) == [100000, -100000, 99999, -99999]\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 4) == [1000, 900, 100, 800]\n assert candidate(arr = [-29, -27, -25, -23, -21, -19, -17, -15, -13, -11, -9, -7, -5, -3, -1],k = 5) == [-1, -29, -3, -27, -5]\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10) == [15, 1, 14, 2, 13, 3, 12, 4, 11, 5]\n assert candidate(arr = [-100, 0, 50, 100, 200],k = 3) == [200, -100, 100]\n assert candidate(arr = [-1, 0, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10],k = 10) == [10, -10, 9, -9, 8, -8, 7, -7, 6, -6]\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7) == [150, 10, 140, 20, 130, 30, 120]\n assert candidate(arr = [-100000, 100000, 0, 50000, -50000],k = 3) == [100000, -100000, 50000]\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [0, 0, 0, 0, 0]\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 12) == [1500, 100, 1400, 200, 1300, 300, 1200, 400, 1100, 500, 1000, 600]\n assert candidate(arr = [-10, -20, -30, 0, 10, 20, 30, 40, 50, 60],k = 4) == [60, 50, -30, 40]\n assert candidate(arr = [10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 30, 30, 30, 30, 30, 40, 40, 40, 40, 40],k = 15) == [40, 40, 40, 40, 40, 30, 30, 30, 30, 30, 10, 10, 10, 10, 10]\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 10) == [29, 1, 27, 3, 25, 5, 23, 7, 21, 9]\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 15) == [39, 37, 1, 35, 3, 33, 5, 31, 7, 29, 9, 27, 11, 25, 13]\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 7) == [9, 8, -10, 7, -9, 6, -8]\n"}, "metadata": {"canonical_parameter_names": ["arr", "k"], "leetcode_dataset_entry_point": "Solution().getStrongest", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector getStrongest(vector& arr, int k) {", "container": "Solution", "callable": "getStrongest", "parameters": [{"name": "arr", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1473, "task_id": "paint-house-iii", "difficulty": "Hard", "problem_description": "There is a row of m houses in a small city, each house must be painted with one of the n colors (labeled from 1 to n), some houses that have been painted last summer should not be painted again.\nA neighborhood is a maximal group of continuous houses that are painted with the same color.\n\nFor example: houses = [1,2,2,3,3,2,1,1] contains 5 neighborhoods [{1}, {2,2}, {3,3}, {2}, {1,1}].\n\nGiven an array houses, an m x n matrix cost and an integer target where:\n\nhouses[i]: is the color of the house i, and 0 if the house is not painted yet.\ncost[i][j]: is the cost of paint the house i with the color j + 1.\n\nReturn the minimum cost of painting all the remaining houses in such a way that there are exactly target neighborhoods. If it is not possible, return -1.\n \nExample 1:\n\nInput: houses = [0,0,0,0,0], cost = [[1,10],[10,1],[10,1],[1,10],[5,1]], m = 5, n = 2, target = 3\nOutput: 9\nExplanation: Paint houses of this way [1,2,2,1,1]\nThis array contains target = 3 neighborhoods, [{1}, {2,2}, {1,1}].\nCost of paint all houses (1 + 1 + 1 + 1 + 5) = 9.\n\nExample 2:\n\nInput: houses = [0,2,1,2,0], cost = [[1,10],[10,1],[10,1],[1,10],[5,1]], m = 5, n = 2, target = 3\nOutput: 11\nExplanation: Some houses are already painted, Paint the houses of this way [2,2,1,2,2]\nThis array contains target = 3 neighborhoods, [{2,2}, {1}, {2,2}]. \nCost of paint the first and last house (10 + 1) = 11.\n\nExample 3:\n\nInput: houses = [3,1,2,3], cost = [[1,1,1],[1,1,1],[1,1,1],[1,1,1]], m = 4, n = 3, target = 3\nOutput: -1\nExplanation: Houses are already painted with a total of 4 neighborhoods [{3},{1},{2},{3}] different of target = 3.\n\n \nConstraints:\n\nm == houses.length == cost.length\nn == cost[i].length\n1 <= m <= 100\n1 <= n <= 20\n1 <= target <= m\n0 <= houses[i] <= n\n1 <= cost[i][j] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(houses = [1, 0, 0, 0, 0],cost = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],m = 5,n = 2,target = 2) == 15\n assert candidate(houses = [0, 0, 0, 0, 0],cost = [[10, 20, 30, 40], [20, 30, 40, 50], [30, 40, 50, 60], [40, 50, 60, 70], [50, 60, 70, 80]],m = 5,n = 4,target = 3) == 160\n assert candidate(houses = [1, 2, 3, 4, 5],cost = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]],m = 5,n = 5,target = 5) == 0\n assert candidate(houses = [3, 1, 2, 3],cost = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],m = 4,n = 3,target = 3) == -1\n assert candidate(houses = [1, 0, 1, 0, 0],cost = [[1, 2], [3, 4], [1, 2], [3, 4], [1, 2]],m = 5,n = 2,target = 2) == 8\n assert candidate(houses = [0, 2, 1, 2, 0],cost = [[1, 10], [10, 1], [10, 1], [1, 10], [5, 1]],m = 5,n = 2,target = 3) == 11\n assert candidate(houses = [0, 1, 0, 0, 0],cost = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2]],m = 5,n = 2,target = 2) == 5\n assert candidate(houses = [0, 0, 0, 0, 0],cost = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],m = 5,n = 3,target = 2) == 36\n assert candidate(houses = [0, 0, 0, 0, 0, 0],cost = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],m = 6,n = 2,target = 1) == 6\n assert candidate(houses = [1, 0, 2, 0, 3],cost = [[5, 8, 6], [19, 14, 13], [7, 5, 5], [3, 6, 14], [2, 11, 1]],m = 5,n = 3,target = 3) == 20\n assert candidate(houses = [1, 0, 3, 0, 2],cost = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],m = 5,n = 3,target = 3) == 2\n assert candidate(houses = [0, 0, 0, 0, 0],cost = [[1, 10], [10, 1], [10, 1], [1, 10], [5, 1]],m = 5,n = 2,target = 3) == 9\n assert candidate(houses = [0, 0, 0],cost = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],m = 3,n = 3,target = 2) == 13\n assert candidate(houses = [0, 0, 0, 0, 0],cost = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8]],m = 5,n = 4,target = 2) == 16\n assert candidate(houses = [0, 2, 0, 0, 0, 1, 0, 0, 0, 0],cost = [[10, 20, 30], [20, 30, 10], [30, 10, 20], [10, 20, 30], [20, 30, 10], [30, 10, 20], [10, 20, 30], [20, 30, 10], [30, 10, 20], [10, 20, 30]],m = 10,n = 3,target = 5) == 100\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0],cost = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],m = 7,n = 5,target = 7) == 7\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 4, 7, 2, 8, 6], [5, 9, 1, 3, 4, 7], [9, 3, 5, 6, 2, 8], [8, 6, 9, 1, 7, 4], [7, 5, 8, 9, 3, 2], [6, 8, 4, 5, 9, 1], [3, 7, 9, 8, 6, 5], [2, 9, 6, 7, 4, 8], [8, 1, 4, 2, 9, 6], [6, 2, 8, 3, 1, 9]],m = 10,n = 6,target = 5) == 22\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 2, 3], [4, 5, 6]],m = 8,n = 3,target = 4) == 31\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[2, 5, 1], [1, 2, 5], [5, 1, 2], [2, 5, 1], [1, 2, 5], [5, 1, 2], [2, 5, 1], [1, 2, 5], [5, 1, 2], [2, 5, 1], [1, 2, 5]],m = 11,n = 3,target = 5) == 19\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[5, 4, 3, 2, 1], [1, 2, 3, 4, 5], [5, 5, 5, 5, 5], [1, 1, 1, 1, 1], [10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [2, 4, 6, 8, 10], [10, 8, 6, 4, 2], [1, 1, 1, 1, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [3, 6, 9, 12, 15], [15, 12, 9, 6, 3], [3, 2, 1, 4, 5], [5, 4, 3, 2, 1]],m = 15,n = 5,target = 7) == 53\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0],cost = [[1, 4, 3], [3, 2, 1], [2, 1, 4], [1, 3, 2], [4, 3, 1], [2, 1, 3], [3, 2, 4]],m = 7,n = 3,target = 4) == 10\n assert candidate(houses = [1, 0, 0, 2, 0, 0, 0, 0, 0, 3],cost = [[1, 2, 3], [2, 3, 1], [3, 1, 2], [1, 2, 3], [2, 3, 1], [3, 1, 2], [1, 2, 3], [2, 3, 1], [3, 1, 2], [1, 2, 3]],m = 10,n = 3,target = 6) == 9\n assert candidate(houses = [0, 3, 0, 1, 0, 2, 0, 0],cost = [[1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3]],m = 8,n = 4,target = 5) == 6\n assert candidate(houses = [0, 0, 1, 0, 0, 0, 0, 0],cost = [[1, 9, 3, 5], [3, 4, 1, 10], [7, 8, 4, 5], [3, 2, 8, 5], [2, 6, 3, 7], [7, 1, 8, 3], [4, 2, 1, 4], [1, 4, 3, 9]],m = 8,n = 4,target = 5) == 11\n assert candidate(houses = [0, 2, 0, 2, 0, 2],cost = [[10, 20, 30, 40], [20, 30, 10, 40], [30, 10, 20, 40], [10, 40, 20, 30], [20, 30, 40, 10], [30, 40, 10, 20]],m = 6,n = 4,target = 3) == 40\n assert candidate(houses = [1, 0, 0, 0, 0, 0, 0, 0, 0, 2],cost = [[10, 20, 30, 40], [1, 2, 3, 4], [10, 20, 30, 40], [1, 2, 3, 4], [10, 20, 30, 40], [1, 2, 3, 4], [10, 20, 30, 40], [1, 2, 3, 4], [10, 20, 30, 40], [1, 2, 3, 4]],m = 10,n = 4,target = 4) == 45\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]],m = 10,n = 10,target = 5) == 57\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],m = 11,n = 11,target = 3) == 11\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[5, 3, 2, 1, 4], [3, 2, 1, 4, 5], [2, 1, 4, 5, 3], [1, 4, 5, 3, 2], [4, 5, 3, 2, 1], [5, 4, 3, 2, 1], [4, 3, 2, 1, 5], [3, 2, 1, 5, 4], [2, 1, 5, 4, 3], [1, 5, 4, 3, 2]],m = 10,n = 5,target = 4) == 16\n assert candidate(houses = [0, 2, 0, 2, 0, 2, 0, 2, 0, 2],cost = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8], [6, 7, 8, 9], [7, 8, 9, 10], [8, 9, 10, 11], [9, 10, 11, 12], [10, 11, 12, 13]],m = 10,n = 4,target = 5) == 28\n assert candidate(houses = [0, 2, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[10, 10, 10], [1, 2, 3], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10]],m = 10,n = 3,target = 3) == 90\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2]],m = 15,n = 2,target = 7) == 19\n assert candidate(houses = [0, 0, 0, 2, 0, 0, 0, 0],cost = [[4, 3, 1, 2], [9, 1, 4, 8], [5, 7, 9, 6], [1, 1, 5, 2], [8, 5, 3, 3], [4, 6, 1, 9], [2, 3, 7, 7], [7, 4, 8, 5]],m = 8,n = 4,target = 4) == 20\n assert candidate(houses = [0, 0, 0, 1, 0, 0, 0],cost = [[2, 3, 1], [3, 1, 2], [1, 2, 3], [2, 3, 1], [3, 1, 2], [1, 2, 3], [2, 3, 1]],m = 7,n = 3,target = 4) == 8\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0],cost = [[10, 15], [15, 10], [20, 25], [25, 20], [30, 35], [35, 30], [40, 45], [45, 40]],m = 8,n = 2,target = 6) == 205\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0],cost = [[4, 8, 2], [1, 10, 9], [6, 4, 8], [10, 2, 9], [3, 7, 5], [8, 3, 2], [1, 6, 5], [2, 4, 3]],m = 8,n = 3,target = 3) == 24\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0],cost = [[7, 5, 9], [9, 7, 5], [5, 9, 7], [7, 5, 9], [9, 7, 5], [5, 9, 7], [7, 5, 9], [9, 7, 5]],m = 8,n = 3,target = 5) == 46\n assert candidate(houses = [0, 3, 0, 2, 0, 1, 0, 0],cost = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],m = 8,n = 4,target = 4) == 5\n assert candidate(houses = [2, 0, 2, 0, 2, 0, 2, 0],cost = [[1, 2, 3], [3, 2, 1], [2, 1, 3], [1, 3, 2], [3, 2, 1], [2, 1, 3], [1, 3, 2], [3, 2, 1]],m = 8,n = 3,target = 3) == 6\n assert candidate(houses = [0, 0, 2, 1, 0, 0, 3],cost = [[10, 8, 6, 4, 2], [9, 7, 5, 3, 1], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [5, 10, 15, 20, 25], [100, 90, 80, 70, 60], [30, 25, 20, 15, 10]],m = 7,n = 5,target = 4) == 80\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0],cost = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9]],m = 7,n = 3,target = 4) == 30\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0],cost = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8], [6, 7, 8, 9], [7, 8, 9, 10]],m = 7,n = 4,target = 4) == 30\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1]],m = 20,n = 2,target = 10) == 25\n assert candidate(houses = [0, 0, 1, 0, 0, 0],cost = [[1, 2, 3], [2, 3, 1], [3, 1, 2], [1, 2, 3], [2, 3, 1], [3, 1, 2]],m = 6,n = 3,target = 4) == 6\n assert candidate(houses = [0, 2, 0, 2, 0, 2, 0, 2, 0, 2],cost = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9]],m = 10,n = 2,target = 5) == 28\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1]],m = 10,n = 2,target = 5) == 13\n assert candidate(houses = [0, 0, 0, 1, 0, 0, 0, 0],cost = [[1, 2, 3, 4], [4, 3, 2, 1], [1, 4, 2, 3], [3, 2, 4, 1], [1, 2, 3, 4], [4, 3, 2, 1], [1, 4, 2, 3], [3, 2, 4, 1]],m = 8,n = 4,target = 5) == 9\n assert candidate(houses = [0, 0, 3, 0, 0, 0, 0],cost = [[1, 3, 2], [3, 1, 4], [1, 2, 3], [3, 2, 1], [1, 3, 2], [3, 2, 1], [1, 2, 3]],m = 7,n = 3,target = 3) == 9\n assert candidate(houses = [2, 0, 2, 0, 2, 0, 2, 0, 2, 0],cost = [[100, 100, 100], [50, 50, 50], [100, 100, 100], [50, 50, 50], [100, 100, 100], [50, 50, 50], [100, 100, 100], [50, 50, 50], [100, 100, 100], [50, 50, 50]],m = 10,n = 3,target = 5) == 250\n assert candidate(houses = [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]],m = 11,n = 10,target = 6) == 66\n assert candidate(houses = [1, 0, 2, 0, 3, 0, 4, 0],cost = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]],m = 8,n = 5,target = 4) == 10\n assert candidate(houses = [0, 1, 0, 2, 0, 0, 0],cost = [[1, 10, 100, 1000], [10, 100, 1000, 10000], [100, 1000, 10000, 100000], [1000, 10000, 100000, 1000000], [10, 100, 1000, 10000], [100, 1000, 10000, 100000], [1000, 10000, 100000, 1000000]],m = 7,n = 4,target = 3) == 1211\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],m = 20,n = 2,target = 10) == 20\n assert candidate(houses = [0, 1, 2, 0, 0, 0, 0],cost = [[1, 2, 3], [2, 3, 1], [3, 1, 2], [4, 5, 6], [5, 6, 4], [6, 4, 5], [7, 8, 9]],m = 7,n = 3,target = 5) == 21\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[3, 2, 1, 8, 9], [7, 8, 6, 4, 5], [2, 4, 3, 1, 8], [9, 1, 5, 7, 3], [4, 9, 2, 3, 7], [5, 3, 8, 1, 4], [1, 7, 2, 8, 6], [8, 6, 4, 9, 2], [3, 1, 7, 2, 5]],m = 9,n = 5,target = 4) == 24\n assert candidate(houses = [1, 0, 2, 0, 3, 0, 1, 0, 2],cost = [[10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10]],m = 9,n = 3,target = 6) == 40\n assert candidate(houses = [0, 1, 2, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 1], [3, 4, 1, 2], [4, 1, 2, 3]],m = 20,n = 4,target = 12) == 23\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],m = 10,n = 3,target = 10) == 10\n assert candidate(houses = [0, 2, 0, 0, 0, 2, 0],cost = [[5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5]],m = 7,n = 3,target = 3) == 25\n assert candidate(houses = [0, 0, 0, 1, 0, 0, 0, 0, 0],cost = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6, 6, 6, 6], [7, 7, 7, 7, 7, 7, 7, 7, 7], [8, 8, 8, 8, 8, 8, 8, 8, 8], [9, 9, 9, 9, 9, 9, 9, 9, 9]],m = 9,n = 9,target = 6) == 41\n assert candidate(houses = [1, 0, 1, 0, 1, 0, 1],cost = [[10, 20, 30], [30, 10, 20], [20, 30, 10], [10, 20, 30], [30, 10, 20], [20, 30, 10], [10, 20, 30]],m = 7,n = 3,target = 3) == 40\n assert candidate(houses = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],cost = [[1, 10], [10, 1], [1, 10], [10, 1], [1, 10], [10, 1], [1, 10], [10, 1], [1, 10], [10, 1]],m = 10,n = 2,target = 5) == 32\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 11], [10, 11, 12]],m = 10,n = 3,target = 5) == 57\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1]],m = 10,n = 2,target = 5) == 13\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],m = 15,n = 2,target = 8) == 15\n assert candidate(houses = [0, 2, 0, 1, 0, 3, 0],cost = [[1, 2, 3, 4], [4, 3, 2, 1], [2, 1, 4, 3], [3, 4, 1, 2], [1, 4, 3, 2], [2, 3, 4, 1], [4, 1, 2, 3]],m = 7,n = 4,target = 5) == 4\n assert candidate(houses = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],cost = [[7, 2, 1, 9, 5, 6, 3, 8], [8, 7, 6, 3, 9, 1, 5, 4], [2, 1, 8, 7, 6, 9, 4, 3], [5, 6, 7, 8, 2, 1, 9, 4], [9, 4, 5, 6, 7, 8, 2, 1], [3, 9, 4, 5, 6, 7, 8, 2], [1, 3, 9, 4, 5, 6, 7, 8], [6, 1, 3, 9, 4, 5, 6, 7], [7, 6, 1, 3, 9, 4, 5, 6], [8, 7, 6, 1, 3, 9, 4, 5], [5, 8, 7, 6, 1, 3, 9, 4]],m = 11,n = 8,target = 6) == 21\n"}, "metadata": {"canonical_parameter_names": ["houses", "cost", "m", "n", "target"], "leetcode_dataset_entry_point": "Solution().minCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minCost(vector& houses, vector>& cost, int m, int n, int target) {", "container": "Solution", "callable": "minCost", "parameters": [{"name": "houses", "type": "vector&"}, {"name": "cost", "type": "vector>&"}, {"name": "m", "type": "int"}, {"name": "n", "type": "int"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1475, "task_id": "final-prices-with-a-special-discount-in-a-shop", "difficulty": "Easy", "problem_description": "You are given an integer array prices where prices[i] is the price of the ith item in a shop.\nThere is a special discount for items in the shop. If you buy the ith item, then you will receive a discount equivalent to prices[j] where j is the minimum index such that j > i and prices[j] <= prices[i]. Otherwise, you will not receive any discount at all.\nReturn an integer array answer where answer[i] is the final price you will pay for the ith item of the shop, considering the special discount.\n \nExample 1:\n\nInput: prices = [8,4,6,2,3]\nOutput: [4,2,4,2,3]\nExplanation: \nFor item 0 with price[0]=8 you will receive a discount equivalent to prices[1]=4, therefore, the final price you will pay is 8 - 4 = 4.\nFor item 1 with price[1]=4 you will receive a discount equivalent to prices[3]=2, therefore, the final price you will pay is 4 - 2 = 2.\nFor item 2 with price[2]=6 you will receive a discount equivalent to prices[3]=2, therefore, the final price you will pay is 6 - 2 = 4.\nFor items 3 and 4 you will not receive any discount at all.\n\nExample 2:\n\nInput: prices = [1,2,3,4,5]\nOutput: [1,2,3,4,5]\nExplanation: In this case, for all items, you will not receive any discount at all.\n\nExample 3:\n\nInput: prices = [10,1,1,6]\nOutput: [9,0,1,6]\n\n \nConstraints:\n\n1 <= prices.length <= 500\n1 <= prices[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(prices = [5, 5, 5, 5, 5]) == [0, 0, 0, 0, 5]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [8, 4, 6, 2, 3]) == [4, 2, 4, 2, 3]\n assert candidate(prices = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(prices = [9, 8, 7, 6, 5]) == [1, 1, 1, 1, 5]\n assert candidate(prices = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(prices = [1, 3, 5, 7, 9, 11, 13, 15, 17]) == [1, 3, 5, 7, 9, 11, 13, 15, 17]\n assert candidate(prices = [60, 70, 80, 90, 100]) == [60, 70, 80, 90, 100]\n assert candidate(prices = [10, 10, 10, 10, 10, 10]) == [0, 0, 0, 0, 0, 10]\n assert candidate(prices = [5, 1, 4, 2, 3]) == [4, 1, 2, 2, 3]\n assert candidate(prices = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(prices = [100, 50, 25, 12, 6, 3, 1]) == [50, 25, 13, 6, 3, 2, 1]\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(prices = [10, 1, 1, 6]) == [9, 0, 1, 6]\n assert candidate(prices = [1, 2, 3, 2, 1]) == [0, 0, 1, 1, 1]\n assert candidate(prices = [5, 1, 3, 4, 6, 2]) == [4, 1, 1, 2, 4, 2]\n assert candidate(prices = [3, 3, 3, 2, 2, 1]) == [0, 0, 1, 0, 1, 1]\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [100, 90, 80, 70, 60]) == [10, 10, 10, 10, 60]\n assert candidate(prices = [100, 200, 300, 200, 100]) == [0, 0, 100, 100, 100]\n assert candidate(prices = [1, 1, 1, 1, 1]) == [0, 0, 0, 0, 1]\n assert candidate(prices = [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]\n assert candidate(prices = [2, 3, 1]) == [1, 2, 1]\n assert candidate(prices = [100, 50, 50, 100, 50, 25, 25, 100]) == [50, 0, 0, 50, 25, 0, 25, 100]\n assert candidate(prices = [10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5, 10]) == [5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 5, 10]\n assert candidate(prices = [100, 50, 25, 12, 6, 3, 1, 0, 0, 0]) == [50, 25, 13, 6, 3, 2, 1, 0, 0, 0]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5]\n assert candidate(prices = [1, 2, 3, 2, 3, 4, 5, 4, 5, 6]) == [1, 0, 1, 2, 3, 0, 1, 4, 5, 6]\n assert candidate(prices = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 2]\n assert candidate(prices = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]\n assert candidate(prices = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 10]\n assert candidate(prices = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == [1, 98, 2, 96, 3, 94, 4, 92, 5, 96]\n assert candidate(prices = [10, 10, 10, 10, 10, 10, 10, 10]) == [0, 0, 0, 0, 0, 0, 0, 10]\n assert candidate(prices = [10, 5, 15, 5, 20, 10, 25, 15, 30, 20]) == [5, 0, 10, 5, 10, 10, 10, 15, 10, 20]\n assert candidate(prices = [7, 6, 5, 4, 3, 2, 1, 2, 3, 4]) == [1, 1, 1, 1, 1, 1, 1, 2, 3, 4]\n assert candidate(prices = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == [0, 9, 0, 9, 0, 9, 0, 9, 1, 10]\n assert candidate(prices = [7, 5, 6, 4, 3, 2, 1, 8, 9, 10]) == [2, 1, 2, 1, 1, 1, 1, 8, 9, 10]\n assert candidate(prices = [2, 3, 3, 2, 1, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1]) == [0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1]\n assert candidate(prices = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [0, 1, 2, 3, 4, 1, 2, 3, 4, 5]\n assert candidate(prices = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == [0, 8, 1, 6, 2, 4, 3, 2, 4, 5, 1, 8, 2, 6, 3, 4, 4, 2, 5, 6]\n assert candidate(prices = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1000]\n assert candidate(prices = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]\n assert candidate(prices = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == [0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5]\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]\n assert candidate(prices = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == [500, 250, 125, 63, 31, 16, 8, 4, 2, 1]\n assert candidate(prices = [10, 20, 30, 40, 50, 40, 30, 20, 10]) == [0, 0, 0, 0, 10, 10, 10, 10, 10]\n assert candidate(prices = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == [0, 10, 0, 10, 0, 10, 0, 10, 10, 20]\n assert candidate(prices = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == [0, 0, 1, 1, 0, 0, 1, 1, 1]\n assert candidate(prices = [30, 20, 10, 10, 20, 30, 40, 50, 40, 30, 20, 10]) == [10, 10, 0, 0, 0, 0, 0, 10, 10, 10, 10, 10]\n assert candidate(prices = [5, 4, 3, 2, 1, 2, 3, 4, 5]) == [1, 1, 1, 1, 1, 2, 3, 4, 5]\n assert candidate(prices = [8, 6, 7, 6, 5, 4, 3, 2, 1]) == [2, 0, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(prices = [300, 200, 100, 50, 25, 12, 6, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [100, 100, 50, 25, 13, 6, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(prices = [8, 4, 6, 2, 3, 8, 4, 6, 2, 3]) == [4, 2, 4, 0, 1, 4, 2, 4, 2, 3]\n assert candidate(prices = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == [0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 1, 10]\n assert candidate(prices = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7]) == [1, 1, 2, 1, 3, 1, 4, 1, 5, 7]\n assert candidate(prices = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]\n assert candidate(prices = [15, 10, 5, 10, 15, 5, 10, 15, 20, 10]) == [5, 5, 0, 5, 10, 5, 0, 5, 10, 10]\n assert candidate(prices = [10, 20, 30, 10, 20, 30, 10, 20, 30]) == [0, 10, 20, 0, 10, 20, 10, 20, 30]\n assert candidate(prices = [3, 6, 5, 1, 8, 7, 9, 2, 4, 10]) == [2, 1, 4, 1, 1, 5, 7, 2, 4, 10]\n assert candidate(prices = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == [0, 1, 0, 1, 0, 1, 0, 1, 2, 3]\n assert candidate(prices = [8, 5, 7, 6, 4, 5, 3, 2, 1]) == [3, 1, 1, 2, 1, 2, 1, 1, 1]\n assert candidate(prices = [100, 50, 25, 12, 6, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [50, 25, 13, 6, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(prices = [50, 20, 30, 10, 20, 30, 40, 50, 60, 70]) == [30, 10, 20, 10, 20, 30, 40, 50, 60, 70]\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -5]\n assert candidate(prices = [500, 100, 200, 300, 400, 500, 600, 700, 800, 900]) == [400, 100, 200, 300, 400, 500, 600, 700, 800, 900]\n assert candidate(prices = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5]) == [99, 1, 198, 2, 297, 3, 396, 4, 495, 5]\n assert candidate(prices = [999, 1000, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == [1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 980]\n assert candidate(prices = [100, 200, 150, 250, 300, 220, 180, 160, 170]) == [100, 50, 150, 30, 80, 40, 20, 160, 170]\n assert candidate(prices = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(prices = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(prices = [5, 10, 15, 20, 15, 10, 5, 10, 15, 20, 15, 10, 5]) == [0, 0, 0, 5, 5, 5, 0, 0, 0, 5, 5, 5, 5]\n assert candidate(prices = [3, 3, 3, 3, 1, 1, 1, 1, 5, 5, 5, 5]) == [0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 5]\n assert candidate(prices = [5, 15, 25, 10, 20, 5, 30, 25, 40, 10]) == [0, 5, 15, 5, 15, 5, 5, 15, 30, 10]\n assert candidate(prices = [5, 5, 5, 5, 5, 5, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 1]\n assert candidate(prices = [8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5]\n assert candidate(prices = [1000, 1000, 1000, 1000, 1000]) == [0, 0, 0, 0, 1000]\n assert candidate(prices = [5, 1, 4, 3, 2, 6, 7, 8, 10, 9]) == [4, 1, 1, 1, 2, 6, 7, 8, 1, 9]\n assert candidate(prices = [8, 4, 6, 2, 3, 5, 7, 1, 9, 10]) == [4, 2, 4, 1, 2, 4, 6, 1, 9, 10]\n assert candidate(prices = [500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1]) == [100, 100, 100, 100, 50, 25, 13, 6, 3, 2, 1]\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(prices = [250, 200, 150, 100, 50, 100, 150, 200, 250, 300]) == [50, 50, 50, 50, 50, 100, 150, 200, 250, 300]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 6]\n assert candidate(prices = [1, 10, 1, 10, 1, 10, 1, 10]) == [0, 9, 0, 9, 0, 9, 1, 10]\n assert candidate(prices = [30, 25, 20, 15, 10, 5, 10, 15, 20, 25]) == [5, 5, 5, 5, 5, 5, 10, 15, 20, 25]\n assert candidate(prices = [4, 3, 2, 1, 2, 3, 4, 5, 6, 7]) == [1, 1, 1, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(prices = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == [1, 1, 1, 1, 0, 1, 2, 3, 4, 5]\n assert candidate(prices = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1]\n assert candidate(prices = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 50]\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 1, 0, 0, 0, 0, 1]\n assert candidate(prices = [5, 10, 5, 10, 5, 10, 5, 10, 5, 10]) == [0, 5, 0, 5, 0, 5, 0, 5, 5, 10]\n assert candidate(prices = [7, 6, 5, 4, 3, 2, 1, 0, 0, 0]) == [1, 1, 1, 1, 1, 1, 1, 0, 0, 0]\n assert candidate(prices = [1, 2, 2, 1, 1, 2, 2, 1, 1]) == [0, 0, 1, 0, 0, 0, 1, 0, 1]\n assert candidate(prices = [100, 50, 25, 200, 100, 50, 25, 200]) == [50, 25, 0, 100, 50, 25, 25, 200]\n assert candidate(prices = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]) == [1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8]\n assert candidate(prices = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 2, 3]\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 10]\n assert candidate(prices = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(prices = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == [0, 9, 0, 9, 0, 9, 0, 9, 1, 10]\n assert candidate(prices = [3, 2, 3, 2, 3, 2, 3, 2, 3, 2]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 2]\n assert candidate(prices = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(prices = [1, 3, 2, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == [0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [10, 20, 30, 40, 50, 40, 30, 20, 10, 5]) == [0, 0, 0, 0, 10, 10, 10, 10, 5, 5]\n assert candidate(prices = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10]\n assert candidate(prices = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5]\n assert candidate(prices = [50, 40, 30, 20, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == [10, 10, 10, 10, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]\n assert candidate(prices = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == [4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4]\n assert candidate(prices = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(prices = [50, 25, 75, 100, 50, 75, 100, 125]) == [25, 25, 25, 50, 50, 75, 100, 125]\n assert candidate(prices = [100, 200, 300, 400, 500, 400, 300, 200, 100]) == [0, 0, 0, 0, 100, 100, 100, 100, 100]\n"}, "metadata": {"canonical_parameter_names": ["prices"], "leetcode_dataset_entry_point": "Solution().finalPrices", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector finalPrices(vector& prices) {", "container": "Solution", "callable": "finalPrices", "parameters": [{"name": "prices", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1477, "task_id": "find-two-non-overlapping-sub-arrays-each-with-target-sum", "difficulty": "Medium", "problem_description": "You are given an array of integers arr and an integer target.\nYou have to find two non-overlapping sub-arrays of arr each with a sum equal target. There can be multiple answers so you have to find an answer where the sum of the lengths of the two sub-arrays is minimum.\nReturn the minimum sum of the lengths of the two required sub-arrays, or return -1 if you cannot find such two sub-arrays.\n \nExample 1:\n\nInput: arr = [3,2,2,4,3], target = 3\nOutput: 2\nExplanation: Only two sub-arrays have sum = 3 ([3] and [3]). The sum of their lengths is 2.\n\nExample 2:\n\nInput: arr = [7,3,4,7], target = 7\nOutput: 2\nExplanation: Although we have three non-overlapping sub-arrays of sum = 7 ([7], [3,4] and [7]), but we will choose the first and third sub-arrays as the sum of their lengths is 2.\n\nExample 3:\n\nInput: arr = [4,3,2,6,2,3,4], target = 6\nOutput: -1\nExplanation: We have only one sub-array of sum = 6.\n\n \nConstraints:\n\n1 <= arr.length <= 105\n1 <= arr[i] <= 1000\n1 <= target <= 108\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [5, 5, 5, 5, 5],target = 10) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 5\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = 6) == 6\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3],target = 6) == 5\n assert candidate(arr = [1, 2, 3, 4, 5],target = 9) == -1\n assert candidate(arr = [3, 2, 2, 4, 3],target = 3) == 2\n assert candidate(arr = [5, 5, 4, 4, 5],target = 9) == 4\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = 4) == 4\n assert candidate(arr = [1000, 1000, 1000],target = 2000) == -1\n assert candidate(arr = [7, 3, 4, 7],target = 7) == 2\n assert candidate(arr = [1000, 1000, 1000, 1000, 1000],target = 2000) == 4\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3],target = 3) == 2\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],target = 3) == 4\n assert candidate(arr = [1000, 1000, 1000, 1000, 1000],target = 5000) == -1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1],target = 2) == 4\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5],target = 15) == 6\n assert candidate(arr = [1, 2, 3, 4, 5],target = 10) == -1\n assert candidate(arr = [10, 20, 30, 40, 50],target = 60) == -1\n assert candidate(arr = [1, 4, 4, 4, 4, 4, 4, 4, 4, 1],target = 8) == 4\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 15) == 6\n assert candidate(arr = [4, 3, 2, 6, 2, 3, 4],target = 6) == -1\n assert candidate(arr = [10, 20, 30, 40, 50],target = 90) == -1\n assert candidate(arr = [999, 1, 999, 1, 999, 1, 999, 1, 999, 1],target = 1000) == 4\n assert candidate(arr = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25],target = 50) == 4\n assert candidate(arr = [3, 1, 2, 4, 3, 2, 1, 3, 4, 2, 1, 3, 5, 2, 1, 3, 4, 2, 1, 3],target = 6) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],target = 30) == 4\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 15) == 3\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],target = 500) == -1\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],target = 300) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],target = 100) == 13\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 20) == 8\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 20) == -1\n assert candidate(arr = [1, 3, 2, 1, 5, 2, 3, 1, 4, 2, 3, 1, 5, 2, 3, 1, 4, 2, 3, 1],target = 6) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 15) == 3\n assert candidate(arr = [1, 4, 2, 3, 5, 7, 9, 11, 13, 15],target = 15) == 4\n assert candidate(arr = [5, 1, 3, 5, 10, 7, 4, 9, 2, 8, 6],target = 15) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 4\n assert candidate(arr = [1, 4, 4, 1, 1, 2, 3, 5, 3, 2, 3, 4, 1],target = 8) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 10\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = 30) == 6\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 10) == 20\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 20) == 8\n assert candidate(arr = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50],target = 60) == 4\n assert candidate(arr = [9, 1, 2, 3, 9, 4, 5, 9, 6, 7, 8, 9],target = 9) == 2\n assert candidate(arr = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],target = 6) == 6\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 15) == 6\n assert candidate(arr = [5, 2, 3, 4, 1, 5, 2, 3, 4, 1, 5, 2, 3, 4, 1, 5, 2, 3, 4, 1],target = 10) == 6\n assert candidate(arr = [5, 1, 3, 5, 2, 1, 2, 3, 5, 2, 1, 2, 3, 5, 2, 1, 2, 3, 5, 2, 1, 2, 3, 5, 2, 1, 2, 3],target = 9) == -1\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 1500) == 5\n assert candidate(arr = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 4\n assert candidate(arr = [7, 8, 3, 4, 7, 6, 5, 4, 3, 2, 1],target = 15) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 20) == -1\n assert candidate(arr = [7, 1, 3, 1, 2, 1, 3, 1, 7, 1, 3, 1, 2, 1, 3, 1, 7, 1, 3, 1, 2, 1, 3, 1, 7, 1, 3, 1],target = 10) == 10\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 10\n assert candidate(arr = [5, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 21) == 5\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],target = 3000) == 8\n assert candidate(arr = [1, 4, 2, 3, 5, 2, 3, 1, 4, 2, 3, 5, 2, 3, 1, 4, 2, 3, 5, 2, 3, 1, 4, 2, 3, 5, 2, 3, 1, 4, 2, 3],target = 8) == 4\n assert candidate(arr = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500],target = 600) == 5\n assert candidate(arr = [2, 3, 2, 2, 3, 3, 2, 2, 2, 3],target = 6) == 5\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 1500) == 5\n assert candidate(arr = [100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200, 300, 100, 200, 300],target = 600) == 6\n assert candidate(arr = [5, 1, 3, 5, 2, 4, 8, 6, 3, 7],target = 10) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 30) == 8\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 150) == 5\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 10) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 10\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 15) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 5\n assert candidate(arr = [3, 2, 2, 4, 3, 3, 2, 2, 4, 3, 3, 2, 2, 4, 3, 3, 2, 2, 4, 3, 3, 2, 2, 4, 3, 3, 2, 2, 4, 3],target = 5) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 10\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 2) == 4\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],target = 400) == -1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 20) == 40\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 100) == -1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 9) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 20) == 6\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 2) == 4\n assert candidate(arr = [5, 1, 3, 5, 10, 7, 4, 9, 2, 8],target = 15) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],target = 3) == 3\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],target = 4) == 6\n assert candidate(arr = [100, 200, 100, 300, 200, 400, 300, 500, 400, 600],target = 300) == 2\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 150) == 5\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 10) == 4\n assert candidate(arr = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500],target = 1000) == 8\n"}, "metadata": {"canonical_parameter_names": ["arr", "target"], "leetcode_dataset_entry_point": "Solution().minSumOfLengths", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minSumOfLengths(vector& arr, int target) {", "container": "Solution", "callable": "minSumOfLengths", "parameters": [{"name": "arr", "type": "vector&"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1478, "task_id": "allocate-mailboxes", "difficulty": "Hard", "problem_description": "Given the array houses where houses[i] is the location of the ith house along a street and an integer k, allocate k mailboxes in the street.\nReturn the minimum total distance between each house and its nearest mailbox.\nThe test cases are generated so that the answer fits in a 32-bit integer.\n \nExample 1:\n\n\nInput: houses = [1,4,8,10,20], k = 3\nOutput: 5\nExplanation: Allocate mailboxes in position 3, 9 and 20.\nMinimum total distance from each houses to nearest mailboxes is |3-1| + |4-3| + |9-8| + |10-9| + |20-20| = 5 \n\nExample 2:\n\n\nInput: houses = [2,3,5,12,18], k = 2\nOutput: 9\nExplanation: Allocate mailboxes in position 3 and 14.\nMinimum total distance from each houses to nearest mailboxes is |2-3| + |3-3| + |5-3| + |12-14| + |18-14| = 9.\n\n \nConstraints:\n\n1 <= k <= houses.length <= 100\n1 <= houses[i] <= 104\nAll the integers of houses are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(houses = [10, 5, 17, 1, 18, 2, 12, 9],k = 3) == 8\n assert candidate(houses = [5, 10, 15, 20, 25],k = 2) == 15\n assert candidate(houses = [3, 6, 14, 10],k = 4) == 0\n assert candidate(houses = [3, 6, 14, 16, 25, 28, 30],k = 2) == 26\n assert candidate(houses = [1, 4, 8, 10, 20],k = 3) == 5\n assert candidate(houses = [1, 10000],k = 1) == 9999\n assert candidate(houses = [1, 2, 3, 4, 5],k = 1) == 6\n assert candidate(houses = [2, 3, 5, 12, 18],k = 2) == 9\n assert candidate(houses = [7, 4, 6, 1],k = 1) == 8\n assert candidate(houses = [5, 7, 10, 11, 12, 16],k = 3) == 4\n assert candidate(houses = [5, 10, 15, 20, 25, 30],k = 2) == 20\n assert candidate(houses = [8, 5, 2, 9, 6],k = 2) == 5\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 5\n assert candidate(houses = [10, 20, 30, 40, 50],k = 5) == 0\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 5) == 200\n assert candidate(houses = [1, 6, 9, 12, 17, 23, 30],k = 4) == 12\n assert candidate(houses = [2, 5, 7, 12, 16, 22, 26, 30, 35],k = 3) == 24\n assert candidate(houses = [1, 3, 6, 8, 12, 15, 18, 22],k = 4) == 10\n assert candidate(houses = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125],k = 6) == 70\n assert candidate(houses = [2, 6, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == 28\n assert candidate(houses = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29],k = 4) == 18\n assert candidate(houses = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50],k = 5) == 42\n assert candidate(houses = [1, 3, 6, 8, 12, 15, 18, 22, 25, 28, 30, 33, 36, 39, 42, 45, 48],k = 6) == 32\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 100\n assert candidate(houses = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 7) == 465\n assert candidate(houses = [1, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],k = 15) == 159\n assert candidate(houses = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496, 528, 561, 595, 630, 666, 703, 741, 780, 820, 861, 903, 946, 990],k = 15) == 633\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 10\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 20) == 0\n assert candidate(houses = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5) == 599\n assert candidate(houses = [1, 10, 100, 1000, 10000],k = 2) == 1089\n assert candidate(houses = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],k = 5) == 65025\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 100\n assert candidate(houses = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 2) == 111098889\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 10\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 20\n assert candidate(houses = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 3) == 225\n assert candidate(houses = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 3) == 999\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 5) == 100\n assert candidate(houses = [1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97, 103, 109, 115, 121, 127, 133, 139, 145, 151, 157, 163, 169, 175],k = 15) == 90\n assert candidate(houses = [1, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7) == 89\n assert candidate(houses = [10, 25, 62, 155, 387, 967, 2417, 6042, 15105, 37762, 94405, 236012],k = 6) == 3674\n assert candidate(houses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 2) == 60\n assert candidate(houses = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],k = 4) == 8001\n assert candidate(houses = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90],k = 15) == 45\n assert candidate(houses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 10) == 50\n assert candidate(houses = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90],k = 10) == 60\n assert candidate(houses = [10, 25, 40, 55, 70, 85, 100, 115, 130, 145, 160, 175, 190, 200],k = 8) == 85\n assert candidate(houses = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946],k = 8) == 701\n assert candidate(houses = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101],k = 16) == 40\n assert candidate(houses = [1, 3, 6, 9, 12, 15, 18, 21, 24, 27],k = 3) == 23\n assert candidate(houses = [1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600, 6227020800, 87178291200],k = 8) == 5871\n assert candidate(houses = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 10\n assert candidate(houses = [2, 8, 14, 20, 26, 32, 38, 44, 50, 56],k = 5) == 30\n assert candidate(houses = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961],k = 12) == 539\n assert candidate(houses = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205],k = 5) == 220\n assert candidate(houses = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 109\n assert candidate(houses = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 5) == 10\n assert candidate(houses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150],k = 10) == 100\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 100\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 50\n assert candidate(houses = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],k = 5) == 16\n assert candidate(houses = [2, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 11) == 48\n assert candidate(houses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 10) == 50\n assert candidate(houses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80],k = 8) == 40\n assert candidate(houses = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 3) == 36\n assert candidate(houses = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50],k = 10) == 30\n assert candidate(houses = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225],k = 13) == 100\n assert candidate(houses = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576],k = 10) == 3969\n assert candidate(houses = [5, 15, 45, 135, 405, 1215, 3645, 10935, 32805, 98415],k = 5) == 1690\n assert candidate(houses = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101],k = 8) == 80\n assert candidate(houses = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],k = 5) == 199\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 50\n assert candidate(houses = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 5) == 35\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 6) == 90\n assert candidate(houses = [1, 5, 10, 20, 35, 55, 80, 110, 145, 185, 230],k = 3) == 189\n assert candidate(houses = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 7) == 139\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 3) == 80\n assert candidate(houses = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 4) == 34\n assert candidate(houses = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 10\n assert candidate(houses = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],k = 15) == 20\n assert candidate(houses = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 5) == 100\n assert candidate(houses = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],k = 2) == 131\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7) == 80\n assert candidate(houses = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70],k = 6) == 44\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 5\n assert candidate(houses = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],k = 7) == 24\n assert candidate(houses = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987],k = 6) == 154\n assert candidate(houses = [1, 3, 6, 8, 14, 15, 20, 25],k = 4) == 10\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130],k = 7) == 60\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 4) == 24\n assert candidate(houses = [1, 3, 6, 10, 15, 21, 28, 36, 45],k = 4) == 24\n assert candidate(houses = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 7) == 465\n assert candidate(houses = [2, 8, 24, 64, 160, 416, 1040, 2608, 6528, 16384, 40960, 102400],k = 8) == 214\n assert candidate(houses = [2, 8, 15, 20, 26, 32, 40, 45, 50],k = 4) == 27\n assert candidate(houses = [7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57, 62, 67, 72, 77],k = 3) == 90\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 8\n assert candidate(houses = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500],k = 20) == 300\n assert candidate(houses = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],k = 8) == 120\n assert candidate(houses = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],k = 7) == 130\n assert candidate(houses = [1, 2, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 4) == 1697\n assert candidate(houses = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],k = 4) == 33\n assert candidate(houses = [3, 7, 11, 15, 19, 23, 27, 31],k = 3) == 20\n assert candidate(houses = [2, 5, 9, 14, 20, 27, 35, 44, 54, 65, 77, 90],k = 6) == 39\n assert candidate(houses = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100],k = 25) == 50\n assert candidate(houses = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 6) == 9\n assert candidate(houses = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 10) == 20\n assert candidate(houses = [1, 5, 9, 14, 20, 25, 30, 35, 40],k = 4) == 23\n"}, "metadata": {"canonical_parameter_names": ["houses", "k"], "leetcode_dataset_entry_point": "Solution().minDistance", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minDistance(vector& houses, int k) {", "container": "Solution", "callable": "minDistance", "parameters": [{"name": "houses", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1480, "task_id": "running-sum-of-1d-array", "difficulty": "Easy", "problem_description": "Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]).\nReturn the running sum of nums.\n \nExample 1:\n\nInput: nums = [1,2,3,4]\nOutput: [1,3,6,10]\nExplanation: Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4].\nExample 2:\n\nInput: nums = [1,1,1,1,1]\nOutput: [1,2,3,4,5]\nExplanation: Running sum is obtained as follows: [1, 1+1, 1+1+1, 1+1+1+1, 1+1+1+1+1].\nExample 3:\n\nInput: nums = [3,1,2,10,1]\nOutput: [3,4,6,16,17]\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n-10^6 <= nums[i] <= 10^6\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, 2, -3, 4, -5]) == [-1, 1, -2, 2, -3]\n assert candidate(nums = [-5]) == [-5]\n assert candidate(nums = [0, -1, 2, -3, 4]) == [0, -1, 1, -2, 2]\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0]\n assert candidate(nums = [1]) == [1]\n assert candidate(nums = [1000000, -1000000, 1000000, -1000000]) == [1000000, 0, 1000000, 0]\n assert candidate(nums = [1, 2, 3, 4]) == [1, 3, 6, 10]\n assert candidate(nums = [0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1]) == [1, 2, 3, 4, 5]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(nums = [0, 0, 0, 0]) == [0, 0, 0, 0]\n assert candidate(nums = [-1, -2, -3, -4]) == [-1, -3, -6, -10]\n assert candidate(nums = [1000000, -1000000, 1000000, -1000000, 1000000]) == [1000000, 0, 1000000, 0, 1000000]\n assert candidate(nums = [-1000000]) == [-1000000]\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000]) == [1000000, 2000000, 3000000, 4000000]\n assert candidate(nums = [5]) == [5]\n assert candidate(nums = [1000000]) == [1000000]\n assert candidate(nums = [1000000, -1000000, 1000000, -1000000]) == [1000000, 0, 1000000, 0]\n assert candidate(nums = [3, 1, 2, 10, 1]) == [3, 4, 6, 16, 17]\n assert candidate(nums = [1000, -500, 250, -125, 62.5, -31.25, 15.625, -7.8125, 3.90625, -1.953125, 0.9765625, -0.48828125, 0.244140625, -0.1220703125, 0.06103515625]) == [1000, 500, 750, 625, 687.5, 656.25, 671.875, 664.0625, 667.96875, 666.015625, 666.9921875, 666.50390625, 666.748046875, 666.6259765625, 666.68701171875]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [5, 15, 30, 50, 75, 105, 140, 180, 225, 275, 330, 390, 455, 525, 600, 680, 765, 855, 950, 1050]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300]) == [100, 300, 600, 1000, 1500, 2100, 2800, 3600, 4500, 5500, 6600, 7800, 9100]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 11, 111, 1111, 11111, 111111, 1111111, 1111112, 1111111, 1111112, 1111111, 1111112, 1111111, 1111112, 1111111, 1111112, 1111111]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == [-1, -3, -6, -10, -15, -21, -28, -36, -45, -55, -66, -78, -91, -105, -120, -136, -153, -171, -190, -210]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [100, 300, 600, 1000, 1500, 2100, 2800, 3600, 4500, 5500]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [5, 20, 45, 80, 125, 180, 245, 320, 405, 500, 605]\n assert candidate(nums = [100, 50, -50, -100, 150, 200, -250, 300, -350, 400]) == [100, 150, 100, 0, 150, 350, 100, 400, 50, 450]\n assert candidate(nums = [-1000000, 500000, -250000, 125000, -62500]) == [-1000000, -500000, -750000, -625000, -687500]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15]) == [-1, -3, -6, -10, -15, -21, -28, -36, -45, -55, -66, -78, -91, -105, -120]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]\n assert candidate(nums = [-1000000, -2000000, -3000000, -4000000, -5000000]) == [-1000000, -3000000, -6000000, -10000000, -15000000]\n assert candidate(nums = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000, -5000]) == [1000, 0, 2000, 0, 3000, 0, 4000, 0, 5000, 0]\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000]) == [1000000, 2000000, 3000000, 4000000]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == [10, 0, 20, 0, 30, 0, 40, 0, 50, 0]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 19, 27, 34, 40, 45, 49, 52, 54, 55]\n assert candidate(nums = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111]) == [999999, 1888887, 2666664, 3333330, 3888885, 4333329, 4666662, 4888884, 4999995]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [20, 39, 57, 74, 90, 105, 119, 132, 144, 155, 165, 174, 182, 189, 195, 200, 204, 207, 209, 210]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(nums = [10, -10, 20, -20, 30, -30]) == [10, 0, 20, 0, 30, 0]\n assert candidate(nums = [-1000, -2000, -3000, -4000, -5000, -6000, -7000, -8000, -9000, -10000]) == [-1000, -3000, -6000, -10000, -15000, -21000, -28000, -36000, -45000, -55000]\n assert candidate(nums = [500000, -500000, 500000, -500000, 500000, -500000, 500000, -500000, 500000, -500000]) == [500000, 0, 500000, 0, 500000, 0, 500000, 0, 500000, 0]\n assert candidate(nums = [5, -5, 15, -15, 25, -25]) == [5, 0, 15, 0, 25, 0]\n assert candidate(nums = [1000000, -1000000, 1000000, -1000000, 1000000]) == [1000000, 0, 1000000, 0, 1000000]\n assert candidate(nums = [1000000, -500000, 500000, -250000, 250000]) == [1000000, 500000, 1000000, 750000, 1000000]\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == [10000, 30000, 60000, 100000, 150000, 210000, 280000, 360000, 450000, 550000]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [15, 29, 42, 54, 65, 75, 84, 92, 99, 105, 110, 114, 117, 119, 120]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]\n assert candidate(nums = [-1000000, -999999, -999998, -999997, -999996, -999995]) == [-1000000, -1999999, -2999997, -3999994, -4999990, -5999985]\n assert candidate(nums = [500000, 500000, 500000, 500000, 500000, -2500000]) == [500000, 1000000, 1500000, 2000000, 2500000, 0]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]\n assert candidate(nums = [999999, -999998, 999997, -999996, 999995, -999994, 999993, -999992, 999991]) == [999999, 1, 999998, 2, 999997, 3, 999996, 4, 999995]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [10, 30, 60, 100, 150, 210, 280, 360, 450, 550]\n assert candidate(nums = [0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1000000, -1000000, 500000, -500000, 250000, -250000]) == [1000000, 0, 500000, 0, 250000, 0]\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]\n assert candidate(nums = [999999, -999998, 999997, -999996, 999995, -999994, 999993, -999992]) == [999999, 1, 999998, 2, 999997, 3, 999996, 4]\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70]) == [10, -10, 20, -20, 30, -30, 40]\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000]) == [1000000, 3000000, 6000000, 10000000, 15000000]\n assert candidate(nums = [1000000, -500000, 250000, -125000, 62500]) == [1000000, 500000, 750000, 625000, 687500]\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0]\n assert candidate(nums = [999999, 1, -999998, 2, -999997, 3]) == [999999, 1000000, 2, 4, -999993, -999990]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(nums = [-1000000, -2000000, -3000000, -4000000, -5000000, -6000000, -7000000, -8000000, -9000000, -10000000]) == [-1000000, -3000000, -6000000, -10000000, -15000000, -21000000, -28000000, -36000000, -45000000, -55000000]\n assert candidate(nums = [-1000, 2000, -3000, 4000, -5000, 6000, -7000, 8000, -9000, 10000]) == [-1000, 1000, -2000, 2000, -3000, 3000, -4000, 4000, -5000, 5000]\n assert candidate(nums = [123456, -234567, 345678, -456789, 567890, -678901, 789012, -890123, 901234]) == [123456, -111111, 234567, -222222, 345668, -333233, 455779, -434344, 466890]\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990]) == [999999, 1999997, 2999994, 3999990, 4999985, 5999979, 6999972, 7999964, 8999955, 9999945]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == [100, 199, 297, 394, 490, 585, 679, 772, 864, 955, 1045, 1134, 1222, 1309, 1395, 1480, 1564, 1647, 1729, 1810]\n assert candidate(nums = [1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1]) == [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]\n assert candidate(nums = [-999999, -888888, -777777, -666666, -555555, -444444, -333333, -222222, -111111]) == [-999999, -1888887, -2666664, -3333330, -3888885, -4333329, -4666662, -4888884, -4999995]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(nums = [1000000, 500000, -1500000, 2000000, -2500000, 3000000, -3500000]) == [1000000, 1500000, 0, 2000000, -500000, 2500000, -1000000]\n assert candidate(nums = [1000000, -1000000, 2000000, -2000000, 3000000, -3000000]) == [1000000, 0, 2000000, 0, 3000000, 0]\n assert candidate(nums = [500000, 250000, -125000, 62500, -31250, 15625, -7812, 3906, -1953]) == [500000, 750000, 625000, 687500, 656250, 671875, 664063, 667969, 666016]\n assert candidate(nums = [0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8]\n assert candidate(nums = [-1000000, -1000000, -1000000, -1000000]) == [-1000000, -2000000, -3000000, -4000000]\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == [1, 0, 2, 0, 3, 0]\n assert candidate(nums = [100, 200, 300, 400, 500, -1500, 600, 700, 800, 900]) == [100, 300, 600, 1000, 1500, 0, 600, 1300, 2100, 3000]\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == [5, 0, 5, 0, 5, 0, 5, 0, 5, 0]\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == [1, 2, 4, 7, 12, 20, 33, 54, 88, 143, 232, 376, 609, 986, 1596, 2583, 4180, 6764, 10945, 17710]\n assert candidate(nums = [999999, -999999, 999999, -999999, 999999, -999999, 999999, -999999, 999999, -999999]) == [999999, 0, 999999, 0, 999999, 0, 999999, 0, 999999, 0]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == [1000, 3000, 6000, 10000, 15000, 21000, 28000, 36000, 45000, 55000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210]\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -110, -120, -130, -140, -150]) == [-10, -30, -60, -100, -150, -210, -280, -360, -450, -550, -660, -780, -910, -1050, -1200]\n assert candidate(nums = [500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500]) == [500, 900, 1200, 1400, 1500, 1500, 1400, 1200, 900, 500, 0]\n assert candidate(nums = [100, -50, 25, -12, 6, -3, 1, 0, -1, 3, -6, 12, -24, 48, -96, 192, -384, 768, -1536, 3072]) == [100, 50, 75, 63, 69, 66, 67, 67, 66, 69, 63, 75, 51, 99, 3, 195, -189, 579, -957, 2115]\n assert candidate(nums = [1, 0, -1, 2, 0, -2, 3, 0, -3]) == [1, 1, 0, 2, 2, 0, 3, 3, 0]\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == [1000000, 3000000, 6000000, 10000000, 15000000, 21000000, 28000000, 36000000, 45000000, 55000000]\n assert candidate(nums = [999999, -999998, 999997, -999996, 999995, -999994, 999993, -999992, 999991, -999990]) == [999999, 1, 999998, 2, 999997, 3, 999996, 4, 999995, 5]\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == [-10, -19, -27, -34, -40, -45, -49, -52, -54, -55]\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().runningSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector runningSum(vector& nums) {", "container": "Solution", "callable": "runningSum", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1481, "task_id": "least-number-of-unique-integers-after-k-removals", "difficulty": "Medium", "problem_description": "Given an array of integers arr and an integer k. Find the least number of unique integers after removing exactly k elements.\\r\n\\r\n\\r\n\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: arr = [5,5,4], k = 1\\r\nOutput: 1\\r\nExplanation: Remove the single 4, only 5 is left.\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: arr = [4,3,1,1,3,3,2], k = 3\\r\nOutput: 2\\r\nExplanation: Remove 4, 2 and either one of the two 1s or three 3s. 1 and 3 will be left.\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= arr.length <= 10^5\\r\n\t1 <= arr[i] <= 10^9\\r\n\t0 <= k <= arr.length\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 1, 1, 1, 1],k = 3) == 1\n assert candidate(arr = [1, 2, 3, 4, 5],k = 2) == 3\n assert candidate(arr = [10, 20, 20, 10, 10, 30, 50, 10, 20],k = 4) == 2\n assert candidate(arr = [10, 20, 30, 40, 50, 60],k = 0) == 6\n assert candidate(arr = [4, 3, 1, 1, 3, 3, 2],k = 3) == 2\n assert candidate(arr = [1, 2, 3, 4, 5],k = 0) == 5\n assert candidate(arr = [10, 10, 10, 20, 20, 30],k = 3) == 1\n assert candidate(arr = [1, 1, 1, 1, 1],k = 2) == 1\n assert candidate(arr = [1, 2, 3, 4, 5],k = 5) == 0\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 9) == 5\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 4) == 2\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 1\n assert candidate(arr = [5, 5, 4],k = 1) == 1\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 2) == 3\n assert candidate(arr = [1, 2, 2, 3, 3, 3],k = 2) == 2\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 5) == 3\n assert candidate(arr = [10, 20, 20, 10, 10, 30, 50, 10, 20],k = 5) == 1\n assert candidate(arr = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 50],k = 10) == 1\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 30) == 2\n assert candidate(arr = [100, 100, 200, 200, 200, 300, 300, 300, 300, 400, 400, 400, 400, 400, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500],k = 15) == 1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 15) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 20) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9],k = 18) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 50) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 5\n assert candidate(arr = [29, 30, 30, 31, 31, 31, 32, 32, 32, 32, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35],k = 25) == 1\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8, 9],k = 20) == 3\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 30) == 4\n assert candidate(arr = [6, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 10],k = 8) == 2\n assert candidate(arr = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60, 70, 70, 70, 70, 70, 70, 70, 80, 80, 80, 80, 80, 80, 80, 80, 90, 90, 90, 90, 90, 90, 90, 90, 90, 100],k = 25) == 3\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 25) == 5\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6],k = 18) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 20) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8],k = 20) == 2\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 15) == 1\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 25) == 2\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 7) == 2\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5],k = 15) == 1\n assert candidate(arr = [7, 7, 7, 7, 8, 8, 8, 9, 9, 10, 10, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 13],k = 10) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 20) == 20\n assert candidate(arr = [11, 12, 12, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16],k = 8) == 3\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 5) == 2\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 30) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 14],k = 15) == 2\n assert candidate(arr = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60],k = 15) == 1\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 5) == 3\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 1\n assert candidate(arr = [7, 7, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12],k = 10) == 3\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 5) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 40) == 1\n assert candidate(arr = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 30) == 1\n assert candidate(arr = [6, 7, 7, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10],k = 10) == 1\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 20) == 4\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 30) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 10) == 3\n assert candidate(arr = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60],k = 12) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 25) == 2\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5],k = 15) == 2\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 15) == 2\n assert candidate(arr = [22, 23, 23, 24, 24, 24, 25, 25, 25, 25, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28],k = 20) == 2\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 15) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 1\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 20) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 10\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 20) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 25) == 1\n assert candidate(arr = [36, 37, 37, 38, 38, 38, 39, 39, 39, 39, 40, 40, 40, 40, 40, 41, 41, 41, 41, 41, 41, 41, 41, 41, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42],k = 30) == 1\n assert candidate(arr = [17, 18, 18, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21],k = 15) == 1\n"}, "metadata": {"canonical_parameter_names": ["arr", "k"], "leetcode_dataset_entry_point": "Solution().findLeastNumOfUniqueInts", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int findLeastNumOfUniqueInts(vector& arr, int k) {", "container": "Solution", "callable": "findLeastNumOfUniqueInts", "parameters": [{"name": "arr", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1482, "task_id": "minimum-number-of-days-to-make-m-bouquets", "difficulty": "Medium", "problem_description": "You are given an integer array bloomDay, an integer m and an integer k.\nYou want to make m bouquets. To make a bouquet, you need to use k adjacent flowers from the garden.\nThe garden consists of n flowers, the ith flower will bloom in the bloomDay[i] and then can be used in exactly one bouquet.\nReturn the minimum number of days you need to wait to be able to make m bouquets from the garden. If it is impossible to make m bouquets return -1.\n \nExample 1:\n\nInput: bloomDay = [1,10,3,10,2], m = 3, k = 1\nOutput: 3\nExplanation: Let us see what happened in the first three days. x means flower bloomed and _ means flower did not bloom in the garden.\nWe need 3 bouquets each should contain 1 flower.\nAfter day 1: [x, _, _, _, _] // we can only make one bouquet.\nAfter day 2: [x, _, _, _, x] // we can only make two bouquets.\nAfter day 3: [x, _, x, _, x] // we can make 3 bouquets. The answer is 3.\n\nExample 2:\n\nInput: bloomDay = [1,10,3,10,2], m = 3, k = 2\nOutput: -1\nExplanation: We need 3 bouquets each has 2 flowers, that means we need 6 flowers. We only have 5 flowers so it is impossible to get the needed bouquets and we return -1.\n\nExample 3:\n\nInput: bloomDay = [7,7,7,7,12,7,7], m = 2, k = 3\nOutput: 12\nExplanation: We need 2 bouquets each should have 3 flowers.\nHere is the garden after the 7 and 12 days:\nAfter day 7: [x, x, x, x, _, x, x]\nWe can make one bouquet of the first three flowers that bloomed. We cannot make another bouquet from the last three flowers that bloomed because they are not adjacent.\nAfter day 12: [x, x, x, x, x, x, x]\nIt is obvious that we can make two bouquets in different ways.\n\n \nConstraints:\n\nbloomDay.length == n\n1 <= n <= 105\n1 <= bloomDay[i] <= 109\n1 <= m <= 106\n1 <= k <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(bloomDay = [1, 10, 3, 10, 2],m = 3,k = 1) == 3\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 5,k = 2) == 1\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 5,k = 1) == 5\n assert candidate(bloomDay = [1],m = 1,k = 1) == 1\n assert candidate(bloomDay = [1000000000, 1000000000, 1000000000],m = 1,k = 3) == 1000000000\n assert candidate(bloomDay = [1, 10, 3, 10, 2],m = 3,k = 2) == -1\n assert candidate(bloomDay = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 5,k = 2) == 10\n assert candidate(bloomDay = [1000000000, 1000000000, 1000000000],m = 1,k = 2) == 1000000000\n assert candidate(bloomDay = [7, 7, 7, 7, 12, 7, 7],m = 2,k = 3) == 12\n assert candidate(bloomDay = [1, 3, 2],m = 1,k = 2) == 3\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 1,k = 10) == 10\n assert candidate(bloomDay = [1, 2, 4, 9, 3, 4, 1],m = 2,k = 2) == 4\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 2,k = 5) == 1\n assert candidate(bloomDay = [5, 8, 6, 9, 3, 2, 7, 4],m = 3,k = 2) == 8\n assert candidate(bloomDay = [5, 5, 5, 5, 5, 5],m = 2,k = 3) == 5\n assert candidate(bloomDay = [5, 8, 6, 9, 7],m = 2,k = 2) == 9\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 5,k = 2) == 10\n assert candidate(bloomDay = [2, 1, 3, 1, 2],m = 3,k = 1) == 2\n assert candidate(bloomDay = [100, 100, 100, 100],m = 1,k = 4) == 100\n assert candidate(bloomDay = [1, 2, 3, 4, 5],m = 1,k = 5) == 5\n assert candidate(bloomDay = [1000000000],m = 1,k = 1) == 1000000000\n assert candidate(bloomDay = [5, 8, 6, 9, 2, 5, 9, 1, 1, 5, 1, 8, 9, 1, 8],m = 3,k = 1) == 1\n assert candidate(bloomDay = [5, 8, 6, 9, 2, 4, 7, 1, 3, 10],m = 4,k = 2) == 9\n assert candidate(bloomDay = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],m = 10,k = 2) == 20\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 2,k = 7) == 1\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 5,k = 3) == 15\n assert candidate(bloomDay = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 5,k = 3) == 6\n assert candidate(bloomDay = [30, 10, 20, 30, 20, 10, 30, 20, 10, 30],m = 3,k = 3) == 30\n assert candidate(bloomDay = [9, 1, 2, 3, 4, 5, 6, 7, 8, 1000000000],m = 1,k = 1) == 1\n assert candidate(bloomDay = [3, 5, 1, 5, 9, 6, 2, 10, 8, 7],m = 3,k = 3) == 10\n assert candidate(bloomDay = [9, 8, 7, 6, 5, 4, 3, 2, 1],m = 3,k = 3) == 9\n assert candidate(bloomDay = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],m = 3,k = 3) == 9\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 5,k = 5) == 1\n assert candidate(bloomDay = [2, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1],m = 8,k = 2) == 10\n assert candidate(bloomDay = [5, 3, 8, 1, 9, 2, 4, 6, 7],m = 3,k = 2) == 7\n assert candidate(bloomDay = [5, 1, 10, 2, 8, 3, 5, 10],m = 2,k = 2) == 5\n assert candidate(bloomDay = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000],m = 4,k = 2) == 1000000000\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 3,k = 5) == -1\n assert candidate(bloomDay = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 2,k = 5) == 10\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 1,k = 10) == 1\n assert candidate(bloomDay = [5, 8, 4, 3, 7, 1, 9],m = 3,k = 2) == 8\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 10,k = 1) == 1\n assert candidate(bloomDay = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],m = 4,k = 3) == 3\n assert candidate(bloomDay = [9, 8, 7, 6, 5, 4, 3, 2, 1],m = 3,k = 2) == 6\n assert candidate(bloomDay = [3, 1, 5, 1, 3, 2, 5, 7, 5, 8, 4, 3],m = 3,k = 2) == 4\n assert candidate(bloomDay = [1000000000, 1000000000, 1000000000, 1000000000],m = 1,k = 4) == 1000000000\n assert candidate(bloomDay = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1],m = 4,k = 2) == 10\n assert candidate(bloomDay = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],m = 3,k = 4) == 2\n assert candidate(bloomDay = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],m = 5,k = 3) == -1\n assert candidate(bloomDay = [6, 5, 8, 10, 6, 11, 5, 3],m = 4,k = 1) == 6\n assert candidate(bloomDay = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],m = 3,k = 3) == 3\n assert candidate(bloomDay = [1, 2, 2, 1, 2, 1, 1, 2, 2, 1],m = 2,k = 3) == 2\n assert candidate(bloomDay = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 5,k = 4) == 20\n assert candidate(bloomDay = [9, 8, 7, 6, 5, 4, 3, 2, 1],m = 4,k = 2) == 8\n assert candidate(bloomDay = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10],m = 4,k = 2) == 8\n assert candidate(bloomDay = [5, 3, 3, 3, 5, 5, 2, 2, 2, 5],m = 3,k = 3) == 5\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 100,k = 5) == -1\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 3,k = 5) == 5\n assert candidate(bloomDay = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1],m = 5,k = 1) == 1\n assert candidate(bloomDay = [5, 8, 9, 6, 4, 3, 7, 2, 1],m = 4,k = 2) == 8\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 10,k = 2) == 20\n assert candidate(bloomDay = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10],m = 1,k = 10) == 10\n assert candidate(bloomDay = [2, 4, 1, 1, 1, 1, 2, 3, 3],m = 2,k = 3) == 3\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 4,k = 3) == -1\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 5,k = 3) == 1\n assert candidate(bloomDay = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],m = 1,k = 8) == 1000000000\n assert candidate(bloomDay = [5, 8, 6, 9, 10, 11, 12, 13, 14, 15],m = 4,k = 2) == 13\n assert candidate(bloomDay = [7, 7, 7, 12, 7, 7, 7, 12, 7, 7, 7, 12],m = 4,k = 3) == 12\n assert candidate(bloomDay = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9],m = 1,k = 1) == 1\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 5,k = 3) == 1\n assert candidate(bloomDay = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],m = 5,k = 3) == 2\n assert candidate(bloomDay = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],m = 5,k = 2) == 20\n assert candidate(bloomDay = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],m = 10,k = 5) == -1\n assert candidate(bloomDay = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],m = 5,k = 4) == 10\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],m = 15,k = 2) == 30\n assert candidate(bloomDay = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],m = 5,k = 3) == 30\n assert candidate(bloomDay = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 10,k = 2) == 1\n assert candidate(bloomDay = [3, 2, 1, 6, 5, 4, 9, 8, 7, 12, 11, 10],m = 3,k = 3) == 9\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 10,k = 1) == 10\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 3,k = 5) == 5\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 15,k = 5) == 10\n assert candidate(bloomDay = [1, 10, 3, 10, 2, 1, 10, 3, 10, 2],m = 4,k = 2) == 10\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 5,k = 3) == 15\n assert candidate(bloomDay = [9, 3, 5, 7, 2, 8, 10, 6, 4],m = 2,k = 3) == 9\n assert candidate(bloomDay = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],m = 5,k = 4) == 7\n assert candidate(bloomDay = [5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5, 1, 3, 1, 5],m = 10,k = 2) == 3\n assert candidate(bloomDay = [5, 8, 6, 9, 7, 2, 4, 3, 10, 1],m = 2,k = 4) == 9\n assert candidate(bloomDay = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9],m = 3,k = 3) == 9\n assert candidate(bloomDay = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],m = 5,k = 3) == 5\n assert candidate(bloomDay = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],m = 5,k = 4) == 200\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 3,k = 3) == 9\n assert candidate(bloomDay = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],m = 5,k = 5) == 25\n assert candidate(bloomDay = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],m = 10,k = 3) == 3\n"}, "metadata": {"canonical_parameter_names": ["bloomDay", "m", "k"], "leetcode_dataset_entry_point": "Solution().minDays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minDays(vector& bloomDay, int m, int k) {", "container": "Solution", "callable": "minDays", "parameters": [{"name": "bloomDay", "type": "vector&"}, {"name": "m", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1486, "task_id": "xor-operation-in-an-array", "difficulty": "Easy", "problem_description": "You are given an integer n and an integer start.\nDefine an array nums where nums[i] = start + 2 * i (0-indexed) and n == nums.length.\nReturn the bitwise XOR of all elements of nums.\n \nExample 1:\n\nInput: n = 5, start = 0\nOutput: 8\nExplanation: Array nums is equal to [0, 2, 4, 6, 8] where (0 ^ 2 ^ 4 ^ 6 ^ 8) = 8.\nWhere \"^\" corresponds to bitwise XOR operator.\n\nExample 2:\n\nInput: n = 4, start = 3\nOutput: 8\nExplanation: Array nums is equal to [3, 5, 7, 9] where (3 ^ 5 ^ 7 ^ 9) = 8.\n\n \nConstraints:\n\n1 <= n <= 1000\n0 <= start <= 1000\nn == nums.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,start = 3) == 8\n assert candidate(n = 8,start = 12) == 0\n assert candidate(n = 7,start = 2) == 0\n assert candidate(n = 3,start = 2) == 0\n assert candidate(n = 10,start = 1) == 2\n assert candidate(n = 5,start = 0) == 8\n assert candidate(n = 1,start = 7) == 7\n assert candidate(n = 10,start = 5) == 2\n assert candidate(n = 8,start = 2) == 16\n assert candidate(n = 7,start = 5) == 19\n assert candidate(n = 1,start = 5) == 5\n assert candidate(n = 10,start = 999) == 30\n assert candidate(n = 50,start = 25) == 2\n assert candidate(n = 100,start = 200) == 0\n assert candidate(n = 15,start = 2) == 0\n assert candidate(n = 33,start = 17) == 81\n assert candidate(n = 12,start = 8) == 0\n assert candidate(n = 750,start = 10) == 1518\n assert candidate(n = 750,start = 50) == 1598\n assert candidate(n = 3,start = 333) == 339\n assert candidate(n = 666,start = 333) == 2\n assert candidate(n = 500,start = 250) == 1048\n assert candidate(n = 12,start = 3) == 24\n assert candidate(n = 9,start = 1) == 17\n assert candidate(n = 50,start = 10) == 102\n assert candidate(n = 6,start = 999) == 22\n assert candidate(n = 8,start = 11) == 16\n assert candidate(n = 64,start = 42) == 128\n assert candidate(n = 15,start = 7) == 5\n assert candidate(n = 80,start = 600) == 0\n assert candidate(n = 250,start = 100) == 2\n assert candidate(n = 20,start = 10) == 56\n assert candidate(n = 30,start = 42) == 78\n assert candidate(n = 7,start = 25) == 39\n assert candidate(n = 256,start = 128) == 0\n assert candidate(n = 400,start = 400) == 0\n assert candidate(n = 11,start = 8) == 30\n assert candidate(n = 100,start = 250) == 312\n assert candidate(n = 20,start = 11) == 56\n assert candidate(n = 500,start = 750) == 1080\n assert candidate(n = 500,start = 500) == 0\n assert candidate(n = 700,start = 600) == 0\n assert candidate(n = 60,start = 8) == 0\n assert candidate(n = 100,start = 999) == 1864\n assert candidate(n = 250,start = 250) == 534\n assert candidate(n = 8,start = 15) == 16\n assert candidate(n = 18,start = 4) == 2\n assert candidate(n = 1000,start = 0) == 0\n assert candidate(n = 333,start = 256) == 920\n assert candidate(n = 75,start = 300) == 450\n assert candidate(n = 128,start = 99) == 256\n assert candidate(n = 500,start = 999) == 1064\n assert candidate(n = 100,start = 50) == 200\n assert candidate(n = 50,start = 50) == 166\n assert candidate(n = 250,start = 123) == 534\n assert candidate(n = 999,start = 0) == 1998\n assert candidate(n = 999,start = 500) == 2498\n assert candidate(n = 25,start = 6) == 6\n assert candidate(n = 64,start = 32) == 0\n assert candidate(n = 20,start = 12) == 0\n assert candidate(n = 50,start = 100) == 2\n assert candidate(n = 8,start = 1) == 0\n assert candidate(n = 30,start = 15) == 70\n assert candidate(n = 9,start = 7) == 7\n assert candidate(n = 13,start = 11) == 11\n assert candidate(n = 20,start = 3) == 40\n assert candidate(n = 100,start = 25) == 0\n assert candidate(n = 500,start = 0) == 0\n assert candidate(n = 120,start = 750) == 304\n assert candidate(n = 7,start = 1) == 15\n assert candidate(n = 15,start = 12) == 42\n assert candidate(n = 50,start = 0) == 2\n assert candidate(n = 1000,start = 1) == 0\n assert candidate(n = 333,start = 222) == 222\n assert candidate(n = 20,start = 15) == 56\n assert candidate(n = 7,start = 14) == 12\n assert candidate(n = 1000,start = 1000) == 0\n assert candidate(n = 800,start = 150) == 1600\n assert candidate(n = 300,start = 300) == 0\n assert candidate(n = 8,start = 100) == 0\n assert candidate(n = 7,start = 17) == 31\n assert candidate(n = 7,start = 10) == 8\n assert candidate(n = 666,start = 128) == 2\n assert candidate(n = 20,start = 2) == 40\n assert candidate(n = 300,start = 600) == 0\n assert candidate(n = 12,start = 42) == 104\n assert candidate(n = 40,start = 0) == 0\n assert candidate(n = 20,start = 0) == 0\n assert candidate(n = 80,start = 12) == 0\n assert candidate(n = 300,start = 450) == 1496\n assert candidate(n = 999,start = 1) == 1999\n assert candidate(n = 600,start = 300) == 0\n"}, "metadata": {"canonical_parameter_names": ["n", "start"], "leetcode_dataset_entry_point": "Solution().xorOperation", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int xorOperation(int n, int start) {", "container": "Solution", "callable": "xorOperation", "parameters": [{"name": "n", "type": "int"}, {"name": "start", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1487, "task_id": "making-file-names-unique", "difficulty": "Medium", "problem_description": "Given an array of strings names of size n. You will create n folders in your file system such that, at the ith minute, you will create a folder with the name names[i].\nSince two files cannot have the same name, if you enter a folder name that was previously used, the system will have a suffix addition to its name in the form of (k), where, k is the smallest positive integer such that the obtained name remains unique.\nReturn an array of strings of length n where ans[i] is the actual name the system will assign to the ith folder when you create it.\n \nExample 1:\n\nInput: names = [\"pes\",\"fifa\",\"gta\",\"pes(2019)\"]\nOutput: [\"pes\",\"fifa\",\"gta\",\"pes(2019)\"]\nExplanation: Let's see how the file system creates folder names:\n\"pes\" --> not assigned before, remains \"pes\"\n\"fifa\" --> not assigned before, remains \"fifa\"\n\"gta\" --> not assigned before, remains \"gta\"\n\"pes(2019)\" --> not assigned before, remains \"pes(2019)\"\n\nExample 2:\n\nInput: names = [\"gta\",\"gta(1)\",\"gta\",\"avalon\"]\nOutput: [\"gta\",\"gta(1)\",\"gta(2)\",\"avalon\"]\nExplanation: Let's see how the file system creates folder names:\n\"gta\" --> not assigned before, remains \"gta\"\n\"gta(1)\" --> not assigned before, remains \"gta(1)\"\n\"gta\" --> the name is reserved, system adds (k), since \"gta(1)\" is also reserved, systems put k = 2. it becomes \"gta(2)\"\n\"avalon\" --> not assigned before, remains \"avalon\"\n\nExample 3:\n\nInput: names = [\"onepiece\",\"onepiece(1)\",\"onepiece(2)\",\"onepiece(3)\",\"onepiece\"]\nOutput: [\"onepiece\",\"onepiece(1)\",\"onepiece(2)\",\"onepiece(3)\",\"onepiece(4)\"]\nExplanation: When the last folder is created, the smallest positive valid k is 4, and it becomes \"onepiece(4)\".\n\n \nConstraints:\n\n1 <= names.length <= 5 * 104\n1 <= names[i].length <= 20\nnames[i] consists of lowercase English letters, digits, and/or round brackets.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(names = ['doc', 'doc(1)', 'image', 'doc(1)', 'doc']) == ['doc', 'doc(1)', 'image', 'doc(1)(1)', 'doc(2)']\n assert candidate(names = ['abcd', 'abcde', 'abcd(1)', 'abcd', 'abcd(2)', 'abcd(1)(1)']) == ['abcd', 'abcde', 'abcd(1)', 'abcd(2)', 'abcd(2)(1)', 'abcd(1)(1)']\n assert candidate(names = ['a', 'a', 'a', 'a', 'a']) == ['a', 'a(1)', 'a(2)', 'a(3)', 'a(4)']\n assert candidate(names = ['pes', 'fifa', 'gta', 'pes(2019)']) == ['pes', 'fifa', 'gta', 'pes(2019)']\n assert candidate(names = ['gta', 'gta(1)', 'gta', 'avalon']) == ['gta', 'gta(1)', 'gta(2)', 'avalon']\n assert candidate(names = ['doc', 'doc', 'image', 'doc(1)', 'doc']) == ['doc', 'doc(1)', 'image', 'doc(1)(1)', 'doc(2)']\n assert candidate(names = ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']) == ['a', 'a(1)', 'a(2)', 'a(3)', 'a(4)', 'a(5)', 'a(6)', 'a(7)', 'a(8)', 'a(9)']\n assert candidate(names = ['doc', 'doc(1)', 'image', 'doc(1)(1)', 'doc(2)', 'doc(1)(2)', 'doc(3)', 'doc(1)(3)', 'doc(2)(1)']) == ['doc', 'doc(1)', 'image', 'doc(1)(1)', 'doc(2)', 'doc(1)(2)', 'doc(3)', 'doc(1)(3)', 'doc(2)(1)']\n assert candidate(names = ['a', 'a', 'a', 'a', 'a', 'a']) == ['a', 'a(1)', 'a(2)', 'a(3)', 'a(4)', 'a(5)']\n assert candidate(names = ['onepiece', 'onepiece(1)', 'onepiece(2)', 'onepiece(3)', 'onepiece']) == ['onepiece', 'onepiece(1)', 'onepiece(2)', 'onepiece(3)', 'onepiece(4)']\n assert candidate(names = ['a', 'a', 'a', 'a(1)', 'a(2)', 'a(1)(1)']) == ['a', 'a(1)', 'a(2)', 'a(1)(1)', 'a(2)(1)', 'a(1)(1)(1)']\n assert candidate(names = ['game', 'game(1)', 'game', 'game(2)', 'game(1)', 'game(3)', 'game(1)(1)']) == ['game', 'game(1)', 'game(2)', 'game(2)(1)', 'game(1)(1)', 'game(3)', 'game(1)(1)(1)']\n assert candidate(names = ['project', 'project', 'project', 'project', 'project(1)', 'project(1)', 'project(2)', 'project', 'project(1)', 'project(2)', 'project(3)', 'project(1)(1)', 'project(1)(2)', 'project(1)(3)', 'project(1)', 'project(2)', 'project(3)', 'project(4)', 'project', 'project(1)', 'project(2)', 'project(3)', 'project(4)', 'project(5)']) == ['project', 'project(1)', 'project(2)', 'project(3)', 'project(1)(1)', 'project(1)(2)', 'project(2)(1)', 'project(4)', 'project(1)(3)', 'project(2)(2)', 'project(3)(1)', 'project(1)(1)(1)', 'project(1)(2)(1)', 'project(1)(3)(1)', 'project(1)(4)', 'project(2)(3)', 'project(3)(2)', 'project(4)(1)', 'project(5)', 'project(1)(5)', 'project(2)(4)', 'project(3)(3)', 'project(4)(2)', 'project(5)(1)']\n assert candidate(names = ['file1', 'file1(1)', 'file1', 'file1(2)', 'file1', 'file1(1)', 'file1(2)', 'file1(1)(1)', 'file1(1)(2)', 'file1(1)(1)(1)', 'file1(1)(1)(2)', 'file1(1)(1)(1)(1)', 'file1(3)', 'file1(4)', 'file1(5)', 'file1(1)(3)', 'file1(1)(4)', 'file1(2)(1)', 'file1(2)(2)', 'file1(2)(1)(1)']) == ['file1', 'file1(1)', 'file1(2)', 'file1(2)(1)', 'file1(3)', 'file1(1)(1)', 'file1(2)(2)', 'file1(1)(1)(1)', 'file1(1)(2)', 'file1(1)(1)(1)(1)', 'file1(1)(1)(2)', 'file1(1)(1)(1)(1)(1)', 'file1(3)(1)', 'file1(4)', 'file1(5)', 'file1(1)(3)', 'file1(1)(4)', 'file1(2)(1)(1)', 'file1(2)(2)(1)', 'file1(2)(1)(1)(1)']\n assert candidate(names = ['album', 'album', 'album', 'album(1)', 'album(2)', 'album', 'album(1)(1)', 'album(1)', 'album(1)(2)', 'album(1)(3)', 'album(1)(4)', 'album(1)(5)', 'album(1)(6)', 'album(1)(7)', 'album(1)(8)', 'album(1)(9)', 'album(1)(10)']) == ['album', 'album(1)', 'album(2)', 'album(1)(1)', 'album(2)(1)', 'album(3)', 'album(1)(1)(1)', 'album(1)(2)', 'album(1)(2)(1)', 'album(1)(3)', 'album(1)(4)', 'album(1)(5)', 'album(1)(6)', 'album(1)(7)', 'album(1)(8)', 'album(1)(9)', 'album(1)(10)']\n assert candidate(names = ['data', 'data', 'data(1)', 'data(2)', 'data', 'data(1)(1)', 'data(1)', 'data(2)', 'data(3)', 'data(2)(1)', 'data(2)(2)', 'data(2)(3)', 'data(2)(1)(1)']) == ['data', 'data(1)', 'data(1)(1)', 'data(2)', 'data(3)', 'data(1)(1)(1)', 'data(1)(2)', 'data(2)(1)', 'data(3)(1)', 'data(2)(1)(1)', 'data(2)(2)', 'data(2)(3)', 'data(2)(1)(1)(1)']\n assert candidate(names = ['photo', 'photo', 'photo(1)', 'photo', 'photo(2)', 'photo(3)', 'photo(1)(1)', 'photo(1)(2)', 'photo(1)']) == ['photo', 'photo(1)', 'photo(1)(1)', 'photo(2)', 'photo(2)(1)', 'photo(3)', 'photo(1)(1)(1)', 'photo(1)(2)', 'photo(1)(3)']\n assert candidate(names = ['video', 'video', 'video(1)', 'video(2)', 'video', 'video(1)', 'video', 'video(1)(1)', 'video(3)', 'video(4)', 'video(2)(2)', 'video(5)', 'video(2)', 'video(6)', 'video(7)', 'video', 'video(8)', 'video(9)', 'video(10)']) == ['video', 'video(1)', 'video(1)(1)', 'video(2)', 'video(3)', 'video(1)(2)', 'video(4)', 'video(1)(1)(1)', 'video(3)(1)', 'video(4)(1)', 'video(2)(2)', 'video(5)', 'video(2)(1)', 'video(6)', 'video(7)', 'video(8)', 'video(8)(1)', 'video(9)', 'video(10)']\n assert candidate(names = ['report', 'report', 'report(1)', 'report', 'report(1)', 'report(2)', 'report(2)', 'report(3)', 'report(3)', 'report(4)', 'report(4)', 'report(5)', 'report(5)']) == ['report', 'report(1)', 'report(1)(1)', 'report(2)', 'report(1)(2)', 'report(2)(1)', 'report(2)(2)', 'report(3)', 'report(3)(1)', 'report(4)', 'report(4)(1)', 'report(5)', 'report(5)(1)']\n assert candidate(names = ['image', 'image', 'image', 'image', 'image(1)', 'image(1)', 'image(2)', 'image', 'image(1)', 'image(2)', 'image(3)', 'image(1)(1)', 'image(1)(2)', 'image(1)(3)', 'image(1)', 'image(2)', 'image(3)', 'image(4)', 'image', 'image(1)', 'image(2)', 'image(3)', 'image(4)', 'image(5)', 'image(1)(1)', 'image(1)(2)', 'image(1)(3)', 'image(1)(4)', 'image(1)(5)', 'image(1)(6)', 'image(1)(7)', 'image(1)(8)', 'image(1)(9)', 'image(1)(10)', 'image(1)(11)', 'image(1)(12)', 'image(1)(13)', 'image(1)(14)', 'image(1)(15)']) == ['image', 'image(1)', 'image(2)', 'image(3)', 'image(1)(1)', 'image(1)(2)', 'image(2)(1)', 'image(4)', 'image(1)(3)', 'image(2)(2)', 'image(3)(1)', 'image(1)(1)(1)', 'image(1)(2)(1)', 'image(1)(3)(1)', 'image(1)(4)', 'image(2)(3)', 'image(3)(2)', 'image(4)(1)', 'image(5)', 'image(1)(5)', 'image(2)(4)', 'image(3)(3)', 'image(4)(2)', 'image(5)(1)', 'image(1)(1)(2)', 'image(1)(2)(2)', 'image(1)(3)(2)', 'image(1)(4)(1)', 'image(1)(5)(1)', 'image(1)(6)', 'image(1)(7)', 'image(1)(8)', 'image(1)(9)', 'image(1)(10)', 'image(1)(11)', 'image(1)(12)', 'image(1)(13)', 'image(1)(14)', 'image(1)(15)']\n assert candidate(names = ['photo', 'photo', 'photo(1)', 'photo', 'photo(1)', 'photo(2)', 'photo(1)(1)', 'photo(1)']) == ['photo', 'photo(1)', 'photo(1)(1)', 'photo(2)', 'photo(1)(2)', 'photo(2)(1)', 'photo(1)(1)(1)', 'photo(1)(3)']\n assert candidate(names = ['data', 'data', 'data(1)', 'data', 'data(1)', 'data(2)', 'data', 'data(1)', 'data(2)', 'data(3)', 'data(1)(1)', 'data(1)(2)', 'data(1)(3)', 'data(1)', 'data(2)', 'data(3)', 'data']) == ['data', 'data(1)', 'data(1)(1)', 'data(2)', 'data(1)(2)', 'data(2)(1)', 'data(3)', 'data(1)(3)', 'data(2)(2)', 'data(3)(1)', 'data(1)(1)(1)', 'data(1)(2)(1)', 'data(1)(3)(1)', 'data(1)(4)', 'data(2)(3)', 'data(3)(2)', 'data(4)']\n assert candidate(names = ['project', 'project', 'project', 'project(1)', 'project', 'project(1)', 'project(2)', 'project(3)']) == ['project', 'project(1)', 'project(2)', 'project(1)(1)', 'project(3)', 'project(1)(2)', 'project(2)(1)', 'project(3)(1)']\n assert candidate(names = ['record', 'record', 'record', 'record(1)', 'record(2)', 'record(3)', 'record', 'record(1)(1)', 'record(1)(2)', 'record(2)(1)', 'record(4)', 'record', 'record(5)', 'record(6)', 'record(1)(1)', 'record(7)', 'record', 'record(2)', 'record(8)', 'record(9)', 'record(10)', 'record(11)']) == ['record', 'record(1)', 'record(2)', 'record(1)(1)', 'record(2)(1)', 'record(3)', 'record(4)', 'record(1)(1)(1)', 'record(1)(2)', 'record(2)(1)(1)', 'record(4)(1)', 'record(5)', 'record(5)(1)', 'record(6)', 'record(1)(1)(2)', 'record(7)', 'record(8)', 'record(2)(2)', 'record(8)(1)', 'record(9)', 'record(10)', 'record(11)']\n assert candidate(names = ['document', 'document', 'document', 'document(1)', 'document', 'document(1)', 'document', 'document(2)', 'document(1)(1)', 'document(1)', 'document(2)', 'document', 'document(1)', 'document(1)(1)', 'document(1)(2)', 'document(1)(3)', 'document(1)(4)', 'document(1)(5)', 'document(1)(6)', 'document(1)(7)', 'document(1)(8)', 'document(1)(9)', 'document(1)(10)', 'document(1)(11)', 'document(1)(12)', 'document(1)(13)', 'document(1)(14)', 'document(1)(15)', 'document(1)(16)', 'document(1)(17)', 'document(1)(18)', 'document(1)(19)', 'document(1)(20)']) == ['document', 'document(1)', 'document(2)', 'document(1)(1)', 'document(3)', 'document(1)(2)', 'document(4)', 'document(2)(1)', 'document(1)(1)(1)', 'document(1)(3)', 'document(2)(2)', 'document(5)', 'document(1)(4)', 'document(1)(1)(2)', 'document(1)(2)(1)', 'document(1)(3)(1)', 'document(1)(4)(1)', 'document(1)(5)', 'document(1)(6)', 'document(1)(7)', 'document(1)(8)', 'document(1)(9)', 'document(1)(10)', 'document(1)(11)', 'document(1)(12)', 'document(1)(13)', 'document(1)(14)', 'document(1)(15)', 'document(1)(16)', 'document(1)(17)', 'document(1)(18)', 'document(1)(19)', 'document(1)(20)']\n assert candidate(names = ['project', 'project', 'project(1)', 'project', 'project(2)', 'project(1)(1)', 'project(1)', 'project(2)(2)', 'project(1)(2)', 'project(2)(1)']) == ['project', 'project(1)', 'project(1)(1)', 'project(2)', 'project(2)(1)', 'project(1)(1)(1)', 'project(1)(2)', 'project(2)(2)', 'project(1)(2)(1)', 'project(2)(1)(1)']\n assert candidate(names = ['game', 'game(1)', 'game', 'game(1)', 'game(2)', 'game', 'game(1)(1)']) == ['game', 'game(1)', 'game(2)', 'game(1)(1)', 'game(2)(1)', 'game(3)', 'game(1)(1)(1)']\n assert candidate(names = ['music', 'music', 'music(1)', 'music', 'music(2)', 'music(3)', 'music', 'music(1)(1)', 'music(4)']) == ['music', 'music(1)', 'music(1)(1)', 'music(2)', 'music(2)(1)', 'music(3)', 'music(4)', 'music(1)(1)(1)', 'music(4)(1)']\n assert candidate(names = ['movie', 'movie', 'movie', 'movie(1)', 'movie', 'movie(1)', 'movie', 'movie(2)', 'movie(1)(1)', 'movie(1)', 'movie(2)']) == ['movie', 'movie(1)', 'movie(2)', 'movie(1)(1)', 'movie(3)', 'movie(1)(2)', 'movie(4)', 'movie(2)(1)', 'movie(1)(1)(1)', 'movie(1)(3)', 'movie(2)(2)']\n assert candidate(names = ['document', 'document(1)', 'document(2)', 'document', 'document(1)', 'document', 'document(3)', 'document(1)(1)', 'document(2)(1)', 'document(4)']) == ['document', 'document(1)', 'document(2)', 'document(3)', 'document(1)(1)', 'document(4)', 'document(3)(1)', 'document(1)(1)(1)', 'document(2)(1)', 'document(4)(1)']\n assert candidate(names = ['data', 'data', 'data', 'data(1)', 'data(2)', 'data(3)', 'data', 'data(1)(1)', 'data(1)(2)', 'data(2)(1)', 'data(4)', 'data', 'data(5)', 'data(6)', 'data(1)(1)', 'data(7)']) == ['data', 'data(1)', 'data(2)', 'data(1)(1)', 'data(2)(1)', 'data(3)', 'data(4)', 'data(1)(1)(1)', 'data(1)(2)', 'data(2)(1)(1)', 'data(4)(1)', 'data(5)', 'data(5)(1)', 'data(6)', 'data(1)(1)(2)', 'data(7)']\n assert candidate(names = ['doc', 'doc', 'doc(1)', 'doc', 'doc(1)', 'doc(2)', 'doc', 'doc(1)(1)', 'doc(1)(2)', 'doc(1)(1)']) == ['doc', 'doc(1)', 'doc(1)(1)', 'doc(2)', 'doc(1)(2)', 'doc(2)(1)', 'doc(3)', 'doc(1)(1)(1)', 'doc(1)(2)(1)', 'doc(1)(1)(2)']\n assert candidate(names = ['test', 'test', 'test', 'test(1)', 'test', 'test(1)', 'test(2)', 'test(1)(1)', 'test(1)(2)', 'test(1)(1)(1)', 'test(1)(1)(2)', 'test(1)(1)(1)(1)']) == ['test', 'test(1)', 'test(2)', 'test(1)(1)', 'test(3)', 'test(1)(2)', 'test(2)(1)', 'test(1)(1)(1)', 'test(1)(2)(1)', 'test(1)(1)(1)(1)', 'test(1)(1)(2)', 'test(1)(1)(1)(1)(1)']\n assert candidate(names = ['file', 'file', 'file(1)', 'file(1)', 'file(2)', 'file(3)', 'file(2)', 'file(1)(1)']) == ['file', 'file(1)', 'file(1)(1)', 'file(1)(2)', 'file(2)', 'file(3)', 'file(2)(1)', 'file(1)(1)(1)']\n assert candidate(names = ['file', 'file', 'file', 'file', 'file(1)', 'file(1)', 'file(2)', 'file(1)(1)', 'file(1)(2)', 'file(1)', 'file(2)']) == ['file', 'file(1)', 'file(2)', 'file(3)', 'file(1)(1)', 'file(1)(2)', 'file(2)(1)', 'file(1)(1)(1)', 'file(1)(2)(1)', 'file(1)(3)', 'file(2)(2)']\n assert candidate(names = ['project', 'project', 'project', 'project', 'project(1)', 'project(1)', 'project', 'project(2)', 'project(1)(1)', 'project(1)', 'project(2)', 'project', 'project(1)', 'project(1)(1)', 'project(1)(2)']) == ['project', 'project(1)', 'project(2)', 'project(3)', 'project(1)(1)', 'project(1)(2)', 'project(4)', 'project(2)(1)', 'project(1)(1)(1)', 'project(1)(3)', 'project(2)(2)', 'project(5)', 'project(1)(4)', 'project(1)(1)(2)', 'project(1)(2)(1)']\n assert candidate(names = ['file', 'file', 'file(1)', 'file(1)', 'file(2)', 'file(2)', 'file(3)']) == ['file', 'file(1)', 'file(1)(1)', 'file(1)(2)', 'file(2)', 'file(2)(1)', 'file(3)']\n assert candidate(names = ['app', 'app', 'app', 'app(1)', 'app(1)', 'app(2)', 'app', 'app(1)(1)', 'app(1)(2)', 'app(1)(1)(1)', 'app(1)(1)(2)', 'app(1)(1)(1)(1)', 'app(3)', 'app(4)', 'app(5)', 'app(1)(3)', 'app(1)(4)', 'app(2)(1)', 'app(2)(2)', 'app(2)(1)(1)', 'app(5)', 'app(1)', 'app(2)', 'app(3)', 'app(1)(1)', 'app(1)(2)', 'app(1)(1)(1)', 'app(1)(1)(2)', 'app(1)(1)(1)(1)', 'app(6)', 'app(7)', 'app(8)', 'app(1)(5)', 'app(1)(6)', 'app(2)(3)', 'app(2)(4)', 'app(2)(1)(2)']) == ['app', 'app(1)', 'app(2)', 'app(1)(1)', 'app(1)(2)', 'app(2)(1)', 'app(3)', 'app(1)(1)(1)', 'app(1)(2)(1)', 'app(1)(1)(1)(1)', 'app(1)(1)(2)', 'app(1)(1)(1)(1)(1)', 'app(3)(1)', 'app(4)', 'app(5)', 'app(1)(3)', 'app(1)(4)', 'app(2)(1)(1)', 'app(2)(2)', 'app(2)(1)(1)(1)', 'app(5)(1)', 'app(1)(5)', 'app(2)(3)', 'app(3)(2)', 'app(1)(1)(3)', 'app(1)(2)(2)', 'app(1)(1)(1)(2)', 'app(1)(1)(2)(1)', 'app(1)(1)(1)(1)(2)', 'app(6)', 'app(7)', 'app(8)', 'app(1)(5)(1)', 'app(1)(6)', 'app(2)(3)(1)', 'app(2)(4)', 'app(2)(1)(2)']\n assert candidate(names = ['report', 'report', 'report(1)', 'report(2)', 'report(1)(1)', 'report', 'report(1)', 'report(2)', 'report(1)(1)', 'report(1)(2)', 'report(2)(1)', 'report(2)(2)', 'report(2)(3)', 'report(1)(2)(1)', 'report(1)(1)(1)']) == ['report', 'report(1)', 'report(1)(1)', 'report(2)', 'report(1)(1)(1)', 'report(3)', 'report(1)(2)', 'report(2)(1)', 'report(1)(1)(2)', 'report(1)(2)(1)', 'report(2)(1)(1)', 'report(2)(2)', 'report(2)(3)', 'report(1)(2)(1)(1)', 'report(1)(1)(1)(1)']\n assert candidate(names = ['test', 'test', 'test(1)', 'test(2)', 'test', 'test(1)(1)', 'test(1)', 'test(2)', 'test(3)', 'test(2)(1)', 'test(2)(2)', 'test(2)(3)', 'test(1)(2)(1)', 'test(1)(1)(1)', 'test(1)(1)(2)', 'test(1)(1)(1)(1)', 'test(1)(1)(1)(2)']) == ['test', 'test(1)', 'test(1)(1)', 'test(2)', 'test(3)', 'test(1)(1)(1)', 'test(1)(2)', 'test(2)(1)', 'test(3)(1)', 'test(2)(1)(1)', 'test(2)(2)', 'test(2)(3)', 'test(1)(2)(1)', 'test(1)(1)(1)(1)', 'test(1)(1)(2)', 'test(1)(1)(1)(1)(1)', 'test(1)(1)(1)(2)']\n assert candidate(names = ['example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example', 'example']) == ['example', 'example(1)', 'example(2)', 'example(3)', 'example(4)', 'example(5)', 'example(6)', 'example(7)', 'example(8)', 'example(9)', 'example(10)', 'example(11)', 'example(12)', 'example(13)', 'example(14)', 'example(15)', 'example(16)', 'example(17)', 'example(18)', 'example(19)', 'example(20)', 'example(21)', 'example(22)', 'example(23)', 'example(24)', 'example(25)', 'example(26)', 'example(27)', 'example(28)', 'example(29)', 'example(30)', 'example(31)', 'example(32)', 'example(33)', 'example(34)', 'example(35)', 'example(36)', 'example(37)', 'example(38)', 'example(39)', 'example(40)', 'example(41)', 'example(42)', 'example(43)', 'example(44)', 'example(45)', 'example(46)', 'example(47)', 'example(48)', 'example(49)', 'example(50)', 'example(51)', 'example(52)', 'example(53)', 'example(54)', 'example(55)', 'example(56)', 'example(57)']\n assert candidate(names = ['file', 'file', 'file', 'file(1)', 'file(2)', 'file', 'file(3)', 'file(1)(1)', 'file(2)(1)', 'file(1)', 'file(4)', 'file(1)(2)', 'file(5)', 'file(2)', 'file(6)']) == ['file', 'file(1)', 'file(2)', 'file(1)(1)', 'file(2)(1)', 'file(3)', 'file(3)(1)', 'file(1)(1)(1)', 'file(2)(1)(1)', 'file(1)(2)', 'file(4)', 'file(1)(2)(1)', 'file(5)', 'file(2)(2)', 'file(6)']\n assert candidate(names = ['movie', 'movie', 'movie', 'movie(1)', 'movie(2)', 'movie(3)', 'movie', 'movie(1)(1)', 'movie(1)(2)', 'movie(2)(1)', 'movie(4)', 'movie', 'movie(5)', 'movie(6)', 'movie(1)(1)', 'movie(7)', 'movie', 'movie(2)', 'movie(8)']) == ['movie', 'movie(1)', 'movie(2)', 'movie(1)(1)', 'movie(2)(1)', 'movie(3)', 'movie(4)', 'movie(1)(1)(1)', 'movie(1)(2)', 'movie(2)(1)(1)', 'movie(4)(1)', 'movie(5)', 'movie(5)(1)', 'movie(6)', 'movie(1)(1)(2)', 'movie(7)', 'movie(8)', 'movie(2)(2)', 'movie(8)(1)']\n assert candidate(names = ['file', 'file', 'file', 'file', 'file', 'file', 'file', 'file', 'file', 'file(1)', 'file(1)', 'file(2)', 'file(2)']) == ['file', 'file(1)', 'file(2)', 'file(3)', 'file(4)', 'file(5)', 'file(6)', 'file(7)', 'file(8)', 'file(1)(1)', 'file(1)(2)', 'file(2)(1)', 'file(2)(2)']\n assert candidate(names = ['alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha', 'alpha']) == ['alpha', 'alpha(1)', 'alpha(2)', 'alpha(3)', 'alpha(4)', 'alpha(5)', 'alpha(6)', 'alpha(7)', 'alpha(8)', 'alpha(9)', 'alpha(10)', 'alpha(11)', 'alpha(12)', 'alpha(13)', 'alpha(14)', 'alpha(15)', 'alpha(16)', 'alpha(17)', 'alpha(18)', 'alpha(19)']\n assert candidate(names = ['doc', 'doc', 'doc', 'doc(1)', 'doc', 'doc(1)', 'doc(2)', 'doc(1)(1)', 'doc(1)(1)', 'doc(1)(2)']) == ['doc', 'doc(1)', 'doc(2)', 'doc(1)(1)', 'doc(3)', 'doc(1)(2)', 'doc(2)(1)', 'doc(1)(1)(1)', 'doc(1)(1)(2)', 'doc(1)(2)(1)']\n assert candidate(names = ['report', 'report', 'report', 'report(1)', 'report', 'report(1)', 'report', 'report(2)', 'report(1)(1)', 'report(1)', 'report(2)', 'report', 'report(1)', 'report(1)(1)', 'report(1)(2)', 'report(1)(3)', 'report(1)(4)', 'report(1)(5)', 'report(1)(6)', 'report(1)(7)', 'report(1)(8)', 'report(1)(9)', 'report(1)(10)', 'report(1)(11)', 'report(1)(12)', 'report(1)(13)', 'report(1)(14)', 'report(1)(15)']) == ['report', 'report(1)', 'report(2)', 'report(1)(1)', 'report(3)', 'report(1)(2)', 'report(4)', 'report(2)(1)', 'report(1)(1)(1)', 'report(1)(3)', 'report(2)(2)', 'report(5)', 'report(1)(4)', 'report(1)(1)(2)', 'report(1)(2)(1)', 'report(1)(3)(1)', 'report(1)(4)(1)', 'report(1)(5)', 'report(1)(6)', 'report(1)(7)', 'report(1)(8)', 'report(1)(9)', 'report(1)(10)', 'report(1)(11)', 'report(1)(12)', 'report(1)(13)', 'report(1)(14)', 'report(1)(15)']\n assert candidate(names = ['doc', 'doc(1)', 'image', 'image', 'doc', 'doc(1)', 'doc(2)', 'doc(2)', 'image(1)', 'image(1)']) == ['doc', 'doc(1)', 'image', 'image(1)', 'doc(2)', 'doc(1)(1)', 'doc(2)(1)', 'doc(2)(2)', 'image(1)(1)', 'image(1)(2)']\n assert candidate(names = ['video', 'video', 'video', 'video', 'video(1)', 'video(1)', 'video(2)', 'video', 'video(1)', 'video(2)', 'video(3)', 'video(1)(1)', 'video(1)(2)', 'video(1)(3)', 'video(1)', 'video(2)', 'video(3)', 'video(4)', 'video', 'video(1)', 'video(2)', 'video(3)', 'video(4)', 'video(5)', 'video(1)(1)', 'video(1)(2)', 'video(1)(3)', 'video(1)(4)', 'video(1)(5)', 'video(1)(6)']) == ['video', 'video(1)', 'video(2)', 'video(3)', 'video(1)(1)', 'video(1)(2)', 'video(2)(1)', 'video(4)', 'video(1)(3)', 'video(2)(2)', 'video(3)(1)', 'video(1)(1)(1)', 'video(1)(2)(1)', 'video(1)(3)(1)', 'video(1)(4)', 'video(2)(3)', 'video(3)(2)', 'video(4)(1)', 'video(5)', 'video(1)(5)', 'video(2)(4)', 'video(3)(3)', 'video(4)(2)', 'video(5)(1)', 'video(1)(1)(2)', 'video(1)(2)(2)', 'video(1)(3)(2)', 'video(1)(4)(1)', 'video(1)(5)(1)', 'video(1)(6)']\n assert candidate(names = ['game', 'game', 'game', 'game(1)', 'game(1)', 'game(2)', 'game', 'game(1)(1)', 'game(1)(1)']) == ['game', 'game(1)', 'game(2)', 'game(1)(1)', 'game(1)(2)', 'game(2)(1)', 'game(3)', 'game(1)(1)(1)', 'game(1)(1)(2)']\n assert candidate(names = ['photo', 'photo(1)', 'photo', 'photo(1)', 'photo(2)', 'photo(1)(1)', 'photo(2)(1)']) == ['photo', 'photo(1)', 'photo(2)', 'photo(1)(1)', 'photo(2)(1)', 'photo(1)(1)(1)', 'photo(2)(1)(1)']\n assert candidate(names = ['test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test', 'test']) == ['test', 'test(1)', 'test(2)', 'test(3)', 'test(4)', 'test(5)', 'test(6)', 'test(7)', 'test(8)', 'test(9)', 'test(10)', 'test(11)', 'test(12)', 'test(13)', 'test(14)', 'test(15)', 'test(16)']\n assert candidate(names = ['report', 'report', 'report(1)', 'report(2)', 'report', 'report(1)', 'report', 'report(1)(1)', 'report(3)', 'report(4)', 'report(2)(2)', 'report(5)', 'report(2)', 'report(6)', 'report(7)']) == ['report', 'report(1)', 'report(1)(1)', 'report(2)', 'report(3)', 'report(1)(2)', 'report(4)', 'report(1)(1)(1)', 'report(3)(1)', 'report(4)(1)', 'report(2)(2)', 'report(5)', 'report(2)(1)', 'report(6)', 'report(7)']\n assert candidate(names = ['report', 'report', 'report', 'report', 'report(1)', 'report(1)', 'report(2)', 'report', 'report(1)(1)', 'report(1)(2)', 'report(1)', 'report(2)', 'report(3)', 'report']) == ['report', 'report(1)', 'report(2)', 'report(3)', 'report(1)(1)', 'report(1)(2)', 'report(2)(1)', 'report(4)', 'report(1)(1)(1)', 'report(1)(2)(1)', 'report(1)(3)', 'report(2)(2)', 'report(3)(1)', 'report(5)']\n assert candidate(names = ['file', 'file(1)', 'file', 'file(2)', 'file', 'file(1)', 'file', 'file(1)(1)', 'file(3)', 'file(4)', 'file(2)(2)']) == ['file', 'file(1)', 'file(2)', 'file(2)(1)', 'file(3)', 'file(1)(1)', 'file(4)', 'file(1)(1)(1)', 'file(3)(1)', 'file(4)(1)', 'file(2)(2)']\n assert candidate(names = ['log', 'log', 'log(1)', 'log(2)', 'log', 'log(1)(1)', 'log(1)', 'log(2)', 'log(3)', 'log(2)(1)', 'log(2)(2)', 'log(2)(3)', 'log(1)(2)(1)', 'log(1)(1)(1)', 'log(1)(1)(2)', 'log(1)(1)(1)(1)', 'log(1)(1)(1)(2)', 'log(3)(1)', 'log(3)(2)', 'log(3)(3)', 'log(3)(2)(1)']) == ['log', 'log(1)', 'log(1)(1)', 'log(2)', 'log(3)', 'log(1)(1)(1)', 'log(1)(2)', 'log(2)(1)', 'log(3)(1)', 'log(2)(1)(1)', 'log(2)(2)', 'log(2)(3)', 'log(1)(2)(1)', 'log(1)(1)(1)(1)', 'log(1)(1)(2)', 'log(1)(1)(1)(1)(1)', 'log(1)(1)(1)(2)', 'log(3)(1)(1)', 'log(3)(2)', 'log(3)(3)', 'log(3)(2)(1)']\n assert candidate(names = ['game', 'game(1)', 'game(2)', 'game(3)', 'game', 'game(1)', 'game(4)']) == ['game', 'game(1)', 'game(2)', 'game(3)', 'game(4)', 'game(1)(1)', 'game(4)(1)']\n assert candidate(names = ['image', 'image', 'image', 'image(1)', 'image(2)', 'image(3)', 'image', 'image(1)(1)', 'image(1)(2)', 'image(2)(1)', 'image(4)', 'image', 'image(5)', 'image(6)', 'image(1)(1)', 'image(7)', 'image', 'image(2)', 'image(8)', 'image(9)', 'image(10)', 'image(11)', 'image', 'image(12)', 'image', 'image(13)', 'image', 'image(14)', 'image', 'image(15)', 'image', 'image(16)', 'image', 'image(17)']) == ['image', 'image(1)', 'image(2)', 'image(1)(1)', 'image(2)(1)', 'image(3)', 'image(4)', 'image(1)(1)(1)', 'image(1)(2)', 'image(2)(1)(1)', 'image(4)(1)', 'image(5)', 'image(5)(1)', 'image(6)', 'image(1)(1)(2)', 'image(7)', 'image(8)', 'image(2)(2)', 'image(8)(1)', 'image(9)', 'image(10)', 'image(11)', 'image(12)', 'image(12)(1)', 'image(13)', 'image(13)(1)', 'image(14)', 'image(14)(1)', 'image(15)', 'image(15)(1)', 'image(16)', 'image(16)(1)', 'image(17)', 'image(17)(1)']\n assert candidate(names = ['game', 'game', 'game(1)', 'game', 'game(1)', 'game(2)', 'game(2)']) == ['game', 'game(1)', 'game(1)(1)', 'game(2)', 'game(1)(2)', 'game(2)(1)', 'game(2)(2)']\n assert candidate(names = ['data', 'data', 'data', 'data(1)', 'data', 'data(1)', 'data(2)', 'data(1)(1)', 'data(1)(2)', 'data(1)(1)(1)']) == ['data', 'data(1)', 'data(2)', 'data(1)(1)', 'data(3)', 'data(1)(2)', 'data(2)(1)', 'data(1)(1)(1)', 'data(1)(2)(1)', 'data(1)(1)(1)(1)']\n assert candidate(names = ['music', 'music', 'music', 'music', 'music(1)', 'music(1)', 'music(2)', 'music', 'music(1)', 'music(2)', 'music(3)', 'music(1)(1)', 'music(1)(2)', 'music(1)(3)', 'music(1)', 'music(2)', 'music(3)', 'music(4)', 'music', 'music(1)', 'music(2)', 'music(3)', 'music(4)', 'music(5)', 'music(1)(1)', 'music(1)(2)', 'music(1)(3)', 'music(1)(4)', 'music(1)(5)', 'music(1)(6)', 'music(1)(7)', 'music(1)(8)', 'music(1)(9)', 'music(1)(10)']) == ['music', 'music(1)', 'music(2)', 'music(3)', 'music(1)(1)', 'music(1)(2)', 'music(2)(1)', 'music(4)', 'music(1)(3)', 'music(2)(2)', 'music(3)(1)', 'music(1)(1)(1)', 'music(1)(2)(1)', 'music(1)(3)(1)', 'music(1)(4)', 'music(2)(3)', 'music(3)(2)', 'music(4)(1)', 'music(5)', 'music(1)(5)', 'music(2)(4)', 'music(3)(3)', 'music(4)(2)', 'music(5)(1)', 'music(1)(1)(2)', 'music(1)(2)(2)', 'music(1)(3)(2)', 'music(1)(4)(1)', 'music(1)(5)(1)', 'music(1)(6)', 'music(1)(7)', 'music(1)(8)', 'music(1)(9)', 'music(1)(10)']\n assert candidate(names = ['doc', 'doc', 'doc(1)', 'doc', 'doc(1)', 'doc(2)', 'doc', 'doc(1)', 'doc(2)', 'doc(3)', 'doc']) == ['doc', 'doc(1)', 'doc(1)(1)', 'doc(2)', 'doc(1)(2)', 'doc(2)(1)', 'doc(3)', 'doc(1)(3)', 'doc(2)(2)', 'doc(3)(1)', 'doc(4)']\n assert candidate(names = ['movie', 'movie', 'movie', 'movie', 'movie(1)', 'movie(1)', 'movie(2)', 'movie(2)', 'movie(3)', 'movie(3)']) == ['movie', 'movie(1)', 'movie(2)', 'movie(3)', 'movie(1)(1)', 'movie(1)(2)', 'movie(2)(1)', 'movie(2)(2)', 'movie(3)(1)', 'movie(3)(2)']\n assert candidate(names = ['photo', 'photo', 'photo(1)', 'photo', 'photo(2)', 'photo(1)', 'photo(3)', 'photo(4)']) == ['photo', 'photo(1)', 'photo(1)(1)', 'photo(2)', 'photo(2)(1)', 'photo(1)(2)', 'photo(3)', 'photo(4)']\n assert candidate(names = ['game', 'game', 'game', 'game(1)', 'game(2)', 'game', 'game(1)(1)', 'game(1)']) == ['game', 'game(1)', 'game(2)', 'game(1)(1)', 'game(2)(1)', 'game(3)', 'game(1)(1)(1)', 'game(1)(2)']\n assert candidate(names = ['doc', 'doc', 'doc', 'doc', 'doc', 'doc(1)', 'doc(2)', 'doc', 'doc(3)', 'doc(1)(1)']) == ['doc', 'doc(1)', 'doc(2)', 'doc(3)', 'doc(4)', 'doc(1)(1)', 'doc(2)(1)', 'doc(5)', 'doc(3)(1)', 'doc(1)(1)(1)']\n"}, "metadata": {"canonical_parameter_names": ["names"], "leetcode_dataset_entry_point": "Solution().getFolderNames", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector getFolderNames(vector& names) {", "container": "Solution", "callable": "getFolderNames", "parameters": [{"name": "names", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1488, "task_id": "avoid-flood-in-the-city", "difficulty": "Medium", "problem_description": "Your country has an infinite number of lakes. Initially, all the lakes are empty, but when it rains over the nth lake, the nth lake becomes full of water. If it rains over a lake that is full of water, there will be a flood. Your goal is to avoid floods in any lake.\nGiven an integer array rains where:\n\nrains[i] > 0 means there will be rains over the rains[i] lake.\nrains[i] == 0 means there are no rains this day and you can choose one lake this day and dry it.\n\nReturn an array ans where:\n\nans.length == rains.length\nans[i] == -1 if rains[i] > 0.\nans[i] is the lake you choose to dry in the ith day if rains[i] == 0.\n\nIf there are multiple valid answers return any of them. If it is impossible to avoid flood return an empty array.\nNotice that if you chose to dry a full lake, it becomes empty, but if you chose to dry an empty lake, nothing changes.\n \nExample 1:\n\nInput: rains = [1,2,3,4]\nOutput: [-1,-1,-1,-1]\nExplanation: After the first day full lakes are [1]\nAfter the second day full lakes are [1,2]\nAfter the third day full lakes are [1,2,3]\nAfter the fourth day full lakes are [1,2,3,4]\nThere's no day to dry any lake and there is no flood in any lake.\n\nExample 2:\n\nInput: rains = [1,2,0,0,2,1]\nOutput: [-1,-1,2,1,-1,-1]\nExplanation: After the first day full lakes are [1]\nAfter the second day full lakes are [1,2]\nAfter the third day, we dry lake 2. Full lakes are [1]\nAfter the fourth day, we dry lake 1. There is no full lakes.\nAfter the fifth day, full lakes are [2].\nAfter the sixth day, full lakes are [1,2].\nIt is easy that this scenario is flood-free. [-1,-1,1,2,-1,-1] is another acceptable scenario.\n\nExample 3:\n\nInput: rains = [1,2,0,1,2]\nOutput: []\nExplanation: After the second day, full lakes are [1,2]. We have to dry one lake in the third day.\nAfter that, it will rain over lakes [1,2]. It's easy to prove that no matter which lake you choose to dry in the 3rd day, the other one will flood.\n\n \nConstraints:\n\n1 <= rains.length <= 105\n0 <= rains[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rains = [0, 1, 1, 0, 2, 0, 1]) == []\n assert candidate(rains = [1, 2, 0, 1, 2]) == []\n assert candidate(rains = [1, 0, 2, 0, 0, 1, 0, 2]) == [-1, 1, -1, 2, 1, -1, 1, -1]\n assert candidate(rains = [0, 0, 0, 0]) == [1, 1, 1, 1]\n assert candidate(rains = [1, 2, 0, 0, 2, 1]) == [-1, -1, 2, 1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 2, 1]) == [-1, 1, -1, 2, -1, -1]\n assert candidate(rains = [1, 2, 3, 0, 0, 1, 2, 3]) == []\n assert candidate(rains = [2, 3, 0, 0, 3, 1, 0, 1, 0, 1]) == [-1, -1, 3, 1, -1, -1, 1, -1, 1, -1]\n assert candidate(rains = [0, 1, 0, 2, 0, 1, 0, 2]) == [1, -1, 1, -1, 2, -1, 1, -1]\n assert candidate(rains = [1, 2, 0, 2, 1, 0, 1, 0]) == []\n assert candidate(rains = [1, 2, 0, 0, 2, 0, 1, 0]) == [-1, -1, 2, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 4]) == [-1, -1, -1, -1]\n assert candidate(rains = [0, 1, 1]) == []\n assert candidate(rains = [1, 2, 0, 0, 0, 1, 2]) == [-1, -1, 1, 2, 1, -1, -1]\n assert candidate(rains = [1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 6, 0, 0, 7, 0, 0]) == [-1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 1]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0]) == [-1, 1, -1, 2, -1, 3, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0]) == [-1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 10, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == []\n assert candidate(rains = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == []\n assert candidate(rains = [0, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0, 20]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 10, -1, 11, -1, 12, -1, 13, -1, 14, -1, 15, -1, 16, -1, 17, -1, 18, -1, 19, -1, 20, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3]) == [-1, 1, -1, 2, -1, 3, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0]) == [-1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [-1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 2, 0, 3, 4, 0, 5, 6, 0, 7, 8, 0, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == []\n assert candidate(rains = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1]) == []\n assert candidate(rains = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == []\n assert candidate(rains = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == []\n assert candidate(rains = [1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0]) == [-1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1]\n assert candidate(rains = [1, 0, 2, 3, 4, 0, 0, 1, 2, 3, 4, 0, 0, 1, 2, 3, 4, 0, 0, 1, 2, 3, 4]) == []\n assert candidate(rains = [1, 2, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, 2, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3]) == [-1, -1, -1, 1, -1, 2, -1, 3, -1, 1, -1, 2, -1, 3, -1, 1, -1, 2, -1, 3, -1]\n assert candidate(rains = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5]) == [-1, -1, -1, -1, -1, 1, 2, 3, 4, 5, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0, 20]) == []\n assert candidate(rains = [1, 2, 0, 0, 2, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]) == [-1, -1, 2, 1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 0, 1, 0, 2, 0, 2, 0, 3, 0, 3, 0, 4, 0, 4, 0, 5, 0, 5, 0]) == [-1, 1, -1, 1, -1, 2, -1, 1, -1, 3, -1, 1, -1, 4, -1, 1, -1, 5, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 4, 5, 0, 6, 7, 0, 8, 9, 0, 10, 11, 0, 12, 13, 0, 14, 15, 0, 16, 17, 0, 18, 19, 0, 20]) == [-1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 1]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 0, 1, 2, 3, 4, 5]) == []\n assert candidate(rains = [1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0]) == [-1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 0, 1, 2, 3, 0, 3, 4, 0, 4, 5, 0, 5, 6, 0, 6, 7, 0, 7, 8, 0, 8, 9, 0, 9, 10, 0, 10]) == []\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3]) == [-1, 1, -1, 2, -1, 3, -1, 1, -1, 2, -1, 3, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 0, 4, 5, 0, 1, 2, 3, 0, 4, 5, 0, 1, 2, 3, 0, 4, 5]) == []\n assert candidate(rains = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [3, 0, 4, 0, 5, 0, 3, 0, 4, 0, 5]) == [-1, 3, -1, 4, -1, 5, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 0, 0, 0, 0, 5, 6, 7, 8, 0, 0, 0, 0]) == [-1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1, 1, 1, 1, 1]\n assert candidate(rains = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 1, 0, 2, 0, 3, 0]) == [-1, 1, -1, 2, -1, 3, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5]) == [-1, -1, -1, -1, -1, 1, 2, 3, 4, 5, 1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == []\n assert candidate(rains = [1, 2, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0]) == [-1, -1, -1, 1, -1, 2, -1, 3, -1, 1, -1, 2, -1, 3, -1, 1]\n assert candidate(rains = [1, 0, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, 0, 0, 5, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 4, 0, 0, 0, 0, 5, 0, 0, 0, 0]) == [-1, 1, 1, 1, 1, -1, 2, 1, 1, -1, 3, 1, 1, 1, -1, 4, 1, 1, 1, -1, 5, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 2, 0, 0, 2, 0, 1, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == []\n assert candidate(rains = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]) == []\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 1]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [0, 0, 0, 1, 2, 3, 4, 0, 0, 1, 2, 3, 4, 0, 0, 0, 1, 2, 3, 4]) == []\n assert candidate(rains = [1, 2, 3, 0, 0, 0, 1, 2, 3, 0, 0, 0, 1, 2, 3, 0, 0, 0, 1, 2, 3, 0, 0, 0, 1, 2, 3]) == [-1, -1, -1, 1, 2, 3, -1, -1, -1, 1, 2, 3, -1, -1, -1, 1, 2, 3, -1, -1, -1, 1, 2, 3, -1, -1, -1]\n assert candidate(rains = [1, 2, 0, 0, 0, 0, 2, 0, 1, 0, 0, 0, 1, 0, 0, 0]) == [-1, -1, 2, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1]\n assert candidate(rains = [1, 0, 0, 2, 0, 0, 2, 0, 3, 0, 0, 3, 0, 0, 4, 0, 0, 4, 0, 0, 5, 0, 0, 5]) == [-1, 1, 1, -1, 2, 1, -1, 1, -1, 3, 1, -1, 1, 1, -1, 4, 1, -1, 1, 1, -1, 5, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 1, 0, 2, 0, 3, 0, 4]) == [-1, 1, -1, 2, -1, 3, -1, 4, -1, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0]) == [-1, 1, -1, 2, -1, 3, -1, 2, -1, 1, -1, 3, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0]) == []\n assert candidate(rains = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]) == [-1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6]) == [-1, -1, -1, -1, -1, -1, 1, 2, 3, 4, 5, 6, 1, -1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 2, 3, 0, 0, 0, 4, 5, 6, 0, 0, 0, 7, 8, 9, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1, 7, -1, 8, -1, 9, -1, 10, -1, 1]\n assert candidate(rains = [1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 6, 0, 0, 7, 0, 0, 8, 0, 0, 9, 0, 0, 10, 0, 0]) == [-1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1, -1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 5, 0, 4, 0, 3, 0, 2, 0, 1, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5]) == [-1, -1, -1, -1, -1, 5, -1, 4, -1, 3, -1, 2, -1, 1, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1]\n assert candidate(rains = [1, 2, 0, 3, 4, 0, 5, 6, 0, 7, 8, 0, 9, 10, 0, 11, 12, 0, 13, 14]) == [-1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0]) == []\n assert candidate(rains = [1, 0, 2, 0, 1, 0, 2]) == [-1, 1, -1, 2, -1, 1, -1]\n assert candidate(rains = [1, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 1, 0, 2, 0, 3, 0, 4, 0]) == [-1, -1, 1, -1, 2, -1, 3, -1, 4, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 0, 2, 0, 3, 0, 0, 1, 0, 2, 0, 3, 0, 0, 1, 0, 2, 0, 3]) == [-1, 1, 1, -1, 2, -1, 3, 1, -1, 1, -1, 2, -1, 3, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 1, 0, 0, 0, 2, 2, 0, 0, 3, 3, 0, 0, 4, 4, 0, 0, 5, 5, 0, 0]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6]) == [-1, -1, -1, -1, -1, -1, 1, 2, 3, 4, 5, 6, -1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 0, 0, 0, 0, 3, 0, 4, 0, 0, 0, 5, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, 1, -1, 2, 1, 1, 1, 1, -1, 3, -1, 4, 1, 1, -1, 5, 1, 1, -1, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0, 5, 0, 0, 0, 6, 0, 0, 0, 7, 0, 0, 0, 8, 0, 0, 0, 9, 0, 0, 0, 10, 0, 0, 0]) == [-1, -1, 1, 2, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1]\n assert candidate(rains = [1, 0, 0, 2, 0, 0, 1, 0, 0, 2, 0, 0, 1, 0, 0, 2, 0, 0]) == [-1, 1, 1, -1, 2, 1, -1, 1, 1, -1, 2, 1, -1, 1, 1, -1, 1, 1]\n assert candidate(rains = [1, 1, 0, 2, 2, 0, 3, 3, 0, 4, 4, 0, 5, 5, 0, 6, 6, 0, 7, 7, 0, 8, 8, 0, 9, 9, 0]) == []\n assert candidate(rains = [1, 0, 2, 0, 1, 0, 2, 3, 0, 4, 0, 5, 0, 4]) == [-1, 1, -1, 2, -1, 1, -1, -1, 1, -1, 4, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5]) == [-1, -1, -1, -1, -1, 1, 2, 3, 4, 5, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, 1, 2, 3, 4, 5, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0, 20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == []\n assert candidate(rains = [1, 0, 2, 0, 2, 0, 1, 0, 1, 0, 2, 0]) == [-1, 1, -1, 2, -1, 2, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1000000000, 0, 1000000000, 0, 1000000000, 0, 1000000000, 0]) == [-1, 1000000000, -1, 1000000000, -1, 1000000000, -1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 1, 2, 3, 4, 5, 0, 0, 1, 2, 3, 4, 5]) == []\n assert candidate(rains = [1, 2, 3, 4, 0, 0, 0, 0, 1, 2, 3, 4]) == [-1, -1, -1, -1, 1, 2, 3, 4, -1, -1, -1, -1]\n assert candidate(rains = [1, 0, 2, 3, 0, 1, 2, 0, 3, 4, 0, 5, 4, 0, 3, 2, 1, 0]) == []\n assert candidate(rains = [1, 1, 0, 0]) == []\n assert candidate(rains = [0, 1, 2, 3, 0, 1, 2]) == []\n assert candidate(rains = [1, 2, 0, 0, 0, 1, 2, 0, 0, 1]) == [-1, -1, 1, 2, 1, -1, -1, 1, 1, -1]\n assert candidate(rains = [1, 1, 0, 2, 0, 2, 1]) == []\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1]\n assert candidate(rains = [0]) == [1]\n assert candidate(rains = [1, 0, 1, 0, 1, 0]) == [-1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 2, 0, 0, 0, 0, 2]) == [-1, 1, -1, 2, 1, 1, 1, -1]\n assert candidate(rains = [1, 1, 1, 0, 2, 0, 1, 0]) == []\n assert candidate(rains = [1, 0, 2, 0, 2, 0, 1]) == [-1, 1, -1, 2, -1, 1, -1]\n assert candidate(rains = [1, 2, 0, 1, 2]) == []\n assert candidate(rains = [1, 2, 3, 0, 0, 0, 1, 2, 3]) == [-1, -1, -1, 1, 2, 3, -1, -1, -1]\n assert candidate(rains = [1, 1, 2, 2, 0, 0]) == []\n assert candidate(rains = [1, 2, 3, 0, 4, 0, 5, 0, 6, 0, 1, 2, 3, 4, 5, 6]) == []\n assert candidate(rains = [1, 0, 2, 0, 2, 0, 1]) == [-1, 1, -1, 2, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 0, 0, 0, 3, 0, 2, 0, 1]) == [-1, -1, -1, 3, 2, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 0, 2, 3, 0, 1, 2]) == [-1, 1, -1, -1, 2, -1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 0, 0]) == [-1, -1, -1, -1, -1, 1, 1, 1, 1]\n assert candidate(rains = [1, 0, 2, 0, 2, 0, 1, 0, 2]) == [-1, 1, -1, 2, -1, 2, -1, 1, -1]\n assert candidate(rains = [0, 0, 0, 0]) == [1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 0, 1, 2, 3]) == []\n assert candidate(rains = [1, 2, 3, 0, 0, 0, 3, 2, 1]) == [-1, -1, -1, 3, 2, 1, -1, -1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(rains = [1, 2, 0, 0, 2, 0, 1]) == [-1, -1, 2, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 0, 2, 0, 0, 1, 2]) == [-1, 1, 1, -1, 2, 1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 2, 0, 1, 0, 3, 0]) == [-1, 1, -1, 2, -1, 3, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 1, 0, 2, 0, 3]) == [-1, -1, -1, 1, -1, 2, -1, 3, -1]\n assert candidate(rains = [1, 1, 1, 0, 2, 0, 2]) == []\n assert candidate(rains = [1, 2, 0, 1, 2, 0]) == []\n assert candidate(rains = [1, 0, 2, 3, 0, 1, 0, 2, 3]) == [-1, 1, -1, -1, 2, -1, 3, -1, -1]\n assert candidate(rains = [1, 0, 2, 3, 0, 0, 1, 2]) == [-1, 1, -1, -1, 2, 1, -1, -1]\n assert candidate(rains = [2, 3, 0, 0, 2, 1, 0, 1, 2]) == []\n assert candidate(rains = [1, 1, 0, 0, 2, 2]) == []\n assert candidate(rains = [0, 1, 0, 2, 0, 3, 0, 1, 2, 3]) == [1, -1, 1, -1, 2, -1, 3, -1, -1, -1]\n assert candidate(rains = [1, 0, 0, 0, 0, 2, 1]) == [-1, 1, 1, 1, 1, -1, -1]\n assert candidate(rains = [1, 0, 0, 0, 0, 2, 0, 2]) == [-1, 1, 1, 1, 1, -1, 2, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 1, 2, 3, 4, 0, 5]) == [-1, 1, -1, 2, -1, 3, -1, 4, -1, -1, -1, -1, 1, -1]\n assert candidate(rains = [1, 2, 0, 0, 3, 0, 1, 0, 2, 0, 3]) == [-1, -1, 1, 2, -1, 3, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 0, 4, 0, 5, 0, 1, 2, 3]) == [-1, -1, -1, 1, -1, 2, -1, 3, -1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 1, 2]) == [-1, 1, -1, 2, -1, -1]\n assert candidate(rains = [1, 1, 1, 0, 2, 0, 2]) == []\n assert candidate(rains = [1, 2, 3, 0, 1, 0, 2, 0, 3, 0]) == [-1, -1, -1, 1, -1, 2, -1, 3, -1, 1]\n assert candidate(rains = [0, 0, 0, 0, 0]) == [1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 5, 0, 1, 2, 3, 4, 5]) == []\n assert candidate(rains = [1, 0, 1, 0, 1, 0, 1, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 0, 0, 2, 0, 1, 0]) == [-1, 1, 1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 2, 0, 0, 0, 0, 1, 0, 2]) == [-1, 1, -1, 2, 1, 1, 1, -1, 1, -1]\n assert candidate(rains = [1, 0, 0, 0, 0, 0, 1]) == [-1, 1, 1, 1, 1, 1, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 1, 0, 2, 2, 0, 3, 3]) == []\n assert candidate(rains = [0, 0, 0, 0, 1, 1, 1, 1]) == []\n assert candidate(rains = [1, 2, 3, 0, 0, 0, 0, 1, 2, 3]) == [-1, -1, -1, 1, 2, 3, 1, -1, -1, -1]\n assert candidate(rains = [1, 2, 0, 0, 2, 1]) == [-1, -1, 2, 1, -1, -1]\n assert candidate(rains = [1, 2, 3, 0, 4, 5, 0, 1, 2, 3, 4, 5]) == []\n assert candidate(rains = [1000000000, 0, 1000000000, 0]) == [-1, 1000000000, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 1, 2, 0, 3]) == []\n assert candidate(rains = [1, 2, 3, 0, 4, 0, 5, 0, 6, 0, 1]) == [-1, -1, -1, 1, -1, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 0, 0, 2, 1, 0, 1, 0, 2]) == [-1, -1, 2, 1, -1, -1, 1, -1, 2, -1]\n assert candidate(rains = [1, 0, 2, 3, 0, 4, 5, 0, 6, 7, 0, 8, 9, 0, 10, 11, 0, 12, 13, 0]) == [-1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1, -1, -1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 1, 2, 0, 1, 2, 0]) == []\n assert candidate(rains = [1, 2, 3, 0, 4, 0, 5, 0, 1, 2, 3, 4, 5]) == []\n assert candidate(rains = [1, 1, 1, 0, 2, 0, 1]) == []\n assert candidate(rains = [0, 1, 1, 0, 2, 0, 1, 0, 2, 0]) == []\n assert candidate(rains = [1, 2, 0, 0, 0, 1, 0, 2, 0]) == [-1, -1, 1, 2, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 2]) == [-1, 1, -1, 2, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == []\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 1, 2]) == [-1, 1, -1, 2, -1, 1, -1, 1, -1, -1]\n assert candidate(rains = [1, 2, 3, 0, 2, 1, 0, 1, 2, 0]) == []\n assert candidate(rains = [1, 2, 0, 0, 0, 1, 0, 2]) == [-1, -1, 1, 2, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 0, 0, 0, 0, 4]) == [-1, -1, -1, 1, 1, 1, 1, -1]\n assert candidate(rains = [1, 2, 3, 0, 2, 0, 3, 0, 1]) == [-1, -1, -1, 2, -1, 3, -1, 1, -1]\n assert candidate(rains = [10, 20, 20]) == []\n assert candidate(rains = [1, 0, 2, 0, 0, 0, 1, 2]) == [-1, 1, -1, 2, 1, 1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 2, 0, 4, 0, 2, 0, 1, 0, 2, 0, 1, 0, 1, 0]) == [-1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 2, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 4, 5, 3, 0]) == [-1, -1, -1, 3, -1, -1, -1, 1]\n assert candidate(rains = [1, 2, 0, 0, 0, 0, 2, 1]) == [-1, -1, 2, 1, 1, 1, -1, -1]\n assert candidate(rains = [1, 0, 1, 0, 1, 0, 1, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 0, 1, 0, 1, 0, 1]) == [-1, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [1]) == [-1]\n assert candidate(rains = [1, 0, 2, 0, 1, 0, 3, 0, 2, 0, 4, 0]) == [-1, 1, -1, 2, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 0, 1, 0, 2, 0, 1]) == [-1, -1, 1, -1, 2, -1, 1, -1]\n assert candidate(rains = [1, 1, 0, 2, 2, 0, 1]) == []\n assert candidate(rains = [1, 2, 3, 4, 0, 0]) == [-1, -1, -1, -1, 1, 1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 2, 0, 1]) == [-1, 1, -1, 2, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 0, 0, 2, 0, 0, 1, 0, 2]) == [-1, 1, 1, -1, 2, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 0, 0, 2, 1, 0, 0]) == [-1, -1, 2, 1, -1, -1, 1, 1]\n assert candidate(rains = [1, 1, 1, 1, 1]) == []\n assert candidate(rains = [1, 2, 0, 0, 0, 3, 2]) == [-1, -1, 2, 1, 1, -1, -1]\n assert candidate(rains = [1, 0, 2, 0, 0, 1, 0, 2]) == [-1, 1, -1, 2, 1, -1, 1, -1]\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]) == [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 0, 0, 0, 0, 0, 2]) == [-1, 1, 1, 1, 1, 1, 1, -1]\n assert candidate(rains = [1, 2, 3, 0, 0, 0]) == [-1, -1, -1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 0, 4, 5, 0, 1, 0, 2, 3, 4, 5]) == []\n assert candidate(rains = [3, 3, 0, 0, 0, 2, 0, 0, 3, 2, 1, 0, 0, 1]) == []\n assert candidate(rains = [1, 1, 0, 1, 2]) == []\n assert candidate(rains = [1, 0, 0, 0, 2, 0, 0, 2]) == [-1, 1, 1, 1, -1, 2, 1, -1]\n assert candidate(rains = [1, 0, 0, 2, 0, 0, 1, 0]) == [-1, 1, 1, -1, 1, 1, -1, 1]\n assert candidate(rains = [1, 1, 1, 0, 2, 0, 2, 0]) == []\n assert candidate(rains = [1, 2, 0, 0, 2, 1, 0]) == [-1, -1, 2, 1, -1, -1, 1]\n assert candidate(rains = [1, 2, 3, 4, 0, 0, 0, 0]) == [-1, -1, -1, -1, 1, 1, 1, 1]\n assert candidate(rains = [1, 1, 1, 0, 2, 0, 3]) == []\n assert candidate(rains = [1, 2, 0, 2, 3, 0, 1]) == [-1, -1, 2, -1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 0, 1, 2, 3]) == []\n assert candidate(rains = [1, 0, 0, 0, 2, 2, 2, 0]) == []\n assert candidate(rains = [1, 0, 2, 0, 0, 3, 0, 2, 1, 0]) == [-1, 1, -1, 2, 1, -1, 1, -1, -1, 1]\n assert candidate(rains = [1, 2, 3, 4, 0, 0, 0]) == [-1, -1, -1, -1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 4]) == [-1, -1, -1, -1]\n assert candidate(rains = [1, 0, 2, 3, 0, 1, 0, 2, 0, 3]) == [-1, 1, -1, -1, 2, -1, 3, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 5, 0, 0, 0, 0, 1]) == [-1, -1, -1, -1, -1, 1, 1, 1, 1, -1]\n assert candidate(rains = [1, 0, 2, 0, 2, 0, 1, 0]) == [-1, 1, -1, 2, -1, 1, -1, 1]\n assert candidate(rains = [1, 2, 3, 0, 0, 1, 2, 3, 0, 0, 1, 2]) == []\n assert candidate(rains = [1, 0, 2, 0, 3, 0, 1]) == [-1, 1, -1, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 0, 0, 0, 1, 0, 2]) == [-1, -1, 1, 2, 1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 0, 0, 0, 0, 0, 0]) == [-1, -1, -1, -1, 1, 1, 1, 1, 1, 1]\n assert candidate(rains = [1, 2, 3, 0, 4, 5, 0, 1]) == [-1, -1, -1, 1, -1, -1, 1, -1]\n assert candidate(rains = [1, 2, 3, 0, 0, 2, 0, 1, 0]) == [-1, -1, -1, 2, 1, -1, 1, -1, 1]\n assert candidate(rains = [0, 1, 0, 2, 0, 1, 0]) == [1, -1, 1, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 2, 0, 1, 0, 2, 0]) == [-1, 1, -1, 2, -1, 1, -1, 1]\n assert candidate(rains = [1, 0, 0, 0, 2, 0, 0, 1]) == [-1, 1, 1, 1, -1, 1, 1, -1]\n assert candidate(rains = [1, 2, 3, 4, 0, 0, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == []\n"}, "metadata": {"canonical_parameter_names": ["rains"], "leetcode_dataset_entry_point": "Solution().avoidFlood", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector avoidFlood(vector& rains) {", "container": "Solution", "callable": "avoidFlood", "parameters": [{"name": "rains", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1489, "task_id": "find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree", "difficulty": "Hard", "problem_description": "Given a weighted undirected connected graph with n vertices numbered from 0 to n - 1, and an array edges where edges[i] = [ai, bi, weighti] represents a bidirectional and weighted edge between nodes ai and bi. A minimum spanning tree (MST) is a subset of the graph's edges that connects all vertices without cycles and with the minimum possible total edge weight.\nFind all the critical and pseudo-critical edges in the given graph's minimum spanning tree (MST). An MST edge whose deletion from the graph would cause the MST weight to increase is called a critical edge. On the other hand, a pseudo-critical edge is that which can appear in some MSTs but not all.\nNote that you can return the indices of the edges in any order.\n \nExample 1:\n\n\nInput: n = 5, edges = [[0,1,1],[1,2,1],[2,3,2],[0,3,2],[0,4,3],[3,4,3],[1,4,6]]\nOutput: [[0,1],[2,3,4,5]]\nExplanation: The figure above describes the graph.\nThe following figure shows all the possible MSTs:\n\nNotice that the two edges 0 and 1 appear in all MSTs, therefore they are critical edges, so we return them in the first list of the output.\nThe edges 2, 3, 4, and 5 are only part of some MSTs, therefore they are considered pseudo-critical edges. We add them to the second list of the output.\n\nExample 2:\n\n\nInput: n = 4, edges = [[0,1,1],[1,2,1],[2,3,1],[0,3,1]]\nOutput: [[],[0,1,2,3]]\nExplanation: We can observe that since all 4 edges have equal weight, choosing any 3 edges from the given 4 will yield an MST. Therefore all 4 edges are pseudo-critical.\n\n \nConstraints:\n\n2 <= n <= 100\n1 <= edges.length <= min(200, n * (n - 1) / 2)\nedges[i].length == 3\n0 <= ai < bi < n\n1 <= weighti <= 1000\nAll pairs (ai, bi) are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3,edges = [[0, 1, 1], [1, 2, 1], [0, 2, 2]]) == [[0, 1], []]\n assert candidate(n = 5,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 2], [0, 3, 2], [0, 4, 3], [3, 4, 3], [1, 4, 6]]) == [[0, 1], [2, 3, 4, 5]]\n assert candidate(n = 6,edges = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5], [3, 4, 6], [4, 5, 7]]) == [[0, 1, 3, 5, 6], []]\n assert candidate(n = 6,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 0, 5], [1, 3, 6]]) == [[0, 1, 2, 3, 4], []]\n assert candidate(n = 4,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [0, 3, 1]]) == [[], [0, 1, 2, 3]]\n assert candidate(n = 3,edges = [[0, 1, 1], [1, 2, 2], [2, 0, 2]]) == [[0], [1, 2]]\n assert candidate(n = 3,edges = [[0, 1, 1], [1, 2, 2], [0, 2, 3]]) == [[0, 1], []]\n assert candidate(n = 7,edges = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [1, 2, 1], [1, 3, 1], [2, 3, 1], [3, 4, 2], [4, 5, 2], [5, 6, 2], [6, 3, 2]]) == [[], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]\n assert candidate(n = 7,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 0, 1]]) == [[], [0, 1, 2, 3, 4, 5, 6]]\n assert candidate(n = 5,edges = [[0, 1, 2], [0, 3, 6], [1, 2, 5], [1, 3, 8], [1, 4, 9], [2, 4, 7], [3, 4, 4]]) == [[0, 6, 2, 1], []]\n assert candidate(n = 6,edges = [[0, 1, 4], [0, 2, 4], [1, 2, 2], [1, 3, 3], [1, 4, 2], [2, 3, 1], [3, 4, 2], [3, 5, 3], [4, 5, 3]]) == [[5], [2, 4, 6, 7, 8, 0, 1]]\n assert candidate(n = 7,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 2, 4], [1, 3, 5], [1, 4, 6], [2, 3, 7], [2, 4, 8], [2, 5, 9], [3, 4, 10], [3, 5, 11], [3, 6, 12], [4, 5, 13], [4, 6, 14], [5, 6, 15], [0, 4, 16], [0, 5, 17], [0, 6, 18], [1, 5, 19], [1, 6, 20], [2, 6, 21]]) == [[0, 1, 2, 5, 8, 11], []]\n assert candidate(n = 12,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 0, 1], [0, 6, 2], [1, 7, 2], [2, 8, 2], [3, 9, 2], [4, 10, 2], [5, 11, 2]]) == [[], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]]\n assert candidate(n = 10,edges = [[0, 1, 10], [0, 2, 20], [0, 3, 30], [1, 2, 10], [1, 3, 20], [1, 4, 30], [2, 3, 10], [2, 4, 20], [2, 5, 30], [3, 4, 10], [3, 5, 20], [3, 6, 30], [4, 5, 10], [4, 6, 20], [4, 7, 30], [5, 6, 10], [5, 7, 20], [5, 8, 30], [6, 7, 10], [6, 8, 20], [6, 9, 30], [7, 8, 10], [7, 9, 20], [8, 9, 10]]) == [[0, 3, 6, 9, 12, 15, 18, 21, 23], []]\n assert candidate(n = 10,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 2, 4], [1, 3, 5], [2, 3, 6], [2, 4, 7], [3, 4, 8], [4, 5, 9], [4, 6, 10], [5, 6, 11], [5, 7, 12], [6, 7, 13], [6, 8, 14], [7, 8, 15], [7, 9, 16], [8, 9, 17]]) == [[0, 1, 2, 6, 8, 9, 11, 13, 15], []]\n assert candidate(n = 12,edges = [[0, 1, 3], [0, 2, 4], [0, 3, 5], [1, 2, 2], [1, 3, 6], [1, 4, 7], [2, 3, 8], [2, 4, 9], [2, 5, 10], [3, 4, 11], [3, 5, 12], [3, 6, 13], [4, 5, 14], [4, 6, 15], [4, 7, 16], [5, 6, 17], [5, 7, 18], [5, 8, 19], [6, 7, 20], [6, 8, 21], [6, 9, 22], [7, 8, 23], [7, 9, 24], [7, 10, 25], [8, 9, 26], [8, 10, 27], [8, 11, 28], [9, 10, 29], [9, 11, 30], [10, 11, 31]]) == [[3, 0, 2, 5, 8, 11, 14, 17, 20, 23, 26], []]\n assert candidate(n = 9,edges = [[0, 1, 100], [0, 2, 90], [0, 3, 95], [1, 2, 85], [1, 3, 80], [1, 4, 75], [2, 3, 65], [2, 4, 60], [2, 5, 55], [3, 4, 50], [3, 5, 45], [3, 6, 40], [4, 5, 35], [4, 6, 30], [4, 7, 25], [5, 6, 20], [5, 7, 15], [5, 8, 10], [6, 7, 5], [6, 8, 1], [7, 8, 50]]) == [[19, 18, 17, 14, 11, 8, 5, 1], []]\n assert candidate(n = 12,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [1, 4, 40], [2, 5, 50], [2, 6, 60], [3, 7, 70], [3, 8, 80], [4, 9, 90], [4, 10, 100], [5, 11, 110], [6, 11, 120], [7, 8, 130], [8, 9, 140], [9, 10, 150], [10, 11, 160], [0, 3, 170], [1, 5, 180], [2, 7, 190], [3, 9, 200], [4, 11, 210]]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], []]\n assert candidate(n = 15,edges = [[0, 1, 10], [0, 2, 20], [0, 3, 30], [1, 2, 25], [1, 4, 35], [2, 3, 40], [2, 5, 45], [3, 4, 50], [3, 6, 55], [4, 5, 60], [5, 6, 65], [6, 7, 70], [6, 8, 75], [7, 8, 80], [7, 9, 85], [8, 9, 90], [9, 10, 95], [9, 11, 100], [10, 11, 105], [10, 12, 110], [11, 12, 115], [12, 13, 120], [12, 14, 125], [13, 14, 130]]) == [[0, 1, 2, 4, 6, 8, 11, 12, 14, 16, 17, 19, 21, 22], []]\n assert candidate(n = 8,edges = [[0, 1, 2], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [0, 7, 8], [1, 3, 9], [2, 4, 10], [3, 5, 11], [4, 6, 12], [5, 7, 13], [0, 3, 14], [1, 4, 15], [2, 5, 16], [3, 6, 17], [4, 7, 18]]) == [[0, 1, 2, 3, 4, 5, 6], []]\n assert candidate(n = 8,edges = [[0, 1, 5], [0, 2, 20], [0, 3, 30], [1, 2, 15], [1, 4, 10], [2, 3, 10], [2, 4, 25], [2, 5, 35], [3, 4, 5], [3, 6, 15], [4, 5, 20], [4, 6, 10], [4, 7, 25], [5, 6, 30], [5, 7, 15], [6, 7, 20]]) == [[0, 8, 4, 5, 11, 14], [10, 15]]\n assert candidate(n = 8,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [0, 7, 7], [1, 3, 8], [2, 4, 9], [3, 5, 10], [4, 6, 11]]) == [[0, 1, 2, 3, 4, 5, 6], []]\n assert candidate(n = 6,edges = [[0, 1, 100], [0, 2, 50], [0, 3, 20], [1, 2, 60], [1, 3, 40], [1, 4, 70], [2, 3, 30], [2, 4, 80], [2, 5, 90], [3, 4, 5], [3, 5, 10], [4, 5, 100]]) == [[9, 10, 2, 6, 4], []]\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 2, 4], [1, 3, 5], [1, 4, 6], [2, 3, 7], [2, 4, 8], [2, 5, 9], [3, 4, 10], [3, 5, 11], [3, 6, 12], [4, 5, 13], [4, 6, 14], [4, 7, 15], [5, 6, 16], [5, 7, 17], [6, 7, 18]]) == [[0, 1, 2, 5, 8, 11, 14], []]\n assert candidate(n = 8,edges = [[0, 1, 10], [0, 2, 6], [0, 3, 5], [1, 3, 15], [2, 3, 4], [2, 4, 11], [3, 4, 9], [3, 5, 10], [4, 5, 13], [4, 6, 14], [5, 6, 16], [5, 7, 7], [6, 7, 18]]) == [[4, 2, 11, 6, 0, 7, 9], []]\n assert candidate(n = 12,edges = [[0, 1, 2], [0, 2, 4], [1, 3, 3], [1, 4, 5], [2, 3, 6], [2, 4, 7], [3, 5, 8], [4, 5, 9], [5, 6, 10], [6, 7, 11], [6, 8, 12], [7, 9, 13], [8, 9, 14], [9, 10, 15], [10, 11, 16], [11, 0, 17], [2, 7, 18], [3, 8, 19], [4, 9, 20], [5, 10, 21]]) == [[0, 2, 1, 3, 6, 8, 9, 10, 11, 13, 14], []]\n assert candidate(n = 10,edges = [[0, 1, 10], [0, 2, 20], [1, 2, 5], [1, 3, 15], [2, 3, 25], [2, 4, 10], [3, 4, 30], [3, 5, 15], [4, 5, 5], [4, 6, 20], [5, 6, 25], [5, 7, 10], [6, 7, 30], [6, 8, 15], [7, 8, 5], [7, 9, 20], [8, 9, 25]]) == [[2, 8, 14, 0, 5, 11, 13, 15], [3, 7]]\n assert candidate(n = 9,edges = [[0, 1, 5], [0, 2, 6], [0, 3, 7], [1, 2, 8], [1, 3, 9], [2, 3, 10], [2, 4, 11], [3, 4, 12], [3, 5, 13], [4, 5, 14], [4, 6, 15], [5, 6, 16], [5, 7, 17], [6, 7, 18], [6, 8, 19], [7, 8, 20], [0, 4, 21], [1, 5, 22], [2, 6, 23], [3, 7, 24], [4, 8, 25]]) == [[0, 1, 2, 6, 8, 10, 12, 14], []]\n assert candidate(n = 10,edges = [[0, 1, 10], [0, 2, 15], [0, 3, 20], [1, 2, 35], [1, 3, 25], [2, 3, 30], [4, 5, 10], [4, 6, 20], [4, 7, 30], [5, 6, 25], [5, 7, 35], [6, 7, 40], [8, 9, 5], [8, 7, 15], [7, 9, 10]]) == [[12, 0, 6, 14, 1, 13, 2, 7, 4, 9, 5, 8, 3, 10, 11], []]\n assert candidate(n = 15,edges = [[0, 1, 5], [0, 2, 7], [0, 3, 9], [1, 2, 3], [1, 3, 2], [1, 4, 6], [2, 3, 1], [2, 4, 4], [2, 5, 8], [3, 4, 11], [3, 5, 13], [3, 6, 15], [4, 5, 12], [4, 6, 14], [5, 6, 16], [5, 7, 18], [5, 8, 20], [6, 7, 21], [6, 8, 22], [7, 8, 23], [7, 9, 25], [7, 10, 27], [8, 9, 24], [8, 10, 26], [9, 10, 28], [9, 11, 29], [9, 12, 31], [10, 11, 30], [10, 12, 32], [11, 12, 33], [11, 13, 35], [11, 14, 37], [12, 13, 34], [12, 14, 36], [13, 14, 38]]) == [[6, 4, 7, 0, 8, 13, 15, 16, 22, 23, 25, 26, 32, 33], []]\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [1, 4, 4], [2, 5, 5], [2, 6, 6], [3, 6, 7], [3, 7, 8], [4, 7, 9], [5, 7, 10], [0, 3, 11], [1, 5, 12], [2, 4, 13], [6, 7, 14]]) == [[0, 1, 2, 3, 4, 5, 7], []]\n assert candidate(n = 9,edges = [[0, 1, 5], [0, 2, 6], [0, 3, 7], [1, 2, 8], [1, 3, 9], [1, 4, 10], [2, 3, 11], [2, 4, 12], [2, 5, 13], [3, 4, 14], [3, 5, 15], [3, 6, 16], [4, 5, 17], [4, 6, 18], [4, 7, 19], [5, 6, 20], [5, 7, 21], [5, 8, 22], [6, 7, 23], [7, 8, 24]]) == [[0, 1, 2, 5, 8, 11, 14, 17], []]\n assert candidate(n = 10,edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 0, 10], [0, 3, 20], [1, 4, 20], [2, 5, 20], [3, 6, 20], [4, 7, 20], [5, 8, 20], [6, 9, 20], [7, 0, 20], [8, 1, 20], [9, 2, 20]]) == [[], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]\n assert candidate(n = 10,edges = [[0, 1, 4], [0, 2, 8], [1, 2, 2], [1, 3, 6], [2, 3, 3], [3, 4, 5], [4, 5, 9], [5, 6, 10], [6, 7, 1], [7, 8, 7], [8, 9, 11], [9, 0, 12], [1, 4, 13], [2, 5, 14]]) == [[8, 2, 4, 0, 5, 9, 6, 7, 10], []]\n assert candidate(n = 12,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 2, 4], [1, 3, 5], [1, 4, 6], [2, 3, 7], [2, 4, 8], [2, 5, 9], [3, 4, 10], [3, 5, 11], [3, 6, 12], [4, 5, 13], [4, 6, 14], [5, 6, 15], [6, 7, 16], [6, 8, 17], [7, 8, 18], [7, 9, 19], [8, 9, 20], [8, 10, 21], [9, 10, 22], [9, 11, 23], [10, 11, 24]]) == [[0, 1, 2, 5, 8, 11, 15, 16, 18, 20, 22], []]\n assert candidate(n = 10,edges = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5], [3, 4, 6], [4, 5, 7], [5, 6, 8], [6, 7, 9], [7, 8, 10], [8, 9, 11], [0, 9, 15], [2, 8, 12], [4, 7, 13]]) == [[0, 1, 3, 5, 6, 7, 8, 9, 10], []]\n assert candidate(n = 11,edges = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 5], [1, 2, 6], [1, 3, 7], [1, 4, 8], [1, 5, 9], [2, 3, 10], [2, 4, 11], [2, 5, 12], [2, 6, 13], [3, 4, 14], [3, 5, 15], [3, 6, 16], [3, 7, 17], [4, 5, 18], [4, 6, 19], [4, 7, 20], [4, 8, 21], [5, 6, 22], [5, 7, 23], [5, 8, 24], [5, 9, 25], [6, 7, 26], [6, 8, 27], [6, 9, 28], [6, 10, 29], [7, 8, 30], [7, 9, 31], [7, 10, 32], [8, 9, 33], [8, 10, 34], [9, 10, 35]]) == [[0, 1, 2, 3, 7, 11, 15, 19, 23, 27], []]\n assert candidate(n = 8,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 0, 9], [0, 3, 10], [1, 4, 11], [2, 5, 12], [3, 6, 13], [4, 7, 14], [5, 0, 15], [6, 1, 16], [7, 2, 17]]) == [[0, 1, 2, 3, 4, 5, 6], []]\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [1, 4, 1], [1, 5, 1], [2, 4, 1], [2, 6, 1], [3, 5, 1], [3, 6, 1], [4, 7, 1], [5, 7, 1], [6, 7, 1], [7, 8, 1], [0, 4, 1], [0, 5, 1], [0, 6, 1], [1, 6, 1], [1, 7, 1], [2, 5, 1], [2, 7, 1], [3, 4, 1], [3, 7, 1], [4, 6, 1], [5, 6, 1], [4, 8, 1], [5, 8, 1], [6, 8, 1]]) == [[], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]]\n assert candidate(n = 7,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 0, 10], [0, 3, 20], [1, 4, 20], [2, 5, 20], [3, 6, 20], [4, 0, 20], [5, 1, 20], [6, 2, 20]]) == [[], [0, 1, 2, 3, 4, 5, 6]]\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [0, 4, 4], [0, 5, 5], [0, 6, 6], [0, 7, 7], [0, 8, 8], [1, 2, 9], [2, 3, 10], [3, 4, 11], [4, 5, 12], [5, 6, 13], [6, 7, 14], [7, 8, 15], [8, 1, 16], [1, 3, 17], [3, 5, 18], [5, 7, 19], [7, 1, 20], [1, 4, 21], [4, 6, 22], [6, 8, 23], [8, 2, 24], [2, 4, 25], [4, 7, 26], [7, 3, 27], [3, 6, 28], [6, 1, 29], [1, 5, 30], [5, 2, 31], [2, 7, 32], [7, 4, 33], [4, 8, 34], [8, 3, 35], [3, 1, 36]]) == [[0, 1, 2, 3, 4, 5, 6, 7], []]\n assert candidate(n = 8,edges = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [0, 4, 1], [0, 5, 1], [0, 6, 1], [0, 7, 1], [1, 2, 2], [2, 3, 2], [3, 4, 2], [4, 5, 2], [5, 6, 2], [6, 7, 2], [7, 1, 2], [1, 3, 2], [3, 5, 2], [5, 7, 2], [7, 2, 2], [2, 4, 2], [4, 6, 2], [6, 1, 2], [1, 4, 2], [4, 7, 2], [7, 3, 2], [3, 6, 2], [6, 2, 2], [2, 5, 2], [5, 3, 2], [3, 7, 2], [7, 4, 2], [4, 1, 2], [1, 5, 2], [5, 2, 2], [2, 6, 2], [6, 3, 2], [3, 1, 2], [1, 6, 2], [6, 4, 2], [4, 2, 2], [2, 7, 2], [7, 5, 2], [5, 4, 2], [4, 3, 2], [3, 2, 2], [2, 1, 2], [1, 7, 2], [7, 6, 2], [6, 5, 2], [5, 4, 2], [4, 3, 2], [3, 1, 2], [1, 6, 2], [6, 4, 2], [4, 2, 2], [2, 7, 2], [7, 5, 2], [5, 3, 2], [3, 7, 2]]) == [[0, 1, 2, 3, 4, 5, 6], []]\n assert candidate(n = 12,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 4, 4], [1, 5, 5], [2, 6, 6], [2, 7, 7], [3, 8, 8], [3, 9, 9], [4, 10, 10], [5, 11, 11], [6, 11, 12], [7, 10, 13], [8, 9, 14], [9, 10, 15], [10, 11, 16]]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], []]\n assert candidate(n = 10,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 0, 1], [0, 5, 2], [1, 6, 2], [2, 7, 2], [3, 8, 2], [4, 9, 2]]) == [[], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]\n assert candidate(n = 12,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 0, 11], [0, 2, 12], [1, 3, 13], [2, 4, 14], [3, 5, 15], [4, 6, 16], [5, 7, 17], [6, 8, 18], [7, 9, 19], [8, 10, 20], [9, 11, 21], [10, 0, 22], [11, 1, 23], [0, 3, 24], [1, 4, 25], [2, 5, 26], [3, 6, 27], [4, 7, 28], [5, 8, 29], [6, 9, 30], [7, 10, 31], [8, 11, 32], [9, 0, 33], [10, 1, 34], [11, 2, 35], [0, 4, 36], [1, 5, 37], [2, 6, 38], [3, 7, 39], [4, 8, 40], [5, 9, 41], [6, 10, 42], [7, 11, 43], [8, 0, 44], [9, 1, 45], [10, 2, 46], [11, 3, 47], [0, 5, 48], [1, 6, 49], [2, 7, 50], [3, 8, 51], [4, 9, 52], [5, 10, 53], [6, 11, 54], [7, 0, 55], [8, 1, 56], [9, 2, 57], [10, 3, 58], [11, 4, 59]]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], []]\n assert candidate(n = 8,edges = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [1, 2, 1], [1, 3, 5], [1, 4, 6], [2, 3, 7], [2, 4, 8], [2, 5, 9], [3, 4, 10], [3, 5, 11], [3, 6, 12], [4, 5, 13], [4, 6, 14], [4, 7, 15], [5, 6, 16], [5, 7, 17], [6, 7, 18]]) == [[3, 0, 2, 5, 8, 11, 14], []]\n assert candidate(n = 15,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15], [0, 7, 16], [1, 8, 17], [2, 9, 18], [3, 10, 19], [4, 11, 20], [5, 12, 21], [6, 13, 22], [7, 14, 23], [8, 0, 24], [9, 1, 25], [10, 2, 26], [11, 3, 27], [12, 4, 28], [13, 5, 29], [14, 6, 30]]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], []]\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5], [2, 4, 6], [3, 4, 7], [3, 5, 8], [4, 5, 9], [4, 6, 10], [5, 6, 11], [5, 7, 12], [6, 7, 13], [6, 8, 14], [7, 8, 15], [0, 4, 16], [1, 5, 17], [2, 6, 18], [3, 7, 19], [0, 5, 20], [1, 6, 21], [2, 7, 22], [3, 8, 23], [0, 6, 24], [1, 7, 25], [2, 8, 26]]) == [[0, 1, 3, 5, 7, 9, 11, 13], []]\n assert candidate(n = 9,edges = [[0, 1, 1], [0, 2, 10], [0, 3, 10], [1, 2, 10], [1, 3, 10], [2, 3, 10], [2, 4, 1], [2, 5, 10], [3, 4, 10], [3, 5, 10], [4, 5, 1], [4, 6, 10], [4, 7, 10], [5, 6, 10], [5, 7, 10], [6, 7, 1], [6, 8, 10], [7, 8, 10]]) == [[0, 6, 10, 15], [1, 2, 3, 4, 5, 8, 9, 11, 12, 13, 14, 16, 17]]\n assert candidate(n = 9,edges = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [1, 2, 5], [1, 3, 6], [2, 3, 7], [3, 4, 8], [4, 5, 9], [5, 6, 10], [6, 7, 11], [7, 8, 12], [8, 4, 13], [0, 5, 14], [1, 6, 15], [2, 7, 16]]) == [[0, 1, 2, 6, 7, 8, 9, 10], []]\n assert candidate(n = 12,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 2, 4], [1, 3, 5], [1, 4, 6], [2, 3, 7], [2, 4, 8], [2, 5, 9], [3, 4, 10], [3, 5, 11], [3, 6, 12], [4, 5, 13], [4, 6, 14], [4, 7, 15], [5, 6, 16], [5, 7, 17], [5, 8, 18], [6, 7, 19], [6, 8, 20], [6, 9, 21], [7, 8, 22], [7, 9, 23], [7, 10, 24], [8, 9, 25], [8, 10, 26], [8, 11, 27], [9, 10, 28], [9, 11, 29], [10, 11, 30]]) == [[0, 1, 2, 5, 8, 11, 14, 17, 20, 23, 26], []]\n assert candidate(n = 10,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10], [0, 5, 11], [1, 6, 12], [2, 7, 13], [3, 8, 14], [4, 9, 15]]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8], []]\n assert candidate(n = 9,edges = [[0, 1, 2], [1, 2, 2], [2, 3, 2], [3, 4, 2], [4, 5, 2], [5, 6, 2], [6, 7, 2], [7, 8, 2], [8, 0, 2], [0, 2, 3], [1, 3, 3], [2, 4, 3], [3, 5, 3], [4, 6, 3], [5, 7, 3], [6, 8, 3], [7, 0, 3], [8, 1, 3]]) == [[], [0, 1, 2, 3, 4, 5, 6, 7, 8]]\n assert candidate(n = 15,edges = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 2, 4], [1, 3, 5], [1, 4, 6], [2, 3, 7], [2, 4, 8], [2, 5, 9], [3, 4, 10], [3, 5, 11], [3, 6, 12], [4, 5, 13], [4, 6, 14], [4, 7, 15], [5, 6, 16], [5, 7, 17], [5, 8, 18], [6, 7, 19], [6, 8, 20], [6, 9, 21], [7, 8, 22], [7, 9, 23], [7, 10, 24], [8, 9, 25], [8, 10, 26], [8, 11, 27], [9, 10, 28], [9, 11, 29], [10, 11, 30], [11, 12, 31], [11, 13, 32], [11, 14, 33], [12, 13, 34], [12, 14, 35], [13, 14, 36]]) == [[0, 1, 2, 5, 8, 11, 14, 17, 20, 23, 26, 30, 31, 32], []]\n assert candidate(n = 10,edges = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [1, 2, 1], [1, 4, 5], [1, 5, 6], [2, 3, 2], [2, 5, 3], [3, 6, 7], [3, 7, 8], [4, 5, 2], [4, 8, 9], [5, 6, 4], [5, 9, 10], [6, 7, 5], [7, 8, 6], [8, 9, 7]]) == [[3, 0, 6, 10, 7, 12, 14, 15, 16], []]\n"}, "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().findCriticalAndPseudoCriticalEdges", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector> findCriticalAndPseudoCriticalEdges(int n, vector>& edges) {", "container": "Solution", "callable": "findCriticalAndPseudoCriticalEdges", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "vector>&"}], "return_type": "vector>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1491, "task_id": "average-salary-excluding-the-minimum-and-maximum-salary", "difficulty": "Easy", "problem_description": "You are given an array of unique integers salary where salary[i] is the salary of the ith employee.\nReturn the average salary of employees excluding the minimum and maximum salary. Answers within 10-5 of the actual answer will be accepted.\n \nExample 1:\n\nInput: salary = [4000,3000,1000,2000]\nOutput: 2500.00000\nExplanation: Minimum salary and maximum salary are 1000 and 4000 respectively.\nAverage salary excluding minimum and maximum salary is (2000+3000) / 2 = 2500\n\nExample 2:\n\nInput: salary = [1000,2000,3000]\nOutput: 2000.00000\nExplanation: Minimum salary and maximum salary are 1000 and 3000 respectively.\nAverage salary excluding minimum and maximum salary is (2000) / 1 = 2000\n\n \nConstraints:\n\n3 <= salary.length <= 100\n1000 <= salary[i] <= 106\nAll the integers of salary are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(salary = [54000, 25000, 75000, 30000, 45000]) == 43000.0\n assert candidate(salary = [7500, 8500, 6500, 9500, 7000]) == 7666.666666666667\n assert candidate(salary = [5000, 6000, 7000, 8000, 9000, 10000]) == 7500.0\n assert candidate(salary = [12000, 11000, 13000, 9000, 10000, 14000]) == 11500.0\n assert candidate(salary = [4000, 3000, 1000, 2000]) == 2500.0\n assert candidate(salary = [8000, 9000, 2000, 3000, 6000, 10000, 5000]) == 6200.0\n assert candidate(salary = [1500, 2500, 3500, 4500, 5500]) == 3500.0\n assert candidate(salary = [5000, 10000, 15000, 20000, 25000]) == 15000.0\n assert candidate(salary = [15000, 25000, 35000, 45000, 55000]) == 35000.0\n assert candidate(salary = [100000, 120000, 110000]) == 110000.0\n assert candidate(salary = [1000, 2000, 3000]) == 2000.0\n assert candidate(salary = [7500, 8200, 9000, 12000, 6000]) == 8233.333333333334\n assert candidate(salary = [6000, 5000, 4000, 3000, 2000, 1000]) == 3500.0\n assert candidate(salary = [9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 5000.0\n assert candidate(salary = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990]) == 999994.5\n assert candidate(salary = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]) == 550000.0\n assert candidate(salary = [1234, 2345, 3456, 4567, 5678, 6789, 7890, 8901, 9012, 1012]) == 5107.5\n assert candidate(salary = [9999, 10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009, 10010]) == 10004.5\n assert candidate(salary = [45000, 55000, 65000, 35000, 25000, 75000, 85000, 95000, 105000, 115000, 125000, 135000]) == 80000.0\n assert candidate(salary = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000]) == 60000.0\n assert candidate(salary = [123456, 234567, 345678, 456789, 567890, 678901, 789012, 890123, 901234, 12345, 54321]) == 460081.8888888889\n assert candidate(salary = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989, 999988, 999987, 999986, 999985, 999984, 999983, 999982, 999981]) == 999990.5\n assert candidate(salary = [111111, 222222, 333333, 444444, 555555, 666666, 777777, 888888, 999999, 1111111, 2222222, 3333333, 4444444, 5555555, 6666666, 7777777, 8888888, 9999999, 10000000]) == 3228757.588235294\n assert candidate(salary = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009, 10010, 11011, 12012, 13013]) == 7007.0\n assert candidate(salary = [10000, 10100, 10200, 10300, 10400, 10500, 10600, 10700, 10800, 10900, 11000, 11100, 11200]) == 10600.0\n assert candidate(salary = [888888, 888889, 888890, 888891, 888892, 888893, 888894, 888895, 888896, 888897, 888898, 888899, 888900, 888901, 888902, 888903, 888904]) == 888896.0\n assert candidate(salary = [555555, 555556, 555557, 555558, 555559, 555560, 555561, 555562, 555563, 555564, 555565]) == 555560.0\n assert candidate(salary = [123456, 234567, 345678, 456789, 567890, 678901, 789012, 890123, 901234, 101234, 212345, 321234, 432123, 543212, 654321, 765432]) == 501077.35714285716\n assert candidate(salary = [1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010]) == 1005.5\n assert candidate(salary = [50000, 55000, 60000, 65000, 70000, 75000, 80000, 85000, 90000, 95000]) == 72500.0\n assert candidate(salary = [3500, 4500, 5500, 6500, 7500, 8500, 9500, 10500, 11500, 12500, 13500]) == 8500.0\n assert candidate(salary = [9999, 10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007]) == 10003.0\n assert candidate(salary = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000]) == 7000.0\n assert candidate(salary = [15000, 14000, 13000, 12000, 11000, 10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 8000.0\n assert candidate(salary = [10500, 20500, 30500, 40500, 50500, 60500, 70500, 80500, 90500, 100500]) == 55500.0\n assert candidate(salary = [555555, 444444, 333333, 222222, 111111, 999999, 888888, 777777, 666666, 123456, 789012, 345678, 901234, 567890, 234567, 890123, 456789, 678901, 101234, 987654]) == 554183.3333333334\n assert candidate(salary = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5, 999996, 6, 999995, 7, 999994, 8, 999993, 9, 999992, 10]) == 470589.29411764705\n assert candidate(salary = [500000, 490000, 480000, 470000, 460000, 450000, 440000, 430000, 420000, 410000, 400000]) == 450000.0\n assert candidate(salary = [5000, 3000, 4000, 6000, 7000, 8000, 9000, 10000, 11000]) == 7000.0\n assert candidate(salary = [8000, 16000, 24000, 32000, 40000, 48000, 56000, 64000, 72000, 80000, 88000, 96000, 104000, 112000, 120000, 128000]) == 68000.0\n assert candidate(salary = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == 5500000.0\n assert candidate(salary = [123456, 654321, 111111, 999999, 555555, 333333, 777777, 888888, 222222, 444444, 666666, 100000, 900000]) == 516161.1818181818\n assert candidate(salary = [5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000, 55000, 60000, 65000, 70000, 75000, 80000, 85000, 90000, 95000, 100000]) == 52500.0\n assert candidate(salary = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 11000000, 12000000, 13000000, 14000000, 15000000]) == 8000000.0\n assert candidate(salary = [250000, 225000, 200000, 175000, 150000, 125000, 100000, 75000, 50000, 25000]) == 137500.0\n assert candidate(salary = [150000, 250000, 140000, 160000, 130000, 170000, 120000, 180000, 110000, 190000, 100000, 200000, 210000]) == 160000.0\n assert candidate(salary = [150000, 150001, 150002, 150003, 150004, 150005, 150006, 150007, 150008, 150009, 150010, 150011, 150012]) == 150006.0\n assert candidate(salary = [123456, 234567, 345678, 456789, 567890, 678901, 789012, 890123, 901234, 101234]) == 510802.0\n assert candidate(salary = [1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013]) == 1007.0\n assert candidate(salary = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991]) == 999995.5\n assert candidate(salary = [999999, 800000, 700000, 600000, 500000, 400000, 300000, 200000, 100001, 100000]) == 450000.125\n assert candidate(salary = [100001, 100002, 100003, 100004, 100005, 100006, 100007, 100008, 100009, 100010]) == 100005.5\n assert candidate(salary = [999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111, 100000000, 99999999, 88888888, 77777777, 66666666, 55555555, 44444444, 33333333, 22222222, 11111111]) == 269934640.0\n assert candidate(salary = [1000, 1200, 1400, 1600, 1800, 2000, 2200, 2400, 2600, 2800, 3000, 3200, 3400, 3600, 3800, 4000]) == 2500.0\n assert candidate(salary = [30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000, 130000, 140000, 150000]) == 90000.0\n assert candidate(salary = [50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000, 130000, 140000, 150000, 160000, 170000, 180000, 190000]) == 120000.0\n assert candidate(salary = [1234, 2345, 3456, 4567, 5678, 6789, 7890, 8901, 9012, 1012, 2123, 3234, 4345, 5456, 6567, 7678, 8789, 9890, 8989, 7989]) == 5835.666666666667\n assert candidate(salary = [500001, 500002, 500003, 500004, 500005, 500006, 500007, 500008, 500009, 500010, 500011, 500012, 500013, 500014, 500015, 500016, 500017, 500018, 500019, 500020, 500021, 500022, 500023, 500024, 500025]) == 500013.0\n assert candidate(salary = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000, 1100000]) == 600000.0\n assert candidate(salary = [250000, 260000, 270000, 280000, 290000, 300000, 310000, 320000, 330000, 340000, 350000, 360000, 370000, 380000, 390000]) == 320000.0\n assert candidate(salary = [100000, 100001, 100002, 100003, 100004, 100005, 100006, 100007, 100008, 100009, 100010]) == 100005.0\n assert candidate(salary = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000]) == 500000.0\n assert candidate(salary = [100001, 100002, 100003, 100004, 100005, 100006, 100007, 100008, 100009, 100010, 100011, 100012, 100013, 100014, 100015]) == 100008.0\n assert candidate(salary = [500000, 400000, 300000, 200000, 100000, 150000, 250000, 350000, 450000, 550000]) == 325000.0\n assert candidate(salary = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 13.0\n assert candidate(salary = [123456, 789012, 345678, 901234, 567890, 234567, 890123]) == 565454.0\n assert candidate(salary = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 11000000, 12000000, 13000000, 14000000, 15000000, 16000000, 17000000, 18000000, 19000000, 20000000]) == 10500000.0\n assert candidate(salary = [999999, 1000000, 1000001, 1000002, 1000003, 1000004, 1000005]) == 1000002.0\n assert candidate(salary = [5000, 5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008, 5009, 5010, 5011]) == 5005.5\n assert candidate(salary = [1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015]) == 1008.0\n assert candidate(salary = [500000, 600000, 700000, 800000, 900000, 1000000, 1100000, 1200000, 1300000, 1400000, 1500000, 1600000, 1700000, 1800000, 1900000, 2000000]) == 1250000.0\n assert candidate(salary = [1000, 999999, 500000, 250000, 750000, 375000, 625000]) == 500000.0\n assert candidate(salary = [1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011]) == 1006.0\n assert candidate(salary = [100000, 200000, 150000, 180000, 170000, 160000, 130000, 120000, 110000]) == 145714.2857142857\n assert candidate(salary = [987654, 876543, 765432, 654321, 543210, 432109, 321098, 210987, 109876, 98765, 87654, 76543, 65432, 54321, 43210, 32109, 21098, 10987, 9876, 8765]) == 245198.38888888888\n assert candidate(salary = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991]) == 999995.0\n assert candidate(salary = [999999, 1000000, 1000001, 1000002, 1000003, 1000004, 1000005, 1000006]) == 1000002.5\n assert candidate(salary = [500000, 500001, 500002, 500003, 500004, 500005, 500006, 500007, 500008, 500009, 500010, 500011, 500012, 500013, 500014, 500015]) == 500007.5\n assert candidate(salary = [1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000, 100000000000, 1000000000000, 1000000000001, 1000000000002]) == 211111111000.1\n assert candidate(salary = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 11000000, 12000000, 13000000]) == 7000000.0\n assert candidate(salary = [999999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 8.5\n assert candidate(salary = [987654, 876543, 765432, 654321, 543210, 432109, 321098, 210987, 109876, 98765, 87654, 76543, 65432, 54321, 43210, 32109]) == 309964.35714285716\n assert candidate(salary = [987654, 876543, 765432, 654321, 543210, 432109, 321098, 210987, 109876, 98765, 87654, 76543, 65432]) == 379685.2727272727\n assert candidate(salary = [999999, 1000000, 1000001, 1000002, 1000003, 1000004, 1000005, 1000006, 1000007, 1000008, 1000009, 1000010]) == 1000004.5\n assert candidate(salary = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 5500.0\n assert candidate(salary = [200000, 150000, 180000, 170000, 190000, 160000, 210000, 220000, 230000, 240000]) == 195000.0\n assert candidate(salary = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000, 1100000, 1200000, 1300000, 1400000, 1500000]) == 800000.0\n assert candidate(salary = [23456, 34567, 45678, 56789, 67890, 78901, 89012, 90123, 101234, 111234, 121234, 131234, 141234, 151234]) == 89094.16666666667\n assert candidate(salary = [500000, 600000, 700000, 800000, 900000, 1000000, 1100000, 1200000, 1300000, 1400000]) == 950000.0\n assert candidate(salary = [150000, 250000, 350000, 450000, 550000, 650000, 750000, 850000, 950000, 1050000, 1150000, 1250000, 1350000, 1450000, 1550000, 1650000, 1750000, 1850000, 1950000, 2050000]) == 1100000.0\n assert candidate(salary = [3456, 6543, 1234, 4321, 9876, 6789, 2345, 5432, 8765, 7654, 1111, 2222, 3333]) == 4735.818181818182\n assert candidate(salary = [999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989, 999988, 999987, 999986, 999985, 999984]) == 999991.0\n assert candidate(salary = [123456, 789012, 345678, 901234, 567890, 1234567, 2345678, 3456789, 4567890, 5678901, 6789012, 7890123, 8901234, 9012345, 10123456]) == 4036950.230769231\n assert candidate(salary = [1000, 2500, 5000, 7500, 10000, 12500, 15000]) == 7500.0\n assert candidate(salary = [120000, 95000, 110000, 90000, 105000, 85000, 100000, 80000, 115000]) == 100000.0\n assert candidate(salary = [123456789, 987654321, 111222333, 444555666, 777888999, 222333444, 555666777, 888999000, 333444555, 666777888, 999000111]) == 555641937.6666666\n assert candidate(salary = [95000, 96000, 97000, 98000, 99000, 100000, 101000, 102000, 103000, 104000, 105000, 106000, 107000, 108000, 109000]) == 102000.0\n assert candidate(salary = [12000, 15000, 13000, 10000, 9000, 11000, 14000]) == 12000.0\n assert candidate(salary = [80000, 75000, 100000, 65000, 90000, 55000, 60000, 70000]) == 73333.33333333333\n"}, "metadata": {"canonical_parameter_names": ["salary"], "leetcode_dataset_entry_point": "Solution().average", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "double average(vector& salary) {", "container": "Solution", "callable": "average", "parameters": [{"name": "salary", "type": "vector&"}], "return_type": "double", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1492, "task_id": "the-kth-factor-of-n", "difficulty": "Medium", "problem_description": "You are given two positive integers n and k. A factor of an integer n is defined as an integer i where n % i == 0.\nConsider a list of all factors of n sorted in ascending order, return the kth factor in this list or return -1 if n has less than k factors.\n \nExample 1:\n\nInput: n = 12, k = 3\nOutput: 3\nExplanation: Factors list is [1, 2, 3, 4, 6, 12], the 3rd factor is 3.\n\nExample 2:\n\nInput: n = 7, k = 2\nOutput: 7\nExplanation: Factors list is [1, 7], the 2nd factor is 7.\n\nExample 3:\n\nInput: n = 4, k = 4\nOutput: -1\nExplanation: Factors list is [1, 2, 4], there is only 3 factors. We should return -1.\n\n \nConstraints:\n\n1 <= k <= n <= 1000\n\n \nFollow up:\nCould you solve this problem in less than O(n) complexity?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1,k = 1) == 1\n assert candidate(n = 49,k = 3) == 49\n assert candidate(n = 100,k = 5) == 10\n assert candidate(n = 7,k = 2) == 7\n assert candidate(n = 17,k = 2) == 17\n assert candidate(n = 1000,k = 15) == 500\n assert candidate(n = 30,k = 5) == 6\n assert candidate(n = 12,k = 3) == 3\n assert candidate(n = 30,k = 1) == 1\n assert candidate(n = 100,k = 10) == -1\n assert candidate(n = 36,k = 6) == 9\n assert candidate(n = 1000,k = 10) == 50\n assert candidate(n = 84,k = 5) == 6\n assert candidate(n = 500,k = 7) == 25\n assert candidate(n = 999,k = 9) == -1\n assert candidate(n = 97,k = 2) == 97\n assert candidate(n = 17,k = 1) == 1\n assert candidate(n = 4,k = 4) == -1\n assert candidate(n = 50,k = 5) == 25\n assert candidate(n = 37,k = 1) == 1\n assert candidate(n = 60,k = 8) == 12\n assert candidate(n = 81,k = 4) == 27\n assert candidate(n = 60,k = 6) == 6\n assert candidate(n = 100,k = 11) == -1\n assert candidate(n = 120,k = 12) == 24\n assert candidate(n = 144,k = 9) == 16\n assert candidate(n = 841,k = 3) == 841\n assert candidate(n = 49,k = 2) == 7\n assert candidate(n = 36,k = 8) == 18\n assert candidate(n = 121,k = 3) == 121\n assert candidate(n = 100,k = 7) == 25\n assert candidate(n = 256,k = 7) == 64\n assert candidate(n = 360,k = 15) == 30\n assert candidate(n = 999,k = 20) == -1\n assert candidate(n = 64,k = 7) == 64\n assert candidate(n = 504,k = 8) == 9\n assert candidate(n = 625,k = 5) == 625\n assert candidate(n = 15,k = 3) == 5\n assert candidate(n = 120,k = 7) == 8\n assert candidate(n = 997,k = 2) == 997\n assert candidate(n = 256,k = 8) == 128\n assert candidate(n = 999,k = 15) == -1\n assert candidate(n = 500,k = 15) == -1\n assert candidate(n = 810,k = 16) == 135\n assert candidate(n = 841,k = 7) == -1\n assert candidate(n = 45,k = 5) == 15\n assert candidate(n = 441,k = 4) == 9\n assert candidate(n = 1024,k = 9) == 256\n assert candidate(n = 200,k = 1) == 1\n assert candidate(n = 999,k = 3) == 9\n assert candidate(n = 25,k = 3) == 25\n assert candidate(n = 1000,k = 18) == -1\n assert candidate(n = 1000,k = 16) == 1000\n assert candidate(n = 450,k = 15) == 90\n assert candidate(n = 600,k = 15) == 40\n assert candidate(n = 6,k = 4) == 6\n assert candidate(n = 225,k = 8) == 75\n assert candidate(n = 500,k = 8) == 50\n assert candidate(n = 9,k = 3) == 9\n assert candidate(n = 729,k = 6) == 243\n assert candidate(n = 504,k = 10) == 14\n assert candidate(n = 500,k = 12) == 500\n assert candidate(n = 96,k = 10) == 32\n assert candidate(n = 999,k = 5) == 37\n assert candidate(n = 343,k = 3) == 49\n assert candidate(n = 72,k = 9) == 18\n assert candidate(n = 450,k = 20) == -1\n assert candidate(n = 1000,k = 1) == 1\n assert candidate(n = 1024,k = 10) == 512\n assert candidate(n = 36,k = 11) == -1\n assert candidate(n = 441,k = 5) == 21\n assert candidate(n = 729,k = 12) == -1\n assert candidate(n = 999,k = 10) == -1\n assert candidate(n = 36,k = 7) == 12\n assert candidate(n = 50,k = 3) == 5\n assert candidate(n = 225,k = 5) == 15\n assert candidate(n = 200,k = 20) == -1\n assert candidate(n = 100,k = 9) == 100\n assert candidate(n = 16,k = 5) == 16\n assert candidate(n = 625,k = 6) == -1\n assert candidate(n = 840,k = 10) == 12\n"}, "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().kthFactor", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int kthFactor(int n, int k) {", "container": "Solution", "callable": "kthFactor", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1493, "task_id": "longest-subarray-of-1s-after-deleting-one-element", "difficulty": "Medium", "problem_description": "Given a binary array nums, you should delete one element from it.\nReturn the size of the longest non-empty subarray containing only 1's in the resulting array. Return 0 if there is no such subarray.\n \nExample 1:\n\nInput: nums = [1,1,0,1]\nOutput: 3\nExplanation: After deleting the number in position 2, [1,1,1] contains 3 numbers with value of 1's.\n\nExample 2:\n\nInput: nums = [0,1,1,1,0,1,1,0,1]\nOutput: 5\nExplanation: After deleting the number in position 4, [0,1,1,1,1,1,0,1] longest subarray with value of 1's is [1,1,1,1,1].\n\nExample 3:\n\nInput: nums = [1,1,1]\nOutput: 2\nExplanation: You must delete one element.\n\n \nConstraints:\n\n1 <= nums.length <= 105\nnums[i] is either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1]) == 4\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 2\n assert candidate(nums = [0, 0, 0]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 1, 1, 1, 0]) == 5\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0]) == 6\n assert candidate(nums = [1, 1, 1]) == 2\n assert candidate(nums = [1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0]) == 6\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 1, 1, 0, 1]) == 4\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1]) == 6\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0]) == 7\n assert candidate(nums = [1, 1, 0, 1]) == 3\n assert candidate(nums = [0, 1, 1, 1, 0, 1, 1, 0, 1]) == 5\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1]) == 4\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 24\n assert candidate(nums = [0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1]) == 9\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0]) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 19\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 38\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 24\n assert candidate(nums = [1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 25\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1]) == 4\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1]) == 23\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 29\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0]) == 10\n assert candidate(nums = [0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0]) == 6\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1]) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 33\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1]) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 29\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1]) == 14\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0]) == 3\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1]) == 9\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1]) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0]) == 20\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1]) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 22\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 19\n assert candidate(nums = [1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0]) == 4\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 3\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1]) == 6\n assert candidate(nums = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 24\n assert candidate(nums = [0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1]) == 6\n assert candidate(nums = [1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1]) == 22\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1]) == 9\n assert candidate(nums = [1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 19\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 32\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 28\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 31\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1]) == 8\n assert candidate(nums = [1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0]) == 6\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1]) == 30\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == 5\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1]) == 9\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1]) == 16\n assert candidate(nums = [1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1]) == 7\n assert candidate(nums = [1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1]) == 8\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]) == 1\n assert candidate(nums = [1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0]) == 10\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0]) == 1\n assert candidate(nums = [1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums = [0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1]) == 3\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 43\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 2\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().longestSubarray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int longestSubarray(vector& nums) {", "container": "Solution", "callable": "longestSubarray", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1494, "task_id": "parallel-courses-ii", "difficulty": "Hard", "problem_description": "You are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also given an array relations where relations[i] = [prevCoursei, nextCoursei], representing a prerequisite relationship between course prevCoursei and course nextCoursei: course prevCoursei has to be taken before course nextCoursei. Also, you are given the integer k.\nIn one semester, you can take at most k courses as long as you have taken all the prerequisites in the previous semesters for the courses you are taking.\nReturn the minimum number of semesters needed to take all courses. The testcases will be generated such that it is possible to take every course.\n \nExample 1:\n\n\nInput: n = 4, relations = [[2,1],[3,1],[1,4]], k = 2\nOutput: 3\nExplanation: The figure above represents the given graph.\nIn the first semester, you can take courses 2 and 3.\nIn the second semester, you can take course 1.\nIn the third semester, you can take course 4.\n\nExample 2:\n\n\nInput: n = 5, relations = [[2,1],[3,1],[4,1],[1,5]], k = 2\nOutput: 4\nExplanation: The figure above represents the given graph.\nIn the first semester, you can only take courses 2 and 3 since you cannot take more than two per semester.\nIn the second semester, you can take course 4.\nIn the third semester, you can take course 1.\nIn the fourth semester, you can take course 5.\n\n \nConstraints:\n\n1 <= n <= 15\n1 <= k <= n\n0 <= relations.length <= n * (n-1) / 2\nrelations[i].length == 2\n1 <= prevCoursei, nextCoursei <= n\nprevCoursei != nextCoursei\nAll the pairs [prevCoursei, nextCoursei] are unique.\nThe given graph is a directed acyclic graph.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,relations = [[2, 1], [3, 1], [1, 4]],k = 2) == 3\n assert candidate(n = 5,relations = [],k = 3) == 2\n assert candidate(n = 5,relations = [[2, 1], [3, 1], [4, 1], [1, 5]],k = 2) == 4\n assert candidate(n = 3,relations = [[1, 3], [2, 3]],k = 2) == 2\n assert candidate(n = 3,relations = [],k = 3) == 1\n assert candidate(n = 4,relations = [[2, 1], [3, 1]],k = 1) == 4\n assert candidate(n = 6,relations = [[1, 2], [2, 3], [4, 5], [5, 6]],k = 2) == 3\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [7, 15]],k = 4) == 5\n assert candidate(n = 15,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],k = 3) == 15\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [3, 6], [4, 6], [5, 6], [6, 7], [6, 8], [7, 9], [8, 9], [9, 10], [9, 11], [10, 12], [11, 12], [12, 13], [12, 14], [13, 15], [14, 15]],k = 3) == 10\n assert candidate(n = 3,relations = [],k = 2) == 2\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15]],k = 4) == 5\n assert candidate(n = 10,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 3], [1, 5], [1, 7], [1, 9]],k = 4) == 10\n assert candidate(n = 7,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [1, 4], [2, 5], [3, 6]],k = 2) == 7\n assert candidate(n = 14,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],k = 2) == 14\n assert candidate(n = 15,relations = [[1, 5], [2, 5], [3, 5], [4, 5], [1, 6], [2, 6], [3, 6], [4, 6], [1, 7], [2, 7], [3, 7], [4, 7]],k = 3) == 5\n assert candidate(n = 8,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8]],k = 2) == 5\n assert candidate(n = 8,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],k = 3) == 8\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 15], [9, 15], [10, 15], [11, 15], [12, 15], [13, 15], [14, 15]],k = 5) == 5\n assert candidate(n = 7,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],k = 2) == 7\n assert candidate(n = 10,relations = [[1, 5], [1, 6], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10]],k = 3) == 4\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12]],k = 2) == 7\n assert candidate(n = 12,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],k = 4) == 12\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11], [7, 12], [8, 12], [9, 12], [10, 12]],k = 3) == 5\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 10]],k = 4) == 4\n assert candidate(n = 8,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 8], [7, 8]],k = 2) == 5\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 12], [10, 12], [11, 12]],k = 4) == 5\n assert candidate(n = 13,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11], [7, 12], [8, 12], [9, 13], [10, 13]],k = 5) == 5\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 10]],k = 2) == 6\n assert candidate(n = 14,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 14], [12, 14], [13, 14]],k = 5) == 6\n assert candidate(n = 9,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 4], [3, 6], [4, 7], [5, 7], [6, 7], [7, 8], [7, 9]],k = 2) == 6\n assert candidate(n = 10,relations = [[1, 5], [1, 6], [2, 6], [2, 7], [3, 7], [3, 8], [4, 8], [4, 9], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10]],k = 3) == 4\n assert candidate(n = 14,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [4, 6], [5, 7], [5, 8], [6, 9], [6, 10], [7, 11], [7, 12], [8, 13], [8, 14], [9, 13], [10, 14]],k = 4) == 6\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 15], [11, 15], [12, 15], [13, 15], [14, 15]],k = 2) == 9\n assert candidate(n = 13,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 8], [5, 9], [6, 10], [6, 11], [7, 10], [7, 11], [8, 12], [8, 13], [9, 12], [9, 13], [10, 13], [11, 13]],k = 4) == 5\n assert candidate(n = 9,relations = [[1, 3], [1, 4], [1, 5], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 7], [4, 8], [5, 7], [5, 8], [6, 9], [7, 9], [8, 9]],k = 3) == 4\n assert candidate(n = 11,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 11]],k = 3) == 5\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10]],k = 4) == 4\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11], [7, 12], [8, 12], [9, 12], [10, 12]],k = 4) == 5\n assert candidate(n = 14,relations = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 6], [5, 7], [5, 8], [5, 9], [6, 10], [7, 10], [8, 10], [9, 10], [10, 11], [11, 12], [11, 13], [11, 14]],k = 4) == 6\n assert candidate(n = 13,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 12], [10, 13], [11, 13]],k = 4) == 5\n assert candidate(n = 14,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 14]],k = 3) == 6\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 12]],k = 2) == 7\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],k = 2) == 14\n assert candidate(n = 10,relations = [[1, 5], [2, 5], [3, 5], [4, 5], [6, 7], [7, 8], [8, 9], [9, 10]],k = 2) == 5\n assert candidate(n = 14,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14]],k = 3) == 6\n assert candidate(n = 15,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],k = 5) == 15\n assert candidate(n = 12,relations = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 12], [11, 12]],k = 3) == 5\n assert candidate(n = 8,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 8], [7, 8]],k = 2) == 5\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 8], [5, 9], [6, 10], [6, 11], [7, 10], [7, 11], [8, 12], [9, 12], [10, 12], [11, 12]],k = 4) == 5\n assert candidate(n = 8,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 5], [3, 6], [4, 6], [4, 7], [5, 8], [6, 8], [7, 8]],k = 2) == 5\n assert candidate(n = 13,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]],k = 4) == 13\n assert candidate(n = 12,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],k = 3) == 12\n assert candidate(n = 9,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],k = 2) == 8\n assert candidate(n = 10,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],k = 1) == 10\n assert candidate(n = 7,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 7], [6, 7]],k = 2) == 5\n assert candidate(n = 15,relations = [[1, 6], [1, 7], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 14], [7, 15], [8, 14], [8, 15], [9, 14], [9, 15], [10, 14], [10, 15], [11, 14], [11, 15], [12, 14], [12, 15], [13, 14], [13, 15]],k = 5) == 4\n assert candidate(n = 11,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 8], [5, 9], [6, 10], [7, 10], [8, 11], [9, 11]],k = 3) == 5\n assert candidate(n = 9,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9]],k = 2) == 5\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 15], [11, 15], [12, 15], [13, 15], [14, 15]],k = 4) == 6\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],k = 3) == 11\n assert candidate(n = 11,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11]],k = 3) == 5\n assert candidate(n = 8,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 8], [7, 8]],k = 3) == 5\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10]],k = 3) == 6\n assert candidate(n = 8,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 7], [4, 8]],k = 2) == 5\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10]],k = 3) == 6\n assert candidate(n = 10,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],k = 3) == 10\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9], [6, 10], [7, 10], [8, 10], [9, 10]],k = 3) == 6\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 12]],k = 2) == 7\n assert candidate(n = 9,relations = [[1, 2], [2, 3], [1, 3], [4, 5], [5, 6], [4, 6], [7, 8], [8, 9], [7, 9], [2, 4], [3, 5]],k = 3) == 5\n assert candidate(n = 15,relations = [[1, 3], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],k = 5) == 14\n assert candidate(n = 14,relations = [[1, 4], [2, 4], [3, 4], [4, 5], [5, 6], [5, 7], [6, 8], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],k = 3) == 11\n assert candidate(n = 10,relations = [[1, 3], [2, 3], [3, 4], [3, 5], [4, 6], [5, 6], [6, 7], [6, 8], [7, 9], [8, 9], [9, 10]],k = 3) == 7\n assert candidate(n = 12,relations = [[1, 3], [2, 3], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9], [6, 10], [6, 11], [7, 12], [8, 10], [9, 11]],k = 3) == 6\n assert candidate(n = 7,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 6], [6, 7]],k = 2) == 5\n assert candidate(n = 12,relations = [[1, 3], [2, 3], [3, 4], [3, 5], [4, 6], [5, 6], [6, 7], [6, 8], [7, 9], [8, 9], [9, 10], [9, 11], [10, 12], [11, 12]],k = 3) == 8\n assert candidate(n = 14,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14]],k = 3) == 6\n assert candidate(n = 7,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]],k = 1) == 7\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [3, 5], [4, 6], [5, 7], [5, 8], [6, 9], [6, 10], [7, 10], [8, 10]],k = 2) == 6\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [5, 7], [6, 8], [7, 8], [8, 9], [8, 10]],k = 3) == 7\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 14], [7, 15], [8, 14], [8, 15], [9, 14], [9, 15], [10, 14], [10, 15], [11, 14], [11, 15], [12, 14], [12, 15], [13, 14], [13, 15]],k = 5) == 5\n assert candidate(n = 15,relations = [[1, 4], [1, 5], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10], [10, 11], [10, 12], [11, 13], [12, 13], [13, 14], [13, 15], [14, 15]],k = 4) == 8\n assert candidate(n = 9,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],k = 2) == 5\n assert candidate(n = 11,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 8], [5, 9], [6, 10], [6, 11], [7, 10], [7, 11], [8, 11], [9, 10]],k = 3) == 5\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 10], [7, 10]],k = 3) == 5\n assert candidate(n = 10,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 6], [2, 7], [3, 8], [4, 9]],k = 4) == 10\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15]],k = 3) == 6\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10]],k = 2) == 6\n assert candidate(n = 11,relations = [[1, 3], [1, 4], [2, 4], [2, 5], [3, 6], [4, 7], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [2, 6], [3, 7]],k = 2) == 6\n assert candidate(n = 13,relations = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13]],k = 2) == 7\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],k = 1) == 10\n assert candidate(n = 15,relations = [[1, 15], [2, 15], [3, 15], [4, 15], [5, 15], [6, 15], [7, 15], [8, 15], [9, 15], [10, 15], [11, 15], [12, 15], [13, 15], [14, 15]],k = 5) == 4\n"}, "metadata": {"canonical_parameter_names": ["n", "relations", "k"], "leetcode_dataset_entry_point": "Solution().minNumberOfSemesters", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minNumberOfSemesters(int n, vector>& relations, int k) {", "container": "Solution", "callable": "minNumberOfSemesters", "parameters": [{"name": "n", "type": "int"}, {"name": "relations", "type": "vector>&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1496, "task_id": "path-crossing", "difficulty": "Easy", "problem_description": "Given a string path, where path[i] = 'N', 'S', 'E' or 'W', each representing moving one unit north, south, east, or west, respectively. You start at the origin (0, 0) on a 2D plane and walk on the path specified by path.\nReturn true if the path crosses itself at any point, that is, if at any time you are on a location you have previously visited. Return false otherwise.\n \nExample 1:\n\n\nInput: path = \"NES\"\nOutput: false \nExplanation: Notice that the path doesn't cross any point more than once.\n\nExample 2:\n\n\nInput: path = \"NESWW\"\nOutput: true\nExplanation: Notice that the path visits the origin twice.\n \nConstraints:\n\n1 <= path.length <= 104\npath[i] is either 'N', 'S', 'E', or 'W'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(path = \"NEESWNWWSNNWNSSSWEWEWEWE\") == True\n assert candidate(path = \"NNNSSSSSSEEEEEEEWWWWWWWWW\") == True\n assert candidate(path = \"NEWSNEWS\") == True\n assert candidate(path = \"EWEWEWEW\") == True\n assert candidate(path = \"NESWW\") == True\n assert candidate(path = \"NSSS\") == True\n assert candidate(path = \"N\") == False\n assert candidate(path = \"NNSSEEEWWS\") == True\n assert candidate(path = \"NSSSWEWNNEE\") == True\n assert candidate(path = \"\") == False\n assert candidate(path = \"NSNSNSNS\") == True\n assert candidate(path = \"NNNSSSSS\") == True\n assert candidate(path = \"NESWNE\") == True\n assert candidate(path = \"NNESSEWSWNWNWSSSNW\") == True\n assert candidate(path = \"NS\") == True\n assert candidate(path = \"NNESSWW\") == True\n assert candidate(path = \"NENESSWW\") == True\n assert candidate(path = \"EWE\") == True\n assert candidate(path = \"NES\") == False\n assert candidate(path = \"NEWS\") == True\n assert candidate(path = \"NNNNSSSSWWWWEEEE\") == True\n assert candidate(path = \"WEWEWEWE\") == True\n assert candidate(path = \"NWSWEWNWNW\") == True\n assert candidate(path = \"NNEESSWW\") == True\n assert candidate(path = \"NNEEESSWWNNNEEESSWWNNNESSWWN\") == True\n assert candidate(path = \"EEEE\") == False\n assert candidate(path = \"EESSEENN\") == False\n assert candidate(path = \"WEWN\") == True\n assert candidate(path = \"EENW\") == False\n assert candidate(path = \"NEEEEWWWWSSSSNNN\") == True\n assert candidate(path = \"ENWSWNESWSWNESWS\") == True\n assert candidate(path = \"NENWSEWSWESWESWESW\") == True\n assert candidate(path = \"NNEWSSEESSEENNNWNNNW\") == True\n assert candidate(path = \"NNNSSSWEWEWESWNWNWNWWSWSWENENE\") == True\n assert candidate(path = \"ENWNENWENW\") == True\n assert candidate(path = \"NWSNWSNWSNWSNWS\") == True\n assert candidate(path = \"EEEEEWWWWWSSSSSNNNNN\") == True\n assert candidate(path = \"NWNWNWNWNWSWSWSWSW\") == False\n assert candidate(path = \"NESWWNESWWNESWW\") == True\n assert candidate(path = \"EESWWNNESWNESESW\") == True\n assert candidate(path = \"WENWENWENW\") == True\n assert candidate(path = \"NSEENWNNWSSSWEE\") == True\n assert candidate(path = \"NNSSEEEWWW\") == True\n assert candidate(path = \"NEWSNEWSNEWSNEWSNEWS\") == True\n assert candidate(path = \"SSNNEEWW\") == True\n assert candidate(path = \"NNWNWSSSWNEEEEEN\") == True\n assert candidate(path = \"NNESWSWNWNWS\") == True\n assert candidate(path = \"NNNNSSSSWWWW\") == True\n assert candidate(path = \"EENWNWSS\") == True\n assert candidate(path = \"NNNNEEESSEWWNNNNEE\") == True\n assert candidate(path = \"NESEWNESEWNESEW\") == True\n assert candidate(path = \"EENNWWSSNNSSEE\") == True\n assert candidate(path = \"SSSSNNNNEEEEWWWW\") == True\n assert candidate(path = \"EEEEEEEEEEEEEEEWWWWWWWWWWWWWWWSSSSSSSSSSSSSSSNNNNNNNNNNNNNNN\") == True\n assert candidate(path = \"NNNSSSNNNSSS\") == True\n assert candidate(path = \"NEWSNEWSNEWS\") == True\n assert candidate(path = \"ENSNWNWNWN\") == True\n assert candidate(path = \"ESSNNWWSSEN\") == True\n assert candidate(path = \"SWENSWENSWENSWEN\") == True\n assert candidate(path = \"WESSNNESWWSE\") == True\n assert candidate(path = \"NENWSWSENENW\") == True\n assert candidate(path = \"WSEWSEWSEWSEW\") == True\n assert candidate(path = \"NNNSSSSSSEEWWWW\") == True\n assert candidate(path = \"WENSNWSWES\") == True\n assert candidate(path = \"NWWWSSENNE\") == True\n assert candidate(path = \"NEESWNESWSWN\") == True\n assert candidate(path = \"WEWNSWESWESWESW\") == True\n assert candidate(path = \"NNWESWSWSEENW\") == True\n assert candidate(path = \"WNWSSNSSWEEENEEN\") == True\n assert candidate(path = \"EWEWEWEWEEWWEWEEWWSWWSW\") == True\n assert candidate(path = \"NSSSSEEEEWWWNNSNWEEE\") == True\n assert candidate(path = \"SSENNWESSW\") == True\n assert candidate(path = \"NEEEEESWWWWNSSSSS\") == True\n assert candidate(path = \"NNNNNSSSSSAAAABBBB\") == True\n assert candidate(path = \"NESWNEESWW\") == True\n assert candidate(path = \"NENWSEWSWENWSEWSW\") == True\n assert candidate(path = \"NNNNNNNNSSSSSSSSWWWWWWWWEEEEEEEE\") == True\n assert candidate(path = \"ENENEWNWNWSWSW\") == True\n assert candidate(path = \"NENENENENESESESESESWSWSWSWSW\") == False\n assert candidate(path = \"ENEWWNNEWSWE\") == True\n assert candidate(path = \"NNNNNNNNNN\") == False\n assert candidate(path = \"ENWESWNESEENWSWEN\") == True\n assert candidate(path = \"NESESWWSSWNE\") == True\n assert candidate(path = \"NENENENENEWWWWWW\") == True\n assert candidate(path = \"NNNEEEESSSNNNWWSW\") == True\n assert candidate(path = \"NENENENENNENESESWSWWSW\") == True\n assert candidate(path = \"ENSWNESWNESEWS\") == True\n assert candidate(path = \"ENWSESWNESWENSWE\") == True\n assert candidate(path = \"ENEENWNNWSSSSNE\") == True\n assert candidate(path = \"EEESSSNNNW\") == True\n assert candidate(path = \"NNNSSSSSSEEEWWWW\") == True\n assert candidate(path = \"EESNNWWSSEEN\") == True\n assert candidate(path = \"NNNEEESSEESWWNN\") == True\n assert candidate(path = \"EENWNNWSSNNWEE\") == True\n assert candidate(path = \"NEWWNWSSWSEWSSN\") == True\n assert candidate(path = \"NESESWNESESWNESESW\") == True\n assert candidate(path = \"NENWSWNWNWSWNWNW\") == True\n assert candidate(path = \"NENWSESWNESWNES\") == True\n assert candidate(path = \"NENENNENNE\") == False\n assert candidate(path = \"NEWSNEWSNEWSNEWS\") == True\n assert candidate(path = \"NSEWSSEEEWWWNNEENW\") == True\n assert candidate(path = \"NNWESSSWNE\") == True\n assert candidate(path = \"ESSSWWNNEEEWWNNSSEEE\") == True\n assert candidate(path = \"NESWNESWNESW\") == True\n assert candidate(path = \"NESESWWSWN\") == False\n assert candidate(path = \"NESWNESESWNESESW\") == True\n assert candidate(path = \"NENWSEWSWNNWSEWSW\") == True\n assert candidate(path = \"ENWNNWSSNWNWEE\") == True\n assert candidate(path = \"NNWSENNWWSSSEEE\") == True\n assert candidate(path = \"WNWSSNSSWEEENEENE\") == True\n assert candidate(path = \"NSEWNSSEWW\") == True\n assert candidate(path = \"ENWSENWSENWSENWS\") == True\n assert candidate(path = \"SSSSWWWWNNEE\") == False\n assert candidate(path = \"NSSSWWNEEENNEESSE\") == True\n assert candidate(path = \"ENWSWWSESNWEN\") == True\n assert candidate(path = \"NSSSNWWNEEEE\") == True\n assert candidate(path = \"NNSESSWWNE\") == True\n assert candidate(path = \"NESWENSWEWNENSWSEWNESW\") == True\n assert candidate(path = \"WESSNNWESSNNWESSNN\") == True\n assert candidate(path = \"SSWWSSENNE\") == True\n assert candidate(path = \"ESWENSWENSWENSWENSWEN\") == True\n assert candidate(path = \"NESWNSWENSWE\") == True\n assert candidate(path = \"NESWWSEN\") == True\n assert candidate(path = \"EWEWNEWEWN\") == True\n assert candidate(path = \"EENNWWNSSSNEEE\") == True\n assert candidate(path = \"EESWWNNEWSNEWSNEWS\") == True\n assert candidate(path = \"WEWNENEWNWNWSWSNEN\") == True\n assert candidate(path = \"NESWNSWENWEWSWEWNSWEWENWSWEN\") == True\n assert candidate(path = \"NENWSEWNENWSEWNENWSEW\") == True\n assert candidate(path = \"WNESSWNESSWNE\") == True\n assert candidate(path = \"WENWNNWENWSE\") == True\n assert candidate(path = \"NSEWNNNSSSWEWEWEWWE\") == True\n assert candidate(path = \"NENWNWNWSENW\") == True\n assert candidate(path = \"WNEEESSNWWWEN\") == True\n assert candidate(path = \"EEENNWWWWNEESSS\") == True\n assert candidate(path = \"SSSSNNNNWWEEEE\") == True\n assert candidate(path = \"EEENNNEEWWSSSWWN\") == True\n assert candidate(path = \"EEEEEEEWWWWWWSSSSSSNNNNNN\") == True\n assert candidate(path = \"EEEEEENNNNNNSSSSSWEWE\") == True\n assert candidate(path = \"NSSSSWWWWEEEEEENNN\") == True\n assert candidate(path = \"SSSSEEEEWWWWNNNN\") == True\n assert candidate(path = \"SSSSSSSSSS\") == False\n assert candidate(path = \"NSSSWWEENNSSSWWEEN\") == True\n assert candidate(path = \"EENNWWSSNWNWEEWN\") == True\n assert candidate(path = \"NENENENE\") == False\n assert candidate(path = \"NENESWNESE\") == True\n assert candidate(path = \"ENWSWEWNWSWEWNWS\") == True\n assert candidate(path = \"NENWSEWSWNESWESW\") == True\n assert candidate(path = \"WWEENNWEES\") == True\n assert candidate(path = \"EWEWNEWNWSWE\") == True\n assert candidate(path = \"NNNSSSSSSSWWWWWWWWWEEEEE\") == True\n assert candidate(path = \"NWSWNWSWNW\") == False\n assert candidate(path = \"NNSSWWEENN\") == True\n assert candidate(path = \"NSEENWNNWSSSWEEE\") == True\n assert candidate(path = \"NENWSNWSNESW\") == True\n assert candidate(path = \"NNSWESWESWESWESW\") == True\n assert candidate(path = \"NESNESNESNESNES\") == True\n assert candidate(path = \"NESWNNNWWWEES\") == True\n assert candidate(path = \"SSNNSSNNSS\") == True\n assert candidate(path = \"NEWSWNNWSSNWNWEE\") == True\n assert candidate(path = \"NNWNWSSSWNEEE\") == True\n assert candidate(path = \"NENWNSNS\") == True\n assert candidate(path = \"EWSWNWESWE\") == True\n assert candidate(path = \"NNEEWWSS\") == True\n assert candidate(path = \"SEENENENEWSWSWNENE\") == True\n assert candidate(path = \"WNWSSNSSSENEEN\") == True\n assert candidate(path = \"NESESWSEWN\") == True\n assert candidate(path = \"NNEWSWSEWSSNENW\") == True\n assert candidate(path = \"EWEWEWEWEW\") == True\n assert candidate(path = \"SSEWEEWEEE\") == True\n assert candidate(path = \"NSSSSEEEEEWWWWNNNN\") == True\n assert candidate(path = \"NNNWWWSSSE\") == False\n assert candidate(path = \"NSSSNEEEWNWSS\") == True\n assert candidate(path = \"NESWNESW\") == True\n assert candidate(path = \"ESESWNEWSWSWNENESE\") == True\n assert candidate(path = \"NNNWWSSSNE\") == True\n assert candidate(path = \"NEWSWNESWESWNES\") == True\n assert candidate(path = \"NNESSEWW\") == True\n assert candidate(path = \"WEEWEEWEEE\") == True\n assert candidate(path = \"NENENWENWENWENWENW\") == True\n assert candidate(path = \"NNSSEEEWWWS\") == True\n assert candidate(path = \"SWSWSWSWNENENENENE\") == True\n assert candidate(path = \"SSSEEESSSWWNNN\") == True\n assert candidate(path = \"NNSSNNSS\") == True\n assert candidate(path = \"NNSEESSWNW\") == True\n assert candidate(path = \"NNNSSSWEWEWESWNWNWNWWSWSWENENESESESESNESWENSWEWNENSWSEWNESW\") == True\n"}, "metadata": {"canonical_parameter_names": ["path"], "leetcode_dataset_entry_point": "Solution().isPathCrossing", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool isPathCrossing(string path) {", "container": "Solution", "callable": "isPathCrossing", "parameters": [{"name": "path", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1497, "task_id": "check-if-array-pairs-are-divisible-by-k", "difficulty": "Medium", "problem_description": "Given an array of integers arr of even length n and an integer k.\nWe want to divide the array into exactly n / 2 pairs such that the sum of each pair is divisible by k.\nReturn true If you can find a way to do that or false otherwise.\n \nExample 1:\n\nInput: arr = [1,2,3,4,5,10,6,7,8,9], k = 5\nOutput: true\nExplanation: Pairs are (1,9),(2,8),(3,7),(4,6) and (5,10).\n\nExample 2:\n\nInput: arr = [1,2,3,4,5,6], k = 7\nOutput: true\nExplanation: Pairs are (1,6),(2,5) and(3,4).\n\nExample 3:\n\nInput: arr = [1,2,3,4,5,6], k = 10\nOutput: false\nExplanation: You can try all possible pairs to see that there is no way to divide arr into 3 pairs each with sum divisible by 10.\n\n \nConstraints:\n\narr.length == n\n1 <= n <= 105\nn is even.\n-109 <= arr[i] <= 109\n1 <= k <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8],k = 4) == True\n assert candidate(arr = [0, 0, 0, 0],k = 1) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6],k = 10) == False\n assert candidate(arr = [-1, 1, -2, 2, -3, 3],k = 2) == True\n assert candidate(arr = [-1, 1, -2, 2, -3, 3],k = 3) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6],k = 7) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 11) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8],k = 8) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 10, 6, 7, 8, 9],k = 5) == True\n assert candidate(arr = [0, 0, 0, 0],k = 3) == True\n assert candidate(arr = [0, 0, 0, 0],k = 2) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 6) == False\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32],k = 8) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],k = 10) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 7) == False\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 3) == False\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155],k = 20) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 5) == True\n assert candidate(arr = [123, 246, 369, 492, 615, 738, 861, 984, 1107, 1230],k = 123) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 5) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 25) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == True\n assert candidate(arr = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 6) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24],k = 6) == False\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 10) == False\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],k = 3) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 5) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 17) == False\n assert candidate(arr = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],k = 3) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 13) == False\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32],k = 10) == False\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84],k = 7) == True\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16],k = 6) == False\n assert candidate(arr = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600],k = 50) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 7) == True\n assert candidate(arr = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, 6, 6],k = 5) == False\n assert candidate(arr = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80],k = 15) == False\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 15) == False\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 10) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 4) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150],k = 15) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 1) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 20) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 13) == False\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],k = 15) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 100000) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 19) == False\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 7) == False\n assert candidate(arr = [1000000000, 2000000000, -3000000000, 4000000000, 500000000, -600000000, 70000000, -80000000],k = 500000000) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 31) == True\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 20) == True\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 7) == True\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],k = 4) == False\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 2) == True\n assert candidate(arr = [1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97, 103, 109, 115],k = 6) == False\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 2) == True\n assert candidate(arr = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5],k = 10) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60],k = 25) == False\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220],k = 11) == True\n assert candidate(arr = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 13) == False\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16],k = 5) == False\n assert candidate(arr = [1, 3, 2, 4, 6, 8, 5, 7, 9, 11],k = 3) == False\n assert candidate(arr = [7, 3, 2, 6, 8, 10, 9, 5, 1, 4],k = 7) == False\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3],k = 5) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 5) == False\n assert candidate(arr = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],k = 10) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12],k = 5) == False\n assert candidate(arr = [9, 7, 5, 3, 1, 8, 6, 4, 2, 0, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 10) == False\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160],k = 20) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 9) == False\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],k = 5) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 8) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 13) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24],k = 5) == False\n assert candidate(arr = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],k = 9) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == True\n assert candidate(arr = [-1, -2, -3, -4, 1, 2, 3, 4],k = 3) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 15) == True\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],k = 20) == False\n assert candidate(arr = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5],k = 3) == True\n assert candidate(arr = [-10, 10, 20, -20, 30, -30, 40, -40],k = 10) == True\n assert candidate(arr = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 8) == True\n assert candidate(arr = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010],k = 101) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32],k = 19) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 39) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == True\n"}, "metadata": {"canonical_parameter_names": ["arr", "k"], "leetcode_dataset_entry_point": "Solution().canArrange", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool canArrange(vector& arr, int k) {", "container": "Solution", "callable": "canArrange", "parameters": [{"name": "arr", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1498, "task_id": "number-of-subsequences-that-satisfy-the-given-sum-condition", "difficulty": "Medium", "problem_description": "You are given an array of integers nums and an integer target.\nReturn the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal to target. Since the answer may be too large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: nums = [3,5,6,7], target = 9\nOutput: 4\nExplanation: There are 4 subsequences that satisfy the condition.\n[3] -> Min value + max value <= target (3 + 3 <= 9)\n[3,5] -> (3 + 5 <= 9)\n[3,5,6] -> (3 + 6 <= 9)\n[3,6] -> (3 + 6 <= 9)\n\nExample 2:\n\nInput: nums = [3,3,6,8], target = 10\nOutput: 6\nExplanation: There are 6 subsequences that satisfy the condition. (nums can have repeated numbers).\n[3] , [3] , [3,3], [3,6] , [3,6] , [3,3,6]\n\nExample 3:\n\nInput: nums = [2,3,3,4,6,7], target = 12\nOutput: 61\nExplanation: There are 63 non-empty subsequences, two of them do not satisfy the condition ([6,7], [7]).\nNumber of valid subsequences (63 - 2 = 61).\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 106\n1 <= target <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5],target = 10) == 31\n assert candidate(nums = [10, 10, 10, 10],target = 20) == 15\n assert candidate(nums = [1, 3, 5, 7],target = 8) == 10\n assert candidate(nums = [1, 2, 3, 4, 5],target = 5) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10) == 341\n assert candidate(nums = [9, 7, 5, 3, 1],target = 10) == 21\n assert candidate(nums = [1, 2, 3],target = 5) == 6\n assert candidate(nums = [5, 2, 4, 1, 7, 6, 8],target = 12) == 117\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 2) == 1023\n assert candidate(nums = [1],target = 1) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],target = 10) == 31\n assert candidate(nums = [1000000],target = 1000000) == 0\n assert candidate(nums = [3, 3, 6, 8],target = 10) == 6\n assert candidate(nums = [2, 3, 3, 4, 6, 7],target = 12) == 61\n assert candidate(nums = [3, 5, 6, 7],target = 9) == 4\n assert candidate(nums = [5, 2, 4, 1, 7, 6, 8],target = 10) == 101\n assert candidate(nums = [1, 3, 5, 7, 9],target = 10) == 21\n assert candidate(nums = [1, 2, 4, 8, 16],target = 24) == 30\n assert candidate(nums = [1, 1, 1, 1, 1],target = 2) == 31\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 20) == 349525\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 2) == 1023\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],target = 250) == 1026730\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000],target = 1111111) == 126\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],target = 10) == 341\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],target = 1999998) == 1023\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 20) == 682\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 2) == 1048575\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 1024) == 1023\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996],target = 2000000) == 31\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],target = 30) == 357913941\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 10) == 1023\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],target = 200) == 349525\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],target = 30) == 21845\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 10) == 191690598\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 25) == 1026730\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],target = 40) == 699050\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 15) == 10922\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],target = 50) == 966320448\n assert candidate(nums = [999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999],target = 1999998) == 1048575\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],target = 200) == 873813\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 10) == 341\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 21) == 699050\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 1200) == 853\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 1002\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],target = 100) == 898961330\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],target = 1000000) == 511\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 15) == 1002\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],target = 2000000) == 1023\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],target = 30) == 357913941\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 100) == 341\n assert candidate(nums = [1, 100, 1000, 10000, 100000, 1000000],target = 1100000) == 62\n assert candidate(nums = [500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000],target = 1000000) == 1023\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],target = 300) == 1047893\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],target = 2000000) == 1023\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 1002\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 30) == 1047893\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],target = 300) == 1047893\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 2) == 986564552\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],target = 150) == 1047893\n assert candidate(nums = [2, 2, 3, 3, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12],target = 15) == 986316\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995],target = 1999993) == 10\n assert candidate(nums = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5, 999996],target = 1000000) == 341\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = 20) == 1048575\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 150) == 1002\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],target = 1999998) == 1021\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],target = 1000000) == 1048574\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],target = 1048576) == 1048575\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000],target = 1000000) == 0\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4],target = 6) == 967\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],target = 15) == 1002\n assert candidate(nums = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989],target = 1999989) == 1706\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000],target = 1500000) == 1002\n assert candidate(nums = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5, 999996],target = 2000000) == 1023\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],target = 2500) == 32746\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],target = 10) == 209715\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 20) == 349525\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],target = 200000) == 1023\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],target = 30) == 21845\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9],target = 10) == 985115752\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 20) == 32085\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],target = 10) == 18641351\n"}, "metadata": {"canonical_parameter_names": ["nums", "target"], "leetcode_dataset_entry_point": "Solution().numSubseq", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numSubseq(vector& nums, int target) {", "container": "Solution", "callable": "numSubseq", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1499, "task_id": "max-value-of-equation", "difficulty": "Hard", "problem_description": "You are given an array points containing the coordinates of points on a 2D plane, sorted by the x-values, where points[i] = [xi, yi] such that xi < xj for all 1 <= i < j <= points.length. You are also given an integer k.\nReturn the maximum value of the equation yi + yj + |xi - xj| where |xi - xj| <= k and 1 <= i < j <= points.length.\nIt is guaranteed that there exists at least one pair of points that satisfy the constraint |xi - xj| <= k.\n \nExample 1:\n\nInput: points = [[1,3],[2,0],[5,10],[6,-10]], k = 1\nOutput: 4\nExplanation: The first two points satisfy the condition |xi - xj| <= 1 and if we calculate the equation we get 3 + 0 + |1 - 2| = 4. Third and fourth points also satisfy the condition and give a value of 10 + -10 + |5 - 6| = 1.\nNo other pairs satisfy the condition, so we return the max of 4 and 1.\n\nExample 2:\n\nInput: points = [[0,0],[3,0],[9,2]], k = 3\nOutput: 3\nExplanation: Only the first two points have an absolute difference of 3 or less in the x-values, and give the value of 0 + 0 + |0 - 3| = 3.\n\n \nConstraints:\n\n2 <= points.length <= 105\npoints[i].length == 2\n-108 <= xi, yi <= 108\n0 <= k <= 2 * 108\nxi < xj for all 1 <= i < j <= points.length\nxi form a strictly increasing sequence.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[1, 3], [2, 0], [5, 10], [6, -10]],k = 1) == 4\n assert candidate(points = [[100000000, 100000000], [200000000, 200000000], [300000000, 300000000]],k = 100000000) == 600000000\n assert candidate(points = [[1, 5], [2, 3], [4, 7], [8, 10]],k = 6) == 21\n assert candidate(points = [[1, 3], [2, 0], [5, 10], [6, -10], [7, 5]],k = 4) == 17\n assert candidate(points = [[-10, -10], [-5, -5], [0, 0], [5, 5], [10, 10]],k = 15) == 20\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4]],k = 2) == 8\n assert candidate(points = [[-1, 1], [-2, 2], [-3, 3]],k = 1) == 4\n assert candidate(points = [[-10, 5], [0, 0], [10, 10], [20, -5]],k = 25) == 35\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5]],k = 2) == 10\n assert candidate(points = [[-10, -10], [0, 0], [10, 10]],k = 20) == 20\n assert candidate(points = [[1, 100000000], [100000000, 1]],k = 200000000) == 200000000\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],k = 4) == 10\n assert candidate(points = [[1, 1], [3, 3], [5, 5]],k = 4) == 10\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],k = 2) == 10\n assert candidate(points = [[0, 0], [3, 0], [9, 2]],k = 3) == 3\n assert candidate(points = [[-1, 2], [-3, 3], [1, 3], [2, 4]],k = 4) == 10\n assert candidate(points = [[-1, 20], [-10, 15], [-5, 10], [0, 5], [5, 0], [10, -5], [15, -10]],k = 12) == 30\n assert candidate(points = [[1, 100000000], [2, 99999999], [3, 99999998], [4, 99999997], [5, 99999996], [6, 99999995]],k = 4) == 200000000\n assert candidate(points = [[1, 1], [2, 100000000], [3, 1], [4, 100000000], [5, 1]],k = 1) == 100000002\n assert candidate(points = [[100000000, 100000000], [200000000, -200000000], [300000000, 300000000]],k = 150000000) == 200000000\n assert candidate(points = [[1, 1], [3, 4], [5, 7], [8, 10], [12, 13], [15, 14], [18, 15], [20, 16], [25, 17], [30, 18]],k = 15) == 47\n assert candidate(points = [[100000000, -100000000], [100000001, 100000000], [100000002, -100000000], [100000003, 100000000]],k = 4) == 200000002\n assert candidate(points = [[1, 3], [4, 1], [8, 5], [15, 10], [20, 6], [25, 3]],k = 15) == 27\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],k = 9) == 11\n assert candidate(points = [[1, 3], [4, 5], [7, 8], [10, 12], [13, 15], [16, 18]],k = 5) == 36\n assert candidate(points = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 0], [7, -1], [8, -2], [9, -3], [10, -4]],k = 4) == 10\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]],k = 2) == 30\n assert candidate(points = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700]],k = 3) == 1301\n assert candidate(points = [[1, 3], [5, 10], [8, 15], [10, 7], [12, 20], [16, 5], [20, 25]],k = 10) == 53\n assert candidate(points = [[1, -1], [2, -2], [3, -3], [4, -4], [5, -5], [6, -6], [7, -7], [8, -8], [9, -9], [10, -10], [11, -11], [12, -12], [13, -13], [14, -14], [15, -15], [16, -16], [17, -17], [18, -18], [19, -19], [20, -20]],k = 5) == -2\n assert candidate(points = [[-1, 1], [0, 0], [1, -1], [2, 2], [3, -3], [4, 4], [5, -5], [6, 6]],k = 2) == 12\n assert candidate(points = [[1, 100], [5, 200], [10, 300], [15, 400], [20, 500], [25, 600], [30, 700]],k = 10) == 1305\n assert candidate(points = [[1, 3], [2, 0], [5, 10], [6, -10], [7, 2], [8, -5], [10, 4]],k = 3) == 14\n assert candidate(points = [[1, 1], [2, 3], [4, 2], [5, 3], [6, 5], [8, 6], [9, 7], [10, 8]],k = 5) == 17\n assert candidate(points = [[1, -1], [2, -2], [3, -3], [4, -4], [5, -5], [6, -6], [7, -7], [8, -8], [9, -9], [10, -10]],k = 5) == -2\n assert candidate(points = [[1, 100000000], [2, -100000000], [3, 100000000], [4, -100000000], [5, 100000000], [6, -100000000], [7, 100000000], [8, -100000000], [9, 100000000], [10, -100000000]],k = 1) == 1\n assert candidate(points = [[1, 1], [3, 5], [5, 3], [7, 9], [9, 4], [11, 10], [13, 6], [15, 8], [17, 2], [19, 12]],k = 4) == 24\n assert candidate(points = [[100000, -100000], [100005, 100000], [100010, -100000], [100015, 100000]],k = 10) == 200010\n assert candidate(points = [[1, 10], [3, 20], [5, 15], [7, 5], [9, 25], [11, 30], [13, 10], [15, 35]],k = 15) == 69\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],k = 1) == 3\n assert candidate(points = [[-5, 10], [-2, 3], [0, 0], [3, -5], [7, 2], [8, -1], [10, 6]],k = 4) == 16\n assert candidate(points = [[1, 1], [3, 4], [6, 7], [8, 10], [11, 13], [15, 16], [18, 19]],k = 7) == 39\n assert candidate(points = [[100000000, -100000000], [200000000, -200000000], [300000000, 100000000], [400000000, 200000000]],k = 250000000) == 400000000\n assert candidate(points = [[-5, -5], [-3, -3], [0, 0], [4, 4], [6, 6], [10, 10]],k = 6) == 20\n assert candidate(points = [[-20, 20], [-18, 18], [-16, 16], [-14, 14], [-12, 12], [-10, 10], [-8, 8], [-6, 6], [-4, 4], [-2, 2]],k = 4) == 40\n assert candidate(points = [[-100000000, -100000000], [-90000000, -90000000], [-80000000, -80000000], [-70000000, -70000000], [-60000000, -60000000], [-50000000, -50000000], [-40000000, -40000000], [-30000000, -30000000], [-20000000, -20000000], [-10000000, -10000000]],k = 20000000) == -20000000\n assert candidate(points = [[1, 100000000], [2, 99999999], [3, 99999998], [4, 99999997], [5, 99999996]],k = 1) == 200000000\n assert candidate(points = [[1, 100000000], [2, 50000000], [5, 10000000], [10, 5000000], [20, 1000000], [50, 500000], [100, 100000]],k = 99) == 150000001\n assert candidate(points = [[-5, -10], [-3, -7], [-1, -2], [1, 3], [4, 9]],k = 4) == 15\n assert candidate(points = [[1, 5], [4, 3], [6, 7], [8, 2], [10, 8]],k = 5) == 19\n assert candidate(points = [[1, 5], [3, 4], [7, 10], [8, 2], [10, 1]],k = 5) == 18\n assert candidate(points = [[1, 2], [4, 5], [6, 7], [8, 9], [10, 12], [12, 15], [14, 17], [16, 19], [18, 21], [20, 23]],k = 10) == 46\n assert candidate(points = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],k = 15) == 29\n assert candidate(points = [[1, 100000000], [-50000000, -100000000], [100000000, -100000000], [-100000000, 100000000]],k = 200000000) == 99999999\n assert candidate(points = [[1, 1], [3, 5], [6, 2], [8, 8], [10, 4], [15, 7], [20, 1]],k = 5) == 18\n assert candidate(points = [[1, 100000000], [100000000, 1], [100000001, 2], [200000000, 3], [300000000, 4], [400000000, 5], [500000000, 6], [600000000, 7], [700000000, 8], [800000000, 9], [900000000, 10]],k = 100000000) == 200000002\n assert candidate(points = [[-1000000, -1000000], [-900000, -900000], [-800000, -800000], [-700000, -700000], [-600000, -600000]],k = 100000) == -1200000\n assert candidate(points = [[-5, 5], [0, 0], [1, 3], [3, -1], [5, 10], [6, -10], [8, 2], [10, 3], [15, 0]],k = 5) == 18\n assert candidate(points = [[1, -1], [2, -2], [3, -3], [4, -4], [5, -5], [6, -6], [7, -7], [8, -8], [9, -9]],k = 2) == -2\n assert candidate(points = [[1, 1], [10, 10], [100, 100], [1000, 1000], [10000, 10000], [100000, 100000], [1000000, 1000000], [10000000, 10000000], [100000000, 100000000]],k = 50000000) == 20000000\n assert candidate(points = [[100000, -100000], [100001, -99999], [100002, -99998], [100003, -99997], [100004, -99996]],k = 4) == -199992\n assert candidate(points = [[-10, -10], [-9, -9], [-8, -8], [-7, -7], [-6, -6], [-5, -5], [-4, -4], [-3, -3], [-2, -2], [-1, -1]],k = 2) == -2\n assert candidate(points = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]],k = 3) == 200\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],k = 3) == 20\n assert candidate(points = [[1, 5], [3, 7], [6, 8], [8, 6], [10, 9], [15, 1]],k = 5) == 21\n assert candidate(points = [[-50, -50], [-25, -100], [0, 0], [25, 100], [50, 50]],k = 75) == 175\n assert candidate(points = [[1, 1000], [2, 900], [3, 800], [4, 700], [5, 600], [6, 500], [7, 400], [8, 300], [9, 200], [10, 100]],k = 3) == 1901\n assert candidate(points = [[1, 2], [2, 4], [3, 8], [4, 16], [5, 32]],k = 4) == 49\n assert candidate(points = [[1, 10], [2, 15], [5, 20], [8, 25], [10, 30], [15, 35], [20, 40], [25, 45], [30, 50], [35, 55]],k = 15) == 110\n assert candidate(points = [[-5, -5], [-3, -1], [0, 0], [2, 4], [3, 6], [8, 8]],k = 5) == 19\n assert candidate(points = [[1, 1], [10, 2], [20, 3], [30, 4], [40, 5], [50, 6], [60, 7], [70, 8], [80, 9], [90, 10]],k = 15) == 29\n assert candidate(points = [[-100000000, 100000000], [-90000000, 90000000], [0, -50000000], [100000000, 50000000]],k = 110000000) == 200000000\n assert candidate(points = [[1, -1], [3, -2], [5, -3], [7, -4], [9, -5], [11, -6], [13, -7], [15, -8], [17, -9], [19, -10]],k = 18) == 7\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],k = 1) == 20\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],k = 10) == 20\n assert candidate(points = [[2, 3], [5, 6], [8, 9], [11, 12], [14, 15]],k = 3) == 30\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],k = 1) == -inf\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],k = 1) == 18\n assert candidate(points = [[1, -100000000], [2, 100000000], [3, -100000000], [4, 100000000], [5, -100000000], [6, 100000000], [7, -100000000]],k = 2) == 200000002\n assert candidate(points = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9]],k = 1) == 20\n assert candidate(points = [[1, 100000000], [2, 99999999], [3, 99999998], [4, 99999997], [5, 99999996], [6, 99999995], [7, 99999994], [8, 99999993], [9, 99999992], [10, 99999991]],k = 1) == 200000000\n assert candidate(points = [[1, 10], [2, 3], [3, 5], [4, 7], [5, 2], [6, 8]],k = 4) == 20\n assert candidate(points = [[10, 50], [20, 30], [30, 20], [40, 10], [50, 0], [60, -10], [70, -20], [80, -30], [90, -40]],k = 25) == 90\n assert candidate(points = [[1, 100000000], [2, 90000000], [3, 80000000], [4, 70000000], [5, 60000000]],k = 3) == 190000001\n assert candidate(points = [[5, 5], [15, 10], [25, 3], [35, 15], [45, 10], [55, 20], [65, 5], [75, 25]],k = 20) == 65\n assert candidate(points = [[1, 1], [10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90]],k = 30) == 180\n assert candidate(points = [[1, 1], [2, 10], [3, 3], [4, 15], [5, 5], [6, 20], [7, 7], [8, 25], [9, 9], [10, 30]],k = 10) == 57\n assert candidate(points = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15], [17, 17], [19, 19], [21, 21], [23, 23], [25, 25], [27, 27], [29, 29], [31, 31], [33, 33], [35, 35], [37, 37], [39, 39]],k = 2) == 78\n assert candidate(points = [[-100000000, 100000000], [0, 0], [100000000, -100000000]],k = 200000000) == 200000000\n assert candidate(points = [[-100, 100], [-90, 90], [-80, 80], [-70, 70], [-60, 60], [-50, 50], [-40, 40], [-30, 30], [-20, 20], [-10, 10]],k = 20) == 200\n assert candidate(points = [[-5, -5], [-2, 3], [-1, 2], [0, 0], [1, 5], [2, 1], [4, -2], [6, 3]],k = 4) == 11\n assert candidate(points = [[-10, 0], [-9, 1], [-8, 2], [-7, 3], [-6, 4], [-5, 5], [-4, 6], [-3, 7], [-2, 8], [-1, 9]],k = 3) == 18\n assert candidate(points = [[10, 20], [15, 10], [20, 20], [25, 30], [30, 5], [35, 25], [40, 30]],k = 10) == 65\n assert candidate(points = [[1, 5], [3, 4], [6, 7], [8, 2], [10, 10]],k = 4) == 21\n assert candidate(points = [[-5, 10], [0, -1], [4, 3], [7, -2], [12, 5]],k = 5) == 14\n assert candidate(points = [[-100, 100], [-90, -80], [-80, 80], [-70, -70], [-60, 60], [-50, -50]],k = 20) == 200\n assert candidate(points = [[1, 10], [2, 5], [3, -5], [4, -10], [5, -15], [6, -20], [7, -25], [8, -30]],k = 3) == 16\n assert candidate(points = [[1, 3], [2, 1], [3, 2], [4, 4], [5, 1], [6, 3], [7, 2], [8, 5], [9, 4]],k = 4) == 13\n assert candidate(points = [[-5, -5], [-3, -2], [-1, 0], [2, 3], [5, 5], [8, 8], [11, 11]],k = 7) == 22\n assert candidate(points = [[1, 1], [3, 2], [5, 3], [7, 4], [9, 5], [11, 6], [13, 7], [15, 8], [17, 9]],k = 8) == 22\n assert candidate(points = [[1, 2], [3, 5], [5, 7], [7, 10], [9, 15], [11, 20], [13, 25], [15, 30], [17, 35], [19, 40]],k = 10) == 77\n assert candidate(points = [[-50, 10], [-30, 20], [-10, 30], [10, 40], [30, 50], [50, 60], [70, 70], [90, 80], [110, 90]],k = 30) == 190\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],k = 3) == 20\n assert candidate(points = [[-100000000, 100000000], [0, -100000000], [100000000, 100000000]],k = 200000000) == 400000000\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],k = 2) == 40\n assert candidate(points = [[-100000000, 100000000], [-99999999, 99999999], [-99999998, 99999998], [-99999997, 99999997], [-99999996, 99999996], [-99999995, 99999995]],k = 4) == 200000000\n assert candidate(points = [[-100000, 100000], [-90000, 50000], [-80000, 0], [-70000, -50000], [-60000, -100000], [-50000, 100000], [-40000, 50000], [-30000, 0], [-20000, -50000], [-10000, -100000], [0, 100000], [10000, 50000], [20000, 0], [30000, -50000], [40000, -100000], [50000, 100000], [60000, 50000], [70000, 0], [80000, -50000], [90000, -100000], [100000, 100000]],k = 20000) == 160000\n assert candidate(points = [[1, 100], [2, 50], [3, 75], [4, 25], [5, 150]],k = 4) == 254\n"}, "metadata": {"canonical_parameter_names": ["points", "k"], "leetcode_dataset_entry_point": "Solution().findMaxValueOfEquation", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int findMaxValueOfEquation(vector>& points, int k) {", "container": "Solution", "callable": "findMaxValueOfEquation", "parameters": [{"name": "points", "type": "vector>&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1502, "task_id": "can-make-arithmetic-progression-from-sequence", "difficulty": "Easy", "problem_description": "A sequence of numbers is called an arithmetic progression if the difference between any two consecutive elements is the same.\nGiven an array of numbers arr, return true if the array can be rearranged to form an arithmetic progression. Otherwise, return false.\n \nExample 1:\n\nInput: arr = [3,5,1]\nOutput: true\nExplanation: We can reorder the elements as [1,3,5] or [5,3,1] with differences 2 and -2 respectively, between each consecutive elements.\n\nExample 2:\n\nInput: arr = [1,2,4]\nOutput: false\nExplanation: There is no way to reorder the elements to obtain an arithmetic progression.\n\n \nConstraints:\n\n2 <= arr.length <= 1000\n-106 <= arr[i] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 4, 6, 8, 10]) == True\n assert candidate(arr = [-1, 1, 0]) == True\n assert candidate(arr = [5, 3, 1, 4, 2]) == True\n assert candidate(arr = [10, 20, 30, 40, 50]) == True\n assert candidate(arr = [10, 5, 15]) == True\n assert candidate(arr = [5, 3, 1, 2, 4]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11]) == True\n assert candidate(arr = [5, 3, 1, 4]) == False\n assert candidate(arr = [1, 2, 3, 5]) == False\n assert candidate(arr = [100, -100, 0]) == True\n assert candidate(arr = [-5, -3, -1, 1, 3, 5]) == True\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(arr = [5, 3, 1]) == True\n assert candidate(arr = [1, 2, 3, 4, 5]) == True\n assert candidate(arr = [0, 0, 0, 0]) == True\n assert candidate(arr = [10, 5, 0, -5, -10]) == True\n assert candidate(arr = [1, 1, 1, 1]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == True\n assert candidate(arr = [1, 2, 4]) == False\n assert candidate(arr = [-1, 1, 3]) == True\n assert candidate(arr = [100, 50, 0, -50, -100]) == True\n assert candidate(arr = [3, 5, 1]) == True\n assert candidate(arr = [0, 0, 0]) == True\n assert candidate(arr = [-1, 0, 1, 2]) == True\n assert candidate(arr = [1, 2, 2, 3, 3, 4]) == False\n assert candidate(arr = [10, 10, 10, 10]) == True\n assert candidate(arr = [1000000, -1000000, 0]) == True\n assert candidate(arr = [10, 0, 20, 10]) == False\n assert candidate(arr = [-5, 0, 5, 10, 15, 20, 25]) == True\n assert candidate(arr = [5, 8, 11, 14, 17, 20]) == True\n assert candidate(arr = [100, 200, 300, 400, 500]) == True\n assert candidate(arr = [-3, -6, -9, -12, -15]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == True\n assert candidate(arr = [5, 5, 5, 5, 5]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16]) == True\n assert candidate(arr = [1, 2, 2, 3, 4]) == False\n assert candidate(arr = [1, 6, 3, 11, 9, 5]) == False\n assert candidate(arr = [-1000000, -999998, -999996, -999994]) == True\n assert candidate(arr = [1000000, -1000000, 500000, -500000, 0]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == False\n assert candidate(arr = [1000000, 999998, 999996, 999994]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27]) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]) == False\n assert candidate(arr = [1000000, 2000000, 3000000, 4000000, 5000000]) == True\n assert candidate(arr = [1000000, 999998, 1000002, 999996, 1000004, 999994, 1000006, 999992, 1000008, 999990]) == True\n assert candidate(arr = [1, 2, 3, 4, 6, 8, 10]) == False\n assert candidate(arr = [12, 15, 18, 21, 24, 27, 30, 33, 36, 39]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == True\n assert candidate(arr = [-2, -4, -6, -8, -10, -12, -14, -16]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 100]) == False\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == True\n assert candidate(arr = [38, 34, 30, 26, 22, 18, 14, 10, 6, 2]) == True\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(arr = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == True\n assert candidate(arr = [-5, 0, 5, 10, 15]) == True\n assert candidate(arr = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]) == False\n assert candidate(arr = [1000000, 1000000, 1000000, 1000000, 1000000]) == True\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56]) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(arr = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == True\n assert candidate(arr = [1000, 1001, 1002, 1003, 1004, 1005]) == True\n assert candidate(arr = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(arr = [1, 2, 2, 3, 4, 5]) == False\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == True\n assert candidate(arr = [100, 50, 0, -50, -100]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60]) == True\n assert candidate(arr = [-1000000, -1000001, -1000002, -1000003, -1000004]) == True\n assert candidate(arr = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 0, -1, -3, -7, -15, -31, -62, -125, -250, -500, -1000]) == False\n assert candidate(arr = [1000000, 500000, 0, -500000, -1000000]) == True\n assert candidate(arr = [100, 50, 25, 0, -25, -50, -100]) == False\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == True\n assert candidate(arr = [-1000000, -999999, -999998, -999997, -999996]) == True\n assert candidate(arr = [9, 3, 15, 6, 12, 0, 18, 21, 24, 27]) == True\n assert candidate(arr = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == True\n assert candidate(arr = [1, 3, 6, 10, 15]) == False\n assert candidate(arr = [-3, -1, 1, 3, 5, 7, 9, 11, 13]) == True\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == True\n assert candidate(arr = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700]) == True\n assert candidate(arr = [1, 6, 11, 16, 21, 26]) == True\n assert candidate(arr = [7, 3, 11, 5, 9, 1]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == True\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == False\n assert candidate(arr = [7, 14, 21, 28, 35]) == True\n assert candidate(arr = [10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48]) == True\n assert candidate(arr = [1, 2, 3, 4, 6, 7, 8, 9, 10]) == False\n assert candidate(arr = [7, 7, 7, 7, 7]) == True\n assert candidate(arr = [-1000, 1000, 0, 500, -500, 250, -250, 750, -750]) == True\n assert candidate(arr = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == True\n assert candidate(arr = [7, 7, 7, 7, 7, 7]) == True\n assert candidate(arr = [23, 19, 15, 11, 7, 3, -1, -5]) == True\n assert candidate(arr = [10, 20, 30, 40, 50]) == True\n assert candidate(arr = [10, 5, 0, -5, -10, -15, -20, -25, -30]) == True\n assert candidate(arr = [-10, -20, -30, -40, -50]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n assert candidate(arr = [10, 20, 40, 50, 60]) == False\n assert candidate(arr = [42, 42]) == True\n assert candidate(arr = [-1000000, 1000000, 0, 500000, -500000]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 600]) == True\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 101]) == False\n assert candidate(arr = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]) == True\n assert candidate(arr = [-5, -10, -15, -20, -25, -30]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(arr = [-1000000, -1000001, -1000002, -1000003]) == True\n assert candidate(arr = [3, -1, 1, 5, -3, 7]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 11]) == False\n assert candidate(arr = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38]) == True\n assert candidate(arr = [0, 1, 3, 6, 10, 15, 21]) == False\n assert candidate(arr = [100, 99, 97, 94, 90, 85, 79, 72, 64, 55, 45]) == False\n assert candidate(arr = [5, 1, 7, 3, 9]) == True\n assert candidate(arr = [-5, -10, -15, -20, -25]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == True\n assert candidate(arr = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == True\n assert candidate(arr = [1000000, 999999, 999998, 999997]) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == True\n assert candidate(arr = [1000000, -1000000, 500000, 0, 1500000, -500000]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24]) == True\n assert candidate(arr = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == True\n assert candidate(arr = [1, 2, 3, 6, 5, 4]) == True\n assert candidate(arr = [100, 200, 150, 50, 250, 0]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33]) == True\n assert candidate(arr = [-3, -2, -1, 0, 1, 2, 3]) == True\n assert candidate(arr = [1, 2, 2, 3, 4, 5, 6]) == False\n assert candidate(arr = [50, 60, 70, 80, 90, 100, 110, 120]) == True\n assert candidate(arr = [2, 4, 8, 16, 32]) == False\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64]) == False\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15]) == True\n assert candidate(arr = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == True\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37]) == True\n assert candidate(arr = [5, 9, 13, 17, 21, 25]) == True\n assert candidate(arr = [12, 18, 24, 30, 36, 42, 48]) == True\n assert candidate(arr = [1, 1, 2, 3, 5, 8, 13, 21]) == False\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == True\n assert candidate(arr = [100, 200, 150, 250, 300, 350, 400]) == True\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1]) == True\n assert candidate(arr = [10, 70, 30, 50, 90]) == True\n assert candidate(arr = [1, 100, 50, 75, 25]) == False\n assert candidate(arr = [500000, 499998, 499996, 499994, 499992]) == True\n assert candidate(arr = [1, 4, 7, 10, 13, 16, 19, 22, 25]) == True\n assert candidate(arr = [10, 5, 0, -5, -10]) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1]) == True\n assert candidate(arr = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40]) == True\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == True\n assert candidate(arr = [-1000, -500, 0, 500, 1000]) == True\n assert candidate(arr = [5, 3, 1, -1, -3, -5, -7, -9, -11, -13]) == True\n assert candidate(arr = [1000000, -1000000, 0, 500000, -500000]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == True\n assert candidate(arr = [10, 0, -10, -20, -30]) == True\n assert candidate(arr = [-5, 0, 5, 10, 15, 20]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30]) == True\n assert candidate(arr = [5, 10, 15, 20, 25]) == True\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == False\n assert candidate(arr = [3, 1, 5, 7, 9]) == True\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().canMakeArithmeticProgression", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool canMakeArithmeticProgression(vector& arr) {", "container": "Solution", "callable": "canMakeArithmeticProgression", "parameters": [{"name": "arr", "type": "vector&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1503, "task_id": "last-moment-before-all-ants-fall-out-of-a-plank", "difficulty": "Medium", "problem_description": "We have a wooden plank of the length n units. Some ants are walking on the plank, each ant moves with a speed of 1 unit per second. Some of the ants move to the left, the other move to the right.\nWhen two ants moving in two different directions meet at some point, they change their directions and continue moving again. Assume changing directions does not take any additional time.\nWhen an ant reaches one end of the plank at a time t, it falls out of the plank immediately.\nGiven an integer n and two integer arrays left and right, the positions of the ants moving to the left and the right, return the moment when the last ant(s) fall out of the plank.\n \nExample 1:\n\n\nInput: n = 4, left = [4,3], right = [0,1]\nOutput: 4\nExplanation: In the image above:\n-The ant at index 0 is named A and going to the right.\n-The ant at index 1 is named B and going to the right.\n-The ant at index 3 is named C and going to the left.\n-The ant at index 4 is named D and going to the left.\nThe last moment when an ant was on the plank is t = 4 seconds. After that, it falls immediately out of the plank. (i.e., We can say that at t = 4.0000000001, there are no ants on the plank).\n\nExample 2:\n\n\nInput: n = 7, left = [], right = [0,1,2,3,4,5,6,7]\nOutput: 7\nExplanation: All ants are going to the right, the ant at index 0 needs 7 seconds to fall.\n\nExample 3:\n\n\nInput: n = 7, left = [0,1,2,3,4,5,6,7], right = []\nOutput: 7\nExplanation: All ants are going to the left, the ant at index 7 needs 7 seconds to fall.\n\n \nConstraints:\n\n1 <= n <= 104\n0 <= left.length <= n + 1\n0 <= left[i] <= n\n0 <= right.length <= n + 1\n0 <= right[i] <= n\n1 <= left.length + right.length <= n + 1\nAll values of left and right are unique, and each value can appear only in one of the two arrays.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 15,left = [10, 11, 12],right = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 15\n assert candidate(n = 1,left = [],right = [0]) == 1\n assert candidate(n = 5,left = [5],right = [0]) == 5\n assert candidate(n = 1,left = [1],right = []) == 1\n assert candidate(n = 5,left = [1, 2],right = [3, 4]) == 2\n assert candidate(n = 1,left = [0],right = [1]) == 0\n assert candidate(n = 7,left = [0, 1, 2, 3, 4, 5, 6, 7],right = []) == 7\n assert candidate(n = 4,left = [4, 3],right = [0, 1]) == 4\n assert candidate(n = 10,left = [2, 6, 7],right = [1, 3, 5, 8]) == 9\n assert candidate(n = 100,left = [10, 20, 30, 40, 50],right = [60, 70, 80, 90, 100]) == 50\n assert candidate(n = 10,left = [2, 6],right = [3, 7]) == 7\n assert candidate(n = 7,left = [],right = [0, 1, 2, 3, 4, 5, 6]) == 7\n assert candidate(n = 100,left = [],right = [0, 100]) == 100\n assert candidate(n = 1000,left = [500, 501, 502],right = [497, 498, 499]) == 503\n assert candidate(n = 100,left = [50],right = [50]) == 50\n assert candidate(n = 1,left = [0],right = []) == 0\n assert candidate(n = 7,left = [],right = [0, 1, 2, 3, 4, 5, 6, 7]) == 7\n assert candidate(n = 7,left = [0, 1, 2, 3, 4, 5, 6],right = []) == 6\n assert candidate(n = 100,left = [0, 100],right = []) == 100\n assert candidate(n = 10,left = [5],right = [5]) == 5\n assert candidate(n = 10000,left = [1, 2, 3],right = [9997, 9998, 9999]) == 3\n assert candidate(n = 10,left = [1, 2, 3],right = [5, 6, 7]) == 5\n assert candidate(n = 200,left = [100, 150],right = [50, 100]) == 150\n assert candidate(n = 7000,left = [0, 7000],right = [3500]) == 7000\n assert candidate(n = 10000,left = [],right = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000]) == 9000\n assert candidate(n = 1000,left = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],right = [990, 991, 992, 993, 994, 995, 996, 997, 998, 999]) == 10\n assert candidate(n = 3000,left = [100, 200, 300, 400, 500, 600],right = [2400, 2500, 2600, 2700, 2800, 2900]) == 600\n assert candidate(n = 8000,left = [100, 200, 300, 400, 500],right = [7900, 7800, 7700, 7600, 7500]) == 500\n assert candidate(n = 3000,left = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],right = [2999, 2998, 2997, 2996, 2995, 2994, 2993, 2992, 2991, 2990]) == 10\n assert candidate(n = 10000,left = [1000, 3000, 5000],right = [2000, 4000, 6000, 8000, 9000]) == 8000\n assert candidate(n = 5000,left = [1234, 2345, 3456, 4567],right = [1000, 2000, 3000, 4000]) == 4567\n assert candidate(n = 10000,left = [1000, 2000, 3000, 4000],right = [6000, 7000, 8000, 9000]) == 4000\n assert candidate(n = 10000,left = [9990, 9991, 9992, 9993, 9994, 9995, 9996, 9997, 9998, 9999],right = []) == 9999\n assert candidate(n = 6000,left = [1500, 2000, 2500, 3000],right = [3500, 4000, 4500, 5000, 5500]) == 3000\n assert candidate(n = 8000,left = [1, 100, 200, 300, 400, 500, 600, 700],right = [7999, 7899, 7799, 7699, 7599, 7499, 7399, 7299]) == 701\n assert candidate(n = 6000,left = [1000, 2000, 3000, 4000, 5000],right = [1500, 2500, 3500, 4500, 5500]) == 5000\n assert candidate(n = 3000,left = [300, 600, 900, 1200, 1500],right = [2700, 2400, 2100, 1800, 1500]) == 1500\n assert candidate(n = 9000,left = [9000],right = [0]) == 9000\n assert candidate(n = 10000,left = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],right = [9990, 9991, 9992, 9993, 9994, 9995, 9996, 9997, 9998, 9999]) == 10\n assert candidate(n = 4000,left = [0, 800, 1600, 2400, 3200],right = [0, 800, 1600, 2400, 3200]) == 4000\n assert candidate(n = 8000,left = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],right = [7900, 7910, 7920, 7930, 7940, 7950, 7960, 7970, 7980, 7990]) == 100\n assert candidate(n = 10000,left = [5000, 6000, 7000, 8000, 9000],right = [1000, 2000, 3000, 4000]) == 9000\n assert candidate(n = 9999,left = [9998, 9997, 9996],right = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9998\n assert candidate(n = 7000,left = [1000, 2000, 3000, 4000, 5000, 6000],right = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 6999\n assert candidate(n = 2000,left = [1000, 1500, 1600, 1700],right = [400, 500, 600, 700]) == 1700\n assert candidate(n = 6000,left = [3000],right = [3000]) == 3000\n assert candidate(n = 6000,left = [0, 1000, 2000, 3000, 4000, 5000],right = [1500, 2500, 3500, 4500, 5500]) == 5000\n assert candidate(n = 15000,left = [],right = [0, 3000, 6000, 9000, 12000, 15000]) == 15000\n assert candidate(n = 9000,left = [1000, 3000, 5000, 7000],right = [2000, 4000, 6000, 8000]) == 7000\n assert candidate(n = 6000,left = [50, 150, 250, 350, 450, 550],right = [5450, 5550, 5650, 5750, 5850, 5950]) == 550\n assert candidate(n = 8000,left = [1000, 2000, 3000, 4000, 5000],right = [3000, 4000, 5000, 6000, 7000]) == 5000\n assert candidate(n = 9000,left = [100, 200, 300, 400, 500, 600, 700, 800],right = [8200, 8300, 8400, 8500, 8600, 8700, 8800, 8900]) == 800\n assert candidate(n = 2000,left = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900],right = [900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 1400, 1500, 1600, 1700, 1800, 1900, 1000, 100]) == 1900\n assert candidate(n = 10000,left = [1, 10, 100, 1000, 10000],right = [2, 20, 200, 2000, 9999]) == 10000\n assert candidate(n = 2000,left = [500, 1500],right = [100, 1900, 1600]) == 1900\n assert candidate(n = 10000,left = [1, 2, 3, 5000, 9999],right = [4, 6, 5002, 9997]) == 9999\n assert candidate(n = 8000,left = [0, 1000, 2000, 3000, 4000, 5000, 6000, 7000],right = [8000]) == 7000\n assert candidate(n = 4000,left = [2000],right = [2000]) == 2000\n assert candidate(n = 10000,left = [],right = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9999\n assert candidate(n = 12000,left = [0, 2400, 4800, 7200, 9600, 12000],right = []) == 12000\n assert candidate(n = 7500,left = [100, 200, 300, 400, 500, 600, 700],right = [7400, 7300, 7200, 7100, 7000, 6900, 6800]) == 700\n assert candidate(n = 9000,left = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500],right = [8500, 8000, 7500, 7000, 6500, 6000, 5500, 5000, 4500]) == 4500\n assert candidate(n = 7000,left = [100, 200, 300, 400],right = [6600, 6700, 6800, 6900]) == 400\n assert candidate(n = 5000,left = [2500, 2501, 2502, 2503],right = [2499, 2498, 2497, 2496]) == 2504\n assert candidate(n = 500,left = [10, 20, 30, 40, 50],right = [450, 460, 470, 480, 490]) == 50\n assert candidate(n = 8000,left = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],right = [7990, 7991, 7992, 7993, 7994, 7995, 7996, 7997, 7998, 7999]) == 10\n assert candidate(n = 9000,left = [100, 200, 300, 400, 500, 600, 700, 800, 900],right = [8100, 8200, 8300, 8400, 8500, 8600, 8700, 8800, 8900]) == 900\n assert candidate(n = 5000,left = [1000, 2000, 3000, 4000, 5000],right = [1, 2, 3, 4]) == 5000\n assert candidate(n = 2000,left = [500, 1000, 1500],right = [100, 600, 1100, 1600]) == 1900\n assert candidate(n = 1500,left = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],right = [1400, 1390, 1380, 1370, 1360, 1350, 1340, 1330, 1320, 1310]) == 190\n assert candidate(n = 5000,left = [10, 20, 30, 40, 50],right = [4950, 4960, 4970, 4980, 4990]) == 50\n assert candidate(n = 12000,left = [6000, 6100, 6200, 6300],right = [5700, 5800, 5900, 6000]) == 6300\n assert candidate(n = 5000,left = [1, 2, 3, 4, 5],right = [4995, 4996, 4997, 4998, 4999]) == 5\n assert candidate(n = 10000,left = [2000, 4000, 6000, 8000],right = [1000, 3000, 5000, 7000, 9000]) == 9000\n assert candidate(n = 10000,left = [1, 100, 1000, 10000],right = [2, 200, 2000, 9999]) == 10000\n assert candidate(n = 1000,left = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],right = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 990\n assert candidate(n = 2000,left = [500, 1000, 1500, 2000],right = [10, 20, 30, 40, 50]) == 2000\n assert candidate(n = 4500,left = [500, 1500, 2500, 3500],right = [1000, 2000, 3000, 4000]) == 3500\n assert candidate(n = 10000,left = [0, 2500, 5000, 7500, 10000],right = [10000, 7500, 5000, 2500, 0]) == 10000\n assert candidate(n = 9500,left = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500],right = [1, 2, 3, 4, 5]) == 9500\n assert candidate(n = 10000,left = [1, 3, 5, 7, 9],right = [2, 4, 6, 8, 10]) == 9998\n assert candidate(n = 6000,left = [1000, 2000, 3000, 4000, 5000],right = [500, 1500, 2500, 3500, 4500]) == 5500\n assert candidate(n = 7500,left = [1000, 2000, 3000],right = [5000, 6000, 7000, 7499]) == 3000\n assert candidate(n = 7500,left = [3000, 4000, 5000],right = [2000, 3000, 4000]) == 5500\n assert candidate(n = 12000,left = [12000],right = [6000]) == 12000\n assert candidate(n = 10000,left = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000],right = []) == 9000\n assert candidate(n = 10000,left = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500],right = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500]) == 9500\n assert candidate(n = 6000,left = [1000, 2000, 3000, 4000, 5000],right = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 5900\n assert candidate(n = 10000,left = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],right = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 9998\n assert candidate(n = 1000,left = [500, 600, 700, 800, 900],right = [100, 200, 300, 400]) == 900\n assert candidate(n = 7000,left = [0, 7000],right = [0, 7000]) == 7000\n assert candidate(n = 8000,left = [1, 2, 3, 4, 5, 6, 7, 8],right = [7992, 7993, 7994, 7995, 7996, 7997, 7998, 7999]) == 8\n assert candidate(n = 10000,left = [5000],right = [5000]) == 5000\n assert candidate(n = 1000,left = [999],right = [0]) == 1000\n assert candidate(n = 1000,left = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509],right = [499, 498, 497, 496, 495, 494, 493, 492, 491, 490]) == 510\n assert candidate(n = 5000,left = [100, 200, 300, 400, 500],right = [4500, 4600, 4700, 4800, 4900]) == 500\n assert candidate(n = 5000,left = [0, 1250, 2500, 3750, 5000],right = [1249, 2499, 3749, 4998]) == 5000\n assert candidate(n = 4000,left = [100, 200, 300, 400],right = [3600, 3700, 3800, 3900]) == 400\n assert candidate(n = 12000,left = [2000, 4000, 6000, 8000, 10000],right = [1000, 3000, 5000, 7000, 9000, 11000]) == 11000\n assert candidate(n = 9000,left = [1000, 2000, 3000, 4000, 5000],right = [6000, 7000, 8000, 9000]) == 5000\n assert candidate(n = 9999,left = [1, 2, 3, 4, 5, 6, 7, 8, 9],right = [9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990]) == 9\n assert candidate(n = 9000,left = [100, 200, 300, 400, 500, 600, 700, 800, 900],right = [8900, 8800, 8700, 8600, 8500, 8400, 8300, 8200, 8100]) == 900\n assert candidate(n = 7000,left = [100, 1000, 2000, 3000, 4000],right = [300, 1300, 2300, 3300, 4300]) == 6700\n assert candidate(n = 5000,left = [2500, 2501, 2502, 2503, 2504],right = [2495, 2496, 2497, 2498, 2499]) == 2505\n assert candidate(n = 1000,left = [100, 200, 300, 400, 500, 600, 700, 800, 900],right = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == 950\n assert candidate(n = 9999,left = [500, 1500, 2500, 3500, 4500],right = [5500, 6500, 7500, 8500, 9500]) == 4500\n assert candidate(n = 1000,left = [100, 200, 300, 400, 500],right = [600, 700, 800, 900]) == 500\n assert candidate(n = 10000,left = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],right = [9991, 9992, 9993, 9994, 9995, 9996, 9997, 9998, 9999, 10000]) == 10\n assert candidate(n = 10000,left = [1, 2, 3, 4, 5],right = [9996, 9995, 9994, 9993, 9992]) == 8\n assert candidate(n = 8500,left = [8500],right = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 7500]) == 8500\n assert candidate(n = 6000,left = [0, 6000],right = [3000]) == 6000\n assert candidate(n = 5000,left = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],right = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 4998\n assert candidate(n = 5000,left = [4999, 4998, 4997, 4996],right = [1, 2, 3, 4]) == 4999\n assert candidate(n = 5000,left = [1000, 2000, 3000, 4000],right = [500, 1500, 2500, 3500, 4500]) == 4500\n assert candidate(n = 10000,left = [1000, 2000, 3000, 4000],right = [7000, 8000, 9000]) == 4000\n assert candidate(n = 12000,left = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],right = [11900, 11800, 11700, 11600, 11500, 11400, 11300, 11200, 11100, 11000]) == 1000\n assert candidate(n = 500,left = [0, 250, 500],right = [0, 250, 500]) == 500\n assert candidate(n = 9999,left = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],right = [9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989]) == 10\n assert candidate(n = 10000,left = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990],right = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 9999\n assert candidate(n = 500,left = [0, 100, 200, 300, 400],right = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 490\n assert candidate(n = 7000,left = [500, 1000, 1500, 2000, 2500],right = [6500, 7000, 6000, 6500, 7000]) == 2500\n assert candidate(n = 5000,left = [100, 200, 300, 400],right = [4600, 4700, 4800, 4900]) == 400\n assert candidate(n = 10000,left = [1, 100, 1000, 10000],right = [50, 500, 5000, 9950]) == 10000\n assert candidate(n = 8000,left = [1, 2, 3, 4, 5],right = [7995, 7996, 7997, 7998, 7999]) == 5\n assert candidate(n = 2000,left = [100, 200, 300, 400, 500],right = [1500, 1600, 1700, 1800, 1900]) == 500\n assert candidate(n = 3000,left = [500, 1000, 1500, 2000, 2500],right = [100, 600, 1100, 1600, 2100]) == 2900\n"}, "metadata": {"canonical_parameter_names": ["n", "left", "right"], "leetcode_dataset_entry_point": "Solution().getLastMoment", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int getLastMoment(int n, vector& left, vector& right) {", "container": "Solution", "callable": "getLastMoment", "parameters": [{"name": "n", "type": "int"}, {"name": "left", "type": "vector&"}, {"name": "right", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1504, "task_id": "count-submatrices-with-all-ones", "difficulty": "Medium", "problem_description": "Given an m x n binary matrix mat, return the number of submatrices that have all ones.\n \nExample 1:\n\n\nInput: mat = [[1,0,1],[1,1,0],[1,1,0]]\nOutput: 13\nExplanation: \nThere are 6 rectangles of side 1x1.\nThere are 2 rectangles of side 1x2.\nThere are 3 rectangles of side 2x1.\nThere is 1 rectangle of side 2x2. \nThere is 1 rectangle of side 3x1.\nTotal number of rectangles = 6 + 2 + 3 + 1 + 1 = 13.\n\nExample 2:\n\n\nInput: mat = [[0,1,1,0],[0,1,1,1],[1,1,1,0]]\nOutput: 24\nExplanation: \nThere are 8 rectangles of side 1x1.\nThere are 5 rectangles of side 1x2.\nThere are 2 rectangles of side 1x3. \nThere are 4 rectangles of side 2x1.\nThere are 2 rectangles of side 2x2. \nThere are 2 rectangles of side 3x1. \nThere is 1 rectangle of side 3x2. \nTotal number of rectangles = 8 + 5 + 2 + 4 + 2 + 2 + 1 = 24.\n\n \nConstraints:\n\n1 <= m, n <= 150\nmat[i][j] is either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[0, 0], [0, 0]]) == 0\n assert candidate(mat = [[1, 0, 1], [1, 1, 0], [1, 1, 0]]) == 13\n assert candidate(mat = [[1, 0], [0, 1]]) == 2\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 60\n assert candidate(mat = [[0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(mat = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(mat = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 36\n assert candidate(mat = [[0, 1, 1, 0], [0, 1, 1, 1], [1, 1, 1, 0]]) == 24\n assert candidate(mat = [[1, 1], [1, 1]]) == 9\n assert candidate(mat = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(mat = [[1, 1, 0, 1], [0, 1, 1, 0], [1, 0, 1, 1], [1, 1, 1, 1]]) == 28\n assert candidate(mat = [[0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 0, 0, 0, 1]]) == 89\n assert candidate(mat = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]]) == 36\n assert candidate(mat = [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 15\n assert candidate(mat = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 1, 0, 1, 1], [0, 1, 1, 1, 0], [1, 0, 1, 0, 1]]) == 32\n assert candidate(mat = [[0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [1, 1, 1, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0]]) == 29\n assert candidate(mat = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 126\n assert candidate(mat = [[0, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 0]]) == 69\n assert candidate(mat = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 18\n assert candidate(mat = [[1, 1, 1, 0, 0, 0], [1, 1, 0, 1, 1, 0], [1, 0, 0, 0, 0, 1], [1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1], [0, 0, 1, 1, 1, 0]]) == 43\n assert candidate(mat = [[1, 0, 1, 1], [1, 1, 1, 1], [0, 1, 1, 0], [1, 0, 1, 0], [0, 1, 1, 1]]) == 40\n assert candidate(mat = [[1, 1, 1, 0, 1], [1, 1, 0, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0]]) == 59\n assert candidate(mat = [[1, 1, 0, 1], [1, 1, 1, 0], [0, 1, 1, 1], [1, 0, 1, 1]]) == 31\n assert candidate(mat = [[1, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1]]) == 85\n assert candidate(mat = [[1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1]]) == 50\n assert candidate(mat = [[1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0]]) == 18\n assert candidate(mat = [[1, 1, 0, 1, 1], [1, 0, 1, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 0, 1], [1, 0, 1, 1, 1]]) == 50\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 420\n assert candidate(mat = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 1, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 28\n assert candidate(mat = [[1, 0, 0, 0, 1], [0, 1, 1, 1, 0], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [1, 0, 0, 0, 1]]) == 25\n assert candidate(mat = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 1, 1], [1, 0, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 1]]) == 105\n assert candidate(mat = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 13\n assert candidate(mat = [[1, 1, 1, 1, 0, 1], [0, 1, 1, 1, 1, 1], [1, 1, 0, 1, 1, 1], [1, 1, 1, 1, 0, 1], [0, 1, 1, 1, 1, 1]]) == 105\n assert candidate(mat = [[1, 1, 0, 0], [1, 1, 1, 1], [0, 0, 1, 0], [1, 1, 1, 1]]) == 30\n assert candidate(mat = [[1, 1, 0, 1], [1, 1, 1, 1], [0, 1, 1, 1], [1, 0, 1, 0]]) == 36\n assert candidate(mat = [[1, 0, 1], [1, 1, 1], [0, 1, 1], [1, 1, 1], [1, 0, 1]]) == 37\n assert candidate(mat = [[1, 1, 0, 0, 1, 1], [0, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 0, 0]]) == 60\n assert candidate(mat = [[1, 1, 1, 0, 0], [1, 1, 1, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1], [1, 1, 1, 1, 1]]) == 48\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 128\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 270\n assert candidate(mat = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1], [1, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 141\n assert candidate(mat = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1]]) == 93\n assert candidate(mat = [[1, 1, 1, 1, 0], [1, 1, 1, 1, 0], [1, 1, 0, 0, 1], [0, 1, 0, 1, 1], [1, 1, 1, 1, 1]]) == 71\n assert candidate(mat = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 21\n assert candidate(mat = [[1, 1, 1, 1, 1], [0, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 0], [1, 1, 0, 0, 1]]) == 114\n assert candidate(mat = [[1, 1, 1, 0], [0, 1, 1, 1], [1, 1, 1, 1], [0, 1, 0, 1]]) == 41\n assert candidate(mat = [[1, 0, 1, 1], [1, 1, 1, 0], [1, 1, 0, 1], [0, 1, 1, 1]]) == 29\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 233\n assert candidate(mat = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 0, 1]]) == 44\n assert candidate(mat = [[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]]) == 9\n assert candidate(mat = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 1, 1, 1], [0, 1, 1, 0]]) == 34\n assert candidate(mat = [[1, 0, 1, 0, 1], [1, 1, 0, 1, 1], [0, 1, 1, 0, 1], [1, 0, 1, 0, 1], [1, 1, 0, 1, 1]]) == 36\n assert candidate(mat = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0]]) == 18\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 57\n assert candidate(mat = [[1, 1, 0, 0, 1, 1], [0, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1], [1, 1, 1, 1, 1, 0]]) == 76\n assert candidate(mat = [[1, 1, 0, 1, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [0, 1, 1, 1, 1]]) == 51\n assert candidate(mat = [[1, 1, 1], [0, 0, 0], [1, 1, 1], [0, 0, 0], [1, 1, 1], [0, 0, 0]]) == 18\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1]]) == 196\n assert candidate(mat = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 210\n assert candidate(mat = [[1, 1, 0, 1], [0, 1, 1, 0], [1, 0, 1, 1], [0, 1, 0, 1], [1, 1, 1, 0]]) == 23\n assert candidate(mat = [[1, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == 62\n assert candidate(mat = [[0, 0, 1, 0, 0], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0]]) == 54\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 540\n assert candidate(mat = [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 1, 1]]) == 25\n assert candidate(mat = [[0, 1, 1, 0, 0, 1, 1, 0, 0, 1], [1, 1, 1, 0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 0, 0, 1, 1, 0, 0, 1], [1, 1, 1, 0, 0, 1, 1, 1, 0, 0]]) == 74\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, 1], [1, 1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0], [1, 1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 112\n assert candidate(mat = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 315\n assert candidate(mat = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 10\n assert candidate(mat = [[1, 1, 1, 0, 1, 1], [1, 0, 1, 1, 1, 0], [1, 1, 0, 1, 1, 1], [0, 1, 1, 1, 1, 0]]) == 52\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 56\n assert candidate(mat = [[1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1]]) == 71\n assert candidate(mat = [[1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1]]) == 87\n assert candidate(mat = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == 89\n assert candidate(mat = [[1, 0, 1, 0, 1], [1, 1, 1, 0, 0], [0, 1, 1, 1, 1], [1, 1, 1, 1, 0]]) == 45\n assert candidate(mat = [[1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0], [0, 1, 1, 0, 1, 1, 0], [1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0]]) == 30\n assert candidate(mat = [[1, 1, 1, 0, 0, 1], [1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1], [1, 0, 0, 1, 1, 1]]) == 51\n assert candidate(mat = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 14\n assert candidate(mat = [[1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1]]) == 45\n assert candidate(mat = [[1, 1, 1, 0, 0], [1, 1, 1, 1, 0], [0, 1, 1, 1, 1], [0, 0, 1, 1, 1], [1, 1, 1, 0, 0]]) == 67\n assert candidate(mat = [[0, 1, 1, 0, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [0, 1, 1, 0, 1]]) == 68\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 110\n assert candidate(mat = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]) == 45\n assert candidate(mat = [[1, 1, 1, 1, 0], [1, 1, 1, 1, 1], [1, 1, 0, 1, 1], [1, 0, 1, 1, 1], [0, 1, 1, 1, 1]]) == 91\n assert candidate(mat = [[1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 0], [1, 0, 1, 1]]) == 28\n assert candidate(mat = [[1, 1, 0, 1], [1, 1, 1, 1], [0, 1, 1, 1], [1, 1, 1, 1]]) == 56\n assert candidate(mat = [[0, 1, 1, 0, 1], [1, 1, 1, 1, 1], [1, 0, 0, 1, 1], [0, 1, 1, 1, 0], [1, 1, 0, 1, 1]]) == 50\n assert candidate(mat = [[1, 0, 1, 1, 1], [1, 1, 1, 0, 1], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1]]) == 58\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 117\n assert candidate(mat = [[1, 1, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1, 1]]) == 56\n"}, "metadata": {"canonical_parameter_names": ["mat"], "leetcode_dataset_entry_point": "Solution().numSubmat", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numSubmat(vector>& mat) {", "container": "Solution", "callable": "numSubmat", "parameters": [{"name": "mat", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1505, "task_id": "minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits", "difficulty": "Hard", "problem_description": "You are given a string num representing the digits of a very large integer and an integer k. You are allowed to swap any two adjacent digits of the integer at most k times.\nReturn the minimum integer you can obtain also as a string.\n \nExample 1:\n\n\nInput: num = \"4321\", k = 4\nOutput: \"1342\"\nExplanation: The steps to obtain the minimum integer from 4321 with 4 adjacent swaps are shown.\n\nExample 2:\n\nInput: num = \"100\", k = 1\nOutput: \"010\"\nExplanation: It's ok for the output to have leading zeros, but the input is guaranteed not to have any leading zeros.\n\nExample 3:\n\nInput: num = \"36789\", k = 1000\nOutput: \"36789\"\nExplanation: We can keep the number without any swaps.\n\n \nConstraints:\n\n1 <= num.length <= 3 * 104\nnum consists of only digits and does not contain leading zeros.\n1 <= k <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = \"36789\",k = 1000) == \"36789\"\n assert candidate(num = \"100\",k = 1) == \"010\"\n assert candidate(num = \"9876543210\",k = 9) == \"0987654321\"\n assert candidate(num = \"9876543210\",k = 100) == \"0123456789\"\n assert candidate(num = \"222111333\",k = 10) == \"111222333\"\n assert candidate(num = \"4321\",k = 4) == \"1342\"\n assert candidate(num = \"3452345\",k = 3) == \"2345345\"\n assert candidate(num = \"111222333\",k = 5) == \"111222333\"\n assert candidate(num = \"9876543210\",k = 5) == \"4987653210\"\n assert candidate(num = \"123456789\",k = 0) == \"123456789\"\n assert candidate(num = \"102030405060708090\",k = 20) == \"000001023456708090\"\n assert candidate(num = \"29431\",k = 2) == \"23941\"\n assert candidate(num = \"59585756555453525150\",k = 100) == \"01234555555556987555\"\n assert candidate(num = \"9999999999\",k = 50) == \"9999999999\"\n assert candidate(num = \"9487653210\",k = 10) == \"0498765321\"\n assert candidate(num = \"1234567890\",k = 9) == \"0123456789\"\n assert candidate(num = \"5397268410\",k = 15) == \"0235796841\"\n assert candidate(num = \"111222333444555\",k = 25) == \"111222333444555\"\n assert candidate(num = \"98765432101234567890\",k = 50) == \"00112987654323456789\"\n assert candidate(num = \"5432109876\",k = 10) == \"0145329876\"\n assert candidate(num = \"1234321\",k = 5) == \"1123432\"\n assert candidate(num = \"9999999999888888888877777777776666666666\",k = 100) == \"6668999999999988888888877777777776666666\"\n assert candidate(num = \"0000000000000000000000001\",k = 1) == \"0000000000000000000000001\"\n assert candidate(num = \"198765432\",k = 20) == \"123479865\"\n assert candidate(num = \"54321098765432109876543210\",k = 50) == \"00012453987654321987654321\"\n assert candidate(num = \"98765432101234567890\",k = 100) == \"00112233445566778899\"\n assert candidate(num = \"5432109876\",k = 30) == \"0123456789\"\n assert candidate(num = \"5943281760\",k = 15) == \"0159432876\"\n assert candidate(num = \"19876543210\",k = 10) == \"01987654321\"\n assert candidate(num = \"77665544332211009988\",k = 100) == \"00112233447766559988\"\n assert candidate(num = \"543210987654321098765432109876543210\",k = 200) == \"000011112222345498765398765439876543\"\n assert candidate(num = \"5946132780\",k = 15) == \"0145963278\"\n assert candidate(num = \"987654321012345678909876543210\",k = 1000) == \"000111222333444555666777888999\"\n assert candidate(num = \"342134213421\",k = 15) == \"112234343421\"\n assert candidate(num = \"9876543210\",k = 30) == \"0123987654\"\n assert candidate(num = \"1234567890\",k = 10) == \"0123456789\"\n assert candidate(num = \"1234567890\",k = 15) == \"0123456789\"\n assert candidate(num = \"999999999999999999999999\",k = 1000000) == \"999999999999999999999999\"\n assert candidate(num = \"44444444444444444444\",k = 1000) == \"44444444444444444444\"\n assert candidate(num = \"87654321098765432109\",k = 200) == \"00112233445566778899\"\n assert candidate(num = \"999888777666555444333222111000\",k = 1000) == \"000111222333444555666777888999\"\n assert candidate(num = \"9876543210987654321098765432109876543210\",k = 200) == \"0000111122369875498765439876543298765432\"\n assert candidate(num = \"5555555555\",k = 100) == \"5555555555\"\n assert candidate(num = \"98765432109876543210\",k = 25) == \"01289765439876543210\"\n assert candidate(num = \"9876543210\",k = 45) == \"0123456789\"\n assert candidate(num = \"9876543210\",k = 0) == \"9876543210\"\n assert candidate(num = \"1234567890123456789012345678901234567890\",k = 500) == \"0000111122223333444455556666777788889999\"\n assert candidate(num = \"55555555555555555555555555555555\",k = 10000) == \"55555555555555555555555555555555\"\n assert candidate(num = \"12345678901234567890\",k = 100) == \"00112233445566778899\"\n assert candidate(num = \"1010101010101010101010101010101010101010\",k = 50) == \"0000000001111101111110101010101010101010\"\n assert candidate(num = \"9438527610\",k = 10) == \"0493852761\"\n assert candidate(num = \"987654321098765432109876543210\",k = 1000) == \"000111222333444555666777888999\"\n assert candidate(num = \"5432198760\",k = 20) == \"0123458976\"\n assert candidate(num = \"9876543210123456789098765432101234567890\",k = 300) == \"0000111122223333444479865567899876556789\"\n assert candidate(num = \"2134567890\",k = 5) == \"1234506789\"\n assert candidate(num = \"3333222211110000\",k = 50) == \"0000332332221111\"\n assert candidate(num = \"1234567890987654321\",k = 25) == \"0112345678998765432\"\n assert candidate(num = \"0000000001\",k = 5) == \"0000000001\"\n assert candidate(num = \"1098765432\",k = 20) == \"0123489765\"\n assert candidate(num = \"111112222233333444445555566666777778888899999\",k = 500) == \"111112222233333444445555566666777778888899999\"\n assert candidate(num = \"12345678909876543210\",k = 50) == \"00112345657899876432\"\n assert candidate(num = \"1432214321\",k = 10) == \"1122343421\"\n assert candidate(num = \"12341234123412341234\",k = 50) == \"11111222223434343434\"\n assert candidate(num = \"111222333444555666777888999\",k = 300) == \"111222333444555666777888999\"\n assert candidate(num = \"333222111000999888777666555444333222111000\",k = 500) == \"000000111111222222333333444555666779899887\"\n assert candidate(num = \"9999999999999999999999999999999999999999\",k = 100000) == \"9999999999999999999999999999999999999999\"\n assert candidate(num = \"1111111111111111111111111111111\",k = 30000) == \"1111111111111111111111111111111\"\n assert candidate(num = \"6482319570\",k = 8) == \"1264839570\"\n assert candidate(num = \"5999888777666555444333222111000\",k = 100) == \"0004599988877766655544333222111\"\n assert candidate(num = \"94321\",k = 3) == \"29431\"\n assert candidate(num = \"1234321\",k = 3) == \"1223431\"\n assert candidate(num = \"87654321098765432109\",k = 50) == \"00115876432987654329\"\n assert candidate(num = \"8765432109\",k = 100) == \"0123456789\"\n assert candidate(num = \"555555555555555555555555\",k = 100000) == \"555555555555555555555555\"\n assert candidate(num = \"123456789876543212345678987654321\",k = 150) == \"111222233334456789876545678987654\"\n assert candidate(num = \"54321098765432109876\",k = 100) == \"00112233445566778899\"\n assert candidate(num = \"432101234\",k = 10) == \"011432234\"\n assert candidate(num = \"1234567890\",k = 30) == \"0123456789\"\n assert candidate(num = \"9876543210\",k = 50) == \"0123456789\"\n assert candidate(num = \"1987654320\",k = 15) == \"0139876542\"\n assert candidate(num = \"5142369870\",k = 15) == \"0123456987\"\n assert candidate(num = \"444333222111000\",k = 50) == \"000134344322211\"\n assert candidate(num = \"98765432109876543210\",k = 20) == \"01698754329876543210\"\n assert candidate(num = \"9457836120\",k = 8) == \"1495783620\"\n assert candidate(num = \"9876543210\",k = 10000) == \"0123456789\"\n assert candidate(num = \"9632147850\",k = 12) == \"0296314785\"\n assert candidate(num = \"10987654321\",k = 10) == \"01189765432\"\n assert candidate(num = \"1234543210\",k = 25) == \"0112233445\"\n assert candidate(num = \"1221331223\",k = 20) == \"1112222333\"\n assert candidate(num = \"1234567890\",k = 50) == \"0123456789\"\n assert candidate(num = \"8642013579\",k = 20) == \"0123456789\"\n assert candidate(num = \"11111111111111111111\",k = 10000) == \"11111111111111111111\"\n assert candidate(num = \"192837465546738291\",k = 50) == \"112233458976546789\"\n assert candidate(num = \"9438276510\",k = 10) == \"0493827651\"\n assert candidate(num = \"123456789012345678901234567890\",k = 100) == \"000111222345678394567893456789\"\n assert candidate(num = \"12345678901234567890\",k = 20) == \"01123456278934567890\"\n assert candidate(num = \"333222111\",k = 20) == \"111323322\"\n assert candidate(num = \"9876543210\",k = 25) == \"0128976543\"\n assert candidate(num = \"98765432109876543210\",k = 100) == \"00112233458976987654\"\n assert candidate(num = \"000111222333444555666777888999\",k = 50) == \"000111222333444555666777888999\"\n assert candidate(num = \"1234567890\",k = 25) == \"0123456789\"\n assert candidate(num = \"5432109876\",k = 15) == \"0123459876\"\n assert candidate(num = \"010203040506070809\",k = 30) == \"000000001234560789\"\n assert candidate(num = \"99999999999999999999\",k = 1000) == \"99999999999999999999\"\n assert candidate(num = \"99887766554433221100\",k = 50) == \"00299887766554433211\"\n assert candidate(num = \"12345678900987654321\",k = 50) == \"00112234567889976543\"\n"}, "metadata": {"canonical_parameter_names": ["num", "k"], "leetcode_dataset_entry_point": "Solution().minInteger", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string minInteger(string num, int k) {", "container": "Solution", "callable": "minInteger", "parameters": [{"name": "num", "type": "string"}, {"name": "k", "type": "int"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1507, "task_id": "reformat-date", "difficulty": "Easy", "problem_description": "Given a date string in the form Day Month Year, where:\n\nDay is in the set {\"1st\", \"2nd\", \"3rd\", \"4th\", ..., \"30th\", \"31st\"}.\nMonth is in the set {\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"}.\nYear is in the range [1900, 2100].\n\nConvert the date string to the format YYYY-MM-DD, where:\n\nYYYY denotes the 4 digit year.\nMM denotes the 2 digit month.\nDD denotes the 2 digit day.\n\n \nExample 1:\n\nInput: date = \"20th Oct 2052\"\nOutput: \"2052-10-20\"\n\nExample 2:\n\nInput: date = \"6th Jun 1933\"\nOutput: \"1933-06-06\"\n\nExample 3:\n\nInput: date = \"26th May 1960\"\nOutput: \"1960-05-26\"\n\n \nConstraints:\n\nThe given dates are guaranteed to be valid, so no error handling is necessary.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(date = \"15th Aug 2022\") == \"2022-08-15\"\n assert candidate(date = \"22nd Aug 1999\") == \"1999-08-22\"\n assert candidate(date = \"3rd Mar 1987\") == \"1987-03-03\"\n assert candidate(date = \"3rd Nov 2022\") == \"2022-11-03\"\n assert candidate(date = \"2nd Mar 2020\") == \"2020-03-02\"\n assert candidate(date = \"15th Nov 2000\") == \"2000-11-15\"\n assert candidate(date = \"2nd Mar 2010\") == \"2010-03-02\"\n assert candidate(date = \"31st Dec 2100\") == \"2100-12-31\"\n assert candidate(date = \"25th Dec 2000\") == \"2000-12-25\"\n assert candidate(date = \"11th Sep 2023\") == \"2023-09-11\"\n assert candidate(date = \"15th Nov 1999\") == \"1999-11-15\"\n assert candidate(date = \"15th Nov 2020\") == \"2020-11-15\"\n assert candidate(date = \"11th Mar 2000\") == \"2000-03-11\"\n assert candidate(date = \"5th Sep 1899\") == \"1899-09-05\"\n assert candidate(date = \"3rd Apr 2015\") == \"2015-04-03\"\n assert candidate(date = \"26th May 1960\") == \"1960-05-26\"\n assert candidate(date = \"11th Sep 1999\") == \"1999-09-11\"\n assert candidate(date = \"28th Feb 1900\") == \"1900-02-28\"\n assert candidate(date = \"20th Oct 2052\") == \"2052-10-20\"\n assert candidate(date = \"6th Jun 1933\") == \"1933-06-06\"\n assert candidate(date = \"2nd Mar 2015\") == \"2015-03-02\"\n assert candidate(date = \"1st Jan 1900\") == \"1900-01-01\"\n assert candidate(date = \"28th Feb 1996\") == \"1996-02-28\"\n assert candidate(date = \"29th Feb 2004\") == \"2004-02-29\"\n assert candidate(date = \"2nd Feb 2020\") == \"2020-02-02\"\n assert candidate(date = \"11th Sep 2020\") == \"2020-09-11\"\n assert candidate(date = \"29th Feb 2000\") == \"2000-02-29\"\n assert candidate(date = \"8th Feb 1987\") == \"1987-02-08\"\n assert candidate(date = \"31st Jan 2100\") == \"2100-01-31\"\n assert candidate(date = \"5th Nov 1999\") == \"1999-11-05\"\n assert candidate(date = \"22nd Sep 1965\") == \"1965-09-22\"\n assert candidate(date = \"27th Jun 2012\") == \"2012-06-27\"\n assert candidate(date = \"30th Nov 2010\") == \"2010-11-30\"\n assert candidate(date = \"19th Dec 2099\") == \"2099-12-19\"\n assert candidate(date = \"31st May 2023\") == \"2023-05-31\"\n assert candidate(date = \"31st Dec 2099\") == \"2099-12-31\"\n assert candidate(date = \"4th Mar 2003\") == \"2003-03-04\"\n assert candidate(date = \"24th Jun 2050\") == \"2050-06-24\"\n assert candidate(date = \"23rd Apr 2040\") == \"2040-04-23\"\n assert candidate(date = \"27th Sep 2077\") == \"2077-09-27\"\n assert candidate(date = \"6th Mar 2077\") == \"2077-03-06\"\n assert candidate(date = \"18th Jun 2050\") == \"2050-06-18\"\n assert candidate(date = \"10th Oct 2033\") == \"2033-10-10\"\n assert candidate(date = \"29th Apr 1999\") == \"1999-04-29\"\n assert candidate(date = \"25th Oct 2050\") == \"2050-10-25\"\n assert candidate(date = \"14th May 2005\") == \"2005-05-14\"\n assert candidate(date = \"23rd Oct 2005\") == \"2005-10-23\"\n assert candidate(date = \"30th Apr 2047\") == \"2047-04-30\"\n assert candidate(date = \"19th Aug 2076\") == \"2076-08-19\"\n assert candidate(date = \"21st Jun 1972\") == \"1972-06-21\"\n assert candidate(date = \"18th May 1950\") == \"1950-05-18\"\n assert candidate(date = \"4th Nov 2035\") == \"2035-11-04\"\n assert candidate(date = \"29th Feb 2020\") == \"2020-02-29\"\n assert candidate(date = \"9th Sep 1987\") == \"1987-09-09\"\n assert candidate(date = \"31st Jan 1980\") == \"1980-01-31\"\n assert candidate(date = \"18th Sep 2089\") == \"2089-09-18\"\n assert candidate(date = \"21st Aug 1955\") == \"1955-08-21\"\n assert candidate(date = \"30th Nov 1969\") == \"1969-11-30\"\n assert candidate(date = \"27th Oct 2075\") == \"2075-10-27\"\n assert candidate(date = \"3rd Nov 2021\") == \"2021-11-03\"\n assert candidate(date = \"18th Jul 1950\") == \"1950-07-18\"\n assert candidate(date = \"12th Aug 2022\") == \"2022-08-12\"\n assert candidate(date = \"19th Dec 2021\") == \"2021-12-19\"\n assert candidate(date = \"3rd Jul 1970\") == \"1970-07-03\"\n assert candidate(date = \"7th Dec 2099\") == \"2099-12-07\"\n assert candidate(date = \"9th Jun 2040\") == \"2040-06-09\"\n assert candidate(date = \"21st Nov 2050\") == \"2050-11-21\"\n assert candidate(date = \"16th May 2067\") == \"2067-05-16\"\n assert candidate(date = \"14th Oct 1960\") == \"1960-10-14\"\n assert candidate(date = \"25th Dec 1984\") == \"1984-12-25\"\n assert candidate(date = \"22nd Sep 2050\") == \"2050-09-22\"\n assert candidate(date = \"28th Feb 2000\") == \"2000-02-28\"\n assert candidate(date = \"15th Aug 2024\") == \"2024-08-15\"\n assert candidate(date = \"5th Oct 2100\") == \"2100-10-05\"\n assert candidate(date = \"22nd Aug 2022\") == \"2022-08-22\"\n assert candidate(date = \"21st Sep 1989\") == \"1989-09-21\"\n assert candidate(date = \"22nd Mar 2015\") == \"2015-03-22\"\n assert candidate(date = \"12th Mar 2021\") == \"2021-03-12\"\n assert candidate(date = \"13th Dec 2033\") == \"2033-12-13\"\n assert candidate(date = \"13th Aug 1984\") == \"1984-08-13\"\n assert candidate(date = \"3rd Mar 2030\") == \"2030-03-03\"\n assert candidate(date = \"13th Aug 2023\") == \"2023-08-13\"\n assert candidate(date = \"10th Oct 1899\") == \"1899-10-10\"\n assert candidate(date = \"17th Mar 1925\") == \"1925-03-17\"\n assert candidate(date = \"21st Dec 1900\") == \"1900-12-21\"\n assert candidate(date = \"4th Mar 1921\") == \"1921-03-04\"\n assert candidate(date = \"24th Jun 1998\") == \"1998-06-24\"\n assert candidate(date = \"22nd Jul 2034\") == \"2034-07-22\"\n assert candidate(date = \"25th Jun 2023\") == \"2023-06-25\"\n assert candidate(date = \"30th Nov 2045\") == \"2045-11-30\"\n assert candidate(date = \"30th Apr 2000\") == \"2000-04-30\"\n assert candidate(date = \"28th Feb 1999\") == \"1999-02-28\"\n assert candidate(date = \"2nd Jan 1901\") == \"1901-01-02\"\n assert candidate(date = \"1st Mar 2024\") == \"2024-03-01\"\n assert candidate(date = \"5th Jul 1955\") == \"1955-07-05\"\n assert candidate(date = \"28th Feb 2001\") == \"2001-02-28\"\n assert candidate(date = \"9th Dec 2030\") == \"2030-12-09\"\n assert candidate(date = \"5th Oct 1987\") == \"1987-10-05\"\n assert candidate(date = \"10th Mar 2012\") == \"2012-03-10\"\n assert candidate(date = \"7th Jun 2080\") == \"2080-06-07\"\n assert candidate(date = \"9th Jul 1987\") == \"1987-07-09\"\n assert candidate(date = \"28th Feb 1901\") == \"1901-02-28\"\n assert candidate(date = \"7th Jul 2021\") == \"2021-07-07\"\n assert candidate(date = \"7th Nov 1969\") == \"1969-11-07\"\n assert candidate(date = \"2nd Mar 1990\") == \"1990-03-02\"\n assert candidate(date = \"28th Feb 2004\") == \"2004-02-28\"\n assert candidate(date = \"30th Apr 2077\") == \"2077-04-30\"\n assert candidate(date = \"30th Apr 2100\") == \"2100-04-30\"\n assert candidate(date = \"12th Sep 1995\") == \"1995-09-12\"\n assert candidate(date = \"2nd Apr 2023\") == \"2023-04-02\"\n assert candidate(date = \"17th Oct 2061\") == \"2061-10-17\"\n"}, "metadata": {"canonical_parameter_names": ["date"], "leetcode_dataset_entry_point": "Solution().reformatDate", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string reformatDate(string date) {", "container": "Solution", "callable": "reformatDate", "parameters": [{"name": "date", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1508, "task_id": "range-sum-of-sorted-subarray-sums", "difficulty": "Medium", "problem_description": "You are given the array nums consisting of n positive integers. You computed the sum of all non-empty continuous subarrays from the array and then sorted them in non-decreasing order, creating a new array of n * (n + 1) / 2 numbers.\nReturn the sum of the numbers from index left to index right (indexed from 1), inclusive, in the new array. Since the answer can be a huge number return it modulo 109 + 7.\n \nExample 1:\n\nInput: nums = [1,2,3,4], n = 4, left = 1, right = 5\nOutput: 13 \nExplanation: All subarray sums are 1, 3, 6, 10, 2, 5, 9, 3, 7, 4. After sorting them in non-decreasing order we have the new array [1, 2, 3, 3, 4, 5, 6, 7, 9, 10]. The sum of the numbers from index le = 1 to ri = 5 is 1 + 2 + 3 + 3 + 4 = 13. \n\nExample 2:\n\nInput: nums = [1,2,3,4], n = 4, left = 3, right = 4\nOutput: 6\nExplanation: The given array is the same as example 1. We have the new array [1, 2, 3, 3, 4, 5, 6, 7, 9, 10]. The sum of the numbers from index le = 3 to ri = 4 is 3 + 3 = 6.\n\nExample 3:\n\nInput: nums = [1,2,3,4], n = 4, left = 1, right = 10\nOutput: 50\n\n \nConstraints:\n\nn == nums.length\n1 <= nums.length <= 1000\n1 <= nums[i] <= 100\n1 <= left <= right <= n * (n + 1) / 2\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4],n = 4,left = 3,right = 4) == 6\n assert candidate(nums = [10, 20, 30],n = 3,left = 1,right = 3) == 60\n assert candidate(nums = [5, 1, 2],n = 3,left = 1,right = 4) == 11\n assert candidate(nums = [1, 2, 3, 4],n = 4,left = 1,right = 5) == 13\n assert candidate(nums = [3, 3, 3, 3],n = 4,left = 2,right = 8) == 36\n assert candidate(nums = [1, 2, 3, 4],n = 4,left = 1,right = 10) == 50\n assert candidate(nums = [3, 3, 3],n = 3,left = 2,right = 5) == 18\n assert candidate(nums = [5, 2, 1, 4],n = 4,left = 3,right = 7) == 24\n assert candidate(nums = [10, 20, 30],n = 3,left = 2,right = 5) == 130\n assert candidate(nums = [5, 1, 4],n = 3,left = 1,right = 6) == 31\n assert candidate(nums = [5, 1, 2, 3],n = 4,left = 2,right = 6) == 18\n assert candidate(nums = [10, 20, 30],n = 3,left = 1,right = 5) == 140\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155],n = 15,left = 60,right = 120) == 46215\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],n = 10,left = 25,right = 50) == 756\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],n = 10,left = 20,right = 30) == 36\n assert candidate(nums = [5, 15, 10, 20, 25],n = 5,left = 1,right = 15) == 520\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],n = 10,left = 25,right = 55) == 2334\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],n = 10,left = 15,right = 45) == 6700\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],n = 10,left = 25,right = 75) == 10110\n assert candidate(nums = [100, 200, 300, 400, 500],n = 5,left = 10,right = 20) == 6900\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],n = 10,left = 1,right = 100) == 2200\n assert candidate(nums = [50, 40, 30, 20, 10],n = 5,left = 5,right = 15) == 960\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],n = 11,left = 15,right = 45) == 460\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],n = 20,left = 100,right = 200) == 11368\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],n = 15,left = 50,right = 100) == 5098\n assert candidate(nums = [23, 34, 45, 56, 67, 78, 89, 90, 100, 110],n = 10,left = 25,right = 60) == 12693\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],n = 9,left = 25,right = 35) == 250\n assert candidate(nums = [10, 20, 30, 40, 50],n = 5,left = 3,right = 12) == 610\n assert candidate(nums = [5, 15, 10, 20],n = 4,left = 5,right = 12) == 200\n assert candidate(nums = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],n = 12,left = 30,right = 75) == 8471\n assert candidate(nums = [30, 20, 10, 40, 50, 60, 70, 80, 90, 100],n = 10,left = 25,right = 75) == 9910\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13],n = 7,left = 1,right = 28) == 588\n assert candidate(nums = [9, 7, 5, 3, 1],n = 5,left = 6,right = 16) == 155\n assert candidate(nums = [5, 6, 7, 8, 9],n = 5,left = 3,right = 7) == 48\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],n = 10,left = 1,right = 55) == 220\n assert candidate(nums = [5, 1, 7, 3, 8],n = 5,left = 3,right = 7) == 34\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],n = 10,left = 15,right = 40) == 497\n assert candidate(nums = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6],n = 10,left = 1,right = 100) == 1210\n assert candidate(nums = [99, 100, 98, 97, 96],n = 5,left = 10,right = 20) == 2158\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],n = 15,left = 50,right = 150) == 9416\n assert candidate(nums = [42, 53, 64, 75, 86, 97, 108, 119, 130, 141],n = 10,left = 15,right = 45) == 11216\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],n = 10,left = 30,right = 70) == 9190\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],n = 10,left = 30,right = 50) == 664\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],n = 20,left = 150,right = 250) == 46005\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],n = 11,left = 20,right = 40) == 310\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],n = 10,left = 25,right = 50) == 7560\n assert candidate(nums = [100, 200, 300, 400, 500],n = 5,left = 1,right = 15) == 10500\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],n = 10,left = 10,right = 30) == 496\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],n = 10,left = 50,right = 100) == 30000\n assert candidate(nums = [9, 8, 7, 6, 5],n = 5,left = 1,right = 15) == 245\n assert candidate(nums = [9, 18, 27, 36, 45, 54],n = 6,left = 10,right = 20) == 1260\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],n = 10,left = 15,right = 30) == 46\n assert candidate(nums = [100, 200, 300, 400, 500, 600],n = 6,left = 10,right = 30) == 16100\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],n = 10,left = 20,right = 40) == 44500\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],n = 10,left = 50,right = 75) == 364\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],n = 10,left = 30,right = 50) == 664\n assert candidate(nums = [7, 3, 8, 6, 2, 5, 4, 9, 1],n = 9,left = 20,right = 40) == 480\n assert candidate(nums = [99, 98, 97, 96, 95, 94],n = 6,left = 20,right = 30) == 1064\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],n = 20,left = 150,right = 250) == 9201\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],n = 10,left = 10,right = 30) == 5233\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],n = 15,left = 50,right = 60) == 379\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],n = 10,left = 20,right = 50) == 1036\n assert candidate(nums = [10, 20, 30, 40, 50, 60],n = 6,left = 10,right = 20) == 1400\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],n = 10,left = 25,right = 35) == 421\n assert candidate(nums = [10, 20, 30, 40, 50],n = 5,left = 1,right = 25) == 1050\n assert candidate(nums = [34, 78, 12, 56, 90, 23, 45, 67, 89, 10],n = 10,left = 30,right = 60) == 8474\n assert candidate(nums = [10, 20, 30, 40, 50, 60],n = 6,left = 10,right = 20) == 1400\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],n = 11,left = 5,right = 20) == 95\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],n = 10,left = 1,right = 100) == 2200\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],n = 10,left = 30,right = 40) == 2810\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],n = 10,left = 30,right = 45) == 908\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],n = 10,left = 55,right = 85) == 550\n assert candidate(nums = [50, 40, 30, 20, 10],n = 5,left = 10,right = 20) == 690\n assert candidate(nums = [9, 7, 5, 3, 1],n = 5,left = 8,right = 12) == 68\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],n = 7,left = 15,right = 25) == 179\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],n = 15,left = 100,right = 200) == 2074\n assert candidate(nums = [50, 40, 30, 20, 10],n = 5,left = 1,right = 15) == 1050\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],n = 15,left = 50,right = 100) == 2715\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],n = 10,left = 45,right = 75) == 5010\n assert candidate(nums = [9, 3, 5, 7, 2, 8],n = 6,left = 4,right = 12) == 89\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],n = 10,left = 25,right = 50) == 133\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20],n = 20,left = 50,right = 150) == 6400\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],n = 20,left = 100,right = 150) == 8103\n assert candidate(nums = [5, 15, 25, 35, 45],n = 5,left = 7,right = 14) == 610\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],n = 20,left = 50,right = 100) == 232\n assert candidate(nums = [1, 2, 3, 4, 5],n = 5,left = 1,right = 15) == 105\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],n = 10,left = 25,right = 50) == 410\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],n = 10,left = 55,right = 75) == 550\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],n = 10,left = 5,right = 55) == 21600\n assert candidate(nums = [5, 15, 25, 35, 45],n = 5,left = 5,right = 15) == 810\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],n = 15,left = 50,right = 100) == 5098\n assert candidate(nums = [8, 6, 4, 2, 0, 8, 6, 4, 2, 0],n = 10,left = 20,right = 40) == 344\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],n = 9,left = 10,right = 30) == 291\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],n = 10,left = 25,right = 45) == 97\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],n = 12,left = 50,right = 75) == 6660\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65],n = 7,left = 15,right = 25) == 1585\n assert candidate(nums = [5, 15, 10, 20, 25],n = 5,left = 4,right = 10) == 195\n assert candidate(nums = [50, 40, 30, 20, 10, 5, 2, 1],n = 8,left = 10,right = 35) == 2000\n assert candidate(nums = [100, 100, 100, 100, 100, 100],n = 6,left = 20,right = 30) == 1100\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],n = 15,left = 50,right = 100) == 5430\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],n = 15,left = 100,right = 150) == 2074\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],n = 10,left = 5,right = 20) == 27\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84],n = 12,left = 40,right = 80) == 13083\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],n = 10,left = 5,right = 15) == 1520\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],n = 20,left = 120,right = 200) == 19092\n"}, "metadata": {"canonical_parameter_names": ["nums", "n", "left", "right"], "leetcode_dataset_entry_point": "Solution().rangeSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int rangeSum(vector& nums, int n, int left, int right) {", "container": "Solution", "callable": "rangeSum", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "n", "type": "int"}, {"name": "left", "type": "int"}, {"name": "right", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1509, "task_id": "minimum-difference-between-largest-and-smallest-value-in-three-moves", "difficulty": "Medium", "problem_description": "You are given an integer array nums.\nIn one move, you can choose one element of nums and change it to any value.\nReturn the minimum difference between the largest and smallest value of nums after performing at most three moves.\n \nExample 1:\n\nInput: nums = [5,3,2,4]\nOutput: 0\nExplanation: We can make at most 3 moves.\nIn the first move, change 2 to 3. nums becomes [5,3,3,4].\nIn the second move, change 4 to 3. nums becomes [5,3,3,3].\nIn the third move, change 5 to 3. nums becomes [3,3,3,3].\nAfter performing 3 moves, the difference between the minimum and maximum is 3 - 3 = 0.\n\nExample 2:\n\nInput: nums = [1,5,0,10,14]\nOutput: 1\nExplanation: We can make at most 3 moves.\nIn the first move, change 5 to 0. nums becomes [1,0,0,10,14].\nIn the second move, change 10 to 0. nums becomes [1,0,0,0,14].\nIn the third move, change 14 to 1. nums becomes [1,0,0,0,1].\nAfter performing 3 moves, the difference between the minimum and maximum is 1 - 0 = 1.\nIt can be shown that there is no way to make the difference 0 in 3 moves.\nExample 3:\n\nInput: nums = [3,100,20]\nOutput: 0\nExplanation: We can make at most 3 moves.\nIn the first move, change 100 to 7. nums becomes [3,7,20].\nIn the second move, change 20 to 7. nums becomes [3,7,7].\nIn the third move, change 3 to 7. nums becomes [7,7,7].\nAfter performing 3 moves, the difference between the minimum and maximum is 7 - 7 = 0.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n-109 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, 100, 20]) == 0\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 6\n assert candidate(nums = [1, 1000000000, -1000000000, 0]) == 0\n assert candidate(nums = [1, 2]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 0]) == 0\n assert candidate(nums = [6, 6, 0, 1, 1, 4, 6]) == 2\n assert candidate(nums = [1, 2, 3]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 11\n assert candidate(nums = [1, 5, 0, 10, 14]) == 1\n assert candidate(nums = [5, 3, 2, 4]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 46\n assert candidate(nums = [1, 2, 3, 1000000, 1000001, 1000002, 1000003, 1000004, 1000005, 1000006]) == 6\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 1100\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101]) == 88\n assert candidate(nums = [-1000000, -900000, -800000, -700000, -600000, -500000, -400000, -300000, -200000, -100000]) == 600000\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 1600\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290]) == 250\n assert candidate(nums = [1, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 999\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, -1, -10, -100, -1000, -10000, -100000, -1000000, -10000000, -100000000, -1000000000]) == 110000000\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 22\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 52\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 32\n assert candidate(nums = [5, 3, 2, 4, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 11\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000]) == 2600\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 8\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 17\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93]) == 96\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 1600\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 36\n assert candidate(nums = [-1, -1, -1, -2, -2, -2, -3, -3, -3, -4, -4, -4, -5, -5, -5, -6, -6, -6, -7, -7, -7, -8, -8, -8, -9, -9, -9, -10, -10, -10]) == 8\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91, 11, 90, 12, 89, 13, 88, 14, 87]) == 96\n assert candidate(nums = [1000, 100, 10, 1, 0, -1, -10, -100, -1000]) == 110\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 6\n assert candidate(nums = [-1000, -999, -998, -997, -996, -995, -994, -993, -992, -991, -990]) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000]) == 16000\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500]) == 600\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990]) == 6\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991]) == 6\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 21\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200]) == 180\n assert candidate(nums = [100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 99999\n assert candidate(nums = [-1000000, 0, 1000000, -500000, 500000, -250000, 250000, -750000, 750000, -1250000, 1250000, -1500000, 1500000, -2000000, 2000000]) == 2750000\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 3\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 0\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990, 999999989, 999999988, 999999987, 999999986, 999999985]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1000, 2000, 3000]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 26\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 80\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500]) == 2100\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105]) == 85\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150]) == 130\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 21\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 60\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == 6000000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 11\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 60\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 160\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250]) == 210\n assert candidate(nums = [1, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 1050, 1100, 1150, 1200]) == 1049\n assert candidate(nums = [5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1000]) == 0\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101]) == 88\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80]) == 17\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 16\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000, 3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000, 4100, 4200, 4300, 4400, 4500, 4600, 4700, 4800, 4900, 5000]) == 4600\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -110, -120, -130, -140, -150]) == 110\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 100, 200, 300, 400, 500]) == 199\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [5, 23, 54, 12, 19, 33, 8, 2, 99, 101, 102, 103, 104, 105, 106]) == 94\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 60\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 46\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 100]) == 93\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986]) == 11\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 0\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014]) == 11\n assert candidate(nums = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000, -1100, -1200, -1300, -1400, -1500, -1600, -1700, -1800, -1900, -2000]) == 1600\n assert candidate(nums = [100, 200, 300, 400, 500, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 199\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15]) == 11\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40]) == 110\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [-1, 0, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10, -11, 11, -12, 12, -13, 13, -14, 14]) == 25\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000]) == 0\n assert candidate(nums = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5, 999996]) == 999996\n assert candidate(nums = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500]) == 2199\n assert candidate(nums = [-1000000000, -900000000, -800000000, -700000000, -600000000, -500000000, -400000000, -300000000, -200000000, -100000000]) == 600000000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 60\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000]) == 0\n assert candidate(nums = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000]) == 600\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 4, 5]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [10, 1, 2, 9, 3, 8, 4, 7, 5, 6]) == 6\n assert candidate(nums = [1000000, 1000001, 1000002, 1000003, 1000004, -1000000, -1000001, -1000002, -1000003, -1000004]) == 2000005\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 110\n assert candidate(nums = [500000000, 500000001, 500000002, 500000003, 500000004, 500000005, 500000006, 500000007, 500000008, 500000009, 500000010]) == 7\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minDifference(vector& nums) {", "container": "Solution", "callable": "minDifference", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1510, "task_id": "stone-game-iv", "difficulty": "Hard", "problem_description": "Alice and Bob take turns playing a game, with Alice starting first.\nInitially, there are n stones in a pile. On each player's turn, that player makes a move consisting of removing any non-zero square number of stones in the pile.\nAlso, if a player cannot make a move, he/she loses the game.\nGiven a positive integer n, return true if and only if Alice wins the game otherwise return false, assuming both players play optimally.\n \nExample 1:\n\nInput: n = 1\nOutput: true\nExplanation: Alice can remove 1 stone winning the game because Bob doesn't have any moves.\nExample 2:\n\nInput: n = 2\nOutput: false\nExplanation: Alice can only remove 1 stone, after that Bob removes the last one winning the game (2 -> 1 -> 0).\n\nExample 3:\n\nInput: n = 4\nOutput: true\nExplanation: n is already a perfect square, Alice can win with one move, removing 4 stones (4 -> 0).\n\n \nConstraints:\n\n1 <= n <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 101) == True\n assert candidate(n = 3) == True\n assert candidate(n = 100) == True\n assert candidate(n = 30) == True\n assert candidate(n = 5) == False\n assert candidate(n = 4) == True\n assert candidate(n = 200) == True\n assert candidate(n = 17) == False\n assert candidate(n = 2) == False\n assert candidate(n = 20) == False\n assert candidate(n = 1) == True\n assert candidate(n = 7) == False\n assert candidate(n = 10) == False\n assert candidate(n = 25) == True\n assert candidate(n = 50) == True\n assert candidate(n = 300) == True\n assert candidate(n = 123) == True\n assert candidate(n = 64) == True\n assert candidate(n = 16) == True\n assert candidate(n = 169) == True\n assert candidate(n = 81) == True\n assert candidate(n = 150) == False\n assert candidate(n = 55) == True\n assert candidate(n = 180) == False\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().winnerSquareGame", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool winnerSquareGame(int n) {", "container": "Solution", "callable": "winnerSquareGame", "parameters": [{"name": "n", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1512, "task_id": "number-of-good-pairs", "difficulty": "Easy", "problem_description": "Given an array of integers nums, return the number of good pairs.\nA pair (i, j) is called good if nums[i] == nums[j] and i < j.\n \nExample 1:\n\nInput: nums = [1,2,3,1,1,3]\nOutput: 4\nExplanation: There are 4 good pairs (0,3), (0,4), (3,4), (2,5) 0-indexed.\n\nExample 2:\n\nInput: nums = [1,1,1,1]\nOutput: 6\nExplanation: Each pair in the array are good.\n\nExample 3:\n\nInput: nums = [1,2,3]\nOutput: 0\n\n \nConstraints:\n\n1 <= nums.length <= 100\n1 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 6, 7, 8, 9, 5]) == 1\n assert candidate(nums = [1, 1, 1, 1]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == 21\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 3]) == 5\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 5\n assert candidate(nums = [5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [42, 42, 42, 42, 42]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11]) == 0\n assert candidate(nums = [5, 6, 7, 8, 9, 5, 6, 7, 8, 9]) == 5\n assert candidate(nums = [10, 10, 10]) == 3\n assert candidate(nums = [1, 3, 2, 3, 3, 4, 1]) == 4\n assert candidate(nums = [1, 2, 3, 1, 1, 3]) == 4\n assert candidate(nums = [1, 2, 1, 3, 2, 3, 4, 5]) == 3\n assert candidate(nums = [1, 2, 1, 2, 1, 2]) == 6\n assert candidate(nums = [10, 20, 10, 10, 30, 20, 50, 20]) == 6\n assert candidate(nums = [1, 2, 3]) == 0\n assert candidate(nums = [100, 100]) == 1\n assert candidate(nums = [1, 2, 1, 3, 2, 1]) == 4\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2]) == 21\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 1653\n assert candidate(nums = [7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9]) == 63\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10]) == 0\n assert candidate(nums = [99, 99, 99, 98, 98, 98, 97, 97, 97, 96, 96, 96, 95, 95, 95, 94, 94, 94, 93, 93]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 0\n assert candidate(nums = [5, 6, 5, 6, 5, 6, 5, 6, 5, 6]) == 20\n assert candidate(nums = [10, 20, 20, 10, 30, 30, 30, 30]) == 8\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [100, 1, 2, 100, 2, 1, 100, 2, 1, 100]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 150\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5]) == 41\n assert candidate(nums = [1, 3, 2, 3, 2, 4, 2, 3, 4, 1, 4, 1, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1]) == 300\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 30\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 3003\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50]) == 5\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50]) == 50\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 30\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 66\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7]) == 84\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 100, 99, 98, 97, 96]) == 5\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 30\n assert candidate(nums = [5, 6, 7, 5, 6, 5, 6, 7, 7]) == 9\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 300\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 190\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 35\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 15\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 45\n assert candidate(nums = [10, 20, 10, 20, 30, 10, 20, 30, 40, 50]) == 7\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 63\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9]) == 59\n assert candidate(nums = [10, 20, 10, 20, 30, 10, 30, 30]) == 7\n assert candidate(nums = [25, 50, 75, 25, 50, 75, 25, 50, 75, 25, 50, 75, 25, 50, 75, 25, 50, 75, 25, 50, 75, 25, 50, 75]) == 84\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 435\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 2346\n assert candidate(nums = [10, 20, 30, 10, 10, 20, 30, 30, 30]) == 10\n assert candidate(nums = [99, 99, 99, 98, 98, 98, 97, 97, 97, 96, 96, 96, 95, 95, 95]) == 15\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2]) == 57\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 165\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 35\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 45\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 135\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 6\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [1, 2, 2, 1, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 36\n assert candidate(nums = [7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10]) == 40\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 1711\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 435\n assert candidate(nums = [10, 20, 10, 20, 10, 30, 20, 10]) == 9\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 190\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 435\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 6105\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 30\n assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 20, 10]) == 7\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 210\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 30\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70]) == 0\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34]) == 435\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 33\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1980\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 35\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(nums = [7, 7, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 65\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 450\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [10, 20, 10, 20, 30, 10, 20, 30, 30]) == 9\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [99, 99, 98, 98, 97, 97, 96, 96, 95, 95, 94, 94, 93, 93, 92, 92, 91, 91, 90, 90, 89, 89, 88, 88, 87, 87, 86, 86, 85, 85, 84, 84, 83, 83, 82, 82, 81, 81, 80, 80, 79, 79, 78, 78, 77, 77, 76, 76, 75, 75, 74, 74, 73, 73, 72, 72, 71, 71, 70, 70, 69, 69, 68, 68, 67, 67, 66, 66, 65, 65, 64, 64, 63, 63, 62, 62, 61, 61, 60, 60, 59, 59, 58, 58, 57, 57, 56, 56, 55, 55, 54, 54, 53, 53, 52, 52, 51, 51, 50, 50]) == 50\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15, 1]) == 105\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().numIdenticalPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numIdenticalPairs(vector& nums) {", "container": "Solution", "callable": "numIdenticalPairs", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1513, "task_id": "number-of-substrings-with-only-1s", "difficulty": "Medium", "problem_description": "Given a binary string s, return the number of substrings with all characters 1's. Since the answer may be too large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: s = \"0110111\"\nOutput: 9\nExplanation: There are 9 substring in total with only 1's characters.\n\"1\" -> 5 times.\n\"11\" -> 3 times.\n\"111\" -> 1 time.\nExample 2:\n\nInput: s = \"101\"\nOutput: 2\nExplanation: Substring \"1\" is shown 2 times in s.\n\nExample 3:\n\nInput: s = \"111111\"\nOutput: 21\nExplanation: Each substring contains only 1's characters.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns[i] is either '0' or '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1100110011\") == 9\n assert candidate(s = \"101\") == 2\n assert candidate(s = \"1001001001\") == 4\n assert candidate(s = \"1111101111\") == 25\n assert candidate(s = \"110110110110110\") == 15\n assert candidate(s = \"000\") == 0\n assert candidate(s = \"111111\") == 21\n assert candidate(s = \"0110111\") == 9\n assert candidate(s = \"0\") == 0\n assert candidate(s = \"01010101010101010101\") == 10\n assert candidate(s = \"111000111000111\") == 18\n assert candidate(s = \"1001001\") == 3\n assert candidate(s = \"111011101110111\") == 24\n assert candidate(s = \"1111111111\") == 55\n assert candidate(s = \"00000\") == 0\n assert candidate(s = \"11111111111111111111\") == 210\n assert candidate(s = \"111100001111\") == 20\n assert candidate(s = \"1\") == 1\n assert candidate(s = \"1100110011001100110011\") == 18\n assert candidate(s = \"11110000111111110000111100001111111111110000\") == 134\n assert candidate(s = \"11111111111111111111111111111111111111111111111111111111111111111111111111111111\") == 3240\n assert candidate(s = \"111000111000111000111000111000111000111000111000111000111000111000111000111\") == 78\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101010101010101010101010101010101\") == 41\n assert candidate(s = \"100100100100100100100100100100100100100100100100100100100100100100100100100100100\") == 27\n assert candidate(s = \"0111111111101111111111101111111111101111111111101111111111101111111111101111111111101111111111101111111111\") == 572\n assert candidate(s = \"000000000000000000000000000000000000000000000000\") == 0\n assert candidate(s = \"101010101010101010101010101010101010101010101010\") == 24\n assert candidate(s = \"111111111100000000000000000000000000000000000000000000000000000000000000000000000001111111111\") == 110\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().numSub", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numSub(string s) {", "container": "Solution", "callable": "numSub", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1514, "task_id": "path-with-maximum-probability", "difficulty": "Medium", "problem_description": "You are given an undirected weighted graph of n nodes (0-indexed), represented by an edge list where edges[i] = [a, b] is an undirected edge connecting the nodes a and b with a probability of success of traversing that edge succProb[i].\nGiven two nodes start and end, find the path with the maximum probability of success to go from start to end and return its success probability.\nIf there is no path from start to end, return 0. Your answer will be accepted if it differs from the correct answer by at most 1e-5.\n \nExample 1:\n\n\nInput: n = 3, edges = [[0,1],[1,2],[0,2]], succProb = [0.5,0.5,0.2], start = 0, end = 2\nOutput: 0.25000\nExplanation: There are two paths from start to end, one having a probability of success = 0.2 and the other has 0.5 * 0.5 = 0.25.\n\nExample 2:\n\n\nInput: n = 3, edges = [[0,1],[1,2],[0,2]], succProb = [0.5,0.5,0.3], start = 0, end = 2\nOutput: 0.30000\n\nExample 3:\n\n\nInput: n = 3, edges = [[0,1]], succProb = [0.5], start = 0, end = 2\nOutput: 0.00000\nExplanation: There is no path between 0 and 2.\n\n \nConstraints:\n\n2 <= n <= 10^4\n0 <= start, end < n\nstart != end\n0 <= a, b < n\na != b\n0 <= succProb.length == edges.length <= 2*10^4\n0 <= succProb[i] <= 1\nThere is at most one edge between every two nodes.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [2, 3]],succProb = [0.1, 0.2, 0.3],start_node = 0,end_node = 3) == 0.006000000000000001\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [2, 3]],succProb = [0.1, 0.9, 0.8],start_node = 0,end_node = 3) == 0.07200000000000001\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [2, 3], [3, 4]],succProb = [0.5, 0.5, 0.5, 0.5],start_node = 0,end_node = 4) == 0.0625\n assert candidate(n = 7,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],succProb = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1],start_node = 0,end_node = 6) == 1.0000000000000004e-06\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 7], [6, 7]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1],start_node = 0,end_node = 7) == 0.09000000000000001\n assert candidate(n = 3,edges = [[0, 1], [1, 2], [0, 2]],succProb = [0.5, 0.5, 0.3],start_node = 0,end_node = 2) == 0.3\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5],start_node = 0,end_node = 5) == 0.0012000000000000003\n assert candidate(n = 3,edges = [[0, 1], [1, 2], [0, 2]],succProb = [0.5, 0.5, 0.2],start_node = 0,end_node = 2) == 0.25\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6],start_node = 0,end_node = 4) == 0.12\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [2, 3]],succProb = [0.1, 0.9, 0.5],start_node = 0,end_node = 3) == 0.045000000000000005\n assert candidate(n = 3,edges = [[0, 1]],succProb = [0.5],start_node = 0,end_node = 2) == 0\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [2, 3]],succProb = [0.9, 0.8, 0.7],start_node = 0,end_node = 3) == 0.504\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [2, 3], [3, 4]],succProb = [0.1, 0.9, 0.8, 0.2],start_node = 0,end_node = 4) == 0.014400000000000003\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [0, 3], [3, 4]],succProb = [0.9, 0.8, 0.7, 0.6],start_node = 0,end_node = 2) == 0.7200000000000001\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [3, 4]],succProb = [0.7, 0.8, 0.9],start_node = 0,end_node = 4) == 0\n assert candidate(n = 5,edges = [[0, 1], [1, 2], [2, 3], [3, 4]],succProb = [0.5, 0.4, 0.3, 0.2],start_node = 0,end_node = 4) == 0.012\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],succProb = [0.01, 0.99, 0.02, 0.98, 0.03, 0.97, 0.04, 0.96, 0.05, 0.95, 0.06, 0.94, 0.07, 0.93],start_node = 0,end_node = 14) == 3.7815442046807046e-11\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8],start_node = 1,end_node = 7) == 0.08000000000000002\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],start_node = 0,end_node = 11) == 0.3\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],succProb = [0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1],start_node = 0,end_node = 5) == 0.5\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7]],succProb = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.8, 0.8, 0.8, 0.8, 0.8, 0.8],start_node = 0,end_node = 7) == 0.06400000000000002\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 14]],succProb = [0.1, 0.1, 0.1, 0.2, 0.2, 0.3, 0.3, 0.4, 0.4, 0.5, 0.5, 0.6, 0.6, 0.7, 0.7],start_node = 0,end_node = 14) == 0.028000000000000004\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1],start_node = 0,end_node = 5) == 0.03024\n assert candidate(n = 7,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 6]],succProb = [0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.99],start_node = 0,end_node = 6) == 0.99\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],succProb = [0.1, 0.9, 0.2, 0.8, 0.3, 0.7, 0.4, 0.6],start_node = 0,end_node = 9) == 0\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6],start_node = 0,end_node = 9) == 0.1\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 0], [1, 4], [4, 5], [5, 6], [6, 7], [7, 4]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],start_node = 0,end_node = 6) == 0.036000000000000004\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 7], [6, 7]],succProb = [0.1, 0.1, 0.2, 0.2, 0.3, 0.3, 0.4, 0.4, 0.5, 0.5],start_node = 0,end_node = 7) == 0.015\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 2], [1, 3], [2, 4], [3, 5]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1],start_node = 0,end_node = 5) == 0.6\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]],succProb = [0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05],start_node = 0,end_node = 19) == 1.907348632812502e-25\n assert candidate(n = 6,edges = [[0, 1], [0, 5], [1, 2], [1, 3], [2, 4], [3, 4], [4, 5]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7],start_node = 0,end_node = 4) == 0.13999999999999999\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [0, 2], [2, 3], [3, 4], [2, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1],start_node = 0,end_node = 9) == 0\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],succProb = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5],start_node = 5,end_node = 9) == 0.0625\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],succProb = [0.99, 0.98, 0.97, 0.96, 0.95, 0.94, 0.93, 0.92, 0.91],start_node = 0,end_node = 9) == 0.6281565095552946\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 0], [6, 1], [7, 2]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8],start_node = 0,end_node = 6) == 0.5599999999999999\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]],succProb = [0.5, 0.4, 0.3, 0.2, 0.1, 0.9, 0.8, 0.7, 0.6, 0.5],start_node = 0,end_node = 9) == 0.5\n assert candidate(n = 7,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 6], [1, 3], [2, 4], [3, 5]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.01],start_node = 0,end_node = 6) == 0.7\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 5]],succProb = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5],start_node = 0,end_node = 5) == 0.5\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 0]],succProb = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1],start_node = 0,end_node = 19) == 0.1\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],start_node = 0,end_node = 9) == 0.0003628800000000001\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [0, 5], [5, 10], [1, 6], [6, 11], [2, 7], [7, 0], [3, 8], [8, 1], [4, 9], [9, 2]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1, 0.2],start_node = 0,end_node = 11) == 0.33599999999999997\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.9],start_node = 0,end_node = 9) == 0.9\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [1, 3], [3, 5], [5, 7], [7, 9]],succProb = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.2, 0.2, 0.2, 0.2],start_node = 0,end_node = 9) == 0.1\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4],start_node = 0,end_node = 14) == 0.048\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]],succProb = [0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.01, 0.02, 0.03, 0.04, 0.05],start_node = 0,end_node = 9) == 0.1\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1, 0.2, 0.3, 0.4, 0.5],start_node = 0,end_node = 9) == 0.1\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]],succProb = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1],start_node = 0,end_node = 19) == 1.000000000000001e-19\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [1, 3], [2, 4], [0, 4], [1, 5], [2, 5]],succProb = [0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.9, 0.9, 0.9, 0.9, 0.9],start_node = 0,end_node = 5) == 0.7290000000000001\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [3, 5], [4, 5]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],start_node = 0,end_node = 5) == 0.108\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [0, 7], [1, 5], [2, 6], [3, 7]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1, 0.2, 0.3],start_node = 0,end_node = 7) == 0.8\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],succProb = [0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6],start_node = 0,end_node = 14) == 2.6127360000000006e-06\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],succProb = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5],start_node = 0,end_node = 9) == 0.001953125\n assert candidate(n = 6,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 3], [2, 5]],succProb = [0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3],start_node = 0,end_node = 5) == 0.21600000000000003\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [0, 14]],succProb = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1],start_node = 0,end_node = 14) == 0.1\n assert candidate(n = 7,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [0, 6], [1, 3], [2, 4], [3, 5]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1],start_node = 0,end_node = 6) == 0.7\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],succProb = [0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18],start_node = 0,end_node = 14) == 2.6676557107200007e-14\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [0, 19]],succProb = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.9],start_node = 0,end_node = 19) == 0.9\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0]],succProb = [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1],start_node = 0,end_node = 5) == 1.0000000000000004e-05\n assert candidate(n = 10,edges = [[0, 9], [0, 8], [8, 9], [1, 7], [1, 6], [6, 7], [2, 5], [2, 4], [4, 5], [3, 0], [3, 1], [3, 2]],succProb = [0.1, 0.2, 0.15, 0.3, 0.4, 0.35, 0.5, 0.6, 0.55, 0.7, 0.8, 0.85],start_node = 3,end_node = 9) == 0.06999999999999999\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],succProb = [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5],start_node = 0,end_node = 4) == 0.0625\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],succProb = [0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.2],start_node = 0,end_node = 11) == 0.024\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]],succProb = [0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.2, 0.3, 0.4, 0.5],start_node = 0,end_node = 19) == 6.584094720000003e-13\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]],succProb = [0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1],start_node = 0,end_node = 19) == 0.8\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]],succProb = [0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05],start_node = 0,end_node = 19) == 1.907348632812502e-25\n assert candidate(n = 7,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],succProb = [0.01, 0.01, 0.01, 0.01, 0.01, 0.01],start_node = 0,end_node = 6) == 1.0000000000000002e-12\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [0, 10], [10, 15]],succProb = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.5, 0.3, 0.4],start_node = 0,end_node = 19) == 0.03024\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7]],succProb = [0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.05, 0.15, 0.25, 0.35, 0.45],start_node = 0,end_node = 7) == 0.2\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],succProb = [0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.99],start_node = 0,end_node = 11) == 9.900000000000002e-21\n assert candidate(n = 25,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 0]],succProb = [0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3],start_node = 0,end_node = 24) == 0.3\n"}, "metadata": {"canonical_parameter_names": ["n", "edges", "succProb", "start_node", "end_node"], "leetcode_dataset_entry_point": "Solution().maxProbability", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "double maxProbability(int n, vector>& edges, vector& succProb, int start_node, int end_node) {", "container": "Solution", "callable": "maxProbability", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "vector>&"}, {"name": "succProb", "type": "vector&"}, {"name": "start_node", "type": "int"}, {"name": "end_node", "type": "int"}], "return_type": "double", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1515, "task_id": "best-position-for-a-service-centre", "difficulty": "Hard", "problem_description": "A delivery company wants to build a new service center in a new city. The company knows the positions of all the customers in this city on a 2D-Map and wants to build the new center in a position such that the sum of the euclidean distances to all customers is minimum.\nGiven an array positions where positions[i] = [xi, yi] is the position of the ith customer on the map, return the minimum sum of the euclidean distances to all customers.\nIn other words, you need to choose the position of the service center [xcentre, ycentre] such that the following formula is minimized:\n\nAnswers within 10-5 of the actual value will be accepted.\n \nExample 1:\n\n\nInput: positions = [[0,1],[1,0],[1,2],[2,1]]\nOutput: 4.00000\nExplanation: As shown, you can see that choosing [xcentre, ycentre] = [1, 1] will make the distance to each customer = 1, the sum of all distances is 4 which is the minimum possible we can achieve.\n\nExample 2:\n\n\nInput: positions = [[1,1],[3,3]]\nOutput: 2.82843\nExplanation: The minimum possible sum of distances = sqrt(2) + sqrt(2) = 2.82843\n\n \nConstraints:\n\n1 <= positions.length <= 50\npositions[i].length == 2\n0 <= xi, yi <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(positions = [[1, 1], [1, 1], [1, 1], [1, 1]]) == 0.0\n assert candidate(positions = [[50, 50], [51, 51], [49, 49]]) == 2.8284271247461903\n assert candidate(positions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 8.485281374238571\n assert candidate(positions = [[2, 2], [2, 3], [3, 2], [3, 3]]) == 2.8284271247461903\n assert candidate(positions = [[1, 2], [2, 3], [3, 4], [4, 5]]) == 5.65685424949238\n assert candidate(positions = [[0, 0], [0, 1], [1, 0], [1, 1]]) == 2.8284271247461903\n assert candidate(positions = [[5, 5], [5, 10], [10, 5], [10, 10]]) == 14.142135623730951\n assert candidate(positions = [[1, 1], [3, 3]]) == 2.8284271247461903\n assert candidate(positions = [[10, 10], [20, 20], [30, 30]]) == 28.284271247461902\n assert candidate(positions = [[0, 0], [100, 100], [50, 50]]) == 141.4213562373095\n assert candidate(positions = [[0, 1], [1, 0], [1, 2], [2, 1]]) == 4.0\n assert candidate(positions = [[1, 1], [1, 1], [1, 1]]) == 0.0\n assert candidate(positions = [[1, 1]]) == 0.0\n assert candidate(positions = [[0, 0], [100, 100]]) == 141.4213562373095\n assert candidate(positions = [[1, 1], [0, 0], [2, 2]]) == 2.8284271247461903\n assert candidate(positions = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]]) == 0.0\n assert candidate(positions = [[0, 0], [0, 100], [100, 0], [100, 100]]) == 282.842712474619\n assert candidate(positions = [[10, 20], [20, 30], [30, 40]]) == 28.284271247461902\n assert candidate(positions = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 8.485281374238571\n assert candidate(positions = [[50, 50], [40, 40], [30, 30], [20, 20], [10, 10]]) == 84.8528137423857\n assert candidate(positions = [[2, 3], [3, 4], [4, 5], [5, 6]]) == 5.65685424949238\n assert candidate(positions = [[10, 10], [20, 20], [30, 30], [40, 40]]) == 56.568542494923804\n assert candidate(positions = [[10, 10], [10, 20], [10, 30], [10, 40], [10, 50], [10, 60], [10, 70], [10, 80], [10, 90], [10, 100]]) == 250.0\n assert candidate(positions = [[10, 20], [20, 10], [30, 40], [40, 30], [50, 50]]) == 92.03629479406317\n assert candidate(positions = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [0, 0]]) == 424.26406871192853\n assert candidate(positions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 35.35533905932737\n assert candidate(positions = [[0, 0], [100, 100], [20, 50], [80, 50], [50, 20], [50, 80], [30, 30], [70, 70], [40, 40], [60, 60]]) == 346.2741699796952\n assert candidate(positions = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100], [10, 90], [90, 10], [50, 50], [25, 75], [75, 25]]) == 364.54949915148427\n assert candidate(positions = [[5, 0], [0, 5], [5, 10], [10, 5], [0, 0], [10, 10]]) == 34.14213562373095\n assert candidate(positions = [[1, 99], [2, 98], [3, 97], [4, 96], [5, 95], [96, 5], [97, 4], [98, 3], [99, 2], [100, 1]]) == 668.2252698115078\n assert candidate(positions = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55], [55, 60], [60, 65], [65, 70], [70, 75], [75, 80]]) == 395.9797974644666\n assert candidate(positions = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 70.71067811865474\n assert candidate(positions = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]]) == 0.0\n assert candidate(positions = [[90, 90], [80, 80], [70, 70], [60, 60], [50, 50], [40, 40], [30, 30], [20, 20], [10, 10], [0, 0]]) == 353.5533905932738\n assert candidate(positions = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20], [21, 21], [22, 22], [23, 23], [24, 24], [25, 25]]) == 220.61731573020282\n assert candidate(positions = [[10, 90], [90, 10], [50, 50], [10, 10], [90, 90]]) == 226.27416997969522\n assert candidate(positions = [[10, 10], [15, 25], [25, 30], [35, 40], [40, 50], [50, 60], [60, 70], [75, 85], [80, 90]]) == 270.02810340103866\n assert candidate(positions = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60]]) == 84.8528137423857\n assert candidate(positions = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90]]) == 282.842712474619\n assert candidate(positions = [[10, 10], [20, 25], [30, 35], [40, 50], [50, 60], [60, 65], [70, 75], [80, 85], [90, 95], [100, 100]]) == 347.5091699395884\n assert candidate(positions = [[10, 10], [10, 11], [11, 10], [11, 11], [50, 50], [50, 51], [51, 50], [51, 51], [90, 90], [90, 91], [91, 90], [91, 91]]) == 455.39444406318626\n assert candidate(positions = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == 79.19595949289332\n assert candidate(positions = [[1, 1], [1, 99], [99, 1], [99, 99], [25, 25], [25, 75], [75, 25], [75, 75], [50, 50]]) == 418.60721446243616\n assert candidate(positions = [[25, 25], [75, 25], [25, 75], [75, 75], [50, 50], [25, 50], [50, 25], [50, 75]]) == 216.42135624263756\n assert candidate(positions = [[20, 20], [20, 30], [20, 40], [20, 50], [20, 60], [20, 70], [20, 80], [20, 90], [20, 100], [20, 10]]) == 250.0\n assert candidate(positions = [[0, 0], [0, 100], [100, 0], [100, 100], [50, 50], [25, 25], [75, 75]]) == 353.5533905932738\n assert candidate(positions = [[15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65], [75, 75], [85, 85], [95, 95], [5, 5], [100, 100]]) == 417.1930016070778\n assert candidate(positions = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100], [110, 120], [130, 140], [150, 160], [170, 180], [190, 200]]) == 707.1067811865476\n assert candidate(positions = [[1, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 10]]) == 24.108834188712063\n assert candidate(positions = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]]) == 79.19595949289332\n assert candidate(positions = [[5, 5], [10, 15], [20, 25], [30, 35], [40, 45], [50, 55]]) == 123.91362113238543\n assert candidate(positions = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100], [10, 90], [90, 10]]) == 283.73687053280355\n assert candidate(positions = [[10, 50], [20, 40], [30, 30], [40, 20], [50, 10], [60, 20], [70, 30], [80, 40], [90, 50]]) == 239.52812655611027\n assert candidate(positions = [[1, 99], [50, 50], [99, 1], [99, 99], [1, 1], [0, 0]]) == 347.8965372098106\n assert candidate(positions = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 70.71067811865474\n assert candidate(positions = [[50, 0], [50, 100], [0, 50], [100, 50], [25, 25], [25, 75], [75, 25], [75, 75], [10, 10], [90, 90], [10, 90], [90, 10]]) == 567.6955262170047\n assert candidate(positions = [[1, 100], [2, 90], [3, 80], [4, 70], [5, 60], [6, 50], [7, 40], [8, 30], [9, 20], [10, 10]]) == 251.24689052802228\n assert candidate(positions = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35]]) == 84.8528137423857\n assert candidate(positions = [[2, 3], [5, 6], [8, 9], [12, 15], [16, 18], [20, 21], [25, 26], [30, 33], [35, 36], [40, 41], [45, 46], [50, 51], [55, 56], [60, 61], [65, 66]]) == 369.09298276151657\n assert candidate(positions = [[5, 5], [5, 10], [5, 15], [10, 5], [10, 10], [10, 15], [15, 5], [15, 10], [15, 15], [20, 20], [20, 30], [30, 20], [30, 30]]) == 129.78753195123062\n assert candidate(positions = [[0, 5], [0, 10], [0, 15], [0, 20], [0, 25], [0, 30], [0, 35], [0, 40], [0, 45], [0, 50]]) == 125.0\n assert candidate(positions = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 42.42640687119285\n assert candidate(positions = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90]]) == 226.27416997969522\n assert candidate(positions = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 90], [90, 80], [80, 70], [70, 60], [60, 50], [50, 40], [40, 30], [30, 20], [20, 10]]) == 594.0883170846846\n assert candidate(positions = [[0, 0], [0, 100], [100, 0], [100, 100], [50, 50], [25, 25], [75, 75], [25, 75], [75, 25]]) == 424.26406871192853\n assert candidate(positions = [[1, 99], [99, 1], [49, 50], [50, 49], [50, 50], [25, 25], [75, 75]]) == 211.23672778921815\n assert candidate(positions = [[25, 25], [25, 75], [75, 25], [75, 75], [50, 50]]) == 141.4213562373095\n assert candidate(positions = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45], [50, 50], [55, 55], [60, 60], [65, 65], [70, 70], [75, 75], [80, 80], [85, 85], [90, 90], [95, 95], [100, 100]]) == 707.1067811865476\n assert candidate(positions = [[10, 5], [20, 30], [50, 20], [30, 10], [70, 60], [80, 90]]) == 207.8396049492494\n assert candidate(positions = [[10, 90], [20, 80], [30, 70], [40, 60], [50, 50], [60, 40], [70, 30], [80, 20], [90, 10]]) == 282.842712474619\n assert candidate(positions = [[0, 0], [0, 100], [100, 0], [100, 100], [50, 50], [25, 25], [75, 75], [25, 75], [75, 25], [50, 25]]) == 449.2640687173813\n assert candidate(positions = [[0, 0], [100, 100], [0, 100], [100, 0], [50, 50], [25, 25], [75, 75], [25, 75], [75, 25], [40, 40], [60, 60], [60, 40], [40, 60]]) == 480.83261120685233\n assert candidate(positions = [[10, 10], [90, 90], [10, 90], [90, 10], [50, 50], [25, 25], [75, 75], [30, 30], [70, 70], [40, 40], [60, 60]]) == 381.8376618407357\n assert candidate(positions = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [10, 50], [50, 10], [25, 25], [35, 35], [45, 45]]) == 176.7766958145084\n assert candidate(positions = [[10, 30], [20, 20], [30, 10], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90]]) == 287.4326185352413\n assert candidate(positions = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 35.35533905932737\n assert candidate(positions = [[10, 50], [20, 40], [30, 30], [40, 20], [50, 10], [60, 20], [70, 30], [80, 40], [90, 50]]) == 239.52812655611027\n assert candidate(positions = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20]]) == 90.50966799187809\n assert candidate(positions = [[1, 1], [1, 99], [99, 1], [99, 99], [50, 50], [20, 20], [80, 80], [30, 30], [70, 70], [40, 40], [60, 60]]) == 446.89148570989806\n assert candidate(positions = [[0, 0], [100, 0], [50, 50], [0, 100], [100, 100], [25, 75], [75, 25]]) == 353.5533905932738\n assert candidate(positions = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [4, 4], [4, 5], [4, 6], [5, 4], [5, 5], [5, 6], [6, 4], [6, 5], [6, 6]]) == 40.91242019857078\n assert candidate(positions = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [0, 0], [100, 100]]) == 424.26406871192853\n assert candidate(positions = [[10, 20], [20, 10], [30, 40], [40, 30], [50, 10], [10, 50], [30, 20], [20, 30], [40, 20], [30, 10]]) == 160.8040760315738\n assert candidate(positions = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]]) == 169.7056274847714\n assert candidate(positions = [[0, 0], [100, 100], [50, 50], [30, 70], [70, 30], [20, 20], [80, 80]]) == 282.842712474619\n assert candidate(positions = [[10, 50], [20, 50], [30, 50], [40, 50], [50, 50], [60, 50], [70, 50], [80, 50], [90, 50]]) == 200.0\n assert candidate(positions = [[20, 20], [40, 40], [60, 60], [80, 80], [10, 10], [30, 30], [50, 50], [70, 70], [90, 90]]) == 282.842712474619\n assert candidate(positions = [[5, 0], [10, 0], [15, 0], [20, 0], [25, 0], [30, 0], [35, 0], [40, 0], [45, 0], [50, 0]]) == 125.0\n assert candidate(positions = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45], [50, 50]]) == 176.7766952966369\n assert candidate(positions = [[20, 20], [21, 21], [22, 22], [23, 23], [24, 24], [30, 30], [31, 31], [32, 32], [33, 33], [34, 34]]) == 70.71067811865476\n assert candidate(positions = [[25, 25], [50, 50], [75, 75], [25, 75], [75, 25], [50, 25], [50, 75], [25, 50], [75, 50]]) == 241.4213562373095\n assert candidate(positions = [[1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 36.909588067414894\n assert candidate(positions = [[0, 0], [50, 0], [0, 50], [50, 50], [25, 25], [10, 10], [40, 40], [30, 30], [20, 20], [15, 15]]) == 212.13203493359106\n assert candidate(positions = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28], [29, 30], [31, 32], [33, 34], [35, 36], [37, 38], [39, 40]]) == 282.842712474619\n assert candidate(positions = [[1, 1], [1, 99], [99, 1], [99, 99]]) == 277.18585822512665\n assert candidate(positions = [[0, 0], [25, 25], [50, 50], [75, 75], [100, 100], [0, 100], [100, 0], [50, 0], [0, 50], [100, 50], [50, 100]]) == 553.5533905932738\n assert candidate(positions = [[1, 1], [10, 1], [1, 10], [10, 10], [5, 5], [2, 2], [8, 8], [3, 3], [7, 7], [4, 4], [6, 6]]) == 42.504733973998164\n assert candidate(positions = [[10, 10], [10, 10], [10, 10], [90, 90], [90, 90], [90, 90], [50, 50], [50, 50], [50, 50], [50, 50]]) == 339.4112549695428\n assert candidate(positions = [[5, 10], [10, 5], [15, 10], [10, 15], [5, 20], [20, 5], [25, 10], [10, 25], [15, 20], [20, 15]]) == 84.7585594020777\n assert candidate(positions = [[1, 1], [2, 3], [3, 1], [4, 5], [5, 3], [6, 7], [7, 5], [8, 9], [9, 7], [10, 11]]) == 38.13182008152135\n assert candidate(positions = [[90, 10], [10, 90], [50, 50], [40, 60], [60, 40], [20, 80], [80, 20]]) == 226.27416997969522\n assert candidate(positions = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35]]) == 84.8528137423857\n assert candidate(positions = [[10, 50], [50, 10], [50, 50], [90, 50], [50, 90], [5, 5], [95, 95], [5, 95], [95, 5], [50, 25]]) == 439.5584412326267\n assert candidate(positions = [[0, 0], [100, 100], [50, 50], [75, 25], [25, 75], [0, 100], [100, 0], [50, 100], [100, 50], [50, 0]]) == 503.55339096524574\n"}, "metadata": {"canonical_parameter_names": ["positions"], "leetcode_dataset_entry_point": "Solution().getMinDistSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "double getMinDistSum(vector>& positions) {", "container": "Solution", "callable": "getMinDistSum", "parameters": [{"name": "positions", "type": "vector>&"}], "return_type": "double", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1518, "task_id": "water-bottles", "difficulty": "Easy", "problem_description": "There are numBottles water bottles that are initially full of water. You can exchange numExchange empty water bottles from the market with one full water bottle.\nThe operation of drinking a full water bottle turns it into an empty bottle.\nGiven the two integers numBottles and numExchange, return the maximum number of water bottles you can drink.\n \nExample 1:\n\n\nInput: numBottles = 9, numExchange = 3\nOutput: 13\nExplanation: You can exchange 3 empty bottles to get 1 full water bottle.\nNumber of water bottles you can drink: 9 + 3 + 1 = 13.\n\nExample 2:\n\n\nInput: numBottles = 15, numExchange = 4\nOutput: 19\nExplanation: You can exchange 4 empty bottles to get 1 full water bottle. \nNumber of water bottles you can drink: 15 + 3 + 1 = 19.\n\n \nConstraints:\n\n1 <= numBottles <= 100\n2 <= numExchange <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(numBottles = 10,numExchange = 2) == 19\n assert candidate(numBottles = 20,numExchange = 6) == 23\n assert candidate(numBottles = 100,numExchange = 10) == 111\n assert candidate(numBottles = 5,numExchange = 5) == 6\n assert candidate(numBottles = 15,numExchange = 4) == 19\n assert candidate(numBottles = 100,numExchange = 2) == 199\n assert candidate(numBottles = 9,numExchange = 3) == 13\n assert candidate(numBottles = 99,numExchange = 2) == 197\n assert candidate(numBottles = 98,numExchange = 14) == 105\n assert candidate(numBottles = 75,numExchange = 9) == 84\n assert candidate(numBottles = 80,numExchange = 10) == 88\n assert candidate(numBottles = 60,numExchange = 10) == 66\n assert candidate(numBottles = 30,numExchange = 15) == 32\n assert candidate(numBottles = 60,numExchange = 8) == 68\n assert candidate(numBottles = 85,numExchange = 3) == 127\n assert candidate(numBottles = 33,numExchange = 33) == 34\n assert candidate(numBottles = 80,numExchange = 7) == 93\n assert candidate(numBottles = 50,numExchange = 5) == 62\n assert candidate(numBottles = 77,numExchange = 14) == 82\n assert candidate(numBottles = 55,numExchange = 9) == 61\n assert candidate(numBottles = 80,numExchange = 12) == 87\n assert candidate(numBottles = 45,numExchange = 12) == 49\n assert candidate(numBottles = 72,numExchange = 8) == 82\n assert candidate(numBottles = 100,numExchange = 100) == 101\n assert candidate(numBottles = 25,numExchange = 11) == 27\n assert candidate(numBottles = 55,numExchange = 13) == 59\n assert candidate(numBottles = 100,numExchange = 9) == 112\n assert candidate(numBottles = 80,numExchange = 5) == 99\n assert candidate(numBottles = 25,numExchange = 3) == 37\n assert candidate(numBottles = 65,numExchange = 9) == 73\n assert candidate(numBottles = 5,numExchange = 6) == 5\n assert candidate(numBottles = 60,numExchange = 4) == 79\n assert candidate(numBottles = 45,numExchange = 9) == 50\n assert candidate(numBottles = 30,numExchange = 7) == 34\n assert candidate(numBottles = 75,numExchange = 8) == 85\n assert candidate(numBottles = 50,numExchange = 3) == 74\n assert candidate(numBottles = 55,numExchange = 11) == 60\n assert candidate(numBottles = 25,numExchange = 6) == 29\n assert candidate(numBottles = 1,numExchange = 2) == 1\n assert candidate(numBottles = 70,numExchange = 8) == 79\n assert candidate(numBottles = 30,numExchange = 4) == 39\n assert candidate(numBottles = 45,numExchange = 4) == 59\n assert candidate(numBottles = 64,numExchange = 8) == 73\n assert candidate(numBottles = 40,numExchange = 8) == 45\n assert candidate(numBottles = 50,numExchange = 7) == 58\n assert candidate(numBottles = 75,numExchange = 6) == 89\n assert candidate(numBottles = 99,numExchange = 9) == 111\n assert candidate(numBottles = 70,numExchange = 9) == 78\n assert candidate(numBottles = 99,numExchange = 7) == 115\n assert candidate(numBottles = 85,numExchange = 5) == 106\n assert candidate(numBottles = 81,numExchange = 9) == 91\n assert candidate(numBottles = 99,numExchange = 10) == 109\n assert candidate(numBottles = 88,numExchange = 11) == 96\n assert candidate(numBottles = 60,numExchange = 11) == 65\n assert candidate(numBottles = 60,numExchange = 12) == 65\n assert candidate(numBottles = 77,numExchange = 13) == 83\n assert candidate(numBottles = 45,numExchange = 7) == 52\n assert candidate(numBottles = 99,numExchange = 3) == 148\n assert candidate(numBottles = 65,numExchange = 15) == 69\n assert candidate(numBottles = 33,numExchange = 11) == 36\n assert candidate(numBottles = 45,numExchange = 3) == 67\n assert candidate(numBottles = 40,numExchange = 13) == 43\n assert candidate(numBottles = 99,numExchange = 5) == 123\n assert candidate(numBottles = 100,numExchange = 11) == 109\n assert candidate(numBottles = 90,numExchange = 6) == 107\n assert candidate(numBottles = 75,numExchange = 12) == 81\n assert candidate(numBottles = 30,numExchange = 6) == 35\n assert candidate(numBottles = 100,numExchange = 5) == 124\n assert candidate(numBottles = 40,numExchange = 15) == 42\n assert candidate(numBottles = 65,numExchange = 13) == 70\n assert candidate(numBottles = 90,numExchange = 4) == 119\n assert candidate(numBottles = 50,numExchange = 10) == 55\n assert candidate(numBottles = 80,numExchange = 4) == 106\n"}, "metadata": {"canonical_parameter_names": ["numBottles", "numExchange"], "leetcode_dataset_entry_point": "Solution().numWaterBottles", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numWaterBottles(int numBottles, int numExchange) {", "container": "Solution", "callable": "numWaterBottles", "parameters": [{"name": "numBottles", "type": "int"}, {"name": "numExchange", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1519, "task_id": "number-of-nodes-in-the-sub-tree-with-the-same-label", "difficulty": "Medium", "problem_description": "You are given a tree (i.e. a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. The root of the tree is the node 0, and each node of the tree has a label which is a lower-case character given in the string labels (i.e. The node with the number i has the label labels[i]).\nThe edges array is given on the form edges[i] = [ai, bi], which means there is an edge between nodes ai and bi in the tree.\nReturn an array of size n where ans[i] is the number of nodes in the subtree of the ith node which have the same label as node i.\nA subtree of a tree T is the tree consisting of a node in T and all of its descendant nodes.\n \nExample 1:\n\n\nInput: n = 7, edges = [[0,1],[0,2],[1,4],[1,5],[2,3],[2,6]], labels = \"abaedcd\"\nOutput: [2,1,1,1,1,1,1]\nExplanation: Node 0 has label 'a' and its sub-tree has node 2 with label 'a' as well, thus the answer is 2. Notice that any node is part of its sub-tree.\nNode 1 has a label 'b'. The sub-tree of node 1 contains nodes 1,4 and 5, as nodes 4 and 5 have different labels than node 1, the answer is just 1 (the node itself).\n\nExample 2:\n\n\nInput: n = 4, edges = [[0,1],[1,2],[0,3]], labels = \"bbbb\"\nOutput: [4,2,1,1]\nExplanation: The sub-tree of node 2 contains only node 2, so the answer is 1.\nThe sub-tree of node 3 contains only node 3, so the answer is 1.\nThe sub-tree of node 1 contains nodes 1 and 2, both have label 'b', thus the answer is 2.\nThe sub-tree of node 0 contains nodes 0, 1, 2 and 3, all with label 'b', thus the answer is 4.\n\nExample 3:\n\n\nInput: n = 5, edges = [[0,1],[0,2],[1,3],[0,4]], labels = \"aabab\"\nOutput: [3,2,1,1,1]\n\n \nConstraints:\n\n1 <= n <= 105\nedges.length == n - 1\nedges[i].length == 2\n0 <= ai, bi < n\nai != bi\nlabels.length == n\nlabels is consisting of only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,edges = [[0, 1], [1, 2], [0, 3]],labels = \"bbbb\") == [4, 2, 1, 1]\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],labels = \"cbabaa\") == [1, 2, 2, 1, 1, 1]\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5]],labels = \"cbabac\") == [2, 2, 1, 1, 1, 1]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],labels = \"aadbdbdbaa\") == [4, 3, 2, 2, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 3,edges = [[0, 1], [0, 2]],labels = \"aaa\") == [3, 1, 1]\n assert candidate(n = 5,edges = [[0, 1], [0, 2], [1, 3], [0, 4]],labels = \"aabab\") == [3, 2, 1, 1, 1]\n assert candidate(n = 7,edges = [[0, 1], [0, 2], [1, 4], [1, 5], [2, 3], [2, 6]],labels = \"abaedcd\") == [2, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]],labels = \"aebabacd\") == [3, 1, 2, 1, 1, 1, 1, 1]\n assert candidate(n = 1,edges = [],labels = \"a\") == [1]\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],labels = \"abacabadabacaba\") == [8, 2, 4, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19]],labels = \"aabbccddeeffgghhiijj\") == [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 26,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [7, 19], [8, 20], [9, 21], [10, 22], [11, 23], [12, 24], [13, 25]],labels = \"abcdefghijklmnopqrstuvwxyz\") == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 30,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [4, 15], [5, 16], [5, 17], [6, 18], [6, 19], [7, 20], [7, 21], [8, 22], [8, 23], [9, 24], [9, 25], [10, 26], [10, 27], [11, 28], [11, 29]],labels = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 30,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 16], [9, 17], [10, 18], [11, 19], [12, 20], [12, 21], [13, 22], [13, 23], [14, 24], [14, 25], [15, 26], [15, 27], [16, 28], [16, 29]],labels = \"ababababababababababababababababab\") == [15, 8, 7, 5, 3, 4, 4, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]],labels = \"abcabcabcabcabcabcabcabcabcabc\") == [7, 6, 4, 3, 3, 2, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],labels = \"abcdefghij\") == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 100,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [7, 19], [7, 20], [8, 21], [8, 22], [9, 23], [9, 24], [10, 25], [10, 26], [11, 27], [11, 28], [12, 29], [12, 30], [13, 31], [13, 32], [14, 33], [14, 34], [15, 35], [15, 36], [16, 37], [16, 38], [17, 39], [17, 40], [18, 41], [18, 42], [19, 43], [19, 44], [20, 45], [20, 46], [21, 47], [21, 48], [22, 49], [22, 50], [23, 51], [23, 52], [24, 53], [24, 54], [25, 55], [25, 56], [26, 57], [26, 58], [27, 59], [27, 60], [28, 61], [28, 62], [29, 63], [29, 64], [30, 65], [30, 66], [31, 67], [31, 68], [32, 69], [32, 70], [33, 71], [33, 72], [34, 73], [34, 74], [35, 75], [35, 76], [36, 77], [36, 78], [37, 79], [37, 80], [38, 81], [38, 82], [39, 83], [39, 84], [40, 85], [40, 86], [41, 87], [41, 88], [42, 89], [42, 90], [43, 91], [43, 92], [44, 93], [44, 94], [45, 95], [45, 96], [46, 97], [46, 98], [47, 99]],labels = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == [4, 2, 2, 3, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 40,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30], [15, 31], [15, 32], [16, 33], [16, 34], [17, 35], [17, 36], [18, 37], [18, 38], [19, 39]],labels = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefgh\") == [2, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 21,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [7, 19], [8, 20]],labels = \"ababababababababababa\") == [11, 5, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 30,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [10, 23], [11, 24], [11, 25], [12, 26], [12, 27], [13, 28], [13, 29]],labels = \"bababbababababababababababababab\") == [16, 7, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19]],labels = \"bbbbbbbbbbbbbbbbbbbb\") == [20, 7, 7, 5, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 30,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [7, 19], [8, 20], [9, 21], [10, 22], [11, 23], [12, 24], [13, 25], [14, 26], [15, 27], [16, 28], [17, 29]],labels = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == [2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],labels = \"abcdefghij\") == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 100,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 25], [2, 26], [2, 27], [2, 28], [2, 29], [3, 30], [3, 31], [3, 32], [3, 33], [3, 34], [3, 35], [3, 36], [3, 37], [3, 38], [3, 39], [4, 40], [4, 41], [4, 42], [4, 43], [4, 44], [4, 45], [4, 46], [4, 47], [4, 48], [4, 49], [5, 50], [5, 51], [5, 52], [5, 53], [5, 54], [5, 55], [5, 56], [5, 57], [5, 58], [5, 59], [6, 60], [6, 61], [6, 62], [6, 63], [6, 64], [6, 65], [6, 66], [6, 67], [6, 68], [6, 69], [7, 70], [7, 71], [7, 72], [7, 73], [7, 74], [7, 75], [7, 76], [7, 77], [7, 78], [7, 79], [8, 80], [8, 81], [8, 82], [8, 83], [8, 84], [8, 85], [8, 86], [8, 87], [8, 88], [8, 89], [9, 90], [9, 91], [9, 92], [9, 93], [9, 94], [9, 95], [9, 96], [9, 97], [9, 98], [9, 99]],labels = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == [4, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14]],labels = \"bababbababababa\") == [8, 2, 3, 3, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 40,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [1, 7], [2, 8], [2, 9], [2, 10], [3, 11], [3, 12], [3, 13], [4, 14], [4, 15], [4, 16], [4, 17], [5, 18], [5, 19], [6, 20], [6, 21], [6, 22], [7, 23], [7, 24], [8, 25], [8, 26], [8, 27], [9, 28], [9, 29], [10, 30], [10, 31], [11, 32], [11, 33], [11, 34], [12, 35], [12, 36], [13, 37], [13, 38], [13, 39]],labels = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == [40, 11, 11, 12, 5, 3, 4, 3, 4, 3, 3, 4, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 25,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11], [4, 12], [5, 13], [5, 14], [6, 15], [6, 16], [7, 17], [7, 18], [8, 19], [8, 20], [9, 21], [10, 22], [10, 23], [11, 24]],labels = \"abcdefghijklmnopqrstuvwxyzabcde\") == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 30,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29]],labels = \"abcdefghijklmnopqrstuvwxyzabcde\") == [2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 30,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [5, 15], [5, 16], [6, 17], [6, 18], [7, 19], [7, 20], [8, 21], [8, 22], [9, 23], [9, 24], [10, 25], [10, 26], [11, 27], [11, 28], [12, 29]],labels = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == [2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14]],labels = \"abcabcabcabcabc\") == [5, 4, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [3, 8], [4, 9]],labels = \"aaaaaaaaaa\") == [10, 3, 2, 2, 2, 1, 1, 1, 1, 1]\n assert candidate(n = 50,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11], [4, 12], [5, 13], [5, 14], [6, 15], [6, 16], [7, 17], [7, 18], [8, 19], [8, 20], [9, 21], [9, 22], [10, 23], [10, 24], [11, 25], [11, 26], [12, 27], [12, 28], [13, 29], [13, 30], [14, 31], [14, 32], [15, 33], [15, 34], [16, 35], [16, 36], [17, 37], [17, 38], [18, 39], [18, 40], [19, 41], [19, 42], [20, 43], [20, 44], [21, 45], [21, 46], [22, 47], [22, 48], [23, 49]],labels = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 26,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [10, 23], [11, 24], [11, 25]],labels = \"abcdefghijklmnopqrstuvwxyz\") == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 26,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25]],labels = \"abcdefghijklmnopqrstuvwxyz\") == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 100,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11], [4, 12], [5, 13], [5, 14], [6, 15], [6, 16], [7, 17], [7, 18], [8, 19], [8, 20], [9, 21], [9, 22], [10, 23], [10, 24], [11, 25], [11, 26], [12, 27], [12, 28], [13, 29], [13, 30], [14, 31], [14, 32], [15, 33], [15, 34], [16, 35], [16, 36], [17, 37], [17, 38], [18, 39], [18, 40], [19, 41], [19, 42], [20, 43], [20, 44], [21, 45], [21, 46], [22, 47], [22, 48], [23, 49], [23, 50], [24, 51], [24, 52], [25, 53], [25, 54], [26, 55], [26, 56], [27, 57], [27, 58], [28, 59], [28, 60], [29, 61], [29, 62], [30, 63], [30, 64], [31, 65], [31, 66], [32, 67], [32, 68], [33, 69], [33, 70], [34, 71], [34, 72], [35, 73], [35, 74], [36, 75], [36, 76], [37, 77], [37, 78], [38, 79], [38, 80], [39, 81], [39, 82], [40, 83], [40, 84], [41, 85], [41, 86], [42, 87], [42, 88], [43, 89], [43, 90], [44, 91], [44, 92], [45, 93], [45, 94], [46, 95], [46, 96], [47, 97], [47, 98], [48, 99]],labels = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == [50, 9, 16, 3, 8, 5, 8, 3, 8, 5, 4, 1, 4, 3, 4, 2, 4, 3, 4, 1, 4, 3, 3, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 27,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26]],labels = \"abcdefghijklmnopqrstuvwxyzabcdef\") == [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 16,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15]],labels = \"aabbccddeeffgghh\") == [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 16], [9, 17], [10, 18], [11, 19]],labels = \"aaaaaaaaaabbbbbbbbbb\") == [10, 6, 3, 3, 2, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 40,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [1, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [4, 15], [5, 16], [5, 17], [5, 18], [6, 19], [6, 20], [6, 21], [7, 22], [7, 23], [7, 24], [8, 25], [8, 26], [8, 27], [9, 28], [9, 29], [9, 30], [10, 31], [10, 32], [10, 33], [11, 34], [11, 35], [11, 36], [12, 37], [12, 38], [12, 39]],labels = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == [40, 13, 13, 13, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19]],labels = \"abababababababababab\") == [10, 4, 4, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 30,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29]],labels = \"cccccccccccccccccccccccccccccc\") == [30, 15, 14, 7, 7, 7, 6, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19]],labels = \"aaaaaaaaaaaaaaaaaaaa\") == [20, 7, 7, 5, 3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 18,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 16], [8, 17]],labels = \"abcdefghijklmnopqr\") == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(n = 27,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26]],labels = \"abcdefghijklmnopqrstuvwxyzabc\") == [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n"}, "metadata": {"canonical_parameter_names": ["n", "edges", "labels"], "leetcode_dataset_entry_point": "Solution().countSubTrees", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector countSubTrees(int n, vector>& edges, string labels) {", "container": "Solution", "callable": "countSubTrees", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "vector>&"}, {"name": "labels", "type": "string"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1520, "task_id": "maximum-number-of-non-overlapping-substrings", "difficulty": "Hard", "problem_description": "Given a string s of lowercase letters, you need to find the maximum number of non-empty substrings of s that meet the following conditions:\n\nThe substrings do not overlap, that is for any two substrings s[i..j] and s[x..y], either j < x or i > y is true.\nA substring that contains a certain character c must also contain all occurrences of c.\n\nFind the maximum number of substrings that meet the above conditions. If there are multiple solutions with the same number of substrings, return the one with minimum total length. It can be shown that there exists a unique solution of minimum total length.\nNotice that you can return the substrings in any order.\n \nExample 1:\n\nInput: s = \"adefaddaccc\"\nOutput: [\"e\",\"f\",\"ccc\"]\nExplanation: The following are all the possible substrings that meet the conditions:\n[\n  \"adefaddaccc\"\n  \"adefadda\",\n  \"ef\",\n  \"e\",\n \"f\",\n  \"ccc\",\n]\nIf we choose the first string, we cannot choose anything else and we'd get only 1. If we choose \"adefadda\", we are left with \"ccc\" which is the only one that doesn't overlap, thus obtaining 2 substrings. Notice also, that it's not optimal to choose \"ef\" since it can be split into two. Therefore, the optimal way is to choose [\"e\",\"f\",\"ccc\"] which gives us 3 substrings. No other solution of the same number of substrings exist.\n\nExample 2:\n\nInput: s = \"abbaccd\"\nOutput: [\"d\",\"bb\",\"cc\"]\nExplanation: Notice that while the set of substrings [\"d\",\"abba\",\"cc\"] also has length 3, it's considered incorrect since it has larger total length.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns contains only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"zazbzczdzezfzgzhzi\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']\n assert candidate(s = \"aabbccaaaabbbbcccc\") == ['aabbccaaaabbbbcccc']\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz']\n assert candidate(s = \"abcdcba\") == ['d']\n assert candidate(s = \"aaaabaaaabaaaabaaaabaaaa\") == ['aaaabaaaabaaaabaaaabaaaa']\n assert candidate(s = \"abababab\") == ['abababab']\n assert candidate(s = \"aaaaa\") == ['aaaaa']\n assert candidate(s = \"zzzzzzz\") == ['zzzzzzz']\n assert candidate(s = \"abcdaabcdabdcabc\") == ['abcdaabcdabdcabc']\n assert candidate(s = \"abcabcabc\") == ['abcabcabc']\n assert candidate(s = \"adefaddaccc\") == ['e', 'f', 'ccc']\n assert candidate(s = \"abcde\") == ['a', 'b', 'c', 'd', 'e']\n assert candidate(s = \"aaa\") == ['aaa']\n assert candidate(s = \"abcdabcdeabcd\") == ['e']\n assert candidate(s = \"xyz\") == ['x', 'y', 'z']\n assert candidate(s = \"ababababa\") == ['ababababa']\n assert candidate(s = \"xyzxyzxyz\") == ['xyzxyzxyz']\n assert candidate(s = \"mnopqrstuvmnopqrstuvmnopqrstuv\") == ['mnopqrstuvmnopqrstuvmnopqrstuv']\n assert candidate(s = \"zzzzzzzzzz\") == ['zzzzzzzzzz']\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == ['zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz']\n assert candidate(s = \"cacaca\") == ['cacaca']\n assert candidate(s = \"abbaccd\") == ['bb', 'cc', 'd']\n assert candidate(s = \"zzzzyzxyz\") == ['x']\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zz']\n assert candidate(s = \"abcdefg\") == ['a', 'b', 'c', 'd', 'e', 'f', 'g']\n assert candidate(s = \"aaaaaaaaaaabbbbbbbbbbccccccccccdddddddddeeeeeeeeeeffffffffffgggggggggg\") == ['aaaaaaaaaaa', 'bbbbbbbbbb', 'cccccccccc', 'ddddddddd', 'eeeeeeeeee', 'ffffffffff', 'gggggggggg']\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == ['abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc']\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == ['abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc']\n assert candidate(s = \"aaaabbbbccccaaaabbbbccccaaaabbbbccccaaaabbbbccccaaaabbbbcccc\") == ['aaaabbbbccccaaaabbbbccccaaaabbbbccccaaaabbbbccccaaaabbbbcccc']\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == ['abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd']\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == ['abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc']\n assert candidate(s = \"zzzzzyyyyyxxxxwwwwvvvuuutttsssrqqppoonnnmmlkkjjiihhggffeedcba\") == ['zzzzz', 'yyyyy', 'xxxx', 'wwww', 'vvv', 'uuu', 'ttt', 'sss', 'r', 'qq', 'pp', 'oo', 'nnn', 'mm', 'l', 'kk', 'jj', 'ii', 'hh', 'gg', 'ff', 'ee', 'd', 'c', 'b', 'a']\n assert candidate(s = \"mnopqrstuvwxyzyxwvutsrqponmlkjihgfedcbamnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == ['mnopqrstuvwxyzyxwvutsrqponmlkjihgfedcbamnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba']\n assert candidate(s = \"abracadabraacadabra\") == ['abracadabraacadabra']\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == ['abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz']\n assert candidate(s = \"abacabadabcabaabacabadabcaba\") == ['abacabadabcabaabacabadabcaba']\n assert candidate(s = \"abacabadabcabaabacabadabcabaabacabadabcabaabacabadabcabaabacabadabcabaabacabadabcaba\") == ['abacabadabcabaabacabadabcabaabacabadabcabaabacabadabcabaabacabadabcabaabacabadabcaba']\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\") == ['aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb']\n assert candidate(s = \"mnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuv\") == ['mnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuv']\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababababababababababab\") == ['abababababababababababababababababababababababababababababababababababababababababababababababab']\n assert candidate(s = \"abcabcabcabcabcabcabcabc\") == ['abcabcabcabcabcabcabcabc']\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == ['zz']\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == ['abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz']\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == ['zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz']\n assert candidate(s = \"abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef\") == ['abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef']\n assert candidate(s = \"aababbabacabcabcadabcdeabcdeafaghafaiabakabalacamadanaeafaagaagaa\") == ['h', 'i', 'k', 'l', 'm', 'n']\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == ['xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz']\n assert candidate(s = \"aabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeff\") == ['aabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeffaabbccddeeff']\n assert candidate(s = \"aaaaaabbbbbccccdddddeeeee\") == ['aaaaaa', 'bbbbb', 'cccc', 'ddddd', 'eeeee']\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == ['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa']\n assert candidate(s = \"aaaaaaaaaabbbbbbbbccccccccddddddddeeeeeeeeffffffffgggggggghhhhhhhhiiiiiiiiijjjjjjjjkkkkkkkkkllllllllmmmmmmmmnnnnnnnnooooooooppppppppqqqqqqqqrrrrrrrrssssssssttttttttuuuuuuuuvvvvvvvvwwwwwwwwwxxxxxxxxxyyyyyyyyyzzzzzzzzz\") == ['aaaaaaaaaa', 'bbbbbbbb', 'cccccccc', 'dddddddd', 'eeeeeeee', 'ffffffff', 'gggggggg', 'hhhhhhhh', 'iiiiiiiii', 'jjjjjjjj', 'kkkkkkkkk', 'llllllll', 'mmmmmmmm', 'nnnnnnnn', 'oooooooo', 'pppppppp', 'qqqqqqqq', 'rrrrrrrr', 'ssssssss', 'tttttttt', 'uuuuuuuu', 'vvvvvvvv', 'wwwwwwwww', 'xxxxxxxxx', 'yyyyyyyyy', 'zzzzzzzzz']\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh', 'ii', 'jj', 'kk', 'll', 'mm', 'nn', 'oo', 'pp', 'qq', 'rr', 'ss', 'tt', 'uu', 'vv', 'ww', 'xx', 'yy', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz']\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyz\") == ['aa']\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == ['xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz']\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == ['zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz']\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == ['abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd']\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabad\") == ['abacabadabacabadabacabadabacabadabacabadabacabad']\n assert candidate(s = \"zzzzzyyyyyxxxxwwwwvvvvuuuuttttssssrrrrqqqqpppplllloooonnnnmmmm\") == ['zzzzz', 'yyyyy', 'xxxx', 'wwww', 'vvvv', 'uuuu', 'tttt', 'ssss', 'rrrr', 'qqqq', 'pppp', 'llll', 'oooo', 'nnnn', 'mmmm']\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxNumOfSubstrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector maxNumOfSubstrings(string s) {", "container": "Solution", "callable": "maxNumOfSubstrings", "parameters": [{"name": "s", "type": "string"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1521, "task_id": "find-a-value-of-a-mysterious-function-closest-to-target", "difficulty": "Hard", "problem_description": "\nWinston was given the above mysterious function func. He has an integer array arr and an integer target and he wants to find the values l and r that make the value |func(arr, l, r) - target| minimum possible.\nReturn the minimum possible value of |func(arr, l, r) - target|.\nNotice that func should be called with the values l and r where 0 <= l, r < arr.length.\n \nExample 1:\n\nInput: arr = [9,12,3,7,15], target = 5\nOutput: 2\nExplanation: Calling func with all the pairs of [l,r] = [[0,0],[1,1],[2,2],[3,3],[4,4],[0,1],[1,2],[2,3],[3,4],[0,2],[1,3],[2,4],[0,3],[1,4],[0,4]], Winston got the following results [9,12,3,7,15,8,0,3,7,0,0,3,0,0,0]. The value closest to 5 is 7 and 3, thus the minimum difference is 2.\n\nExample 2:\n\nInput: arr = [1000000,1000000,1000000], target = 1\nOutput: 999999\nExplanation: Winston called the func with all possible values of [l,r] and he always got 1000000, thus the min difference is 999999.\n\nExample 3:\n\nInput: arr = [1,2,4,8,16], target = 0\nOutput: 0\n\n \nConstraints:\n\n1 <= arr.length <= 105\n1 <= arr[i] <= 106\n0 <= target <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [7, 7, 7, 7, 7, 7],target = 8) == 1\n assert candidate(arr = [1000000],target = 1000000) == 0\n assert candidate(arr = [2, 4, 6, 8, 10],target = 7) == 1\n assert candidate(arr = [5, 5, 5, 5, 5],target = 5) == 0\n assert candidate(arr = [1, 1, 1, 1, 1],target = 2) == 1\n assert candidate(arr = [1, 2, 4, 8, 16],target = 0) == 0\n assert candidate(arr = [10, 20, 30, 40, 50],target = 25) == 5\n assert candidate(arr = [9, 12, 3, 7, 15],target = 5) == 2\n assert candidate(arr = [5, 5, 5, 5, 5],target = 3) == 2\n assert candidate(arr = [3, 6, 9, 12, 15],target = 13) == 1\n assert candidate(arr = [1000000, 1000000, 1000000],target = 1) == 999999\n assert candidate(arr = [2, 4, 6, 8, 10],target = 5) == 1\n assert candidate(arr = [1, 3, 5, 7, 9],target = 6) == 1\n assert candidate(arr = [10, 20, 30, 40, 50],target = 0) == 0\n assert candidate(arr = [7, 14, 21, 28, 35],target = 20) == 0\n assert candidate(arr = [3, 6, 9, 12, 15],target = 7) == 1\n assert candidate(arr = [1, 1, 1, 1, 1],target = 0) == 1\n assert candidate(arr = [10, 20, 30, 40, 50],target = 15) == 5\n assert candidate(arr = [100, 200, 300, 400, 500],target = 250) == 6\n assert candidate(arr = [2, 4, 8, 16, 32],target = 10) == 2\n assert candidate(arr = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230],target = 150) == 10\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 100) == 28\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 7) == 0\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],target = 50000) == 15536\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],target = 100) == 53\n assert candidate(arr = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180],target = 100) == 0\n assert candidate(arr = [16, 8, 4, 2, 1, 32, 16, 8, 4, 2, 1],target = 15) == 1\n assert candidate(arr = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],target = 1) == 999983\n assert candidate(arr = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],target = 500000000) == 400000000\n assert candidate(arr = [1000000, 999999, 999998, 999997, 999996, 999995],target = 1000000) == 0\n assert candidate(arr = [4294967295, 2147483647, 1073741823, 536870911, 268435455, 134217727, 67108863, 33554431, 16777215, 8388607],target = 1000000) == 7388607\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 100) == 28\n assert candidate(arr = [5, 3, 8, 12, 14, 2, 11],target = 10) == 1\n assert candidate(arr = [5, 3, 8, 6, 2, 7, 4, 1],target = 5) == 0\n assert candidate(arr = [9, 12, 3, 7, 15, 8, 6, 4, 2, 1],target = 5) == 1\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 10) == 1\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],target = 512) == 1\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],target = 1) == 0\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767],target = 10000) == 1809\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],target = 1000) == 24\n assert candidate(arr = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61, 30, 15, 7, 3, 1],target = 100000) == 1696\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 3) == 2\n assert candidate(arr = [1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125],target = 1000000) == 609375\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56],target = 30) == 2\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40],target = 22) == 2\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],target = 1000) == 24\n assert candidate(arr = [1234567, 2345678, 3456789, 4567890, 5678901, 6789012, 7890123, 8901234, 9012345],target = 5000000) == 377900\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],target = 20) == 1\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 1000) == 24\n assert candidate(arr = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 500) == 12\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],target = 500) == 11\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21],target = 10) == 1\n assert candidate(arr = [83552, 83552, 83552, 83552, 83552, 83552, 83552, 83552],target = 50000) == 33552\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 1) == 2\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],target = 50) == 1\n assert candidate(arr = [2, 6, 14, 30, 62, 126, 254, 510, 1022, 2046],target = 1024) == 2\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],target = 5) == 2\n assert candidate(arr = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048],target = 100000) == 31072\n assert candidate(arr = [13, 23, 33, 43, 53, 63, 73, 83, 93, 103, 113, 123, 133, 143, 153],target = 75) == 2\n assert candidate(arr = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],target = 500000) == 499984\n assert candidate(arr = [111111, 222222, 333333, 444444, 555555, 666666, 777777, 888888, 999999, 1111111],target = 500000) == 24320\n assert candidate(arr = [31, 15, 7, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],target = 16) == 1\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 1) == 2\n assert candidate(arr = [1023, 1022, 1021, 1020, 1019, 1018, 1017, 1016, 1015, 1014, 1013, 1012, 1011, 1010, 1009, 1008, 1007, 1006, 1005, 1004, 1003, 1002, 1001, 1000],target = 500) == 492\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],target = 500) == 11\n assert candidate(arr = [31, 13, 7, 1, 9, 15, 8, 10, 18, 6],target = 12) == 1\n assert candidate(arr = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000],target = 5000) == 0\n assert candidate(arr = [987654, 321654, 654321, 123456, 654123, 321987, 987321, 123654, 456789, 789123],target = 500000) == 43211\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],target = 8190) == 2\n assert candidate(arr = [100000, 200000, 300000, 400000, 500000],target = 350000) == 43216\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],target = 50) == 1\n assert candidate(arr = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],target = 50000000) == 23736448\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],target = 0) == 0\n assert candidate(arr = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61, 30, 15, 7, 3, 1],target = 1000) == 24\n assert candidate(arr = [987654, 876543, 765432, 654321, 543210, 432109, 321098, 210987, 109876, 98765],target = 500000) == 24288\n assert candidate(arr = [8, 4, 2, 1, 16, 32, 64, 128, 256, 512],target = 100) == 28\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],target = 10) == 1\n assert candidate(arr = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],target = 100000) == 1696\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],target = 200) == 55\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 511) == 1\n assert candidate(arr = [123456, 654321, 111111, 222222, 333333, 444444, 555555, 666666, 777777, 888888],target = 333333) == 0\n assert candidate(arr = [31, 15, 7, 3, 1, 1, 3, 7, 15, 31, 15, 7, 3, 1, 1, 3, 7, 15, 31, 15, 7, 3, 1, 1, 3, 7, 15, 31, 15, 7, 3, 1],target = 10) == 3\n assert candidate(arr = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 100000) == 31072\n assert candidate(arr = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],target = 1000000) == 0\n assert candidate(arr = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 1000000) == 48576\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575],target = 1000000) == 48575\n assert candidate(arr = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 1023) == 1\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = 27) == 2\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],target = 4) == 3\n assert candidate(arr = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930],target = 100000) == 1112\n assert candidate(arr = [1000000, 1000000, 1000000, 1, 1, 1, 2, 3, 4, 5],target = 1000005) == 5\n assert candidate(arr = [2147483647, 2147483646, 2147483645, 2147483644, 2147483643, 2147483642, 2147483641, 2147483640],target = 2147483640) == 0\n assert candidate(arr = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31],target = 15) == 2\n assert candidate(arr = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],target = 123456789) == 23456789\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 5\n assert candidate(arr = [33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33],target = 32) == 1\n assert candidate(arr = [512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 300) == 44\n assert candidate(arr = [999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999, 999999],target = 1) == 999998\n assert candidate(arr = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],target = 3) == 3\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],target = 5) == 0\n assert candidate(arr = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],target = 10) == 2\n assert candidate(arr = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],target = 50) == 4\n assert candidate(arr = [123, 456, 789, 101, 112, 131, 44, 55, 66, 77, 88, 99],target = 200) == 56\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],target = 20) == 1\n assert candidate(arr = [2, 4, 8, 16, 32, 64, 128, 256],target = 100) == 28\n assert candidate(arr = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],target = 10) == 3\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],target = 75) == 5\n assert candidate(arr = [987654, 876543, 765432, 654321, 543210, 432109, 321098, 210987, 109876],target = 300000) == 3480\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],target = 750) == 18\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127, 255],target = 123) == 4\n assert candidate(arr = [255, 127, 63, 31, 15, 7, 3, 1],target = 10) == 3\n assert candidate(arr = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],target = 1000) == 24\n assert candidate(arr = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],target = 50) == 4\n assert candidate(arr = [1000000, 900000, 800000, 700000, 600000, 500000, 400000, 300000, 200000, 100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],target = 45000) == 4728\n assert candidate(arr = [123456, 234567, 345678, 456789, 567890, 678901, 789012, 890123, 901234, 101234],target = 400000) == 54322\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767],target = 1024) == 1\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],target = 85) == 5\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],target = 50) == 50\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 7) == 0\n"}, "metadata": {"canonical_parameter_names": ["arr", "target"], "leetcode_dataset_entry_point": "Solution().closestToTarget", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int closestToTarget(vector& arr, int target) {", "container": "Solution", "callable": "closestToTarget", "parameters": [{"name": "arr", "type": "vector&"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1523, "task_id": "count-odd-numbers-in-an-interval-range", "difficulty": "Easy", "problem_description": "Given two non-negative integers low and high. Return the count of odd numbers between low and high (inclusive).\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: low = 3, high = 7\\r\nOutput: 3\\r\nExplanation: The odd numbers between 3 and 7 are [3,5,7].\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: low = 8, high = 10\\r\nOutput: 1\\r\nExplanation: The odd numbers between 8 and 10 are [9].\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t0 <= low <= high <= 10^9\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(low = 3,high = 7) == 3\n assert candidate(low = 0,high = 1000000000) == 500000000\n assert candidate(low = 0,high = 1) == 1\n assert candidate(low = 500000000,high = 500000000) == 0\n assert candidate(low = 1,high = 1000000000) == 500000000\n assert candidate(low = 8,high = 10) == 1\n assert candidate(low = 1000000000,high = 1000000000) == 0\n assert candidate(low = 1,high = 2) == 1\n assert candidate(low = 2,high = 3) == 1\n assert candidate(low = 0,high = 0) == 0\n assert candidate(low = 2,high = 2) == 0\n assert candidate(low = 1,high = 1) == 1\n assert candidate(low = 450000000,high = 450000010) == 5\n assert candidate(low = 3,high = 5) == 2\n assert candidate(low = 16,high = 17) == 1\n assert candidate(low = 500000001,high = 1000000000) == 250000000\n assert candidate(low = 2,high = 999999999) == 499999999\n assert candidate(low = 2,high = 4) == 1\n assert candidate(low = 500000000,high = 1500000000) == 500000000\n assert candidate(low = 2,high = 1999999999) == 999999999\n assert candidate(low = 15,high = 15) == 1\n assert candidate(low = 14,high = 24) == 5\n assert candidate(low = 499999998,high = 500000002) == 2\n assert candidate(low = 234567890,high = 987654321) == 376543216\n assert candidate(low = 20,high = 29) == 5\n assert candidate(low = 100000000,high = 999999999) == 450000000\n assert candidate(low = 99,high = 101) == 2\n assert candidate(low = 1,high = 10) == 5\n assert candidate(low = 1,high = 1000000001) == 500000001\n assert candidate(low = 800000000,high = 850000000) == 25000000\n assert candidate(low = 300,high = 400) == 50\n assert candidate(low = 1000000000,high = 1000000001) == 1\n assert candidate(low = 25,high = 75) == 26\n assert candidate(low = 100,high = 200) == 50\n assert candidate(low = 123456,high = 654321) == 265433\n assert candidate(low = 500000001,high = 1500000001) == 500000001\n assert candidate(low = 1000000001,high = 9999999999) == 4500000000\n assert candidate(low = 45,high = 100) == 28\n assert candidate(low = 1,high = 999999999) == 500000000\n assert candidate(low = 1,high = 2000000000) == 1000000000\n assert candidate(low = 9,high = 11) == 2\n assert candidate(low = 8,high = 1000000008) == 500000000\n assert candidate(low = 15,high = 25) == 6\n assert candidate(low = 333333333,high = 666666666) == 166666667\n assert candidate(low = 2,high = 21) == 10\n assert candidate(low = 0,high = 2) == 1\n assert candidate(low = 25,high = 35) == 6\n assert candidate(low = 11,high = 21) == 6\n assert candidate(low = 123456789,high = 987654321) == 432098767\n assert candidate(low = 1,high = 20) == 10\n assert candidate(low = 21,high = 31) == 6\n assert candidate(low = 1000000000,high = 1000000002) == 1\n assert candidate(low = 100000001,high = 100000001) == 1\n assert candidate(low = 3,high = 1800000001) == 900000000\n assert candidate(low = 500000000,high = 500000002) == 1\n assert candidate(low = 10,high = 20) == 5\n assert candidate(low = 999999998,high = 999999999) == 1\n assert candidate(low = 5,high = 99) == 48\n assert candidate(low = 789012345,high = 789012345) == 1\n assert candidate(low = 15,high = 16) == 1\n assert candidate(low = 20,high = 30) == 5\n assert candidate(low = 1000000001,high = 2000000000) == 500000000\n assert candidate(low = 5,high = 7) == 2\n assert candidate(low = 1,high = 3) == 2\n assert candidate(low = 4,high = 1700000002) == 849999999\n assert candidate(low = 999999999,high = 1000000000) == 1\n assert candidate(low = 500,high = 1500) == 500\n assert candidate(low = 500,high = 500000005) == 249999753\n assert candidate(low = 4,high = 6) == 1\n assert candidate(low = 100000000,high = 100000010) == 5\n assert candidate(low = 12,high = 22) == 5\n assert candidate(low = 9,high = 9) == 1\n assert candidate(low = 100000000,high = 900000000) == 400000000\n assert candidate(low = 100,high = 1000) == 450\n assert candidate(low = 1000000,high = 2000000) == 500000\n assert candidate(low = 5,high = 5) == 1\n assert candidate(low = 500000001,high = 500000005) == 3\n assert candidate(low = 123456,high = 789012) == 332778\n assert candidate(low = 5,high = 500000005) == 250000001\n assert candidate(low = 1000000001,high = 1000000001) == 1\n assert candidate(low = 500,high = 600) == 50\n assert candidate(low = 888888888,high = 999999999) == 55555556\n assert candidate(low = 100000000,high = 200000000) == 50000000\n assert candidate(low = 13,high = 23) == 6\n assert candidate(low = 500000001,high = 600000000) == 50000000\n assert candidate(low = 10,high = 19) == 5\n assert candidate(low = 2000000000,high = 3000000000) == 500000000\n assert candidate(low = 500000000,high = 1000000000) == 250000000\n assert candidate(low = 999999998,high = 1000000000) == 1\n assert candidate(low = 250000000,high = 750000000) == 250000000\n assert candidate(low = 499999999,high = 500000001) == 2\n assert candidate(low = 1000000000,high = 2000000000) == 500000000\n assert candidate(low = 500000001,high = 500000001) == 1\n"}, "metadata": {"canonical_parameter_names": ["low", "high"], "leetcode_dataset_entry_point": "Solution().countOdds", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countOdds(int low, int high) {", "container": "Solution", "callable": "countOdds", "parameters": [{"name": "low", "type": "int"}, {"name": "high", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1524, "task_id": "number-of-sub-arrays-with-odd-sum", "difficulty": "Medium", "problem_description": "Given an array of integers arr, return the number of subarrays with an odd sum.\nSince the answer can be very large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: arr = [1,3,5]\nOutput: 4\nExplanation: All subarrays are [[1],[1,3],[1,3,5],[3],[3,5],[5]]\nAll sub-arrays sum are [1,4,9,3,8,5].\nOdd sums are [1,9,3,5] so the answer is 4.\n\nExample 2:\n\nInput: arr = [2,4,6]\nOutput: 0\nExplanation: All subarrays are [[2],[2,4],[2,4,6],[4],[4,6],[6]]\nAll sub-arrays sum are [2,6,12,4,10,6].\nAll sub-arrays have even sum and the answer is 0.\n\nExample 3:\n\nInput: arr = [1,2,3,4,5,6,7]\nOutput: 16\n\n \nConstraints:\n\n1 <= arr.length <= 105\n1 <= arr[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 4, 6, 8, 10]) == 0\n assert candidate(arr = [100, 100, 100, 100, 100]) == 0\n assert candidate(arr = [50, 50, 50, 50, 50]) == 0\n assert candidate(arr = [1, 2, 3]) == 4\n assert candidate(arr = [2, 2, 2, 2, 2]) == 0\n assert candidate(arr = [1, 2]) == 2\n assert candidate(arr = [99, 100, 101]) == 4\n assert candidate(arr = [100, 100, 100]) == 0\n assert candidate(arr = [2, 4, 6]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7]) == 16\n assert candidate(arr = [1]) == 1\n assert candidate(arr = [1, 1, 1, 1, 1]) == 9\n assert candidate(arr = [100, 99, 98, 97, 96]) == 8\n assert candidate(arr = [101, 102, 103, 104, 105]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5]) == 9\n assert candidate(arr = [2, 3, 4, 5, 6, 7, 8, 9, 10]) == 24\n assert candidate(arr = [2]) == 0\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4]) == 14\n assert candidate(arr = [1, 3, 5]) == 4\n assert candidate(arr = [97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78]) == 110\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 0\n assert candidate(arr = [99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1, 99, 1]) == 110\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 462\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 30\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 30\n assert candidate(arr = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == 30\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 64\n assert candidate(arr = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5]) == 30\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15]) == 20\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 30\n assert candidate(arr = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 30\n assert candidate(arr = [97, 2, 83, 4, 81, 6, 79, 8, 77, 10, 75, 12, 73, 14, 71, 16, 69, 18, 67, 20]) == 110\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 110\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 0\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 110\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 0\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 30\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 0\n assert candidate(arr = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 64\n assert candidate(arr = [99, 199, 299, 399, 499, 599, 699, 799, 899, 999]) == 30\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 0\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 63\n assert candidate(arr = [1, 3, 5, 7, 9, 11]) == 12\n assert candidate(arr = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100]) == 30\n assert candidate(arr = [97, 98, 99, 100, 1, 2, 3, 4, 5, 6]) == 30\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 30\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]) == 60\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 10\n assert candidate(arr = [50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51, 50, 51]) == 110\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 30\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 240\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 30\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 240\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]) == 28\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 240\n assert candidate(arr = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750]) == 0\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 110\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 0\n assert candidate(arr = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]) == 36\n assert candidate(arr = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == 98\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 0\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 110\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 110\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 0\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 63\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 110\n assert candidate(arr = [99, 100, 98, 97, 101, 96, 102, 95, 103, 94, 104, 93, 105, 92, 106]) == 48\n assert candidate(arr = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36]) == 64\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 30\n assert candidate(arr = [101, 201, 301, 401, 501, 601, 701, 801, 901, 1001]) == 30\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 64\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 0\n assert candidate(arr = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 110\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 0\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 64\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60]) == 0\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 310\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 52\n assert candidate(arr = [100, 99, 1, 2, 98, 3, 4, 97, 5, 6]) == 30\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 110\n assert candidate(arr = [1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21]) == 110\n assert candidate(arr = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == 110\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 420\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 15\n assert candidate(arr = [100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100]) == 0\n assert candidate(arr = [100, 50, 25, 12, 6, 3, 1, 0, 0, 0]) == 28\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().numOfSubarrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numOfSubarrays(vector& arr) {", "container": "Solution", "callable": "numOfSubarrays", "parameters": [{"name": "arr", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1525, "task_id": "number-of-good-ways-to-split-a-string", "difficulty": "Medium", "problem_description": "You are given a string s.\nA split is called good if you can split s into two non-empty strings sleft and sright where their concatenation is equal to s (i.e., sleft + sright = s) and the number of distinct letters in sleft and sright is the same.\nReturn the number of good splits you can make in s.\n \nExample 1:\n\nInput: s = \"aacaba\"\nOutput: 2\nExplanation: There are 5 ways to split \"aacaba\" and 2 of them are good. \n(\"a\", \"acaba\") Left string and right string contains 1 and 3 different letters respectively.\n(\"aa\", \"caba\") Left string and right string contains 1 and 3 different letters respectively.\n(\"aac\", \"aba\") Left string and right string contains 2 and 2 different letters respectively (good split).\n(\"aaca\", \"ba\") Left string and right string contains 2 and 2 different letters respectively (good split).\n(\"aacab\", \"a\") Left string and right string contains 3 and 1 different letters respectively.\n\nExample 2:\n\nInput: s = \"abcd\"\nOutput: 1\nExplanation: Split the string as follows (\"ab\", \"cd\").\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"xyzxyzxyz\") == 4\n assert candidate(s = \"aabbcc\") == 1\n assert candidate(s = \"abcde\") == 0\n assert candidate(s = \"abcdefghij\") == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijj\") == 1\n assert candidate(s = \"abacaba\") == 0\n assert candidate(s = \"aacaba\") == 2\n assert candidate(s = \"aabbbcc\") == 2\n assert candidate(s = \"aaa\") == 2\n assert candidate(s = \"abcd\") == 1\n assert candidate(s = \"aaaaa\") == 4\n assert candidate(s = \"xyz\") == 0\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(s = \"aabbccddeeff\") == 1\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 45\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzxywvutsrqponmlkjihgfedcba\") == 1\n assert candidate(s = \"aabacadaeafagahaiajakalalamanaoaopapaqaraasatauavaawaxayaza\") == 0\n assert candidate(s = \"ababababababababababababababababababababababababab\") == 47\n assert candidate(s = \"abacabadabacabadabacabad\") == 12\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzz\") == 1\n assert candidate(s = \"aaaaaabbccdddeeffggghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 1\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababab\") == 77\n assert candidate(s = \"nnnnaaaaccccbbbbbddddnnnnaaaaccccbbbbbdddd\") == 7\n assert candidate(s = \"thisisaverylongstringwithavarietyofcharactersandrepeatpatterns\") == 3\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 3\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\") == 27\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzqqqqqqqq\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"abbaccddeeffaabbccddeeff\") == 3\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz\") == 1\n assert candidate(s = \"abacabadabacaba\") == 0\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadab\") == 84\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 89\n assert candidate(s = \"abracadabra\") == 2\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 25\n assert candidate(s = \"pppppppppppppppppppppppppppppppppppppppppppppppp\") == 47\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 73\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyxwvutsrqponmlkjihgfedcba\") == 2\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 63\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyyxwwvvuutsrrqponmlkjihgfedcba\") == 2\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\") == 25\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyz\") == 2\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyz\") == 1\n assert candidate(s = \"mississississississippi\") == 16\n assert candidate(s = \"abcdefghihgfedcba\") == 0\n assert candidate(s = \"abracadabraabracadabraabracadabra\") == 20\n assert candidate(s = \"pppppppppppppppppppppppppppppp\") == 29\n assert candidate(s = \"11223344556677889900112233445566778899001122334455667788990011223344556677889900\") == 43\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 61\n assert candidate(s = \"mnbvcxzlkjhgfdsapoiuytrewqasdfghjklzxcvbnmmnbvcxzlkjhgfdsapoiuytrewq\") == 17\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 68\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaedcba\") == 1\n assert candidate(s = \"mississippimississippimississippimississippimississippi\") == 36\n assert candidate(s = \"bacaabacababacaacbacaaacaaacaacbaaaacaacaaacaacaaacaaacaa\") == 29\n assert candidate(s = \"abcdefghijklnmopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 77\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 51\n assert candidate(s = \"abracadabraabracadabraabracadabraabracadabraabracadabraabracadabra\") == 53\n assert candidate(s = \"abbaccddeeffaabbccddeeffaabbccddeeff\") == 15\n assert candidate(s = \"nnnnaaaaccccbbbbbdddd\") == 3\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 79\n assert candidate(s = \"mississippi\") == 4\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(s = \"aaabbbcccddd\") == 1\n assert candidate(s = \"abababababababababababababababababababababababababababa\") == 52\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 81\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcde\") == 1\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 73\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcd\") == 21\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 49\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 53\n assert candidate(s = \"aabbaabbaabbaabb\") == 11\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().numSplits", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numSplits(string s) {", "container": "Solution", "callable": "numSplits", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1526, "task_id": "minimum-number-of-increments-on-subarrays-to-form-a-target-array", "difficulty": "Hard", "problem_description": "You are given an integer array target. You have an integer array initial of the same size as target with all elements initially zeros.\nIn one operation you can choose any subarray from initial and increment each value by one.\nReturn the minimum number of operations to form a target array from initial.\nThe test cases are generated so that the answer fits in a 32-bit integer.\n \nExample 1:\n\nInput: target = [1,2,3,2,1]\nOutput: 3\nExplanation: We need at least 3 operations to form the target array from the initial array.\n[0,0,0,0,0] increment 1 from index 0 to 4 (inclusive).\n[1,1,1,1,1] increment 1 from index 1 to 3 (inclusive).\n[1,2,2,2,1] increment 1 at index 2.\n[1,2,3,2,1] target array is formed.\n\nExample 2:\n\nInput: target = [3,1,1,2]\nOutput: 4\nExplanation: [0,0,0,0] -> [1,1,1,1] -> [1,1,1,2] -> [2,1,1,2] -> [3,1,1,2]\n\nExample 3:\n\nInput: target = [3,1,5,4,2]\nOutput: 7\nExplanation: [0,0,0,0,0] -> [1,1,1,1,1] -> [2,1,1,1,1] -> [3,1,1,1,1] -> [3,1,2,2,2] -> [3,1,3,3,2] -> [3,1,4,4,2] -> [3,1,5,4,2].\n\n \nConstraints:\n\n1 <= target.length <= 105\n1 <= target[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(target = [1, 2, 3, 4, 5]) == 5\n assert candidate(target = [5, 4, 3, 2, 1]) == 5\n assert candidate(target = [100000]) == 100000\n assert candidate(target = [1, 1, 1, 1, 1]) == 1\n assert candidate(target = [1, 3, 2, 4, 5]) == 6\n assert candidate(target = [10, 10, 10, 10, 10]) == 10\n assert candidate(target = [3, 1, 5, 4, 2]) == 7\n assert candidate(target = [1, 100000, 1]) == 100000\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 5\n assert candidate(target = [3, 1, 1, 2]) == 4\n assert candidate(target = [1, 3, 5, 7, 9]) == 9\n assert candidate(target = [100000, 100000, 100000, 100000, 100000]) == 100000\n assert candidate(target = [1, 2, 3, 2, 1]) == 3\n assert candidate(target = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 5\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(target = [9, 7, 5, 3, 1]) == 9\n assert candidate(target = [1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 13\n assert candidate(target = [1, 3, 5, 7, 9, 7, 5, 3, 1]) == 9\n assert candidate(target = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(target = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1]) == 3\n assert candidate(target = [10, 10, 10, 10, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10]) == 19\n assert candidate(target = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 7\n assert candidate(target = [3, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28]) == 41\n assert candidate(target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(target = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == 4\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(target = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1]) == 10\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(target = [3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 13\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(target = [1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 1, 1]) == 5\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(target = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5]) == 10\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(target = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 14\n assert candidate(target = [5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5]) == 9\n assert candidate(target = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 6\n assert candidate(target = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 5\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 15\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 19\n assert candidate(target = [100, 50, 100, 50, 100, 50, 100, 50, 100, 50]) == 300\n assert candidate(target = [1, 2, 3, 2, 1, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1]) == 7\n assert candidate(target = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == 5\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 3, 3, 2, 2, 1, 1]) == 4\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 50, 100, 50, 100, 50]) == 200\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 30\n assert candidate(target = [5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 9\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 10\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(target = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 50\n assert candidate(target = [5, 10, 15, 20, 25, 20, 15, 10, 5]) == 25\n assert candidate(target = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(target = [10, 20, 30, 20, 10, 5, 0, 5, 10, 20, 30, 20, 10]) == 60\n assert candidate(target = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3]) == 15\n assert candidate(target = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1]) == 3\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 30\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 100\n assert candidate(target = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(target = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 13\n assert candidate(target = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(target = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 10\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 20\n assert candidate(target = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(target = [1, 2, 3, 4, 3, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 3, 4, 5, 4, 3, 2, 1]) == 13\n assert candidate(target = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(target = [5, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5]) == 10\n assert candidate(target = [2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2]) == 4\n assert candidate(target = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 11\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 11, 9, 7, 5, 3, 1]) == 13\n assert candidate(target = [3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 9\n assert candidate(target = [5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15]) == 15\n assert candidate(target = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10]) == 19\n assert candidate(target = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 7\n assert candidate(target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(target = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 11\n assert candidate(target = [10, 1, 20, 30, 40, 50, 40, 30, 20, 10]) == 59\n assert candidate(target = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 5, 6, 4, 7, 3, 8, 2, 9, 1, 10]) == 51\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 20\n assert candidate(target = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == 90\n assert candidate(target = [1, 2, 3, 2, 3, 4, 5, 4, 3, 2, 1]) == 6\n assert candidate(target = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == 4\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(target = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == 10\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(target = [1, 5, 2, 5, 1, 5, 2, 5, 1, 5, 2, 5, 1, 5, 2, 5, 1]) == 29\n assert candidate(target = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == 5\n assert candidate(target = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 46\n assert candidate(target = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 46\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 6\n assert candidate(target = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(target = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 5\n assert candidate(target = [100, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50]) == 100\n assert candidate(target = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 9\n assert candidate(target = [10, 20, 30, 40, 50, 40, 30, 20, 10, 20, 30, 40, 50, 40, 30, 20, 10]) == 90\n assert candidate(target = [1, 2, 3, 4, 5, 4, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 11\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n assert candidate(target = [5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5]) == 7\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 19\n assert candidate(target = [1, 3, 5, 7, 9, 7, 5, 3, 1, 3, 5, 7, 9, 7, 5, 3, 1, 3, 5, 7, 9, 7, 5, 3, 1]) == 25\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(target = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 14\n"}, "metadata": {"canonical_parameter_names": ["target"], "leetcode_dataset_entry_point": "Solution().minNumberOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minNumberOperations(vector& target) {", "container": "Solution", "callable": "minNumberOperations", "parameters": [{"name": "target", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1528, "task_id": "shuffle-string", "difficulty": "Easy", "problem_description": "You are given a string s and an integer array indices of the same length. The string s will be shuffled such that the character at the ith position moves to indices[i] in the shuffled string.\nReturn the shuffled string.\n \nExample 1:\n\n\nInput: s = \"codeleet\", indices = [4,5,6,7,0,2,1,3]\nOutput: \"leetcode\"\nExplanation: As shown, \"codeleet\" becomes \"leetcode\" after shuffling.\n\nExample 2:\n\nInput: s = \"abc\", indices = [0,1,2]\nOutput: \"abc\"\nExplanation: After shuffling, each character remains in its position.\n\n \nConstraints:\n\ns.length == indices.length == n\n1 <= n <= 100\ns consists of only lowercase English letters.\n0 <= indices[i] < n\nAll values of indices are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"codeleet\",indices = [4, 5, 6, 7, 0, 2, 1, 3]) == \"leetcode\"\n assert candidate(s = \"aaiougrt\",indices = [4, 0, 2, 6, 7, 3, 1, 5]) == \"arigatou\"\n assert candidate(s = \"aiohn\",indices = [3, 1, 4, 2, 0]) == \"nihao\"\n assert candidate(s = \"abc\",indices = [0, 1, 2]) == \"abc\"\n assert candidate(s = \"art\",indices = [1, 0, 2]) == \"rat\"\n assert candidate(s = \"abcdefgh\",indices = [7, 6, 5, 4, 3, 2, 1, 0]) == \"hgfedcba\"\n assert candidate(s = \"permutation\",indices = [8, 5, 4, 10, 0, 9, 2, 6, 3, 1, 7]) == \"uoairetnptm\"\n assert candidate(s = \"development\",indices = [3, 6, 5, 1, 0, 4, 8, 9, 2, 7, 10]) == \"leedovenpmt\"\n assert candidate(s = \"exampleinput\",indices = [11, 2, 5, 0, 8, 1, 6, 7, 4, 3, 9, 10]) == \"mlxpnaeipute\"\n assert candidate(s = \"abcdefghij\",indices = [5, 8, 1, 6, 7, 0, 3, 2, 9, 4]) == \"fchgjadebi\"\n assert candidate(s = \"abcdefgxyz\",indices = [6, 1, 7, 5, 8, 0, 9, 4, 3, 2]) == \"fbzyxdaceg\"\n assert candidate(s = \"pneumonia\",indices = [2, 8, 7, 6, 5, 4, 3, 1, 0]) == \"aipnomuen\"\n assert candidate(s = \"randomization\",indices = [4, 1, 5, 0, 2, 7, 8, 6, 3, 9, 10, 11, 12]) == \"daoarnzmition\"\n assert candidate(s = \"character\",indices = [8, 4, 2, 5, 6, 1, 0, 7, 3]) == \"tcarhraec\"\n assert candidate(s = \"fqtv\",indices = [1, 3, 2, 0]) == \"vftq\"\n assert candidate(s = \"visualization\",indices = [10, 1, 9, 12, 0, 2, 8, 4, 6, 7, 11, 3, 5]) == \"ailoznatisviu\"\n assert candidate(s = \"waterbottle\",indices = [8, 7, 6, 5, 4, 3, 2, 1, 9, 0, 10]) == \"ltobretawte\"\n assert candidate(s = \"shuffle\",indices = [4, 2, 5, 1, 6, 3, 0]) == \"efhlsuf\"\n assert candidate(s = \"intermediate\",indices = [11, 8, 2, 0, 7, 3, 4, 9, 1, 6, 5, 10]) == \"eitmetarndei\"\n assert candidate(s = \"programming\",indices = [10, 2, 1, 7, 8, 6, 5, 3, 0, 9, 4]) == \"iormgmagrnp\"\n assert candidate(s = \"alphabet\",indices = [5, 6, 7, 4, 3, 2, 1, 0]) == \"tebahalp\"\n assert candidate(s = \"permutation\",indices = [1, 10, 9, 0, 8, 6, 3, 5, 4, 2, 7]) == \"mpoaittnure\"\n assert candidate(s = \"shuffling\",indices = [8, 4, 3, 5, 7, 2, 6, 1, 0]) == \"gnluhfifs\"\n assert candidate(s = \"exampleinput\",indices = [11, 4, 0, 7, 8, 3, 5, 6, 2, 9, 1, 10]) == \"aunlxeimppte\"\n assert candidate(s = \"generation\",indices = [5, 3, 6, 7, 2, 1, 8, 0, 4, 9]) == \"iareognetn\"\n assert candidate(s = \"xylophone\",indices = [1, 4, 8, 2, 7, 5, 3, 6, 0]) == \"exooyhnpl\"\n assert candidate(s = \"uniquecharacters\",indices = [12, 1, 13, 2, 0, 15, 5, 14, 4, 7, 11, 6, 8, 10, 9, 3]) == \"unqsaccrtreauihe\"\n assert candidate(s = \"complexstringshuffle\",indices = [15, 6, 11, 19, 8, 1, 0, 12, 18, 5, 2, 3, 10, 13, 17, 14, 4, 16, 7, 9]) == \"xeinfrollegmssucfhtp\"\n assert candidate(s = \"alphanumeric\",indices = [9, 5, 7, 3, 4, 8, 10, 0, 11, 2, 1, 6]) == \"mirhalcpnaue\"\n assert candidate(s = \"abracadabra\",indices = [10, 6, 5, 3, 0, 9, 7, 8, 2, 1, 4]) == \"crbaarbdaaa\"\n assert candidate(s = \"python\",indices = [4, 0, 1, 5, 3, 2]) == \"ytnoph\"\n assert candidate(s = \"algorithm\",indices = [1, 2, 3, 0, 4, 5, 6, 7, 8]) == \"oalgrithm\"\n assert candidate(s = \"characters\",indices = [9, 3, 0, 7, 5, 2, 1, 6, 4, 8]) == \"atchraersc\"\n assert candidate(s = \"python\",indices = [5, 1, 2, 4, 0, 3]) == \"oytnhp\"\n assert candidate(s = \"algorithmdesign\",indices = [8, 12, 1, 10, 9, 13, 0, 5, 2, 4, 3, 6, 7, 11, 14]) == \"tgmedhsiaroglin\"\n assert candidate(s = \"randomized\",indices = [7, 1, 8, 2, 0, 4, 5, 9, 6, 3]) == \"oaddmiernz\"\n assert candidate(s = \"shufflethis\",indices = [8, 2, 0, 5, 3, 7, 4, 1, 6, 9, 10, 11]) == \"uthfefhlsis\"\n assert candidate(s = \"complex\",indices = [6, 4, 1, 2, 5, 0, 3]) == \"empxolc\"\n assert candidate(s = \"jumble\",indices = [3, 0, 5, 4, 2, 1]) == \"ueljbm\"\n assert candidate(s = \"rearrange\",indices = [8, 4, 3, 0, 5, 2, 7, 6, 1]) == \"reaaergnr\"\n assert candidate(s = \"algorithm\",indices = [5, 1, 4, 0, 2, 7, 6, 8, 3]) == \"olrmgatih\"\n assert candidate(s = \"randomization\",indices = [12, 1, 6, 5, 0, 11, 10, 9, 8, 7, 4, 3, 2]) == \"oanoidntazimr\"\n assert candidate(s = \"continuous\",indices = [1, 6, 5, 9, 0, 3, 7, 4, 8, 2]) == \"icsnonouut\"\n assert candidate(s = \"programming\",indices = [2, 4, 5, 0, 1, 6, 3, 7, 8, 9, 10, 11, 12]) == \"grpmroaming\"\n assert candidate(s = \"shufflingstring\",indices = [11, 7, 9, 6, 13, 2, 0, 10, 1, 12, 3, 4, 5, 8, 14]) == \"igltrifhnunssfg\"\n assert candidate(s = \"complexity\",indices = [3, 6, 1, 5, 2, 0, 7, 4, 9, 8]) == \"emlcipoxyt\"\n assert candidate(s = \"rearrange\",indices = [3, 7, 5, 2, 8, 0, 4, 1, 6]) == \"agrrnaeer\"\n assert candidate(s = \"python\",indices = [3, 1, 5, 0, 2, 4]) == \"hyopnt\"\n assert candidate(s = \"algorithm\",indices = [1, 0, 6, 4, 2, 5, 3, 7, 8]) == \"lartoighm\"\n assert candidate(s = \"algorithm\",indices = [6, 4, 3, 0, 5, 2, 1, 8, 7]) == \"otiglramh\"\n assert candidate(s = \"permutation\",indices = [8, 5, 1, 6, 7, 3, 9, 2, 0, 4, 10]) == \"irttoemupan\"\n assert candidate(s = \"scrambled\",indices = [3, 2, 0, 6, 7, 4, 1, 5, 8]) == \"rlcsbeamd\"\n assert candidate(s = \"shuffling\",indices = [1, 3, 6, 8, 0, 2, 5, 4, 7]) == \"fslhniugf\"\n assert candidate(s = \"vivid\",indices = [2, 0, 4, 3, 1]) == \"idviv\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",indices = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"zkrw\",indices = [2, 3, 0, 1]) == \"rwzk\"\n assert candidate(s = \"randomize\",indices = [3, 8, 0, 5, 4, 7, 2, 6, 1]) == \"neirodzma\"\n assert candidate(s = \"jumbledtext\",indices = [9, 0, 5, 3, 8, 6, 1, 2, 7, 4, 10]) == \"udtbxmeeljt\"\n assert candidate(s = \"environment\",indices = [1, 7, 4, 6, 2, 0, 3, 8, 10, 5, 9]) == \"oernvninmte\"\n assert candidate(s = \"characters\",indices = [6, 2, 9, 5, 7, 4, 1, 0, 3, 8]) == \"ethrcrcasa\"\n assert candidate(s = \"jfbm\",indices = [3, 0, 1, 2]) == \"fbmj\"\n"}, "metadata": {"canonical_parameter_names": ["s", "indices"], "leetcode_dataset_entry_point": "Solution().restoreString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string restoreString(string s, vector& indices) {", "container": "Solution", "callable": "restoreString", "parameters": [{"name": "s", "type": "string"}, {"name": "indices", "type": "vector&"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1529, "task_id": "minimum-suffix-flips", "difficulty": "Medium", "problem_description": "You are given a 0-indexed binary string target of length n. You have another binary string s of length n that is initially set to all zeros. You want to make s equal to target.\nIn one operation, you can pick an index i where 0 <= i < n and flip all bits in the inclusive range [i, n - 1]. Flip means changing '0' to '1' and '1' to '0'.\nReturn the minimum number of operations needed to make s equal to target.\n \nExample 1:\n\nInput: target = \"10111\"\nOutput: 3\nExplanation: Initially, s = \"00000\".\nChoose index i = 2: \"00000\" -> \"00111\"\nChoose index i = 0: \"00111\" -> \"11000\"\nChoose index i = 1: \"11000\" -> \"10111\"\nWe need at least 3 flip operations to form target.\n\nExample 2:\n\nInput: target = \"101\"\nOutput: 3\nExplanation: Initially, s = \"000\".\nChoose index i = 0: \"000\" -> \"111\"\nChoose index i = 1: \"111\" -> \"100\"\nChoose index i = 2: \"100\" -> \"101\"\nWe need at least 3 flip operations to form target.\n\nExample 3:\n\nInput: target = \"00000\"\nOutput: 0\nExplanation: We do not need any operations since the initial s already equals target.\n\n \nConstraints:\n\nn == target.length\n1 <= n <= 105\ntarget[i] is either '0' or '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = \"00000\") == 0\n assert candidate(target = \"00110\") == 2\n assert candidate(target = \"1100110011\") == 5\n assert candidate(target = \"000111000111\") == 3\n assert candidate(target = \"001100\") == 2\n assert candidate(target = \"10001\") == 3\n assert candidate(target = \"010101010101010101\") == 17\n assert candidate(target = \"001001001\") == 5\n assert candidate(target = \"1111111111\") == 1\n assert candidate(target = \"0000000000\") == 0\n assert candidate(target = \"01010\") == 4\n assert candidate(target = \"101\") == 3\n assert candidate(target = \"11001100\") == 4\n assert candidate(target = \"10010\") == 4\n assert candidate(target = \"11001\") == 3\n assert candidate(target = \"10111\") == 3\n assert candidate(target = \"001100110011\") == 5\n assert candidate(target = \"111100001111\") == 3\n assert candidate(target = \"11111\") == 1\n assert candidate(target = \"1001010\") == 6\n assert candidate(target = \"010101\") == 5\n assert candidate(target = \"1001001\") == 5\n assert candidate(target = \"0101010101\") == 9\n assert candidate(target = \"110011\") == 3\n assert candidate(target = \"111000111\") == 3\n assert candidate(target = \"10101010101010101010\") == 20\n assert candidate(target = \"000011110000111100001111\") == 5\n assert candidate(target = \"011010101010101010101010\") == 22\n assert candidate(target = \"10101010101010101010101010101010\") == 32\n assert candidate(target = \"110011001100110\") == 8\n assert candidate(target = \"000000000000000000000000000000000000000000000000\") == 0\n assert candidate(target = \"10001000100010001000\") == 10\n assert candidate(target = \"101010101010101010101010101010101010101010101010\") == 48\n assert candidate(target = \"000111000111000\") == 4\n assert candidate(target = \"1001001001\") == 7\n assert candidate(target = \"1111111111111111111111111111111111111111111111111111111111111111\") == 1\n assert candidate(target = \"01010101010101010101\") == 19\n assert candidate(target = \"1001001001001001001001001001001001001001\") == 27\n assert candidate(target = \"1010101010101010101010101010\") == 28\n assert candidate(target = \"00000111110000011111\") == 3\n assert candidate(target = \"0000000000111111111100000000001111111111\") == 3\n assert candidate(target = \"11111111111111111111111111\") == 1\n assert candidate(target = \"1010101010101010101010101010101010101010101010101010\") == 52\n assert candidate(target = \"000000000000000000000001\") == 1\n assert candidate(target = \"1100110011001100110011001100\") == 14\n assert candidate(target = \"00000000000000000000000000000000000000000000000000000000000000000\") == 0\n assert candidate(target = \"00000000000000000000000000\") == 0\n assert candidate(target = \"00110011001100110011\") == 9\n assert candidate(target = \"1111111111111111111111111111\") == 1\n assert candidate(target = \"11111111111111111110\") == 2\n assert candidate(target = \"11000000000000000001\") == 3\n assert candidate(target = \"111111111111111111111111111111111111111111111111\") == 1\n assert candidate(target = \"101010101010101010101010101010101010\") == 36\n assert candidate(target = \"0101010101010101010101010101\") == 27\n assert candidate(target = \"110110110110110110110110110110\") == 20\n assert candidate(target = \"111100001111000011110000\") == 6\n assert candidate(target = \"000111000111000111000111\") == 7\n assert candidate(target = \"100110011001100110011001\") == 13\n assert candidate(target = \"01010101010101010101010101010101010101\") == 37\n assert candidate(target = \"000000000000000000000000000000000000\") == 0\n assert candidate(target = \"10010010010010010010010010010010010010010010010010\") == 34\n assert candidate(target = \"1001001001001001001001001001001001001001001001001\") == 33\n assert candidate(target = \"01100110011001100110\") == 10\n assert candidate(target = \"11110000111100001111\") == 5\n assert candidate(target = \"111000111000111000111000\") == 8\n assert candidate(target = \"11111000001111100000111110000011111000001111100000\") == 10\n assert candidate(target = \"00000000000000000000000000000000000000000000000000\") == 0\n assert candidate(target = \"10101010101010101010101010\") == 26\n assert candidate(target = \"11001100110011001100110011\") == 13\n assert candidate(target = \"00110011001100110011001100110011001100110011001100\") == 24\n assert candidate(target = \"0111111111111111111111111111\") == 1\n assert candidate(target = \"01010101010101010101010101\") == 25\n assert candidate(target = \"11111000000000000000\") == 2\n assert candidate(target = \"1000000000000000000000000000\") == 2\n assert candidate(target = \"11111111111111111111111111111111111111111111\") == 1\n assert candidate(target = \"00000111110000011111000001111100000111110000011111\") == 9\n assert candidate(target = \"01001001001001001001001001001001\") == 21\n assert candidate(target = \"11111000001111100000\") == 4\n assert candidate(target = \"00000000000000000001\") == 1\n assert candidate(target = \"11011011011011011011\") == 13\n assert candidate(target = \"001001001001001001001001\") == 15\n assert candidate(target = \"11001100110011001100110011001100110011001100110011\") == 25\n assert candidate(target = \"001100110011001100110011001100110011001100110011\") == 23\n assert candidate(target = \"11001100110011001100110011001100\") == 16\n assert candidate(target = \"1001001001001001001001001001\") == 19\n assert candidate(target = \"00001111000011110000\") == 4\n assert candidate(target = \"111000111000111000111000111000111000111000111000111000111000111000\") == 22\n assert candidate(target = \"111111111111111111111111111111111111\") == 1\n assert candidate(target = \"0101010101010101010101010101010101010101010101010101\") == 51\n assert candidate(target = \"00000000000000000000000000000000000000000000\") == 0\n assert candidate(target = \"01110111011101110111\") == 9\n assert candidate(target = \"0110110110\") == 6\n assert candidate(target = \"00000111111111111111\") == 1\n assert candidate(target = \"000111000111000111\") == 5\n assert candidate(target = \"000011110000\") == 2\n assert candidate(target = \"11111111111111111111111111111111111111111111111110\") == 2\n assert candidate(target = \"01001001001001001001\") == 13\n assert candidate(target = \"111111111111111111111110\") == 2\n assert candidate(target = \"101010101010101010\") == 18\n assert candidate(target = \"100101010101010101010101\") == 23\n assert candidate(target = \"00000000001111111111000000000011111111110000000000\") == 4\n assert candidate(target = \"010101010101010101010101010101\") == 29\n assert candidate(target = \"0101010101010101010101010101010101\") == 33\n assert candidate(target = \"000000000000000000000000000000\") == 0\n assert candidate(target = \"01010101010101010101010101010101010101010101010101\") == 49\n assert candidate(target = \"0011001100110011001100110011\") == 13\n assert candidate(target = \"11001100110011001100\") == 10\n assert candidate(target = \"00001111111111110000\") == 2\n assert candidate(target = \"01001001001001001001001001001001001001001001001001\") == 33\n assert candidate(target = \"00000000001111111111\") == 1\n assert candidate(target = \"01001001001001001001001001001001001001001001\") == 29\n assert candidate(target = \"01010101010101010101010101010101\") == 31\n assert candidate(target = \"0000000000000000000000000000\") == 0\n assert candidate(target = \"11111111110000000000\") == 2\n assert candidate(target = \"110011001100110011\") == 9\n assert candidate(target = \"10010010010010010010\") == 14\n assert candidate(target = \"11111111111111111111\") == 1\n"}, "metadata": {"canonical_parameter_names": ["target"], "leetcode_dataset_entry_point": "Solution().minFlips", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minFlips(string target) {", "container": "Solution", "callable": "minFlips", "parameters": [{"name": "target", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1530, "task_id": "number-of-good-leaf-nodes-pairs", "difficulty": "Medium", "problem_description": "You are given the root of a binary tree and an integer distance. A pair of two different leaf nodes of a binary tree is said to be good if the length of the shortest path between them is less than or equal to distance.\nReturn the number of good leaf node pairs in the tree.\n \nExample 1:\n\n\nInput: root = [1,2,3,null,4], distance = 3\nOutput: 1\nExplanation: The leaf nodes of the tree are 3 and 4 and the length of the shortest path between them is 3. This is the only good pair.\n\nExample 2:\n\n\nInput: root = [1,2,3,4,5,6,7], distance = 3\nOutput: 2\nExplanation: The good pairs are [4,5] and [6,7] with shortest path = 2. The pair [4,6] is not good because the length of ther shortest path between them is 4.\n\nExample 3:\n\nInput: root = [7,1,4,6,null,5,3,null,null,null,null,null,2], distance = 3\nOutput: 1\nExplanation: The only good pair is [2,5].\n\n \nConstraints:\n\nThe number of nodes in the tree is in the range [1, 210].\n1 <= Node.val <= 100\n1 <= distance <= 10\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([1]),distance = 1) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7]),distance = 5) == 6\n assert candidate(root = tree_node([1, 2, 3, None, 4]),distance = 3) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7]),distance = 3) == 2\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7]),distance = 1) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),distance = 2) == 4\n assert candidate(root = tree_node([7, 1, 4, 6, None, 5, 3, None, None, None, None, None, 2]),distance = 3) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, None, 6, None, 7, None, 8, None, 9]),distance = 3) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 6, 7, None, None, 8, None, None, None, 9]),distance = 4) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]),distance = 7) == 56\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, None, None, 6, 7, None, None, None, None, 8, 9, None, None, None, None, 10, 11, None, None, None, None, 12, 13, None, None, None, None, 14, 15, None, None, None, None, 16, 17, None, None, None, None, 18, 19, None, None, None, None, 20, 21]),distance = 8) == 3\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, 6, 7, None, None, None, None, 8, 9]),distance = 5) == 6\n assert candidate(root = tree_node([1, 2, 3, 4, None, 5, None, 6, 7, None, None, None, 8, None, 9, None, None, 10, None, None, None, None, None, None, None, None, None, 11, None, None, None, None, None, None, None, None, None, 12, None, None, None, None, None, None, None, None, None, 13, None, None, None, None, None, None, None, None, None, 14, None, None, None, None, None, None, None, None, None, 15]),distance = 6) == 2\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12]),distance = 6) == 0\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20, None, 21, None, 22, None, 23, None, 24, None, 25, None, 26, None, 27, None, 28, None, 29, None, 30]),distance = 4) == 0\n assert candidate(root = tree_node([2, 1, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9]),distance = 6) == 0\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11]),distance = 6) == 0\n assert candidate(root = tree_node([8, 5, 9, 4, 6, 10, 11, 3, 7, None, None, None, None, None, None, None, 2, None, None, None, None, None, None, None]),distance = 3) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, None, None, None, None, None, 6, None, None, None, None, None, 7]),distance = 6) == 1\n assert candidate(root = tree_node([1, 2, 3, 4, None, 5, 6, 7, 8, 9, 10, None, None, None, None, None, 11, None, 12, 13, None, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20]),distance = 6) == 4\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]),distance = 3) == 10\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]),distance = 3) == 7\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20, None, 21, None, 22, None, 23, None, 24, None, 25]),distance = 6) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 6, 7, 8, None, None, 9, 10, 11, 12, None, None, 13, 14, None, None, 15, 16]),distance = 5) == 14\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, None, 6, 7, None, None, None, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15]),distance = 3) == 2\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]),distance = 5) == 45\n assert candidate(root = tree_node([1, 2, 3, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13]),distance = 7) == 0\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, 1, None, 6, 9, None, None, 12, 14]),distance = 5) == 8\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, None, 6, 7, None, None, 8, 9, None, None, None, None, None, 10, 11, None, None, None, None, None, None, None, None, 12]),distance = 4) == 6\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]),distance = 6) == 38\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 6, None, 7, None, 8, None, 9]),distance = 5) == 1\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20]),distance = 5) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, None, 6, 7, 8, 9, None, None, 10, 11, None, None, None, None, None, None, 12, 13, None, None, None, None, None, None, 14, 15]),distance = 3) == 5\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),distance = 2) == 4\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, None, None, None, None, None, None, None, None, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20]),distance = 5) == 6\n assert candidate(root = tree_node([1, 2, None, 3, 4, None, 5, 6, 7, None, None, None, 8, 9, 10, None, None, None, None, None, None, None, None, None, None, 11]),distance = 5) == 6\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20]),distance = 10) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10]),distance = 5) == 0\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10]),distance = 2) == 0\n assert candidate(root = tree_node([5, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),distance = 4) == 12\n assert candidate(root = tree_node([5, 1, 4, None, 2, None, 3, 6, 7, None, 8, None, 9, 10, 11, None, None, None, None, None, None]),distance = 5) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, None, 5, 6, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15]),distance = 5) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16, None, 17, None, 18, None, 19, None, 20, None, 21, None, 22, None, 23, None, 24, None, 25, None, 26, None, 27, None, 28, None, 29, None, 30, None, 31, None, 32, None, 33, None, 34, None, 35, None, 36, None, 37, None, 38, None, 39, None, 40, None, 41, None, 42, None, 43, None, 44, None, 45, None, 46, None, 47, None, 48, None, 49, None, 50]),distance = 6) == 0\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 18, 1, 4, 6, 8, 11, 13, 17, 19, None, None, None, None, None, None, None, None, 2, None, 9]),distance = 4) == 8\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 5, 6, None, None, 7, 8, None, None, 9, None, 10, None, None, 11]),distance = 5) == 0\n assert candidate(root = tree_node([5, 4, 8, 11, None, 17, 4, 7, 1, None, None, 5, 3]),distance = 6) == 10\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, None, 6, 7, None, None, 8, 9]),distance = 3) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]),distance = 3) == 25\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, None, None, 5, None, 6, None, 7, None, 8, None, 9]),distance = 5) == 0\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),distance = 4) == 12\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, 6, 7, None, None, None, None, 8, 9, None, None, None, None, None, None, None, None, None, 10]),distance = 5) == 10\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]),distance = 4) == 24\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, None, 6, 7, None, None, 8, 9, None, None, None, None, 10, None, 11, None, None, None, None, None, None, None, None, None]),distance = 4) == 3\n assert candidate(root = tree_node([3, 5, 1, 6, 2, 0, 8, None, None, 7, 4, None, None, 10, None, None, 11, None, None, 12, None, None, 13, None, None, 14, None, None, 15]),distance = 4) == 3\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, None, None, None, 10, None, None, 11, None, None, 12]),distance = 4) == 5\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),distance = 5) == 17\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, None, 41, None, 42]),distance = 4) == 26\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]),distance = 10) == 300\n assert candidate(root = tree_node([3, 5, 1, 6, 2, 0, 8, None, None, 7, 4, None, None, None, None, None, None]),distance = 3) == 4\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, None, None, 6, None, None, 7]),distance = 5) == 3\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9]),distance = 7) == 0\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, None, 5, 6, None, None, None, None, None, None, None, None, None, None, 7, 8, None, None, None, None, None, None, None, None, 9, 10, None, None, None, None, None, None, None, None, None, 11, 12, None, None, None, None, None, None, None, None, None, 13, 14, None, None, None, None, None, None, None, None, None, 15, 16, None, None, None, None, None, None, None, None, None, 17, 18]),distance = 5) == 3\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, 6, 7, None, None, 8, 9]),distance = 4) == 8\n assert candidate(root = tree_node([50, 25, 75, 12, 37, 63, 87, 6, 18, 31, 43, 55, 70, 81, 93, 3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 61, 67, 73, 77, 83, 89, 95, None, 10, 19, 28, 35, 41, 47, 53, 59, 65, 71, 75, 79, 85, 91, 97, None, 13, 23, 32, 40, 46, 52, 58, 64, 70, 76, 82, 88, 94, 100, None, None, None, 16, 22, 29, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, None, None, None, None, None, 20, 26, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97, None, None, None, None, None, None, None, None, 24, 30, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89, 95, None, None, None, None, None, None, None, None, None, 28, 33, 38, 44, 50, 56, 62, 68, 74, 80, 86, 92, 98, None, None, None, None, None, None, None, None, None, None, None, 32, 37, 43, 49, 55, 61, 67, 73, 79, 85, 91, 97, None, None, None, None, None, None, None, None, None, None, None, None, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 40, 46, 52, 58, 64, 70, 76, 82, 88, 94, 100]),distance = 5) == 118\n assert candidate(root = tree_node([31, 30, 48, 29, 38, 39, 49, 27, None, None, None, None, None, None, None, 28, None, 26, None, None, None, None, None, None]),distance = 2) == 1\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15, None, 16]),distance = 7) == 0\n"}, "metadata": {"canonical_parameter_names": ["root", "distance"], "leetcode_dataset_entry_point": "Solution().countPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countPairs(TreeNode* root, int distance) {", "container": "Solution", "callable": "countPairs", "parameters": [{"name": "root", "type": "TreeNode*"}, {"name": "distance", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1531, "task_id": "string-compression-ii", "difficulty": "Hard", "problem_description": "Run-length encoding is a string compression method that works by replacing consecutive identical characters (repeated 2 or more times) with the concatenation of the character and the number marking the count of the characters (length of the run). For example, to compress the string \"aabccc\" we replace \"aa\" by \"a2\" and replace \"ccc\" by \"c3\". Thus the compressed string becomes \"a2bc3\".\nNotice that in this problem, we are not adding '1' after single characters.\nGiven a string s and an integer k. You need to delete at most k characters from s such that the run-length encoded version of s has minimum length.\nFind the minimum length of the run-length encoded version of s after deleting at most k characters.\n \nExample 1:\n\nInput: s = \"aaabcccd\", k = 2\nOutput: 4\nExplanation: Compressing s without deleting anything will give us \"a3bc3d\" of length 6. Deleting any of the characters 'a' or 'c' would at most decrease the length of the compressed string to 5, for instance delete 2 'a' then we will have s = \"abcccd\" which compressed is abc3d. Therefore, the optimal way is to delete 'b' and 'd', then the compressed version of s will be \"a3c3\" of length 4.\nExample 2:\n\nInput: s = \"aabbaa\", k = 2\nOutput: 2\nExplanation: If we delete both 'b' characters, the resulting compressed string would be \"a4\" of length 2.\n\nExample 3:\n\nInput: s = \"aaaaaaaaaaa\", k = 0\nOutput: 3\nExplanation: Since k is zero, we cannot delete anything. The compressed string is \"a11\" of length 3.\n\n \nConstraints:\n\n1 <= s.length <= 100\n0 <= k <= s.length\ns contains only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcabcabc\",k = 5) == 3\n assert candidate(s = \"aaabcccd\",k = 2) == 4\n assert candidate(s = \"aabcc\",k = 1) == 4\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 20) == 32\n assert candidate(s = \"aabccabcc\",k = 2) == 5\n assert candidate(s = \"nnnhoorq\",k = 2) == 5\n assert candidate(s = \"aaaaaaaaaaa\",k = 0) == 3\n assert candidate(s = \"aabbaa\",k = 2) == 2\n assert candidate(s = \"abbbcccaaaa\",k = 3) == 5\n assert candidate(s = \"abbbabbbcabbbabbbb\",k = 3) == 6\n assert candidate(s = \"aabbccddeeff\",k = 6) == 6\n assert candidate(s = \"abababababababababababababababababababab\",k = 15) == 12\n assert candidate(s = \"a\",k = 0) == 1\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",k = 10) == 3\n assert candidate(s = \"aabbbcccbbaa\",k = 3) == 6\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 10) == 3\n assert candidate(s = \"abcdabcdabcd\",k = 6) == 5\n assert candidate(s = \"a\",k = 1) == 0\n assert candidate(s = \"aabbcc\",k = 1) == 5\n assert candidate(s = \"aabcccccaaa\",k = 2) == 5\n assert candidate(s = \"abcde\",k = 2) == 3\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",k = 15) == 21\n assert candidate(s = \"aabbccddeeff\",k = 4) == 8\n assert candidate(s = \"abcdefghijaaaaaaaaaaaaaa\",k = 5) == 8\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzzzz\",k = 30) == 23\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\",k = 25) == 64\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",k = 30) == 14\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\",k = 35) == 18\n assert candidate(s = \"mississippi\",k = 3) == 6\n assert candidate(s = \"aaaaaabbbbccccddddeeeeffffgggghhhh\",k = 8) == 12\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",k = 15) == 58\n assert candidate(s = \"abacabadabacaba\",k = 5) == 6\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyx\",k = 30) == 25\n assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 25) == 3\n assert candidate(s = \"aaabbbcccddddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwww\",k = 30) == 26\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbcccccccccccdddddddddd\",k = 20) == 6\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\",k = 5) == 8\n assert candidate(s = \"mnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopq\",k = 10) == 75\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzz\",k = 10) == 18\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 25) == 53\n assert candidate(s = \"aaabaaaacaaadaaaeaaafaaagaaahaaaiaaa\",k = 10) == 3\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",k = 25) == 26\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 30) == 3\n assert candidate(s = \"abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcde\",k = 25) == 60\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",k = 10) == 16\n assert candidate(s = \"abababababab\",k = 3) == 7\n assert candidate(s = \"zzzzzyyyyyxxxyyyxxxxzzzzzzz\",k = 15) == 3\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",k = 20) == 55\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 26) == 26\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabc\",k = 15) == 15\n assert candidate(s = \"ppppppppppqqqqqqqqqqrrrrrrrrrrsssssssssssssssssssssssssssssssssssssssssssssssssssssssssss\",k = 50) == 3\n assert candidate(s = \"abbbcccdddeeeeeffgggghhhiiijjjjj\",k = 10) == 12\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 25) == 3\n assert candidate(s = \"aabbaacccaaadd\",k = 4) == 6\n assert candidate(s = \"abbbccccddee\",k = 4) == 5\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababababababab\",k = 20) == 50\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbccccccccddddddddeeeeeeeeeffffffffgggggggghhhhhhhhiiiiiiiiijjjjjjj\",k = 25) == 14\n assert candidate(s = \"pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\",k = 30) == 3\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 25) == 27\n assert candidate(s = \"ababababababababababababababababababababab\",k = 10) == 24\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\",k = 15) == 6\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 30) == 3\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",k = 5) == 24\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",k = 30) == 26\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\",k = 20) == 59\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcd\",k = 12) == 13\n assert candidate(s = \"wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww\",k = 45) == 3\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 0) == 52\n assert candidate(s = \"abcdefg\",k = 3) == 4\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 10) == 3\n assert candidate(s = \"aabbaabbaabbaabbaabbaabb\",k = 10) == 4\n assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 50) == 0\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",k = 20) == 52\n assert candidate(s = \"abababababababababababababab\",k = 10) == 10\n assert candidate(s = \"pppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp\",k = 50) == 3\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzz\",k = 40) == 13\n assert candidate(s = \"aaaaabbbbbaaaaabbbbbaaaaabbbbbaaaaabbbbbaaaaa\",k = 10) == 11\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbcccccdddddeeeeeeeeeeee\",k = 20) == 5\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 15) == 37\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeee\",k = 10) == 10\n assert candidate(s = \"ppppppqqqqqqqqqqqqqqqqqqqqqqrrrrrrrrrrrrrrrrsssssssssssttttttttttt\",k = 30) == 6\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 10) == 3\n assert candidate(s = \"aaaaaaaaaaabbbbbbbbbbbccccccccccdddddddddd\",k = 10) == 8\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffgggggggggg\",k = 25) == 10\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().getLengthOfOptimalCompression", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int getLengthOfOptimalCompression(string s, int k) {", "container": "Solution", "callable": "getLengthOfOptimalCompression", "parameters": [{"name": "s", "type": "string"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1534, "task_id": "count-good-triplets", "difficulty": "Easy", "problem_description": "Given an array of integers arr, and three integers a, b and c. You need to find the number of good triplets.\\r\n\\r\nA triplet (arr[i], arr[j], arr[k]) is good if the following conditions are true:\\r\n\\r\n\\r\n\t0 <= i < j < k < arr.length\\r\n\t|arr[i] - arr[j]| <= a\\r\n\t|arr[j] - arr[k]| <= b\\r\n\t|arr[i] - arr[k]| <= c\\r\n\\r\n\\r\nWhere |x| denotes the absolute value of x.\\r\n\\r\nReturn the number of good triplets.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: arr = [3,0,1,1,9,7], a = 7, b = 2, c = 3\\r\nOutput: 4\\r\nExplanation: There are 4 good triplets: [(3,0,1), (3,0,1), (3,1,1), (0,1,1)].\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: arr = [1,1,2,2,3], a = 0, b = 0, c = 1\\r\nOutput: 0\\r\nExplanation: No triplet satisfies all conditions.\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t3 <= arr.length <= 100\\r\n\t0 <= arr[i] <= 1000\\r\n\t0 <= a, b, c <= 1000\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [3, 0, 1, 1, 9, 7],a = 7,b = 2,c = 3) == 4\n assert candidate(arr = [1, 3, 5, 7, 9],a = 2,b = 3,c = 4) == 3\n assert candidate(arr = [1, 1, 2, 2, 3],a = 0,b = 0,c = 1) == 0\n assert candidate(arr = [10, 20, 30, 40, 50],a = 5,b = 10,c = 15) == 0\n assert candidate(arr = [10, 20, 30, 40, 50],a = 15,b = 25,c = 35) == 5\n assert candidate(arr = [0, 0, 0, 0, 0],a = 0,b = 0,c = 0) == 10\n assert candidate(arr = [10, 20, 30, 40, 50],a = 15,b = 15,c = 15) == 0\n assert candidate(arr = [10, 20, 30, 40, 50],a = 10,b = 10,c = 10) == 0\n assert candidate(arr = [1, 3, 5, 7, 9],a = 2,b = 2,c = 2) == 0\n assert candidate(arr = [0, 0, 0, 0, 0],a = 1,b = 1,c = 1) == 10\n assert candidate(arr = [0, 0, 0, 0],a = 1,b = 1,c = 1) == 4\n assert candidate(arr = [1, 5, 6, 8, 10, 14, 15, 18, 20, 22],a = 4,b = 3,c = 5) == 8\n assert candidate(arr = [5, 8, 12, 15, 19, 22, 25, 28, 31, 34],a = 5,b = 7,c = 10) == 14\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],a = 1,b = 1,c = 2) == 88\n assert candidate(arr = [5, 8, 12, 15, 18, 22, 25, 28, 31],a = 5,b = 5,c = 10) == 7\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],a = 2,b = 2,c = 4) == 44\n assert candidate(arr = [10, 20, 20, 20, 30, 40, 50, 60, 70, 80],a = 5,b = 5,c = 10) == 1\n assert candidate(arr = [7, 1, 5, 3, 6, 4, 2, 8, 9],a = 2,b = 3,c = 4) == 20\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],a = 2,b = 2,c = 2) == 8\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],a = 0,b = 0,c = 0) == 1140\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900],a = 150,b = 250,c = 350) == 13\n assert candidate(arr = [5, 8, 12, 15, 20, 22, 25],a = 5,b = 6,c = 7) == 4\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],a = 0,b = 0,c = 0) == 120\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],a = 10,b = 20,c = 30) == 25\n assert candidate(arr = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80],a = 5,b = 10,c = 15) == 25\n assert candidate(arr = [5, 8, 8, 10, 15, 17],a = 5,b = 3,c = 8) == 5\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33],a = 4,b = 4,c = 8) == 7\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4],a = 1,b = 1,c = 2) == 54\n assert candidate(arr = [15, 10, 15, 10, 15, 10, 15],a = 5,b = 5,c = 10) == 35\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],a = 100,b = 200,c = 300) == 15\n assert candidate(arr = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 0],a = 100,b = 200,c = 300) == 17\n assert candidate(arr = [9, 7, 5, 3, 1, 2, 4, 6, 8, 0],a = 1,b = 2,c = 3) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],a = 2,b = 2,c = 3) == 37\n assert candidate(arr = [7, 3, 19, 5, 11, 13, 17, 15, 2, 9],a = 6,b = 5,c = 10) == 24\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],a = 1,b = 1,c = 2) == 132\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],a = 0,b = 0,c = 0) == 120\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],a = 2,b = 3,c = 4) == 58\n assert candidate(arr = [5, 8, 2, 3, 6, 9, 10, 12],a = 3,b = 4,c = 5) == 16\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],a = 1,b = 2,c = 3) == 25\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],a = 1,b = 1,c = 1) == 0\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900],a = 100,b = 100,c = 100) == 0\n assert candidate(arr = [100, 200, 150, 300, 250, 400, 350, 500, 450, 600],a = 50,b = 100,c = 150) == 6\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],a = 1,b = 1,c = 1) == 0\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],a = 150,b = 200,c = 250) == 8\n assert candidate(arr = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],a = 20,b = 30,c = 40) == 64\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],a = 5,b = 5,c = 5) == 120\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],a = 0,b = 0,c = 0) == 120\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],a = 0,b = 0,c = 1) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],a = 3,b = 3,c = 3) == 324\n assert candidate(arr = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],a = 1,b = 1,c = 2) == 120\n assert candidate(arr = [4, 9, 1, 3, 13, 12, 7],a = 6,b = 4,c = 10) == 8\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],a = 2,b = 2,c = 4) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],a = 1,b = 1,c = 2) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],a = 1,b = 1,c = 1) == 0\n assert candidate(arr = [8, 12, 15, 20, 25, 30, 35, 40, 45, 50],a = 5,b = 10,c = 15) == 15\n assert candidate(arr = [5, 8, 12, 15, 16, 20, 25, 30],a = 7,b = 5,c = 10) == 12\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],a = 4,b = 8,c = 12) == 15\n assert candidate(arr = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],a = 0,b = 0,c = 0) == 455\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57],a = 4,b = 8,c = 12) == 25\n assert candidate(arr = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50],a = 15,b = 25,c = 35) == 17\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4, 4],a = 0,b = 0,c = 0) == 84\n assert candidate(arr = [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],a = 1,b = 1,c = 2) == 9\n assert candidate(arr = [2, 5, 1, 2, 10, 9, 10, 6],a = 4,b = 4,c = 7) == 15\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],a = 0,b = 0,c = 0) == 455\n assert candidate(arr = [5, 3, 7, 8, 2, 1, 9, 6, 4, 10],a = 5,b = 5,c = 5) == 60\n assert candidate(arr = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30],a = 10,b = 20,c = 30) == 166\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],a = 9,b = 19,c = 29) == 0\n assert candidate(arr = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70],a = 4,b = 5,c = 6) == 0\n assert candidate(arr = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],a = 5,b = 5,c = 5) == 60\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],a = 15,b = 15,c = 20) == 8\n assert candidate(arr = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],a = 10,b = 10,c = 10) == 120\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],a = 2,b = 3,c = 5) == 8\n assert candidate(arr = [1, 5, 3, 2, 4, 8, 7, 6, 9, 0],a = 3,b = 3,c = 5) == 34\n assert candidate(arr = [34, 23, 54, 28, 90, 56, 78, 45, 12, 67],a = 20,b = 25,c = 30) == 15\n assert candidate(arr = [50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],a = 5,b = 10,c = 15) == 17\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],a = 1,b = 1,c = 1) == 120\n assert candidate(arr = [7, 3, 8, 1, 4, 6, 5, 2, 9, 0],a = 1,b = 1,c = 2) == 3\n assert candidate(arr = [15, 15, 15, 20, 20, 20, 25, 25, 25],a = 5,b = 5,c = 10) == 66\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],a = 0,b = 0,c = 0) == 1140\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],a = 1,b = 1,c = 2) == 100\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],a = 10,b = 20,c = 30) == 15\n assert candidate(arr = [5, 8, 2, 4, 3, 7, 6, 9, 1],a = 3,b = 4,c = 5) == 35\n assert candidate(arr = [30, 40, 50, 60, 70, 80, 90, 100, 110],a = 10,b = 10,c = 20) == 7\n assert candidate(arr = [2, 2, 2, 2, 2],a = 0,b = 0,c = 0) == 10\n assert candidate(arr = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],a = 15,b = 25,c = 35) == 17\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],a = 1,b = 1,c = 1) == 0\n assert candidate(arr = [1, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],a = 4,b = 5,c = 6) == 214\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],a = 10,b = 10,c = 20) == 8\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49],a = 4,b = 6,c = 8) == 11\n assert candidate(arr = [8, 1, 3, 2, 10, 1, 4],a = 1,b = 2,c = 3) == 4\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],a = 100,b = 150,c = 200) == 8\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10],a = 3,b = 3,c = 4) == 152\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],a = 15,b = 20,c = 25) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],a = 1,b = 1,c = 1) == 0\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10],a = 1,b = 1,c = 2) == 112\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57],a = 3,b = 4,c = 5) == 0\n assert candidate(arr = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],a = 1,b = 2,c = 3) == 15\n assert candidate(arr = [0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],a = 1,b = 1,c = 2) == 124\n assert candidate(arr = [5, 1, 4, 1, 3, 6, 2],a = 2,b = 3,c = 5) == 14\n assert candidate(arr = [5, 8, 12, 15, 16, 23, 42],a = 5,b = 7,c = 10) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],a = 0,b = 0,c = 0) == 0\n"}, "metadata": {"canonical_parameter_names": ["arr", "a", "b", "c"], "leetcode_dataset_entry_point": "Solution().countGoodTriplets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countGoodTriplets(vector& arr, int a, int b, int c) {", "container": "Solution", "callable": "countGoodTriplets", "parameters": [{"name": "arr", "type": "vector&"}, {"name": "a", "type": "int"}, {"name": "b", "type": "int"}, {"name": "c", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1535, "task_id": "find-the-winner-of-an-array-game", "difficulty": "Medium", "problem_description": "Given an integer array arr of distinct integers and an integer k.\nA game will be played between the first two elements of the array (i.e. arr[0] and arr[1]). In each round of the game, we compare arr[0] with arr[1], the larger integer wins and remains at position 0, and the smaller integer moves to the end of the array. The game ends when an integer wins k consecutive rounds.\nReturn the integer which will win the game.\nIt is guaranteed that there will be a winner of the game.\n \nExample 1:\n\nInput: arr = [2,1,3,5,4,6,7], k = 2\nOutput: 5\nExplanation: Let's see the rounds of the game:\nRound | arr | winner | win_count\n 1 | [2,1,3,5,4,6,7] | 2 | 1\n 2 | [2,3,5,4,6,7,1] | 3 | 1\n 3 | [3,5,4,6,7,1,2] | 5 | 1\n 4 | [5,4,6,7,1,2,3] | 5 | 2\nSo we can see that 4 rounds will be played and 5 is the winner because it wins 2 consecutive games.\n\nExample 2:\n\nInput: arr = [3,2,1], k = 10\nOutput: 3\nExplanation: 3 will win the first 10 rounds consecutively.\n\n \nConstraints:\n\n2 <= arr.length <= 105\n1 <= arr[i] <= 106\narr contains distinct integers.\n1 <= k <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [2, 1, 3, 5, 4, 6, 7],k = 2) == 5\n assert candidate(arr = [7, 10, 5, 3, 8],k = 3) == 10\n assert candidate(arr = [5, 4, 3, 2, 1],k = 1) == 5\n assert candidate(arr = [3, 2, 1],k = 10) == 3\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 4) == 100\n assert candidate(arr = [5, 1, 4, 2, 3],k = 4) == 5\n assert candidate(arr = [1, 2, 3, 4, 5],k = 1) == 2\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 10\n assert candidate(arr = [1, 2, 3, 4, 5],k = 3) == 5\n assert candidate(arr = [7, 6, 5, 4, 3, 2, 1],k = 3) == 7\n assert candidate(arr = [7, 6, 5, 8, 4, 3, 2, 1],k = 4) == 8\n assert candidate(arr = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10],k = 7) == 10\n assert candidate(arr = [999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990],k = 7) == 999999\n assert candidate(arr = [5, 1, 9, 3, 7, 2, 8, 4, 6],k = 4) == 9\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 6) == 19\n assert candidate(arr = [7, 6, 5, 4, 3, 2, 1, 8, 9, 10],k = 2) == 7\n assert candidate(arr = [500000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],k = 10) == 500000\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 10\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],k = 1) == 3\n assert candidate(arr = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],k = 50) == 100\n assert candidate(arr = [2, 1, 3, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 20\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 3) == 20\n assert candidate(arr = [7, 14, 28, 8, 16, 32, 4, 2, 1],k = 6) == 32\n assert candidate(arr = [1000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 1000000\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1000000) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 2\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 200\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 1) == 3\n assert candidate(arr = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 10\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 4) == 19\n assert candidate(arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19],k = 3) == 20\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 10) == 10\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 7) == 20\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 10\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 8) == 20\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 20\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 5) == 19\n assert candidate(arr = [5, 8, 4, 9, 3, 2, 1, 6, 7, 10],k = 6) == 9\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 100\n assert candidate(arr = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 100\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 100) == 100\n assert candidate(arr = [1000000, 999999, 999998, 999997, 999996, 999995, 999994],k = 6) == 1000000\n assert candidate(arr = [4, 8, 6, 2, 7, 3, 9, 1, 5, 10],k = 6) == 10\n assert candidate(arr = [50, 20, 30, 10, 40],k = 3) == 50\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 3) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 500000],k = 10) == 500000\n assert candidate(arr = [5, 1, 4, 3, 2],k = 4) == 5\n assert candidate(arr = [5, 2, 9, 1, 7, 8, 3, 6, 4],k = 5) == 9\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10],k = 7) == 9\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 7) == 10\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 15) == 30\n assert candidate(arr = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5],k = 3) == 50\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 7) == 30\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 10) == 20\n assert candidate(arr = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],k = 4) == 10\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 10\n assert candidate(arr = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],k = 10) == 1000000\n assert candidate(arr = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],k = 5) == 1000000\n assert candidate(arr = [9, 3, 5, 2, 8, 1, 7, 6, 4, 10],k = 2) == 9\n assert candidate(arr = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6],k = 3) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 20\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 20\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 19\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],k = 2) == 9\n assert candidate(arr = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989],k = 10) == 100000\n assert candidate(arr = [5, 1, 4, 2, 3],k = 4) == 5\n assert candidate(arr = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6],k = 4) == 5\n assert candidate(arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 15],k = 8) == 15\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 15) == 30\n assert candidate(arr = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 20) == 30\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 10\n assert candidate(arr = [7, 6, 5, 4, 3, 2, 1, 8, 9, 10],k = 4) == 7\n assert candidate(arr = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],k = 3) == 100\n assert candidate(arr = [5, 3, 8, 6, 7, 2, 4, 9, 1],k = 4) == 8\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10],k = 1) == 9\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 3) == 10\n assert candidate(arr = [7, 6, 5, 4, 3, 2, 1, 12, 11, 10, 9, 8],k = 5) == 7\n assert candidate(arr = [1, 100, 2, 99, 3, 98, 4, 97],k = 3) == 100\n assert candidate(arr = [23, 45, 67, 89, 12, 34, 56, 78, 90, 11],k = 5) == 89\n assert candidate(arr = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9],k = 3) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 2\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11],k = 5) == 20\n assert candidate(arr = [1, 25, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 25\n assert candidate(arr = [7, 14, 4, 14, 13, 2, 6, 13],k = 3) == 14\n assert candidate(arr = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],k = 2) == 2\n assert candidate(arr = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10],k = 3) == 5\n assert candidate(arr = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],k = 5) == 10\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 3) == 1000\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 25) == 100\n assert candidate(arr = [99, 1, 98, 2, 97, 3, 96, 4, 95, 5],k = 10) == 99\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10) == 15\n assert candidate(arr = [23, 11, 45, 78, 90, 67, 34, 21, 56, 89],k = 4) == 90\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 9) == 1000\n assert candidate(arr = [7, 10, 4, 3, 20, 15, 6, 1, 2, 8, 5, 9],k = 4) == 20\n assert candidate(arr = [100, 200, 50, 150, 250, 500, 400, 300, 600, 700],k = 7) == 700\n assert candidate(arr = [7, 8, 9, 10, 11, 5, 6, 1, 2, 3, 4],k = 3) == 11\n assert candidate(arr = [500, 400, 300, 200, 100, 101, 102, 103, 104, 105],k = 3) == 500\n assert candidate(arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19],k = 10) == 20\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 1) == 10\n assert candidate(arr = [1, 3, 2, 4, 6, 5, 7, 9, 8, 10],k = 2) == 3\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 9\n assert candidate(arr = [1, 3, 2, 4, 5, 7, 6, 8, 9, 11, 10, 12, 13, 15, 14, 16, 17, 19, 18, 20],k = 5) == 20\n assert candidate(arr = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],k = 4) == 100\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 10\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],k = 12) == 75\n"}, "metadata": {"canonical_parameter_names": ["arr", "k"], "leetcode_dataset_entry_point": "Solution().getWinner", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int getWinner(vector& arr, int k) {", "container": "Solution", "callable": "getWinner", "parameters": [{"name": "arr", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1536, "task_id": "minimum-swaps-to-arrange-a-binary-grid", "difficulty": "Medium", "problem_description": "Given an n x n binary grid, in one step you can choose two adjacent rows of the grid and swap them.\nA grid is said to be valid if all the cells above the main diagonal are zeros.\nReturn the minimum number of steps needed to make the grid valid, or -1 if the grid cannot be valid.\nThe main diagonal of a grid is the diagonal that starts at cell (1, 1) and ends at cell (n, n).\n \nExample 1:\n\n\nInput: grid = [[0,0,1],[1,1,0],[1,0,0]]\nOutput: 3\n\nExample 2:\n\n\nInput: grid = [[0,1,1,0],[0,1,1,0],[0,1,1,0],[0,1,1,0]]\nOutput: -1\nExplanation: All rows are similar, swaps have no effect on the grid.\n\nExample 3:\n\n\nInput: grid = [[1,0,0],[1,1,0],[1,1,1]]\nOutput: 0\n\n \nConstraints:\n\nn == grid.length == grid[i].length\n1 <= n <= 200\ngrid[i][j] is either 0 or 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 0, 1], [1, 1, 0], [1, 0, 0]]) == 3\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 1], [0, 1, 1, 1]]) == -1\n assert candidate(grid = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == 0\n assert candidate(grid = [[0, 1, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 1\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0]]) == 3\n assert candidate(grid = [[0, 0, 0], [0, 0, 1], [0, 1, 0]]) == 1\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 0], [0, 0, 0, 0]]) == 2\n assert candidate(grid = [[1, 0, 0], [1, 1, 0], [1, 1, 1]]) == 0\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[0, 1, 1, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 1, 1, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 0, 0, 1, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 28\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 1], [0, 0, 0, 1, 1], [0, 0, 1, 1, 1], [0, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 0], [1, 1, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0]]) == 10\n assert candidate(grid = [[0, 0, 0, 1, 0], [0, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [1, 0, 0, 0, 0]]) == 6\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == -1\n assert candidate(grid = [[0, 1, 1, 1, 1, 1], [1, 0, 1, 1, 1, 1], [1, 1, 0, 1, 1, 1], [1, 1, 1, 0, 1, 1], [1, 1, 1, 1, 0, 1], [1, 1, 1, 1, 1, 0]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 55\n assert candidate(grid = [[0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 1, 1, 0, 0], [0, 1, 1, 0, 0, 0], [1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 1], [0, 1, 1, 1, 1], [0, 0, 1, 1, 1], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1]]) == -1\n assert candidate(grid = [[0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0]]) == 2\n assert candidate(grid = [[0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 11\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 0, 0, 0]]) == 6\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0]]) == 10\n assert candidate(grid = [[0, 1, 1, 1, 1], [1, 0, 1, 1, 1], [1, 1, 0, 1, 1], [1, 1, 1, 0, 1], [1, 1, 1, 1, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 1], [0, 0, 0, 1, 1], [0, 0, 1, 1, 1], [0, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 1, 1, 1], [0, 0, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0]]) == 10\n assert candidate(grid = [[0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0], [0, 1, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 1]]) == -1\n assert candidate(grid = [[0, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[1, 1, 0, 0, 0], [0, 1, 1, 0, 0], [0, 0, 1, 1, 0], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 0], [1, 1, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 6\n assert candidate(grid = [[0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1], [0, 1, 0, 0, 0], [1, 0, 0, 0, 0]]) == 7\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == 11\n assert candidate(grid = [[0, 0, 0, 0, 1], [0, 0, 0, 1, 1], [0, 0, 1, 1, 0], [0, 1, 1, 0, 0], [1, 1, 0, 0, 0]]) == -1\n assert candidate(grid = [[1, 1, 0, 0, 0, 0], [0, 1, 1, 0, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 1], [0, 0, 1, 1], [0, 0, 0, 0], [1, 1, 1, 1]]) == -1\n assert candidate(grid = [[1, 1, 1, 1, 0, 0], [1, 1, 1, 0, 0, 0], [1, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == 6\n assert candidate(grid = [[0, 0, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1], [0, 0, 0, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1], [0, 0, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[1, 1, 1, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1], [0, 1, 0, 0, 0], [1, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 1, 1, 1, 1], [0, 0, 1, 1, 1], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0], [0, 0, 1, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 13\n assert candidate(grid = [[1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1], [0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0]]) == 6\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1], [0, 0, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1]]) == -1\n assert candidate(grid = [[0, 0, 0, 1, 1, 0], [1, 0, 0, 0, 0, 1], [0, 1, 0, 0, 1, 0], [0, 0, 1, 1, 0, 0], [0, 1, 1, 0, 0, 0], [1, 0, 0, 0, 0, 0]]) == -1\n assert candidate(grid = [[0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0]]) == 8\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minSwaps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minSwaps(vector>& grid) {", "container": "Solution", "callable": "minSwaps", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1537, "task_id": "get-the-maximum-score", "difficulty": "Hard", "problem_description": "You are given two sorted arrays of distinct integers nums1 and nums2.\nA valid path is defined as follows:\n\nChoose array nums1 or nums2 to traverse (from index-0).\nTraverse the current array from left to right.\nIf you are reading any value that is present in nums1 and nums2 you are allowed to change your path to the other array. (Only one repeated value is considered in the valid path).\n\nThe score is defined as the sum of unique values in a valid path.\nReturn the maximum score you can obtain of all possible valid paths. Since the answer may be too large, return it modulo 109 + 7.\n \nExample 1:\n\n\nInput: nums1 = [2,4,5,8,10], nums2 = [4,6,8,9]\nOutput: 30\nExplanation: Valid paths:\n[2,4,5,8,10], [2,4,5,8,9], [2,4,6,8,9], [2,4,6,8,10], (starting from nums1)\n[4,6,8,9], [4,5,8,10], [4,5,8,9], [4,6,8,10] (starting from nums2)\nThe maximum is obtained with the path in green [2,4,6,8,10].\n\nExample 2:\n\nInput: nums1 = [1,3,5,7,9], nums2 = [3,5,100]\nOutput: 109\nExplanation: Maximum sum is obtained with the path [1,3,5,100].\n\nExample 3:\n\nInput: nums1 = [1,2,3,4,5], nums2 = [6,7,8,9,10]\nOutput: 40\nExplanation: There are no common elements between nums1 and nums2.\nMaximum sum is obtained with the path [6,7,8,9,10].\n\n \nConstraints:\n\n1 <= nums1.length, nums2.length <= 105\n1 <= nums1[i], nums2[i] <= 107\nnums1 and nums2 are strictly increasing.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [10000000],nums2 = [10000000]) == 10000000\n assert candidate(nums1 = [2, 4, 5, 8, 10],nums2 = [4, 6, 8, 9]) == 30\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6, 7, 8, 9, 10]) == 49\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 155\n assert candidate(nums1 = [1, 4, 6, 8, 10],nums2 = [2, 4, 6, 8, 12]) == 32\n assert candidate(nums1 = [5, 10, 15, 20],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [3, 5, 100]) == 109\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 7, 8, 9, 10]) == 40\n assert candidate(nums1 = [1, 2, 3],nums2 = [3, 4, 5]) == 15\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45, 55]) == 180\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [3, 4, 5, 6, 7, 8]) == 36\n assert candidate(nums1 = [10, 20, 30, 40],nums2 = [5, 15, 25, 35, 45]) == 125\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6]) == 15\n assert candidate(nums1 = [1, 10000000],nums2 = [2, 9999999]) == 10000001\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45]) == 150\n assert candidate(nums1 = [1],nums2 = [1]) == 1\n assert candidate(nums1 = [1, 4, 6, 8],nums2 = [2, 3, 5, 7]) == 19\n assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],nums2 = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 4095\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 605\n assert candidate(nums1 = [9999991, 9999992, 9999993, 9999994, 9999995, 9999996, 9999997, 9999998, 9999999, 10000000],nums2 = [10000001, 10000002, 10000003, 10000004, 10000005, 10000006, 10000007, 10000008, 10000009, 10000010]) == 100000055\n assert candidate(nums1 = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 551\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [5, 15, 25, 35, 45]) == 275\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 135\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 240\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 550\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 1300\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 195\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums1 = [1, 4, 6, 7, 10, 20, 30],nums2 = [2, 4, 5, 7, 11, 12, 15, 20]) == 107\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 100\n assert candidate(nums1 = [1, 4, 6, 7, 8, 10, 15, 20],nums2 = [2, 4, 5, 7, 9, 10, 13, 18]) == 73\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(nums1 = [2, 3, 6, 7, 11, 15],nums2 = [1, 2, 3, 8, 12, 16, 20]) == 62\n assert candidate(nums1 = [1, 2, 3, 5, 7, 9, 11, 13, 15, 17],nums2 = [4, 6, 8, 10, 12, 14, 16, 18, 20]) == 108\n assert candidate(nums1 = [1000000, 2000000, 3000000, 4000000, 5000000],nums2 = [1500000, 2500000, 3500000, 4500000, 5500000]) == 17500000\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 110\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(nums1 = [5, 15, 25, 35, 45],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 225\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5]) == 55\n assert candidate(nums1 = [10000000, 20000000, 30000000, 40000000, 50000000],nums2 = [15000000, 20000000, 25000000, 35000000, 40000000, 45000000, 55000000]) == 235000000\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 110\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],nums2 = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44]) == 990\n assert candidate(nums1 = [1, 4, 5, 6, 10, 15, 20, 25],nums2 = [2, 4, 7, 10, 12, 15, 22]) == 99\n assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],nums2 = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536]) == 3069\n assert candidate(nums1 = [1, 10000000],nums2 = [5000000, 10000000]) == 15000000\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 110\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 3, 5, 8, 9, 10, 12, 15, 18, 20]) == 104\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 120\n assert candidate(nums1 = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],nums2 = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 208\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [150, 250, 350, 450, 550, 650, 750, 850, 950, 1050]) == 6000\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 240\n assert candidate(nums1 = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97],nums2 = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98]) == 1250\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 240\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 550\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 420\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 420\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45, 55]) == 180\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 121\n assert candidate(nums1 = [1, 10000000],nums2 = [2, 9999999]) == 10000001\n assert candidate(nums1 = [1, 100, 1000, 10000, 100000],nums2 = [10, 100, 1000, 10000, 100000, 1000000]) == 1111110\n assert candidate(nums1 = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000],nums2 = [2, 20, 200, 2000, 20000, 200000, 2000000, 20000000]) == 22222222\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [15, 20, 25, 35, 40, 45, 55, 65, 70, 75, 85, 95]) == 640\n assert candidate(nums1 = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000],nums2 = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]) == 11111111\n assert candidate(nums1 = [1, 2, 4, 5, 7, 8, 10, 12],nums2 = [3, 4, 6, 7, 9, 10, 11, 13]) == 63\n assert candidate(nums1 = [1, 3, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 3, 5, 7, 11, 13, 17, 18, 19]) == 119\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 365\n assert candidate(nums1 = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 306\n assert candidate(nums1 = [10000000],nums2 = [9999999, 10000000, 10000001]) == 30000000\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 145\n assert candidate(nums1 = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28],nums2 = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29]) == 155\n assert candidate(nums1 = [2, 6, 10, 14, 18],nums2 = [3, 6, 9, 12, 15, 18, 21]) == 84\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40],nums2 = [10, 20, 30, 40, 50, 60, 70]) == 360\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 435\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) == 300\n assert candidate(nums1 = [3, 6, 9, 12, 15, 18, 21, 24],nums2 = [2, 5, 8, 11, 14, 17, 20, 23, 26]) == 126\n assert candidate(nums1 = [2, 4, 6, 8, 10],nums2 = [1, 3, 5, 7, 9, 10, 12]) == 47\n assert candidate(nums1 = [1, 4, 7, 10, 13, 16, 19],nums2 = [2, 5, 8, 11, 14, 17, 20]) == 77\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 730\n assert candidate(nums1 = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57],nums2 = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58]) == 450\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 1300\n assert candidate(nums1 = [10000000],nums2 = [5000000, 10000000, 15000000]) == 30000000\n assert candidate(nums1 = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 500\n assert candidate(nums1 = [1, 4, 7, 10, 13, 16, 19],nums2 = [2, 4, 6, 8, 10, 12, 14]) == 78\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 490\n assert candidate(nums1 = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45],nums2 = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44]) == 345\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 365\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [5, 10, 15, 20, 25]) == 115\n assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],nums2 = [512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456]) == 536870911\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 605\n assert candidate(nums1 = [1, 4, 6, 8, 10, 12, 14, 16, 18, 20],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 110\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 435\n assert candidate(nums1 = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == 2500\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 105\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],nums2 = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 1290\n assert candidate(nums1 = [1, 5, 10, 20, 30, 40, 50],nums2 = [3, 10, 15, 25, 35, 45, 55]) == 191\n assert candidate(nums1 = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000],nums2 = [250, 500, 750, 1000, 1250, 1500, 1750, 2000, 2250, 2500]) == 33750\n assert candidate(nums1 = [1000000, 2000000, 3000000, 4000000, 5000000],nums2 = [500000, 1000000, 1500000, 2000000, 2500000, 3000000, 3500000, 4000000, 4500000, 5000000]) == 27500000\n assert candidate(nums1 = [1, 10, 20, 30, 40],nums2 = [5, 15, 25, 35, 45]) == 125\n assert candidate(nums1 = [1, 4, 7, 10, 13, 16, 19],nums2 = [3, 4, 9, 10, 15, 16, 20]) == 77\n assert candidate(nums1 = [1, 4, 7, 10, 13, 16, 19],nums2 = [1, 5, 9, 13, 17, 21]) == 73\n assert candidate(nums1 = [1, 4, 7, 10, 13, 16, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18]) == 91\n assert candidate(nums1 = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],nums2 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 335\n assert candidate(nums1 = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97],nums2 = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98]) == 1250\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().maxSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxSum(vector& nums1, vector& nums2) {", "container": "Solution", "callable": "maxSum", "parameters": [{"name": "nums1", "type": "vector&"}, {"name": "nums2", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1539, "task_id": "kth-missing-positive-number", "difficulty": "Easy", "problem_description": "Given an array arr of positive integers sorted in a strictly increasing order, and an integer k.\nReturn the kth positive integer that is missing from this array.\n \nExample 1:\n\nInput: arr = [2,3,4,7,11], k = 5\nOutput: 9\nExplanation: The missing positive integers are [1,5,6,8,9,10,12,13,...]. The 5th missing positive integer is 9.\n\nExample 2:\n\nInput: arr = [1,2,3,4], k = 2\nOutput: 6\nExplanation: The missing positive integers are [5,6,7,...]. The 2nd missing positive integer is 6.\n\n \nConstraints:\n\n1 <= arr.length <= 1000\n1 <= arr[i] <= 1000\n1 <= k <= 1000\narr[i] < arr[j] for 1 <= i < j <= arr.length\n\n \nFollow up:\nCould you solve this problem in less than O(n) complexity?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 20\n assert candidate(arr = [10, 20, 30],k = 15) == 16\n assert candidate(arr = [2, 3, 4, 7, 11],k = 5) == 9\n assert candidate(arr = [5, 6, 7, 8, 9],k = 1) == 1\n assert candidate(arr = [5, 6, 8, 9, 10],k = 3) == 3\n assert candidate(arr = [1, 3, 5, 7],k = 3) == 6\n assert candidate(arr = [1, 3, 5, 7, 9],k = 4) == 8\n assert candidate(arr = [10, 20, 30],k = 5) == 5\n assert candidate(arr = [1, 2, 3, 4, 8, 10, 11],k = 5) == 12\n assert candidate(arr = [1, 2, 3, 4],k = 2) == 6\n assert candidate(arr = [10, 20, 30, 40],k = 15) == 16\n assert candidate(arr = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58],k = 60) == 80\n assert candidate(arr = [2, 5, 9, 11, 15, 18, 22, 25],k = 15) == 21\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 100) == 120\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 500) == 509\n assert candidate(arr = [5, 6, 8, 9, 11, 14, 17, 18, 21],k = 10) == 16\n assert candidate(arr = [5, 10, 15, 20, 25],k = 15) == 18\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 20) == 24\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98],k = 25) == 29\n assert candidate(arr = [1, 3, 7, 15, 31, 63, 127],k = 200) == 207\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97],k = 120) == 145\n assert candidate(arr = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59],k = 30) == 40\n assert candidate(arr = [2, 5, 10, 17, 26, 37, 49, 62, 76, 91, 107, 124, 142, 161, 181],k = 25) == 30\n assert candidate(arr = [1, 4, 6, 8, 11, 13, 15, 17, 19, 22, 24, 26, 28, 30, 32],k = 20) == 35\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 30) == 55\n assert candidate(arr = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1000],k = 1000) == 1011\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 15) == 25\n assert candidate(arr = [1, 4, 8, 13, 18, 23, 28, 33, 38],k = 20) == 26\n assert candidate(arr = [1, 4, 6, 9, 11, 15, 17, 20, 23],k = 10) == 16\n assert candidate(arr = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 200) == 221\n assert candidate(arr = [1, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 25) == 35\n assert candidate(arr = [5, 10, 15, 20, 25],k = 10) == 12\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 100) == 110\n assert candidate(arr = [2, 5, 10, 15, 20, 25, 30, 35, 40, 45],k = 15) == 19\n assert candidate(arr = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 75) == 94\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98],k = 150) == 164\n assert candidate(arr = [1, 2, 5, 8, 10, 13, 16, 19, 22, 25],k = 18) == 28\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 60\n assert candidate(arr = [2, 6, 10, 14, 18, 22, 26],k = 15) == 20\n assert candidate(arr = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],k = 75) == 84\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 30) == 40\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 30) == 34\n assert candidate(arr = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120],k = 150) == 165\n assert candidate(arr = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],k = 25) == 28\n assert candidate(arr = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14],k = 25) == 35\n assert candidate(arr = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71],k = 50) == 63\n assert candidate(arr = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58, 61, 64, 67, 70, 73, 76, 79, 82, 85, 88, 91, 94, 97, 100],k = 100) == 134\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 25) == 45\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],k = 50) == 54\n assert candidate(arr = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57],k = 30) == 40\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89],k = 100) == 110\n assert candidate(arr = [25, 50, 75, 100, 125, 150, 175, 200],k = 50) == 52\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],k = 75) == 90\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 10) == 19\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 7) == 10\n assert candidate(arr = [3, 7, 11, 15, 19, 23, 27, 31, 35],k = 20) == 26\n assert candidate(arr = [3, 8, 12, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79],k = 50) == 66\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140],k = 30) == 34\n assert candidate(arr = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],k = 50) == 57\n assert candidate(arr = [2, 5, 9, 12, 15, 18, 21, 24, 27, 30],k = 20) == 29\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140],k = 50) == 58\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 30\n assert candidate(arr = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93, 99],k = 40) == 48\n assert candidate(arr = [1, 2, 3, 5, 6, 7, 9, 10, 12, 13, 15, 16, 18, 19, 21],k = 30) == 45\n assert candidate(arr = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597],k = 100) == 109\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 10) == 19\n assert candidate(arr = [1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 15) == 26\n assert candidate(arr = [1, 2, 3, 5, 6, 7, 8, 10, 11, 12, 14, 15, 16, 18, 19, 20],k = 15) == 31\n assert candidate(arr = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45],k = 30) == 38\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],k = 7) == 10\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 450) == 454\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],k = 500) == 550\n assert candidate(arr = [5, 10, 15, 20, 25, 30],k = 12) == 14\n assert candidate(arr = [2, 5, 7, 11, 14, 17, 20, 23, 26, 29],k = 40) == 50\n assert candidate(arr = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 150) == 171\n assert candidate(arr = [1, 2, 3, 5, 6, 8, 9, 11, 12, 14, 15, 17, 18, 20],k = 50) == 64\n assert candidate(arr = [4, 9, 14, 19, 24, 29, 34, 39, 44, 49],k = 25) == 31\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55],k = 10) == 16\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],k = 100) == 150\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 500) == 505\n assert candidate(arr = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987],k = 50) == 58\n assert candidate(arr = [1, 4, 7, 10, 13, 16, 19, 22, 25],k = 25) == 34\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220],k = 75) == 82\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 15) == 18\n assert candidate(arr = [2, 5, 8, 11, 15],k = 10) == 14\n assert candidate(arr = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255],k = 60) == 64\n assert candidate(arr = [1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 30) == 51\n assert candidate(arr = [300, 600, 900],k = 1000) == 1003\n assert candidate(arr = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987],k = 1000) == 1015\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 100) == 110\n assert candidate(arr = [1, 2, 3, 5, 6, 9, 11, 12, 15],k = 15) == 24\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165],k = 40) == 43\n assert candidate(arr = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],k = 100) == 102\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],k = 150) == 175\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 50) == 58\n assert candidate(arr = [2, 3, 5, 8, 12, 17, 23, 30, 38, 47],k = 35) == 44\n assert candidate(arr = [5, 6, 8, 10, 13, 14],k = 7) == 11\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 25) == 35\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42],k = 20) == 29\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 500) == 505\n assert candidate(arr = [5, 8, 12, 14, 20, 25],k = 8) == 10\n assert candidate(arr = [5, 6, 8, 10, 12, 14, 16, 18, 20],k = 10) == 17\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 20) == 35\n assert candidate(arr = [1, 2, 4, 7, 11, 15, 19, 24, 29, 35],k = 20) == 28\n assert candidate(arr = [11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50],k = 27) == 36\n assert candidate(arr = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],k = 25) == 32\n assert candidate(arr = [1, 2, 5, 6, 9, 10, 13, 14, 17, 18, 21, 22, 25, 26],k = 50) == 64\n assert candidate(arr = [2, 12, 22, 32, 42, 52, 62, 72, 82, 92, 102, 112, 122, 132, 142, 152, 162, 172, 182, 192, 202, 212, 222, 232, 242, 252, 262, 272, 282, 292, 302],k = 150) == 167\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],k = 13) == 15\n"}, "metadata": {"canonical_parameter_names": ["arr", "k"], "leetcode_dataset_entry_point": "Solution().findKthPositive", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int findKthPositive(vector& arr, int k) {", "container": "Solution", "callable": "findKthPositive", "parameters": [{"name": "arr", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1540, "task_id": "can-convert-string-in-k-moves", "difficulty": "Medium", "problem_description": "Given two strings s and t, your goal is to convert s into t in k moves or less.\nDuring the ith (1 <= i <= k) move you can:\n\nChoose any index j (1-indexed) from s, such that 1 <= j <= s.length and j has not been chosen in any previous move, and shift the character at that index i times.\nDo nothing.\n\nShifting a character means replacing it by the next letter in the alphabet (wrapping around so that 'z' becomes 'a'). Shifting a character by i means applying the shift operations i times.\nRemember that any index j can be picked at most once.\nReturn true if it's possible to convert s into t in no more than k moves, otherwise return false.\n \nExample 1:\n\nInput: s = \"input\", t = \"ouput\", k = 9\nOutput: true\nExplanation: In the 6th move, we shift 'i' 6 times to get 'o'. And in the 7th move we shift 'n' to get 'u'.\n\nExample 2:\n\nInput: s = \"abc\", t = \"bcd\", k = 10\nOutput: false\nExplanation: We need to shift each character in s one time to convert it into t. We can shift 'a' to 'b' during the 1st move. However, there is no way to shift the other characters in the remaining moves to obtain t from s.\n\nExample 3:\n\nInput: s = \"aab\", t = \"bbb\", k = 27\nOutput: true\nExplanation: In the 1st move, we shift the first 'a' 1 time to get 'b'. In the 27th move, we shift the second 'a' 27 times to get 'b'.\n\n \nConstraints:\n\n1 <= s.length, t.length <= 10^5\n0 <= k <= 10^9\ns, t contain only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abc\",t = \"abc\",k = 0) == True\n assert candidate(s = \"aaa\",t = \"zzz\",k = 702) == True\n assert candidate(s = \"abc\",t = \"bcd\",k = 10) == False\n assert candidate(s = \"abc\",t = \"xyz\",k = 702) == True\n assert candidate(s = \"abcd\",t = \"pqrs\",k = 100) == True\n assert candidate(s = \"zzz\",t = \"aaa\",k = 78) == True\n assert candidate(s = \"abcd\",t = \"pqrs\",k = 78) == False\n assert candidate(s = \"aaa\",t = \"abc\",k = 3) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"bcdefghijklmnopqrstuvwxyza\",k = 25) == False\n assert candidate(s = \"zzz\",t = \"aaa\",k = 25) == False\n assert candidate(s = \"aab\",t = \"bbb\",k = 27) == True\n assert candidate(s = \"a\",t = \"z\",k = 25) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"abcdefghijklmnopqrstuvwxyz\",k = 0) == True\n assert candidate(s = \"input\",t = \"ouput\",k = 9) == True\n assert candidate(s = \"repeatedchars\",t = \"sfpqeueftdsft\",k = 150) == True\n assert candidate(s = \"zzzzz\",t = \"aaaaa\",k = 122) == True\n assert candidate(s = \"aaaaaaaaaa\",t = \"zzzzzzzzzz\",k = 260) == True\n assert candidate(s = \"abcde\",t = \"edcba\",k = 155) == True\n assert candidate(s = \"wraparound\",t = \"xqcsbpsboe\",k = 150) == True\n assert candidate(s = \"abcdef\",t = \"fedcba\",k = 50) == True\n assert candidate(s = \"z\",t = \"a\",k = 1) == True\n assert candidate(s = \"xylophone\",t = \"xylophone\",k = 1) == True\n assert candidate(s = \"testcase\",t = \"testcase\",k = 0) == True\n assert candidate(s = \"pqrs\",t = \"abcd\",k = 76) == False\n assert candidate(s = \"xyz\",t = \"abc\",k = 25) == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zyxwvutsrqponmlkjihgfedcba\",k = 104) == True\n assert candidate(s = \"longstringexample\",t = \"mpjutjvqygfqfcqpf\",k = 300) == True\n assert candidate(s = \"xyzzxyzz\",t = \"abcdabcd\",k = 156) == True\n assert candidate(s = \"zzz\",t = \"abc\",k = 78) == True\n assert candidate(s = \"hello\",t = \"tqxxa\",k = 100) == False\n assert candidate(s = \"abcabcabc\",t = \"defdefdef\",k = 24) == False\n assert candidate(s = \"aaaaabbbbb\",t = \"bbbbbccccc\",k = 250) == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",t = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",k = 900) == True\n assert candidate(s = \"hello\",t = \"worry\",k = 100) == True\n assert candidate(s = \"python\",t = \"pythom\",k = 100) == True\n assert candidate(s = \"aquickbrownfoxjumpsoverthelazydog\",t = \"zptjhoqznbmmktgdobnkszemgsvx\",k = 1000) == False\n assert candidate(s = \"abcd\",t = \"dcba\",k = 10) == False\n assert candidate(s = \"mississippi\",t = \"ssissippi\",k = 100) == False\n assert candidate(s = \"hello\",t = \"khoor\",k = 15) == False\n assert candidate(s = \"almostthere\",t = \"bnmpsuusfsf\",k = 99) == False\n assert candidate(s = \"abcdefghij\",t = \"jihgfedcba\",k = 260) == True\n assert candidate(s = \"shifting\",t = \"zmtxlqjq\",k = 300) == True\n assert candidate(s = \"abcde\",t = \"edcba\",k = 156) == True\n assert candidate(s = \"abc\",t = \"bcd\",k = 2) == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"bcccdddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzza\",k = 1000) == False\n assert candidate(s = \"conversion\",t = \"cvqfvkzqpo\",k = 100) == True\n assert candidate(s = \"xyz\",t = \"abc\",k = 24) == False\n assert candidate(s = \"abcxyz\",t = \"bcdyza\",k = 27) == False\n assert candidate(s = \"zzzzzzzzzz\",t = \"aaaaaaaaaa\",k = 259) == True\n assert candidate(s = \"hello\",t = \"uifsf\",k = 100) == True\n assert candidate(s = \"abc\",t = \"xyz\",k = 100) == True\n assert candidate(s = \"thisisatest\",t = \"ujkjkfbtftu\",k = 150) == True\n assert candidate(s = \"aaaaaaa\",t = \"zzzzzzz\",k = 702) == True\n assert candidate(s = \"abcd\",t = \"abcd\",k = 0) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 1000) == True\n assert candidate(s = \"abcdabcdabcd\",t = \"efghefghijkl\",k = 100) == False\n assert candidate(s = \"aaaabbbb\",t = \"bbbbcccc\",k = 26) == False\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",t = \"bcdebcdebcdebcdebcdebcdebcdebcdebcdebcde\",k = 100) == False\n assert candidate(s = \"aaaaaaaaaaa\",t = \"bbbbbbbbbbb\",k = 1000) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"abcdefghijklmnopqrstuvwxyz\",k = 1) == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",t = \"aaaaaaaaaaaaaaaaaaaa\",k = 260) == False\n assert candidate(s = \"ab\",t = \"yz\",k = 51) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zabcdefghijklmnopqrstuvwxy\",k = 51) == False\n assert candidate(s = \"abcdabcdabcd\",t = \"efefefefefef\",k = 80) == False\n assert candidate(s = \"hello\",t = \"world\",k = 20) == False\n assert candidate(s = \"aabbaabb\",t = \"bbccbbcc\",k = 25) == False\n assert candidate(s = \"aaaabbbb\",t = \"bbbbcccc\",k = 100) == False\n assert candidate(s = \"aaaa\",t = \"bbbb\",k = 26) == False\n assert candidate(s = \"abcabcabcabcabcabc\",t = \"defdefdefdefdefdef\",k = 260) == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"bcdefghijklmnopqrstuvwxyza\",k = 200) == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"bcdefghijklmnopqrstuvwxyza\",k = 26) == False\n assert candidate(s = \"azazaz\",t = \"bbbbbb\",k = 78) == True\n assert candidate(s = \"aabbcc\",t = \"bbccdd\",k = 29) == False\n assert candidate(s = \"abcdabcd\",t = \"bcdebcde\",k = 10) == False\n assert candidate(s = \"hello\",t = \"world\",k = 51) == True\n assert candidate(s = \"zzzz\",t = \"aaaa\",k = 104) == True\n assert candidate(s = \"aaaaaaaaaa\",t = \"bbbbbbbbbb\",k = 100) == False\n assert candidate(s = \"hello\",t = \"ifmmp\",k = 5) == False\n assert candidate(s = \"abcd\",t = \"dcba\",k = 104) == True\n assert candidate(s = \"abcd\",t = \"dcba\",k = 100) == True\n assert candidate(s = \"abacabadabacaba\",t = \"bcbbcadbbcbcbbc\",k = 200) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 675) == True\n assert candidate(s = \"aaaaaaaaaaaa\",t = \"bbbbbbbbbbbb\",k = 12) == False\n assert candidate(s = \"python\",t = \"python\",k = 0) == True\n assert candidate(s = \"abcabcabc\",t = \"defdefdef\",k = 26) == False\n assert candidate(s = \"hello\",t = \"world\",k = 52) == True\n assert candidate(s = \"abcdef\",t = \"ghijkl\",k = 18) == False\n assert candidate(s = \"xyz\",t = \"abc\",k = 77) == True\n assert candidate(s = \"abcdefghij\",t = \"jihgfedcba\",k = 100) == True\n assert candidate(s = \"same\",t = \"same\",k = 10) == True\n assert candidate(s = \"programming\",t = \"qpsxstjnnqj\",k = 200) == True\n assert candidate(s = \"programming\",t = \"programming\",k = 1000) == True\n assert candidate(s = \"conversion\",t = \"wxvqivlxnt\",k = 500) == True\n assert candidate(s = \"thisisatest\",t = \"ytnsytyfyty\",k = 150) == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\",t = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaa\",k = 1325) == True\n assert candidate(s = \"aaa\",t = \"zzz\",k = 701) == True\n assert candidate(s = \"a\",t = \"a\",k = 0) == True\n assert candidate(s = \"aaa\",t = \"zzz\",k = 78) == True\n assert candidate(s = \"conversion\",t = \"hxqzsrqvok\",k = 200) == True\n assert candidate(s = \"aaa\",t = \"abc\",k = 2) == True\n assert candidate(s = \"abcdefgh\",t = \"hgfedcba\",k = 50) == True\n assert candidate(s = \"abcabcabc\",t = \"defdefdef\",k = 78) == False\n assert candidate(s = \"mississippi\",t = \"vvvttttpppp\",k = 260) == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"bcdefghijklmnopqrstuvwxyza\",k = 260) == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",t = \"zabcdefghijklmnopqrstuvwxy\",k = 100) == False\n assert candidate(s = \"racecar\",t = \"racecar\",k = 100) == True\n assert candidate(s = \"aabbcc\",t = \"bbccdd\",k = 30) == False\n assert candidate(s = \"aabbaabb\",t = \"bbccbbcc\",k = 26) == False\n assert candidate(s = \"aaaa\",t = \"zzzz\",k = 103) == True\n assert candidate(s = \"python\",t = \"qzuipo\",k = 65) == False\n assert candidate(s = \"zzzzz\",t = \"aaaab\",k = 130) == True\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",t = \"bcdbcdbcdbcdbcdbcdbcdbcdbcdbcdbcdcb\",k = 260) == False\n assert candidate(s = \"mississippi\",t = \"aaaaaaaaaaa\",k = 130) == True\n assert candidate(s = \"yzyzyzyzyz\",t = \"acacacacac\",k = 520) == True\n assert candidate(s = \"hello\",t = \"world\",k = 50) == True\n assert candidate(s = \"quickbrownfox\",t = \"rvjdlqpsqfy\",k = 200) == False\n assert candidate(s = \"leetcode\",t = \"leetcode\",k = 0) == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",t = \"bbaacceeggiikkmmppttuuwwyyzzeeddfgghhjjoonnuuxx\",k = 1000) == False\n assert candidate(s = \"longstringwithmultiplecharacters\",t = \"nqprxuixwqywwpdqfhhcifqtf\",k = 500) == False\n"}, "metadata": {"canonical_parameter_names": ["s", "t", "k"], "leetcode_dataset_entry_point": "Solution().canConvertString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool canConvertString(string s, string t, int k) {", "container": "Solution", "callable": "canConvertString", "parameters": [{"name": "s", "type": "string"}, {"name": "t", "type": "string"}, {"name": "k", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1541, "task_id": "minimum-insertions-to-balance-a-parentheses-string", "difficulty": "Medium", "problem_description": "Given a parentheses string s containing only the characters '(' and ')'. A parentheses string is balanced if:\n\nAny left parenthesis '(' must have a corresponding two consecutive right parenthesis '))'.\nLeft parenthesis '(' must go before the corresponding two consecutive right parenthesis '))'.\n\nIn other words, we treat '(' as an opening parenthesis and '))' as a closing parenthesis.\n\nFor example, \"())\", \"())(())))\" and \"(())())))\" are balanced, \")()\", \"()))\" and \"(()))\" are not balanced.\n\nYou can insert the characters '(' and ')' at any position of the string to balance it if needed.\nReturn the minimum number of insertions needed to make s balanced.\n \nExample 1:\n\nInput: s = \"(()))\"\nOutput: 1\nExplanation: The second '(' has two matching '))', but the first '(' has only ')' matching. We need to add one more ')' at the end of the string to be \"(())))\" which is balanced.\n\nExample 2:\n\nInput: s = \"())\"\nOutput: 0\nExplanation: The string is already balanced.\n\nExample 3:\n\nInput: s = \"))())(\"\nOutput: 3\nExplanation: Add '(' to match the first '))', Add '))' to match the last '('.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists of '(' and ')' only.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"(()))\") == 1\n assert candidate(s = \"))())(\") == 3\n assert candidate(s = \"())\") == 0\n assert candidate(s = \"(()(())))))))))))()()\") == 6\n assert candidate(s = \"(()))(()))(()))(()))(())))()\") == 5\n assert candidate(s = \"(()(()(()(()(())))))\") == 10\n assert candidate(s = \"()(()(()))())(()(()))()\") == 10\n assert candidate(s = \"(()(()(())))()(()(()(())))()()\") == 15\n assert candidate(s = \"(((()(()(()(()(())))))()))))))))))))))))))))\") == 10\n assert candidate(s = \"(()(()(())))()(()(()(())))\") == 13\n assert candidate(s = \"((((((())\") == 12\n assert candidate(s = \"(()(()(()(()(())))))))()(()))(())))()\") == 11\n assert candidate(s = \")((((()))))))))))))\") == 5\n assert candidate(s = \"(()(()))())\") == 4\n assert candidate(s = \"((((((())))))\") == 8\n assert candidate(s = \"(((((())))))))\") == 4\n assert candidate(s = \"(()())()(()(()(())))\") == 10\n assert candidate(s = \"((((((())))))))))\") == 4\n assert candidate(s = \"(()(()(())))()()(()(()(()))))(()))(()))(()))\") == 16\n assert candidate(s = \"()()()()()()()()()()()()()()()()\") == 16\n assert candidate(s = \"(()))(()))(()))(()))(()))(()))(()))(()))(()))\") == 9\n assert candidate(s = \"((())()())\") == 5\n assert candidate(s = \"(()))(()(()))\") == 5\n assert candidate(s = \"()(()(()(()(()(()))))())()()\") == 14\n assert candidate(s = \"())()(()))\") == 2\n assert candidate(s = \"((((()))))(()(()))()(()(()))()()\") == 16\n assert candidate(s = \"(()(()))(()(()))(()(()))(()(()))\") == 16\n assert candidate(s = \"))))))))))))))))\") == 8\n assert candidate(s = \"(()(((()(()))())()()(())))\") == 13\n assert candidate(s = \"(((((())))(((((())))\") == 16\n assert candidate(s = \"((((((((()))))))))\") == 9\n assert candidate(s = \"(()(()(()(()(())))))))\") == 8\n assert candidate(s = \"(((()))))()(()(()))(()(()))()\") == 13\n assert candidate(s = \"((((((()))))))\") == 7\n assert candidate(s = \"(()))(()))(()())\") == 5\n assert candidate(s = \"((())))))((()))))\") == 1\n assert candidate(s = \"(()(()(())))()()(()(()(())))()()(()(()(())))\") == 22\n assert candidate(s = \"(((((())))))()(()))(()))(()))(()))(()))\") == 12\n assert candidate(s = \"()(()(()(()(()(()))))())()\") == 13\n assert candidate(s = \"()(()(()(()(()))))(())))\") == 9\n assert candidate(s = \")(((((((((((((())))))))))))\") == 18\n assert candidate(s = \"((((()))))(()(()))()(()(()))\") == 14\n assert candidate(s = \"()(()(()(()(()(()(())))))()()()()()()()()()\") == 23\n assert candidate(s = \"(((((())))(((((())))))))\") == 12\n assert candidate(s = \"(()))(()))(()))(()))(()))(()))(()))(()))\") == 8\n assert candidate(s = \")(()))(()(()))\") == 7\n assert candidate(s = \"(()))(()))(()))(()))(()))(()))(()))(()))(()))(()))(()))(()))\") == 12\n assert candidate(s = \"(()(()(())))()()(()(()(()))))(()))\") == 14\n assert candidate(s = \"()(()(()(()(()(()))))())()()()\") == 15\n assert candidate(s = \"()()()()()()()()()()\") == 10\n assert candidate(s = \"(((((()))(()))()))\") == 9\n assert candidate(s = \"(((()))))()(()(()))(()(()))\") == 12\n assert candidate(s = \"(((((((((())))))))\") == 12\n assert candidate(s = \"(()((())(()))\") == 8\n assert candidate(s = \"((((((((((((((())))))))))))))()()()()()()()()()()()()()()()()()()()()()()()\") == 39\n assert candidate(s = \"(()))(()(()))())\") == 5\n assert candidate(s = \"(()))())\") == 1\n assert candidate(s = \"()()()()\") == 4\n assert candidate(s = \"(()))(()))(()(()()(())))\") == 9\n assert candidate(s = \"(()))(()))(()))(()))\") == 4\n assert candidate(s = \"(((((((((((((())))))))))))\") == 16\n assert candidate(s = \"(()(()(()(()(())))))))()(()))\") == 10\n assert candidate(s = \"((((()))))))\") == 3\n assert candidate(s = \"(()))(()))(()))(()))(()))(()))\") == 6\n assert candidate(s = \"(()(()(()(())))()())\") == 10\n assert candidate(s = \"())(()))(()(()))\") == 5\n assert candidate(s = \"(()(()(()(()(())))))))()(()))(())))\") == 10\n assert candidate(s = \"(()(()(())))\") == 6\n assert candidate(s = \"(()))(()))(()))\") == 3\n assert candidate(s = \"(()))(()))(()))(()))(()))(()))(()))\") == 7\n assert candidate(s = \"((()))()()()()()()()\") == 10\n assert candidate(s = \"(()))())(())))\") == 1\n assert candidate(s = \")()()()()()()()()()()()()()()()()()()()()()\") == 23\n assert candidate(s = \"(((((()))())(()(((()))())))\") == 15\n assert candidate(s = \"()(()(()(()(()(()(())))))()()()()()()()()()()()()()()\") == 28\n assert candidate(s = \"(((((())))))()(()))(()))(()))(()))(()))()(()))(()))(()))()(()))(()))()(()))\") == 21\n assert candidate(s = \"()(()(()(()(()))))\") == 9\n assert candidate(s = \"(()))(()))(()))(()))(()))(()))(()))(()))(()))(()))\") == 10\n assert candidate(s = \"()(()(()(()(()(()))())))\") == 12\n assert candidate(s = \"()((((()))))))((((()))))))\") == 7\n assert candidate(s = \"(()(()))(()\") == 7\n assert candidate(s = \"(((())))\") == 4\n assert candidate(s = \"(((((())))))()(()))(()))(()))(()))(()))()(()))(()))(()))\") == 16\n assert candidate(s = \"(()(()(()(()(())))))))()()\") == 10\n assert candidate(s = \"()(()(()(()(()(()))())))()()\") == 14\n assert candidate(s = \"(()(()(()(()(())))))))()())\") == 9\n assert candidate(s = \"())()(()(()(()(()))))\") == 9\n assert candidate(s = \"))))(((\") == 8\n assert candidate(s = \"(()(()(()(()))))())\") == 8\n assert candidate(s = \"(()))(()))(())))\") == 2\n assert candidate(s = \"()(()(()(())))()\") == 8\n assert candidate(s = \"(()(()(())))()()(()(()(()))))(()))(()))(()))(()))\") == 17\n assert candidate(s = \"()()()()()()()()()()(()(()(()(()(())))))\") == 20\n assert candidate(s = \"(()(()(()(()(()))))(())))\") == 11\n assert candidate(s = \")()()()()()()\") == 8\n assert candidate(s = \"()(()(()(()(()(()))))())\") == 12\n assert candidate(s = \"(()))(()))(()))(()))(()))\") == 5\n assert candidate(s = \"(()(()(())))()()(()(()(())))\") == 14\n assert candidate(s = \"(()))(()(()(())))()()(()(()(()))))(()))(()))\") == 16\n assert candidate(s = \"(((((()))))(()(()))(()(()))()()()()\") == 19\n assert candidate(s = \"((((((((((((()))))))))))))))))\") == 9\n assert candidate(s = \"(()(()))())(()))\") == 5\n assert candidate(s = \"(()))(()))\") == 2\n assert candidate(s = \"()()()()()()\") == 6\n assert candidate(s = \"(()))(((())))((()))(()))()()(()(())))\") == 14\n assert candidate(s = \"()))))(((()))(()))\") == 9\n assert candidate(s = \"(()))(()(()(()))())\") == 8\n assert candidate(s = \"(()(()(()(()(()))))))))))))))\") == 7\n assert candidate(s = \"((()))))\") == 1\n assert candidate(s = \"())(()(()(()))())\") == 7\n assert candidate(s = \"((((((()))))))))\") == 5\n assert candidate(s = \"()()()()()()()()()\") == 9\n assert candidate(s = \"()(()(()(()(()(()(())))))()()()()()()\") == 20\n assert candidate(s = \"((((()))))(()(()))()(()(()))()()()\") == 17\n assert candidate(s = \"(()(()(()(()(())))))))()(()))(()))\") == 11\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minInsertions", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minInsertions(string s) {", "container": "Solution", "callable": "minInsertions", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1542, "task_id": "find-longest-awesome-substring", "difficulty": "Hard", "problem_description": "You are given a string s. An awesome substring is a non-empty substring of s such that we can make any number of swaps in order to make it a palindrome.\nReturn the length of the maximum length awesome substring of s.\n \nExample 1:\n\nInput: s = \"3242415\"\nOutput: 5\nExplanation: \"24241\" is the longest awesome substring, we can form the palindrome \"24142\" with some swaps.\n\nExample 2:\n\nInput: s = \"12345678\"\nOutput: 1\n\nExample 3:\n\nInput: s = \"213123\"\nOutput: 6\nExplanation: \"213123\" is the longest awesome substring, we can form the palindrome \"231132\" with some swaps.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists only of digits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1111\") == 4\n assert candidate(s = \"1000000001\") == 10\n assert candidate(s = \"9876543210\") == 1\n assert candidate(s = \"213123\") == 6\n assert candidate(s = \"9437493749\") == 9\n assert candidate(s = \"1221\") == 4\n assert candidate(s = \"1232112321\") == 10\n assert candidate(s = \"122112211\") == 9\n assert candidate(s = \"123454321\") == 9\n assert candidate(s = \"98765432100123456789\") == 20\n assert candidate(s = \"1111111111\") == 10\n assert candidate(s = \"0000000000000000000\") == 19\n assert candidate(s = \"2020202020\") == 9\n assert candidate(s = \"1111111\") == 7\n assert candidate(s = \"0123456789\") == 1\n assert candidate(s = \"3242415\") == 5\n assert candidate(s = \"2002\") == 4\n assert candidate(s = \"0123210\") == 7\n assert candidate(s = \"1234567890987654321\") == 19\n assert candidate(s = \"00\") == 2\n assert candidate(s = \"12321\") == 5\n assert candidate(s = \"202020202\") == 9\n assert candidate(s = \"12345678\") == 1\n assert candidate(s = \"12345432101234543210\") == 20\n assert candidate(s = \"123454321123454321\") == 18\n assert candidate(s = \"2211001122110011221\") == 19\n assert candidate(s = \"12345678901234567890123456789012345678901234567890\") == 41\n assert candidate(s = \"1234321987897898765456543213212345654321234321\") == 27\n assert candidate(s = \"99887766554433221100000000112233445566778899\") == 44\n assert candidate(s = \"9876543211234567890\") == 19\n assert candidate(s = \"1111111111111111111\") == 19\n assert candidate(s = \"111112222233333444445555566666777778888899999\") == 13\n assert candidate(s = \"999999999999999999999999999999999999999999999999999\") == 51\n assert candidate(s = \"123321122132123321122132123321122132123321\") == 39\n assert candidate(s = \"1232100000000000000012321\") == 25\n assert candidate(s = \"123456543210101\") == 15\n assert candidate(s = \"000000111111222222333333\") == 24\n assert candidate(s = \"112233445566778899\") == 18\n assert candidate(s = \"1122334455667788990000998877665544332211\") == 40\n assert candidate(s = \"0000000000\") == 10\n assert candidate(s = \"5959595959595959595\") == 19\n assert candidate(s = \"2211221133443344\") == 16\n assert candidate(s = \"1221333122133312213331221\") == 25\n assert candidate(s = \"99887766554433221100112233445566778899\") == 38\n assert candidate(s = \"123456789098765432101234567890\") == 21\n assert candidate(s = \"1234543210987654321\") == 9\n assert candidate(s = \"54321098765432109876543210987654321098765432109876\") == 41\n assert candidate(s = \"1234567890123456789012345678901234567890\") == 40\n assert candidate(s = \"01234567890987654321\") == 20\n assert candidate(s = \"987654321098765432109876543210987654321098765432109876543210987654321098765432109876543210\") == 81\n assert candidate(s = \"22221111000033334444\") == 20\n assert candidate(s = \"12345678900000000001\") == 11\n assert candidate(s = \"9090909090909090909090909090909090909090909090909090\") == 52\n assert candidate(s = \"123123123123123123123123123123123123123123123123123\") == 49\n assert candidate(s = \"99999999999999999999\") == 20\n assert candidate(s = \"1234567898765432112345678987654321\") == 34\n assert candidate(s = \"11111111111111111111\") == 20\n assert candidate(s = \"11223344556677889900\") == 20\n assert candidate(s = \"1122334455667788990099887766554433221100001100\") == 46\n assert candidate(s = \"1221122112211221122112211221122112211221122112211221\") == 52\n assert candidate(s = \"999988887777666655554444333322221111\") == 36\n assert candidate(s = \"5555555555\") == 10\n assert candidate(s = \"32165498798546123\") == 17\n assert candidate(s = \"00000000000000000000000000000000000000000000000\") == 47\n assert candidate(s = \"2468024680246802468\") == 19\n assert candidate(s = \"123432101234321\") == 15\n assert candidate(s = \"98765432109876543210\") == 20\n assert candidate(s = \"3332222211111000000\") == 15\n assert candidate(s = \"12345678909876543210123456789098765432101234567890\") == 41\n assert candidate(s = \"111222333444555666777888999\") == 7\n assert candidate(s = \"020406080080604020\") == 18\n assert candidate(s = \"98765432123456789\") == 17\n assert candidate(s = \"1122334455667788990011\") == 22\n assert candidate(s = \"01234567898765432101234567890\") == 21\n assert candidate(s = \"1221122112211\") == 13\n assert candidate(s = \"111222333444555666777\") == 7\n assert candidate(s = \"12213332211233333312\") == 19\n assert candidate(s = \"998877665544332211000112233445566778899\") == 39\n assert candidate(s = \"11112222333344445555\") == 20\n assert candidate(s = \"12345432112345432100\") == 20\n assert candidate(s = \"0246802468024680246\") == 19\n assert candidate(s = \"101010101010101010101010101010101010101010101010101\") == 51\n assert candidate(s = \"0121021012321012321\") == 19\n assert candidate(s = \"9999888877776666555544443333222211110000\") == 40\n assert candidate(s = \"9876543210987654321\") == 19\n assert candidate(s = \"98765432109876543210987654321098765432109876543210\") == 41\n assert candidate(s = \"12321232123212321\") == 17\n assert candidate(s = \"0101010101010101010\") == 19\n assert candidate(s = \"789789789\") == 7\n assert candidate(s = \"12332145654\") == 11\n assert candidate(s = \"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\") == 81\n assert candidate(s = \"111222333444555666777888999000\") == 7\n assert candidate(s = \"98765432100000000009\") == 11\n assert candidate(s = \"9999999999\") == 10\n assert candidate(s = \"0000000000111111111122222222223333333333\") == 40\n assert candidate(s = \"1357913579135791357\") == 19\n assert candidate(s = \"10203040504030201\") == 17\n assert candidate(s = \"123454321012321\") == 9\n assert candidate(s = \"55555555555555555555\") == 20\n assert candidate(s = \"12345678900987654321\") == 20\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101\") == 52\n assert candidate(s = \"00000000000000000000\") == 20\n assert candidate(s = \"123123123123123123\") == 18\n assert candidate(s = \"111222333444555666\") == 7\n assert candidate(s = \"12213332122133321\") == 17\n assert candidate(s = \"01010101010101\") == 13\n assert candidate(s = \"1122334455667788990011223344556677889900\") == 40\n assert candidate(s = \"555555555555555555555555555555555555\") == 36\n assert candidate(s = \"9876543210123456789\") == 19\n assert candidate(s = \"001122334455667788990099887766554433221100\") == 42\n assert candidate(s = \"5555555555555555555555\") == 22\n assert candidate(s = \"1010101010101010101010101010101010101010\") == 40\n assert candidate(s = \"9988776655443322110099887766554433221100\") == 40\n assert candidate(s = \"1122334455667788990099887766554433221100000000\") == 46\n assert candidate(s = \"00112233445566778899\") == 20\n assert candidate(s = \"122112333211\") == 11\n assert candidate(s = \"00000000000000000001\") == 19\n assert candidate(s = \"1223344556677889900998877665544332211\") == 37\n assert candidate(s = \"1234567890098765432112345678900987654321\") == 40\n assert candidate(s = \"111122223333444455556666\") == 24\n assert candidate(s = \"00000111112222233333444445555566666777778888899999\") == 13\n assert candidate(s = \"10000000000000000001\") == 20\n assert candidate(s = \"000111222333444555666\") == 7\n assert candidate(s = \"12345678900987654321012345678998765432101234567890\") == 41\n assert candidate(s = \"12345678900000000000\") == 11\n assert candidate(s = \"0220220120\") == 7\n assert candidate(s = \"123123123123123\") == 13\n assert candidate(s = \"10101010101010101010\") == 20\n assert candidate(s = \"1122334455667788991111222233334444\") == 34\n assert candidate(s = \"98765432100123456789987654321001234567899876543210\") == 41\n assert candidate(s = \"121312131213121312131213121312131213\") == 35\n assert candidate(s = \"5554443332221110000\") == 9\n assert candidate(s = \"010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\") == 96\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().longestAwesome", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int longestAwesome(string s) {", "container": "Solution", "callable": "longestAwesome", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1544, "task_id": "make-the-string-great", "difficulty": "Easy", "problem_description": "Given a string s of lower and upper case English letters.\nA good string is a string which doesn't have two adjacent characters s[i] and s[i + 1] where:\n\n0 <= i <= s.length - 2\ns[i] is a lower-case letter and s[i + 1] is the same letter but in upper-case or vice-versa.\n\nTo make the string good, you can choose two adjacent characters that make the string bad and remove them. You can keep doing this until the string becomes good.\nReturn the string after making it good. The answer is guaranteed to be unique under the given constraints.\nNotice that an empty string is also good.\n \nExample 1:\n\nInput: s = \"leEeetcode\"\nOutput: \"leetcode\"\nExplanation: In the first step, either you choose i = 1 or i = 2, both will result \"leEeetcode\" to be reduced to \"leetcode\".\n\nExample 2:\n\nInput: s = \"abBAcC\"\nOutput: \"\"\nExplanation: We have many possible scenarios, and all lead to the same answer. For example:\n\"abBAcC\" --> \"aAcC\" --> \"cC\" --> \"\"\n\"abBAcC\" --> \"abBA\" --> \"aA\" --> \"\"\n\nExample 3:\n\nInput: s = \"s\"\nOutput: \"s\"\n\n \nConstraints:\n\n1 <= s.length <= 100\ns contains only lower and upper case English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcdefg\") == \"abcdefg\"\n assert candidate(s = \"ABCDEFG\") == \"ABCDEFG\"\n assert candidate(s = \"vVtTkKsSiIdDgGhHjJfFcCrRlLpPoOeEaAqQzZxXcCvVbBnNmM\") == \"\"\n assert candidate(s = \"aAbBcCdDeEfFgG\") == \"\"\n assert candidate(s = \"Ab\") == \"Ab\"\n assert candidate(s = \"abBAcC\") == \"\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n assert candidate(s = \"aBbAcC\") == \"\"\n assert candidate(s = \"aabAAB\") == \"aabAAB\"\n assert candidate(s = \"\") == \"\"\n assert candidate(s = \"AbcCdEfGhIjKlMnOpQrStUvWxYz\") == \"AbdEfGhIjKlMnOpQrStUvWxYz\"\n assert candidate(s = \"aBbAcCdDeEfFgG\") == \"\"\n assert candidate(s = \"ZyXwVuTsRqPoNmLkJiHgFeDcBa\") == \"ZyXwVuTsRqPoNmLkJiHgFeDcBa\"\n assert candidate(s = \"abcABC\") == \"abcABC\"\n assert candidate(s = \"QwErTyUiOpAsDfGhJkLzXcVbNm\") == \"QwErTyUiOpAsDfGhJkLzXcVbNm\"\n assert candidate(s = \"aA\") == \"\"\n assert candidate(s = \"leEeetcode\") == \"leetcode\"\n assert candidate(s = \"AaAaAa\") == \"\"\n assert candidate(s = \"s\") == \"s\"\n assert candidate(s = \"abcAbC\") == \"abcAbC\"\n assert candidate(s = \"AbcabcABC\") == \"AbcabcABC\"\n assert candidate(s = \"aBcAdBeCfD\") == \"aBcAdBeCfD\"\n assert candidate(s = \"AaBbCc\") == \"\"\n assert candidate(s = \"aB\") == \"aB\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYz\") == \"AbCdEfGhIjKlMnOpQrStUvWxYz\"\n assert candidate(s = \"aAbB\") == \"\"\n assert candidate(s = \"aaBBccDDeeFFggHHiiJJkkLLmmNNooppQQrrSSttuuVVwwXXyyZZ\") == \"aaBBccDDeeFFggHHiiJJkkLLmmNNooppQQrrSSttuuVVwwXXyyZZ\"\n assert candidate(s = \"ZzYyXxWwVvUuTtSsRrQqPpOoNnMmLlKkJjIiHhGgFfEeDdCcBbAa\") == \"\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaB\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaB\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZzYxWvUtSrQpOnMlKjIhGfEdCbA\") == \"\"\n assert candidate(s = \"aBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcD\") == \"aBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcDaBcD\"\n assert candidate(s = \"abABabABabABabABabAB\") == \"abABabABabABabABabAB\"\n assert candidate(s = \"ZzYyXxWwVvUuTtSsRrQqPpOoNnMmLlKkJiHhGgFfEeDdCcBbAa\") == \"Ji\"\n assert candidate(s = \"XyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"XyZ\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStVuWxYzAbCdEfGhIjKlMnOpQrStVuWxYzAbCdEfGhIjKlMnOpQrStVuWxYzAbCdEfGhIjKlMnOpQrStVuWxYz\") == \"AbCdEfGhIjKlMnOpQrStVuWxYzAbCdEfGhIjKlMnOpQrStVuWxYzAbCdEfGhIjKlMnOpQrStVuWxYzAbCdEfGhIjKlMnOpQrStVuWxYz\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAa\") == \"\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZyXwVuTsRqPoNlKjIhGfEdCbAaB\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZyXwVuTsRqPoNlKjIhGfEdC\"\n assert candidate(s = \"zZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKiIjJhHgGfFeEdDcCbBaA\") == \"\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzYxWVuTsRqPoNlKjIhGfEdCbAaBc\") == \"AbCdEfGhIjKlMnOpQrStUvWxYzYxWVuTsRqPoNlKjIhGfEd\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJ\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzabcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aBcCdDeEfFgGHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"aB\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBc\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBc\"\n assert candidate(s = \"AbCDefGhIjKlMnOpQrStUvWxYzZyXwVuTsRqPoNlKjIhGfEdCbAaBcDe\") == \"AbCDefGhIjKlMlKjIhGf\"\n assert candidate(s = \"aBcAbCDefEDfGhIGhIJkIkJlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aBcAbCDefEDfGhIGhIJkIkJ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCd\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZd\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCd\") == \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCd\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz\") == \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStVuWxYzABcDEfGHijKLmNoPQRSTuvWXyZ\") == \"AbCdEfGhIjKlMnOpQrStVuWxYzABcDEfGHijKLmNoPQRSTuvWXyZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZyXwVuTsRqPoNlKjIhGfEdCbAaBcDeFaGbHcIeJfKgHlIjKlM\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZyXwVuTsRqPoNlKjIhGaGbHcIeJfKgHlIjKlM\"\n assert candidate(s = \"bBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBbBb\") == \"b\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ1234567890\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ1234567890\"\n assert candidate(s = \"mNbvCxzlKjHgfDsApoiuYtrewqQ\") == \"mNbvCxzlKjHgfDsApoiuYtrew\"\n assert candidate(s = \"aAbBcCdDeEfFgGHh\") == \"\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZzYxWvUtSrQpOnMlKjIgFeDcBa\") == \"aBcDeFgHgFeDcBa\"\n assert candidate(s = \"aBcAbCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaA\") == \"aBcAbC\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"\"\n assert candidate(s = \"abcdEfghIjklMNopQRstUVwxYZ\") == \"abcdEfghIjklMNopQRstUVwxYZ\"\n assert candidate(s = \"AbCdeFgHijklmNoPQRstUvWxYz\") == \"AbCdeFgHijklmNoPQRstUvWxYz\"\n assert candidate(s = \"bBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAb\") == \"b\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzABcdEFghIJklMNopQRstUVwxYZ\") == \"AbCdEfGhIjKlMnOpQrStUvWxYzABcdEFghIJklMNopQRstUVwxYZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDe\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZe\"\n assert candidate(s = \"zZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzZyXwVuTsRqPoNlKjIhGfEdCbA\") == \"AbCdEfGhIjKlMlKjIhGfEdCbA\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz\") == \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEf\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZf\"\n assert candidate(s = \"abcdefgHIJKLMnopqrstuvwxyz\") == \"abcdefgHIJKLMnopqrstuvwxyz\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"AbcDefGhIjKlMnOpQrStVuWxYzabcDEFghijKLMnopqrSTUVwxyZ\") == \"AbcDefGhIjKlMnOpQrStVuWxYzabcDEFghijKLMnopqrSTUVwxyZ\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgG\") == \"\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA\") == \"zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhH\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"aBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890!@#$%^&*()\") == \"a1234567890!@#$%^&*()\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZyXwVuTsRqPoNlKjIhGfEdCbAaBcDeFaGbHcIeJfKgHlIjKlMnOpQrStUvWxYzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZyXwVuTsRqPoNlKjIhGaGbHcIeJfKgHlIjKlMnOpQrStUvWxYz\"\n assert candidate(s = \"AbCbaBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"AbCbaB\"\n assert candidate(s = \"mNnMoPpQqRrSsTtUuVvWwXxYyZz\") == \"o\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"\"\n assert candidate(s = \"aBbAcCcAdDdAeEeAfFfAgGgAhHhAiIiAjJjAkKkAlLlAmMmAnNnAoOoApPpAqQqArRrAsStTuUuAvVvAwWwAxXxAyYyAzZz\") == \"cAdAeAfAgAhAiAjAkAlAmAnAoApAqArAuAvAwAxAyAz\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz\") == \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz\"\n assert candidate(s = \"aBbAcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"\"\n assert candidate(s = \"abcABCabcABC\") == \"abcABCabcABC\"\n assert candidate(s = \"xYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZ\") == \"xYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZ\"\n assert candidate(s = \"abcABCabcABCabcABCabcABC\") == \"abcABCabcABCabcABCabcABC\"\n assert candidate(s = \"ThisIsATestStringToCheckTheFunctionalityOfTheGivenCode\") == \"ThisIsATestStringToCheckTheFunctionalityOfTheGivenCode\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzZyXwVuTsRqPoNlKjIhGfEdCbAaBcDeFaGbHcIeJfKgHlIjKlMnOpQrStUvWxYz\") == \"AbCdEfGhIjKlMlKjIhGaGbHcIeJfKgHlIjKlMnOpQrStUvWxYz\"\n assert candidate(s = \"abcdefGHIJKLmnopQRSTuvwXYZ\") == \"abcdefGHIJKLmnopQRSTuvwXYZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgG\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZyXwVuTsRqPoNlKjIhGfEdCbAaBcDeFaGbHcIeJ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZyXwVuTsRqPoNlKjIhGaGbHcIeJ\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStVuWxYzAbCdEfGhIjKlMnOpQrStVuWxYz\") == \"AbCdEfGhIjKlMnOpQrStVuWxYzAbCdEfGhIjKlMnOpQrStVuWxYz\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZzYxWvUtSrQpOnMlKjIhGfEdCbAaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"aaaaAAaaAAaaaAAaAaaaAA\") == \"aaaa\"\n assert candidate(s = \"ZyXwVuTsRqPoNmLkJiHgFeDcBaCbAdCdEfFgHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"ZyXwVuTsRqPoNmLkJiHgFeDcBaCbAdCdEgH\"\n assert candidate(s = \"XyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYz\") == \"XyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYzXyZxYz\"\n assert candidate(s = \"aBcCdEfFgHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaA\") == \"aBdEgH\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().makeGood", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string makeGood(string s) {", "container": "Solution", "callable": "makeGood", "parameters": [{"name": "s", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1545, "task_id": "find-kth-bit-in-nth-binary-string", "difficulty": "Medium", "problem_description": "Given two positive integers n and k, the binary string Sn is formed as follows:\n\nS1 = \"0\"\nSi = Si - 1 + \"1\" + reverse(invert(Si - 1)) for i > 1\n\nWhere + denotes the concatenation operation, reverse(x) returns the reversed string x, and invert(x) inverts all the bits in x (0 changes to 1 and 1 changes to 0).\nFor example, the first four strings in the above sequence are:\n\nS1 = \"0\"\nS2 = \"011\"\nS3 = \"0111001\"\nS4 = \"011100110110001\"\n\nReturn the kth bit in Sn. It is guaranteed that k is valid for the given n.\n \nExample 1:\n\nInput: n = 3, k = 1\nOutput: \"0\"\nExplanation: S3 is \"0111001\".\nThe 1st bit is \"0\".\n\nExample 2:\n\nInput: n = 4, k = 11\nOutput: \"1\"\nExplanation: S4 is \"011100110110001\".\nThe 11th bit is \"1\".\n\n \nConstraints:\n\n1 <= n <= 20\n1 <= k <= 2n - 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,k = 31) == \"1\"\n assert candidate(n = 4,k = 11) == \"1\"\n assert candidate(n = 14,k = 511) == \"1\"\n assert candidate(n = 15,k = 545) == \"0\"\n assert candidate(n = 17,k = 65536) == \"1\"\n assert candidate(n = 18,k = 131071) == \"1\"\n assert candidate(n = 10,k = 127) == \"1\"\n assert candidate(n = 19,k = 262144) == \"1\"\n assert candidate(n = 13,k = 289) == \"0\"\n assert candidate(n = 12,k = 2047) == \"1\"\n assert candidate(n = 7,k = 40) == \"1\"\n assert candidate(n = 11,k = 148) == \"1\"\n assert candidate(n = 10,k = 511) == \"1\"\n assert candidate(n = 20,k = 524287) == \"1\"\n assert candidate(n = 16,k = 1023) == \"1\"\n assert candidate(n = 11,k = 1024) == \"1\"\n assert candidate(n = 9,k = 85) == \"0\"\n assert candidate(n = 14,k = 8191) == \"1\"\n assert candidate(n = 15,k = 16384) == \"1\"\n assert candidate(n = 16,k = 32767) == \"1\"\n assert candidate(n = 20,k = 4095) == \"1\"\n assert candidate(n = 20,k = 1048575) == \"1\"\n assert candidate(n = 12,k = 255) == \"1\"\n assert candidate(n = 5,k = 16) == \"1\"\n assert candidate(n = 8,k = 63) == \"1\"\n assert candidate(n = 17,k = 1057) == \"0\"\n assert candidate(n = 3,k = 1) == \"0\"\n assert candidate(n = 8,k = 127) == \"1\"\n assert candidate(n = 9,k = 256) == \"1\"\n assert candidate(n = 13,k = 4096) == \"1\"\n assert candidate(n = 19,k = 2081) == \"0\"\n assert candidate(n = 18,k = 2047) == \"1\"\n assert candidate(n = 7,k = 64) == \"1\"\n assert candidate(n = 19,k = 262143) == \"1\"\n assert candidate(n = 9,k = 128) == \"1\"\n assert candidate(n = 17,k = 32767) == \"1\"\n assert candidate(n = 10,k = 1023) == \"1\"\n assert candidate(n = 12,k = 4096) == \"1\"\n assert candidate(n = 18,k = 262144) == \"1\"\n assert candidate(n = 14,k = 8192) == \"1\"\n assert candidate(n = 14,k = 4096) == \"1\"\n assert candidate(n = 13,k = 2048) == \"1\"\n assert candidate(n = 13,k = 8191) == \"1\"\n assert candidate(n = 11,k = 1023) == \"1\"\n assert candidate(n = 17,k = 131071) == \"1\"\n assert candidate(n = 16,k = 65535) == \"1\"\n assert candidate(n = 18,k = 65536) == \"1\"\n assert candidate(n = 19,k = 4096) == \"1\"\n assert candidate(n = 19,k = 524288) == \"1\"\n assert candidate(n = 9,k = 255) == \"1\"\n assert candidate(n = 20,k = 524288) == \"1\"\n assert candidate(n = 17,k = 131072) == \"1\"\n assert candidate(n = 11,k = 2048) == \"1\"\n assert candidate(n = 14,k = 16383) == \"1\"\n assert candidate(n = 15,k = 32767) == \"1\"\n assert candidate(n = 19,k = 524287) == \"1\"\n assert candidate(n = 19,k = 4095) == \"1\"\n assert candidate(n = 5,k = 32) == \"1\"\n assert candidate(n = 10,k = 512) == \"1\"\n assert candidate(n = 3,k = 5) == \"0\"\n assert candidate(n = 8,k = 256) == \"1\"\n assert candidate(n = 16,k = 65536) == \"1\"\n assert candidate(n = 15,k = 32768) == \"1\"\n assert candidate(n = 6,k = 64) == \"1\"\n assert candidate(n = 17,k = 16385) == \"0\"\n assert candidate(n = 11,k = 2047) == \"1\"\n assert candidate(n = 9,k = 511) == \"1\"\n assert candidate(n = 8,k = 255) == \"1\"\n assert candidate(n = 7,k = 128) == \"1\"\n assert candidate(n = 3,k = 7) == \"1\"\n assert candidate(n = 8,k = 128) == \"1\"\n assert candidate(n = 19,k = 327679) == \"1\"\n assert candidate(n = 13,k = 8192) == \"1\"\n assert candidate(n = 18,k = 262143) == \"1\"\n assert candidate(n = 16,k = 32768) == \"1\"\n assert candidate(n = 9,k = 512) == \"1\"\n assert candidate(n = 14,k = 16384) == \"1\"\n assert candidate(n = 19,k = 511999) == \"1\"\n assert candidate(n = 2,k = 2) == \"1\"\n assert candidate(n = 17,k = 65535) == \"1\"\n assert candidate(n = 13,k = 4095) == \"1\"\n assert candidate(n = 8,k = 64) == \"1\"\n assert candidate(n = 20,k = 1) == \"0\"\n assert candidate(n = 10,k = 256) == \"1\"\n assert candidate(n = 10,k = 1024) == \"1\"\n"}, "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().findKthBit", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "char findKthBit(int n, int k) {", "container": "Solution", "callable": "findKthBit", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "char", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1546, "task_id": "maximum-number-of-non-overlapping-subarrays-with-sum-equals-target", "difficulty": "Medium", "problem_description": "Given an array nums and an integer target, return the maximum number of non-empty non-overlapping subarrays such that the sum of values in each subarray is equal to target.\n \nExample 1:\n\nInput: nums = [1,1,1,1,1], target = 2\nOutput: 2\nExplanation: There are 2 non-overlapping subarrays [1,1,1,1,1] with sum equals to target(2).\n\nExample 2:\n\nInput: nums = [-1,3,5,1,4,2,-9], target = 6\nOutput: 2\nExplanation: There are 3 subarrays with sum equal to 6.\n([5,1], [4,2], [3,5,1,4,2,-9]) but only the first 2 are non-overlapping.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n-104 <= nums[i] <= 104\n0 <= target <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5],target = 10) == 2\n assert candidate(nums = [1, 2, 3, 4, 5],target = 9) == 1\n assert candidate(nums = [-1, 3, 5, 1, 4, 2, -9],target = 6) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5],target = 15) == 2\n assert candidate(nums = [0, 0, 0, 0, 0],target = 0) == 5\n assert candidate(nums = [1, -1, 2, -2, 3, -3],target = 0) == 3\n assert candidate(nums = [1, 1, 1, 1, 1],target = 2) == 2\n assert candidate(nums = [5, 5, 5, 5, 5],target = 15) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 15) == 3\n assert candidate(nums = [10, -5, 5, -3, 2, 3, -1, 7],target = 5) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 20) == 1\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 38) == 1\n assert candidate(nums = [-2, 2, -2, 2, -2, 2, -2, 2, -2, 2],target = 0) == 5\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500],target = 0) == 5\n assert candidate(nums = [-1, -2, -3, -4, -5, -1, -2, -3, -4, -5, -1, -2, -3, -4, -5, -1, -2, -3, -4, -5, -1, -2, -3, -4, -5, -1, -2, -3, -4, -5, -1, -2, -3, -4, -5, -1, -2, -3, -4, -5, -1, -2, -3, -4, -5, -1, -2, -3, -4, -5],target = -15) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 2\n assert candidate(nums = [100, -25, 25, -50, 50, 150, -150, 200, -200],target = 100) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 0, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],target = 5) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, -15, 1, 2, 3, 4, 5, -10, 1, 2, 3],target = 10) == 2\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],target = 0) == 10\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],target = -15) == 2\n assert candidate(nums = [1000, -500, 500, -300, 200, 300, -100, 700],target = 500) == 3\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 9) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 150) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 1) == 30\n assert candidate(nums = [5, -2, 5, -2, 5, -2, 5, -2, 5, -2],target = 3) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 1) == 10\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = 6) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 1) == 1\n assert candidate(nums = [100, -50, 50, -25, 25, 125, -125, 62, -62, 31, -31],target = 50) == 2\n assert candidate(nums = [5, 1, 3, 7, 8, 2, 4, 6, 9, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9],target = 5) == 2\n assert candidate(nums = [10, 5, 5, 15, 10, 10, 5, 5, 20, 15],target = 20) == 3\n assert candidate(nums = [10000, -10000, 10000, -10000, 10000],target = 10000) == 3\n assert candidate(nums = [3, 4, -2, 3, -2, 5, -5, 1, 1, 1],target = 3) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 2) == 10\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],target = 2) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 4\n assert candidate(nums = [2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],target = 9) == 3\n assert candidate(nums = [10, 5, -5, 10, 15, -25, 30, -30, 35, -35, 40, -40, 45, -45, 50, -50, 55, -55, 60, -60],target = 10) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],target = 55) == 2\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],target = -5) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 150) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5],target = 9) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 1500) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 3\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],target = -30) == 2\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],target = 0) == 10\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500],target = 100) == 5\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],target = 0) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 1) == 20\n assert candidate(nums = [100, -25, 25, -50, 50, -75, 75, -100, 100, -125, 125],target = 50) == 2\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],target = 0) == 27\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15) == 3\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 9) == 3\n assert candidate(nums = [100, -25, 25, -25, 25, 25, -50, 25, -25, 25, 25, -50, 100, -200, 100],target = 25) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 30) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 1, 2, 3, 4, 5],target = 5) == 4\n assert candidate(nums = [5, 1, 3, 7, 2, 8, 6, 4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10) == 5\n assert candidate(nums = [10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10, -10, 10, -10],target = 0) == 10\n assert candidate(nums = [9, 3, 6, 9, 3, 6, 9, 3, 6, 9],target = 12) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 10) == 10\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],target = 0) == 10\n assert candidate(nums = [1, -1, 0, 1, 0, -1, 1],target = 0) == 4\n assert candidate(nums = [3, 2, 1, 6, 3, 3, 2, 1, 6, 3, 3, 2, 1, 6, 3],target = 9) == 4\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],target = 0) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 55) == 1\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],target = 3) == 5\n assert candidate(nums = [100, -50, 50, -25, 25, -10, 10, 5, -5, 15, -15],target = 25) == 3\n assert candidate(nums = [-1, -2, -3, -4, -5, 10, 5, 0, -5, -10, 1, 2, 3, 4, 5],target = 0) == 3\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],target = 0) == 10\n assert candidate(nums = [1000, -500, 500, -250, 250, -125, 125, 0, 0, 0, 0, 0, 0, 0, 0],target = 250) == 2\n assert candidate(nums = [-2, 2, 3, -3, 4, 5, -5, 4, 6, -6, 7, -7, 8, -8],target = 0) == 6\n assert candidate(nums = [5, 1, 3, 2, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 6) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 15) == 8\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],target = 0) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],target = 150) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 5) == 8\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55],target = 75) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],target = 0) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 20) == 1\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5],target = 5) == 5\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100, 110, -120, 130, -140, 150, -160, 170, -180, 190, -200],target = 100) == 1\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = 100) == 2\n assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1, 0, 1, -1],target = 0) == 6\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6],target = 10) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],target = 0) == 20\n assert candidate(nums = [10000, -10000, 10000, -10000, 10000, -10000],target = 10000) == 3\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = 75) == 2\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],target = -15) == 3\n assert candidate(nums = [10, -10, 10, -10, 10, -10, 10, -10, 10, -10],target = 0) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15) == 3\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5],target = 0) == 10\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],target = 0) == 15\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],target = 100) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 15) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 28) == 1\n"}, "metadata": {"canonical_parameter_names": ["nums", "target"], "leetcode_dataset_entry_point": "Solution().maxNonOverlapping", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxNonOverlapping(vector& nums, int target) {", "container": "Solution", "callable": "maxNonOverlapping", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1547, "task_id": "minimum-cost-to-cut-a-stick", "difficulty": "Hard", "problem_description": "Given a wooden stick of length n units. The stick is labelled from 0 to n. For example, a stick of length 6 is labelled as follows:\n\nGiven an integer array cuts where cuts[i] denotes a position you should perform a cut at.\nYou should perform the cuts in order, you can change the order of the cuts as you wish.\nThe cost of one cut is the length of the stick to be cut, the total cost is the sum of costs of all cuts. When you cut a stick, it will be split into two smaller sticks (i.e. the sum of their lengths is the length of the stick before the cut). Please refer to the first example for a better explanation.\nReturn the minimum total cost of the cuts.\n \nExample 1:\n\n\nInput: n = 7, cuts = [1,3,4,5]\nOutput: 16\nExplanation: Using cuts order = [1, 3, 4, 5] as in the input leads to the following scenario:\n\nThe first cut is done to a rod of length 7 so the cost is 7. The second cut is done to a rod of length 6 (i.e. the second part of the first cut), the third is done to a rod of length 4 and the last cut is to a rod of length 3. The total cost is 7 + 6 + 4 + 3 = 20.\nRearranging the cuts to be [3, 5, 1, 4] for example will lead to a scenario with total cost = 16 (as shown in the example photo 7 + 4 + 3 + 2 = 16).\nExample 2:\n\nInput: n = 9, cuts = [5,6,1,4,2]\nOutput: 22\nExplanation: If you try the given cuts ordering the cost will be 25.\nThere are much ordering with total cost <= 25, for example, the order [4, 6, 5, 2, 1] has total cost = 22 which is the minimum possible.\n\n \nConstraints:\n\n2 <= n <= 106\n1 <= cuts.length <= min(n - 1, 100)\n1 <= cuts[i] <= n - 1\nAll the integers in cuts array are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 15,cuts = [3, 5, 10]) == 30\n assert candidate(n = 100,cuts = [50, 25, 75, 10, 90, 60, 30, 40, 80]) == 330\n assert candidate(n = 15,cuts = [1, 5, 9, 13]) == 35\n assert candidate(n = 7,cuts = [1, 3, 4, 5]) == 16\n assert candidate(n = 10,cuts = [2, 4, 7]) == 20\n assert candidate(n = 8,cuts = [1, 3, 5, 7]) == 19\n assert candidate(n = 8,cuts = [1, 3, 6]) == 16\n assert candidate(n = 6,cuts = [3, 1, 5]) == 12\n assert candidate(n = 6,cuts = [1, 2, 3, 4, 5]) == 16\n assert candidate(n = 15,cuts = [3, 5, 12, 10]) == 35\n assert candidate(n = 12,cuts = [1, 3, 5, 7, 9]) == 31\n assert candidate(n = 12,cuts = [2, 3, 10, 11]) == 26\n assert candidate(n = 12,cuts = [1, 5, 8, 10]) == 28\n assert candidate(n = 10,cuts = [1, 2, 3, 4, 5]) == 22\n assert candidate(n = 5,cuts = [1, 4]) == 9\n assert candidate(n = 15,cuts = [2, 7, 10, 13]) == 35\n assert candidate(n = 8,cuts = [2, 5]) == 13\n assert candidate(n = 9,cuts = [5, 6, 1, 4, 2]) == 22\n assert candidate(n = 12,cuts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 44\n assert candidate(n = 8,cuts = [2, 3, 5, 6]) == 19\n assert candidate(n = 20,cuts = [3, 8, 10, 12, 15]) == 51\n assert candidate(n = 20,cuts = [3, 6, 9, 12, 15]) == 52\n assert candidate(n = 8,cuts = [3, 5]) == 13\n assert candidate(n = 50,cuts = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == 170\n assert candidate(n = 400,cuts = [120, 240, 60, 180, 300, 360, 90, 210, 330, 390]) == 1360\n assert candidate(n = 150,cuts = [20, 40, 60, 80, 100, 120, 140]) == 450\n assert candidate(n = 512,cuts = [64, 128, 192, 256, 320, 384, 448]) == 1536\n assert candidate(n = 300,cuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290]) == 1480\n assert candidate(n = 1024,cuts = [128, 256, 384, 512, 640, 768, 896]) == 3072\n assert candidate(n = 200,cuts = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190]) == 700\n assert candidate(n = 500,cuts = [100, 150, 200, 250, 300, 350, 400, 450]) == 1600\n assert candidate(n = 10000,cuts = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000]) == 34000\n assert candidate(n = 900,cuts = [100, 200, 300, 400, 500, 600, 700, 800, 450, 350, 250, 150, 50]) == 3400\n assert candidate(n = 300,cuts = [50, 100, 150, 200, 250, 125, 175, 225, 275, 75, 25, 200, 250, 150, 100, 300, 50]) == 1250\n assert candidate(n = 30,cuts = [29, 1, 28, 14, 22, 19, 3, 7, 11, 25, 26, 9, 21, 15, 6, 23, 17, 2, 18, 5, 24, 20, 12, 16, 8, 10, 4, 27, 13]) == 148\n assert candidate(n = 750,cuts = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400, 420, 440, 460, 480, 500, 520, 540, 560, 580, 600, 620, 640, 660, 680, 700, 720, 740]) == 3980\n assert candidate(n = 600,cuts = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 580]) == 2250\n assert candidate(n = 35,cuts = [3, 7, 11, 15, 19, 23, 27, 31]) == 112\n assert candidate(n = 20,cuts = [2, 5, 8, 11, 14, 17]) == 57\n assert candidate(n = 150,cuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140]) == 590\n assert candidate(n = 750,cuts = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 125, 275, 425, 575, 325, 475, 625, 225, 375, 525, 675]) == 3550\n assert candidate(n = 900,cuts = [90, 180, 270, 360, 450, 540, 630, 720, 810, 900, 45, 135, 225, 315, 405, 495, 585, 675, 765, 855, 945]) == 4275\n assert candidate(n = 729,cuts = [27, 54, 81, 108, 135, 162, 189, 216, 243, 270, 297, 324, 351, 378, 405, 432, 459, 486, 513, 540, 567, 594, 621, 648, 675, 702]) == 3510\n assert candidate(n = 120,cuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 440\n assert candidate(n = 1500,cuts = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 1050, 1100, 1150, 1200, 1250, 1300, 1350, 1400, 1450]) == 7400\n assert candidate(n = 25,cuts = [5, 15, 20, 10]) == 60\n assert candidate(n = 500,cuts = [10, 25, 45, 70, 100, 150, 200, 250, 300, 350, 400]) == 1720\n assert candidate(n = 1000,cuts = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == 3400\n assert candidate(n = 2500,cuts = [200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000, 2200, 2400]) == 9400\n assert candidate(n = 999,cuts = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == 1565\n assert candidate(n = 50,cuts = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == 170\n assert candidate(n = 750,cuts = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700]) == 2950\n assert candidate(n = 200,cuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 880\n assert candidate(n = 1000,cuts = [10, 50, 90, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == 3640\n assert candidate(n = 700,cuts = [140, 280, 420, 560, 70, 210, 350, 490, 630, 175, 315, 455, 595]) == 2660\n assert candidate(n = 10000,cuts = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000]) == 34000\n assert candidate(n = 250,cuts = [25, 50, 75, 100, 125, 150, 175, 200, 225]) == 850\n assert candidate(n = 500,cuts = [100, 200, 300, 400, 150, 250, 350, 450, 50, 450]) == 1750\n assert candidate(n = 1000,cuts = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == 3400\n assert candidate(n = 70,cuts = [7, 14, 21, 28, 35, 42, 49, 56, 63]) == 238\n assert candidate(n = 100,cuts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 182\n assert candidate(n = 40,cuts = [10, 20, 30]) == 80\n assert candidate(n = 600,cuts = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400, 420, 440, 460, 480, 500, 520, 540, 560, 580]) == 2960\n assert candidate(n = 600,cuts = [30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360, 390, 420, 450, 480, 510, 540, 570]) == 2640\n assert candidate(n = 400,cuts = [50, 100, 150, 200, 250, 300, 350]) == 1200\n assert candidate(n = 2000,cuts = [100, 500, 800, 1500, 1900, 1600, 1200, 700, 300, 1100, 1700, 1800, 600, 900, 400, 200]) == 8100\n assert candidate(n = 500,cuts = [100, 200, 300, 400, 150, 250, 350]) == 1500\n assert candidate(n = 99,cuts = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97]) == 566\n assert candidate(n = 800,cuts = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750]) == 3200\n assert candidate(n = 800,cuts = [160, 320, 480, 640, 80, 240, 400, 560, 720, 110, 270, 430, 590, 750, 90, 250, 410, 570, 730]) == 3270\n assert candidate(n = 5000,cuts = [2000, 1000, 3000, 4000, 500, 1500, 2500, 3500, 4500, 1250, 1750, 2250, 2750, 3250, 3750, 4250, 4750, 625, 750, 1125, 1375, 1625, 1875, 2125, 2375, 2625, 2875, 3125, 3375, 3625, 3875, 4125, 4375, 4625, 4875]) == 25750\n assert candidate(n = 1200,cuts = [120, 240, 360, 480, 600, 720, 840, 960, 1080, 1200, 60, 180, 300, 420, 540, 660, 780, 900, 1020, 1140, 30, 90, 150, 210, 270, 330, 390, 450, 510, 570, 630, 690, 750, 810, 870, 930, 990, 1050, 1110, 1170]) == 6510\n assert candidate(n = 15,cuts = [1, 4, 7, 10, 13]) == 39\n assert candidate(n = 3000,cuts = [100, 300, 500, 700, 900, 1100, 1300, 1500, 1700, 1900, 2100, 2300, 2500, 2700, 2900]) == 12000\n assert candidate(n = 50,cuts = [2, 25, 49, 23, 37, 17, 33, 9, 41, 35]) == 170\n assert candidate(n = 300,cuts = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275]) == 1100\n assert candidate(n = 900,cuts = [150, 300, 450, 600, 750, 100, 200, 500, 800, 90, 180, 270, 360, 450, 540, 630, 720, 810, 900]) == 3820\n assert candidate(n = 1200,cuts = [200, 400, 600, 800, 1000, 120, 320, 520, 720, 920]) == 4200\n assert candidate(n = 500,cuts = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450, 475]) == 2200\n assert candidate(n = 256,cuts = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240, 248]) == 1280\n assert candidate(n = 600,cuts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590]) == 3560\n assert candidate(n = 1024,cuts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255]) == 3063\n assert candidate(n = 200,cuts = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195]) == 770\n assert candidate(n = 2000,cuts = [100, 300, 500, 700, 900, 1100, 1300, 1500, 1700, 1900, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800]) == 8800\n assert candidate(n = 800,cuts = [50, 100, 150, 200, 250, 300, 350, 400, 450, 550, 600, 650, 700, 750, 800]) == 3200\n assert candidate(n = 1500,cuts = [250, 500, 750, 1000, 1250, 1300, 1400, 1450, 1350, 1200]) == 4750\n assert candidate(n = 99,cuts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98]) == 664\n assert candidate(n = 50,cuts = [3, 10, 20, 30, 40]) == 130\n assert candidate(n = 150,cuts = [15, 30, 45, 60, 75, 90, 105, 120, 135, 105, 45, 15, 90, 75, 135, 60, 120]) == 630\n assert candidate(n = 55,cuts = [11, 22, 33, 44, 5]) == 143\n assert candidate(n = 60,cuts = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 59]) == 225\n assert candidate(n = 300,cuts = [30, 60, 90, 120, 150, 180, 210, 240, 270]) == 1020\n assert candidate(n = 1000,cuts = [200, 400, 600, 800, 300, 700, 100, 900, 500]) == 3400\n assert candidate(n = 1200,cuts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100]) == 4400\n assert candidate(n = 20,cuts = [3, 6, 9, 12, 15, 18]) == 57\n assert candidate(n = 30,cuts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == 148\n assert candidate(n = 1000,cuts = [200, 400, 600, 800, 100, 300, 500, 700, 900]) == 3400\n"}, "metadata": {"canonical_parameter_names": ["n", "cuts"], "leetcode_dataset_entry_point": "Solution().minCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minCost(int n, vector& cuts) {", "container": "Solution", "callable": "minCost", "parameters": [{"name": "n", "type": "int"}, {"name": "cuts", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1550, "task_id": "three-consecutive-odds", "difficulty": "Easy", "problem_description": "Given an integer array arr, return true if there are three consecutive odd numbers in the array. Otherwise, return false.\n \nExample 1:\n\nInput: arr = [2,6,4,1]\nOutput: false\nExplanation: There are no three consecutive odds.\n\nExample 2:\n\nInput: arr = [1,2,34,3,4,5,7,23,12]\nOutput: true\nExplanation: [5,7,23] are three consecutive odds.\n\n \nConstraints:\n\n1 <= arr.length <= 1000\n1 <= arr[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 3, 2, 5, 7, 9]) == True\n assert candidate(arr = [2, 4, 6, 8, 10]) == False\n assert candidate(arr = [1, 1, 1, 1, 1, 1]) == True\n assert candidate(arr = [1000, 999, 998, 997]) == False\n assert candidate(arr = [2, 3, 5, 7, 11, 13]) == True\n assert candidate(arr = [2, 6, 4, 1]) == False\n assert candidate(arr = [999, 997, 995, 993, 991]) == True\n assert candidate(arr = [11, 13, 15, 17, 19]) == True\n assert candidate(arr = [1, 3, 2, 3, 5, 7]) == True\n assert candidate(arr = [2, 4, 6, 8]) == False\n assert candidate(arr = [1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == False\n assert candidate(arr = [1, 2, 1, 2, 1, 2]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(arr = [999, 997, 995]) == True\n assert candidate(arr = [1001, 1003, 1005]) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == False\n assert candidate(arr = [999, 1001, 1003, 1005]) == True\n assert candidate(arr = [1, 2, 34, 3, 4, 5, 7, 23, 12]) == True\n assert candidate(arr = [1, 1, 1, 1]) == True\n assert candidate(arr = [1, 2, 3, 5, 7, 9, 11]) == True\n assert candidate(arr = [2, 3, 5, 7, 9, 11]) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2]) == False\n assert candidate(arr = [1, 3, 5, 7, 9]) == True\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19]) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2]) == False\n assert candidate(arr = [11, 13, 15, 17, 19, 21]) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(arr = [1, 3, 5]) == True\n assert candidate(arr = [3, 9, 15, 21, 27, 33, 39, 45, 51, 57, 63, 69, 75, 81, 87, 93]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == False\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 21, 23, 25]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 21, 23]) == True\n assert candidate(arr = [999, 1001, 1003, 1005, 1007, 1009, 1011, 1013, 1015, 1017, 1019, 1021]) == True\n assert candidate(arr = [1, 1, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1]) == True\n assert candidate(arr = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15]) == True\n assert candidate(arr = [101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, 159, 161, 163, 165, 167, 169]) == True\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == False\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == True\n assert candidate(arr = [23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163]) == True\n assert candidate(arr = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61]) == True\n assert candidate(arr = [8, 10, 12, 14, 16, 18, 20, 1, 3, 5]) == True\n assert candidate(arr = [1001, 1003, 1005, 1007, 1009, 1011, 1013, 1015]) == True\n assert candidate(arr = [1000, 1000, 1000, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == True\n assert candidate(arr = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]) == False\n assert candidate(arr = [101, 203, 305, 407, 509, 611, 713, 815, 917, 1019]) == True\n assert candidate(arr = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == True\n assert candidate(arr = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 1, 3, 5]) == True\n assert candidate(arr = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == False\n assert candidate(arr = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == False\n assert candidate(arr = [999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000]) == False\n assert candidate(arr = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == True\n assert candidate(arr = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 989, 987, 985, 983, 981, 979]) == True\n assert candidate(arr = [2, 4, 6, 8, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == True\n assert candidate(arr = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]) == False\n assert candidate(arr = [200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229]) == False\n assert candidate(arr = [2, 4, 6, 8, 10, 11, 13, 15, 17, 19, 21, 23, 25]) == True\n assert candidate(arr = [89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191]) == True\n assert candidate(arr = [1, 4, 6, 8, 10, 12, 14, 16, 18, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 3, 5, 7]) == True\n assert candidate(arr = [3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10]) == True\n assert candidate(arr = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13]) == True\n assert candidate(arr = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139]) == True\n assert candidate(arr = [1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1]) == False\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 21, 23, 25, 27, 29]) == True\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13]) == True\n assert candidate(arr = [2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3]) == False\n assert candidate(arr = [1, 3, 5, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 21, 23, 25, 27, 29, 31, 33]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == True\n assert candidate(arr = [21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == True\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19]) == False\n assert candidate(arr = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == False\n assert candidate(arr = [1001, 1003, 1005, 2, 4, 6, 8, 1007, 1009, 1011]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5]) == True\n assert candidate(arr = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == True\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 5, 5, 5, 7, 7, 7, 11, 11, 11, 13, 13, 13, 17, 17, 17, 19, 19, 19]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == True\n assert candidate(arr = [1000, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == True\n assert candidate(arr = [300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324]) == False\n assert candidate(arr = [2, 4, 6, 8, 10, 11, 13, 15, 17, 19, 21, 23, 25]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 2, 4, 6, 8, 10]) == True\n assert candidate(arr = [5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 41, 43, 45]) == True\n assert candidate(arr = [999, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 11, 13, 15, 17, 19, 21]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 11]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == False\n assert candidate(arr = [1, 1, 2, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1, 2, 1, 1, 1]) == True\n assert candidate(arr = [999, 997, 995, 993, 991, 989, 987, 985, 983, 981, 979, 977, 975, 973, 971, 969, 967, 965, 963, 961, 959, 957, 955, 953, 951, 949, 947, 945, 943, 941, 939, 937, 935, 933, 931, 929, 927, 925, 923, 921, 919, 917, 915, 913, 911, 909, 907, 905, 903, 901, 899, 897, 895, 893, 891, 889, 887, 885, 883, 881]) == True\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19]) == True\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 11, 13, 15, 17, 19]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == True\n assert candidate(arr = [499, 501, 503, 505, 507, 509, 511, 513, 515, 517, 519, 521, 523, 525, 527, 529]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == False\n assert candidate(arr = [1001, 1003, 1005, 1007, 1009, 1011, 1013, 1015, 1017, 1019]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 11, 13, 15, 17, 19]) == True\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == True\n assert candidate(arr = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79]) == True\n assert candidate(arr = [5, 3, 1, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45]) == True\n assert candidate(arr = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990]) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == False\n assert candidate(arr = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109]) == True\n assert candidate(arr = [1, 3, 5, 2, 4, 6, 7, 9, 11, 13, 8, 10, 12, 14, 16, 18, 20]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == True\n assert candidate(arr = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == False\n assert candidate(arr = [5, 3, 1, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == True\n assert candidate(arr = [1, 2, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27]) == True\n assert candidate(arr = [2, 4, 6, 8, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == True\n assert candidate(arr = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989]) == False\n assert candidate(arr = [1, 2, 1, 3, 1, 5, 1, 7, 1, 9, 1, 11, 1, 13, 1, 15]) == True\n assert candidate(arr = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987]) == False\n assert candidate(arr = [1, 2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8, 9, 8, 9, 10, 11, 10, 11, 12, 13, 12, 13, 14, 15, 14, 15, 16, 17, 16, 17, 18, 19, 18, 19, 20]) == False\n assert candidate(arr = [1, 3, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 21, 23, 25]) == True\n assert candidate(arr = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == True\n assert candidate(arr = [999, 1001, 1003, 1005, 1007, 1009, 1011, 1013, 1015, 1017, 1019]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 21]) == True\n assert candidate(arr = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == False\n assert candidate(arr = [42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 71]) == False\n assert candidate(arr = [8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == True\n assert candidate(arr = [101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151, 153, 155, 157, 159, 161, 163, 165, 167, 169, 171, 173, 175, 177, 179, 181, 183, 185, 187, 189, 191, 193, 195, 197, 199, 201, 203, 205, 207, 209]) == True\n assert candidate(arr = [1001, 1003, 1005, 1007, 1009, 1011, 1013, 1015, 1017]) == True\n assert candidate(arr = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45]) == True\n assert candidate(arr = [3, 5, 7, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 11]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == False\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().threeConsecutiveOdds", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool threeConsecutiveOdds(vector& arr) {", "container": "Solution", "callable": "threeConsecutiveOdds", "parameters": [{"name": "arr", "type": "vector&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1551, "task_id": "minimum-operations-to-make-array-equal", "difficulty": "Medium", "problem_description": "You have an array arr of length n where arr[i] = (2 * i) + 1 for all valid values of i (i.e., 0 <= i < n).\nIn one operation, you can select two indices x and y where 0 <= x, y < n and subtract 1 from arr[x] and add 1 to arr[y] (i.e., perform arr[x] -=1 and arr[y] += 1). The goal is to make all the elements of the array equal. It is guaranteed that all the elements of the array can be made equal using some operations.\nGiven an integer n, the length of the array, return the minimum number of operations needed to make all the elements of arr equal.\n \nExample 1:\n\nInput: n = 3\nOutput: 2\nExplanation: arr = [1, 3, 5]\nFirst operation choose x = 2 and y = 0, this leads arr to be [2, 3, 4]\nIn the second operation choose x = 2 and y = 0 again, thus arr = [3, 3, 3].\n\nExample 2:\n\nInput: n = 6\nOutput: 9\n\n \nConstraints:\n\n1 <= n <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 2\n assert candidate(n = 100) == 2500\n assert candidate(n = 10000) == 25000000\n assert candidate(n = 6) == 9\n assert candidate(n = 1) == 0\n assert candidate(n = 1000) == 250000\n assert candidate(n = 10) == 25\n assert candidate(n = 15000) == 56250000\n assert candidate(n = 12345) == 38099756\n assert candidate(n = 7000) == 12250000\n assert candidate(n = 49) == 600\n assert candidate(n = 2000) == 1000000\n assert candidate(n = 7500) == 14062500\n assert candidate(n = 8888) == 19749136\n assert candidate(n = 50) == 625\n assert candidate(n = 3333) == 2777222\n assert candidate(n = 5) == 6\n assert candidate(n = 3000) == 2250000\n assert candidate(n = 6789) == 11522630\n assert candidate(n = 1200) == 360000\n assert candidate(n = 99) == 2450\n assert candidate(n = 5001) == 6252500\n assert candidate(n = 1001) == 250500\n assert candidate(n = 2) == 1\n assert candidate(n = 101) == 2550\n assert candidate(n = 8) == 16\n assert candidate(n = 9998) == 24990001\n assert candidate(n = 20000) == 100000000\n assert candidate(n = 999) == 249500\n assert candidate(n = 5555) == 7714506\n assert candidate(n = 8000) == 16000000\n assert candidate(n = 5000) == 6250000\n assert candidate(n = 9999) == 24995000\n assert candidate(n = 19) == 90\n assert candidate(n = 77) == 1482\n assert candidate(n = 12000) == 36000000\n assert candidate(n = 6667) == 11112222\n assert candidate(n = 150) == 5625\n assert candidate(n = 13) == 42\n assert candidate(n = 7654) == 14645929\n assert candidate(n = 11111) == 30863580\n assert candidate(n = 11) == 30\n assert candidate(n = 15) == 56\n assert candidate(n = 2500) == 1562500\n assert candidate(n = 9000) == 20250000\n assert candidate(n = 4999) == 6247500\n assert candidate(n = 200) == 10000\n assert candidate(n = 6000) == 9000000\n assert candidate(n = 499) == 62250\n assert candidate(n = 500) == 62500\n assert candidate(n = 7) == 12\n assert candidate(n = 25) == 156\n assert candidate(n = 1500) == 562500\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minOperations(int n) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1552, "task_id": "magnetic-force-between-two-balls", "difficulty": "Medium", "problem_description": "In the universe Earth C-137, Rick discovered a special form of magnetic force between two balls if they are put in his new invented basket. Rick has n empty baskets, the ith basket is at position[i], Morty has m balls and needs to distribute the balls into the baskets such that the minimum magnetic force between any two balls is maximum.\nRick stated that magnetic force between two different balls at positions x and y is |x - y|.\nGiven the integer array position and the integer m. Return the required force.\n \nExample 1:\n\n\nInput: position = [1,2,3,4,7], m = 3\nOutput: 3\nExplanation: Distributing the 3 balls into baskets 1, 4 and 7 will make the magnetic force between ball pairs [3, 3, 6]. The minimum magnetic force is 3. We cannot achieve a larger minimum magnetic force than 3.\n\nExample 2:\n\nInput: position = [5,4,3,2,1,1000000000], m = 2\nOutput: 999999999\nExplanation: We can use baskets 1 and 1000000000.\n\n \nConstraints:\n\nn == position.length\n2 <= n <= 105\n1 <= position[i] <= 109\nAll integers in position are distinct.\n2 <= m <= position.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 5) == 2\n assert candidate(position = [5, 4, 3, 2, 1, 1000000000],m = 2) == 999999999\n assert candidate(position = [1, 3, 5, 7, 9],m = 4) == 2\n assert candidate(position = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],m = 5) == 4\n assert candidate(position = [10, 20, 30, 40, 50],m = 4) == 10\n assert candidate(position = [10, 15, 20, 25, 30],m = 3) == 10\n assert candidate(position = [1, 1000000000],m = 2) == 999999999\n assert candidate(position = [10, 20, 30, 40, 50],m = 3) == 20\n assert candidate(position = [1, 2, 3, 4, 7],m = 3) == 3\n assert candidate(position = [1, 2, 8, 4, 9],m = 3) == 3\n assert candidate(position = [1, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000],m = 11) == 99\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],m = 10) == 30\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],m = 12) == 10\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],m = 10) == 3\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],m = 7) == 20\n assert candidate(position = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],m = 6) == 31\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],m = 25) == 1\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10) == 1\n assert candidate(position = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],m = 20) == 2\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],m = 25) == 2\n assert candidate(position = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],m = 15) == 5\n assert candidate(position = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],m = 5) == 999999\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 10) == 2\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500],m = 7) == 40\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],m = 50) == 2\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],m = 10) == 20\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250],m = 12) == 20\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],m = 20) == 10\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500],m = 8) == 30\n assert candidate(position = [1, 2, 8, 4, 9, 15, 22, 28, 34, 40, 46, 52, 58, 64, 70, 76, 82, 88, 94, 100],m = 6) == 18\n assert candidate(position = [1, 4, 10, 15, 20, 26, 30, 40],m = 5) == 9\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],m = 20) == 10\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 5) == 20\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],m = 15) == 2\n assert candidate(position = [1, 1000000000, 2000000000, 3000000000, 4000000000, 5000000000, 6000000000, 7000000000, 8000000000, 9000000000],m = 5) == 2000000000\n assert candidate(position = [1, 500000000, 1000000000, 1500000000, 2000000000],m = 3) == 999999999\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 6) == 19\n assert candidate(position = [1, 2, 3, 6, 7, 8, 10, 12, 13, 15],m = 6) == 2\n assert candidate(position = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],m = 25) == 4\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 7) == 2\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 300, 400, 500, 600],m = 15) == 19\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],m = 17) == 1\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],m = 15) == 10\n assert candidate(position = [1, 1000000000],m = 2) == 999999999\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 200, 300, 400, 500, 600, 700, 800, 900, 1000],m = 10) == 100\n assert candidate(position = [1, 100, 1000, 10000, 100000, 1000000, 10000000],m = 4) == 99999\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],m = 10) == 20\n assert candidate(position = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576],m = 15) == 127\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],m = 10) == 20\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 6) == 19\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 10) == 2\n assert candidate(position = [1, 5, 9, 15, 22, 30],m = 5) == 6\n assert candidate(position = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],m = 15) == 4\n assert candidate(position = [1, 3, 6, 8, 12, 15, 18, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],m = 15) == 5\n assert candidate(position = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024],m = 15) == 57\n assert candidate(position = [1, 3, 6, 8, 11, 14, 17, 20, 25, 30, 35, 40, 45, 50],m = 8) == 5\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500],m = 25) == 20\n assert candidate(position = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125],m = 7) == 20\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 6) == 10\n assert candidate(position = [1, 1000000000, 2, 500000000, 750000000],m = 3) == 499999999\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 5) == 20\n assert candidate(position = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82],m = 5) == 18\n assert candidate(position = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],m = 6) == 20\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 8) == 2\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],m = 8) == 20\n assert candidate(position = [1, 5, 9, 14, 20, 25, 30],m = 5) == 5\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],m = 5) == 20\n assert candidate(position = [1, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],m = 5) == 999999\n assert candidate(position = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],m = 7) == 9999\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],m = 5) == 20\n assert candidate(position = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900],m = 5) == 200\n assert candidate(position = [1, 2, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120],m = 5) == 6\n assert candidate(position = [1, 3, 6, 8, 12, 15, 18, 20, 22, 25, 28, 30],m = 7) == 3\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],m = 15) == 2\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],m = 20) == 2\n assert candidate(position = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],m = 8) == 20\n assert candidate(position = [5, 18, 23, 42, 57, 62, 75, 80],m = 5) == 18\n assert candidate(position = [1, 2, 1000000000, 2000000000, 3000000000, 4000000000, 5000000000],m = 4) == 1000000000\n assert candidate(position = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210],m = 15) == 10\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],m = 15) == 20\n assert candidate(position = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61],m = 8) == 8\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],m = 20) == 1\n assert candidate(position = [2, 6, 8, 12, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98, 100, 102, 104, 106, 108, 110],m = 25) == 4\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],m = 13) == 2\n assert candidate(position = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],m = 11) == 19\n assert candidate(position = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],m = 15) == 1\n assert candidate(position = [1, 100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000, 1000000000],m = 6) == 199999999\n"}, "metadata": {"canonical_parameter_names": ["position", "m"], "leetcode_dataset_entry_point": "Solution().maxDistance", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxDistance(vector& position, int m) {", "container": "Solution", "callable": "maxDistance", "parameters": [{"name": "position", "type": "vector&"}, {"name": "m", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1553, "task_id": "minimum-number-of-days-to-eat-n-oranges", "difficulty": "Hard", "problem_description": "There are n oranges in the kitchen and you decided to eat some of these oranges every day as follows:\n\nEat one orange.\nIf the number of remaining oranges n is divisible by 2 then you can eat n / 2 oranges.\nIf the number of remaining oranges n is divisible by 3 then you can eat 2 * (n / 3) oranges.\n\nYou can only choose one of the actions per day.\nGiven the integer n, return the minimum number of days to eat n oranges.\n \nExample 1:\n\nInput: n = 10\nOutput: 4\nExplanation: You have 10 oranges.\nDay 1: Eat 1 orange, 10 - 1 = 9. \nDay 2: Eat 6 oranges, 9 - 2*(9/3) = 9 - 6 = 3. (Since 9 is divisible by 3)\nDay 3: Eat 2 oranges, 3 - 2*(3/3) = 3 - 2 = 1. \nDay 4: Eat the last orange 1 - 1 = 0.\nYou need at least 4 days to eat the 10 oranges.\n\nExample 2:\n\nInput: n = 6\nOutput: 3\nExplanation: You have 6 oranges.\nDay 1: Eat 3 oranges, 6 - 6/2 = 6 - 3 = 3. (Since 6 is divisible by 2).\nDay 2: Eat 2 oranges, 3 - 2*(3/3) = 3 - 2 = 1. (Since 3 is divisible by 3)\nDay 3: Eat the last orange 1 - 1 = 0.\nYou need at least 3 days to eat the 6 oranges.\n\n \nConstraints:\n\n1 <= n <= 2 * 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 2\n assert candidate(n = 2000000000) == 32\n assert candidate(n = 100) == 8\n assert candidate(n = 1000) == 10\n assert candidate(n = 5) == 4\n assert candidate(n = 4) == 3\n assert candidate(n = 2) == 2\n assert candidate(n = 8) == 4\n assert candidate(n = 27) == 4\n assert candidate(n = 20) == 5\n assert candidate(n = 1000000000) == 31\n assert candidate(n = 18017459) == 28\n assert candidate(n = 15) == 5\n assert candidate(n = 9) == 3\n assert candidate(n = 1000000) == 20\n assert candidate(n = 6) == 3\n assert candidate(n = 1) == 1\n assert candidate(n = 10) == 4\n assert candidate(n = 25) == 6\n assert candidate(n = 619) == 12\n assert candidate(n = 239) == 11\n assert candidate(n = 53) == 8\n assert candidate(n = 2147483647) == 35\n assert candidate(n = 587) == 12\n assert candidate(n = 787) == 11\n assert candidate(n = 1000000019) == 34\n assert candidate(n = 971) == 13\n assert candidate(n = 43) == 7\n assert candidate(n = 887) == 13\n assert candidate(n = 983) == 11\n assert candidate(n = 523) == 10\n assert candidate(n = 379) == 9\n assert candidate(n = 103) == 9\n assert candidate(n = 37) == 6\n assert candidate(n = 937) == 11\n assert candidate(n = 487) == 8\n assert candidate(n = 223) == 9\n assert candidate(n = 211) == 11\n assert candidate(n = 23) == 7\n assert candidate(n = 73) == 7\n assert candidate(n = 941) == 12\n assert candidate(n = 827) == 13\n assert candidate(n = 547) == 10\n assert candidate(n = 251) == 10\n assert candidate(n = 181) == 8\n assert candidate(n = 333333333) == 29\n assert candidate(n = 193) == 9\n assert candidate(n = 1048576) == 21\n assert candidate(n = 131) == 10\n assert candidate(n = 241) == 9\n assert candidate(n = 263) == 10\n assert candidate(n = 347) == 11\n assert candidate(n = 1000000013) == 34\n assert candidate(n = 857) == 13\n assert candidate(n = 383) == 11\n assert candidate(n = 997) == 11\n assert candidate(n = 569) == 10\n assert candidate(n = 929) == 12\n assert candidate(n = 571) == 10\n assert candidate(n = 491) == 10\n assert candidate(n = 11) == 5\n assert candidate(n = 643) == 12\n assert candidate(n = 246813579) == 30\n assert candidate(n = 1048575) == 23\n assert candidate(n = 823543) == 23\n assert candidate(n = 500000000) == 31\n assert candidate(n = 353) == 10\n assert candidate(n = 313) == 10\n assert candidate(n = 829) == 11\n assert candidate(n = 167) == 9\n assert candidate(n = 1111111111) == 31\n assert candidate(n = 467) == 12\n assert candidate(n = 54321) == 20\n assert candidate(n = 97) == 8\n assert candidate(n = 29) == 6\n assert candidate(n = 317) == 11\n assert candidate(n = 433) == 9\n assert candidate(n = 131071) == 21\n assert candidate(n = 789456123) == 31\n assert candidate(n = 1999999998) == 31\n assert candidate(n = 271) == 8\n assert candidate(n = 797) == 12\n assert candidate(n = 107) == 10\n assert candidate(n = 163) == 7\n assert candidate(n = 557) == 12\n assert candidate(n = 653) == 10\n assert candidate(n = 631) == 12\n assert candidate(n = 991) == 10\n assert candidate(n = 617) == 12\n assert candidate(n = 389) == 11\n assert candidate(n = 751) == 11\n assert candidate(n = 625000000) == 28\n assert candidate(n = 401) == 11\n assert candidate(n = 1000000002) == 31\n assert candidate(n = 44) == 7\n assert candidate(n = 137) == 9\n assert candidate(n = 919) == 11\n assert candidate(n = 17) == 6\n assert candidate(n = 257) == 10\n assert candidate(n = 811) == 9\n assert candidate(n = 509) == 11\n assert candidate(n = 16777215) == 24\n assert candidate(n = 777777777) == 33\n assert candidate(n = 101) == 9\n assert candidate(n = 907) == 12\n assert candidate(n = 821) == 11\n assert candidate(n = 421) == 12\n assert candidate(n = 479) == 12\n assert candidate(n = 89) == 9\n assert candidate(n = 953) == 13\n assert candidate(n = 877) == 11\n assert candidate(n = 71) == 10\n assert candidate(n = 1000000001) == 32\n assert candidate(n = 599) == 12\n assert candidate(n = 81) == 5\n assert candidate(n = 593) == 11\n assert candidate(n = 151) == 9\n assert candidate(n = 293) == 10\n assert candidate(n = 691) == 11\n assert candidate(n = 41) == 7\n assert candidate(n = 647) == 13\n assert candidate(n = 727) == 11\n assert candidate(n = 209) == 10\n assert candidate(n = 83) == 7\n assert candidate(n = 661) == 10\n assert candidate(n = 123456789) == 28\n assert candidate(n = 283) == 10\n assert candidate(n = 499) == 10\n assert candidate(n = 577) == 10\n assert candidate(n = 1000000011) == 32\n assert candidate(n = 739) == 9\n assert candidate(n = 881) == 11\n assert candidate(n = 659) == 11\n assert candidate(n = 79) == 8\n assert candidate(n = 63) == 6\n assert candidate(n = 269) == 11\n assert candidate(n = 61) == 7\n assert candidate(n = 373) == 10\n assert candidate(n = 999999999) == 30\n assert candidate(n = 227) == 10\n assert candidate(n = 563) == 12\n assert candidate(n = 47) == 8\n assert candidate(n = 4096) == 13\n assert candidate(n = 113) == 8\n assert candidate(n = 233) == 10\n assert candidate(n = 911) == 13\n assert candidate(n = 863) == 15\n assert candidate(n = 859) == 13\n assert candidate(n = 359) == 12\n assert candidate(n = 443) == 11\n assert candidate(n = 135792468) == 28\n assert candidate(n = 78125) == 18\n assert candidate(n = 191) == 9\n assert candidate(n = 125000000) == 29\n assert candidate(n = 311) == 12\n assert candidate(n = 457) == 10\n assert candidate(n = 179) == 11\n assert candidate(n = 337) == 9\n assert candidate(n = 773) == 12\n assert candidate(n = 733) == 9\n assert candidate(n = 419) == 12\n assert candidate(n = 314159265) == 28\n assert candidate(n = 65536) == 17\n assert candidate(n = 967) == 12\n assert candidate(n = 127) == 8\n assert candidate(n = 1000000007) == 34\n assert candidate(n = 947) == 13\n assert candidate(n = 987654321) == 29\n assert candidate(n = 1234567890) == 29\n assert candidate(n = 307) == 10\n assert candidate(n = 503) == 12\n assert candidate(n = 397) == 10\n assert candidate(n = 3125000000) == 30\n assert candidate(n = 26) == 6\n assert candidate(n = 281) == 10\n assert candidate(n = 743) == 11\n assert candidate(n = 1800000000) == 31\n assert candidate(n = 3125) == 15\n assert candidate(n = 1999999999) == 32\n assert candidate(n = 899999999) == 36\n assert candidate(n = 13) == 5\n assert candidate(n = 719) == 14\n assert candidate(n = 222222222) == 29\n assert candidate(n = 59049) == 11\n assert candidate(n = 601) == 11\n assert candidate(n = 1000000003) == 32\n assert candidate(n = 367) == 10\n assert candidate(n = 125) == 9\n assert candidate(n = 839) == 11\n assert candidate(n = 277) == 10\n assert candidate(n = 19683) == 10\n assert candidate(n = 613) == 11\n assert candidate(n = 89123456) == 27\n assert candidate(n = 197) == 10\n assert candidate(n = 157) == 9\n assert candidate(n = 769) == 11\n assert candidate(n = 673) == 10\n assert candidate(n = 439) == 10\n assert candidate(n = 1500000000) == 32\n assert candidate(n = 331) == 9\n assert candidate(n = 173) == 9\n assert candidate(n = 67) == 8\n assert candidate(n = 607) == 12\n assert candidate(n = 349) == 10\n assert candidate(n = 431) == 14\n assert candidate(n = 666666666) == 30\n assert candidate(n = 683) == 12\n assert candidate(n = 449) == 10\n assert candidate(n = 677) == 11\n assert candidate(n = 809) == 13\n assert candidate(n = 977) == 10\n assert candidate(n = 897654321) == 30\n assert candidate(n = 463) == 11\n assert candidate(n = 757) == 9\n assert candidate(n = 521) == 12\n assert candidate(n = 853) == 13\n assert candidate(n = 1024) == 11\n assert candidate(n = 883) == 11\n assert candidate(n = 709) == 11\n assert candidate(n = 701) == 12\n assert candidate(n = 823) == 11\n assert candidate(n = 149) == 9\n assert candidate(n = 19) == 5\n assert candidate(n = 139) == 9\n assert candidate(n = 461) == 11\n assert candidate(n = 541) == 9\n assert candidate(n = 641) == 11\n assert candidate(n = 761) == 11\n assert candidate(n = 109) == 7\n assert candidate(n = 31) == 6\n assert candidate(n = 229) == 9\n assert candidate(n = 199) == 9\n assert candidate(n = 7) == 4\n assert candidate(n = 409) == 10\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().minDays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minDays(int n) {", "container": "Solution", "callable": "minDays", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1556, "task_id": "thousand-separator", "difficulty": "Easy", "problem_description": "Given an integer n, add a dot (\".\") as the thousands separator and return it in string format.\n \nExample 1:\n\nInput: n = 987\nOutput: \"987\"\n\nExample 2:\n\nInput: n = 1234\nOutput: \"1.234\"\n\n \nConstraints:\n\n0 <= n <= 231 - 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 0) == \"0\"\n assert candidate(n = 1234) == \"1.234\"\n assert candidate(n = 1000000) == \"1.000.000\"\n assert candidate(n = 2147483647) == \"2.147.483.647\"\n assert candidate(n = 123456789) == \"123.456.789\"\n assert candidate(n = 1234567) == \"1.234.567\"\n assert candidate(n = 123456) == \"123.456\"\n assert candidate(n = 56789) == \"56.789\"\n assert candidate(n = 1000) == \"1.000\"\n assert candidate(n = 987) == \"987\"\n assert candidate(n = 111222333444555666777888999) == \"111.222.333.444.555.666.777.888.999\"\n assert candidate(n = 123456789012) == \"123.456.789.012\"\n assert candidate(n = 999999999) == \"999.999.999\"\n assert candidate(n = 1000000000000000) == \"1.000.000.000.000.000\"\n assert candidate(n = 1234567890123456789) == \"1.234.567.890.123.456.789\"\n assert candidate(n = 123456789123456789) == \"123.456.789.123.456.789\"\n assert candidate(n = 999999999999) == \"999.999.999.999\"\n assert candidate(n = 100) == \"100\"\n assert candidate(n = 456789012) == \"456.789.012\"\n assert candidate(n = 1000000000000) == \"1.000.000.000.000\"\n assert candidate(n = 123) == \"123\"\n assert candidate(n = 1) == \"1\"\n assert candidate(n = 1001001) == \"1.001.001\"\n assert candidate(n = 1234567890123456) == \"1.234.567.890.123.456\"\n assert candidate(n = 10000) == \"10.000\"\n assert candidate(n = 111111111111111) == \"111.111.111.111.111\"\n assert candidate(n = 1001) == \"1.001\"\n assert candidate(n = 9876543210987654321) == \"9.876.543.210.987.654.321\"\n assert candidate(n = 101010101) == \"101.010.101\"\n assert candidate(n = 10000000000) == \"10.000.000.000\"\n assert candidate(n = 100000) == \"100.000\"\n assert candidate(n = 98765432109876543210987654321) == \"98.765.432.109.876.543.210.987.654.321\"\n assert candidate(n = 9876543210) == \"9.876.543.210\"\n assert candidate(n = 999) == \"999\"\n assert candidate(n = 1000000000) == \"1.000.000.000\"\n assert candidate(n = 1234567890123) == \"1.234.567.890.123\"\n assert candidate(n = 111111111) == \"111.111.111\"\n assert candidate(n = 1010101010) == \"1.010.101.010\"\n assert candidate(n = 456789012345) == \"456.789.012.345\"\n assert candidate(n = 1234567890) == \"1.234.567.890\"\n assert candidate(n = 567890123) == \"567.890.123\"\n assert candidate(n = 987654321) == \"987.654.321\"\n assert candidate(n = 987654321098) == \"987.654.321.098\"\n assert candidate(n = 123456789012345) == \"123.456.789.012.345\"\n assert candidate(n = 123456789123) == \"123.456.789.123\"\n assert candidate(n = 999999) == \"999.999\"\n assert candidate(n = 987654321098765) == \"987.654.321.098.765\"\n assert candidate(n = 1111111111) == \"1.111.111.111\"\n assert candidate(n = 54321) == \"54.321\"\n assert candidate(n = 10) == \"10\"\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().thousandSeparator", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string thousandSeparator(int n) {", "container": "Solution", "callable": "thousandSeparator", "parameters": [{"name": "n", "type": "int"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1557, "task_id": "minimum-number-of-vertices-to-reach-all-nodes", "difficulty": "Medium", "problem_description": "Given a directed acyclic graph, with n vertices numbered from 0 to n-1, and an array edges where edges[i] = [fromi, toi] represents a directed edge from node fromi to node toi.\nFind the smallest set of vertices from which all nodes in the graph are reachable. It's guaranteed that a unique solution exists.\nNotice that you can return the vertices in any order.\n \nExample 1:\n\n\nInput: n = 6, edges = [[0,1],[0,2],[2,5],[3,4],[4,2]]\nOutput: [0,3]\nExplanation: It's not possible to reach all the nodes from a single vertex. From 0 we can reach [0,1,2,5]. From 3 we can reach [3,4,2,5]. So we output [0,3].\nExample 2:\n\n\nInput: n = 5, edges = [[0,1],[2,1],[3,1],[1,4],[2,4]]\nOutput: [0,2,3]\nExplanation: Notice that vertices 0, 3 and 2 are not reachable from any other node, so we must include them. Also any of these vertices can reach nodes 1 and 4.\n\n \nConstraints:\n\n2 <= n <= 10^5\n1 <= edges.length <= min(10^5, n * (n - 1) / 2)\nedges[i].length == 2\n0 <= fromi, toi < n\nAll pairs (fromi, toi) are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 7,edges = [[1, 2], [3, 4], [5, 6]]) == [0, 1, 3, 5]\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [2, 5], [3, 4], [4, 2]]) == [0, 3]\n assert candidate(n = 4,edges = [[2, 0], [2, 1], [1, 3]]) == [2]\n assert candidate(n = 3,edges = [[0, 1], [0, 2]]) == [0]\n assert candidate(n = 5,edges = [[0, 1], [2, 1], [3, 1], [1, 4], [2, 4]]) == [0, 2, 3]\n assert candidate(n = 10,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [5, 6], [6, 7], [7, 8], [8, 9]]) == [0, 5]\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14]]) == [0]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 19], [17, 19], [18, 19]]) == [0]\n assert candidate(n = 16,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 13], [14, 15]]) == [0]\n assert candidate(n = 11,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]]) == [0]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19]]) == [0]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15], [13, 16], [14, 17], [15, 18], [16, 19]]) == [0]\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == [0]\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14]]) == [0]\n assert candidate(n = 14,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 7], [4, 8], [5, 9], [5, 10], [6, 11], [6, 12], [7, 13], [8, 13]]) == [0]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == [0]\n assert candidate(n = 14,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 13], [11, 12]]) == [0]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9]]) == [0]\n assert candidate(n = 13,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == [0]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [0, 9]]) == [0]\n assert candidate(n = 13,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12]]) == [0]\n assert candidate(n = 25,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24]]) == [0]\n assert candidate(n = 12,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [3, 6], [4, 7], [5, 8]]) == []\n assert candidate(n = 9,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [5, 7], [6, 8]]) == [0]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [3, 4], [4, 5], [6, 7], [8, 9]]) == [0, 1, 6, 8]\n assert candidate(n = 16,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 15], [9, 15], [10, 15], [11, 15], [12, 15]]) == [0]\n assert candidate(n = 11,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 8], [6, 8], [7, 9], [8, 10]]) == [0]\n assert candidate(n = 9,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 8]]) == [0]\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [0, 1]]) == []\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 0], [11, 0]]) == []\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 9], [7, 9], [8, 9]]) == [0]\n assert candidate(n = 8,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 0], [6, 1], [7, 2]]) == []\n assert candidate(n = 30,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29]]) == [0]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 7], [7, 8], [8, 9], [9, 7]]) == [0]\n assert candidate(n = 14,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13]]) == [0]\n assert candidate(n = 25,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20], [17, 21], [18, 22], [19, 23], [20, 24]]) == [0]\n assert candidate(n = 8,edges = [[0, 2], [1, 2], [2, 3], [4, 5], [6, 7]]) == [0, 1, 4, 6]\n assert candidate(n = 10,edges = [[0, 2], [0, 3], [1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [4, 6], [5, 7], [6, 7]]) == [0, 1, 8, 9]\n assert candidate(n = 9,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [0, 5], [1, 6], [2, 7], [3, 8], [4, 0], [5, 1], [6, 2], [7, 3], [8, 4]]) == []\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19]]) == [0]\n assert candidate(n = 9,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [0, 8]]) == [0]\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11]]) == [0]\n assert candidate(n = 20,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [10, 19], [11, 19], [12, 19], [13, 19], [14, 19]]) == [0]\n assert candidate(n = 18,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17]]) == [0]\n assert candidate(n = 11,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == [0]\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 11]]) == [0]\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == [0]\n assert candidate(n = 6,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [2, 4], [3, 4]]) == [0, 5]\n assert candidate(n = 10,edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == [0, 2, 4, 6, 8]\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [5, 11]]) == [0]\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == [0]\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 6], [6, 7]]) == [0]\n assert candidate(n = 8,edges = [[0, 2], [1, 2], [2, 3], [2, 4], [3, 5], [4, 5], [5, 6], [5, 7]]) == [0, 1]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 0], [9, 1]]) == []\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]]) == [0]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == [0]\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7]]) == [0]\n assert candidate(n = 16,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15]]) == [0]\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0]]) == []\n assert candidate(n = 20,edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [0, 4], [4, 8], [8, 12], [12, 16], [16, 0], [1, 5], [5, 9], [9, 13], [13, 17], [17, 1]]) == [2, 6, 10, 14, 18]\n assert candidate(n = 20,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == [0]\n assert candidate(n = 20,edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [0, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12], [12, 14], [14, 16], [16, 18], [1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19]]) == [0]\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [10, 11], [11, 12], [12, 13], [13, 14]]) == [0, 10]\n assert candidate(n = 13,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [0, 5], [2, 7], [4, 9]]) == [0]\n assert candidate(n = 9,edges = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 8], [8, 4]]) == []\n assert candidate(n = 25,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24]]) == [0]\n assert candidate(n = 15,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 12], [12, 13], [13, 14]]) == [0]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 8], [6, 8], [7, 9], [8, 9]]) == [0]\n assert candidate(n = 16,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15]]) == [0]\n assert candidate(n = 10,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 8], [6, 8], [7, 9]]) == [0]\n assert candidate(n = 12,edges = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9], [6, 10], [7, 11]]) == [0]\n assert candidate(n = 15,edges = [[0, 5], [2, 3], [3, 4], [5, 14], [1, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == [0, 1, 2]\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 7], [6, 7]]) == [0]\n assert candidate(n = 30,edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [20, 21], [22, 23], [24, 25], [26, 27], [28, 29]]) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28]\n assert candidate(n = 8,edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 7]]) == [0]\n assert candidate(n = 9,edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 7], [4, 8]]) == [0]\n assert candidate(n = 12,edges = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == [0]\n"}, "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().findSmallestSetOfVertices", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector findSmallestSetOfVertices(int n, vector>& edges) {", "container": "Solution", "callable": "findSmallestSetOfVertices", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1558, "task_id": "minimum-numbers-of-function-calls-to-make-target-array", "difficulty": "Medium", "problem_description": "You are given an integer array nums. You have an integer array arr of the same length with all values set to 0 initially. You also have the following modify function:\n\nYou want to use the modify function to convert arr to nums using the minimum number of calls.\nReturn the minimum number of function calls to make nums from arr.\nThe test cases are generated so that the answer fits in a 32-bit signed integer.\n \nExample 1:\n\nInput: nums = [1,5]\nOutput: 5\nExplanation: Increment by 1 (second element): [0, 0] to get [0, 1] (1 operation).\nDouble all the elements: [0, 1] -> [0, 2] -> [0, 4] (2 operations).\nIncrement by 1 (both elements) [0, 4] -> [1, 4] -> [1, 5] (2 operations).\nTotal of operations: 1 + 2 + 2 = 5.\n\nExample 2:\n\nInput: nums = [2,2]\nOutput: 3\nExplanation: Increment by 1 (both elements) [0, 0] -> [0, 1] -> [1, 1] (2 operations).\nDouble all the elements: [1, 1] -> [2, 2] (1 operation).\nTotal of operations: 2 + 1 = 3.\n\nExample 3:\n\nInput: nums = [4,2,5]\nOutput: 6\nExplanation: (initial)[0,0,0] -> [1,0,0] -> [1,0,1] -> [2,0,2] -> [2,1,2] -> [4,2,4] -> [4,2,5](nums).\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1000000000]) == 43\n assert candidate(nums = [10, 20, 30]) == 12\n assert candidate(nums = [10, 15, 20]) == 12\n assert candidate(nums = [1, 1, 1, 1]) == 4\n assert candidate(nums = [3, 3, 3, 3]) == 9\n assert candidate(nums = [2, 4, 6, 8, 10]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9]) == 13\n assert candidate(nums = [1, 5]) == 5\n assert candidate(nums = [1, 3, 7, 15, 31]) == 19\n assert candidate(nums = [1000000000, 1000000000]) == 55\n assert candidate(nums = [4, 2, 5]) == 6\n assert candidate(nums = [1000000000, 1000000000, 1000000000]) == 68\n assert candidate(nums = [3, 6, 9, 12, 15]) == 15\n assert candidate(nums = [5, 10, 15, 20, 25, 30]) == 21\n assert candidate(nums = [1, 2, 3, 4, 5]) == 9\n assert candidate(nums = [1023, 511, 255]) == 36\n assert candidate(nums = [16, 8, 4, 2, 1]) == 9\n assert candidate(nums = [0, 0, 0]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [9, 9, 9, 9, 9]) == 13\n assert candidate(nums = [2, 2]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 84\n assert candidate(nums = [81, 27, 9, 3, 1]) == 18\n assert candidate(nums = [100, 200, 300, 400]) == 21\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 40\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 41\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 20\n assert candidate(nums = [1000000000]) == 42\n assert candidate(nums = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 41\n assert candidate(nums = [256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144]) == 29\n assert candidate(nums = [1, 1000000000]) == 43\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == 229\n assert candidate(nums = [1048575, 1048574, 1048573, 1048572, 1048571, 1048570, 1048569, 1048568, 1048567, 1048566, 1048565, 1048564, 1048563, 1048562, 1048561, 1048560]) == 307\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 37\n assert candidate(nums = [10, 20, 40, 80, 160, 320, 640, 1280, 2560]) == 29\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 20\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [63, 127, 255, 511, 1023]) == 49\n assert candidate(nums = [2147483647, 2147483647, 2147483647, 2147483647, 2147483647]) == 185\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 10\n assert candidate(nums = [8388607, 4194303, 2097151, 1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15]) == 292\n assert candidate(nums = [7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584, 7168, 14336, 28672, 57344, 114688]) == 61\n assert candidate(nums = [31, 15, 7, 3, 1]) == 19\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 21\n assert candidate(nums = [987654321, 123456789, 98765432, 12345678, 9876543, 1234567]) == 112\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == 47\n assert candidate(nums = [987654321, 876543210, 765432109, 654321098, 543210987, 432109876, 321098765, 210987654, 109876543, 98765432, 87654321, 76543210, 65432109, 54321098, 43210987, 32109876, 21098765, 10987654, 9876543, 8765432]) == 320\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 30\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260]) == 87\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000]) == 94\n assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 229\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990]) == 224\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383]) == 118\n assert candidate(nums = [31, 31, 31, 31, 31, 31, 31, 31, 31, 31]) == 54\n assert candidate(nums = [1000000000, 1000000000, 1000000000]) == 68\n assert candidate(nums = [16, 8, 4, 2, 1, 0, 0, 0, 0, 0]) == 9\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == 159\n assert candidate(nums = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512]) == 29\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 16\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 5\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 29\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 15\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000]) == 81\n assert candidate(nums = [1000000000, 0, 1000000000, 0, 1000000000, 0, 1000000000, 0, 1000000000, 0]) == 94\n assert candidate(nums = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048]) == 30\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 92\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 29\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 32\n assert candidate(nums = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128]) == 23\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125, 976562, 488281, 244140, 122070, 61035, 30517, 15258, 7629, 3814, 1907, 953, 476, 238, 119, 59, 29, 14, 7, 3, 1]) == 303\n assert candidate(nums = [29, 14, 7, 3, 1]) == 17\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 20\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 31\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 64\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15]) == 23\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 73\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0]) == 8\n assert candidate(nums = [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683]) == 57\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == 86\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 35\n assert candidate(nums = [1023, 512, 256, 128, 64]) == 23\n assert candidate(nums = [16, 8, 4, 2, 1, 32, 64, 128, 256, 512]) == 19\n assert candidate(nums = [1073741824, 536870912, 268435456, 134217728, 67108864]) == 35\n assert candidate(nums = [5, 15, 25, 35, 45, 55]) == 26\n assert candidate(nums = [1023, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 29\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 25\n assert candidate(nums = [84, 126, 189, 252, 315, 378, 441, 504, 567, 630]) == 66\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995]) == 129\n assert candidate(nums = [123456789, 987654321, 135792468, 246813579, 111222333]) == 100\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 35\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 21\n assert candidate(nums = [13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 82\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(nums = [299999999, 299999999, 299999999, 299999999, 299999999]) == 113\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 54\n assert candidate(nums = [10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 91\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == 106\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minOperations(vector& nums) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1559, "task_id": "detect-cycles-in-2d-grid", "difficulty": "Medium", "problem_description": "Given a 2D array of characters grid of size m x n, you need to find if there exists any cycle consisting of the same value in grid.\nA cycle is a path of length 4 or more in the grid that starts and ends at the same cell. From a given cell, you can move to one of the cells adjacent to it - in one of the four directions (up, down, left, or right), if it has the same value of the current cell.\nAlso, you cannot move to the cell that you visited in your last move. For example, the cycle (1, 1) -> (1, 2) -> (1, 1) is invalid because from (1, 2) we visited (1, 1) which was the last visited cell.\nReturn true if any cycle of the same value exists in grid, otherwise, return false.\n \nExample 1:\n\n\nInput: grid = [[\"a\",\"a\",\"a\",\"a\"],[\"a\",\"b\",\"b\",\"a\"],[\"a\",\"b\",\"b\",\"a\"],[\"a\",\"a\",\"a\",\"a\"]]\nOutput: true\nExplanation: There are two valid cycles shown in different colors in the image below:\n\n\nExample 2:\n\n\nInput: grid = [[\"c\",\"c\",\"c\",\"a\"],[\"c\",\"d\",\"c\",\"c\"],[\"c\",\"c\",\"e\",\"c\"],[\"f\",\"c\",\"c\",\"c\"]]\nOutput: true\nExplanation: There is only one valid cycle highlighted in the image below:\n\n\nExample 3:\n\n\nInput: grid = [[\"a\",\"b\",\"b\"],[\"b\",\"z\",\"b\"],[\"b\",\"b\",\"a\"]]\nOutput: false\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 500\ngrid consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [['a', 'b', 'c'], ['b', 'c', 'a'], ['c', 'a', 'b']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a'], ['a', 'b', 'b', 'a'], ['a', 'b', 'b', 'a'], ['a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b'], ['b', 'a']]) == False\n assert candidate(grid = [['c', 'c', 'c', 'a'], ['c', 'd', 'c', 'c'], ['c', 'c', 'e', 'c'], ['f', 'c', 'c', 'c']]) == True\n assert candidate(grid = [['a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a'], ['a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'b'], ['b', 'z', 'b'], ['b', 'b', 'a']]) == False\n assert candidate(grid = [['a']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'a', 'b', 'a'], ['a', 'b', 'a', 'b', 'b', 'a'], ['a', 'a', 'b', 'b', 'a', 'a'], ['a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e'], ['a', 'a', 'a', 'a', 'a'], ['b', 'b', 'b', 'b', 'b'], ['c', 'c', 'c', 'c', 'c'], ['d', 'd', 'd', 'd', 'd']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'b', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['p', 'q', 'r'], ['q', 'r', 'p'], ['r', 'p', 'q'], ['p', 'q', 'r']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a'], ['a', 'b', 'b', 'a'], ['a', 'b', 'b', 'a'], ['a', 'a', 'a', 'a'], ['a', 'b', 'b', 'a'], ['a', 'b', 'b', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'a'], ['b', 'c', 'a', 'b'], ['c', 'a', 'b', 'c'], ['a', 'b', 'c', 'a']]) == False\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e'], ['b', 'a', 'e', 'd', 'c'], ['c', 'e', 'a', 'b', 'd'], ['d', 'c', 'b', 'a', 'e'], ['e', 'd', 'c', 'e', 'a']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'b', 'b'], ['a', 'a', 'b', 'b', 'a'], ['a', 'b', 'b', 'a', 'a'], ['b', 'b', 'a', 'a', 'a'], ['b', 'a', 'a', 'a', 'b']]) == True\n assert candidate(grid = [['z', 'y', 'x', 'w', 'v', 'u', 't'], ['y', 'x', 'w', 'v', 'u', 't', 's'], ['x', 'w', 'v', 'u', 't', 's', 'r'], ['w', 'v', 'u', 't', 's', 'r', 'q'], ['v', 'u', 't', 's', 'r', 'q', 'p'], ['u', 't', 's', 'r', 'q', 'p', 'o'], ['t', 's', 'r', 'q', 'p', 'o', 'n']]) == False\n assert candidate(grid = [['c', 'c', 'c', 'c', 'c'], ['c', 'd', 'd', 'd', 'c'], ['c', 'd', 'c', 'd', 'c'], ['c', 'd', 'd', 'd', 'c'], ['c', 'c', 'c', 'c', 'c']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e', 'f'], ['f', 'a', 'b', 'c', 'd', 'e'], ['e', 'f', 'a', 'b', 'c', 'd'], ['d', 'e', 'f', 'a', 'b', 'c'], ['c', 'd', 'e', 'f', 'a', 'b'], ['b', 'c', 'd', 'e', 'f', 'a']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'b', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'a', 'a'], ['a', 'b', 'b', 'a', 'a'], ['a', 'a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e', 'f'], ['f', 'e', 'd', 'c', 'b', 'a'], ['a', 'b', 'c', 'd', 'e', 'f'], ['f', 'e', 'd', 'c', 'b', 'a'], ['a', 'b', 'c', 'd', 'e', 'f']]) == False\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e', 'f'], ['b', 'c', 'd', 'e', 'f', 'a'], ['c', 'd', 'e', 'f', 'a', 'b'], ['d', 'e', 'f', 'a', 'b', 'c'], ['e', 'f', 'a', 'b', 'c', 'd'], ['f', 'a', 'b', 'c', 'd', 'e']]) == False\n assert candidate(grid = [['a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b']]) == False\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e', 'f'], ['f', 'e', 'd', 'c', 'b', 'a'], ['a', 'b', 'c', 'd', 'e', 'f'], ['f', 'e', 'd', 'c', 'b', 'a'], ['a', 'b', 'c', 'd', 'e', 'f'], ['f', 'e', 'd', 'c', 'b', 'a']]) == False\n assert candidate(grid = [['a', 'b', 'a', 'b'], ['b', 'a', 'b', 'a'], ['a', 'b', 'a', 'b'], ['b', 'a', 'b', 'a']]) == False\n assert candidate(grid = [['a', 'b', 'a', 'b', 'a'], ['b', 'a', 'b', 'a', 'b'], ['a', 'b', 'a', 'b', 'a'], ['b', 'a', 'b', 'a', 'b'], ['a', 'b', 'a', 'b', 'a']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'b', 'c', 'b', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a', 'a'], ['a', 'b', 'a'], ['a', 'a', 'a'], ['a', 'b', 'a'], ['a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e'], ['b', 'c', 'd', 'e', 'f'], ['c', 'd', 'e', 'f', 'g'], ['d', 'e', 'f', 'g', 'h'], ['e', 'f', 'g', 'h', 'i']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']]) == False\n assert candidate(grid = [['x', 'y', 'z', 'x'], ['y', 'z', 'x', 'y'], ['z', 'x', 'y', 'z'], ['x', 'y', 'z', 'x']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'b', 'c', 'b', 'a'], ['a', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'a', 'b', 'c'], ['b', 'c', 'a', 'b', 'c', 'a'], ['c', 'a', 'b', 'c', 'a', 'b'], ['a', 'b', 'c', 'a', 'b', 'c'], ['b', 'c', 'a', 'b', 'c', 'a'], ['c', 'a', 'b', 'c', 'a', 'b']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'b', 'a'], ['a', 'b', 'a', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'b', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'b', 'b', 'a'], ['a', 'b', 'b', 'b', 'a', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'a', 'a', 'a'], ['a', 'a', 'a', 'b', 'a', 'b', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'b', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'a', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'a', 'a', 'a'], ['a', 'b', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'b', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'a', 'a', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'c', 'c', 'b', 'a'], ['a', 'b', 'c', 'c', 'b', 'a'], ['a', 'b', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['x', 'y', 'z'], ['y', 'x', 'y'], ['z', 'y', 'x'], ['y', 'x', 'y'], ['x', 'y', 'z']]) == False\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e'], ['b', 'a', 'b', 'c', 'd'], ['c', 'b', 'a', 'b', 'c'], ['d', 'c', 'b', 'a', 'b'], ['e', 'd', 'c', 'b', 'a']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'a', 'b', 'a'], ['a', 'b', 'a', 'a', 'b', 'a'], ['a', 'b', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'a', 'a', 'a', 'b', 'a'], ['a', 'b', 'a', 'b', 'b', 'a', 'b', 'a'], ['a', 'b', 'a', 'a', 'a', 'a', 'b', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['x', 'x', 'x', 'x', 'x', 'x'], ['x', 'y', 'y', 'y', 'y', 'x'], ['x', 'y', 'z', 'z', 'y', 'x'], ['x', 'y', 'z', 'z', 'y', 'x'], ['x', 'y', 'y', 'y', 'y', 'x'], ['x', 'x', 'x', 'x', 'x', 'x']]) == True\n assert candidate(grid = [['x', 'x', 'x', 'x'], ['x', 'y', 'y', 'x'], ['x', 'y', 'y', 'x'], ['x', 'x', 'x', 'x']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e', 'f'], ['a', 'a', 'a', 'a', 'a', 'a'], ['b', 'c', 'd', 'e', 'f', 'g'], ['g', 'f', 'e', 'd', 'c', 'b'], ['a', 'a', 'a', 'a', 'a', 'a']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'a', 'a', 'b', 'a'], ['a', 'b', 'a', 'a', 'a', 'b', 'a'], ['a', 'b', 'a', 'a', 'a', 'b', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c'], ['b', 'a', 'b'], ['c', 'b', 'a']]) == False\n assert candidate(grid = [['p', 'p', 'q', 'p', 'p'], ['p', 'q', 'q', 'q', 'p'], ['q', 'q', 'r', 'q', 'q'], ['p', 'q', 'q', 'q', 'p'], ['p', 'p', 'q', 'p', 'p']]) == True\n assert candidate(grid = [['a', 'b', 'a', 'b', 'a'], ['b', 'a', 'b', 'a', 'b'], ['a', 'b', 'a', 'b', 'a'], ['b', 'a', 'b', 'a', 'b']]) == False\n assert candidate(grid = [['a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b'], ['b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a'], ['a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b'], ['b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a'], ['a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b'], ['b', 'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b', 'a']]) == False\n assert candidate(grid = [['a', 'a', 'a'], ['b', 'b', 'b'], ['a', 'a', 'a'], ['b', 'b', 'b'], ['a', 'a', 'a']]) == False\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e'], ['b', 'c', 'd', 'e', 'a'], ['c', 'd', 'e', 'a', 'b'], ['d', 'e', 'a', 'b', 'c'], ['e', 'a', 'b', 'c', 'd']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'c', 'c', 'c', 'b', 'a'], ['a', 'b', 'c', 'd', 'd', 'c', 'b'], ['a', 'b', 'c', 'd', 'd', 'c', 'b'], ['a', 'b', 'c', 'c', 'c', 'b', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a', 'a', 'a'], ['a', 'b', 'b', 'a'], ['a', 'b', 'b', 'a'], ['a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a', 'a', 'a'], ['a', 'b', 'b', 'a'], ['a', 'b', 'a', 'a'], ['a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd', 'a'], ['b', 'a', 'b', 'c', 'b'], ['c', 'b', 'a', 'b', 'c'], ['d', 'c', 'b', 'a', 'd'], ['a', 'b', 'c', 'd', 'a']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'c', 'c', 'c', 'b', 'a'], ['a', 'b', 'c', 'd', 'c', 'b', 'a'], ['a', 'b', 'c', 'c', 'c', 'b', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'a'], ['b', 'a', 'b', 'c'], ['c', 'b', 'c', 'b'], ['a', 'c', 'b', 'a']]) == False\n assert candidate(grid = [['a', 'b', 'a', 'b', 'a', 'b'], ['b', 'a', 'b', 'a', 'b', 'a'], ['a', 'b', 'a', 'b', 'a', 'b'], ['b', 'a', 'b', 'a', 'b', 'a'], ['a', 'b', 'a', 'b', 'a', 'b'], ['b', 'a', 'b', 'a', 'b', 'a']]) == False\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e'], ['b', 'c', 'd', 'e', 'a'], ['c', 'd', 'e', 'a', 'b'], ['d', 'e', 'a', 'b', 'c'], ['e', 'a', 'b', 'c', 'd']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a'], ['b', 'b', 'b', 'b'], ['c', 'c', 'c', 'c'], ['d', 'd', 'd', 'd'], ['e', 'e', 'e', 'e'], ['f', 'f', 'f', 'f']]) == False\n assert candidate(grid = [['m', 'm', 'm', 'm'], ['m', 'n', 'n', 'm'], ['m', 'n', 'o', 'm'], ['m', 'n', 'n', 'm'], ['m', 'm', 'm', 'm']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'], ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o']]) == False\n assert candidate(grid = [['a', 'a', 'b', 'b'], ['a', 'c', 'c', 'a'], ['b', 'c', 'd', 'b'], ['a', 'c', 'c', 'a']]) == False\n assert candidate(grid = [['x', 'y', 'z', 'x'], ['y', 'x', 'y', 'x'], ['z', 'y', 'z', 'y'], ['x', 'z', 'x', 'z']]) == False\n assert candidate(grid = [['a', 'b', 'a', 'b', 'a', 'b', 'a'], ['b', 'a', 'b', 'a', 'b', 'a', 'b'], ['a', 'b', 'a', 'b', 'a', 'b', 'a'], ['b', 'a', 'b', 'a', 'b', 'a', 'b'], ['a', 'b', 'a', 'b', 'a', 'b', 'a']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a'], ['a', 'b', 'b', 'a'], ['a', 'b', 'b', 'a'], ['a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd'], ['e', 'f', 'g', 'h'], ['i', 'j', 'k', 'l'], ['m', 'n', 'o', 'p']]) == False\n assert candidate(grid = [['a', 'b', 'c', 'd', 'e', 'f', 'g'], ['h', 'i', 'j', 'k', 'l', 'm', 'n'], ['o', 'p', 'q', 'r', 's', 't', 'u'], ['v', 'w', 'x', 'y', 'z', 'v', 'w'], ['x', 'y', 'z', 'v', 'w', 'x', 'y'], ['z', 'v', 'w', 'x', 'y', 'z', 'v']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'a', 'a', 'a', 'a', 'b', 'a'], ['a', 'b', 'a', 'c', 'c', 'a', 'b', 'a'], ['a', 'b', 'a', 'c', 'c', 'a', 'b', 'a'], ['a', 'b', 'a', 'a', 'a', 'a', 'b', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'b', 'c'], ['b', 'c', 'b'], ['c', 'b', 'a'], ['b', 'c', 'b'], ['a', 'b', 'c']]) == False\n assert candidate(grid = [['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'b', 'c', 'c', 'c', 'c', 'b', 'a'], ['a', 'b', 'c', 'd', 'd', 'c', 'b', 'a'], ['a', 'b', 'c', 'd', 'd', 'c', 'b', 'a'], ['a', 'b', 'c', 'c', 'c', 'c', 'b', 'a'], ['a', 'b', 'b', 'b', 'b', 'b', 'b', 'a'], ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']]) == True\n assert candidate(grid = [['a', 'a', 'a', 'b', 'b', 'b'], ['a', 'c', 'a', 'b', 'a', 'b'], ['a', 'a', 'a', 'b', 'b', 'b']]) == True\n assert candidate(grid = [['a', 'b', 'c', 'd'], ['b', 'a', 'd', 'c'], ['c', 'd', 'a', 'b'], ['d', 'c', 'b', 'a']]) == False\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().containsCycle", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool containsCycle(vector>& grid) {", "container": "Solution", "callable": "containsCycle", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1560, "task_id": "most-visited-sector-in-a-circular-track", "difficulty": "Easy", "problem_description": "Given an integer n and an integer array rounds. We have a circular track which consists of n sectors labeled from 1 to n. A marathon will be held on this track, the marathon consists of m rounds. The ith round starts at sector rounds[i - 1] and ends at sector rounds[i]. For example, round 1 starts at sector rounds[0] and ends at sector rounds[1]\nReturn an array of the most visited sectors sorted in ascending order.\nNotice that you circulate the track in ascending order of sector numbers in the counter-clockwise direction (See the first example).\n \nExample 1:\n\n\nInput: n = 4, rounds = [1,3,1,2]\nOutput: [1,2]\nExplanation: The marathon starts at sector 1. The order of the visited sectors is as follows:\n1 --> 2 --> 3 (end of round 1) --> 4 --> 1 (end of round 2) --> 2 (end of round 3 and the marathon)\nWe can see that both sectors 1 and 2 are visited twice and they are the most visited sectors. Sectors 3 and 4 are visited only once.\nExample 2:\n\nInput: n = 2, rounds = [2,1,2,1,2,1,2,1,2]\nOutput: [2]\n\nExample 3:\n\nInput: n = 7, rounds = [1,3,5,7]\nOutput: [1,2,3,4,5,6,7]\n\n \nConstraints:\n\n2 <= n <= 100\n1 <= m <= 100\nrounds.length == m + 1\n1 <= rounds[i] <= n\nrounds[i] != rounds[i + 1] for 0 <= i < m\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,rounds = [1, 3, 1, 2]) == [1, 2]\n assert candidate(n = 7,rounds = [1, 3, 5, 7]) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 6,rounds = [3, 6, 2, 4, 1]) == [1, 3, 4, 5, 6]\n assert candidate(n = 6,rounds = [3, 6, 2, 5]) == [3, 4, 5]\n assert candidate(n = 10,rounds = [3, 8, 3]) == [3]\n assert candidate(n = 2,rounds = [2, 1, 2, 1, 2, 1, 2, 1, 2]) == [2]\n assert candidate(n = 5,rounds = [1, 5, 1]) == [1]\n assert candidate(n = 6,rounds = [6, 2, 6, 5]) == [1, 2, 3, 4, 5, 6]\n assert candidate(n = 6,rounds = [3, 6, 2, 5, 1]) == [1, 3, 4, 5, 6]\n assert candidate(n = 3,rounds = [1, 2, 3, 1]) == [1]\n assert candidate(n = 8,rounds = [5, 4, 3, 2, 1, 8, 7, 6, 5]) == [5]\n assert candidate(n = 10,rounds = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 10]\n assert candidate(n = 10,rounds = [3, 8, 3, 10, 3]) == [3]\n assert candidate(n = 10,rounds = [1, 5, 9, 4, 8, 2, 6, 3, 7, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(n = 8,rounds = [4, 8, 1, 5, 9, 2, 6, 3, 7]) == [4, 5, 6, 7]\n assert candidate(n = 15,rounds = [10, 1, 12, 7, 14, 2, 15, 8]) == [1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15]\n assert candidate(n = 7,rounds = [3, 6, 2, 5, 3, 6, 2, 5, 3, 6, 2, 5]) == [3, 4, 5]\n assert candidate(n = 12,rounds = [2, 7, 1, 11, 6, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(n = 16,rounds = [8, 16, 10, 4, 12, 2, 14, 6, 1, 9, 17, 3, 11, 5, 13, 7]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]\n assert candidate(n = 100,rounds = [1, 50, 25, 75, 100, 50, 25, 75, 100, 1, 50, 25]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(n = 20,rounds = [3, 7, 12, 18, 20, 5, 10, 15, 1]) == [1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(n = 30,rounds = [15, 25, 5, 15, 25, 10, 5, 20, 10, 25, 15, 20, 5, 10, 15, 20, 25, 1, 6, 11, 16, 21, 26, 30, 4, 9, 14, 19, 24, 29]) == [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]\n assert candidate(n = 25,rounds = [10, 20, 5, 15, 25, 1, 11, 16, 6, 21, 12, 22, 7, 23, 13, 24, 8, 2, 18, 9, 3, 19, 4, 24, 25, 17]) == [10, 11, 12, 13, 14, 15, 16, 17]\n assert candidate(n = 10,rounds = [1, 5, 3, 8, 10, 4]) == [1, 2, 3, 4]\n assert candidate(n = 20,rounds = [10, 15, 5, 20, 1, 6, 11, 16, 1, 11]) == [10, 11]\n assert candidate(n = 15,rounds = [15, 5, 10, 12, 3, 14, 8, 6, 1]) == [1, 15]\n assert candidate(n = 20,rounds = [10, 20, 15, 5, 1, 15, 10, 5, 20, 15, 10, 5, 1]) == [1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(n = 8,rounds = [5, 1, 4, 7, 2, 6, 3]) == [1, 2, 3, 5, 6, 7, 8]\n assert candidate(n = 100,rounds = [50, 25, 75, 100, 1, 50, 25, 75, 100, 1, 50, 25, 75, 100, 1]) == [1, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]\n assert candidate(n = 25,rounds = [1, 13, 24, 7, 18, 12, 22, 5, 17, 11, 21, 4, 16, 10, 20, 3, 15, 9, 19, 2, 14, 8, 1, 13, 24, 7]) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 90,rounds = [1, 45, 90, 45, 1, 60, 30, 90, 60, 30, 1, 45, 60, 90, 30, 45, 1, 60, 90, 30]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(n = 10,rounds = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1]\n assert candidate(n = 18,rounds = [18, 10, 3, 12, 6, 15, 9, 2, 14, 7, 1, 13, 5, 16, 8, 4, 17, 11]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 18]\n assert candidate(n = 60,rounds = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190, 210, 230, 250, 270, 290, 310, 330, 350, 370, 390, 410, 430, 450, 470, 490, 510, 530, 550, 570, 590]) == [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590]\n assert candidate(n = 9,rounds = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 9]\n assert candidate(n = 11,rounds = [1, 3, 5, 7, 9, 11, 1, 3, 5, 7, 9, 11]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(n = 40,rounds = [1, 20, 40, 20, 1, 30, 20, 10, 30, 40, 10, 20, 30, 40, 1, 10, 20, 30, 40]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]\n assert candidate(n = 11,rounds = [1, 3, 5, 7, 9, 11, 2, 4, 6, 8, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(n = 25,rounds = [15, 20, 25, 5, 10, 1, 16, 21, 2, 17, 22, 3, 18, 23, 4, 19, 24, 6, 20, 25, 7, 1, 8, 16, 9, 12]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(n = 25,rounds = [25, 15, 10, 20, 5, 2, 17, 12, 7, 22, 1, 16, 11, 6, 21, 13, 8, 3, 18, 14, 9, 23, 4, 19, 24]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(n = 7,rounds = [7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]) == [1, 7]\n assert candidate(n = 12,rounds = [12, 3, 6, 9, 12, 3, 6, 9, 12, 3, 6, 9, 12]) == [12]\n assert candidate(n = 9,rounds = [9, 1, 3, 5, 7, 2, 4, 6, 8]) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 15,rounds = [5, 10, 15, 1, 6, 11, 13, 8]) == [5, 6, 7, 8]\n assert candidate(n = 12,rounds = [1, 12, 4, 8, 11, 2, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 50,rounds = [25, 45, 5, 30, 40, 50, 10, 35, 45, 20, 40, 50, 25, 50, 15, 45, 25, 50, 35, 50, 45, 50, 10, 40, 20, 50, 30, 50, 40, 50]) == [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]\n assert candidate(n = 22,rounds = [11, 22, 7, 17, 2, 12, 8, 18, 3, 13, 9, 19, 4, 14, 10, 20, 5, 15, 6, 16, 1, 21]) == [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]\n assert candidate(n = 9,rounds = [3, 6, 9, 2, 5, 8, 1, 4, 7]) == [3, 4, 5, 6, 7]\n assert candidate(n = 12,rounds = [1, 7, 12, 4, 9, 2, 8, 5, 10, 3, 11, 6, 1]) == [1]\n assert candidate(n = 20,rounds = [10, 15, 5, 18, 12, 20, 14, 8, 17, 11, 6, 19, 13, 9, 4, 16, 10, 3, 1, 7, 2]) == [1, 2, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(n = 8,rounds = [7, 1, 4, 8, 2, 6, 3, 5]) == [1, 2, 3, 4, 5, 7, 8]\n assert candidate(n = 30,rounds = [30, 10, 20, 3, 13, 23, 6, 16, 26, 9, 19, 29, 12, 22, 3, 13, 23, 6, 16, 26, 9, 19, 29, 12, 22]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 30]\n assert candidate(n = 75,rounds = [1, 38, 75, 38, 1, 50, 25, 75, 50, 25, 1, 38, 50, 75, 25, 38, 1, 50, 75, 25]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(n = 15,rounds = [1, 15, 5, 10, 3, 8, 13, 2]) == [1, 2]\n assert candidate(n = 40,rounds = [20, 30, 40, 10, 20, 30, 10, 40, 20, 30, 10, 40, 20, 30, 10, 40, 20, 30, 10, 40, 20, 30, 10, 40, 20, 30, 10, 40]) == [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]\n assert candidate(n = 11,rounds = [11, 4, 8, 1, 7, 10, 3, 9, 6, 2, 5, 11, 8]) == [1, 2, 3, 4, 5, 6, 7, 8, 11]\n assert candidate(n = 15,rounds = [1, 15, 5, 10, 1, 6, 11, 3, 8, 13]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]\n assert candidate(n = 8,rounds = [7, 3, 6, 2, 5, 1, 8, 4]) == [1, 2, 3, 4, 7, 8]\n assert candidate(n = 14,rounds = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 50,rounds = [1, 25, 50, 1, 25, 50, 1, 25, 50, 1, 25, 50, 1, 25, 50, 1, 25, 50, 1, 25, 50]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]\n assert candidate(n = 9,rounds = [3, 6, 2, 8, 4, 1, 9, 5, 7, 3, 6, 2, 8, 4, 1, 9, 5, 7]) == [3, 4, 5, 6, 7]\n assert candidate(n = 50,rounds = [1, 25, 50, 25, 1, 25, 50, 25, 1, 25, 50, 25, 1, 25, 50, 25, 1, 25, 50, 25]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(n = 15,rounds = [14, 3, 12, 8, 5, 2, 15, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 14, 15]\n assert candidate(n = 8,rounds = [8, 1, 4, 7, 2, 5, 8, 3, 6]) == [1, 2, 3, 4, 5, 6, 8]\n assert candidate(n = 12,rounds = [5, 9, 1, 11, 7, 3, 12, 6, 2, 8, 4, 10]) == [5, 6, 7, 8, 9, 10]\n assert candidate(n = 8,rounds = [7, 3, 5, 2, 8, 6, 1, 4]) == [1, 2, 3, 4, 7, 8]\n assert candidate(n = 10,rounds = [1, 5, 3, 9, 2, 8, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(n = 18,rounds = [1, 9, 18, 7, 15, 5, 13, 3, 11, 1, 9, 18, 7, 15, 5, 13, 3, 11]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(n = 50,rounds = [25, 30, 15, 40, 5, 20, 35, 45, 10, 4, 34, 29]) == [25, 26, 27, 28, 29]\n assert candidate(n = 15,rounds = [3, 10, 15, 5, 12, 7, 13, 2, 9, 14, 4, 11, 6, 1, 8]) == [3, 4, 5, 6, 7, 8]\n assert candidate(n = 6,rounds = [6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 6]\n assert candidate(n = 20,rounds = [1, 10, 15, 20, 1, 5, 10, 15, 20, 1, 10, 15]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(n = 12,rounds = [12, 6, 3, 9, 1, 7, 4, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12]\n assert candidate(n = 10,rounds = [1, 4, 7, 2, 8, 3, 9, 5, 10, 6]) == [1, 2, 3, 4, 5, 6]\n assert candidate(n = 12,rounds = [4, 8, 1, 7, 11, 5, 9, 12, 6, 10, 2]) == [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(n = 9,rounds = [9, 4, 8, 3, 7, 2, 6, 1, 5]) == [1, 2, 3, 4, 5, 9]\n assert candidate(n = 25,rounds = [12, 17, 22, 2, 7, 12, 17, 22, 2, 7, 12, 17]) == [12, 13, 14, 15, 16, 17]\n assert candidate(n = 7,rounds = [1, 4, 7, 2, 5, 3, 6, 1, 4, 7]) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 15,rounds = [1, 14, 8, 11, 5, 13, 9, 2, 7, 15, 4, 12, 6, 3, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(n = 10,rounds = [5, 8, 3, 10, 2, 6]) == [5, 6]\n assert candidate(n = 18,rounds = [18, 13, 8, 3, 17, 12, 7, 2, 16, 11, 6, 1, 15, 10, 5, 14, 9, 4]) == [1, 2, 3, 4, 18]\n assert candidate(n = 8,rounds = [7, 1, 4, 7, 3, 6, 2, 8]) == [7, 8]\n assert candidate(n = 9,rounds = [3, 6, 9, 3, 6, 9, 3]) == [3]\n assert candidate(n = 20,rounds = [1, 15, 5, 10, 20, 12, 7, 18, 3, 16, 8, 13, 2, 19, 6, 14, 4, 17, 9, 11]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(n = 20,rounds = [1, 10, 20, 5, 15, 1, 11, 16, 6, 12, 17, 7, 13, 18, 8, 14, 19, 9, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(n = 15,rounds = [5, 10, 15, 1, 6, 11, 2, 7, 12, 3, 8, 13, 4, 9, 14]) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 9,rounds = [3, 9, 2, 8, 1, 7, 4, 6, 5]) == [3, 4, 5]\n assert candidate(n = 12,rounds = [1, 4, 7, 10, 1, 4, 7, 10, 1]) == [1]\n assert candidate(n = 10,rounds = [10, 3, 5, 7, 9, 2]) == [1, 2, 10]\n assert candidate(n = 12,rounds = [7, 3, 9, 12, 4, 10, 5, 11, 6, 1, 8, 2]) == [1, 2, 7, 8, 9, 10, 11, 12]\n assert candidate(n = 20,rounds = [1, 10, 20, 5, 15, 10, 1, 16, 6, 11, 1, 17, 7, 12, 1, 18, 8, 13, 1, 19]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(n = 10,rounds = [1, 5, 10, 3, 7, 1]) == [1]\n assert candidate(n = 14,rounds = [1, 7, 14, 2, 8, 13, 3, 9, 12, 4, 10, 11, 5, 6, 1]) == [1]\n assert candidate(n = 10,rounds = [5, 10, 3, 8, 1]) == [1, 5, 6, 7, 8, 9, 10]\n assert candidate(n = 25,rounds = [5, 15, 25, 10, 20, 1, 11, 16, 6, 16, 11, 1, 20, 10, 25, 15, 5]) == [5]\n assert candidate(n = 8,rounds = [5, 8, 2, 7, 3, 6, 4, 1]) == [1, 5, 6, 7, 8]\n assert candidate(n = 20,rounds = [1, 10, 20, 5, 15, 3, 9, 18, 7, 12, 19]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(n = 8,rounds = [4, 8, 1, 5, 2, 6, 3, 7]) == [4, 5, 6, 7]\n"}, "metadata": {"canonical_parameter_names": ["n", "rounds"], "leetcode_dataset_entry_point": "Solution().mostVisited", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector mostVisited(int n, vector& rounds) {", "container": "Solution", "callable": "mostVisited", "parameters": [{"name": "n", "type": "int"}, {"name": "rounds", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1561, "task_id": "maximum-number-of-coins-you-can-get", "difficulty": "Medium", "problem_description": "There are 3n piles of coins of varying size, you and your friends will take piles of coins as follows:\n\nIn each step, you will choose any 3 piles of coins (not necessarily consecutive).\nOf your choice, Alice will pick the pile with the maximum number of coins.\nYou will pick the next pile with the maximum number of coins.\nYour friend Bob will pick the last pile.\nRepeat until there are no more piles of coins.\n\nGiven an array of integers piles where piles[i] is the number of coins in the ith pile.\nReturn the maximum number of coins that you can have.\n \nExample 1:\n\nInput: piles = [2,4,1,2,7,8]\nOutput: 9\nExplanation: Choose the triplet (2, 7, 8), Alice Pick the pile with 8 coins, you the pile with 7 coins and Bob the last one.\nChoose the triplet (1, 2, 4), Alice Pick the pile with 4 coins, you the pile with 2 coins and Bob the last one.\nThe maximum number of coins which you can have are: 7 + 2 = 9.\nOn the other hand if we choose this arrangement (1, 2, 8), (2, 4, 7) you only get 2 + 4 = 6 coins which is not optimal.\n\nExample 2:\n\nInput: piles = [2,4,5]\nOutput: 4\n\nExample 3:\n\nInput: piles = [9,8,7,6,5,1,2,3,4]\nOutput: 18\n\n \nConstraints:\n\n3 <= piles.length <= 105\npiles.length % 3 == 0\n1 <= piles[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(piles = [1, 12, 2, 11, 3, 10, 4, 9, 5, 8, 6, 7]) == 32\n assert candidate(piles = [2, 4, 1, 2, 7, 8]) == 9\n assert candidate(piles = [9, 8, 7, 6, 5, 1, 2, 3, 4]) == 18\n assert candidate(piles = [10000, 10000, 10000, 1, 1, 1, 2, 2, 2]) == 10004\n assert candidate(piles = [1, 12, 3, 11, 5, 10, 7, 4, 8, 6, 9, 2]) == 32\n assert candidate(piles = [1, 12, 3, 10, 5, 8, 7, 4, 6, 9, 11, 2]) == 32\n assert candidate(piles = [2, 4, 5]) == 4\n assert candidate(piles = [10000, 1, 10000, 1, 10000, 1]) == 10001\n assert candidate(piles = [3000, 1000, 2000, 4000, 5000, 6000]) == 8000\n assert candidate(piles = [10000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 32\n assert candidate(piles = [10000, 1, 10000, 2, 10000, 3]) == 10003\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 18\n assert candidate(piles = [1, 12, 3, 11, 5, 6, 7, 9, 8]) == 25\n assert candidate(piles = [3, 3, 3, 3, 3, 3]) == 6\n assert candidate(piles = [3, 3, 3, 3, 3, 3, 3, 3, 3]) == 9\n assert candidate(piles = [10000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 10200\n assert candidate(piles = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 316\n assert candidate(piles = [9999, 1, 9998, 2, 9997, 3, 9996, 4, 9995, 5, 9994, 6, 9993, 7, 9992, 8, 9991, 9, 9990, 10, 9989, 11, 9988, 12, 9987, 13, 9986, 14, 9985, 15, 9984, 16, 9983, 17, 9982, 18, 9981, 19]) == 89974\n assert candidate(piles = [3000, 2000, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2999, 2998, 2997, 2996, 2995, 2994, 2993, 2992, 2991, 2990, 2989, 2988, 2987, 2986, 2985, 2984, 2983, 2982, 2981, 2980, 2979, 2978, 2977, 2976, 2975, 2974, 2973, 2972, 2971, 2970, 2969, 2968, 2967, 2966, 2965, 2964, 2963, 2962, 2961, 2960]) == 64980\n assert candidate(piles = [8, 1, 3, 9, 2, 4, 10, 5, 6, 11, 7, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 2278\n assert candidate(piles = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991, 11, 990, 12, 989, 13, 988, 14, 987, 15, 986]) == 6990\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 50\n assert candidate(piles = [33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 242\n assert candidate(piles = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 18\n assert candidate(piles = [33, 29, 45, 17, 67, 78, 54, 90, 12, 34, 56, 78, 89, 90, 100, 200, 300, 400]) == 689\n assert candidate(piles = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 50\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 50\n assert candidate(piles = [500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 4, 3, 2, 1]) == 1100\n assert candidate(piles = [42, 23, 36, 17, 55, 87, 31, 69, 90, 14, 78, 52, 25, 63, 91, 19, 82, 46, 11, 73, 58, 39, 97, 15, 89, 44, 18, 76, 59, 41, 99, 12, 81, 45, 20, 75, 60, 42, 94, 13, 80, 43, 21, 74, 61, 47, 98, 16, 79, 48, 22, 72, 62, 50, 92, 24, 77, 51, 26, 71, 64, 53, 93, 27, 70, 54, 28, 67, 65, 56, 96, 29, 68, 57, 30, 66, 69, 58, 95, 32, 31, 34, 33, 38, 37, 40, 39, 44, 43, 46, 45, 48, 47, 50, 49, 52, 51]) == 2165\n assert candidate(piles = [20, 30, 10, 40, 50, 15, 60, 70, 25, 80, 90, 5, 100, 110, 35, 120, 130, 45, 140]) == 580\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 320\n assert candidate(piles = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981, 9980]) == 69951\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27]) == 162\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500]) == 5610\n assert candidate(piles = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 651\n assert candidate(piles = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000]) == 20000\n assert candidate(piles = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981, 9980, 9979, 9978, 9977, 9976, 9975, 9974, 9973, 9972, 9971]) == 99900\n assert candidate(piles = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18]) == 91\n assert candidate(piles = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000]) == 32000\n assert candidate(piles = [9, 7, 5, 3, 1, 8, 6, 4, 2]) == 18\n assert candidate(piles = [15, 18, 12, 3, 6, 9, 14, 17, 5, 10, 13, 7, 2, 16, 1, 8, 11, 4, 19, 20]) == 91\n assert candidate(piles = [50, 25, 75, 100, 200, 150, 175, 300, 225, 400, 125, 350, 500, 600, 800, 700, 900, 1000, 2000, 1500, 1100, 1300, 1600, 1400]) == 6775\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350]) == 2760\n assert candidate(piles = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 561\n assert candidate(piles = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981]) == 69951\n assert candidate(piles = [3, 1, 2, 6, 5, 4, 9, 8, 7, 12, 11, 10, 15, 14, 13, 18, 17, 16, 21, 20, 19, 24, 23, 22, 27, 26, 25, 30, 29, 28]) == 200\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 561\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 180\n assert candidate(piles = [10, 12, 34, 33, 5, 7, 6, 11, 13, 15, 17, 19]) == 74\n assert candidate(piles = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70]) == 890\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 910\n assert candidate(piles = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2569\n assert candidate(piles = [1, 3, 2, 4, 5, 6, 8, 7, 9, 11, 10, 12, 14, 13, 15, 17, 16, 18, 20, 19, 21, 22, 23, 24, 25]) == 153\n assert candidate(piles = [3, 1, 2, 5, 7, 8, 9, 4, 6]) == 18\n assert candidate(piles = [42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 392\n assert candidate(piles = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 644\n assert candidate(piles = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000, 21000, 22000, 23000, 24000, 25000, 26000, 27000]) == 162000\n assert candidate(piles = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 25\n assert candidate(piles = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 105\n assert candidate(piles = [5000, 4999, 4998, 4997, 4996, 4995, 4994, 4993, 4992, 4991, 4990, 4989, 4988, 4987, 4986, 4985, 4984, 4983, 4982, 4981, 4980, 4979, 4978, 4977, 4976, 4975, 4974, 4973, 4972, 4971]) == 49900\n assert candidate(piles = [23, 45, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90, 11, 22, 33, 44, 55, 66]) == 357\n assert candidate(piles = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992]) == 29991\n assert candidate(piles = [3, 1, 2, 5, 4, 6, 9, 7, 8, 12, 10, 11, 15, 13, 14, 18, 16, 17, 21, 19, 20, 24, 22, 23, 27, 25, 26, 30, 28, 29]) == 200\n assert candidate(piles = [300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1000, 950, 900]) == 1490\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 200\n assert candidate(piles = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 14]) == 33\n assert candidate(piles = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 45\n assert candidate(piles = [10, 11, 12, 13, 14, 15, 16, 17, 18]) == 45\n assert candidate(piles = [8, 5, 2, 12, 3, 7, 11, 6, 10, 4, 9, 1, 15, 14, 13, 18, 17, 16, 21, 20, 19, 24, 23, 22, 27, 26, 25, 30, 29, 28]) == 200\n assert candidate(piles = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5, 600, 6, 700, 7, 800, 8, 900, 9]) == 2016\n assert candidate(piles = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000]) == 20000\n assert candidate(piles = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2278\n assert candidate(piles = [3, 1, 2, 6, 4, 5, 9, 7, 8, 12, 10, 11, 15, 13, 14, 18, 16, 17, 21, 19, 20, 24, 22, 23, 27, 25, 26, 30, 28, 29, 33, 31, 32, 36, 34, 35, 39, 37, 38, 42, 40, 41, 45, 43, 44, 48, 46, 47, 51, 49, 50, 54, 52, 53, 57, 55, 56, 60, 58, 59, 63, 61, 62, 66, 64, 65]) == 968\n assert candidate(piles = [8, 6, 7, 5, 3, 0, 9, 1, 4, 2, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28]) == 190\n assert candidate(piles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(piles = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 145\n assert candidate(piles = [3333, 3332, 3331, 3330, 3329, 3328, 3327, 3326, 3325, 3324, 3323, 3322, 3321, 3320, 3319, 3318, 3317, 3316, 3315, 3314, 3313, 3312, 3311, 3310, 3309, 3308, 3307, 3306, 3305]) == 33230\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45]) == 450\n assert candidate(piles = [1, 10000, 2, 9999, 3, 9998, 4, 9997, 5, 9996, 6, 9995, 7, 9994, 8, 9993, 9, 9992, 10, 9991, 11, 9990, 12, 9989, 13, 9988, 14, 9987, 15, 9986]) == 69990\n assert candidate(piles = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000]) == 50000\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 153\n assert candidate(piles = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 31\n assert candidate(piles = [8, 1, 3, 5, 7, 2, 6, 4, 9, 12, 11, 10, 18, 17, 15, 16, 14, 13, 21, 20, 19, 24, 23, 22, 30, 29, 27, 28, 26]) == 192\n assert candidate(piles = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5]) == 2640\n assert candidate(piles = [3000, 2999, 2998, 2997, 2996, 2995, 2994, 2993, 2992, 2991, 2990, 2989, 2988, 2987, 2986, 2985, 2984, 2983, 2982, 2981]) == 20951\n assert candidate(piles = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 200\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250]) == 1530\n assert candidate(piles = [1, 2, 3, 100, 99, 98, 97, 96, 95, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94]) == 2278\n assert candidate(piles = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == 3200\n assert candidate(piles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == 1105\n assert candidate(piles = [1, 3, 2, 4, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19, 22, 21, 24, 23, 26, 25, 28, 27, 30, 29]) == 200\n assert candidate(piles = [50, 25, 75, 100, 200, 150, 300, 400, 350, 275, 175, 225]) == 975\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 200\n assert candidate(piles = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, 17, 16]) == 91\n assert candidate(piles = [5, 3, 8, 1, 9, 4, 2, 7, 6, 15, 10, 11, 14, 12, 13, 20, 16, 17, 19, 18, 25, 21, 22, 24, 23, 30, 26, 27, 29, 28]) == 200\n assert candidate(piles = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 189\n assert candidate(piles = [10, 10, 10, 20, 20, 20, 30, 30, 30, 40, 40, 40, 50, 50, 50]) == 180\n assert candidate(piles = [30, 20, 10, 50, 40, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 500\n assert candidate(piles = [10000, 10000, 10000, 9999, 9999, 9999, 9998, 9998, 9998, 9997, 9997, 9997, 9996, 9996, 9996, 9995, 9995, 9995, 9994, 9994, 9994, 9993, 9993, 9993, 9992, 9992, 9992, 9991, 9991, 9991, 9990, 9990, 9990, 9989, 9989, 9989, 9988, 9988, 9988, 9987, 9987, 9987, 9986, 9986, 9986, 9985, 9985, 9985, 9984, 9984, 9984, 9983, 9983, 9983, 9982, 9982, 9982, 9981, 9981, 9981, 9980, 9980, 9980, 9979, 9979, 9979, 9978, 9978, 9978]) == 229831\n"}, "metadata": {"canonical_parameter_names": ["piles"], "leetcode_dataset_entry_point": "Solution().maxCoins", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxCoins(vector& piles) {", "container": "Solution", "callable": "maxCoins", "parameters": [{"name": "piles", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1562, "task_id": "find-latest-group-of-size-m", "difficulty": "Medium", "problem_description": "Given an array arr that represents a permutation of numbers from 1 to n.\nYou have a binary string of size n that initially has all its bits set to zero. At each step i (assuming both the binary string and arr are 1-indexed) from 1 to n, the bit at position arr[i] is set to 1.\nYou are also given an integer m. Find the latest step at which there exists a group of ones of length m. A group of ones is a contiguous substring of 1's such that it cannot be extended in either direction.\nReturn the latest step at which there exists a group of ones of length exactly m. If no such group exists, return -1.\n \nExample 1:\n\nInput: arr = [3,5,1,2,4], m = 1\nOutput: 4\nExplanation: \nStep 1: \"00100\", groups: [\"1\"]\nStep 2: \"00101\", groups: [\"1\", \"1\"]\nStep 3: \"10101\", groups: [\"1\", \"1\", \"1\"]\nStep 4: \"11101\", groups: [\"111\", \"1\"]\nStep 5: \"11111\", groups: [\"11111\"]\nThe latest step at which there exists a group of size 1 is step 4.\n\nExample 2:\n\nInput: arr = [3,1,5,4,2], m = 2\nOutput: -1\nExplanation: \nStep 1: \"00100\", groups: [\"1\"]\nStep 2: \"10100\", groups: [\"1\", \"1\"]\nStep 3: \"10101\", groups: [\"1\", \"1\", \"1\"]\nStep 4: \"10111\", groups: [\"1\", \"111\"]\nStep 5: \"11111\", groups: [\"11111\"]\nNo group of size 2 exists during any step.\n\n \nConstraints:\n\nn == arr.length\n1 <= m <= n <= 105\n1 <= arr[i] <= n\nAll integers in arr are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 2, 3, 4, 5],m = 3) == 3\n assert candidate(arr = [1, 3, 5, 2, 4],m = 1) == 4\n assert candidate(arr = [2, 1, 3, 5, 4],m = 1) == 4\n assert candidate(arr = [3, 5, 1, 2, 4],m = 1) == 4\n assert candidate(arr = [5, 4, 3, 2, 1],m = 1) == 1\n assert candidate(arr = [5, 4, 3, 2, 1],m = 2) == 2\n assert candidate(arr = [3, 1, 5, 4, 2],m = 2) == -1\n assert candidate(arr = [1, 3, 2, 5, 4],m = 1) == 4\n assert candidate(arr = [1, 3, 5, 2, 4],m = 2) == -1\n assert candidate(arr = [2, 5, 8, 1, 4, 7, 10, 3, 6, 9],m = 3) == -1\n assert candidate(arr = [15, 1, 13, 2, 14, 3, 12, 4, 11, 5, 10, 6, 9, 7, 8],m = 5) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 6],m = 3) == 3\n assert candidate(arr = [8, 5, 10, 1, 9, 3, 6, 7, 4, 2],m = 2) == 7\n assert candidate(arr = [3, 2, 5, 1, 4, 6, 7, 8],m = 3) == 4\n assert candidate(arr = [3, 6, 2, 8, 1, 9, 4, 7, 5, 10],m = 3) == 6\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 6) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 3) == 3\n assert candidate(arr = [5, 10, 1, 2, 6, 8, 4, 7, 9, 3],m = 5) == 8\n assert candidate(arr = [1, 2, 4, 3, 6, 5, 8, 7, 10, 9],m = 3) == -1\n assert candidate(arr = [1, 10, 5, 6, 7, 8, 9, 2, 3, 4],m = 3) == 9\n assert candidate(arr = [5, 3, 1, 2, 4, 9, 7, 6, 8, 10],m = 1) == 8\n assert candidate(arr = [1, 2, 5, 6, 3, 4, 7, 8, 10, 9],m = 3) == 5\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],m = 2) == -1\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 5) == 5\n assert candidate(arr = [1, 4, 7, 10, 2, 5, 8, 11, 3, 6, 9, 12],m = 2) == 10\n assert candidate(arr = [5, 1, 9, 2, 6, 3, 7, 4, 8, 10],m = 3) == 7\n assert candidate(arr = [10, 1, 20, 2, 19, 3, 18, 4, 17, 5, 16, 6, 15, 7, 14, 8, 13, 9, 12, 11],m = 7) == 16\n assert candidate(arr = [1, 5, 9, 2, 6, 3, 7, 4, 8, 10],m = 2) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 1) == 1\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 6) == 6\n assert candidate(arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9],m = 2) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10) == 10\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 1) == 1\n assert candidate(arr = [2, 4, 1, 6, 5, 3],m = 2) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 5) == 5\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 4) == 4\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 10) == 10\n assert candidate(arr = [6, 2, 5, 9, 7, 8, 3, 1, 10, 4],m = 5) == 8\n assert candidate(arr = [1, 6, 4, 3, 2, 5],m = 1) == 5\n assert candidate(arr = [5, 1, 6, 3, 8, 2, 7, 10, 4, 9],m = 3) == 8\n assert candidate(arr = [1, 15, 2, 14, 3, 13, 4, 12, 5, 11, 6, 10, 7, 9, 8],m = 7) == 14\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 2) == 2\n assert candidate(arr = [10, 5, 2, 7, 1, 8, 3, 6, 9, 4],m = 3) == 9\n assert candidate(arr = [10, 8, 6, 4, 2, 1, 3, 5, 7, 9],m = 1) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 5) == 5\n assert candidate(arr = [6, 5, 4, 3, 2, 1],m = 3) == 3\n assert candidate(arr = [7, 3, 10, 8, 6, 9, 1, 5, 4, 2],m = 4) == -1\n assert candidate(arr = [1, 2, 5, 4, 3, 6, 7, 8, 9, 10],m = 2) == 4\n assert candidate(arr = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],m = 9) == -1\n assert candidate(arr = [3, 6, 1, 9, 7, 8, 2, 5, 10, 4],m = 3) == 9\n assert candidate(arr = [3, 1, 7, 5, 9, 2, 8, 6, 10, 4],m = 4) == -1\n assert candidate(arr = [6, 7, 8, 1, 2, 3, 4, 5, 12, 11, 9, 10],m = 6) == -1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 1) == 1\n assert candidate(arr = [10, 5, 1, 6, 3, 8, 9, 2, 7, 4],m = 2) == 8\n assert candidate(arr = [3, 5, 2, 1, 4, 6, 8, 7, 10, 9],m = 1) == 9\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],m = 4) == 9\n assert candidate(arr = [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 10, 20],m = 10) == -1\n assert candidate(arr = [3, 1, 5, 7, 6, 2, 8, 4, 9, 10],m = 2) == -1\n assert candidate(arr = [1, 2, 5, 6, 3, 4, 9, 10, 7, 8],m = 2) == 9\n assert candidate(arr = [1, 10, 3, 8, 5, 12, 7, 2, 9, 4, 6, 11],m = 4) == 10\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 5) == 5\n assert candidate(arr = [6, 5, 8, 4, 7, 10, 9, 1, 2, 3],m = 3) == 4\n assert candidate(arr = [9, 5, 10, 1, 2, 3, 4, 6, 7, 8],m = 4) == -1\n assert candidate(arr = [3, 1, 4, 2, 5, 6, 7, 8, 9, 10],m = 3) == -1\n assert candidate(arr = [6, 2, 3, 1, 5, 4],m = 2) == 5\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],m = 1) == 8\n assert candidate(arr = [6, 3, 1, 5, 4, 2],m = 1) == 5\n assert candidate(arr = [5, 1, 9, 3, 7, 2, 8, 6, 4, 10],m = 2) == -1\n assert candidate(arr = [5, 2, 1, 8, 3, 4, 7, 6, 10, 9],m = 2) == 7\n assert candidate(arr = [10, 2, 8, 4, 6, 3, 9, 5, 7, 1],m = 3) == 8\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 3) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 5) == 5\n assert candidate(arr = [5, 1, 6, 3, 4, 2],m = 1) == 5\n assert candidate(arr = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],m = 4) == 5\n assert candidate(arr = [5, 1, 9, 10, 3, 7, 4, 6, 8, 2],m = 3) == 7\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 3) == 3\n assert candidate(arr = [6, 4, 2, 8, 10, 1, 3, 5, 7, 9],m = 2) == 6\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 1) == 1\n assert candidate(arr = [3, 1, 4, 2, 6, 5, 7, 10, 9, 8],m = 4) == 5\n assert candidate(arr = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9],m = 2) == 6\n assert candidate(arr = [5, 1, 7, 10, 3, 8, 4, 6, 9, 2],m = 4) == -1\n assert candidate(arr = [3, 6, 1, 8, 2, 7, 4, 9, 5, 10],m = 1) == 5\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 20, 12, 19, 13, 18, 14, 17, 15, 16],m = 8) == -1\n assert candidate(arr = [1, 2, 4, 5, 3, 7, 6, 8, 10, 9],m = 2) == 4\n assert candidate(arr = [6, 3, 5, 1, 2, 4, 9, 7, 8, 10],m = 4) == -1\n assert candidate(arr = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9],m = 5) == -1\n assert candidate(arr = [1, 5, 3, 9, 7, 2, 6, 10, 4, 8],m = 1) == 7\n assert candidate(arr = [7, 5, 3, 1, 9, 10, 8, 6, 4, 2],m = 5) == -1\n assert candidate(arr = [5, 3, 8, 6, 2, 4, 1, 7, 9, 10],m = 3) == -1\n assert candidate(arr = [3, 2, 5, 4, 8, 7, 10, 9, 6, 1],m = 4) == 8\n assert candidate(arr = [1, 6, 10, 3, 5, 9, 2, 4, 8, 7],m = 4) == -1\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],m = 4) == 9\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 2) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 4) == 4\n assert candidate(arr = [5, 3, 1, 2, 4, 6, 7, 8, 9, 10],m = 3) == 4\n assert candidate(arr = [5, 1, 9, 3, 7, 2, 8, 10, 4, 6],m = 5) == 9\n assert candidate(arr = [3, 6, 9, 2, 5, 8, 1, 4, 7, 10],m = 2) == 8\n assert candidate(arr = [10, 2, 6, 4, 7, 9, 1, 8, 5, 3],m = 5) == 8\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4],m = 3) == 9\n assert candidate(arr = [5, 2, 8, 10, 3, 7, 4, 6, 9, 1],m = 2) == 7\n assert candidate(arr = [10, 8, 6, 4, 2, 1, 3, 5, 7, 9],m = 2) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 4) == 4\n assert candidate(arr = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5],m = 4) == 9\n assert candidate(arr = [1, 2, 5, 4, 7, 3, 8, 6, 9, 10],m = 2) == 7\n assert candidate(arr = [5, 3, 1, 7, 9, 10, 8, 6, 4, 2],m = 3) == -1\n assert candidate(arr = [6, 1, 4, 5, 3, 7, 9, 8, 10, 2],m = 2) == -1\n"}, "metadata": {"canonical_parameter_names": ["arr", "m"], "leetcode_dataset_entry_point": "Solution().findLatestStep", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int findLatestStep(vector& arr, int m) {", "container": "Solution", "callable": "findLatestStep", "parameters": [{"name": "arr", "type": "vector&"}, {"name": "m", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1563, "task_id": "stone-game-v", "difficulty": "Hard", "problem_description": "There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.\nIn each round of the game, Alice divides the row into two non-empty rows (i.e. left row and right row), then Bob calculates the value of each row which is the sum of the values of all the stones in this row. Bob throws away the row which has the maximum value, and Alice's score increases by the value of the remaining row. If the value of the two rows are equal, Bob lets Alice decide which row will be thrown away. The next round starts with the remaining row.\nThe game ends when there is only one stone remaining. Alice's is initially zero.\nReturn the maximum score that Alice can obtain.\n \nExample 1:\n\nInput: stoneValue = [6,2,3,4,5,5]\nOutput: 18\nExplanation: In the first round, Alice divides the row to [6,2,3], [4,5,5]. The left row has the value 11 and the right row has value 14. Bob throws away the right row and Alice's score is now 11.\nIn the second round Alice divides the row to [6], [2,3]. This time Bob throws away the left row and Alice's score becomes 16 (11 + 5).\nThe last round Alice has only one choice to divide the row which is [2], [3]. Bob throws away the right row and Alice's score is now 18 (16 + 2). The game ends because only one stone is remaining in the row.\n\nExample 2:\n\nInput: stoneValue = [7,7,7,7,7,7,7]\nOutput: 28\n\nExample 3:\n\nInput: stoneValue = [4]\nOutput: 0\n\n \nConstraints:\n\n1 <= stoneValue.length <= 500\n1 <= stoneValue[i] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(stoneValue = [1, 2, 3, 4, 5]) == 10\n assert candidate(stoneValue = [5, 3, 1, 4, 2]) == 9\n assert candidate(stoneValue = [1, 3, 5, 7, 9, 11, 13]) == 35\n assert candidate(stoneValue = [3, 6, 2, 8, 7, 4, 5]) == 23\n assert candidate(stoneValue = [3, 2, 4, 1, 4, 1, 3, 2]) == 17\n assert candidate(stoneValue = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 40\n assert candidate(stoneValue = [3, 1, 5, 4, 2]) == 8\n assert candidate(stoneValue = [4]) == 0\n assert candidate(stoneValue = [1, 100, 1]) == 1\n assert candidate(stoneValue = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 35\n assert candidate(stoneValue = [6, 2, 3, 4, 5, 5]) == 18\n assert candidate(stoneValue = [7, 7, 7, 7, 7, 7, 7]) == 28\n assert candidate(stoneValue = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(stoneValue = [10, 10, 10, 10, 10, 10]) == 40\n assert candidate(stoneValue = [3, 6, 1, 2, 5, 4]) == 13\n assert candidate(stoneValue = [1000000, 1000000]) == 1000000\n assert candidate(stoneValue = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 37\n assert candidate(stoneValue = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 84\n assert candidate(stoneValue = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 35\n assert candidate(stoneValue = [1000000, 1000000]) == 1000000\n assert candidate(stoneValue = [10, 10, 10, 10, 10]) == 30\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 277\n assert candidate(stoneValue = [100, 200, 300, 400, 500, 400, 300, 200, 100]) == 1400\n assert candidate(stoneValue = [8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 366\n assert candidate(stoneValue = [15, 20, 5, 10, 25, 30, 5]) == 70\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 92\n assert candidate(stoneValue = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 125\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 1179\n assert candidate(stoneValue = [1000000, 900000, 800000, 700000, 600000, 500000, 400000, 300000, 200000, 100000]) == 3700000\n assert candidate(stoneValue = [1000000, 1, 1000000, 1, 1000000]) == 1000002\n assert candidate(stoneValue = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 35\n assert candidate(stoneValue = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 194\n assert candidate(stoneValue = [1000000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 35\n assert candidate(stoneValue = [5, 1, 4, 9, 7, 2, 8, 6, 3]) == 31\n assert candidate(stoneValue = [5, 3, 8, 2, 7, 9, 1, 4, 6, 10]) == 36\n assert candidate(stoneValue = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 184\n assert candidate(stoneValue = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(stoneValue = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 137\n assert candidate(stoneValue = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 35\n assert candidate(stoneValue = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 26\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 92\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 920\n assert candidate(stoneValue = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 79\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 80\n assert candidate(stoneValue = [100, 200, 300, 400, 500, 150, 250, 350, 450, 550]) == 2500\n assert candidate(stoneValue = [1, 2, 3, 4, 3, 2, 1]) == 10\n assert candidate(stoneValue = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 184\n assert candidate(stoneValue = [1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000]) == 7000004\n assert candidate(stoneValue = [5, 10, 5, 10, 5, 10, 5, 10, 5, 10, 5]) == 55\n assert candidate(stoneValue = [1000000, 500000, 750000, 250000, 600000, 400000]) == 2000000\n assert candidate(stoneValue = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 74\n assert candidate(stoneValue = [1000000, 999999, 999998, 999997, 999996, 999995]) == 3999985\n assert candidate(stoneValue = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 357\n assert candidate(stoneValue = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 21\n assert candidate(stoneValue = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 460\n assert candidate(stoneValue = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 35\n assert candidate(stoneValue = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 800\n assert candidate(stoneValue = [10, 5, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 945\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 189\n assert candidate(stoneValue = [100, 50, 30, 20, 10, 5, 1]) == 100\n assert candidate(stoneValue = [8, 6, 4, 2, 1, 3, 5, 7, 9]) == 32\n assert candidate(stoneValue = [23, 45, 12, 67, 89, 34, 56, 78, 90, 12, 34, 56, 78, 90]) == 606\n assert candidate(stoneValue = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 90\n assert candidate(stoneValue = [1000000, 900000, 800000, 700000, 600000, 500000, 400000, 300000, 200000, 100000]) == 3700000\n assert candidate(stoneValue = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205]) == 1780\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == 25\n assert candidate(stoneValue = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 3700\n assert candidate(stoneValue = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == 555\n assert candidate(stoneValue = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41]) == 165\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 1890\n assert candidate(stoneValue = [20, 30, 10, 40, 50, 15, 25, 35]) == 170\n assert candidate(stoneValue = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == 278\n assert candidate(stoneValue = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 35\n assert candidate(stoneValue = [50, 25, 75, 100, 200, 150, 300, 50, 25, 75, 100, 200, 150, 300, 50]) == 1625\n assert candidate(stoneValue = [42, 33, 24, 15, 6, 3, 12, 21, 30, 39, 48, 57, 66]) == 327\n assert candidate(stoneValue = [1, 3, 2, 4, 7, 6, 5, 8, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]) == 189\n assert candidate(stoneValue = [500000, 400000, 300000, 200000, 100000, 50000, 40000, 30000, 20000, 10000]) == 1140000\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 59\n assert candidate(stoneValue = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 3700\n assert candidate(stoneValue = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000]) == 92000\n assert candidate(stoneValue = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 89\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 800\n assert candidate(stoneValue = [50, 40, 30, 20, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 1980\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 40, 30, 20, 10, 5, 15, 25, 35, 45, 55]) == 355\n assert candidate(stoneValue = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 18900\n assert candidate(stoneValue = [9, 1, 9, 1, 9, 1, 9, 1, 9, 1]) == 32\n assert candidate(stoneValue = [5, 12, 8, 4, 9, 2, 7]) == 33\n assert candidate(stoneValue = [10, 20, 30, 40, 50, 40, 30, 20, 10]) == 140\n assert candidate(stoneValue = [5, 3, 8, 7, 1, 9, 4, 6, 2, 10]) == 36\n assert candidate(stoneValue = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == 11000000\n assert candidate(stoneValue = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 37\n assert candidate(stoneValue = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2]) == 76\n"}, "metadata": {"canonical_parameter_names": ["stoneValue"], "leetcode_dataset_entry_point": "Solution().stoneGameV", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int stoneGameV(vector& stoneValue) {", "container": "Solution", "callable": "stoneGameV", "parameters": [{"name": "stoneValue", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1566, "task_id": "detect-pattern-of-length-m-repeated-k-or-more-times", "difficulty": "Easy", "problem_description": "Given an array of positive integers arr, find a pattern of length m that is repeated k or more times.\nA pattern is a subarray (consecutive sub-sequence) that consists of one or more values, repeated multiple times consecutively without overlapping. A pattern is defined by its length and the number of repetitions.\nReturn true if there exists a pattern of length m that is repeated k or more times, otherwise return false.\n \nExample 1:\n\nInput: arr = [1,2,4,4,4,4], m = 1, k = 3\nOutput: true\nExplanation: The pattern (4) of length 1 is repeated 4 consecutive times. Notice that pattern can be repeated k or more times but not less.\n\nExample 2:\n\nInput: arr = [1,2,1,2,1,1,1,3], m = 2, k = 2\nOutput: true\nExplanation: The pattern (1,2) of length 2 is repeated 2 consecutive times. Another valid pattern (2,1) is also repeated 2 times.\n\nExample 3:\n\nInput: arr = [1,2,1,2,1,3], m = 2, k = 3\nOutput: false\nExplanation: The pattern (1,2) is of length 2 but is repeated only 2 times. There is no pattern of length 2 that is repeated 3 or more times.\n\n \nConstraints:\n\n2 <= arr.length <= 100\n1 <= arr[i] <= 100\n1 <= m <= 100\n2 <= k <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [1, 2, 4, 4, 4, 4],m = 1,k = 3) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2],m = 2,k = 2) == True\n assert candidate(arr = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3],m = 2,k = 5) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],m = 1,k = 10) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5],m = 7,k = 1) == False\n assert candidate(arr = [1, 1, 1, 1, 1, 1],m = 1,k = 6) == True\n assert candidate(arr = [1, 1, 1, 1],m = 1,k = 4) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3],m = 3,k = 3) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],m = 2,k = 5) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1],m = 9,k = 1) == False\n assert candidate(arr = [5, 5, 5, 1, 5, 5, 5, 5],m = 3,k = 2) == False\n assert candidate(arr = [1, 2, 2, 1, 2, 2, 1, 2, 2],m = 2,k = 3) == False\n assert candidate(arr = [1, 2, 1, 2, 1, 3],m = 2,k = 3) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3],m = 5,k = 2) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 5,k = 2) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],m = 1,k = 10) == True\n assert candidate(arr = [2, 2, 2, 2, 2, 2],m = 2,k = 3) == True\n assert candidate(arr = [1, 1, 2, 2, 1, 1, 2, 2],m = 2,k = 2) == False\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3],m = 3,k = 2) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5],m = 3,k = 2) == True\n assert candidate(arr = [1, 2, 1, 2, 1, 1, 1, 3],m = 2,k = 2) == True\n assert candidate(arr = [10, 20, 10, 20, 10, 20, 10],m = 2,k = 4) == False\n assert candidate(arr = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1],m = 2,k = 3) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1],m = 1,k = 2) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 1,k = 2) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9],m = 9,k = 2) == True\n assert candidate(arr = [1, 1, 1, 1, 1],m = 1,k = 5) == True\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5],m = 4,k = 2) == True\n assert candidate(arr = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],m = 4,k = 3) == True\n assert candidate(arr = [2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6],m = 4,k = 2) == False\n assert candidate(arr = [3, 1, 3, 1, 3, 1, 3, 1],m = 2,k = 4) == True\n assert candidate(arr = [6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9],m = 4,k = 6) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1],m = 3,k = 3) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],m = 6,k = 2) == True\n assert candidate(arr = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30],m = 3,k = 5) == True\n assert candidate(arr = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30],m = 3,k = 4) == True\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],m = 2,k = 12) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 4, 5],m = 3,k = 3) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 5,k = 2) == True\n assert candidate(arr = [4, 5, 6, 7, 8, 4, 5, 6, 7, 8, 4, 5, 6, 7, 8, 4, 5, 6, 7, 8, 4, 5],m = 5,k = 3) == True\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],m = 4,k = 4) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 5,k = 4) == True\n assert candidate(arr = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30],m = 3,k = 4) == True\n assert candidate(arr = [100, 100, 99, 99, 98, 98, 97, 97, 96, 96, 95, 95, 94, 94, 93, 93, 92, 92, 91, 91],m = 2,k = 5) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6],m = 5,k = 2) == True\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],m = 7,k = 2) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10,k = 2) == True\n assert candidate(arr = [5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7],m = 3,k = 10) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],m = 3,k = 6) == True\n assert candidate(arr = [4, 4, 4, 5, 5, 5, 4, 4, 4, 5, 5, 5, 4, 4, 4, 5, 5, 5],m = 2,k = 6) == False\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 10,k = 2) == True\n assert candidate(arr = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],m = 4,k = 5) == True\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2],m = 3,k = 4) == False\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],m = 4,k = 2) == False\n assert candidate(arr = [6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],m = 2,k = 5) == False\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],m = 2,k = 10) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],m = 3,k = 7) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 4],m = 3,k = 3) == True\n assert candidate(arr = [1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2],m = 2,k = 4) == False\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3],m = 3,k = 2) == False\n assert candidate(arr = [3, 3, 3, 3, 3, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3],m = 5,k = 2) == False\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],m = 2,k = 13) == True\n assert candidate(arr = [2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1],m = 4,k = 2) == False\n assert candidate(arr = [4, 4, 5, 5, 5, 5, 5, 4, 4, 5, 5, 5, 5, 5],m = 5,k = 2) == False\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],m = 5,k = 5) == True\n assert candidate(arr = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],m = 5,k = 3) == True\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],m = 1,k = 18) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],m = 3,k = 3) == True\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],m = 5,k = 5) == True\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 5,k = 6) == True\n assert candidate(arr = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],m = 5,k = 5) == True\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],m = 2,k = 10) == True\n assert candidate(arr = [4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5],m = 2,k = 5) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],m = 6,k = 3) == True\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1],m = 2,k = 10) == True\n assert candidate(arr = [10, 10, 20, 20, 10, 10, 20, 20, 10, 10],m = 2,k = 3) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9],m = 9,k = 4) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 5,k = 3) == True\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],m = 2,k = 5) == True\n assert candidate(arr = [9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6],m = 5,k = 2) == False\n assert candidate(arr = [9, 8, 7, 6, 9, 8, 7, 6, 9, 8, 7, 6, 9, 8, 7, 6],m = 4,k = 3) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 5,k = 5) == True\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3, 1, 1],m = 3,k = 2) == False\n assert candidate(arr = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30],m = 3,k = 7) == True\n assert candidate(arr = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1],m = 3,k = 12) == True\n assert candidate(arr = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 7, 8],m = 4,k = 3) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 4, 5, 6],m = 3,k = 2) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],m = 3,k = 3) == True\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 1, 1, 1, 2, 2, 2],m = 3,k = 2) == False\n assert candidate(arr = [5, 6, 7, 5, 6, 7, 5, 6, 8, 5, 6, 7, 5, 6, 7, 5, 6, 7],m = 3,k = 3) == True\n assert candidate(arr = [3, 3, 3, 3, 3, 1, 3, 3, 3, 3],m = 4,k = 2) == False\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 2, 2, 3, 3, 4, 4],m = 2,k = 3) == False\n assert candidate(arr = [5, 6, 5, 6, 7, 8, 7, 8, 9, 10, 9, 10, 9, 10],m = 2,k = 2) == True\n assert candidate(arr = [3, 3, 3, 4, 4, 4, 3, 3, 3, 4, 4, 4, 3, 3, 3, 4, 4, 4],m = 3,k = 2) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 5,k = 2) == True\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],m = 1,k = 8) == True\n assert candidate(arr = [10, 10, 10, 20, 20, 20, 30, 30, 30, 10, 10, 10, 20, 20, 20, 30, 30, 30],m = 3,k = 2) == False\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],m = 10,k = 3) == True\n assert candidate(arr = [6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9, 6, 7, 8, 9],m = 4,k = 4) == True\n assert candidate(arr = [4, 5, 6, 7, 4, 5, 6, 7, 4, 5, 6, 7, 4, 5, 6, 7, 4, 5, 6, 7],m = 4,k = 5) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 1, 2, 3, 4, 5, 6, 1, 2, 3],m = 3,k = 3) == True\n assert candidate(arr = [7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9],m = 3,k = 4) == True\n assert candidate(arr = [7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9, 7, 8, 9],m = 3,k = 4) == True\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],m = 3,k = 4) == False\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],m = 5,k = 3) == True\n assert candidate(arr = [9, 10, 11, 9, 10, 11, 9, 10, 11, 9, 10, 11, 9, 10, 11],m = 3,k = 5) == True\n assert candidate(arr = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20],m = 2,k = 5) == True\n assert candidate(arr = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3],m = 2,k = 5) == True\n assert candidate(arr = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],m = 4,k = 5) == True\n assert candidate(arr = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],m = 10,k = 3) == True\n assert candidate(arr = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20],m = 3,k = 3) == True\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],m = 5,k = 2) == True\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 2, 2, 3, 3, 4, 4, 1, 1, 2, 2],m = 4,k = 2) == False\n assert candidate(arr = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1],m = 2,k = 4) == False\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],m = 10,k = 1) == False\n assert candidate(arr = [1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2],m = 2,k = 5) == False\n assert candidate(arr = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],m = 5,k = 3) == True\n assert candidate(arr = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],m = 4,k = 5) == True\n assert candidate(arr = [1, 2, 3, 4, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 1, 2, 3, 4],m = 4,k = 3) == False\n assert candidate(arr = [2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4, 2, 4],m = 2,k = 10) == True\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2],m = 4,k = 2) == False\n assert candidate(arr = [1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2],m = 6,k = 2) == True\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],m = 5,k = 4) == True\n assert candidate(arr = [5, 5, 1, 1, 5, 5, 1, 1, 5, 5, 1, 1, 5, 5, 1, 1, 5, 5],m = 2,k = 4) == False\n assert candidate(arr = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],m = 10,k = 3) == True\n assert candidate(arr = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],m = 10,k = 3) == True\n assert candidate(arr = [8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 8, 8, 9, 9, 10, 10, 11, 11],m = 2,k = 4) == False\n assert candidate(arr = [1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2],m = 6,k = 2) == False\n"}, "metadata": {"canonical_parameter_names": ["arr", "m", "k"], "leetcode_dataset_entry_point": "Solution().containsPattern", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool containsPattern(vector& arr, int m, int k) {", "container": "Solution", "callable": "containsPattern", "parameters": [{"name": "arr", "type": "vector&"}, {"name": "m", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1567, "task_id": "maximum-length-of-subarray-with-positive-product", "difficulty": "Medium", "problem_description": "Given an array of integers nums, find the maximum length of a subarray where the product of all its elements is positive.\nA subarray of an array is a consecutive sequence of zero or more values taken out of that array.\nReturn the maximum length of a subarray with positive product.\n \nExample 1:\n\nInput: nums = [1,-2,-3,4]\nOutput: 4\nExplanation: The array nums already has a positive product of 24.\n\nExample 2:\n\nInput: nums = [0,1,-2,-3,-4]\nOutput: 3\nExplanation: The longest subarray with positive product is [1,-2,-3] which has a product of 6.\nNotice that we cannot include 0 in the subarray since that'll make the product 0 which is not positive.\nExample 3:\n\nInput: nums = [-1,-2,-3,0,1]\nOutput: 2\nExplanation: The longest subarray with positive product is [-1,-2] or [-2,-3].\n\n \nConstraints:\n\n1 <= nums.length <= 105\n-109 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, 2, -3, 4, -5]) == 4\n assert candidate(nums = [-1, -2, -3, 0, 1]) == 2\n assert candidate(nums = [-1]) == 0\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, 2, 3, 0, -1, -2, -3]) == 3\n assert candidate(nums = [1, 0, -2, 3, -4, 0, 5, 6]) == 3\n assert candidate(nums = [-1, 0, 1, 0, -1]) == 1\n assert candidate(nums = [1, 2, 3, 0, -1, -2, -3, 4, 5, 0, 6, 7, 8]) == 4\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1]) == 5\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [-1, -1, -1, -1]) == 4\n assert candidate(nums = [-1, 0, 1, 0, -1, 0, 1]) == 1\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 2, 3, -4, 5, 0, -6, 7, 8, 9]) == 3\n assert candidate(nums = [-10, -20, -30, -40, -50]) == 4\n assert candidate(nums = [1, 0, -2, 3, 4, -5, 0, 6, 7, 8, 9, 0, -1]) == 4\n assert candidate(nums = [0, 1, -2, -3, -4]) == 3\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000]) == 4\n assert candidate(nums = [1, 2, 0, 3, 4, -5, 6, 0, 7, 8]) == 2\n assert candidate(nums = [1, -2, -3, 4]) == 4\n assert candidate(nums = [1, 0, -2, 0, 3, 0, -4]) == 1\n assert candidate(nums = [1, 2, -1, -2, -1, 1, 2, -1, -2, -1]) == 10\n assert candidate(nums = [1, 2, 3, 0, -1, -2, -3, 0, 4, 5, 6, 0, -7, -8, -9, 0, 10, 11, 12]) == 3\n assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6]) == 1\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15]) == 15\n assert candidate(nums = [-1, 0, 1, 0, -1, 0, 1, 0, -1, 0]) == 1\n assert candidate(nums = [0, 0, 0, 0, 1, 2, -3, 4, 5, 0, 0, -1, -2, -3, 0, 4, 5, 6]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000]) == 5\n assert candidate(nums = [0, 1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20, 0, 21, -22, 23, -24, 25, -26, 27, -28, 29, -30, 0]) == 20\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, 0]) == 9\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 1\n assert candidate(nums = [1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1]) == 1\n assert candidate(nums = [-1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 20\n assert candidate(nums = [-1, -1, -1, -1, 1, 1, 1, 1, -1, -1, -1, -1]) == 12\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20, 21, -22, 23, -24, 25, -26, 27, -28, 29, -30]) == 29\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, -10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 0]) == 10\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 0, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 0, -1, -2, -3, -4, -5, 0, 1, 2, 3, 4, 5, 0, -1, -2, -3, -4, -5]) == 5\n assert candidate(nums = [1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0]) == 1\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 20\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60]) == 12\n assert candidate(nums = [1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 0, 1, 2, 3, 4, 5, -6, -7, -8, -9, -10]) == 14\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 13\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 40\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 2, 3, -4, 5, 6, -7, 8, 9, 10]) == 10\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 20\n assert candidate(nums = [1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]) == 20\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000]) == 5\n assert candidate(nums = [1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, -1]) == 1\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 20\n assert candidate(nums = [1, -1, -1, 1, -1, -1, 1, -1, -1, 1]) == 10\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 0, -1, -2, -3, -4, -5, 0]) == 5\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 28\n assert candidate(nums = [0, 1, 2, 3, 0, -1, -2, -3, 0, 1, 2, 3]) == 3\n assert candidate(nums = [1, 2, 3, 0, 0, 0, 0, 0, 0, 4, 5, 6, 0, 7, 8, 9, 0, 10, 11, 12]) == 3\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11]) == 11\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 14\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 13\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 9\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100]) == 9\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30]) == 30\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, -1]) == 9\n assert candidate(nums = [0, 0, 0, 1, 2, 3, 0, -1, -2, -3, 0]) == 3\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 1]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 20\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [0, 0, 0, 0, 1, -1, 1, -1, 0, 0, 0, 1, 1, 1, -1, -1, -1, 0, 0, 0]) == 5\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 0, -1, -2, -3, -4, -5]) == 5\n assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5]) == 1\n assert candidate(nums = [1, 2, 3, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, 11, 12, 13, 14, 15]) == 18\n assert candidate(nums = [-1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1]) == 1\n assert candidate(nums = [1, -2, 0, 3, -4, 0, 5, -6, 0, 7, -8, 0, 9, -10, 0]) == 1\n assert candidate(nums = [0, 0, 0, 0, 1, -2, 3, -4, 5]) == 5\n assert candidate(nums = [1, 2, 0, 3, 4, 0, 5, 6, 0, 7, 8, 9]) == 3\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 0, 6, 7, 8, 9, 0, 10, 11, 12, 0, 13, 14, 15, 0]) == 5\n assert candidate(nums = [1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0]) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 9\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 0, -1, -2, -3, -4, -5, 0, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == 25\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23, 24, -25, 26, -27, 28, -29, 30]) == 29\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16]) == 16\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 10\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [-2, -3, -5, 0, 5, 7, -2, -3, 1, 0, 12, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 12\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 9\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 9\n assert candidate(nums = [0, -1, 2, -3, 4, -5, 6, -7, 8, 0, -9, 10, -11]) == 8\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100, -110, 120]) == 12\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, -6, -7, -8, -9, -10, -11, -12]) == 11\n assert candidate(nums = [5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 16\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 10\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 10\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0]) == 20\n assert candidate(nums = [5, 6, 7, 8, 9, 10, -11, -12, -13, -14, -15, 16, 17, 18, 19, 20]) == 10\n assert candidate(nums = [1, 2, 3, 4, -5, 6, 7, 8, 9, -10]) == 10\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 16\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == 40\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000, 0, 100, -200, 300]) == 9\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 20\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().getMaxLen", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int getMaxLen(vector& nums) {", "container": "Solution", "callable": "getMaxLen", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1568, "task_id": "minimum-number-of-days-to-disconnect-island", "difficulty": "Hard", "problem_description": "You are given an m x n binary grid grid where 1 represents land and 0 represents water. An island is a maximal 4-directionally (horizontal or vertical) connected group of 1's.\nThe grid is said to be connected if we have exactly one island, otherwise is said disconnected.\nIn one day, we are allowed to change any single land cell (1) into a water cell (0).\nReturn the minimum number of days to disconnect the grid.\n \nExample 1:\n\n\nInput: grid = [[0,1,1,0],[0,1,1,0],[0,0,0,0]]\n\nOutput: 2\nExplanation: We need at least 2 days to get a disconnected grid.\nChange land grid[1][1] and grid[0][2] to water and get 2 disconnected island.\n\nExample 2:\n\n\nInput: grid = [[1,1]]\nOutput: 2\nExplanation: Grid of full water is also disconnected ([[1,1]] -> [[0,0]]), 0 islands.\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 30\ngrid[i][j] is either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1]]) == 2\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == 2\n assert candidate(grid = [[1, 1, 0], [0, 0, 0], [0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 1, 1, 0], [1, 0, 1, 1, 0, 1, 0], [0, 0, 0, 0, 1, 0, 0], [1, 1, 0, 0, 0, 0, 1], [0, 0, 1, 1, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 1, 1, 1, 0], [0, 1, 0, 1, 0], [0, 1, 1, 1, 0], [1, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 1, 1], [1, 1, 0, 1, 1], [0, 0, 0, 0, 0], [1, 1, 0, 1, 1], [1, 1, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 0], [1, 0, 1, 0, 1, 0], [1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1], [0, 1, 0, 1, 0, 1], [0, 0, 0, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 0, 0, 0, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0], [0, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1], [0, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 1, 1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 1, 1, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 0, 1, 1, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 0, 0, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 0, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0], [0, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 0], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0], [1, 0, 1, 0, 0], [1, 1, 1, 1, 0], [0, 0, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 0], [1, 0, 0, 1, 0], [1, 1, 1, 1, 0], [0, 0, 0, 0, 0]]) == 2\n assert candidate(grid = [[1, 1, 1, 1, 0, 0, 0], [1, 0, 0, 1, 1, 1, 0], [0, 0, 1, 0, 0, 0, 1], [0, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 0], [1, 0, 0, 1, 1, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0], [1, 1, 0, 1, 1, 0], [0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 1, 1, 1], [0, 1, 0, 1, 0, 0], [0, 0, 1, 1, 0, 0], [0, 1, 0, 1, 0, 0], [1, 1, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 1, 0, 1], [1, 0, 1, 1], [1, 0, 0, 1]]) == 1\n assert candidate(grid = [[1, 1, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [1, 0, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [1, 0, 0, 0, 0, 1], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [1, 0, 0, 0, 0, 1], [1, 1, 0, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid = [[1, 1, 0, 0, 0], [1, 1, 0, 1, 1], [0, 0, 0, 1, 1], [0, 1, 0, 0, 0], [0, 1, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 0], [1, 1, 0, 1, 0], [1, 1, 1, 1, 0], [0, 0, 0, 0, 0]]) == 2\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 0, 0], [1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 0], [1, 0, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 1, 1], [1, 0, 1], [1, 1, 1]]) == 2\n assert candidate(grid = [[1, 0, 0, 1, 0, 1, 0], [0, 1, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 1, 0, 1, 0, 1, 1], [0, 1, 0, 1, 0, 0, 1], [0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 0, 1], [0, 1, 1, 1, 0, 0], [0, 1, 0, 1, 0, 0], [0, 1, 1, 1, 0, 0], [1, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 1, 1, 1], [1, 0, 1, 1]]) == 1\n assert candidate(grid = [[1, 1, 1, 0, 0], [0, 0, 1, 1, 1], [0, 1, 1, 1, 0], [0, 0, 0, 1, 1], [0, 0, 0, 0, 1]]) == 1\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 1]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 0], [1, 0, 0, 1, 0], [1, 1, 0, 1, 1], [0, 0, 0, 0, 1]]) == 1\n assert candidate(grid = [[0, 1, 1, 1, 0], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [0, 1, 1, 1, 0]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0], [0, 0, 1, 0, 1, 0], [0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 0, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 0, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0]]) == 0\n assert candidate(grid = [[1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 1, 1, 1, 0, 1, 1, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 1, 1, 0, 1, 1, 1, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 1, 0, 1, 1], [0, 1, 1, 1, 0], [1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 0, 0, 1, 1], [1, 1, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0], [1, 0, 1, 0, 0], [1, 0, 1, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 0, 1, 1], [1, 0, 0, 0, 1], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [1, 0, 0, 0, 1], [1, 1, 0, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 0, 0, 1, 1], [1, 1, 0, 0, 1], [0, 1, 1, 0, 0], [0, 0, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 0], [1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 0, 1, 0, 1], [0, 0, 1, 1, 0, 1, 0], [0, 0, 0, 0, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0, 1], [1, 0, 0, 1, 1, 0, 1], [0, 0, 1, 1, 1, 1, 0], [1, 0, 0, 1, 1, 0, 1], [1, 1, 0, 0, 0, 0, 1], [1, 1, 1, 0, 0, 1, 1]]) == 0\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().minDays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minDays(vector>& grid) {", "container": "Solution", "callable": "minDays", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1569, "task_id": "number-of-ways-to-reorder-array-to-get-same-bst", "difficulty": "Hard", "problem_description": "Given an array nums that represents a permutation of integers from 1 to n. We are going to construct a binary search tree (BST) by inserting the elements of nums in order into an initially empty BST. Find the number of different ways to reorder nums so that the constructed BST is identical to that formed from the original array nums.\n\nFor example, given nums = [2,1,3], we will have 2 as the root, 1 as a left child, and 3 as a right child. The array [2,3,1] also yields the same BST but [3,2,1] yields a different BST.\n\nReturn the number of ways to reorder nums such that the BST formed is identical to the original BST formed from nums.\nSince the answer may be very large, return it modulo 109 + 7.\n \nExample 1:\n\n\nInput: nums = [2,1,3]\nOutput: 1\nExplanation: We can reorder nums to be [2,3,1] which will yield the same BST. There are no other ways to reorder nums which will yield the same BST.\n\nExample 2:\n\n\nInput: nums = [3,4,5,1,2]\nOutput: 5\nExplanation: The following 5 arrays will yield the same BST: \n[3,1,2,4,5]\n[3,1,4,2,5]\n[3,1,4,5,2]\n[3,4,1,2,5]\n[3,4,1,5,2]\n\nExample 3:\n\n\nInput: nums = [1,2,3]\nOutput: 0\nExplanation: There are no other orderings of nums that will yield the same BST.\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n1 <= nums[i] <= nums.length\nAll integers in nums are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 5, 15, 3, 7, 13, 18, 1, 4, 6, 8, 12, 14, 17, 19]) == 21964799\n assert candidate(nums = [1, 3, 2]) == 0\n assert candidate(nums = [10, 5, 15, 3, 7, 12, 18, 1, 4, 6, 8, 11, 13, 17, 19]) == 21964799\n assert candidate(nums = [8, 5, 12, 3, 7, 10, 15, 1, 4, 6, 9, 11, 13, 14, 16, 17, 18, 19, 20]) == 572970385\n assert candidate(nums = [9, 4, 10, 2, 5, 8, 11, 1, 3, 6, 7]) == 3149\n assert candidate(nums = [6, 2, 9, 1, 3, 8, 10, 4, 5, 7]) == 1511\n assert candidate(nums = [1, 2, 3]) == 0\n assert candidate(nums = [2, 1, 3]) == 1\n assert candidate(nums = [8, 4, 12, 2, 6, 10, 14, 1, 3, 5, 7, 9, 11, 13, 15, 16]) == 108107999\n assert candidate(nums = [8, 5, 10, 3, 6, 9, 11, 1, 4, 7]) == 3359\n assert candidate(nums = [5, 3, 6, 2, 4, 1]) == 14\n assert candidate(nums = [3, 4, 5, 1, 2]) == 5\n assert candidate(nums = [4, 2, 5, 1, 3]) == 7\n assert candidate(nums = [5, 2, 6, 1, 3, 4]) == 14\n assert candidate(nums = [20, 10, 30, 5, 15, 25, 35, 3, 7, 12, 17, 22, 27, 32, 37, 2, 4, 6, 8, 11, 13, 16, 18, 21, 23, 26, 28, 31, 33, 36, 38, 1, 9, 14, 19, 24, 29, 34, 39]) == 447293125\n assert candidate(nums = [100, 50, 150, 25, 75, 125, 175, 12, 37, 62, 87, 112, 137, 162, 187, 6, 18, 28, 43, 53, 61, 68, 72, 82, 91, 3, 9, 14, 21, 26, 31, 36, 41, 46, 51, 56, 65, 70, 77, 84, 89, 94, 99]) == 7608543\n assert candidate(nums = [50, 25, 75, 12, 37, 62, 87, 6, 18, 29, 43, 56, 68, 81, 93, 3, 8, 14, 16, 23, 27, 33, 35, 41, 44, 48, 51, 55, 58, 60, 65, 67, 70, 73, 76, 78, 80, 83, 85, 88, 90, 91, 92, 95, 96, 97, 98, 99, 100]) == 346227338\n assert candidate(nums = [25, 15, 30, 10, 20, 28, 35, 5, 12, 18, 26, 32, 38, 2, 7, 11, 14, 17, 19, 22, 25, 29, 31, 34, 37, 39, 40, 41]) == 677042095\n assert candidate(nums = [64, 32, 96, 16, 48, 80, 112, 8, 24, 40, 56, 72, 88, 104, 120, 4, 12, 20, 28, 36, 44, 52, 60, 68, 76, 84, 92, 100, 108, 116, 124, 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98, 102, 106, 110, 114, 118, 122, 126, 130, 134, 138, 142, 146, 150]) == 320734915\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 0\n assert candidate(nums = [300, 150, 450, 75, 225, 375, 525, 38, 113, 188, 250, 325, 400, 475, 550, 19, 58, 87, 138, 175, 208, 238, 288, 306, 344, 363, 413, 442, 463, 488, 508, 538, 563, 588, 608, 2, 9, 20, 36, 51, 67, 79, 94, 107, 120, 133, 148, 163, 178, 193, 209, 224, 240, 256, 271, 287, 302, 318, 333, 349, 364, 380, 396, 412, 428, 443, 459, 474, 490, 505, 521, 536, 552, 568, 583, 599, 614, 629, 644, 659, 674, 689, 704, 719, 734, 749, 764, 779, 794, 809, 824, 839, 854, 869, 884, 899, 914, 929, 944, 959, 974, 989, 1004]) == 118530866\n assert candidate(nums = [50, 25, 75, 12, 37, 63, 87, 6, 18, 28, 43, 55, 61, 70, 80, 90, 1, 9, 15, 20, 29, 34, 38, 42, 48, 53, 58, 62, 68, 72, 78, 82, 85, 88, 95]) == 446421114\n assert candidate(nums = [50, 25, 75, 12, 37, 62, 87, 6, 18, 28, 43, 53, 61, 68, 72, 82, 91, 3, 9, 14, 21, 27, 31, 41, 46, 50, 57, 65, 70, 78, 85, 88, 94, 1, 5, 8, 11, 15, 19, 23, 26, 30, 35, 40, 45, 49, 52, 55, 58, 63, 66, 71, 74, 77, 80, 83, 86, 90, 93, 97, 99]) == 571657448\n assert candidate(nums = [5, 3, 8, 1, 4, 7, 9, 2, 6, 10, 11, 12, 13, 14, 15]) == 108107\n assert candidate(nums = [20, 10, 30, 5, 15, 25, 35, 3, 7, 12, 18, 23, 27, 33, 37, 2, 4, 6, 8, 11, 13, 16, 19, 22, 24, 26, 28, 31, 32, 34, 36, 38, 39, 40]) == 479196662\n assert candidate(nums = [50, 25, 75, 12, 37, 63, 88, 6, 18, 30, 45, 55, 60, 70, 85, 90, 3, 9, 15, 21, 27, 33, 40, 48, 52, 58, 62, 68, 73, 77, 83, 87, 92, 95, 98]) == 668093717\n assert candidate(nums = [50, 25, 75, 12, 37, 63, 87, 6, 18, 30, 45, 55, 61, 65, 72, 81, 93, 3, 9, 15, 20, 27, 32, 40, 47, 52, 57, 60, 62, 64, 67, 70, 74, 78, 84, 86, 89, 90, 91, 92, 95, 96, 97, 98, 99]) == 194452240\n assert candidate(nums = [6, 4, 8, 2, 5, 7, 9, 1, 3, 10, 11]) == 8063\n assert candidate(nums = [10, 5, 15, 3, 7, 12, 18, 1, 4, 6, 8, 11, 13, 14, 16, 17, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 372948988\n assert candidate(nums = [6, 3, 9, 1, 4, 7, 10, 2, 5, 8]) == 2267\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [20, 10, 30, 5, 15, 25, 35, 1, 7, 12, 18, 22, 28, 33, 40, 2, 4, 6, 8, 9, 11, 13, 16, 17, 19, 21, 23, 24, 26, 27, 29, 31, 32, 34, 36, 37, 38, 39]) == 823462672\n assert candidate(nums = [15, 10, 20, 5, 12, 17, 25, 3, 7, 11, 14, 16, 18, 23, 28]) == 21964799\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 0\n assert candidate(nums = [256, 128, 384, 64, 192, 288, 448, 32, 96, 160, 224, 320, 352, 416, 480, 16, 48, 80, 112, 144, 176, 208, 240, 272, 304, 336, 368, 400, 432, 464, 496, 8, 24, 40, 56, 72, 88, 104, 120, 136, 152, 168, 184, 200, 216, 232, 248, 264, 280, 296, 312, 328, 344, 360, 376, 392, 408, 424, 440, 456, 472, 488, 512]) == 968800645\n assert candidate(nums = [5, 2, 7, 1, 3, 6, 8, 4]) == 209\n assert candidate(nums = [7, 2, 11, 1, 4, 8, 12, 3, 5, 6, 9, 10]) == 27719\n assert candidate(nums = [100, 50, 150, 25, 75, 125, 175, 12, 37, 63, 87, 112, 137, 163, 187, 6, 18, 28, 43, 55, 61, 70, 80, 90, 102, 117, 132, 142, 153, 168, 178, 182, 188, 195]) == 84315017\n assert candidate(nums = [15, 7, 20, 3, 11, 17, 25, 1, 5, 9, 13, 16, 19, 23, 27, 2, 4, 6, 8, 10, 12, 14, 18, 21, 22, 24, 26, 28, 29]) == 993050933\n assert candidate(nums = [50, 25, 75, 12, 37, 62, 88, 6, 18, 28, 43, 55, 60, 70, 80, 90, 3, 9, 15, 20, 24, 26, 32, 36, 39, 42, 45, 48, 53, 58, 61, 65, 68, 72, 74, 77, 82, 85, 87, 89, 92, 94, 96, 98, 100]) == 587907399\n assert candidate(nums = [25, 10, 30, 5, 15, 20, 35, 2, 7, 13, 18, 22, 28, 33, 38, 1, 4, 6, 8, 11, 14, 17, 19, 21, 23, 27, 31, 32, 34, 36, 37, 39, 40]) == 138112265\n assert candidate(nums = [60, 30, 90, 15, 45, 75, 105, 10, 20, 40, 50, 70, 80, 95, 100, 110, 5, 8, 12, 17, 25, 35, 42, 48, 55, 65, 72, 78, 85, 93, 98, 102, 108, 115, 120, 125, 130, 135, 140, 145, 150]) == 303275395\n assert candidate(nums = [30, 15, 45, 7, 22, 37, 52, 3, 11, 18, 26, 32, 40, 48, 55, 1, 2, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 19, 20, 21, 23, 24, 25, 27, 28, 29, 31, 33, 34, 35, 36, 38, 39, 41, 42, 43, 44, 46, 47, 49, 50, 51, 53, 54, 56, 57, 58, 59, 60]) == 443856139\n assert candidate(nums = [600, 300, 900, 150, 450, 750, 1050, 75, 225, 375, 525, 675, 825, 975, 1125, 1275, 38, 113, 188, 263, 338, 413, 488, 563, 638, 713, 788, 863, 938, 1013, 1088, 1163, 1238, 1313, 1388, 1463, 1538, 1613, 1688, 1763, 1838, 1913, 1988, 24, 69, 114, 159, 204, 249, 294, 339, 384, 429, 474, 519, 564, 609, 654, 699, 744, 789, 834, 879, 924, 969, 1014, 1059, 1104, 1149, 1194, 1239, 1284, 1329, 1374, 1419, 1464, 1509, 1554, 1599, 1644, 1689, 1734, 1779, 1824, 1869, 1914, 1959, 1994, 12, 36, 60, 84, 108, 132, 156, 180, 204, 228, 252, 276, 300, 324, 348, 372, 396, 420, 444, 468, 492, 516, 540, 564, 588, 612, 636, 660, 684, 708, 732, 756, 780, 804, 828, 852, 876, 900, 924, 948, 972, 996, 1020, 1044, 1068, 1092, 1116, 1140, 1164, 1188, 1212, 1236, 1260, 1284, 1308, 1332, 1356, 1380, 1404, 1428, 1452, 1476, 1500, 1524, 1548, 1572, 1596, 1620, 1644, 1668, 1692, 1716, 1740, 1764, 1788, 1812, 1836, 1860, 1884, 1908, 1932, 1956, 1980]) == 244403225\n assert candidate(nums = [7, 3, 11, 1, 5, 9, 13, 2, 4, 6, 8, 10, 12, 14, 15]) == 12612599\n assert candidate(nums = [20, 10, 30, 5, 15, 25, 35, 3, 7, 13, 17, 23, 27, 33, 37, 2, 4, 6, 8, 12, 14, 16, 18, 22, 24, 26, 28, 32, 34, 36, 38]) == 203434153\n assert candidate(nums = [15, 7, 24, 3, 11, 19, 28, 1, 5, 9, 13, 16, 22, 26, 31, 2, 4, 6, 8, 10, 12, 14, 17, 18, 20, 21, 23, 25, 27, 29, 30, 32, 33, 34, 35, 36, 37]) == 765197211\n assert candidate(nums = [15, 8, 21, 3, 12, 18, 25, 1, 5, 10, 13, 16, 20, 22, 24, 26, 27, 28, 29, 30]) == 935107010\n assert candidate(nums = [100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 80, 110, 140, 160, 180]) == 21964799\n assert candidate(nums = [15, 8, 23, 4, 12, 19, 27, 2, 6, 10, 14, 17, 21, 25, 29, 1, 3, 5, 7, 9, 11, 13, 16, 18, 20, 22, 24, 26, 28, 30]) == 637714638\n assert candidate(nums = [20, 10, 30, 5, 15, 25, 35, 2, 7, 12, 18, 23, 27, 32, 37, 1, 4, 6, 8, 11, 13, 14, 16, 17, 19, 21, 22, 24, 26, 28, 29, 31, 33, 34, 36, 38, 39, 40]) == 327188662\n assert candidate(nums = [5, 3, 7, 2, 4, 6, 8, 1, 9, 10]) == 1511\n assert candidate(nums = [100, 50, 150, 25, 75, 125, 175, 12, 37, 62, 88, 112, 138, 162, 188, 6, 18, 31, 43, 56, 71, 83, 94, 106, 118, 129, 139, 150, 161, 172, 183, 194, 3, 9, 14, 20, 26, 33, 40, 47, 53, 60, 67, 74, 81, 87, 93, 99, 105, 111, 117, 123, 130, 136, 142, 148, 154, 160, 166, 173, 179, 185, 191, 197, 2, 5, 7, 11, 13, 16, 19, 22, 24, 27, 29, 32, 35, 38, 41, 44, 46, 49, 52, 55, 58, 61, 64, 66, 69, 72, 75, 78, 80, 84, 86, 89, 91, 95, 97, 101, 103, 107, 109, 113, 115, 119, 121, 124, 127, 131, 133, 137, 140, 144, 146, 149, 151, 155, 157, 163, 165, 168, 170, 174, 176, 178, 181, 184, 186, 189, 192, 196, 198, 199]) == 963420092\n assert candidate(nums = [10, 5, 15, 3, 7, 13, 18, 2, 4, 6, 8, 12, 14, 16, 17, 19, 20]) == 615014399\n assert candidate(nums = [70, 35, 105, 17, 53, 59, 88, 126, 9, 26, 44, 50, 56, 81, 93, 112, 120, 130, 140, 150, 5, 13, 20, 29, 39, 42, 48, 51, 58, 76, 80, 85, 89, 91, 97, 100, 102, 107, 109, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 139, 141, 143, 145, 147, 149, 151]) == 583396661\n assert candidate(nums = [500, 250, 750, 125, 375, 625, 875, 63, 188, 292, 463, 532, 594, 656, 725, 788, 844, 913, 969, 1025, 1082, 1138, 1194, 1250, 1306, 1362, 1418, 1475, 1531, 1587, 1643, 1699, 1755, 1812, 1868, 1924, 1980, 31, 94, 148, 224, 299, 355, 400, 446, 482, 520, 556, 591, 626, 662, 697, 733, 769, 804, 840, 876, 911, 947, 982, 1018, 1054, 1089, 1125, 1161, 1196, 1232, 1268, 1303, 1339, 1375, 1410, 1446, 1482, 1517, 1553, 1589, 1624, 1660, 1695, 1731, 1767, 1802, 1838, 1874, 1909, 1945, 1981, 7, 26, 45, 64, 83, 102, 121, 140, 159, 178, 197, 216, 235, 254, 273, 292, 311, 330, 349, 368, 387, 406, 425, 444, 463, 482, 501, 520, 539, 558, 577, 596, 615, 634, 653, 672, 691, 710, 729, 748, 767, 786, 805, 824, 843, 862, 881, 900, 919, 938, 957, 976, 995]) == 126685497\n assert candidate(nums = [7, 4, 12, 2, 5, 9, 15, 1, 3, 6, 8, 11, 13, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 240043756\n assert candidate(nums = [15, 9, 20, 7, 11, 18, 22, 5, 8, 10, 12, 16, 19, 21, 23, 3, 6, 13, 14, 17, 24]) == 290541228\n assert candidate(nums = [100, 50, 150, 25, 75, 125, 175, 12, 37, 62, 87, 112, 137, 162, 187, 6, 18, 27, 46, 57, 72, 81, 96, 107, 117, 127, 132, 147, 157, 167, 172, 182, 197, 1, 11, 15, 21, 33, 41, 51, 59, 61, 71, 77, 83, 89, 91, 97, 101, 109, 111, 118, 121, 129, 131, 138, 141, 149, 151, 159, 161, 168, 171, 179, 181, 188, 191, 199]) == 248577023\n assert candidate(nums = [15, 10, 20, 8, 12, 17, 22, 5, 9, 11, 13, 16, 19, 21, 23, 3, 7, 4, 6, 14, 18, 24, 25]) == 252477357\n assert candidate(nums = [20, 10, 30, 5, 15, 25, 35, 2, 7, 13, 18, 23, 27, 32, 33, 1, 3, 6, 8, 12, 14, 16, 17, 19, 21, 22, 24, 26, 28, 29, 31, 34, 36]) == 852994108\n assert candidate(nums = [12, 7, 15, 4, 8, 13, 16, 2, 5, 9, 14, 3, 6, 10, 11]) == 2270267\n assert candidate(nums = [1, 4, 2, 7, 3, 5, 8, 6, 9, 10, 11, 12, 13, 14, 15]) == 3509\n assert candidate(nums = [7, 3, 11, 1, 5, 9, 13, 2, 4, 6, 8, 10, 12, 14, 15]) == 12612599\n assert candidate(nums = [800, 400, 1200, 200, 600, 1000, 1400, 100, 300, 500, 700, 900, 1100, 1300, 1500, 50, 150, 250, 350, 450, 550, 650, 750, 850, 950, 1050, 1150, 1250, 1350, 1450, 1550, 25, 75, 125, 175, 225, 275, 325, 375, 425, 475, 525, 575, 625, 675, 725, 775, 825, 875, 925, 975, 1025, 1075, 1125, 1175, 1225, 1275, 1325, 1375, 1425, 1475, 1525, 1575]) == 665258151\n assert candidate(nums = [80, 40, 120, 20, 60, 100, 140, 10, 30, 50, 70, 90, 110, 130, 150, 5, 9, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155]) == 348178224\n assert candidate(nums = [13, 7, 18, 3, 10, 15, 20, 1, 5, 8, 11, 14, 16, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 321724227\n assert candidate(nums = [25, 12, 30, 8, 18, 27, 32, 5, 10, 15, 22, 26, 31, 33, 3, 7, 9, 11, 13, 14, 16, 17, 19, 20, 21, 23, 24, 28, 29]) == 106594954\n assert candidate(nums = [1000, 500, 1500, 250, 750, 1250, 1750, 125, 375, 625, 875, 1125, 1375, 1625, 1875, 63, 188, 288, 313, 438, 563, 713, 813, 938, 1063, 1213, 1313, 1438, 1563, 1713, 1813, 1938, 2063, 2213, 2313, 2438, 2563, 2713, 2813, 2938, 3063, 3213, 3313, 3438, 3563, 3713, 3813, 3938, 4063, 4213, 4313, 4438, 4563, 4713, 4813, 4938, 5063, 5213, 5313, 5438, 5563, 5713, 5813, 5938, 6063, 6213, 6313, 6438, 6563, 6713, 6813, 6938, 7063, 7213, 7313, 7438, 7563, 7713, 7813, 7938, 8063, 8213, 8313, 8438, 8563, 8713, 8813, 8938, 9063, 9213, 9313, 9438, 9563, 9713, 9813, 9938, 10063, 10213, 10313, 10438, 10563, 10713, 10813, 10938, 11063, 11213, 11313, 11438, 11563, 11713, 11813, 11938, 12063, 12213, 12313, 12438, 12563, 12713, 12813, 12938, 13063, 13213, 13313, 13438, 13563, 13713, 13813, 13938, 14063, 14213, 14313, 14438, 14563, 14713, 14813, 14938, 15063, 15213, 15313, 15438, 15563, 15713, 15813, 15938, 16063, 16213, 16313, 16438, 16563, 16713, 16813, 16938, 17063, 17213, 17313, 17438, 17563, 17713, 17813, 17938, 18063, 18213, 18313, 18438, 18563, 18713, 18813, 18938, 19063, 19213, 19313, 19438, 19563, 19713, 19813, 19938]) == 998164136\n assert candidate(nums = [20, 10, 30, 5, 15, 25, 35, 2, 7, 12, 18, 23, 28, 33, 40]) == 21964799\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [25, 15, 35, 10, 20, 30, 40, 5, 12, 18, 23, 28, 33, 38, 43]) == 21964799\n assert candidate(nums = [25, 15, 35, 10, 20, 30, 40, 5, 12, 18, 22, 28, 32, 38, 45, 3, 7, 11, 14, 16, 19, 21, 24, 26, 29, 31, 33, 36, 37, 39, 41, 42, 43, 44, 46, 47, 48, 49, 50]) == 625852341\n assert candidate(nums = [50, 25, 75, 12, 37, 63, 87, 6, 18, 30, 42, 56, 70, 81, 93]) == 21964799\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().numOfWays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numOfWays(vector& nums) {", "container": "Solution", "callable": "numOfWays", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1572, "task_id": "matrix-diagonal-sum", "difficulty": "Easy", "problem_description": "Given a square matrix mat, return the sum of the matrix diagonals.\nOnly include the sum of all the elements on the primary diagonal and all the elements on the secondary diagonal that are not part of the primary diagonal.\n \nExample 1:\n\n\nInput: mat = [[1,2,3],\n  [4,5,6],\n  [7,8,9]]\nOutput: 25\nExplanation: Diagonals sum: 1 + 5 + 9 + 3 + 7 = 25\nNotice that element mat[1][1] = 5 is counted only once.\n\nExample 2:\n\nInput: mat = [[1,1,1,1],\n  [1,1,1,1],\n  [1,1,1,1],\n  [1,1,1,1]]\nOutput: 8\n\nExample 3:\n\nInput: mat = [[5]]\nOutput: 5\n\n \nConstraints:\n\nn == mat.length == mat[i].length\n1 <= n <= 100\n1 <= mat[i][j] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[7, 3, 1, 9], [3, 4, 6, 9], [6, 9, 6, 6], [9, 5, 8, 5]]) == 55\n assert candidate(mat = [[5]]) == 5\n assert candidate(mat = [[10, 1, 1], [1, 0, 1], [1, 1, 10]]) == 22\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 25\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 8\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]]) == 520\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 117\n assert candidate(mat = [[5, 3, 1, 4, 2], [8, 6, 9, 7, 5], [3, 2, 8, 6, 4], [1, 4, 5, 2, 3], [7, 5, 4, 8, 6]]) == 47\n assert candidate(mat = [[100, 100, 100], [100, 99, 100], [100, 100, 100]]) == 499\n assert candidate(mat = [[50, 2, 3, 4, 5, 6, 7], [8, 50, 10, 11, 12, 13, 14], [15, 16, 50, 18, 19, 20, 21], [22, 23, 24, 50, 26, 27, 28], [29, 30, 31, 32, 50, 34, 35], [36, 37, 38, 39, 40, 50, 42], [43, 44, 45, 46, 47, 48, 50]]) == 500\n assert candidate(mat = [[5, 2, 3, 4, 5, 6, 7], [8, 5, 2, 3, 4, 5, 6], [7, 8, 5, 2, 3, 4, 5], [6, 7, 8, 5, 2, 3, 4], [5, 6, 7, 8, 5, 2, 3], [4, 5, 6, 7, 8, 5, 2], [3, 4, 5, 6, 7, 8, 5]]) == 65\n assert candidate(mat = [[10, 20, 30, 40, 50, 60], [1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30]]) == 225\n assert candidate(mat = [[2, 3, 4, 5, 6], [1, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 119\n assert candidate(mat = [[9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [9, 8, 7, 6, 5]]) == 43\n assert candidate(mat = [[100, 200, 300, 400, 500, 600], [700, 800, 900, 1000, 1100, 1200], [1300, 1400, 1500, 1600, 1700, 1800], [1900, 2000, 2100, 2200, 2300, 2400], [2500, 2600, 2700, 2800, 2900, 3000], [3100, 3200, 3300, 3400, 3500, 3600]]) == 22200\n assert candidate(mat = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120], [130, 140, 150, 160]]) == 680\n assert candidate(mat = [[1, 2], [3, 4]]) == 10\n assert candidate(mat = [[10, 20, 30, 40, 50], [60, 70, 80, 90, 100], [110, 120, 130, 140, 150], [160, 170, 180, 190, 200], [210, 220, 230, 240, 250]]) == 1170\n assert candidate(mat = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90], [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]]) == 1010\n assert candidate(mat = [[100, 99, 98, 97, 96, 95, 94, 93, 92], [91, 90, 89, 88, 87, 86, 85, 84, 83], [82, 81, 80, 79, 78, 77, 76, 75, 74], [73, 72, 71, 70, 69, 68, 67, 66, 65], [64, 63, 62, 61, 60, 59, 58, 57, 56], [55, 54, 53, 52, 51, 50, 49, 48, 47], [46, 45, 44, 43, 42, 41, 40, 39, 38], [37, 36, 35, 34, 33, 32, 31, 30, 29], [28, 27, 26, 25, 24, 23, 22, 21, 20]]) == 1020\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]]) == 222\n assert candidate(mat = [[100, 99, 98, 97, 96, 95, 94], [93, 92, 91, 90, 89, 88, 87], [86, 85, 84, 83, 82, 81, 80], [79, 78, 77, 76, 75, 74, 73], [72, 71, 70, 69, 68, 67, 66], [65, 64, 63, 62, 61, 60, 59], [58, 57, 56, 55, 54, 53, 52]]) == 988\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3], [4, 5, 6, 7, 8, 9, 10, 11], [11, 12, 13, 14, 15, 16, 17, 18]]) == 110\n assert candidate(mat = [[9, 8, 7, 6, 5, 4], [3, 2, 1, 0, -1, -2], [-3, -4, -5, -6, -7, -8], [-9, -10, -11, -12, -13, -14], [-15, -16, -17, -18, -19, -20], [-21, -22, -23, -24, -25, -26]]) == -102\n assert candidate(mat = [[9, 8, 7], [6, 5, 4], [3, 2, 1]]) == 25\n assert candidate(mat = [[5, 2, 1, 4, 3], [9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [3, 2, 1, 0, 3], [1, 0, 3, 2, 1]]) == 28\n assert candidate(mat = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 0], [3, 4, 5, 6, 7, 8, 9, 0, 1], [4, 5, 6, 7, 8, 9, 0, 1, 2], [5, 6, 7, 8, 9, 0, 1, 2, 3], [6, 7, 8, 9, 0, 1, 2, 3, 4], [7, 8, 9, 0, 1, 2, 3, 4, 5], [8, 9, 0, 1, 2, 3, 4, 5, 6], [9, 0, 1, 2, 3, 4, 5, 6, 7]]) == 113\n assert candidate(mat = [[9, 2, 3, 4, 5, 6, 7, 8, 9], [2, 8, 3, 4, 5, 6, 7, 8, 9], [3, 4, 8, 4, 5, 6, 7, 8, 9], [4, 5, 6, 8, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 6, 7, 8, 9], [6, 7, 8, 9, 6, 8, 7, 8, 9], [7, 8, 9, 6, 7, 8, 8, 8, 9], [8, 9, 6, 7, 8, 9, 6, 8, 9], [9, 6, 7, 8, 9, 6, 7, 8, 8]]) == 140\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22], [23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33], [34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44], [45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55], [56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66], [67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77], [78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88], [89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110], [111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121]]) == 1281\n assert candidate(mat = [[50, 20, 10, 5, 1], [40, 30, 15, 25, 3], [35, 28, 20, 30, 4], [29, 22, 18, 26, 5], [23, 16, 12, 21, 6]]) == 203\n assert candidate(mat = [[2, 0, 0, 0, 2], [0, 3, 0, 3, 0], [0, 0, 4, 0, 0], [0, 5, 0, 5, 0], [6, 0, 0, 0, 6]]) == 36\n assert candidate(mat = [[50, 51, 52, 53, 54, 55, 56, 57], [58, 59, 60, 61, 62, 63, 64, 65], [66, 67, 68, 69, 70, 71, 72, 73], [74, 75, 76, 77, 78, 79, 80, 81], [82, 83, 84, 85, 86, 87, 88, 89], [90, 91, 92, 93, 94, 95, 96, 97], [98, 99, 100, 101, 102, 103, 104, 105], [106, 107, 108, 109, 110, 111, 112, 113]]) == 1304\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90], [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]]) == 1010\n assert candidate(mat = [[2, 5, 4, 1, 6], [9, 7, 3, 8, 5], [6, 2, 9, 1, 3], [1, 6, 5, 9, 2], [7, 8, 4, 6, 9]]) == 63\n assert candidate(mat = [[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]]) == 9\n assert candidate(mat = [[1, 0, 0, 0, 0, 1], [0, 1, 0, 0, 1, 0], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [0, 1, 0, 0, 1, 0], [1, 0, 0, 0, 0, 1]]) == 12\n assert candidate(mat = [[10, 11, 12, 13, 14, 15], [16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27], [28, 29, 30, 31, 32, 33], [34, 35, 36, 37, 38, 39], [40, 41, 42, 43, 44, 45]]) == 330\n assert candidate(mat = [[2, 3, 4, 5, 6], [7, 8, 9, 10, 11], [12, 13, 14, 15, 16], [17, 18, 19, 20, 21], [22, 23, 24, 25, 26]]) == 126\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]]) == 222\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 13\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2], [8, 9, 10, 11, 12, 13], [13, 14, 15, 16, 17, 18]]) == 84\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 7, 5, 3, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6, 6, 6, 6]]) == 70\n assert candidate(mat = [[10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24], [25, 26, 27, 28, 29], [30, 31, 32, 33, 34]]) == 198\n assert candidate(mat = [[10, 15, 20, 25, 30], [5, 9, 12, 18, 22], [7, 11, 14, 17, 21], [4, 8, 13, 16, 23], [1, 2, 3, 6, 24]]) == 130\n assert candidate(mat = [[2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13], [14, 15, 16, 17, 18, 19], [20, 21, 22, 23, 24, 25], [26, 27, 28, 29, 30, 31], [32, 33, 34, 35, 36, 37]]) == 234\n assert candidate(mat = [[50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63], [64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77], [78, 79, 80, 81, 82, 83, 84], [85, 86, 87, 88, 89, 90, 91], [92, 93, 94, 95, 96, 97, 98]]) == 962\n assert candidate(mat = [[2, 4, 6, 8], [10, 12, 14, 16], [18, 20, 22, 24], [26, 28, 30, 32]]) == 136\n assert candidate(mat = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65], [30, 40, 50, 60, 70]]) == 360\n assert candidate(mat = [[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]]) == 9\n assert candidate(mat = [[9, 0, 9, 0, 9, 0, 9, 0, 9, 0], [0, 9, 0, 9, 0, 9, 0, 9, 0, 9], [9, 0, 9, 0, 9, 0, 9, 0, 9, 0], [0, 9, 0, 9, 0, 9, 0, 9, 0, 9], [9, 0, 9, 0, 9, 0, 9, 0, 9, 0], [0, 9, 0, 9, 0, 9, 0, 9, 0, 9], [9, 0, 9, 0, 9, 0, 9, 0, 9, 0], [0, 9, 0, 9, 0, 9, 0, 9, 0, 9], [9, 0, 9, 0, 9, 0, 9, 0, 9, 0], [0, 9, 0, 9, 0, 9, 0, 9, 0, 9]]) == 90\n assert candidate(mat = [[1, 0, 0, 0, 0], [0, 2, 0, 0, 0], [0, 0, 3, 0, 0], [0, 0, 0, 4, 0], [0, 0, 0, 0, 5]]) == 15\n assert candidate(mat = [[2, 3, 4, 5, 6], [7, 8, 9, 10, 11], [12, 13, 14, 15, 16], [17, 18, 19, 20, 21], [22, 23, 24, 25, 26]]) == 126\n assert candidate(mat = [[50, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 50, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 50, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 50, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 50, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 50, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 50, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 50, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 50, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 50]]) == 510\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48, 49]]) == 325\n"}, "metadata": {"canonical_parameter_names": ["mat"], "leetcode_dataset_entry_point": "Solution().diagonalSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int diagonalSum(vector>& mat) {", "container": "Solution", "callable": "diagonalSum", "parameters": [{"name": "mat", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1573, "task_id": "number-of-ways-to-split-a-string", "difficulty": "Medium", "problem_description": "Given a binary string s, you can split s into 3 non-empty strings s1, s2, and s3 where s1 + s2 + s3 = s.\nReturn the number of ways s can be split such that the number of ones is the same in s1, s2, and s3. Since the answer may be too large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: s = \"10101\"\nOutput: 4\nExplanation: There are four ways to split s in 3 parts where each part contain the same number of letters '1'.\n\"1|010|1\"\n\"1|01|01\"\n\"10|10|1\"\n\"10|1|01\"\n\nExample 2:\n\nInput: s = \"1001\"\nOutput: 0\n\nExample 3:\n\nInput: s = \"0000\"\nOutput: 3\nExplanation: There are three ways to split s in 3 parts.\n\"0|0|00\"\n\"0|00|0\"\n\"00|0|0\"\n\n \nConstraints:\n\n3 <= s.length <= 105\ns[i] is either '0' or '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"101010101\") == 0\n assert candidate(s = \"10101010101\") == 4\n assert candidate(s = \"0000\") == 3\n assert candidate(s = \"0000000\") == 15\n assert candidate(s = \"010101010\") == 0\n assert candidate(s = \"111000\") == 1\n assert candidate(s = \"11111111111\") == 0\n assert candidate(s = \"111111\") == 1\n assert candidate(s = \"10101\") == 4\n assert candidate(s = \"001001001\") == 9\n assert candidate(s = \"1111111\") == 0\n assert candidate(s = \"1001001001\") == 0\n assert candidate(s = \"111000111000111\") == 16\n assert candidate(s = \"01010101010\") == 0\n assert candidate(s = \"1010101010\") == 0\n assert candidate(s = \"0000000000\") == 36\n assert candidate(s = \"1100110011\") == 9\n assert candidate(s = \"00000000000\") == 45\n assert candidate(s = \"1000000000001\") == 0\n assert candidate(s = \"0101010101\") == 0\n assert candidate(s = \"10100101010101\") == 0\n assert candidate(s = \"11011011011\") == 0\n assert candidate(s = \"111000111\") == 1\n assert candidate(s = \"100010001\") == 16\n assert candidate(s = \"1001\") == 0\n assert candidate(s = \"01010101010101010101010101010101\") == 0\n assert candidate(s = \"00000000000000000000000000000000000000000000000000\") == 1176\n assert candidate(s = \"1001001001001001001001\") == 0\n assert candidate(s = \"111000111000111000111000111\") == 1\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"0000001110000011100000111\") == 36\n assert candidate(s = \"1000000010000000100000001\") == 0\n assert candidate(s = \"1110111011101110111011101110111\") == 1\n assert candidate(s = \"111111111111111111111111111111111111111111111111\") == 1\n assert candidate(s = \"101010101010101010101010101010101010101010101010\") == 4\n assert candidate(s = \"1000100010001000100010001000100010001000100010001\") == 0\n assert candidate(s = \"001001001001001001001001001001001001001\") == 0\n assert candidate(s = \"1001001001001\") == 0\n assert candidate(s = \"00001000010000100001000010000100001000010000100001\") == 0\n assert candidate(s = \"111000111000111000111000111000111000111000111\") == 1\n assert candidate(s = \"111111111111111111111111111111111111111111111111111\") == 1\n assert candidate(s = \"1001001001001001001001001001001001001001001001001\") == 0\n assert candidate(s = \"0010101010100\") == 0\n assert candidate(s = \"1111000011110000111100001111\") == 0\n assert candidate(s = \"10101010101010101010101010\") == 0\n assert candidate(s = \"101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001\") == 9\n assert candidate(s = \"100000000000000000000000000000000000000000000000000000001\") == 0\n assert candidate(s = \"001001001001001001001001001001001001001001001001001001\") == 9\n assert candidate(s = \"1100110011001100110011\") == 9\n assert candidate(s = \"0000111100001111000011110000111100001111\") == 0\n assert candidate(s = \"0011001100110011001100110011\") == 0\n assert candidate(s = \"110011001100110011001100110011\") == 0\n assert candidate(s = \"10000000001000000001\") == 90\n assert candidate(s = \"110011001100110\") == 0\n assert candidate(s = \"100000100000100000100000100000100000\") == 36\n assert candidate(s = \"10101010101010101010101010101010101010101010101\") == 4\n assert candidate(s = \"0101010101010101010101010101\") == 0\n assert candidate(s = \"10001000100010001000100010001000100010001000100010001000\") == 0\n assert candidate(s = \"111110000011111000001111100000111110000011111\") == 0\n assert candidate(s = \"1100110011001100110011001100110011001100110011001100\") == 0\n assert candidate(s = \"000000000000000\") == 91\n assert candidate(s = \"101010101010101010101\") == 0\n assert candidate(s = \"00010001000100010001\") == 0\n assert candidate(s = \"100000000000100000000010000000001\") == 0\n assert candidate(s = \"1000000000000000000001\") == 0\n assert candidate(s = \"1001001001001001001001001001001001001001\") == 0\n assert candidate(s = \"101010101010101010101010101\") == 0\n assert candidate(s = \"000000000000000000000000000000000000000000000000000\") == 1225\n assert candidate(s = \"10100100100100100\") == 9\n assert candidate(s = \"0100100100100100100100100100100100100100100100100100\") == 0\n assert candidate(s = \"111111000000111111000000111111\") == 49\n assert candidate(s = \"00010001000100010001000100010001\") == 0\n assert candidate(s = \"0000000000000000000000\") == 210\n assert candidate(s = \"0000000000000000000000000\") == 276\n assert candidate(s = \"11011011011011011011011011011011\") == 0\n assert candidate(s = \"11111000001111100000111110000011111\") == 0\n assert candidate(s = \"111000111000111000111000\") == 1\n assert candidate(s = \"1000010000100001000010000100001\") == 0\n assert candidate(s = \"110011001100110011\") == 0\n assert candidate(s = \"101001010010100101001010010100101001010010100101001\") == 6\n assert candidate(s = \"0000000000000000000000000000\") == 351\n assert candidate(s = \"01001001001001\") == 0\n assert candidate(s = \"000000000000000000000000000000000000000000000\") == 946\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().numWays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numWays(string s) {", "container": "Solution", "callable": "numWays", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1574, "task_id": "shortest-subarray-to-be-removed-to-make-array-sorted", "difficulty": "Medium", "problem_description": "Given an integer array arr, remove a subarray (can be empty) from arr such that the remaining elements in arr are non-decreasing.\nReturn the length of the shortest subarray to remove.\nA subarray is a contiguous subsequence of the array.\n \nExample 1:\n\nInput: arr = [1,2,3,10,4,2,3,5]\nOutput: 3\nExplanation: The shortest subarray we can remove is [10,4,2] of length 3. The remaining elements after that will be [1,2,3,3,5] which are sorted.\nAnother correct solution is to remove the subarray [3,10,4].\n\nExample 2:\n\nInput: arr = [5,4,3,2,1]\nOutput: 4\nExplanation: Since the array is strictly decreasing, we can only keep a single element. Therefore we need to remove a subarray of length 4, either [5,4,3,2] or [4,3,2,1].\n\nExample 3:\n\nInput: arr = [1,2,3]\nOutput: 0\nExplanation: The array is already non-decreasing. We do not need to remove any elements.\n\n \nConstraints:\n\n1 <= arr.length <= 105\n0 <= arr[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [5, 4, 3, 2, 1]) == 4\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1]) == 9\n assert candidate(arr = [1, 2, 3]) == 0\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 5]) == 1\n assert candidate(arr = [1, 2, 2, 2, 3, 4, 5, 5, 5, 4, 3, 2, 1]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 1\n assert candidate(arr = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12]) == 6\n assert candidate(arr = [1]) == 0\n assert candidate(arr = [1, 3, 5, 4, 7]) == 1\n assert candidate(arr = [1, 1, 1, 1, 1]) == 0\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(arr = [1, 3, 5, 2, 4, 6, 7]) == 2\n assert candidate(arr = [1, 2, 2, 3, 4, 5]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 5, 6, 7, 8, 9]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 4, 5]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5]) == 0\n assert candidate(arr = [1, 2, 3, 10, 4, 2, 3, 5]) == 3\n assert candidate(arr = [1, 2, 2, 3, 1, 4, 5]) == 1\n assert candidate(arr = [1, 2, 3, 2, 1]) == 2\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(arr = [1, 3, 2, 4, 5]) == 1\n assert candidate(arr = [1, 3, 2, 4, 3, 5]) == 2\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3]) == 5\n assert candidate(arr = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 13\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10]) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10]) == 21\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(arr = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12, 14, 16, 15, 17, 19, 18, 20, 22, 21, 23, 25, 24, 26, 28, 27, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80]) == 21\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6]) == 6\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 14, 12, 10, 8, 6, 4, 2, 0, 1, 3, 5, 7, 9, 11, 13, 15]) == 15\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 21\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 13\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 14, 12, 10, 8, 6, 4, 2, 0]) == 8\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 8, 9, 10, 11, 12, 13, 14]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8]) == 23\n assert candidate(arr = [1, 2, 3, 10, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 29\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 15, 16, 17, 18, 19]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 7\n assert candidate(arr = [1, 2, 3, 10, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4]) == 27\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6]) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(arr = [1, 3, 5, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 9\n assert candidate(arr = [1, 2, 3, 10, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5, 12, 13, 14, 15, 16, 17]) == 13\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8]) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 18\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 7\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 5, 7, 9, 8, 10, 12, 11, 13, 15, 14, 16, 18, 17, 19, 21, 20, 22, 24, 23, 25]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 19\n assert candidate(arr = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 29\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 12\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 17\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9]) == 10\n assert candidate(arr = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 600]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 1\n assert candidate(arr = [1, 2, 3, 10, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2]) == 26\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 49\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7]) == 7\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 18\n assert candidate(arr = [40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 39\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 14\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(arr = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12, 20, 22, 21, 24, 23, 26, 25, 28, 27, 30, 29, 32, 31, 34, 33, 36, 35]) == 23\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 15\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 29\n assert candidate(arr = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12, 14, 15, 16, 17, 18, 19, 20]) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == 17\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 95, 105, 110, 115, 120, 125, 130, 135, 140, 145]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 16\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == 18\n assert candidate(arr = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 13\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 17\n assert candidate(arr = [10, 20, 30, 25, 26, 27, 15, 16, 17, 18, 19]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 10\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 29\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 8\n assert candidate(arr = [1, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8]) == 16\n assert candidate(arr = [1, 2, 3, 10, 11, 12, 4, 5, 6, 7, 8, 9, 13, 14, 15]) == 3\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 8\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 19\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 19\n assert candidate(arr = [1, 10, 20, 15, 25, 30, 5, 10, 15, 20]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 10, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3]) == 27\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 5, 10, 15]) == 11\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 10, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5, 12, 13, 14, 15, 16, 17, 18, 19]) == 15\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 10, 11, 12, 13, 14, 15]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 14\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 21\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 14\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7]) == 7\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9]) == 22\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 1, 3, 5, 7, 9, 11]) == 23\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19, 21, 22, 23, 24, 26, 27, 28, 29]) == 6\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 51\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(arr = [1, 2, 3, 10, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5]) == 13\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 10\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 14, 12, 10, 8, 6, 4, 2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 15\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(arr = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 15\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9]) == 5\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10]) == 17\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 18\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == 14\n assert candidate(arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 29\n assert candidate(arr = [60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 59\n assert candidate(arr = [5, 4, 3, 2, 1, 2, 3, 4, 5]) == 4\n assert candidate(arr = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12, 14, 16, 15, 17, 19, 18, 20, 22, 21, 23, 25, 24, 26, 28, 27, 29]) == 21\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 23\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 15\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 19\n assert candidate(arr = [1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1]) == 1\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2, 3, 4]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(arr = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12, 15, 17, 16, 18, 20, 19, 21, 23, 22, 24, 26, 25]) == 18\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 10\n assert candidate(arr = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12, 14, 16, 15, 17, 19, 18, 20, 22, 21, 23, 25, 24, 26, 28, 27, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 21\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]) == 0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3]) == 33\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 3, 5, 7, 9, 11]) == 6\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 35\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 2]) == 2\n assert candidate(arr = [1, 2, 3, 4, 5, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 2\n assert candidate(arr = [1, 3, 5, 4, 7, 9, 8, 11, 13, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 9\n assert candidate(arr = [1, 2, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().findLengthOfShortestSubarray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int findLengthOfShortestSubarray(vector& arr) {", "container": "Solution", "callable": "findLengthOfShortestSubarray", "parameters": [{"name": "arr", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1575, "task_id": "count-all-possible-routes", "difficulty": "Hard", "problem_description": "You are given an array of distinct positive integers locations where locations[i] represents the position of city i. You are also given integers start, finish and fuel representing the starting city, ending city, and the initial amount of fuel you have, respectively.\nAt each step, if you are at city i, you can pick any city j such that j != i and 0 <= j < locations.length and move to city j. Moving from city i to city j reduces the amount of fuel you have by |locations[i] - locations[j]|. Please notice that |x| denotes the absolute value of x.\nNotice that fuel cannot become negative at any point in time, and that you are allowed to visit any city more than once (including start and finish).\nReturn the count of all possible routes from start to finish. Since the answer may be too large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: locations = [2,3,6,8,4], start = 1, finish = 3, fuel = 5\nOutput: 4\nExplanation: The following are all possible routes, each uses 5 units of fuel:\n1 -> 3\n1 -> 2 -> 3\n1 -> 4 -> 3\n1 -> 4 -> 2 -> 3\n\nExample 2:\n\nInput: locations = [4,3,1], start = 1, finish = 0, fuel = 6\nOutput: 5\nExplanation: The following are all possible routes:\n1 -> 0, used fuel = 1\n1 -> 2 -> 0, used fuel = 5\n1 -> 2 -> 1 -> 0, used fuel = 5\n1 -> 0 -> 1 -> 0, used fuel = 3\n1 -> 0 -> 1 -> 0 -> 1 -> 0, used fuel = 5\n\nExample 3:\n\nInput: locations = [5,2,1], start = 0, finish = 2, fuel = 3\nOutput: 0\nExplanation: It is impossible to get from 0 to 2 using only 3 units of fuel since the shortest route needs 4 units of fuel.\n\n \nConstraints:\n\n2 <= locations.length <= 100\n1 <= locations[i] <= 109\nAll integers in locations are distinct.\n0 <= start, finish < locations.length\n1 <= fuel <= 200\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(locations = [4, 3, 1],start = 1,finish = 0,fuel = 6) == 5\n assert candidate(locations = [1, 10, 100, 1000, 10000],start = 0,finish = 4,fuel = 5000) == 0\n assert candidate(locations = [1, 2, 3, 4, 5],start = 0,finish = 4,fuel = 10) == 1208\n assert candidate(locations = [5, 2, 1],start = 0,finish = 2,fuel = 3) == 0\n assert candidate(locations = [10, 20, 30, 40],start = 0,finish = 3,fuel = 50) == 16\n assert candidate(locations = [2, 3, 6, 8, 4],start = 1,finish = 3,fuel = 5) == 4\n assert candidate(locations = [1, 2, 3],start = 0,finish = 2,fuel = 3) == 2\n assert candidate(locations = [10, 20, 30, 40, 50],start = 0,finish = 4,fuel = 100) == 1208\n assert candidate(locations = [2, 8, 14, 20, 26, 32, 38, 44, 50, 56, 62],start = 2,finish = 9,fuel = 100) == 549504\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90],start = 3,finish = 8,fuel = 150) == 461824\n assert candidate(locations = [10, 25, 40, 55, 70, 85, 100, 115, 130, 145, 160, 175, 190],start = 0,finish = 12,fuel = 300) == 23453696\n assert candidate(locations = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],start = 20,finish = 0,fuel = 300) == 984041497\n assert candidate(locations = [10, 25, 35, 45, 55],start = 0,finish = 4,fuel = 80) == 40\n assert candidate(locations = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],start = 4,finish = 0,fuel = 150) == 179664\n assert candidate(locations = [5, 6, 8, 9, 11, 12, 14, 15, 17, 18],start = 0,finish = 9,fuel = 20) == 28672\n assert candidate(locations = [5, 10, 15, 20, 25, 30, 35, 40, 45],start = 0,finish = 8,fuel = 120) == 838699257\n assert candidate(locations = [1, 5, 9, 12, 18, 23],start = 0,finish = 5,fuel = 40) == 464\n assert candidate(locations = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550],start = 1,finish = 9,fuel = 1000) == 78931328\n assert candidate(locations = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],start = 0,finish = 9,fuel = 100) == 11616768\n assert candidate(locations = [1, 3, 5, 7, 9, 11, 13],start = 0,finish = 6,fuel = 15) == 32\n assert candidate(locations = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],start = 15,finish = 0,fuel = 2500) == 886790116\n assert candidate(locations = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],start = 0,finish = 9,fuel = 20) == 256\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],start = 0,finish = 14,fuel = 150) == 8192\n assert candidate(locations = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],start = 0,finish = 19,fuel = 150) == 505021546\n assert candidate(locations = [1, 10, 100, 1000, 10000, 100000, 1000000],start = 0,finish = 6,fuel = 1000000) == 32\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],start = 0,finish = 19,fuel = 1000) == 762710068\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80],start = 2,finish = 5,fuel = 100) == 1952\n assert candidate(locations = [3, 7, 12, 18, 23, 29, 34, 39, 44],start = 1,finish = 8,fuel = 100) == 11186944\n assert candidate(locations = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],start = 0,finish = 9,fuel = 1000) == 256\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],start = 0,finish = 19,fuel = 200) == 262144\n assert candidate(locations = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70],start = 6,finish = 11,fuel = 200) == 460940892\n assert candidate(locations = [1, 3, 5, 7, 9, 11, 13, 15],start = 7,finish = 0,fuel = 15) == 64\n assert candidate(locations = [5, 20, 15, 40, 25, 35, 10],start = 2,finish = 6,fuel = 80) == 225320\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],start = 0,finish = 19,fuel = 1800) == 387985368\n assert candidate(locations = [2, 15, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],start = 1,finish = 17,fuel = 100) == 524288\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500],start = 49,finish = 0,fuel = 2000) == 430143451\n assert candidate(locations = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],start = 9,finish = 18,fuel = 300) == 279596282\n assert candidate(locations = [100, 200, 300, 400, 500],start = 1,finish = 3,fuel = 600) == 76\n assert candidate(locations = [1, 5, 10, 15, 20, 25, 30],start = 0,finish = 6,fuel = 40) == 224\n assert candidate(locations = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],start = 0,finish = 9,fuel = 150) == 892249801\n assert candidate(locations = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190, 210, 230, 250, 270, 290, 310, 330, 350, 370, 390, 410, 430, 450, 470, 490],start = 0,finish = 24,fuel = 1200) == 765380918\n assert candidate(locations = [7, 15, 22, 30, 35, 40, 45],start = 1,finish = 4,fuel = 70) == 12736\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],start = 10,finish = 19,fuel = 150) == 290816\n assert candidate(locations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],start = 0,finish = 9,fuel = 25) == 563971037\n assert candidate(locations = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190, 210, 230, 250, 270, 290, 310, 330, 350, 370, 390, 410, 430, 450, 470, 490],start = 0,finish = 24,fuel = 1500) == 191567701\n assert candidate(locations = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],start = 0,finish = 9,fuel = 150) == 1469184\n assert candidate(locations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],start = 1,finish = 13,fuel = 40) == 344143577\n assert candidate(locations = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],start = 1,finish = 13,fuel = 100) == 569120129\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],start = 9,finish = 10,fuel = 50) == 43\n assert candidate(locations = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],start = 4,finish = 9,fuel = 1023) == 16\n assert candidate(locations = [1, 5, 10, 15, 20, 25, 30],start = 0,finish = 6,fuel = 30) == 32\n assert candidate(locations = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],start = 0,finish = 9,fuel = 500) == 0\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 5,finish = 9,fuel = 150) == 179664\n assert candidate(locations = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],start = 0,finish = 19,fuel = 9900) == 762710068\n assert candidate(locations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],start = 29,finish = 0,fuel = 50) == 593376807\n assert candidate(locations = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],start = 1,finish = 8,fuel = 15) == 64\n assert candidate(locations = [5, 8, 12, 18, 25, 30, 35, 40, 45, 50, 55, 60],start = 11,finish = 0,fuel = 100) == 15490048\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],start = 5,finish = 10,fuel = 150) == 500736\n assert candidate(locations = [1000, 1005, 1010, 1015, 1020, 1025, 1030, 1035, 1040, 1045, 1050, 1055, 1060, 1065, 1070, 1075, 1080, 1085, 1090, 1095, 1100],start = 10,finish = 20,fuel = 600) == 512001622\n assert candidate(locations = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],start = 0,finish = 20,fuel = 300) == 652750206\n assert candidate(locations = [100, 200, 300, 400, 500, 600, 700, 800],start = 1,finish = 7,fuel = 1500) == 116544\n assert candidate(locations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],start = 15,finish = 0,fuel = 100) == 802029339\n assert candidate(locations = [10, 25, 40, 55, 70, 85, 100, 115, 130, 145],start = 0,finish = 9,fuel = 500) == 216449452\n assert candidate(locations = [1, 5, 10, 20, 30, 40],start = 0,finish = 5,fuel = 60) == 208\n assert candidate(locations = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],start = 0,finish = 29,fuel = 300) == 268435456\n assert candidate(locations = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155],start = 7,finish = 15,fuel = 300) == 343225957\n assert candidate(locations = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],start = 0,finish = 20,fuel = 190) == 0\n assert candidate(locations = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],start = 0,finish = 19,fuel = 524288) == 262144\n assert candidate(locations = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],start = 10,finish = 0,fuel = 150) == 759294305\n assert candidate(locations = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210],start = 19,finish = 0,fuel = 210) == 262144\n assert candidate(locations = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200],start = 0,finish = 39,fuel = 500) == 319204339\n assert candidate(locations = [3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151],start = 0,finish = 19,fuel = 2097150) == 262144\n assert candidate(locations = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],start = 4,finish = 8,fuel = 30) == 277680\n assert candidate(locations = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140],start = 0,finish = 14,fuel = 500) == 6482820\n assert candidate(locations = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150],start = 0,finish = 29,fuel = 150) == 268435456\n assert candidate(locations = [1, 5, 10, 15, 20, 25],start = 0,finish = 5,fuel = 40) == 112\n assert candidate(locations = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],start = 0,finish = 19,fuel = 524287) == 262144\n assert candidate(locations = [100, 200, 300, 400, 500, 600],start = 0,finish = 5,fuel = 1500) == 149696\n assert candidate(locations = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],start = 7,finish = 14,fuel = 120) == 5760\n assert candidate(locations = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],start = 0,finish = 9,fuel = 1500) == 183296\n assert candidate(locations = [1, 5, 10, 20, 50, 100, 200, 500, 1000, 2000],start = 0,finish = 9,fuel = 3000) == 149308961\n assert candidate(locations = [5, 15, 25, 35, 45, 55, 65],start = 0,finish = 6,fuel = 150) == 71872\n assert candidate(locations = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],start = 9,finish = 0,fuel = 100) == 11616768\n assert candidate(locations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],start = 0,finish = 19,fuel = 18) == 0\n assert candidate(locations = [100, 200, 300, 400, 500, 600],start = 5,finish = 0,fuel = 1500) == 149696\n assert candidate(locations = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],start = 0,finish = 11,fuel = 100) == 9483264\n assert candidate(locations = [1, 3, 5, 7, 9, 11, 13],start = 0,finish = 6,fuel = 20) == 1536\n assert candidate(locations = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],start = 0,finish = 9,fuel = 100) == 256\n assert candidate(locations = [5, 10, 15, 20, 25, 30],start = 0,finish = 5,fuel = 50) == 592\n assert candidate(locations = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],start = 0,finish = 9,fuel = 1800) == 1469184\n assert candidate(locations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],start = 0,finish = 29,fuel = 150) == 996660885\n assert candidate(locations = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225, 235, 245, 255, 265, 275, 285, 295],start = 29,finish = 0,fuel = 1500) == 996660885\n assert candidate(locations = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],start = 10,finish = 0,fuel = 50) == 636086244\n assert candidate(locations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],start = 0,finish = 14,fuel = 50) == 928900893\n assert candidate(locations = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],start = 0,finish = 19,fuel = 190) == 533148385\n assert candidate(locations = [100, 200, 300, 400, 500, 600, 700, 800, 900],start = 0,finish = 8,fuel = 2000) == 32131968\n"}, "metadata": {"canonical_parameter_names": ["locations", "start", "finish", "fuel"], "leetcode_dataset_entry_point": "Solution().countRoutes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countRoutes(vector& locations, int start, int finish, int fuel) {", "container": "Solution", "callable": "countRoutes", "parameters": [{"name": "locations", "type": "vector&"}, {"name": "start", "type": "int"}, {"name": "finish", "type": "int"}, {"name": "fuel", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1576, "task_id": "replace-all-s-to-avoid-consecutive-repeating-characters", "difficulty": "Easy", "problem_description": "Given a string s containing only lowercase English letters and the '?' character, convert all the '?' characters into lowercase letters such that the final string does not contain any consecutive repeating characters. You cannot modify the non '?' characters.\nIt is guaranteed that there are no consecutive repeating characters in the given string except for '?'.\nReturn the final string after all the conversions (possibly zero) have been made. If there is more than one solution, return any of them. It can be shown that an answer is always possible with the given constraints.\n \nExample 1:\n\nInput: s = \"?zs\"\nOutput: \"azs\"\nExplanation: There are 25 solutions for this problem. From \"azs\" to \"yzs\", all are valid. Only \"z\" is an invalid modification as the string will consist of consecutive repeating characters in \"zzs\".\n\nExample 2:\n\nInput: s = \"ubv?w\"\nOutput: \"ubvaw\"\nExplanation: There are 24 solutions for this problem. Only \"v\" and \"w\" are invalid modifications as the strings will consist of consecutive repeating characters in \"ubvvw\" and \"ubvww\".\n\n \nConstraints:\n\n1 <= s.length <= 100\ns consist of lowercase English letters and '?'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"?zs\") == \"azs\"\n assert candidate(s = \"b?a\") == \"bca\"\n assert candidate(s = \"a?b?\") == \"acba\"\n assert candidate(s = \"zz?z?zz\") == \"zzazazz\"\n assert candidate(s = \"z?z\") == \"zaz\"\n assert candidate(s = \"abc?de?\") == \"abcadea\"\n assert candidate(s = \"?abcd\") == \"babcd\"\n assert candidate(s = \"zyx?\") == \"zyxa\"\n assert candidate(s = \"z?a?a?a?z\") == \"zbabababz\"\n assert candidate(s = \"a?b?c?\") == \"acbaca\"\n assert candidate(s = \"a?c?e?\") == \"abcaea\"\n assert candidate(s = \"??a??\") == \"ababa\"\n assert candidate(s = \"abc?ef?\") == \"abcaefa\"\n assert candidate(s = \"b?a?c?\") == \"bcabca\"\n assert candidate(s = \"?a?a?a?\") == \"bababab\"\n assert candidate(s = \"????\") == \"abab\"\n assert candidate(s = \"a?b?c?d?\") == \"acbacada\"\n assert candidate(s = \"abcd?\") == \"abcda\"\n assert candidate(s = \"xyz?\") == \"xyza\"\n assert candidate(s = \"?\") == \"a\"\n assert candidate(s = \"a?b\") == \"acb\"\n assert candidate(s = \"?a?b?c?\") == \"bacbaca\"\n assert candidate(s = \"a?b?c\") == \"acbac\"\n assert candidate(s = \"?a?a?a\") == \"bababa\"\n assert candidate(s = \"a?c\") == \"abc\"\n assert candidate(s = \"a?a\") == \"aba\"\n assert candidate(s = \"ubv?w\") == \"ubvaw\"\n assert candidate(s = \"?????\") == \"ababa\"\n assert candidate(s = \"abc?\") == \"abca\"\n assert candidate(s = \"?a?b?c\") == \"bacbac\"\n assert candidate(s = \"????????????\") == \"abababababab\"\n assert candidate(s = \"??a??b??c??d??\") == \"ababababcabdab\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?abcdef?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbabcdefa\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbacbacadaeafagahaiajakalamanaoapaqarasatauavawaxayaz\"\n assert candidate(s = \"z?????????\") == \"zababababa\"\n assert candidate(s = \"a?b?c?d?e?fa?b?c?d?e?fa?b?c?d?e?fa?b?c?d?e?fa?b?c?d?e?f\") == \"acbacadaeafacbacadaeafacbacadaeafacbacadaeafacbacadaeaf\"\n assert candidate(s = \"x?y?z?x?y?\") == \"xayazaxaya\"\n assert candidate(s = \"?a?b?c?d?e\") == \"bacbacadae\"\n assert candidate(s = \"????????????????????\") == \"abababababababababab\"\n assert candidate(s = \"a?z?b?y?c?x?d?w?e?v?f?u?g?t?h?s?i?r?j?q?k?p?l?o?m?n?l?k?j?i?h?g?f?e?d?c?b?a\") == \"abzabayacaxadawaeavafauagatahasaiarajaqakapalaoamanalakajaiahagafaeadacabca\"\n assert candidate(s = \"abcd????efgh????ijkl????mnop????qrst????uvw????xyz????\") == \"abcdababefghababijklababmnopababqrstababuvwababxyzabab\"\n assert candidate(s = \"a?b?c?d?e?f?g?\") == \"acbacadaeafaga\"\n assert candidate(s = \"?b?a?b?a?b?a?b?a?b?\") == \"abcacbcacbcacbcacba\"\n assert candidate(s = \"a??????b??????c??????d??????e??????\") == \"abababababababcabababdabababeababab\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz????\") == \"abcdefghijklmnopqrstuvwxyzabab\"\n assert candidate(s = \"ab?cde?fg?hij?kl?mno?pqr?stu?vwx?yz?\") == \"abacdeafgahijaklamnoapqrastuavwxayza\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?ab?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbaba\"\n assert candidate(s = \"a????b????c????\") == \"abababababcabab\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?abcdefghijklmnopqrstuvwxyz\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbabcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba?\") == \"zyxwvutsrqponmlkjihgfedcbab\"\n assert candidate(s = \"x???x???\") == \"xabaxaba\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?abcde?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbabcdea\"\n assert candidate(s = \"abc????def????ghi????jkl????mno????pqr????stu????vwx????yz?\") == \"abcababdefababghiababjklababmnoababpqrababstuababvwxababyza\"\n assert candidate(s = \"a????b????c????d????e????\") == \"abababababcababdababeabab\"\n assert candidate(s = \"?????????\") == \"ababababa\"\n assert candidate(s = \"abcd?efg?hij?\") == \"abcdaefgahija\"\n assert candidate(s = \"a?z?b?y?c?x?d?w?e?v?f?u?g?t?h?s?i?r?j?q?k?p?l?o?m?n?l?k?j?i?h?g?f?e?d?c?b?a????\") == \"abzabayacaxadawaeavafauagatahasaiarajaqakapalaoamanalakajaiahagafaeadacabcababa\"\n assert candidate(s = \"?a?b?c?d?e?fg?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z\") == \"bacbacadaeafgahaiajakalamanaoapaqarasatauavawaxayaz\"\n assert candidate(s = \"a???????????????????????????????????????????????????????b\") == \"abababababababababababababababababababababababababababacb\"\n assert candidate(s = \"a?z?b?y?c?x?d?w?e?v?f?u?g?t?h?s?i?r?j?q?k?p?l?o?m?n?l?k?j?i?h?g?f?e?d?c?b?a?z?y?x?w?\") == \"abzabayacaxadawaeavafauagatahasaiarajaqakapalaoamanalakajaiahagafaeadacabcabzayaxawa\"\n assert candidate(s = \"xyz???uvw???stu???rst???qpo???nml???kji???hgf???edc???ba???\") == \"xyzabauvwabastuabarstabaqpoabanmlabakjiabahgfabaedcabababab\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz????\") == \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabab\"\n assert candidate(s = \"?a?b?c?d?e?f?g\") == \"bacbacadaeafag\"\n assert candidate(s = \"????a????\") == \"ababababa\"\n assert candidate(s = \"z?y?x?w?v?u?t?s?r?q?p?o?n?m?l?k?j?i?h?g?f?e?d?c?b?a?\") == \"zayaxawavauatasaraqapaoanamalakajaiahagafaeadacabcab\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z????\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazabab\"\n assert candidate(s = \"abc??xyz?\") == \"abcabxyza\"\n assert candidate(s = \"abc?de?fg?\") == \"abcadeafga\"\n assert candidate(s = \"????z\") == \"ababz\"\n assert candidate(s = \"a?????z\") == \"abababz\"\n assert candidate(s = \"abc????????de?????fg????hi????j????k????lm????n????op????qr????st????uv????wxyz????\") == \"abcababababdeababafgababhiababjababkabablmababnababopababqrababstababuvababwxyzabab\"\n assert candidate(s = \"a?????b?????c?????d?????e?????f?????g?????h?????i?????j?????\") == \"ababacbababacababadababaeababafababagababahababaiababajababa\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?a?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbab\"\n assert candidate(s = \"xyz???abc\") == \"xyzabcabc\"\n assert candidate(s = \"xyz?yxz?\") == \"xyzayxza\"\n assert candidate(s = \"?a?b?c?d?e?\") == \"bacbacadaea\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayaza\"\n assert candidate(s = \"ab?cd?ef?gh?ij?kl?mn?op?qr?st?uv?wx?yz?a?b?c?d?e?\") == \"abacdaefaghaijaklamnaopaqrastauvawxayzbacbacadaea\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?abcdefg?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbabcdefga\"\n assert candidate(s = \"????abc????def????ghi????jkl????mno????pqr????stu????vwx????yz????\") == \"abababcababdefababghiababjklababmnoababpqrababstuababvwxababyzabab\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?\") == \"acbacadaeafagahaiaja\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?a?b?c?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbacbaca\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?a?b?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbacba\"\n assert candidate(s = \"a?????????????????????????????????????????????b\") == \"ababababababababababababababababababababababacb\"\n assert candidate(s = \"????????\") == \"abababab\"\n assert candidate(s = \"????abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"abababcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"a????????????????????z\") == \"ababababababababababaz\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayaz\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?abcdefghijklmnopqrstuvwxyz?a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z????\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbabcdefghijklmnopqrstuvwxyzbacbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazabab\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?abc?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbabca\"\n assert candidate(s = \"?b?a?c?b?a?\") == \"abcabcabcab\"\n assert candidate(s = \"z??y?x?w?\") == \"zabyaxawa\"\n assert candidate(s = \"????abcdefghijklmnopqrstuvwxyz\") == \"abababcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxy?\") == \"abcdefghijklmnopqrstuvwxya\"\n assert candidate(s = \"a?b?c?d?e?\") == \"acbacadaea\"\n assert candidate(s = \"abc?def?ghi?jkl?mno?pqr?stu?vwx?yz?\") == \"abcadefaghiajklamnoapqrastuavwxayza\"\n assert candidate(s = \"a?b?a?b?a?b?a?b?a?\") == \"acbcacbcacbcacbcab\"\n assert candidate(s = \"ab?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?\") == \"abacadaeafagahaiajakalamanaoapaqarasatauavawaxayaza\"\n assert candidate(s = \"a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z?abcd?\") == \"acbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazbabcda\"\n assert candidate(s = \"z?a?y?b?x?c?w?v?d?u?t?e?s?r?q?p?o?n?m?l?k?j?i?h?g?f?e?d?c?b?a?\") == \"zbabyabaxacawavadauataeasaraqapaoanamalakajaiahagafaeadacabcab\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz?a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z????\") == \"abcdefghijklmnopqrstuvwxyzbacbacadaeafagahaiajakalamanaoapaqarasatauavawaxayazabab\"\n assert candidate(s = \"aaaa???bbbbb???ccccc???\") == \"aaaabacbbbbbabacccccaba\"\n assert candidate(s = \"?a?b?c?d?e?f?g?\") == \"bacbacadaeafaga\"\n assert candidate(s = \"z?y?x?w?v?u?t?s?r?q?p?o?n?m?l?k?j?i?h?g?f?e?d?c?b?a\") == \"zayaxawavauatasaraqapaoanamalakajaiahagafaeadacabca\"\n assert candidate(s = \"?a?b?c?d?e?f?g?h?i?j?k?l?m?n?o?p?q?r?s?t?u?v?w?x?y?z\") == \"bacbacadaeafagahaiajakalamanaoapaqarasatauavawaxayaz\"\n assert candidate(s = \"a?a?a?a?a?a?a?a?a?a\") == \"abababababababababa\"\n assert candidate(s = \"a??b??c??d??\") == \"abababcabdab\"\n assert candidate(s = \"??a?b??c??\") == \"abacbabcab\"\n assert candidate(s = \"a?b??c?d\") == \"acbabcad\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz?\") == \"abcdefghijklmnopqrstuvwxyza\"\n assert candidate(s = \"abcd????????efgh????????ijkl????????mnop????????qrst????????uvwx????????yz??\") == \"abcdababababefghababababijklababababmnopababababqrstababababuvwxababababyzab\"\n assert candidate(s = \"z????z????z????z????z\") == \"zababzababzababzababz\"\n assert candidate(s = \"a?a?a?a?a?b?b?b?b?b?c?c?c?c?c?d?d?d?d?d?\") == \"ababababacbababababacacacacacadadadadada\"\n assert candidate(s = \"xyz?abc?def?ghi?\") == \"xyzbabcadefaghia\"\n assert candidate(s = \"xyz??abc\") == \"xyzababc\"\n assert candidate(s = \"abcd????efgh\") == \"abcdababefgh\"\n assert candidate(s = \"?ab?bc?cd?de?ef?fg?\") == \"bababcacdadeaefafga\"\n assert candidate(s = \"a?????z?????y?????x?????w?????v?????u?????t?????s?????r?????q?????p?????o?????n?????m?????l?????k?????j?????i?????h?????g?????f?????e?????d?????c?????b\") == \"abababzababayababaxababawababavababauababatababasababarababaqababapababaoababanababamababalababakababajababaiababahababagababafababaeababadababacababab\"\n assert candidate(s = \"abc???def\") == \"abcabadef\"\n assert candidate(s = \"b?a?b?a?b?a?\") == \"bcacbcacbcab\"\n assert candidate(s = \"abc?def?ghi?jkl?mno?pqr?stu?vwx?yz\") == \"abcadefaghiajklamnoapqrastuavwxayz\"\n assert candidate(s = \"abc?def?ghi?\") == \"abcadefaghia\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().modifyString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string modifyString(string s) {", "container": "Solution", "callable": "modifyString", "parameters": [{"name": "s", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1577, "task_id": "number-of-ways-where-square-of-number-is-equal-to-product-of-two-numbers", "difficulty": "Medium", "problem_description": "Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:\n\nType 1: Triplet (i, j, k) if nums1[i]2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length.\nType 2: Triplet (i, j, k) if nums2[i]2 == nums1[j] * nums1[k] where 0 <= i < nums2.length and 0 <= j < k < nums1.length.\n\n \nExample 1:\n\nInput: nums1 = [7,4], nums2 = [5,2,8,9]\nOutput: 1\nExplanation: Type 1: (1, 1, 2), nums1[1]2 = nums2[1] * nums2[2]. (42 = 2 * 8). \n\nExample 2:\n\nInput: nums1 = [1,1], nums2 = [1,1,1]\nOutput: 9\nExplanation: All Triplets are valid, because 12 = 1 * 1.\nType 1: (0,0,1), (0,0,2), (0,1,2), (1,0,1), (1,0,2), (1,1,2). nums1[i]2 = nums2[j] * nums2[k].\nType 2: (0,0,1), (1,0,1), (2,0,1). nums2[i]2 = nums1[j] * nums1[k].\n\nExample 3:\n\nInput: nums1 = [7,7,8,3], nums2 = [1,2,9,7]\nOutput: 2\nExplanation: There are 2 valid triplets.\nType 1: (3,0,2). nums1[3]2 = nums2[0] * nums2[2].\nType 2: (3,0,1). nums2[3]2 = nums1[0] * nums1[1].\n\n \nConstraints:\n\n1 <= nums1.length, nums2.length <= 1000\n1 <= nums1[i], nums2[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [3, 5, 7],nums2 = [9, 25, 49]) == 0\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [25, 25, 25, 25]) == 0\n assert candidate(nums1 = [10, 5, 2],nums2 = [100, 25, 4]) == 1\n assert candidate(nums1 = [2, 3, 5],nums2 = [2, 5, 10]) == 0\n assert candidate(nums1 = [2, 2, 2, 2],nums2 = [4, 4, 4]) == 0\n assert candidate(nums1 = [7, 4],nums2 = [5, 2, 8, 9]) == 1\n assert candidate(nums1 = [3, 3, 3],nums2 = [3, 3, 3, 3]) == 30\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 4, 9, 16, 25]) == 4\n assert candidate(nums1 = [6, 10, 15],nums2 = [36, 100, 225]) == 0\n assert candidate(nums1 = [10, 10, 10],nums2 = [10, 10, 10, 10]) == 30\n assert candidate(nums1 = [5],nums2 = [5, 5, 5]) == 3\n assert candidate(nums1 = [7, 7, 8, 3],nums2 = [1, 2, 9, 7]) == 2\n assert candidate(nums1 = [3, 3, 3, 3],nums2 = [9, 9, 9, 9]) == 0\n assert candidate(nums1 = [1000],nums2 = [1, 10, 100, 1000]) == 0\n assert candidate(nums1 = [2, 3, 5],nums2 = [4, 9, 25]) == 0\n assert candidate(nums1 = [3, 15, 9],nums2 = [9, 25, 36]) == 1\n assert candidate(nums1 = [2, 3, 4],nums2 = [1, 5, 6, 10]) == 0\n assert candidate(nums1 = [10, 10, 10],nums2 = [10, 10, 10]) == 18\n assert candidate(nums1 = [1],nums2 = [1, 1, 1, 1, 1]) == 10\n assert candidate(nums1 = [10, 5, 3],nums2 = [2, 4, 8, 16]) == 0\n assert candidate(nums1 = [1, 1],nums2 = [1, 1, 1]) == 9\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [1, 9, 25, 49, 81, 121, 169, 225, 289, 361]) == 10\n assert candidate(nums1 = [3, 9, 27, 81],nums2 = [9, 81, 243, 729, 2187, 6561]) == 3\n assert candidate(nums1 = [11, 22, 33, 44],nums2 = [121, 484, 726, 1936, 2904]) == 0\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [25, 25, 25, 25, 25, 25, 25]) == 0\n assert candidate(nums1 = [6, 10, 12, 15],nums2 = [36, 100, 144, 225, 150]) == 0\n assert candidate(nums1 = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [36, 49, 64, 81, 100, 121, 144, 169, 196, 225]) == 0\n assert candidate(nums1 = [100, 200, 300, 400],nums2 = [10000, 40000, 90000, 160000]) == 0\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3],nums2 = [9, 9, 9, 9, 9, 9, 9]) == 0\n assert candidate(nums1 = [1, 2, 2, 3, 3, 3],nums2 = [1, 4, 4, 9, 9, 9, 9]) == 16\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 900\n assert candidate(nums1 = [3, 9, 27, 81, 243, 729],nums2 = [9, 27, 81, 243, 729, 2187]) == 12\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [10000, 40000, 90000, 160000, 250000]) == 0\n assert candidate(nums1 = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],nums2 = [49, 196, 441, 784, 1225, 1764, 2401, 3136, 3969, 4900, 5929, 7056, 8281, 9604, 11025]) == 1\n assert candidate(nums1 = [13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13],nums2 = [169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169]) == 0\n assert candidate(nums1 = [4, 8, 12, 16, 20],nums2 = [16, 64, 144, 256, 400, 625, 1024]) == 0\n assert candidate(nums1 = [2, 4, 6, 8, 10],nums2 = [4, 16, 36, 64, 100, 144, 196]) == 2\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [25, 25, 25, 25, 25, 25]) == 0\n assert candidate(nums1 = [6, 10, 15],nums2 = [36, 100, 150, 225]) == 0\n assert candidate(nums1 = [13, 169, 2197, 28561, 371293, 4826809, 62748517, 815730721, 10604499373],nums2 = [169, 2197, 28561, 371293, 4826809, 62748517, 815730721, 10604499373, 13841287201]) == 28\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == 13\n assert candidate(nums1 = [6, 12, 18, 24],nums2 = [36, 144, 324, 576, 864, 1152, 1440]) == 0\n assert candidate(nums1 = [3, 6, 9, 12, 15, 18],nums2 = [9, 36, 81, 144, 225, 324, 441]) == 1\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1]) == 220\n assert candidate(nums1 = [8, 9, 12, 15, 18],nums2 = [64, 81, 144, 225, 324]) == 0\n assert candidate(nums1 = [5, 10, 15, 20, 25],nums2 = [25, 100, 225, 400, 625]) == 0\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30],nums2 = [25, 100, 225, 400, 625, 900]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [1, 9, 25, 49, 81]) == 4\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4],nums2 = [1, 1, 4, 4, 9, 9, 16, 16]) == 32\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12],nums2 = [4, 16, 36, 64, 100, 144, 256]) == 3\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144]) == 13\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],nums2 = [4, 16, 36, 64, 100, 144, 196, 256, 324, 400]) == 5\n assert candidate(nums1 = [10, 100, 1000, 10000, 100000],nums2 = [100, 10000, 1000000, 100000000, 10000000000]) == 6\n assert candidate(nums1 = [12, 15, 20, 25, 30],nums2 = [144, 225, 400, 625, 900]) == 0\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [25, 25, 25, 25, 25]) == 0\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 0\n assert candidate(nums1 = [11, 11, 121, 1331, 14641],nums2 = [121, 1331, 14641, 161051, 1771561]) == 6\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3],nums2 = [9, 9, 9, 9, 9, 9, 9, 9, 9]) == 0\n assert candidate(nums1 = [7, 49, 343, 2401, 16807, 117649, 823543, 5764801, 40353607, 282475249],nums2 = [49, 343, 2401, 16807, 117649, 823543, 5764801, 40353607, 282475249, 2004761894]) == 36\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [1, 9, 25, 49, 81, 121, 169, 225, 289, 361]) == 10\n assert candidate(nums1 = [3, 6, 9, 12, 15, 18],nums2 = [9, 36, 81, 144, 225, 324]) == 1\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36]) == 0\n assert candidate(nums1 = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],nums2 = [1, 1, 1, 4, 4, 4, 9, 9, 9, 16, 16, 16, 1]) == 156\n assert candidate(nums1 = [1000, 2000, 3000, 4000, 5000],nums2 = [1000000, 4000000, 9000000, 16000000, 25000000]) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [100, 400, 900, 1600, 2500, 3600, 4900, 6400, 8100, 10000, 12100, 14400, 16900, 19600, 22500]) == 0\n assert candidate(nums1 = [1, 2, 2, 4, 8, 16, 32],nums2 = [1, 1, 4, 4, 16, 16, 64]) == 33\n assert candidate(nums1 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],nums2 = [4, 16, 36, 64, 100, 144, 196, 256, 324, 400]) == 5\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [100, 400, 900, 1600, 2500, 50, 250, 1250, 6250]) == 0\n assert candidate(nums1 = [100, 200, 300, 400],nums2 = [10000, 40000, 90000, 160000]) == 0\n assert candidate(nums1 = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],nums2 = [4, 9, 25, 49, 121, 169, 289, 361, 529, 841]) == 0\n assert candidate(nums1 = [7, 49, 343, 2401],nums2 = [49, 343, 2401, 16807]) == 4\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 325\n assert candidate(nums1 = [5, 10, 15, 20, 25],nums2 = [25, 50, 75, 100, 125, 150]) == 0\n assert candidate(nums1 = [8, 15, 17, 20],nums2 = [64, 225, 289, 400, 676, 841]) == 0\n assert candidate(nums1 = [2, 4, 8, 16, 32, 64, 128, 256, 512],nums2 = [4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144, 1048576]) == 24\n assert candidate(nums1 = [6, 6, 6, 6, 6],nums2 = [36, 36, 36, 36, 36]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11550\n assert candidate(nums1 = [7, 11, 13, 17, 19, 23, 29, 31, 37],nums2 = [49, 121, 169, 289, 361, 529, 841, 961, 1369, 1681]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225]) == 22\n assert candidate(nums1 = [2, 4, 8, 16, 32, 64],nums2 = [4, 16, 64, 256, 1024, 4096, 16384]) == 9\n assert candidate(nums1 = [10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [100, 225, 400, 625, 900, 1225, 1600, 2025, 2500]) == 0\n assert candidate(nums1 = [7, 24, 25, 30],nums2 = [49, 576, 625, 900, 1440, 1800]) == 0\n assert candidate(nums1 = [2, 3, 5, 7, 11, 13, 17],nums2 = [4, 9, 25, 49, 121, 169, 289]) == 0\n assert candidate(nums1 = [7, 11, 13, 17, 19],nums2 = [49, 121, 169, 289, 361, 529]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 900\n assert candidate(nums1 = [1, 3, 3, 3, 1],nums2 = [1, 9, 9, 1, 1, 9]) == 36\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [10000, 40000, 90000, 160000, 250000, 360000, 490000, 640000, 810000, 1000000]) == 0\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == 0\n assert candidate(nums1 = [1, 2, 2, 3, 3, 3],nums2 = [1, 1, 2, 2, 3, 3]) == 14\n assert candidate(nums1 = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],nums2 = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 563\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [1, 1, 1, 4, 4, 9]) == 27\n assert candidate(nums1 = [3, 9, 27, 81, 243],nums2 = [27, 81, 243, 729, 2187]) == 6\n assert candidate(nums1 = [31, 37, 41, 43, 47, 53, 59],nums2 = [961, 1369, 1681, 1849, 2209, 2809, 3481]) == 0\n assert candidate(nums1 = [2, 4, 8, 16, 32, 64, 128, 256],nums2 = [4, 16, 64, 256, 1024, 4096]) == 17\n assert candidate(nums1 = [2, 2, 2, 2],nums2 = [4, 4, 4, 4, 4]) == 0\n assert candidate(nums1 = [2, 4, 8, 16, 32, 64],nums2 = [4, 16, 64, 256, 1024, 4096]) == 9\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6],nums2 = [36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36]) == 0\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [25, 100, 225, 400, 625, 900, 1225, 1600, 2025, 2500]) == 1\n assert candidate(nums1 = [3, 5, 8, 12, 15, 17, 20],nums2 = [9, 25, 64, 144, 225, 289, 400]) == 1\n assert candidate(nums1 = [15, 20, 25, 30],nums2 = [225, 400, 625, 900, 1200, 1800]) == 0\n assert candidate(nums1 = [10, 10, 10],nums2 = [100, 100, 100, 100]) == 0\n assert candidate(nums1 = [7, 11, 13, 17, 19],nums2 = [49, 121, 169, 289, 361]) == 0\n assert candidate(nums1 = [6, 7, 8],nums2 = [36, 49, 64, 84, 112]) == 0\n assert candidate(nums1 = [2, 3, 5, 7, 11],nums2 = [4, 6, 9, 10, 14, 15, 21, 22, 30, 33, 35, 55, 77, 105]) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [100, 400, 900, 1600, 2500]) == 0\n assert candidate(nums1 = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],nums2 = [121, 484, 1089, 1936, 3025, 4356, 5929, 7744, 9801, 12100, 14641, 17424, 20736, 24336, 28081]) == 0\n assert candidate(nums1 = [10, 20, 30, 40],nums2 = [100, 400, 900, 1600, 2500]) == 0\n assert candidate(nums1 = [6, 8, 10, 12, 14],nums2 = [36, 64, 100, 144, 196, 256]) == 0\n assert candidate(nums1 = [15, 25, 35, 45, 55],nums2 = [225, 625, 1225, 2025, 3025, 450, 750, 1050, 1350, 1650]) == 0\n assert candidate(nums1 = [100000, 99999, 99998, 99997, 99996],nums2 = [10000000000, 9999800001, 9999600004, 9999400009, 9999200016]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 351\n assert candidate(nums1 = [6, 8, 10, 12, 14],nums2 = [36, 64, 100, 144, 196, 48, 72, 96, 112, 120]) == 0\n assert candidate(nums1 = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80],nums2 = [64, 256, 576, 1024, 1600, 2304, 3136, 4096, 5184, 6400]) == 0\n assert candidate(nums1 = [6, 10, 14, 18, 22, 26, 30],nums2 = [36, 100, 196, 324, 484, 676, 900]) == 0\n assert candidate(nums1 = [3, 5, 7, 11, 13],nums2 = [9, 25, 49, 121, 169, 289]) == 0\n assert candidate(nums1 = [7, 11, 13, 17, 19, 23, 29],nums2 = [49, 121, 169, 289, 361, 529, 841]) == 0\n assert candidate(nums1 = [5, 12, 13, 15],nums2 = [25, 144, 169, 225, 441]) == 0\n assert candidate(nums1 = [11, 13, 17, 19],nums2 = [121, 169, 289, 361, 441, 529]) == 0\n assert candidate(nums1 = [1, 2, 2, 3, 3, 3, 4],nums2 = [1, 4, 4, 9, 9, 16]) == 12\n assert candidate(nums1 = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],nums2 = [4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144, 1048576]) == 30\n assert candidate(nums1 = [7, 11, 13, 17, 19],nums2 = [49, 121, 169, 289, 361, 441]) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().numTriplets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numTriplets(vector& nums1, vector& nums2) {", "container": "Solution", "callable": "numTriplets", "parameters": [{"name": "nums1", "type": "vector&"}, {"name": "nums2", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1578, "task_id": "minimum-time-to-make-rope-colorful", "difficulty": "Medium", "problem_description": "Alice has n balloons arranged on a rope. You are given a 0-indexed string colors where colors[i] is the color of the ith balloon.\nAlice wants the rope to be colorful. She does not want two consecutive balloons to be of the same color, so she asks Bob for help. Bob can remove some balloons from the rope to make it colorful. You are given a 0-indexed integer array neededTime where neededTime[i] is the time (in seconds) that Bob needs to remove the ith balloon from the rope.\nReturn the minimum time Bob needs to make the rope colorful.\n \nExample 1:\n\n\nInput: colors = \"abaac\", neededTime = [1,2,3,4,5]\nOutput: 3\nExplanation: In the above image, 'a' is blue, 'b' is red, and 'c' is green.\nBob can remove the blue balloon at index 2. This takes 3 seconds.\nThere are no longer two consecutive balloons of the same color. Total time = 3.\nExample 2:\n\n\nInput: colors = \"abc\", neededTime = [1,2,3]\nOutput: 0\nExplanation: The rope is already colorful. Bob does not need to remove any balloons from the rope.\n\nExample 3:\n\n\nInput: colors = \"aabaa\", neededTime = [1,2,3,4,1]\nOutput: 2\nExplanation: Bob will remove the balloons at indices 0 and 4. Each balloons takes 1 second to remove.\nThere are no longer two consecutive balloons of the same color. Total time = 1 + 1 = 2.\n\n \nConstraints:\n\nn == colors.length == neededTime.length\n1 <= n <= 105\n1 <= neededTime[i] <= 104\ncolors contains only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(colors = \"abcabc\",neededTime = [1, 2, 3, 1, 2, 3]) == 0\n assert candidate(colors = \"aaaaa\",neededTime = [5, 4, 3, 2, 1]) == 10\n assert candidate(colors = \"abacabadabacaba\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(colors = \"aabaa\",neededTime = [1, 2, 3, 4, 1]) == 2\n assert candidate(colors = \"zzzz\",neededTime = [1, 1, 1, 1]) == 3\n assert candidate(colors = \"aaaa\",neededTime = [10, 5, 4, 2]) == 11\n assert candidate(colors = \"abcdef\",neededTime = [1, 1, 1, 1, 1, 1]) == 0\n assert candidate(colors = \"abaac\",neededTime = [1, 2, 3, 4, 5]) == 3\n assert candidate(colors = \"abc\",neededTime = [1, 2, 3]) == 0\n assert candidate(colors = \"abcdefg\",neededTime = [1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(colors = \"aaabbb\",neededTime = [1, 2, 3, 4, 5, 6]) == 12\n assert candidate(colors = \"aabbcc\",neededTime = [1, 2, 3, 1, 2, 3]) == 4\n assert candidate(colors = \"abcd\",neededTime = [4, 3, 2, 1]) == 0\n assert candidate(colors = \"bbbaaa\",neededTime = [4, 9, 3, 8, 8, 9]) == 23\n assert candidate(colors = \"ababab\",neededTime = [1, 2, 3, 4, 5, 6]) == 0\n assert candidate(colors = \"a\",neededTime = [5]) == 0\n assert candidate(colors = \"aabab\",neededTime = [3, 5, 10, 7, 5]) == 3\n assert candidate(colors = \"aaabbb\",neededTime = [3, 5, 10, 7, 5, 3]) == 16\n assert candidate(colors = \"a\",neededTime = [1]) == 0\n assert candidate(colors = \"zzzz\",neededTime = [10, 1, 1, 100]) == 12\n assert candidate(colors = \"abcabcabcabc\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 0\n assert candidate(colors = \"ababababab\",neededTime = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 0\n assert candidate(colors = \"aaaaaaaaaabbbbbbbbbb\",neededTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10]) == 18\n assert candidate(colors = \"aaabbbcccdddeee\",neededTime = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 30\n assert candidate(colors = \"aaabaaaabaaaaaaaabaa\",neededTime = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == 28\n assert candidate(colors = \"ababaababaaba\",neededTime = [1, 3, 5, 2, 4, 6, 3, 5, 7, 4, 6, 8, 5]) == 8\n assert candidate(colors = \"aabbaa\",neededTime = [1, 2, 3, 4, 5, 6]) == 9\n assert candidate(colors = \"aaaabbbbccccdddd\",neededTime = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4]) == 30\n assert candidate(colors = \"abacabadabacabadabacabadabacabadabacabad\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 0\n assert candidate(colors = \"aabaaabbaaaabaaa\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 76\n assert candidate(colors = \"aaaabbbbcccc\",neededTime = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == 18\n assert candidate(colors = \"abababababab\",neededTime = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4]) == 0\n assert candidate(colors = \"aabbccddeeff\",neededTime = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]) == 9\n assert candidate(colors = \"aabccbaa\",neededTime = [3, 5, 10, 7, 5, 3, 5, 3]) == 11\n assert candidate(colors = \"aabbccddeeffgg\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 49\n assert candidate(colors = \"aaaaaaaaaa\",neededTime = [1, 10, 100, 1000, 10000, 1, 10, 100, 1000, 10000]) == 12222\n assert candidate(colors = \"zzzzzzzzzz\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(colors = \"bbbaaabbb\",neededTime = [10, 1, 1, 1, 10, 10, 1, 1, 10]) == 15\n assert candidate(colors = \"xyzzzyx\",neededTime = [1, 2, 3, 4, 5, 6, 7]) == 7\n assert candidate(colors = \"aaaaaaaaaaaa\",neededTime = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989]) == 109934\n assert candidate(colors = \"aabbbaaabbbaaa\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 65\n assert candidate(colors = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",neededTime = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == 0\n assert candidate(colors = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 180\n assert candidate(colors = \"abccbaabccba\",neededTime = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]) == 7\n assert candidate(colors = \"aabbaa\",neededTime = [10, 5, 1, 1, 5, 10]) == 11\n assert candidate(colors = \"abcabcabc\",neededTime = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(colors = \"abcdefghij\",neededTime = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 0\n assert candidate(colors = \"aabbccddeeffgghhiijjkk\",neededTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(colors = \"abcabcabcabc\",neededTime = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 0\n assert candidate(colors = \"aaabbbcccddd\",neededTime = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 20\n assert candidate(colors = \"aaaabbbb\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8]) == 24\n assert candidate(colors = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]) == 676\n assert candidate(colors = \"abababababababababab\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(colors = \"aabccbaabccbaabc\",neededTime = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 13\n assert candidate(colors = \"abcabcabcabcabcabcabc\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 0\n assert candidate(colors = \"abababababababababab\",neededTime = [1, 9, 2, 8, 3, 7, 4, 6, 5, 5, 4, 6, 3, 7, 2, 8, 1, 9, 1, 9]) == 0\n assert candidate(colors = \"aabaaaaba\",neededTime = [1, 2, 1, 1, 1, 1, 1, 2, 1]) == 4\n assert candidate(colors = \"ababababab\",neededTime = [5, 4, 5, 4, 5, 4, 5, 4, 5, 4]) == 0\n assert candidate(colors = \"aabbaa\",neededTime = [10, 1, 10, 2, 10, 3]) == 6\n assert candidate(colors = \"abcabcabcabc\",neededTime = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3]) == 0\n assert candidate(colors = \"ababaababa\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(colors = \"abcabcabcabcabcabc\",neededTime = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(colors = \"aaaabbbbccccdddd\",neededTime = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == 24\n assert candidate(colors = \"aabbccddeeffgg\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 49\n assert candidate(colors = \"aabbccddeeffgg\",neededTime = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 33\n assert candidate(colors = \"aaaaaaaaaabbbbbbbbbb\",neededTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10]) == 18\n assert candidate(colors = \"aabbaabbcc\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 25\n assert candidate(colors = \"aaabaaaaba\",neededTime = [5, 5, 5, 1, 1, 5, 5, 1, 1, 5]) == 17\n assert candidate(colors = \"zzzzzzzzz\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 36\n assert candidate(colors = \"abcdabcde\",neededTime = [1, 2, 3, 4, 1, 2, 3, 4, 5]) == 0\n assert candidate(colors = \"abcdefghijklmnopqrstuvwxyz\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]) == 0\n assert candidate(colors = \"aaabaaaabaaab\",neededTime = [3, 2, 1, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == 11\n assert candidate(colors = \"abcdeffedcba\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1]) == 6\n assert candidate(colors = \"aabbaaabbbaaa\",neededTime = [1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1]) == 9\n assert candidate(colors = \"zzzzzzzzzz\",neededTime = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(colors = \"abcabcabcabc\",neededTime = [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30]) == 0\n assert candidate(colors = \"ababababab\",neededTime = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 0\n assert candidate(colors = \"abababababab\",neededTime = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10, 6, 1]) == 0\n assert candidate(colors = \"abcabcabcabcabcabcabcabcabcabc\",neededTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(colors = \"aabbbcccaabbcc\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 54\n assert candidate(colors = \"aabbaabbaabb\",neededTime = [10, 20, 30, 40, 10, 20, 30, 40, 10, 20, 30, 40]) == 120\n assert candidate(colors = \"aabbccddeeff\",neededTime = [10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(colors = \"abcabcabcabc\",neededTime = [2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == 0\n assert candidate(colors = \"zzzzz\",neededTime = [1, 2, 3, 4, 5]) == 10\n assert candidate(colors = \"aabbccddeeffgg\",neededTime = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(colors = \"zzzzzzzzzz\",neededTime = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(colors = \"aabacbacba\",neededTime = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n assert candidate(colors = \"abcdabcda\",neededTime = [1, 2, 3, 4, 1, 2, 3, 4, 1]) == 0\n assert candidate(colors = \"aabbccddeeff\",neededTime = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 6\n assert candidate(colors = \"aaaabbbb\",neededTime = [1, 2, 3, 4, 1, 2, 3, 4]) == 12\n assert candidate(colors = \"abcdefghij\",neededTime = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 0\n"}, "metadata": {"canonical_parameter_names": ["colors", "neededTime"], "leetcode_dataset_entry_point": "Solution().minCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minCost(string colors, vector& neededTime) {", "container": "Solution", "callable": "minCost", "parameters": [{"name": "colors", "type": "string"}, {"name": "neededTime", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1579, "task_id": "remove-max-number-of-edges-to-keep-graph-fully-traversable", "difficulty": "Hard", "problem_description": "Alice and Bob have an undirected graph of n nodes and three types of edges:\n\nType 1: Can be traversed by Alice only.\nType 2: Can be traversed by Bob only.\nType 3: Can be traversed by both Alice and Bob.\n\nGiven an array edges where edges[i] = [typei, ui, vi] represents a bidirectional edge of type typei between nodes ui and vi, find the maximum number of edges you can remove so that after removing the edges, the graph can still be fully traversed by both Alice and Bob. The graph is fully traversed by Alice and Bob if starting from any node, they can reach all other nodes.\nReturn the maximum number of edges you can remove, or return -1 if Alice and Bob cannot fully traverse the graph.\n \nExample 1:\n\n\nInput: n = 4, edges = [[3,1,2],[3,2,3],[1,1,3],[1,2,4],[1,1,2],[2,3,4]]\nOutput: 2\nExplanation: If we remove the 2 edges [1,1,2] and [1,1,3]. The graph will still be fully traversable by Alice and Bob. Removing any additional edge will not make it so. So the maximum number of edges we can remove is 2.\n\nExample 2:\n\n\nInput: n = 4, edges = [[3,1,2],[3,2,3],[1,1,4],[2,1,4]]\nOutput: 0\nExplanation: Notice that removing any edge will not make the graph fully traversable by Alice and Bob.\n\nExample 3:\n\n\nInput: n = 4, edges = [[3,2,3],[1,1,2],[2,3,4]]\nOutput: -1\nExplanation: In the current graph, Alice cannot reach node 4 from the other nodes. Likewise, Bob cannot reach 1. Therefore it's impossible to make the graph fully traversable.\n \n \nConstraints:\n\n1 <= n <= 105\n1 <= edges.length <= min(105, 3 * n * (n - 1) / 2)\nedges[i].length == 3\n1 <= typei <= 3\n1 <= ui < vi <= n\nAll tuples (typei, ui, vi) are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,edges = [[1, 1, 2], [2, 2, 3], [3, 3, 4], [3, 4, 5], [1, 2, 3], [2, 3, 4]]) == -1\n assert candidate(n = 4,edges = [[3, 1, 2], [3, 2, 3], [1, 1, 3], [1, 2, 4], [1, 1, 2], [2, 3, 4]]) == 2\n assert candidate(n = 4,edges = [[3, 1, 2], [3, 2, 3], [1, 1, 4], [2, 1, 4]]) == 0\n assert candidate(n = 5,edges = [[3, 1, 2], [3, 2, 3], [3, 4, 5], [1, 1, 3], [1, 1, 4], [2, 3, 5]]) == 1\n assert candidate(n = 3,edges = [[1, 1, 2], [2, 1, 2], [3, 2, 3]]) == 0\n assert candidate(n = 4,edges = [[3, 2, 3], [1, 1, 2], [2, 3, 4]]) == -1\n assert candidate(n = 6,edges = [[1, 1, 2], [1, 2, 3], [2, 3, 4], [2, 4, 5], [3, 5, 6]]) == -1\n assert candidate(n = 3,edges = [[3, 1, 2], [1, 1, 3], [2, 2, 3]]) == 0\n assert candidate(n = 8,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [1, 1, 5], [1, 5, 6], [1, 6, 7], [2, 4, 5], [2, 5, 8], [3, 7, 8], [1, 2, 8], [2, 3, 7]]) == -1\n assert candidate(n = 20,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [3, 12, 13], [3, 13, 14], [3, 14, 15], [3, 15, 16], [3, 16, 17], [3, 17, 18], [3, 18, 19], [3, 19, 20], [1, 1, 20], [2, 2, 19], [1, 3, 18], [2, 4, 17], [1, 5, 16], [2, 6, 15], [1, 7, 14], [2, 8, 13], [1, 9, 12], [2, 10, 11]]) == 10\n assert candidate(n = 7,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [1, 5, 6], [1, 6, 7], [2, 5, 7], [1, 1, 4], [2, 1, 2]]) == -1\n assert candidate(n = 15,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [3, 12, 13], [3, 13, 14], [3, 14, 15], [1, 1, 15], [2, 2, 14], [1, 3, 13], [2, 4, 12], [1, 5, 11], [2, 6, 10], [1, 7, 9], [2, 8, 9]]) == 8\n assert candidate(n = 15,edges = [[3, 1, 2], [1, 2, 3], [2, 3, 4], [1, 4, 5], [2, 5, 6], [1, 6, 7], [2, 7, 8], [3, 8, 1], [3, 1, 3], [3, 2, 4], [3, 4, 6], [3, 5, 7], [1, 9, 10], [2, 10, 11], [3, 11, 12], [1, 12, 13], [2, 13, 14], [3, 14, 15], [1, 15, 1]]) == -1\n assert candidate(n = 12,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [1, 1, 12], [2, 1, 12], [1, 2, 3], [2, 3, 2], [1, 4, 5], [2, 5, 4], [1, 6, 7], [2, 7, 6], [1, 8, 9], [2, 9, 8]]) == 10\n assert candidate(n = 6,edges = [[3, 1, 2], [3, 2, 3], [1, 1, 3], [1, 2, 4], [1, 4, 5], [2, 3, 4], [2, 5, 6], [3, 1, 4]]) == -1\n assert candidate(n = 6,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [1, 1, 6], [2, 1, 6]]) == 2\n assert candidate(n = 20,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [3, 12, 13], [3, 13, 14], [3, 14, 15], [3, 15, 16], [3, 16, 17], [3, 17, 18], [3, 18, 19], [3, 19, 20], [1, 1, 6], [2, 6, 12], [1, 5, 7], [2, 5, 8], [1, 3, 9], [3, 2, 10], [1, 4, 11], [2, 7, 13], [3, 8, 14], [1, 9, 15], [2, 10, 14], [1, 11, 16], [2, 12, 17], [1, 13, 18], [2, 14, 19], [1, 15, 20], [2, 16, 18], [3, 17, 19]]) == 18\n assert candidate(n = 8,edges = [[3, 1, 2], [1, 1, 3], [2, 2, 3], [3, 3, 4], [1, 3, 4], [2, 3, 4], [3, 4, 5], [1, 4, 5], [2, 4, 5], [3, 5, 6], [1, 5, 6], [2, 5, 6], [3, 6, 7], [1, 6, 7], [2, 6, 7], [3, 7, 8], [1, 7, 8], [2, 7, 8], [1, 1, 8], [2, 1, 8]]) == 12\n assert candidate(n = 8,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [1, 1, 4], [2, 4, 5], [1, 5, 6], [2, 6, 7], [1, 7, 8], [2, 1, 8], [1, 2, 5], [2, 3, 6], [1, 4, 7], [2, 5, 8]]) == 2\n assert candidate(n = 8,edges = [[1, 1, 2], [2, 2, 3], [1, 3, 4], [2, 4, 5], [1, 5, 6], [2, 6, 7], [1, 7, 8], [2, 8, 1], [3, 1, 5], [3, 2, 6], [3, 3, 7], [3, 4, 8]]) == -1\n assert candidate(n = 15,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [3, 12, 13], [3, 13, 14], [3, 14, 15], [1, 1, 8], [1, 8, 15], [2, 2, 9], [2, 9, 14]]) == 4\n assert candidate(n = 6,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [1, 1, 2], [1, 3, 4], [1, 5, 6], [2, 2, 3], [2, 4, 5]]) == 5\n assert candidate(n = 9,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [1, 4, 5], [1, 5, 6], [2, 6, 7], [2, 7, 8], [1, 8, 9], [2, 1, 2], [2, 1, 3], [1, 1, 9]]) == -1\n assert candidate(n = 7,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [1, 1, 6], [1, 6, 7], [2, 2, 4], [2, 4, 6], [2, 5, 7], [1, 2, 5], [2, 1, 3], [3, 1, 7]]) == 5\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [1, 1, 2], [1, 3, 4], [1, 5, 6], [1, 7, 8], [1, 9, 10], [2, 2, 3], [2, 4, 5], [2, 6, 7], [2, 8, 9]]) == 9\n assert candidate(n = 20,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [3, 12, 13], [3, 13, 14], [3, 14, 15], [3, 15, 16], [3, 16, 17], [3, 17, 18], [3, 18, 19], [3, 19, 20], [1, 1, 20], [2, 20, 1], [1, 2, 3], [2, 3, 2], [1, 4, 5], [2, 5, 4], [1, 6, 7], [2, 7, 6], [1, 8, 9], [2, 9, 8], [1, 10, 11], [2, 11, 10], [1, 12, 13], [2, 13, 12], [1, 14, 15], [2, 15, 14], [1, 16, 17], [2, 17, 16], [1, 18, 19], [2, 19, 18]]) == 20\n assert candidate(n = 9,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [1, 1, 7], [1, 7, 8], [1, 8, 9], [2, 2, 5], [2, 5, 8], [2, 3, 6], [3, 1, 6], [1, 2, 8], [2, 3, 7]]) == -1\n assert candidate(n = 9,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [1, 1, 4], [1, 4, 7], [1, 7, 9], [2, 2, 5], [2, 5, 8]]) == 5\n assert candidate(n = 12,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [1, 1, 6], [1, 6, 11], [2, 2, 7], [2, 7, 12]]) == 4\n assert candidate(n = 6,edges = [[1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [3, 1, 3], [3, 2, 4], [3, 3, 5], [3, 4, 6]]) == 8\n assert candidate(n = 12,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [1, 6, 7], [1, 7, 8], [1, 8, 9], [1, 9, 10], [1, 10, 11], [1, 11, 12], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7], [2, 7, 8], [2, 8, 9], [2, 9, 10], [2, 10, 11], [2, 11, 12]]) == 22\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [1, 1, 7], [1, 7, 8], [1, 8, 9], [1, 9, 10], [2, 1, 10], [2, 2, 5], [2, 3, 6], [2, 4, 7]]) == -1\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [1, 7, 8], [1, 8, 9], [2, 9, 10], [1, 1, 10], [2, 1, 5], [1, 2, 3]]) == -1\n assert candidate(n = 11,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [1, 6, 7], [1, 7, 8], [1, 8, 9], [1, 9, 10], [1, 10, 11], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7], [2, 7, 8], [2, 8, 9], [2, 9, 10], [2, 10, 11]]) == 20\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [1, 1, 3], [2, 3, 5], [1, 5, 7], [2, 7, 9], [1, 2, 4], [2, 4, 6], [1, 6, 8], [2, 8, 10]]) == 8\n assert candidate(n = 7,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [1, 1, 2], [1, 3, 4], [1, 5, 6], [2, 2, 3], [2, 4, 5], [2, 6, 7], [1, 1, 7], [2, 2, 7]]) == 8\n assert candidate(n = 6,edges = [[3, 1, 2], [3, 2, 3], [1, 1, 4], [1, 4, 5], [2, 2, 4], [2, 4, 6], [3, 3, 5], [3, 5, 6], [1, 1, 6], [2, 1, 2]]) == 4\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [1, 1, 4], [1, 4, 7], [1, 7, 10], [2, 2, 5], [2, 5, 8], [2, 8, 10]]) == 6\n assert candidate(n = 11,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [1, 1, 11], [2, 2, 10], [1, 3, 9], [2, 4, 8], [1, 5, 7], [2, 6, 6], [1, 7, 5], [2, 8, 4], [1, 9, 3], [2, 10, 2], [1, 11, 1]]) == 11\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [1, 6, 7], [1, 7, 8], [1, 8, 9], [1, 9, 10], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7], [2, 7, 8], [2, 8, 9], [2, 9, 10]]) == 18\n assert candidate(n = 7,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [1, 1, 6], [2, 6, 7], [1, 5, 7], [3, 2, 7]]) == 1\n assert candidate(n = 8,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [1, 1, 5], [1, 5, 6], [1, 6, 7], [1, 7, 8], [2, 2, 4], [2, 4, 6], [2, 6, 8]]) == -1\n assert candidate(n = 6,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6]]) == 10\n assert candidate(n = 6,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [1, 1, 5], [1, 2, 6], [2, 4, 5], [2, 5, 6], [1, 3, 5], [2, 2, 4]]) == 2\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 1, 3], [1, 3, 5], [2, 5, 6], [2, 6, 7], [2, 7, 8], [2, 8, 9], [2, 9, 10], [2, 5, 7], [2, 7, 9]]) == -1\n assert candidate(n = 9,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [1, 1, 9], [2, 2, 8], [1, 3, 7], [2, 4, 6], [1, 5, 5], [2, 1, 3], [1, 2, 4], [2, 3, 6], [1, 4, 7], [2, 5, 8], [1, 6, 9]]) == 11\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [1, 1, 2], [2, 2, 3], [1, 3, 4], [2, 4, 5], [1, 5, 6], [2, 6, 7], [1, 7, 8], [2, 8, 9], [1, 9, 10], [1, 1, 10]]) == 10\n assert candidate(n = 7,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [1, 1, 4], [2, 2, 5], [1, 2, 3], [2, 3, 4], [1, 3, 6], [2, 4, 7], [1, 5, 6], [2, 5, 7], [1, 6, 7]]) == 9\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [1, 1, 5], [2, 5, 10]]) == 2\n assert candidate(n = 12,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [1, 1, 5], [1, 5, 6], [1, 6, 7], [2, 4, 5], [2, 5, 8], [3, 7, 8], [1, 2, 8], [2, 3, 7], [1, 9, 10], [2, 10, 11], [3, 11, 12], [1, 1, 12], [2, 1, 11]]) == -1\n assert candidate(n = 10,edges = [[3, 1, 2], [3, 2, 3], [1, 1, 3], [1, 2, 4], [1, 1, 2], [2, 3, 4], [3, 4, 5], [1, 5, 6], [2, 6, 7], [1, 7, 8], [2, 8, 9], [1, 9, 10], [2, 10, 1], [3, 1, 10]]) == -1\n assert candidate(n = 8,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [1, 1, 6], [2, 6, 7], [1, 5, 7], [2, 5, 8], [1, 3, 8], [3, 1, 5]]) == -1\n assert candidate(n = 12,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [1, 1, 6], [2, 6, 12], [1, 5, 7], [2, 5, 8], [1, 3, 9], [3, 2, 10]]) == 6\n assert candidate(n = 15,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [3, 12, 13], [3, 13, 14], [3, 14, 15], [1, 1, 6], [2, 6, 12], [1, 5, 7], [2, 5, 8], [1, 3, 9], [3, 2, 10], [1, 4, 11], [2, 7, 13], [3, 8, 14], [1, 9, 15], [2, 10, 14]]) == 11\n assert candidate(n = 7,edges = [[1, 1, 2], [1, 2, 3], [1, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7], [3, 1, 7]]) == -1\n assert candidate(n = 7,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [1, 6, 7], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7]]) == 12\n assert candidate(n = 9,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [1, 6, 7], [1, 7, 8], [1, 8, 9], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7], [2, 7, 8], [2, 8, 9]]) == 16\n assert candidate(n = 9,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [1, 1, 2], [1, 3, 4], [1, 5, 6], [1, 7, 8], [2, 2, 3], [2, 4, 5], [2, 6, 7], [2, 8, 9], [1, 1, 9], [2, 2, 9]]) == 10\n assert candidate(n = 8,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [1, 6, 7], [1, 7, 8], [2, 5, 7], [2, 6, 8], [1, 1, 3], [2, 1, 4]]) == 2\n assert candidate(n = 7,edges = [[1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [1, 6, 7], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7], [3, 1, 4], [3, 2, 5], [3, 3, 6], [3, 4, 7]]) == 8\n assert candidate(n = 8,edges = [[3, 1, 2], [1, 2, 3], [2, 3, 4], [1, 4, 5], [2, 5, 6], [1, 6, 7], [2, 7, 8], [3, 8, 1], [3, 1, 3], [3, 2, 4], [3, 4, 6], [3, 5, 7]]) == 4\n assert candidate(n = 8,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [1, 1, 2], [1, 2, 3], [1, 3, 4], [1, 4, 5], [1, 5, 6], [1, 6, 7], [1, 7, 8], [2, 1, 2], [2, 2, 3], [2, 3, 4], [2, 4, 5], [2, 5, 6], [2, 6, 7], [2, 7, 8]]) == 14\n assert candidate(n = 15,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [3, 12, 13], [3, 13, 14], [3, 14, 15], [1, 1, 5], [2, 5, 9], [1, 9, 13], [2, 13, 15], [1, 2, 3], [2, 4, 6], [1, 6, 7], [2, 8, 10], [1, 10, 11], [2, 12, 14]]) == 10\n assert candidate(n = 12,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [3, 6, 7], [3, 7, 8], [3, 8, 9], [3, 9, 10], [3, 10, 11], [3, 11, 12], [1, 1, 3], [2, 3, 5], [1, 5, 7], [2, 7, 9], [1, 9, 11], [2, 1, 2], [1, 2, 4], [2, 4, 6], [1, 6, 8], [2, 8, 10], [1, 10, 12]]) == 11\n assert candidate(n = 6,edges = [[3, 1, 2], [3, 2, 3], [3, 3, 4], [3, 4, 5], [3, 5, 6], [1, 1, 3], [2, 2, 4], [1, 1, 2], [2, 3, 4], [1, 2, 5], [2, 4, 6]]) == 6\n"}, "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().maxNumEdgesToRemove", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxNumEdgesToRemove(int n, vector>& edges) {", "container": "Solution", "callable": "maxNumEdgesToRemove", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1582, "task_id": "special-positions-in-a-binary-matrix", "difficulty": "Easy", "problem_description": "Given an m x n binary matrix mat, return the number of special positions in mat.\nA position (i, j) is called special if mat[i][j] == 1 and all other elements in row i and column j are 0 (rows and columns are 0-indexed).\n \nExample 1:\n\n\nInput: mat = [[1,0,0],[0,0,1],[1,0,0]]\nOutput: 1\nExplanation: (1, 2) is a special position because mat[1][2] == 1 and all other elements in row 1 and column 2 are 0.\n\nExample 2:\n\n\nInput: mat = [[1,0,0],[0,1,0],[0,0,1]]\nOutput: 3\nExplanation: (0, 0), (1, 1) and (2, 2) are special positions.\n\n \nConstraints:\n\nm == mat.length\nn == mat[i].length\n1 <= m, n <= 100\nmat[i][j] is either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1, 0], [0, 1]]) == 2\n assert candidate(mat = [[1, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 0]]) == 2\n assert candidate(mat = [[1, 0, 0], [0, 0, 1], [1, 0, 0]]) == 1\n assert candidate(mat = [[0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == 3\n assert candidate(mat = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(mat = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) == 3\n assert candidate(mat = [[1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1]]) == 6\n assert candidate(mat = [[1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0]]) == 8\n assert candidate(mat = [[0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0]]) == 8\n assert candidate(mat = [[0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0]]) == 1\n assert candidate(mat = [[1, 0, 1, 0], [0, 0, 0, 0], [1, 0, 1, 0], [0, 0, 0, 0]]) == 0\n assert candidate(mat = [[0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1], [1, 0, 0, 0, 0]]) == 4\n assert candidate(mat = [[1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 0]]) == 4\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0]]) == 7\n assert candidate(mat = [[1, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0]]) == 2\n assert candidate(mat = [[0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 1]]) == 4\n assert candidate(mat = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0]]) == 5\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1]]) == 6\n assert candidate(mat = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 0]]) == 1\n assert candidate(mat = [[0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0]]) == 6\n assert candidate(mat = [[0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0]]) == 3\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0]]) == 8\n assert candidate(mat = [[0, 1, 0, 0], [1, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0]]) == 1\n assert candidate(mat = [[0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0]]) == 6\n assert candidate(mat = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == 0\n assert candidate(mat = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == 5\n assert candidate(mat = [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) == 4\n assert candidate(mat = [[0, 0, 1, 0, 0], [0, 0, 0, 0, 1], [1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0]]) == 5\n assert candidate(mat = [[0, 1, 0, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 1, 0]]) == 4\n assert candidate(mat = [[0, 0, 0, 0, 1], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 0], [0, 1, 0, 0, 0]]) == 4\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0]]) == 6\n assert candidate(mat = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0]]) == 5\n assert candidate(mat = [[0, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0]]) == 6\n assert candidate(mat = [[1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0]]) == 6\n assert candidate(mat = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == 4\n assert candidate(mat = [[1, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == 5\n assert candidate(mat = [[0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [1, 0, 0, 0, 1], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0]]) == 2\n assert candidate(mat = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0]]) == 4\n assert candidate(mat = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0]]) == 10\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 0\n assert candidate(mat = [[1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1]]) == 7\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0]]) == 6\n assert candidate(mat = [[1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1]]) == 6\n assert candidate(mat = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == 4\n assert candidate(mat = [[0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0]]) == 0\n assert candidate(mat = [[0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1]]) == 6\n assert candidate(mat = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0]]) == 5\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0]]) == 7\n assert candidate(mat = [[1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 1, 0, 0]]) == 6\n assert candidate(mat = [[1, 1, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0]]) == 3\n assert candidate(mat = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]]) == 1\n assert candidate(mat = [[1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 1, 0, 0, 0]]) == 7\n assert candidate(mat = [[0, 1, 0, 0, 0], [0, 0, 0, 1, 0], [1, 0, 0, 0, 1], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == 3\n assert candidate(mat = [[0, 0, 1, 0], [0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) == 3\n assert candidate(mat = [[1, 1, 0, 0], [0, 0, 0, 0], [1, 0, 1, 0], [0, 0, 0, 1]]) == 1\n assert candidate(mat = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1]]) == 2\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0]]) == 6\n assert candidate(mat = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 1], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 1, 0, 0, 0]]) == 5\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0]]) == 6\n assert candidate(mat = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == 0\n assert candidate(mat = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1]]) == 6\n assert candidate(mat = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0]]) == 2\n assert candidate(mat = [[0, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 0, 0, 1]]) == 3\n assert candidate(mat = [[1, 0, 1, 0, 0], [0, 0, 0, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 0, 0], [0, 0, 1, 1, 0]]) == 1\n assert candidate(mat = [[0, 1, 1], [0, 0, 0], [1, 0, 0]]) == 1\n assert candidate(mat = [[1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1], [1, 1, 0, 0]]) == 0\n assert candidate(mat = [[0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1], [1, 0, 0, 0]]) == 4\n assert candidate(mat = [[0, 0, 0, 0, 1], [0, 0, 1, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 1, 0]]) == 4\n assert candidate(mat = [[1, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 1], [0, 1, 0, 0, 0], [0, 0, 0, 1, 0]]) == 5\n assert candidate(mat = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 0], [1, 0, 0, 0, 0, 0]]) == 5\n"}, "metadata": {"canonical_parameter_names": ["mat"], "leetcode_dataset_entry_point": "Solution().numSpecial", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numSpecial(vector>& mat) {", "container": "Solution", "callable": "numSpecial", "parameters": [{"name": "mat", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1583, "task_id": "count-unhappy-friends", "difficulty": "Medium", "problem_description": "You are given a list of preferences for n friends, where n is always even.\nFor each person i, preferences[i] contains a list of friends sorted in the order of preference. In other words, a friend earlier in the list is more preferred than a friend later in the list. Friends in each list are denoted by integers from 0 to n-1.\nAll the friends are divided into pairs. The pairings are given in a list pairs, where pairs[i] = [xi, yi] denotes xi is paired with yi and yi is paired with xi.\nHowever, this pairing may cause some of the friends to be unhappy. A friend x is unhappy if x is paired with y and there exists a friend u who is paired with v but:\n\nx prefers u over y, and\nu prefers x over v.\n\nReturn the number of unhappy friends.\n \nExample 1:\n\nInput: n = 4, preferences = [[1, 2, 3], [3, 2, 0], [3, 1, 0], [1, 2, 0]], pairs = [[0, 1], [2, 3]]\nOutput: 2\nExplanation:\nFriend 1 is unhappy because:\n- 1 is paired with 0 but prefers 3 over 0, and\n- 3 prefers 1 over 2.\nFriend 3 is unhappy because:\n- 3 is paired with 2 but prefers 1 over 2, and\n- 1 prefers 3 over 0.\nFriends 0 and 2 are happy.\n\nExample 2:\n\nInput: n = 2, preferences = [[1], [0]], pairs = [[1, 0]]\nOutput: 0\nExplanation: Both friends 0 and 1 are happy.\n\nExample 3:\n\nInput: n = 4, preferences = [[1, 3, 2], [2, 3, 0], [1, 3, 0], [0, 2, 1]], pairs = [[1, 3], [0, 2]]\nOutput: 4\n\n \nConstraints:\n\n2 <= n <= 500\nn is even.\npreferences.length == n\npreferences[i].length == n - 1\n0 <= preferences[i][j] <= n - 1\npreferences[i] does not contain i.\nAll values in preferences[i] are unique.\npairs.length == n/2\npairs[i].length == 2\nxi != yi\n0 <= xi, yi <= n - 1\nEach person is contained in exactly one pair.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,preferences = [[1, 3, 2], [2, 3, 0], [1, 3, 0], [0, 2, 1]],pairs = [[1, 3], [0, 2]]) == 4\n assert candidate(n = 8,preferences = [[7, 6, 5, 4, 3, 2, 1, 0], [7, 6, 5, 4, 3, 2, 1, 0], [7, 6, 5, 4, 3, 2, 1, 0], [7, 6, 5, 4, 3, 2, 1, 0], [7, 6, 5, 4, 3, 2, 1, 0], [7, 6, 5, 4, 3, 2, 1, 0], [7, 6, 5, 4, 3, 2, 1, 0], [7, 6, 5, 4, 3, 2, 1, 0]],pairs = [[0, 7], [1, 6], [2, 5], [3, 4]]) == 7\n assert candidate(n = 8,preferences = [[3, 2, 5, 4, 7, 6, 0, 1], [6, 7, 0, 1, 5, 4, 2, 3], [4, 5, 6, 7, 1, 0, 2, 3], [5, 4, 3, 2, 7, 6, 1, 0], [2, 3, 0, 1, 6, 7, 4, 5], [3, 2, 1, 0, 6, 7, 4, 5], [7, 6, 5, 4, 1, 0, 2, 3], [6, 7, 4, 5, 2, 3, 0, 1]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7]]) == 5\n assert candidate(n = 6,preferences = [[1, 3, 5, 2, 4, 0], [0, 2, 4, 1, 3, 5], [1, 0, 3, 4, 5, 2], [2, 5, 4, 0, 3, 1], [5, 0, 1, 3, 2, 4], [3, 1, 4, 0, 2, 5]],pairs = [[1, 3], [2, 4], [0, 5]]) == 6\n assert candidate(n = 4,preferences = [[1, 2, 3], [3, 2, 0], [3, 1, 0], [1, 2, 0]],pairs = [[0, 1], [2, 3]]) == 2\n assert candidate(n = 2,preferences = [[1], [0]],pairs = [[1, 0]]) == 0\n assert candidate(n = 14,preferences = [[13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 2, 4, 6, 8, 10, 12, 1, 3, 5, 7, 9, 11, 13], [1, 3, 5, 7, 9, 11, 13, 0, 2, 4, 6, 8, 10, 12], [2, 4, 6, 8, 10, 12, 0, 1, 3, 5, 7, 9, 11, 13], [3, 5, 7, 9, 11, 13, 1, 2, 4, 6, 8, 10, 12, 0], [4, 6, 8, 10, 12, 0, 1, 2, 3, 5, 7, 9, 11, 13], [5, 7, 9, 11, 13, 1, 2, 3, 4, 6, 8, 10, 12, 0], [6, 8, 10, 12, 0, 1, 2, 3, 4, 5, 7, 9, 11, 13], [7, 9, 11, 13, 1, 2, 3, 4, 5, 6, 8, 10, 12, 0], [8, 10, 12, 0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13], [9, 11, 13, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 0], [10, 12, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 13], [11, 13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 0], [12, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 13]],pairs = [[0, 13], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7]]) == 12\n assert candidate(n = 10,preferences = [[1, 9, 7, 8, 4, 3, 6, 5, 2, 0], [0, 7, 8, 9, 3, 4, 6, 5, 2, 1], [9, 8, 1, 0, 5, 6, 7, 4, 3, 2], [6, 4, 5, 0, 1, 2, 3, 7, 8, 9], [7, 6, 0, 1, 2, 3, 4, 8, 9, 5], [1, 0, 2, 3, 4, 5, 6, 7, 8, 9], [2, 3, 0, 1, 4, 5, 6, 7, 8, 9], [3, 2, 0, 1, 4, 5, 6, 7, 8, 9], [4, 3, 0, 1, 2, 5, 6, 7, 8, 9], [5, 4, 0, 1, 2, 3, 6, 7, 8, 9]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 8\n assert candidate(n = 12,preferences = [[11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 11], [1, 3, 5, 7, 9, 11, 0, 2, 4, 6, 8, 10], [2, 4, 6, 8, 10, 0, 1, 3, 5, 7, 9, 11], [3, 5, 7, 9, 11, 1, 2, 4, 6, 8, 10, 0], [4, 6, 8, 10, 0, 2, 3, 5, 7, 9, 11, 1], [5, 7, 9, 11, 1, 3, 4, 6, 8, 10, 0, 2], [6, 8, 10, 0, 2, 4, 5, 7, 9, 11, 1, 3], [7, 9, 11, 1, 3, 5, 6, 8, 10, 0, 2, 4], [8, 10, 0, 2, 4, 6, 7, 9, 11, 1, 3, 5], [9, 11, 1, 3, 5, 7, 8, 10, 0, 2, 4, 6], [10, 0, 2, 4, 6, 8, 9, 11, 1, 3, 5, 7]],pairs = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 10\n assert candidate(n = 10,preferences = [[1, 3, 5, 7, 9, 2, 4, 6, 8, 0], [0, 2, 4, 6, 8, 1, 3, 5, 7, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 2, 4, 6, 8, 1, 3, 5, 7, 9], [1, 3, 5, 7, 9, 2, 4, 6, 8, 0], [0, 2, 4, 6, 8, 1, 3, 5, 7, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 2, 4, 6, 8, 1, 3, 5, 7, 9], [1, 3, 5, 7, 9, 2, 4, 6, 8, 0], [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 5\n assert candidate(n = 6,preferences = [[5, 4, 2, 3, 0, 1], [4, 5, 1, 0, 3, 2], [2, 4, 5, 0, 1, 3], [3, 2, 0, 5, 4, 1], [0, 1, 2, 3, 4, 5], [1, 0, 3, 2, 5, 4]],pairs = [[0, 1], [2, 3], [4, 5]]) == 6\n assert candidate(n = 6,preferences = [[5, 4, 3, 2, 1, 0], [0, 1, 2, 3, 4, 5], [1, 0, 3, 2, 5, 4], [4, 5, 2, 3, 0, 1], [2, 3, 0, 1, 4, 5], [5, 4, 1, 0, 3, 2]],pairs = [[0, 1], [2, 3], [4, 5]]) == 5\n assert candidate(n = 6,preferences = [[2, 3, 5, 1, 4, 0], [3, 5, 1, 4, 0, 2], [5, 1, 4, 0, 2, 3], [1, 4, 0, 2, 3, 5], [4, 0, 2, 3, 5, 1], [0, 2, 3, 5, 1, 4]],pairs = [[0, 3], [1, 4], [2, 5]]) == 3\n assert candidate(n = 14,preferences = [[2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13]]) == 7\n assert candidate(n = 8,preferences = [[1, 4, 7, 2, 5, 0, 6, 3], [4, 7, 2, 5, 0, 6, 3, 1], [2, 5, 0, 6, 3, 1, 4, 7], [5, 0, 6, 3, 1, 4, 7, 2], [0, 6, 3, 1, 4, 7, 2, 5], [6, 3, 1, 4, 7, 2, 5, 0], [3, 1, 4, 7, 2, 5, 0, 6], [1, 4, 7, 2, 5, 0, 6, 3]],pairs = [[0, 2], [1, 3], [4, 6], [5, 7]]) == 8\n assert candidate(n = 6,preferences = [[4, 5, 1, 0, 2, 3], [1, 3, 0, 2, 5, 4], [2, 0, 3, 1, 4, 5], [3, 4, 1, 0, 5, 2], [5, 3, 0, 1, 4, 2], [4, 1, 3, 2, 5, 0]],pairs = [[0, 3], [1, 4], [2, 5]]) == 6\n assert candidate(n = 10,preferences = [[3, 5, 2, 7, 6, 4, 1, 9, 8, 0], [2, 4, 6, 1, 0, 3, 5, 9, 8, 7], [5, 3, 7, 2, 8, 1, 0, 6, 9, 4], [7, 8, 4, 5, 3, 9, 2, 0, 6, 1], [9, 4, 5, 7, 8, 0, 3, 1, 2, 6], [6, 0, 8, 9, 4, 2, 5, 3, 1, 7], [8, 6, 4, 3, 1, 5, 9, 2, 7, 0], [4, 7, 2, 1, 8, 0, 5, 9, 3, 6], [0, 8, 1, 6, 7, 9, 4, 2, 5, 3], [1, 9, 6, 5, 3, 2, 4, 8, 0, 7]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 9\n assert candidate(n = 10,preferences = [[9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [8, 9, 7, 6, 5, 4, 3, 2, 1, 0], [7, 8, 9, 6, 5, 4, 3, 2, 1, 0], [6, 7, 8, 9, 5, 4, 3, 2, 1, 0], [5, 6, 7, 8, 9, 4, 3, 2, 1, 0], [4, 5, 6, 7, 8, 9, 3, 2, 1, 0], [3, 4, 5, 6, 7, 8, 9, 2, 1, 0], [2, 3, 4, 5, 6, 7, 8, 9, 1, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 8\n assert candidate(n = 10,preferences = [[7, 6, 5, 4, 3, 2, 1, 0, 9, 8], [6, 7, 0, 1, 2, 3, 4, 5, 8, 9], [5, 6, 7, 0, 1, 2, 3, 4, 9, 8], [4, 5, 6, 7, 0, 1, 2, 3, 8, 9], [3, 4, 5, 6, 7, 0, 1, 2, 9, 8], [2, 3, 4, 5, 6, 7, 0, 1, 8, 9], [1, 2, 3, 4, 5, 6, 7, 0, 9, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 0, 1, 2, 3, 4, 5, 6, 7], [8, 9, 0, 1, 2, 3, 4, 5, 6, 7]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 8\n assert candidate(n = 12,preferences = [[1, 5, 9, 2, 6, 10, 3, 7, 11, 4, 8, 0], [0, 5, 9, 2, 6, 10, 3, 7, 11, 4, 8, 1], [1, 0, 5, 9, 2, 6, 10, 3, 7, 11, 4, 8], [0, 1, 5, 9, 2, 6, 10, 3, 7, 11, 4, 8], [5, 9, 2, 6, 10, 3, 7, 11, 4, 8, 0, 1], [9, 2, 6, 10, 3, 7, 11, 4, 8, 0, 1, 5], [2, 6, 10, 3, 7, 11, 4, 8, 0, 1, 5, 9], [6, 10, 3, 7, 11, 4, 8, 0, 1, 5, 9, 2], [3, 7, 11, 4, 8, 0, 1, 5, 9, 2, 6, 10], [7, 11, 4, 8, 0, 1, 5, 9, 2, 6, 10, 3], [4, 8, 0, 1, 5, 9, 2, 6, 10, 3, 7, 11], [8, 0, 1, 5, 9, 2, 6, 10, 3, 7, 11, 4]],pairs = [[0, 4], [1, 5], [2, 6], [3, 7], [8, 11], [9, 10]]) == 8\n assert candidate(n = 12,preferences = [[5, 6, 7, 8, 9, 10, 11, 3, 2, 1, 0, 4], [6, 7, 8, 9, 10, 11, 0, 4, 3, 2, 1, 5], [7, 8, 9, 10, 11, 1, 0, 4, 3, 2, 5, 6], [8, 9, 10, 11, 2, 1, 0, 4, 3, 5, 6, 7], [9, 10, 11, 3, 2, 1, 0, 4, 5, 6, 7, 8], [10, 11, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [11, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1], [3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2], [4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2, 3]],pairs = [[0, 2], [1, 3], [4, 6], [5, 7], [8, 10], [9, 11]]) == 12\n assert candidate(n = 12,preferences = [[11, 9, 5, 7, 3, 1, 4, 6, 8, 10, 0, 2], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [1, 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [2, 1, 0, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 2, 1, 0, 4, 5, 6, 7, 8, 9, 10, 11], [4, 3, 2, 1, 0, 5, 6, 7, 8, 9, 10, 11], [5, 4, 3, 2, 1, 0, 6, 7, 8, 9, 10, 11], [6, 5, 4, 3, 2, 1, 0, 7, 8, 9, 10, 11], [7, 6, 5, 4, 3, 2, 1, 0, 8, 9, 10, 11], [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 10, 11], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 11], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11]],pairs = [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [10, 11]]) == 9\n assert candidate(n = 8,preferences = [[5, 6, 7, 4, 3, 2, 1, 0], [6, 5, 7, 4, 3, 2, 1, 0], [7, 5, 6, 4, 3, 2, 1, 0], [0, 5, 6, 7, 3, 2, 1, 4], [1, 5, 6, 7, 4, 3, 2, 0], [2, 0, 6, 7, 4, 3, 1, 5], [3, 0, 1, 7, 4, 6, 2, 5], [4, 0, 1, 2, 3, 6, 7, 5]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7]]) == 8\n assert candidate(n = 10,preferences = [[3, 9, 4, 5, 6, 7, 8, 1, 0, 2], [8, 7, 6, 5, 4, 3, 2, 1, 0, 9], [5, 4, 3, 2, 1, 0, 9, 8, 7, 6], [4, 5, 6, 7, 8, 9, 0, 1, 2, 3], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [2, 1, 0, 9, 8, 7, 6, 5, 4, 3], [6, 7, 8, 9, 0, 1, 2, 3, 4, 5], [7, 6, 5, 4, 3, 2, 1, 0, 9, 8], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 9\n assert candidate(n = 6,preferences = [[1, 2, 3, 4, 5], [0, 3, 2, 5, 4], [1, 4, 0, 5, 3], [0, 5, 2, 4, 1], [1, 2, 0, 3, 5], [0, 1, 2, 3, 4]],pairs = [[0, 1], [2, 3], [4, 5]]) == 4\n assert candidate(n = 10,preferences = [[9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [8, 7, 6, 5, 4, 3, 2, 1, 0, 9], [7, 6, 5, 4, 3, 2, 1, 0, 9, 8], [6, 5, 4, 3, 2, 1, 0, 9, 8, 7], [5, 4, 3, 2, 1, 0, 9, 8, 7, 6], [4, 3, 2, 1, 0, 9, 8, 7, 6, 5], [3, 2, 1, 0, 9, 8, 7, 6, 5, 4], [2, 1, 0, 9, 8, 7, 6, 5, 4, 3], [1, 0, 9, 8, 7, 6, 5, 4, 3, 2], [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 8\n assert candidate(n = 6,preferences = [[1, 3, 5, 0, 4, 2], [2, 5, 4, 1, 0, 3], [4, 0, 5, 2, 3, 1], [5, 1, 4, 3, 0, 2], [0, 3, 2, 5, 1, 4], [3, 0, 1, 4, 2, 5]],pairs = [[0, 1], [2, 3], [4, 5]]) == 5\n assert candidate(n = 6,preferences = [[1, 3, 4, 0, 5, 2], [3, 4, 5, 1, 0, 2], [4, 5, 3, 2, 1, 0], [5, 4, 3, 2, 0, 1], [4, 3, 2, 1, 5, 0], [5, 4, 3, 2, 1, 0]],pairs = [[0, 2], [1, 4], [3, 5]]) == 4\n assert candidate(n = 10,preferences = [[9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [0, 2, 4, 6, 8, 1, 3, 5, 7, 9], [1, 3, 5, 7, 9, 0, 2, 4, 6, 8], [2, 4, 6, 8, 0, 1, 3, 5, 7, 9], [3, 5, 7, 9, 1, 2, 4, 6, 8, 0], [4, 6, 8, 0, 2, 3, 5, 7, 9, 1], [5, 7, 9, 1, 3, 4, 6, 8, 0, 2], [6, 8, 0, 2, 4, 5, 7, 9, 1, 3], [7, 9, 1, 3, 5, 6, 8, 0, 2, 4], [8, 0, 2, 4, 6, 7, 9, 1, 3, 5]],pairs = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 8\n assert candidate(n = 10,preferences = [[9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [8, 9, 7, 6, 5, 4, 3, 2, 1, 0], [7, 6, 9, 8, 5, 4, 3, 2, 1, 0], [6, 7, 8, 9, 5, 4, 3, 2, 1, 0], [5, 4, 3, 2, 9, 8, 7, 6, 1, 0], [4, 5, 3, 2, 8, 9, 7, 6, 1, 0], [3, 2, 1, 0, 9, 8, 7, 6, 5, 4], [2, 3, 1, 0, 8, 9, 7, 6, 5, 4], [1, 0, 2, 3, 8, 9, 7, 6, 5, 4], [0, 1, 2, 3, 9, 8, 7, 6, 5, 4]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 8\n assert candidate(n = 6,preferences = [[1, 2, 3, 4, 5], [0, 2, 3, 4, 1], [1, 0, 3, 5, 4], [2, 1, 0, 5, 4], [1, 2, 3, 0, 5], [0, 1, 2, 4, 3]],pairs = [[0, 5], [1, 2], [3, 4]]) == 3\n assert candidate(n = 10,preferences = [[1, 3, 5, 7, 9, 2, 4, 6, 8, 0], [0, 2, 4, 6, 8, 1, 3, 5, 7, 9], [9, 7, 5, 3, 1, 8, 6, 4, 2, 0], [8, 6, 4, 2, 0, 9, 7, 5, 3, 1], [7, 5, 3, 1, 9, 0, 8, 6, 4, 2], [6, 4, 2, 0, 8, 1, 9, 7, 5, 3], [5, 3, 1, 9, 7, 2, 0, 8, 6, 4], [4, 2, 0, 8, 6, 3, 1, 9, 7, 5], [3, 1, 9, 7, 5, 4, 2, 0, 8, 6], [2, 0, 8, 6, 4, 5, 3, 1, 9, 7]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 8\n assert candidate(n = 20,preferences = [[19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [18, 19, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [17, 16, 19, 18, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [16, 17, 18, 19, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [15, 14, 13, 12, 19, 18, 17, 16, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [14, 15, 13, 12, 18, 19, 17, 16, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [13, 12, 11, 10, 9, 8, 7, 6, 19, 18, 17, 16, 15, 14, 5, 4, 3, 2, 1, 0], [12, 13, 11, 10, 8, 9, 7, 6, 18, 19, 17, 16, 15, 14, 5, 4, 3, 2, 1, 0], [11, 10, 12, 13, 7, 8, 9, 6, 17, 16, 19, 18, 15, 14, 5, 4, 3, 2, 1, 0], [10, 11, 12, 13, 6, 7, 8, 9, 16, 17, 18, 19, 15, 14, 5, 4, 3, 2, 1, 0], [9, 8, 7, 6, 5, 4, 3, 2, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 1, 0], [8, 9, 7, 6, 4, 5, 3, 2, 18, 19, 17, 16, 15, 14, 13, 12, 11, 10, 1, 0], [7, 6, 8, 9, 3, 4, 5, 2, 17, 16, 19, 18, 15, 14, 13, 12, 11, 10, 1, 0], [6, 7, 8, 9, 2, 3, 4, 5, 16, 17, 18, 19, 15, 14, 13, 12, 11, 10, 1, 0], [5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10], [4, 5, 3, 2, 0, 1, 8, 9, 7, 6, 18, 19, 17, 16, 15, 14, 13, 12, 11, 10], [3, 2, 1, 0, 5, 4, 7, 6, 9, 8, 17, 16, 19, 18, 15, 14, 13, 12, 11, 10], [2, 3, 1, 0, 4, 5, 6, 7, 8, 9, 16, 17, 18, 19, 15, 14, 13, 12, 11, 10], [1, 0, 2, 3, 3, 4, 5, 6, 7, 8, 9, 16, 17, 18, 19, 15, 14, 13, 12, 11], [0, 1, 2, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10, 16, 17, 18, 19, 15, 14, 13], [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19]]) == 20\n assert candidate(n = 6,preferences = [[5, 1, 3, 2, 4], [4, 3, 5, 1, 2], [1, 4, 5, 3, 2], [5, 4, 2, 1, 3], [2, 1, 3, 4, 5], [1, 3, 4, 2, 0]],pairs = [[0, 5], [1, 4], [2, 3]]) == 4\n assert candidate(n = 10,preferences = [[5, 3, 8, 2, 7, 6, 9, 0, 1, 4], [9, 4, 2, 5, 8, 6, 3, 7, 1, 0], [4, 5, 6, 7, 8, 9, 0, 1, 2, 3], [7, 6, 5, 4, 3, 2, 1, 0, 8, 9], [1, 0, 3, 4, 2, 5, 6, 7, 8, 9], [2, 0, 1, 4, 3, 5, 6, 7, 8, 9], [6, 5, 4, 3, 2, 1, 0, 7, 8, 9], [3, 2, 1, 0, 4, 5, 6, 7, 8, 9], [8, 9, 0, 1, 2, 3, 4, 5, 6, 7], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]],pairs = [[0, 4], [1, 5], [2, 6], [3, 7], [8, 9]]) == 8\n assert candidate(n = 8,preferences = [[7, 6, 5, 4, 3, 2, 1, 0], [6, 7, 0, 1, 2, 3, 4, 5], [5, 4, 3, 2, 1, 0, 7, 6], [4, 5, 6, 7, 0, 1, 2, 3], [3, 2, 1, 0, 7, 6, 5, 4], [2, 3, 0, 1, 6, 7, 4, 5], [1, 0, 7, 6, 5, 4, 3, 2], [0, 1, 2, 3, 4, 5, 6, 7]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7]]) == 8\n assert candidate(n = 12,preferences = [[11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [10, 11, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [9, 10, 11, 8, 7, 6, 5, 4, 3, 2, 1, 0], [8, 9, 10, 11, 7, 6, 5, 4, 3, 2, 1, 0], [7, 8, 9, 10, 11, 6, 5, 4, 3, 2, 1, 0], [6, 7, 8, 9, 10, 11, 5, 4, 3, 2, 1, 0], [5, 6, 7, 8, 9, 10, 11, 4, 3, 2, 1, 0], [4, 5, 6, 7, 8, 9, 10, 11, 3, 2, 1, 0], [3, 4, 5, 6, 7, 8, 9, 10, 11, 2, 1, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]],pairs = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11]]) == 12\n"}, "metadata": {"canonical_parameter_names": ["n", "preferences", "pairs"], "leetcode_dataset_entry_point": "Solution().unhappyFriends", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int unhappyFriends(int n, vector>& preferences, vector>& pairs) {", "container": "Solution", "callable": "unhappyFriends", "parameters": [{"name": "n", "type": "int"}, {"name": "preferences", "type": "vector>&"}, {"name": "pairs", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1584, "task_id": "min-cost-to-connect-all-points", "difficulty": "Medium", "problem_description": "You are given an array points representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi].\nThe cost of connecting two points [xi, yi] and [xj, yj] is the manhattan distance between them: |xi - xj| + |yi - yj|, where |val| denotes the absolute value of val.\nReturn the minimum cost to make all points connected. All points are connected if there is exactly one simple path between any two points.\n \nExample 1:\n\n\nInput: points = [[0,0],[2,2],[3,10],[5,2],[7,0]]\nOutput: 20\nExplanation: \n\nWe can connect the points as shown above to get the minimum cost of 20.\nNotice that there is a unique path between every pair of points.\n\nExample 2:\n\nInput: points = [[3,12],[-2,5],[-4,1]]\nOutput: 18\n\n \nConstraints:\n\n1 <= points.length <= 1000\n-106 <= xi, yi <= 106\nAll pairs (xi, yi) are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[0, 0], [2, 2], [4, 4], [6, 6], [8, 8]]) == 16\n assert candidate(points = [[1, 1], [0, 0], [2, 2], [3, 3], [4, 4]]) == 8\n assert candidate(points = [[-1000000, 1000000], [1000000, -1000000], [0, 0]]) == 4000000\n assert candidate(points = [[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3]]) == 8\n assert candidate(points = [[0, 0], [1, 1], [1, 0], [-1, 1]]) == 4\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 10\n assert candidate(points = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25]]) == 40\n assert candidate(points = [[-1000000, -1000000], [1000000, 1000000]]) == 4000000\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == 8\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4]]) == 6\n assert candidate(points = [[-1, -1], [-2, -2], [-3, -3], [-4, -4]]) == 6\n assert candidate(points = [[-1, 0], [0, 1], [1, 0], [0, -1]]) == 6\n assert candidate(points = [[3, 12], [-2, 5], [-4, 1]]) == 18\n assert candidate(points = [[1000000, -1000000], [-1000000, 1000000], [0, 0]]) == 4000000\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1]]) == 3\n assert candidate(points = [[0, 0], [1, 1], [1, 0], [0, 1]]) == 3\n assert candidate(points = [[0, 0], [2, 2], [3, 10], [5, 2], [7, 0]]) == 20\n assert candidate(points = [[1, 1], [2, 2], [3, 3]]) == 4\n assert candidate(points = [[0, 0], [1, 1], [1, 0], [0, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 19\n assert candidate(points = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000]]) == 1600\n assert candidate(points = [[0, 0], [0, 1000000], [1000000, 0], [1000000, 1000000], [500000, 500000], [250000, 750000], [750000, 250000], [100000, 100000], [900000, 900000], [100000, 900000], [900000, 100000]]) == 4000000\n assert candidate(points = [[1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [3, 4], [4, 3], [4, 4], [5, 5], [5, 6], [6, 5], [6, 6], [7, 7], [7, 8], [8, 7], [8, 8], [9, 9], [9, 10], [10, 9], [10, 10]]) == 23\n assert candidate(points = [[-1, 0], [0, -1], [1, 0], [0, 1], [-2, 0], [0, -2], [2, 0], [0, 2], [-3, 0], [0, -3], [3, 0], [0, 3], [-4, 0], [0, -4], [4, 0], [0, 4]]) == 18\n assert candidate(points = [[0, 0], [10, 0], [0, 10], [10, 10], [20, 0], [20, 10], [30, 0], [30, 10], [40, 0], [40, 10]]) == 90\n assert candidate(points = [[-5, 5], [0, 0], [5, -5], [10, 10], [-10, -10], [15, 15], [-15, -15]]) == 80\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1], [3, 0], [3, 1], [4, 0], [4, 1], [5, 0], [5, 1], [6, 0], [6, 1], [7, 0], [7, 1], [8, 0], [8, 1], [9, 0], [9, 1]]) == 19\n assert candidate(points = [[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]]) == 18\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 18\n assert candidate(points = [[1, 1], [2, 3], [4, 5], [8, 10], [15, 20], [25, 30], [40, 50]]) == 88\n assert candidate(points = [[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [0, 0]]) == 20\n assert candidate(points = [[1000000, 1000000], [-1000000, -1000000], [0, 0], [500000, 500000], [-500000, -500000]]) == 4000000\n assert candidate(points = [[-50, -100], [-150, -200], [-250, -300], [-350, -400], [-450, -500], [-550, -600], [-650, -700], [-750, -800], [-850, -900], [-950, -1000]]) == 1800\n assert candidate(points = [[1000000, -1000000], [0, 0], [-1000000, 1000000], [500000, 500000], [-500000, -500000]]) == 6000000\n assert candidate(points = [[0, 0], [1, 0], [0, 1], [1, 1], [-1, 0], [0, -1], [-1, -1], [-1, 1], [1, -1], [2, 0], [0, 2], [-2, 0], [0, -2], [-2, -1], [-1, -2], [-2, 1], [1, -2]]) == 16\n assert candidate(points = [[10, 10], [20, 10], [20, 20], [10, 20], [15, 15], [5, 5], [25, 25], [10, 5], [10, 15], [5, 10]]) == 60\n assert candidate(points = [[1, 2], [4, 6], [5, 7], [8, 9], [11, 10], [10, 11], [3, 5], [2, 3], [6, 8], [9, 4]]) == 26\n assert candidate(points = [[-1000000, 1000000], [1000000, -1000000], [0, 0], [-500000, 500000], [500000, -500000]]) == 4000000\n assert candidate(points = [[1, 1000000], [1000000, 1], [1, 2], [2, 1], [1000000, 2], [2, 1000000], [1000000, 1000000]]) == 2999998\n assert candidate(points = [[1, 2], [4, 8], [1, 7], [6, 1], [9, 7], [7, 4], [9, 1], [7, 9], [9, 2], [7, 6]]) == 29\n assert candidate(points = [[-500000, -500000], [0, 0], [500000, 500000], [1000000, 1000000], [1500000, 1500000]]) == 4000000\n assert candidate(points = [[-5, -5], [-4, -4], [-3, -3], [-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 20\n assert candidate(points = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10]]) == 90\n assert candidate(points = [[1, 2], [4, 6], [5, 7], [8, 4], [2, 1], [5, 5], [7, 8], [8, 9], [1, 4], [2, 8], [7, 1], [9, 5]]) == 32\n assert candidate(points = [[-1, -2], [-3, -4], [-5, -6], [-7, -8], [-9, -10], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == 38\n assert candidate(points = [[-3, -3], [-2, -2], [-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14]]) == 34\n assert candidate(points = [[1, 1], [2, 3], [3, 1], [4, 3], [5, 1], [6, 3], [7, 1], [8, 3], [9, 1], [10, 3]]) == 19\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 0], [2, 1], [3, 0], [3, 1], [4, 0], [4, 1]]) == 9\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [150, 250], [250, 150], [350, 450], [450, 350], [550, 450]]) == 1300\n assert candidate(points = [[0, 0], [1, 1], [1, 0], [0, 1], [2, 2], [2, 0], [0, 2], [1, 2], [2, 1], [0, 3], [3, 0], [3, 3]]) == 12\n assert candidate(points = [[1, 2], [4, 8], [5, 0], [7, 3], [8, 9], [9, 6], [9, 7], [10, 4], [10, 8], [11, 2]]) == 32\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1], [0, 2], [1, 2], [2, 0], [2, 1], [2, 2], [3, 0], [3, 1], [3, 2]]) == 11\n assert candidate(points = [[100, 200], [300, 400], [500, 600], [700, 800], [900, 1000], [1100, 1200], [1300, 1400], [1500, 1600]]) == 2800\n assert candidate(points = [[1, 1], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6], [8, 9], [9, 8], [10, 10]]) == 26\n assert candidate(points = [[10, 10], [20, 10], [20, 20], [10, 20], [30, 10], [30, 20], [40, 10], [40, 20], [15, 15], [25, 15], [35, 15], [15, 25], [25, 25], [35, 25]]) == 130\n assert candidate(points = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0], [11, 0], [12, 0], [13, 0], [14, 0]]) == 14\n assert candidate(points = [[-1, -1], [1, 1], [0, 0], [2, 2], [-2, -2], [3, 3], [-3, -3], [4, 4], [-4, -4], [5, 5], [-5, -5], [6, 6], [-6, -6]]) == 24\n assert candidate(points = [[-100, 0], [0, 100], [100, 0], [0, -100], [50, 50], [-50, -50], [50, -50], [-50, 50], [0, 0], [0, 0]]) == 800\n assert candidate(points = [[0, 0], [1, 2], [2, 4], [4, 8], [8, 16], [16, 32], [32, 64], [64, 128], [128, 256], [256, 512]]) == 768\n assert candidate(points = [[0, 0], [1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20], [11, 22], [12, 24], [13, 26], [14, 28]]) == 42\n assert candidate(points = [[500000, 500000], [400000, 400000], [300000, 300000], [200000, 200000], [100000, 100000], [0, 0], [-100000, -100000], [-200000, -200000], [-300000, -300000], [-400000, -400000], [-500000, -500000]]) == 2000000\n assert candidate(points = [[0, 0], [1, 2], [3, 1], [2, 3], [4, 5], [6, 4], [5, 6], [7, 8], [9, 7], [8, 9], [10, 10], [12, 11], [11, 12], [13, 14], [15, 13], [14, 15], [16, 16], [18, 17], [17, 18], [19, 19]]) == 54\n assert candidate(points = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100], [110, 120], [130, 140], [150, 160], [170, 180], [190, 200]]) == 360\n assert candidate(points = [[-1, -1], [0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 20\n assert candidate(points = [[1000000, 0], [0, 1000000], [500000, 500000], [250000, 750000], [750000, 250000]]) == 2000000\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 21\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 36\n assert candidate(points = [[1000000, 1000000], [1000001, 1000001], [1000002, 1000002], [1000003, 1000003], [1000004, 1000004]]) == 8\n assert candidate(points = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000], [1000, 1100]]) == 1800\n assert candidate(points = [[0, 0], [1000000, 1000000], [500000, 500000], [250000, 250000], [750000, 750000], [125000, 125000], [875000, 875000], [312500, 312500], [687500, 687500], [437500, 437500]]) == 2000000\n assert candidate(points = [[-200000, 200000], [-400000, 400000], [-600000, 600000], [-800000, 800000], [-1000000, 1000000], [200000, -200000], [400000, -400000], [600000, -600000], [800000, -800000], [1000000, -1000000]]) == 4000000\n assert candidate(points = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9], [11, 12], [12, 11]]) == 32\n assert candidate(points = [[0, 0], [1, 1], [1, 0], [0, 1], [2, 2], [2, 0], [0, 2]]) == 7\n assert candidate(points = [[0, 0], [0, 1000000], [1000000, 0], [1000000, 1000000], [500000, 500000]]) == 4000000\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 1], [9, 2], [10, 3]]) == 42\n assert candidate(points = [[-1, -1], [-2, -2], [-3, -3], [-4, -4], [-5, -5], [-6, -6], [-7, -7], [-8, -8], [-9, -9], [-10, -10]]) == 18\n assert candidate(points = [[-1, 2], [-4, 6], [-5, 7], [-8, 9], [-11, 10], [-10, -11], [-3, -5], [-2, -3], [-6, -8], [-9, -4]]) == 47\n assert candidate(points = [[-1, 0], [0, 1], [1, 0], [0, -1], [2, 2], [-2, 2], [2, -2], [-2, -2], [3, 3], [-3, 3], [3, -3], [-3, -3]]) == 26\n assert candidate(points = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0], [11, 0], [12, 0], [13, 0], [14, 0], [15, 0]]) == 15\n assert candidate(points = [[-1000000, 1000000], [1000000, -1000000], [-500000, -500000], [500000, 500000], [0, 0], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == 5999999\n assert candidate(points = [[500000, 500000], [500001, 500001], [500002, 500002], [500003, 500003], [500004, 500004]]) == 8\n assert candidate(points = [[0, 0], [1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18]]) == 27\n assert candidate(points = [[0, 0], [1, 3], [2, 6], [3, 9], [4, 12], [5, 15], [6, 18], [7, 21], [8, 24], [9, 27], [10, 30], [11, 33], [12, 36], [13, 39], [14, 42]]) == 56\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 18\n assert candidate(points = [[10, 10], [10, 20], [10, 30], [20, 10], [20, 20], [20, 30], [30, 10], [30, 20], [30, 30], [15, 15], [25, 25]]) == 100\n assert candidate(points = [[-3, -3], [3, 3], [0, 0], [-1, 1], [1, -1], [-2, 2], [2, -2], [-3, 0], [3, 0], [0, -3], [0, 3], [-2, -1], [2, 1], [1, 2], [-1, -2], [-2, 1], [2, -1], [1, -2], [-1, 2]]) == 32\n assert candidate(points = [[-1, -1], [-2, -2], [1, 1], [2, 2], [-3, -3], [3, 3], [-4, -4], [4, 4], [-5, -5], [5, 5], [-6, -6], [6, 6], [-7, -7], [7, 7], [-8, -8], [8, 8], [-9, -9], [9, 9]]) == 36\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1], [0, 2], [2, 0], [1, 2], [2, 1], [2, 2], [0, 3], [3, 0], [1, 3], [3, 1], [2, 3], [3, 2], [3, 3]]) == 15\n assert candidate(points = [[0, 0], [1, 1], [0, 1], [1, 0], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 19\n assert candidate(points = [[-500000, -500000], [-500001, -500001], [-500002, -500002], [-500003, -500003], [-500004, -500004]]) == 8\n assert candidate(points = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 38\n assert candidate(points = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0], [11, 0], [12, 0], [13, 0], [14, 0], [15, 0], [16, 0], [17, 0], [18, 0], [19, 0]]) == 19\n assert candidate(points = [[1000000, 1000000], [999999, 1000000], [1000000, 999999], [1000000, 1000001], [999999, 999999], [999999, 1000001], [1000001, 999999], [1000001, 1000001]]) == 7\n assert candidate(points = [[0, 0], [0, 1000000], [1000000, 0], [1000000, 1000000], [500000, 500000], [250000, 250000], [750000, 750000], [250000, 750000], [750000, 250000]]) == 4000000\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]]) == 19\n assert candidate(points = [[-100, -200], [-50, -50], [0, 0], [50, 50], [100, 200], [200, 400], [400, 800], [800, 1600], [1600, 3200], [3200, 6400]]) == 9900\n assert candidate(points = [[-1000000, -1000000], [-500000, -500000], [0, 0], [500000, 500000], [1000000, 1000000]]) == 4000000\n assert candidate(points = [[1, 2], [4, 6], [5, 7], [8, 4], [2, 1], [6, 9], [7, 8], [3, 5], [9, 2], [0, 3]]) == 26\n assert candidate(points = [[-500000, -500000], [500000, 500000], [-400000, -400000], [400000, 400000], [-300000, -300000], [300000, 300000], [-200000, -200000], [200000, 200000], [-100000, -100000], [100000, 100000]]) == 2000000\n assert candidate(points = [[500000, 500000], [100000, 100000], [900000, 900000], [200000, 200000], [800000, 800000], [300000, 300000], [700000, 700000], [400000, 400000], [600000, 600000], [550000, 550000]]) == 1600000\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19]]) == 38\n assert candidate(points = [[3, 1], [1, 4], [1, 1], [1, 3], [2, 6], [3, 5], [6, 5], [4, 3], [7, 4], [4, 6], [5, 4], [5, 5], [6, 7], [8, 4], [2, 3]]) == 23\n assert candidate(points = [[-1, -1], [1, 1], [-2, -2], [2, 2], [-3, -3], [3, 3], [-4, -4], [4, 4], [-5, -5], [5, 5]]) == 20\n assert candidate(points = [[0, 0], [10, 0], [0, 10], [10, 10], [5, 5], [3, 7], [8, 2], [2, 8], [7, 3], [4, 6], [6, 4]]) == 40\n assert candidate(points = [[0, 0], [10, 0], [10, 10], [0, 10], [5, 5], [2, 2], [8, 8], [3, 3], [7, 7], [6, 6]]) == 40\n"}, "metadata": {"canonical_parameter_names": ["points"], "leetcode_dataset_entry_point": "Solution().minCostConnectPoints", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minCostConnectPoints(vector>& points) {", "container": "Solution", "callable": "minCostConnectPoints", "parameters": [{"name": "points", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1585, "task_id": "check-if-string-is-transformable-with-substring-sort-operations", "difficulty": "Hard", "problem_description": "Given two strings s and t, transform string s into string t using the following operation any number of times:\n\nChoose a non-empty substring in s and sort it in place so the characters are in ascending order.\n\n\t\nFor example, applying the operation on the underlined substring in \"14234\" results in \"12344\".\n\n\n\nReturn true if it is possible to transform s into t. Otherwise, return false.\nA substring is a contiguous sequence of characters within a string.\n \nExample 1:\n\nInput: s = \"84532\", t = \"34852\"\nOutput: true\nExplanation: You can transform s into t using the following sort operations:\n\"84532\" (from index 2 to 3) -> \"84352\"\n\"84352\" (from index 0 to 2) -> \"34852\"\n\nExample 2:\n\nInput: s = \"34521\", t = \"23415\"\nOutput: true\nExplanation: You can transform s into t using the following sort operations:\n\"34521\" -> \"23451\"\n\"23451\" -> \"23415\"\n\nExample 3:\n\nInput: s = \"12345\", t = \"12435\"\nOutput: false\n\n \nConstraints:\n\ns.length == t.length\n1 <= s.length <= 105\ns and t consist of only digits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"9876543210\",t = \"0123456789\") == True\n assert candidate(s = \"1221\",t = \"1122\") == True\n assert candidate(s = \"987654321\",t = \"123456789\") == True\n assert candidate(s = \"123\",t = \"321\") == False\n assert candidate(s = \"9876543210\",t = \"9876543211\") == False\n assert candidate(s = \"98765\",t = \"56789\") == True\n assert candidate(s = \"11111\",t = \"11111\") == True\n assert candidate(s = \"34521\",t = \"23415\") == True\n assert candidate(s = \"12345\",t = \"12435\") == False\n assert candidate(s = \"12\",t = \"21\") == False\n assert candidate(s = \"1\",t = \"1\") == True\n assert candidate(s = \"123\",t = \"132\") == False\n assert candidate(s = \"12345\",t = \"54321\") == False\n assert candidate(s = \"123456789\",t = \"123456789\") == True\n assert candidate(s = \"1234567890\",t = \"0987654321\") == False\n assert candidate(s = \"4321\",t = \"1234\") == True\n assert candidate(s = \"13579\",t = \"97531\") == False\n assert candidate(s = \"84532\",t = \"34852\") == True\n assert candidate(s = \"1221\",t = \"2112\") == False\n assert candidate(s = \"123123\",t = \"112233\") == True\n assert candidate(s = \"111222333\",t = \"333222111\") == False\n assert candidate(s = \"12345678909876543210\",t = \"12345678909876543210\") == True\n assert candidate(s = \"100200300400500600700800900\",t = \"0000000000000000000123456789\") == False\n assert candidate(s = \"12345678909876543210\",t = \"09876543210123456789\") == False\n assert candidate(s = \"111122223333\",t = \"123123123123\") == False\n assert candidate(s = \"31415926535\",t = \"11233455569\") == True\n assert candidate(s = \"000111222333444555666777888999\",t = \"111122223333444455556666777788889999\") == False\n assert candidate(s = \"555544443333222211110000\",t = \"000011112222333344445555\") == True\n assert candidate(s = \"321123\",t = \"112233\") == True\n assert candidate(s = \"987654321987654321\",t = \"111122223333444455556666777788889999\") == False\n assert candidate(s = \"987654321009876543210\",t = \"00112233445566778899\") == True\n assert candidate(s = \"44443333222211110000\",t = \"00001111222233334444\") == True\n assert candidate(s = \"56321456\",t = \"12345566\") == True\n assert candidate(s = \"5432167890\",t = \"1234567890\") == True\n assert candidate(s = \"112233445566778899\",t = \"98765432101234567890\") == False\n assert candidate(s = \"632541\",t = \"123456\") == True\n assert candidate(s = \"11111111112222222222\",t = \"22222222221111111111\") == False\n assert candidate(s = \"0000111122223333\",t = \"3333222211110000\") == False\n assert candidate(s = \"234234234\",t = \"222333444\") == True\n assert candidate(s = \"33322111\",t = \"11122333\") == True\n assert candidate(s = \"98765432100123456789\",t = \"01234567890987654321\") == False\n assert candidate(s = \"654321654321\",t = \"111222333444555666\") == False\n assert candidate(s = \"987654321098765432109876543210\",t = \"000111222333444555666777888999\") == True\n assert candidate(s = \"98765432101234567890\",t = \"09876543210123456789\") == True\n assert candidate(s = \"123454321\",t = \"122113454\") == False\n assert candidate(s = \"3211123123\",t = \"111223332\") == False\n assert candidate(s = \"1222222222\",t = \"2222222221\") == False\n assert candidate(s = \"9876543210\",t = \"1098765432\") == True\n assert candidate(s = \"122112211\",t = \"111222112\") == True\n assert candidate(s = \"123456789012345678901234567890\",t = \"000111222333444555666777888999\") == True\n assert candidate(s = \"5432112345\",t = \"1122334455\") == True\n assert candidate(s = \"012345678901234567890123456789\",t = \"0011223344556677889900112233445566778899\") == False\n assert candidate(s = \"6677889900\",t = \"0011223344\") == False\n assert candidate(s = \"1234512345\",t = \"1122334455\") == True\n assert candidate(s = \"543216789\",t = \"123456789\") == True\n assert candidate(s = \"12345678909876543210\",t = \"01234567890123456789\") == True\n assert candidate(s = \"999888777666555444333222111000\",t = \"000111222333444555666777888999\") == True\n assert candidate(s = \"765432109876543210\",t = \"00112233445566778899\") == False\n assert candidate(s = \"99887766554433221100\",t = \"00112233445566778899\") == True\n assert candidate(s = \"98765432109876543210\",t = \"00112233445566778899\") == True\n assert candidate(s = \"333333333\",t = \"333333333\") == True\n assert candidate(s = \"1332211\",t = \"1112233\") == True\n assert candidate(s = \"567891234\",t = \"123456789\") == True\n assert candidate(s = \"12341234\",t = \"11223344\") == True\n assert candidate(s = \"35421\",t = \"12345\") == True\n assert candidate(s = \"5432109876\",t = \"0123456789\") == True\n assert candidate(s = \"54321\",t = \"12345\") == True\n assert candidate(s = \"534987621\",t = \"123456789\") == True\n assert candidate(s = \"111122223333\",t = \"333322221111\") == False\n assert candidate(s = \"11111111112222222222\",t = \"11111111112222222222\") == True\n assert candidate(s = \"98765432100987654321\",t = \"00112233445566778899\") == True\n assert candidate(s = \"99887766554433221100\",t = \"0011223344556677889900112233445566778899\") == False\n assert candidate(s = \"54321098765432109876543210\",t = \"0000111122223333444455556666777788889999\") == False\n assert candidate(s = \"5555555555\",t = \"5555555555\") == True\n assert candidate(s = \"65432123456\",t = \"12345623456\") == True\n assert candidate(s = \"432143214321\",t = \"111222333\") == True\n assert candidate(s = \"102030405060708090\",t = \"0000000000123456789\") == False\n assert candidate(s = \"111111111111\",t = \"111111111111\") == True\n assert candidate(s = \"98765432109876543210\",t = \"01234567890123456789\") == True\n assert candidate(s = \"9876543210\",t = \"1234567890\") == True\n assert candidate(s = \"432143214321\",t = \"111222333444\") == True\n assert candidate(s = \"10987654321\",t = \"12345678901\") == False\n assert candidate(s = \"5931246870\",t = \"0123456789\") == True\n assert candidate(s = \"111222333444555666777888999000\",t = \"000111222333444555666777888999\") == True\n assert candidate(s = \"9999888877776666555544443333222211110000\",t = \"0000111122223333444455556666777788889999\") == True\n assert candidate(s = \"123456789012345678901234567890\",t = \"000111222333444555666777888999111222333444555666777888999000\") == False\n assert candidate(s = \"55554444333322221111\",t = \"11112222333344445555\") == True\n assert candidate(s = \"1011121314151617181920\",t = \"1011121314151617181920\") == True\n assert candidate(s = \"333222111\",t = \"111222333\") == True\n assert candidate(s = \"12345678900987654321\",t = \"01234567899876543210\") == False\n assert candidate(s = \"111222333\",t = \"312312312\") == False\n assert candidate(s = \"23232323232323232323\",t = \"22222222223333333333\") == True\n assert candidate(s = \"123321\",t = \"112233\") == True\n assert candidate(s = \"12345678901234567890\",t = \"09876543210987654321\") == False\n assert candidate(s = \"99999888887777766666555554444433333222221111100000\",t = \"00000111112222233333444445555566666777778888899999\") == True\n assert candidate(s = \"654321123456\",t = \"112233445566\") == True\n assert candidate(s = \"010203040506070809\",t = \"00112233445566778899\") == False\n assert candidate(s = \"333222111222333111222333\",t = \"111111222222333333222\") == True\n assert candidate(s = \"321321321\",t = \"111222333\") == True\n assert candidate(s = \"12345678900987654321\",t = \"00123456789123456789\") == True\n assert candidate(s = \"11111111111111111111\",t = \"11111111111111111111\") == True\n assert candidate(s = \"111222333\",t = \"123123123\") == False\n assert candidate(s = \"2121212121\",t = \"1212121212\") == True\n assert candidate(s = \"2222211111\",t = \"1111122222\") == True\n assert candidate(s = \"12345678909876543210\",t = \"000111222333444555666777888999\") == False\n assert candidate(s = \"1111111111\",t = \"1111111111\") == True\n assert candidate(s = \"628491375\",t = \"123456789\") == True\n assert candidate(s = \"5317246\",t = \"1234567\") == True\n assert candidate(s = \"12345678901234567890\",t = \"01234567890123456789\") == True\n assert candidate(s = \"11223344556677889900\",t = \"00112233445566778899\") == True\n assert candidate(s = \"654321098765\",t = \"012345657896\") == True\n assert candidate(s = \"1234567890987654321012345678909876543210\",t = \"000000111111222222333333444444555555666666777777888888999999\") == False\n assert candidate(s = \"989898989898989898\",t = \"88888888888888888899\") == False\n assert candidate(s = \"321456987\",t = \"123456789\") == True\n assert candidate(s = \"143425\",t = \"123445\") == True\n assert candidate(s = \"98765432100123456789\",t = \"00112233445566778899\") == True\n assert candidate(s = \"12345678901234567890\",t = \"01020304050607080919\") == False\n assert candidate(s = \"321321321321321321\",t = \"111112222233333333\") == False\n assert candidate(s = \"12345678900123456789\",t = \"01234567891234567890\") == False\n assert candidate(s = \"12332121321321321\",t = \"11112222333323333\") == False\n assert candidate(s = \"98765432109876543210\",t = \"0011223344556677889900112233445566778899\") == False\n assert candidate(s = \"312312312\",t = \"111222333\") == True\n assert candidate(s = \"5555555555555555555555\",t = \"5555555555555555555555\") == True\n assert candidate(s = \"987654321010203040506070809\",t = \"0000111122223333444455556666777788889999\") == False\n assert candidate(s = \"9345728160\",t = \"0123456789\") == True\n assert candidate(s = \"43214321\",t = \"11223344\") == True\n assert candidate(s = \"1357924680\",t = \"0123456789\") == True\n assert candidate(s = \"98765432100123456789\",t = \"00123456789876543210\") == False\n assert candidate(s = \"123123123\",t = \"111222333\") == True\n assert candidate(s = \"123123123\",t = \"312312312\") == False\n assert candidate(s = \"543215432154321\",t = \"11112222333344445555\") == False\n assert candidate(s = \"98765432101111111111\",t = \"0111111111123456789\") == True\n assert candidate(s = \"43211234\",t = \"11223344\") == True\n assert candidate(s = \"6543210987\",t = \"7890123456\") == False\n assert candidate(s = \"12345678901234567890\",t = \"00112233445566778899\") == True\n assert candidate(s = \"555444333222111000\",t = \"000111222333444555\") == True\n assert candidate(s = \"98765432100123456789\",t = \"00123456789987654321\") == False\n assert candidate(s = \"0123456789876543210123456789\",t = \"0011223344556677889900112233445566778899\") == False\n assert candidate(s = \"55555555555555555555\",t = \"55555555555555555555\") == True\n assert candidate(s = \"11223344556677889900\",t = \"00998877665544332211\") == False\n assert candidate(s = \"1234567890987654321\",t = \"1234567890123456789\") == True\n assert candidate(s = \"6666666666\",t = \"6666666666\") == True\n assert candidate(s = \"6543212132435465768798\",t = \"11223344556677889965432\") == False\n assert candidate(s = \"333322211\",t = \"112223333\") == True\n assert candidate(s = \"4321111111234\",t = \"1111111234432\") == False\n assert candidate(s = \"87654321098765432109876543210\",t = \"0000001111112222223333334444445555556666667777778888889999999\") == False\n assert candidate(s = \"53142\",t = \"12345\") == True\n"}, "metadata": {"canonical_parameter_names": ["s", "t"], "leetcode_dataset_entry_point": "Solution().isTransformable", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool isTransformable(string s, string t) {", "container": "Solution", "callable": "isTransformable", "parameters": [{"name": "s", "type": "string"}, {"name": "t", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1588, "task_id": "sum-of-all-odd-length-subarrays", "difficulty": "Easy", "problem_description": "Given an array of positive integers arr, return the sum of all possible odd-length subarrays of arr.\nA subarray is a contiguous subsequence of the array.\n \nExample 1:\n\nInput: arr = [1,4,2,5,3]\nOutput: 58\nExplanation: The odd-length subarrays of arr and their sums are:\n[1] = 1\n[4] = 4\n[2] = 2\n[5] = 5\n[3] = 3\n[1,4,2] = 7\n[4,2,5] = 11\n[2,5,3] = 10\n[1,4,2,5,3] = 15\nIf we add all these together we get 1 + 4 + 2 + 5 + 3 + 7 + 11 + 10 + 15 = 58\nExample 2:\n\nInput: arr = [1,2]\nOutput: 3\nExplanation: There are only 2 subarrays of odd length, [1] and [2]. Their sum is 3.\nExample 3:\n\nInput: arr = [10,11,12]\nOutput: 66\n\n \nConstraints:\n\n1 <= arr.length <= 100\n1 <= arr[i] <= 1000\n\n \nFollow up:\nCould you solve this problem in O(n) time complexity?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 8760\n assert candidate(arr = [2, 4, 6, 8, 10]) == 114\n assert candidate(arr = [1, 2]) == 3\n assert candidate(arr = [5]) == 5\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 614\n assert candidate(arr = [5, 5, 5, 5, 5]) == 95\n assert candidate(arr = [100, 200, 300, 400, 500]) == 5700\n assert candidate(arr = [10, 11, 12]) == 66\n assert candidate(arr = [1]) == 1\n assert candidate(arr = [7]) == 7\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 605\n assert candidate(arr = [100, 200, 300]) == 1200\n assert candidate(arr = [1, 2, 3, 4, 5]) == 57\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 425\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13]) == 308\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 425\n assert candidate(arr = [1, 4, 2, 5, 3]) == 58\n assert candidate(arr = [1, 3, 5, 7, 9]) == 95\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16]) == 540\n assert candidate(arr = [7, 1, 14, 11]) == 81\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75]) == 127803\n assert candidate(arr = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 281775\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 281775\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 3003\n assert candidate(arr = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100, 104, 108, 112, 116, 120]) == 153760\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 15400\n assert candidate(arr = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2752\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 19097\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 19540\n assert candidate(arr = [999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000]) == 109945\n assert candidate(arr = [23, 45, 12, 67, 89, 34, 56, 78, 90, 11, 22, 33, 44, 55, 66, 77, 88, 99, 100, 111, 222, 333, 444, 555, 666, 777, 888, 999]) == 311940\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 13760\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]) == 18711\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 27520\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 8208\n assert candidate(arr = [250, 240, 230, 220, 210, 200, 190, 180, 170, 160, 150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 190970\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 15400\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 74400\n assert candidate(arr = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160]) == 64680\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51]) == 13203\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700]) == 440100\n assert candidate(arr = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 38440\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 60792\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 13860\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220, 231, 242, 253, 264, 275, 286, 297, 308, 319, 330]) == 422840\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 7590\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9224\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == 31648\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130]) == 110565\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 6050\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 3003\n assert candidate(arr = [101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123]) == 20384\n assert candidate(arr = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == 388680\n assert candidate(arr = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144]) == 43320\n assert candidate(arr = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96]) == 65000\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205]) == 93555\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250]) == 190970\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 2752\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 80850\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2736\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 36725\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 40425\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 275200\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125]) == 95485\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 40425\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 19097\n assert candidate(arr = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400, 420, 440, 460, 480, 500]) == 381940\n assert candidate(arr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 60792\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 808500\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77]) == 101728\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120]) == 81250\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 3850\n assert candidate(arr = [150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170]) == 142560\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154]) == 81466\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75]) == 57291\n assert candidate(arr = [101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129]) == 39560\n assert candidate(arr = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 24050\n assert candidate(arr = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168]) == 176610\n assert candidate(arr = [50, 25, 75, 100, 200, 150, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000]) == 438225\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 275200\n assert candidate(arr = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == 761915\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175]) == 133679\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 31570\n assert candidate(arr = [21, 34, 41, 53, 67, 71, 82, 95, 100, 121, 134, 141, 153, 167, 171, 182, 195]) == 52492\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220, 231, 242, 253, 264, 275, 286, 297]) == 282436\n assert candidate(arr = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 4480\n assert candidate(arr = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50]) == 0\n assert candidate(arr = [1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 57040\n assert candidate(arr = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 51000\n assert candidate(arr = [33, 66, 99, 132, 165, 198, 231, 264, 297, 330, 363, 396, 429, 462, 495, 528, 561, 594, 627, 660, 693, 726, 759, 792, 825]) == 630201\n assert candidate(arr = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195]) == 70350\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300]) == 161700\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 117670\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 8085\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 60500\n assert candidate(arr = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 5848\n assert candidate(arr = [50, 40, 30, 20, 10, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 12770\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 5500\n assert candidate(arr = [300, 200, 100, 50, 25, 12, 6, 3, 1]) == 5364\n assert candidate(arr = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 109]) == 8614\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]) == 14700\n assert candidate(arr = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270]) == 184960\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 60500\n assert candidate(arr = [42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80]) == 46970\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().sumOddLengthSubarrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int sumOddLengthSubarrays(vector& arr) {", "container": "Solution", "callable": "sumOddLengthSubarrays", "parameters": [{"name": "arr", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1589, "task_id": "maximum-sum-obtained-of-any-permutation", "difficulty": "Medium", "problem_description": "We have an array of integers, nums, and an array of requests where requests[i] = [starti, endi]. The ith request asks for the sum of nums[starti] + nums[starti + 1] + ... + nums[endi - 1] + nums[endi]. Both starti and endi are 0-indexed.\nReturn the maximum total sum of all requests among all permutations of nums.\nSince the answer may be too large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: nums = [1,2,3,4,5], requests = [[1,3],[0,1]]\nOutput: 19\nExplanation: One permutation of nums is [2,1,3,4,5] with the following result: \nrequests[0] -> nums[1] + nums[2] + nums[3] = 1 + 3 + 4 = 8\nrequests[1] -> nums[0] + nums[1] = 2 + 1 = 3\nTotal sum: 8 + 3 = 11.\nA permutation with a higher total sum is [3,5,4,2,1] with the following result:\nrequests[0] -> nums[1] + nums[2] + nums[3] = 5 + 4 + 2 = 11\nrequests[1] -> nums[0] + nums[1] = 3 + 5 = 8\nTotal sum: 11 + 8 = 19, which is the best that you can do.\n\nExample 2:\n\nInput: nums = [1,2,3,4,5,6], requests = [[0,1]]\nOutput: 11\nExplanation: A permutation with the max total sum is [6,5,4,3,2,1] with request sums [11].\nExample 3:\n\nInput: nums = [1,2,3,4,5,10], requests = [[0,2],[1,3],[1,1]]\nOutput: 47\nExplanation: A permutation with the max total sum is [4,10,5,3,2,1] with request sums [19,18,10].\n \nConstraints:\n\nn == nums.length\n1 <= n <= 105\n0 <= nums[i] <= 105\n1 <= requests.length <= 105\nrequests[i].length == 2\n0 <= starti <= endi < n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 10],requests = [[0, 2], [1, 3], [1, 1]]) == 47\n assert candidate(nums = [10, 20, 30, 40, 50],requests = [[0, 0], [1, 2], [2, 3], [3, 4]]) == 240\n assert candidate(nums = [0, 0, 0, 0, 0],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == 0\n assert candidate(nums = [1, 2, 3],requests = [[0, 2], [0, 1], [1, 2]]) == 15\n assert candidate(nums = [5, 2, 4, 1, 3],requests = [[0, 4], [2, 3], [1, 2]]) == 32\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996],requests = [[0, 2], [2, 4], [0, 4]]) == 1099980\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],requests = [[0, 4], [4, 8], [0, 9]]) == 119\n assert candidate(nums = [1, 2, 3, 4, 5],requests = [[1, 3], [0, 1]]) == 19\n assert candidate(nums = [5, 2, 4, 1, 3],requests = [[0, 4], [1, 3], [0, 0], [3, 4]]) == 35\n assert candidate(nums = [1, 2, 3, 4, 5, 6],requests = [[0, 1]]) == 11\n assert candidate(nums = [5, 2, 4, 1],requests = [[0, 1], [1, 2], [2, 3]]) == 21\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],requests = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4]]) == 155\n assert candidate(nums = [100, 101, 102, 103, 104, 105],requests = [[0, 5], [1, 4], [2, 3]]) == 1238\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],requests = [[0, 9], [0, 8], [0, 7], [0, 6], [0, 5], [0, 4], [0, 3], [0, 2], [0, 1]]) == 54\n assert candidate(nums = [10, 20, 30, 40, 50],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]]) == 150\n assert candidate(nums = [8, 9, 7, 6, 5],requests = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 59\n assert candidate(nums = [5, 3, 7, 2, 1],requests = [[0, 2], [1, 4], [2, 3]]) == 40\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 10\n assert candidate(nums = [10, 20, 30, 40, 50],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 1], [1, 2], [2, 3], [3, 4], [0, 4]]) == 570\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 2050000\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],requests = [[0, 2], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 8], [7, 8], [0, 8]]) == 206\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 5500\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[0, 19], [0, 9], [10, 19], [5, 14], [9, 14]]) == 680\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 1], [2, 4]]) == 3499885\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],requests = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [1, 2], [3, 4], [5, 6], [7, 8], [0, 9]]) == 296\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],requests = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5]]) == 5050000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 1485\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],requests = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 2860\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 1025\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 1485\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9, 0],requests = [[0, 9], [1, 5], [3, 7], [2, 8], [4, 6]]) == 175\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1],requests = [[0, 3], [2, 5], [1, 4], [3, 7]]) == 95\n assert candidate(nums = [5, 3, 2, 1, 4],requests = [[0, 2], [1, 4], [0, 3], [2, 4]]) == 47\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 2050\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],requests = [[0, 19], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 19]]) == 799\n assert candidate(nums = [5, 3, 8, 1, 4, 7],requests = [[0, 5], [2, 4], [1, 3]]) == 67\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 26000\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995],requests = [[0, 2], [1, 4], [0, 5], [2, 3]]) == 1499972\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],requests = [[0, 9], [0, 4], [5, 9], [2, 7]]) == 1550000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [0, 19]]) == 627\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],requests = [[0, 19], [5, 15], [10, 20], [1, 2], [3, 4], [7, 8], [12, 13], [17, 18]]) == 1175\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],requests = [[0, 19], [5, 15], [10, 10], [15, 15], [0, 9], [10, 19]]) == 6240\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],requests = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7]]) == 6520\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 9]]) == 20\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],requests = [[0, 9], [0, 8], [0, 7], [0, 6], [0, 5], [0, 4], [0, 3], [0, 2], [0, 1]]) == 54\n assert candidate(nums = [2, 3, 1, 5, 4],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 4]]) == 42\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 3], [3, 6], [6, 9]]) == 275000\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19]]) == 210\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],requests = [[0, 9], [0, 9], [0, 9], [0, 9], [0, 9]]) == 50\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],requests = [[0, 9], [1, 2], [3, 4], [5, 6], [7, 8], [0, 4], [5, 9]]) == 16200\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]]) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],requests = [[0, 10], [10, 20], [20, 30], [0, 20], [10, 30], [0, 30]]) == 17290\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],requests = [[0, 9], [0, 0], [9, 9], [2, 2], [5, 5], [1, 8], [3, 7]]) == 1650\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],requests = [[0, 4], [5, 9], [0, 5], [4, 9], [0, 9]]) == 1840000\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],requests = [[0, 9], [10, 19], [0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 8475\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],requests = [[0, 9], [1, 3], [2, 5], [4, 7], [0, 5], [3, 8]]) == 1533\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],requests = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 430\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],requests = [[0, 4], [5, 9], [0, 9], [2, 7], [3, 8]]) == 398\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 50\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],requests = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 1485\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],requests = [[0, 2], [2, 4], [4, 6], [6, 8], [0, 9], [1, 8], [3, 7], [5, 5]]) == 1165\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35],requests = [[0, 6], [1, 4], [2, 3], [0, 2], [4, 5]]) == 420\n assert candidate(nums = [99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111, 0],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 1944425\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[0, 19], [0, 9], [10, 19], [5, 15], [3, 17], [7, 13]]) == 899\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],requests = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 3430\n assert candidate(nums = [9, 1, 5, 3, 7, 2, 8, 4, 6, 0],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 175\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120],requests = [[0, 5], [3, 7], [1, 4], [6, 9], [0, 2], [8, 10]]) == 1728\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],requests = [[0, 3], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [0, 9]]) == 2510\n assert candidate(nums = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],requests = [[0, 4], [5, 9], [2, 6], [3, 7], [1, 5], [6, 10]]) == 3380\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],requests = [[0, 19], [0, 9], [10, 19], [5, 14], [9, 14], [0, 5], [5, 10], [10, 15]]) == 1828\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 1300\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],requests = [[0, 10], [5, 15], [10, 20], [0, 20], [1, 19], [2, 18], [3, 17], [4, 16], [5, 15], [6, 14]]) == 8216\n assert candidate(nums = [100, 200, 300, 400, 500],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 4]]) == 3000\n assert candidate(nums = [5, 3, 7, 9, 1, 6, 4, 8, 2, 10],requests = [[0, 9], [2, 5], [3, 7], [1, 8], [0, 4], [5, 9]]) == 234\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[0, 19], [0, 9], [10, 19], [0, 10], [10, 20]]) == 650\n assert candidate(nums = [50, 40, 30, 20, 10],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [0, 4], [1, 3], [2, 4]]) == 530\n assert candidate(nums = [23, 17, 54, 32, 45, 67, 89, 101, 120, 34, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34],requests = [[0, 9], [1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18]]) == 7390\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]]) == 179\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 417\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14]]) == 1135\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],requests = [[0, 4], [1, 3], [2, 2], [3, 9], [4, 8], [5, 7], [6, 6], [7, 9], [0, 9], [0, 0], [9, 9]]) == 23600\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],requests = [[0, 4], [1, 3], [2, 2], [0, 0], [4, 4], [3, 3]]) == 87\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],requests = [[0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 760\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 550\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[0, 19], [0, 9], [10, 19], [0, 4], [5, 9], [10, 14], [15, 19]]) == 630\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],requests = [[0, 19], [0, 0], [19, 19], [5, 15], [10, 10]]) == 170\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],requests = [[0, 19], [0, 18], [0, 17], [0, 16], [0, 15], [0, 14], [0, 13], [0, 12], [0, 11], [0, 10]]) == 155\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 4], [6, 3], [7, 2], [8, 1], [9, 0]]) == 110\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],requests = [[0, 12], [2, 5], [6, 9], [1, 4], [7, 10]]) == 449\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],requests = [[0, 9], [10, 19], [0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 3260\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [0, 19], [1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8], [10, 9], [11, 10], [12, 11], [13, 12], [14, 13], [15, 14], [16, 15], [17, 16], [18, 17], [19, 18]]) == 627\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [0, 9], [0, 5], [5, 9], [3, 7], [2, 8]]) == 221\n assert candidate(nums = [100, 200, 300, 400, 500],requests = [[0, 4], [1, 3], [2, 2], [0, 0], [4, 4]]) == 3500\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],requests = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]) == 9350\n"}, "metadata": {"canonical_parameter_names": ["nums", "requests"], "leetcode_dataset_entry_point": "Solution().maxSumRangeQuery", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxSumRangeQuery(vector& nums, vector>& requests) {", "container": "Solution", "callable": "maxSumRangeQuery", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "requests", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1590, "task_id": "make-sum-divisible-by-p", "difficulty": "Medium", "problem_description": "Given an array of positive integers nums, remove the smallest subarray (possibly empty) such that the sum of the remaining elements is divisible by p. It is not allowed to remove the whole array.\nReturn the length of the smallest subarray that you need to remove, or -1 if it's impossible.\nA subarray is defined as a contiguous block of elements in the array.\n \nExample 1:\n\nInput: nums = [3,1,4,2], p = 6\nOutput: 1\nExplanation: The sum of the elements in nums is 10, which is not divisible by 6. We can remove the subarray [4], and the sum of the remaining elements is 6, which is divisible by 6.\n\nExample 2:\n\nInput: nums = [6,3,5,2], p = 9\nOutput: 2\nExplanation: We cannot remove a single element to get a sum divisible by 9. The best way is to remove the subarray [5,2], leaving us with [6,3] with sum 9.\n\nExample 3:\n\nInput: nums = [1,2,3], p = 3\nOutput: 0\nExplanation: Here the sum is 6. which is already divisible by 3. Thus we do not need to remove anything.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 109\n1 <= p <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5, 5],p = 3) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],p = 2) == 1\n assert candidate(nums = [7, 8, 9, 10, 11],p = 11) == 4\n assert candidate(nums = [1, 2, 3, 4, 5],p = 10) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],p = 5) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],p = 11) == 1\n assert candidate(nums = [1000000000],p = 1000000000) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],p = 5) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],p = 5) == 0\n assert candidate(nums = [7, 1, 3, 5, 2, 9],p = 10) == 1\n assert candidate(nums = [10, 11, 12],p = 6) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],p = 3) == 1\n assert candidate(nums = [6, 3, 5, 2],p = 9) == 2\n assert candidate(nums = [10, 20, 30, 40, 50],p = 10) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],p = 7) == 1\n assert candidate(nums = [1, 2, 3],p = 3) == 0\n assert candidate(nums = [1],p = 1) == 0\n assert candidate(nums = [5, 5, 5, 5, 5],p = 10) == 1\n assert candidate(nums = [3, 1, 4, 2],p = 6) == 1\n assert candidate(nums = [1000000000, 1000000000, 1000000000],p = 3000000000) == 0\n assert candidate(nums = [11, 13, 17, 19, 23, 29],p = 101) == 1\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],p = 13) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],p = 13) == 1\n assert candidate(nums = [11, 22, 33, 44, 55, 66],p = 11) == 0\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],p = 3) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],p = 17) == 1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],p = 13) == 1\n assert candidate(nums = [45, 54, 63, 72, 81, 90, 99, 108, 117, 126],p = 13) == 2\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000],p = 3) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],p = 3) == 1\n assert candidate(nums = [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],p = 19) == 1\n assert candidate(nums = [8, 5, 6, 10, 8, 7, 3, 5, 8, 1, 2, 9, 4, 6, 5, 1, 3, 4, 7, 8],p = 5) == 0\n assert candidate(nums = [1000000007, 1000000007, 1000000007, 1000000007, 1000000007],p = 500000003) == -1\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],p = 5) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],p = 19) == 1\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],p = 1) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],p = 13) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],p = 101) == 6\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],p = 11) == 1\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],p = 7) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],p = 1000000007) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],p = 11) == 0\n assert candidate(nums = [8, 6, 4, 2, 0, 8, 6, 4, 2, 0, 8, 6, 4, 2, 0],p = 10) == 0\n assert candidate(nums = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],p = 26) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60],p = 25) == 1\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],p = 27) == 1\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3],p = 5) == 0\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165],p = 17) == 1\n assert candidate(nums = [17, 23, 29, 31, 37, 41, 43, 47, 53, 59],p = 11) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],p = 11) == 0\n assert candidate(nums = [13, 23, 33, 43, 53, 63, 73, 83, 93, 103],p = 11) == 1\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1],p = 11) == 1\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10],p = 11) == 1\n assert candidate(nums = [2, 6, 3, 8, 7, 1, 5, 4, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],p = 17) == 1\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],p = 7) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],p = 2) == 0\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444],p = 123456789) == 5\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111],p = 1000000007) == -1\n assert candidate(nums = [1000000000, 1000000001, 1000000002, 1000000003],p = 4) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],p = 5) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],p = 5) == 2\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],p = 100) == 5\n assert candidate(nums = [23, 32, 45, 65, 77, 88, 91, 103, 114, 125],p = 13) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],p = 19) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],p = 2) == 0\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993],p = 7) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],p = 13) == 1\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],p = 1000000007) == -1\n assert candidate(nums = [314159, 271828, 161803, 334993, 986264, 338327, 795028, 841971, 693993, 751058],p = 1234567) == -1\n assert candidate(nums = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000],p = 15000000000) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],p = 17) == -1\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],p = 7) == 1\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],p = 5) == 0\n assert candidate(nums = [61, 57, 59, 55, 53, 67, 71, 61, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997],p = 53) == 1\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555],p = 1000000007) == -1\n assert candidate(nums = [123456789, 987654321, 246813579, 135792468, 111213141, 222324252, 333435363, 444546474, 555657585, 666768696],p = 1000000009) == -1\n"}, "metadata": {"canonical_parameter_names": ["nums", "p"], "leetcode_dataset_entry_point": "Solution().minSubarray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minSubarray(vector& nums, int p) {", "container": "Solution", "callable": "minSubarray", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "p", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1591, "task_id": "strange-printer-ii", "difficulty": "Hard", "problem_description": "There is a strange printer with the following two special requirements:\n\nOn each turn, the printer will print a solid rectangular pattern of a single color on the grid. This will cover up the existing colors in the rectangle.\nOnce the printer has used a color for the above operation, the same color cannot be used again.\n\nYou are given a m x n matrix targetGrid, where targetGrid[row][col] is the color in the position (row, col) of the grid.\nReturn true if it is possible to print the matrix targetGrid, otherwise, return false.\n \nExample 1:\n\n\nInput: targetGrid = [[1,1,1,1],[1,2,2,1],[1,2,2,1],[1,1,1,1]]\nOutput: true\n\nExample 2:\n\n\nInput: targetGrid = [[1,1,1,1],[1,1,3,3],[1,1,3,4],[5,5,1,4]]\nOutput: true\n\nExample 3:\n\nInput: targetGrid = [[1,2,1],[2,1,2],[1,2,1]]\nOutput: false\nExplanation: It is impossible to form targetGrid because it is not allowed to print the same color in different turns.\n\n \nConstraints:\n\nm == targetGrid.length\nn == targetGrid[i].length\n1 <= m, n <= 60\n1 <= targetGrid[row][col] <= 60\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(targetGrid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 1], [1, 2, 2, 1], [1, 2, 2, 1], [1, 1, 1, 1]]) == True\n assert candidate(targetGrid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == True\n assert candidate(targetGrid = [[1, 2, 1], [2, 1, 2], [1, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 3, 4], [2, 1, 4, 3], [3, 4, 1, 2], [4, 3, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 1], [1, 1, 3, 3], [1, 1, 3, 4], [5, 5, 1, 4]]) == True\n assert candidate(targetGrid = [[1, 2, 1, 4], [2, 1, 4, 1], [1, 4, 1, 2], [4, 1, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 1], [1, 1], [2, 2], [2, 2]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 2, 1], [2, 3, 4, 3, 2], [3, 4, 5, 4, 3], [2, 3, 4, 3, 2], [1, 2, 3, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 3], [2, 3, 3, 4], [2, 3, 3, 4], [1, 2, 2, 3]]) == False\n assert candidate(targetGrid = [[1, 1, 2, 2, 3, 3, 4, 4], [1, 1, 2, 2, 3, 3, 4, 4], [1, 1, 2, 2, 3, 3, 4, 4], [5, 5, 6, 6, 7, 7, 8, 8], [5, 5, 6, 6, 7, 7, 8, 8], [5, 5, 6, 6, 7, 7, 8, 8], [5, 5, 6, 6, 7, 7, 8, 8], [5, 5, 6, 6, 7, 7, 8, 8]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 2, 2, 3], [1, 4, 1, 5, 2, 3], [1, 4, 6, 5, 2, 3], [1, 4, 6, 5, 2, 3], [1, 4, 1, 5, 2, 3], [1, 1, 1, 2, 2, 3]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 1], [3, 4, 5, 6, 1, 2], [4, 5, 6, 1, 2, 3], [5, 6, 1, 2, 3, 4], [6, 1, 2, 3, 4, 5]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 2, 1], [1, 2, 3, 4, 3, 2, 1], [1, 2, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6, 7], [2, 1, 2, 3, 4, 5, 6], [3, 2, 1, 2, 3, 4, 5], [4, 3, 2, 1, 2, 3, 4], [5, 4, 3, 2, 1, 2, 3], [6, 5, 4, 3, 2, 1, 2], [7, 6, 5, 4, 3, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6], [2, 1, 4, 5, 6, 3], [3, 4, 1, 6, 5, 2], [4, 5, 6, 1, 2, 3], [5, 6, 2, 3, 1, 4], [6, 3, 5, 4, 3, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6, 7], [2, 1, 3, 4, 5, 6, 7], [3, 2, 1, 4, 5, 6, 7], [4, 3, 2, 1, 5, 6, 7], [5, 4, 3, 2, 1, 6, 7], [6, 5, 4, 3, 2, 1, 7], [7, 6, 5, 4, 3, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 2, 2, 2], [1, 3, 1, 3, 3, 2], [1, 3, 1, 3, 3, 2], [1, 1, 1, 2, 2, 2], [1, 3, 3, 3, 3, 3], [1, 3, 3, 3, 3, 3]]) == False\n assert candidate(targetGrid = [[1, 2, 3, 4, 5], [5, 1, 2, 3, 4], [4, 5, 1, 2, 3], [3, 4, 5, 1, 2], [2, 3, 4, 5, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 2, 2, 2], [2, 3, 3, 3, 3, 2], [2, 3, 4, 4, 3, 2], [2, 3, 4, 4, 3, 2], [2, 3, 3, 3, 3, 2], [2, 2, 2, 2, 2, 2]]) == True\n assert candidate(targetGrid = [[1, 2, 2, 1, 1], [2, 3, 3, 2, 2], [2, 3, 3, 2, 2], [1, 2, 2, 1, 1], [5, 5, 5, 5, 5]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 2, 2, 2, 3, 3, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [4, 4, 4, 5, 5, 5, 6, 6, 6], [4, 4, 4, 5, 5, 5, 6, 6, 6], [7, 7, 7, 8, 8, 8, 9, 9, 9], [7, 7, 7, 8, 8, 8, 9, 9, 9]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 3, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 1, 1]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 1, 2, 2, 2, 2], [1, 2, 2, 2, 2, 2, 2, 2], [1, 2, 3, 3, 3, 3, 2, 2], [1, 2, 3, 4, 4, 3, 2, 2], [1, 2, 3, 4, 4, 3, 2, 2], [1, 2, 3, 3, 3, 3, 2, 2], [1, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 2, 2, 2, 2]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 3, 2, 1], [1, 2, 3, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 4, 5], [2, 1, 4, 5, 3], [3, 4, 1, 2, 5], [4, 5, 2, 3, 1], [5, 3, 1, 4, 2]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 3], [2, 4, 4, 3], [2, 4, 4, 3], [1, 2, 2, 3]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 3, 1], [1, 2, 2, 3, 1], [4, 5, 5, 6, 4], [4, 5, 5, 6, 4], [7, 8, 8, 9, 7]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7]]) == True\n assert candidate(targetGrid = [[5, 5, 5, 5, 5], [5, 6, 6, 6, 5], [5, 6, 7, 6, 5], [5, 6, 6, 6, 5], [5, 5, 5, 5, 5]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6, 7], [7, 1, 2, 3, 4, 5, 6], [6, 7, 1, 2, 3, 4, 5], [5, 6, 7, 1, 2, 3, 4], [4, 5, 6, 7, 1, 2, 3], [3, 4, 5, 6, 7, 1, 2], [2, 3, 4, 5, 6, 7, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 2, 2, 2], [2, 1, 3, 3, 3, 2], [2, 1, 3, 4, 3, 2], [2, 1, 3, 3, 3, 2], [2, 2, 2, 2, 2, 2]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 4, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == True\n assert candidate(targetGrid = [[1, 2, 2, 1], [2, 3, 3, 2], [2, 3, 3, 2], [1, 2, 2, 1], [1, 2, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48, 49]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 3, 4, 5], [2, 1, 2, 3, 4], [3, 2, 1, 2, 3], [4, 3, 2, 1, 2], [5, 4, 3, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 1, 2, 2, 3, 3], [1, 1, 2, 2, 3, 3], [1, 1, 4, 4, 5, 5], [1, 1, 4, 4, 5, 5], [6, 6, 6, 6, 6, 6], [6, 6, 6, 6, 6, 6]]) == True\n assert candidate(targetGrid = [[1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 2, 2, 2], [1, 1, 1, 2, 2, 2], [3, 3, 3, 4, 4, 4], [3, 3, 3, 4, 4, 4], [5, 5, 5, 6, 6, 6], [5, 5, 5, 6, 6, 6]]) == True\n assert candidate(targetGrid = [[1, 1, 2, 2, 2, 3], [1, 4, 4, 4, 2, 3], [1, 4, 5, 4, 2, 3], [1, 4, 5, 4, 2, 3], [1, 1, 5, 5, 2, 3], [1, 1, 5, 5, 2, 3]]) == False\n assert candidate(targetGrid = [[5, 5, 5, 5, 5, 5], [5, 6, 6, 6, 6, 5], [5, 6, 7, 7, 6, 5], [5, 6, 7, 7, 6, 5], [5, 6, 6, 6, 6, 5], [5, 5, 5, 5, 5, 5]]) == True\n assert candidate(targetGrid = [[1, 2, 2, 1], [1, 1, 2, 2], [1, 2, 2, 1], [1, 1, 2, 2], [1, 2, 2, 1], [1, 1, 2, 2]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 1, 1, 2, 2, 2], [1, 2, 2, 2, 1, 2, 2, 2], [1, 2, 3, 3, 1, 2, 2, 2], [1, 2, 3, 3, 1, 2, 2, 2], [1, 1, 1, 1, 1, 2, 2, 2], [4, 4, 4, 4, 4, 5, 5, 5], [4, 4, 6, 6, 4, 5, 5, 5], [4, 4, 6, 6, 4, 5, 5, 5]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 1, 1], [2, 3, 3, 2, 1], [2, 3, 3, 2, 1], [1, 2, 2, 1, 1], [1, 1, 1, 1, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 1, 1, 1], [2, 1, 1, 1, 1, 2], [2, 1, 3, 3, 1, 2], [2, 1, 3, 3, 1, 2], [2, 1, 1, 1, 1, 2], [1, 2, 2, 1, 1, 1]]) == False\n assert candidate(targetGrid = [[1, 1, 2, 2, 3, 3], [1, 1, 2, 2, 3, 3], [4, 4, 5, 5, 6, 6], [4, 4, 5, 5, 6, 6], [7, 7, 8, 8, 9, 9], [7, 7, 8, 8, 9, 9]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4], [5, 5, 5, 5]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 5, 4, 3, 2], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == False\n assert candidate(targetGrid = [[1, 1, 1, 1, 2, 2, 2, 2], [1, 1, 1, 1, 2, 2, 2, 2], [1, 1, 1, 1, 2, 2, 2, 2], [1, 1, 1, 1, 2, 2, 2, 2], [3, 3, 3, 3, 4, 4, 4, 4], [3, 3, 3, 3, 4, 4, 4, 4], [3, 3, 3, 3, 4, 4, 4, 4], [3, 3, 3, 3, 4, 4, 4, 4]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 2, 2], [1, 1, 1, 2, 2], [1, 1, 1, 2, 2], [3, 3, 3, 4, 4], [3, 3, 3, 4, 4]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 2, 2, 2, 3, 3, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [1, 1, 1, 2, 2, 2, 3, 3, 3], [4, 4, 4, 5, 5, 5, 6, 6, 6], [4, 4, 4, 5, 5, 5, 6, 6, 6], [4, 4, 4, 5, 5, 5, 6, 6, 6], [7, 7, 7, 8, 8, 8, 9, 9, 9], [7, 7, 7, 8, 8, 8, 9, 9, 9], [7, 7, 7, 8, 8, 8, 9, 9, 9]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 2, 2, 2], [1, 1, 1, 2, 2, 2], [1, 1, 1, 2, 2, 2], [3, 3, 3, 4, 4, 4], [3, 3, 3, 4, 4, 4], [3, 3, 3, 4, 4, 4]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 2, 2], [1, 1, 1, 2, 2], [3, 3, 3, 4, 4], [3, 3, 3, 4, 4], [5, 5, 5, 6, 6], [5, 5, 5, 6, 6]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 2, 2, 3, 3, 3], [1, 1, 1, 2, 2, 3, 3, 3], [1, 1, 1, 2, 2, 3, 3, 3], [4, 4, 4, 5, 5, 6, 6, 6], [4, 4, 4, 5, 5, 6, 6, 6], [4, 4, 4, 5, 5, 6, 6, 6], [7, 7, 7, 8, 8, 9, 9, 9], [7, 7, 7, 8, 8, 9, 9, 9]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 3, 4, 5, 6], [6, 1, 2, 3, 4, 5], [5, 6, 1, 2, 3, 4], [4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2], [2, 3, 4, 5, 6, 1]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 2, 2, 2], [1, 1, 3, 3, 3, 1], [1, 1, 3, 4, 3, 1], [1, 1, 3, 3, 3, 1], [1, 1, 1, 1, 1, 1]]) == True\n assert candidate(targetGrid = [[1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 1], [1, 2, 3, 3, 2, 1], [1, 2, 3, 3, 2, 1], [1, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1]]) == True\n assert candidate(targetGrid = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 1], [3, 4, 5, 1, 2], [4, 5, 1, 2, 3], [5, 1, 2, 3, 4]]) == False\n assert candidate(targetGrid = [[1, 2, 2, 1, 1, 2], [2, 1, 2, 1, 2, 1], [2, 1, 1, 2, 1, 2], [1, 2, 2, 1, 1, 2], [1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2]]) == False\n"}, "metadata": {"canonical_parameter_names": ["targetGrid"], "leetcode_dataset_entry_point": "Solution().isPrintable", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool isPrintable(vector>& targetGrid) {", "container": "Solution", "callable": "isPrintable", "parameters": [{"name": "targetGrid", "type": "vector>&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1592, "task_id": "rearrange-spaces-between-words", "difficulty": "Easy", "problem_description": "You are given a string text of words that are placed among some number of spaces. Each word consists of one or more lowercase English letters and are separated by at least one space. It's guaranteed that text contains at least one word.\nRearrange the spaces so that there is an equal number of spaces between every pair of adjacent words and that number is maximized. If you cannot redistribute all the spaces equally, place the extra spaces at the end, meaning the returned string should be the same length as text.\nReturn the string after rearranging the spaces.\n \nExample 1:\n\nInput: text = \" this is a sentence \"\nOutput: \"this is a sentence\"\nExplanation: There are a total of 9 spaces and 4 words. We can evenly divide the 9 spaces between the words: 9 / (4-1) = 3 spaces.\n\nExample 2:\n\nInput: text = \" practice makes perfect\"\nOutput: \"practice makes perfect \"\nExplanation: There are a total of 7 spaces and 3 words. 7 / (3-1) = 3 spaces plus 1 extra space. We place this extra space at the end of the string.\n\n \nConstraints:\n\n1 <= text.length <= 100\ntext consists of lowercase English letters and ' '.\ntext contains at least one word.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(text = \" leading and trailing spaces \") == \"leading and trailing spaces \"\n assert candidate(text = \"one\") == \"one\"\n assert candidate(text = \" a \") == \"a \"\n assert candidate(text = \"hello world\") == \"hello world\"\n assert candidate(text = \"example example example\") == \"example example example\"\n assert candidate(text = \"a b c d e\") == \"a b c d e\"\n assert candidate(text = \" this is a sentence \") == \"this is a sentence\"\n assert candidate(text = \"one two three\") == \"one two three\"\n assert candidate(text = \" multiple spaces here \") == \"multiple spaces here \"\n assert candidate(text = \"the quick brown fox\") == \"the quick brown fox \"\n assert candidate(text = \" a \") == \"a \"\n assert candidate(text = \"uneven spacing in text\") == \"uneven spacing in text \"\n assert candidate(text = \" hello world \") == \"hello world\"\n assert candidate(text = \" practice makes perfect\") == \"practice makes perfect \"\n assert candidate(text = \"two words\") == \"two words\"\n assert candidate(text = \"one two three four\") == \"one two three four\"\n assert candidate(text = \"a b\") == \"a b\"\n assert candidate(text = \" one two three four \") == \"one two three four \"\n assert candidate(text = \"a b\") == \"a b\"\n assert candidate(text = \" welcome to the jungle \") == \"welcome to the jungle \"\n assert candidate(text = \"a\") == \"a\"\n assert candidate(text = \"equal spaces\") == \"equal spaces\"\n assert candidate(text = \"a b c d e f g h i j\") == \"a b c d e f g h i j\"\n assert candidate(text = \"longerwordwithnospaces\") == \"longerwordwithnospaces\"\n assert candidate(text = \"word\") == \"word\"\n assert candidate(text = \"consecutive spaces should be handled\") == \"consecutive spaces should be handled\"\n assert candidate(text = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\") == \"a b c d e f g h i j k l m n o p q r s t u v w x y z\"\n assert candidate(text = \"equal spaces between words\") == \"equal spaces between words\"\n assert candidate(text = \" spaces before and after and in between \") == \"spaces before and after and in between \"\n assert candidate(text = \"equal spaces should be here\") == \"equal spaces should be here\"\n assert candidate(text = \" spaces before and after and in between \") == \"spaces before and after and in between \"\n assert candidate(text = \"spaces at the beginning and end of the sentence\") == \"spaces at the beginning and end of the sentence \"\n assert candidate(text = \" uneven spaces distribution is tricky \") == \"uneven spaces distribution is tricky \"\n assert candidate(text = \" a\") == \"a \"\n assert candidate(text = \"onewordwith trailing\") == \"onewordwith trailing\"\n assert candidate(text = \" uneven spacing everywhere \") == \"uneven spacing everywhere\"\n assert candidate(text = \"evenly distributed spaces are good for readability\") == \"evenly distributed spaces are good for readability\"\n assert candidate(text = \"one verylongwordthatwillnotgetsplit\") == \"one verylongwordthatwillnotgetsplit\"\n assert candidate(text = \"a b c d e\") == \"a b c d e \"\n assert candidate(text = \" equal spacing here \") == \"equal spacing here\"\n assert candidate(text = \"short longword verylongwordwithnospaces\") == \"short longword verylongwordwithnospaces\"\n assert candidate(text = \"a long sentence with more words to test the functionality\") == \"a long sentence with more words to test the functionality\"\n assert candidate(text = \"one two three four\") == \"one two three four\"\n assert candidate(text = \" singlewordwithmanyspacesbeforeandafterspaces \") == \"singlewordwithmanyspacesbeforeandafterspaces \"\n assert candidate(text = \"one two three four five six seven eight nine ten\") == \"one two three four five six seven eight nine ten\"\n assert candidate(text = \"tiny gaps\") == \"tiny gaps\"\n assert candidate(text = \" one two three four five six seven eight nine ten \") == \"one two three four five six seven eight nine ten \"\n assert candidate(text = \"averylongwordwithnospaces\") == \"averylongwordwithnospaces\"\n assert candidate(text = \"unequal spaces should be here with extra\") == \"unequal spaces should be here with extra\"\n assert candidate(text = \" spacesbeforeand spacesafter \") == \"spacesbeforeand spacesafter\"\n assert candidate(text = \"averylongwordandanotherlongwordandafewmorewords\") == \"averylongwordandanotherlongwordandafewmorewords\"\n assert candidate(text = \"this is a test with multiple spaces\") == \"this is a test with multiple spaces \"\n assert candidate(text = \" one two three four five six seven eight nine ten \") == \"one two three four five six seven eight nine ten \"\n assert candidate(text = \"leading oneword\") == \"leading oneword\"\n assert candidate(text = \"many spaces in the middle\") == \"many spaces in the middle \"\n assert candidate(text = \" singleword \") == \"singleword \"\n assert candidate(text = \"equal spaces between each\") == \"equal spaces between each\"\n assert candidate(text = \"testcase with varied spacing\") == \"testcase with varied spacing\"\n assert candidate(text = \" uneven spacing in this sentence \") == \"uneven spacing in this sentence \"\n assert candidate(text = \" verylongwordwithnospaces \") == \"verylongwordwithnospaces \"\n assert candidate(text = \" multiple spaces between words \") == \"multiple spaces between words \"\n assert candidate(text = \"equal equal equal equal\") == \"equal equal equal equal\"\n assert candidate(text = \"a very long sentence with multiple spaces between words to test the algorithm\") == \"a very long sentence with multiple spaces between words to test the algorithm \"\n assert candidate(text = \"onetwothreefourfivesixseveneightnineten\") == \"onetwothreefourfivesixseveneightnineten\"\n assert candidate(text = \"words with uneven spaces\") == \"words with uneven spaces \"\n assert candidate(text = \" many spaces around each word \") == \"many spaces around each word \"\n assert candidate(text = \"spaces at the beginning and the end \") == \"spaces at the beginning and the end \"\n assert candidate(text = \" multiple spaces between words \") == \"multiple spaces between words \"\n assert candidate(text = \" onewordwithspacesonbothends\") == \"onewordwithspacesonbothends \"\n assert candidate(text = \"equal spaces between words\") == \"equal spaces between words\"\n assert candidate(text = \"uneven spacing between words\") == \"uneven spacing between words \"\n assert candidate(text = \"spaces at the beginning and end spaces\") == \"spaces at the beginning and end spaces\"\n assert candidate(text = \" a b c d e f g \") == \"a b c d e f g \"\n assert candidate(text = \"lastwordwithaspaceattheend \") == \"lastwordwithaspaceattheend \"\n assert candidate(text = \"equal spacing between words\") == \"equal spacing between words\"\n assert candidate(text = \" spaces at the start and end \") == \"spaces at the start and end\"\n assert candidate(text = \"short words in here\") == \"short words in here\"\n assert candidate(text = \"shortwords\") == \"shortwords\"\n assert candidate(text = \"equal spaces should be here\") == \"equal spaces should be here \"\n assert candidate(text = \"a b c d e f g\") == \"a b c d e f g\"\n assert candidate(text = \"one twothree four five six seven\") == \"one twothree four five six seven\"\n assert candidate(text = \" onebigwordwith manyspaces and a few words\") == \"onebigwordwith manyspaces and a few words \"\n assert candidate(text = \"averylongword withaverylongword\") == \"averylongword withaverylongword\"\n assert candidate(text = \"no extra spaces\") == \"no extra spaces\"\n assert candidate(text = \" spacesatthestart\") == \"spacesatthestart \"\n assert candidate(text = \" one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen\") == \"one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen \"\n assert candidate(text = \"spacesattheend \") == \"spacesattheend \"\n assert candidate(text = \"many many many spaces\") == \"many many many spaces\"\n assert candidate(text = \" multiple spaces between words \") == \"multiple spaces between words \"\n assert candidate(text = \"onlyone\") == \"onlyone\"\n assert candidate(text = \"a a a a a a\") == \"a a a a a a\"\n assert candidate(text = \" extra spaces should go to the end\") == \"extra spaces should go to the end \"\n assert candidate(text = \" a b c d \") == \"a b c d \"\n assert candidate(text = \" singlewordwithmanyspaces\") == \"singlewordwithmanyspaces \"\n assert candidate(text = \"averylongword with spaces\") == \"averylongword with spaces \"\n assert candidate(text = \"equal spaces between words\") == \"equal spaces between words\"\n assert candidate(text = \"uneven spacing is tricky\") == \"uneven spacing is tricky\"\n assert candidate(text = \" singleword \") == \"singleword \"\n assert candidate(text = \"beginning spaces are here\") == \"beginning spaces are here\"\n assert candidate(text = \"justoneverylongwordwithoutspaces\") == \"justoneverylongwordwithoutspaces\"\n assert candidate(text = \" a b c d e f g h i j \") == \"a b c d e f g h i j \"\n assert candidate(text = \" one two three four \") == \"one two three four\"\n assert candidate(text = \"only one space\") == \"only one space\"\n assert candidate(text = \"longwordssubstitutingforspaceswhicharespacious\") == \"longwordssubstitutingforspaceswhicharespacious\"\n assert candidate(text = \"a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a\") == \"a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a\"\n assert candidate(text = \"verylongwordwithoutspaces\") == \"verylongwordwithoutspaces\"\n assert candidate(text = \"multiple spaces between words\") == \"multiple spaces between words \"\n assert candidate(text = \"singleword\") == \"singleword\"\n assert candidate(text = \"onewordwithspacesonbothends \") == \"onewordwithspacesonbothends \"\n assert candidate(text = \"uneven spaces at the end\") == \"uneven spaces at the end \"\n assert candidate(text = \"shorttext\") == \"shorttext\"\n assert candidate(text = \" firstwordwithaspaceatthebeginning\") == \"firstwordwithaspaceatthebeginning \"\n assert candidate(text = \"singlewordwithmanyspaces \") == \"singlewordwithmanyspaces \"\n assert candidate(text = \"short words\") == \"short words\"\n assert candidate(text = \"just one word in here\") == \"just one word in here\"\n assert candidate(text = \"verylongwordwithnospaces\") == \"verylongwordwithnospaces\"\n assert candidate(text = \"thisisaverylongword\") == \"thisisaverylongword\"\n assert candidate(text = \"just one word but many spaces\") == \"just one word but many spaces \"\n assert candidate(text = \"a \") == \"a \"\n assert candidate(text = \" spaces at the beginning and the end \") == \"spaces at the beginning and the end \"\n assert candidate(text = \" spaces at the end of the sentence \") == \"spaces at the end of the sentence \"\n assert candidate(text = \"a single word surrounded by spaces\") == \"a single word surrounded by spaces\"\n assert candidate(text = \" \") == \"\"\n assert candidate(text = \" multiple spaces between words \") == \"multiple spaces between words \"\n assert candidate(text = \" word with multiple spaces in between words \") == \"word with multiple spaces in between words \"\n assert candidate(text = \" justone \") == \"justone \"\n assert candidate(text = \"short longword evenlongerword\") == \"short longword evenlongerword\"\n assert candidate(text = \" multiple spaces between words \") == \"multiple spaces between words \"\n assert candidate(text = \"just one more test case\") == \"just one more test case\"\n assert candidate(text = \"a b c d e f g\") == \"a b c d e f g \"\n assert candidate(text = \"many many many many many\") == \"many many many many many\"\n assert candidate(text = \"many spaces at the end \") == \"many spaces at the end\"\n assert candidate(text = \"word1 word2word3word4word5\") == \"word1 word2word3word4word5\"\n assert candidate(text = \"multiple spaces between words\") == \"multiple spaces between words\"\n assert candidate(text = \"multiple spaces between words\") == \"multiple spaces between words \"\n"}, "metadata": {"canonical_parameter_names": ["text"], "leetcode_dataset_entry_point": "Solution().reorderSpaces", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string reorderSpaces(string text) {", "container": "Solution", "callable": "reorderSpaces", "parameters": [{"name": "text", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1593, "task_id": "split-a-string-into-the-max-number-of-unique-substrings", "difficulty": "Medium", "problem_description": "Given a string s, return the maximum number of unique substrings that the given string can be split into.\nYou can split string s into any list of non-empty substrings, where the concatenation of the substrings forms the original string. However, you must split the substrings such that all of them are unique.\nA substring is a contiguous sequence of characters within a string.\n \nExample 1:\n\nInput: s = \"ababccc\"\nOutput: 5\nExplanation: One way to split maximally is ['a', 'b', 'ab', 'c', 'cc']. Splitting like ['a', 'b', 'a', 'b', 'c', 'cc'] is not valid as you have 'a' and 'b' multiple times.\n\nExample 2:\n\nInput: s = \"aba\"\nOutput: 2\nExplanation: One way to split maximally is ['a', 'ba'].\n\nExample 3:\n\nInput: s = \"aa\"\nOutput: 1\nExplanation: It is impossible to split the string any further.\n\n \nConstraints:\n\n\n1 <= s.length <= 16\n\n\ns contains only lower case English letters.\n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaaabbbb\") == 5\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"abac\") == 3\n assert candidate(s = \"abcdef\") == 6\n assert candidate(s = \"aaaaaaaab\") == 4\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"zzzzzzz\") == 3\n assert candidate(s = \"abcabcabc\") == 6\n assert candidate(s = \"abcabcabcabc\") == 7\n assert candidate(s = \"ababccc\") == 5\n assert candidate(s = \"zzzzzzzzzzzzzzzz\") == 5\n assert candidate(s = \"aa\") == 1\n assert candidate(s = \"abcabc\") == 4\n assert candidate(s = \"abcdabcd\") == 6\n assert candidate(s = \"xyzxyzxyz\") == 6\n assert candidate(s = \"noon\") == 3\n assert candidate(s = \"abacabad\") == 5\n assert candidate(s = \"banana\") == 4\n assert candidate(s = \"aba\") == 2\n assert candidate(s = \"zzzzzz\") == 3\n assert candidate(s = \"aabbcc\") == 4\n assert candidate(s = \"zabac\") == 4\n assert candidate(s = \"abcdabcdabcdabcd\") == 9\n assert candidate(s = \"abacaba\") == 4\n assert candidate(s = \"aabbccdd\") == 6\n assert candidate(s = \"abcdefg\") == 7\n assert candidate(s = \"xyxyxyxyxyxyxyxy\") == 7\n assert candidate(s = \"ababcabcabc\") == 7\n assert candidate(s = \"abacabacabacabac\") == 8\n assert candidate(s = \"abacabadabacabadabacabadabacabad\") == 13\n assert candidate(s = \"xyzzyxzyxzy\") == 7\n assert candidate(s = \"ababababababababababababababababab\") == 10\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\") == 20\n assert candidate(s = \"hellohellohello\") == 9\n assert candidate(s = \"abacabadabacabad\") == 9\n assert candidate(s = \"repaid\") == 6\n assert candidate(s = \"aaaaabbbbccccdddd\") == 10\n assert candidate(s = \"abccbaabccba\") == 7\n assert candidate(s = \"redder\") == 4\n assert candidate(s = \"aabaaaabbaabaaab\") == 7\n assert candidate(s = \"abacaxabacaxabacax\") == 10\n assert candidate(s = \"optimization\") == 10\n assert candidate(s = \"aaaaaaaaaaaaaaa\") == 5\n assert candidate(s = \"xyzzyxzyxzyzyxzyz\") == 9\n assert candidate(s = \"kayak\") == 4\n assert candidate(s = \"abcdabcde\") == 7\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\") == 26\n assert candidate(s = \"abababababababab\") == 7\n assert candidate(s = \"ababababababab\") == 6\n assert candidate(s = \"abababababab\") == 6\n assert candidate(s = \"zzzyzxzyzzzzzzzzzz\") == 7\n assert candidate(s = \"abcdefghijkabcdefghijk\") == 16\n assert candidate(s = \"abcabcabcabcabcabc\") == 9\n assert candidate(s = \"abcdefghijklmnop\") == 16\n assert candidate(s = \"level\") == 4\n assert candidate(s = \"ababababababababababababababababa\") == 10\n assert candidate(s = \"abcabcdabcdeabcde\") == 10\n assert candidate(s = \"abcdefghijjihgfedcba\") == 15\n assert candidate(s = \"aaaaaabbbbbbaaaaabbbbbbbaaaa\") == 11\n assert candidate(s = \"aabbaabbccddeeff\") == 11\n assert candidate(s = \"abacabadabacaba\") == 8\n assert candidate(s = \"xyzxyzxyzxyzxyzxyz\") == 9\n assert candidate(s = \"abcdabcdeabcdeabcd\") == 11\n assert candidate(s = \"abcdabcdaabbcc\") == 9\n assert candidate(s = \"abcdefgabcdefg\") == 10\n assert candidate(s = \"abcdeabcdeabcdeabcde\") == 11\n assert candidate(s = \"aabbaabbccdd\") == 8\n assert candidate(s = \"aabbccddeeffgg\") == 10\n assert candidate(s = \"detartrated\") == 8\n assert candidate(s = \"abcdefghij\") == 10\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 26\n assert candidate(s = \"aaaabbbbccccdddd\") == 10\n assert candidate(s = \"aabacabadaba\") == 7\n assert candidate(s = \"abacabadabacabadabacabad\") == 11\n assert candidate(s = \"deified\") == 5\n assert candidate(s = \"noonnoonnoon\") == 6\n assert candidate(s = \"repaper\") == 5\n assert candidate(s = \"abbaabbaabba\") == 6\n assert candidate(s = \"bcbcbcbcbcbcbcbc\") == 7\n assert candidate(s = \"aaaaaaaaaaaaaaaa\") == 5\n assert candidate(s = \"abacdfgdcaba\") == 8\n assert candidate(s = \"abcdeabcdeabcde\") == 10\n assert candidate(s = \"abcdabcabcda\") == 8\n assert candidate(s = \"ababababab\") == 5\n assert candidate(s = \"abcdefgabcdefgabcdefg\") == 14\n assert candidate(s = \"rotor\") == 4\n assert candidate(s = \"abcdefghihgfedcba\") == 13\n assert candidate(s = \"racecar\") == 5\n assert candidate(s = \"abcdefghijabcdefghij\") == 15\n assert candidate(s = \"abcabcabcabcabcabcabcabc\") == 10\n assert candidate(s = \"aabbccddeeffggzzzz\") == 13\n assert candidate(s = \"abcdefabcdefabcdefabcdef\") == 14\n assert candidate(s = \"aaaaabbbbccccddddeeeefffggg\") == 16\n assert candidate(s = \"reviled\") == 6\n assert candidate(s = \"abcdefghabcdefgh\") == 12\n assert candidate(s = \"aabbccddeeffgghh\") == 12\n assert candidate(s = \"zzzzyyyxxxwwwvvvuuu\") == 12\n assert candidate(s = \"mississippi\") == 7\n assert candidate(s = \"abcdeabcdeabcdeabc\") == 11\n assert candidate(s = \"abcabcabcaabbcc\") == 9\n assert candidate(s = \"abcabcabcabcabc\") == 8\n assert candidate(s = \"xyzzzyxyzzzyxyzzzyxyzzzy\") == 11\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxUniqueSplit", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxUniqueSplit(string s) {", "container": "Solution", "callable": "maxUniqueSplit", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1594, "task_id": "maximum-non-negative-product-in-a-matrix", "difficulty": "Medium", "problem_description": "You are given a m x n matrix grid. Initially, you are located at the top-left corner (0, 0), and in each step, you can only move right or down in the matrix.\nAmong all possible paths starting from the top-left corner (0, 0) and ending in the bottom-right corner (m - 1, n - 1), find the path with the maximum non-negative product. The product of a path is the product of all integers in the grid cells visited along the path.\nReturn the maximum non-negative product modulo 109 + 7. If the maximum product is negative, return -1.\nNotice that the modulo is performed after getting the maximum product.\n \nExample 1:\n\n\nInput: grid = [[-1,-2,-3],[-2,-3,-3],[-3,-3,-2]]\nOutput: -1\nExplanation: It is not possible to get non-negative product in the path from (0, 0) to (2, 2), so return -1.\n\nExample 2:\n\n\nInput: grid = [[1,-2,1],[1,-2,1],[3,-4,1]]\nOutput: 8\nExplanation: Maximum non-negative product is shown (1 * 1 * -2 * -4 * 1 = 8).\n\nExample 3:\n\n\nInput: grid = [[1,3],[0,-4]]\nOutput: 0\nExplanation: Maximum non-negative product is shown (1 * 0 * -4 = 0).\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 15\n-4 <= grid[i][j] <= 4\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[-1, -2, -3], [-2, -3, -3], [-3, -3, -2]]) == -1\n assert candidate(grid = [[-1, 0], [-8, -2]]) == 0\n assert candidate(grid = [[-1, 0], [-2, -1]]) == 0\n assert candidate(grid = [[-4, 3], [-3, -4]]) == 48\n assert candidate(grid = [[0, 0], [0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 1\n assert candidate(grid = [[2, 3, 4], [0, 1, 5]]) == 120\n assert candidate(grid = [[-1, 2, -3], [-4, 5, -6], [-7, -8, 9]]) == 2016\n assert candidate(grid = [[-1, -1, -1], [-1, -1, -1], [-1, -1, -1]]) == -1\n assert candidate(grid = [[-1, 2], [-3, 4]]) == 12\n assert candidate(grid = [[2, -3, 4], [-1, -2, 3], [1, 2, -5]]) == 360\n assert candidate(grid = [[1, -2, 1], [1, -2, 1], [3, -4, 1]]) == 8\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1], [1, 1]]) == 1\n assert candidate(grid = [[-1, 0], [-2, -3]]) == 0\n assert candidate(grid = [[1, 2], [3, 4]]) == 12\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 1\n assert candidate(grid = [[1, 3], [0, -4]]) == 0\n assert candidate(grid = [[-4, -4], [-4, -4]]) == -1\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 2016\n assert candidate(grid = [[-1, -4, -7], [-2, -5, -8], [-3, -6, -9]]) == -1\n assert candidate(grid = [[-1, 2, -3], [4, -5, 6], [-7, 8, -9]]) == -1\n assert candidate(grid = [[2, 3, -1, 4], [1, -2, 3, -3], [-4, 5, -6, 7], [-8, -9, 10, 11]]) == 59400\n assert candidate(grid = [[-2, -3, 0, -4], [-1, -2, -3, 1], [0, -1, -2, -3], [2, 3, 4, -5]]) == 1440\n assert candidate(grid = [[-1, 0, 1], [0, 0, 0], [1, 0, -1]]) == 0\n assert candidate(grid = [[-1, 0, 0, 0], [-1, 0, 0, 0], [-1, 0, 0, 0], [-1, 0, 0, 0]]) == 0\n assert candidate(grid = [[-1, 2, -3, 4, -5], [6, -7, 8, -9, 10], [11, -12, 13, -14, 15], [16, -17, 18, -19, 20], [21, -22, 23, -24, 25]]) == 450227165\n assert candidate(grid = [[-1, -1, -1, -1], [1, 1, 1, 1], [-1, -1, -1, -1], [1, 1, 1, 1]]) == 1\n assert candidate(grid = [[-4, 3, -2, 1], [2, -1, 3, -4], [3, -4, 2, 1], [4, 1, -3, 2]]) == 576\n assert candidate(grid = [[-3, 3, -4, 1], [2, -1, 2, -3], [-2, 3, -2, 1], [4, -4, 3, -3]]) == 1728\n assert candidate(grid = [[-1, 2, -3, 4, -5], [5, -6, 7, -8, 9], [-10, 11, -12, 13, -14], [15, -16, 17, -18, 19], [-20, 21, -22, 23, -24]]) == -1\n assert candidate(grid = [[-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]]) == -1\n assert candidate(grid = [[-1, 0, 1, 0, -1], [-1, 1, 0, 1, -1], [0, -1, 1, -1, 0], [1, -1, 0, 1, -1], [-1, 0, 1, 0, -1]]) == 1\n assert candidate(grid = [[2, -2, 3, -3], [-3, 3, -2, 2], [2, -2, 3, -3], [-3, 3, -2, 2]]) == -1\n assert candidate(grid = [[-1, 3, -4, 2], [-2, 1, -1, 0], [3, -3, 2, -3], [4, 0, -1, 2]]) == 216\n assert candidate(grid = [[0, 1, 2, 3, 4, 5], [0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[-1, 0, 0, 0], [-2, 0, 0, 0], [-3, 0, 0, 0], [-4, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]) == 75000\n assert candidate(grid = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[-3, -2, 1], [-2, -1, 3], [-1, 3, -2]]) == 36\n assert candidate(grid = [[4, 3, 2, 1], [3, 2, 1, 0], [2, 1, 0, -1], [1, 0, -1, -2]]) == 0\n assert candidate(grid = [[-2, 0, 2, 0], [-1, -2, -3, -1], [0, 1, 0, 1], [2, -2, 1, -3]]) == 36\n assert candidate(grid = [[1, -1, 1, -1, 1], [-1, 1, -1, 1, -1], [1, -1, 1, -1, 1], [-1, 1, -1, 1, -1], [1, -1, 1, -1, 1]]) == 1\n assert candidate(grid = [[-1, 2, -3, 4], [-2, 3, -4, 5], [3, -4, 5, -6], [4, 5, -6, 7]]) == 5040\n assert candidate(grid = [[1, -1, 2, -3], [2, -2, 3, 4], [-3, 3, -4, 5], [0, -1, 2, -2]]) == 480\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == 1965600\n assert candidate(grid = [[-4, 3, 2, -1, 0], [0, 2, -3, 1, 4], [-1, 2, -1, 3, -2], [3, -2, 1, -1, 2], [1, -3, 2, -2, -4]]) == 4608\n assert candidate(grid = [[4, 3, 2, 1], [3, 2, 1, 0], [2, 1, 0, -1], [1, 0, -1, -2]]) == 0\n assert candidate(grid = [[-1, 2, 3, 4], [5, 6, -7, 8], [-9, 10, 11, -12], [13, -14, 15, 16]]) == 1188000\n assert candidate(grid = [[-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1], [-1, -1, -1, -1, -1]]) == -1\n assert candidate(grid = [[1, -2, 3, -4], [4, -1, 2, -3], [3, 2, -1, 4]]) == 144\n assert candidate(grid = [[4, -1, 2], [1, 2, -1], [2, -1, 4], [-1, 4, -1]]) == 32\n assert candidate(grid = [[1, -1, 0], [1, 0, 1], [0, 1, 1]]) == 0\n assert candidate(grid = [[0, 1, 2, 3, 4], [4, 3, 2, 1, 0], [-1, -2, -3, -4, -5], [-5, -4, -3, -2, -1]]) == 0\n assert candidate(grid = [[0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, -1], [0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3]]) == 13608000\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 732633558\n assert candidate(grid = [[-1, 0, -1], [0, -1, 0], [-1, 0, -1]]) == 0\n assert candidate(grid = [[0, 0, 1], [0, -1, 0], [-1, 0, 0]]) == 0\n assert candidate(grid = [[-1, 0, 0, -1], [0, -1, 0, -1], [0, 0, -1, 0], [-1, 0, 0, -1]]) == 0\n assert candidate(grid = [[-1, -2, -3, -4], [-2, -3, -4, -5], [-3, -4, -5, -6], [-4, -5, -6, -7]]) == -1\n assert candidate(grid = [[-1, 2, -1, 3], [2, -3, 4, -2], [3, -1, -2, 2], [1, -3, 2, -1]]) == 96\n assert candidate(grid = [[4, -3, -2], [-2, 1, 0], [3, -5, 6]]) == 720\n assert candidate(grid = [[0, 3, 0, 4], [0, 0, 0, 0], [0, 4, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(grid = [[-1, 2, -3, 4, -5], [2, -3, 4, -5, 6], [-3, 4, -5, 6, -7], [4, -5, 6, -7, 8], [-5, 6, -7, 8, -9]]) == -1\n assert candidate(grid = [[-1, 2, -3, 4], [-5, 6, -7, 8], [-9, 10, -11, 12], [-13, 14, -15, 16]]) == 1512000\n assert candidate(grid = [[1, -1, 0, 2], [-1, 2, 3, -1], [0, 1, -1, 1], [2, -2, 1, -3]]) == 0\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]) == 674358851\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 1\n assert candidate(grid = [[-4, -3, -2, -1], [-3, -2, -1, 0], [-2, -1, 0, 1], [-1, 0, 1, 2]]) == 0\n assert candidate(grid = [[-2, -3, -4], [-1, -5, -6], [-7, -8, -9]]) == -1\n assert candidate(grid = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]) == 362880\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]) == 5040\n assert candidate(grid = [[-1, -2, -3, -4, -5], [-2, -3, -4, -5, -6], [-3, -4, -5, -6, -7], [-4, -5, -6, -7, -8], [-5, -6, -7, -8, -9]]) == -1\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) == 36960\n assert candidate(grid = [[1, -1, 2, -2, 3, -3], [4, -4, 5, -5, 6, -6], [7, -7, 8, -8, 9, -9], [10, -10, 11, -11, 12, -12], [13, -13, 14, -14, 15, -15]]) == 605239993\n assert candidate(grid = [[-1, -2, -3, -4], [-2, -3, -3, -4], [-3, -4, -5, -6], [-4, -5, -6, -7]]) == -1\n assert candidate(grid = [[1, -2, 3, -4], [5, 6, -7, 8], [-9, 10, -11, 12], [13, -14, 15, -16]]) == 1008000\n assert candidate(grid = [[0, 1, 2, 3, 4], [1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8]]) == 0\n assert candidate(grid = [[-2, -3, 1, -4], [-3, -2, 1, 3], [-1, 2, -3, 1]]) == 72\n assert candidate(grid = [[4, -1, -2, 3], [-1, 2, 1, -1], [-2, -1, 3, 4], [1, -3, 2, 1]]) == 96\n assert candidate(grid = [[2, 3, 4, 5, 6], [7, 8, 9, 10, 11], [12, 13, 14, 15, 16], [17, 18, 19, 20, 21], [22, 23, 24, 25, 26]]) == 544121446\n assert candidate(grid = [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24]]) == 0\n assert candidate(grid = [[4, -4, 3, -3], [-3, 3, -2, 2], [2, -2, 3, -3], [-3, 3, -2, 2]]) == -1\n assert candidate(grid = [[-1, -2, -3, -4], [-4, -5, -6, -7], [-8, -9, -10, -11], [-12, -13, -14, -15]]) == -1\n assert candidate(grid = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]) == 362880\n assert candidate(grid = [[-4, -3, -2, -1], [1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6]]) == 8640\n assert candidate(grid = [[0, -1, 1], [1, -1, 0], [-1, 0, 1]]) == 0\n assert candidate(grid = [[-1, 2, -3, 4], [-4, 1, -2, 3], [2, -1, 4, -3], [3, 4, -1, 2]]) == 288\n assert candidate(grid = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == 0\n assert candidate(grid = [[-2, -3, 0, -1], [-1, -2, -3, -4], [0, -1, -2, -3], [-3, -4, -5, -6]]) == 0\n assert candidate(grid = [[2, -1, 3, -4], [1, 0, 5, -1], [3, -2, 4, 1]]) == 30\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[4, -1, 2], [2, -3, 4], [-1, 2, -3]]) == 288\n assert candidate(grid = [[1, 2, 3], [-1, -2, -3], [1, 2, 3]]) == 36\n assert candidate(grid = [[-1, -2, -3], [-3, -4, -5], [-5, -6, -7]]) == -1\n assert candidate(grid = [[-1, 0, 1], [0, 1, 0], [1, 0, -1]]) == 0\n assert candidate(grid = [[-4, -3, -2], [-2, -1, 0], [3, -5, 6]]) == 360\n assert candidate(grid = [[-4, -4, -4, -4], [-4, -4, -4, -4], [-4, -4, -4, -4], [-4, -4, -4, -4]]) == -1\n assert candidate(grid = [[-2, 3, -1, 4], [-1, 2, -3, 5], [3, -4, 5, -6], [4, -5, 6, -7]]) == 10080\n assert candidate(grid = [[1, -1, 2, -4], [-2, 3, -1, 2], [4, -2, 3, -1], [-2, 1, -3, 4]]) == -1\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 2016\n assert candidate(grid = [[2, -2, 3, 4, -1], [-1, 3, 2, 1, -2], [1, 2, -3, 2, -1], [3, 1, -2, -1, 2], [1, -2, 2, 1, -3]]) == 864\n assert candidate(grid = [[2, -3, 4, 5], [-1, 3, 2, -2], [2, -1, -2, -1], [1, 2, 3, -1]]) == 240\n assert candidate(grid = [[2, 3, 4], [1, 0, 1], [4, 3, 2], [3, 2, 1]]) == 48\n assert candidate(grid = [[-1, 3, -1, -4, 1], [-2, 1, 2, 3, -1], [3, -2, -1, 1, 2], [1, 2, -3, 4, -2]]) == 288\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]) == 5040\n assert candidate(grid = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15]]) == 674358851\n assert candidate(grid = [[-1, 2, -1, 3], [1, -2, 1, -1], [2, 1, -1, -3], [1, -1, -2, 1]]) == 18\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [1, 2, 3, 4, 5]]) == 72000\n assert candidate(grid = [[0, -1, -2, -3], [-1, 0, -1, -2], [-2, -1, 0, -1], [-3, -2, -1, 0]]) == 0\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().maxProductPath", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxProductPath(vector>& grid) {", "container": "Solution", "callable": "maxProductPath", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1595, "task_id": "minimum-cost-to-connect-two-groups-of-points", "difficulty": "Hard", "problem_description": "You are given two groups of points where the first group has size1 points, the second group has size2 points, and size1 >= size2.\nThe cost of the connection between any two points are given in an size1 x size2 matrix where cost[i][j] is the cost of connecting point i of the first group and point j of the second group. The groups are connected if each point in both groups is connected to one or more points in the opposite group. In other words, each point in the first group must be connected to at least one point in the second group, and each point in the second group must be connected to at least one point in the first group.\nReturn the minimum cost it takes to connect the two groups.\n \nExample 1:\n\n\nInput: cost = [[15, 96], [36, 2]]\nOutput: 17\nExplanation: The optimal way of connecting the groups is:\n1--A\n2--B\nThis results in a total cost of 17.\n\nExample 2:\n\n\nInput: cost = [[1, 3, 5], [4, 1, 1], [1, 5, 3]]\nOutput: 4\nExplanation: The optimal way of connecting the groups is:\n1--A\n2--B\n2--C\n3--A\nThis results in a total cost of 4.\nNote that there are multiple points connected to point 2 in the first group and point A in the second group. This does not matter as there is no limit to the number of points that can be connected. We only care about the minimum total cost.\n\nExample 3:\n\nInput: cost = [[2, 5, 1], [3, 4, 7], [8, 1, 2], [6, 2, 4], [3, 8, 8]]\nOutput: 10\n\n \nConstraints:\n\nsize1 == cost.length\nsize2 == cost[i].length\n1 <= size1, size2 <= 12\nsize1 >= size2\n0 <= cost[i][j] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(cost = [[2, 5, 1], [3, 4, 7], [8, 1, 2], [6, 2, 4], [3, 8, 8]]) == 10\n assert candidate(cost = [[1, 3, 5], [4, 1, 1], [1, 5, 3]]) == 4\n assert candidate(cost = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 16\n assert candidate(cost = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6]]) == 13\n assert candidate(cost = [[15, 96], [36, 2]]) == 17\n assert candidate(cost = [[10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10]]) == 40\n assert candidate(cost = [[10, 20], [30, 40], [50, 60]]) == 100\n assert candidate(cost = [[5, 5, 5], [5, 5, 5]]) == 15\n"}, "metadata": {"canonical_parameter_names": ["cost"], "leetcode_dataset_entry_point": "Solution().connectTwoGroups", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int connectTwoGroups(vector>& cost) {", "container": "Solution", "callable": "connectTwoGroups", "parameters": [{"name": "cost", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1598, "task_id": "crawler-log-folder", "difficulty": "Easy", "problem_description": "The Leetcode file system keeps a log each time some user performs a change folder operation.\nThe operations are described below:\n\n\"../\" : Move to the parent folder of the current folder. (If you are already in the main folder, remain in the same folder).\n\"./\" : Remain in the same folder.\n\"x/\" : Move to the child folder named x (This folder is guaranteed to always exist).\n\nYou are given a list of strings logs where logs[i] is the operation performed by the user at the ith step.\nThe file system starts in the main folder, then the operations in logs are performed.\nReturn the minimum number of operations needed to go back to the main folder after the change folder operations.\n \nExample 1:\n\n\nInput: logs = [\"d1/\",\"d2/\",\"../\",\"d21/\",\"./\"]\nOutput: 2\nExplanation: Use this change folder operation \"../\" 2 times and go back to the main folder.\n\nExample 2:\n\n\nInput: logs = [\"d1/\",\"d2/\",\"./\",\"d3/\",\"../\",\"d31/\"]\nOutput: 3\n\nExample 3:\n\nInput: logs = [\"d1/\",\"../\",\"../\",\"../\"]\nOutput: 0\n\n \nConstraints:\n\n1 <= logs.length <= 103\n2 <= logs[i].length <= 10\nlogs[i] contains lowercase English letters, digits, '.', and '/'.\nlogs[i] follows the format described in the statement.\nFolder names consist of lowercase English letters and digits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(logs = ['d1/', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', '../', 'd21/', './']) == 2\n assert candidate(logs = ['d1/', '../', 'd2/', '../', 'd3/', '../', 'd4/', '../', 'd5/', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', '../', '../', '../', '../', 'd5/']) == 1\n assert candidate(logs = ['d1/', '../', 'd2/', '../', 'd3/', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', '../../..']) == 4\n assert candidate(logs = ['d1/', '../', 'd2/', '../', 'd3/', '../', 'd4/']) == 1\n assert candidate(logs = ['./', './', 'd1/']) == 1\n assert candidate(logs = ['d1/', '../', 'd2/', '../', 'd3/', '../', 'd4/', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', './', 'd3/', '../', 'd31/']) == 3\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', 'd4/', 'd5/', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', 'd3/', 'd4/']) == 3\n assert candidate(logs = ['./', './', './']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/']) == 4\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', '../../../../']) == 5\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['../', '../', 'd1/']) == 1\n assert candidate(logs = ['./', './', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', 'd11/', 'd12/', 'd13/', 'd14/', 'd15/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', '../', '../', '../', '../', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', './', './', 'd3/', 'd4/', 'd5/', '../', '../', '../', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['x1/', 'x2/', 'x3/', '../../', 'y1/', 'y2/', 'y3/', '../', 'z1/', 'z2/', '../', '../', '../']) == 4\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', '../../', '../', '../../', '../', '../../', '../', '../../', '../', '../', '../', '../']) == 2\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', 'd11/', 'd12/', 'd13/', 'd14/', 'd15/', 'd16/', 'd17/', 'd18/', 'd19/', 'd20/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../', '../', '../', '../', '../', '../', '../', '../', 'd11/', 'd12/', 'd13/', 'd14/', 'd15/', 'd16/', 'd17/', 'd18/', 'd19/', 'd20/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', './', './', './', '../', '../', '../', 'd6/', 'd7/', 'd8/', './', './', './', '../', '../', '../', 'd9/', 'd10/', 'd11/', './', './', './', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['./', './', './', 'folderA/', '../', 'folderB/', 'folderC/', '../', 'folderD/', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', './', 'd4/', '../', '../', 'd5/', '../', '../', 'd6/', '../', 'd7/', './', './', 'd8/', '../', '../', 'd9/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['deep1/', 'deep2/', 'deep3/', 'deep4/', 'deep5/', 'deep6/', 'deep7/', 'deep8/', 'deep9/', 'deep10/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', '../', '../', '../', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', 'd11/', 'd12/', 'd13/', 'd14/', 'd15/', 'd16/', 'd17/', 'd18/', 'd19/', 'd20/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', 'd4/', 'd5/', '../', 'd6/', 'd7/', '../', '../', 'd8/', 'd9/', '../', '../', 'd10/', 'd11/', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', '../', 'd3/', 'd4/', 'd5/', '../', '../', '../', 'd6/', 'd7/', 'd8/', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['./', './', './', 'd1/', '../', 'd2/', '../', '../', 'd3/', '../', '../', 'd4/', '../', '../', 'd5/', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', './', './', './', '../', '../', '../', 'd5/', 'd6/', 'd7/', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', './', 'd4/', 'd5/', './', '../', 'd6/', 'd7/', './', '../', 'd8/', 'd9/', './', '../', 'd10/', 'd11/', './', '../', '../', '../', '../', '../', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', 'd4/', 'd5/', 'd6/', '../', 'd7/', '../', '../', 'd8/', 'd9/', '../', '../', 'd10/', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', './', './', './', '../', '../', 'd6/', 'd7/', 'd8/', '../', '../', '../', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', './', './', './', '../', 'd3/', 'd4/', '../', '../', '../', '../', '../', './', './', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', 'd11/', 'd12/', 'd13/', 'd14/', 'd15/', 'd16/', 'd17/', 'd18/', 'd19/', 'd20/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', '../', './', 'd3/', 'd4/', '../', '../', 'd5/', 'd6/', '../', '../', '../', 'd7/']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', 'd4/', 'd5/', '../', 'd6/', 'd7/', '../', '../', '../', 'd8/']) == 2\n assert candidate(logs = ['folder1/', 'folder2/', '../', 'folder3/', 'folder4/', 'folder5/', 'folder6/', '../../', 'folder7/', 'folder8/', '../', '../', '../', '../', '../']) == 2\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', '../', 'd6/', 'd7/', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', 'd4/', 'd5/', '../', 'd6/', 'd7/', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', '../', 'd21/', '../', 'd211/', '../', '../', 'd2111/', '../', '../', '../', '../', 'd21111/', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', 'd4/', 'd5/', '../', '../', 'd6/', 'd7/', '../', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', './', './', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../', 'd1/', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', './', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', 'd11/', 'd12/', 'd13/', 'd14/', 'd15/', 'd16/', 'd17/', 'd18/', 'd19/', 'd20/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', 'd11/', 'd12/', 'd13/', 'd14/', 'd15/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', 'd4/', 'd5/', '../', '../', 'd6/', 'd7/', '../', '../', '../', 'd8/', 'd9/', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', './', 'd2/', 'd3/', '../', 'd4/', 'd5/', 'd6/', 'd7/', '../', '../', '../', '../', '../', '../', 'd8/', 'd9/', 'd10/', 'd11/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', '../', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../', '../', '../', '../', '../', '../', '../', '../', '../', 'd11/', 'd12/', 'd13/', 'd14/', 'd15/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', '../', '../', 'd4/', 'd5/', 'd6/', 'd7/', '../', '../', 'd8/', 'd9/', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', './', 'd4/', '../', 'd5/', '../', 'd6/', './', '../', 'd7/', '../', '../', 'd8/', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', '../../', '../../', '../', '../', '../', '../', '../']) == 4\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', 'd1/', 'd2/', 'd3/', '../', '../', 'd1/', 'd2/', 'd3/', '../', '../', 'd1/', 'd2/', 'd3/', '../', '../', '../', '../']) == 2\n assert candidate(logs = ['a/', 'b/', '../', 'c/', './', 'd/', '../', 'e/', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', '../', '../', '../', 'd1/', 'd2/', 'd3/', '../', '../', '../', '../', '../', 'd4/', 'd5/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../../', '../../', '../../', '../../', '../../', '../../', '../../', '../../', '../../', '../../']) == 10\n assert candidate(logs = ['main/', 'sub1/', 'sub2/', 'sub3/', 'sub4/', 'sub5/', 'sub6/', 'sub7/', 'sub8/', 'sub9/', 'sub10/', '../../../../../../', '../']) == 10\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', './', 'd2/', '../', 'd3/', './', 'd4/', '../', 'd5/', './', 'd6/', '../', 'd7/', './', 'd8/', '../', 'd9/', './', '../', '../', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', '../', 'd2/', 'd3/', '../', '../', 'd4/', 'd5/', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../', './', '../']) == 0\n assert candidate(logs = ['alpha/', 'beta/', 'gamma/', './', 'delta/', 'epsilon/', 'zeta/', 'eta/', 'theta/', 'iota/', 'kappa/', 'lambda/', 'mu/', 'nu/', 'xi/', 'omicron/', 'pi/', 'rho/', 'sigma/', 'tau/', 'upsilon/', 'phi/', 'chi/', 'psi/', 'omega/', '../../../../../../../../../', '../', '../', '../', '../']) == 20\n assert candidate(logs = ['d1/', '../', 'd2/', '../', 'd3/', '../', 'd4/', '../', 'd5/', '../', 'd6/', '../', 'd7/', '../', 'd8/', '../', 'd9/', '../', 'd10/', '../', 'd11/', '../', 'd12/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', 'd9/', 'd10/', 'd11/', 'd12/', 'd13/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', './', './', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', '../', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', '../../', './', '../../', 'd9/', 'd10/', 'd11/', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../../../../..']) == 10\n assert candidate(logs = ['d1/', 'd2/', '../', 'd3/', 'd4/', 'd5/', './', 'd6/', '../', 'd7/', 'd8/', 'd9/', 'd10/', './', './', '../', '../', '../', 'd11/', 'd12/', '../', '../', '../', '../', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', '../', '../', '../', '../', '../', 'd6/', 'd7/', '../', 'd8/', '../', 'd9/', 'd10/', '../', '../', '../', '../', '../', 'd11/', 'd12/', 'd13/', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['./', '../', './', 'd1/', 'd2/', '../', './', 'd21/', '../', './', 'd211/', '../', './', 'd2111/', '../', './', 'd21111/', '../', './', '../', './']) == 0\n assert candidate(logs = ['d1/', 'd2/', '../', 'd3/', 'd4/', 'd5/', 'd6/', '../', '../', '../', '../', 'd7/', 'd8/', 'd9/']) == 4\n assert candidate(logs = ['d1/', 'd2/', '../', '../', './', 'd3/', 'd4/', '../', 'd5/', 'd6/', '../', 'd7/', './', '../', '../', '../', 'd8/']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', './', './', './', '../', '../', '../', '../', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', 'd11/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 1\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', './', './', './', './', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', '../', './', 'd4/', 'd5/', '../', '../', 'd6/', '../', '../', '../']) == 0\n assert candidate(logs = ['d1/', 'd2/', 'd3/', 'd4/', 'd5/', 'd6/', 'd7/', 'd8/', 'd9/', 'd10/', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../', '../']) == 0\n"}, "metadata": {"canonical_parameter_names": ["logs"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minOperations(vector& logs) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "logs", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1599, "task_id": "maximum-profit-of-operating-a-centennial-wheel", "difficulty": "Medium", "problem_description": "You are the operator of a Centennial Wheel that has four gondolas, and each gondola has room for up to four people. You have the ability to rotate the gondolas counterclockwise, which costs you runningCost dollars.\nYou are given an array customers of length n where customers[i] is the number of new customers arriving just before the ith rotation (0-indexed). This means you must rotate the wheel i times before the customers[i] customers arrive. You cannot make customers wait if there is room in the gondola. Each customer pays boardingCost dollars when they board on the gondola closest to the ground and will exit once that gondola reaches the ground again.\nYou can stop the wheel at any time, including before serving all customers. If you decide to stop serving customers, all subsequent rotations are free in order to get all the customers down safely. Note that if there are currently more than four customers waiting at the wheel, only four will board the gondola, and the rest will wait for the next rotation.\nReturn the minimum number of rotations you need to perform to maximize your profit. If there is no scenario where the profit is positive, return -1.\n \nExample 1:\n\n\nInput: customers = [8,3], boardingCost = 5, runningCost = 6\nOutput: 3\nExplanation: The numbers written on the gondolas are the number of people currently there.\n1. 8 customers arrive, 4 board and 4 wait for the next gondola, the wheel rotates. Current profit is 4 * $5 - 1 * $6 = $14.\n2. 3 customers arrive, the 4 waiting board the wheel and the other 3 wait, the wheel rotates. Current profit is 8 * $5 - 2 * $6 = $28.\n3. The final 3 customers board the gondola, the wheel rotates. Current profit is 11 * $5 - 3 * $6 = $37.\nThe highest profit was $37 after rotating the wheel 3 times.\n\nExample 2:\n\nInput: customers = [10,9,6], boardingCost = 6, runningCost = 4\nOutput: 7\nExplanation:\n1. 10 customers arrive, 4 board and 6 wait for the next gondola, the wheel rotates. Current profit is 4 * $6 - 1 * $4 = $20.\n2. 9 customers arrive, 4 board and 11 wait (2 originally waiting, 9 newly waiting), the wheel rotates. Current profit is 8 * $6 - 2 * $4 = $40.\n3. The final 6 customers arrive, 4 board and 13 wait, the wheel rotates. Current profit is 12 * $6 - 3 * $4 = $60.\n4. 4 board and 9 wait, the wheel rotates. Current profit is 16 * $6 - 4 * $4 = $80.\n5. 4 board and 5 wait, the wheel rotates. Current profit is 20 * $6 - 5 * $4 = $100.\n6. 4 board and 1 waits, the wheel rotates. Current profit is 24 * $6 - 6 * $4 = $120.\n7. 1 boards, the wheel rotates. Current profit is 25 * $6 - 7 * $4 = $122.\nThe highest profit was $122 after rotating the wheel 7 times.\n\nExample 3:\n\nInput: customers = [3,4,0,5,1], boardingCost = 1, runningCost = 92\nOutput: -1\nExplanation:\n1. 3 customers arrive, 3 board and 0 wait, the wheel rotates. Current profit is 3 * $1 - 1 * $92 = -$89.\n2. 4 customers arrive, 4 board and 0 wait, the wheel rotates. Current profit is 7 * $1 - 2 * $92 = -$177.\n3. 0 customers arrive, 0 board and 0 wait, the wheel rotates. Current profit is 7 * $1 - 3 * $92 = -$269.\n4. 5 customers arrive, 4 board and 1 waits, the wheel rotates. Current profit is 11 * $1 - 4 * $92 = -$357.\n5. 1 customer arrives, 2 board and 0 wait, the wheel rotates. Current profit is 13 * $1 - 5 * $92 = -$447.\nThe profit was never positive, so return -1.\n\n \nConstraints:\n\nn == customers.length\n1 <= n <= 105\n0 <= customers[i] <= 50\n1 <= boardingCost, runningCost <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(customers = [50, 50, 50, 50, 50],boardingCost = 100,runningCost = 1) == 63\n assert candidate(customers = [5, 5, 0, 8, 2],boardingCost = 6,runningCost = 3) == 6\n assert candidate(customers = [0, 0, 0, 0, 0],boardingCost = 1,runningCost = 1) == -1\n assert candidate(customers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boardingCost = 1,runningCost = 2) == -1\n assert candidate(customers = [0, 0, 0, 0],boardingCost = 10,runningCost = 5) == -1\n assert candidate(customers = [10, 9, 6],boardingCost = 6,runningCost = 4) == 7\n assert candidate(customers = [0, 0, 0, 0],boardingCost = 10,runningCost = 1) == -1\n assert candidate(customers = [8, 3],boardingCost = 5,runningCost = 6) == 3\n assert candidate(customers = [0, 0, 0, 0, 0],boardingCost = 1,runningCost = 10) == -1\n assert candidate(customers = [0, 0, 0, 0, 0],boardingCost = 5,runningCost = 1) == -1\n assert candidate(customers = [50, 50, 50, 50],boardingCost = 2,runningCost = 1) == 50\n assert candidate(customers = [50, 50, 50, 50, 50],boardingCost = 10,runningCost = 1) == 63\n assert candidate(customers = [3, 4, 0, 5, 1],boardingCost = 1,runningCost = 92) == -1\n assert candidate(customers = [5, 5, 0, 8, 7, 1, 4, 7, 3, 23],boardingCost = 43,runningCost = 59) == 16\n assert candidate(customers = [10, 10, 10, 10, 10],boardingCost = 5,runningCost = 4) == 13\n assert candidate(customers = [50, 50, 50, 50, 50],boardingCost = 100,runningCost = 50) == 63\n assert candidate(customers = [49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49],boardingCost = 1,runningCost = 1) == 343\n assert candidate(customers = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0],boardingCost = 5,runningCost = 3) == 13\n assert candidate(customers = [0, 10, 0, 10, 0, 10, 0, 10, 0, 10],boardingCost = 1,runningCost = 99) == -1\n assert candidate(customers = [50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0, 50, 0],boardingCost = 10,runningCost = 20) == 125\n assert candidate(customers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],boardingCost = 1,runningCost = 2) == 54\n assert candidate(customers = [10, 0, 0, 10, 0, 0, 10, 0, 0, 10],boardingCost = 6,runningCost = 4) == 12\n assert candidate(customers = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],boardingCost = 3,runningCost = 15) == -1\n assert candidate(customers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],boardingCost = 2,runningCost = 1) == 13\n assert candidate(customers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 100],boardingCost = 5,runningCost = 4) == 34\n assert candidate(customers = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20],boardingCost = 5,runningCost = 8) == 50\n assert candidate(customers = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],boardingCost = 2,runningCost = 3) == 53\n assert candidate(customers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boardingCost = 1,runningCost = 1) == -1\n assert candidate(customers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boardingCost = 10,runningCost = 5) == 138\n assert candidate(customers = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100],boardingCost = 5,runningCost = 1) == 35\n assert candidate(customers = [10, 20, 30, 40, 50],boardingCost = 50,runningCost = 1) == 38\n assert candidate(customers = [10, 20, 15, 5, 25],boardingCost = 4,runningCost = 7) == 19\n assert candidate(customers = [20, 10, 0, 30, 10, 0, 40, 10, 0, 50],boardingCost = 20,runningCost = 10) == 43\n assert candidate(customers = [30, 0, 10, 40, 20],boardingCost = 3,runningCost = 5) == 25\n assert candidate(customers = [50, 0, 50, 0, 50, 0, 50, 0, 50, 0],boardingCost = 10,runningCost = 5) == 63\n assert candidate(customers = [10, 20, 30, 40, 50, 40, 30, 20, 10, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 100, 95, 85, 75, 65, 55, 45, 35, 25, 15, 5],boardingCost = 10,runningCost = 20) == 337\n assert candidate(customers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boardingCost = 1,runningCost = 5) == -1\n assert candidate(customers = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],boardingCost = 1,runningCost = 1) == 10\n assert candidate(customers = [30, 20, 10, 0, 0, 0, 0, 0, 0, 0],boardingCost = 3,runningCost = 10) == 15\n assert candidate(customers = [45, 50, 55, 60, 65, 70, 75, 80, 85, 90],boardingCost = 15,runningCost = 12) == 169\n assert candidate(customers = [100, 0, 0, 0, 0, 0, 0, 0, 0, 0],boardingCost = 1,runningCost = 2) == 25\n assert candidate(customers = [10, 20, 30, 40, 50],boardingCost = 1,runningCost = 95) == -1\n assert candidate(customers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],boardingCost = 5,runningCost = 4) == 145\n assert candidate(customers = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25],boardingCost = 2,runningCost = 3) == 63\n assert candidate(customers = [100, 0, 0, 0, 0, 0, 0, 0, 0, 0],boardingCost = 10,runningCost = 90) == -1\n assert candidate(customers = [4, 3, 2, 1, 0, 0, 0, 0, 0, 0],boardingCost = 50,runningCost = 2) == 4\n assert candidate(customers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boardingCost = 10,runningCost = 20) == 15\n assert candidate(customers = [40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40],boardingCost = 1,runningCost = 1) == 200\n assert candidate(customers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boardingCost = 2,runningCost = 3) == 15\n assert candidate(customers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],boardingCost = 5,runningCost = 4) == 25\n assert candidate(customers = [2, 5, 3, 1, 4, 6, 2, 3, 5, 1, 4, 2, 3, 6, 5, 1, 4, 2, 3, 6, 5],boardingCost = 3,runningCost = 5) == 22\n assert candidate(customers = [15, 25, 35, 45, 55],boardingCost = 10,runningCost = 8) == 44\n assert candidate(customers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boardingCost = 5,runningCost = 4) == 20\n assert candidate(customers = [50, 25, 50, 25, 50, 25, 50, 25, 50, 25],boardingCost = 4,runningCost = 10) == 94\n assert candidate(customers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],boardingCost = 5,runningCost = 6) == -1\n"}, "metadata": {"canonical_parameter_names": ["customers", "boardingCost", "runningCost"], "leetcode_dataset_entry_point": "Solution().minOperationsMaxProfit", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minOperationsMaxProfit(vector& customers, int boardingCost, int runningCost) {", "container": "Solution", "callable": "minOperationsMaxProfit", "parameters": [{"name": "customers", "type": "vector&"}, {"name": "boardingCost", "type": "int"}, {"name": "runningCost", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1601, "task_id": "maximum-number-of-achievable-transfer-requests", "difficulty": "Hard", "problem_description": "We have n buildings numbered from 0 to n - 1. Each building has a number of employees. It's transfer season, and some employees want to change the building they reside in.\nYou are given an array requests where requests[i] = [fromi, toi] represents an employee's request to transfer from building fromi to building toi.\nAll buildings are full, so a list of requests is achievable only if for each building, the net change in employee transfers is zero. This means the number of employees leaving is equal to the number of employees moving in. For example if n = 3 and two employees are leaving building 0, one is leaving building 1, and one is leaving building 2, there should be two employees moving to building 0, one employee moving to building 1, and one employee moving to building 2.\nReturn the maximum number of achievable requests.\n \nExample 1:\n\n\nInput: n = 5, requests = [[0,1],[1,0],[0,1],[1,2],[2,0],[3,4]]\nOutput: 5\nExplantion: Let's see the requests:\nFrom building 0 we have employees x and y and both want to move to building 1.\nFrom building 1 we have employees a and b and they want to move to buildings 2 and 0 respectively.\nFrom building 2 we have employee z and they want to move to building 0.\nFrom building 3 we have employee c and they want to move to building 4.\nFrom building 4 we don't have any requests.\nWe can achieve the requests of users x and b by swapping their places.\nWe can achieve the requests of users y, a and z by swapping the places in the 3 buildings.\n\nExample 2:\n\n\nInput: n = 3, requests = [[0,0],[1,2],[2,1]]\nOutput: 3\nExplantion: Let's see the requests:\nFrom building 0 we have employee x and they want to stay in the same building 0.\nFrom building 1 we have employee y and they want to move to building 2.\nFrom building 2 we have employee z and they want to move to building 1.\nWe can achieve all the requests. \nExample 3:\n\nInput: n = 4, requests = [[0,3],[3,1],[1,2],[2,0]]\nOutput: 4\n\n \nConstraints:\n\n1 <= n <= 20\n1 <= requests.length <= 16\nrequests[i].length == 2\n0 <= fromi, toi < n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]]) == 6\n assert candidate(n = 4,requests = [[0, 1], [1, 0], [0, 2], [2, 0], [0, 3], [3, 0]]) == 6\n assert candidate(n = 4,requests = [[0, 3], [3, 1], [1, 2], [2, 0]]) == 4\n assert candidate(n = 3,requests = [[0, 1], [1, 0], [0, 2], [2, 0]]) == 4\n assert candidate(n = 3,requests = [[0, 1], [1, 2], [2, 0], [0, 2]]) == 3\n assert candidate(n = 6,requests = [[0, 3], [3, 4], [4, 2], [2, 5], [5, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 7\n assert candidate(n = 3,requests = [[0, 0], [1, 2], [2, 1]]) == 3\n assert candidate(n = 2,requests = [[0, 0], [1, 1]]) == 2\n assert candidate(n = 3,requests = [[0, 1], [1, 0], [1, 2], [2, 1], [0, 2], [2, 0]]) == 6\n assert candidate(n = 5,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]) == 5\n assert candidate(n = 5,requests = [[0, 1], [1, 0], [0, 1], [1, 2], [2, 0], [3, 4]]) == 5\n assert candidate(n = 2,requests = [[0, 1], [1, 0]]) == 2\n assert candidate(n = 6,requests = [[0, 1], [1, 0], [1, 2], [2, 1], [2, 3], [3, 2], [3, 4], [4, 3], [4, 5], [5, 4], [5, 0], [0, 5], [0, 2], [2, 0], [1, 3], [3, 1]]) == 16\n assert candidate(n = 4,requests = [[0, 1], [1, 2], [2, 3], [3, 0], [0, 2], [2, 1], [1, 3], [3, 2], [0, 3], [3, 1]]) == 8\n assert candidate(n = 8,requests = [[0, 1], [1, 0], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6], [0, 7], [1, 6], [2, 5], [3, 4]]) == 8\n assert candidate(n = 4,requests = [[0, 1], [1, 0], [0, 2], [2, 0], [1, 3], [3, 1], [2, 3], [3, 2], [0, 3], [3, 0]]) == 10\n assert candidate(n = 7,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 3], [3, 6], [6, 2], [2, 5], [5, 1], [1, 4], [4, 0]]) == 14\n assert candidate(n = 10,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 2], [2, 4], [4, 6], [6, 8], [8, 0], [1, 3], [3, 5], [5, 7], [7, 9], [9, 1]]) == 20\n assert candidate(n = 5,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 2], [1, 3], [2, 4], [3, 0], [4, 1], [0, 3], [1, 4], [2, 0], [3, 1], [4, 2]]) == 15\n assert candidate(n = 8,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 3], [3, 6], [6, 1], [1, 4], [4, 7], [7, 2], [2, 5], [5, 0]]) == 16\n assert candidate(n = 8,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 0]]) == 16\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 0], [5, 1], [0, 3], [1, 4], [2, 5], [3, 0], [4, 1], [5, 2], [0, 4], [1, 5], [2, 0], [3, 1], [4, 2], [5, 3]]) == 24\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 0], [5, 1]]) == 12\n assert candidate(n = 10,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 3], [3, 6], [6, 9], [9, 2], [2, 5], [5, 8], [8, 1], [1, 4], [4, 7], [7, 0]]) == 20\n assert candidate(n = 12,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [0, 5], [5, 10], [10, 3]]) == 12\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]]) == 18\n assert candidate(n = 4,requests = [[0, 1], [1, 2], [2, 3], [3, 0], [0, 2], [2, 1], [1, 3], [3, 2]]) == 7\n assert candidate(n = 4,requests = [[0, 1], [1, 2], [2, 3], [3, 0], [0, 2], [1, 3], [2, 0], [3, 1], [0, 3], [1, 0], [2, 1], [3, 2]]) == 12\n assert candidate(n = 20,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 0]]) == 20\n assert candidate(n = 15,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0], [0, 7], [7, 14], [14, 7], [7, 0], [0, 7]]) == 19\n assert candidate(n = 7,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 3], [3, 6], [6, 3], [3, 0], [0, 3], [3, 0], [0, 6], [6, 0], [0, 3], [3, 0]]) == 17\n assert candidate(n = 8,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 3], [3, 6], [1, 4], [4, 7], [2, 5], [5, 0]]) == 10\n assert candidate(n = 10,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 2], [2, 4], [4, 6], [6, 8], [8, 0]]) == 15\n assert candidate(n = 4,requests = [[0, 1], [1, 2], [2, 3], [3, 0], [0, 1], [1, 2], [2, 3], [3, 0], [0, 1], [1, 2], [2, 3], [3, 0], [0, 2], [1, 3], [2, 0], [3, 1], [0, 3], [1, 0], [2, 1], [3, 2]]) == 20\n assert candidate(n = 8,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 3], [3, 1], [1, 4], [4, 2], [2, 5], [5, 3], [3, 6], [6, 4], [4, 7], [7, 5]]) == 15\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 3], [3, 2], [1, 4], [4, 0]]) == 9\n assert candidate(n = 5,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 2], [2, 4], [4, 1], [1, 3], [3, 0]]) == 10\n assert candidate(n = 7,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 6], [1, 5], [2, 4]]) == 7\n assert candidate(n = 7,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 2], [2, 4], [4, 6], [6, 1], [1, 3], [3, 5], [5, 0]]) == 14\n assert candidate(n = 9,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [0, 8], [8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 0]]) == 18\n assert candidate(n = 12,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [0, 6], [6, 3], [3, 9], [9, 5], [5, 1], [1, 7], [7, 10], [10, 4], [4, 8], [8, 2], [2, 11], [11, 0]]) == 24\n assert candidate(n = 15,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0]]) == 15\n assert candidate(n = 5,requests = [[0, 1], [1, 0], [0, 2], [2, 0], [0, 3], [3, 0], [0, 4], [4, 0], [1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [2, 3], [3, 2], [2, 4], [4, 2], [3, 4], [4, 3]]) == 20\n assert candidate(n = 5,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 2], [1, 3], [2, 4], [3, 0], [4, 1]]) == 10\n assert candidate(n = 7,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 1], [6, 2], [0, 3], [1, 4], [2, 5], [3, 6], [4, 0], [5, 1], [6, 2]]) == 20\n assert candidate(n = 4,requests = [[0, 1], [1, 0], [0, 2], [2, 0], [0, 3], [3, 0], [1, 2], [2, 1], [1, 3], [3, 1], [2, 3], [3, 2]]) == 12\n assert candidate(n = 5,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]) == 10\n assert candidate(n = 5,requests = [[0, 1], [0, 2], [1, 0], [2, 0], [1, 2], [2, 1], [3, 4], [4, 3]]) == 8\n assert candidate(n = 6,requests = [[0, 1], [1, 0], [2, 3], [3, 2], [4, 5], [5, 4], [0, 3], [3, 0], [1, 4], [4, 1], [2, 5], [5, 2]]) == 12\n assert candidate(n = 4,requests = [[0, 1], [1, 2], [2, 3], [3, 0], [0, 2], [1, 3], [2, 0], [3, 1]]) == 8\n assert candidate(n = 3,requests = [[0, 1], [1, 2], [2, 0], [0, 2], [1, 0], [2, 1], [0, 1], [1, 2], [2, 0]]) == 9\n assert candidate(n = 10,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == 10\n assert candidate(n = 8,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 2], [2, 4], [4, 6], [6, 1], [1, 3], [3, 5], [5, 7], [7, 0]]) == 16\n assert candidate(n = 6,requests = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]]) == 12\n assert candidate(n = 5,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 4], [1, 3], [2, 0]]) == 5\n assert candidate(n = 7,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 0], [6, 1]]) == 14\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 3], [3, 1], [1, 4], [4, 2], [2, 5], [5, 3]]) == 11\n assert candidate(n = 10,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 2], [2, 4], [4, 6], [6, 8], [8, 1], [1, 3], [3, 5], [5, 7], [7, 9], [9, 1]]) == 19\n assert candidate(n = 8,requests = [[0, 7], [7, 1], [1, 6], [6, 2], [2, 5], [5, 3], [3, 4], [4, 0], [0, 2], [2, 4], [4, 6], [6, 0]]) == 12\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 2], [1, 3], [2, 4], [3, 5]]) == 12\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 3], [3, 1], [1, 4], [4, 2], [2, 5], [5, 0]]) == 12\n assert candidate(n = 10,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]]) == 10\n assert candidate(n = 15,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0], [0, 7], [7, 12], [12, 5]]) == 15\n assert candidate(n = 5,requests = [[0, 1], [0, 1], [1, 0], [1, 0], [0, 2], [2, 0], [1, 2], [2, 1], [0, 3], [3, 0], [1, 3], [3, 1], [2, 3], [3, 2], [0, 4], [4, 0], [1, 4], [4, 1], [2, 4], [4, 2], [3, 4], [4, 3]]) == 22\n assert candidate(n = 18,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 0], [0, 9], [9, 15], [15, 3]]) == 18\n assert candidate(n = 8,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 1], [6, 2], [7, 3]]) == 15\n assert candidate(n = 10,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 3], [3, 6], [6, 9]]) == 10\n assert candidate(n = 12,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 1], [11, 2]]) == 23\n assert candidate(n = 5,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 4], [4, 3], [3, 2], [2, 1], [1, 0]]) == 10\n assert candidate(n = 7,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 1], [6, 2]]) == 13\n assert candidate(n = 6,requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [0, 2], [2, 4], [4, 1], [1, 3], [3, 5], [5, 3]]) == 10\n"}, "metadata": {"canonical_parameter_names": ["n", "requests"], "leetcode_dataset_entry_point": "Solution().maximumRequests", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumRequests(int n, vector>& requests) {", "container": "Solution", "callable": "maximumRequests", "parameters": [{"name": "n", "type": "int"}, {"name": "requests", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1604, "task_id": "alert-using-same-key-card-three-or-more-times-in-a-one-hour-period", "difficulty": "Medium", "problem_description": "LeetCode company workers use key-cards to unlock office doors. Each time a worker uses their key-card, the security system saves the worker's name and the time when it was used. The system emits an alert if any worker uses the key-card three or more times in a one-hour period.\nYou are given a list of strings keyName and keyTime where [keyName[i], keyTime[i]] corresponds to a person's name and the time when their key-card was used in a single day.\nAccess times are given in the 24-hour time format \"HH:MM\", such as \"23:51\" and \"09:49\".\nReturn a list of unique worker names who received an alert for frequent keycard use. Sort the names in ascending order alphabetically.\nNotice that \"10:00\" - \"11:00\" is considered to be within a one-hour period, while \"22:51\" - \"23:52\" is not considered to be within a one-hour period.\n \nExample 1:\n\nInput: keyName = [\"daniel\",\"daniel\",\"daniel\",\"luis\",\"luis\",\"luis\",\"luis\"], keyTime = [\"10:00\",\"10:40\",\"11:00\",\"09:00\",\"11:00\",\"13:00\",\"15:00\"]\nOutput: [\"daniel\"]\nExplanation: \"daniel\" used the keycard 3 times in a one-hour period (\"10:00\",\"10:40\", \"11:00\").\n\nExample 2:\n\nInput: keyName = [\"alice\",\"alice\",\"alice\",\"bob\",\"bob\",\"bob\",\"bob\"], keyTime = [\"12:01\",\"12:00\",\"18:00\",\"21:00\",\"21:20\",\"21:30\",\"23:00\"]\nOutput: [\"bob\"]\nExplanation: \"bob\" used the keycard 3 times in a one-hour period (\"21:00\",\"21:20\", \"21:30\").\n\n \nConstraints:\n\n1 <= keyName.length, keyTime.length <= 105\nkeyName.length == keyTime.length\nkeyTime[i] is in the format \"HH:MM\".\n[keyName[i], keyTime[i]] is unique.\n1 <= keyName[i].length <= 10\nkeyName[i] contains only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(keyName = ['daniel', 'daniel', 'daniel', 'luis', 'luis', 'luis', 'luis'],keyTime = ['10:00', '10:40', '11:00', '09:00', '11:00', '13:00', '15:00']) == ['daniel']\n assert candidate(keyName = ['amy', 'amy', 'amy', 'adam', 'adam', 'adam', 'adam'],keyTime = ['12:00', '12:05', '12:10', '09:00', '09:15', '09:30', '09:45']) == ['adam', 'amy']\n assert candidate(keyName = ['alice', 'alice', 'alice', 'bob', 'bob', 'bob', 'bob'],keyTime = ['12:01', '12:00', '18:00', '21:00', '21:20', '21:30', '23:00']) == ['bob']\n assert candidate(keyName = ['john', 'john', 'john'],keyTime = ['09:15', '09:30', '10:00']) == ['john']\n assert candidate(keyName = ['amy', 'david', 'david'],keyTime = ['12:00', '12:00', '13:00']) == []\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['08:00', '08:20', '08:40', '09:00', '09:20']) == ['eve']\n assert candidate(keyName = ['chris', 'chris', 'chris'],keyTime = ['09:00', '09:30', '10:00']) == ['chris']\n assert candidate(keyName = ['john', 'john', 'john', 'john'],keyTime = ['09:00', '09:15', '09:30', '10:00']) == ['john']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['01:00', '01:10', '01:20', '02:00', '02:10']) == ['eve']\n assert candidate(keyName = ['john'],keyTime = ['00:00']) == []\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['23:58', '23:59', '00:00', '00:01', '00:02']) == ['eve']\n assert candidate(keyName = ['john', 'john', 'john', 'john'],keyTime = ['09:15', '09:45', '10:00', '10:30']) == ['john']\n assert candidate(keyName = ['anna', 'anna', 'anna', 'anna'],keyTime = ['10:00', '10:10', '10:20', '10:30']) == ['anna']\n assert candidate(keyName = ['alice', 'bob', 'alice'],keyTime = ['10:00', '10:10', '10:20']) == []\n assert candidate(keyName = ['mike', 'mike', 'mike', 'mike'],keyTime = ['00:00', '00:05', '00:10', '00:15']) == ['mike']\n assert candidate(keyName = ['anna', 'anna', 'bob', 'bob', 'bob'],keyTime = ['12:00', '12:05', '12:00', '12:05', '12:10']) == ['bob']\n assert candidate(keyName = ['amy', 'amy', 'amy', 'adam'],keyTime = ['08:00', '08:10', '08:20', '08:30']) == ['amy']\n assert candidate(keyName = ['grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace'],keyTime = ['08:00', '08:10', '08:20', '08:30', '08:40', '08:50', '09:00', '09:10', '09:20', '09:30', '09:40', '09:50']) == ['grace']\n assert candidate(keyName = ['grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace'],keyTime = ['23:50', '00:00', '00:10', '00:20', '00:30', '00:40', '00:50', '01:00', '01:10', '01:20']) == ['grace']\n assert candidate(keyName = ['amy', 'amy', 'amy', 'amy', 'amy'],keyTime = ['08:00', '08:30', '09:00', '09:30', '10:00']) == ['amy']\n assert candidate(keyName = ['alice', 'alice', 'alice', 'alice', 'alice'],keyTime = ['08:00', '08:10', '08:20', '08:30', '08:40']) == ['alice']\n assert candidate(keyName = ['grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace'],keyTime = ['12:00', '12:15', '12:30', '12:45', '13:00', '13:15', '13:30']) == ['grace']\n assert candidate(keyName = ['karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen'],keyTime = ['01:00', '01:10', '01:20', '01:30', '01:40', '01:50', '02:00', '02:10']) == ['karen']\n assert candidate(keyName = ['carol', 'carol', 'carol', 'carol', 'carol', 'carol', 'carol'],keyTime = ['23:00', '23:15', '23:30', '23:45', '00:00', '00:15', '00:30']) == ['carol']\n assert candidate(keyName = ['grace', 'grace', 'grace', 'grace', 'grace', 'grace'],keyTime = ['23:55', '00:00', '00:01', '00:02', '00:03', '00:04']) == ['grace']\n assert candidate(keyName = ['hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank'],keyTime = ['10:00', '10:05', '10:10', '10:15', '10:20', '10:25', '10:30', '10:35', '10:40', '10:45', '10:50', '10:55', '11:00', '11:05', '11:10', '11:15', '11:20', '11:25', '11:30', '11:35', '11:40', '11:45', '11:50', '11:55', '12:00']) == ['hank']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20', '10:30', '10:40', '10:50']) == ['ivan']\n assert candidate(keyName = ['dave', 'dave', 'dave', 'dave', 'dave', 'dave', 'dave', 'dave'],keyTime = ['09:00', '09:30', '10:00', '10:30', '11:00', '11:30', '12:00', '12:30']) == ['dave']\n assert candidate(keyName = ['alice', 'alice', 'alice', 'alice', 'alice'],keyTime = ['09:00', '09:15', '09:30', '09:45', '10:00']) == ['alice']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['09:00', '09:01', '09:02', '09:03', '09:04', '09:05', '09:06', '09:07', '09:08', '09:09', '09:10', '09:11', '09:12', '09:13', '09:14', '09:15', '09:16', '09:17', '09:18', '09:19', '09:20', '09:21', '09:22', '09:23', '09:24']) == ['ivan']\n assert candidate(keyName = ['karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20', '10:30', '10:40', '10:50', '11:00', '11:10', '11:20', '11:30', '11:40', '11:50', '12:00']) == ['karen']\n assert candidate(keyName = ['leo', 'leo', 'leo', 'leo', 'leo', 'leo', 'leo', 'leo', 'leo'],keyTime = ['22:00', '22:10', '22:20', '22:30', '22:40', '22:50', '23:00', '23:10', '23:20']) == ['leo']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10']) == ['eve']\n assert candidate(keyName = ['max', 'max', 'max', 'max', 'max', 'max', 'max', 'max', 'max', 'max', 'max', 'max', 'max'],keyTime = ['09:00', '09:05', '09:10', '09:15', '09:20', '09:25', '09:30', '09:35', '09:40', '09:45', '09:50', '09:55', '10:00']) == ['max']\n assert candidate(keyName = ['lucy', 'lucy', 'lucy', 'lucy', 'lucy', 'lucy', 'lucy'],keyTime = ['16:00', '16:05', '16:10', '16:15', '16:20', '16:25', '16:30']) == ['lucy']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['12:00', '12:20', '12:40', '13:00', '13:20', '13:40', '14:00']) == ['eve']\n assert candidate(keyName = ['alice', 'alice', 'alice', 'bob', 'bob', 'bob', 'charlie', 'charlie', 'charlie'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:35', '09:40', '09:00', '09:55', '10:05']) == ['alice', 'bob']\n assert candidate(keyName = ['tom', 'jerry', 'tom', 'jerry', 'tom', 'jerry', 'tom', 'jerry'],keyTime = ['09:00', '09:05', '09:10', '09:15', '09:20', '09:25', '09:30', '09:35']) == ['jerry', 'tom']\n assert candidate(keyName = ['alice', 'alice', 'alice', 'bob', 'bob', 'bob', 'bob', 'bob', 'charlie', 'charlie', 'charlie', 'charlie'],keyTime = ['08:59', '09:00', '09:01', '23:59', '00:01', '00:02', '00:03', '00:04', '10:00', '10:59', '11:00', '11:01']) == ['alice', 'bob', 'charlie']\n assert candidate(keyName = ['amy', 'amy', 'amy', 'amy', 'amy', 'amy', 'amy', 'amy', 'amy', 'amy', 'amy'],keyTime = ['08:00', '08:15', '08:30', '08:45', '09:00', '09:15', '09:30', '09:45', '10:00', '10:15', '10:30']) == ['amy']\n assert candidate(keyName = ['david', 'david', 'david', 'david', 'david'],keyTime = ['08:00', '08:05', '08:10', '08:55', '09:00']) == ['david']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['08:00', '08:10', '08:20', '08:30', '08:40', '08:50', '09:00', '09:10', '09:20', '09:30']) == ['eve']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20', '10:30']) == ['ivan']\n assert candidate(keyName = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank'],keyTime = ['08:00', '08:10', '08:20', '08:30', '08:40', '08:50', '09:00', '09:10', '09:20']) == ['frank']\n assert candidate(keyName = ['david', 'david', 'david', 'david', 'david', 'david'],keyTime = ['09:00', '09:10', '09:20', '10:00', '10:10', '10:20']) == ['david']\n assert candidate(keyName = ['hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank'],keyTime = ['11:00', '11:10', '11:20', '11:30', '11:40', '11:50', '12:00', '12:10', '12:20', '12:30', '12:40', '12:50', '13:00', '13:10', '13:20', '13:30', '13:40', '13:50', '14:00', '14:10']) == ['hank']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['23:00', '23:30', '00:00', '00:30', '01:00', '01:30']) == ['eve']\n assert candidate(keyName = ['lucy', 'lucy', 'lucy', 'lucy', 'lucy', 'lucy', 'lucy', 'lucy'],keyTime = ['12:00', '12:15', '12:30', '12:45', '13:00', '13:15', '13:30', '13:45']) == ['lucy']\n assert candidate(keyName = ['grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace'],keyTime = ['10:00', '10:15', '10:30', '10:45', '11:00', '11:15', '11:30', '11:45', '12:00', '12:15', '12:30', '12:45', '13:00', '13:15', '13:30', '13:45', '14:00', '14:15', '14:30', '14:45']) == ['grace']\n assert candidate(keyName = ['jane', 'jane', 'jane', 'jane', 'jane', 'jane', 'jane', 'jane', 'jane'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20']) == ['jane']\n assert candidate(keyName = ['judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy', 'judy'],keyTime = ['11:00', '11:10', '11:20', '11:30', '11:40', '11:50', '12:00', '12:10', '12:20', '12:30', '12:40', '12:50', '13:00', '13:10', '13:20', '13:30', '13:40', '13:50', '14:00', '14:10']) == ['judy']\n assert candidate(keyName = ['hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank'],keyTime = ['08:00', '08:30', '09:00', '09:30', '10:00', '10:30', '11:00', '11:30']) == ['hank']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['08:50', '08:55', '09:00', '09:05', '09:10', '09:15', '09:20', '09:25', '09:30', '09:35']) == ['eve']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['06:00', '06:15', '06:30', '06:45', '07:00', '07:15', '07:30', '07:45', '08:00', '08:15', '08:30', '08:45', '09:00', '09:15', '09:30', '09:45', '10:00', '10:15', '10:30']) == ['ivan']\n assert candidate(keyName = ['dave', 'dave', 'dave', 'dave', 'dave', 'dave', 'dave', 'dave', 'dave'],keyTime = ['08:00', '08:10', '08:20', '08:30', '08:40', '08:50', '09:00', '09:10', '09:20']) == ['dave']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['23:50', '00:00', '00:10', '00:20', '00:30', '00:40', '00:50', '01:00', '01:10', '01:20', '01:30', '01:40', '01:50', '02:00', '02:10', '02:20']) == ['ivan']\n assert candidate(keyName = ['bob', 'bob', 'bob', 'bob', 'bob', 'bob'],keyTime = ['23:50', '00:05', '00:10', '00:15', '00:20', '00:25']) == ['bob']\n assert candidate(keyName = ['chris', 'chris', 'chris', 'chris', 'chris', 'chris'],keyTime = ['23:45', '00:00', '00:15', '00:30', '00:45', '01:00']) == ['chris']\n assert candidate(keyName = ['dave', 'dave', 'dave', 'dave', 'dave', 'dave', 'dave'],keyTime = ['23:55', '00:00', '00:01', '00:02', '00:03', '00:04', '00:05']) == ['dave']\n assert candidate(keyName = ['grace', 'grace', 'grace', 'grace', 'grace', 'grace'],keyTime = ['09:00', '09:01', '09:02', '09:03', '09:04', '09:05']) == ['grace']\n assert candidate(keyName = ['grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace'],keyTime = ['08:00', '08:15', '08:30', '08:45', '09:00', '09:15', '09:30', '09:45', '10:00', '10:15', '10:30', '10:45', '11:00', '11:15']) == ['grace']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['09:00', '09:05', '09:10', '09:15', '09:20', '09:25', '09:30', '09:35', '09:40', '09:45']) == ['eve']\n assert candidate(keyName = ['charlie', 'charlie', 'charlie', 'charlie', 'charlie', 'charlie', 'charlie'],keyTime = ['12:00', '12:20', '12:40', '13:00', '13:20', '13:40', '14:00']) == ['charlie']\n assert candidate(keyName = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank'],keyTime = ['08:00', '08:10', '08:20', '08:30', '08:40', '08:50', '09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10']) == ['frank']\n assert candidate(keyName = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank'],keyTime = ['10:00', '10:10', '10:20', '10:30', '10:40', '10:50', '11:00', '11:10', '11:20', '11:30']) == ['frank']\n assert candidate(keyName = ['alice', 'alice', 'bob', 'bob', 'bob', 'bob', 'bob'],keyTime = ['08:00', '08:05', '08:00', '08:10', '08:15', '08:20', '08:25']) == ['bob']\n assert candidate(keyName = ['bob', 'bob', 'bob', 'bob', 'bob', 'bob'],keyTime = ['09:00', '09:20', '09:40', '10:00', '10:20', '10:40']) == ['bob']\n assert candidate(keyName = ['emma', 'emma', 'emma', 'emma', 'emma'],keyTime = ['09:00', '09:15', '09:30', '09:45', '10:00']) == ['emma']\n assert candidate(keyName = ['daniel', 'daniel', 'daniel', 'daniel', 'daniel', 'daniel'],keyTime = ['10:00', '10:15', '10:30', '11:00', '11:15', '11:30']) == ['daniel']\n assert candidate(keyName = ['alice', 'bob', 'charlie', 'alice', 'bob', 'charlie'],keyTime = ['08:00', '08:05', '08:10', '08:15', '08:20', '08:25']) == []\n assert candidate(keyName = ['jane', 'jane', 'jane', 'jane', 'jane', 'jane', 'jane', 'jane', 'jane', 'jane'],keyTime = ['09:00', '09:01', '09:02', '09:03', '09:04', '09:05', '09:06', '09:07', '09:08', '09:09']) == ['jane']\n assert candidate(keyName = ['charlie', 'charlie', 'charlie', 'dave', 'dave', 'dave', 'dave'],keyTime = ['08:00', '08:10', '08:20', '12:00', '12:05', '12:10', '12:15']) == ['charlie', 'dave']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['08:00', '08:10', '08:20', '08:30', '08:40', '08:50', '09:00', '09:10', '09:20']) == ['eve']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['12:00', '12:20', '12:40', '13:00', '13:20', '13:40', '14:00', '14:20', '14:40', '15:00']) == ['eve']\n assert candidate(keyName = ['alice', 'alice', 'bob', 'bob', 'charlie', 'charlie'],keyTime = ['12:00', '12:59', '13:00', '13:59', '14:00', '14:59']) == []\n assert candidate(keyName = ['heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi'],keyTime = ['23:50', '23:55', '00:00', '00:05', '00:10', '00:15', '00:20']) == ['heidi']\n assert candidate(keyName = ['tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim', 'tim'],keyTime = ['08:00', '08:10', '08:20', '08:30', '08:40', '08:50', '09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20']) == ['tim']\n assert candidate(keyName = ['jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20', '10:30', '10:40', '10:50', '11:00', '11:10', '11:20', '11:30', '11:40']) == ['jill']\n assert candidate(keyName = ['hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank', 'hank'],keyTime = ['12:00', '12:10', '12:20', '12:30', '12:40', '12:50', '13:00', '13:10', '13:20', '13:30', '13:40', '13:50', '14:00', '14:10']) == ['hank']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['07:00', '07:10', '07:20', '07:30', '07:40', '07:50', '08:00']) == ['ivan']\n assert candidate(keyName = ['charlie', 'david', 'david', 'charlie', 'david'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:35']) == ['david']\n assert candidate(keyName = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank'],keyTime = ['09:00', '09:01', '09:02', '09:03', '09:04', '09:05']) == ['frank']\n assert candidate(keyName = ['heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi'],keyTime = ['11:00', '11:10', '11:20', '11:30', '11:40', '11:50', '12:00', '12:10', '12:20', '12:30', '12:40']) == ['heidi']\n assert candidate(keyName = ['heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi', 'heidi'],keyTime = ['07:00', '07:30', '08:00', '08:30', '09:00', '09:30', '10:00', '10:30', '11:00', '11:30', '12:00', '12:30', '13:00', '13:30', '14:00']) == ['heidi']\n assert candidate(keyName = ['dave', 'dave', 'dave', 'dave', 'dave', 'dave', 'dave'],keyTime = ['08:00', '08:30', '09:00', '09:30', '10:00', '10:30', '11:00']) == ['dave']\n assert candidate(keyName = ['grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace', 'grace'],keyTime = ['23:00', '23:10', '23:20', '23:30', '23:40', '23:50', '00:00', '00:10', '00:20', '00:30', '00:40', '00:50', '01:00', '01:10', '01:20', '01:30']) == ['grace']\n assert candidate(keyName = ['alice', 'alice', 'alice', 'alice', 'alice'],keyTime = ['08:00', '08:30', '09:00', '09:30', '10:00']) == ['alice']\n assert candidate(keyName = ['eve', 'eve', 'eve', 'eve', 'eve', 'eve'],keyTime = ['10:00', '10:10', '10:20', '10:30', '10:40', '10:50']) == ['eve']\n assert candidate(keyName = ['jane', 'jane', 'jane', 'jane', 'jane', 'jane', 'jane'],keyTime = ['18:00', '18:10', '18:20', '18:30', '18:40', '18:50', '19:00']) == ['jane']\n assert candidate(keyName = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank'],keyTime = ['00:00', '00:15', '00:30', '00:45', '01:00', '01:15', '01:30', '01:45', '02:00', '02:15', '02:30', '02:45', '03:00']) == ['frank']\n assert candidate(keyName = ['mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike', 'mike'],keyTime = ['09:00', '09:05', '09:10', '09:15', '09:20', '09:25', '09:30', '09:35', '09:40', '09:45', '09:50', '09:55', '10:00', '10:05', '10:10', '10:15', '10:20']) == ['mike']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['09:00', '09:05', '09:10', '09:15', '09:20', '09:25', '09:30', '09:35', '09:40', '09:45']) == ['ivan']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['11:00', '11:10', '11:20', '11:30', '11:40', '11:50', '12:00', '12:10']) == ['ivan']\n assert candidate(keyName = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank'],keyTime = ['09:00', '09:15', '09:30', '09:45', '10:00', '10:15', '10:30', '10:45', '11:00', '11:15', '11:30', '11:45']) == ['frank']\n assert candidate(keyName = ['frank', 'grace', 'heidi', 'frank', 'grace', 'heidi', 'frank', 'grace', 'heidi'],keyTime = ['10:00', '10:00', '10:00', '10:05', '10:05', '10:05', '10:10', '10:10', '10:10']) == ['frank', 'grace', 'heidi']\n assert candidate(keyName = ['ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan', 'ivan'],keyTime = ['09:00', '09:01', '09:02', '09:03', '09:04', '09:05', '09:06', '09:07', '09:08', '09:09', '09:10', '09:11', '09:12', '09:13', '09:14', '09:15', '09:16', '09:17', '09:18', '09:19', '09:20', '09:21', '09:22', '09:23', '09:24', '09:25', '09:26', '09:27', '09:28', '09:29', '09:30']) == ['ivan']\n assert candidate(keyName = ['daniel', 'daniel', 'daniel', 'daniel', 'daniel', 'daniel'],keyTime = ['09:00', '09:15', '09:30', '10:00', '10:15', '10:30']) == ['daniel']\n assert candidate(keyName = ['sam', 'sam', 'sam', 'sam', 'sam', 'sam', 'sam', 'sam', 'sam', 'sam'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20', '10:30']) == ['sam']\n assert candidate(keyName = ['jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill', 'jill'],keyTime = ['09:00', '09:30', '10:00', '10:30', '11:00', '11:30', '12:00', '12:30', '13:00', '13:30', '14:00', '14:30', '15:00', '15:30', '16:00', '16:30', '17:00', '17:30', '18:00', '18:30', '19:00', '19:30', '20:00', '20:30', '21:00', '21:30', '22:00', '22:30', '23:00', '23:30', '00:00', '00:30', '01:00', '01:30', '02:00', '02:30', '03:00', '03:30', '04:00', '04:30']) == ['jill']\n assert candidate(keyName = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank'],keyTime = ['23:45', '23:50', '23:55', '00:00', '00:05', '00:10', '00:15']) == ['frank']\n assert candidate(keyName = ['charlie', 'charlie', 'charlie', 'charlie', 'charlie', 'charlie', 'charlie'],keyTime = ['10:00', '10:10', '10:20', '10:30', '10:40', '11:00', '11:10']) == ['charlie']\n assert candidate(keyName = ['hank', 'hank', 'hank', 'hank', 'hank', 'hank'],keyTime = ['14:00', '14:30', '15:00', '15:30', '16:00', '16:30']) == ['hank']\n assert candidate(keyName = ['kyle', 'kyle', 'kyle', 'kyle', 'kyle', 'kyle', 'kyle'],keyTime = ['22:00', '22:15', '22:30', '22:45', '23:00', '23:15', '23:30']) == ['kyle']\n assert candidate(keyName = ['frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank', 'frank'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20']) == ['frank']\n assert candidate(keyName = ['julia', 'julia', 'julia', 'julia', 'julia', 'julia', 'julia', 'julia', 'julia', 'julia', 'julia'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20', '10:30', '10:40']) == ['julia']\n assert candidate(keyName = ['julia', 'julia', 'julia', 'julia', 'julia', 'julia', 'julia', 'julia'],keyTime = ['12:00', '12:10', '12:20', '12:30', '12:40', '12:50', '13:00', '13:10']) == ['julia']\n assert candidate(keyName = ['karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen', 'karen'],keyTime = ['09:00', '09:10', '09:20', '09:30', '09:40', '09:50', '10:00', '10:10', '10:20', '10:30', '10:40', '10:50']) == ['karen']\n assert candidate(keyName = ['bob', 'bob', 'bob', 'bob', 'bob', 'bob'],keyTime = ['12:00', '12:01', '12:02', '12:03', '12:04', '12:05']) == ['bob']\n assert candidate(keyName = ['alice', 'alice', 'alice', 'alice', 'alice'],keyTime = ['09:00', '09:30', '10:00', '10:30', '11:00']) == ['alice']\n"}, "metadata": {"canonical_parameter_names": ["keyName", "keyTime"], "leetcode_dataset_entry_point": "Solution().alertNames", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector alertNames(vector& keyName, vector& keyTime) {", "container": "Solution", "callable": "alertNames", "parameters": [{"name": "keyName", "type": "vector&"}, {"name": "keyTime", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1605, "task_id": "find-valid-matrix-given-row-and-column-sums", "difficulty": "Medium", "problem_description": "You are given two arrays rowSum and colSum of non-negative integers where rowSum[i] is the sum of the elements in the ith row and colSum[j] is the sum of the elements of the jth column of a 2D matrix. In other words, you do not know the elements of the matrix, but you do know the sums of each row and column.\nFind any matrix of non-negative integers of size rowSum.length x colSum.length that satisfies the rowSum and colSum requirements.\nReturn a 2D array representing any matrix that fulfills the requirements. It's guaranteed that at least one matrix that fulfills the requirements exists.\n \nExample 1:\n\nInput: rowSum = [3,8], colSum = [4,7]\nOutput: [[3,0],\n [1,7]]\nExplanation: \n0th row: 3 + 0 = 3 == rowSum[0]\n1st row: 1 + 7 = 8 == rowSum[1]\n0th column: 3 + 1 = 4 == colSum[0]\n1st column: 0 + 7 = 7 == colSum[1]\nThe row and column sums match, and all matrix elements are non-negative.\nAnother possible matrix is: [[1,2],\n [3,5]]\n\nExample 2:\n\nInput: rowSum = [5,7,10], colSum = [8,6,8]\nOutput: [[0,5,0],\n [6,1,0],\n [2,0,8]]\n\n \nConstraints:\n\n1 <= rowSum.length, colSum.length <= 500\n0 <= rowSum[i], colSum[i] <= 108\nsum(rowSum) == sum(colSum)\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rowSum = [10, 15],colSum = [12, 13]) == [[10, 0], [2, 13]]\n assert candidate(rowSum = [5, 5, 5],colSum = [5, 5, 5]) == [[5, 0, 0], [0, 5, 0], [0, 0, 5]]\n assert candidate(rowSum = [10, 20],colSum = [15, 15]) == [[10, 0], [5, 15]]\n assert candidate(rowSum = [10, 15, 20],colSum = [15, 15, 15]) == [[10, 0, 0], [5, 10, 0], [0, 5, 15]]\n assert candidate(rowSum = [1, 2, 3, 4],colSum = [1, 2, 3, 4]) == [[1, 0, 0, 0], [0, 2, 0, 0], [0, 0, 3, 0], [0, 0, 0, 4]]\n assert candidate(rowSum = [1, 1, 1],colSum = [1, 1, 1]) == [[1, 0, 0], [0, 1, 0], [0, 0, 1]]\n assert candidate(rowSum = [5, 7, 10],colSum = [8, 6, 8]) == [[5, 0, 0], [3, 4, 0], [0, 2, 8]]\n assert candidate(rowSum = [10, 15, 20],colSum = [5, 10, 20]) == [[5, 5, 0], [0, 5, 10], [0, 0, 10]]\n assert candidate(rowSum = [0, 0],colSum = [0, 0]) == [[0, 0], [0, 0]]\n assert candidate(rowSum = [1, 2],colSum = [3, 0]) == [[1, 0], [2, 0]]\n assert candidate(rowSum = [1, 2, 3],colSum = [3, 2, 1]) == [[1, 0, 0], [2, 0, 0], [0, 2, 1]]\n assert candidate(rowSum = [0, 0, 0],colSum = [0, 0, 0]) == [[0, 0, 0], [0, 0, 0], [0, 0, 0]]\n assert candidate(rowSum = [3, 8],colSum = [4, 7]) == [[3, 0], [1, 7]]\n assert candidate(rowSum = [25, 25, 25, 25, 25],colSum = [25, 25, 25, 25, 25]) == [[25, 0, 0, 0, 0], [0, 25, 0, 0, 0], [0, 0, 25, 0, 0], [0, 0, 0, 25, 0], [0, 0, 0, 0, 25]]\n assert candidate(rowSum = [9, 18, 27, 36, 45],colSum = [5, 10, 15, 20, 25]) == [[5, 4, 0, 0, 0], [0, 6, 12, 0, 0], [0, 0, 3, 20, 4], [0, 0, 0, 0, 21], [0, 0, 0, 0, 0]]\n assert candidate(rowSum = [10, 20, 30],colSum = [6, 9, 12, 15]) == [[6, 4, 0, 0], [0, 5, 12, 3], [0, 0, 0, 12]]\n assert candidate(rowSum = [5, 5, 5, 5],colSum = [4, 4, 4, 4]) == [[4, 1, 0, 0], [0, 3, 2, 0], [0, 0, 2, 3], [0, 0, 0, 1]]\n assert candidate(rowSum = [10, 20, 30],colSum = [6, 15, 29]) == [[6, 4, 0], [0, 11, 9], [0, 0, 20]]\n assert candidate(rowSum = [300, 400, 500, 600],colSum = [200, 300, 400, 700]) == [[200, 100, 0, 0], [0, 200, 200, 0], [0, 0, 200, 300], [0, 0, 0, 400]]\n assert candidate(rowSum = [12, 25, 30],colSum = [20, 15, 20]) == [[12, 0, 0], [8, 15, 2], [0, 0, 18]]\n assert candidate(rowSum = [12, 15, 20],colSum = [10, 10, 17]) == [[10, 2, 0], [0, 8, 7], [0, 0, 10]]\n assert candidate(rowSum = [1000, 2000, 3000],colSum = [1500, 2000, 2500]) == [[1000, 0, 0], [500, 1500, 0], [0, 500, 2500]]\n assert candidate(rowSum = [9, 18, 27],colSum = [12, 15, 18]) == [[9, 0, 0], [3, 15, 0], [0, 0, 18]]\n assert candidate(rowSum = [100, 100, 100, 100],colSum = [25, 25, 25, 25]) == [[25, 25, 25, 25], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]\n assert candidate(rowSum = [45, 55, 65, 75, 85],colSum = [50, 60, 70, 80, 90]) == [[45, 0, 0, 0, 0], [5, 50, 0, 0, 0], [0, 10, 55, 0, 0], [0, 0, 15, 60, 0], [0, 0, 0, 20, 65]]\n assert candidate(rowSum = [99, 100, 101, 102],colSum = [101, 102, 99, 100]) == [[99, 0, 0, 0], [2, 98, 0, 0], [0, 4, 97, 0], [0, 0, 2, 100]]\n assert candidate(rowSum = [50, 100, 150],colSum = [25, 75, 100, 150]) == [[25, 25, 0, 0], [0, 50, 50, 0], [0, 0, 50, 100]]\n assert candidate(rowSum = [25, 50, 75, 100],colSum = [10, 20, 30, 40, 95]) == [[10, 15, 0, 0, 0], [0, 5, 30, 15, 0], [0, 0, 0, 25, 50], [0, 0, 0, 0, 45]]\n assert candidate(rowSum = [100, 150, 200, 250],colSum = [100, 100, 150, 200]) == [[100, 0, 0, 0], [0, 100, 50, 0], [0, 0, 100, 100], [0, 0, 0, 100]]\n assert candidate(rowSum = [45, 55, 65, 75, 85],colSum = [30, 40, 50, 60, 70]) == [[30, 15, 0, 0, 0], [0, 25, 30, 0, 0], [0, 0, 20, 45, 0], [0, 0, 0, 15, 60], [0, 0, 0, 0, 10]]\n assert candidate(rowSum = [100, 200, 300, 400],colSum = [150, 250, 350, 450]) == [[100, 0, 0, 0], [50, 150, 0, 0], [0, 100, 200, 0], [0, 0, 150, 250]]\n assert candidate(rowSum = [300, 200, 100, 50],colSum = [150, 150, 150, 100, 50]) == [[150, 150, 0, 0, 0], [0, 0, 150, 50, 0], [0, 0, 0, 50, 50], [0, 0, 0, 0, 0]]\n assert candidate(rowSum = [20, 30, 40, 50],colSum = [10, 20, 30, 40]) == [[10, 10, 0, 0], [0, 10, 20, 0], [0, 0, 10, 30], [0, 0, 0, 10]]\n assert candidate(rowSum = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],colSum = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]\n assert candidate(rowSum = [100, 200, 300],colSum = [150, 100, 250]) == [[100, 0, 0], [50, 100, 50], [0, 0, 200]]\n assert candidate(rowSum = [50, 50, 50],colSum = [40, 40, 40, 40]) == [[40, 10, 0, 0], [0, 30, 20, 0], [0, 0, 20, 30]]\n assert candidate(rowSum = [10, 20, 30, 40, 50],colSum = [15, 15, 15, 15, 15]) == [[10, 0, 0, 0, 0], [5, 15, 0, 0, 0], [0, 0, 15, 15, 0], [0, 0, 0, 0, 15], [0, 0, 0, 0, 0]]\n assert candidate(rowSum = [500, 500, 500, 500, 500],colSum = [250, 250, 250, 250, 250]) == [[250, 250, 0, 0, 0], [0, 0, 250, 250, 0], [0, 0, 0, 0, 250], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]\n assert candidate(rowSum = [5, 6, 7, 8],colSum = [10, 8, 6, 4]) == [[5, 0, 0, 0], [5, 1, 0, 0], [0, 7, 0, 0], [0, 0, 6, 2]]\n assert candidate(rowSum = [100, 200, 300],colSum = [150, 250, 100]) == [[100, 0, 0], [50, 150, 0], [0, 100, 100]]\n assert candidate(rowSum = [25, 50, 75, 100],colSum = [40, 50, 60, 50]) == [[25, 0, 0, 0], [15, 35, 0, 0], [0, 15, 60, 0], [0, 0, 0, 50]]\n assert candidate(rowSum = [10, 20, 30, 40, 50],colSum = [50, 40, 30, 20, 10]) == [[10, 0, 0, 0, 0], [20, 0, 0, 0, 0], [20, 10, 0, 0, 0], [0, 30, 10, 0, 0], [0, 0, 20, 20, 10]]\n assert candidate(rowSum = [500, 300, 200],colSum = [400, 350, 250]) == [[400, 100, 0], [0, 250, 50], [0, 0, 200]]\n assert candidate(rowSum = [50, 75, 100],colSum = [120, 100, 30]) == [[50, 0, 0], [70, 5, 0], [0, 95, 5]]\n assert candidate(rowSum = [8, 16, 24, 32],colSum = [16, 24, 16, 24]) == [[8, 0, 0, 0], [8, 8, 0, 0], [0, 16, 8, 0], [0, 0, 8, 24]]\n assert candidate(rowSum = [8, 6, 4, 2, 0],colSum = [1, 2, 3, 4, 5]) == [[1, 2, 3, 2, 0], [0, 0, 0, 2, 4], [0, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]\n assert candidate(rowSum = [88, 77, 66, 55, 44],colSum = [99, 88, 77, 66, 55]) == [[88, 0, 0, 0, 0], [11, 66, 0, 0, 0], [0, 22, 44, 0, 0], [0, 0, 33, 22, 0], [0, 0, 0, 44, 0]]\n assert candidate(rowSum = [150, 200, 250],colSum = [200, 150, 300]) == [[150, 0, 0], [50, 150, 0], [0, 0, 250]]\n assert candidate(rowSum = [88, 88, 88, 88, 88, 88],colSum = [77, 77, 77, 77, 77, 77]) == [[77, 11, 0, 0, 0, 0], [0, 66, 22, 0, 0, 0], [0, 0, 55, 33, 0, 0], [0, 0, 0, 44, 44, 0], [0, 0, 0, 0, 33, 55], [0, 0, 0, 0, 0, 22]]\n assert candidate(rowSum = [120, 110, 100, 90],colSum = [105, 95, 85, 75]) == [[105, 15, 0, 0], [0, 80, 30, 0], [0, 0, 55, 45], [0, 0, 0, 30]]\n assert candidate(rowSum = [50, 60, 70, 80, 90],colSum = [90, 80, 70, 60, 50]) == [[50, 0, 0, 0, 0], [40, 20, 0, 0, 0], [0, 60, 10, 0, 0], [0, 0, 60, 20, 0], [0, 0, 0, 40, 50]]\n assert candidate(rowSum = [123, 456, 789],colSum = [456, 789, 123]) == [[123, 0, 0], [333, 123, 0], [0, 666, 123]]\n assert candidate(rowSum = [10, 20, 30, 40, 50],colSum = [5, 10, 15, 20, 60]) == [[5, 5, 0, 0, 0], [0, 5, 15, 0, 0], [0, 0, 0, 20, 10], [0, 0, 0, 0, 40], [0, 0, 0, 0, 10]]\n assert candidate(rowSum = [8, 16, 24, 32],colSum = [16, 24, 32, 8]) == [[8, 0, 0, 0], [8, 8, 0, 0], [0, 16, 8, 0], [0, 0, 24, 8]]\n assert candidate(rowSum = [100, 200, 300, 400],colSum = [200, 300, 200, 400]) == [[100, 0, 0, 0], [100, 100, 0, 0], [0, 200, 100, 0], [0, 0, 100, 300]]\n assert candidate(rowSum = [120, 80, 40],colSum = [90, 70, 30, 10]) == [[90, 30, 0, 0], [0, 40, 30, 10], [0, 0, 0, 0]]\n assert candidate(rowSum = [10, 20, 30, 40],colSum = [15, 25, 25, 25]) == [[10, 0, 0, 0], [5, 15, 0, 0], [0, 10, 20, 0], [0, 0, 5, 25]]\n assert candidate(rowSum = [99, 98, 97, 96, 95],colSum = [95, 96, 97, 98, 99]) == [[95, 4, 0, 0, 0], [0, 92, 6, 0, 0], [0, 0, 91, 6, 0], [0, 0, 0, 92, 4], [0, 0, 0, 0, 95]]\n assert candidate(rowSum = [15, 25, 35, 45],colSum = [10, 20, 30, 40]) == [[10, 5, 0, 0], [0, 15, 10, 0], [0, 0, 20, 15], [0, 0, 0, 25]]\n assert candidate(rowSum = [75, 80, 85, 90, 95, 100],colSum = [60, 65, 70, 75, 80, 85]) == [[60, 15, 0, 0, 0, 0], [0, 50, 30, 0, 0, 0], [0, 0, 40, 45, 0, 0], [0, 0, 0, 30, 60, 0], [0, 0, 0, 0, 20, 75], [0, 0, 0, 0, 0, 10]]\n assert candidate(rowSum = [100, 150, 200],colSum = [200, 120, 130]) == [[100, 0, 0], [100, 50, 0], [0, 70, 130]]\n assert candidate(rowSum = [120, 140, 160, 180, 200],colSum = [200, 180, 160, 140, 120]) == [[120, 0, 0, 0, 0], [80, 60, 0, 0, 0], [0, 120, 40, 0, 0], [0, 0, 120, 60, 0], [0, 0, 0, 80, 120]]\n assert candidate(rowSum = [50, 60, 70, 80],colSum = [30, 40, 50, 60]) == [[30, 20, 0, 0], [0, 20, 40, 0], [0, 0, 10, 60], [0, 0, 0, 0]]\n assert candidate(rowSum = [30, 20, 10, 0],colSum = [10, 10, 10, 30]) == [[10, 10, 10, 0], [0, 0, 0, 20], [0, 0, 0, 10], [0, 0, 0, 0]]\n assert candidate(rowSum = [5, 10, 15, 20, 25],colSum = [25, 20, 15, 10, 5]) == [[5, 0, 0, 0, 0], [10, 0, 0, 0, 0], [10, 5, 0, 0, 0], [0, 15, 5, 0, 0], [0, 0, 10, 10, 5]]\n assert candidate(rowSum = [20, 40, 60, 80],colSum = [30, 30, 30, 30]) == [[20, 0, 0, 0], [10, 30, 0, 0], [0, 0, 30, 30], [0, 0, 0, 0]]\n assert candidate(rowSum = [1, 1, 1, 1, 1, 1],colSum = [1, 1, 1, 1, 1, 1]) == [[1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1]]\n assert candidate(rowSum = [50, 45, 60],colSum = [40, 30, 35]) == [[40, 10, 0], [0, 20, 25], [0, 0, 10]]\n assert candidate(rowSum = [123, 456, 789],colSum = [321, 654, 987]) == [[123, 0, 0], [198, 258, 0], [0, 396, 393]]\n assert candidate(rowSum = [100, 200, 300],colSum = [150, 150, 150]) == [[100, 0, 0], [50, 150, 0], [0, 0, 150]]\n assert candidate(rowSum = [30, 40, 50, 60],colSum = [50, 40, 40, 30]) == [[30, 0, 0, 0], [20, 20, 0, 0], [0, 20, 30, 0], [0, 0, 10, 30]]\n assert candidate(rowSum = [1, 2, 3, 4, 5],colSum = [5, 4, 3, 2, 1]) == [[1, 0, 0, 0, 0], [2, 0, 0, 0, 0], [2, 1, 0, 0, 0], [0, 3, 1, 0, 0], [0, 0, 2, 2, 1]]\n assert candidate(rowSum = [30, 20, 10],colSum = [15, 20, 15]) == [[15, 15, 0], [0, 5, 15], [0, 0, 0]]\n assert candidate(rowSum = [20, 30, 40, 50],colSum = [15, 15, 15, 15, 20, 10]) == [[15, 5, 0, 0, 0, 0], [0, 10, 15, 5, 0, 0], [0, 0, 0, 10, 20, 10], [0, 0, 0, 0, 0, 0]]\n assert candidate(rowSum = [150, 200, 250, 300, 350, 400],colSum = [200, 250, 300, 350, 400, 450]) == [[150, 0, 0, 0, 0, 0], [50, 150, 0, 0, 0, 0], [0, 100, 150, 0, 0, 0], [0, 0, 150, 150, 0, 0], [0, 0, 0, 200, 150, 0], [0, 0, 0, 0, 250, 150]]\n assert candidate(rowSum = [7, 14, 21, 28],colSum = [7, 14, 21, 28]) == [[7, 0, 0, 0], [0, 14, 0, 0], [0, 0, 21, 0], [0, 0, 0, 28]]\n assert candidate(rowSum = [30, 60, 90, 120],colSum = [20, 40, 60, 80, 100]) == [[20, 10, 0, 0, 0], [0, 30, 30, 0, 0], [0, 0, 30, 60, 0], [0, 0, 0, 20, 100]]\n assert candidate(rowSum = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],colSum = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [2, 0, 0, 0, 0, 0, 0, 0, 0, 0], [3, 0, 0, 0, 0, 0, 0, 0, 0, 0], [4, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 5, 0, 0, 0, 0, 0, 0, 0, 0], [0, 4, 2, 0, 0, 0, 0, 0, 0, 0], [0, 0, 6, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 6, 2, 0, 0, 0, 0, 0], [0, 0, 0, 0, 4, 5, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 4, 3, 2, 1]]\n assert candidate(rowSum = [10, 20, 30, 40, 50],colSum = [15, 25, 35, 25, 15]) == [[10, 0, 0, 0, 0], [5, 15, 0, 0, 0], [0, 10, 20, 0, 0], [0, 0, 15, 25, 0], [0, 0, 0, 0, 15]]\n assert candidate(rowSum = [33, 33, 33, 33, 33, 33],colSum = [22, 22, 22, 22, 22, 22]) == [[22, 11, 0, 0, 0, 0], [0, 11, 22, 0, 0, 0], [0, 0, 0, 22, 11, 0], [0, 0, 0, 0, 11, 22], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]\n assert candidate(rowSum = [100, 200, 300, 400, 500],colSum = [500, 400, 300, 200, 100]) == [[100, 0, 0, 0, 0], [200, 0, 0, 0, 0], [200, 100, 0, 0, 0], [0, 300, 100, 0, 0], [0, 0, 200, 200, 100]]\n assert candidate(rowSum = [10000, 20000, 30000],colSum = [15000, 20000, 25000]) == [[10000, 0, 0], [5000, 15000, 0], [0, 5000, 25000]]\n assert candidate(rowSum = [5, 15, 25, 35],colSum = [10, 10, 10, 30]) == [[5, 0, 0, 0], [5, 10, 0, 0], [0, 0, 10, 15], [0, 0, 0, 15]]\n assert candidate(rowSum = [1, 1, 1, 1, 1],colSum = [1, 1, 1, 1, 1]) == [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]\n assert candidate(rowSum = [7, 14, 21, 28, 35],colSum = [5, 10, 15, 20, 25]) == [[5, 2, 0, 0, 0], [0, 8, 6, 0, 0], [0, 0, 9, 12, 0], [0, 0, 0, 8, 20], [0, 0, 0, 0, 5]]\n assert candidate(rowSum = [12, 34, 56, 78, 90, 123],colSum = [23, 45, 67, 89, 101, 112]) == [[12, 0, 0, 0, 0, 0], [11, 23, 0, 0, 0, 0], [0, 22, 34, 0, 0, 0], [0, 0, 33, 45, 0, 0], [0, 0, 0, 44, 46, 0], [0, 0, 0, 0, 55, 68]]\n assert candidate(rowSum = [100, 200, 300, 400],colSum = [100, 150, 200, 350]) == [[100, 0, 0, 0], [0, 150, 50, 0], [0, 0, 150, 150], [0, 0, 0, 200]]\n assert candidate(rowSum = [100, 200, 300, 400, 500],colSum = [250, 250, 250, 250, 250]) == [[100, 0, 0, 0, 0], [150, 50, 0, 0, 0], [0, 200, 100, 0, 0], [0, 0, 150, 250, 0], [0, 0, 0, 0, 250]]\n assert candidate(rowSum = [25, 75],colSum = [100, 50]) == [[25, 0], [75, 0]]\n assert candidate(rowSum = [10, 20, 30, 40, 50],colSum = [5, 15, 25, 35, 45]) == [[5, 5, 0, 0, 0], [0, 10, 10, 0, 0], [0, 0, 15, 15, 0], [0, 0, 0, 20, 20], [0, 0, 0, 0, 25]]\n assert candidate(rowSum = [1000, 2000, 3000],colSum = [1500, 1500, 1500]) == [[1000, 0, 0], [500, 1500, 0], [0, 0, 1500]]\n assert candidate(rowSum = [5, 10, 15, 20],colSum = [20, 15, 10, 5]) == [[5, 0, 0, 0], [10, 0, 0, 0], [5, 10, 0, 0], [0, 5, 10, 5]]\n assert candidate(rowSum = [50, 50, 50, 50, 50],colSum = [25, 25, 25, 25, 25, 25, 25]) == [[25, 25, 0, 0, 0, 0, 0], [0, 0, 25, 25, 0, 0, 0], [0, 0, 0, 0, 25, 25, 0], [0, 0, 0, 0, 0, 0, 25], [0, 0, 0, 0, 0, 0, 0]]\n assert candidate(rowSum = [500, 1000, 1500, 2000],colSum = [600, 700, 800, 900]) == [[500, 0, 0, 0], [100, 700, 200, 0], [0, 0, 600, 900], [0, 0, 0, 0]]\n assert candidate(rowSum = [50, 50, 50, 50],colSum = [60, 60, 60, 60]) == [[50, 0, 0, 0], [10, 40, 0, 0], [0, 20, 30, 0], [0, 0, 30, 20]]\n assert candidate(rowSum = [40, 50, 60],colSum = [70, 60, 50]) == [[40, 0, 0], [30, 20, 0], [0, 40, 20]]\n assert candidate(rowSum = [12, 15, 7],colSum = [10, 10, 12]) == [[10, 2, 0], [0, 8, 7], [0, 0, 5]]\n assert candidate(rowSum = [100, 200, 300],colSum = [250, 250, 200]) == [[100, 0, 0], [150, 50, 0], [0, 200, 100]]\n assert candidate(rowSum = [9, 18, 27, 36],colSum = [12, 24, 36, 48]) == [[9, 0, 0, 0], [3, 15, 0, 0], [0, 9, 18, 0], [0, 0, 18, 18]]\n assert candidate(rowSum = [9, 9, 9, 9],colSum = [6, 6, 6, 6, 9]) == [[6, 3, 0, 0, 0], [0, 3, 6, 0, 0], [0, 0, 0, 6, 3], [0, 0, 0, 0, 6]]\n assert candidate(rowSum = [50, 50, 50, 50, 50, 50],colSum = [50, 50, 50, 50, 50, 50]) == [[50, 0, 0, 0, 0, 0], [0, 50, 0, 0, 0, 0], [0, 0, 50, 0, 0, 0], [0, 0, 0, 50, 0, 0], [0, 0, 0, 0, 50, 0], [0, 0, 0, 0, 0, 50]]\n assert candidate(rowSum = [33, 28, 44, 55],colSum = [30, 33, 25, 50]) == [[30, 3, 0, 0], [0, 28, 0, 0], [0, 2, 25, 17], [0, 0, 0, 33]]\n assert candidate(rowSum = [300, 200, 100],colSum = [150, 200, 150]) == [[150, 150, 0], [0, 50, 150], [0, 0, 0]]\n assert candidate(rowSum = [30, 40, 50],colSum = [20, 50, 20]) == [[20, 10, 0], [0, 40, 0], [0, 0, 20]]\n assert candidate(rowSum = [120, 90, 75, 60],colSum = [80, 100, 75, 60]) == [[80, 40, 0, 0], [0, 60, 30, 0], [0, 0, 45, 30], [0, 0, 0, 30]]\n assert candidate(rowSum = [5, 15, 25, 35],colSum = [10, 20, 30, 40]) == [[5, 0, 0, 0], [5, 10, 0, 0], [0, 10, 15, 0], [0, 0, 15, 20]]\n assert candidate(rowSum = [34, 78, 90, 123],colSum = [50, 60, 70, 80]) == [[34, 0, 0, 0], [16, 60, 2, 0], [0, 0, 68, 22], [0, 0, 0, 58]]\n assert candidate(rowSum = [120, 150, 180],colSum = [100, 130, 200]) == [[100, 20, 0], [0, 110, 40], [0, 0, 160]]\n assert candidate(rowSum = [10, 20, 30],colSum = [30, 20, 10]) == [[10, 0, 0], [20, 0, 0], [0, 20, 10]]\n assert candidate(rowSum = [10, 10, 10, 10, 10],colSum = [5, 5, 5, 5, 50]) == [[5, 5, 0, 0, 0], [0, 0, 5, 5, 0], [0, 0, 0, 0, 10], [0, 0, 0, 0, 10], [0, 0, 0, 0, 10]]\n assert candidate(rowSum = [12, 9, 6],colSum = [10, 10, 7]) == [[10, 2, 0], [0, 8, 1], [0, 0, 6]]\n assert candidate(rowSum = [15, 25, 35, 45],colSum = [20, 30, 25, 25]) == [[15, 0, 0, 0], [5, 20, 0, 0], [0, 10, 25, 0], [0, 0, 0, 25]]\n assert candidate(rowSum = [100, 150, 200, 250],colSum = [150, 200, 250, 100]) == [[100, 0, 0, 0], [50, 100, 0, 0], [0, 100, 100, 0], [0, 0, 150, 100]]\n"}, "metadata": {"canonical_parameter_names": ["rowSum", "colSum"], "leetcode_dataset_entry_point": "Solution().restoreMatrix", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector> restoreMatrix(vector& rowSum, vector& colSum) {", "container": "Solution", "callable": "restoreMatrix", "parameters": [{"name": "rowSum", "type": "vector&"}, {"name": "colSum", "type": "vector&"}], "return_type": "vector>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1606, "task_id": "find-servers-that-handled-most-number-of-requests", "difficulty": "Hard", "problem_description": "You have k servers numbered from 0 to k-1 that are being used to handle multiple requests simultaneously. Each server has infinite computational capacity but cannot handle more than one request at a time. The requests are assigned to servers according to a specific algorithm:\n\nThe ith (0-indexed) request arrives.\nIf all servers are busy, the request is dropped (not handled at all).\nIf the (i % k)th server is available, assign the request to that server.\nOtherwise, assign the request to the next available server (wrapping around the list of servers and starting from 0 if necessary). For example, if the ith server is busy, try to assign the request to the (i+1)th server, then the (i+2)th server, and so on.\n\nYou are given a strictly increasing array arrival of positive integers, where arrival[i] represents the arrival time of the ith request, and another array load, where load[i] represents the load of the ith request (the time it takes to complete). Your goal is to find the busiest server(s). A server is considered busiest if it handled the most number of requests successfully among all the servers.\nReturn a list containing the IDs (0-indexed) of the busiest server(s). You may return the IDs in any order.\n \nExample 1:\n\n\nInput: k = 3, arrival = [1,2,3,4,5], load = [5,2,3,3,3] \nOutput: [1] \nExplanation: \nAll of the servers start out available.\nThe first 3 requests are handled by the first 3 servers in order.\nRequest 3 comes in. Server 0 is busy, so it's assigned to the next available server, which is 1.\nRequest 4 comes in. It cannot be handled since all servers are busy, so it is dropped.\nServers 0 and 2 handled one request each, while server 1 handled two requests. Hence server 1 is the busiest server.\n\nExample 2:\n\nInput: k = 3, arrival = [1,2,3,4], load = [1,2,1,2]\nOutput: [0]\nExplanation: \nThe first 3 requests are handled by first 3 servers.\nRequest 3 comes in. It is handled by server 0 since the server is available.\nServer 0 handled two requests, while servers 1 and 2 handled one request each. Hence server 0 is the busiest server.\n\nExample 3:\n\nInput: k = 3, arrival = [1,2,3], load = [10,12,11]\nOutput: [0,1,2]\nExplanation: Each server handles a single request, so they are all considered the busiest.\n\n \nConstraints:\n\n1 <= k <= 105\n1 <= arrival.length, load.length <= 105\narrival.length == load.length\n1 <= arrival[i], load[i] <= 109\narrival is strictly increasing.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(k = 5,arrival = [1, 7, 8, 9, 10],load = [5, 2, 3, 3, 3]) == [0, 1, 2, 3, 4]\n assert candidate(k = 3,arrival = [1, 2, 3, 4],load = [1, 2, 1, 2]) == [0]\n assert candidate(k = 3,arrival = [1, 2, 3],load = [10, 12, 11]) == [0, 1, 2]\n assert candidate(k = 1,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0]\n assert candidate(k = 5,arrival = [1, 7, 8, 9, 10, 11, 12],load = [2, 3, 2, 1, 3, 2, 2]) == [0, 1]\n assert candidate(k = 10,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 4,arrival = [1, 10, 20, 30, 40],load = [2, 2, 2, 2, 2]) == [0]\n assert candidate(k = 1,arrival = [1, 2, 3, 4, 5],load = [1, 1, 1, 1, 1]) == [0]\n assert candidate(k = 3,arrival = [1, 2, 3, 4, 5],load = [5, 2, 3, 3, 3]) == [1]\n assert candidate(k = 5,arrival = [1, 7, 8, 9, 10],load = [5, 2, 10, 3, 1]) == [0, 1, 2, 3, 4]\n assert candidate(k = 5,arrival = [1, 7, 13, 19, 25, 31, 37, 43, 49, 55],load = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 1, 2, 3, 4]\n assert candidate(k = 4,arrival = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57],load = [4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2]) == [0, 1, 2]\n assert candidate(k = 4,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],load = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0, 1, 2, 3]\n assert candidate(k = 20,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 9,arrival = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91, 101, 111, 121, 131, 141, 151, 161, 171, 181, 191],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 1]\n assert candidate(k = 4,arrival = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2, 3]\n assert candidate(k = 10,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0]\n assert candidate(k = 1000,arrival = [1, 1001, 2001, 3001, 4001, 5001, 6001, 7001, 8001, 9001, 10001],load = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(k = 10,arrival = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59],load = [3, 2, 5, 4, 3, 2, 5, 4, 3, 2, 5, 4, 3, 2, 5, 4, 3, 2, 5, 4]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 100,arrival = [1, 101, 201, 301, 401, 501, 601, 701, 801, 901, 1001],load = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(k = 8,arrival = [1, 4, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144],load = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [0, 1, 2, 3]\n assert candidate(k = 4,arrival = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 1, 2, 3]\n assert candidate(k = 10,arrival = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95],load = [1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 7,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],load = [3, 6, 4, 2, 5, 7, 1, 8, 3, 5, 6, 4, 2, 7, 1]) == [0]\n assert candidate(k = 12,arrival = [1, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90],load = [5, 2, 7, 3, 8, 4, 6, 1, 9, 5, 2, 7, 3, 8, 4, 6, 1, 9, 5, 2, 7, 3, 8, 4, 6, 1, 9, 5, 2, 7, 3]) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(k = 12,arrival = [1, 13, 25, 37, 49, 61, 73, 85, 97, 109, 121, 133, 145, 157, 169, 181, 193, 205, 217, 229],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8]) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(k = 7,arrival = [1, 3, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50],load = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28]) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],load = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [0, 1, 2, 3, 4]\n assert candidate(k = 4,arrival = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225],load = [3, 6, 2, 8, 5, 9, 3, 7, 1, 10, 4, 6, 8, 2, 9]) == [0, 1, 2]\n assert candidate(k = 10,arrival = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],load = [10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 20,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],load = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [0, 1]\n assert candidate(k = 5,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],load = [10, 5, 7, 6, 2, 4, 8, 3, 9, 1, 6]) == [0]\n assert candidate(k = 15,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],load = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(k = 3,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],load = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == [0, 1, 2]\n assert candidate(k = 4,arrival = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040],load = [5, 3, 2, 8, 6, 4, 7, 9, 1, 10, 3, 5, 8, 6, 4, 7, 9, 1, 10, 3, 5, 8, 6, 4, 7, 9, 1, 10, 3]) == [0]\n assert candidate(k = 8,arrival = [1, 2, 3, 5, 10, 12, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(k = 7,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [0, 1, 2]\n assert candidate(k = 10,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],load = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 8,arrival = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76, 81, 86, 91, 96, 101, 106, 111, 116, 121, 126, 131, 136, 141, 146, 151, 156, 161, 166, 171, 176, 181, 186, 191, 196, 201, 206],load = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1]\n assert candidate(k = 5,arrival = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95],load = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [0, 1, 2, 3, 4]\n assert candidate(k = 10,arrival = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400],load = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],load = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [0, 1, 2, 3, 4]\n assert candidate(k = 8,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],load = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5]\n assert candidate(k = 4,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2, 3]\n assert candidate(k = 11,arrival = [1, 12, 23, 34, 45, 56, 67, 78, 89, 100, 111, 122, 133, 144, 155, 166, 177, 188, 199, 210],load = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 10, 9, 8, 7, 6, 5, 4, 3]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(k = 15,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400],load = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(k = 7,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],load = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [0, 1, 2, 3, 4, 5]\n assert candidate(k = 20,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],load = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(k = 9,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],load = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98]) == [0, 1, 2]\n assert candidate(k = 7,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],load = [10, 8, 9, 7, 6, 5, 4, 3, 2, 1, 10, 8, 9, 7, 6, 5, 4, 3, 2, 1, 10, 8, 9, 7, 6, 5, 4, 3, 2, 1, 10, 8, 9, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 3, 4]\n assert candidate(k = 6,arrival = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55],load = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == [0, 1, 2, 3, 4, 5]\n assert candidate(k = 8,arrival = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101, 105, 109, 113, 117],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [0, 1, 2, 3, 4, 5]\n assert candidate(k = 8,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],load = [9, 1, 8, 2, 7, 3, 6, 4, 5, 6, 4, 5, 3, 7, 2, 8, 9, 1, 8, 2]) == [0, 1, 2, 3]\n assert candidate(k = 10,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],load = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 9,arrival = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58],load = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8]) == [0, 1]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100]) == [0, 1, 2, 3, 4]\n assert candidate(k = 7,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 1, 2]\n assert candidate(k = 10,arrival = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],load = [2, 4, 3, 5, 6, 2, 8, 7, 3, 4, 5, 2, 3, 1, 7, 4, 2, 8, 6, 5]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 5,arrival = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],load = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [0, 1, 2, 3, 4]\n assert candidate(k = 10,arrival = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58],load = [4, 7, 2, 9, 1, 8, 6, 5, 3, 2, 10, 5, 7, 9, 1]) == [0, 1, 2, 3, 4]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],load = [5, 5, 5, 5, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2, 3, 4]\n assert candidate(k = 6,arrival = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],load = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == [0, 1, 2, 3]\n assert candidate(k = 10,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],load = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0, 1, 2, 3, 4]\n assert candidate(k = 6,arrival = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 1]\n assert candidate(k = 15,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],load = [5, 15, 10, 5, 10, 15, 5, 10, 15, 5, 10, 15, 5, 10, 15, 5, 10, 15, 5, 10, 15, 5, 10, 15, 5, 10, 15, 5, 10, 15]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(k = 8,arrival = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],load = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [0, 1, 2]\n assert candidate(k = 8,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],load = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [0, 1, 2, 3]\n assert candidate(k = 12,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],load = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [0, 1]\n assert candidate(k = 7,arrival = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40],load = [2, 3, 1, 4, 2, 5, 3, 1, 4, 2, 5, 3, 1, 4]) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(k = 10,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500],load = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 8,arrival = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91, 101, 111, 121, 131, 141, 151, 161, 171, 181, 191],load = [8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5, 4, 3, 2, 1, 8, 7, 6, 5]) == [0, 1, 2, 3]\n assert candidate(k = 3,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],load = [80, 70, 60, 50, 40, 30, 20, 10, 5, 1]) == [0, 2]\n assert candidate(k = 7,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],load = [2, 4, 3, 5, 1, 6, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4]) == [0, 1, 2, 3, 4, 5]\n assert candidate(k = 6,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],load = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5]\n assert candidate(k = 15,arrival = [1, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285],load = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11]) == [0, 1, 2, 3, 4]\n assert candidate(k = 15,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],load = [10, 8, 6, 4, 2, 10, 8, 6, 4, 2, 10, 8, 6, 4, 2, 10, 8, 6, 4, 2, 10, 8, 6, 4, 2, 10, 8, 6, 4, 2]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(k = 4,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1]\n assert candidate(k = 10,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],load = [2, 4, 1, 3, 5, 2, 3, 4, 1, 2, 3, 4, 5, 1, 2, 3, 4, 1, 2, 3, 4, 5, 1, 2, 3, 4, 1, 2, 3, 4]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],load = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [0, 1, 2, 3, 4]\n assert candidate(k = 7,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],load = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60]) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(k = 7,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],load = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5]\n assert candidate(k = 6,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],load = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == [0]\n assert candidate(k = 4,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],load = [2, 3, 1, 4, 2, 1, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]) == [0, 1, 2, 3]\n assert candidate(k = 20,arrival = [1, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400],load = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(k = 6,arrival = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],load = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == [0, 1, 2]\n assert candidate(k = 6,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],load = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0, 1, 2, 3, 4, 5]\n assert candidate(k = 9,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],load = [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8]) == [0, 1]\n assert candidate(k = 5,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == [0]\n assert candidate(k = 10,arrival = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],load = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 5,arrival = [1, 3, 5, 7, 9, 11, 13, 15],load = [2, 2, 2, 2, 2, 2, 2, 2]) == [0, 1, 2]\n assert candidate(k = 1,arrival = [1, 10, 20, 30],load = [5, 5, 5, 5]) == [0]\n assert candidate(k = 4,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0, 1]\n assert candidate(k = 6,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],load = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [0, 1, 2, 3]\n assert candidate(k = 4,arrival = [1, 3, 5, 7, 9, 11, 13, 15],load = [2, 2, 2, 2, 2, 2, 2, 2]) == [0, 1, 2, 3]\n assert candidate(k = 7,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(k = 6,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2, 3]\n assert candidate(k = 10,arrival = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 5,arrival = [1, 5, 9, 14, 18],load = [4, 3, 5, 2, 3]) == [0, 1, 2, 3, 4]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2, 3, 4]\n assert candidate(k = 7,arrival = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == [0, 1, 2, 3, 4]\n assert candidate(k = 1,arrival = [1, 10, 20, 30, 40],load = [1, 1, 1, 1, 1]) == [0]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == [0, 1, 2, 3, 4]\n assert candidate(k = 3,arrival = [1, 2, 3, 4, 5, 6],load = [3, 2, 1, 1, 2, 3]) == [0, 1, 2]\n assert candidate(k = 5,arrival = [1, 7, 13, 19],load = [10, 10, 10, 10]) == [0, 1, 2, 3]\n assert candidate(k = 10,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 2,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],load = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0, 1]\n assert candidate(k = 2,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1]\n assert candidate(k = 4,arrival = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],load = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 1]\n assert candidate(k = 5,arrival = [1, 3, 5, 7, 9],load = [2, 2, 2, 2, 2]) == [0, 1, 2, 3, 4]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [2, 3, 1, 5, 4, 2, 3, 1, 2, 1]) == [0, 1, 2, 3, 4]\n assert candidate(k = 7,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2]\n assert candidate(k = 10,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],load = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 6,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],load = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]) == [0, 1, 2, 3, 4, 5]\n assert candidate(k = 2,arrival = [1, 3, 5, 7, 9],load = [2, 2, 2, 2, 2]) == [0]\n assert candidate(k = 100,arrival = [1, 101, 201, 301, 401, 501, 601, 701, 801, 901],load = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 5,arrival = [1, 2, 3, 8, 10, 13, 15, 16, 17, 20],load = [2, 3, 1, 4, 2, 3, 2, 1, 2, 3]) == [0, 1, 2, 3, 4]\n assert candidate(k = 1,arrival = [1, 10, 20, 30, 40],load = [5, 5, 5, 5, 5]) == [0]\n assert candidate(k = 2,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [5, 3, 5, 3, 5, 3, 5, 3, 5, 3]) == [0, 1]\n assert candidate(k = 10000,arrival = [1, 10001, 20001, 30001, 40001],load = [10000, 10000, 10000, 10000, 10000]) == [0, 1, 2, 3, 4]\n assert candidate(k = 4,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],load = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 1]\n assert candidate(k = 10,arrival = [1, 5, 9, 13, 17],load = [3, 3, 3, 3, 3]) == [0, 1, 2, 3, 4]\n assert candidate(k = 1,arrival = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82],load = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [0]\n assert candidate(k = 6,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],load = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [0, 1, 2, 3]\n assert candidate(k = 6,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],load = [20, 10, 20, 10, 20, 10, 20, 10, 20, 10]) == [0, 1, 2, 3]\n assert candidate(k = 4,arrival = [1, 5, 9, 13, 17, 21],load = [2, 2, 2, 2, 2, 2]) == [0, 1]\n assert candidate(k = 5,arrival = [1, 7, 13, 19, 25],load = [5, 6, 7, 8, 9]) == [0, 1, 2, 3, 4]\n assert candidate(k = 4,arrival = [1, 10, 20, 30, 40, 50],load = [3, 3, 3, 3, 3, 3]) == [0, 1]\n assert candidate(k = 5,arrival = [1, 7, 13, 19, 25],load = [5, 3, 8, 6, 2]) == [0, 1, 2, 3, 4]\n assert candidate(k = 100,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]\n assert candidate(k = 1,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0]\n assert candidate(k = 6,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],load = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]) == [0, 1, 2, 3, 4, 5]\n assert candidate(k = 2,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [0, 1]\n assert candidate(k = 1,arrival = [1, 2, 3, 4, 5],load = [5, 4, 3, 2, 1]) == [0]\n assert candidate(k = 7,arrival = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28],load = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0, 1, 2]\n assert candidate(k = 1000,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 7,arrival = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2]\n assert candidate(k = 2,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == [0, 1]\n assert candidate(k = 10,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],load = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 10,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],load = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 10,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 4,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1]\n assert candidate(k = 7,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],load = [2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == [0, 1, 2, 3, 4, 5]\n assert candidate(k = 4,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2, 3]\n assert candidate(k = 10,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 2,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [0]\n assert candidate(k = 10,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 6,arrival = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28],load = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [0, 1, 2, 3]\n assert candidate(k = 7,arrival = [1, 3, 5, 7, 9, 11, 13, 15],load = [2, 2, 2, 2, 2, 2, 2, 2]) == [0]\n assert candidate(k = 100,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 5,arrival = [1, 7, 13, 19, 25, 31],load = [5, 5, 5, 5, 5, 5]) == [0]\n assert candidate(k = 5,arrival = [1, 7, 13, 19],load = [5, 5, 5, 5]) == [0, 1, 2, 3]\n assert candidate(k = 2,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1]\n assert candidate(k = 7,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [0, 1, 2, 3, 4]\n assert candidate(k = 4,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [2, 1, 3, 2, 1, 3, 2, 1, 3, 2]) == [0, 1]\n assert candidate(k = 6,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],load = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9]) == [0, 1, 2, 3]\n assert candidate(k = 10,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],load = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [0, 1, 2, 3, 4]\n assert candidate(k = 7,arrival = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],load = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2]\n assert candidate(k = 10,arrival = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91],load = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 4,arrival = [1, 5, 9, 13, 17],load = [4, 4, 4, 4, 4]) == [0]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [2, 3, 4, 5, 6, 1, 2, 3, 4, 5]) == [0]\n assert candidate(k = 5,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],load = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 1, 2, 3, 4]\n assert candidate(k = 6,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],load = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 1, 2]\n assert candidate(k = 4,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [0, 1]\n assert candidate(k = 4,arrival = [1, 3, 5, 7, 9],load = [1, 2, 1, 2, 1]) == [0]\n assert candidate(k = 1,arrival = [1, 10, 100, 1000, 10000],load = [1, 2, 3, 4, 5]) == [0]\n assert candidate(k = 5,arrival = [1, 7, 13, 19, 25],load = [5, 5, 5, 5, 5]) == [0, 1, 2, 3, 4]\n assert candidate(k = 1,arrival = [1, 10, 100, 1000, 10000],load = [1, 1, 1, 1, 1]) == [0]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == [0, 1, 2, 3, 4]\n assert candidate(k = 7,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],load = [4, 2, 6, 3, 5, 1, 7, 8, 2, 5]) == [0, 1, 2]\n assert candidate(k = 10,arrival = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],load = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(k = 7,arrival = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],load = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 1, 2]\n assert candidate(k = 5,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == [0, 1, 2, 3]\n assert candidate(k = 4,arrival = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],load = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0]\n assert candidate(k = 2,arrival = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],load = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [0, 1]\n"}, "metadata": {"canonical_parameter_names": ["k", "arrival", "load"], "leetcode_dataset_entry_point": "Solution().busiestServers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector busiestServers(int k, vector& arrival, vector& load) {", "container": "Solution", "callable": "busiestServers", "parameters": [{"name": "k", "type": "int"}, {"name": "arrival", "type": "vector&"}, {"name": "load", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1608, "task_id": "special-array-with-x-elements-greater-than-or-equal-x", "difficulty": "Easy", "problem_description": "You are given an array nums of non-negative integers. nums is considered special if there exists a number x such that there are exactly x numbers in nums that are greater than or equal to x.\nNotice that x does not have to be an element in nums.\nReturn x if the array is special, otherwise, return -1. It can be proven that if nums is special, the value for x is unique.\n \nExample 1:\n\nInput: nums = [3,5]\nOutput: 2\nExplanation: There are 2 values (3 and 5) that are greater than or equal to 2.\n\nExample 2:\n\nInput: nums = [0,0]\nOutput: -1\nExplanation: No numbers fit the criteria for x.\nIf x = 0, there should be 0 numbers >= x, but there are 2.\nIf x = 1, there should be 1 number >= x, but there are 0.\nIf x = 2, there should be 2 numbers >= x, but there are 0.\nx cannot be greater since there are only 2 numbers in nums.\n\nExample 3:\n\nInput: nums = [0,4,3,0,4]\nOutput: 3\nExplanation: There are 3 values that are greater than or equal to 3.\n\n \nConstraints:\n\n1 <= nums.length <= 100\n0 <= nums[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 10\n assert candidate(nums = [0, 1, 2, 3, 4, 5]) == 3\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500]) == 5\n assert candidate(nums = [0, 0]) == -1\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 4\n assert candidate(nums = [10, 20, 30, 40, 50]) == 5\n assert candidate(nums = [5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [0, 0, 0, 0, 0]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5]) == 3\n assert candidate(nums = [1000]) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0]) == -1\n assert candidate(nums = [0]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500]) == 5\n assert candidate(nums = [0, 4, 3, 0, 4]) == 3\n assert candidate(nums = [3, 5]) == 2\n assert candidate(nums = [1000, 999, 998, 997, 996]) == 5\n assert candidate(nums = [1, 2, 3, 3, 3]) == 3\n assert candidate(nums = [1000, 1000, 1000]) == 3\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1000, 1000, 1000, 1000]) == 14\n assert candidate(nums = [9, 30, 20, 10, 40, 50, 60, 70, 80, 90]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == -1\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 10\n assert candidate(nums = [0, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == -1\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 20\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 60\n assert candidate(nums = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 20\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10, 10]) == 8\n assert candidate(nums = [999, 999, 999, 999, 999, 999, 999, 999, 999, 999, 999]) == 11\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == -1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 98\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == -1\n assert candidate(nums = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 10\n assert candidate(nums = [1, 2, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970, 969, 968, 967, 966, 965, 964, 963, 962, 961, 960]) == 41\n assert candidate(nums = [0, 0, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == -1\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == -1\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300]) == 28\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970, 969, 968, 967, 966, 965, 964, 963, 962, 961, 960, 959, 958, 957, 956, 955, 954, 953, 952, 951, 950]) == 50\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == -1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 7\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 1000]) == -1\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == -1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 5, 6, 7, 8, 9, 10, 10, 10]) == -1\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == -1\n assert candidate(nums = [0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50]) == 34\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 14\n assert candidate(nums = [1, 3, 2, 4, 5, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4]) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5]) == -1\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 14\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10]) == 7\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 2, 3, 4, 5]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 8\n assert candidate(nums = [3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == -1\n assert candidate(nums = [1, 0, 3, 0, 5, 0, 7, 0, 9, 0, 11, 0, 13, 0, 15, 0, 17, 0, 19, 0]) == 7\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().specialArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int specialArray(vector& nums) {", "container": "Solution", "callable": "specialArray", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1609, "task_id": "even-odd-tree", "difficulty": "Medium", "problem_description": "A binary tree is named Even-Odd if it meets the following conditions:\n\nThe root of the binary tree is at level index 0, its children are at level index 1, their children are at level index 2, etc.\nFor every even-indexed level, all nodes at the level have odd integer values in strictly increasing order (from left to right).\nFor every odd-indexed level, all nodes at the level have even integer values in strictly decreasing order (from left to right).\n\nGiven the root of a binary tree, return true if the binary tree is Even-Odd, otherwise return false.\n \nExample 1:\n\n\nInput: root = [1,10,4,3,null,7,9,12,8,6,null,null,2]\nOutput: true\nExplanation: The node values on each level are:\nLevel 0: [1]\nLevel 1: [10,4]\nLevel 2: [3,7,9]\nLevel 3: [12,8,6,2]\nSince levels 0 and 2 are all odd and increasing and levels 1 and 3 are all even and decreasing, the tree is Even-Odd.\n\nExample 2:\n\n\nInput: root = [5,4,2,3,3,7]\nOutput: false\nExplanation: The node values on each level are:\nLevel 0: [5]\nLevel 1: [4,2]\nLevel 2: [3,3,7]\nNode values in level 2 must be in strictly increasing order, so the tree is not Even-Odd.\n\nExample 3:\n\n\nInput: root = [5,9,1,3,5,7]\nOutput: false\nExplanation: Node values in the level 1 should be even integers.\n\n \nConstraints:\n\nThe number of nodes in the tree is in the range [1, 105].\n1 <= Node.val <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7])) == False\n assert candidate(root = tree_node([1, 2, 3])) == False\n assert candidate(root = tree_node([2, 1, 3, 4, 7, 6, 8, None, None, None, None, 9])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2])) == True\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 7])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6])) == False\n assert candidate(root = tree_node([1, 3, 5, 7, 9])) == False\n assert candidate(root = tree_node([2, 2, 2])) == False\n assert candidate(root = tree_node([2, 1, 3, 4, 7, 6, 8])) == False\n assert candidate(root = tree_node([5, 9, 1, 3, 5, 7])) == False\n assert candidate(root = tree_node([2, 1, 3, 4, 7, 6, 8, None, None, None, None, None, None, 9])) == False\n assert candidate(root = tree_node([1])) == True\n assert candidate(root = tree_node([11, 8, 6, 1, 3, 9, 11, 30, 20, 18, 16, 12, 10, 4, 2, 17])) == True\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 14])) == False\n assert candidate(root = tree_node([1, 10, 5, 3, 8, None, 7, None, 4, None, None, 2, 6, 9, 11])) == False\n assert candidate(root = tree_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, 21])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, 18, None, None, None, None, None, None, 20, None, None, 21, None, 22, None, None, 23])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, 18, None, None, None, None, None, None, None, None, 19, None, None, None, None, 20])) == False\n assert candidate(root = tree_node([5, 2, 8, None, 11, None, 21, None, 35, 18, None, None, 47, None, 53, 27, None, 65])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, 6, 8, 9, 11, 13, 12, 14])) == False\n assert candidate(root = tree_node([10, 9, 10, 5, 7, 8, 9, 2, 4, 6, 8, 10, 12, 14, 16, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47])) == False\n assert candidate(root = tree_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, 2, 9, 8, 6, 12, 13, 15, 17, 19, 21, 23])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 14, 16, 13, 11, 15, None, None, 18, 17, None, None, 19, None, None, 20])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, 2, 9, 8, 6, 12, None, None, None, None, 13])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, 2, 9, 8, 6, 12, 13, 15])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 14, 13, 11, None, None, 15, 17, 18])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, None, None, 5, None, None, 11, None, None, 13, None, None, 15])) == False\n assert candidate(root = tree_node([1, 8, 6, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 11, 15, None, 5])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 6, 1, 8, 9, 10, 11, 12, 13, 14])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, None, 16, 17, 18, 19, 20, 21, 22])) == False\n assert candidate(root = tree_node([5, 9, 1, 3, 5, 7, None, None, 8, 6, None, 10, 11, 12, None, 14, None, None, None, 13])) == False\n assert candidate(root = tree_node([2, 6, 10, 4, 8, 12, 16, 2, 4, 6, 8, 10, 12, 14, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 14, 16, 13, 11, 15, None, None, 18, 17, None, None, 19])) == False\n assert candidate(root = tree_node([11, 6, 8, 9, 5, 14, 7, 12, None, 9, 15, None, None, None, 1, None, None, 13, None, None, 10])) == False\n assert candidate(root = tree_node([1, 3, 2, 4, 6, 5, None, None, None, None, None, None, 7])) == False\n assert candidate(root = tree_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 11, None, 5])) == False\n assert candidate(root = tree_node([3, 12, 8, 10, 14, 2, 13, 7, 12, None, 6, 14, 9, 14, 9, 14, None, None, 12, None, 13, 13, 7, 12, None, 12, 13, None, None, None, 10, None, 6, None, None, None, None, None, None, 10, None, 14, 9, 3, None, 13, 13, None, None, None, 12, None, None, None, 14, None, None, None, None, None, None, 14])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 11, None, None, None, 5])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, 16])) == False\n assert candidate(root = tree_node([7, 4, 9, 6, 5, 8, 3, 1, None, 2, 6, 4, 5, None, None, None, None, None, 9, 3])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 11, None, 16, 5])) == False\n assert candidate(root = tree_node([9, 14, 4, 14, 2, 9, 5, None, None, 6, None, None, 12, None, None, 14, None, 7, 10])) == False\n assert candidate(root = tree_node([2, 8, 6, 10, 4, 3, 7, 1, 9, 5, 6, 12, None, 11, None, None, None, None, None, None, None, 13])) == False\n assert candidate(root = tree_node([5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 51])) == False\n assert candidate(root = tree_node([5, 9, 1, 3, 5, 7, None, None, 8, 6, None, 10, 11, 12, None, None, None, None, 13])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 5, None, None, 11, 14, None, None, 13, None, None, 15])) == False\n assert candidate(root = tree_node([2, 1, 3, 4, 7, 6, 8, None, None, None, None, 9, 10, 11, 12])) == False\n assert candidate(root = tree_node([2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53])) == False\n assert candidate(root = tree_node([1, 8, 6, None, 9, 2, 5, None, 11, None, None, None, 7])) == False\n assert candidate(root = tree_node([1, 3, 2, 5, 7, 6, 8, 9, 11, 13, 15, 14, 12, 10, 8])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, None, None, 7, 8, 9, None, 11, None, 13, None, None, 17, None, None, 19])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, 18, None, None, None, None, None, None, 20, None, None, 21, None, 22, None, None, 24])) == False\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5])) == True\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 5, None, None, 11])) == True\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 8, 6, 4, 2, None, 9, 11, 13, 15, 17, 19, 21, 23, 25])) == False\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5])) == True\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, 2, 9, 8, 6, 12, 13, 15, 17, 19, 21])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])) == False\n assert candidate(root = tree_node([2, 6, 1, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41])) == False\n assert candidate(root = tree_node([5, 8, 6, 3, 5, 7, 8, 1, 6, None, 10, 9, None, None, 11, None, None, 12, None, None, 13, None, None, 14, None, None, 15, None, None, 16])) == False\n assert candidate(root = tree_node([2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 11, None, None, 5, None])) == False\n assert candidate(root = tree_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 31])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, 2, 9, 8, 6, 12, None, None, None, 13])) == False\n assert candidate(root = tree_node([3, 5, 9, 7, 11, 13, 17, 19, 23, 27, 29, 31, 35, 37, 39, 41, 43, 47, 51, 53, 57, 59])) == False\n assert candidate(root = tree_node([15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, 2, 9, 8, 6, 12, 13])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, 8, 7, 9, 12, 8, 6, 11, None, None, 2, 5])) == False\n assert candidate(root = tree_node([8, 6, 10, 5, 3, 7, 9, 2, None, None, 6, None, None, 11, None, None, 2, 5, 12, 11, 10])) == False\n assert candidate(root = tree_node([15, 9, 11, 7, 13, 17, 19, 3, 5, 12, 14, 18, 20, None, None, None, None, 10])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 11, None, 15, None, 5])) == False\n assert candidate(root = tree_node([2, 1, 3, 4, 7, 6, 8, None, None, 9, 10, None, None, 11, 12, None, None, 13, 14])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, 2, 9, 8, 6, 12])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, 9, None, 11, 13, None, 15])) == False\n assert candidate(root = tree_node([7, 4, 6, 1, None, None, 8, None, 1, None, 3, 5, 9])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 1, 6, None, 8, 4, 5, None, None, None, None, None, 9, 10])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, 18, None, None, None, None, None, None, 20, None, None, 21, None, 22, None, None, 25])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 14, 13, 11, None, None, 15])) == False\n assert candidate(root = tree_node([7, 6, 5, 4, 3, 2, 1, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, None, None, 8, 6, None, 9, None, None, None, None, 10])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, 2, 9, 8, 6, 12, None, None, 13])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, None, None, None, 26, None, None, None, None, None, None, None, 27])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, 16, None, None, None, None, None, None, None, None, 17])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, None, None, 11, None, 5])) == False\n assert candidate(root = tree_node([1, 8, 6, None, 9, 2, 5, None, None, None, None, None, 7])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, None, 7, None, 9, None, 11, None, 13, None, 15, None, 17, None, 19])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, None, None, 8, 9, None, 11, None, 13, None, 15, None, 17, None, 19])) == False\n assert candidate(root = tree_node([31, 15, 16, 7, 9, 11, 13, 3, 5, 6, 8, 10, 12, 14, 18, 1, 2, 4, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 25, None, None, None, None, None, None, None, None, None, None])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 14, 16, 13, 11, 15, None, None, 18, 17])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 14, 13, 11, None, None, 15, 17, 18, 20])) == False\n assert candidate(root = tree_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29])) == False\n assert candidate(root = tree_node([1, 2, 3, None, 4, 5, 6, None, None, 7, 8, 9, 10, None, None, 11, 12, 13, 14])) == False\n assert candidate(root = tree_node([7, 10, 5, 1, 1, None, 6, None, None, 3, 8, 2, 4, None, None, None, 9])) == False\n assert candidate(root = tree_node([1, 3, 2, 4, 6, 5, None, None, None, None, None, 8, None, 7])) == False\n assert candidate(root = tree_node([1, 14, 3, 7, None, 7, 9, 12, 8, 6, None, 10, None, None, None, None, 11])) == False\n assert candidate(root = tree_node([5, 8, 6, 12, 4, None, 10, None, 2, 0, 3, 9, 7, 5, 6])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, None, None, 14, 16, None, 13, None, 11, None, 15, None, None, 18, 17])) == False\n assert candidate(root = tree_node([2, 3, 4, 5, 6, 7, 8, None, None, 9, 10, None, None, 11, 12, None, None, 13, 14, None, None, 15, 16, None, None, 17, 18])) == False\n assert candidate(root = tree_node([1, 2, 3, None, 5, None, 7, None, 9, None, 11])) == False\n assert candidate(root = tree_node([5, 9, 1, 3, 5, 7, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 8, 1, 1, 6, 6, 9, 10, None, None, None, None, None, None, 11, 12])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 5, None, None, 10])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 6, 1, None, 8, 9, 10, 11, 12, 13])) == False\n assert candidate(root = tree_node([5, 9, 1, 3, 5, 7, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 16, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])) == False\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, None, None, 11, None, 13, None, None, 17, None, None, 19])) == False\n assert candidate(root = tree_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 8, 1, 6, None, 10, 9, None, None, 11, None, None, 12, 13])) == False\n assert candidate(root = tree_node([11, 13, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, None, None, 26, 27, 28, 29, 30, 31, 32, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 33])) == False\n assert candidate(root = tree_node([15, 20, 17, 12, 8, 13, 11, 7, 5, 6, 14, 4, 3, 10, 2, 1, 18, 16, 9, 19])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 14, 13, 11, None, None, 15, 17, 18, 20, 22, 24, 26, 28, 30, 32, 34])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 5, None, None, None, 11])) == True\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, 18, None, 19, None, None, 22, None, None, 23, None, None, 26, None, None, 27])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, 2, 9, 8, 6, 12, 13, 15, 17, 19])) == False\n assert candidate(root = tree_node([11, 6, 10, 8, 6, 6, 6, 10, 8, 2, 4, None, None, 10, 1, None, None, 6, 2, 4, 8, None, 10, 6, 2, 6, 4, 8, None, 4, None, None, 4, None, 8, 10, None, 6, None, None, None, None, 4, 8, None, 6, None, 2, 10, 6, None, None, 10, None, None, None, None, None, None, 6, None, None, None, None, None, None, None, None, None, None, None, None, 10])) == False\n assert candidate(root = tree_node([1, 8, 6, 3, 5, 7, 9, 2, 4, None, 6, None, 8, None, None, None, None, None, 10])) == False\n assert candidate(root = tree_node([3, 12, 8, 10, 14, 9, 5, 11, 13, None, None, 4, 6, None, None, 2, 7, None, None, 15, None, 1, 16])) == False\n assert candidate(root = tree_node([5, 9, 1, 3, 5, 7, 6, 2, 4, 8, 10, 12, 14, 16, 18])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 11, 14, None, 5])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, 2, 9, 8, 6, 12, 13, 15, 17])) == False\n assert candidate(root = tree_node([1, 10, 4, 3, None, 7, 9, 12, 8, 6, None, None, 2, 5, None, None, None, None, 11])) == True\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, 2, 9, 8, 6, 12, 13, 15, 17, 19, 21, 23, 25])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 10, 1, None, None, 6, 8, 9, 12])) == False\n assert candidate(root = tree_node([5, 4, 2, 3, 3, 7, 8, 6, 5, 4, 3, 2, 1])) == False\n"}, "metadata": {"canonical_parameter_names": ["root"], "leetcode_dataset_entry_point": "Solution().isEvenOddTree", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool isEvenOddTree(TreeNode* root) {", "container": "Solution", "callable": "isEvenOddTree", "parameters": [{"name": "root", "type": "TreeNode*"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1610, "task_id": "maximum-number-of-visible-points", "difficulty": "Hard", "problem_description": "You are given an array points, an integer angle, and your location, where location = [posx, posy] and points[i] = [xi, yi] both denote integral coordinates on the X-Y plane.\nInitially, you are facing directly east from your position. You cannot move from your position, but you can rotate. In other words, posx and posy cannot be changed. Your field of view in degrees is represented by angle, determining how wide you can see from any given view direction. Let d be the amount in degrees that you rotate counterclockwise. Then, your field of view is the inclusive range of angles [d - angle/2, d + angle/2].\n\nYour browser does not support the video tag or this video format.\n\nYou can see some set of points if, for each point, the angle formed by the point, your position, and the immediate east direction from your position is in your field of view.\nThere can be multiple points at one coordinate. There may be points at your location, and you can always see these points regardless of your rotation. Points do not obstruct your vision to other points.\nReturn the maximum number of points you can see.\n \nExample 1:\n\n\nInput: points = [[2,1],[2,2],[3,3]], angle = 90, location = [1,1]\nOutput: 3\nExplanation: The shaded region represents your field of view. All points can be made visible in your field of view, including [3,3] even though [2,2] is in front and in the same line of sight.\n\nExample 2:\n\nInput: points = [[2,1],[2,2],[3,4],[1,1]], angle = 90, location = [1,1]\nOutput: 4\nExplanation: All points can be made visible in your field of view, including the one at your location.\n\nExample 3:\n\n\nInput: points = [[1,0],[2,1]], angle = 13, location = [1,1]\nOutput: 1\nExplanation: You can only see one of the two points, as shown above.\n\n \nConstraints:\n\n1 <= points.length <= 105\npoints[i].length == 2\nlocation.length == 2\n0 <= angle < 360\n0 <= posx, posy, xi, yi <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[1, 0], [0, 1], [-1, 0], [0, -1]],angle = 90,location = [0, 0]) == 2\n assert candidate(points = [[100, 100], [100, 99], [99, 100], [99, 99]],angle = 45,location = [100, 100]) == 3\n assert candidate(points = [[0, 0], [5, 5], [10, 10]],angle = 90,location = [0, 0]) == 3\n assert candidate(points = [[2, 2], [3, 3], [4, 4], [1, 1]],angle = 45,location = [2, 2]) == 3\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1]],angle = 0,location = [0, 0]) == 2\n assert candidate(points = [[1, 0], [2, 1]],angle = 13,location = [1, 1]) == 1\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5]],angle = 45,location = [1, 1]) == 4\n assert candidate(points = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2]],angle = 90,location = [3, 2]) == 3\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3]],angle = 0,location = [0, 0]) == 4\n assert candidate(points = [[50, 50], [51, 50], [52, 50]],angle = 1,location = [50, 50]) == 3\n assert candidate(points = [[0, 0], [50, 50]],angle = 90,location = [25, 25]) == 1\n assert candidate(points = [[2, 1], [2, 2], [3, 3]],angle = 90,location = [1, 1]) == 3\n assert candidate(points = [[100, 100]],angle = 360,location = [100, 100]) == 1\n assert candidate(points = [[0, 0], [100, 100]],angle = 1,location = [50, 50]) == 1\n assert candidate(points = [[1, 1], [1, 1], [1, 1]],angle = 180,location = [1, 1]) == 3\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],angle = 360,location = [1, 1]) == 5\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],angle = 180,location = [3, 3]) == 5\n assert candidate(points = [[10, 10], [11, 10], [12, 10], [13, 10], [14, 10]],angle = 45,location = [10, 10]) == 5\n assert candidate(points = [[1, 1], [2, 2], [1, 2], [2, 1]],angle = 45,location = [1, 1]) == 3\n assert candidate(points = [[2, 1], [2, 2], [3, 4], [1, 1]],angle = 90,location = [1, 1]) == 4\n assert candidate(points = [[0, 0], [0, 1], [1, 0], [1, 1]],angle = 90,location = [0, 0]) == 4\n assert candidate(points = [[0, 0], [0, 0], [0, 0]],angle = 180,location = [0, 0]) == 3\n assert candidate(points = [[1, 1], [1, 1], [1, 1]],angle = 360,location = [1, 1]) == 3\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]],angle = 360,location = [1, 1]) == 17\n assert candidate(points = [[1, 0], [0, 1], [-1, 0], [0, -1], [2, 0], [0, 2], [-2, 0], [0, -2]],angle = 45,location = [0, 0]) == 2\n assert candidate(points = [[10, 10], [10, 20], [20, 10], [20, 20], [15, 15], [5, 5], [25, 25], [5, 25], [25, 5], [15, 5], [5, 15], [25, 15], [15, 25]],angle = 120,location = [15, 15]) == 6\n assert candidate(points = [[5, 5], [10, 5], [15, 5], [20, 5], [25, 5], [5, 10], [10, 10], [15, 10], [20, 10], [25, 10]],angle = 45,location = [15, 15]) == 5\n assert candidate(points = [[0, 0], [10, 0], [20, 0], [30, 0], [40, 0], [50, 0], [60, 0], [70, 0], [80, 0], [90, 0]],angle = 10,location = [50, 0]) == 6\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],angle = 30,location = [5, 5]) == 5\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9]],angle = 10,location = [1, 5]) == 5\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [3, 3], [4, 4]],angle = 180,location = [1, 1]) == 10\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4]],angle = 180,location = [2, 2]) == 12\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]],angle = 30,location = [5, 1]) == 10\n assert candidate(points = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]],angle = 30,location = [5, 5]) == 6\n assert candidate(points = [[2, 1], [1, 2], [3, 1], [1, 3], [2, 2]],angle = 90,location = [2, 1]) == 4\n assert candidate(points = [[10, 0], [20, 0], [30, 0], [40, 0], [50, 0]],angle = 180,location = [25, 25]) == 5\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],angle = 359,location = [1, 1]) == 10\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],angle = 180,location = [5, 5]) == 10\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 5], [5, 1]],angle = 90,location = [3, 3]) == 4\n assert candidate(points = [[100, 100], [50, 50], [50, 100], [100, 50], [75, 75], [25, 25], [75, 25], [25, 75]],angle = 45,location = [50, 50]) == 4\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]],angle = 90,location = [4, 4]) == 5\n assert candidate(points = [[2, 3], [3, 2], [4, 5], [5, 4], [6, 5], [5, 6]],angle = 45,location = [4, 4]) == 2\n assert candidate(points = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [5, 6], [6, 5], [5, 4], [4, 5]],angle = 90,location = [5, 5]) == 8\n assert candidate(points = [[2, 1], [3, 4], [5, 5], [4, 2], [1, 2], [3, 1]],angle = 45,location = [3, 3]) == 2\n assert candidate(points = [[2, 0], [2, 2], [1, 3], [3, 3], [0, 2]],angle = 60,location = [2, 1]) == 3\n assert candidate(points = [[5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]],angle = 10,location = [5, 5]) == 6\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9]],angle = 90,location = [5, 1]) == 11\n assert candidate(points = [[10, 10], [10, 9], [9, 10], [9, 11], [11, 10], [11, 11], [8, 8], [8, 9], [9, 8], [11, 9]],angle = 45,location = [10, 10]) == 4\n assert candidate(points = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 6], [6, 5], [7, 8], [8, 7], [9, 10], [10, 9]],angle = 30,location = [5, 5]) == 4\n assert candidate(points = [[1, 2], [2, 2], [4, 5], [5, 4], [3, 3]],angle = 45,location = [3, 3]) == 3\n assert candidate(points = [[1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [0, 1], [2, 1], [0, 2], [2, 2], [0, 3], [2, 3], [0, 4], [2, 4], [0, 5], [2, 5]],angle = 90,location = [1, 1]) == 17\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],angle = 45,location = [25, 25]) == 3\n assert candidate(points = [[5, 5], [5, 10], [5, 15], [5, 20], [5, 25]],angle = 90,location = [5, 15]) == 3\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],angle = 30,location = [3, 3]) == 3\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],angle = 90,location = [5, 1]) == 6\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],angle = 30,location = [5, 5]) == 4\n assert candidate(points = [[10, 10], [10, 20], [20, 10], [20, 20], [15, 15], [5, 5], [25, 25]],angle = 90,location = [15, 15]) == 4\n assert candidate(points = [[0, 1], [1, 0], [0, -1], [-1, 0], [0, 0], [1, 1], [-1, -1], [1, -1], [-1, 1]],angle = 90,location = [0, 0]) == 4\n assert candidate(points = [[5, 5], [5, 6], [6, 5], [6, 6], [7, 7], [8, 8], [9, 9]],angle = 45,location = [5, 5]) == 6\n assert candidate(points = [[50, 50], [50, 40], [50, 30], [50, 20], [50, 10], [50, 0], [50, -10], [50, -20], [50, -30], [50, -40]],angle = 120,location = [50, 50]) == 10\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [1, 2], [2, 2], [3, 2], [1, 3], [2, 3], [3, 3]],angle = 60,location = [2, 2]) == 3\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4], [5, 5], [5, 5], [5, 5]],angle = 90,location = [3, 3]) == 9\n assert candidate(points = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]],angle = 45,location = [5, 5]) == 6\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],angle = 30,location = [0, 0]) == 10\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],angle = 60,location = [5, 1]) == 6\n assert candidate(points = [[10, 10], [10, 20], [10, 30], [10, 40], [10, 50], [10, 60], [10, 70]],angle = 15,location = [10, 10]) == 7\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],angle = 30,location = [25, 25]) == 3\n assert candidate(points = [[100, 0], [0, 100], [100, 100], [50, 50], [25, 25], [75, 75]],angle = 60,location = [50, 50]) == 3\n assert candidate(points = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]],angle = 180,location = [10, 5]) == 10\n assert candidate(points = [[1, 0], [0, 1], [-1, 0], [0, -1], [0, 0]],angle = 90,location = [0, 0]) == 3\n assert candidate(points = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0], [11, 0]],angle = 90,location = [5, 0]) == 7\n assert candidate(points = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10]],angle = 15,location = [25, 10]) == 3\n assert candidate(points = [[1, 1], [1, 2], [2, 1], [2, 2], [3, 1], [3, 2], [4, 1], [4, 2], [5, 1], [5, 2]],angle = 90,location = [3, 2]) == 6\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],angle = 90,location = [30, 30]) == 3\n assert candidate(points = [[1, 0], [0, 1], [1, 1], [0, 0], [2, 2], [3, 3], [4, 4], [5, 5]],angle = 90,location = [1, 1]) == 5\n assert candidate(points = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]],angle = 60,location = [5, 5]) == 6\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],angle = 10,location = [5, 5]) == 6\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]],angle = 10,location = [5, 1]) == 5\n assert candidate(points = [[10, 10], [11, 11], [10, 11], [9, 10], [10, 9], [9, 9], [9, 11], [11, 9]],angle = 60,location = [10, 10]) == 3\n assert candidate(points = [[0, 1], [1, 0], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]],angle = 60,location = [3, 3]) == 5\n assert candidate(points = [[5, 5], [5, 6], [6, 5], [6, 6], [10, 10], [10, 11], [11, 10], [11, 11]],angle = 90,location = [8, 8]) == 4\n assert candidate(points = [[10, 10], [10, 20], [20, 10], [20, 20], [15, 15]],angle = 45,location = [15, 15]) == 2\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 2], [1, 2], [1, 2], [1, 3], [1, 3], [1, 3], [1, 4], [1, 4], [1, 4], [1, 5], [1, 5], [1, 5], [1, 1], [1, 1], [1, 1]],angle = 10,location = [1, 3]) == 12\n assert candidate(points = [[100, 0], [0, 100], [0, 0], [100, 100], [50, 50]],angle = 90,location = [50, 50]) == 3\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],angle = 10,location = [5, 5]) == 6\n assert candidate(points = [[5, 5], [5, 6], [6, 5], [6, 6], [7, 7], [7, 8], [8, 7], [8, 8]],angle = 90,location = [6, 6]) == 5\n assert candidate(points = [[50, 50], [50, 49], [50, 51], [49, 50], [51, 50], [49, 49], [51, 51], [52, 52], [48, 48]],angle = 30,location = [50, 50]) == 3\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],angle = 5,location = [1, 5]) == 6\n assert candidate(points = [[2, 0], [0, 2], [2, 2], [1, 1], [0, 0], [1, 0]],angle = 45,location = [1, 1]) == 3\n assert candidate(points = [[10, 0], [0, 10], [10, 10], [5, 5], [2, 2], [8, 8]],angle = 30,location = [5, 5]) == 3\n assert candidate(points = [[1, 1], [2, 1], [2, 2], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3], [4, 4]],angle = 45,location = [3, 3]) == 6\n assert candidate(points = [[1, 2], [2, 1], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]],angle = 120,location = [1, 1]) == 10\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],angle = 90,location = [0, 0]) == 10\n assert candidate(points = [[100, 100], [100, 99], [99, 100], [99, 98], [101, 100], [100, 101]],angle = 10,location = [100, 100]) == 2\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],angle = 90,location = [1, 1]) == 15\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],angle = 45,location = [5, 5]) == 5\n assert candidate(points = [[10, 10], [20, 10], [15, 20], [10, 15], [15, 15]],angle = 30,location = [15, 15]) == 2\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],angle = 90,location = [5, 5]) == 6\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],angle = 360,location = [5, 5]) == 15\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],angle = 360,location = [3, 4]) == 11\n assert candidate(points = [[10, 10], [10, 11], [11, 10], [11, 11], [10, 9], [9, 10], [9, 9], [9, 11], [11, 9]],angle = 60,location = [10, 10]) == 3\n assert candidate(points = [[0, 1], [1, 0], [1, 2], [2, 1], [2, 3], [3, 2], [3, 4], [4, 3]],angle = 10,location = [2, 2]) == 1\n assert candidate(points = [[10, 0], [0, 10], [10, 10], [0, 0], [5, 5]],angle = 60,location = [5, 5]) == 2\n assert candidate(points = [[50, 50], [50, 40], [50, 60], [40, 50], [60, 50], [40, 40], [60, 60], [40, 60], [60, 40], [50, 30], [50, 70], [30, 50], [70, 50]],angle = 60,location = [50, 50]) == 4\n assert candidate(points = [[10, 10], [9, 10], [8, 10], [7, 10], [6, 10], [5, 10], [4, 10], [3, 10], [2, 10], [1, 10]],angle = 5,location = [5, 10]) == 6\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],angle = 20,location = [1, 5]) == 6\n assert candidate(points = [[90, 90], [91, 90], [90, 91], [91, 91], [100, 100]],angle = 10,location = [90, 90]) == 3\n assert candidate(points = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]],angle = 30,location = [5, 5]) == 4\n assert candidate(points = [[10, 1], [1, 10], [10, 9], [9, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8]],angle = 60,location = [5, 5]) == 5\n assert candidate(points = [[5, 0], [5, 10], [10, 5], [0, 5]],angle = 180,location = [5, 5]) == 3\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 2], [1, 2], [1, 2], [1, 3], [1, 3], [1, 3], [1, 4], [1, 4], [1, 4], [1, 5], [1, 5], [1, 5]],angle = 10,location = [1, 3]) == 9\n assert candidate(points = [[10, 10], [10, 20], [10, 30], [10, 40], [10, 50], [10, 60], [10, 70], [10, 80], [10, 90]],angle = 10,location = [10, 50]) == 5\n assert candidate(points = [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0]],angle = 10,location = [5, 0]) == 6\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]],angle = 180,location = [1, 1]) == 10\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]],angle = 5,location = [5, 1]) == 5\n assert candidate(points = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],angle = 30,location = [5, 50]) == 6\n assert candidate(points = [[5, 0], [0, 5], [5, 5], [0, 0], [2, 2], [3, 3], [1, 1], [4, 4]],angle = 90,location = [2, 2]) == 5\n assert candidate(points = [[1, 0], [2, 1], [3, 0], [4, 1], [5, 0], [6, 1], [7, 0], [8, 1], [9, 0], [10, 1]],angle = 15,location = [5, 0]) == 4\n assert candidate(points = [[5, 5], [5, 6], [6, 5], [6, 6], [7, 7]],angle = 45,location = [5, 5]) == 4\n assert candidate(points = [[10, 10], [10, 20], [10, 30], [20, 10], [20, 20], [20, 30], [30, 10], [30, 20], [30, 30]],angle = 30,location = [20, 20]) == 2\n assert candidate(points = [[1, 0], [2, 1], [1, 2], [0, 1], [0, 2], [1, 1], [2, 0], [2, 2], [0, 0]],angle = 45,location = [1, 1]) == 3\n assert candidate(points = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0]],angle = 90,location = [2, 0]) == 4\n assert candidate(points = [[50, 50], [51, 50], [52, 50], [53, 50], [54, 50], [55, 50]],angle = 5,location = [52, 50]) == 4\n assert candidate(points = [[10, 10], [20, 10], [10, 20], [20, 20], [10, 30], [20, 30], [10, 40], [20, 40]],angle = 180,location = [15, 15]) == 7\n assert candidate(points = [[100, 0], [0, 100], [50, 50], [25, 25], [75, 75]],angle = 45,location = [50, 50]) == 2\n assert candidate(points = [[1, 2], [2, 2], [4, 5], [5, 4], [3, 3], [2, 1]],angle = 45,location = [3, 3]) == 4\n assert candidate(points = [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0], [10, 0]],angle = 180,location = [5, 0]) == 10\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]],angle = 180,location = [5, 1]) == 9\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],angle = 90,location = [1, 5]) == 6\n assert candidate(points = [[0, 0], [1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0], [7, 0], [8, 0], [9, 0]],angle = 1,location = [5, 0]) == 6\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],angle = 40,location = [50, 50]) == 6\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],angle = 45,location = [1, 5]) == 6\n assert candidate(points = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40]],angle = 90,location = [20, 20]) == 5\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2]],angle = 90,location = [3, 1]) == 6\n assert candidate(points = [[5, 5], [5, 6], [6, 5], [6, 6], [7, 7], [8, 8], [9, 9]],angle = 60,location = [5, 5]) == 6\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90]],angle = 45,location = [50, 50]) == 5\n assert candidate(points = [[5, 5], [5, 6], [6, 5], [6, 6], [7, 7], [8, 8], [9, 9], [5, 4], [4, 5], [4, 4], [6, 4], [4, 6], [7, 6], [6, 7], [8, 6], [6, 8]],angle = 45,location = [5, 5]) == 8\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],angle = 30,location = [1, 1]) == 10\n assert candidate(points = [[5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]],angle = 10,location = [5, 5]) == 6\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [2, 1], [2, 1], [2, 1], [3, 1], [3, 1], [3, 1], [4, 1], [4, 1], [4, 1], [5, 1], [5, 1], [5, 1]],angle = 90,location = [3, 1]) == 9\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [10, 10], [10, 10]],angle = 45,location = [15, 15]) == 3\n assert candidate(points = [[2, 2], [3, 2], [4, 2], [2, 3], [3, 3], [4, 3], [2, 4], [3, 4], [4, 4]],angle = 45,location = [3, 3]) == 3\n"}, "metadata": {"canonical_parameter_names": ["points", "angle", "location"], "leetcode_dataset_entry_point": "Solution().visiblePoints", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int visiblePoints(vector>& points, int angle, vector& location) {", "container": "Solution", "callable": "visiblePoints", "parameters": [{"name": "points", "type": "vector>&"}, {"name": "angle", "type": "int"}, {"name": "location", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1611, "task_id": "minimum-one-bit-operations-to-make-integers-zero", "difficulty": "Hard", "problem_description": "Given an integer n, you must transform it into 0 using the following operations any number of times:\n\nChange the rightmost (0th) bit in the binary representation of n.\nChange the ith bit in the binary representation of n if the (i-1)th bit is set to 1 and the (i-2)th through 0th bits are set to 0.\n\nReturn the minimum number of operations to transform n into 0.\n \nExample 1:\n\nInput: n = 3\nOutput: 2\nExplanation: The binary representation of 3 is \"11\".\n\"11\" -> \"01\" with the 2nd operation since the 0th bit is 1.\n\"01\" -> \"00\" with the 1st operation.\n\nExample 2:\n\nInput: n = 6\nOutput: 4\nExplanation: The binary representation of 6 is \"110\".\n\"110\" -> \"010\" with the 2nd operation since the 1st bit is 1 and 0th through 0th bits are 0.\n\"010\" -> \"011\" with the 1st operation.\n\"011\" -> \"001\" with the 2nd operation since the 0th bit is 1.\n\"001\" -> \"000\" with the 1st operation.\n\n \nConstraints:\n\n0 <= n <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 0) == 0\n assert candidate(n = 8) == 15\n assert candidate(n = 3) == 2\n assert candidate(n = 100) == 71\n assert candidate(n = 15) == 10\n assert candidate(n = 16) == 31\n assert candidate(n = 31) == 21\n assert candidate(n = 1000000000) == 756249599\n assert candidate(n = 32) == 63\n assert candidate(n = 6) == 4\n assert candidate(n = 1023) == 682\n assert candidate(n = 1) == 1\n assert candidate(n = 500) == 344\n assert candidate(n = 7) == 5\n assert candidate(n = 10) == 12\n assert candidate(n = 1024) == 2047\n assert candidate(n = 2097152) == 4194303\n assert candidate(n = 63) == 42\n assert candidate(n = 896) == 767\n assert candidate(n = 131071) == 87381\n assert candidate(n = 67108864) == 134217727\n assert candidate(n = 4096) == 8191\n assert candidate(n = 67108863) == 44739242\n assert candidate(n = 2147483647) == 1431655765\n assert candidate(n = 32767) == 21845\n assert candidate(n = 511) == 341\n assert candidate(n = 262143) == 174762\n assert candidate(n = 2047) == 1365\n assert candidate(n = 268435456) == 536870911\n assert candidate(n = 16383) == 10922\n assert candidate(n = 16384) == 32767\n assert candidate(n = 524287) == 349525\n assert candidate(n = 987654) == 662532\n assert candidate(n = 268435455) == 178956970\n assert candidate(n = 16777216) == 33554431\n assert candidate(n = 4194303) == 2796202\n assert candidate(n = 134217727) == 89478485\n assert candidate(n = 64) == 127\n assert candidate(n = 8388607) == 5592405\n assert candidate(n = 2097151) == 1398101\n assert candidate(n = 4194304) == 8388607\n assert candidate(n = 192) == 128\n assert candidate(n = 134217728) == 268435455\n assert candidate(n = 1073741823) == 715827882\n assert candidate(n = 33554432) == 67108863\n assert candidate(n = 16777215) == 11184810\n assert candidate(n = 1073741824) == 2147483647\n assert candidate(n = 4095) == 2730\n assert candidate(n = 128) == 255\n assert candidate(n = 100000) == 66752\n assert candidate(n = 255) == 170\n assert candidate(n = 1048576) == 2097151\n assert candidate(n = 8192) == 16383\n assert candidate(n = 8191) == 5461\n assert candidate(n = 2048) == 4095\n assert candidate(n = 65536) == 131071\n assert candidate(n = 256) == 511\n assert candidate(n = 262144) == 524287\n assert candidate(n = 65535) == 43690\n assert candidate(n = 127) == 85\n assert candidate(n = 987654321) == 747917089\n assert candidate(n = 1048575) == 699050\n assert candidate(n = 500000000) == 378124799\n assert candidate(n = 536870911) == 357913941\n assert candidate(n = 1000000) == 687231\n assert candidate(n = 512) == 1023\n assert candidate(n = 123456789) == 93489638\n assert candidate(n = 1047552) == 698368\n assert candidate(n = 123456) == 82816\n assert candidate(n = 33554431) == 22369621\n assert candidate(n = 54321) == 38945\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().minimumOneBitOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumOneBitOperations(int n) {", "container": "Solution", "callable": "minimumOneBitOperations", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1614, "task_id": "maximum-nesting-depth-of-the-parentheses", "difficulty": "Easy", "problem_description": "Given a valid parentheses string s, return the nesting depth of s. The nesting depth is the maximum number of nested parentheses.\n \nExample 1:\n\nInput: s = \"(1+(2*3)+((8)/4))+1\"\nOutput: 3\nExplanation:\nDigit 8 is inside of 3 nested parentheses in the string.\n\nExample 2:\n\nInput: s = \"(1)+((2))+(((3)))\"\nOutput: 3\nExplanation:\nDigit 3 is inside of 3 nested parentheses in the string.\n\nExample 3:\n\nInput: s = \"()(())((()()))\"\nOutput: 3\n\n \nConstraints:\n\n1 <= s.length <= 100\ns consists of digits 0-9 and characters '+', '-', '*', '/', '(', and ')'.\nIt is guaranteed that parentheses expression s is a VPS.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"(1+(2*3)+((8)/4))+1\") == 3\n assert candidate(s = \"(a+(b*c)+((d/e)+f))\") == 3\n assert candidate(s = \"()()()\") == 1\n assert candidate(s = \"(a+b)+((c*d)+e)\") == 2\n assert candidate(s = \"(1+2)\") == 1\n assert candidate(s = \"1+(2*3)\") == 1\n assert candidate(s = \"\") == 0\n assert candidate(s = \"(())\") == 2\n assert candidate(s = \"((1+3)*(2-4))\") == 2\n assert candidate(s = \"(1)\") == 1\n assert candidate(s = \"((())()())\") == 3\n assert candidate(s = \"((1+2)*3/(4-5))\") == 2\n assert candidate(s = \"(1)+((2))+(((3)))\") == 3\n assert candidate(s = \"()(())((()()))\") == 3\n assert candidate(s = \"()\") == 1\n assert candidate(s = \"(a+b+c)*(d/e/f)+((g-(h*i))+j)\") == 3\n assert candidate(s = \"(a)\") == 1\n assert candidate(s = \"((()))\") == 3\n assert candidate(s = \"((a+b)*c)+(((d+e)*f)+g)\") == 3\n assert candidate(s = \"(1+(2*(((3+4)*5)+(6/(7*((8-9)+10))))))\") == 7\n assert candidate(s = \"(a+(b+(c+(d+(e+(f+(g+(h+(i+(j+(k+(l+(m+(n+(o+(p+(q+(r+(s+(t+(u+(v+(w+(x+(y+(z+(a+b))))))))))))))))))))))))))\") == 27\n assert candidate(s = \"(((((1+2)*(3+4))-((5+6)*(7+8)))+(((9+0)*(1+2))-((3+4)*(5+6))))\") == 5\n assert candidate(s = \"((a+(b*c))+((d+e)/(f-g)))+((h*(i-j)))\") == 3\n assert candidate(s = \"((a+b)+(((c+d)+((e+f)+((g+h)+((i+j)+((k+l)+((m+n)+((o+p)+((q+r)+((s+t)+u))))))))))\") == 12\n assert candidate(s = \"((x+y)+((z+w)*((a+b)*(c+d))))\") == 4\n assert candidate(s = \"(((a+b)+((c+d)*(e+f)))+((g-h)*((i+j)/(k-l))))\") == 4\n assert candidate(s = \"(1+(((2+((3+((4+((5+((6+((7+((8+((9+(10)))))))))))))))))))\") == 19\n assert candidate(s = \"(((a+b)+(c*d))+(((e-f)-(g*h)))+((i+j)*(k+l)))\") == 4\n assert candidate(s = \"(x+(y*(z+(w/(v+(u+((t)+s))))))\") == 8\n assert candidate(s = \"(((a+b)+c)+((d+e)+f))+(((g+h)+i)+(j+(k+l)))\") == 3\n assert candidate(s = \"(a+(b*(c+(d/(e+f)+g)+h)+i)\") == 5\n assert candidate(s = \"((a+b)+(c*(d+(e/(f+(g+(h+(i+(j))))))))\") == 9\n assert candidate(s = \"(1+(2*(3+(4*(5+(6+(7*(8+(9*(10)))))))))\") == 10\n assert candidate(s = \"(((((((a+b)*c)+d)+e)+f)+g)+h)\") == 7\n assert candidate(s = \"(1+(2*(3+(4*(5+(6+(7+(8+(9))))))))\") == 9\n assert candidate(s = \"(((a+(b*c))+((d+(e*f))+(g+(h*i))))+((j+(k*l))+((m+(n*o))+(p+(q+(r+(s+t))))))\") == 7\n assert candidate(s = \"(1+(2*((3+4)*(5+6)*((7+8)*(9+10))))+11)\") == 5\n assert candidate(s = \"((a+(b*(c+(d*(e+f)))))+(((g-h)+(i-j))*((k-l)+(m*n))))\") == 6\n assert candidate(s = \"((a+b)*((c-d)+e))+((f+(g/h))-((i*j)))\") == 3\n assert candidate(s = \"(1+((2+((3+((4+((5+6)+7))+8))+9))+10)+11\") == 9\n assert candidate(s = \"((a+b)+(((c+d)+((e+f)+((g+h)*(i+j))))*(k+l)))\") == 6\n assert candidate(s = \"((a+(b*c))+(d/((e+f)*(g-h))))\") == 4\n assert candidate(s = \"(((((x+(y*z))+(w*((a+b)*c)))+((d+e)+((f*g)+((h+i)+((j+k)*l)))))\") == 8\n assert candidate(s = \"((x+(y*z))+((u-(v*w))+(((p+q)*r)/s)))\") == 5\n assert candidate(s = \"(a+(b*(c+d)))+((e+f)*((g+h)*(i+j)))+(((k+l)*(m+n))+(o+(p*(q+r))))\") == 4\n assert candidate(s = \"(a+(b*(c+d)))+((e/f)-(g*h))\") == 3\n assert candidate(s = \"((1+(2*(3+(4*(5+(6*(7+(8*(9))))))))+10)\") == 10\n assert candidate(s = \"(a+(b*(c+d))+e+(f/(g-h)))\") == 3\n assert candidate(s = \"(((((1+2)*3)+4)*5)+((6+(7*(8+9)))/10))\") == 5\n assert candidate(s = \"(((((a+(b+(c+(d+(e+(f+(g+(h+(i+(j+(k+(l+(m+(n+(o+p))))))))))))+q)+r)+s)+t)+u)+v\") == 19\n assert candidate(s = \"((a+b)+((c+d)+((e+f)+((g+h)+((i+j)+((k+l)+((m+n)+((o+p)+((q+r)+((s+t)+((u+v)+((w+x)+((y+z))))))))))))\") == 14\n assert candidate(s = \"((((a+b)+((c+d)*(e+f)))+((g+h)+((i+j)*(k+l))))+(m+(n*(o+p))))\") == 5\n assert candidate(s = \"((((a+b)*c)+((d+e)*f))+(((g+h)*i)+((j+k)*l)))+((((m+n)*o)+((p+q)*r))+(((s+t)*u)+((v+w)*x))))\") == 4\n assert candidate(s = \"(1+(2+(3+(4+(5+(6+(7+(8+(9))))))))\") == 9\n assert candidate(s = \"(((1+2)*3)+((4+5)*(6/7)))+(((8+9)*((10-11)/12)))+13\") == 4\n assert candidate(s = \"((x+(y*((z+w)*v)))+(((u-t)-s)+(((r-q)+(p-o))*(n-m))))\") == 5\n assert candidate(s = \"(1+((2*((3+4)*(5-6)))/(7+(8*(9-10)))))\") == 5\n assert candidate(s = \"(a+(b*(c+d)))+((e+f)/(g-h))\") == 3\n assert candidate(s = \"(1+((2+3)*(4/5)))+((6-(7+8))*(((9/10)-11)+(12*13)))\") == 4\n assert candidate(s = \"((1)+((2)+(((3)+((4)+(5)))+(6))))\") == 6\n assert candidate(s = \"((1+2)*((3/4)-5)+((6*7)+8))\") == 3\n assert candidate(s = \"(a+(b+(c+(d+(e+(f+(g+(h+(i+(j+(k+(l+(m+(n+(o+p))))))))))))+q)+r)+s\") == 15\n assert candidate(s = \"((x+(y*z))+((u-(v*w))+(((p+q)*r)/s)))+((t+(u*v))+(((w+x)*y)/z))\") == 5\n assert candidate(s = \"((1+2)*((3+4)*((5+6)*((7+8)*((9+0))))))\") == 6\n assert candidate(s = \"(a+((b+((c+((d+e)*f))*g))*h))\") == 7\n assert candidate(s = \"(((((1+2)+3)+4)+5)+6)+7\") == 5\n assert candidate(s = \"((a+(b+(c+(d+(e+(f+(g+(h+(i+(j+(k+(l+(m+(n+(o+(p+(q+(r+(s+(t+(u+(v+(w+(x+(y+(z*1))))))))))))))))))))))))\") == 27\n assert candidate(s = \"(a+(b*(c+(d*(e+(f*(g+(h*(i+(j)))))))))+(k+(l*(m+(n*(o+(p*(q+(r*(s+(t))))))))))\") == 11\n assert candidate(s = \"(((((1+2)*3)+4)*5)+6)\") == 5\n assert candidate(s = \"(((a+b)+((c+d)*(e/f)))+(((g-h)+(i/j))*((k+l)*(m-n))))\") == 4\n assert candidate(s = \"((1+((2+3)*4))+(((5-6)+7)+((8+9)*10)))+(((11+(12*13))+14)+15)\") == 4\n assert candidate(s = \"(a+((b+c)*(d+((e+f)*(g+(h+i)))))+((j-k)*((l-m)+((n-o)*(p+((q-r)+s)))))\") == 7\n assert candidate(s = \"(1+(2*(3+(4*(5+(6+(7+(8+(9+0))))))))\") == 9\n assert candidate(s = \"((1+2)*((3+(4*(5+(6/7))))+((8-(9*10))+((11*12)+((13/14)+15))))\") == 6\n assert candidate(s = \"1+((2+(3*(4+5)))/6)+(((7-8)*9)/10)\") == 4\n assert candidate(s = \"((1+(2+(3+(4+(5+(6+(7+(8+(9+(10+(11+(12+(13+(14+(15+(16+(17+(18+(19+(20+(21+(22+(23+(24+(25+(26+(27+(28+(29+(30)))))))))))))))))))))))))+31)+32)+33\") == 31\n assert candidate(s = \"(a+(b+(c+(d+(e+(f+(g+(h+(i+(j)))))))))\") == 10\n assert candidate(s = \"(((((a+b)+(c*d))-(e/f))*g)+(h-(i+j)))\") == 5\n assert candidate(s = \"(((a+(b*c))+((d+(e*f))+((g+(h*i))+((j+(k*l))+((m+(n*o))+((p+(q*r))+((s+(t*u))+((v+(w*x))+((y+(z*1))+2))))))))\") == 12\n assert candidate(s = \"(a+(b+(c+(d+(e+(f+(g+(h+(i+(j+(k+(l+(m+(n+(o+(p+(q+(r+(s+(t+(u+(v+(w+(x+(y+(z+(a+(b+(c+(d+(e+(f+(g+(h+(i+(j+(k+(l+(m+(n+(o+p))))))))))))))))))))))))))))))))+a)+b)+c)+d)+e)+f)+g)+h)+i)+j)+k)+l)+m)+n)+o)+p)+q)+r)+s)+t)+u)+v)+w)+x)+y)+z\") == 41\n assert candidate(s = \"(1+((2+(3*(4/5)))+((6-(7*8))))\") == 5\n assert candidate(s = \"(1+(2*((3+4)*(5+(6*(7+(8+9))))))+(10*((11-12)+(13*((14-15)+(16*(17+18))))))\") == 7\n assert candidate(s = \"((x+(y*z))+(u/(v-((w+x)*(y-z)))))+(a+b)-(c*d)\") == 5\n assert candidate(s = \"(((a+b)*(c-d))+(((e+f)*(g-h))+(((i+j)*(k-l))+(((m+n)*(o-p))+((q+r)*(s-t)))))\") == 6\n assert candidate(s = \"(((a+b)*((c-d)+e))-(((f+g)*h)-(i/j)))\") == 4\n assert candidate(s = \"(((((1+2)*3)+((4-5)*6))+(((7/8)+9)*10)))\") == 5\n assert candidate(s = \"(((((1)+2)*3)+(((((4)+5)*6)+((7)+8))))\") == 7\n assert candidate(s = \"(a+(b+(c+(d+(e+(f+(g+(h+(i+(j+(k+(l+(m+(n+(o+(p+(q+(r+(s+(t+(u+(v+(w+(x+(y+z))))))))))))))))))))))\") == 25\n assert candidate(s = \"(((1+2)*((3-4)+(5/6)))+(((7*8)-9)+((10+11)*12)))\") == 4\n assert candidate(s = \"(a+(b+(c+(d+(e+(f+(g+(h+(i+(j+(k+(l+(m+(n+(o+(p+(q+(r+(s+(t+(u+(v+(w+(x+(y+(z+(a+b)))))))))))))))))))))))))\") == 27\n assert candidate(s = \"((a+(b*c)+(d/e))-(((f+g)*(h-i))+((j/k)+(l*m))))\") == 4\n assert candidate(s = \"(a+(b*(c/(d-e))))+(((f+g)*((h-i)+j))+((k-l)/(m*(n-o))))\") == 4\n assert candidate(s = \"((a+(b+(c+(d+(e+(f+(g+(h+(i+(j+(k+(l+(m+(n+(o+(p+(q+(r+(s+(t+(u+(v+(w+(x+(y+z))))))))))))))))))))))))\") == 26\n assert candidate(s = \"(a+(b*(c+d)))+((e+f)/(g-(h*i)))\") == 3\n assert candidate(s = \"(a+(b*(c+d)))+(((e+f)*(g-h)))+1\") == 3\n assert candidate(s = \"(a+(b*(c+(d/(e+(f*(g+(h/(i+j))))))))\") == 9\n assert candidate(s = \"(1+(2*(3+4)/(5-6))+((7+8)*9))\") == 3\n assert candidate(s = \"((((((((((1+2)+3)+4)+5)+6)+7)+8)+9)+10)\") == 10\n assert candidate(s = \"(((((x*y)+z)+((a*b)+c))+(((d*e)+f)+((g*h)+i))))\") == 5\n assert candidate(s = \"(a+(b+(c+(d+(e+(f+(g+(h+(i+(j+(k+(l+(m+(n+(o+(p+(q+(r+(s+(t+(u+(v+(w+(x+(y+z)))))))))))))))))))))+a)+b)+c\") == 25\n assert candidate(s = \"((((1+(2+(3+(4+(5+(6+(7+(8+(9+(10+(11+(12+(13+(14+(15+(16+(17+(18+(19+(20))))))))))))))))+21)+22)+23)+24)+25)+26\") == 23\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxDepth", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxDepth(string s) {", "container": "Solution", "callable": "maxDepth", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1615, "task_id": "maximal-network-rank", "difficulty": "Medium", "problem_description": "There is an infrastructure of n cities with some number of roads connecting these cities. Each roads[i] = [ai, bi] indicates that there is a bidirectional road between cities ai and bi.\nThe network rank of two different cities is defined as the total number of directly connected roads to either city. If a road is directly connected to both cities, it is only counted once.\nThe maximal network rank of the infrastructure is the maximum network rank of all pairs of different cities.\nGiven the integer n and the array roads, return the maximal network rank of the entire infrastructure.\n \nExample 1:\n\n\nInput: n = 4, roads = [[0,1],[0,3],[1,2],[1,3]]\nOutput: 4\nExplanation: The network rank of cities 0 and 1 is 4 as there are 4 roads that are connected to either 0 or 1. The road between 0 and 1 is only counted once.\n\nExample 2:\n\n\nInput: n = 5, roads = [[0,1],[0,3],[1,2],[1,3],[2,3],[2,4]]\nOutput: 5\nExplanation: There are 5 roads that are connected to cities 1 or 2.\n\nExample 3:\n\nInput: n = 8, roads = [[0,1],[1,2],[2,3],[2,4],[5,6],[5,7]]\nOutput: 5\nExplanation: The network rank of 2 and 5 is 5. Notice that all the cities do not have to be connected.\n\n \nConstraints:\n\n2 <= n <= 100\n0 <= roads.length <= n * (n - 1) / 2\nroads[i].length == 2\n0 <= ai, bi <= n-1\nai != bi\nEach pair of cities has at most one road connecting them.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,roads = [[0, 1], [0, 3], [1, 2], [1, 3]]) == 4\n assert candidate(n = 100,roads = []) == 0\n assert candidate(n = 6,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5]]) == 5\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]) == 9\n assert candidate(n = 5,roads = [[0, 1], [0, 3], [1, 2], [1, 3], [2, 3], [2, 4]]) == 5\n assert candidate(n = 3,roads = [[0, 1], [1, 2]]) == 2\n assert candidate(n = 6,roads = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3]]) == 5\n assert candidate(n = 10,roads = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 2\n assert candidate(n = 10,roads = []) == 0\n assert candidate(n = 8,roads = [[0, 1], [1, 2], [2, 3], [2, 4], [5, 6], [5, 7]]) == 5\n assert candidate(n = 10,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 4\n assert candidate(n = 7,roads = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6]]) == 4\n assert candidate(n = 15,roads = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14]]) == 4\n assert candidate(n = 15,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14]]) == 5\n assert candidate(n = 15,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 12], [12, 13], [13, 14]]) == 6\n assert candidate(n = 15,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14]]) == 14\n assert candidate(n = 40,roads = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15]]) == 6\n assert candidate(n = 7,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 3], [2, 4], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [5, 6]]) == 11\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 6], [7, 8], [8, 9]]) == 7\n assert candidate(n = 60,roads = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [20, 21], [22, 23], [24, 25], [26, 27], [28, 29], [30, 31], [32, 33], [34, 35], [36, 37], [38, 39], [40, 41], [42, 43], [44, 45], [46, 47], [48, 49], [50, 51], [52, 53], [54, 55], [56, 57], [58, 59]]) == 2\n assert candidate(n = 20,roads = [[0, 1], [0, 2], [1, 2], [3, 4], [3, 5], [4, 5], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [10, 11], [12, 13], [12, 14], [13, 14], [15, 16], [15, 17], [16, 17], [18, 19]]) == 4\n assert candidate(n = 20,roads = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 7\n assert candidate(n = 25,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 9], [9, 5], [10, 11], [11, 12], [12, 13], [13, 14], [14, 10], [15, 16], [16, 17], [17, 18], [18, 19], [19, 15], [20, 21], [21, 22], [22, 23], [23, 24], [24, 20], [0, 15], [5, 10], [10, 15], [20, 25]]) == 7\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]) == 7\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 7\n assert candidate(n = 70,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 7], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17], [12, 18], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 13]]) == 10\n assert candidate(n = 15,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [5, 9], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9]]) == 8\n assert candidate(n = 20,roads = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]]) == 6\n assert candidate(n = 20,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [0, 19]]) == 4\n assert candidate(n = 15,roads = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [7, 8], [7, 9], [8, 9], [10, 11], [10, 12], [11, 12], [13, 14]]) == 5\n assert candidate(n = 20,roads = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 4\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [7, 8], [7, 9], [8, 9]]) == 5\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 6\n assert candidate(n = 20,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [5, 9], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [10, 11], [10, 12], [10, 13], [10, 14], [11, 12], [11, 13], [11, 14], [12, 13], [12, 14], [13, 14]]) == 8\n assert candidate(n = 30,roads = [[0, 1], [0, 2], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29]]) == 5\n assert candidate(n = 25,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 6], [1, 7], [1, 8], [1, 9], [2, 10], [2, 11], [2, 12], [3, 13], [3, 14], [4, 15], [4, 16], [5, 17], [5, 18], [6, 19], [6, 20], [7, 21], [7, 22], [8, 23], [8, 24], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24]]) == 9\n assert candidate(n = 10,roads = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == 5\n assert candidate(n = 15,roads = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12], [13, 14]]) == 7\n assert candidate(n = 20,roads = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [5, 9], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [10, 11], [10, 12], [10, 13], [10, 14], [11, 12], [11, 13], [11, 14], [12, 13], [12, 14], [13, 14], [15, 16], [15, 17], [15, 18], [15, 19], [16, 17], [16, 18], [16, 19], [17, 18], [17, 19], [18, 19]]) == 8\n assert candidate(n = 60,roads = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15]]) == 6\n"}, "metadata": {"canonical_parameter_names": ["n", "roads"], "leetcode_dataset_entry_point": "Solution().maximalNetworkRank", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximalNetworkRank(int n, vector>& roads) {", "container": "Solution", "callable": "maximalNetworkRank", "parameters": [{"name": "n", "type": "int"}, {"name": "roads", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1616, "task_id": "split-two-strings-to-make-palindrome", "difficulty": "Medium", "problem_description": "You are given two strings a and b of the same length. Choose an index and split both strings at the same index, splitting a into two strings: aprefix and asuffix where a = aprefix + asuffix, and splitting b into two strings: bprefix and bsuffix where b = bprefix + bsuffix. Check if aprefix + bsuffix or bprefix + asuffix forms a palindrome.\nWhen you split a string s into sprefix and ssuffix, either ssuffix or sprefix is allowed to be empty. For example, if s = \"abc\", then \"\" + \"abc\", \"a\" + \"bc\", \"ab\" + \"c\" , and \"abc\" + \"\" are valid splits.\nReturn true if it is possible to form a palindrome string, otherwise return false.\nNotice that x + y denotes the concatenation of strings x and y.\n \nExample 1:\n\nInput: a = \"x\", b = \"y\"\nOutput: true\nExplaination: If either a or b are palindromes the answer is true since you can split in the following way:\naprefix = \"\", asuffix = \"x\"\nbprefix = \"\", bsuffix = \"y\"\nThen, aprefix + bsuffix = \"\" + \"y\" = \"y\", which is a palindrome.\n\nExample 2:\n\nInput: a = \"xbdef\", b = \"xecab\"\nOutput: false\n\nExample 3:\n\nInput: a = \"ulacfd\", b = \"jizalu\"\nOutput: true\nExplaination: Split them at index 3:\naprefix = \"ula\", asuffix = \"cfd\"\nbprefix = \"jiz\", bsuffix = \"alu\"\nThen, aprefix + bsuffix = \"ula\" + \"alu\" = \"ulaalu\", which is a palindrome.\n\n \nConstraints:\n\n1 <= a.length, b.length <= 105\na.length == b.length\na and b consist of lowercase English letters\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(a = \"abcdefg\",b = \"gfedcba\") == True\n assert candidate(a = \"abcxxcba\",b = \"abcdcba\") == True\n assert candidate(a = \"aabbcc\",b = \"ccbbdd\") == True\n assert candidate(a = \"ulacfd\",b = \"jizalu\") == True\n assert candidate(a = \"aabbaa\",b = \"aabbaa\") == True\n assert candidate(a = \"abba\",b = \"abba\") == True\n assert candidate(a = \"abcba\",b = \"abcba\") == True\n assert candidate(a = \"x\",b = \"y\") == True\n assert candidate(a = \"xbdef\",b = \"xecab\") == False\n assert candidate(a = \"abccba\",b = \"abccba\") == True\n assert candidate(a = \"noon\",b = \"noon\") == True\n assert candidate(a = \"race\",b = \"ecar\") == True\n assert candidate(a = \"abcd\",b = \"dcba\") == True\n assert candidate(a = \"aabbcc\",b = \"ccbbaa\") == True\n assert candidate(a = \"abc\",b = \"def\") == False\n assert candidate(a = \"abcde\",b = \"edcba\") == True\n assert candidate(a = \"abacaba\",b = \"bacabab\") == True\n assert candidate(a = \"rotor\",b = \"rotor\") == True\n assert candidate(a = \"noonappapoon\",b = \"poongggnop\") == False\n assert candidate(a = \"abacax\",b = \"xananaba\") == False\n assert candidate(a = \"abcdedcba\",b = \"afghihgfa\") == True\n assert candidate(a = \"abcdefghijk\",b = \"kjihgfedcba\") == True\n assert candidate(a = \"xyzzzzzxy\",b = \"yxzzzzzxy\") == True\n assert candidate(a = \"abcdabcdabcd\",b = \"dcbaedcbadcb\") == False\n assert candidate(a = \"aaaaabaaaa\",b = \"bbbbabbbbb\") == False\n assert candidate(a = \"abcdeedcba\",b = \"fghijijihgf\") == True\n assert candidate(a = \"rotorabc\",b = \"abcrotor\") == True\n assert candidate(a = \"abcdeffedcba\",b = \"mnopqrstsrqponm\") == True\n assert candidate(a = \"abac\",b = \"cab\") == True\n assert candidate(a = \"abcdexyzabc\",b = \"cbazyxcdeba\") == True\n assert candidate(a = \"abcdefgxyz\",b = \"zyxgfedcba\") == True\n assert candidate(a = \"abcdef\",b = \"fedcba\") == True\n assert candidate(a = \"aabbccddeeffgghhiijj\",b = \"jjiihhggfeeddccbaa\") == True\n assert candidate(a = \"abcdefgh\",b = \"hgfedcba\") == True\n assert candidate(a = \"xyzzxy\",b = \"yxzzyx\") == True\n assert candidate(a = \"mnopqr\",b = \"rqponm\") == True\n assert candidate(a = \"abcdefghij\",b = \"utvwxzyabc\") == False\n assert candidate(a = \"levelupx\",b = \"xyzlevol\") == False\n assert candidate(a = \"abcdefghijkjihgfedcba\",b = \"nopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(a = \"abcdefggfedcba\",b = \"xyzzyxzyxzyx\") == True\n assert candidate(a = \"aabbccddeeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",b = \"zzyyxxwwvvuuttssrrqqponnmmllkkjjiihhggffeeddccbaabb\") == False\n assert candidate(a = \"abcdxyzabc\",b = \"cbazyxdcba\") == True\n assert candidate(a = \"abcxxy\",b = \"yxxcba\") == True\n assert candidate(a = \"abcdeedcba\",b = \"zzzzzzzzzz\") == True\n assert candidate(a = \"xyzzzzyx\",b = \"abcdef\") == True\n assert candidate(a = \"abcdefghijabc\",b = \"cbazyxwvut\") == False\n assert candidate(a = \"abcdedcba\",b = \"xyzdedcba\") == True\n assert candidate(a = \"abcdefg\",b = \"hgfedcb\") == False\n assert candidate(a = \"aabbccddeeefffggg\",b = \"gggfffeeeddccbbaa\") == True\n assert candidate(a = \"abcdefghij\",b = \"jihgfedcba\") == True\n assert candidate(a = \"abcdabcdeedcba\",b = \"zzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(a = \"abcdeffedcba\",b = \"xyzzyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(a = \"racecarx\",b = \"xmadam\") == True\n assert candidate(a = \"xyzzzzzyx\",b = \"abcdcba\") == True\n assert candidate(a = \"redivider\",b = \"repaidred\") == True\n assert candidate(a = \"aabbccddeeaabbccddee\",b = \"eeddccbbaaeeddccbbaa\") == True\n assert candidate(a = \"noon\",b = \"moon\") == True\n assert candidate(a = \"abababab\",b = \"babababa\") == True\n assert candidate(a = \"abacabadabacaba\",b = \"fedcbadcba\") == True\n assert candidate(a = \"zxcvbnm\",b = \"mlkjihg\") == False\n assert candidate(a = \"abcdefggfedcba\",b = \"abcdggfedcba\") == True\n assert candidate(a = \"qwertyuiop\",b = \"poiuytrewq\") == True\n assert candidate(a = \"zzzzzzzzzzz\",b = \"aaaaaaaaaaa\") == True\n assert candidate(a = \"aabbccddeeffgghhiijjkk\",b = \"kkjjiihhggfeeddccbaa\") == True\n assert candidate(a = \"noon\",b = \"racecar\") == True\n assert candidate(a = \"abcdex\",b = \"xcdeba\") == False\n assert candidate(a = \"zyxwvutsrqponmlkjihgfedcba\",b = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(a = \"abccba\",b = \"abcdef\") == True\n assert candidate(a = \"abccba\",b = \"xyzzyx\") == True\n assert candidate(a = \"aabbccdd\",b = \"aabbccdd\") == False\n assert candidate(a = \"abcdabc\",b = \"cbadacb\") == True\n assert candidate(a = \"xyxzyxzyx\",b = \"yzxzyxzyz\") == False\n assert candidate(a = \"abcdexyz\",b = \"zyxcdeba\") == False\n assert candidate(a = \"abacaxbacad\",b = \"dadcabaxbacba\") == False\n assert candidate(a = \"abacaba\",b = \"zzzazzz\") == True\n assert candidate(a = \"aabbccdd\",b = \"ddeebbaa\") == True\n assert candidate(a = \"racecar\",b = \"level\") == True\n assert candidate(a = \"abcdefghij\",b = \"abcdefghij\") == False\n assert candidate(a = \"aaaa\",b = \"bbbb\") == True\n assert candidate(a = \"level\",b = \"deified\") == True\n assert candidate(a = \"abacdfgdcaba\",b = \"abacdgfdcaba\") == True\n assert candidate(a = \"abcdeabcde\",b = \"edcbaedcba\") == True\n assert candidate(a = \"abcdexyzzyxcdeba\",b = \"mnopqrstuutsrqpomn\") == False\n assert candidate(a = \"abxyzyxcba\",b = \"cdyxzyxdc\") == False\n assert candidate(a = \"madam\",b = \"refer\") == True\n assert candidate(a = \"aabbcc\",b = \"ccbaab\") == True\n assert candidate(a = \"abcddcba\",b = \"xyzzyx\") == True\n assert candidate(a = \"abracadabra\",b = \"arbadacarba\") == True\n assert candidate(a = \"abcddcba\",b = \"efghihgf\") == True\n assert candidate(a = \"abcdefxyzzyxcba\",b = \"pqrstuvwzyxwvutsrqp\") == False\n assert candidate(a = \"aaaabaaa\",b = \"bbbbbabb\") == False\n assert candidate(a = \"abacdfgdcaba\",b = \"abaffghffaba\") == False\n assert candidate(a = \"abacabad\",b = \"daadacab\") == False\n assert candidate(a = \"abcdexyz\",b = \"zyxeabcd\") == True\n assert candidate(a = \"abcdef\",b = \"xyzzzzyx\") == True\n assert candidate(a = \"abacdfgdcaba\",b = \"abcdcba\") == True\n assert candidate(a = \"abccba\",b = \"defedf\") == True\n assert candidate(a = \"xyzyx\",b = \"xzyzx\") == True\n assert candidate(a = \"palindrome\",b = \"emordnilap\") == True\n assert candidate(a = \"zzzzzzzzzzzzzzzzzz\",b = \"aaaaaaaaaaaaaaaa\") == True\n assert candidate(a = \"abccba\",b = \"defed\") == True\n assert candidate(a = \"abccba\",b = \"fghihgf\") == True\n assert candidate(a = \"tacocat\",b = \"racecar\") == True\n assert candidate(a = \"abcdef\",b = \"ghijkl\") == False\n assert candidate(a = \"aaaabbbb\",b = \"bbbbaaaa\") == True\n assert candidate(a = \"abcdefghihgfedcba\",b = \"abcdefghihgfedcba\") == True\n assert candidate(a = \"aabbccddeeff\",b = \"ffeeddccbbaa\") == True\n assert candidate(a = \"abcdexyzabcd\",b = \"dcbaxyzedcba\") == False\n assert candidate(a = \"abacabadabacaba\",b = \"abacabadabacaba\") == True\n assert candidate(a = \"abcxyzz\",b = \"zzzyxcba\") == True\n assert candidate(a = \"abacabadabacaba\",b = \"zzzzzzzzzzzzzzzzz\") == True\n assert candidate(a = \"abcabcabcabc\",b = \"cbacbacbacba\") == True\n assert candidate(a = \"abcxxa\",b = \"bxxcba\") == True\n assert candidate(a = \"racecar\",b = \"madam\") == True\n assert candidate(a = \"aaaaaaabbbbb\",b = \"bbbbbaaaaaaa\") == True\n assert candidate(a = \"abcdabcdabcd\",b = \"dcbaabcdabcd\") == False\n assert candidate(a = \"deifiedxx\",b = \"yytefified\") == True\n assert candidate(a = \"aaaaaaa\",b = \"bbbbbbb\") == True\n assert candidate(a = \"abab\",b = \"baba\") == True\n assert candidate(a = \"abcdeffedcba\",b = \"xyzzyxwxyzzyx\") == True\n assert candidate(a = \"abcdabcd\",b = \"dcbaabcd\") == True\n assert candidate(a = \"abcdeffedcba\",b = \"xyzzyxwvut\") == True\n assert candidate(a = \"abcdedcba\",b = \"mnopqrstuv\") == True\n assert candidate(a = \"abcdefghihgfedcba\",b = \"ijklmnopponmlkjihgf\") == True\n assert candidate(a = \"aabbcc\",b = \"zzxxzz\") == True\n assert candidate(a = \"abcdexyz\",b = \"zyxwvuts\") == False\n"}, "metadata": {"canonical_parameter_names": ["a", "b"], "leetcode_dataset_entry_point": "Solution().checkPalindromeFormation", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool checkPalindromeFormation(string a, string b) {", "container": "Solution", "callable": "checkPalindromeFormation", "parameters": [{"name": "a", "type": "string"}, {"name": "b", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1617, "task_id": "count-subtrees-with-max-distance-between-cities", "difficulty": "Hard", "problem_description": "There are n cities numbered from 1 to n. You are given an array edges of size n-1, where edges[i] = [ui, vi] represents a bidirectional edge between cities ui and vi. There exists a unique path between each pair of cities. In other words, the cities form a tree.\\r\n\\r\nA subtree is a subset of cities where every city is reachable from every other city in the subset, where the path between each pair passes through only the cities from the subset. Two subtrees are different if there is a city in one subtree that is not present in the other.\\r\n\\r\nFor each d from 1 to n-1, find the number of subtrees in which the maximum distance between any two cities in the subtree is equal to d.\\r\n\\r\nReturn an array of size n-1 where the dth element (1-indexed) is the number of subtrees in which the maximum distance between any two cities is equal to d.\\r\n\\r\nNotice that the distance between the two cities is the number of edges in the path between them.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\n\\r\n\\r\nInput: n = 4, edges = [[1,2],[2,3],[2,4]]\\r\nOutput: [3,4,0]\\r\nExplanation:\\r\nThe subtrees with subsets {1,2}, {2,3} and {2,4} have a max distance of 1.\\r\nThe subtrees with subsets {1,2,3}, {1,2,4}, {2,3,4} and {1,2,3,4} have a max distance of 2.\\r\nNo subtree has two nodes where the max distance between them is 3.\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: n = 2, edges = [[1,2]]\\r\nOutput: [1]\\r\n\\r\n\\r\nExample 3:\\r\n\\r\n\\r\nInput: n = 3, edges = [[1,2],[2,3]]\\r\nOutput: [2,1]\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t2 <= n <= 15\\r\n\tedges.length == n-1\\r\n\tedges[i].length == 2\\r\n\t1 <= ui, vi <= n\\r\n\tAll pairs (ui, vi) are distinct.\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == [5, 8, 9, 0, 0]\n assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 4], [4, 5]]) == [4, 3, 2, 1]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10]]) == [9, 14, 18, 26, 33, 0, 0, 0, 0]\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [3, 6], [4, 7]]) == [6, 7, 9, 7, 0, 0]\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6]]) == [5, 6, 4, 3, 0]\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [1, 4], [1, 5]]) == [4, 11, 0, 0]\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [2, 4], [2, 5]]) == [4, 5, 3, 0]\n assert candidate(n = 4,edges = [[1, 2], [2, 3], [2, 4]]) == [3, 4, 0]\n assert candidate(n = 3,edges = [[1, 2], [2, 3]]) == [2, 1]\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [5, 6]]) == [5, 4, 3, 2, 1]\n assert candidate(n = 2,edges = [[1, 2]]) == [1]\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [7, 12]]) == [11, 16, 24, 33, 48, 55, 0, 0, 0, 0, 0]\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]]) == [8, 9, 9, 9, 7, 4, 2, 0]\n assert candidate(n = 11,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11]]) == [10, 17, 24, 48, 63, 0, 0, 0, 0, 0]\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9]]) == [8, 13, 15, 15, 18, 0, 0, 0]\n assert candidate(n = 13,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [7, 12], [7, 13]]) == [12, 19, 30, 43, 66, 121, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 11,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 14,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14]]) == [13, 38, 70, 649, 308, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 11,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11]]) == [10, 13, 18, 23, 30, 25, 0, 0, 0, 0]\n assert candidate(n = 13,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12], [6, 13]]) == [12, 29, 49, 120, 259, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == [7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 14,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14]]) == [13, 22, 36, 65, 96, 231, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [6, 8]]) == [7, 10, 9, 11, 6, 0, 0]\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]]) == [6, 9, 6, 9, 0, 0]\n assert candidate(n = 11,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11]]) == [10, 15, 21, 28, 39, 22, 0, 0, 0, 0]\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12]]) == [11, 20, 36, 99, 126, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == [8, 13, 21, 39, 0, 0, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15]]) == [14, 25, 48, 168, 483, 210, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15]]) == [14, 25, 42, 87, 126, 441, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8]]) == [7, 10, 9, 11, 6, 0, 0]\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12]]) == [11, 18, 27, 50, 69, 42, 0, 0, 0, 0, 0]\n assert candidate(n = 6,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == [5, 4, 3, 2, 1]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == [9, 16, 27, 81, 0, 0, 0, 0, 0]\n assert candidate(n = 13,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13]]) == [12, 21, 33, 54, 81, 126, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12]]) == [11, 14, 19, 26, 35, 34, 15, 0, 0, 0, 0]\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [4, 7], [5, 8]]) == [7, 8, 10, 10, 5, 0, 0]\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [3, 8], [4, 9]]) == [8, 17, 13, 23, 14, 0, 0, 0]\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9]]) == [8, 11, 12, 16, 15, 0, 0, 0]\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 11], [6, 12]]) == [11, 20, 36, 99, 126, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 13,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]]) == [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9]]) == [8, 13, 21, 24, 12, 0, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [3, 11], [4, 12], [4, 13], [4, 14], [5, 15]]) == [14, 45, 154, 1995, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n"}, "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().countSubgraphsForEachDiameter", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector countSubgraphsForEachDiameter(int n, vector>& edges) {", "container": "Solution", "callable": "countSubgraphsForEachDiameter", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1619, "task_id": "mean-of-array-after-removing-some-elements", "difficulty": "Easy", "problem_description": "Given an integer array arr, return the mean of the remaining integers after removing the smallest 5% and the largest 5% of the elements.\nAnswers within 10-5 of the actual answer will be considered accepted.\n \nExample 1:\n\nInput: arr = [1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3]\nOutput: 2.00000\nExplanation: After erasing the minimum and the maximum values of this array, all elements are equal to 2, so the mean is 2.\n\nExample 2:\n\nInput: arr = [6,2,7,5,1,2,0,3,10,2,5,0,5,5,0,8,7,6,8,0]\nOutput: 4.00000\n\nExample 3:\n\nInput: arr = [6,0,7,0,7,5,7,8,3,4,0,7,8,1,6,8,1,1,2,4,8,1,9,5,4,3,8,5,10,8,6,6,1,0,6,10,8,2,3,4]\nOutput: 4.77778\n\n \nConstraints:\n\n20 <= arr.length <= 1000\narr.length is a multiple of 20.\n0 <= arr[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [6, 0, 7, 0, 7, 5, 7, 8, 3, 4, 0, 7, 8, 1, 6, 8, 1, 1, 2, 4, 8, 1, 9, 5, 4, 3, 8, 5, 10, 8, 6, 6, 1, 0, 6, 10, 8, 2, 3, 4]) == 4.77778\n assert candidate(arr = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]) == 2.0\n assert candidate(arr = [6, 2, 7, 5, 1, 2, 0, 3, 10, 2, 5, 0, 5, 5, 0, 8, 7, 6, 8, 0]) == 4.0\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 105.0\n assert candidate(arr = [42, 85, 94, 12, 85, 74, 15, 7, 83, 52, 53, 87, 27, 30, 67, 94, 84, 90, 72, 18, 62, 85, 81, 69, 82, 69, 39, 72, 25, 90, 45, 88, 61, 53, 74, 69, 46, 12, 43, 96, 89, 90, 25, 46, 23, 88, 97, 30, 69, 58, 76, 67, 50, 87, 94, 82, 63, 30, 93, 50, 33, 98, 60, 69, 88, 75, 29, 11, 94, 47, 87, 93, 34, 97, 32, 96, 79, 97, 78, 77, 45, 35, 94, 66, 62, 58, 42, 23, 83, 82, 72, 58, 75, 86, 80, 94, 28, 44, 62, 40, 96, 97, 46, 28, 96, 37, 82, 96, 62, 98, 28, 37, 81, 74, 90, 98, 73, 72, 99, 40, 54, 34, 55, 65, 70, 71, 80, 92, 93]) == 65.75\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500]) == 250.0\n assert candidate(arr = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994, 8, 99993, 9, 99992, 10, 99991, 11, 99990, 12, 99989, 13, 99988, 14, 99987, 15, 99986, 16, 99985, 17, 99984, 18, 99983, 19, 99982, 20, 99981]) == 50000.5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 25.0\n assert candidate(arr = [3, 1, 2, 4, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]) == 29.5\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400]) == 205.0\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0.76056\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5.0\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 475.0\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600, 610, 620, 630, 640, 650, 660, 670, 680, 690, 700, 710, 720, 730, 740, 750, 760, 770, 780, 790, 800, 810, 820, 830, 840, 850, 860, 870, 880, 890, 900, 910, 920, 930, 940, 950, 960, 970, 980, 990, 1000]) == 505.0\n assert candidate(arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7, 5, 1, 0, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 4, 9, 0, 3, 0, 1, 4, 1, 5]) == 4.44156\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109]) == 54.0\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 8.98182\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000, 3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900, 4000, 4100, 4200, 4300, 4400, 4500, 4600, 4700, 4800, 4900, 5000]) == 2500.0\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40]) == 69.5\n assert candidate(arr = [100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0]) == 49122.80702\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10.5\n assert candidate(arr = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 500.0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 25.0\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5.0\n assert candidate(arr = [100000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100000]) == 5555.55556\n assert candidate(arr = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 50000.0\n assert candidate(arr = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 42.0\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 13.01852\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 20.5\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1.78082\n assert candidate(arr = [100000, 0, 50000, 25000, 75000, 30000, 80000, 10000, 90000, 40000, 60000, 20000, 95000, 55000, 85000, 15000, 99000, 65000, 70000, 35000, 100000, 0, 50000, 25000, 75000, 30000, 80000, 10000, 90000, 40000, 60000, 20000, 95000, 55000, 85000, 15000, 99000, 65000, 70000, 35000]) == 55500.0\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 8.23529\n assert candidate(arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195]) == 100.0\n assert candidate(arr = [100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0]) == 48780.4878\n assert candidate(arr = [99999, 1, 99998, 2, 99997, 3, 99996, 4, 99995, 5, 99994, 6, 99993, 7, 99992, 8, 99991, 9, 99990, 10, 99989, 11, 99988, 12, 99987, 13, 99986, 14, 99985, 15, 99984, 16, 99983, 17, 99982, 18, 99981, 19, 99980, 20, 99979, 21, 99978, 22, 99977, 23, 99976, 24, 99975, 25]) == 48888.95556\n assert candidate(arr = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 50.0\n assert candidate(arr = [50000, 1, 20000, 2, 30000, 3, 40000, 4, 50000, 5, 60000, 6, 70000, 7, 80000, 8, 90000, 9, 100000, 10, 110000, 11, 120000, 12, 130000, 13, 140000, 14, 150000, 15, 160000, 16, 170000, 17, 180000, 18, 190000, 19, 200000, 20, 210000, 21, 220000, 22, 230000, 23, 240000, 24, 250000, 25, 260000, 26, 270000, 27, 280000, 28, 290000, 29, 300000]) == 70748.74074\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5.0\n assert candidate(arr = [15, 22, 10, 27, 18, 35, 40, 50, 60, 5, 90, 80, 75, 45, 30, 25, 65, 70, 100, 55]) == 45.11111\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10.0\n assert candidate(arr = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 42.0\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2.0\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 50.5\n assert candidate(arr = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5]) == 0.075\n assert candidate(arr = [99999, 1, 99998, 2, 99997, 3, 99996, 4, 99995, 5, 99994, 6, 99993, 7, 99992, 8, 99991, 9, 99990, 10, 99989, 11, 99988, 12, 99987, 13, 99986, 14, 99985, 15, 99984, 16, 99983, 17, 99982, 18, 99981, 19, 99980, 20, 99979, 21, 99978, 22, 99977, 23, 99976, 24, 99975, 25, 99974, 26, 99973, 27, 99972, 28, 99971, 29, 99970]) == 49999.5\n assert candidate(arr = [99999, 100000, 1, 99999, 100000, 1, 99999, 100000, 1, 99999, 100000, 1, 99999, 100000, 1, 99999, 100000, 1, 99999, 100000, 1, 99999, 100000, 1, 99999, 100000, 1, 99999, 100000, 1, 99999, 100000, 1, 99999, 100000, 1, 99999, 100000, 1, 99999, 100000, 1]) == 67567.51351\n assert candidate(arr = [100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0]) == 48717.94872\n assert candidate(arr = [3, 2, 1, 6, 5, 4, 9, 8, 7, 12, 11, 10, 15, 14, 13, 18, 17, 16, 21, 20, 25, 24, 23, 30, 29, 28, 33, 32, 31, 36, 35, 34, 39, 38, 37, 42, 41, 40, 45, 44, 43, 48, 47, 46, 51, 50, 49, 54, 53, 52, 57, 56, 55, 60, 59, 58, 63, 62, 61, 66, 65, 64, 69, 68, 67, 72, 71, 70]) == 36.81967\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 20.5\n assert candidate(arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 0, 0, 0, 0, 0]) == 17.14634\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().trimMean", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "double trimMean(vector& arr) {", "container": "Solution", "callable": "trimMean", "parameters": [{"name": "arr", "type": "vector&"}], "return_type": "double", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1620, "task_id": "coordinate-with-maximum-network-quality", "difficulty": "Medium", "problem_description": "You are given an array of network towers towers, where towers[i] = [xi, yi, qi] denotes the ith network tower with location (xi, yi) and quality factor qi. All the coordinates are integral coordinates on the X-Y plane, and the distance between the two coordinates is the Euclidean distance.\nYou are also given an integer radius where a tower is reachable if the distance is less than or equal to radius. Outside that distance, the signal becomes garbled, and the tower is not reachable.\nThe signal quality of the ith tower at a coordinate (x, y) is calculated with the formula ⌊qi / (1 + d)⌋, where d is the distance between the tower and the coordinate. The network quality at a coordinate is the sum of the signal qualities from all the reachable towers.\nReturn the array [cx, cy] representing the integral coordinate (cx, cy) where the network quality is maximum. If there are multiple coordinates with the same network quality, return the lexicographically minimum non-negative coordinate.\nNote:\n\nA coordinate (x1, y1) is lexicographically smaller than (x2, y2) if either:\n\n\t\nx1 < x2, or\nx1 == x2 and y1 < y2.\n\n\n⌊val��� is the greatest integer less than or equal to val (the floor function).\n\n \nExample 1:\n\n\nInput: towers = [[1,2,5],[2,1,7],[3,1,9]], radius = 2\nOutput: [2,1]\nExplanation: At coordinate (2, 1) the total quality is 13.\n- Quality of 7 from (2, 1) results in ⌊7 / (1 + sqrt(0)⌋ = ⌊7⌋ = 7\n- Quality of 5 from (1, 2) results in ⌊5 / (1 + sqrt(2)⌋ = ⌊2.07⌋ = 2\n- Quality of 9 from (3, 1) results in ⌊9 / (1 + sqrt(1)⌋ = ⌊4.5⌋ = 4\nNo other coordinate has a higher network quality.\nExample 2:\n\nInput: towers = [[23,11,21]], radius = 9\nOutput: [23,11]\nExplanation: Since there is only one tower, the network quality is highest right at the tower's location.\n\nExample 3:\n\nInput: towers = [[1,2,13],[2,1,7],[0,1,9]], radius = 2\nOutput: [1,2]\nExplanation: Coordinate (1, 2) has the highest network quality.\n\n \nConstraints:\n\n1 <= towers.length <= 50\ntowers[i].length == 3\n0 <= xi, yi, qi <= 50\n1 <= radius <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(towers = [[23, 11, 21]],radius = 9) == [23, 11]\n assert candidate(towers = [[5, 5, 15], [6, 6, 20], [7, 7, 25]],radius = 3) == [6, 6]\n assert candidate(towers = [[1, 2, 5], [2, 1, 7], [3, 1, 9]],radius = 2) == [2, 1]\n assert candidate(towers = [[0, 0, 10], [1, 1, 20], [2, 2, 30]],radius = 1) == [2, 2]\n assert candidate(towers = [[5, 5, 5], [5, 6, 5], [6, 5, 5], [6, 6, 5]],radius = 1) == [5, 5]\n assert candidate(towers = [[0, 0, 10], [5, 5, 20], [10, 10, 30]],radius = 15) == [10, 10]\n assert candidate(towers = [[0, 0, 1], [1, 1, 1], [2, 2, 1]],radius = 1) == [0, 0]\n assert candidate(towers = [[10, 0, 10], [0, 10, 10], [10, 10, 10]],radius = 15) == [0, 10]\n assert candidate(towers = [[0, 0, 10], [5, 5, 5]],radius = 6) == [0, 0]\n assert candidate(towers = [[0, 0, 10], [10, 10, 20]],radius = 15) == [10, 10]\n assert candidate(towers = [[10, 10, 5], [15, 15, 10], [20, 20, 15]],radius = 10) == [20, 20]\n assert candidate(towers = [[1, 2, 13], [2, 1, 7], [0, 1, 9]],radius = 2) == [1, 2]\n assert candidate(towers = [[1, 1, 1], [2, 2, 1], [3, 3, 1]],radius = 1) == [1, 1]\n assert candidate(towers = [[0, 0, 1], [1, 0, 1], [0, 1, 1], [1, 1, 1], [2, 2, 1], [2, 3, 1], [3, 2, 1], [3, 3, 1]],radius = 2) == [0, 0]\n assert candidate(towers = [[0, 0, 100], [1, 1, 99], [2, 2, 98], [3, 3, 97], [4, 4, 96], [5, 5, 95], [6, 6, 94], [7, 7, 93], [8, 8, 92], [9, 9, 91]],radius = 4) == [2, 2]\n assert candidate(towers = [[10, 10, 20], [15, 15, 10], [20, 20, 5], [5, 5, 15]],radius = 10) == [10, 10]\n assert candidate(towers = [[5, 5, 10], [15, 15, 20], [25, 25, 30], [35, 35, 40], [45, 45, 50]],radius = 10) == [45, 45]\n assert candidate(towers = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],radius = 1) == [13, 14]\n assert candidate(towers = [[5, 5, 15], [6, 6, 25], [7, 7, 35], [8, 8, 45], [9, 9, 55]],radius = 5) == [8, 8]\n assert candidate(towers = [[2, 2, 5], [4, 4, 10], [6, 6, 15], [8, 8, 20], [10, 10, 25], [12, 12, 30], [14, 14, 35]],radius = 7) == [12, 12]\n assert candidate(towers = [[10, 10, 1], [10, 11, 2], [10, 12, 3], [10, 13, 4], [10, 14, 5]],radius = 4) == [10, 14]\n assert candidate(towers = [[5, 5, 10], [10, 10, 20], [15, 15, 30], [20, 20, 40], [25, 25, 50]],radius = 10) == [25, 25]\n assert candidate(towers = [[0, 0, 1], [1, 0, 2], [2, 0, 3], [3, 0, 4], [4, 0, 5], [5, 0, 6], [6, 0, 7], [7, 0, 8], [8, 0, 9], [9, 0, 10]],radius = 2) == [7, 0]\n assert candidate(towers = [[1, 2, 5], [2, 1, 7], [3, 1, 9], [4, 3, 12], [5, 2, 8]],radius = 3) == [3, 1]\n assert candidate(towers = [[1, 1, 1], [1, 2, 1], [1, 3, 1], [2, 1, 1], [2, 2, 1], [2, 3, 1], [3, 1, 1], [3, 2, 1], [3, 3, 1]],radius = 1) == [1, 1]\n assert candidate(towers = [[1, 1, 5], [1, 2, 5], [2, 1, 5], [2, 2, 5], [3, 3, 5], [4, 4, 5], [5, 5, 5], [6, 6, 5]],radius = 2) == [2, 2]\n assert candidate(towers = [[10, 10, 50], [20, 10, 40], [10, 20, 30], [20, 20, 20], [10, 30, 10], [20, 30, 5]],radius = 15) == [10, 10]\n assert candidate(towers = [[10, 10, 50], [20, 20, 50], [30, 30, 50], [40, 40, 50], [50, 50, 50]],radius = 20) == [20, 20]\n assert candidate(towers = [[25, 25, 50], [10, 10, 30], [40, 40, 20], [30, 30, 40], [15, 15, 25], [45, 45, 10]],radius = 12) == [25, 25]\n assert candidate(towers = [[5, 5, 10], [15, 15, 15], [25, 25, 20], [35, 35, 25], [45, 45, 30]],radius = 15) == [45, 45]\n assert candidate(towers = [[0, 0, 1], [50, 0, 1], [0, 50, 1], [50, 50, 1], [25, 25, 100]],radius = 30) == [25, 25]\n assert candidate(towers = [[25, 25, 50], [24, 25, 49], [26, 25, 48], [25, 24, 47], [25, 26, 46], [24, 24, 45], [24, 26, 44], [26, 24, 43], [26, 26, 42]],radius = 2) == [25, 25]\n assert candidate(towers = [[0, 0, 10], [0, 10, 20], [10, 0, 30], [10, 10, 40], [5, 5, 50]],radius = 15) == [5, 5]\n assert candidate(towers = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]],radius = 1) == [10, 10]\n assert candidate(towers = [[5, 10, 20], [10, 5, 30], [15, 15, 40], [20, 10, 50], [25, 5, 60]],radius = 7) == [25, 5]\n assert candidate(towers = [[25, 25, 100], [30, 30, 200], [35, 35, 300], [40, 40, 400], [45, 45, 500], [50, 50, 600]],radius = 15) == [50, 50]\n assert candidate(towers = [[25, 25, 100], [15, 15, 90], [35, 15, 80], [15, 35, 70], [35, 35, 60], [25, 15, 50], [15, 25, 40], [35, 25, 30], [25, 35, 20], [15, 30, 10], [35, 30, 5], [20, 20, 25], [30, 30, 25]],radius = 15) == [25, 25]\n assert candidate(towers = [[0, 0, 1], [0, 1, 1], [1, 0, 1], [1, 1, 1], [0, 2, 1], [1, 2, 1], [2, 0, 1], [2, 1, 1], [2, 2, 1]],radius = 1) == [0, 0]\n assert candidate(towers = [[5, 5, 50], [10, 10, 50], [15, 15, 50], [20, 20, 50], [25, 25, 50]],radius = 5) == [5, 5]\n assert candidate(towers = [[1, 1, 100], [2, 2, 200], [3, 3, 300], [4, 4, 400], [5, 5, 500]],radius = 10) == [4, 4]\n assert candidate(towers = [[0, 0, 1], [0, 1, 1], [0, 2, 1], [1, 0, 1], [1, 1, 1], [1, 2, 1], [2, 0, 1], [2, 1, 1], [2, 2, 1]],radius = 1) == [0, 0]\n assert candidate(towers = [[10, 10, 10], [20, 10, 20], [30, 10, 30], [40, 10, 40], [50, 10, 50], [10, 20, 50], [20, 20, 40], [30, 20, 30], [40, 20, 20], [50, 20, 10]],radius = 10) == [10, 20]\n assert candidate(towers = [[1, 1, 5], [1, 2, 5], [1, 3, 5], [2, 1, 5], [2, 2, 5], [2, 3, 5], [3, 1, 5], [3, 2, 5], [3, 3, 5]],radius = 2) == [2, 2]\n assert candidate(towers = [[1, 1, 10], [2, 2, 20], [3, 3, 30], [4, 4, 40]],radius = 5) == [4, 4]\n assert candidate(towers = [[25, 25, 50], [24, 24, 40], [23, 23, 30], [22, 22, 20], [21, 21, 10], [20, 20, 5]],radius = 6) == [24, 24]\n assert candidate(towers = [[1, 2, 5], [3, 4, 5], [5, 6, 5], [7, 8, 5], [9, 10, 5]],radius = 5) == [3, 4]\n assert candidate(towers = [[25, 25, 10], [30, 30, 20], [35, 35, 30], [40, 40, 40], [45, 45, 50]],radius = 15) == [45, 45]\n assert candidate(towers = [[5, 5, 20], [10, 10, 30], [15, 15, 40], [20, 20, 50], [25, 25, 60], [30, 30, 70]],radius = 12) == [30, 30]\n assert candidate(towers = [[25, 25, 100], [25, 26, 100], [26, 25, 100], [26, 26, 100], [24, 25, 100], [25, 24, 100], [24, 24, 100], [26, 24, 100], [24, 26, 100], [26, 26, 100]],radius = 1) == [25, 25]\n assert candidate(towers = [[5, 5, 10], [10, 5, 10], [5, 10, 10], [10, 10, 10], [2, 2, 10], [8, 8, 10], [2, 8, 10], [8, 2, 10]],radius = 5) == [8, 8]\n assert candidate(towers = [[5, 5, 10], [10, 5, 20], [5, 10, 20], [10, 10, 30], [15, 15, 40], [20, 20, 50]],radius = 10) == [20, 20]\n assert candidate(towers = [[0, 0, 1], [5, 5, 10], [10, 10, 100], [15, 15, 1000], [20, 20, 10000]],radius = 20) == [20, 20]\n assert candidate(towers = [[0, 0, 100], [0, 50, 100], [50, 0, 100], [50, 50, 100], [25, 25, 100]],radius = 30) == [0, 0]\n assert candidate(towers = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [2, 1, 4], [2, 2, 5], [2, 3, 6], [3, 1, 7], [3, 2, 8], [3, 3, 9]],radius = 1) == [3, 2]\n assert candidate(towers = [[10, 10, 20], [20, 20, 30], [30, 30, 40], [40, 40, 50], [50, 50, 60]],radius = 25) == [50, 50]\n assert candidate(towers = [[3, 3, 3], [6, 6, 6], [9, 9, 9], [12, 12, 12], [15, 15, 15]],radius = 5) == [15, 15]\n assert candidate(towers = [[10, 10, 100], [20, 20, 200], [30, 30, 300], [40, 40, 400], [50, 50, 500]],radius = 20) == [50, 50]\n assert candidate(towers = [[10, 10, 30], [20, 20, 20], [30, 30, 10], [40, 40, 5]],radius = 10) == [10, 10]\n assert candidate(towers = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1]],radius = 2) == [1, 1]\n assert candidate(towers = [[10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40], [50, 50, 50], [0, 0, 0], [5, 5, 5], [15, 15, 15]],radius = 10) == [50, 50]\n assert candidate(towers = [[10, 10, 20], [20, 20, 30], [15, 15, 15], [5, 5, 10]],radius = 10) == [20, 20]\n assert candidate(towers = [[5, 10, 5], [10, 5, 10], [15, 10, 15], [20, 5, 20], [25, 10, 25]],radius = 5) == [25, 10]\n assert candidate(towers = [[5, 5, 10], [10, 10, 20], [15, 15, 30], [20, 20, 40], [25, 25, 50]],radius = 15) == [25, 25]\n assert candidate(towers = [[5, 5, 20], [10, 10, 15], [15, 15, 10], [20, 20, 5], [25, 25, 1]],radius = 12) == [5, 5]\n assert candidate(towers = [[2, 3, 15], [5, 5, 10], [8, 7, 8], [10, 10, 20]],radius = 5) == [10, 10]\n assert candidate(towers = [[5, 0, 5], [10, 0, 5], [15, 0, 5], [20, 0, 5], [25, 0, 5]],radius = 10) == [5, 0]\n assert candidate(towers = [[0, 0, 1], [0, 1, 2], [0, 2, 3], [1, 0, 4], [1, 1, 5], [1, 2, 6], [2, 0, 7], [2, 1, 8], [2, 2, 9]],radius = 2) == [1, 1]\n assert candidate(towers = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]],radius = 2) == [8, 8]\n assert candidate(towers = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1], [10, 10, 1]],radius = 2) == [1, 1]\n assert candidate(towers = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]],radius = 5) == [9, 9]\n assert candidate(towers = [[1, 1, 10], [2, 2, 20], [3, 3, 30], [4, 4, 40]],radius = 3) == [4, 4]\n assert candidate(towers = [[10, 10, 10], [20, 10, 20], [30, 10, 30], [10, 20, 20], [20, 20, 30], [30, 20, 40]],radius = 10) == [30, 20]\n assert candidate(towers = [[10, 10, 50], [20, 20, 50], [30, 30, 50], [40, 40, 50], [50, 50, 50]],radius = 5) == [10, 10]\n assert candidate(towers = [[0, 0, 1], [1, 1, 2], [2, 2, 3], [3, 3, 4], [4, 4, 5], [5, 5, 6]],radius = 2) == [4, 4]\n assert candidate(towers = [[10, 10, 10], [20, 20, 20], [15, 15, 15], [25, 25, 5]],radius = 10) == [20, 20]\n assert candidate(towers = [[0, 0, 1], [10, 0, 2], [20, 0, 3], [30, 0, 4], [40, 0, 5], [50, 0, 6]],radius = 15) == [50, 0]\n assert candidate(towers = [[1, 1, 10], [2, 2, 20], [3, 3, 30], [4, 4, 40], [5, 5, 50]],radius = 2) == [4, 4]\n assert candidate(towers = [[0, 0, 10], [50, 0, 10], [0, 50, 10], [50, 50, 10], [25, 25, 15]],radius = 20) == [25, 25]\n assert candidate(towers = [[0, 0, 50], [50, 0, 50], [50, 50, 50], [0, 50, 50], [25, 25, 50], [25, 0, 40], [25, 50, 40], [0, 25, 40], [50, 25, 40]],radius = 25) == [25, 25]\n assert candidate(towers = [[5, 5, 10], [10, 10, 20], [15, 15, 30], [20, 20, 40], [25, 25, 50]],radius = 10) == [25, 25]\n assert candidate(towers = [[10, 0, 100], [0, 10, 100], [10, 10, 100], [0, 0, 100]],radius = 15) == [0, 0]\n assert candidate(towers = [[10, 10, 50], [11, 10, 45], [12, 10, 40], [13, 10, 35], [14, 10, 30]],radius = 4) == [11, 10]\n assert candidate(towers = [[10, 10, 100], [20, 20, 200], [30, 30, 300], [40, 40, 400]],radius = 10) == [40, 40]\n assert candidate(towers = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [2, 1, 2], [2, 2, 4], [2, 3, 2], [3, 1, 3], [3, 2, 2], [3, 3, 1]],radius = 1) == [2, 2]\n assert candidate(towers = [[0, 0, 1], [1, 1, 2], [2, 2, 3], [3, 3, 4], [4, 4, 5], [5, 5, 6]],radius = 2) == [4, 4]\n assert candidate(towers = [[10, 10, 50], [20, 20, 30], [30, 30, 10], [0, 0, 20]],radius = 15) == [10, 10]\n assert candidate(towers = [[25, 25, 50], [25, 26, 45], [26, 25, 40], [26, 26, 35], [24, 24, 30]],radius = 3) == [25, 25]\n assert candidate(towers = [[0, 0, 1], [1, 0, 2], [0, 1, 2], [1, 1, 3], [2, 2, 4], [3, 3, 5], [4, 4, 6], [5, 5, 7], [6, 6, 8]],radius = 1) == [6, 6]\n assert candidate(towers = [[2, 2, 5], [3, 3, 10], [4, 4, 15], [5, 5, 20], [6, 6, 25]],radius = 2) == [5, 5]\n assert candidate(towers = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]],radius = 3) == [4, 4]\n assert candidate(towers = [[50, 50, 50], [40, 40, 40], [30, 30, 30], [20, 20, 20], [10, 10, 10]],radius = 10) == [50, 50]\n assert candidate(towers = [[20, 30, 40], [30, 40, 50], [40, 50, 60], [50, 60, 70], [60, 70, 80]],radius = 15) == [40, 50]\n assert candidate(towers = [[30, 30, 100], [25, 25, 50], [20, 20, 75], [15, 15, 60], [10, 10, 90]],radius = 10) == [30, 30]\n assert candidate(towers = [[10, 10, 100], [10, 11, 90], [11, 10, 90], [11, 11, 80], [12, 12, 70], [9, 9, 60], [9, 12, 50], [12, 9, 40], [8, 8, 30], [12, 12, 20]],radius = 3) == [10, 10]\n assert candidate(towers = [[0, 0, 5], [5, 5, 5], [10, 10, 5], [15, 15, 5], [20, 20, 5]],radius = 8) == [0, 0]\n assert candidate(towers = [[0, 0, 10], [10, 0, 10], [0, 10, 10], [10, 10, 10], [5, 5, 20]],radius = 10) == [5, 5]\n assert candidate(towers = [[20, 20, 30], [25, 25, 20], [15, 15, 40]],radius = 10) == [15, 15]\n assert candidate(towers = [[5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5]],radius = 0) == [5, 5]\n assert candidate(towers = [[1, 1, 10], [1, 2, 10], [1, 3, 10], [1, 4, 10], [2, 1, 10], [2, 2, 10], [2, 3, 10], [2, 4, 10], [3, 1, 10], [3, 2, 10], [3, 3, 10], [3, 4, 10], [4, 1, 10], [4, 2, 10], [4, 3, 10], [4, 4, 10]],radius = 3) == [2, 2]\n assert candidate(towers = [[25, 25, 25], [30, 30, 30], [20, 20, 20], [15, 15, 15], [5, 5, 5], [10, 10, 10]],radius = 5) == [30, 30]\n assert candidate(towers = [[0, 0, 5], [0, 10, 5], [10, 0, 5], [10, 10, 5], [5, 5, 10]],radius = 5) == [5, 5]\n assert candidate(towers = [[5, 5, 100], [15, 5, 90], [25, 5, 80], [35, 5, 70], [45, 5, 60], [55, 5, 50], [65, 5, 40], [75, 5, 30], [85, 5, 20], [95, 5, 10]],radius = 10) == [5, 5]\n assert candidate(towers = [[3, 3, 9], [6, 6, 12], [9, 9, 15], [12, 12, 18], [15, 15, 21]],radius = 5) == [12, 12]\n assert candidate(towers = [[10, 10, 20], [20, 20, 15], [30, 30, 25], [15, 25, 30], [25, 15, 20]],radius = 8) == [15, 25]\n assert candidate(towers = [[10, 10, 10], [10, 11, 20], [10, 12, 30], [11, 10, 40], [11, 11, 50], [11, 12, 60], [12, 10, 70], [12, 11, 80], [12, 12, 90]],radius = 3) == [12, 11]\n assert candidate(towers = [[0, 0, 1], [1, 1, 2], [2, 2, 3], [3, 3, 4], [4, 4, 5]],radius = 10) == [3, 3]\n assert candidate(towers = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]],radius = 2) == [4, 4]\n assert candidate(towers = [[25, 25, 50], [25, 26, 50], [26, 25, 50], [26, 26, 50], [24, 24, 50], [24, 25, 50], [25, 24, 50], [24, 26, 50], [26, 24, 50]],radius = 1) == [25, 25]\n"}, "metadata": {"canonical_parameter_names": ["towers", "radius"], "leetcode_dataset_entry_point": "Solution().bestCoordinate", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector bestCoordinate(vector>& towers, int radius) {", "container": "Solution", "callable": "bestCoordinate", "parameters": [{"name": "towers", "type": "vector>&"}, {"name": "radius", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1621, "task_id": "number-of-sets-of-k-non-overlapping-line-segments", "difficulty": "Medium", "problem_description": "Given n points on a 1-D plane, where the ith point (from 0 to n-1) is at x = i, find the number of ways we can draw exactly k non-overlapping line segments such that each segment covers two or more points. The endpoints of each segment must have integral coordinates. The k line segments do not have to cover all n points, and they are allowed to share endpoints.\nReturn the number of ways we can draw k non-overlapping line segments. Since this number can be huge, return it modulo 109 + 7.\n \nExample 1:\n\n\nInput: n = 4, k = 2\nOutput: 5\nExplanation: The two line segments are shown in red and blue.\nThe image above shows the 5 different ways {(0,2),(2,3)}, {(0,1),(1,3)}, {(0,1),(2,3)}, {(1,2),(2,3)}, {(0,1),(1,2)}.\n\nExample 2:\n\nInput: n = 3, k = 1\nOutput: 3\nExplanation: The 3 ways are {(0,1)}, {(0,2)}, {(1,2)}.\n\nExample 3:\n\nInput: n = 30, k = 7\nOutput: 796297179\nExplanation: The total number of possible ways to draw 7 line segments is 3796297200. Taking this number modulo 109 + 7 gives us 796297179.\n\n \nConstraints:\n\n2 <= n <= 1000\n1 <= k <= n-1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3,k = 1) == 3\n assert candidate(n = 1000,k = 500) == 70047606\n assert candidate(n = 30,k = 7) == 796297179\n assert candidate(n = 6,k = 3) == 28\n assert candidate(n = 8,k = 4) == 165\n assert candidate(n = 5,k = 2) == 15\n assert candidate(n = 7,k = 1) == 21\n assert candidate(n = 100,k = 50) == 237930091\n assert candidate(n = 4,k = 2) == 5\n assert candidate(n = 20,k = 10) == 10015005\n assert candidate(n = 9,k = 2) == 210\n assert candidate(n = 10,k = 3) == 924\n assert candidate(n = 400,k = 200) == 849395041\n assert candidate(n = 300,k = 150) == 188049093\n assert candidate(n = 250,k = 125) == 61117700\n assert candidate(n = 200,k = 100) == 412289370\n assert candidate(n = 150,k = 50) == 703668401\n assert candidate(n = 500,k = 200) == 89039524\n assert candidate(n = 80,k = 20) == 527894588\n assert candidate(n = 1000,k = 999) == 1\n assert candidate(n = 999,k = 998) == 1\n assert candidate(n = 750,k = 300) == 966786381\n assert candidate(n = 800,k = 350) == 811412361\n assert candidate(n = 950,k = 400) == 686452764\n assert candidate(n = 25,k = 10) == 391975633\n assert candidate(n = 1000,k = 300) == 535696304\n assert candidate(n = 50,k = 10) == 984308396\n assert candidate(n = 600,k = 250) == 917595427\n assert candidate(n = 400,k = 150) == 37130153\n assert candidate(n = 998,k = 499) == 990039585\n assert candidate(n = 700,k = 250) == 1718306\n assert candidate(n = 50,k = 20) == 875426906\n assert candidate(n = 700,k = 350) == 906610068\n assert candidate(n = 999,k = 499) == 970118741\n assert candidate(n = 900,k = 450) == 891508928\n assert candidate(n = 600,k = 100) == 945626632\n assert candidate(n = 8,k = 3) == 210\n assert candidate(n = 150,k = 75) == 937415442\n assert candidate(n = 250,k = 20) == 344905395\n assert candidate(n = 250,k = 100) == 47365034\n assert candidate(n = 25,k = 5) == 20030010\n assert candidate(n = 100,k = 10) == 697218647\n assert candidate(n = 100,k = 20) == 114267332\n assert candidate(n = 15,k = 5) == 92378\n assert candidate(n = 50,k = 15) == 188331431\n assert candidate(n = 100,k = 40) == 234333249\n assert candidate(n = 1000,k = 1) == 499500\n assert candidate(n = 600,k = 220) == 66442708\n assert candidate(n = 800,k = 300) == 374845297\n assert candidate(n = 750,k = 375) == 796219809\n assert candidate(n = 600,k = 300) == 508930020\n assert candidate(n = 50,k = 5) == 930713009\n assert candidate(n = 800,k = 400) == 530286193\n assert candidate(n = 250,k = 75) == 928665746\n assert candidate(n = 999,k = 500) == 688428127\n assert candidate(n = 350,k = 175) == 134369598\n assert candidate(n = 500,k = 100) == 698790075\n assert candidate(n = 500,k = 250) == 540818587\n"}, "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().numberOfSets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numberOfSets(int n, int k) {", "container": "Solution", "callable": "numberOfSets", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1624, "task_id": "largest-substring-between-two-equal-characters", "difficulty": "Easy", "problem_description": "Given a string s, return the length of the longest substring between two equal characters, excluding the two characters. If there is no such substring return -1.\nA substring is a contiguous sequence of characters within a string.\n \nExample 1:\n\nInput: s = \"aa\"\nOutput: 0\nExplanation: The optimal substring here is an empty substring between the two 'a's.\nExample 2:\n\nInput: s = \"abca\"\nOutput: 2\nExplanation: The optimal substring here is \"bc\".\n\nExample 3:\n\nInput: s = \"cbzxy\"\nOutput: -1\nExplanation: There are no characters that appear twice in s.\n\n \nConstraints:\n\n1 <= s.length <= 300\ns contains only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aabbaa\") == 4\n assert candidate(s = \"xyzx\") == 2\n assert candidate(s = \"a\") == -1\n assert candidate(s = \"aa\") == 0\n assert candidate(s = \"abcda\") == 3\n assert candidate(s = \"abcabc\") == 2\n assert candidate(s = \"abcdabcd\") == 3\n assert candidate(s = \"xyz\") == -1\n assert candidate(s = \"abcabcbb\") == 5\n assert candidate(s = \"leetcode\") == 5\n assert candidate(s = \"mnopqrstuvmnop\") == 9\n assert candidate(s = \"zzzzzzzzzz\") == 8\n assert candidate(s = \"zabz\") == 2\n assert candidate(s = \"cbzxy\") == -1\n assert candidate(s = \"abcdeabcde\") == 4\n assert candidate(s = \"aabbcc\") == 0\n assert candidate(s = \"zabacdz\") == 5\n assert candidate(s = \"mnopqrlomn\") == 7\n assert candidate(s = \"abacaba\") == 5\n assert candidate(s = \"abca\") == 2\n assert candidate(s = \"abcdefg\") == -1\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihggffeeddccbbaa\") == 102\n assert candidate(s = \"aaaabbbbccccdddd\") == 2\n assert candidate(s = \"abcabcabcabcabcabcabc\") == 17\n assert candidate(s = \"ababcabcab\") == 7\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzxywvutsrqponmlkjihgfedcba\") == 50\n assert candidate(s = \"abcdexyzabcdexyzabcdexyz\") == 15\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzza\") == 51\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzz\") == 8\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 49\n assert candidate(s = \"deified\") == 5\n assert candidate(s = \"pqrstuvwxyzabcdefghijklmno\") == -1\n assert candidate(s = \"abcdefgahijklmnopqrstuvwxyz\") == 6\n assert candidate(s = \"rotorrotorrotor\") == 13\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbccccccccddddddddeeeeeeeeeffffffffggggggggghhhhhhhhiiiiiiiiiijjjjjjjjjjjjjjjjjkkkkkkkkkkkllllllllllllllllllmmmmmmmmmmmmmmmmmmmnnnnnnnnnnnnnnnnnnnooooooooooooooooppppppppppppppppppppqqqqqqqqqqqqqqqqqqqqrrrrrrrrrrrrrrrrrrrrsssssssssssssssssssssttttttttttttttttttttuuuuuuuuuuuuuuuuuuuuvvvvvvvvvvvvvvvvvvvvwwwwwwwwwwwwwwwwwwwwxxxyyyyyyyyyyyyyyyyyyyyyzzzzzzzzzzzzzzzzzzzz\") == 19\n assert candidate(s = \"aaaaabbbbbcccccdddddeeeee\") == 3\n assert candidate(s = \"kayak\") == 3\n assert candidate(s = \"abacabadabacaba\") == 13\n assert candidate(s = \"aabbccddeeaabbccddeeffgghheeffgghhii\") == 18\n assert candidate(s = \"abracadabra\") == 9\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 54\n assert candidate(s = \"abcabcabcabc\") == 8\n assert candidate(s = \"abcdaebcdfeghifijkiljklmnopqrstuvswxyzxyzz\") == 4\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 51\n assert candidate(s = \"xyzyxzyzyxzyzyxzyzyx\") == 18\n assert candidate(s = \"ab\") == -1\n assert candidate(s = \"xyzwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyz\") == 48\n assert candidate(s = \"aabcdefghijklmnopqrstuvwxyzabcde\") == 26\n assert candidate(s = \"xyzzxyzzxyzzxyzzxyzz\") == 16\n assert candidate(s = \"abcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcb\") == 113\n assert candidate(s = \"acbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcbabcba\") == 110\n assert candidate(s = \"rotor\") == 3\n assert candidate(s = \"racecar\") == 5\n assert candidate(s = \"aaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaaabbbaaa\") == 105\n assert candidate(s = \"abcdefghijabcdefghij\") == 9\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 50\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 25\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\") == 19\n assert candidate(s = \"noon\") == 2\n assert candidate(s = \"aaabaaaacaaaaadaaaaaeaaaaa\") == 24\n assert candidate(s = \"abcdefgabcdefg\") == 6\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\") == 37\n assert candidate(s = \"lkjlkjlkjlkjlkjlkj\") == 14\n assert candidate(s = \"abcdeafghijaklmnopqrastuvwxyz\") == 19\n assert candidate(s = \"aabbaaabbbaaa\") == 11\n assert candidate(s = \"abcdaebcdfeghifijkiljklmnopqrstuvswxyzxyzzzyxwvutsrqponmlkjilfedcbazyxwvutsrqponmlkjihgfedcba\") == 91\n assert candidate(s = \"abcdefghijjihegfedcba\") == 19\n assert candidate(s = \"abacaxab\") == 5\n assert candidate(s = \"mississippi\") == 8\n assert candidate(s = \"xyzzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxz\") == 124\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 0\n assert candidate(s = \"level\") == 3\n assert candidate(s = \"abcdefghijzyxwvutsrqponmlkjihgfedcba\") == 34\n assert candidate(s = \"abcdefgxyzgfedcba\") == 15\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxLengthBetweenEqualCharacters", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxLengthBetweenEqualCharacters(string s) {", "container": "Solution", "callable": "maxLengthBetweenEqualCharacters", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1625, "task_id": "lexicographically-smallest-string-after-applying-operations", "difficulty": "Medium", "problem_description": "You are given a string s of even length consisting of digits from 0 to 9, and two integers a and b.\nYou can apply either of the following two operations any number of times and in any order on s:\n\nAdd a to all odd indices of s (0-indexed). Digits post 9 are cycled back to 0. For example, if s = \"3456\" and a = 5, s becomes \"3951\".\nRotate s to the right by b positions. For example, if s = \"3456\" and b = 1, s becomes \"6345\".\n\nReturn the lexicographically smallest string you can obtain by applying the above operations any number of times on s.\nA string a is lexicographically smaller than a string b (of the same length) if in the first position where a and b differ, string a has a letter that appears earlier in the alphabet than the corresponding letter in b. For example, \"0158\" is lexicographically smaller than \"0190\" because the first position they differ is at the third letter, and '5' comes before '9'.\n \nExample 1:\n\nInput: s = \"5525\", a = 9, b = 2\nOutput: \"2050\"\nExplanation: We can apply the following operations:\nStart: \"5525\"\nRotate: \"2555\"\nAdd: \"2454\"\nAdd: \"2353\"\nRotate: \"5323\"\nAdd: \"5222\"\nAdd: \"5121\"\nRotate: \"2151\"\nAdd: \"2050\"​​​​​\nThere is no way to obtain a string that is lexicographically smaller than \"2050\".\n\nExample 2:\n\nInput: s = \"74\", a = 5, b = 1\nOutput: \"24\"\nExplanation: We can apply the following operations:\nStart: \"74\"\nRotate: \"47\"\n​​​​​​​Add: \"42\"\n​​​​​​​Rotate: \"24\"​​​​​​​​​​​​\nThere is no way to obtain a string that is lexicographically smaller than \"24\".\n\nExample 3:\n\nInput: s = \"0011\", a = 4, b = 2\nOutput: \"0011\"\nExplanation: There are no sequence of operations that will give us a lexicographically smaller string than \"0011\".\n\n \nConstraints:\n\n2 <= s.length <= 100\ns.length is even.\ns consists of digits from 0 to 9 only.\n1 <= a <= 9\n1 <= b <= s.length - 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"5525\",a = 9,b = 2) == \"2050\"\n assert candidate(s = \"9876543210\",a = 7,b = 4) == \"1098765432\"\n assert candidate(s = \"74\",a = 5,b = 1) == \"24\"\n assert candidate(s = \"8900\",a = 3,b = 3) == \"0018\"\n assert candidate(s = \"1234567890\",a = 7,b = 3) == \"0022446688\"\n assert candidate(s = \"3456\",a = 5,b = 1) == \"0189\"\n assert candidate(s = \"0011\",a = 4,b = 2) == \"0011\"\n assert candidate(s = \"1234567890\",a = 3,b = 3) == \"0022446688\"\n assert candidate(s = \"9876543210\",a = 3,b = 4) == \"1098765432\"\n assert candidate(s = \"1234567890\",a = 1,b = 5) == \"0022446688\"\n assert candidate(s = \"5432109876\",a = 6,b = 7) == \"0189674523\"\n assert candidate(s = \"0246802468\",a = 4,b = 2) == \"0044882266\"\n assert candidate(s = \"908070605040302010\",a = 5,b = 7) == \"000908070604030201\"\n assert candidate(s = \"3692581470\",a = 4,b = 2) == \"1076329854\"\n assert candidate(s = \"1111111111\",a = 1,b = 2) == \"1010101010\"\n assert candidate(s = \"2222222222\",a = 5,b = 6) == \"2222222222\"\n assert candidate(s = \"0246813579\",a = 4,b = 2) == \"0044893377\"\n assert candidate(s = \"9999999999\",a = 2,b = 7) == \"1111111111\"\n assert candidate(s = \"8274635910\",a = 3,b = 3) == \"0017365544\"\n assert candidate(s = \"123412341234\",a = 2,b = 4) == \"103210321032\"\n assert candidate(s = \"2468024680\",a = 3,b = 3) == \"0044882266\"\n assert candidate(s = \"0987654321\",a = 7,b = 3) == \"0088664422\"\n assert candidate(s = \"9135791357\",a = 8,b = 12) == \"9135791357\"\n assert candidate(s = \"3333333333\",a = 3,b = 2) == \"3030303030\"\n assert candidate(s = \"9999999999\",a = 1,b = 4) == \"9090909090\"\n assert candidate(s = \"12345678901234567890\",a = 9,b = 10) == \"10325476981032547698\"\n assert candidate(s = \"1111111111\",a = 7,b = 9) == \"0000000000\"\n assert candidate(s = \"595959\",a = 3,b = 3) == \"000000\"\n assert candidate(s = \"9753186420\",a = 7,b = 6) == \"1066229955\"\n assert candidate(s = \"0246802468\",a = 5,b = 7) == \"0246802468\"\n assert candidate(s = \"1357924680\",a = 5,b = 10) == \"1357924680\"\n assert candidate(s = \"9999999999\",a = 2,b = 1) == \"1111111111\"\n assert candidate(s = \"5959595959\",a = 2,b = 1) == \"1111111111\"\n assert candidate(s = \"6420875319\",a = 9,b = 7) == \"0055117844\"\n assert candidate(s = \"6666666666\",a = 6,b = 8) == \"6060606060\"\n assert candidate(s = \"2828282828\",a = 3,b = 13) == \"2020202020\"\n assert candidate(s = \"8642086420\",a = 7,b = 25) == \"8046026824\"\n assert candidate(s = \"00000000000000000000\",a = 7,b = 15) == \"00000000000000000000\"\n assert candidate(s = \"3333333333\",a = 7,b = 11) == \"3030303030\"\n assert candidate(s = \"1212121212\",a = 4,b = 6) == \"1010101010\"\n assert candidate(s = \"5678901234\",a = 2,b = 3) == \"0123456789\"\n assert candidate(s = \"8642086420\",a = 5,b = 9) == \"0369258147\"\n assert candidate(s = \"11223344556677889900\",a = 7,b = 8) == \"10213243546576879809\"\n assert candidate(s = \"676767676767676767676767\",a = 9,b = 17) == \"000000000000000000000000\"\n assert candidate(s = \"9876543210\",a = 1,b = 3) == \"0088664422\"\n assert candidate(s = \"999999\",a = 5,b = 3) == \"444444\"\n assert candidate(s = \"0987654321\",a = 9,b = 10) == \"0088664422\"\n assert candidate(s = \"5937160482\",a = 4,b = 6) == \"0088553312\"\n assert candidate(s = \"8642086420\",a = 3,b = 3) == \"0066228844\"\n assert candidate(s = \"4321098765\",a = 6,b = 10) == \"4129078563\"\n assert candidate(s = \"112233445566778899\",a = 4,b = 8) == \"112233445566778899\"\n assert candidate(s = \"1212121212\",a = 5,b = 5) == \"1212121212\"\n assert candidate(s = \"3141592653589793238462643383\",a = 3,b = 10) == \"2057529197278866683787354553\"\n assert candidate(s = \"135791357913579135\",a = 6,b = 5) == \"115533771155993377\"\n assert candidate(s = \"86420\",a = 3,b = 2) == \"00000\"\n assert candidate(s = \"2468024680\",a = 9,b = 4) == \"0044882266\"\n assert candidate(s = \"0246813579\",a = 6,b = 3) == \"0044893377\"\n assert candidate(s = \"0123456789\",a = 9,b = 8) == \"0022446688\"\n assert candidate(s = \"8765432109\",a = 6,b = 7) == \"0189674523\"\n assert candidate(s = \"3692581470\",a = 4,b = 14) == \"3096521874\"\n assert candidate(s = \"020406080020406080020406\",a = 8,b = 11) == \"000204000204060828486888\"\n assert candidate(s = \"0123456789\",a = 9,b = 11) == \"0022446688\"\n assert candidate(s = \"4545454545\",a = 5,b = 15) == \"4040404040\"\n assert candidate(s = \"4949494949\",a = 2,b = 10) == \"4141414141\"\n assert candidate(s = \"1212121212\",a = 5,b = 6) == \"1212121212\"\n assert candidate(s = \"9360258174\",a = 5,b = 9) == \"0258174936\"\n assert candidate(s = \"2468024680\",a = 8,b = 4) == \"0044882266\"\n assert candidate(s = \"1122334455\",a = 6,b = 5) == \"1021379809\"\n assert candidate(s = \"246802468024680246802468\",a = 7,b = 13) == \"004400448822660044882266\"\n assert candidate(s = \"2244668800\",a = 3,b = 7) == \"0022446688\"\n assert candidate(s = \"1357913579\",a = 4,b = 2) == \"1155993377\"\n assert candidate(s = \"9999999999\",a = 3,b = 3) == \"0000000000\"\n assert candidate(s = \"0246813579\",a = 4,b = 3) == \"0044893377\"\n assert candidate(s = \"0000000000\",a = 9,b = 5) == \"0000000000\"\n assert candidate(s = \"8642097531\",a = 6,b = 8) == \"0177338844\"\n assert candidate(s = \"0918273645\",a = 2,b = 3) == \"0091827819\"\n assert candidate(s = \"0246813579\",a = 8,b = 2) == \"0044893377\"\n assert candidate(s = \"1122334455\",a = 7,b = 8) == \"1021324354\"\n assert candidate(s = \"7777777777\",a = 3,b = 2) == \"7070707070\"\n assert candidate(s = \"86420\",a = 9,b = 1) == \"00000\"\n assert candidate(s = \"1357924680\",a = 5,b = 1) == \"0135792468\"\n assert candidate(s = \"4826037195\",a = 2,b = 7) == \"0077599422\"\n assert candidate(s = \"5050505050\",a = 9,b = 6) == \"5050505050\"\n assert candidate(s = \"595959595959595959\",a = 4,b = 2) == \"515151515151515151\"\n assert candidate(s = \"7035298461\",a = 8,b = 5) == \"1068392574\"\n assert candidate(s = \"1928374655\",a = 3,b = 3) == \"0019283746\"\n assert candidate(s = \"5973159731\",a = 2,b = 7) == \"1135775993\"\n assert candidate(s = \"99887766554433221100\",a = 3,b = 6) == \"00998877665544332211\"\n assert candidate(s = \"9999999999\",a = 9,b = 3) == \"0000000000\"\n assert candidate(s = \"1231231231\",a = 8,b = 4) == \"1039103921\"\n assert candidate(s = \"2468035791\",a = 2,b = 8) == \"0155992266\"\n assert candidate(s = \"8642086420\",a = 5,b = 5) == \"3197531975\"\n assert candidate(s = \"2468024680\",a = 6,b = 5) == \"0044882266\"\n assert candidate(s = \"5319753197\",a = 6,b = 7) == \"1177339955\"\n assert candidate(s = \"9999999999\",a = 2,b = 10) == \"9191919191\"\n assert candidate(s = \"1357924680\",a = 2,b = 7) == \"0033771266\"\n assert candidate(s = \"0123456789\",a = 9,b = 9) == \"0022446688\"\n assert candidate(s = \"2468024680\",a = 5,b = 8) == \"0246802468\"\n assert candidate(s = \"1111111111\",a = 8,b = 1) == \"1111111111\"\n assert candidate(s = \"99999999999999999999999999\",a = 2,b = 19) == \"11111111111111111111111111\"\n assert candidate(s = \"1357924680\",a = 3,b = 3) == \"0033771266\"\n assert candidate(s = \"2736814950\",a = 3,b = 8) == \"2039844253\"\n assert candidate(s = \"1357913579\",a = 8,b = 6) == \"1155993377\"\n assert candidate(s = \"2468013579\",a = 7,b = 4) == \"0034782367\"\n assert candidate(s = \"1111111111\",a = 9,b = 9) == \"0000000000\"\n assert candidate(s = \"9182736450\",a = 4,b = 2) == \"5091827364\"\n assert candidate(s = \"5317902468\",a = 6,b = 4) == \"1194286257\"\n assert candidate(s = \"9080706050\",a = 8,b = 5) == \"0009030201\"\n assert candidate(s = \"4826093751\",a = 5,b = 10) == \"4321043256\"\n"}, "metadata": {"canonical_parameter_names": ["s", "a", "b"], "leetcode_dataset_entry_point": "Solution().findLexSmallestString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string findLexSmallestString(string s, int a, int b) {", "container": "Solution", "callable": "findLexSmallestString", "parameters": [{"name": "s", "type": "string"}, {"name": "a", "type": "int"}, {"name": "b", "type": "int"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1626, "task_id": "best-team-with-no-conflicts", "difficulty": "Medium", "problem_description": "You are the manager of a basketball team. For the upcoming tournament, you want to choose the team with the highest overall score. The score of the team is the sum of scores of all the players in the team.\nHowever, the basketball team is not allowed to have conflicts. A conflict exists if a younger player has a strictly higher score than an older player. A conflict does not occur between players of the same age.\nGiven two lists, scores and ages, where each scores[i] and ages[i] represents the score and age of the ith player, respectively, return the highest overall score of all possible basketball teams.\n \nExample 1:\n\nInput: scores = [1,3,5,10,15], ages = [1,2,3,4,5]\nOutput: 34\nExplanation: You can choose all the players.\n\nExample 2:\n\nInput: scores = [4,5,6,5], ages = [2,1,2,1]\nOutput: 16\nExplanation: It is best to choose the last 3 players. Notice that you are allowed to choose multiple people of the same age.\n\nExample 3:\n\nInput: scores = [1,2,3,5], ages = [8,9,10,1]\nOutput: 6\nExplanation: It is best to choose the first 3 players. \n\n \nConstraints:\n\n1 <= scores.length, ages.length <= 1000\nscores.length == ages.length\n1 <= scores[i] <= 106\n1 <= ages[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(scores = [1000000, 999999, 999998],ages = [1, 2, 3]) == 1000000\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(scores = [50, 50, 50, 50],ages = [1, 2, 3, 4]) == 200\n assert candidate(scores = [10, 22, 35, 47, 55, 65],ages = [16, 19, 22, 25, 28, 31]) == 234\n assert candidate(scores = [5, 5, 5, 5],ages = [1, 2, 3, 4]) == 20\n assert candidate(scores = [1, 1, 1, 1, 1],ages = [1, 1, 1, 1, 1]) == 5\n assert candidate(scores = [100000, 100000, 100000],ages = [1000, 1000, 1000]) == 300000\n assert candidate(scores = [100, 200, 300, 400],ages = [4, 3, 2, 1]) == 400\n assert candidate(scores = [4, 5, 6, 5],ages = [2, 1, 2, 1]) == 16\n assert candidate(scores = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 50\n assert candidate(scores = [1, 2, 3, 5],ages = [8, 9, 10, 1]) == 6\n assert candidate(scores = [10, 9, 8, 7],ages = [1, 2, 3, 4]) == 10\n assert candidate(scores = [5, 3, 7, 5, 2],ages = [5, 4, 8, 5, 2]) == 22\n assert candidate(scores = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(scores = [1000000, 1000000, 1000000],ages = [1, 1, 1]) == 3000000\n assert candidate(scores = [1, 3, 5, 10, 15],ages = [1, 2, 3, 4, 5]) == 34\n assert candidate(scores = [1, 2, 2, 1],ages = [3, 1, 1, 3]) == 4\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 30\n assert candidate(scores = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 550\n assert candidate(scores = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 150\n assert candidate(scores = [100, 90, 80, 70, 60],ages = [18, 17, 16, 15, 14]) == 400\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],ages = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 550\n assert candidate(scores = [90, 85, 90, 100, 105, 110, 105, 115, 120],ages = [25, 30, 25, 30, 35, 40, 45, 50, 55]) == 730\n assert candidate(scores = [2, 5, 3, 1, 4],ages = [1, 2, 3, 4, 5]) == 9\n assert candidate(scores = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(scores = [20, 30, 20, 30, 20],ages = [2, 2, 3, 3, 4]) == 80\n assert candidate(scores = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 36\n assert candidate(scores = [10, 5, 7, 1, 9, 6, 8, 3, 4, 2],ages = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 55\n assert candidate(scores = [10, 20, 30, 20, 10, 40, 50],ages = [1, 2, 3, 1, 2, 3, 4]) == 170\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(scores = [25, 30, 5, 50, 40, 60, 70, 10, 80, 90],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 405\n assert candidate(scores = [4, 10, 4, 3, 8, 9],ages = [4, 1, 2, 4, 3, 1]) == 19\n assert candidate(scores = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6],ages = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6]) == 45\n assert candidate(scores = [5, 10, 15, 20, 25, 30, 35, 40],ages = [1, 3, 2, 5, 4, 7, 6, 8]) == 120\n assert candidate(scores = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],ages = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 55\n assert candidate(scores = [40, 20, 30, 10, 50],ages = [2, 1, 3, 4, 5]) == 110\n assert candidate(scores = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5500\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],ages = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 45\n assert candidate(scores = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],ages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 605\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],ages = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == 55\n assert candidate(scores = [10, 20, 30, 25, 40],ages = [4, 3, 5, 2, 6]) == 95\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],ages = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 550\n assert candidate(scores = [20, 30, 25, 20, 40, 35, 30, 45, 50, 60],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 245\n assert candidate(scores = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1000000000\n assert candidate(scores = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],ages = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1000\n assert candidate(scores = [10, 6, 5, 7, 3, 8],ages = [4, 3, 2, 4, 1, 5]) == 31\n assert candidate(scores = [8, 5, 6, 10, 7, 9, 4, 2, 11, 3],ages = [8, 6, 6, 9, 7, 8, 5, 4, 10, 3]) == 63\n assert candidate(scores = [1000, 500, 250, 750, 100],ages = [20, 25, 30, 35, 40]) == 1250\n assert candidate(scores = [4, 1, 3, 2, 5],ages = [2, 1, 2, 3, 1]) == 8\n assert candidate(scores = [10, 20, 30, 40, 50],ages = [10, 20, 30, 40, 50]) == 150\n assert candidate(scores = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60],ages = [1, 2, 1, 3, 2, 4, 3, 5, 4, 5]) == 310\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],ages = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n assert candidate(scores = [10, 9, 2, 5, 3, 7, 1, 8, 6, 4],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 22\n assert candidate(scores = [1000000, 100000, 10000, 1000, 100, 10, 1],ages = [1, 2, 3, 4, 5, 6, 7]) == 1000000\n assert candidate(scores = [10, 20, 30, 40, 50],ages = [3, 2, 1, 2, 3]) == 120\n assert candidate(scores = [9, 2, 8, 5, 7, 6, 3, 4, 1, 10],ages = [4, 1, 6, 3, 5, 4, 2, 3, 1, 7]) == 46\n assert candidate(scores = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(scores = [100, 200, 300, 400, 500],ages = [5, 4, 3, 2, 1]) == 500\n assert candidate(scores = [100, 200, 300, 200, 100],ages = [1, 2, 3, 4, 5]) == 600\n assert candidate(scores = [9, 8, 7, 6, 5, 4, 3, 2, 1],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 45\n assert candidate(scores = [20, 10, 20, 10, 20, 10, 20, 10, 20, 10],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(scores = [4, 5, 6, 5, 7, 8, 6, 9],ages = [2, 1, 2, 1, 3, 4, 3, 5]) == 46\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],ages = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 550\n assert candidate(scores = [20, 30, 10, 40, 50],ages = [10, 10, 10, 10, 10]) == 150\n assert candidate(scores = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 50\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(scores = [9, 2, 8, 8, 8, 2, 1, 1, 1, 4],ages = [6, 2, 4, 7, 7, 2, 2, 2, 4, 3]) == 34\n assert candidate(scores = [8, 2, 7, 5, 4, 3, 9],ages = [2, 3, 1, 2, 3, 4, 5]) == 24\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(scores = [1, 2, 3, 2, 1, 4, 5, 4, 3, 2, 1],ages = [1, 2, 3, 2, 1, 4, 5, 4, 3, 2, 1]) == 28\n assert candidate(scores = [15, 20, 5, 10, 25, 30],ages = [5, 5, 2, 3, 5, 5]) == 105\n assert candidate(scores = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(scores = [5, 10, 15, 20, 25, 30, 35],ages = [20, 20, 20, 20, 20, 20, 20]) == 140\n assert candidate(scores = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 95\n assert candidate(scores = [8, 6, 7, 5, 3, 0, 9],ages = [1, 2, 2, 3, 3, 3, 4]) == 22\n assert candidate(scores = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 550\n assert candidate(scores = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],ages = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5]) == 20\n assert candidate(scores = [3, 10, 2, 1, 5, 7, 8, 6, 4, 9],ages = [1, 3, 2, 4, 2, 2, 3, 2, 2, 1]) == 43\n assert candidate(scores = [50, 40, 30, 20, 10, 100, 90, 80, 70, 60],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 150\n assert candidate(scores = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 275\n assert candidate(scores = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(scores = [10, 20, 20, 10, 30, 30, 40, 40],ages = [1, 1, 2, 2, 3, 3, 4, 4]) == 190\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 12\n assert candidate(scores = [10, 20, 20, 10, 30],ages = [1, 2, 3, 4, 5]) == 80\n assert candidate(scores = [1000, 1000, 1000, 1000, 1000],ages = [1, 1, 1, 1, 1]) == 5000\n assert candidate(scores = [30, 10, 20, 40, 50, 15, 25, 35, 45, 55],ages = [3, 1, 2, 4, 5, 1, 2, 3, 4, 5]) == 325\n assert candidate(scores = [50, 40, 30, 20, 10],ages = [1, 1, 1, 1, 1]) == 150\n assert candidate(scores = [1, 3, 2, 5, 4, 6, 7, 8, 9, 10],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(scores = [20, 20, 20, 20, 20],ages = [1, 2, 3, 4, 5]) == 100\n assert candidate(scores = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(scores = [5, 4, 3, 2, 1],ages = [1, 1, 1, 1, 1]) == 15\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 550\n assert candidate(scores = [100, 200, 150, 100, 50, 250],ages = [5, 4, 3, 2, 1, 6]) == 750\n assert candidate(scores = [3, 1, 2],ages = [1, 1, 1]) == 6\n assert candidate(scores = [3, 2, 3, 2, 3, 2, 3, 2, 3, 2],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 25\n assert candidate(scores = [4, 1, 6, 2, 5, 3],ages = [2, 1, 3, 1, 2, 3]) == 18\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 30\n assert candidate(scores = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],ages = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 20\n assert candidate(scores = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],ages = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 54\n assert candidate(scores = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2],ages = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 11\n assert candidate(scores = [15, 30, 10, 20, 50],ages = [5, 10, 15, 20, 25]) == 95\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],ages = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == 350\n assert candidate(scores = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50],ages = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == 200\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],ages = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 55\n assert candidate(scores = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],ages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1000000\n assert candidate(scores = [20, 10, 30, 40, 50, 60, 70, 80, 90, 100],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 540\n assert candidate(scores = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 26\n assert candidate(scores = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 165\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 65\n assert candidate(scores = [2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1],ages = [2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1]) == 75\n assert candidate(scores = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(scores = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],ages = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6]) == 23\n assert candidate(scores = [1000, 500, 200, 1000, 1000, 500, 200],ages = [2, 1, 3, 2, 3, 1, 3]) == 4000\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(scores = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 22\n assert candidate(scores = [100, 200, 300, 400, 500, 150, 250, 350, 450, 550],ages = [10, 9, 8, 7, 6, 1, 2, 3, 4, 5]) == 1750\n assert candidate(scores = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 550\n assert candidate(scores = [10, 20, 30, 40, 50],ages = [1, 3, 2, 5, 4]) == 90\n assert candidate(scores = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 50\n assert candidate(scores = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(scores = [4, 10, 10, 6, 7, 1, 9],ages = [4, 1, 4, 2, 2, 3, 6]) == 23\n assert candidate(scores = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],ages = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == 30\n assert candidate(scores = [1, 2, 3, 4, 5],ages = [5, 4, 3, 2, 1]) == 5\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 550\n assert candidate(scores = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(scores = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],ages = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 275\n assert candidate(scores = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],ages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 550\n assert candidate(scores = [5, 4, 3, 2, 1],ages = [1, 2, 3, 4, 5]) == 5\n assert candidate(scores = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 220\n assert candidate(scores = [100, 90, 80, 70, 60],ages = [5, 4, 3, 2, 1]) == 400\n assert candidate(scores = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20],ages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 200\n assert candidate(scores = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],ages = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 1]) == 19\n assert candidate(scores = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],ages = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1998046\n"}, "metadata": {"canonical_parameter_names": ["scores", "ages"], "leetcode_dataset_entry_point": "Solution().bestTeamScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int bestTeamScore(vector& scores, vector& ages) {", "container": "Solution", "callable": "bestTeamScore", "parameters": [{"name": "scores", "type": "vector&"}, {"name": "ages", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1627, "task_id": "graph-connectivity-with-threshold", "difficulty": "Hard", "problem_description": "We have n cities labeled from 1 to n. Two different cities with labels x and y are directly connected by a bidirectional road if and only if x and y share a common divisor strictly greater than some threshold. More formally, cities with labels x and y have a road between them if there exists an integer z such that all of the following are true:\n\nx % z == 0,\ny % z == 0, and\nz > threshold.\n\nGiven the two integers, n and threshold, and an array of queries, you must determine for each queries[i] = [ai, bi] if cities ai and bi are connected directly or indirectly. (i.e. there is some path between them).\nReturn an array answer, where answer.length == queries.length and answer[i] is true if for the ith query, there is a path between ai and bi, or answer[i] is false if there is no path.\n \nExample 1:\n\n\nInput: n = 6, threshold = 2, queries = [[1,4],[2,5],[3,6]]\nOutput: [false,false,true]\nExplanation: The divisors for each number:\n1: 1\n2: 1, 2\n3: 1, 3\n4: 1, 2, 4\n5: 1, 5\n6: 1, 2, 3, 6\nUsing the underlined divisors above the threshold, only cities 3 and 6 share a common divisor, so they are the\nonly ones directly connected. The result of each query:\n[1,4] 1 is not connected to 4\n[2,5] 2 is not connected to 5\n[3,6] 3 is connected to 6 through path 3--6\n\nExample 2:\n\n\nInput: n = 6, threshold = 0, queries = [[4,5],[3,4],[3,2],[2,6],[1,3]]\nOutput: [true,true,true,true,true]\nExplanation: The divisors for each number are the same as the previous example. However, since the threshold is 0,\nall divisors can be used. Since all numbers share 1 as a divisor, all cities are connected.\n\nExample 3:\n\n\nInput: n = 5, threshold = 1, queries = [[4,5],[4,5],[3,2],[2,3],[3,4]]\nOutput: [false,false,false,false,false]\nExplanation: Only cities 2 and 4 share a common divisor 2 which is strictly greater than the threshold 1, so they are the only ones directly connected.\nPlease notice that there can be multiple queries for the same pair of nodes [x, y], and that the query [x, y] is equivalent to the query [y, x].\n\n \nConstraints:\n\n2 <= n <= 104\n0 <= threshold <= n\n1 <= queries.length <= 105\nqueries[i].length == 2\n1 <= ai, bi <= cities\nai != bi\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,threshold = 0,queries = [[4, 5], [3, 4], [3, 2], [2, 6], [1, 3]]) == [True, True, True, True, True]\n assert candidate(n = 10,threshold = 3,queries = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == [False, False, False, False, False]\n assert candidate(n = 100,threshold = 50,queries = [[1, 2], [51, 100], [49, 99]]) == [False, False, False]\n assert candidate(n = 6,threshold = 2,queries = [[1, 4], [2, 5], [3, 6]]) == [False, False, True]\n assert candidate(n = 5,threshold = 1,queries = [[4, 5], [4, 5], [3, 2], [2, 3], [3, 4]]) == [False, False, False, False, False]\n assert candidate(n = 100,threshold = 50,queries = [[1, 99], [2, 98], [3, 97], [4, 96]]) == [False, False, False, False]\n assert candidate(n = 3000,threshold = 1500,queries = [[1501, 2250], [1502, 2251], [1503, 2252], [1504, 2253], [1505, 2254], [1506, 2255], [1507, 2256], [1508, 2257], [1509, 2258], [1510, 2259]]) == [False, False, False, False, False, False, False, False, False, False]\n assert candidate(n = 10000,threshold = 1000,queries = [[1, 2000], [3000, 4000], [5000, 6000], [7000, 8000], [9000, 10000]]) == [False, True, True, True, True]\n assert candidate(n = 50,threshold = 5,queries = [[6, 12], [10, 20], [14, 28], [18, 36], [22, 44]]) == [True, True, True, True, True]\n assert candidate(n = 999,threshold = 333,queries = [[1, 334], [2, 335], [3, 336], [4, 337], [5, 338], [6, 339]]) == [False, False, False, False, False, False]\n assert candidate(n = 100,threshold = 0,queries = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96]]) == [True, True, True, True, True]\n assert candidate(n = 5000,threshold = 1000,queries = [[1000, 2000], [3000, 4000], [4999, 5000]]) == [False, False, False]\n assert candidate(n = 100,threshold = 25,queries = [[26, 52], [27, 54], [28, 56], [29, 58], [30, 60]]) == [True, True, True, True, True]\n assert candidate(n = 1000,threshold = 1,queries = [[2, 4], [3, 6], [5, 10], [7, 14], [8, 16], [9, 18], [10, 20], [11, 22], [12, 24], [13, 26]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10000,threshold = 5000,queries = [[1, 6000], [2, 6001], [3, 6002], [4, 6003], [5, 6004], [6, 6005]]) == [False, False, False, False, False, False]\n assert candidate(n = 1000,threshold = 250,queries = [[150, 300], [200, 400], [500, 750], [800, 900], [100, 900]]) == [False, False, False, False, False]\n assert candidate(n = 1000,threshold = 250,queries = [[1, 500], [2, 501], [3, 502], [4, 503], [5, 504], [6, 505]]) == [False, False, False, False, False, False]\n assert candidate(n = 10000,threshold = 9999,queries = [[1, 10000], [2, 9999], [3, 9998], [4, 9997]]) == [False, False, False, False]\n assert candidate(n = 500,threshold = 250,queries = [[251, 500], [252, 499], [253, 498], [254, 497], [255, 496], [256, 495]]) == [False, False, False, False, False, False]\n assert candidate(n = 10000,threshold = 5000,queries = [[1000, 9000], [5000, 6000], [1, 2], [9999, 10000]]) == [False, False, False, False]\n assert candidate(n = 5000,threshold = 100,queries = [[100, 200], [50, 150], [300, 600], [1, 2], [4999, 5000]]) == [False, False, True, False, False]\n assert candidate(n = 1000,threshold = 250,queries = [[1, 500], [2, 750], [3, 900], [4, 950], [5, 999]]) == [False, False, False, False, False]\n assert candidate(n = 5000,threshold = 2000,queries = [[1, 3000], [2, 4000], [3, 4500], [4, 4900], [5, 4999]]) == [False, False, False, False, False]\n assert candidate(n = 50,threshold = 10,queries = [[11, 22], [13, 26], [15, 30], [7, 14], [21, 42]]) == [True, True, True, False, True]\n assert candidate(n = 5000,threshold = 250,queries = [[125, 250], [375, 500], [625, 750], [875, 1000], [1125, 1250]]) == [False, True, True, True, True]\n assert candidate(n = 1000,threshold = 200,queries = [[500, 750], [250, 501], [750, 1000], [1, 999]]) == [True, False, True, False]\n assert candidate(n = 10000,threshold = 0,queries = [[1, 9999], [2, 9998], [3, 9997], [4, 9996], [5, 9995], [6, 9994], [7, 9993], [8, 9992], [9, 9991], [10, 9990]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10000,threshold = 5000,queries = [[5100, 9900], [5200, 9800], [5300, 9700], [5400, 9600], [5500, 9500]]) == [False, False, False, False, False]\n assert candidate(n = 5000,threshold = 1000,queries = [[1200, 2400], [1500, 3000], [2500, 4000], [3500, 4500], [1000, 4000]]) == [True, True, False, False, False]\n assert candidate(n = 1000,threshold = 5,queries = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996]]) == [False, False, False, False, False]\n assert candidate(n = 100,threshold = 10,queries = [[1, 11], [2, 12], [3, 13], [4, 14], [5, 15]]) == [False, False, False, False, False]\n assert candidate(n = 1000,threshold = 50,queries = [[1, 50], [2, 50], [3, 50], [4, 50], [5, 50], [6, 50], [7, 50], [8, 50]]) == [False, False, False, False, False, False, False, False]\n assert candidate(n = 5000,threshold = 2500,queries = [[1, 2501], [1000, 3000], [2500, 5000]]) == [False, False, False]\n assert candidate(n = 2000,threshold = 100,queries = [[100, 200], [300, 400], [500, 600], [700, 800], [900, 1000], [1100, 1200], [1300, 1400], [1500, 1600], [1700, 1800], [1900, 2000]]) == [False, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 100,threshold = 20,queries = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]]) == [False, False, False, False, False]\n assert candidate(n = 20,threshold = 19,queries = [[1, 20], [2, 19], [3, 18], [4, 17], [5, 16]]) == [False, False, False, False, False]\n assert candidate(n = 2000,threshold = 1000,queries = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == [False, False, False, False, False]\n assert candidate(n = 5000,threshold = 1000,queries = [[2000, 3000], [1001, 2001], [4000, 5000], [999, 4999]]) == [False, False, False, False]\n assert candidate(n = 8000,threshold = 4000,queries = [[4001, 8000], [4002, 7999], [4003, 7998], [4004, 7997], [4005, 7996], [4006, 7995]]) == [False, False, False, False, False, False]\n assert candidate(n = 2000,threshold = 100,queries = [[50, 150], [100, 200], [150, 250], [200, 300], [250, 350], [300, 400], [350, 450], [400, 500], [450, 550], [500, 600]]) == [False, False, True, True, True, True, True, True, True, True]\n assert candidate(n = 1000,threshold = 5,queries = [[1, 3], [2, 4], [5, 7], [8, 10], [11, 13], [14, 16], [17, 19], [20, 22], [23, 25], [26, 28], [29, 31], [32, 34], [35, 37], [38, 40], [41, 43], [44, 46], [47, 49], [50, 52], [53, 55], [56, 58], [59, 61], [62, 64], [65, 67], [68, 70], [71, 73], [74, 76], [77, 79], [80, 82], [83, 85], [86, 88], [89, 91], [92, 94], [95, 97], [98, 100]]) == [False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10000,threshold = 50,queries = [[51, 101], [52, 102], [53, 103], [54, 104], [55, 105], [56, 106], [57, 107], [58, 108], [59, 109], [60, 110]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10000,threshold = 1,queries = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == [False, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 1000,threshold = 500,queries = [[10, 20], [30, 50], [25, 75], [500, 1000], [999, 1000]]) == [False, False, False, False, False]\n assert candidate(n = 1000,threshold = 50,queries = [[51, 100], [52, 99], [53, 98], [54, 97], [55, 96], [56, 95], [57, 94], [58, 93], [59, 92], [60, 91]]) == [True, True, False, False, True, True, False, False, False, True]\n assert candidate(n = 8000,threshold = 4000,queries = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == [False, False, False, False, False]\n assert candidate(n = 3000,threshold = 1500,queries = [[1501, 2000], [1502, 2500], [1503, 3000], [2000, 3000], [1504, 1505], [1506, 1507]]) == [False, False, False, False, False, False]\n assert candidate(n = 10000,threshold = 2000,queries = [[2001, 4000], [2002, 4001], [2003, 4002], [2004, 4003], [2005, 4004], [2006, 4005], [2007, 4006], [2008, 4007], [2009, 4008], [2010, 4009]]) == [False, False, False, False, False, False, False, False, False, False]\n assert candidate(n = 10000,threshold = 5000,queries = [[1, 7000], [2, 8000], [3, 9000], [4, 9500], [5, 9999]]) == [False, False, False, False, False]\n assert candidate(n = 10000,threshold = 5000,queries = [[1, 5001], [2, 5002], [3, 5003], [4, 5004], [5, 5005]]) == [False, False, False, False, False]\n assert candidate(n = 100,threshold = 99,queries = [[1, 100]]) == [False]\n assert candidate(n = 5000,threshold = 2,queries = [[3, 6], [5, 10], [7, 14], [9, 18], [11, 22], [13, 26], [15, 30], [17, 34], [19, 38], [21, 42]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10000,threshold = 5000,queries = [[5001, 5002], [5003, 5004], [5005, 5006], [5007, 5008], [5009, 5010]]) == [False, False, False, False, False]\n assert candidate(n = 5000,threshold = 2500,queries = [[1, 500], [1000, 1500], [2000, 2500], [3000, 3500], [4000, 4500], [4500, 5000]]) == [False, False, False, False, False, False]\n assert candidate(n = 1000,threshold = 300,queries = [[101, 202], [303, 404], [505, 606], [707, 808], [909, 1000]]) == [False, False, False, False, False]\n assert candidate(n = 100,threshold = 1,queries = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == [False, True, True, True, True]\n assert candidate(n = 2000,threshold = 0,queries = [[1, 1999], [2, 1998], [3, 1997], [4, 1996], [5, 1995], [6, 1994], [7, 1993], [8, 1992], [9, 1991], [10, 1990]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 500,threshold = 250,queries = [[251, 500], [252, 499], [253, 498], [254, 497], [255, 496]]) == [False, False, False, False, False]\n assert candidate(n = 5000,threshold = 2500,queries = [[1, 2501], [2, 2502], [3, 2503], [4, 2504], [5, 2505]]) == [False, False, False, False, False]\n assert candidate(n = 2000,threshold = 1,queries = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == [False, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 150,threshold = 50,queries = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110], [110, 120], [120, 130], [130, 140], [140, 150]]) == [False, False, False, False, False, False, False, False, False, False, False, False, False, False]\n assert candidate(n = 1000,threshold = 0,queries = [[1, 999], [2, 998], [3, 997], [4, 996], [5, 995], [10, 100], [50, 150], [200, 300], [700, 800], [900, 1000]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 500,threshold = 250,queries = [[1, 251], [2, 252], [3, 253], [4, 254], [5, 255], [250, 499], [251, 498], [252, 497], [253, 496], [254, 495]]) == [False, False, False, False, False, False, False, False, False, False]\n"}, "metadata": {"canonical_parameter_names": ["n", "threshold", "queries"], "leetcode_dataset_entry_point": "Solution().areConnected", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector areConnected(int n, int threshold, vector>& queries) {", "container": "Solution", "callable": "areConnected", "parameters": [{"name": "n", "type": "int"}, {"name": "threshold", "type": "int"}, {"name": "queries", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1629, "task_id": "slowest-key", "difficulty": "Easy", "problem_description": "A newly designed keypad was tested, where a tester pressed a sequence of n keys, one at a time.\nYou are given a string keysPressed of length n, where keysPressed[i] was the ith key pressed in the testing sequence, and a sorted list releaseTimes, where releaseTimes[i] was the time the ith key was released. Both arrays are 0-indexed. The 0th key was pressed at the time 0, and every subsequent key was pressed at the exact time the previous key was released.\nThe tester wants to know the key of the keypress that had the longest duration. The ith keypress had a duration of releaseTimes[i] - releaseTimes[i - 1], and the 0th keypress had a duration of releaseTimes[0].\nNote that the same key could have been pressed multiple times during the test, and these multiple presses of the same key may not have had the same duration.\nReturn the key of the keypress that had the longest duration. If there are multiple such keypresses, return the lexicographically largest key of the keypresses.\n \nExample 1:\n\nInput: releaseTimes = [9,29,49,50], keysPressed = \"cbcd\"\nOutput: \"c\"\nExplanation: The keypresses were as follows:\nKeypress for 'c' had a duration of 9 (pressed at time 0 and released at time 9).\nKeypress for 'b' had a duration of 29 - 9 = 20 (pressed at time 9 right after the release of the previous character and released at time 29).\nKeypress for 'c' had a duration of 49 - 29 = 20 (pressed at time 29 right after the release of the previous character and released at time 49).\nKeypress for 'd' had a duration of 50 - 49 = 1 (pressed at time 49 right after the release of the previous character and released at time 50).\nThe longest of these was the keypress for 'b' and the second keypress for 'c', both with duration 20.\n'c' is lexicographically larger than 'b', so the answer is 'c'.\n\nExample 2:\n\nInput: releaseTimes = [12,23,36,46,62], keysPressed = \"spuda\"\nOutput: \"a\"\nExplanation: The keypresses were as follows:\nKeypress for 's' had a duration of 12.\nKeypress for 'p' had a duration of 23 - 12 = 11.\nKeypress for 'u' had a duration of 36 - 23 = 13.\nKeypress for 'd' had a duration of 46 - 36 = 10.\nKeypress for 'a' had a duration of 62 - 46 = 16.\nThe longest of these was the keypress for 'a' with duration 16.\n \nConstraints:\n\nreleaseTimes.length == n\nkeysPressed.length == n\n2 <= n <= 1000\n1 <= releaseTimes[i] <= 109\nreleaseTimes[i] < releaseTimes[i+1]\nkeysPressed contains only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(releaseTimes = [2, 3, 7, 10, 15],keysPressed = \"zzzaa\") == \"a\"\n assert candidate(releaseTimes = [5, 10, 15, 20, 25],keysPressed = \"zabzc\") == \"z\"\n assert candidate(releaseTimes = [5, 15, 25, 35, 45, 55],keysPressed = \"abcdef\") == \"f\"\n assert candidate(releaseTimes = [50, 70, 80, 90],keysPressed = \"abcd\") == \"a\"\n assert candidate(releaseTimes = [9, 29, 49, 50],keysPressed = \"cbcd\") == \"c\"\n assert candidate(releaseTimes = [10, 15, 20, 25, 30],keysPressed = \"aabcd\") == \"a\"\n assert candidate(releaseTimes = [12, 23, 36, 46, 62],keysPressed = \"spuda\") == \"a\"\n assert candidate(releaseTimes = [1, 2, 3, 4, 5],keysPressed = \"abcde\") == \"e\"\n assert candidate(releaseTimes = [50, 75, 100, 125, 150],keysPressed = \"zzzzz\") == \"z\"\n assert candidate(releaseTimes = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],keysPressed = \"qwertyuiopz\") == \"z\"\n assert candidate(releaseTimes = [100, 200, 300, 400, 500],keysPressed = \"aaaaa\") == \"a\"\n assert candidate(releaseTimes = [2, 5, 10, 15, 20, 25, 30],keysPressed = \"zzzzzz\") == \"z\"\n assert candidate(releaseTimes = [1, 3, 5, 7, 9],keysPressed = \"abcde\") == \"e\"\n assert candidate(releaseTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],keysPressed = \"abcdefghij\") == \"j\"\n assert candidate(releaseTimes = [100, 200, 300, 400],keysPressed = \"abcd\") == \"d\"\n assert candidate(releaseTimes = [10, 20, 30, 40, 50],keysPressed = \"aaaaa\") == \"a\"\n assert candidate(releaseTimes = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41],keysPressed = \"abcdefghijk\") == \"k\"\n assert candidate(releaseTimes = [5, 10, 15, 20, 25, 30],keysPressed = \"ppppp\") == \"p\"\n assert candidate(releaseTimes = [10, 20, 30, 40],keysPressed = \"abcd\") == \"d\"\n assert candidate(releaseTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],keysPressed = \"abcdefghijklmnopqrstuvwxyz\") == \"z\"\n assert candidate(releaseTimes = [10, 30, 70, 150, 230, 320, 420, 530, 650, 780, 920, 1080, 1260, 1460, 1680, 1920],keysPressed = \"zzzzzzzzzzzzzzzz\") == \"z\"\n assert candidate(releaseTimes = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496, 528, 561, 595, 630, 666, 703, 741, 780, 820, 861, 903, 946, 990, 1035, 1081, 1128, 1176, 1225, 1275, 1326, 1378, 1431, 1485, 1540, 1596, 1653, 1711, 1770, 1830, 1891, 1953, 2016, 2080, 2145, 2211, 2278, 2346, 2415, 2485, 2556, 2628, 2701, 2775, 2850, 2926, 3003, 3081, 3160, 3240, 3321, 3403, 3486, 3570, 3655, 3741, 3828, 3916, 4005, 4095, 4186, 4278, 4371, 4465, 4560, 4656, 4753, 4851, 4950],keysPressed = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == \"a\"\n assert candidate(releaseTimes = [10, 25, 40, 55, 70, 85, 100, 115, 130, 145, 160, 175, 190, 205, 220, 235, 250, 265, 280, 295, 310, 325, 340, 355, 370, 385, 400, 415, 430, 445],keysPressed = \"zyxwvutsrqponmlkjihgfedcba\") == \"y\"\n assert candidate(releaseTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],keysPressed = \"abcdefghijklmno\") == \"o\"\n assert candidate(releaseTimes = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],keysPressed = \"zzzzzzzzzzzzzzzzzzzz\") == \"z\"\n assert candidate(releaseTimes = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300],keysPressed = \"nopqrstuvwxyz\") == \"z\"\n assert candidate(releaseTimes = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155],keysPressed = \"abcdefghijklmno\") == \"a\"\n assert candidate(releaseTimes = [10, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145],keysPressed = \"abcdefghijklmn\") == \"b\"\n assert candidate(releaseTimes = [20, 45, 60, 80, 100, 120, 140, 160, 180, 200],keysPressed = \"abcdefghij\") == \"b\"\n assert candidate(releaseTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60],keysPressed = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"z\"\n assert candidate(releaseTimes = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62, 65, 68, 71, 74, 77, 80, 83, 86, 89, 92, 95, 98, 101, 104, 107, 110, 113, 116, 119, 122, 125, 128, 131, 134, 137, 140, 143, 146, 149, 152, 155, 158, 161, 164, 167, 170, 173, 176, 179, 182, 185, 188, 191, 194, 197, 200],keysPressed = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"z\"\n assert candidate(releaseTimes = [5, 15, 30, 45, 60, 75, 90, 105, 120, 135],keysPressed = \"abcdefghij\") == \"j\"\n assert candidate(releaseTimes = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200, 205, 210, 215, 220, 225, 230, 235, 240, 245, 250, 255, 260, 265, 270, 275, 280, 285, 290, 295, 300],keysPressed = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == \"a\"\n assert candidate(releaseTimes = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],keysPressed = \"zzzzzzzzzzzzzzz\") == \"z\"\n assert candidate(releaseTimes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],keysPressed = \"abcdefghijklmnopqrst\") == \"t\"\n assert candidate(releaseTimes = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600],keysPressed = \"zyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyz\") == \"z\"\n assert candidate(releaseTimes = [5, 9, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253],keysPressed = \"mississippiissiippi\") == \"i\"\n assert candidate(releaseTimes = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000],keysPressed = \"abcdefghijklmnopqrst\") == \"t\"\n"}, "metadata": {"canonical_parameter_names": ["releaseTimes", "keysPressed"], "leetcode_dataset_entry_point": "Solution().slowestKey", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "char slowestKey(vector& releaseTimes, string keysPressed) {", "container": "Solution", "callable": "slowestKey", "parameters": [{"name": "releaseTimes", "type": "vector&"}, {"name": "keysPressed", "type": "string"}], "return_type": "char", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1630, "task_id": "arithmetic-subarrays", "difficulty": "Medium", "problem_description": "A sequence of numbers is called arithmetic if it consists of at least two elements, and the difference between every two consecutive elements is the same. More formally, a sequence s is arithmetic if and only if s[i+1] - s[i] == s[1] - s[0] for all valid i.\nFor example, these are arithmetic sequences:\n\n1, 3, 5, 7, 9\n7, 7, 7, 7\n3, -1, -5, -9\nThe following sequence is not arithmetic:\n\n1, 1, 2, 5, 7\nYou are given an array of n integers, nums, and two arrays of m integers each, l and r, representing the m range queries, where the ith query is the range [l[i], r[i]]. All the arrays are 0-indexed.\nReturn a list of boolean elements answer, where answer[i] is true if the subarray nums[l[i]], nums[l[i]+1], ... , nums[r[i]] can be rearranged to form an arithmetic sequence, and false otherwise.\n \nExample 1:\n\nInput: nums = [4,6,5,9,3,7], l = [0,0,2], r = [2,3,5]\nOutput: [true,false,true]\nExplanation:\nIn the 0th query, the subarray is [4,6,5]. This can be rearranged as [6,5,4], which is an arithmetic sequence.\nIn the 1st query, the subarray is [4,6,5,9]. This cannot be rearranged as an arithmetic sequence.\nIn the 2nd query, the subarray is [5,9,3,7]. This can be rearranged as [3,5,7,9], which is an arithmetic sequence.\nExample 2:\n\nInput: nums = [-12,-9,-3,-12,-6,15,20,-25,-20,-15,-10], l = [0,1,6,4,8,7], r = [4,4,9,7,9,10]\nOutput: [false,true,false,false,true,true]\n\n \nConstraints:\n\nn == nums.length\nm == l.length\nm == r.length\n2 <= n <= 500\n1 <= m <= 500\n0 <= l[i] < r[i] < n\n-105 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 1, 1, 1],l = [0, 0, 2, 3],r = [1, 2, 4, 4]) == [True, True, True, True]\n assert candidate(nums = [5, 5, 5, 5, 5],l = [0, 1, 2],r = [1, 2, 3]) == [True, True, True]\n assert candidate(nums = [0, 3, 5, 7, 9],l = [0, 1, 2],r = [1, 2, 3]) == [True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5],l = [0, 1, 2],r = [1, 2, 4]) == [True, True, True]\n assert candidate(nums = [0, 5, 10, 15, 20],l = [0, 0, 1, 2],r = [2, 3, 3, 4]) == [True, True, True, True]\n assert candidate(nums = [-12, -9, -3, -12, -6, 15, 20, -25, -20, -15, -10],l = [0, 1, 6, 4, 8, 7],r = [4, 4, 9, 7, 9, 10]) == [False, True, False, False, True, True]\n assert candidate(nums = [1, 2, 3, 5, 6],l = [0, 2],r = [2, 4]) == [True, False]\n assert candidate(nums = [10, 9, 8, 7, 6],l = [0, 1, 2],r = [1, 2, 4]) == [True, True, True]\n assert candidate(nums = [1, 2, 4, 6, 8, 10],l = [0, 1, 2],r = [1, 2, 3]) == [True, True, True]\n assert candidate(nums = [5, 3, 1, 7, 9],l = [0, 1, 2],r = [1, 2, 4]) == [True, True, False]\n assert candidate(nums = [1, 2, 4, 6, 8],l = [0, 1, 2, 3],r = [2, 3, 4, 4]) == [False, True, True, True]\n assert candidate(nums = [1, 1, 2, 5, 7],l = [0, 2, 3],r = [2, 3, 4]) == [False, True, True]\n assert candidate(nums = [1, 2, 4, 6, 8],l = [0, 1, 2],r = [1, 2, 4]) == [True, True, True]\n assert candidate(nums = [4, 6, 5, 9, 3, 7],l = [0, 0, 2],r = [2, 3, 5]) == [True, False, True]\n assert candidate(nums = [10, 5, 3, 7, 8],l = [0, 1, 2, 3],r = [1, 2, 3, 4]) == [True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5],l = [0, 1, 2],r = [2, 3, 4]) == [True, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1],l = [0, 1, 2],r = [1, 2, 3]) == [True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5],l = [0, 1, 2],r = [4, 3, 4]) == [True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50],l = [0, 2],r = [1, 3]) == [True, True]\n assert candidate(nums = [1, 1, 1, 1, 1],l = [0, 1, 2],r = [1, 2, 4]) == [True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600],l = [0, 1, 2],r = [2, 3, 4]) == [True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5],l = [0, 1, 2],r = [4, 3, 3]) == [True, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1],l = [0, 1, 2],r = [4, 3, 3]) == [True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5],l = [0, 1],r = [2, 4]) == [True, True]\n assert candidate(nums = [-10, -7, -4, -1, 2, 5, 8, 11],l = [0, 1, 2, 3],r = [2, 4, 6, 7]) == [True, True, True, True]\n assert candidate(nums = [-5, -10, -15, -20, -25, -30],l = [0, 2, 4],r = [1, 3, 5]) == [True, True, True]\n assert candidate(nums = [20, 10, 30, 50, 40, 60, 70, 80, 90, 100],l = [0, 1, 2, 3, 4, 5],r = [2, 4, 6, 8, 9, 9]) == [True, False, True, True, False, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],l = [0, 3, 6, 9, 12],r = [2, 5, 8, 11, 14]) == [True, True, True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],l = [1, 3, 5, 7],r = [8, 9, 8, 9]) == [True, True, True, True]\n assert candidate(nums = [100000, -100000, 50000, -50000, 25000, -25000, 12500, -12500],l = [0, 2, 4, 6],r = [2, 4, 6, 7]) == [False, False, False, True]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],l = [0, 1, 2, 3, 4, 5, 6],r = [1, 2, 3, 4, 5, 6, 9]) == [True, True, True, True, True, True, False]\n assert candidate(nums = [10, 5, 15, 20, 25, 30, 35, 40],l = [1, 0, 2, 5],r = [6, 4, 4, 7]) == [False, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],l = [0, 0, 2, 4, 6, 8],r = [2, 4, 6, 8, 9, 9]) == [True, True, True, True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900],l = [0, 1, 3, 5],r = [2, 4, 6, 8]) == [True, True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],l = [0, 6, 12, 18],r = [5, 11, 17, 19]) == [True, True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],l = [0, 5, 10],r = [4, 9, 12]) == [True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],l = [0, 2, 4, 6, 8, 10],r = [1, 3, 5, 7, 9, 20]) == [True, True, True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],l = [0, 5, 10, 15],r = [4, 9, 14, 19]) == [True, True, True, True]\n assert candidate(nums = [5, 8, 11, 14, 17, 20, 23, 26, 29],l = [0, 2, 5, 6],r = [3, 5, 7, 8]) == [True, True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],l = [0, 3, 6, 9, 1],r = [2, 5, 8, 10, 4]) == [True, True, True, True, True]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],l = [0, 0, 2, 4, 6, 8],r = [2, 4, 6, 8, 9, 9]) == [True, True, True, True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 10]) == [True, True, True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],l = [0, 0, 0, 0],r = [3, 4, 5, 6]) == [True, True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],l = [0, 1, 2, 3, 4],r = [4, 5, 6, 7, 9]) == [True, True, True, True, True]\n assert candidate(nums = [10, 5, 0, -5, -10, -15, -20, -25, -30, -35],l = [0, 0, 0, 0],r = [4, 5, 6, 7]) == [True, True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],l = [0, 1, 2, 3, 4],r = [2, 3, 4, 5, 6]) == [True, True, True, True, True]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77],l = [0, 4, 8, 12, 16],r = [3, 7, 11, 15, 19]) == [True, True, True, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],l = [0, 1, 2, 3, 4, 5, 6, 7, 8],r = [2, 4, 6, 8, 9, 9, 9, 9, 9]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32],l = [0, 3, 6, 9, 12, 15],r = [1, 4, 7, 10, 13, 16]) == [True, True, True, True, True, True]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36],l = [0, 3, 6, 9],r = [2, 5, 8, 11]) == [True, True, True, True]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41],l = [0, 1, 2, 3, 4, 5, 6, 7, 8],r = [1, 2, 3, 4, 5, 6, 7, 8, 10]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 9]) == [True, True, True, True, True]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],l = [0, 2, 4, 6],r = [3, 5, 7, 9]) == [True, True, True, True]\n assert candidate(nums = [5, 3, 1, -1, -3, -5, -7, -9, -11, -13],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 9]) == [True, True, True, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 11]) == [True, True, True, True, True]\n assert candidate(nums = [1, 2, 3, 5, 6, 8, 9, 10],l = [0, 2, 4, 1, 3],r = [1, 5, 7, 7, 6]) == [True, False, False, False, False]\n assert candidate(nums = [5, 8, 1, 3, 4, 9, 10],l = [0, 1, 2, 3],r = [2, 4, 5, 6]) == [False, False, False, False]\n assert candidate(nums = [5, 8, 3, 7, 10, 1, 2, 9, 4, 6],l = [0, 2, 5, 7],r = [3, 7, 9, 9]) == [False, False, False, False]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],l = [0, 1, 2, 3, 4],r = [2, 4, 6, 8, 9]) == [False, False, False, False, False]\n assert candidate(nums = [10, 5, 15, 20, 30, 25, 40, 35, 50, 45],l = [0, 1, 2, 3, 4, 5, 6],r = [3, 5, 7, 9, 9, 9, 9]) == [True, False, True, True, True, False, True]\n assert candidate(nums = [4, 3, 2, 1, 0, -1, -2, -3, -4],l = [0, 3, 4, 5],r = [8, 7, 6, 8]) == [True, True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],l = [0, 1, 2, 3, 4],r = [3, 4, 5, 6, 9]) == [True, True, True, True, True]\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],l = [0, 5, 10, 15, 20],r = [4, 9, 14, 19, 24]) == [False, True, True, True, True]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],l = [0, 1, 2, 3, 4, 5, 6],r = [1, 2, 3, 4, 5, 6, 9]) == [True, True, True, True, True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90],l = [0, 1, 2, 3],r = [1, 2, 3, 8]) == [True, True, True, True]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],l = [0, 1, 2, 3, 4, 5, 6, 7, 8],r = [1, 2, 3, 4, 5, 6, 7, 8, 10]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [-5, -10, -15, -20, -25, -30, -35, -40, -45, -50],l = [0, 1, 2, 3, 4, 5, 6],r = [3, 5, 7, 9, 9, 9, 9]) == [True, True, True, True, True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],l = [0, 2, 4, 6],r = [1, 3, 5, 9]) == [True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],l = [0, 5, 10, 15, 20],r = [4, 9, 14, 19, 24]) == [True, True, True, True, True]\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],l = [0, 5, 10],r = [4, 9, 13]) == [True, True, True]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5],l = [0, 1, 2],r = [1, 2, 3]) == [True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],l = [0, 3, 6, 9, 12],r = [2, 5, 8, 11, 14]) == [True, True, True, True, True]\n assert candidate(nums = [5, 8, 11, 14, 17, 20, 23, 26, 29],l = [0, 3, 6],r = [2, 5, 8]) == [True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],l = [0, 5, 10],r = [4, 9, 14]) == [True, True, True]\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13],l = [0, 2, 4, 6],r = [1, 5, 7, 8]) == [True, False, False, False]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20],l = [0, 5, 10, 15],r = [4, 9, 14, 19]) == [True, True, True, True]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61],l = [0, 3, 6, 9, 12, 15],r = [2, 5, 8, 11, 14, 17]) == [True, True, True, True, True, True]\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],l = [0, 1, 2, 3, 4, 5, 6, 7, 8],r = [1, 2, 3, 4, 5, 6, 7, 8, 10]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4],l = [0, 3, 6],r = [2, 5, 8]) == [True, False, False]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],l = [0, 1, 3, 5, 7],r = [2, 4, 6, 8, 9]) == [True, True, True, True, True]\n assert candidate(nums = [5, 3, 1, -1, -3, -5, -7, -9, -11, -13],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 9]) == [True, True, True, True, True]\n assert candidate(nums = [9, 7, 5, 3, 1, 10, 8, 6, 4, 2],l = [0, 2, 4, 6, 8],r = [2, 4, 6, 8, 9]) == [True, True, False, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1],l = [0, 1, 2, 3],r = [2, 3, 4, 8]) == [True, True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],l = [0, 0, 2, 4, 6, 8],r = [2, 4, 6, 8, 9, 9]) == [True, True, True, True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],l = [0, 4, 6, 8],r = [3, 7, 9, 9]) == [True, True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700],l = [0, 1, 2, 3],r = [1, 2, 3, 4]) == [True, True, True, True]\n assert candidate(nums = [2, 10, 4, 5, 7, 6, 9],l = [0, 1, 2, 3, 4],r = [2, 3, 5, 5, 6]) == [False, False, True, True, False]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],l = [0, 1, 2, 3, 4],r = [1, 2, 3, 4, 9]) == [True, True, True, True, True]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],l = [0, 5, 2, 8],r = [4, 10, 6, 10]) == [True, True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 9]) == [True, True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],l = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24],r = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == [True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],l = [0, 2, 4, 6],r = [3, 5, 7, 8]) == [True, True, True, True]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90],l = [0, 4, 8, 12, 16],r = [3, 7, 11, 15, 18]) == [True, True, True, True, False]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90],l = [0, 1, 2, 3, 4, 5],r = [1, 2, 3, 4, 5, 8]) == [True, True, True, True, True, True]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35],l = [0, 2, 4],r = [2, 4, 6]) == [True, True, True]\n assert candidate(nums = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28],l = [0, 2, 4, 6],r = [1, 3, 5, 9]) == [True, True, True, True]\n assert candidate(nums = [-100000, -99999, -99998, -99997, -99996, -99995, -99994, -99993, -99992, -99991],l = [0, 1, 2, 3, 4, 5, 6, 7],r = [1, 2, 3, 4, 5, 6, 7, 9]) == [True, True, True, True, True, True, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 9]) == [True, True, True, True, True]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],l = [0, 1, 2, 3, 4, 5, 6, 7, 8],r = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66],l = [0, 1, 2, 3, 4, 5, 6, 7, 8],r = [1, 2, 3, 4, 5, 6, 7, 8, 10]) == [True, True, True, True, True, True, True, True, False]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17],l = [0, 2, 4, 6],r = [2, 4, 6, 8]) == [True, True, True, True]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],l = [0, 5, 10, 15],r = [4, 9, 14, 19]) == [False, False, False, False]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 9]) == [True, True, True, True, True]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],l = [0, 1, 2, 3, 4, 5, 6, 7, 8],r = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],l = [0, 5, 7, 9],r = [4, 9, 10, 11]) == [True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],l = [0, 1, 2, 3, 4, 5, 6],r = [1, 2, 3, 4, 5, 6, 14]) == [True, True, True, True, True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],l = [0, 2, 4, 6],r = [1, 3, 5, 7]) == [True, True, True, True]\n assert candidate(nums = [10, 5, 15, 20, 25, 30, 35],l = [0, 2, 4],r = [4, 5, 6]) == [True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],l = [0, 2, 4, 6, 8],r = [1, 4, 7, 9, 9]) == [True, True, True, True, True]\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],l = [0, 2, 4, 6, 8],r = [2, 4, 6, 8, 9]) == [False, False, False, False, True]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25],l = [0, 1, 2, 3],r = [1, 2, 3, 6]) == [True, True, True, True]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],l = [0, 3, 6, 9, 12],r = [2, 5, 8, 11, 14]) == [True, True, True, True, True]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],l = [0, 1, 2, 3, 4, 5],r = [1, 2, 3, 4, 5, 9]) == [True, True, True, True, True, True]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],l = [0, 2, 4, 6],r = [2, 4, 6, 8]) == [True, True, True, True]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],l = [0, 5, 10, 15],r = [4, 9, 14, 19]) == [True, True, True, True]\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10],l = [0, 2, 4, 6],r = [1, 5, 7, 9]) == [True, True, True, True]\n assert candidate(nums = [5, 1, 3, 2, 4, 6, 8, 7, 9, 10],l = [0, 2, 4, 6, 8],r = [2, 4, 6, 8, 9]) == [True, True, True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 9]) == [True, True, True, True, True]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800],l = [0, 1, 2, 3, 4],r = [1, 3, 5, 7, 7]) == [True, True, True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],l = [0, 2, 4, 6, 8, 10],r = [1, 3, 5, 7, 9, 11]) == [True, True, True, True, True, True]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25],l = [0, 3, 5],r = [2, 5, 6]) == [True, True, True]\n assert candidate(nums = [-10, 0, 10, 20, 30, -20, -30],l = [0, 3, 4],r = [2, 5, 6]) == [True, False, False]\n assert candidate(nums = [1, 2, 3, 6, 5, 4, 9, 8, 7, 12, 11, 10],l = [0, 3, 6, 9],r = [2, 5, 8, 11]) == [True, True, True, True]\n assert candidate(nums = [1, 2, 3, 6, 5, 4, 7, 8, 9],l = [0, 1, 3],r = [2, 5, 8]) == [True, True, True]\n assert candidate(nums = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16],l = [0, 2, 4, 6, 8],r = [1, 3, 5, 7, 10]) == [True, True, True, True, False]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],l = [0, 7, 12],r = [6, 11, 14]) == [True, True, True]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],l = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],r = [1, 2, 3, 4, 5, 6, 7, 8, 9, 19]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21],l = [0, 1, 2, 3, 4],r = [1, 2, 3, 4, 6]) == [True, True, True, True, True]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],l = [0, 3, 6, 9],r = [2, 5, 8, 10]) == [True, True, True, True]\n"}, "metadata": {"canonical_parameter_names": ["nums", "l", "r"], "leetcode_dataset_entry_point": "Solution().checkArithmeticSubarrays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector checkArithmeticSubarrays(vector& nums, vector& l, vector& r) {", "container": "Solution", "callable": "checkArithmeticSubarrays", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "l", "type": "vector&"}, {"name": "r", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1631, "task_id": "path-with-minimum-effort", "difficulty": "Medium", "problem_description": "You are a hiker preparing for an upcoming hike. You are given heights, a 2D array of size rows x columns, where heights[row][col] represents the height of cell (row, col). You are situated in the top-left cell, (0, 0), and you hope to travel to the bottom-right cell, (rows-1, columns-1) (i.e., 0-indexed). You can move up, down, left, or right, and you wish to find a route that requires the minimum effort.\nA route's effort is the maximum absolute difference in heights between two consecutive cells of the route.\nReturn the minimum effort required to travel from the top-left cell to the bottom-right cell.\n \nExample 1:\n\n\nInput: heights = [[1,2,2],[3,8,2],[5,3,5]]\nOutput: 2\nExplanation: The route of [1,3,5,3,5] has a maximum absolute difference of 2 in consecutive cells.\nThis is better than the route of [1,2,2,2,5], where the maximum absolute difference is 3.\n\nExample 2:\n\n\nInput: heights = [[1,2,3],[3,8,4],[5,3,5]]\nOutput: 1\nExplanation: The route of [1,2,3,4,5] has a maximum absolute difference of 1 in consecutive cells, which is better than route [1,3,5,3,5].\n\nExample 3:\n\n\nInput: heights = [[1,2,1,1,1],[1,2,1,2,1],[1,2,1,2,1],[1,2,1,2,1],[1,1,1,2,1]]\nOutput: 0\nExplanation: This route does not require any effort.\n\n \nConstraints:\n\nrows == heights.length\ncolumns == heights[i].length\n1 <= rows, columns <= 100\n1 <= heights[i][j] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(heights = [[4, 3, 4, 10, 5, 5, 9, 2], [10, 8, 2, 10, 9, 7, 5, 6], [5, 8, 1, 10, 10, 7, 7, 2], [5, 10, 2, 8, 3, 9, 7, 9], [7, 6, 6, 8, 6, 6, 4, 4], [4, 9, 6, 10, 2, 1, 2, 7], [5, 10, 3, 7, 7, 5, 10, 10]]) == 4\n assert candidate(heights = [[4, 3, 4, 10, 5, 5, 9, 2], [10, 8, 2, 10, 9, 7, 5, 6], [5, 8, 10, 10, 10, 7, 4, 2], [5, 1, 3, 1, 1, 3, 1, 9], [6, 4, 10, 6, 10, 9, 4, 6]]) == 5\n assert candidate(heights = [[7, 1, 4, 10, 10, 6, 9, 4, 10, 9, 7], [1, 2, 5, 9, 1, 5, 7, 5, 4, 10, 7], [6, 9, 8, 10, 9, 9, 9, 8, 10, 10, 8], [2, 7, 6, 8, 5, 5, 9, 9, 10, 10, 7], [5, 7, 6, 8, 3, 5, 6, 7, 1, 8, 6], [8, 8, 10, 10, 4, 3, 10, 7, 10, 10, 10], [9, 8, 9, 1, 2, 6, 3, 6, 8, 2, 2], [6, 9, 10, 9, 1, 6, 6, 6, 10, 8, 9], [4, 6, 10, 7, 9, 8, 3, 5, 6, 10, 2], [8, 1, 8, 5, 6, 5, 10, 8, 10, 10, 9]]) == 6\n assert candidate(heights = [[1, 10], [10, 1]]) == 9\n assert candidate(heights = [[1, 2, 1, 1, 1], [1, 2, 1, 2, 1], [1, 2, 1, 2, 1], [1, 2, 1, 2, 1], [1, 1, 1, 2, 1]]) == 0\n assert candidate(heights = [[1, 10, 6, 7, 9, 10, 4, 9]]) == 9\n assert candidate(heights = [[1, 2, 3], [3, 8, 4], [5, 3, 5]]) == 1\n assert candidate(heights = [[1, 1], [1, 1]]) == 0\n assert candidate(heights = [[1, 10, 6], [1, 3, 5], [4, 8, 2]]) == 3\n assert candidate(heights = [[1, 2, 2], [3, 8, 2], [5, 3, 5]]) == 2\n assert candidate(heights = [[1, 9, 20, 8, 15], [9, 10, 5, 11, 9], [8, 7, 2, 15, 12], [1, 11, 1, 1, 12], [20, 7, 11, 10, 2]]) == 8\n assert candidate(heights = [[4, 3, 4, 10, 5, 5, 9, 2], [10, 8, 2, 10, 9, 7, 5, 6], [5, 8, 1, 10, 10, 7, 7, 2], [10, 1, 3, 1, 1, 6, 6, 9], [6, 10, 6, 3, 9, 4, 9, 7], [1, 10, 6, 1, 2, 3, 8, 1], [6, 6, 9, 2, 3, 8, 1, 7], [10, 4, 6, 10, 4, 3, 8, 1]]) == 6\n assert candidate(heights = [[5, 8, 4, 1], [9, 6, 6, 7], [1, 6, 1, 1], [4, 9, 9, 1]]) == 5\n assert candidate(heights = [[1, 2, 1, 3, 4, 5], [1, 2, 1, 2, 2, 2], [2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1], [3, 3, 3, 3, 3, 3]]) == 2\n assert candidate(heights = [[1, 2, 3, 4, 5], [4, 3, 2, 1, 6], [7, 8, 9, 10, 11], [12, 13, 14, 15, 16]]) == 5\n assert candidate(heights = [[4, 3, 4, 10, 5], [6, 7, 3, 9, 2], [3, 8, 1, 3, 4], [10, 6, 3, 2, 20], [6, 1, 1, 5, 4]]) == 3\n assert candidate(heights = [[1, 6, 5, 1, 3], [4, 7, 1, 4, 2], [6, 2, 5, 3, 1], [4, 1, 2, 1, 2], [2, 6, 3, 1, 1]]) == 3\n assert candidate(heights = [[1, 2, 100, 3, 4], [2, 3, 100, 4, 5], [3, 4, 100, 5, 6], [4, 5, 100, 6, 7], [5, 6, 100, 7, 8]]) == 94\n assert candidate(heights = [[5, 6, 2, 4, 6], [4, 8, 3, 3, 8], [8, 9, 4, 7, 10], [10, 9, 2, 3, 8], [5, 1, 5, 8, 1]]) == 7\n assert candidate(heights = [[4, 3, 2, 1], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == 4\n assert candidate(heights = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(heights = [[1, 6, 3, 1, 2], [2, 2, 5, 1, 3], [6, 1, 1, 1, 1], [2, 1, 1, 2, 1], [3, 1, 1, 1, 1]]) == 1\n assert candidate(heights = [[1, 5, 9, 8, 11, 9, 4], [3, 9, 4, 8, 15, 9, 1], [2, 9, 2, 10, 15, 1, 6], [9, 10, 2, 10, 10, 2, 3], [10, 8, 2, 10, 7, 2, 8], [6, 8, 10, 10, 8, 10, 3], [1, 7, 5, 8, 3, 7, 1]]) == 5\n assert candidate(heights = [[1, 1, 1, 1, 1, 1], [1, 100000, 1, 100000, 1, 1], [1, 1, 1, 1, 1, 1], [1, 100000, 1, 100000, 1, 1], [1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(heights = [[10, 1, 1, 1, 1], [1, 1, 1, 1, 10], [1, 1, 10, 1, 1], [1, 10, 1, 10, 1], [10, 1, 1, 1, 10]]) == 9\n assert candidate(heights = [[1, 6, 1, 1, 5], [1, 2, 9, 1, 5], [1, 3, 1, 8, 5], [1, 2, 1, 2, 5], [1, 2, 1, 2, 1]]) == 1\n assert candidate(heights = [[1000000, 999999, 999998, 999997], [999996, 999995, 999994, 999993], [999992, 999991, 999990, 999989], [999988, 999987, 999986, 999985]]) == 4\n assert candidate(heights = [[1, 3, 5, 7, 9, 11, 13], [2, 4, 6, 8, 10, 12, 14], [3, 5, 7, 9, 11, 13, 15], [4, 6, 8, 10, 12, 14, 16], [5, 7, 9, 11, 13, 15, 17]]) == 2\n assert candidate(heights = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 1\n assert candidate(heights = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 1\n assert candidate(heights = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]]) == 1\n assert candidate(heights = [[1, 10, 10, 10, 1], [10, 1, 1, 1, 1], [10, 10, 10, 1, 10], [10, 1, 1, 1, 10], [1, 1, 1, 10, 1]]) == 9\n assert candidate(heights = [[1, 100, 100, 100], [100, 100, 100, 100], [100, 100, 100, 100], [100, 100, 100, 1]]) == 99\n assert candidate(heights = [[10, 15, 5], [20, 10, 5], [10, 10, 10]]) == 5\n assert candidate(heights = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 5, 5, 4, 3, 1], [1, 2, 3, 4, 5, 6, 5, 4, 3, 1], [1, 2, 3, 4, 5, 5, 5, 4, 3, 1], [1, 2, 3, 4, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 2, 1]]) == 0\n assert candidate(heights = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [8, 7, 6, 5, 4, 3, 2, 1, 9], [7, 6, 5, 4, 3, 2, 1, 9, 8], [6, 5, 4, 3, 2, 1, 9, 8, 7], [5, 4, 3, 2, 1, 9, 8, 7, 6], [4, 3, 2, 1, 9, 8, 7, 6, 5], [3, 2, 1, 9, 8, 7, 6, 5, 4], [2, 1, 9, 8, 7, 6, 5, 4, 3], [1, 9, 8, 7, 6, 5, 4, 3, 2]]) == 8\n assert candidate(heights = [[1, 100, 1], [1, 100, 1], [1, 100, 1], [1, 100, 1], [1, 1, 1]]) == 0\n assert candidate(heights = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]]) == 1\n assert candidate(heights = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41]]) == 10\n assert candidate(heights = [[1, 6, 7, 5, 3, 1, 2, 6, 3, 10], [10, 1, 5, 8, 2, 10, 4, 10, 8, 7], [1, 9, 3, 5, 7, 4, 5, 10, 9, 8], [10, 8, 7, 5, 1, 10, 1, 10, 3, 7], [1, 10, 8, 1, 3, 8, 10, 7, 1, 10], [1, 5, 4, 4, 3, 2, 8, 3, 9, 9], [9, 6, 7, 4, 3, 2, 1, 8, 7, 6], [5, 2, 1, 3, 2, 3, 4, 5, 6, 7], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 9\n assert candidate(heights = [[1, 6, 3, 8, 5, 4, 2, 7, 9], [6, 3, 8, 5, 4, 2, 7, 9, 1], [3, 8, 5, 4, 2, 7, 9, 1, 6], [8, 5, 4, 2, 7, 9, 1, 6, 3], [5, 4, 2, 7, 9, 1, 6, 3, 8], [4, 2, 7, 9, 1, 6, 3, 8, 5], [2, 7, 9, 1, 6, 3, 8, 5, 4], [7, 9, 1, 6, 3, 8, 5, 4, 2], [9, 1, 6, 3, 8, 5, 4, 2, 7]]) == 8\n assert candidate(heights = [[5, 6, 7, 8, 9], [4, 3, 2, 1, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 5\n assert candidate(heights = [[1, 2, 3], [6, 5, 4], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]]) == 3\n assert candidate(heights = [[4, 3, 4, 10, 5, 5, 9, 2], [10, 8, 2, 10, 9, 7, 5, 6], [5, 5, 1, 3, 1, 3, 7, 6], [8, 1, 2, 1, 6, 8, 5, 1], [2, 1, 1, 8, 1, 5, 6, 1], [1, 1, 8, 1, 5, 9, 1, 4], [3, 1, 2, 5, 4, 8, 3, 1]]) == 4\n assert candidate(heights = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 5\n assert candidate(heights = [[1, 9, 9, 1], [9, 0, 0, 9], [9, 0, 0, 9], [1, 9, 9, 1]]) == 8\n assert candidate(heights = [[8, 5, 2], [6, 7, 3], [5, 1, 4], [6, 9, 8], [9, 3, 7]]) == 3\n assert candidate(heights = [[7, 9, 6, 9, 6], [6, 6, 8, 6, 6], [6, 9, 7, 9, 6], [9, 6, 9, 9, 6], [6, 9, 8, 9, 6], [6, 6, 9, 6, 6]]) == 2\n assert candidate(heights = [[5, 3, 1], [6, 4, 2], [7, 5, 3], [8, 6, 4], [9, 7, 5], [10, 8, 6]]) == 2\n assert candidate(heights = [[20, 21, 22, 23, 24, 25], [19, 18, 17, 16, 15, 14], [13, 12, 11, 10, 9, 8], [7, 6, 5, 4, 3, 2], [1, 2, 3, 4, 5, 6]]) == 6\n assert candidate(heights = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(heights = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16], [21, 22, 23, 24, 25]]) == 1\n assert candidate(heights = [[1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2], [2, 1, 2, 1, 2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]]) == 1\n assert candidate(heights = [[1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 10, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(heights = [[10, 8, 9, 10, 12], [13, 14, 15, 16, 17], [18, 19, 20, 21, 22], [23, 24, 25, 26, 27], [28, 29, 30, 31, 32]]) == 5\n assert candidate(heights = [[5, 8, 1, 3, 5, 6], [3, 5, 4, 5, 6, 6], [1, 3, 5, 8, 2, 2], [6, 6, 3, 3, 2, 6], [8, 5, 1, 1, 2, 5], [9, 5, 3, 3, 4, 1]]) == 3\n assert candidate(heights = [[10, 18, 16, 19], [6, 13, 8, 15], [7, 19, 18, 17], [4, 9, 9, 18], [3, 5, 12, 9]]) == 4\n assert candidate(heights = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 3, 5, 7, 9]]) == 2\n assert candidate(heights = [[1, 3, 1, 3, 1, 3], [2, 1, 2, 1, 2, 1], [3, 2, 3, 2, 3, 2], [1, 3, 1, 3, 1, 3], [2, 1, 2, 1, 2, 1]]) == 2\n assert candidate(heights = [[7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [7, 1, 7, 7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 1, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 1, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7, 1, 7, 7], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [7, 7, 7, 7, 7, 7, 7, 7, 7, 1]]) == 6\n assert candidate(heights = [[10, 11, 12, 13, 14], [9, 8, 7, 6, 5], [4, 3, 2, 1, 100], [101, 102, 103, 104, 105], [106, 107, 108, 109, 110]]) == 95\n assert candidate(heights = [[5, 3, 1, 1, 1], [4, 2, 1, 1, 1], [4, 2, 1, 1, 1], [4, 2, 1, 1, 1], [4, 3, 2, 2, 1]]) == 1\n assert candidate(heights = [[1, 2, 2, 1, 2, 1, 2, 1], [2, 1, 1, 2, 1, 2, 1, 2], [1, 2, 2, 1, 2, 1, 2, 1], [2, 1, 1, 2, 1, 2, 1, 2], [1, 2, 2, 1, 2, 1, 2, 1]]) == 1\n assert candidate(heights = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21], [22, 23, 24], [25, 26, 27], [28, 29, 30]]) == 3\n assert candidate(heights = [[1, 2, 3, 4, 5], [6, 5, 4, 3, 2], [3, 4, 5, 6, 7], [8, 7, 6, 5, 4], [9, 10, 11, 12, 13]]) == 1\n assert candidate(heights = [[1, 5, 5, 1], [5, 1, 5, 5], [1, 5, 1, 5], [5, 1, 5, 1]]) == 4\n assert candidate(heights = [[1, 6, 3, 7, 2, 8], [4, 5, 2, 6, 8, 5], [3, 9, 4, 10, 12, 1], [9, 3, 8, 11, 14, 6], [12, 11, 9, 13, 15, 7]]) == 5\n assert candidate(heights = [[1, 9, 3, 1, 2], [9, 9, 9, 1, 1], [1, 9, 9, 9, 1], [1, 1, 1, 1, 1], [2, 1, 1, 1, 3]]) == 8\n assert candidate(heights = [[5, 5, 5, 5, 5], [5, 4, 4, 4, 5], [5, 4, 3, 4, 5], [5, 4, 4, 4, 5], [5, 5, 5, 5, 5]]) == 0\n"}, "metadata": {"canonical_parameter_names": ["heights"], "leetcode_dataset_entry_point": "Solution().minimumEffortPath", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumEffortPath(vector>& heights) {", "container": "Solution", "callable": "minimumEffortPath", "parameters": [{"name": "heights", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1632, "task_id": "rank-transform-of-a-matrix", "difficulty": "Hard", "problem_description": "Given an m x n matrix, return a new matrix answer where answer[row][col] is the rank of matrix[row][col].\nThe rank is an integer that represents how large an element is compared to other elements. It is calculated using the following rules:\n\nThe rank is an integer starting from 1.\nIf two elements p and q are in the same row or column, then:\n\t\nIf p < q then rank(p) < rank(q)\nIf p == q then rank(p) == rank(q)\nIf p > q then rank(p) > rank(q)\n\n\nThe rank should be as small as possible.\n\nThe test cases are generated so that answer is unique under the given rules.\n \nExample 1:\n\n\nInput: matrix = [[1,2],[3,4]]\nOutput: [[1,2],[2,3]]\nExplanation:\nThe rank of matrix[0][0] is 1 because it is the smallest integer in its row and column.\nThe rank of matrix[0][1] is 2 because matrix[0][1] > matrix[0][0] and matrix[0][0] is rank 1.\nThe rank of matrix[1][0] is 2 because matrix[1][0] > matrix[0][0] and matrix[0][0] is rank 1.\nThe rank of matrix[1][1] is 3 because matrix[1][1] > matrix[0][1], matrix[1][1] > matrix[1][0], and both matrix[0][1] and matrix[1][0] are rank 2.\n\nExample 2:\n\n\nInput: matrix = [[7,7],[7,7]]\nOutput: [[1,1],[1,1]]\n\nExample 3:\n\n\nInput: matrix = [[20,-21,14],[-19,4,19],[22,-47,24],[-19,4,19]]\nOutput: [[4,2,3],[1,3,4],[5,1,6],[1,3,4]]\n\n \nConstraints:\n\nm == matrix.length\nn == matrix[i].length\n1 <= m, n <= 500\n-109 <= matrix[row][col] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[-1, -2], [-3, -4]]) == [[3, 2], [2, 1]]\n assert candidate(matrix = [[20, -21, 14], [-19, 4, 19], [22, -47, 24], [-19, 4, 19]]) == [[4, 2, 3], [1, 3, 4], [5, 1, 6], [1, 3, 4]]\n assert candidate(matrix = [[1, 2], [3, 4]]) == [[1, 2], [2, 3]]\n assert candidate(matrix = [[-3, -3], [1, -2], [2, -2], [1, 2]]) == [[1, 1], [3, 2], [4, 2], [3, 4]]\n assert candidate(matrix = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == [[1, 1, 1], [1, 1, 1], [1, 1, 1]]\n assert candidate(matrix = [[7, 7], [7, 7]]) == [[1, 1], [1, 1]]\n assert candidate(matrix = [[1, 2, 3], [3, 2, 1], [2, 1, 3]]) == [[1, 2, 3], [3, 2, 1], [2, 1, 3]]\n assert candidate(matrix = [[3, 3, 3], [3, 3, 3], [3, 3, 3], [3, 3, 3]]) == [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]\n assert candidate(matrix = [[-1, -1, -1], [-1, 0, -1], [-1, -1, -1]]) == [[1, 1, 1], [1, 2, 1], [1, 1, 1]]\n assert candidate(matrix = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]]) == [[5, 4, 3], [4, 3, 2], [3, 2, 1]]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2], [3, 4, 5, 6, 1, 2], [2, 1, 6, 5, 4, 3]]) == [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2], [3, 4, 5, 6, 1, 2], [2, 1, 6, 5, 4, 3]]\n assert candidate(matrix = [[10, 20, 30], [20, 30, 10], [30, 10, 20], [10, 20, 30]]) == [[1, 2, 3], [2, 3, 1], [3, 1, 2], [1, 2, 3]]\n assert candidate(matrix = [[1, 0, -1], [0, 0, 0], [-1, 0, 1]]) == [[3, 2, 1], [2, 2, 2], [1, 2, 3]]\n assert candidate(matrix = [[-5, -4, -3, -2, -1], [0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19]]) == [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]\n assert candidate(matrix = [[10, 9, 8, 7, 6], [9, 8, 7, 6, 5], [8, 7, 6, 5, 4], [7, 6, 5, 4, 3], [6, 5, 4, 3, 2], [5, 4, 3, 2, 1], [4, 3, 2, 1, 0], [3, 2, 1, 0, -1], [2, 1, 0, -1, -2], [1, 0, -1, -2, -3]]) == [[14, 13, 12, 11, 10], [13, 12, 11, 10, 9], [12, 11, 10, 9, 8], [11, 10, 9, 8, 7], [10, 9, 8, 7, 6], [9, 8, 7, 6, 5], [8, 7, 6, 5, 4], [7, 6, 5, 4, 3], [6, 5, 4, 3, 2], [5, 4, 3, 2, 1]]\n assert candidate(matrix = [[-10, -10, -10], [-10, -10, -10], [-10, -10, -10]]) == [[1, 1, 1], [1, 1, 1], [1, 1, 1]]\n assert candidate(matrix = [[-1, 0, 1], [0, 0, 0], [1, 0, -1], [0, 1, 0]]) == [[1, 2, 3], [2, 2, 2], [3, 2, 1], [2, 3, 2]]\n assert candidate(matrix = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]) == [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]\n assert candidate(matrix = [[10, 20, 30, 40, 50], [40, 50, 10, 20, 30], [30, 40, 50, 10, 20], [20, 30, 40, 50, 10], [50, 10, 20, 30, 40]]) == [[1, 2, 3, 4, 5], [4, 5, 1, 2, 3], [3, 4, 5, 1, 2], [2, 3, 4, 5, 1], [5, 1, 2, 3, 4]]\n assert candidate(matrix = [[9, 9, 9, 9, 9, 9, 9, 9, 9, 9], [8, 8, 8, 8, 8, 8, 8, 8, 8, 8], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [6, 6, 6, 6, 6, 6, 6, 6, 6, 6], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [9, 9, 9, 9, 9, 9, 9, 9, 9, 9], [8, 8, 8, 8, 8, 8, 8, 8, 8, 8], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7], [6, 6, 6, 6, 6, 6, 6, 6, 6, 6], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]\n assert candidate(matrix = [[100, 90, 80], [70, 60, 50], [40, 30, 20], [10, 0, -10]]) == [[6, 5, 4], [5, 4, 3], [4, 3, 2], [3, 2, 1]]\n assert candidate(matrix = [[10, 10, 10, 10], [10, 20, 20, 10], [10, 20, 30, 10], [10, 10, 10, 10]]) == [[1, 1, 1, 1], [1, 2, 2, 1], [1, 2, 3, 1], [1, 1, 1, 1]]\n assert candidate(matrix = [[0, 0, 0, 0, 0], [0, 1, 2, 3, 4], [0, 2, 4, 6, 8], [0, 3, 6, 9, 12], [0, 4, 8, 12, 16]]) == [[1, 1, 1, 1, 1], [1, 2, 3, 4, 5], [1, 3, 4, 5, 6], [1, 4, 5, 6, 7], [1, 5, 6, 7, 8]]\n assert candidate(matrix = [[7, -3, 10], [3, 7, 1], [-3, 10, 7], [10, 1, 3]]) == [[3, 1, 5], [2, 3, 1], [1, 5, 4], [4, 2, 3]]\n assert candidate(matrix = [[-10, -9, -8, -7, -6], [-9, -8, -7, -6, -5], [-8, -7, -6, -5, -4], [-7, -6, -5, -4, -3], [-6, -5, -4, -3, -2], [-5, -4, -3, -2, -1], [-4, -3, -2, -1, 0], [-3, -2, -1, 0, 1], [-2, -1, 0, 1, 2], [-1, 0, 1, 2, 3]]) == [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9], [6, 7, 8, 9, 10], [7, 8, 9, 10, 11], [8, 9, 10, 11, 12], [9, 10, 11, 12, 13], [10, 11, 12, 13, 14]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]) == [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]\n assert candidate(matrix = [[-10, 5, 3, -5], [0, 0, 0, 0], [-10, 5, 3, -5], [10, -5, -3, 5]]) == [[1, 5, 4, 2], [3, 3, 3, 3], [1, 5, 4, 2], [5, 1, 2, 4]]\n assert candidate(matrix = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]) == [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]]\n assert candidate(matrix = [[0, 1, 2, 3, 4], [4, 3, 2, 1, 0], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1], [0, 2, 4, 6, 8]]) == [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 4, 5, 6, 7], [7, 6, 5, 4, 2], [1, 3, 4, 5, 6]]\n assert candidate(matrix = [[-10, 9, 6, 1, 6, 8, 3, -1, 5, 3, 0], [9, -10, -8, -10, 2, 3, 8, 10, 4, 5, -8], [6, -8, 10, -8, 10, 3, -8, 5, -9, 3, -10], [1, 10, -10, 3, -8, 8, 5, 10, -1, 2, -8], [6, -8, 10, -8, 10, 3, -8, 5, -9, 3, -10], [8, 3, -10, 8, 5, 10, -1, 2, -8, 1, 6], [-1, 5, -9, -1, 2, -8, 1, 6, 8, 3, 0], [5, 3, 8, -1, 6, 10, 3, -8, 1, 6, -8], [3, 0, 3, 5, -1, 6, 8, 3, 0, 3, 10], [3, -10, 3, -8, 10, -8, 5, 10, -1, 2, 6], [0, 3, 10, -8, 3, -10, 8, 5, -1, 2, 6]]) == [[1, 13, 11, 6, 11, 12, 8, 4, 10, 8, 5], [12, 1, 3, 1, 7, 8, 11, 14, 9, 10, 3], [10, 3, 14, 3, 14, 8, 3, 9, 2, 8, 1], [6, 14, 1, 8, 3, 12, 9, 14, 4, 7, 3], [10, 3, 14, 3, 14, 8, 3, 9, 2, 8, 1], [11, 8, 1, 11, 9, 13, 4, 6, 3, 5, 10], [4, 9, 2, 4, 7, 3, 6, 10, 11, 8, 5], [9, 8, 12, 4, 11, 13, 8, 3, 6, 11, 3], [8, 5, 8, 9, 4, 10, 11, 8, 5, 8, 12], [8, 1, 8, 3, 14, 3, 9, 14, 4, 7, 10], [5, 8, 14, 3, 8, 1, 11, 9, 4, 7, 10]]\n assert candidate(matrix = [[1, 2, 3], [3, 2, 1], [2, 1, 3]]) == [[1, 2, 3], [3, 2, 1], [2, 1, 3]]\n assert candidate(matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]\n assert candidate(matrix = [[1, 3, 1, 3, 1], [2, 4, 2, 4, 2], [1, 3, 1, 3, 1], [2, 4, 2, 4, 2]]) == [[1, 2, 1, 2, 1], [2, 3, 2, 3, 2], [1, 2, 1, 2, 1], [2, 3, 2, 3, 2]]\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 3, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 1, 1]]) == [[1, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 3, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 1, 1]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [4, 5, 6, 7, 8], [7, 8, 9, 10, 11], [10, 11, 12, 13, 14], [13, 14, 15, 16, 17]]) == [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]\n assert candidate(matrix = [[10, 10, 10, 10], [10, 10, 10, 10], [10, 10, 10, 10], [10, 10, 10, 10]]) == [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]\n assert candidate(matrix = [[-10, 5, 0, 3], [6, -10, 8, 2], [1, 10, -5, 7], [4, -3, 9, -10]]) == [[1, 4, 2, 3], [4, 1, 5, 2], [2, 5, 1, 4], [3, 2, 6, 1]]\n assert candidate(matrix = [[-1, -1, -1, -1], [-1, 0, 0, -1], [-1, 0, 1, -1], [-1, -1, -1, 1]]) == [[1, 1, 1, 1], [1, 2, 2, 1], [1, 2, 3, 1], [1, 1, 1, 2]]\n assert candidate(matrix = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]\n assert candidate(matrix = [[1, 5, 9], [2, 6, 10], [3, 7, 11], [4, 8, 12], [5, 9, 13]]) == [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]\n assert candidate(matrix = [[1, 1000000000, -1000000000], [1000000000, 1, -1000000000], [-1000000000, -1000000000, 1]]) == [[2, 3, 1], [3, 2, 1], [1, 1, 2]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 1], [3, 4, 5, 1, 2], [4, 5, 1, 2, 3], [5, 1, 2, 3, 4]]) == [[1, 2, 3, 4, 5], [2, 3, 4, 5, 1], [3, 4, 5, 1, 2], [4, 5, 1, 2, 3], [5, 1, 2, 3, 4]]\n assert candidate(matrix = [[-10, 0, 10], [0, 0, 0], [-10, 0, 10]]) == [[1, 2, 3], [2, 2, 2], [1, 2, 3]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 2, 4], [4, 2, 1, 5, 3], [2, 4, 6, 8, 10]]) == [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 2, 4], [4, 2, 1, 5, 3], [2, 4, 6, 7, 8]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]\n assert candidate(matrix = [[0, -1, 1000000000, 0], [1000000000, 0, -1, 0], [-1, 1000000000, 0, 0], [0, 0, 0, 0]]) == [[2, 1, 3, 2], [3, 2, 1, 2], [1, 3, 2, 2], [2, 2, 2, 2]]\n assert candidate(matrix = [[5, 1, 3, 2, 1], [5, 5, 4, 4, 5], [4, 2, 3, 3, 2], [5, 5, 5, 5, 5], [4, 4, 4, 4, 4]]) == [[5, 1, 3, 2, 1], [5, 5, 4, 4, 5], [4, 2, 3, 3, 2], [5, 5, 5, 5, 5], [4, 4, 4, 4, 4]]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6], [5, 6, 1, 2, 3, 4], [4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2], [2, 3, 4, 5, 6, 1], [1, 2, 3, 4, 5, 6]]) == [[1, 2, 3, 4, 5, 6], [5, 6, 1, 2, 3, 4], [4, 5, 6, 1, 2, 3], [3, 4, 5, 6, 1, 2], [2, 3, 4, 5, 6, 1], [1, 2, 3, 4, 5, 6]]\n assert candidate(matrix = [[-1, -1, -1, -1, -1], [-1, 1, -1, 1, -1], [-1, -1, -1, -1, -1], [-1, 1, -1, 1, -1], [-1, -1, -1, -1, -1]]) == [[1, 1, 1, 1, 1], [1, 2, 1, 2, 1], [1, 1, 1, 1, 1], [1, 2, 1, 2, 1], [1, 1, 1, 1, 1]]\n assert candidate(matrix = [[0, 1, 2, 3, 4], [4, 3, 2, 1, 0], [1, 3, 0, 2, 4], [2, 4, 1, 0, 3], [3, 0, 4, 1, 2]]) == [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 4, 1, 3, 5], [3, 5, 2, 1, 4], [4, 1, 5, 2, 3]]\n assert candidate(matrix = [[-1000000000, 1000000000], [1000000000, -1000000000]]) == [[1, 2], [2, 1]]\n assert candidate(matrix = [[1, 2, 3, 4], [2, 1, 4, 3], [3, 4, 1, 2], [4, 3, 2, 1]]) == [[1, 2, 3, 4], [2, 1, 4, 3], [3, 4, 1, 2], [4, 3, 2, 1]]\n assert candidate(matrix = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == [[1, 1, 1], [1, 2, 1], [1, 1, 1]]\n assert candidate(matrix = [[5, 3, 1], [-1, 7, 6], [8, 4, 2]]) == [[3, 2, 1], [1, 4, 3], [4, 3, 2]]\n assert candidate(matrix = [[5, 1, 9, 11], [2, 4, 6, 8], [13, 3, 7, 15], [16, 14, 12, 10]]) == [[2, 1, 6, 7], [1, 3, 4, 5], [6, 2, 5, 8], [9, 8, 7, 6]]\n assert candidate(matrix = [[-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1], [-1, -1, -1, -1]]) == [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]\n assert candidate(matrix = [[1, 1, 1], [1, 2, 2], [1, 2, 3]]) == [[1, 1, 1], [1, 2, 2], [1, 2, 3]]\n assert candidate(matrix = [[-10, -10, -10, -10], [-10, 0, 0, -10], [-10, 0, 0, -10], [-10, -10, -10, -10]]) == [[1, 1, 1, 1], [1, 2, 2, 1], [1, 2, 2, 1], [1, 1, 1, 1]]\n assert candidate(matrix = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]) == [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]]\n assert candidate(matrix = [[5, -4, 5, -9, -1], [9, -1, 9, 5, -5], [5, -5, 5, 9, 9], [9, 9, 9, 5, -1], [5, -4, 5, -9, -1]]) == [[4, 2, 4, 1, 3], [5, 3, 5, 4, 1], [4, 1, 4, 5, 5], [5, 5, 5, 4, 3], [4, 2, 4, 1, 3]]\n assert candidate(matrix = [[-10, 20, 30, -40], [-10, 20, 30, -40], [-10, 20, 30, -40], [-10, 20, 30, -40]]) == [[2, 3, 4, 1], [2, 3, 4, 1], [2, 3, 4, 1], [2, 3, 4, 1]]\n assert candidate(matrix = [[1, 2, 3, 4], [4, 3, 2, 1], [2, 3, 4, 1], [3, 4, 1, 2]]) == [[1, 2, 3, 4], [4, 3, 2, 1], [2, 3, 4, 1], [3, 4, 1, 2]]\n assert candidate(matrix = [[5, 1, 9, 11], [2, 4, 8, 10], [13, 3, 6, 7], [15, 14, 12, 16]]) == [[2, 1, 5, 6], [1, 3, 4, 5], [5, 2, 3, 4], [8, 7, 6, 9]]\n assert candidate(matrix = [[-1, -2, -3], [-2, -3, -4], [-3, -4, -5]]) == [[5, 4, 3], [4, 3, 2], [3, 2, 1]]\n assert candidate(matrix = [[10, 20, 30, 40], [40, 30, 20, 10], [10, 20, 30, 40], [40, 30, 20, 10]]) == [[1, 2, 3, 4], [4, 3, 2, 1], [1, 2, 3, 4], [4, 3, 2, 1]]\n assert candidate(matrix = [[-1, -2, -3, -4, -5], [-6, -7, -8, -9, -10], [-11, -12, -13, -14, -15], [-16, -17, -18, -19, -20], [-21, -22, -23, -24, -25]]) == [[9, 8, 7, 6, 5], [8, 7, 6, 5, 4], [7, 6, 5, 4, 3], [6, 5, 4, 3, 2], [5, 4, 3, 2, 1]]\n assert candidate(matrix = [[-10, 100, 0], [5, -5, 5], [10, 10, 10], [0, 0, 0]]) == [[1, 5, 2], [3, 1, 3], [4, 4, 4], [2, 2, 2]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [2, 1, 4, 3, 5], [3, 4, 1, 2, 5], [4, 3, 2, 1, 5], [5, 5, 5, 5, 5]]) == [[1, 2, 3, 4, 5], [2, 1, 4, 3, 5], [3, 4, 1, 2, 5], [4, 3, 2, 1, 5], [5, 5, 5, 5, 5]]\n assert candidate(matrix = [[100, 200, 300, 400, 500], [500, 400, 300, 200, 100], [200, 300, 400, 500, 100], [400, 500, 100, 200, 300], [300, 100, 200, 300, 400]]) == [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 1], [4, 5, 1, 2, 3], [3, 1, 2, 3, 4]]\n assert candidate(matrix = [[-10, 0, 10], [20, 30, 40], [50, 60, 70]]) == [[1, 2, 3], [2, 3, 4], [3, 4, 5]]\n assert candidate(matrix = [[-5, -5, -5], [-5, -5, -5], [-5, -5, -5], [-5, -5, -5]]) == [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2]]) == [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 1], [1, 6, 5, 4, 3, 2]]\n assert candidate(matrix = [[-10, -20, -30], [-5, -15, -25], [-1, -11, -21]]) == [[3, 2, 1], [4, 3, 2], [5, 4, 3]]\n assert candidate(matrix = [[1], [2], [3], [4], [5]]) == [[1], [2], [3], [4], [5]]\n assert candidate(matrix = [[1, 1, 2], [2, 2, 1], [3, 3, 2]]) == [[1, 1, 2], [2, 2, 1], [3, 3, 2]]\n assert candidate(matrix = [[1, 3, 5], [2, 3, 6], [4, 6, 9]]) == [[1, 3, 4], [2, 3, 5], [3, 4, 6]]\n assert candidate(matrix = [[5, 3, 1, 4, 2], [10, 8, 6, 9, 7], [15, 13, 11, 14, 12], [20, 18, 16, 19, 17], [25, 23, 21, 24, 22]]) == [[5, 3, 1, 4, 2], [6, 4, 2, 5, 3], [7, 5, 3, 6, 4], [8, 6, 4, 7, 5], [9, 7, 5, 8, 6]]\n assert candidate(matrix = [[5, 1, 9, 5, 5], [1, 5, 5, 9, 1], [9, 5, 1, 1, 5], [5, 9, 5, 5, 1], [5, 5, 1, 5, 9]]) == [[2, 1, 3, 2, 2], [1, 2, 2, 3, 1], [3, 2, 1, 1, 2], [2, 3, 2, 2, 1], [2, 2, 1, 2, 3]]\n assert candidate(matrix = [[1000000000, 999999999, 999999998, 999999997], [999999996, 999999995, 999999994, 999999993], [999999992, 999999991, 999999990, 999999989], [999999988, 999999987, 999999986, 999999985]]) == [[7, 6, 5, 4], [6, 5, 4, 3], [5, 4, 3, 2], [4, 3, 2, 1]]\n assert candidate(matrix = [[-5, -4, -3, -2, -1], [-4, -3, -2, -1, 0], [-3, -2, -1, 0, 1], [-2, -1, 0, 1, 2], [-1, 0, 1, 2, 3]]) == [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9]]\n assert candidate(matrix = [[5, 1, 9, 1, 5, 9], [1, 5, 5, 1, 5, 1], [9, 5, 1, 9, 1, 9]]) == [[2, 1, 3, 1, 2, 3], [1, 2, 2, 1, 2, 1], [3, 2, 1, 3, 1, 3]]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 1], [3, 4, 5, 6, 1, 2], [4, 5, 6, 1, 2, 3], [5, 6, 1, 2, 3, 4], [6, 1, 2, 3, 4, 5]]) == [[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 1], [3, 4, 5, 6, 1, 2], [4, 5, 6, 1, 2, 3], [5, 6, 1, 2, 3, 4], [6, 1, 2, 3, 4, 5]]\n assert candidate(matrix = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]\n assert candidate(matrix = [[-1, -10, 100, 50, 25], [-1, -20, 99, 49, 24], [0, 0, 0, 0, 0], [1, 2, 3, 4, 5], [10, 20, 30, 40, 50]]) == [[3, 2, 13, 12, 11], [3, 1, 12, 11, 10], [4, 4, 4, 4, 4], [5, 6, 7, 8, 9], [6, 7, 8, 9, 12]]\n assert candidate(matrix = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]\n assert candidate(matrix = [[9, 7, 5], [6, 8, 4], [3, 1, 2]]) == [[6, 5, 4], [4, 6, 3], [3, 1, 2]]\n assert candidate(matrix = [[-1, 0, 0, 1, 2], [-1, -1, 1, 1, 2], [1, 1, 1, 1, 1], [-1, 0, 0, 1, 1], [-1, -1, 1, 1, 1]]) == [[1, 2, 2, 3, 4], [1, 1, 3, 3, 4], [3, 3, 3, 3, 3], [1, 2, 2, 3, 3], [1, 1, 3, 3, 3]]\n assert candidate(matrix = [[0, 0, 0, 0], [0, 1, 1, 1], [0, 1, 2, 2], [0, 1, 2, 3]]) == [[1, 1, 1, 1], [1, 2, 2, 2], [1, 2, 3, 3], [1, 2, 3, 4]]\n assert candidate(matrix = [[10, 20, 30], [20, 30, 10], [30, 10, 20]]) == [[1, 2, 3], [2, 3, 1], [3, 1, 2]]\n assert candidate(matrix = [[5, 1, 3, 1], [2, 4, 6, 4], [7, 8, 9, 8], [1, 3, 5, 3]]) == [[3, 1, 2, 1], [2, 3, 4, 3], [4, 5, 6, 5], [1, 2, 3, 2]]\n assert candidate(matrix = [[-1, -2, -3], [-3, -1, -2], [-2, -3, -1]]) == [[3, 2, 1], [1, 3, 2], [2, 1, 3]]\n assert candidate(matrix = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 1], [4, 5, 1, 2, 3], [3, 1, 2, 4, 5]]) == [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 1], [4, 5, 1, 2, 3], [3, 1, 2, 4, 5]]\n assert candidate(matrix = [[1000000000, -1000000000, 1000000000, -1000000000], [-1000000000, 1000000000, -1000000000, 1000000000], [1000000000, -1000000000, 1000000000, -1000000000], [-1000000000, 1000000000, -1000000000, 1000000000]]) == [[2, 1, 2, 1], [1, 2, 1, 2], [2, 1, 2, 1], [1, 2, 1, 2]]\n assert candidate(matrix = [[-5, -5, -5, -5], [-5, -5, -5, -5], [-5, -5, -5, -5], [-5, -5, -5, -5]]) == [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 10, 1], [1, 10, 9, 8, 7, 6, 5, 4, 3, 2], [3, 2, 1, 10, 9, 8, 7, 6, 5, 4], [4, 5, 6, 7, 8, 9, 10, 1, 2, 3], [5, 6, 7, 8, 9, 10, 1, 2, 3, 4], [6, 7, 8, 9, 10, 1, 2, 3, 4, 5], [7, 8, 9, 10, 1, 2, 3, 4, 5, 6], [8, 9, 10, 1, 2, 3, 4, 5, 6, 7]]) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 10, 1], [1, 10, 9, 8, 7, 6, 5, 4, 3, 2], [3, 2, 1, 10, 9, 8, 7, 6, 5, 4], [4, 5, 6, 7, 8, 9, 10, 1, 2, 3], [5, 6, 7, 8, 9, 10, 1, 2, 3, 4], [6, 7, 8, 9, 10, 1, 2, 3, 4, 5], [7, 8, 9, 10, 1, 2, 3, 4, 5, 6], [8, 9, 10, 1, 2, 3, 4, 5, 6, 7]]\n assert candidate(matrix = [[1, 2, 3, 4], [4, 3, 2, 1], [1, 2, 3, 4], [4, 3, 2, 1]]) == [[1, 2, 3, 4], [4, 3, 2, 1], [1, 2, 3, 4], [4, 3, 2, 1]]\n"}, "metadata": {"canonical_parameter_names": ["matrix"], "leetcode_dataset_entry_point": "Solution().matrixRankTransform", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector> matrixRankTransform(vector>& matrix) {", "container": "Solution", "callable": "matrixRankTransform", "parameters": [{"name": "matrix", "type": "vector>&"}], "return_type": "vector>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1636, "task_id": "sort-array-by-increasing-frequency", "difficulty": "Easy", "problem_description": "Given an array of integers nums, sort the array in increasing order based on the frequency of the values. If multiple values have the same frequency, sort them in decreasing order.\nReturn the sorted array.\n \nExample 1:\n\nInput: nums = [1,1,2,2,2,3]\nOutput: [3,1,1,2,2,2]\nExplanation: '3' has a frequency of 1, '1' has a frequency of 2, and '2' has a frequency of 3.\n\nExample 2:\n\nInput: nums = [2,3,1,3,2]\nOutput: [1,3,3,2,2]\nExplanation: '2' and '3' both have a frequency of 2, so they are sorted in decreasing order.\n\nExample 3:\n\nInput: nums = [-1,1,-6,4,5,-6,1,4,1]\nOutput: [5,-1,4,4,-6,-6,1,1,1]\n \nConstraints:\n\n1 <= nums.length <= 100\n-100 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 2, 2, 2, 3]) == [3, 1, 1, 2, 2, 2]\n assert candidate(nums = [10, 10, 20, 20, 30]) == [30, 20, 20, 10, 10]\n assert candidate(nums = [7, 7, 7, 6, 6, 5, 5, 5, 5]) == [6, 6, 7, 7, 7, 5, 5, 5, 5]\n assert candidate(nums = [5, 5, 4, 6, 4, 4, 4]) == [6, 5, 5, 4, 4, 4, 4]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]\n assert candidate(nums = [7, 7, 7, 8, 8, 9]) == [9, 8, 8, 7, 7, 7]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [-1, -1, -1, -2, -2, -3]) == [-3, -2, -2, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [1]) == [1]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == [7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [2, 3, 1, 3, 2]) == [1, 3, 3, 2, 2]\n assert candidate(nums = [100, -100, 100, -100, 100]) == [-100, -100, 100, 100, 100]\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3]) == [3, 3, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0]\n assert candidate(nums = [100, -100, 0, 0, 0, 0]) == [100, -100, 0, 0, 0, 0]\n assert candidate(nums = [5, 5, 5, 4, 4, 3, 3, 3, 3]) == [4, 4, 5, 5, 5, 3, 3, 3, 3]\n assert candidate(nums = [-100, 100]) == [100, -100]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]\n assert candidate(nums = [5, 5, 4, 4, 4, 6, 6, 6, 6]) == [5, 5, 4, 4, 4, 6, 6, 6, 6]\n assert candidate(nums = [-5, -5, -4, -4, -3, -3, -2, -2, -1, -1]) == [-1, -1, -2, -2, -3, -3, -4, -4, -5, -5]\n assert candidate(nums = [100, -100, 0, 0, 0]) == [100, -100, 0, 0, 0]\n assert candidate(nums = [0, 0, 0, 1, 1, 2, 2, 2, 2]) == [1, 1, 0, 0, 0, 2, 2, 2, 2]\n assert candidate(nums = [-1, 1, -6, 4, 5, -6, 1, 4, 1]) == [5, -1, 4, 4, -6, -6, 1, 1, 1]\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == [4, 3, 2, 2, 1, 1, 1, 5, 5, 5, 5, 0, 0, 0, 0, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10]) == [9, 8, 7, 6, 5, 4, 3, 2, 2, 1, 1, 1, 0, 0, 0, 0, 10, 10, 10, 10, 10]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9]) == [8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 7, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3]) == [0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5]) == [9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12]) == [12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]) == [0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]) == [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [9, 8, 7, 6, 5, 4, 4, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 12, 12, 12, -12, -12, -12]) == [100, 50, 25, -25, -50, -100, 12, 12, 12, -12, -12, -12]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [-1, -1, -1, -2, -2, -3, -3, -3, -3, -4, -4, -4, -4, -4, -5, -5, -5, -5, -5, -5]) == [-2, -2, -1, -1, -1, -3, -3, -3, -3, -4, -4, -4, -4, -4, -5, -5, -5, -5, -5, -5]\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99]) == [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == [10, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(nums = [7, 7, 7, 8, 8, 9, 9, 9, 9]) == [8, 8, 7, 7, 7, 9, 9, 9, 9]\n assert candidate(nums = [1, 1, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8]) == [2, 3, 3, 1, 1, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 9, 10, 11, 12, 13, 14, 15]) == [15, 14, 13, 12, 11, 10, 9, 8, 8, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 5]\n assert candidate(nums = [7, 7, 7, 7, 8, 8, 9, 9, 9, 10, 10, 10, 10, 10]) == [8, 8, 9, 9, 9, 7, 7, 7, 7, 10, 10, 10, 10, 10]\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [9, 8, 7, 6, 5, 4, 3, 3, 2, 2, 2, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == [2, 2, 3, 3, 3, 1, 1, 1, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [-5, -5, -5, -5, -4, -4, -3, -3, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 3, 3]) == [3, 3, 2, 2, 1, 1, 0, 0, -1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -5, -5]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]\n assert candidate(nums = [7, 7, 7, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10]) == [8, 8, 7, 7, 7, 9, 9, 9, 9, 10, 10, 10, 10, 10]\n assert candidate(nums = [-50, -50, -50, -50, -50, -49, -49, -49, -48, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35, -36, -37, -38, -39, -40, -41, -42, -43, -44, -45, -46, -47, -48, -48, -49, -49, -49, -50, -50, -50, -50, -50]\n assert candidate(nums = [7, 3, 7, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == [7, 7, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1]\n assert candidate(nums = [5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 12, -12, 6, -6, 3, -3, 1, -1, 0]) == [100, 50, 25, 12, 6, 3, 1, 0, -1, -3, -6, -12, -25, -50, -100]\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 3, 2, 2, 2, 1, 1, 1, 1]\n assert candidate(nums = [15, 15, 15, 15, 20, 20, 20, 25, 25, 30, 30, 30, 30, 30, 35, 35]) == [35, 35, 25, 25, 20, 20, 20, 15, 15, 15, 15, 30, 30, 30, 30, 30]\n assert candidate(nums = [7, 7, 7, 7, 6, 6, 6, 5, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]) == [4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, 5, 5, 6, 6, 6, 7, 7, 7, 7]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -10, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, -1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -6, -6, -7, -7, -8, -8, -9, -9, -10, -10, -10]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]\n assert candidate(nums = [-5, -5, -5, -5, -4, -4, -3, -3, -2, -1, 0, 1, 2, 3, 3, 4, 4, 4, 5, 5, 5, 5]) == [2, 1, 0, -1, -2, 3, 3, -3, -3, -4, -4, 4, 4, 4, 5, 5, 5, 5, -5, -5, -5, -5]\n assert candidate(nums = [-10, -10, -10, -9, -9, -8, -8, -7, -6, -6, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -7, -8, -8, -9, -9, -6, -6, -6, -10, -10, -10]\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == [2, 2, 1, 1, 1, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(nums = [100, -100, 100, 99, 99, 98, 98, 98, 97, 97, 97, 97]) == [-100, 100, 100, 99, 99, 98, 98, 98, 97, 97, 97, 97]\n assert candidate(nums = [5, 3, 8, 5, 8, 3, 9, 5, 3, 8, 8, 8, 8, 3, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [5, 5, 5, 3, 3, 3, 3, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5]) == [4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3]) == [3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [7, 7, 7, 3, 3, 5, 5, 5, 2, 2, 1]) == [1, 3, 3, 2, 2, 7, 7, 7, 5, 5, 5]\n assert candidate(nums = [0, -1, 0, -1, 0, -1, 1, 1, 1, 1, 1]) == [0, 0, 0, -1, -1, -1, 1, 1, 1, 1, 1]\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 100, 100, 90, 90, 80, 80, 70, 70, 60, 60, 50, 50, 40, 40, 30, 30, 20, 20, 10]) == [10, 10, 100, 100, 100, 90, 90, 90, 80, 80, 80, 70, 70, 70, 60, 60, 60, 50, 50, 50, 40, 40, 40, 30, 30, 30, 20, 20, 20]\n assert candidate(nums = [-1, -1, -1, -2, -2, -3, -3, -4, -4, -4, -5, -5, -5, -5, -5, -6, -6, -6, -6, -6, -6]) == [-2, -2, -3, -3, -1, -1, -1, -4, -4, -4, -5, -5, -5, -5, -5, -6, -6, -6, -6, -6, -6]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == [50, 50, 50, 50, 50, 50, 40, 40, 40, 40, 40, 40, 30, 30, 30, 30, 30, 30, 20, 20, 20, 20, 20, 20, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [10, 10, 20, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40, 40, 50]) == [50, 10, 10, 20, 20, 20, 30, 30, 30, 30, 40, 40, 40, 40, 40]\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 6, 7]) == [7, 6, 5, 4, 4, 3, 3, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0]\n assert candidate(nums = [100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100]) == [100, 100, 100, 100, 100, 100, 100, 100, -100, -100, -100, -100, -100, -100, -100, -100]\n assert candidate(nums = [100, -100, 100, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-100, 100, 100, 50, 50, 50, 50, 50, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 0, 0, 0, 0, 0]) == [100, 50, 25, -25, -50, -100, 0, 0, 0, 0, 0]\n assert candidate(nums = [9, 8, 8, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4]) == [9, 8, 8, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(nums = [5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1, 0, -1, -2, -2, -3, -3, -3, -4, -4, -4, -4, -5, -5, -5, -5, -5]) == [1, 0, -1, 2, 2, -2, -2, 3, 3, 3, -3, -3, -3, 4, 4, 4, 4, -4, -4, -4, -4, 5, 5, 5, 5, 5, -5, -5, -5, -5, -5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 10, 10, 10, 10]\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 75, -75, 0, 0, 0, 0, 0, 0]) == [100, 75, 50, 25, -25, -50, -75, -100, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == [2, 2, 1, 1, 1, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]\n assert candidate(nums = [10, 10, 10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60]) == [20, 20, 30, 30, 30, 10, 10, 10, 40, 40, 40, 40, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 60]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -5, -5, -5, -5]) == [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -5, -5, -5, -5]\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10]) == [50, 50, 50, 50, 40, 40, 40, 40, 30, 30, 30, 30, 20, 20, 20, 20, 10, 10, 10, 10, 10]\n assert candidate(nums = [2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50]) == [50, 50, 49, 49, 48, 48, 47, 47, 46, 46, 45, 45, 44, 44, 43, 43, 42, 42, 41, 41, 40, 40, 39, 39, 38, 38, 37, 37, 36, 36, 35, 35, 34, 34, 33, 33, 32, 32, 31, 31, 30, 30, 29, 29, 28, 28, 27, 27, 26, 26, 25, 25, 24, 24, 23, 23, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18, 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -10, -10, -10, -10, -10, -10, -10, -10, -10]\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [99, 99, 99, 99, 98, 98, 98, 97, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75]) == [96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 97, 97, 98, 98, 98, 99, 99, 99, 99]\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35, -36, -37, -38, -39, -40, -41, -42, -43, -44, -45, -46, -47, -48, -49, -50, -51, -52, -53, -54, -55, -56, -57, -58, -59, -60, -61, -62, -63, -64, -65, -66, -67, -68, -69, -70, -71, -72, -73, -74, -75, -76, -77, -78, -79, -80, -81, -82, -83, -84, -85, -86, -87, -88, -89, -90, -91, -92, -93, -94, -95, -96, -97, -98, -99, -100]\n assert candidate(nums = [-5, -5, -5, -5, -5, -10, -10, -10, 0, 0, 0, 0, 0, 0, 0]) == [-10, -10, -10, -5, -5, -5, -5, -5, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]) == [2, 2, 3, 3, 3, 1, 1, 1, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(nums = [-1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -6, -6, -7, -7, -8, -8, -9, -9, -10, -10, -11, -11, -12, -12, -13, -13, -14, -14, -15, -15]) == [-1, -1, -2, -2, -3, -3, -4, -4, -5, -5, -6, -6, -7, -7, -8, -8, -9, -9, -10, -10, -11, -11, -12, -12, -13, -13, -14, -14, -15, -15]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [0, 0, 0, 0, 0, -1, -1, -1, 1, 1, 1, 1, 1]) == [-1, -1, -1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6]) == [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 40, 40, 40, 40, 40, 40, 30, 30, 30, 20, 20, 10]) == [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 40, 40, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]\n assert candidate(nums = [0, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, -1, -1]) == [1, 0, 2, 2, -1, -1, 3, 3, 3, 4, 4, 4, 4]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().frequencySort", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector frequencySort(vector& nums) {", "container": "Solution", "callable": "frequencySort", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1637, "task_id": "widest-vertical-area-between-two-points-containing-no-points", "difficulty": "Easy", "problem_description": "Given n points on a 2D plane where points[i] = [xi, yi], Return the widest vertical area between two points such that no points are inside the area.\nA vertical area is an area of fixed-width extending infinitely along the y-axis (i.e., infinite height). The widest vertical area is the one with the maximum width.\nNote that points on the edge of a vertical area are not considered included in the area.\n \nExample 1:\n​\n\nInput: points = [[8,7],[9,9],[7,4],[9,7]]\nOutput: 1\nExplanation: Both the red and the blue area are optimal.\n\nExample 2:\n\nInput: points = [[3,1],[9,0],[1,0],[1,4],[5,3],[8,8]]\nOutput: 3\n\n \nConstraints:\n\nn == points.length\n2 <= n <= 105\npoints[i].length == 2\n0 <= xi, yi <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 1\n assert candidate(points = [[1, 10], [3, 3], [5, 5], [7, 7], [9, 9]]) == 2\n assert candidate(points = [[5, 1], [4, 1], [3, 1], [2, 1], [1, 1]]) == 1\n assert candidate(points = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]]) == 10\n assert candidate(points = [[1, 1], [3, 3], [5, 5], [7, 7]]) == 2\n assert candidate(points = [[3, 1], [9, 0], [1, 0], [1, 4], [5, 3], [8, 8]]) == 3\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 1\n assert candidate(points = [[0, 0], [1000000000, 1000000000]]) == 1000000000\n assert candidate(points = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600]]) == 100\n assert candidate(points = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3]]) == 1\n assert candidate(points = [[8, 7], [9, 9], [7, 4], [9, 7]]) == 1\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]]) == 10\n assert candidate(points = [[5, 5], [15, 5], [25, 5], [35, 5], [45, 5]]) == 10\n assert candidate(points = [[1, 2], [4, 5], [7, 8], [10, 11], [13, 14]]) == 3\n assert candidate(points = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]]) == 1\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40]]) == 10\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900], [1000, 1000]]) == 100\n assert candidate(points = [[1, 1], [2, 2], [4, 4], [8, 8], [16, 16], [32, 32], [64, 64], [128, 128], [256, 256], [512, 512]]) == 256\n assert candidate(points = [[5, 1], [4, 1], [3, 1], [2, 1], [1, 1], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]]) == 1\n assert candidate(points = [[1, 1], [1000000000, 1000000000], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 999999991\n assert candidate(points = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100], [11, 110]]) == 1\n assert candidate(points = [[2, 5], [2, 8], [3, 6], [5, 9], [7, 10], [9, 3], [11, 7], [13, 4]]) == 2\n assert candidate(points = [[1, 10], [10, 1], [100, 10], [1000, 1], [10000, 10], [100000, 1], [1000000, 10], [10000000, 1], [100000000, 10], [1000000000, 1]]) == 900000000\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [10, 10], [20, 20], [30, 30], [40, 40]]) == 10\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == 1\n assert candidate(points = [[2, 1], [4, 3], [6, 5], [8, 7], [10, 9], [12, 11], [14, 13], [16, 15], [18, 17], [20, 19], [22, 21]]) == 2\n assert candidate(points = [[1, 999999999], [2, 999999998], [3, 999999997], [4, 999999996], [5, 999999995], [6, 999999994], [7, 999999993], [8, 999999992], [9, 999999991], [10, 999999990]]) == 1\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 1\n assert candidate(points = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0], [11, 1], [12, 2], [13, 3], [14, 4], [15, 5], [16, 6], [17, 7], [18, 8], [19, 9]]) == 1\n assert candidate(points = [[1, 5], [3, 5], [5, 5], [7, 5], [9, 5], [11, 5], [13, 5], [15, 5], [17, 5], [19, 5], [21, 5], [23, 5], [25, 5], [27, 5], [29, 5], [31, 5], [33, 5], [35, 5]]) == 2\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 1\n assert candidate(points = [[5, 2], [4, 3], [3, 4], [2, 5], [1, 6], [0, 7], [10, 8], [9, 9], [8, 10], [7, 11]]) == 2\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [5, 5], [8, 8], [13, 13], [21, 21], [34, 34], [55, 55], [89, 89], [144, 144], [233, 233], [377, 377]]) == 144\n assert candidate(points = [[2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15]]) == 2\n assert candidate(points = [[500000000, 500000000], [600000000, 500000000], [700000000, 500000000], [800000000, 500000000], [900000000, 500000000], [1000000000, 500000000], [1100000000, 500000000], [1200000000, 500000000], [1300000000, 500000000], [1400000000, 500000000]]) == 100000000\n assert candidate(points = [[1, 1], [2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6], [8, 9], [9, 8], [10, 11], [11, 10], [12, 13], [13, 12], [14, 15], [15, 14]]) == 1\n assert candidate(points = [[100, 1], [200, 1], [300, 1], [400, 1], [500, 1], [600, 1], [700, 1], [800, 1], [900, 1], [1000, 1]]) == 100\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600]]) == 100\n assert candidate(points = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15], [17, 17], [19, 19], [21, 21], [23, 23], [25, 25], [27, 27], [29, 29], [31, 31]]) == 2\n assert candidate(points = [[1, 1000000000], [1000000000, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 999999991\n assert candidate(points = [[1000000000, 1], [2000000000, 2], [3000000000, 3], [4000000000, 4], [5000000000, 5]]) == 1000000000\n assert candidate(points = [[1, 1], [10, 10], [100, 100], [1000, 1000], [10000, 10000], [100000, 100000], [1000000, 1000000], [10000000, 10000000], [100000000, 100000000], [1000000000, 1000000000], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 900000000\n assert candidate(points = [[1000000000, 10], [500000000, 20], [250000000, 30], [125000000, 40], [62500000, 50]]) == 500000000\n assert candidate(points = [[10, 10], [20, 25], [30, 30], [40, 45], [50, 50], [60, 65], [70, 70], [80, 85], [90, 90], [100, 105]]) == 10\n assert candidate(points = [[100, 1], [200, 1], [300, 1], [400, 1], [500, 1], [600, 1], [700, 1], [800, 1], [900, 1], [1000, 1]]) == 100\n assert candidate(points = [[10, 10], [100, 20], [1000, 30], [10000, 40], [100000, 50], [1000000, 60], [10000000, 70], [100000000, 80], [1000000000, 90]]) == 900000000\n assert candidate(points = [[5, 5], [10, 5], [15, 5], [20, 5], [25, 5], [30, 5], [35, 5], [40, 5], [45, 5], [50, 5]]) == 5\n assert candidate(points = [[1, 1], [500000000, 1], [1000000000, 1], [1500000000, 1], [2000000000, 1], [2500000000, 1], [3000000000, 1], [3500000000, 1], [4000000000, 1], [4500000000, 1], [5000000000, 1], [5500000000, 1], [6000000000, 1], [6500000000, 1], [7000000000, 1], [7500000000, 1], [8000000000, 1], [8500000000, 1], [9000000000, 1], [9500000000, 1], [10000000000, 1]]) == 500000000\n assert candidate(points = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15], [17, 17], [19, 19], [21, 21], [23, 23], [25, 25]]) == 2\n assert candidate(points = [[1, 1], [1000000000, 1], [500000000, 1], [750000000, 1], [250000000, 1], [125000000, 1], [375000000, 1], [625000000, 1], [875000000, 1]]) == 125000000\n assert candidate(points = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10], [110, 10], [120, 10], [130, 10], [140, 10], [150, 10], [160, 10], [170, 10], [180, 10], [190, 10], [200, 10], [210, 10], [220, 10], [230, 10], [240, 10], [250, 10], [260, 10], [270, 10], [280, 10], [290, 10], [300, 10], [310, 10], [320, 10], [330, 10], [340, 10], [350, 10], [360, 10], [370, 10], [380, 10], [390, 10], [400, 10], [410, 10], [420, 10], [430, 10], [440, 10], [450, 10], [460, 10], [470, 10], [480, 10], [490, 10], [500, 10]]) == 10\n assert candidate(points = [[1, 2], [4, 6], [7, 8], [10, 5], [13, 9], [16, 3], [19, 7]]) == 3\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16]]) == 2\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2]]) == 1\n assert candidate(points = [[1000000000, 1000000000], [999999999, 999999999], [999999998, 1000000000], [999999997, 999999999], [999999996, 1000000000], [999999995, 999999999], [999999994, 1000000000]]) == 1\n assert candidate(points = [[1, 10], [100, 100], [200, 100], [300, 100], [400, 100], [500, 100]]) == 100\n assert candidate(points = [[10, 20], [20, 10], [30, 30], [40, 20], [50, 10], [60, 30], [70, 20], [80, 10], [90, 30], [100, 20]]) == 10\n assert candidate(points = [[1, 2], [3, 4], [6, 5], [7, 8], [10, 9], [15, 1], [20, 6], [25, 3]]) == 5\n assert candidate(points = [[10, 1], [15, 2], [20, 3], [25, 4], [30, 5], [35, 6], [40, 7], [45, 8], [50, 9], [55, 10], [60, 11], [65, 12], [70, 13], [75, 14], [80, 15]]) == 5\n assert candidate(points = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110], [110, 120], [120, 130], [130, 140], [140, 150], [150, 160], [160, 170], [170, 180], [180, 190], [190, 200], [200, 210], [210, 220], [220, 230], [230, 240], [240, 250], [250, 260], [260, 270], [270, 280], [280, 290], [290, 300]]) == 10\n assert candidate(points = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 1\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1], [16, 1], [17, 1], [18, 1], [19, 1], [20, 1]]) == 1\n assert candidate(points = [[100, 100], [101, 101], [102, 102], [200, 200], [201, 201], [300, 300], [301, 301]]) == 99\n assert candidate(points = [[1, 1], [10, 10], [100, 100], [1000, 1000], [10000, 10000], [100000, 100000], [1000000, 1000000], [10000000, 10000000], [100000000, 100000000]]) == 90000000\n assert candidate(points = [[10, 15], [25, 20], [5, 5], [35, 30], [40, 40], [50, 5], [60, 60], [75, 80], [80, 85], [90, 90]]) == 15\n assert candidate(points = [[1, 1], [2, 2], [4, 4], [8, 8], [16, 16], [32, 32], [64, 64], [128, 128], [256, 256], [512, 512], [1024, 1024]]) == 512\n assert candidate(points = [[0, 0], [0, 1], [0, 2], [0, 3], [1, 0], [1, 1], [1, 2], [1, 3], [2, 0], [2, 1], [2, 2], [2, 3]]) == 1\n assert candidate(points = [[1, 1], [1000000000, 1000000000], [2, 2], [999999999, 999999999], [3, 3], [999999998, 999999998]]) == 999999995\n assert candidate(points = [[1, 1], [1000000000, 1000000000], [500000000, 500000000], [250000000, 250000000], [750000000, 750000000]]) == 250000000\n assert candidate(points = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19]]) == 1\n assert candidate(points = [[1, 9], [3, 8], [5, 7], [7, 6], [9, 5], [11, 4], [13, 3], [15, 2], [17, 1], [19, 0], [21, 9], [23, 8], [25, 7], [27, 6], [29, 5], [31, 4], [33, 3], [35, 2], [37, 1], [39, 0]]) == 2\n assert candidate(points = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0], [11, 9], [12, 8], [13, 7], [14, 6], [15, 5], [16, 4], [17, 3], [18, 2], [19, 1], [20, 0]]) == 1\n assert candidate(points = [[5, 5], [5, 1], [5, 9], [10, 10], [10, 5], [10, 0], [15, 15], [15, 10], [15, 0]]) == 5\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 2\n assert candidate(points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15]]) == 0\n assert candidate(points = [[100, 200], [200, 200], [300, 200], [400, 200], [500, 200], [600, 200], [700, 200], [800, 200], [900, 200], [1000, 200]]) == 100\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500]]) == 50\n assert candidate(points = [[1, 10], [2, 20], [3, 30], [10, 40], [11, 50], [20, 60], [21, 70]]) == 9\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]]) == 1\n assert candidate(points = [[1000000, 1], [2000000, 2], [3000000, 3], [4000000, 4], [5000000, 5], [6000000, 6], [7000000, 7], [8000000, 8], [9000000, 9], [10000000, 10]]) == 1000000\n assert candidate(points = [[1, 1], [1000000000, 1000000000], [500000000, 500000000], [250000000, 250000000], [750000000, 750000000], [125000000, 125000000], [625000000, 625000000], [375000000, 375000000], [875000000, 875000000]]) == 125000000\n assert candidate(points = [[10, 20], [30, 20], [20, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10]]) == 10\n assert candidate(points = [[500000000, 1], [500000001, 2], [500000002, 3], [500000003, 4], [500000004, 5]]) == 1\n assert candidate(points = [[1000000000, 0], [1000000000, 1000000000], [0, 0], [0, 1000000000], [500000000, 500000000]]) == 500000000\n assert candidate(points = [[1, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 1\n assert candidate(points = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65], [75, 75], [85, 85], [95, 95], [105, 105]]) == 10\n assert candidate(points = [[1, 1], [10, 2], [100, 3], [1000, 4], [10000, 5], [100000, 6], [1000000, 7], [10000000, 8], [100000000, 9], [1000000000, 10]]) == 900000000\n assert candidate(points = [[1, 5], [2, 3], [3, 1], [4, 4], [5, 7], [6, 2], [7, 6], [8, 8], [9, 9], [10, 0]]) == 1\n assert candidate(points = [[0, 0], [1000000000, 1000000000], [500000000, 500000000], [250000000, 250000000], [750000000, 750000000]]) == 250000000\n assert candidate(points = [[8, 1], [16, 2], [24, 3], [32, 4], [40, 5], [48, 6], [56, 7], [64, 8], [72, 9], [80, 10], [88, 11], [96, 12], [104, 13], [112, 14], [120, 15]]) == 8\n assert candidate(points = [[1, 10], [2, 20], [4, 30], [8, 40], [16, 50], [32, 60], [64, 70], [128, 80], [256, 90], [512, 100]]) == 256\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500], [550, 550], [600, 600]]) == 50\n assert candidate(points = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [110, 11]]) == 10\n assert candidate(points = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0], [11, 9], [12, 8], [13, 7], [14, 6], [15, 5]]) == 1\n assert candidate(points = [[1, 1], [2, 2], [4, 4], [8, 8], [16, 16], [32, 32], [64, 64], [128, 128], [256, 256], [512, 512], [1024, 1024], [2048, 2048], [4096, 4096], [8192, 8192], [16384, 16384]]) == 8192\n assert candidate(points = [[5, 9], [5, 8], [5, 7], [5, 6], [5, 5], [5, 4], [5, 3], [5, 2], [5, 1], [5, 0]]) == 0\n assert candidate(points = [[10, 1], [20, 1], [30, 1], [40, 1], [50, 1], [60, 1], [70, 1], [80, 1], [90, 1], [100, 1]]) == 10\n assert candidate(points = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [2, 1]]) == 1\n assert candidate(points = [[1, 1], [10, 1], [100, 1], [1000, 1], [10000, 1], [100000, 1], [1000000, 1], [10000000, 1], [100000000, 1], [1000000000, 1]]) == 900000000\n assert candidate(points = [[1, 10], [1, 20], [1, 30], [1, 40], [1, 50], [1, 60], [1, 70], [1, 80], [1, 90], [1, 100], [1, 110], [1, 120], [1, 130], [1, 140], [1, 150]]) == 0\n assert candidate(points = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [110, 11], [120, 12], [130, 13], [140, 14], [150, 15]]) == 10\n assert candidate(points = [[8, 7], [9, 9], [7, 4], [9, 7], [11, 11], [12, 12], [10, 10], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18]]) == 1\n assert candidate(points = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]) == 1\n assert candidate(points = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]]) == 1\n"}, "metadata": {"canonical_parameter_names": ["points"], "leetcode_dataset_entry_point": "Solution().maxWidthOfVerticalArea", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxWidthOfVerticalArea(vector>& points) {", "container": "Solution", "callable": "maxWidthOfVerticalArea", "parameters": [{"name": "points", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1638, "task_id": "count-substrings-that-differ-by-one-character", "difficulty": "Medium", "problem_description": "Given two strings s and t, find the number of ways you can choose a non-empty substring of s and replace a single character by a different character such that the resulting substring is a substring of t. In other words, find the number of substrings in s that differ from some substring in t by exactly one character.\nFor example, the underlined substrings in \"computer\" and \"computation\" only differ by the 'e'/'a', so this is a valid way.\nReturn the number of substrings that satisfy the condition above.\nA substring is a contiguous sequence of characters within a string.\n \nExample 1:\n\nInput: s = \"aba\", t = \"baba\"\nOutput: 6\nExplanation: The following are the pairs of substrings from s and t that differ by exactly 1 character:\n(\"aba\", \"baba\")\n(\"aba\", \"baba\")\n(\"aba\", \"baba\")\n(\"aba\", \"baba\")\n(\"aba\", \"baba\")\n(\"aba\", \"baba\")\nThe underlined portions are the substrings that are chosen from s and t.\n\n​​Example 2:\n\nInput: s = \"ab\", t = \"bb\"\nOutput: 3\nExplanation: The following are the pairs of substrings from s and t that differ by 1 character:\n(\"ab\", \"bb\")\n(\"ab\", \"bb\")\n(\"ab\", \"bb\")\n​​​​The underlined portions are the substrings that are chosen from s and t.\n\n \nConstraints:\n\n1 <= s.length, t.length <= 100\ns and t consist of lowercase English letters only.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abc\",t = \"abcd\") == 9\n assert candidate(s = \"abcde\",t = \"bcdef\") == 21\n assert candidate(s = \"aaaa\",t = \"bbbb\") == 16\n assert candidate(s = \"xyz\",t = \"xya\") == 9\n assert candidate(s = \"python\",t = \"typhon\") == 40\n assert candidate(s = \"xyz\",t = \"xyy\") == 9\n assert candidate(s = \"zzz\",t = \"zzz\") == 0\n assert candidate(s = \"same\",t = \"same\") == 12\n assert candidate(s = \"abcd\",t = \"abcf\") == 16\n assert candidate(s = \"abcde\",t = \"fghij\") == 25\n assert candidate(s = \"abcabc\",t = \"abcabc\") == 24\n assert candidate(s = \"aaaa\",t = \"aaab\") == 10\n assert candidate(s = \"mississippi\",t = \"misissippi\") == 126\n assert candidate(s = \"xyz\",t = \"xyw\") == 9\n assert candidate(s = \"a\",t = \"a\") == 0\n assert candidate(s = \"abcd\",t = \"dcba\") == 16\n assert candidate(s = \"abc\",t = \"def\") == 9\n assert candidate(s = \"a\",t = \"b\") == 1\n assert candidate(s = \"test\",t = \"tast\") == 16\n assert candidate(s = \"aba\",t = \"baba\") == 6\n assert candidate(s = \"aaa\",t = \"aaa\") == 0\n assert candidate(s = \"test\",t = \"text\") == 16\n assert candidate(s = \"abcd\",t = \"abce\") == 16\n assert candidate(s = \"hello\",t = \"hallo\") == 30\n assert candidate(s = \"code\",t = \"cide\") == 18\n assert candidate(s = \"ab\",t = \"bb\") == 3\n assert candidate(s = \"same\",t = \"sane\") == 18\n assert candidate(s = \"abcdefg\",t = \"abcdxyz\") == 49\n assert candidate(s = \"aaaaaab\",t = \"aaaaaac\") == 49\n assert candidate(s = \"qwertyuiop\",t = \"qwertuiopq\") == 99\n assert candidate(s = \"banana\",t = \"banane\") == 38\n assert candidate(s = \"asdfghjkl\",t = \"asdfghjkl\") == 72\n assert candidate(s = \"substring\",t = \"substrung\") == 94\n assert candidate(s = \"aaaaabbbbb\",t = \"bbbbbbaaaa\") == 91\n assert candidate(s = \"banana\",t = \"anana\") == 21\n assert candidate(s = \"algorithm\",t = \"algorihm\") == 72\n assert candidate(s = \"racecar\",t = \"racecdr\") == 55\n assert candidate(s = \"abacaba\",t = \"abacabb\") == 50\n assert candidate(s = \"aabbcc\",t = \"aabbcz\") == 41\n assert candidate(s = \"abcdefg\",t = \"gfedcba\") == 52\n assert candidate(s = \"aabbccddeeff\",t = \"aaabccddeeff\") == 177\n assert candidate(s = \"hellohello\",t = \"hellohelll\") == 101\n assert candidate(s = \"aabbccdd\",t = \"bbccddaa\") == 64\n assert candidate(s = \"racecar\",t = \"racecars\") == 52\n assert candidate(s = \"xyzxyzxyz\",t = \"zyxzyxzyx\") == 96\n assert candidate(s = \"programming\",t = \"programminh\") == 125\n assert candidate(s = \"banana\",t = \"bandana\") == 44\n assert candidate(s = \"abcdefg\",t = \"abcdefgh\") == 49\n assert candidate(s = \"qwert\",t = \"qwqrt\") == 29\n assert candidate(s = \"abcdefg\",t = \"abcdeff\") == 49\n assert candidate(s = \"abcdefghij\",t = \"abcdefghjk\") == 100\n assert candidate(s = \"abcabcabc\",t = \"abcabcabd\") == 72\n assert candidate(s = \"aaaaabbbbb\",t = \"aaaabbbbbb\") == 123\n assert candidate(s = \"abcdefghij\",t = \"abcdefghib\") == 100\n assert candidate(s = \"abcdefghi\",t = \"abcfghi\") == 63\n assert candidate(s = \"hellohello\",t = \"hallohallo\") == 134\n assert candidate(s = \"abcdefgh\",t = \"abcdefgha\") == 63\n assert candidate(s = \"qwert\",t = \"qwera\") == 25\n assert candidate(s = \"programming\",t = \"progrcmming\") == 150\n assert candidate(s = \"banana\",t = \"banama\") == 42\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",t = \"pneumonoultramicroscopicsilicovolcanoconiosus\") == 2250\n assert candidate(s = \"abcdabcd\",t = \"abceabcd\") == 72\n assert candidate(s = \"abcdefghij\",t = \"abcdefghix\") == 100\n assert candidate(s = \"example\",t = \"exampel\") == 48\n assert candidate(s = \"abcdefgh\",t = \"abxdefgh\") == 74\n assert candidate(s = \"abcabcabc\",t = \"defdefdef\") == 81\n assert candidate(s = \"programming\",t = \"prognamming\") == 149\n assert candidate(s = \"abcdefghij\",t = \"jihgfedcba\") == 106\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",t = \"pneumonoultramicroscopicsilicovolcanoconiosi\") == 2118\n assert candidate(s = \"abcdef\",t = \"fedcba\") == 38\n assert candidate(s = \"abcdabcd\",t = \"dcbaabcd\") == 66\n assert candidate(s = \"abcdefgh\",t = \"fedcbagh\") == 68\n assert candidate(s = \"abcdefgh\",t = \"abcdexyz\") == 64\n assert candidate(s = \"abcdefg\",t = \"fghijkl\") == 47\n assert candidate(s = \"abcdefg\",t = \"abcdefh\") == 49\n assert candidate(s = \"abcdefghij\",t = \"abcdefghia\") == 99\n assert candidate(s = \"abcdef\",t = \"abcxef\") == 42\n assert candidate(s = \"abcdeabcde\",t = \"abcdeabcda\") == 94\n assert candidate(s = \"xyzzyx\",t = \"zyxzyx\") == 38\n assert candidate(s = \"zxcvbnm\",t = \"zxsvbnm\") == 57\n assert candidate(s = \"abcdabcd\",t = \"abxdabcd\") == 72\n assert candidate(s = \"mississippi\",t = \"misssissippi\") == 155\n assert candidate(s = \"longerstring\",t = \"longerstirng\") == 148\n assert candidate(s = \"pqrstuvw\",t = \"pqrsvwxy\") == 64\n assert candidate(s = \"zzzzzzzzzz\",t = \"zzzzzzzzza\") == 55\n assert candidate(s = \"abcdefg\",t = \"abcdefi\") == 49\n assert candidate(s = \"substring\",t = \"substrang\") == 93\n assert candidate(s = \"abacaba\",t = \"abaxaba\") == 56\n assert candidate(s = \"abcabcabc\",t = \"abcabcab\") == 48\n assert candidate(s = \"abcdefgh\",t = \"abcefgih\") == 67\n assert candidate(s = \"abcdefgabcdefg\",t = \"abcdefgabcdeff\") == 189\n assert candidate(s = \"python\",t = \"pythpn\") == 40\n assert candidate(s = \"abcdabcd\",t = \"abcddcba\") == 66\n assert candidate(s = \"abcdefg\",t = \"abcdefj\") == 49\n assert candidate(s = \"testtest\",t = \"tasttest\") == 68\n assert candidate(s = \"algorithm\",t = \"algorithr\") == 81\n assert candidate(s = \"aaaaab\",t = \"aaaabb\") == 35\n assert candidate(s = \"programming\",t = \"programming\") == 114\n assert candidate(s = \"banana\",t = \"bananas\") == 40\n assert candidate(s = \"testcase\",t = \"tastcase\") == 73\n assert candidate(s = \"aabbcc\",t = \"aabbbcc\") == 54\n assert candidate(s = \"qwertyuiop\",t = \"qwertuiop\") == 90\n assert candidate(s = \"programming\",t = \"programmimg\") == 136\n assert candidate(s = \"aabbccddeeff\",t = \"aabbccddeegg\") == 160\n assert candidate(s = \"abcdefg\",t = \"abcdefa\") == 48\n assert candidate(s = \"abcabcabc\",t = \"abcababc\") == 66\n assert candidate(s = \"abcabcabc\",t = \"abcabcbca\") == 71\n assert candidate(s = \"abcdefghij\",t = \"abcdefghja\") == 99\n assert candidate(s = \"testtest\",t = \"settsett\") == 83\n assert candidate(s = \"abcdefgh\",t = \"efghabcd\") == 56\n assert candidate(s = \"abacaba\",t = \"abacaba\") == 40\n assert candidate(s = \"abcdxyz\",t = \"xyzabcd\") == 42\n assert candidate(s = \"zzzzzz\",t = \"zzzzzz\") == 0\n assert candidate(s = \"pqrstuv\",t = \"qrsuvwp\") == 48\n assert candidate(s = \"abcabcabc\",t = \"ababcabc\") == 63\n assert candidate(s = \"abcdefghijk\",t = \"abcdefghijx\") == 121\n assert candidate(s = \"algorithm\",t = \"algorihtm\") == 83\n assert candidate(s = \"abcdabcd\",t = \"abacabad\") == 74\n assert candidate(s = \"zzzzz\",t = \"zzzzz\") == 0\n assert candidate(s = \"xyzz\",t = \"xyyz\") == 18\n assert candidate(s = \"banana\",t = \"bananna\") == 44\n assert candidate(s = \"programming\",t = \"progrMming\") == 118\n assert candidate(s = \"aaaaabbbb\",t = \"aaaabbbbb\") == 98\n assert candidate(s = \"pattern\",t = \"patterr\") == 51\n assert candidate(s = \"abacax\",t = \"abacay\") == 40\n assert candidate(s = \"mississippi\",t = \"mississippa\") == 141\n assert candidate(s = \"programming\",t = \"progranning\") == 125\n assert candidate(s = \"substrings\",t = \"substraings\") == 108\n assert candidate(s = \"abcdefgh\",t = \"abcdefga\") == 63\n assert candidate(s = \"mississippi\",t = \"mississipp\") == 119\n assert candidate(s = \"zzzzzzzzzz\",t = \"zzzzzzzzzz\") == 0\n assert candidate(s = \"abcdefghij\",t = \"abcegijhif\") == 104\n assert candidate(s = \"aaaaaaaaaa\",t = \"bbbbbbbbbb\") == 100\n assert candidate(s = \"programming\",t = \"programminq\") == 125\n assert candidate(s = \"xyzzyx\",t = \"zyxzyz\") == 39\n assert candidate(s = \"aabbcc\",t = \"bbaacc\") == 38\n assert candidate(s = \"abcabcabcabc\",t = \"abababababab\") == 166\n assert candidate(s = \"mnopqr\",t = \"mnopqs\") == 36\n assert candidate(s = \"abacabadabacaba\",t = \"abacabadabacaba\") == 272\n assert candidate(s = \"racecar\",t = \"racecer\") == 56\n assert candidate(s = \"abacaba\",t = \"babcaba\") == 47\n assert candidate(s = \"abcdefgh\",t = \"abcdefgi\") == 64\n assert candidate(s = \"abababa\",t = \"bababab\") == 25\n assert candidate(s = \"abcd\",t = \"abdc\") == 16\n assert candidate(s = \"qwerty\",t = \"qwertyuiop\") == 54\n assert candidate(s = \"interview\",t = \"interviww\") == 89\n assert candidate(s = \"mississippi\",t = \"mississipxy\") == 140\n assert candidate(s = \"qwertyuiop\",t = \"poiuytrewq\") == 106\n assert candidate(s = \"abcdefg\",t = \"abacdef\") == 49\n assert candidate(s = \"abcdefg\",t = \"abcxefg\") == 58\n assert candidate(s = \"aaaaabbbbb\",t = \"aaaabbbbba\") == 128\n assert candidate(s = \"aaaaab\",t = \"aaabaa\") == 39\n assert candidate(s = \"aaaaaaab\",t = \"aaaaaaax\") == 64\n assert candidate(s = \"abcdefgh\",t = \"hgfedcba\") == 68\n assert candidate(s = \"abababab\",t = \"babababa\") == 32\n assert candidate(s = \"abcdef\",t = \"abcdeg\") == 36\n"}, "metadata": {"canonical_parameter_names": ["s", "t"], "leetcode_dataset_entry_point": "Solution().countSubstrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countSubstrings(string s, string t) {", "container": "Solution", "callable": "countSubstrings", "parameters": [{"name": "s", "type": "string"}, {"name": "t", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1639, "task_id": "number-of-ways-to-form-a-target-string-given-a-dictionary", "difficulty": "Hard", "problem_description": "You are given a list of strings of the same length words and a string target.\nYour task is to form target using the given words under the following rules:\n\ntarget should be formed from left to right.\nTo form the ith character (0-indexed) of target, you can choose the kth character of the jth string in words if target[i] = words[j][k].\nOnce you use the kth character of the jth string of words, you can no longer use the xth character of any string in words where x <= k. In other words, all characters to the left of or at index k become unusuable for every string.\nRepeat the process until you form the string target.\n\nNotice that you can use multiple characters from the same string in words provided the conditions above are met.\nReturn the number of ways to form target from words. Since the answer may be too large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: words = [\"acca\",\"bbbb\",\"caca\"], target = \"aba\"\nOutput: 6\nExplanation: There are 6 ways to form target.\n\"aba\" -> index 0 (\"acca\"), index 1 (\"bbbb\"), index 3 (\"caca\")\n\"aba\" -> index 0 (\"acca\"), index 2 (\"bbbb\"), index 3 (\"caca\")\n\"aba\" -> index 0 (\"acca\"), index 1 (\"bbbb\"), index 3 (\"acca\")\n\"aba\" -> index 0 (\"acca\"), index 2 (\"bbbb\"), index 3 (\"acca\")\n\"aba\" -> index 1 (\"caca\"), index 2 (\"bbbb\"), index 3 (\"acca\")\n\"aba\" -> index 1 (\"caca\"), index 2 (\"bbbb\"), index 3 (\"caca\")\n\nExample 2:\n\nInput: words = [\"abba\",\"baab\"], target = \"bab\"\nOutput: 4\nExplanation: There are 4 ways to form target.\n\"bab\" -> index 0 (\"baab\"), index 1 (\"baab\"), index 2 (\"abba\")\n\"bab\" -> index 0 (\"baab\"), index 1 (\"baab\"), index 3 (\"baab\")\n\"bab\" -> index 0 (\"baab\"), index 2 (\"baab\"), index 3 (\"baab\")\n\"bab\" -> index 1 (\"abba\"), index 2 (\"baab\"), index 3 (\"baab\")\n\n \nConstraints:\n\n1 <= words.length <= 1000\n1 <= words[i].length <= 1000\nAll strings in words have the same length.\n1 <= target.length <= 1000\nwords[i] and target contain only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['a', 'b', 'c'],target = \"abc\") == 0\n assert candidate(words = ['abc', 'def'],target = \"ad\") == 0\n assert candidate(words = ['mississippi'],target = \"issi\") == 15\n assert candidate(words = ['aaa', 'aaa', 'aaa'],target = \"aaa\") == 27\n assert candidate(words = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba'],target = \"abc\") == 8\n assert candidate(words = ['abc', 'bcd', 'cde'],target = \"abc\") == 1\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi'],target = \"miss\") == 567\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi'],target = \"issi\") == 1215\n assert candidate(words = ['acca', 'bbbb', 'caca'],target = \"aba\") == 6\n assert candidate(words = ['leetcode', 'leetcode', 'leetcode'],target = \"leet\") == 81\n assert candidate(words = ['aaa', 'aaa', 'aaa'],target = \"a\") == 9\n assert candidate(words = ['zzz', 'zzz', 'zzz'],target = \"zzz\") == 27\n assert candidate(words = ['abc', 'bcd', 'cde'],target = \"aab\") == 0\n assert candidate(words = ['abc', 'bcd', 'cde'],target = \"abd\") == 1\n assert candidate(words = ['aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa'],target = \"aaaa\") == 17010\n assert candidate(words = ['abc', 'def', 'ghi'],target = \"adg\") == 0\n assert candidate(words = ['abba', 'baab'],target = \"bab\") == 4\n assert candidate(words = ['mississippi'],target = \"sip\") == 12\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghijk\") == 0\n assert candidate(words = ['abcdef', 'bcadef', 'cdefgh'],target = \"abcd\") == 2\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"mnop\") == 1\n assert candidate(words = ['abcdefgh', 'ijklmnop', 'qrstuvwx', 'yzabcdef'],target = \"aceg\") == 1\n assert candidate(words = ['abcdefg', 'xyzabc', 'mnopqr', 'stuvwx'],target = \"abc\") == 4\n assert candidate(words = ['aaaaaa', 'bbbbbb', 'cccccc', 'dddddd'],target = \"abcd\") == 15\n assert candidate(words = ['aaaa', 'bbbb', 'cccc', 'dddd'],target = \"abcd\") == 1\n assert candidate(words = ['xyzxyz', 'yzxyzy', 'zxyzxy', 'yzyxzy'],target = \"zyx\") == 26\n assert candidate(words = ['thisisanexample', 'thisisanexample', 'thisisanexample'],target = \"example\") == 2187\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi', 'mississippi'],target = \"miss\") == 1792\n assert candidate(words = ['hello', 'hello', 'hello', 'hello', 'hello'],target = \"hello\") == 3125\n assert candidate(words = ['xylophone', 'xylophone', 'xylophone'],target = \"xylo\") == 162\n assert candidate(words = ['hellohellohello', 'worldworldworld', 'hellohellohello'],target = \"helloworld\") == 2496\n assert candidate(words = ['ababababab', 'bababababa', 'ababababab'],target = \"ababab\") == 4339\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"aceg\") == 81\n assert candidate(words = ['lloremipsumdolorsitamet', 'lloremipsumdolorsitamet', 'lloremipsumdolorsitamet'],target = \"lorem\") == 1458\n assert candidate(words = ['abacabadabacaba', 'bacabadabacabab', 'acabadabacababa'],target = \"abacaba\") == 13252\n assert candidate(words = ['abcabc', 'bcabca', 'cababc'],target = \"abc\") == 39\n assert candidate(words = ['aabbccddeeff', 'bbaacceeddff', 'ccaabbeedddf', 'ddaabbccdeff'],target = \"abcde\") == 1496\n assert candidate(words = ['zzzz', 'zzzz', 'zzzz', 'zzzz', 'zzzz'],target = \"zz\") == 150\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"abcd\") == 5\n assert candidate(words = ['zzzzzz', 'yyyyyy', 'xxxxxx', 'wwwwww', 'vvvvvv'],target = \"zyxwv\") == 6\n assert candidate(words = ['abcabcabcabc', 'defdefdefdef', 'ghighighighi', 'jkljkljkljkl'],target = \"adgj\") == 1\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghij\") == 999999937\n assert candidate(words = ['abcde', 'fghij', 'klmno', 'pqrst'],target = \"afkp\") == 0\n assert candidate(words = ['zzzz', 'zzzz', 'zzzz', 'zzzz'],target = \"zzz\") == 256\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"ijkl\") == 1\n assert candidate(words = ['xyzxyzxyzxyz', 'yzxyzyzyzx', 'zxyzxyzxyz'],target = \"xyzxyz\") == 770\n assert candidate(words = ['aabbccddeeff', 'bbccddeeffgg', 'ccddeeffgghh'],target = \"abcdeffg\") == 414\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"acfi\") == 256\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"mnopqr\") == 1\n assert candidate(words = ['hello', 'hello', 'hello', 'hello', 'hello'],target = \"hello\") == 3125\n assert candidate(words = ['aabbcc', 'bbaacc', 'ccaabb'],target = \"abc\") == 40\n assert candidate(words = ['banana', 'banana', 'banana', 'banana'],target = \"ban\") == 192\n assert candidate(words = ['abcdefghi', 'jklmnopqr', 'stuvwxyz'],target = \"adgt\") == 0\n assert candidate(words = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij'],target = \"abcde\") == 1\n assert candidate(words = ['abcabcabc', 'abcabcabc', 'abcabcabc'],target = \"abc\") == 270\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi'],target = \"mississippi\") == 177147\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi', 'mississippi', 'mississippi', 'mississippi'],target = \"issipi\") == 746496\n assert candidate(words = ['zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz'],target = \"zzzz\") == 131250\n assert candidate(words = ['aabbcc', 'ddeeff', 'gghhii', 'jjkkll', 'mmnnoo'],target = \"abcd\") == 0\n assert candidate(words = ['aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa'],target = \"aaaa\") == 53760\n assert candidate(words = ['zzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzz'],target = \"zzzz\") == 392445\n assert candidate(words = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"afg\") == 0\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"acegi\") == 3125\n assert candidate(words = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij'],target = \"efghij\") == 1\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba'],target = \"zyxwvutsrqponmlkjihgfedcba\") == 1\n assert candidate(words = ['abacaba', 'bacabab', 'cacabac', 'dacabad'],target = \"abac\") == 81\n assert candidate(words = ['zzzzzzzzzz', 'yyyyyyyyyy', 'xxxxxxxxxx', 'wwwwwwwwww', 'vvvvvvvvvv'],target = \"zyxwv\") == 252\n assert candidate(words = ['aaaaaaaaaa', 'bbbbbbbbbb', 'cccccccccc'],target = \"abc\") == 120\n assert candidate(words = ['abcdef', 'bcdefg', 'cdefgh', 'defghi', 'efghij'],target = \"defg\") == 15\n assert candidate(words = ['target', 'target', 'target', 'target', 'target'],target = \"target\") == 15625\n assert candidate(words = ['abcdefghij', 'jihgfedcba', 'abcdefghij', 'jihgfedcba'],target = \"abcdefghij\") == 1024\n assert candidate(words = ['abcdefghij', 'klmnopqr', 'stuvwxyz', 'abcdefghij', 'klmnopqr'],target = \"mnop\") == 16\n assert candidate(words = ['banana', 'banana', 'banana', 'banana', 'banana'],target = \"ban\") == 375\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghij\") == 59049\n assert candidate(words = ['aaaa', 'abbb', 'accc', 'addd'],target = \"abcd\") == 4\n assert candidate(words = ['aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz', 'aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz'],target = \"abcdefghijklmnopqrstu\") == 46480318\n assert candidate(words = ['abcdefg', 'abcdefg', 'abcdefg', 'abcdefg', 'abcdefg'],target = \"abcdefg\") == 78125\n assert candidate(words = ['abcdefghijklmnop', 'qrstuvwxyzab', 'cdefghijklmnop', 'qrstuvwxyzab'],target = \"abcde\") == 1\n assert candidate(words = ['aaaaaa', 'bbbbbb', 'cccccc', 'dddddd'],target = \"abcd\") == 15\n assert candidate(words = ['abcdefghijk', 'abcdefghij', 'abcdefghi', 'abcdefgh', 'abcdefg', 'abcdef', 'abcde', 'abcd', 'abc'],target = \"abcdefg\") == 1224720\n assert candidate(words = ['aabbccdd', 'aabbccdd', 'aabbccdd', 'aabbccdd'],target = \"abcd\") == 4096\n assert candidate(words = ['abcd', 'abcf', 'acdf', 'adef'],target = \"ace\") == 4\n assert candidate(words = ['abcdefghij', 'klmnopqr', 'stuvwxyz', 'abcdefghij', 'klmnopqr'],target = \"mnopqrst\") == 0\n assert candidate(words = ['aaaaaaaabaaaaaa', 'baaaaaaaabaaaaa', 'caaaaaaabaaaaaa'],target = \"aaaaaabaaaaaa\") == 9920232\n assert candidate(words = ['abacabadabacaba', 'bcbdbecbdbecb', 'dcdcdcddcdcdc'],target = \"abc\") == 110\n assert candidate(words = ['abababababababab', 'bababababababa', 'abababababababab'],target = \"abab\") == 9394\n assert candidate(words = ['abcdef', 'fedcba', 'abcdef'],target = \"abcdef\") == 64\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"stuvwx\") == 1\n assert candidate(words = ['qwerty', 'qwerty', 'qwerty', 'qwerty', 'qwerty'],target = \"qwe\") == 125\n assert candidate(words = ['abcabcabc', 'defdefdef', 'ghighighi'],target = \"adg\") == 1\n assert candidate(words = ['abcdefghijk', 'abcdefghij', 'abcdefghi', 'abcdefgh', 'abcdefg', 'abcdef', 'abcde', 'abcd', 'abc'],target = \"abc\") == 729\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghijabcdefghij\") == 0\n assert candidate(words = ['aabbcc', 'ddeeff', 'gghhii', 'jjkkgg'],target = \"abgi\") == 4\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba'],target = \"zyxwvutsrqponmlkjihgfedcba\") == 67108864\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'zyxwvutsrqponmlkjihgfedcba', 'abcdefghijklmnopqrstuvwxyz'],target = \"abcdefghijklmnopqrstuvwxyz\") == 67108864\n assert candidate(words = ['aaaa', 'abab', 'acac', 'adad', 'aeae'],target = \"aa\") == 46\n assert candidate(words = ['programming', 'is', 'fun'],target = \"pin\") == 1\n assert candidate(words = ['sequence', 'sequence', 'sequence', 'sequence', 'sequence'],target = \"seq\") == 125\n assert candidate(words = ['abcd', 'abcd', 'abcd', 'abcd', 'abcd'],target = \"abcd\") == 625\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi'],target = \"ssss\") == 81\n assert candidate(words = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"abc\") == 4\n assert candidate(words = ['abcdefghijkl', 'mnopqrstuv', 'wxyzabcdef', 'ghijklmnop'],target = \"mnop\") == 5\n assert candidate(words = ['abcdefghijabcdefghij', 'jihgfedcbaabcdef', 'abcdefghijjihgfe'],target = \"abcdefghij\") == 3536\n assert candidate(words = ['abacaba', 'bcbcbcb', 'cacacac'],target = \"abcabc\") == 10\n assert candidate(words = ['aabbccddeeff', 'gghhiijjkkll', 'mmnnooppqqrr', 'ssttuuvvwwxx'],target = \"abcdefff\") == 0\n assert candidate(words = ['abcde', 'abfgh', 'acjkl'],target = \"abac\") == 0\n assert candidate(words = ['algorithm', 'algorithm', 'algorithm', 'algorithm', 'algorithm'],target = \"algo\") == 625\n assert candidate(words = ['aaaaaaaaaa', 'aaaaaaaaab', 'aaaaaaaaac', 'aaaaaaaaad'],target = \"aaa\") == 5952\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"yzabcd\") == 1\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghij\") == 9765625\n assert candidate(words = ['abcdef', 'ghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"abcde\") == 1\n assert candidate(words = ['abcdefg', 'bcdefgh', 'cdefghi'],target = \"efg\") == 10\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghij\") == 9765625\n assert candidate(words = ['racecar', 'racecar', 'racecar', 'racecar', 'racecar'],target = \"race\") == 625\n assert candidate(words = ['zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz', 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'],target = \"zzzzzzzzzz\") == 277520636\n assert candidate(words = ['abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd'],target = \"abcdabcd\") == 0\n assert candidate(words = ['abcabcabcabc', 'bcabcabcabca', 'cabcabcabcab'],target = \"abcabc\") == 924\n assert candidate(words = ['aabbccdd', 'bbaaddcc', 'ccddaabb', 'ddbbaacc'],target = \"abcd\") == 77\n assert candidate(words = ['aaaaaaaaa', 'bbbbbbbbb', 'ccccccccc', 'ddddddddd', 'eeeeeeeee', 'fffffff', 'ggggggggg', 'hhhhhhhhh', 'iiiiiiiii'],target = \"abcdefghi\") == 1\n assert candidate(words = ['zzzzzz', 'zzzzzz', 'zzzzzz'],target = \"zzz\") == 540\n assert candidate(words = ['quickbrownfox', 'quickbrownfox', 'quickbrownfox'],target = \"quickfox\") == 6561\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghij\") == 59049\n assert candidate(words = ['abacabadabacaba', 'bcbdbecbdbecb', 'dcdcdcddcdcdc', 'efefegfefegfe', 'ghighighihighi'],target = \"abcdefg\") == 40\n assert candidate(words = ['abcdabcdabcd', 'abcdabcdabcd', 'abcdabcdabcd'],target = \"abcd\") == 1215\n assert candidate(words = ['abcdabcdabcd', 'bcdbcdbcdb', 'cdcdcdcdcd'],target = \"abcdabcd\") == 184\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"abcdef\") == 1\n assert candidate(words = ['abcabcabc', 'defdefdef', 'ghighighi'],target = \"adg\") == 1\n assert candidate(words = ['abcdefg', 'hijklmn', 'opqrstu', 'vwxyzab', 'cdefghi'],target = \"abcde\") == 1\n assert candidate(words = ['abcdef', 'ghijkl', 'mnopqr'],target = \"abcghi\") == 0\n assert candidate(words = ['abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy', 'zabcd'],target = \"ace\") == 4\n assert candidate(words = ['aaaaaaaaaa', 'bbbbbbbbbb', 'cccccccccc', 'dddddddddd', 'eeeeeeeeee'],target = \"abcde\") == 252\n assert candidate(words = ['zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz'],target = \"zzz\") == 7680\n assert candidate(words = ['aabbcc', 'ddeeff', 'gghhii', 'jjkkll'],target = \"abcd\") == 0\n assert candidate(words = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee'],target = \"abcde\") == 1\n assert candidate(words = ['abcdefgh', 'efghijkl', 'mnopqr', 'stuvwx', 'yzabcd'],target = \"efgh\") == 5\n assert candidate(words = ['abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz', 'abcdefghijklmnopqrstuvwxyz'],target = \"zyxwvut\") == 0\n assert candidate(words = ['abcde', 'fghij', 'klmno', 'pqrst'],target = \"afk\") == 0\n assert candidate(words = ['leetcode', 'leetcode', 'leetcode', 'leetcode'],target = \"leet\") == 256\n assert candidate(words = ['abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh', 'abcdefgh'],target = \"abcdefgh\") == 390625\n assert candidate(words = ['thisisalongstring', 'thisisalongstring', 'thisisalongstring', 'thisisalongstring'],target = \"thisisalongstring\") == 179869065\n assert candidate(words = ['zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz', 'zzzzzzzzzz'],target = \"zzzz\") == 53760\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"afik\") == 0\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abcdefghij\") == 1048576\n assert candidate(words = ['abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij', 'abcdefghij'],target = \"abc\") == 125\n assert candidate(words = ['mississippi', 'mississippi', 'mississippi'],target = \"missi\") == 3645\n assert candidate(words = ['abracadabra', 'abracadabra', 'abracadabra', 'abracadabra'],target = \"abrac\") == 1024\n assert candidate(words = ['ababababab', 'bababababa', 'ababababab', 'bababababa'],target = \"abab\") == 3360\n assert candidate(words = ['xylophone', 'xylophone', 'xylophone', 'xylophone', 'xylophone'],target = \"xyl\") == 125\n"}, "metadata": {"canonical_parameter_names": ["words", "target"], "leetcode_dataset_entry_point": "Solution().numWays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numWays(vector& words, string target) {", "container": "Solution", "callable": "numWays", "parameters": [{"name": "words", "type": "vector&"}, {"name": "target", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1640, "task_id": "check-array-formation-through-concatenation", "difficulty": "Easy", "problem_description": "You are given an array of distinct integers arr and an array of integer arrays pieces, where the integers in pieces are distinct. Your goal is to form arr by concatenating the arrays in pieces in any order. However, you are not allowed to reorder the integers in each array pieces[i].\nReturn true if it is possible to form the array arr from pieces. Otherwise, return false.\n \nExample 1:\n\nInput: arr = [15,88], pieces = [[88],[15]]\nOutput: true\nExplanation: Concatenate [15] then [88]\n\nExample 2:\n\nInput: arr = [49,18,16], pieces = [[16,18,49]]\nOutput: false\nExplanation: Even though the numbers match, we cannot reorder pieces[0].\n\nExample 3:\n\nInput: arr = [91,4,64,78], pieces = [[78],[4,64],[91]]\nOutput: true\nExplanation: Concatenate [91] then [4,64] then [78]\n\n \nConstraints:\n\n1 <= pieces.length <= arr.length <= 100\nsum(pieces[i].length) == arr.length\n1 <= pieces[i].length <= arr.length\n1 <= arr[i], pieces[i][j] <= 100\nThe integers in arr are distinct.\nThe integers in pieces are distinct (i.e., If we flatten pieces in a 1D array, all the integers in this array are distinct).\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [10, 20, 30, 40, 50],pieces = [[10, 20], [30, 40, 50]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5],pieces = [[2, 3], [1, 4], [5]]) == False\n assert candidate(arr = [91, 4, 64, 78],pieces = [[78], [4, 64], [91]]) == True\n assert candidate(arr = [49, 18, 16],pieces = [[16, 18, 49]]) == False\n assert candidate(arr = [15, 88],pieces = [[88], [15]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5],pieces = [[2], [4, 5], [3], [1]]) == True\n assert candidate(arr = [5, 9, 13, 17, 21, 25],pieces = [[5, 9, 13], [17, 21, 25]]) == True\n assert candidate(arr = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110],pieces = [[101, 102], [103, 104], [105, 106], [107, 108], [109, 110]]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14],pieces = [[2, 4], [6, 8], [10, 12], [14]]) == True\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],pieces = [[100, 99], [98, 97], [96, 95, 94], [93, 92], [91]]) == True\n assert candidate(arr = [91, 4, 64, 78, 100, 50],pieces = [[78, 100], [91, 4], [64], [50]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],pieces = [[1, 3, 5, 7], [9, 11], [13, 15, 17, 19], [21, 23, 25], [27, 29]]) == True\n assert candidate(arr = [8, 16, 24, 32, 40, 48, 56, 64],pieces = [[8, 16, 24], [32, 40, 48], [56, 64]]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 600],pieces = [[100, 200], [300, 400], [500, 600]]) == True\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99],pieces = [[11, 22], [33, 44, 55], [66, 77, 88, 99]]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40],pieces = [[5, 10, 15], [20, 25], [30, 35, 40]]) == True\n assert candidate(arr = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],pieces = [[100], [200, 300], [400, 500, 600], [700, 800], [900, 1000]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],pieces = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],pieces = [[1, 3, 5], [7, 9, 11], [13, 15, 17, 19]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[1, 2, 3], [4, 5], [6, 7, 8, 9, 10]]) == True\n assert candidate(arr = [23, 32, 45, 54, 67, 76, 89, 98],pieces = [[23, 32], [45, 54, 67], [76, 89], [98]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],pieces = [[1, 3], [5, 7, 9], [11, 13], [15, 17, 19]]) == True\n assert candidate(arr = [3, 1, 2, 5, 4],pieces = [[3, 1], [2, 5], [4]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9],pieces = [[1, 2], [3, 4, 5], [6], [7, 8, 9]]) == True\n assert candidate(arr = [8, 6, 7, 5, 3, 0, 9],pieces = [[8, 6], [7, 5], [3, 0], [9]]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pieces = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]]) == True\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],pieces = [[100, 99], [98, 97, 96], [95, 94, 93], [92, 91]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],pieces = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11], [12, 13, 14, 15]]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pieces = [[2, 4], [6, 8, 10], [12, 14], [16, 18, 20]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],pieces = [[1, 2, 3], [4, 5], [6, 7, 8], [9, 10, 11], [12, 13, 14, 15]]) == True\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],pieces = [[9], [8], [7], [6], [5], [4], [3], [2], [1]]) == True\n assert candidate(arr = [42, 13, 56, 78, 91, 100],pieces = [[42], [13, 56], [78], [91, 100]]) == True\n assert candidate(arr = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30],pieces = [[21, 22], [23, 24], [25, 26], [27, 28], [29, 30]]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90],pieces = [[10, 20, 30], [40, 50], [60, 70, 80, 90]]) == True\n assert candidate(arr = [12, 14, 16, 18, 20, 22, 24, 26, 28, 30],pieces = [[12, 14, 16], [18, 20], [22, 24, 26, 28, 30]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == True\n assert candidate(arr = [99, 88, 77, 66, 55, 44, 33, 22, 11],pieces = [[99], [88], [77], [66], [55], [44], [33], [22], [11]]) == True\n assert candidate(arr = [20, 30, 10, 50, 40],pieces = [[20, 30], [10, 50], [40]]) == True\n assert candidate(arr = [7, 14, 28, 21, 42],pieces = [[7, 14, 28], [21, 42]]) == True\n assert candidate(arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],pieces = [[100, 90], [80, 70, 60, 50], [40, 30, 20, 10]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[3, 4], [1, 2], [7, 8], [5, 6], [9, 10]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],pieces = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) == True\n assert candidate(arr = [42, 43, 44, 45, 46, 47, 48, 49, 50],pieces = [[42, 43], [44, 45, 46], [47, 48], [49, 50]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],pieces = [[1, 3, 5], [7, 9], [11, 13], [15, 17, 19]]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40],pieces = [[5], [10, 15], [20, 25, 30], [35, 40]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15],pieces = [[1, 3, 5], [7, 9], [11, 13, 15]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],pieces = [[1], [3, 5], [7, 9], [11, 13], [15, 17, 19]]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90],pieces = [[10], [20], [30], [40], [50], [60], [70], [80], [90]]) == True\n assert candidate(arr = [101, 102, 103, 104, 105, 106],pieces = [[101, 102, 103], [104, 105], [106]]) == True\n assert candidate(arr = [2, 5, 3, 8, 9, 4],pieces = [[2, 5], [3], [8, 9], [4]]) == True\n assert candidate(arr = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],pieces = [[99, 98, 97], [96, 95, 94], [93, 92, 91, 90]]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21, 24, 27],pieces = [[3, 6, 9], [12, 15], [18, 21, 24, 27]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9],pieces = [[1, 2], [3, 4, 5], [6, 7, 8], [9]]) == True\n assert candidate(arr = [3, 5, 7, 9, 11, 13, 15],pieces = [[3, 5, 7], [9, 11], [13, 15]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[1, 2], [3, 4, 5], [6, 7], [8, 9, 10]]) == True\n assert candidate(arr = [3, 5, 7, 9, 11, 13, 15],pieces = [[3, 5, 7], [9], [11, 13, 15]]) == True\n assert candidate(arr = [100, 99, 98, 97, 96],pieces = [[97, 98], [96], [99], [100]]) == False\n assert candidate(arr = [7, 14, 21, 28, 35, 42],pieces = [[7], [14], [21], [28], [35], [42]]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30],pieces = [[10, 15], [5], [20, 25, 30]]) == True\n assert candidate(arr = [5, 6, 1, 2, 3, 4],pieces = [[5, 6], [1, 2], [3, 4]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) == True\n assert candidate(arr = [100, 99, 98, 97, 96, 95],pieces = [[100], [99, 98], [97, 96, 95]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[1, 2], [3, 4, 5], [6, 7, 8, 9, 10]]) == True\n assert candidate(arr = [100, 99, 98, 97, 96, 95],pieces = [[100, 99], [98, 97], [96, 95]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],pieces = [[1, 3, 5], [7, 9, 11], [13, 15, 17], [19, 21]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pieces = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35],pieces = [[5, 10, 15], [20], [25, 30, 35]]) == True\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99],pieces = [[11, 22, 33], [44, 55], [66, 77, 88, 99]]) == True\n assert candidate(arr = [70, 80, 90, 100, 110, 120],pieces = [[70, 80], [90, 100], [110, 120]]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70],pieces = [[10, 20], [30, 40, 50], [60, 70]]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],pieces = [[10, 20, 30], [40, 50, 60], [70, 80, 90], [100, 110], [120, 130, 140, 150]]) == True\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pieces = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]]) == True\n assert candidate(arr = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34],pieces = [[25, 26], [27, 28, 29], [30, 31, 32, 33], [34]]) == True\n assert candidate(arr = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],pieces = [[5, 10, 15], [20, 25, 30], [35, 40, 45], [50]]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16],pieces = [[2, 4], [6, 8, 10], [12, 14, 16]]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pieces = [[2, 4], [6, 8, 10], [12, 14], [16, 18, 20]]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pieces = [[2, 4, 6], [8, 10, 12], [14, 16, 18], [20]]) == True\n assert candidate(arr = [3, 6, 9, 12, 15, 18, 21],pieces = [[3, 6], [9, 12], [15, 18], [21]]) == True\n assert candidate(arr = [5, 4, 3, 2, 1],pieces = [[5], [4, 3], [2, 1]]) == True\n assert candidate(arr = [31, 32, 33, 34, 35, 36, 37, 38, 39, 40],pieces = [[31, 32], [33, 34], [35, 36], [37, 38], [39, 40]]) == True\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],pieces = [[100, 99], [98, 97], [96, 95], [94, 93], [92, 91]]) == True\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pieces = [[2, 4, 6], [8, 10], [12, 14, 16, 18, 20]]) == True\n assert candidate(arr = [23, 29, 20, 32, 45, 67],pieces = [[23, 29, 20], [32], [45, 67]]) == True\n assert candidate(arr = [7, 14, 21, 28, 35, 42, 49, 56],pieces = [[7, 14, 21, 28], [35, 42], [49, 56]]) == True\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9],pieces = [[1, 2], [3, 4], [5, 6], [7, 8], [9]]) == True\n assert candidate(arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],pieces = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10]]) == True\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1],pieces = [[9, 8, 7], [6, 5], [4, 3, 2], [1]]) == True\n assert candidate(arr = [5, 1, 3, 7, 8, 2, 4, 9, 6],pieces = [[1, 3], [5], [7, 8], [2, 4], [9, 6]]) == True\n assert candidate(arr = [100, 200, 300, 400, 500],pieces = [[100], [200, 300], [400, 500]]) == True\n assert candidate(arr = [5, 3, 8, 9, 10, 15, 20],pieces = [[5], [3, 8, 9], [10, 15], [20]]) == True\n assert candidate(arr = [4, 2, 5, 3, 6, 1, 7],pieces = [[4, 2], [5], [3, 6], [1, 7]]) == True\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99],pieces = [[11, 22], [33, 44], [55, 66], [77, 88, 99]]) == True\n assert candidate(arr = [42, 24, 66, 33, 55, 77],pieces = [[42], [24, 66], [33, 55], [77]]) == True\n assert candidate(arr = [8, 6, 7, 5, 3, 0, 9],pieces = [[8, 6], [7, 5, 3], [0, 9]]) == True\n assert candidate(arr = [5, 1, 3, 9, 7, 6],pieces = [[5, 1], [3, 9], [7, 6]]) == True\n assert candidate(arr = [11, 22, 33, 44, 55, 66, 77, 88, 99, 100],pieces = [[11, 22], [33, 44], [55, 66], [77, 88], [99, 100]]) == True\n assert candidate(arr = [60, 70, 80, 90, 100, 110, 120],pieces = [[60, 70, 80], [90, 100], [110, 120]]) == True\n assert candidate(arr = [8, 6, 7, 5, 3, 0, 9],pieces = [[8, 6, 7], [5, 3], [0, 9]]) == True\n assert candidate(arr = [23, 45, 67, 89, 90, 12, 34, 56],pieces = [[23, 45], [67, 89, 90], [12, 34, 56]]) == True\n"}, "metadata": {"canonical_parameter_names": ["arr", "pieces"], "leetcode_dataset_entry_point": "Solution().canFormArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool canFormArray(vector& arr, vector>& pieces) {", "container": "Solution", "callable": "canFormArray", "parameters": [{"name": "arr", "type": "vector&"}, {"name": "pieces", "type": "vector>&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1641, "task_id": "count-sorted-vowel-strings", "difficulty": "Medium", "problem_description": "Given an integer n, return the number of strings of length n that consist only of vowels (a, e, i, o, u) and are lexicographically sorted.\nA string s is lexicographically sorted if for all valid i, s[i] is the same as or comes before s[i+1] in the alphabet.\n \nExample 1:\n\nInput: n = 1\nOutput: 5\nExplanation: The 5 sorted strings that consist of vowels only are [\"a\",\"e\",\"i\",\"o\",\"u\"].\n\nExample 2:\n\nInput: n = 2\nOutput: 15\nExplanation: The 15 sorted strings that consist of vowels only are\n[\"aa\",\"ae\",\"ai\",\"ao\",\"au\",\"ee\",\"ei\",\"eo\",\"eu\",\"ii\",\"io\",\"iu\",\"oo\",\"ou\",\"uu\"].\nNote that \"ea\" is not a valid string since 'e' comes after 'a' in the alphabet.\n\nExample 3:\n\nInput: n = 33\nOutput: 66045\n\n \nConstraints:\n\n1 <= n <= 50 \n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 35\n assert candidate(n = 4) == 70\n assert candidate(n = 33) == 66045\n assert candidate(n = 2) == 15\n assert candidate(n = 20) == 10626\n assert candidate(n = 1) == 5\n assert candidate(n = 50) == 316251\n assert candidate(n = 10) == 1001\n assert candidate(n = 5) == 126\n assert candidate(n = 45) == 211876\n assert candidate(n = 49) == 292825\n assert candidate(n = 12) == 1820\n assert candidate(n = 28) == 35960\n assert candidate(n = 30) == 46376\n assert candidate(n = 40) == 135751\n assert candidate(n = 8) == 495\n assert candidate(n = 22) == 14950\n assert candidate(n = 27) == 31465\n assert candidate(n = 35) == 82251\n assert candidate(n = 15) == 3876\n assert candidate(n = 9) == 715\n assert candidate(n = 6) == 210\n assert candidate(n = 7) == 330\n assert candidate(n = 25) == 23751\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().countVowelStrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countVowelStrings(int n) {", "container": "Solution", "callable": "countVowelStrings", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1642, "task_id": "furthest-building-you-can-reach", "difficulty": "Medium", "problem_description": "You are given an integer array heights representing the heights of buildings, some bricks, and some ladders.\nYou start your journey from building 0 and move to the next building by possibly using bricks or ladders.\nWhile moving from building i to building i+1 (0-indexed),\n\nIf the current building's height is greater than or equal to the next building's height, you do not need a ladder or bricks.\nIf the current building's height is less than the next building's height, you can either use one ladder or (h[i+1] - h[i]) bricks.\n\nReturn the furthest building index (0-indexed) you can reach if you use the given ladders and bricks optimally.\n \nExample 1:\n\n\nInput: heights = [4,2,7,6,9,14,12], bricks = 5, ladders = 1\nOutput: 4\nExplanation: Starting at building 0, you can follow these steps:\n- Go to building 1 without using ladders nor bricks since 4 >= 2.\n- Go to building 2 using 5 bricks. You must use either bricks or ladders because 2 < 7.\n- Go to building 3 without using ladders nor bricks since 7 >= 6.\n- Go to building 4 using your only ladder. You must use either bricks or ladders because 6 < 9.\nIt is impossible to go beyond building 4 because you do not have any more bricks or ladders.\n\nExample 2:\n\nInput: heights = [4,12,2,7,3,18,20,3,19], bricks = 10, ladders = 2\nOutput: 7\n\nExample 3:\n\nInput: heights = [14,3,19,3], bricks = 17, ladders = 0\nOutput: 3\n\n \nConstraints:\n\n1 <= heights.length <= 105\n1 <= heights[i] <= 106\n0 <= bricks <= 109\n0 <= ladders <= heights.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(heights = [10, 15, 20, 25, 30],bricks = 0,ladders = 2) == 2\n assert candidate(heights = [3, 1, 2, 1, 5],bricks = 2,ladders = 1) == 4\n assert candidate(heights = [5, 5, 5, 5, 5],bricks = 0,ladders = 0) == 4\n assert candidate(heights = [1, 1000000, 1, 1000000, 1],bricks = 1000000,ladders = 1) == 4\n assert candidate(heights = [10, 15, 20, 25, 30],bricks = 30,ladders = 2) == 4\n assert candidate(heights = [1, 1000000],bricks = 999999,ladders = 0) == 1\n assert candidate(heights = [14, 3, 19, 3],bricks = 17,ladders = 0) == 3\n assert candidate(heights = [1, 2, 3, 4, 5],bricks = 10,ladders = 0) == 4\n assert candidate(heights = [5, 4, 3, 2, 1],bricks = 0,ladders = 0) == 4\n assert candidate(heights = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],bricks = 100,ladders = 5) == 9\n assert candidate(heights = [100, 90, 80, 70, 60],bricks = 50,ladders = 0) == 4\n assert candidate(heights = [10, 15, 20, 25, 30],bricks = 30,ladders = 0) == 4\n assert candidate(heights = [1, 3, 5, 7, 9],bricks = 20,ladders = 2) == 4\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],bricks = 0,ladders = 5) == 5\n assert candidate(heights = [3, 14, 3, 14, 3, 3, 14, 3, 14],bricks = 1,ladders = 1) == 2\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15],bricks = 20,ladders = 3) == 7\n assert candidate(heights = [1, 3, 5, 7, 9],bricks = 10,ladders = 0) == 4\n assert candidate(heights = [1, 1, 1, 1, 1],bricks = 0,ladders = 0) == 4\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],bricks = 18,ladders = 1) == 9\n assert candidate(heights = [4, 2, 7, 6, 9, 14, 12],bricks = 5,ladders = 1) == 4\n assert candidate(heights = [1, 5, 1, 2, 3, 4, 10000],bricks = 4,ladders = 1) == 5\n assert candidate(heights = [5, 1, 3, 4, 2],bricks = 0,ladders = 1) == 2\n assert candidate(heights = [4, 2, 3],bricks = 0,ladders = 1) == 2\n assert candidate(heights = [5, 18, 22, 33, 8, 26, 48, 29, 55, 46],bricks = 83,ladders = 3) == 9\n assert candidate(heights = [1, 2],bricks = 0,ladders = 0) == 0\n assert candidate(heights = [4, 12, 2, 7, 3, 18, 20, 3, 19],bricks = 10,ladders = 2) == 7\n assert candidate(heights = [1, 3, 5, 7, 9],bricks = 100,ladders = 0) == 4\n assert candidate(heights = [9, 8, 7, 6, 5],bricks = 0,ladders = 5) == 4\n assert candidate(heights = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105],bricks = 100,ladders = 2) == 13\n assert candidate(heights = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],bricks = 10,ladders = 0) == 10\n assert candidate(heights = [1, 3, 5, 4, 2, 1, 3, 5, 4, 2, 1, 3, 5, 4, 2, 1, 3, 5, 4, 2, 1],bricks = 20,ladders = 3) == 20\n assert candidate(heights = [5, 18, 3, 14, 5, 19, 2, 13, 11, 18, 23, 25, 28, 30, 35],bricks = 30,ladders = 4) == 14\n assert candidate(heights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],bricks = 200,ladders = 3) == 9\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],bricks = 10,ladders = 0) == 9\n assert candidate(heights = [1, 2, 3, 100, 101, 102, 103, 104, 105],bricks = 10,ladders = 3) == 8\n assert candidate(heights = [1, 5, 3, 6, 7, 3, 8, 4, 9, 2, 10, 6, 11, 7, 12, 8, 13, 9, 14, 10],bricks = 20,ladders = 4) == 17\n assert candidate(heights = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],bricks = 50,ladders = 2) == 9\n assert candidate(heights = [4, 12, 2, 7, 3, 18, 20, 3, 19, 10, 5, 21, 17, 8, 15],bricks = 15,ladders = 3) == 13\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],bricks = 100,ladders = 3) == 15\n assert candidate(heights = [5, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36],bricks = 50,ladders = 5) == 19\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],bricks = 0,ladders = 0) == 19\n assert candidate(heights = [4, 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50],bricks = 20,ladders = 4) == 10\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],bricks = 100,ladders = 3) == 9\n assert candidate(heights = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],bricks = 0,ladders = 0) == 49\n assert candidate(heights = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],bricks = 100,ladders = 10) == 59\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],bricks = 0,ladders = 0) == 9\n assert candidate(heights = [5, 8, 17, 14, 12, 19, 21, 16, 18, 25, 27, 22, 24, 26, 30],bricks = 30,ladders = 4) == 14\n assert candidate(heights = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],bricks = 50,ladders = 5) == 9\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],bricks = 100,ladders = 5) == 24\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],bricks = 50,ladders = 5) == 19\n assert candidate(heights = [10, 15, 20, 25, 30, 35, 40],bricks = 30,ladders = 2) == 6\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1000],bricks = 0,ladders = 0) == 8\n assert candidate(heights = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],bricks = 15,ladders = 3) == 19\n assert candidate(heights = [3, 17, 9, 16, 14, 3, 17, 13, 19, 20, 15, 2, 18, 12, 1, 12, 14, 9, 1, 19],bricks = 20,ladders = 3) == 14\n assert candidate(heights = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],bricks = 25,ladders = 3) == 9\n assert candidate(heights = [5, 18, 3, 14, 5, 19, 2, 13, 11, 18],bricks = 20,ladders = 3) == 9\n assert candidate(heights = [40, 20, 30, 10, 50, 60, 70, 80, 90],bricks = 100,ladders = 2) == 8\n assert candidate(heights = [1, 2, 3, 4, 5, 15, 20, 25, 30, 35],bricks = 10,ladders = 0) == 4\n assert candidate(heights = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],bricks = 0,ladders = 0) == 29\n assert candidate(heights = [1, 1, 2, 1, 1, 2, 1, 1, 2, 1],bricks = 1,ladders = 1) == 7\n assert candidate(heights = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],bricks = 10,ladders = 0) == 19\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1],bricks = 10,ladders = 5) == 10\n assert candidate(heights = [10, 16, 18, 15, 12, 19, 20, 18, 17, 16],bricks = 15,ladders = 2) == 9\n assert candidate(heights = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],bricks = 0,ladders = 5) == 10\n assert candidate(heights = [5, 4, 3, 2, 1, 0],bricks = 10,ladders = 1) == 5\n assert candidate(heights = [1, 3, 6, 7, 8, 10, 12, 13, 14, 15, 17],bricks = 15,ladders = 2) == 10\n assert candidate(heights = [1, 3, 6, 7, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54],bricks = 100,ladders = 5) == 19\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],bricks = 30,ladders = 5) == 19\n assert candidate(heights = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],bricks = 30,ladders = 1) == 8\n assert candidate(heights = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],bricks = 5,ladders = 0) == 9\n assert candidate(heights = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],bricks = 100,ladders = 5) == 9\n assert candidate(heights = [4, 10, 15, 20, 25, 30, 35, 40, 45, 50],bricks = 50,ladders = 2) == 9\n assert candidate(heights = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],bricks = 50,ladders = 4) == 9\n assert candidate(heights = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],bricks = 0,ladders = 0) == 24\n assert candidate(heights = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],bricks = 10,ladders = 1) == 9\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],bricks = 100,ladders = 3) == 19\n assert candidate(heights = [100, 150, 200, 250, 300, 350, 400, 450, 500],bricks = 1000,ladders = 3) == 8\n assert candidate(heights = [1, 5, 1, 5, 1, 5, 1, 5, 1, 5],bricks = 20,ladders = 3) == 9\n assert candidate(heights = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55],bricks = 100,ladders = 2) == 9\n assert candidate(heights = [1, 5, 20, 30, 40, 50, 60, 70, 80, 90],bricks = 150,ladders = 2) == 9\n assert candidate(heights = [1, 100, 2, 101, 3, 102, 4, 103, 5],bricks = 100,ladders = 2) == 6\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],bricks = 100,ladders = 5) == 24\n assert candidate(heights = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105],bricks = 100,ladders = 5) == 13\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],bricks = 50,ladders = 5) == 9\n assert candidate(heights = [1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000, 1, 1000000],bricks = 1000000,ladders = 4) == 9\n assert candidate(heights = [5, 18, 12, 15, 20, 10, 19, 21],bricks = 50,ladders = 3) == 7\n assert candidate(heights = [4, 4, 4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],bricks = 20,ladders = 2) == 19\n assert candidate(heights = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],bricks = 1,ladders = 1) == 29\n assert candidate(heights = [1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9],bricks = 30,ladders = 5) == 15\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],bricks = 150,ladders = 5) == 29\n assert candidate(heights = [10, 15, 20, 25, 30, 35, 40, 45, 50],bricks = 30,ladders = 2) == 8\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],bricks = 45,ladders = 0) == 9\n assert candidate(heights = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105],bricks = 100,ladders = 1) == 13\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],bricks = 50,ladders = 5) == 14\n assert candidate(heights = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],bricks = 20,ladders = 3) == 16\n assert candidate(heights = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11],bricks = 50,ladders = 3) == 19\n assert candidate(heights = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],bricks = 100,ladders = 3) == 9\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],bricks = 200,ladders = 15) == 39\n assert candidate(heights = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],bricks = 25,ladders = 2) == 8\n assert candidate(heights = [4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1],bricks = 15,ladders = 2) == 19\n assert candidate(heights = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],bricks = 20,ladders = 3) == 19\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],bricks = 100,ladders = 10) == 19\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],bricks = 30,ladders = 2) == 19\n assert candidate(heights = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],bricks = 4000,ladders = 5) == 9\n assert candidate(heights = [5, 8, 6, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24],bricks = 50,ladders = 3) == 19\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],bricks = 50,ladders = 4) == 19\n assert candidate(heights = [1, 5, 7, 8, 10, 12, 15, 20, 25, 30],bricks = 15,ladders = 3) == 9\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],bricks = 150,ladders = 10) == 29\n assert candidate(heights = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],bricks = 55,ladders = 3) == 8\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],bricks = 50,ladders = 2) == 19\n assert candidate(heights = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55],bricks = 20,ladders = 2) == 6\n assert candidate(heights = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119],bricks = 50,ladders = 5) == 19\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],bricks = 50,ladders = 3) == 9\n assert candidate(heights = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],bricks = 0,ladders = 0) == 31\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],bricks = 100,ladders = 0) == 9\n assert candidate(heights = [5, 10, 15, 10, 5, 10, 15, 20, 25, 30],bricks = 40,ladders = 1) == 9\n assert candidate(heights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],bricks = 150,ladders = 3) == 9\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],bricks = 100,ladders = 4) == 24\n"}, "metadata": {"canonical_parameter_names": ["heights", "bricks", "ladders"], "leetcode_dataset_entry_point": "Solution().furthestBuilding", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int furthestBuilding(vector& heights, int bricks, int ladders) {", "container": "Solution", "callable": "furthestBuilding", "parameters": [{"name": "heights", "type": "vector&"}, {"name": "bricks", "type": "int"}, {"name": "ladders", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1643, "task_id": "kth-smallest-instructions", "difficulty": "Hard", "problem_description": "Bob is standing at cell (0, 0), and he wants to reach destination: (row, column). He can only travel right and down. You are going to help Bob by providing instructions for him to reach destination.\nThe instructions are represented as a string, where each character is either:\n\n'H', meaning move horizontally (go right), or\n'V', meaning move vertically (go down).\n\nMultiple instructions will lead Bob to destination. For example, if destination is (2, 3), both \"HHHVV\" and \"HVHVH\" are valid instructions.\nHowever, Bob is very picky. Bob has a lucky number k, and he wants the kth lexicographically smallest instructions that will lead him to destination. k is 1-indexed.\nGiven an integer array destination and an integer k, return the kth lexicographically smallest instructions that will take Bob to destination.\n \nExample 1:\n\n\nInput: destination = [2,3], k = 1\nOutput: \"HHHVV\"\nExplanation: All the instructions that reach (2, 3) in lexicographic order are as follows:\n[\"HHHVV\", \"HHVHV\", \"HHVVH\", \"HVHHV\", \"HVHVH\", \"HVVHH\", \"VHHHV\", \"VHHVH\", \"VHVHH\", \"VVHHH\"].\n\nExample 2:\n\n\nInput: destination = [2,3], k = 2\nOutput: \"HHVHV\"\n\nExample 3:\n\n\nInput: destination = [2,3], k = 3\nOutput: \"HHVVH\"\n\n \nConstraints:\n\ndestination.length == 2\n1 <= row, column <= 15\n1 <= k <= nCr(row + column, row), where nCr(a, b) denotes a choose b​​​​​.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(destination = [3, 3],k = 5) == \"HVHHVV\"\n assert candidate(destination = [2, 3],k = 1) == \"HHHVV\"\n assert candidate(destination = [4, 4],k = 10) == \"HHVVHHVV\"\n assert candidate(destination = [3, 3],k = 10) == \"HVVVHH\"\n assert candidate(destination = [2, 3],k = 2) == \"HHVHV\"\n assert candidate(destination = [2, 3],k = 3) == \"HHVVH\"\n assert candidate(destination = [4, 4],k = 20) == \"HVHVHHVV\"\n assert candidate(destination = [4, 5],k = 10) == \"HHHVVHHVV\"\n assert candidate(destination = [15, 15],k = 1) == \"HHHHHHHHHHHHHHHVVVVVVVVVVVVVVV\"\n assert candidate(destination = [3, 2],k = 4) == \"HVVVH\"\n assert candidate(destination = [3, 4],k = 5) == \"HHVHHVV\"\n assert candidate(destination = [5, 5],k = 100) == \"HVVHHVVHVH\"\n assert candidate(destination = [3, 2],k = 1) == \"HHVVV\"\n assert candidate(destination = [3, 10],k = 175) == \"HVHHHHHHVVHHH\"\n assert candidate(destination = [7, 8],k = 1716) == \"HHVVVVVVVHHHHHH\"\n assert candidate(destination = [12, 12],k = 50000) == \"HHHHHVVVVVVVHVVHHVHHVVHH\"\n assert candidate(destination = [15, 5],k = 2000) == \"HVVHVVVVVVVHVVVVVVHH\"\n assert candidate(destination = [9, 5],k = 252) == \"HVHHVVVVHVHVVV\"\n assert candidate(destination = [5, 7],k = 1000) == \"VVVVVVVVVVVV\"\n assert candidate(destination = [7, 9],k = 300) == \"HHHHHVVVVHHVHHVV\"\n assert candidate(destination = [9, 7],k = 5678) == \"VHHVHVHVVHVHVVVH\"\n assert candidate(destination = [10, 10],k = 5000) == \"HHHHVHVVVVVVVVHHHHHV\"\n assert candidate(destination = [9, 9],k = 1000) == \"HHHHVHVHVVVVVVVHHH\"\n assert candidate(destination = [3, 4],k = 15) == \"HVHVHVH\"\n assert candidate(destination = [14, 10],k = 5000) == \"HHHHHVHVVVVVHVHVHVHVVVVV\"\n assert candidate(destination = [15, 15],k = 10000) == \"HHHHHHHHHHVVVHVHVVVHVVVHVVVVVH\"\n assert candidate(destination = [15, 15],k = 500000) == \"HHHHHHVHHHHVVVVVHHVHHVVVVHVVVV\"\n assert candidate(destination = [8, 12],k = 250) == \"HHHHHHHHVHVVHVVVVVHH\"\n assert candidate(destination = [15, 15],k = 40116600) == \"HVHHHVHVHVVHHVVHHVVVVHVHHHVVHV\"\n assert candidate(destination = [10, 5],k = 200) == \"HHVVVHVVVVVVHHV\"\n assert candidate(destination = [12, 5],k = 1234) == \"HVVVHVVHVVVVHVVHV\"\n assert candidate(destination = [5, 15],k = 3003) == \"HHHHHVVVVVHHHHHHHHHH\"\n assert candidate(destination = [12, 8],k = 500) == \"HHHHVHHVVVVHVVHVVVVV\"\n assert candidate(destination = [7, 6],k = 150) == \"HHVHVHHVHVVVV\"\n assert candidate(destination = [3, 7],k = 123) == \"VVVVVVVVVV\"\n assert candidate(destination = [13, 7],k = 4000) == \"HHVHVVVVVVHHVHVVHVVV\"\n assert candidate(destination = [12, 12],k = 100000) == \"HHHHVVHVVVVHHHHVVHVHVHVV\"\n assert candidate(destination = [2, 13],k = 150) == \"VVVVVVVVVVVVVVV\"\n assert candidate(destination = [10, 10],k = 500) == \"HHHHHHVHVVVVVVVHVHHV\"\n assert candidate(destination = [10, 10],k = 1000) == \"HHHHHHVVVVVVVVVHVHHH\"\n assert candidate(destination = [7, 5],k = 30) == \"HHHVVVVHVVVH\"\n assert candidate(destination = [6, 6],k = 500) == \"VHHHVVHHVHVV\"\n assert candidate(destination = [9, 9],k = 10000) == \"HHVVVHHVHVHHVVHHVV\"\n assert candidate(destination = [6, 7],k = 120) == \"HHHVHVHVVVVHH\"\n assert candidate(destination = [8, 9],k = 500) == \"HHHHVHHHHVVVVHVVV\"\n assert candidate(destination = [15, 15],k = 1000000) == \"HHHHHHVVHVVVVHVVVVHHHVHVVVHHHV\"\n assert candidate(destination = [1, 15],k = 1) == \"HHHHHHHHHHHHHHHV\"\n assert candidate(destination = [10, 10],k = 10000) == \"HHHVHHVVVVVVVHVHHHHV\"\n assert candidate(destination = [10, 10],k = 1000) == \"HHHHHHVVVVVVVVVHVHHH\"\n assert candidate(destination = [7, 8],k = 3000) == \"HVVHVHVVHHHHVVH\"\n assert candidate(destination = [3, 10],k = 100) == \"HHHVHHVHHHHHV\"\n assert candidate(destination = [12, 8],k = 5000) == \"HHHVVVVHHVVHVVHVVVVH\"\n assert candidate(destination = [10, 5],k = 200) == \"HHVVVHVVVVVVHHV\"\n assert candidate(destination = [10, 10],k = 50000) == \"HVHHVHHVVVVVHHHVHVHV\"\n assert candidate(destination = [7, 7],k = 343) == \"HHVHHHVHVVVVVH\"\n assert candidate(destination = [7, 8],k = 1000) == \"HHVHHVVVVVHHVHH\"\n assert candidate(destination = [5, 4],k = 50) == \"HVVVHVHHV\"\n assert candidate(destination = [7, 8],k = 2000) == \"HVHHVHVHVHHVVHV\"\n assert candidate(destination = [3, 12],k = 200) == \"HHHVHHVHVHHHHHH\"\n assert candidate(destination = [6, 14],k = 10000) == \"HHHVHHVVVHVVHHHHHHHH\"\n assert candidate(destination = [8, 9],k = 15000) == \"VHHVHHVVVHHHVVHHV\"\n assert candidate(destination = [12, 4],k = 250) == \"HVVVHVHVVVVHVVVV\"\n assert candidate(destination = [7, 8],k = 1234) == \"HHVHVVVVHHHHHVV\"\n assert candidate(destination = [8, 7],k = 3456) == \"VHHVHVHVVHHVVHV\"\n assert candidate(destination = [13, 2],k = 100) == \"VVVVVVVVVVVHHVV\"\n assert candidate(destination = [11, 11],k = 6000) == \"HHHHHVHVHVVVVHVVHVHVHV\"\n assert candidate(destination = [7, 7],k = 200) == \"HHHVHVVVVHVVHH\"\n assert candidate(destination = [15, 15],k = 12345) == \"HHHHHHHHHHVVVVHVVVVVHVVHHVVVVH\"\n assert candidate(destination = [8, 12],k = 3456) == \"HHHHHVHHVHVHVVHHVVHV\"\n assert candidate(destination = [6, 9],k = 300) == \"HHHHVHVHVVVHVHH\"\n assert candidate(destination = [14, 6],k = 5000) == \"HVHVVVVVHVHVHVHVVVVV\"\n assert candidate(destination = [10, 6],k = 8316) == \"VVVVVVVVVVVVVVVV\"\n assert candidate(destination = [15, 15],k = 10000) == \"HHHHHHHHHHVVVHVHVVVHVVVHVVVVVH\"\n assert candidate(destination = [12, 12],k = 123456) == \"HHHHVVVVVVHHVHHHVHVHHVVV\"\n assert candidate(destination = [10, 10],k = 12870) == \"HHHVHVVVVVHHVVVHHHVH\"\n assert candidate(destination = [14, 6],k = 98765) == \"VVVVVVVVVVVVVVVVVVVV\"\n assert candidate(destination = [8, 6],k = 150) == \"HHHVVVVVHVHHVV\"\n assert candidate(destination = [7, 6],k = 300) == \"HHVVVVHHVHHVV\"\n assert candidate(destination = [12, 8],k = 2500) == \"HHHVHVVHHVVVHVVHVVVV\"\n assert candidate(destination = [5, 6],k = 120) == \"HHVVVHVHVHH\"\n assert candidate(destination = [6, 7],k = 500) == \"HVHHHVVHHVHVV\"\n assert candidate(destination = [9, 7],k = 200) == \"HHHHVVVVVHVVVVHH\"\n assert candidate(destination = [8, 6],k = 500) == \"HVHHHHVVVVHVVV\"\n assert candidate(destination = [15, 15],k = 6435678) == \"HHHHVVVHHHVHHVVVVHVVHHHVHVHVVV\"\n assert candidate(destination = [4, 12],k = 500) == \"HHHVHHHHHHHVHHVV\"\n assert candidate(destination = [8, 7],k = 650) == \"HHVHVHVHVHHVVVV\"\n assert candidate(destination = [6, 7],k = 123) == \"HHHVHVVHHVVHV\"\n assert candidate(destination = [12, 3],k = 200) == \"VVHVVVHHVVVVVVV\"\n assert candidate(destination = [5, 12],k = 500) == \"HHHHHVHHHVHHHVVHV\"\n assert candidate(destination = [5, 7],k = 30) == \"HHHHVHVHVVVH\"\n assert candidate(destination = [6, 4],k = 45) == \"HVHVVVHVHV\"\n assert candidate(destination = [15, 1],k = 1) == \"HVVVVVVVVVVVVVVV\"\n assert candidate(destination = [6, 8],k = 300) == \"HHHVHVHVVVHVHH\"\n"}, "metadata": {"canonical_parameter_names": ["destination", "k"], "leetcode_dataset_entry_point": "Solution().kthSmallestPath", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string kthSmallestPath(vector& destination, int k) {", "container": "Solution", "callable": "kthSmallestPath", "parameters": [{"name": "destination", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1646, "task_id": "get-maximum-in-generated-array", "difficulty": "Easy", "problem_description": "You are given an integer n. A 0-indexed integer array nums of length n + 1 is generated in the following way:\n\nnums[0] = 0\nnums[1] = 1\nnums[2 * i] = nums[i] when 2 <= 2 * i <= n\nnums[2 * i + 1] = nums[i] + nums[i + 1] when 2 <= 2 * i + 1 <= n\n\nReturn the maximum integer in the array nums​​​.\n \nExample 1:\n\nInput: n = 7\nOutput: 3\nExplanation: According to the given rules:\n nums[0] = 0\n nums[1] = 1\n nums[(1 * 2) = 2] = nums[1] = 1\n nums[(1 * 2) + 1 = 3] = nums[1] + nums[2] = 1 + 1 = 2\n nums[(2 * 2) = 4] = nums[2] = 1\n nums[(2 * 2) + 1 = 5] = nums[2] + nums[3] = 1 + 2 = 3\n nums[(3 * 2) = 6] = nums[3] = 2\n nums[(3 * 2) + 1 = 7] = nums[3] + nums[4] = 2 + 1 = 3\nHence, nums = [0,1,1,2,1,3,2,3], and the maximum is max(0,1,1,2,1,3,2,3) = 3.\n\nExample 2:\n\nInput: n = 2\nOutput: 1\nExplanation: According to the given rules, nums = [0,1,1]. The maximum is max(0,1,1) = 1.\n\nExample 3:\n\nInput: n = 3\nOutput: 2\nExplanation: According to the given rules, nums = [0,1,1,2]. The maximum is max(0,1,1,2) = 2.\n\n \nConstraints:\n\n0 <= n <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 0) == 0\n assert candidate(n = 3) == 2\n assert candidate(n = 100) == 21\n assert candidate(n = 99) == 21\n assert candidate(n = 2) == 1\n assert candidate(n = 20) == 7\n assert candidate(n = 1) == 1\n assert candidate(n = 50) == 13\n assert candidate(n = 7) == 3\n assert candidate(n = 10) == 4\n assert candidate(n = 88) == 21\n assert candidate(n = 97) == 21\n assert candidate(n = 63) == 13\n assert candidate(n = 45) == 13\n assert candidate(n = 49) == 13\n assert candidate(n = 47) == 13\n assert candidate(n = 60) == 13\n assert candidate(n = 64) == 13\n assert candidate(n = 37) == 11\n assert candidate(n = 17) == 5\n assert candidate(n = 42) == 11\n assert candidate(n = 90) == 21\n assert candidate(n = 22) == 8\n assert candidate(n = 89) == 21\n assert candidate(n = 75) == 18\n assert candidate(n = 81) == 18\n assert candidate(n = 24) == 8\n assert candidate(n = 11) == 5\n assert candidate(n = 15) == 5\n assert candidate(n = 31) == 8\n assert candidate(n = 25) == 8\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().getMaximumGenerated", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int getMaximumGenerated(int n) {", "container": "Solution", "callable": "getMaximumGenerated", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1647, "task_id": "minimum-deletions-to-make-character-frequencies-unique", "difficulty": "Medium", "problem_description": "A string s is called good if there are no two different characters in s that have the same frequency.\nGiven a string s, return the minimum number of characters you need to delete to make s good.\nThe frequency of a character in a string is the number of times it appears in the string. For example, in the string \"aab\", the frequency of 'a' is 2, while the frequency of 'b' is 1.\n \nExample 1:\n\nInput: s = \"aab\"\nOutput: 0\nExplanation: s is already good.\n\nExample 2:\n\nInput: s = \"aaabbbcc\"\nOutput: 2\nExplanation: You can delete two 'b's resulting in the good string \"aaabcc\".\nAnother way it to delete one 'b' and one 'c' resulting in the good string \"aaabbc\".\nExample 3:\n\nInput: s = \"ceabaacb\"\nOutput: 2\nExplanation: You can delete both 'c's resulting in the good string \"eabaab\".\nNote that we only care about characters that are still in the string at the end (i.e. frequency of 0 is ignored).\n\n \nConstraints:\n\n1 <= s.length <= 105\ns contains only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aab\") == 0\n assert candidate(s = \"aabacabadabaeabafabagabahabaiabajabakabalabamabanabaoabapabaqabarabasabataabuabavabawabaxabayabajabaz\") == 22\n assert candidate(s = \"abcabcabc\") == 3\n assert candidate(s = \"aabbbcccddddeeeeeffffffggggggghhhhhhhhiiiiiiiii\") == 2\n assert candidate(s = \"zzzzzzzzzz\") == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzz\") == 24\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 25\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 49\n assert candidate(s = \"ceabaacb\") == 2\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"aaabbbcc\") == 2\n assert candidate(s = \"aabbccddeeffgghhii\") == 15\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 25\n assert candidate(s = \"a\") == 0\n assert candidate(s = \"zzzzzzzzzzyyyyyyyyyxxxxxxxwwwwwwvvvvuuuuutttttsssssrrrrqqqqppppooooonnnnmmmmlllkkkjjjiii\") == 41\n assert candidate(s = \"aabbccddeeefffggg\") == 11\n assert candidate(s = \"aabbccddeeefffhhhiiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 48\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzz\") == 47\n assert candidate(s = \"pppppppppooooooonnnnnmmmllllllkkkkjjjjiiiiiiiihhhhhhhggggggg\") == 15\n assert candidate(s = \"aabbbccccddddeeeee\") == 3\n assert candidate(s = \"abababababababababab\") == 1\n assert candidate(s = \"zzzzzzzzzzzyyyyyyyxxxxxxxwwwwwwvvvvuuuutttssrrqponmlkjihgfedcba\") == 24\n assert candidate(s = \"aabbbcccddddeeeeeffffffggggggghhhhhhhhiiiiiiiiijjjjjjjjjj\") == 2\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minDeletions", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minDeletions(string s) {", "container": "Solution", "callable": "minDeletions", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1648, "task_id": "sell-diminishing-valued-colored-balls", "difficulty": "Medium", "problem_description": "You have an inventory of different colored balls, and there is a customer that wants orders balls of any color.\nThe customer weirdly values the colored balls. Each colored ball's value is the number of balls of that color you currently have in your inventory. For example, if you own 6 yellow balls, the customer would pay 6 for the first yellow ball. After the transaction, there are only 5 yellow balls left, so the next yellow ball is then valued at 5 (i.e., the value of the balls decreases as you sell more to the customer).\nYou are given an integer array, inventory, where inventory[i] represents the number of balls of the ith color that you initially own. You are also given an integer orders, which represents the total number of balls that the customer wants. You can sell the balls in any order.\nReturn the maximum total value that you can attain after selling orders colored balls. As the answer may be too large, return it modulo 109 + 7.\n \nExample 1:\n\n\nInput: inventory = [2,5], orders = 4\nOutput: 14\nExplanation: Sell the 1st color 1 time (2) and the 2nd color 3 times (5 + 4 + 3).\nThe maximum total value is 2 + 5 + 4 + 3 = 14.\n\nExample 2:\n\nInput: inventory = [3,5], orders = 6\nOutput: 19\nExplanation: Sell the 1st color 2 times (3 + 2) and the 2nd color 4 times (5 + 4 + 3 + 2).\nThe maximum total value is 3 + 2 + 5 + 4 + 3 + 2 = 19.\n\n \nConstraints:\n\n1 <= inventory.length <= 105\n1 <= inventory[i] <= 109\n1 <= orders <= min(sum(inventory[i]), 109)\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(inventory = [10, 10, 10],orders = 5) == 48\n assert candidate(inventory = [3, 5],orders = 6) == 19\n assert candidate(inventory = [1, 2, 3, 4, 5],orders = 10) == 30\n assert candidate(inventory = [1, 1, 1, 1, 1],orders = 3) == 3\n assert candidate(inventory = [7],orders = 7) == 28\n assert candidate(inventory = [1000000000, 1000000000],orders = 1000000000) == 250000035\n assert candidate(inventory = [1000000000],orders = 1) == 1000000000\n assert candidate(inventory = [5, 5, 5, 5, 5],orders = 20) == 70\n assert candidate(inventory = [1000000000],orders = 1000000000) == 21\n assert candidate(inventory = [2, 5],orders = 4) == 14\n assert candidate(inventory = [100],orders = 10) == 955\n assert candidate(inventory = [9, 9, 9, 9, 9, 9],orders = 25) == 185\n assert candidate(inventory = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20],orders = 350) == 4110\n assert candidate(inventory = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],orders = 5) == 5\n assert candidate(inventory = [100, 90, 80, 70, 60],orders = 200) == 12600\n assert candidate(inventory = [1000000, 2000000, 3000000],orders = 5000000) == 335785502\n assert candidate(inventory = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],orders = 100) == 500\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],orders = 50) == 215\n assert candidate(inventory = [1000, 2000, 3000, 4000, 5000],orders = 10000) == 25005000\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],orders = 55) == 220\n assert candidate(inventory = [5, 15, 25, 35, 45],orders = 35) == 1138\n assert candidate(inventory = [100000000, 100000000, 100000000],orders = 299999997) == 44999997\n assert candidate(inventory = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],orders = 50) == 150\n assert candidate(inventory = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],orders = 900) == 70200\n assert candidate(inventory = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],orders = 500) == 37750\n assert candidate(inventory = [1000000000, 500000000, 250000000, 125000000, 62500000],orders = 999999999) == 312500027\n assert candidate(inventory = [500000000, 400000000, 300000000, 200000000, 100000000],orders = 1500000000) == 825000014\n assert candidate(inventory = [100, 200, 300, 400, 500],orders = 1000) == 250500\n assert candidate(inventory = [100000000, 200000000, 300000000, 400000000, 500000000],orders = 900000000) == 778750014\n assert candidate(inventory = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],orders = 50) == 400\n assert candidate(inventory = [999999999, 999999999, 999999999, 999999999, 999999999],orders = 500000000) == 425000028\n assert candidate(inventory = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],orders = 500) == 37750\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],orders = 190) == 1520\n assert candidate(inventory = [50, 40, 30, 20, 10],orders = 100) == 2550\n assert candidate(inventory = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],orders = 1500) == 134972\n assert candidate(inventory = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],orders = 5000) == 1915000\n assert candidate(inventory = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20],orders = 500) == 6080\n assert candidate(inventory = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],orders = 10) == 10\n assert candidate(inventory = [3, 5, 7, 9],orders = 15) == 79\n assert candidate(inventory = [1000000000, 1000000000, 1000000000, 1000000000],orders = 3000000000) == 375000084\n assert candidate(inventory = [500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000],orders = 4500000) == 502241341\n assert candidate(inventory = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],orders = 550) == 19525\n assert candidate(inventory = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],orders = 10000) == 6071070\n assert candidate(inventory = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81],orders = 1000) == 66330\n assert candidate(inventory = [1, 3, 5, 7, 9],orders = 15) == 79\n assert candidate(inventory = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],orders = 7500) == 5500000\n assert candidate(inventory = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],orders = 50) == 110\n assert candidate(inventory = [999999999, 999999999, 999999999, 999999999, 999999999],orders = 4999999995) == 140\n assert candidate(inventory = [10, 10, 20, 20, 30, 30],orders = 50) == 1012\n assert candidate(inventory = [30, 25, 20, 15, 10, 5, 0],orders = 75) == 1100\n assert candidate(inventory = [10, 20, 30, 40, 50],orders = 100) == 2550\n assert candidate(inventory = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],orders = 20) == 20\n assert candidate(inventory = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],orders = 10) == 10\n assert candidate(inventory = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],orders = 300) == 16124\n assert candidate(inventory = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],orders = 200) == 9100\n assert candidate(inventory = [10, 20, 30, 40, 50],orders = 50) == 1708\n assert candidate(inventory = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],orders = 1500) == 94500\n assert candidate(inventory = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],orders = 40) == 110\n assert candidate(inventory = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],orders = 100) == 715\n assert candidate(inventory = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],orders = 25000) == 144369642\n assert candidate(inventory = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9],orders = 1000000000) == 46\n assert candidate(inventory = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],orders = 40) == 200\n assert candidate(inventory = [10, 8, 6, 4, 2],orders = 15) == 94\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],orders = 45) == 210\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],orders = 50) == 465\n assert candidate(inventory = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],orders = 50) == 50\n assert candidate(inventory = [50, 20, 10, 5, 1],orders = 50) == 1375\n assert candidate(inventory = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],orders = 500) == 19375\n assert candidate(inventory = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],orders = 100) == 1155\n assert candidate(inventory = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],orders = 100) == 800\n assert candidate(inventory = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],orders = 10000) == 75005000\n assert candidate(inventory = [1000000000, 500000000, 250000000, 125000000, 62500000],orders = 1000000000) == 562500028\n assert candidate(inventory = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],orders = 1000000) == 499475\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],orders = 30) == 174\n assert candidate(inventory = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990],orders = 1000000000) == 350000124\n assert candidate(inventory = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],orders = 50) == 460\n assert candidate(inventory = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],orders = 1000) == 750500\n assert candidate(inventory = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],orders = 200) == 14627\n assert candidate(inventory = [1000000000, 1000000000, 1000000000, 1000000000],orders = 4000000000) == 84\n assert candidate(inventory = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],orders = 45) == 145\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],orders = 190) == 1520\n assert candidate(inventory = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],orders = 1000) == 175234\n assert candidate(inventory = [50, 40, 30, 20, 10],orders = 150) == 2825\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],orders = 150) == 1416\n assert candidate(inventory = [10, 20, 30, 40, 50],orders = 100) == 2550\n assert candidate(inventory = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],orders = 4999999995) == 100\n assert candidate(inventory = [500000000, 500000000, 500000000, 500000000, 500000000],orders = 2000000000) == 800000028\n assert candidate(inventory = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],orders = 55) == 220\n"}, "metadata": {"canonical_parameter_names": ["inventory", "orders"], "leetcode_dataset_entry_point": "Solution().maxProfit", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxProfit(vector& inventory, int orders) {", "container": "Solution", "callable": "maxProfit", "parameters": [{"name": "inventory", "type": "vector&"}, {"name": "orders", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1649, "task_id": "create-sorted-array-through-instructions", "difficulty": "Hard", "problem_description": "Given an integer array instructions, you are asked to create a sorted array from the elements in instructions. You start with an empty container nums. For each element from left to right in instructions, insert it into nums. The cost of each insertion is the minimum of the following:\\r\n\\r\n\\r\n\tThe number of elements currently in nums that are strictly less than instructions[i].\\r\n\tThe number of elements currently in nums that are strictly greater than instructions[i].\\r\n\\r\n\\r\nFor example, if inserting element 3 into nums = [1,2,3,5], the cost of insertion is min(2, 1) (elements 1 and 2 are less than 3, element 5 is greater than 3) and nums will become [1,2,3,3,5].\\r\n\\r\nReturn the total cost to insert all elements from instructions into nums. Since the answer may be large, return it modulo 109 + 7\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: instructions = [1,5,6,2]\\r\nOutput: 1\\r\nExplanation: Begin with nums = [].\\r\nInsert 1 with cost min(0, 0) = 0, now nums = [1].\\r\nInsert 5 with cost min(1, 0) = 0, now nums = [1,5].\\r\nInsert 6 with cost min(2, 0) = 0, now nums = [1,5,6].\\r\nInsert 2 with cost min(1, 2) = 1, now nums = [1,2,5,6].\\r\nThe total cost is 0 + 0 + 0 + 1 = 1.\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: instructions = [1,2,3,6,5,4]\\r\nOutput: 3\\r\nExplanation: Begin with nums = [].\\r\nInsert 1 with cost min(0, 0) = 0, now nums = [1].\\r\nInsert 2 with cost min(1, 0) = 0, now nums = [1,2].\\r\nInsert 3 with cost min(2, 0) = 0, now nums = [1,2,3].\\r\nInsert 6 with cost min(3, 0) = 0, now nums = [1,2,3,6].\\r\nInsert 5 with cost min(3, 1) = 1, now nums = [1,2,3,5,6].\\r\nInsert 4 with cost min(3, 2) = 2, now nums = [1,2,3,4,5,6].\\r\nThe total cost is 0 + 0 + 0 + 0 + 1 + 2 = 3.\\r\n\\r\n\\r\nExample 3:\\r\n\\r\n\\r\nInput: instructions = [1,3,3,3,2,4,2,1,2]\\r\nOutput: 4\\r\nExplanation: Begin with nums = [].\\r\nInsert 1 with cost min(0, 0) = 0, now nums = [1].\\r\nInsert 3 with cost min(1, 0) = 0, now nums = [1,3].\\r\nInsert 3 with cost min(1, 0) = 0, now nums = [1,3,3].\\r\nInsert 3 with cost min(1, 0) = 0, now nums = [1,3,3,3].\\r\nInsert 2 with cost min(1, 3) = 1, now nums = [1,2,3,3,3].\\r\nInsert 4 with cost min(5, 0) = 0, now nums = [1,2,3,3,3,4].\\r\n​​​​​​​Insert 2 with cost min(1, 4) = 1, now nums = [1,2,2,3,3,3,4].\\r\n​​​​​​​Insert 1 with cost min(0, 6) = 0, now nums = [1,1,2,2,3,3,3,4].\\r\n​​​​​​​Insert 2 with cost min(2, 4) = 2, now nums = [1,1,2,2,2,3,3,3,4].\\r\nThe total cost is 0 + 0 + 0 + 0 + 1 + 0 + 1 + 0 + 2 = 4.\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= instructions.length <= 105\\r\n\t1 <= instructions[i] <= 105\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(instructions = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(instructions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(instructions = [50000, 50001, 50002, 50003, 50004, 50005, 50006, 50007, 50008, 50009]) == 0\n assert candidate(instructions = [1, 2, 3, 6, 5, 4]) == 3\n assert candidate(instructions = [1, 5, 6, 2]) == 1\n assert candidate(instructions = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 20\n assert candidate(instructions = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == 20\n assert candidate(instructions = [1, 3, 3, 3, 2, 4, 2, 1, 2]) == 4\n assert candidate(instructions = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(instructions = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(instructions = [5, 1, 3, 2, 4, 6, 8, 7, 10, 9]) == 5\n assert candidate(instructions = [100000, 1, 100000, 2, 100000, 3, 100000, 4, 100000, 5]) == 10\n assert candidate(instructions = [50000, 40000, 30000, 20000, 10000, 60000, 70000, 80000, 90000, 100000]) == 0\n assert candidate(instructions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 27\n assert candidate(instructions = [5, 3, 8, 6, 2, 7, 4, 1, 10, 9]) == 5\n assert candidate(instructions = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 0\n assert candidate(instructions = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == 10\n assert candidate(instructions = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == 32\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 75\n assert candidate(instructions = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == 4\n assert candidate(instructions = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == 0\n assert candidate(instructions = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 27\n assert candidate(instructions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 75\n assert candidate(instructions = [9, 3, 8, 3, 7, 3, 6, 3, 5, 3, 4, 3, 2, 3, 1, 3]) == 18\n assert candidate(instructions = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 24\n assert candidate(instructions = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 75\n assert candidate(instructions = [5, 10, 5, 10, 5, 10, 5, 10, 5, 10]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 0\n assert candidate(instructions = [1, 2, 3, 6, 5, 4, 1, 2, 3, 6, 5, 4]) == 14\n assert candidate(instructions = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 11, 12, 13, 14, 15]) == 10\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 75\n assert candidate(instructions = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 30\n assert candidate(instructions = [5, 4, 3, 2, 1]) == 0\n assert candidate(instructions = [1, 3, 2, 6, 5, 4, 9, 8, 7, 10, 1, 3, 2, 6, 5, 4, 9, 8, 7, 10, 1, 3, 2, 6, 5, 4, 9, 8, 7, 10]) == 88\n assert candidate(instructions = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 0\n assert candidate(instructions = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 60\n assert candidate(instructions = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10]) == 16\n assert candidate(instructions = [10, 20, 30, 40, 50, 40, 30, 20, 10, 10, 20, 30, 40, 50, 40, 30, 20, 10]) == 22\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 75\n assert candidate(instructions = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(instructions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 27\n assert candidate(instructions = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 0\n assert candidate(instructions = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(instructions = [100000, 99999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == 33\n assert candidate(instructions = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 27\n assert candidate(instructions = [50, 40, 30, 20, 10, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == 14\n assert candidate(instructions = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 36\n assert candidate(instructions = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994, 8, 99993]) == 56\n assert candidate(instructions = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1]) == 0\n assert candidate(instructions = [10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9, 10, 9]) == 0\n assert candidate(instructions = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(instructions = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 0\n assert candidate(instructions = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == 20\n assert candidate(instructions = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 10\n assert candidate(instructions = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5, 10, 1, 9, 2, 8, 3, 7, 4, 6, 5]) == 60\n assert candidate(instructions = [5, 1, 3, 2, 4, 6, 8, 7, 10, 9, 15, 14, 13, 12, 11, 20, 19, 18, 17, 16]) == 25\n assert candidate(instructions = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 0\n assert candidate(instructions = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 0\n assert candidate(instructions = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 0\n assert candidate(instructions = [1, 3, 2, 4, 2, 3, 1, 4, 2, 3]) == 7\n assert candidate(instructions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 0\n assert candidate(instructions = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3, 1]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 75\n assert candidate(instructions = [3, 1, 2, 5, 4, 6, 9, 7, 10, 8]) == 5\n assert candidate(instructions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 30\n assert candidate(instructions = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 0\n assert candidate(instructions = [50000, 50001, 50002, 50003, 50004, 50005, 50006, 50007, 50008, 50009, 50000, 50001, 50002, 50003, 50004, 50005, 50006, 50007, 50008, 50009]) == 27\n assert candidate(instructions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 30\n assert candidate(instructions = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 19\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 45\n assert candidate(instructions = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 27\n assert candidate(instructions = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 0\n assert candidate(instructions = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 317\n assert candidate(instructions = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(instructions = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9]) == 9\n assert candidate(instructions = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 0\n assert candidate(instructions = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 0\n assert candidate(instructions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 27\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(instructions = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 21\n assert candidate(instructions = [100000, 50000, 75000, 25000, 62500, 37500, 87500, 12500, 93750, 43750, 68750, 31250, 81250, 18750, 90625, 46875, 71875, 28125, 89062, 40625, 65625, 34375, 84375, 21875, 82812, 45312, 70312, 29687, 88281, 49218, 74218, 32187, 86171, 42187, 67187, 35156, 83125, 23437, 85937, 50312, 75312, 37812, 81562, 44531, 69531, 33437, 87968, 47968, 72968, 30937, 90468, 52968, 77968, 38906, 85468, 55468, 80468, 43437, 92460, 57460, 82460, 47460, 91718, 61718, 86718, 52656, 94359, 66359, 91359, 57359, 93671, 69671, 94671, 73671, 86913, 64406, 93406, 68406, 92406, 65406, 95507, 70507, 90507, 67507, 92753, 75253, 87753, 62753, 94753, 78753, 83753, 71753, 88281, 53281, 88281, 58281, 83281, 50281, 81281, 45281, 86281, 51281, 82281, 46281, 84281, 48281, 85281, 50281, 87281, 52281, 89281, 54281, 90281, 56281, 91281, 58281, 92281, 60281, 93281, 62281, 94281, 64281, 95281, 66281, 96281, 68281, 97281, 70281, 98281, 72281, 99281, 74281, 100000]) == 2291\n assert candidate(instructions = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(instructions = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 65\n assert candidate(instructions = [5, 1, 4, 2, 3, 8, 6, 7, 10, 9, 5, 5, 5, 5, 5]) == 27\n assert candidate(instructions = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 0\n assert candidate(instructions = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 27\n assert candidate(instructions = [7, 7, 7, 7, 7, 7, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(instructions = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 27\n assert candidate(instructions = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 0\n assert candidate(instructions = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 84\n assert candidate(instructions = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 15\n assert candidate(instructions = [2, 3, 1, 4, 5, 1, 3, 2, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 27\n assert candidate(instructions = [100000, 100000, 100000, 1, 1, 1, 50000, 50000, 50000, 25000]) == 12\n assert candidate(instructions = [1, 2, 3, 4, 5, 100000, 99999, 99998, 99997, 99996]) == 10\n assert candidate(instructions = [5, 4, 3, 2, 1, 100000, 99999, 99998, 99997, 99996]) == 10\n assert candidate(instructions = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 0\n assert candidate(instructions = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5, 600, 6, 700, 7, 800, 8, 900, 9, 1000, 10]) == 45\n assert candidate(instructions = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 27\n assert candidate(instructions = [50000, 50001, 50002, 50003, 50004, 50005, 50006, 50007, 50008, 50009]) == 0\n assert candidate(instructions = [5, 3, 1, 2, 4, 6, 8, 7, 10, 9]) == 4\n assert candidate(instructions = [100, 200, 300, 400, 500, 500, 400, 300, 200, 100]) == 5\n assert candidate(instructions = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000, 95000, 92500, 90000, 87500, 85000, 82500, 80000, 77500, 75000, 72500]) == 52\n assert candidate(instructions = [100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 1]) == 0\n assert candidate(instructions = [5, 1, 9, 2, 8, 3, 7, 4, 6, 10]) == 12\n assert candidate(instructions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(instructions = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 100000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 32\n"}, "metadata": {"canonical_parameter_names": ["instructions"], "leetcode_dataset_entry_point": "Solution().createSortedArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int createSortedArray(vector& instructions) {", "container": "Solution", "callable": "createSortedArray", "parameters": [{"name": "instructions", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1652, "task_id": "defuse-the-bomb", "difficulty": "Easy", "problem_description": "You have a bomb to defuse, and your time is running out! Your informer will provide you with a circular array code of length of n and a key k.\nTo decrypt the code, you must replace every number. All the numbers are replaced simultaneously.\n\nIf k > 0, replace the ith number with the sum of the next k numbers.\nIf k < 0, replace the ith number with the sum of the previous k numbers.\nIf k == 0, replace the ith number with 0.\n\nAs code is circular, the next element of code[n-1] is code[0], and the previous element of code[0] is code[n-1].\nGiven the circular array code and an integer key k, return the decrypted code to defuse the bomb!\n \nExample 1:\n\nInput: code = [5,7,1,4], k = 3\nOutput: [12,10,16,13]\nExplanation: Each number is replaced by the sum of the next 3 numbers. The decrypted code is [7+1+4, 1+4+5, 4+5+7, 5+7+1]. Notice that the numbers wrap around.\n\nExample 2:\n\nInput: code = [1,2,3,4], k = 0\nOutput: [0,0,0,0]\nExplanation: When k is zero, the numbers are replaced by 0. \n\nExample 3:\n\nInput: code = [2,4,9,3], k = -2\nOutput: [12,5,6,13]\nExplanation: The decrypted code is [3+9, 2+3, 4+2, 9+4]. Notice that the numbers wrap around again. If k is negative, the sum is of the previous numbers.\n\n \nConstraints:\n\nn == code.length\n1 <= n <= 100\n1 <= code[i] <= 100\n-(n - 1) <= k <= n - 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(code = [7, 8, 9, 10],k = 4) == [34, 34, 34, 34]\n assert candidate(code = [7, 8, 9],k = 1) == [8, 9, 7]\n assert candidate(code = [6, 5, 4, 3, 2, 1],k = -1) == [1, 6, 5, 4, 3, 2]\n assert candidate(code = [1, 2, 3],k = -3) == [6, 6, 6]\n assert candidate(code = [1, 1, 1, 1, 1],k = -1) == [1, 1, 1, 1, 1]\n assert candidate(code = [5, 7, 1, 4],k = 3) == [12, 10, 16, 13]\n assert candidate(code = [1, 1, 1, 1, 1],k = -5) == [5, 5, 5, 5, 5]\n assert candidate(code = [8, 9, 4, 7],k = 4) == [28, 28, 28, 28]\n assert candidate(code = [8, 6, 4, 2],k = -3) == [12, 14, 16, 18]\n assert candidate(code = [6, 5, 4, 3, 2, 1],k = -3) == [6, 9, 12, 15, 12, 9]\n assert candidate(code = [2, 4, 9, 3],k = -2) == [12, 5, 6, 13]\n assert candidate(code = [10, 20, 30, 40, 50],k = -1) == [50, 10, 20, 30, 40]\n assert candidate(code = [3, 3, 3, 3],k = 1) == [3, 3, 3, 3]\n assert candidate(code = [5, 5, 5, 5, 5],k = -1) == [5, 5, 5, 5, 5]\n assert candidate(code = [10, 20, 30, 40, 50],k = 2) == [50, 70, 90, 60, 30]\n assert candidate(code = [15, 20, 25],k = 0) == [0, 0, 0]\n assert candidate(code = [1, 2, 3, 4],k = 0) == [0, 0, 0, 0]\n assert candidate(code = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = -3) == [6, 12, 18, 24, 21, 18, 15, 12, 9]\n assert candidate(code = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = -5) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(code = [3, 3, 3, 3],k = 0) == [0, 0, 0, 0]\n assert candidate(code = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(code = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = -20) == [410, 400, 390, 380, 370, 360, 350, 340, 330, 320, 310, 300, 290, 280, 270, 260, 250, 240, 230, 220, 210, 230, 250, 270, 290, 310, 330, 350, 370, 390]\n assert candidate(code = [7, 14, 21, 28, 35, 42],k = 3) == [63, 84, 105, 84, 63, 42]\n assert candidate(code = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = -4) == [170, 140, 110, 80, 50, 70, 90, 110, 130, 150]\n assert candidate(code = [50, 40, 30, 20, 10],k = -4) == [100, 110, 120, 130, 140]\n assert candidate(code = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == [20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 75, 60, 45, 30, 15]\n assert candidate(code = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = -18) == [396, 392, 388, 384, 380, 376, 372, 368, 364, 360, 356, 352, 348, 344, 340, 336, 332, 328, 324, 360]\n assert candidate(code = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(code = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == [14, 18, 22, 26, 30, 34, 28, 22, 16, 10]\n assert candidate(code = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = -10) == [385, 385, 385, 385, 385, 385, 385, 385, 385, 385]\n assert candidate(code = [7, 8, 9, 10, 11, 12, 13, 14, 15],k = -4) == [54, 49, 44, 39, 34, 38, 42, 46, 50]\n assert candidate(code = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == [5, 7, 9, 11, 13, 15, 17, 19, 11, 3]\n assert candidate(code = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 9) == [450, 460, 470, 480, 490, 500, 510, 520, 530, 540]\n assert candidate(code = [10, 20, 30, 40, 50],k = -5) == [150, 150, 150, 150, 150]\n assert candidate(code = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 5) == [35, 45, 55, 65, 75, 85, 95, 81, 67, 53, 39, 25]\n assert candidate(code = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = -10) == [105, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 65, 75, 85, 95]\n assert candidate(code = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == [20, 25, 30, 35, 40, 35, 30, 25, 20, 15]\n assert candidate(code = [12, 24, 36, 48, 60, 72, 84, 96, 108],k = -6) == [468, 432, 396, 360, 324, 288, 252, 324, 396]\n assert candidate(code = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 3) == [45, 60, 75, 90, 105, 120, 135, 100, 65, 30]\n assert candidate(code = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = -5) == [80, 70, 60, 50, 40, 30, 40, 50, 60, 70]\n assert candidate(code = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26],k = -6) == [126, 112, 98, 84, 70, 56, 42, 54, 66, 78, 90, 102, 114]\n assert candidate(code = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 9) == [540, 530, 520, 510, 500, 490, 480, 470, 460, 450]\n assert candidate(code = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],k = -9) == [594, 583, 572, 561, 550, 539, 528, 517, 506, 495]\n assert candidate(code = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 4) == [140, 180, 220, 260, 300, 340, 280, 220, 160, 100]\n assert candidate(code = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 3) == [240, 210, 180, 150, 120, 90, 60, 130, 200, 270]\n assert candidate(code = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(code = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = -5) == [150, 200, 250, 300, 350, 400, 350, 300, 250, 200]\n assert candidate(code = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 0) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(code = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = -2) == [3, 10, 17, 15, 13, 11, 9, 7, 5]\n assert candidate(code = [25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325],k = -6) == [1575, 1400, 1225, 1050, 875, 700, 525, 675, 825, 975, 1125, 1275, 1425]\n assert candidate(code = [7, 14, 21, 28, 35],k = -4) == [98, 91, 84, 77, 70]\n assert candidate(code = [9, 18, 27, 36, 45, 54, 63, 72, 81],k = 6) == [243, 297, 351, 324, 297, 270, 243, 216, 189]\n assert candidate(code = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],k = 6) == [240, 300, 360, 420, 480, 430, 380, 330, 280, 230, 180]\n assert candidate(code = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = -4) == [34, 28, 22, 16, 10, 14, 18, 22, 26, 30]\n assert candidate(code = [10, 20, 30, 40, 50],k = 2) == [50, 70, 90, 60, 30]\n assert candidate(code = [97, 98, 99, 100],k = -1) == [100, 97, 98, 99]\n assert candidate(code = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 19) == [1045, 1040, 1035, 1030, 1025, 1020, 1015, 1010, 1005, 1000, 995, 990, 985, 980, 975, 970, 965, 960, 955, 950]\n assert candidate(code = [10, 20, 30, 40, 50],k = 4) == [140, 130, 120, 110, 100]\n assert candidate(code = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 19) == [19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19]\n assert candidate(code = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = -2) == [3, 10, 17, 15, 13, 11, 9, 7, 5]\n assert candidate(code = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 5) == [350, 300, 250, 200, 150, 200, 250, 300, 350, 400]\n assert candidate(code = [42, 84, 126, 168, 210, 252, 294, 336],k = 4) == [588, 756, 924, 1092, 924, 756, 588, 420]\n assert candidate(code = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 3) == [900, 1200, 1500, 1800, 2100, 2400, 2700, 2000, 1300, 600]\n assert candidate(code = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = -4) == [102, 84, 66, 48, 30, 42, 54, 66, 78, 90]\n assert candidate(code = [10, 20, 30, 40, 50],k = -2) == [90, 60, 30, 50, 70]\n assert candidate(code = [26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12],k = -9) == [144, 150, 156, 162, 168, 174, 180, 186, 192, 198, 189, 180, 171, 162, 153]\n assert candidate(code = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = -5) == [150, 200, 250, 300, 350, 400, 350, 300, 250, 200]\n assert candidate(code = [3, 6, 9, 12, 15, 18, 21, 24, 27],k = -4) == [90, 75, 60, 45, 30, 42, 54, 66, 78]\n assert candidate(code = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],k = 7) == [75, 95, 119, 114, 106, 98, 88, 80, 70, 58]\n assert candidate(code = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75],k = -20) == [1690, 1695, 1700, 1705, 1710, 1715, 1720, 1725, 1730, 1735, 1740, 1745, 1750, 1755, 1760, 1765, 1770, 1775, 1780, 1785, 1790, 1770, 1750, 1730, 1710]\n assert candidate(code = [5, 10, 15, 20, 25, 30, 35, 40],k = 7) == [175, 170, 165, 160, 155, 150, 145, 140]\n assert candidate(code = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 8) == [124, 132, 140, 148, 156, 164, 172, 165, 158, 151, 144, 137, 130, 123, 116]\n assert candidate(code = [100, 100, 100, 100, 100, 100, 100, 100],k = 3) == [300, 300, 300, 300, 300, 300, 300, 300]\n assert candidate(code = [50, 40, 30, 20, 10],k = 0) == [0, 0, 0, 0, 0]\n assert candidate(code = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = -5) == [400, 350, 300, 250, 200, 150, 200, 250, 300, 350]\n assert candidate(code = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180],k = -7) == [1008, 912, 816, 720, 624, 528, 432, 336, 420, 504, 588, 672, 756, 840, 924]\n assert candidate(code = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(code = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120],k = 0) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(code = [5, 15, 25, 35, 45, 55],k = -6) == [180, 180, 180, 180, 180, 180]\n assert candidate(code = [31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2],k = -8) == [77, 89, 101, 111, 119, 129, 137, 145, 150, 124, 98]\n assert candidate(code = [23, 45, 12, 67, 34, 89, 23, 56, 78, 90, 12, 34, 56, 78, 90, 23, 45, 67, 89, 10],k = 10) == [506, 495, 539, 550, 606, 540, 562, 573, 584, 504, 515, 526, 482, 471, 415, 481, 459, 448, 437, 517]\n assert candidate(code = [11, 22, 33, 44, 55, 66],k = 0) == [0, 0, 0, 0, 0, 0]\n assert candidate(code = [1, 3, 5, 7, 9, 11, 13],k = 4) == [24, 32, 40, 34, 28, 22, 16]\n assert candidate(code = [30, 20, 10, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = -5) == [35, 60, 74, 77, 74, 66, 38, 21, 15, 15, 20, 25, 30]\n assert candidate(code = [9, 1, 2, 3, 4, 5, 6, 7, 8, 10],k = 4) == [10, 14, 18, 22, 26, 31, 34, 28, 22, 15]\n assert candidate(code = [3, 6, 9, 12, 15, 18, 21],k = -2) == [39, 24, 9, 15, 21, 27, 33]\n assert candidate(code = [5, 10, 15, 20, 25, 30, 35, 40],k = -4) == [130, 110, 90, 70, 50, 70, 90, 110]\n assert candidate(code = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == [26, 22, 18, 14, 10, 15, 20, 25, 30]\n assert candidate(code = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 19) == [418, 416, 414, 412, 410, 408, 406, 404, 402, 400, 398, 396, 394, 392, 390, 388, 386, 384, 382, 380]\n assert candidate(code = [5, 10, 15, 20, 25, 30, 35, 40],k = 5) == [100, 125, 150, 135, 120, 105, 90, 75]\n assert candidate(code = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == [200, 250, 300, 350, 400, 350, 300, 250, 200, 150]\n assert candidate(code = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 9) == [99, 117, 135, 153, 171, 189, 207, 225, 243, 261, 279, 257, 235, 213, 191, 169, 147, 125, 103, 81]\n assert candidate(code = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],k = 15) == [1275, 1425, 1575, 1725, 1875, 1825, 1775, 1725, 1675, 1625, 1575, 1525, 1475, 1425, 1375, 1325, 1275, 1225, 1175, 1125]\n assert candidate(code = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = -7) == [455, 425, 395, 365, 335, 305, 275, 245, 315, 385]\n assert candidate(code = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 10) == [165, 165, 165, 165, 165, 165, 165, 165, 165, 165]\n assert candidate(code = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 8) == [36, 37, 38, 39, 40, 41, 42, 43, 44]\n assert candidate(code = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = -15) == [390, 380, 370, 360, 350, 340, 330, 320, 310, 300, 290, 280, 270, 260, 250, 240, 270, 300, 330, 360]\n assert candidate(code = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 5) == [20, 21, 23, 27, 25, 21, 22, 17, 16, 14, 14]\n assert candidate(code = [50, 40, 30, 20, 10],k = -2) == [30, 60, 90, 70, 50]\n assert candidate(code = [5, 10, 15, 20, 25, 30, 35, 40],k = 0) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(code = [7, 14, 21, 28, 35, 42, 49],k = -3) == [126, 98, 70, 42, 63, 84, 105]\n assert candidate(code = [7, 14, 21, 28, 35, 42],k = -5) == [140, 133, 126, 119, 112, 105]\n assert candidate(code = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 6) == [48, 60, 72, 84, 96, 108, 96, 84, 72, 60, 48, 36]\n assert candidate(code = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == [15, 13, 11, 9, 7, 5, 3, 10, 17]\n assert candidate(code = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 8) == [4400, 5200, 5000, 4800, 4600, 4400, 4200, 4000, 3800, 3600]\n assert candidate(code = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22],k = 7) == [70, 84, 98, 112, 104, 96, 88, 80, 72, 64, 56]\n assert candidate(code = [10, 20, 30, 40, 50, 60],k = 2) == [50, 70, 90, 110, 70, 30]\n assert candidate(code = [23, 45, 12, 67, 34, 89, 23, 56, 78, 90, 12, 34, 56, 78, 90, 23, 45, 67, 89, 10],k = -10) == [504, 515, 526, 482, 471, 415, 481, 459, 448, 437, 517, 506, 495, 539, 550, 606, 540, 562, 573, 584]\n assert candidate(code = [2, 4, 8, 16, 32, 64, 128, 256],k = 3) == [28, 56, 112, 224, 448, 386, 262, 14]\n assert candidate(code = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],k = 5) == [485, 480, 475, 470, 465, 470, 475, 480, 485, 490]\n assert candidate(code = [7, 14, 21, 28, 35, 42, 49],k = 3) == [63, 84, 105, 126, 98, 70, 42]\n assert candidate(code = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = -5) == [95, 81, 67, 53, 39, 25, 35, 45, 55, 65, 75, 85]\n assert candidate(code = [21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],k = -8) == [64, 70, 76, 82, 88, 94, 100, 106, 112, 96, 80]\n assert candidate(code = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 7) == [63, 77, 91, 105, 97, 89, 81, 73, 65, 57, 49]\n assert candidate(code = [23, 17, 15, 9, 2],k = 1) == [17, 15, 9, 2, 23]\n assert candidate(code = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 9) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(code = [3, 6, 9, 12, 15, 18, 21, 24],k = -2) == [45, 27, 9, 15, 21, 27, 33, 39]\n assert candidate(code = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = -19) == [19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19]\n assert candidate(code = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = -4) == [10, 15, 20, 25, 30, 26, 22, 18, 14]\n"}, "metadata": {"canonical_parameter_names": ["code", "k"], "leetcode_dataset_entry_point": "Solution().decrypt", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector decrypt(vector& code, int k) {", "container": "Solution", "callable": "decrypt", "parameters": [{"name": "code", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1653, "task_id": "minimum-deletions-to-make-string-balanced", "difficulty": "Medium", "problem_description": "You are given a string s consisting only of characters 'a' and 'b'​​​​.\nYou can delete any number of characters in s to make s balanced. s is balanced if there is no pair of indices (i,j) such that i < j and s[i] = 'b' and s[j]= 'a'.\nReturn the minimum number of deletions needed to make s balanced.\n \nExample 1:\n\nInput: s = \"aababbab\"\nOutput: 2\nExplanation: You can either:\nDelete the characters at 0-indexed positions 2 and 6 (\"aababbab\" -> \"aaabbb\"), or\nDelete the characters at 0-indexed positions 3 and 6 (\"aababbab\" -> \"aabbbb\").\n\nExample 2:\n\nInput: s = \"bbaaaaabb\"\nOutput: 2\nExplanation: The only solution is to delete the first two characters.\n\n \nConstraints:\n\n1 <= s.length <= 105\ns[i] is 'a' or 'b'​​.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaaaaabbbb\") == 0\n assert candidate(s = \"bbbaaaaa\") == 3\n assert candidate(s = \"bbbaaaaabbbb\") == 3\n assert candidate(s = \"aabbaa\") == 2\n assert candidate(s = \"abababab\") == 3\n assert candidate(s = \"aaaaa\") == 0\n assert candidate(s = \"aabbaabb\") == 2\n assert candidate(s = \"aababbaa\") == 3\n assert candidate(s = \"baabbaab\") == 3\n assert candidate(s = \"abababa\") == 3\n assert candidate(s = \"aabbaaab\") == 2\n assert candidate(s = \"aabbbbbaa\") == 2\n assert candidate(s = \"bbaabb\") == 2\n assert candidate(s = \"babababababababab\") == 8\n assert candidate(s = \"bbbbb\") == 0\n assert candidate(s = \"bababab\") == 3\n assert candidate(s = \"aababbab\") == 2\n assert candidate(s = \"ababababa\") == 4\n assert candidate(s = \"baabbaabba\") == 4\n assert candidate(s = \"bbaaaaabb\") == 2\n assert candidate(s = \"bbbbaaaa\") == 4\n assert candidate(s = \"aabbaaabbbaaabbb\") == 5\n assert candidate(s = \"baababababa\") == 5\n assert candidate(s = \"aaaa\") == 0\n assert candidate(s = \"bbbb\") == 0\n assert candidate(s = \"bbaabbaabbaa\") == 6\n assert candidate(s = \"aabbaaabbbaa\") == 4\n assert candidate(s = \"baba\") == 2\n assert candidate(s = \"abbaaabbbbba\") == 3\n assert candidate(s = \"aabbabba\") == 2\n assert candidate(s = \"bbbbbaaaaa\") == 5\n assert candidate(s = \"bbabbaab\") == 3\n assert candidate(s = \"aaabbbba\") == 1\n assert candidate(s = \"aaaaaaaa\") == 0\n assert candidate(s = \"bbbbbbbb\") == 0\n assert candidate(s = \"baabaa\") == 2\n assert candidate(s = \"bbbbbaaaaaabbbbaaaaabbbbbbaaaabbbaaaaabbbb\") == 18\n assert candidate(s = \"aaaaaaaaaabbbaaabbbbaaaaaaaaa\") == 7\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbb\") == 0\n assert candidate(s = \"aaaaabbbbaaaaabbbb\") == 4\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababababababababababababababababababab\") == 53\n assert candidate(s = \"babababababababa\") == 8\n assert candidate(s = \"abbbbbaaaabbbab\") == 5\n assert candidate(s = \"abbbabbaabbbaabaaabababbbaaabbbaaaabbbabbbaaabbabbaabbaabaabbabbaabbabbaabbbaabb\") == 36\n assert candidate(s = \"abbbbbaaaabbbb\") == 4\n assert candidate(s = \"abababababababa\") == 7\n assert candidate(s = \"bbbbaaaaabbbbbbbba\") == 5\n assert candidate(s = \"aaaaaaaaaabbbabb\") == 1\n assert candidate(s = \"bababababababababab\") == 9\n assert candidate(s = \"ababababaababababa\") == 8\n assert candidate(s = \"baabbabababaabbabababaabbabababaabb\") == 16\n assert candidate(s = \"bbbbbbaaaaaa\") == 6\n assert candidate(s = \"bbbbbbaaaaaabbbb\") == 6\n assert candidate(s = \"aaaabbbaaaaabbbb\") == 3\n assert candidate(s = \"aaaaabbbbbbbbbaaaa\") == 4\n assert candidate(s = \"abbaabbaabbaabbaabbaabba\") == 11\n assert candidate(s = \"baabbaabbaabbaabba\") == 8\n assert candidate(s = \"baaaabbbbaaabbbbaaaaabbbbbaaaaaabbbbbbaaaaabbbbbaaaaaabbbbbbaaaaabbbbbaaaaaabbbbbbaaaaabbbbbaaaaaabbbbbbaaaaabbbbbaaaaaabbbbbbaaaaabb\") == 63\n assert candidate(s = \"baaabbaaabbaabab\") == 6\n assert candidate(s = \"abababababababababababababababababababababababababababababababab\") == 31\n assert candidate(s = \"abbbabbbabbbabbbabbbabbbabbbabbbab\") == 8\n assert candidate(s = \"baaaababababbbabba\") == 6\n assert candidate(s = \"abbbabaaaababbbaaaabbaaababbabaaaabbabaaaaabaa\") == 18\n assert candidate(s = \"bbbbbaaaaabbbbbaaaa\") == 9\n assert candidate(s = \"abababababbababb\") == 6\n assert candidate(s = \"bababababababababababababababababababa\") == 19\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbbbb\") == 0\n assert candidate(s = \"bbbbabbaaababbaaababbaaababbaaababbaaab\") == 18\n assert candidate(s = \"bbbbbbbbbaaaaaaaaa\") == 9\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbbbbaaaaaaabbbbaaaaaaa\") == 14\n assert candidate(s = \"aaaaaabbbbbbaaaaaaabbbbbaaaaabbbbb\") == 11\n assert candidate(s = \"aaabbaabbaabbaabbaabbaabbaabbaabbaa\") == 16\n assert candidate(s = \"baaaaaabbbbbbb\") == 1\n assert candidate(s = \"bbbbbaaaabbbbaaabbbbaa\") == 9\n assert candidate(s = \"aabbbbaaaabbbbbb\") == 4\n assert candidate(s = \"aababbabbaababba\") == 6\n assert candidate(s = \"bbaabbabbaabbabbaa\") == 8\n assert candidate(s = \"abababbababababa\") == 7\n assert candidate(s = \"aabbaaababababba\") == 6\n assert candidate(s = \"aabbaabbaabbaabb\") == 6\n assert candidate(s = \"aaaaaabbbbbbaaabbb\") == 3\n assert candidate(s = \"bbbbbaaaaaabbbbbbaaaaaaabbbbbbbaaaaaaaaa\") == 18\n assert candidate(s = \"bbbaaabbaaabbaabbaaabbaaabbaabbaabbaa\") == 17\n assert candidate(s = \"bbaababbabababbababaababababababaababababababaababababababaababababababaababababababaabababaabababa\") == 47\n assert candidate(s = \"bbaaaaabaaaaabaaaaabaaaaabaaaaabaaaa\") == 7\n assert candidate(s = \"aabbaaabbbaaabbbaaabbbaaabbbaaabbbaaabbbaaabbbaaabbbaa\") == 25\n assert candidate(s = \"abbaabbaabbaabba\") == 7\n assert candidate(s = \"bbbbbbbaaaabbbbbbbaa\") == 6\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbaabbbbaaaaaaaaa\") == 11\n assert candidate(s = \"bbabbababbaaab\") == 6\n assert candidate(s = \"bababababa\") == 5\n assert candidate(s = \"ababababababab\") == 6\n assert candidate(s = \"aabbbabbbabbbabbbabba\") == 5\n assert candidate(s = \"abababababab\") == 5\n assert candidate(s = \"ababababababababab\") == 8\n assert candidate(s = \"bbbbbaaaaabbbbb\") == 5\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaa\") == 17\n assert candidate(s = \"aaaaaaaaaabbbbbb\") == 0\n assert candidate(s = \"baaaaaaaaaaaaaaaaaab\") == 1\n assert candidate(s = \"bbbbaaaabaaaab\") == 5\n assert candidate(s = \"baaaaaabbbbb\") == 1\n assert candidate(s = \"bbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 21\n assert candidate(s = \"bbbbbbbbbaaaaaa\") == 6\n assert candidate(s = \"aaaaaaaaabbbbbbbbbbbaa\") == 2\n assert candidate(s = \"bbbbbaaaaabbaaab\") == 7\n assert candidate(s = \"abbaababbaababbaababbaababbaababbaabab\") == 18\n assert candidate(s = \"aaaaaabbbbbbaaaaaabbbbbbaaaaaabbbbbb\") == 12\n assert candidate(s = \"bbbbaaaabbbbba\") == 5\n assert candidate(s = \"bbbbbbbbbaaaabbb\") == 4\n assert candidate(s = \"baababababaabbaa\") == 7\n assert candidate(s = \"aaaaaaaaaabbbbba\") == 1\n assert candidate(s = \"aabbaaabbaaabbaaabbaaabbaaabbaaabbaaabbb\") == 14\n assert candidate(s = \"abababababababababab\") == 9\n assert candidate(s = \"aaaaabbbbaaaaabbbbbaaa\") == 7\n assert candidate(s = \"aaaaaaaaaabbbaaaaaaaaa\") == 3\n assert candidate(s = \"aababababababababa\") == 8\n assert candidate(s = \"bababababababa\") == 7\n assert candidate(s = \"babbaabbbaabbaabbbaabbaabbbaabbaabba\") == 16\n assert candidate(s = \"aaabbaabbaabbbbb\") == 4\n assert candidate(s = \"aabbaaabbbabbaaabb\") == 6\n assert candidate(s = \"bbbbbbbbbaaaaaaaaaaa\") == 9\n assert candidate(s = \"aaabbbbaaaaabba\") == 5\n assert candidate(s = \"baaaaaabbaaabbbaaa\") == 6\n assert candidate(s = \"bbbaaaaabbbaaaa\") == 6\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbb\") == 0\n assert candidate(s = \"aabbaabbbaaabb\") == 5\n assert candidate(s = \"babababababababababa\") == 10\n assert candidate(s = \"bababababababababababababababab\") == 15\n assert candidate(s = \"baaababbababab\") == 5\n assert candidate(s = \"baabababababababababab\") == 10\n assert candidate(s = \"bbbbbbbbbaaaaaaaaaa\") == 9\n assert candidate(s = \"bbbbbbbbbaaaaa\") == 5\n assert candidate(s = \"bbbbbbbbbbbbbaaaaaaaaa\") == 9\n assert candidate(s = \"baaaaaabbbbbbbaaaaaaaaaabbbbbbbaaaaaaaaaaabbbbbbbaaaaaaaaaaabbbbbbbaaaaaaaaaa\") == 29\n assert candidate(s = \"baaaaaabbbbbbbbba\") == 2\n assert candidate(s = \"abbaabbaabbaabbaab\") == 8\n assert candidate(s = \"babbabbabbabbabbabba\") == 7\n assert candidate(s = \"aababababababababababababababababababababababa\") == 22\n assert candidate(s = \"bbbbbaaaaabbbb\") == 5\n assert candidate(s = \"baabababaabababa\") == 7\n assert candidate(s = \"aaaaabbbbbabbbbb\") == 1\n assert candidate(s = \"babababababababaab\") == 8\n assert candidate(s = \"bbbbbbbbbaaaaaaabbbbbbbbbaaaaaaa\") == 14\n assert candidate(s = \"aaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\") == 0\n assert candidate(s = \"bbbbaaaaabbaaabb\") == 6\n assert candidate(s = \"aaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaa\") == 36\n assert candidate(s = \"bbbbbbaaabaaabbaab\") == 8\n assert candidate(s = \"aabbaabbbaabba\") == 5\n assert candidate(s = \"abbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\") == 46\n assert candidate(s = \"abbaabbaabba\") == 5\n assert candidate(s = \"baaabbbbaaabbbbaaabbbbaaabbbbaaabbb\") == 13\n assert candidate(s = \"aaaaaaaaaabbbbbbaa\") == 2\n assert candidate(s = \"aabbaaabbaabbaa\") == 6\n assert candidate(s = \"ababbababbabab\") == 5\n assert candidate(s = \"bbbbbaaabbaabb\") == 5\n assert candidate(s = \"abababababababababa\") == 9\n assert candidate(s = \"babbbbbaaabbbbaabb\") == 6\n assert candidate(s = \"bbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaa\") == 20\n assert candidate(s = \"abbbbaaababaaaabbaaabaaabbaaaabbbaaabbaaaabbaaabbaaabbbbaaaaa\") == 24\n assert candidate(s = \"bbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbaaaaaaaaa\") == 26\n assert candidate(s = \"bbaaabbaaabbaaabbaaabbaaabbaaabbaaab\") == 14\n assert candidate(s = \"aaabbbaaababba\") == 5\n assert candidate(s = \"ababababab\") == 4\n assert candidate(s = \"aaaaabbbbaaaabbbba\") == 5\n assert candidate(s = \"bbbbaaaaabbaaaab\") == 6\n assert candidate(s = \"aabbaaabbaaabbaaabbaa\") == 8\n assert candidate(s = \"bbbbbbaaabbbbaaaa\") == 7\n assert candidate(s = \"bbbbbaaaaaaaaaaa\") == 5\n assert candidate(s = \"baabaaabbaabaaabbaabaa\") == 8\n assert candidate(s = \"aabbbbbbaabbaaaabb\") == 6\n assert candidate(s = \"aababbbaaababbab\") == 6\n assert candidate(s = \"bbbbabbbbbaaaaa\") == 6\n assert candidate(s = \"bbaaaaaaaaaabbbbaaaabbbba\") == 7\n assert candidate(s = \"aabbaabbabbaabbabbbaaabbaa\") == 11\n assert candidate(s = \"aaaaaaaaaabbbaaa\") == 3\n assert candidate(s = \"aaaaaaaaaabbbaaaabbbbbaaabbbbaaabbbbbaaa\") == 12\n assert candidate(s = \"babababaabab\") == 5\n assert candidate(s = \"bbbbbbbbbaaaaabbbb\") == 5\n assert candidate(s = \"aabbaaabbbaaabbbaaabbbaaabbaa\") == 13\n assert candidate(s = \"aaaabababababbbbba\") == 5\n assert candidate(s = \"aaabbaaabbaaabba\") == 5\n assert candidate(s = \"bbbbbbaaaaaabbbbaaa\") == 9\n assert candidate(s = \"bbbbbbbbaaaaabaaaaabbaaaabbaaaabbbaaaabbbbbbb\") == 16\n assert candidate(s = \"baaaaabbbbaaaaabba\") == 6\n assert candidate(s = \"abababaabababaab\") == 6\n assert candidate(s = \"bbbaaabbaaabbaab\") == 7\n assert candidate(s = \"aaaabaaaabaaaa\") == 2\n assert candidate(s = \"ababababababababababababababababababab\") == 18\n assert candidate(s = \"bbabbbbaaabbbbaaab\") == 7\n assert candidate(s = \"abbaabbaabbbaabb\") == 6\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minimumDeletions", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumDeletions(string s) {", "container": "Solution", "callable": "minimumDeletions", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1654, "task_id": "minimum-jumps-to-reach-home", "difficulty": "Medium", "problem_description": "A certain bug's home is on the x-axis at position x. Help them get there from position 0.\nThe bug jumps according to the following rules:\n\nIt can jump exactly a positions forward (to the right).\nIt can jump exactly b positions backward (to the left).\nIt cannot jump backward twice in a row.\nIt cannot jump to any forbidden positions.\n\nThe bug may jump forward beyond its home, but it cannot jump to positions numbered with negative integers.\nGiven an array of integers forbidden, where forbidden[i] means that the bug cannot jump to the position forbidden[i], and integers a, b, and x, return the minimum number of jumps needed for the bug to reach its home. If there is no possible sequence of jumps that lands the bug on position x, return -1.\n \nExample 1:\n\nInput: forbidden = [14,4,18,1,15], a = 3, b = 15, x = 9\nOutput: 3\nExplanation: 3 jumps forward (0 -> 3 -> 6 -> 9) will get the bug home.\n\nExample 2:\n\nInput: forbidden = [8,3,16,6,12,20], a = 15, b = 13, x = 11\nOutput: -1\n\nExample 3:\n\nInput: forbidden = [1,6,2,14,5,17,4], a = 16, b = 9, x = 7\nOutput: 2\nExplanation: One jump forward (0 -> 16) then one jump backward (16 -> 7) will get the bug home.\n\n \nConstraints:\n\n1 <= forbidden.length <= 1000\n1 <= a, b, forbidden[i] <= 2000\n0 <= x <= 2000\nAll the elements in forbidden are distinct.\nPosition x is not forbidden.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(forbidden = [2, 4, 6, 8, 10],a = 2,b = 1,x = 1) == -1\n assert candidate(forbidden = [],a = 1,b = 1,x = 0) == 0\n assert candidate(forbidden = [5, 6, 7],a = 1,b = 1,x = 10) == -1\n assert candidate(forbidden = [1, 6, 2, 14, 5, 17, 4],a = 16,b = 9,x = 7) == 2\n assert candidate(forbidden = [8, 3, 16, 6, 12, 20],a = 15,b = 13,x = 11) == -1\n assert candidate(forbidden = [14, 4, 18, 1, 15],a = 3,b = 15,x = 9) == 3\n assert candidate(forbidden = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],a = 3,b = 5,x = 20) == -1\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],a = 1,b = 3,x = 50) == -1\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],a = 1,b = 2,x = 25) == -1\n assert candidate(forbidden = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],a = 2,b = 4,x = 58) == 29\n assert candidate(forbidden = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200],a = 5,b = 10,x = 195) == -1\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50],a = 2,b = 1,x = 51) == -1\n assert candidate(forbidden = [300, 600, 900, 1200, 1500, 1800],a = 300,b = 150,x = 2100) == -1\n assert candidate(forbidden = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],a = 2,b = 4,x = 41) == -1\n assert candidate(forbidden = [200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000],a = 100,b = 50,x = 1950) == 21\n assert candidate(forbidden = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],a = 2,b = 3,x = 20) == 10\n assert candidate(forbidden = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900],a = 100,b = 200,x = 1999) == -1\n assert candidate(forbidden = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 1536, 2048],a = 1,b = 2,x = 1500) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],a = 10,b = 20,x = 210) == -1\n assert candidate(forbidden = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],a = 2,b = 1,x = 21) == 12\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],a = 1,b = 2,x = 21) == -1\n assert candidate(forbidden = [200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000],a = 100,b = 200,x = 2100) == -1\n assert candidate(forbidden = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],a = 100,b = 50,x = 1000) == -1\n assert candidate(forbidden = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000],a = 500,b = 100,x = 5500) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],a = 10,b = 5,x = 199) == -1\n assert candidate(forbidden = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],a = 2,b = 1,x = 28) == 14\n assert candidate(forbidden = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519],a = 100,b = 50,x = 600) == 9\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],a = 10,b = 5,x = 210) == -1\n assert candidate(forbidden = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],a = 25,b = 50,x = 600) == -1\n assert candidate(forbidden = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],a = 15,b = 25,x = 100) == -1\n assert candidate(forbidden = [1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991, 1990],a = 1,b = 2,x = 2000) == -1\n assert candidate(forbidden = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 1500],a = 250,b = 125,x = 2000) == 11\n assert candidate(forbidden = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],a = 2,b = 4,x = 50) == 25\n assert candidate(forbidden = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19],a = 5,b = 3,x = 20) == -1\n assert candidate(forbidden = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],a = 100,b = 50,x = 1001) == -1\n assert candidate(forbidden = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],a = 3,b = 6,x = 63) == -1\n assert candidate(forbidden = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],a = 100,b = 50,x = 2100) == -1\n assert candidate(forbidden = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],a = 10,b = 5,x = 195) == 21\n assert candidate(forbidden = [199, 399, 599, 799, 999, 1199, 1399, 1599, 1799, 1999],a = 200,b = 100,x = 1998) == -1\n assert candidate(forbidden = [500, 1000, 1500],a = 100,b = 50,x = 2000) == 23\n assert candidate(forbidden = [2000],a = 1000,b = 500,x = 1500) == 3\n assert candidate(forbidden = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],a = 10,b = 5,x = 200) == 20\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],a = 2,b = 4,x = 30) == -1\n assert candidate(forbidden = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],a = 1,b = 2,x = 25) == -1\n assert candidate(forbidden = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],a = 2,b = 4,x = 21) == -1\n assert candidate(forbidden = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130],a = 5,b = 3,x = 140) == -1\n assert candidate(forbidden = [500, 1000, 1500, 2000],a = 500,b = 250,x = 2500) == -1\n assert candidate(forbidden = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150],a = 5,b = 10,x = 135) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],a = 50,b = 100,x = 350) == -1\n assert candidate(forbidden = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000],a = 500,b = 1000,x = 6000) == -1\n assert candidate(forbidden = [],a = 1000,b = 500,x = 2000) == 2\n assert candidate(forbidden = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],a = 100,b = 200,x = 1500) == -1\n assert candidate(forbidden = [5, 15, 25, 35, 45],a = 10,b = 5,x = 100) == 10\n assert candidate(forbidden = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90],a = 3,b = 9,x = 88) == -1\n assert candidate(forbidden = [100, 150, 200, 250, 300],a = 50,b = 20,x = 180) == 5\n assert candidate(forbidden = [101, 201, 301, 401, 501, 601, 701, 801, 901, 1001, 1101, 1201, 1301, 1401, 1501, 1601, 1701, 1801, 1901],a = 100,b = 50,x = 1899) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],a = 10,b = 5,x = 195) == -1\n assert candidate(forbidden = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],a = 2,b = 4,x = 20) == 10\n assert candidate(forbidden = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],a = 1,b = 2,x = 31) == -1\n assert candidate(forbidden = [150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500, 1650, 1800, 1950],a = 150,b = 100,x = 1000) == -1\n assert candidate(forbidden = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597],a = 7,b = 5,x = 400) == 64\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],a = 1,b = 3,x = 21) == -1\n assert candidate(forbidden = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],a = 20,b = 10,x = 199) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50],a = 5,b = 10,x = 15) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],a = 10,b = 20,x = 200) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],a = 10,b = 5,x = 210) == -1\n assert candidate(forbidden = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],a = 5,b = 10,x = 105) == -1\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],a = 2,b = 1,x = 19) == -1\n assert candidate(forbidden = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],a = 5,b = 3,x = 48) == -1\n assert candidate(forbidden = [3, 6, 9, 12, 15, 18, 21, 24, 27],a = 3,b = 2,x = 30) == -1\n assert candidate(forbidden = [300, 600, 900, 1200, 1500, 1800, 2000],a = 100,b = 200,x = 1900) == -1\n assert candidate(forbidden = [150, 300, 450, 600, 750, 900, 1050, 1200, 1350, 1500, 1650, 1800, 1950],a = 150,b = 75,x = 1995) == -1\n assert candidate(forbidden = [199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180],a = 1,b = 2,x = 175) == 175\n assert candidate(forbidden = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],a = 10,b = 5,x = 199) == -1\n assert candidate(forbidden = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, 103, 107, 111, 115, 119, 123, 127, 131, 135, 139, 143, 147, 151, 155, 159, 163, 167, 171, 175, 179, 183, 187, 191, 195, 199],a = 4,b = 8,x = 197) == -1\n assert candidate(forbidden = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],a = 2,b = 3,x = 50) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],a = 5,b = 10,x = 150) == -1\n assert candidate(forbidden = [50, 100, 150, 200],a = 50,b = 25,x = 200) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],a = 10,b = 5,x = 145) == -1\n assert candidate(forbidden = [100, 200, 300, 400, 500],a = 100,b = 200,x = 600) == -1\n assert candidate(forbidden = [10, 25, 40, 55, 70, 85, 100, 115, 130, 145, 160, 175, 190, 205, 220, 235, 250, 265, 280, 295],a = 15,b = 30,x = 290) == -1\n assert candidate(forbidden = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],a = 1,b = 1,x = 110) == -1\n assert candidate(forbidden = [10, 15, 20, 25, 30],a = 5,b = 10,x = 40) == -1\n assert candidate(forbidden = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],a = 5,b = 10,x = 55) == -1\n assert candidate(forbidden = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],a = 3,b = 1,x = 45) == -1\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60],a = 2,b = 4,x = 62) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],a = 10,b = 5,x = 185) == -1\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],a = 2,b = 1,x = 39) == -1\n assert candidate(forbidden = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],a = 1,b = 2,x = 21) == -1\n assert candidate(forbidden = [2, 5, 7, 10, 15, 20],a = 2,b = 4,x = 25) == -1\n assert candidate(forbidden = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],a = 1,b = 2,x = 2048) == -1\n assert candidate(forbidden = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119],a = 1,b = 1,x = 120) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90],a = 10,b = 5,x = 100) == -1\n assert candidate(forbidden = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],a = 10,b = 20,x = 105) == -1\n assert candidate(forbidden = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],a = 1,b = 2,x = 30) == -1\n assert candidate(forbidden = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],a = 2,b = 3,x = 42) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190],a = 10,b = 5,x = 195) == -1\n assert candidate(forbidden = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290],a = 10,b = 20,x = 299) == -1\n"}, "metadata": {"canonical_parameter_names": ["forbidden", "a", "b", "x"], "leetcode_dataset_entry_point": "Solution().minimumJumps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumJumps(vector& forbidden, int a, int b, int x) {", "container": "Solution", "callable": "minimumJumps", "parameters": [{"name": "forbidden", "type": "vector&"}, {"name": "a", "type": "int"}, {"name": "b", "type": "int"}, {"name": "x", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1655, "task_id": "distribute-repeating-integers", "difficulty": "Hard", "problem_description": "You are given an array of n integers, nums, where there are at most 50 unique values in the array. You are also given an array of m customer order quantities, quantity, where quantity[i] is the amount of integers the ith customer ordered. Determine if it is possible to distribute nums such that:\n\nThe ith customer gets exactly quantity[i] integers,\nThe integers the ith customer gets are all equal, and\nEvery customer is satisfied.\n\nReturn true if it is possible to distribute nums according to the above conditions.\n \nExample 1:\n\nInput: nums = [1,2,3,4], quantity = [2]\nOutput: false\nExplanation: The 0th customer cannot be given two different integers.\n\nExample 2:\n\nInput: nums = [1,2,3,3], quantity = [2]\nOutput: true\nExplanation: The 0th customer is given [3,3]. The integers [1,2] are not used.\n\nExample 3:\n\nInput: nums = [1,1,2,2], quantity = [2,2]\nOutput: true\nExplanation: The 0th customer is given [1,1], and the 1st customer is given [2,2].\n\n \nConstraints:\n\nn == nums.length\n1 <= n <= 105\n1 <= nums[i] <= 1000\nm == quantity.length\n1 <= m <= 10\n1 <= quantity[i] <= 105\nThere are at most 50 unique values in nums.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 2, 2],quantity = [2, 2]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3],quantity = [3, 3]) == True\n assert candidate(nums = [10, 10, 10, 20, 20, 20, 30, 30, 30, 40, 40, 40, 50, 50, 50, 60, 60, 60, 70, 70, 70],quantity = [3, 3, 3, 3, 3]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],quantity = [10, 10]) == True\n assert candidate(nums = [1, 1, 1, 1, 1],quantity = [5]) == True\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50],quantity = [2, 2, 2, 2]) == True\n assert candidate(nums = [1, 2, 3, 4],quantity = [2]) == False\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4],quantity = [4, 4, 4]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],quantity = [2, 2, 2]) == True\n assert candidate(nums = [1, 2, 3, 3],quantity = [2]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],quantity = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50],quantity = [2, 2, 2, 2, 2]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4],quantity = [3, 3, 3, 4]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],quantity = [3, 3, 3]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],quantity = [2, 2, 3, 4, 5]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [5, 5, 5]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 3],quantity = [2, 3]) == True\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],quantity = [10]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4],quantity = [3, 3, 3, 4]) == True\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [2, 3, 3, 4, 4]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],quantity = [10, 10, 10, 10]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6],quantity = [5, 5, 5, 5]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],quantity = [3, 3, 3, 5, 5]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],quantity = [5, 7, 4]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5],quantity = [7, 7, 7, 7]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [10, 10, 10, 10]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],quantity = [5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],quantity = [2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20],quantity = [10, 10, 10]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],quantity = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [3, 3, 3, 3, 3, 3]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [3, 4, 5, 3]) == True\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],quantity = [5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],quantity = [4, 6, 6, 8]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],quantity = [3, 3, 3, 3, 3]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],quantity = [5, 5, 5, 10, 5]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],quantity = [2, 2, 2, 2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],quantity = [4, 4, 4, 4]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],quantity = [2, 2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [15, 15, 15, 15]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10],quantity = [6, 6, 6, 6, 6]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [10, 10, 10, 10, 10]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [5, 5, 5, 5]) == True\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6],quantity = [5, 5, 6]) == True\n assert candidate(nums = [7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10],quantity = [3, 3, 4, 4]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],quantity = [5, 5, 5, 5, 10]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],quantity = [3, 4, 5, 6]) == True\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],quantity = [10, 10, 10]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],quantity = [10, 10, 10]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],quantity = [5, 5, 5]) == False\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],quantity = [5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],quantity = [10, 10, 10, 10, 10]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],quantity = [7, 7, 7, 5]) == True\n assert candidate(nums = [7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],quantity = [5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6],quantity = [2, 2, 3, 3, 3]) == True\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],quantity = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6],quantity = [2, 2, 3, 3, 4]) == True\n assert candidate(nums = [10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50, 50],quantity = [2, 4, 6]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5],quantity = [3, 5, 4]) == True\n"}, "metadata": {"canonical_parameter_names": ["nums", "quantity"], "leetcode_dataset_entry_point": "Solution().canDistribute", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool canDistribute(vector& nums, vector& quantity) {", "container": "Solution", "callable": "canDistribute", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "quantity", "type": "vector&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1657, "task_id": "determine-if-two-strings-are-close", "difficulty": "Medium", "problem_description": "Two strings are considered close if you can attain one from the other using the following operations:\n\nOperation 1: Swap any two existing characters.\n\n\t\nFor example, abcde -> aecdb\n\n\nOperation 2: Transform every occurrence of one existing character into another existing character, and do the same with the other character.\n\t\nFor example, aacabb -> bbcbaa (all a's turn into b's, and all b's turn into a's)\n\n\n\nYou can use the operations on either string as many times as necessary.\nGiven two strings, word1 and word2, return true if word1 and word2 are close, and false otherwise.\n \nExample 1:\n\nInput: word1 = \"abc\", word2 = \"bca\"\nOutput: true\nExplanation: You can attain word2 from word1 in 2 operations.\nApply Operation 1: \"abc\" -> \"acb\"\nApply Operation 1: \"acb\" -> \"bca\"\n\nExample 2:\n\nInput: word1 = \"a\", word2 = \"aa\"\nOutput: false\nExplanation: It is impossible to attain word2 from word1, or vice versa, in any number of operations.\n\nExample 3:\n\nInput: word1 = \"cabbba\", word2 = \"abbccc\"\nOutput: true\nExplanation: You can attain word2 from word1 in 3 operations.\nApply Operation 1: \"cabbba\" -> \"caabbb\"\nApply Operation 2: \"caabbb\" -> \"baaccc\"\nApply Operation 2: \"baaccc\" -> \"abbccc\"\n\n \nConstraints:\n\n1 <= word1.length, word2.length <= 105\nword1 and word2 contain only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word1 = \"leetcode\",word2 = \"coeddlet\") == False\n assert candidate(word1 = \"aaa\",word2 = \"bbb\") == False\n assert candidate(word1 = \"aaabbbbccdddd\",word2 = \"bbbbaacdddd\") == False\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(word1 = \"aabbcc\",word2 = \"ccbbaa\") == True\n assert candidate(word1 = \"abc\",word2 = \"bca\") == True\n assert candidate(word1 = \"abcabcabc\",word2 = \"bcbcbcbcb\") == False\n assert candidate(word1 = \"abcde\",word2 = \"edcba\") == True\n assert candidate(word1 = \"cabbba\",word2 = \"abbccc\") == True\n assert candidate(word1 = \"xyzz\",word2 = \"zzxy\") == True\n assert candidate(word1 = \"xyz\",word2 = \"zyx\") == True\n assert candidate(word1 = \"abcd\",word2 = \"abce\") == False\n assert candidate(word1 = \"aaabbbbcc\",word2 = \"bbbcccaaa\") == False\n assert candidate(word1 = \"uau\",word2 = \"ssx\") == False\n assert candidate(word1 = \"aaabbbbccddd\",word2 = \"bbbccdddcccc\") == False\n assert candidate(word1 = \"aabbbbccc\",word2 = \"bbcccaaaa\") == True\n assert candidate(word1 = \"abab\",word2 = \"baba\") == True\n assert candidate(word1 = \"aaabbbbcc\",word2 = \"aaaabbbcc\") == True\n assert candidate(word1 = \"a\",word2 = \"aa\") == False\n assert candidate(word1 = \"aab\",word2 = \"bba\") == True\n assert candidate(word1 = \"abcd\",word2 = \"dcba\") == True\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\") == False\n assert candidate(word1 = \"aaaabbbbccccdddd\",word2 = \"ddddeeeeffffgggg\") == False\n assert candidate(word1 = \"aaabbcccddeeefffggghhhhiiiii\",word2 = \"iiiiihhhgggfffeeedddcccbbaaa\") == False\n assert candidate(word1 = \"xyzxyzxyz\",word2 = \"zyxzyxzyx\") == True\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"bbacabadabacaba\") == False\n assert candidate(word1 = \"aaabbcccddddeeeeeffffffgggggghhhhhiiiijjjjkkkkklllllmmmmnnooooppqqrrsstttuuuuuvvvvvvvwwxxxxxyyyyzzzzz\",word2 = \"zzzzzyyyyxxxwwwvvvvvvuuuuutttssrrqqppoonnmmllkkjjiihhhgggfffddddccccbbbbaaa\") == False\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"ffeeddccbbaa\") == True\n assert candidate(word1 = \"aaabbbcccdddeeefff\",word2 = \"ffeeeedddcccbbbaaa\") == False\n assert candidate(word1 = \"mississippi\",word2 = \"ppissimissi\") == True\n assert candidate(word1 = \"abcdabcabcabcd\",word2 = \"dcbaababdcbaabab\") == False\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"bacabacababacab\") == False\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzxxyywwvvuuttssrrqqppoonnmmllkkjjiihhggffeeeeddccbbaa\") == False\n assert candidate(word1 = \"ppppoooonnnnmmmlllkkeeeeeddcccbbbaaa\",word2 = \"aaaaaaaaabbbbbbccccdddddeeeeeeeekkkkkklllllmmmmmmmnnnnnnnnoooooooooppppppp\") == False\n assert candidate(word1 = \"qqqwwwweeerrrttt\",word2 = \"tttwwweerrrqqq\") == False\n assert candidate(word1 = \"abcabcabc\",word2 = \"ccbbbaaa\") == False\n assert candidate(word1 = \"qwertypoiuytrewq\",word2 = \"poiuytrewqqwertypo\") == False\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == False\n assert candidate(word1 = \"abcdefabcdefabcdef\",word2 = \"fedcbafedcbafedcba\") == True\n assert candidate(word1 = \"abcdefghij\",word2 = \"jihgfedcba\") == True\n assert candidate(word1 = \"abcdefgh\",word2 = \"hgfedcba\") == True\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"cbacbacbcacbacb\") == False\n assert candidate(word1 = \"abcdefg\",word2 = \"gfedcba\") == True\n assert candidate(word1 = \"loooooonnnngggggwwwoooorrrrddddsssaaammmmeeeerrttttyyyyyyyyyyyynnnnnnnnnn\",word2 = \"nnnnnnnnnnyyyyyyyyyyyttttyyyyymmmeeraatttddddsssaaawwwggggnnnllllloooooo\") == False\n assert candidate(word1 = \"xylophone\",word2 = \"phonexylo\") == True\n assert candidate(word1 = \"abcdefghijklopqrstuvwxyz\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",word2 = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(word1 = \"abcdefabcabc\",word2 = \"abcabcabcdef\") == True\n assert candidate(word1 = \"aaaaabbbbcccccccdddddddd\",word2 = \"ddddddddcccccccbbbbaaaaa\") == True\n assert candidate(word1 = \"mnopqr\",word2 = \"rpqomn\") == True\n assert candidate(word1 = \"mississippi\",word2 = \"ppiimssisss\") == False\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzyyxxwwvvuuttssrrqppoonnmlkkjjiihhggffeeeeddccbbaa\") == False\n assert candidate(word1 = \"anotherexample\",word2 = \"mpleaxarnothee\") == True\n assert candidate(word1 = \"aaaaabbbbbccccc\",word2 = \"bbbbbcccccaaaaa\") == True\n assert candidate(word1 = \"zzzzzzyyyxxx\",word2 = \"yyyxxxzzzzzy\") == False\n assert candidate(word1 = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"yzxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\") == False\n assert candidate(word1 = \"xyzxyzxyzxyzxyzxyzxyz\",word2 = \"zyxzyxzyxzyxzyxzyxzyxzyxzyx\") == False\n assert candidate(word1 = \"aabccddddeeeeefffffff\",word2 = \"eeeeeeffffffdddddcccbaaa\") == False\n assert candidate(word1 = \"mnopqr\",word2 = \"rstuvw\") == False\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == False\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"abcdeffedcba\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"abcdefghijklmnopqrstuvxyzmnopqrstuvwxyzabcdefg\") == False\n assert candidate(word1 = \"uniqueletters\",word2 = \"letterniquesu\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzxxyywwvvuuttssrrqqlloonnmmllkkjjiihhggeeddbbaa\") == False\n assert candidate(word1 = \"abcabcabcabcabcabcabcabcabcabc\",word2 = \"bcabacabcabacabcabacabcabacabcabac\") == False\n assert candidate(word1 = \"abcdefghijk\",word2 = \"abcdefghijl\") == False\n assert candidate(word1 = \"thisisatest\",word2 = \"esttasisthi\") == True\n assert candidate(word1 = \"qqwweerrttyyuuiiooppllaaassddffgg\",word2 = \"ggffddssaallooppuiiyyttreeewwqq\") == False\n assert candidate(word1 = \"abacabadaba\",word2 = \"dabacababad\") == False\n assert candidate(word1 = \"pneumonoultramicroscopicsilicovolcanoconiosis\",word2 = \"oconsinolpnacirosccvilcooimmutapernovulcrosmicn\") == False\n assert candidate(word1 = \"abcabcabcabc\",word2 = \"cccbbbaaabbb\") == False\n assert candidate(word1 = \"leetcode\",word2 = \"codeleet\") == True\n assert candidate(word1 = \"z\",word2 = \"z\") == True\n assert candidate(word1 = \"aabbaa\",word2 = \"bbaabb\") == True\n assert candidate(word1 = \"aaabbbccc\",word2 = \"bbbaaacc\") == False\n assert candidate(word1 = \"transform\",word2 = \"rmorfnapt\") == False\n assert candidate(word1 = \"aaaabbbbccccddddeeeeeffffffgggggg\",word2 = \"ggggggffffffeeeeeeeeeccccbbbbaaaa\") == False\n assert candidate(word1 = \"abacabadabacabad\",word2 = \"badacabdacabad\") == False\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == True\n assert candidate(word1 = \"hello\",word2 = \"ollhe\") == True\n assert candidate(word1 = \"uniquestring\",word2 = \"stringunique\") == True\n assert candidate(word1 = \"abcdef\",word2 = \"gfedcb\") == False\n assert candidate(word1 = \"xyxyxyxyxyxyxyxyxyxy\",word2 = \"yyxyxyxyxyxyxyxyxyxxyx\") == False\n assert candidate(word1 = \"aaaaabbbbccccdddd\",word2 = \"ddddccccbbbbaaa\") == False\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == True\n assert candidate(word1 = \"abcde\",word2 = \"fghij\") == False\n assert candidate(word1 = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",word2 = \"ddddccccbbbbaaaaaaddddccccbbbbaaaaaa\") == False\n assert candidate(word1 = \"aabbbcccc\",word2 = \"cccbbbaaa\") == False\n assert candidate(word1 = \"aabbccddeee\",word2 = \"eeeedddccbbbaaa\") == False\n assert candidate(word1 = \"thisisatest\",word2 = \"esttisita\") == False\n assert candidate(word1 = \"aaabbbcccddd\",word2 = \"ddddcccbbbbaaa\") == False\n assert candidate(word1 = \"abcdefghijabcdefghijabcdefghij\",word2 = \"abcdefghijabcdefghijabcdefghij\") == True\n assert candidate(word1 = \"zzzzzzzzzz\",word2 = \"zzzzzzzzzz\") == True\n assert candidate(word1 = \"abcdeabcde\",word2 = \"edcbaedcba\") == True\n assert candidate(word1 = \"abcdabcdabcdabcdabcdabcd\",word2 = \"dcbaabcdabcdabcdabcdabcd\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzzyyxwwvvuuttrrqqppoonnmmllkkiijjgghhffeeeeddccbbaa\") == False\n assert candidate(word1 = \"abcdexyz\",word2 = \"zyxwvuts\") == False\n assert candidate(word1 = \"qqwweerrttyyuuiiooppaassddffgg\",word2 = \"ggffddssaappoouuiittyyerrrwwqq\") == False\n assert candidate(word1 = \"abcdefg\",word2 = \"ghijklm\") == False\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzxxwwvvuuttssrrqqlloonnmmllkkjjiihhggeeddbbaa\") == False\n assert candidate(word1 = \"aaaabbbbccccddddeee\",word2 = \"eeedddccccbbbbaaaa\") == False\n assert candidate(word1 = \"abcdabcd\",word2 = \"dcbaabcd\") == True\n assert candidate(word1 = \"closestrings\",word2 = \"stringsclose\") == True\n assert candidate(word1 = \"aaaabbbbccccdddd\",word2 = \"ddddccccbbbbaaaa\") == True\n assert candidate(word1 = \"xyzzzz\",word2 = \"zzzzxy\") == True\n"}, "metadata": {"canonical_parameter_names": ["word1", "word2"], "leetcode_dataset_entry_point": "Solution().closeStrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool closeStrings(string word1, string word2) {", "container": "Solution", "callable": "closeStrings", "parameters": [{"name": "word1", "type": "string"}, {"name": "word2", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1658, "task_id": "minimum-operations-to-reduce-x-to-zero", "difficulty": "Medium", "problem_description": "You are given an integer array nums and an integer x. In one operation, you can either remove the leftmost or the rightmost element from the array nums and subtract its value from x. Note that this modifies the array for future operations.\nReturn the minimum number of operations to reduce x to exactly 0 if it is possible, otherwise, return -1.\n \nExample 1:\n\nInput: nums = [1,1,4,2,3], x = 5\nOutput: 2\nExplanation: The optimal solution is to remove the last two elements to reduce x to zero.\n\nExample 2:\n\nInput: nums = [5,6,7,8,9], x = 4\nOutput: -1\n\nExample 3:\n\nInput: nums = [3,2,20,1,1,3], x = 10\nOutput: 5\nExplanation: The optimal solution is to remove the last three elements and the first two elements (5 operations in total) to reduce x to zero.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 104\n1 <= x <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5],x = 15) == 5\n assert candidate(nums = [1, 1, 4, 2, 3],x = 5) == 2\n assert candidate(nums = [10, 20, 30, 40, 50],x = 100) == 3\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000],x = 30000) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 10) == 10\n assert candidate(nums = [3, 2, 20, 1, 1, 3],x = 10) == 5\n assert candidate(nums = [1, 1, 1, 1, 1],x = 5) == 5\n assert candidate(nums = [1, 1, 1, 1, 1],x = 3) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 15) == 5\n assert candidate(nums = [2, 3, 1, 2, 4, 3],x = 7) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 11) == 2\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000],x = 50000) == 5\n assert candidate(nums = [5, 6, 7, 8, 9],x = 4) == -1\n assert candidate(nums = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],x = 25000) == 5\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],x = 15) == 10\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],x = 5000) == 5\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],x = 1400000) == -1\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],x = 10) == 7\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],x = 1111111111) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],x = 1000) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 190) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 190) == 15\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],x = 55000) == 10\n assert candidate(nums = [3, 5, 10, 7, 15, 1, 4, 2, 8, 6],x = 29) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 21) == 6\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 5) == 5\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 95) == 15\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],x = 55000) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 30) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 25) == 5\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],x = 55) == 7\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],x = 15) == 4\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],x = 15) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],x = 85) == 8\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],x = 100) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 10) == 10\n assert candidate(nums = [1, 2, 3, 4, 5],x = 15) == 5\n assert candidate(nums = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],x = 35000) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 10) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 50) == 50\n assert candidate(nums = [3, 2, 20, 1, 1, 3, 5, 10, 1, 1],x = 29) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 1000) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],x = 150) == 5\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],x = 50000) == 5\n assert candidate(nums = [5, 3, 2, 5, 3, 2, 5, 3, 2, 5, 3, 2, 5, 3, 2],x = 20) == 6\n assert candidate(nums = [1, 3, 2, 4, 5, 2, 3, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 150) == 12\n assert candidate(nums = [5, 2, 3, 1, 1, 2, 3, 4, 5],x = 9) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],x = 1225) == 45\n assert candidate(nums = [2, 3, 2, 2, 3, 2, 3, 2, 2, 3, 2, 3, 2, 2, 3, 2, 3, 2, 2, 3, 2, 3, 2, 2, 3, 2, 3, 2, 2, 3],x = 15) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 100) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],x = 100) == 20\n assert candidate(nums = [3, 5, 2, 1, 4, 7, 8, 9, 6, 10],x = 18) == 3\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],x = 45000) == 6\n assert candidate(nums = [3, 2, 2, 2, 3, 2, 3, 3, 2, 2, 3, 3, 3, 2, 2, 3, 3, 3, 3, 2, 3, 3, 2, 3, 2, 2, 3, 3, 3, 3],x = 30) == 11\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],x = 370) == 6\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],x = 50) == 5\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],x = 9) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],x = 1500) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 210) == 20\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],x = 55000) == 10\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000],x = 120000) == 3\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000],x = 120000) == 3\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],x = 90) == -1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],x = 45) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],x = 275) == 20\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],x = 60) == 20\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],x = 100000) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 55) == 10\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],x = 30) == -1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],x = 50) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 100) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],x = 15) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 55) == 10\n assert candidate(nums = [10000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9000],x = 20000) == -1\n assert candidate(nums = [10000, 9999, 10000, 9999, 10000, 9999],x = 59996) == -1\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],x = 3000) == 5\n assert candidate(nums = [9, 1, 2, 3, 9, 3, 2, 1, 9],x = 18) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],x = 80) == 14\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],x = 25) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],x = 105) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],x = 1275) == 50\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 50) == 50\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],x = 435) == 25\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],x = 550) == 10\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],x = 65) == 13\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],x = 100) == 9\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],x = 100) == 10\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],x = 45) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],x = 20) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],x = 120) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],x = 450) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 55) == 10\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],x = 5500) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],x = 55) == 10\n assert candidate(nums = [9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999],x = 49995) == 5\n assert candidate(nums = [5, 2, 3, 1, 1, 5, 5, 3, 2, 5],x = 10) == 2\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],x = 90) == 30\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],x = 80) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],x = 950) == 10\n assert candidate(nums = [3, 5, 2, 4, 1, 9, 6, 7, 8, 10],x = 25) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],x = 100) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],x = 120) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 15) == 15\n assert candidate(nums = [1, 2, 3, 4, 5],x = 0) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],x = 20) == 20\n assert candidate(nums = [5000, 3000, 2000, 4000, 1000, 6000],x = 21000) == 6\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],x = 70000) == 7\n"}, "metadata": {"canonical_parameter_names": ["nums", "x"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minOperations(vector& nums, int x) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "x", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1659, "task_id": "maximize-grid-happiness", "difficulty": "Hard", "problem_description": "You are given four integers, m, n, introvertsCount, and extrovertsCount. You have an m x n grid, and there are two types of people: introverts and extroverts. There are introvertsCount introverts and extrovertsCount extroverts.\nYou should decide how many people you want to live in the grid and assign each of them one grid cell. Note that you do not have to have all the people living in the grid.\nThe happiness of each person is calculated as follows:\n\nIntroverts start with 120 happiness and lose 30 happiness for each neighbor (introvert or extrovert).\nExtroverts start with 40 happiness and gain 20 happiness for each neighbor (introvert or extrovert).\n\nNeighbors live in the directly adjacent cells north, east, south, and west of a person's cell.\nThe grid happiness is the sum of each person's happiness. Return the maximum possible grid happiness.\n \nExample 1:\n\n\nInput: m = 2, n = 3, introvertsCount = 1, extrovertsCount = 2\nOutput: 240\nExplanation: Assume the grid is 1-indexed with coordinates (row, column).\nWe can put the introvert in cell (1,1) and put the extroverts in cells (1,3) and (2,3).\n- Introvert at (1,1) happiness: 120 (starting happiness) - (0 * 30) (0 neighbors) = 120\n- Extrovert at (1,3) happiness: 40 (starting happiness) + (1 * 20) (1 neighbor) = 60\n- Extrovert at (2,3) happiness: 40 (starting happiness) + (1 * 20) (1 neighbor) = 60\nThe grid happiness is 120 + 60 + 60 = 240.\nThe above figure shows the grid in this example with each person's happiness. The introvert stays in the light green cell while the extroverts live on the light purple cells.\n\nExample 2:\n\nInput: m = 3, n = 1, introvertsCount = 2, extrovertsCount = 1\nOutput: 260\nExplanation: Place the two introverts in (1,1) and (3,1) and the extrovert at (2,1).\n- Introvert at (1,1) happiness: 120 (starting happiness) - (1 * 30) (1 neighbor) = 90\n- Extrovert at (2,1) happiness: 40 (starting happiness) + (2 * 20) (2 neighbors) = 80\n- Introvert at (3,1) happiness: 120 (starting happiness) - (1 * 30) (1 neighbor) = 90\nThe grid happiness is 90 + 80 + 90 = 260.\n\nExample 3:\n\nInput: m = 2, n = 2, introvertsCount = 4, extrovertsCount = 0\nOutput: 240\n\n \nConstraints:\n\n1 <= m, n <= 5\n0 <= introvertsCount, extrovertsCount <= min(m * n, 6)\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(m = 5,n = 5,introvertsCount = 6,extrovertsCount = 6) == 1240\n assert candidate(m = 1,n = 1,introvertsCount = 0,extrovertsCount = 1) == 40\n assert candidate(m = 5,n = 1,introvertsCount = 0,extrovertsCount = 0) == 0\n assert candidate(m = 2,n = 3,introvertsCount = 1,extrovertsCount = 2) == 240\n assert candidate(m = 1,n = 1,introvertsCount = 1,extrovertsCount = 0) == 120\n assert candidate(m = 4,n = 4,introvertsCount = 6,extrovertsCount = 0) == 720\n assert candidate(m = 2,n = 2,introvertsCount = 4,extrovertsCount = 0) == 240\n assert candidate(m = 3,n = 1,introvertsCount = 2,extrovertsCount = 1) == 260\n assert candidate(m = 1,n = 1,introvertsCount = 0,extrovertsCount = 0) == 0\n assert candidate(m = 5,n = 1,introvertsCount = 0,extrovertsCount = 5) == 360\n assert candidate(m = 4,n = 4,introvertsCount = 3,extrovertsCount = 3) == 560\n assert candidate(m = 5,n = 5,introvertsCount = 3,extrovertsCount = 3) == 560\n assert candidate(m = 1,n = 5,introvertsCount = 5,extrovertsCount = 0) == 360\n assert candidate(m = 4,n = 5,introvertsCount = 3,extrovertsCount = 2) == 480\n assert candidate(m = 2,n = 5,introvertsCount = 5,extrovertsCount = 5) == 770\n assert candidate(m = 3,n = 5,introvertsCount = 0,extrovertsCount = 6) == 520\n assert candidate(m = 2,n = 5,introvertsCount = 2,extrovertsCount = 4) == 560\n assert candidate(m = 2,n = 2,introvertsCount = 6,extrovertsCount = 0) == 240\n assert candidate(m = 5,n = 2,introvertsCount = 4,extrovertsCount = 2) == 590\n assert candidate(m = 3,n = 3,introvertsCount = 4,extrovertsCount = 1) == 520\n assert candidate(m = 4,n = 3,introvertsCount = 4,extrovertsCount = 3) == 680\n assert candidate(m = 5,n = 2,introvertsCount = 5,extrovertsCount = 1) == 620\n assert candidate(m = 5,n = 2,introvertsCount = 3,extrovertsCount = 2) == 480\n assert candidate(m = 5,n = 5,introvertsCount = 0,extrovertsCount = 0) == 0\n assert candidate(m = 4,n = 4,introvertsCount = 3,extrovertsCount = 4) == 680\n assert candidate(m = 4,n = 4,introvertsCount = 1,extrovertsCount = 6) == 640\n assert candidate(m = 4,n = 4,introvertsCount = 6,extrovertsCount = 6) == 1140\n assert candidate(m = 3,n = 2,introvertsCount = 0,extrovertsCount = 6) == 520\n assert candidate(m = 5,n = 5,introvertsCount = 6,extrovertsCount = 5) == 1120\n assert candidate(m = 4,n = 4,introvertsCount = 2,extrovertsCount = 2) == 360\n assert candidate(m = 1,n = 5,introvertsCount = 1,extrovertsCount = 4) == 390\n assert candidate(m = 4,n = 4,introvertsCount = 4,extrovertsCount = 4) == 800\n assert candidate(m = 2,n = 5,introvertsCount = 2,extrovertsCount = 3) == 440\n assert candidate(m = 5,n = 2,introvertsCount = 4,extrovertsCount = 1) == 520\n assert candidate(m = 3,n = 5,introvertsCount = 3,extrovertsCount = 3) == 560\n assert candidate(m = 2,n = 5,introvertsCount = 2,extrovertsCount = 2) == 360\n assert candidate(m = 3,n = 3,introvertsCount = 4,extrovertsCount = 3) == 640\n assert candidate(m = 3,n = 4,introvertsCount = 2,extrovertsCount = 4) == 560\n assert candidate(m = 5,n = 3,introvertsCount = 1,extrovertsCount = 4) == 440\n assert candidate(m = 4,n = 3,introvertsCount = 2,extrovertsCount = 3) == 440\n assert candidate(m = 3,n = 2,introvertsCount = 0,extrovertsCount = 3) == 200\n assert candidate(m = 5,n = 4,introvertsCount = 3,extrovertsCount = 2) == 480\n assert candidate(m = 3,n = 3,introvertsCount = 0,extrovertsCount = 6) == 520\n assert candidate(m = 3,n = 3,introvertsCount = 5,extrovertsCount = 1) == 610\n assert candidate(m = 5,n = 1,introvertsCount = 5,extrovertsCount = 1) == 380\n assert candidate(m = 5,n = 5,introvertsCount = 5,extrovertsCount = 1) == 640\n assert candidate(m = 4,n = 4,introvertsCount = 2,extrovertsCount = 4) == 560\n assert candidate(m = 4,n = 3,introvertsCount = 5,extrovertsCount = 1) == 640\n assert candidate(m = 4,n = 2,introvertsCount = 4,extrovertsCount = 2) == 520\n assert candidate(m = 5,n = 3,introvertsCount = 2,extrovertsCount = 4) == 560\n assert candidate(m = 4,n = 3,introvertsCount = 3,extrovertsCount = 3) == 560\n assert candidate(m = 3,n = 5,introvertsCount = 3,extrovertsCount = 2) == 480\n assert candidate(m = 3,n = 3,introvertsCount = 3,extrovertsCount = 3) == 550\n assert candidate(m = 4,n = 2,introvertsCount = 3,extrovertsCount = 2) == 470\n assert candidate(m = 5,n = 3,introvertsCount = 4,extrovertsCount = 2) == 600\n assert candidate(m = 4,n = 2,introvertsCount = 2,extrovertsCount = 4) == 550\n assert candidate(m = 5,n = 3,introvertsCount = 6,extrovertsCount = 0) == 720\n assert candidate(m = 5,n = 2,introvertsCount = 0,extrovertsCount = 6) == 520\n assert candidate(m = 4,n = 2,introvertsCount = 1,extrovertsCount = 5) == 520\n assert candidate(m = 4,n = 5,introvertsCount = 1,extrovertsCount = 4) == 440\n assert candidate(m = 4,n = 4,introvertsCount = 4,extrovertsCount = 3) == 680\n assert candidate(m = 4,n = 1,introvertsCount = 2,extrovertsCount = 2) == 340\n assert candidate(m = 4,n = 3,introvertsCount = 5,extrovertsCount = 2) == 710\n assert candidate(m = 5,n = 3,introvertsCount = 3,extrovertsCount = 3) == 560\n assert candidate(m = 2,n = 5,introvertsCount = 1,extrovertsCount = 5) == 520\n assert candidate(m = 5,n = 3,introvertsCount = 3,extrovertsCount = 4) == 680\n assert candidate(m = 4,n = 4,introvertsCount = 4,extrovertsCount = 2) == 600\n assert candidate(m = 4,n = 5,introvertsCount = 6,extrovertsCount = 2) == 840\n assert candidate(m = 3,n = 4,introvertsCount = 2,extrovertsCount = 3) == 440\n assert candidate(m = 3,n = 4,introvertsCount = 0,extrovertsCount = 6) == 520\n assert candidate(m = 3,n = 3,introvertsCount = 4,extrovertsCount = 4) == 700\n assert candidate(m = 2,n = 2,introvertsCount = 2,extrovertsCount = 2) == 280\n assert candidate(m = 5,n = 4,introvertsCount = 2,extrovertsCount = 3) == 440\n assert candidate(m = 3,n = 3,introvertsCount = 6,extrovertsCount = 0) == 600\n assert candidate(m = 4,n = 3,introvertsCount = 2,extrovertsCount = 4) == 560\n assert candidate(m = 5,n = 1,introvertsCount = 5,extrovertsCount = 0) == 360\n assert candidate(m = 2,n = 4,introvertsCount = 3,extrovertsCount = 2) == 470\n assert candidate(m = 2,n = 2,introvertsCount = 0,extrovertsCount = 0) == 0\n assert candidate(m = 3,n = 3,introvertsCount = 1,extrovertsCount = 1) == 160\n assert candidate(m = 1,n = 5,introvertsCount = 3,extrovertsCount = 3) == 420\n assert candidate(m = 3,n = 3,introvertsCount = 2,extrovertsCount = 2) == 360\n assert candidate(m = 3,n = 3,introvertsCount = 2,extrovertsCount = 4) == 550\n assert candidate(m = 2,n = 2,introvertsCount = 0,extrovertsCount = 1) == 40\n assert candidate(m = 2,n = 2,introvertsCount = 0,extrovertsCount = 2) == 120\n assert candidate(m = 3,n = 3,introvertsCount = 0,extrovertsCount = 0) == 0\n assert candidate(m = 3,n = 3,introvertsCount = 2,extrovertsCount = 3) == 440\n assert candidate(m = 5,n = 2,introvertsCount = 5,extrovertsCount = 5) == 770\n assert candidate(m = 5,n = 1,introvertsCount = 3,extrovertsCount = 3) == 420\n assert candidate(m = 5,n = 2,introvertsCount = 5,extrovertsCount = 0) == 600\n assert candidate(m = 4,n = 4,introvertsCount = 2,extrovertsCount = 3) == 440\n assert candidate(m = 5,n = 1,introvertsCount = 1,extrovertsCount = 0) == 120\n assert candidate(m = 2,n = 2,introvertsCount = 1,extrovertsCount = 1) == 160\n assert candidate(m = 1,n = 5,introvertsCount = 0,extrovertsCount = 5) == 360\n assert candidate(m = 4,n = 4,introvertsCount = 0,extrovertsCount = 0) == 0\n assert candidate(m = 4,n = 4,introvertsCount = 3,extrovertsCount = 2) == 480\n assert candidate(m = 4,n = 5,introvertsCount = 5,extrovertsCount = 4) == 920\n assert candidate(m = 1,n = 1,introvertsCount = 1,extrovertsCount = 1) == 120\n assert candidate(m = 5,n = 5,introvertsCount = 1,extrovertsCount = 1) == 160\n assert candidate(m = 1,n = 5,introvertsCount = 1,extrovertsCount = 0) == 120\n assert candidate(m = 1,n = 5,introvertsCount = 0,extrovertsCount = 1) == 40\n assert candidate(m = 5,n = 1,introvertsCount = 0,extrovertsCount = 1) == 40\n assert candidate(m = 2,n = 5,introvertsCount = 3,extrovertsCount = 2) == 480\n"}, "metadata": {"canonical_parameter_names": ["m", "n", "introvertsCount", "extrovertsCount"], "leetcode_dataset_entry_point": "Solution().getMaxGridHappiness", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int getMaxGridHappiness(int m, int n, int introvertsCount, int extrovertsCount) {", "container": "Solution", "callable": "getMaxGridHappiness", "parameters": [{"name": "m", "type": "int"}, {"name": "n", "type": "int"}, {"name": "introvertsCount", "type": "int"}, {"name": "extrovertsCount", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1662, "task_id": "check-if-two-string-arrays-are-equivalent", "difficulty": "Easy", "problem_description": "Given two string arrays word1 and word2, return true if the two arrays represent the same string, and false otherwise.\nA string is represented by an array if the array elements concatenated in order forms the string.\n \nExample 1:\n\nInput: word1 = [\"ab\", \"c\"], word2 = [\"a\", \"bc\"]\nOutput: true\nExplanation:\nword1 represents string \"ab\" + \"c\" -> \"abc\"\nword2 represents string \"a\" + \"bc\" -> \"abc\"\nThe strings are the same, so return true.\nExample 2:\n\nInput: word1 = [\"a\", \"cb\"], word2 = [\"ab\", \"c\"]\nOutput: false\n\nExample 3:\n\nInput: word1 = [\"abc\", \"d\", \"defg\"], word2 = [\"abcddefg\"]\nOutput: true\n\n \nConstraints:\n\n1 <= word1.length, word2.length <= 103\n1 <= word1[i].length, word2[i].length <= 103\n1 <= sum(word1[i].length), sum(word2[i].length) <= 103\nword1[i] and word2[i] consist of lowercase letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word1 = ['abc', 'd', 'defg'],word2 = ['abcddefg']) == True\n assert candidate(word1 = ['x'],word2 = ['y']) == False\n assert candidate(word1 = ['different'],word2 = ['string']) == False\n assert candidate(word1 = ['hello', 'world'],word2 = ['helloworld']) == True\n assert candidate(word1 = ['one', 'two', 'three'],word2 = ['onetwothree']) == True\n assert candidate(word1 = ['abc'],word2 = ['a', 'b', 'c']) == True\n assert candidate(word1 = ['abc'],word2 = ['ab', 'c']) == True\n assert candidate(word1 = ['xyz'],word2 = ['x', 'y', 'z']) == True\n assert candidate(word1 = ['hello', 'world'],word2 = ['helloWorld']) == False\n assert candidate(word1 = ['ab', 'c'],word2 = ['a', 'bc']) == True\n assert candidate(word1 = ['a'],word2 = ['a']) == True\n assert candidate(word1 = ['a', 'cb'],word2 = ['ab', 'c']) == False\n assert candidate(word1 = ['hello'],word2 = ['hello']) == True\n assert candidate(word1 = ['test'],word2 = ['t', 'es', 't']) == True\n assert candidate(word1 = ['a', 'b'],word2 = ['ab']) == True\n assert candidate(word1 = ['same', 'string'],word2 = ['same', 'string']) == True\n assert candidate(word1 = ['a', 'b', 'c'],word2 = ['a', 'b', 'c']) == True\n assert candidate(word1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g'],word2 = ['abcdefg']) == True\n assert candidate(word1 = ['split', 'in', 'pieces'],word2 = ['spli', 'tin', 'pi', 'eces']) == True\n assert candidate(word1 = ['a', 'b', 'c', 'd', 'e', 'f'],word2 = ['abcdef']) == True\n assert candidate(word1 = ['complex', 'string', 'example'],word2 = ['com', 'plex', 'string', 'ex', 'ample']) == True\n assert candidate(word1 = ['a', 'b', 'c'],word2 = ['ab', 'c']) == True\n assert candidate(word1 = ['same', 'same', 'same'],word2 = ['same', 'same', 'same']) == True\n assert candidate(word1 = ['split', 'this', 'up'],word2 = ['splitthis', 'up']) == True\n assert candidate(word1 = ['a', 'b', 'c'],word2 = ['d', 'e', 'f']) == False\n assert candidate(word1 = ['xyz', '123', 'abc'],word2 = ['xyz1', '23abc']) == True\n assert candidate(word1 = ['abcdef'],word2 = ['abc', 'd', 'e', 'f']) == True\n assert candidate(word1 = ['abcd', 'efgh', 'ijkl'],word2 = ['abcdefgh', 'ijkl']) == True\n assert candidate(word1 = ['abc', 'def'],word2 = ['abcdefg']) == False\n assert candidate(word1 = ['abc', 'def', 'ghi'],word2 = ['abc', 'd', 'efghi']) == True\n assert candidate(word1 = ['complex', 'word'],word2 = ['c', 'o', 'm', 'p', 'l', 'e', 'x', 'word']) == True\n assert candidate(word1 = ['partial', 'match'],word2 = ['partialm', 'atch']) == True\n assert candidate(word1 = ['a', 'bc', 'def', 'ghij'],word2 = ['abc', 'defghij']) == True\n assert candidate(word1 = ['equal', 'strings'],word2 = ['equalstrings']) == True\n assert candidate(word1 = ['example'],word2 = ['ex', 'ample']) == True\n assert candidate(word1 = ['complex', 'example'],word2 = ['com', 'plexex', 'ample']) == True\n assert candidate(word1 = ['abcdefg', 'hijklmn'],word2 = ['abc', 'defghijklmn']) == True\n assert candidate(word1 = ['same'],word2 = ['s', 'a', 'm', 'e']) == True\n assert candidate(word1 = ['long', 'word', 'sequence'],word2 = ['l', 'ongw', 'ordsequ', 'ence']) == True\n assert candidate(word1 = ['a', 'very', 'long', 'string', 'here'],word2 = ['averylongstringhere']) == True\n assert candidate(word1 = ['same', 'string'],word2 = ['sam', 'e', 'string']) == True\n assert candidate(word1 = ['abc', 'defg', 'hijkl'],word2 = ['abcdefg', 'hijkl']) == True\n assert candidate(word1 = ['abc', 'def', 'ghi'],word2 = ['abcdef', 'ghi']) == True\n assert candidate(word1 = ['abc', 'def', 'ghi'],word2 = ['abcdefg', 'hi']) == True\n assert candidate(word1 = ['long', 'string', 'here'],word2 = ['longstring', 'here']) == True\n assert candidate(word1 = ['x', 'y', 'z'],word2 = ['xyz']) == True\n assert candidate(word1 = ['z'],word2 = ['z']) == True\n assert candidate(word1 = ['one', 'two', 'three', 'four'],word2 = ['onetwo', 'three', 'four']) == True\n assert candidate(word1 = ['one', 'two', 'three', 'four'],word2 = ['onetwo', 'threefour']) == True\n assert candidate(word1 = ['x', 'y', 'z'],word2 = ['x', 'yz']) == True\n assert candidate(word1 = ['xyz', 'uvw'],word2 = ['xy', 'zu', 'vw']) == True\n assert candidate(word1 = ['a', 'b', 'c', 'd', 'e'],word2 = ['abcd', 'e']) == True\n assert candidate(word1 = ['longerstring', 'here'],word2 = ['longerstringhere']) == True\n assert candidate(word1 = ['onetwothree'],word2 = ['one', 'two', 'three']) == True\n assert candidate(word1 = ['abc', 'def', 'ghi'],word2 = ['ab', 'cdef', 'ghi']) == True\n assert candidate(word1 = ['abcd'],word2 = ['ab', 'c', 'd']) == True\n assert candidate(word1 = ['one', 'two', 'three', 'four'],word2 = ['onetwothreefour']) == True\n assert candidate(word1 = ['almost', 'thesame'],word2 = ['almostthesame', 'extra']) == False\n assert candidate(word1 = ['split', 'into', 'multiple', 'parts'],word2 = ['splitint', 'omulti', 'pleparts']) == True\n assert candidate(word1 = ['ab', 'cde', 'f'],word2 = ['abc', 'def']) == True\n assert candidate(word1 = ['same', 'string', 'here'],word2 = ['samestringhere']) == True\n assert candidate(word1 = ['xyz', 'uvw', 'mnop'],word2 = ['xyzu', 'vw', 'mnop']) == True\n assert candidate(word1 = ['xyz', 'uvw', 'qrst'],word2 = ['xyzuvw', 'qrst']) == True\n assert candidate(word1 = ['same', 'string', 'here'],word2 = ['sam', 'e', 'stringhere']) == True\n assert candidate(word1 = ['longstringhere', 'another'],word2 = ['longstringhereanother']) == True\n assert candidate(word1 = ['this', 'is', 'a', 'test'],word2 = ['thi', 'sisa', 'test']) == True\n assert candidate(word1 = ['abc', 'defg', 'hijk', 'lmnop'],word2 = ['abcdefg', 'hijklmnop']) == True\n assert candidate(word1 = ['longstringhere', 'anotherlongstringhere'],word2 = ['longstringhereanotherlongstringhere']) == True\n assert candidate(word1 = ['a', 'b', 'c', 'd', 'e'],word2 = ['abcde']) == True\n assert candidate(word1 = ['part1', 'part2', 'part3'],word2 = ['part', '1part2', 'part3']) == True\n assert candidate(word1 = ['a', 'longer', 'string', 'here'],word2 = ['a', 'longerstring', 'here']) == True\n assert candidate(word1 = ['part1', 'part2'],word2 = ['part1part2']) == True\n assert candidate(word1 = ['a', 'b', 'c'],word2 = ['abc']) == True\n assert candidate(word1 = ['different', 'length'],word2 = ['differentlen', 'gth']) == True\n assert candidate(word1 = ['longstringone', 'longstringtwo'],word2 = ['longstringone', 'long', 'string', 'two']) == True\n assert candidate(word1 = ['same', 'string', 'here'],word2 = ['samestring', 'here']) == True\n assert candidate(word1 = ['short'],word2 = ['loooooooonger']) == False\n assert candidate(word1 = ['hello', 'world'],word2 = ['he', 'll', 'o', 'wor', 'ld']) == True\n assert candidate(word1 = ['hello', 'world', 'python'],word2 = ['hello', 'wor', 'ldpy', 'thon']) == True\n assert candidate(word1 = ['another', 'example', 'with', 'spaces'],word2 = ['anotherexam', 'plewithspaces']) == True\n assert candidate(word1 = ['xyz', 'uvw', 'rst'],word2 = ['xyzuvw', 'rst']) == True\n assert candidate(word1 = ['abc', 'def'],word2 = ['a', 'bc', 'd', 'ef']) == True\n assert candidate(word1 = ['this', 'is', 'a', 'test'],word2 = ['thisisatest']) == True\n assert candidate(word1 = ['samestringhere'],word2 = ['same', 'string', 'here']) == True\n assert candidate(word1 = ['abcd'],word2 = ['a', 'b', 'c', 'd']) == True\n assert candidate(word1 = ['abc', 'def', 'ghi'],word2 = ['abcdefghi']) == True\n assert candidate(word1 = ['a', 'a', 'a', 'a', 'a'],word2 = ['a', 'a', 'a', 'a', 'a']) == True\n assert candidate(word1 = ['a', 'a', 'a', 'a', 'a'],word2 = ['aaaaa']) == True\n assert candidate(word1 = ['mismatch', 'here'],word2 = ['mismatch', 'there']) == False\n assert candidate(word1 = ['one', 'two', 'three'],word2 = ['on', 'etwothree']) == True\n assert candidate(word1 = ['part', 'one'],word2 = ['p', 'artone']) == True\n assert candidate(word1 = ['equal', 'length', 'words'],word2 = ['equal', 'length', 'word']) == False\n assert candidate(word1 = ['abc', 'def', 'ghi'],word2 = ['abc', 'def', 'ghi']) == True\n assert candidate(word1 = ['equal', 'length'],word2 = ['equal', 'length']) == True\n assert candidate(word1 = ['longwordhere'],word2 = ['l', 'on', 'g', 'wo', 'rd', 'here']) == True\n assert candidate(word1 = ['longer', 'string', 'example'],word2 = ['longerstringexample']) == True\n assert candidate(word1 = ['singleword'],word2 = ['single', 'word']) == True\n assert candidate(word1 = ['different', 'sizes'],word2 = ['different', 'siz', 'es']) == True\n assert candidate(word1 = ['a'],word2 = ['b']) == False\n assert candidate(word1 = ['one', 'two', 'three'],word2 = ['one', 'twothree']) == True\n assert candidate(word1 = ['split', 'this', 'way'],word2 = ['sp', 'lit', 'thi', 'sway']) == True\n assert candidate(word1 = ['one', 'two', 'three'],word2 = ['onetwo', 'three']) == True\n assert candidate(word1 = ['this', 'is', 'a', 'test'],word2 = ['thisis', 'atest']) == True\n assert candidate(word1 = ['a', 'b', 'c', 'd'],word2 = ['abcd']) == True\n assert candidate(word1 = ['split', 'across', 'multiple', 'parts'],word2 = ['splitacrossmultip', 'leparts']) == True\n"}, "metadata": {"canonical_parameter_names": ["word1", "word2"], "leetcode_dataset_entry_point": "Solution().arrayStringsAreEqual", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool arrayStringsAreEqual(vector& word1, vector& word2) {", "container": "Solution", "callable": "arrayStringsAreEqual", "parameters": [{"name": "word1", "type": "vector&"}, {"name": "word2", "type": "vector&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1663, "task_id": "smallest-string-with-a-given-numeric-value", "difficulty": "Medium", "problem_description": "The numeric value of a lowercase character is defined as its position (1-indexed) in the alphabet, so the numeric value of a is 1, the numeric value of b is 2, the numeric value of c is 3, and so on.\nThe numeric value of a string consisting of lowercase characters is defined as the sum of its characters' numeric values. For example, the numeric value of the string \"abe\" is equal to 1 + 2 + 5 = 8.\nYou are given two integers n and k. Return the lexicographically smallest string with length equal to n and numeric value equal to k.\nNote that a string x is lexicographically smaller than string y if x comes before y in dictionary order, that is, either x is a prefix of y, or if i is the first position such that x[i] != y[i], then x[i] comes before y[i] in alphabetic order.\n \nExample 1:\n\nInput: n = 3, k = 27\nOutput: \"aay\"\nExplanation: The numeric value of the string is 1 + 1 + 25 = 27, and it is the smallest string with such a value and length equal to 3.\n\nExample 2:\n\nInput: n = 5, k = 73\nOutput: \"aaszz\"\n\n \nConstraints:\n\n1 <= n <= 105\nn <= k <= 26 * n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 7,k = 100) == \"aaaszzz\"\n assert candidate(n = 1,k = 26) == \"z\"\n assert candidate(n = 4,k = 40) == \"aalz\"\n assert candidate(n = 5,k = 73) == \"aaszz\"\n assert candidate(n = 10,k = 260) == \"zzzzzzzzzz\"\n assert candidate(n = 2,k = 2) == \"aa\"\n assert candidate(n = 1,k = 1) == \"a\"\n assert candidate(n = 2,k = 26) == \"ay\"\n assert candidate(n = 4,k = 52) == \"aaxz\"\n assert candidate(n = 3,k = 27) == \"aay\"\n assert candidate(n = 10,k = 100) == \"aaaaaapzzz\"\n assert candidate(n = 50,k = 650) == \"aaaaaaaaaaaaaaaaaaaaaaaaaazzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(n = 100,k = 1000) == \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(n = 6,k = 161) == \"zzzzz\"\n assert candidate(n = 12,k = 300) == \"nzzzzzzzzzzz\"\n assert candidate(n = 6,k = 156) == \"zzzzzz\"\n assert candidate(n = 10,k = 131) == \"aaaaavzzzz\"\n assert candidate(n = 5,k = 67) == \"aamzz\"\n assert candidate(n = 15,k = 350) == \"akzzzzzzzzzzzzz\"\n assert candidate(n = 25,k = 650) == \"zzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(n = 12,k = 150) == \"aaaaaanzzzzz\"\n assert candidate(n = 7,k = 145) == \"anzzzzz\"\n assert candidate(n = 6,k = 45) == \"aaaaoz\"\n assert candidate(n = 6,k = 160) == \"zzzzz~\"\n assert candidate(n = 3,k = 51) == \"axz\"\n assert candidate(n = 11,k = 260) == \"ayzzzzzzzzz\"\n assert candidate(n = 30,k = 800) == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzŽ\"\n assert candidate(n = 15,k = 180) == \"aaaaaaaapzzzzzz\"\n assert candidate(n = 9,k = 150) == \"aaaqzzzzz\"\n assert candidate(n = 7,k = 104) == \"aaawzzz\"\n assert candidate(n = 7,k = 150) == \"aszzzzz\"\n assert candidate(n = 8,k = 175) == \"arzzzzzz\"\n assert candidate(n = 10,k = 150) == \"aaaapzzzzz\"\n assert candidate(n = 20,k = 400) == \"aaaafzzzzzzzzzzzzzzz\"\n assert candidate(n = 10,k = 52) == \"aaaaaaaarz\"\n assert candidate(n = 6,k = 180) == \"zzzzz’\"\n assert candidate(n = 6,k = 100) == \"aatzzz\"\n assert candidate(n = 12,k = 200) == \"aaaanzzzzzzz\"\n assert candidate(n = 8,k = 208) == \"zzzzzzzz\"\n assert candidate(n = 3,k = 25) == \"aaw\"\n assert candidate(n = 20,k = 200) == \"aaaaaaaaaaaafzzzzzzz\"\n assert candidate(n = 15,k = 150) == \"aaaaaaaaakzzzzz\"\n assert candidate(n = 100,k = 2600) == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(n = 6,k = 78) == \"aaawzz\"\n assert candidate(n = 15,k = 225) == \"aaaaaakzzzzzzzz\"\n assert candidate(n = 26,k = 676) == \"zzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(n = 3,k = 30) == \"acz\"\n assert candidate(n = 12,k = 312) == \"zzzzzzzzzzzz\"\n assert candidate(n = 9,k = 182) == \"aaxzzzzzz\"\n assert candidate(n = 7,k = 91) == \"aaajzzz\"\n assert candidate(n = 5,k = 130) == \"zzzzz\"\n assert candidate(n = 8,k = 120) == \"aaamzzzz\"\n assert candidate(n = 9,k = 234) == \"zzzzzzzzz\"\n assert candidate(n = 5,k = 125) == \"uzzzz\"\n assert candidate(n = 30,k = 780) == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(n = 20,k = 520) == \"zzzzzzzzzzzzzzzzzzzz\"\n assert candidate(n = 50,k = 1300) == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(n = 4,k = 50) == \"aavz\"\n assert candidate(n = 11,k = 286) == \"zzzzzzzzzzz\"\n assert candidate(n = 15,k = 200) == \"aaaaaaakzzzzzzz\"\n assert candidate(n = 9,k = 230) == \"vzzzzzzzz\"\n assert candidate(n = 4,k = 10) == \"aaag\"\n assert candidate(n = 2,k = 27) == \"az\"\n assert candidate(n = 7,k = 42) == \"aaaaakz\"\n assert candidate(n = 4,k = 90) == \"lzzz\"\n"}, "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().getSmallestString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string getSmallestString(int n, int k) {", "container": "Solution", "callable": "getSmallestString", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1664, "task_id": "ways-to-make-a-fair-array", "difficulty": "Medium", "problem_description": "You are given an integer array nums. You can choose exactly one index (0-indexed) and remove the element. Notice that the index of the elements may change after the removal.\nFor example, if nums = [6,1,7,4,1]:\n\nChoosing to remove index 1 results in nums = [6,7,4,1].\nChoosing to remove index 2 results in nums = [6,1,4,1].\nChoosing to remove index 4 results in nums = [6,1,7,4].\n\nAn array is fair if the sum of the odd-indexed values equals the sum of the even-indexed values.\nReturn the number of indices that you could choose such that after the removal, nums is fair. \n \nExample 1:\n\nInput: nums = [2,1,6,4]\nOutput: 1\nExplanation:\nRemove index 0: [1,6,4] -> Even sum: 1 + 4 = 5. Odd sum: 6. Not fair.\nRemove index 1: [2,6,4] -> Even sum: 2 + 4 = 6. Odd sum: 6. Fair.\nRemove index 2: [2,1,4] -> Even sum: 2 + 4 = 6. Odd sum: 1. Not fair.\nRemove index 3: [2,1,6] -> Even sum: 2 + 6 = 8. Odd sum: 1. Not fair.\nThere is 1 index that you can remove to make nums fair.\n\nExample 2:\n\nInput: nums = [1,1,1]\nOutput: 3\nExplanation: You can remove any index and the remaining array is fair.\n\nExample 3:\n\nInput: nums = [1,2,3]\nOutput: 0\nExplanation: You cannot make a fair array after removing any index.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [4, 5, 6, 7, 8, 9]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60]) == 0\n assert candidate(nums = [1, 2]) == 0\n assert candidate(nums = [2, 1, 6, 4]) == 1\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000]) == 5\n assert candidate(nums = [1, 2, 3]) == 0\n assert candidate(nums = [1, 1, 1]) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5]) == 7\n assert candidate(nums = [10, 20, 30, 40, 50]) == 0\n assert candidate(nums = [4, 5, 6, 7, 8]) == 0\n assert candidate(nums = [1, 2, 1, 2, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 0\n assert candidate(nums = [9999, 1, 9999, 1, 9999, 1, 9999, 1, 9999, 1]) == 0\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n assert candidate(nums = [23, 17, 14, 6, 9, 4, 3, 10, 13, 2, 11, 1, 5, 15, 7, 12, 8, 16, 19, 18]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 0\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [23, 45, 67, 89, 12, 34, 56, 78, 90, 11, 33, 55, 77, 99, 22, 44, 66, 88, 10]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 0\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 0\n assert candidate(nums = [7, 10, 5, 8, 6, 3, 2, 9, 4, 1]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 0\n assert candidate(nums = [5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 0\n assert candidate(nums = [10000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15, 14, 16, 15, 17]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 0\n assert candidate(nums = [10000]) == 1\n assert candidate(nums = [5, 3, 2, 4, 1, 6, 7, 8, 9, 10, 11, 12]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 0\n assert candidate(nums = [10000, 9999, 10000, 9999, 10000, 9999, 10000, 9999, 10000, 9999]) == 0\n assert candidate(nums = [42]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 0\n assert candidate(nums = [1, 2, 3, 2, 1]) == 3\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 0\n assert candidate(nums = [5, 3, 5, 3, 5, 3]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119]) == 0\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 0\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 999999999, 99999999, 9999999, 999999, 99999, 9999, 999, 99, 9, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [2468, 1357, 2468, 1357, 2468, 1357, 2468, 1357, 2468, 1357, 2468, 1357, 2468, 1357, 2468]) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 0\n assert candidate(nums = [10000, 1, 10000, 1, 10000, 1, 10000, 1, 10000, 1]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 0\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225, 235, 245, 255, 265, 275, 285, 295]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [10000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 13\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250]) == 0\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n assert candidate(nums = [1, 3, 2, 3, 1, 3, 2, 3, 1, 3, 2, 3, 1, 3, 2, 3, 1, 3, 2, 3]) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 0\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(nums = [2, 1, 6, 4, 3, 5, 7, 8]) == 0\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 91\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010]) == 0\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 0\n assert candidate(nums = [10000, 1, 10000, 1, 10000, 1]) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().waysToMakeFair", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int waysToMakeFair(vector& nums) {", "container": "Solution", "callable": "waysToMakeFair", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1665, "task_id": "minimum-initial-energy-to-finish-tasks", "difficulty": "Hard", "problem_description": "You are given an array tasks where tasks[i] = [actuali, minimumi]:\n\nactuali is the actual amount of energy you spend to finish the ith task.\nminimumi is the minimum amount of energy you require to begin the ith task.\n\nFor example, if the task is [10, 12] and your current energy is 11, you cannot start this task. However, if your current energy is 13, you can complete this task, and your energy will be 3 after finishing it.\nYou can finish the tasks in any order you like.\nReturn the minimum initial amount of energy you will need to finish all the tasks.\n \nExample 1:\n\nInput: tasks = [[1,2],[2,4],[4,8]]\nOutput: 8\nExplanation:\nStarting with 8 energy, we finish the tasks in the following order:\n - 3rd task. Now energy = 8 - 4 = 4.\n - 2nd task. Now energy = 4 - 2 = 2.\n - 1st task. Now energy = 2 - 1 = 1.\nNotice that even though we have leftover energy, starting with 7 energy does not work because we cannot do the 3rd task.\nExample 2:\n\nInput: tasks = [[1,3],[2,4],[10,11],[10,12],[8,9]]\nOutput: 32\nExplanation:\nStarting with 32 energy, we finish the tasks in the following order:\n - 1st task. Now energy = 32 - 1 = 31.\n - 2nd task. Now energy = 31 - 2 = 29.\n - 3rd task. Now energy = 29 - 10 = 19.\n - 4th task. Now energy = 19 - 10 = 9.\n - 5th task. Now energy = 9 - 8 = 1.\nExample 3:\n\nInput: tasks = [[1,7],[2,8],[3,9],[4,10],[5,11],[6,12]]\nOutput: 27\nExplanation:\nStarting with 27 energy, we finish the tasks in the following order:\n - 5th task. Now energy = 27 - 5 = 22.\n - 2nd task. Now energy = 22 - 2 = 20.\n - 3rd task. Now energy = 20 - 3 = 17.\n - 1st task. Now energy = 17 - 1 = 16.\n - 4th task. Now energy = 16 - 4 = 12.\n - 6th task. Now energy = 12 - 6 = 6.\n\n \nConstraints:\n\n1 <= tasks.length <= 105\n1 <= actual​i <= minimumi <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(tasks = [[10, 15], [20, 25], [30, 35]]) == 65\n assert candidate(tasks = [[10, 15], [5, 10], [3, 7]]) == 22\n assert candidate(tasks = [[10, 10], [15, 15], [5, 5]]) == 30\n assert candidate(tasks = [[1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 12]]) == 27\n assert candidate(tasks = [[5, 10], [1, 2], [3, 4]]) == 10\n assert candidate(tasks = [[1, 2], [2, 4], [4, 8]]) == 8\n assert candidate(tasks = [[3, 3], [2, 5], [1, 4]]) == 6\n assert candidate(tasks = [[1, 100], [2, 99], [3, 98]]) == 101\n assert candidate(tasks = [[10, 10], [10, 10], [10, 10], [10, 10]]) == 40\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3]]) == 6\n assert candidate(tasks = [[1, 3], [2, 4], [10, 11], [10, 12], [8, 9]]) == 32\n assert candidate(tasks = [[1, 50], [2, 51], [3, 52], [4, 53], [5, 54], [6, 55], [7, 56], [8, 57], [9, 58], [10, 59], [11, 60], [12, 61], [13, 62], [14, 63], [15, 64], [16, 65], [17, 66], [18, 67], [19, 68], [20, 69], [21, 70], [22, 71], [23, 72], [24, 73], [25, 74]]) == 374\n assert candidate(tasks = [[1, 10000], [2, 9999], [3, 9998], [4, 9997], [5, 9996], [6, 9995]]) == 10010\n assert candidate(tasks = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 191\n assert candidate(tasks = [[1, 2], [2, 4], [4, 8], [8, 16], [16, 32]]) == 32\n assert candidate(tasks = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 56\n assert candidate(tasks = [[1, 10000], [10000, 10000], [1, 10000], [10000, 10000], [1, 10000]]) == 20003\n assert candidate(tasks = [[10000, 10000], [1, 2], [10000, 10000], [1, 2], [10000, 10000], [1, 2]]) == 30003\n assert candidate(tasks = [[100, 150], [50, 100], [30, 70], [20, 50], [10, 30], [5, 15]]) == 230\n assert candidate(tasks = [[10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10]]) == 100\n assert candidate(tasks = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25]]) == 45\n assert candidate(tasks = [[100, 120], [200, 220], [300, 320], [400, 420], [500, 520]]) == 1520\n assert candidate(tasks = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]]) == 59\n assert candidate(tasks = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]) == 100\n assert candidate(tasks = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100], [11, 110], [12, 120], [13, 130], [14, 140], [15, 150]]) == 165\n assert candidate(tasks = [[100, 100], [90, 90], [80, 80], [70, 70], [60, 60], [50, 50], [40, 40], [30, 30], [20, 20], [10, 10], [5, 5]]) == 555\n assert candidate(tasks = [[9999, 10000], [9998, 10001], [9997, 10002], [9996, 10003], [9995, 10004], [9994, 10005], [9993, 10006], [9992, 10007], [9991, 10008], [9990, 10009]]) == 99946\n assert candidate(tasks = [[100, 105], [10, 15], [1, 2], [5, 7], [20, 25], [30, 35], [40, 45], [50, 55], [60, 65], [70, 75]]) == 387\n assert candidate(tasks = [[5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19]]) == 79\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 55\n assert candidate(tasks = [[9999, 10000], [9998, 9999], [9997, 9998], [9996, 9997], [9995, 9996]]) == 49986\n assert candidate(tasks = [[100, 101], [99, 100], [98, 99], [97, 98], [96, 97], [95, 96]]) == 586\n assert candidate(tasks = [[1000, 1000], [900, 950], [800, 850], [700, 750], [600, 650]]) == 4000\n assert candidate(tasks = [[100, 200], [100, 300], [100, 400], [100, 500], [100, 600], [100, 700], [100, 800], [100, 900], [100, 1000]]) == 1000\n assert candidate(tasks = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19]]) == 55\n assert candidate(tasks = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]]) == 136\n assert candidate(tasks = [[1000, 1001], [2000, 2002], [3000, 3003], [4000, 4004], [5000, 5005], [6000, 6006], [7000, 7007], [8000, 8008], [9000, 9009], [10000, 10001]]) == 55001\n assert candidate(tasks = [[500, 1000], [400, 900], [300, 800], [200, 700], [100, 600], [50, 500], [25, 400], [12, 300], [7, 200], [5, 100], [3, 50]]) == 2000\n assert candidate(tasks = [[1, 10000], [10000, 10000], [1, 10000], [10000, 10000], [1, 10000], [10000, 10000]]) == 30003\n assert candidate(tasks = [[10000, 10000], [9999, 9999], [9998, 9998], [9997, 9997], [9996, 9996], [9995, 9995], [9994, 9994], [9993, 9993], [9992, 9992], [9991, 9991]]) == 99955\n assert candidate(tasks = [[1000, 1001], [999, 1002], [998, 1003], [997, 1004], [996, 1005], [995, 1006], [994, 1007], [993, 1008], [992, 1009], [991, 1010], [990, 1011], [989, 1012], [988, 1013], [987, 1014], [986, 1015], [985, 1016], [984, 1017], [983, 1018], [982, 1019], [981, 1020]]) == 19811\n assert candidate(tasks = [[1, 2], [100, 101], [1, 2], [100, 101], [1, 2], [100, 101]]) == 304\n assert candidate(tasks = [[500, 500], [500, 500], [500, 500], [500, 500], [500, 500]]) == 2500\n assert candidate(tasks = [[5, 10], [2, 8], [3, 5], [4, 7]]) == 16\n assert candidate(tasks = [[5000, 5000], [4999, 4999], [4998, 4998], [4997, 4997], [4996, 4996], [4995, 4995], [4994, 4994], [4993, 4993], [4992, 4992], [4991, 4991], [4990, 4990], [4989, 4989], [4988, 4988], [4987, 4987], [4986, 4986], [4985, 4985], [4984, 4984], [4983, 4983], [4982, 4982], [4981, 4981], [4980, 4980], [4979, 4979], [4978, 4978], [4977, 4977], [4976, 4976], [4975, 4975], [4974, 4974], [4973, 4973], [4972, 4972], [4971, 4971], [4970, 4970], [4969, 4969], [4968, 4968], [4967, 4967], [4966, 4966], [4965, 4965], [4964, 4964], [4963, 4963], [4962, 4962], [4961, 4961], [4960, 4960]]) == 204180\n assert candidate(tasks = [[5, 10], [4, 9], [3, 8], [2, 7], [1, 6], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15]]) == 60\n assert candidate(tasks = [[10, 11], [20, 21], [30, 31], [40, 41], [50, 51], [60, 61], [70, 71]]) == 281\n assert candidate(tasks = [[10, 15], [20, 25], [30, 35], [40, 45], [50, 55], [60, 65], [70, 75], [80, 85], [90, 95], [100, 105]]) == 555\n assert candidate(tasks = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [110, 110], [120, 120]]) == 780\n assert candidate(tasks = [[1000, 1000], [2000, 2000], [3000, 3000], [4000, 4000]]) == 10000\n assert candidate(tasks = [[1, 10000], [10000, 10000], [1, 10000], [10000, 10000], [1, 10000], [10000, 10000], [1, 10000], [10000, 10000]]) == 40004\n assert candidate(tasks = [[100, 150], [50, 100], [25, 75], [12, 60], [7, 35], [5, 25], [3, 15]]) == 235\n assert candidate(tasks = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 10\n assert candidate(tasks = [[100, 101], [102, 203], [204, 305], [306, 407], [408, 509], [510, 611], [612, 713], [714, 815], [816, 917], [918, 1019]]) == 4691\n assert candidate(tasks = [[9, 10], [8, 9], [7, 8], [6, 7], [5, 6], [4, 5], [3, 4], [2, 3], [1, 2]]) == 46\n assert candidate(tasks = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 56\n assert candidate(tasks = [[9000, 10000], [8000, 9000], [7000, 8000], [6000, 7000], [5000, 6000], [4000, 5000]]) == 40000\n assert candidate(tasks = [[100, 110], [50, 60], [30, 40], [10, 20], [5, 15], [1, 3]]) == 205\n assert candidate(tasks = [[100, 200], [50, 150], [25, 125], [12, 112], [6, 106], [3, 103], [1, 101], [7, 107], [8, 108], [9, 109], [10, 110]]) == 331\n assert candidate(tasks = [[1, 10000], [2, 9999], [3, 9998], [4, 9997], [5, 9996]]) == 10006\n assert candidate(tasks = [[500, 510], [400, 410], [300, 310], [200, 210], [100, 110], [50, 60], [10, 20], [1, 2], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 1658\n assert candidate(tasks = [[100, 200], [150, 250], [50, 100], [300, 400], [200, 300], [1000, 1200], [500, 600]]) == 2350\n assert candidate(tasks = [[1, 10000], [2, 9999], [3, 9998], [4, 9997], [5, 9996], [6, 9995], [7, 9994], [8, 9993], [9, 9992], [10, 9991], [11, 9990], [12, 9989], [13, 9988], [14, 9987], [15, 9986]]) == 10091\n assert candidate(tasks = [[5, 10], [10, 15], [20, 25], [30, 35], [40, 45]]) == 110\n assert candidate(tasks = [[10000, 10000], [9000, 9000], [8000, 8000], [7000, 7000], [6000, 6000], [5000, 5000], [4000, 4000], [3000, 3000], [2000, 2000], [1000, 1000]]) == 55000\n assert candidate(tasks = [[1, 10000], [2, 9999], [3, 9998], [4, 9997], [5, 9996], [6, 9995]]) == 10010\n assert candidate(tasks = [[8, 12], [15, 20], [5, 7], [10, 15], [3, 6]]) == 43\n assert candidate(tasks = [[7, 10], [4, 8], [6, 12], [2, 5], [1, 3]]) == 22\n assert candidate(tasks = [[1, 2], [3, 6], [5, 10], [7, 14], [9, 18], [11, 22], [13, 26], [15, 30], [17, 34], [19, 38], [21, 42], [23, 46], [25, 50], [27, 54], [29, 58], [31, 62], [33, 66], [35, 70], [37, 74], [39, 78]]) == 402\n assert candidate(tasks = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]]) == 75\n assert candidate(tasks = [[1000, 2000], [500, 1500], [250, 750], [125, 375], [63, 188], [31, 95], [16, 48], [8, 25], [4, 13], [2, 7], [1, 4]]) == 2500\n assert candidate(tasks = [[1000, 1010], [999, 1009], [998, 1008], [997, 1007], [996, 1006], [995, 1005], [994, 1004], [993, 1003], [992, 1002], [991, 1001]]) == 9965\n assert candidate(tasks = [[100, 200], [50, 200], [30, 200], [10, 200], [5, 200], [1, 200], [100, 300], [50, 300], [30, 300], [10, 300], [5, 300], [1, 300]]) == 492\n assert candidate(tasks = [[20, 25], [10, 13], [5, 6], [15, 20], [2, 3], [7, 10]]) == 60\n assert candidate(tasks = [[100, 150], [50, 100], [25, 50], [10, 20], [5, 10]]) == 200\n assert candidate(tasks = [[50, 60], [40, 70], [30, 80], [20, 90], [10, 100], [5, 110], [1, 120]]) == 166\n assert candidate(tasks = [[1000, 1010], [900, 910], [800, 810], [700, 710], [600, 610], [500, 510], [400, 410], [300, 310], [200, 210], [100, 110], [50, 60], [10, 20], [1, 2]]) == 5570\n assert candidate(tasks = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95]]) == 110\n assert candidate(tasks = [[500, 1000], [400, 900], [300, 800], [200, 700], [100, 600], [50, 500], [40, 400], [30, 300], [20, 200], [10, 100]]) == 2000\n assert candidate(tasks = [[1000, 2000], [500, 1500], [300, 1200], [200, 1100], [100, 1000]]) == 3000\n assert candidate(tasks = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28], [29, 30]]) == 226\n assert candidate(tasks = [[5, 7], [8, 10], [12, 14], [15, 18], [20, 22]]) == 62\n assert candidate(tasks = [[9, 1], [8, 2], [7, 3], [6, 4], [5, 5], [4, 6], [3, 7], [2, 8], [1, 9]]) == 37\n assert candidate(tasks = [[1, 20], [2, 21], [3, 22], [4, 23], [5, 24], [6, 25]]) == 40\n assert candidate(tasks = [[2, 5], [3, 6], [4, 7], [5, 8], [1, 3]]) == 17\n assert candidate(tasks = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [0, 0]]) == 55\n assert candidate(tasks = [[100, 200], [150, 250], [200, 300], [50, 100], [25, 50], [75, 150], [30, 60], [40, 80], [60, 120], [80, 160]]) == 835\n assert candidate(tasks = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]]) == 460\n assert candidate(tasks = [[10, 20], [10, 30], [10, 40], [10, 50], [10, 60], [10, 70], [10, 80], [10, 90], [10, 100], [10, 110], [10, 120]]) == 120\n assert candidate(tasks = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16]]) == 16\n assert candidate(tasks = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]]) == 121\n assert candidate(tasks = [[5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20]]) == 60\n assert candidate(tasks = [[5, 7], [8, 12], [10, 15], [3, 4], [6, 9], [2, 3]]) == 35\n assert candidate(tasks = [[2, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30]]) == 80\n assert candidate(tasks = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 10\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]]) == 210\n assert candidate(tasks = [[5000, 5005], [4000, 4007], [3000, 3009], [2000, 2011], [1000, 1013], [500, 517], [100, 121], [50, 130], [10, 140], [1, 150]]) == 15666\n assert candidate(tasks = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60]]) == 160\n assert candidate(tasks = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 191\n assert candidate(tasks = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996], [6, 995], [7, 994], [8, 993], [9, 992], [10, 991]]) == 1036\n assert candidate(tasks = [[7, 10], [5, 7], [4, 5], [3, 6], [2, 4]]) == 22\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [100, 100]]) == 115\n assert candidate(tasks = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]]) == 25\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13]]) == 91\n"}, "metadata": {"canonical_parameter_names": ["tasks"], "leetcode_dataset_entry_point": "Solution().minimumEffort", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumEffort(vector>& tasks) {", "container": "Solution", "callable": "minimumEffort", "parameters": [{"name": "tasks", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1668, "task_id": "maximum-repeating-substring", "difficulty": "Easy", "problem_description": "For a string sequence, a string word is k-repeating if word concatenated k times is a substring of sequence. The word's maximum k-repeating value is the highest value k where word is k-repeating in sequence. If word is not a substring of sequence, word's maximum k-repeating value is 0.\nGiven strings sequence and word, return the maximum k-repeating value of word in sequence.\n \nExample 1:\n\nInput: sequence = \"ababc\", word = \"ab\"\nOutput: 2\nExplanation: \"abab\" is a substring in \"ababc\".\n\nExample 2:\n\nInput: sequence = \"ababc\", word = \"ba\"\nOutput: 1\nExplanation: \"ba\" is a substring in \"ababc\". \"baba\" is not a substring in \"ababc\".\n\nExample 3:\n\nInput: sequence = \"ababc\", word = \"ac\"\nOutput: 0\nExplanation: \"ac\" is not a substring in \"ababc\". \n\n \nConstraints:\n\n1 <= sequence.length <= 100\n1 <= word.length <= 100\nsequence and word contains only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(sequence = \"ababc\",word = \"ac\") == 0\n assert candidate(sequence = \"banana\",word = \"ana\") == 1\n assert candidate(sequence = \"abcabcabc\",word = \"abc\") == 3\n assert candidate(sequence = \"aaaa\",word = \"aa\") == 2\n assert candidate(sequence = \"abc\",word = \"d\") == 0\n assert candidate(sequence = \"ababc\",word = \"ab\") == 2\n assert candidate(sequence = \"mississippi\",word = \"issi\") == 1\n assert candidate(sequence = \"aaaabaaa\",word = \"aa\") == 2\n assert candidate(sequence = \"ababc\",word = \"ba\") == 1\n assert candidate(sequence = \"a\",word = \"a\") == 1\n assert candidate(sequence = \"abcabcabc\",word = \"abcd\") == 0\n assert candidate(sequence = \"hellohellohello\",word = \"llohe\") == 2\n assert candidate(sequence = \"abababababab\",word = \"abab\") == 3\n assert candidate(sequence = \"abababababababab\",word = \"ababab\") == 2\n assert candidate(sequence = \"aabbccddeeff\",word = \"aabbcc\") == 1\n assert candidate(sequence = \"ababababab\",word = \"ababab\") == 1\n assert candidate(sequence = \"xyxxyxyxyxyxyxyxyxyxyx\",word = \"xyxxy\") == 1\n assert candidate(sequence = \"abcabcabcabc\",word = \"abcd\") == 0\n assert candidate(sequence = \"ababababab\",word = \"ab\") == 5\n assert candidate(sequence = \"abcdabcdabcdabcdabcdabcdabcdabcd\",word = \"abcd\") == 8\n assert candidate(sequence = \"abacabadabacaba\",word = \"dab\") == 1\n assert candidate(sequence = \"abcabcabcabcabcabc\",word = \"abcabcabc\") == 2\n assert candidate(sequence = \"abababababababababab\",word = \"ababab\") == 3\n assert candidate(sequence = \"banana\",word = \"ban\") == 1\n assert candidate(sequence = \"abcabcabcabcabc\",word = \"cab\") == 4\n assert candidate(sequence = \"abacabadabacaba\",word = \"cab\") == 1\n assert candidate(sequence = \"hellohellohellohello\",word = \"hello\") == 4\n assert candidate(sequence = \"banana\",word = \"na\") == 2\n assert candidate(sequence = \"abababababab\",word = \"baba\") == 2\n assert candidate(sequence = \"ababababababababab\",word = \"ababab\") == 3\n assert candidate(sequence = \"abcabcabcabcabc\",word = \"abcd\") == 0\n assert candidate(sequence = \"xyzyzyzyzyzyzyzy\",word = \"zyzyzyzyzyzyzyzy\") == 0\n assert candidate(sequence = \"zzzxxzzzxxzzzxx\",word = \"zzzxx\") == 3\n assert candidate(sequence = \"aabbccddeeffgghhiijj\",word = \"ccdd\") == 1\n assert candidate(sequence = \"xyzxyzxyzxyzxyz\",word = \"zyx\") == 0\n assert candidate(sequence = \"abcabcabcabc\",word = \"cab\") == 3\n assert candidate(sequence = \"ababababababababab\",word = \"bab\") == 1\n assert candidate(sequence = \"bananaananabana\",word = \"ana\") == 2\n assert candidate(sequence = \"aaaaabaaa\",word = \"aaaa\") == 1\n assert candidate(sequence = \"abacabadabacaba\",word = \"bac\") == 1\n assert candidate(sequence = \"aaaaabbbbbcccc\",word = \"abc\") == 0\n assert candidate(sequence = \"aaaaaaa\",word = \"aaa\") == 2\n assert candidate(sequence = \"zzzzzzzzzzzz\",word = \"zzzz\") == 3\n assert candidate(sequence = \"ababababa\",word = \"aba\") == 1\n assert candidate(sequence = \"abababcabababc\",word = \"ababc\") == 1\n assert candidate(sequence = \"ababababababababababababababab\",word = \"abab\") == 7\n assert candidate(sequence = \"aaaabaaaabaaaab\",word = \"aaab\") == 1\n assert candidate(sequence = \"abababababababab\",word = \"baba\") == 3\n assert candidate(sequence = \"xyzyzyzyzyzyzyzy\",word = \"zyzy\") == 3\n assert candidate(sequence = \"abcabcabcabc\",word = \"abcabc\") == 2\n assert candidate(sequence = \"aaaabaaaabaaaabaaaab\",word = \"aaaab\") == 4\n assert candidate(sequence = \"abcabcabc\",word = \"cab\") == 2\n assert candidate(sequence = \"abababababababababab\",word = \"abab\") == 5\n assert candidate(sequence = \"abacabadabacaba\",word = \"abaca\") == 1\n assert candidate(sequence = \"aaaaaaa\",word = \"a\") == 7\n assert candidate(sequence = \"aabbccddeeff\",word = \"abc\") == 0\n assert candidate(sequence = \"abcabcabcabcabcabcabc\",word = \"abca\") == 1\n assert candidate(sequence = \"abcabcabcabcabc\",word = \"abcabcab\") == 1\n assert candidate(sequence = \"abcdefabcdefabcdef\",word = \"defabc\") == 2\n assert candidate(sequence = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word = \"aabbccddeeffgghhiijjkkll\") == 1\n assert candidate(sequence = \"abcdefabcdefabcdef\",word = \"abcdef\") == 3\n assert candidate(sequence = \"zzzzzzzzzzzzzzzzzzzz\",word = \"zzzzzz\") == 3\n assert candidate(sequence = \"xyzxyzxyzxyzxyzxyz\",word = \"xyzxyzxyz\") == 2\n assert candidate(sequence = \"abababab\",word = \"ab\") == 4\n assert candidate(sequence = \"abacabacabacabacabac\",word = \"abac\") == 5\n assert candidate(sequence = \"aaaaab\",word = \"aaa\") == 1\n assert candidate(sequence = \"aaaaaaa\",word = \"aaaa\") == 1\n assert candidate(sequence = \"ababababababababababab\",word = \"babab\") == 1\n assert candidate(sequence = \"abababab\",word = \"aba\") == 1\n assert candidate(sequence = \"aaaaaabaaa\",word = \"aaa\") == 2\n assert candidate(sequence = \"aaaaabaaaa\",word = \"aaa\") == 1\n assert candidate(sequence = \"ababababab\",word = \"aba\") == 1\n assert candidate(sequence = \"hellohellohellohellohello\",word = \"hellohello\") == 2\n assert candidate(sequence = \"abcabcabcabcabcabcabcabcabcabc\",word = \"abcabcabc\") == 3\n assert candidate(sequence = \"aabbccddeeefffggghhh\",word = \"eefffggg\") == 1\n assert candidate(sequence = \"mississippi\",word = \"iss\") == 2\n assert candidate(sequence = \"abacabacabac\",word = \"abac\") == 3\n assert candidate(sequence = \"xyxyxyxyxyxyxyxy\",word = \"xyxyxyxyxyxyxy\") == 1\n assert candidate(sequence = \"abcabcabcabcabcabcabcabc\",word = \"abcabcabc\") == 2\n assert candidate(sequence = \"aabbccddeeffgghhiijj\",word = \"aabbcc\") == 1\n assert candidate(sequence = \"xyxyxyxyxyxyxyxyxyxy\",word = \"xyxy\") == 5\n assert candidate(sequence = \"xyxyxyxyxyxyxy\",word = \"xyxy\") == 3\n assert candidate(sequence = \"zzzzzzzzzzzzzzzzzzzz\",word = \"zzzz\") == 5\n assert candidate(sequence = \"mississippi\",word = \"miss\") == 1\n assert candidate(sequence = \"ababababababababab\",word = \"ab\") == 9\n assert candidate(sequence = \"hellohellohellohello\",word = \"hellohello\") == 2\n assert candidate(sequence = \"banana\",word = \"nan\") == 1\n assert candidate(sequence = \"abababaaba\",word = \"aba\") == 2\n assert candidate(sequence = \"hellohellohello\",word = \"lohel\") == 2\n assert candidate(sequence = \"qqqqqqqqqqqq\",word = \"qqqq\") == 3\n assert candidate(sequence = \"xyxxyxyxyxyxyx\",word = \"xyxyx\") == 1\n assert candidate(sequence = \"abcdabcdabcdabcd\",word = \"abcdabcd\") == 2\n assert candidate(sequence = \"sequencewordsequenceword\",word = \"word\") == 1\n assert candidate(sequence = \"abababa\",word = \"aba\") == 1\n assert candidate(sequence = \"xyxyxyxyxyxyxyxy\",word = \"xyxy\") == 4\n assert candidate(sequence = \"abcdefgabcdefgabcdefg\",word = \"abcdefg\") == 3\n assert candidate(sequence = \"abababababababababababab\",word = \"abababab\") == 3\n assert candidate(sequence = \"aaaabaaaabaaaabaaaab\",word = \"aaab\") == 1\n assert candidate(sequence = \"ababababababababab\",word = \"abab\") == 4\n assert candidate(sequence = \"abcdefghijabcdefghij\",word = \"cde\") == 1\n assert candidate(sequence = \"mamamamamamama\",word = \"mama\") == 3\n assert candidate(sequence = \"ababababababab\",word = \"abab\") == 3\n assert candidate(sequence = \"hellohellohello\",word = \"hello\") == 3\n assert candidate(sequence = \"abcabcabcabcabc\",word = \"abcabcabcabc\") == 1\n assert candidate(sequence = \"xyzxyzxyzxyz\",word = \"xyz\") == 4\n assert candidate(sequence = \"abcabcabcabcabcabc\",word = \"bcabc\") == 1\n assert candidate(sequence = \"abababababababab\",word = \"abab\") == 4\n assert candidate(sequence = \"abcdabcdabcdabcdabcdabcdabcdabcd\",word = \"dabc\") == 7\n assert candidate(sequence = \"mississippiissippi\",word = \"issi\") == 1\n assert candidate(sequence = \"xyzxyzxyz\",word = \"xy\") == 1\n assert candidate(sequence = \"abcabcabcabcabcabcabc\",word = \"abcabcabcabcabc\") == 1\n assert candidate(sequence = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word = \"zzzz\") == 7\n assert candidate(sequence = \"abcabcabcabcabcabc\",word = \"abcabc\") == 3\n assert candidate(sequence = \"abcdabcdabcdabcdabcdabcdabcdabcd\",word = \"dcba\") == 0\n assert candidate(sequence = \"qwertyqwertyqwerty\",word = \"qwerty\") == 3\n assert candidate(sequence = \"acacacacacac\",word = \"acac\") == 3\n assert candidate(sequence = \"ababababa\",word = \"bab\") == 1\n assert candidate(sequence = \"ababcabcababc\",word = \"abcab\") == 1\n assert candidate(sequence = \"aaaaaaaaaa\",word = \"aaa\") == 3\n assert candidate(sequence = \"aaaaaaaaaa\",word = \"aaaa\") == 2\n assert candidate(sequence = \"mississippi\",word = \"sip\") == 1\n assert candidate(sequence = \"aaaaaaa\",word = \"aa\") == 3\n assert candidate(sequence = \"aaaaaabaaaaa\",word = \"aaaaa\") == 1\n assert candidate(sequence = \"xyzxyzxyzxyz\",word = \"xyzxyz\") == 2\n assert candidate(sequence = \"ababababc\",word = \"aba\") == 1\n assert candidate(sequence = \"abcabcabcabcabcabc\",word = \"cab\") == 5\n assert candidate(sequence = \"abacabacabacabac\",word = \"abacabac\") == 2\n assert candidate(sequence = \"abcabcabcabcabc\",word = \"abcabcabc\") == 1\n assert candidate(sequence = \"abcabcabcabcabc\",word = \"abcabc\") == 2\n assert candidate(sequence = \"xyzxyzyzyzxzyzyzxzyzyz\",word = \"zyz\") == 1\n assert candidate(sequence = \"xyzxyzxyzxyz\",word = \"zyxzyx\") == 0\n assert candidate(sequence = \"xyzxyzxyzxyz\",word = \"xyzxyzxyz\") == 1\n assert candidate(sequence = \"aaaaaa\",word = \"aa\") == 3\n assert candidate(sequence = \"abcdabcdabcdabcdabcdabcdabcdabcd\",word = \"abcdabcdabcdabcd\") == 2\n assert candidate(sequence = \"abcdabcdabcdabcd\",word = \"cdab\") == 3\n assert candidate(sequence = \"zzzzzzzz\",word = \"zzzz\") == 2\n assert candidate(sequence = \"abcdefgabcdefgabcdefg\",word = \"efg\") == 1\n assert candidate(sequence = \"zzzzzzzzzzzzzzzzzzzz\",word = \"zzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(sequence = \"abcdefgabcdefg\",word = \"abcdefg\") == 2\n assert candidate(sequence = \"bananaananabananananabanananananana\",word = \"anana\") == 2\n assert candidate(sequence = \"qwertyqwertyqwerty\",word = \"erty\") == 1\n assert candidate(sequence = \"pqrspqrspqrspqrspqr\",word = \"pqrs\") == 4\n assert candidate(sequence = \"ababababababa\",word = \"bab\") == 1\n assert candidate(sequence = \"abcbabcabcbabcabc\",word = \"abcabc\") == 1\n assert candidate(sequence = \"qwertyqwertyqwerty\",word = \"qwertyqwerty\") == 1\n assert candidate(sequence = \"zzzzzzzzzzzz\",word = \"zzz\") == 4\n assert candidate(sequence = \"zzzzzzzzzzzzzzz\",word = \"zzzz\") == 3\n assert candidate(sequence = \"xyzxyzxyz\",word = \"xyz\") == 3\n assert candidate(sequence = \"aabbccddeeff\",word = \"eeff\") == 1\n assert candidate(sequence = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word = \"mmnnooppqqrrssttuuvvwwxxyyzz\") == 1\n assert candidate(sequence = \"ababababab\",word = \"abab\") == 2\n assert candidate(sequence = \"xyxyxyxyxyxyxyxy\",word = \"xyxyxyxyxyxyxyxy\") == 1\n assert candidate(sequence = \"abcdabcdabcdabcdabcdabcd\",word = \"abcdabcd\") == 3\n assert candidate(sequence = \"qwertyqwertyqwertyqwerty\",word = \"qwertyqwerty\") == 2\n"}, "metadata": {"canonical_parameter_names": ["sequence", "word"], "leetcode_dataset_entry_point": "Solution().maxRepeating", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxRepeating(string sequence, string word) {", "container": "Solution", "callable": "maxRepeating", "parameters": [{"name": "sequence", "type": "string"}, {"name": "word", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1669, "task_id": "merge-in-between-linked-lists", "difficulty": "Medium", "problem_description": "You are given two linked lists: list1 and list2 of sizes n and m respectively.\nRemove list1's nodes from the ath node to the bth node, and put list2 in their place.\nThe blue edges and nodes in the following figure indicate the result:\n\nBuild the result list and return its head.\n \nExample 1:\n\n\nInput: list1 = [10,1,13,6,9,5], a = 3, b = 4, list2 = [1000000,1000001,1000002]\nOutput: [10,1,13,1000000,1000001,1000002,5]\nExplanation: We remove the nodes 3 and 4 and put the entire list2 in their place. The blue edges and nodes in the above figure indicate the result.\n\nExample 2:\n\n\nInput: list1 = [0,1,2,3,4,5,6], a = 2, b = 5, list2 = [1000000,1000001,1000002,1000003,1000004]\nOutput: [0,1,1000000,1000001,1000002,1000003,1000004,6]\nExplanation: The blue edges and nodes in the above figure indicate the result.\n\n \nConstraints:\n\n3 <= list1.length <= 104\n1 <= a <= b < list1.length - 1\n1 <= list2.length <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5]),a = 1,b = 2,list2 = list_node([10, 20])), list_node([1, 10, 20, 4, 5]))\n assert is_same_list(candidate(list1 = list_node([1, 3, 5, 7, 9, 11, 13]),a = 2,b = 4,list2 = list_node([20, 30])), list_node([1, 3, 20, 30, 11, 13]))\n assert is_same_list(candidate(list1 = list_node([100, 200, 300, 400, 500, 600, 700, 800]),a = 3,b = 5,list2 = list_node([10, 20, 30, 40])), list_node([100, 200, 300, 10, 20, 30, 40, 700, 800]))\n assert is_same_list(candidate(list1 = list_node([6, 7, 8, 9, 10, 11, 12]),a = 2,b = 4,list2 = list_node([13, 14, 15, 16])), list_node([6, 7, 13, 14, 15, 16, 11, 12]))\n assert is_same_list(candidate(list1 = list_node([0, 1, 2, 3, 4, 5, 6]),a = 2,b = 5,list2 = list_node([1000000, 1000001, 1000002, 1000003, 1000004])), list_node([0, 1, 1000000, 1000001, 1000002, 1000003, 1000004, 6]))\n assert is_same_list(candidate(list1 = list_node([5, 7, 9, 11, 13, 15, 17]),a = 3,b = 4,list2 = list_node([8, 10, 12])), list_node([5, 7, 9, 8, 10, 12, 15, 17]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5]),a = 1,b = 2,list2 = list_node([10, 20, 30])), list_node([1, 10, 20, 30, 4, 5]))\n assert is_same_list(candidate(list1 = list_node([1, 3, 5, 7, 9, 11]),a = 2,b = 3,list2 = list_node([2, 4, 6, 8])), list_node([1, 3, 2, 4, 6, 8, 9, 11]))\n assert is_same_list(candidate(list1 = list_node([10, 1, 13, 6, 9, 5]),a = 3,b = 4,list2 = list_node([1000000, 1000001, 1000002])), list_node([10, 1, 13, 1000000, 1000001, 1000002, 5]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5]),a = 1,b = 2,list2 = list_node([9, 8])), list_node([1, 9, 8, 4, 5]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9]),a = 2,b = 6,list2 = list_node([100, 200, 300])), list_node([1, 2, 100, 200, 300, 8, 9]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70]),a = 2,b = 4,list2 = list_node([100, 200, 300])), list_node([10, 20, 100, 200, 300, 60, 70]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),a = 4,b = 10,list2 = list_node([999, 888, 777])), list_node([1, 2, 3, 4, 999, 888, 777, 12, 13, 14, 15]))\n assert is_same_list(candidate(list1 = list_node([1000, 2000, 3000, 4000, 5000, 6000, 7000]),a = 1,b = 5,list2 = list_node([100, 200, 300, 400, 500, 600, 700])), list_node([1000, 100, 200, 300, 400, 500, 600, 700, 7000]))\n assert is_same_list(candidate(list1 = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1]),a = 2,b = 6,list2 = list_node([20, 21, 22, 23, 24, 25])), list_node([9, 8, 20, 21, 22, 23, 24, 25, 2, 1]))\n assert is_same_list(candidate(list1 = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000]),a = 15,b = 28,list2 = list_node([3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900])), list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 3100, 3200, 3300, 3400, 3500, 3600, 3700, 3800, 3900, 3000]))\n assert is_same_list(candidate(list1 = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]),a = 3,b = 12,list2 = list_node([999, 888, 777, 666, 555, 444])), list_node([2, 4, 6, 999, 888, 777, 666, 555, 444, 28, 30]))\n assert is_same_list(candidate(list1 = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]),a = 6,b = 14,list2 = list_node([1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000])), list_node([5, 10, 15, 20, 25, 30, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 80, 85, 90, 95, 100]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]),a = 2,b = 11,list2 = list_node([160, 170, 180, 190, 200, 210, 220, 230])), list_node([10, 20, 160, 170, 180, 190, 200, 210, 220, 230, 130, 140, 150]))\n assert is_same_list(candidate(list1 = list_node([15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115]),a = 3,b = 9,list2 = list_node([200, 300, 400, 500, 600, 700])), list_node([15, 25, 35, 200, 300, 400, 500, 600, 700, 115]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),a = 2,b = 7,list2 = list_node([100, 200, 300, 400, 500])), list_node([1, 2, 100, 200, 300, 400, 500, 9, 10]))\n assert is_same_list(candidate(list1 = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19]),a = 2,b = 7,list2 = list_node([200, 201, 202, 203, 204])), list_node([1, 3, 200, 201, 202, 203, 204, 17, 19]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),a = 8,b = 16,list2 = list_node([9999, 9998, 9997, 9996, 9995, 9994])), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9999, 9998, 9997, 9996, 9995, 9994, 18, 19, 20]))\n assert is_same_list(candidate(list1 = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]),a = 5,b = 12,list2 = list_node([31, 33, 35, 37, 39, 41, 43, 45])), list_node([2, 4, 6, 8, 10, 31, 33, 35, 37, 39, 41, 43, 45, 28, 30]))\n assert is_same_list(candidate(list1 = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]),a = 7,b = 15,list2 = list_node([105, 110, 115, 120, 125, 130, 135, 140])), list_node([5, 10, 15, 20, 25, 30, 35, 105, 110, 115, 120, 125, 130, 135, 140, 85, 90, 95, 100]))\n assert is_same_list(candidate(list1 = list_node([250, 500, 750, 1000, 1250, 1500, 1750, 2000, 2250, 2500, 2750, 3000, 3250, 3500, 3750, 4000, 4250, 4500, 4750, 5000]),a = 7,b = 13,list2 = list_node([5100, 5200, 5300, 5400, 5500, 5600, 5700, 5800, 5900])), list_node([250, 500, 750, 1000, 1250, 1500, 1750, 5100, 5200, 5300, 5400, 5500, 5600, 5700, 5800, 5900, 3750, 4000, 4250, 4500, 4750, 5000]))\n assert is_same_list(candidate(list1 = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]),a = 2,b = 8,list2 = list_node([50, 60, 70, 80, 90, 100, 110, 120, 130])), list_node([100, 200, 50, 60, 70, 80, 90, 100, 110, 120, 130, 1000]))\n assert is_same_list(candidate(list1 = list_node([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),a = 5,b = 12,list2 = list_node([20, 21, 22, 23, 24, 25])), list_node([0, 1, 2, 3, 4, 20, 21, 22, 23, 24, 25, 13, 14, 15, 16, 17, 18, 19]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90]),a = 1,b = 6,list2 = list_node([100, 200, 300, 400, 500])), list_node([10, 100, 200, 300, 400, 500, 80, 90]))\n assert is_same_list(candidate(list1 = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]),a = 7,b = 11,list2 = list_node([750, 850, 950, 1050, 1150, 1250])), list_node([100, 200, 300, 400, 500, 600, 700, 750, 850, 950, 1050, 1150, 1250, 1300, 1400, 1500]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),a = 6,b = 14,list2 = list_node([100, 200, 300, 400, 500, 600, 700, 800])), list_node([1, 2, 3, 4, 5, 6, 100, 200, 300, 400, 500, 600, 700, 800, 16, 17, 18, 19, 20]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),a = 3,b = 7,list2 = list_node([11, 12, 13, 14, 15])), list_node([1, 2, 3, 11, 12, 13, 14, 15, 9, 10]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]),a = 2,b = 18,list2 = list_node([500, 600, 700, 800, 900])), list_node([10, 20, 500, 600, 700, 800, 900, 200]))\n assert is_same_list(candidate(list1 = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60]),a = 10,b = 25,list2 = list_node([62, 64, 66, 68, 70, 72, 74, 76, 78, 80])), list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 54, 56, 58, 60]))\n assert is_same_list(candidate(list1 = list_node([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]),a = 3,b = 9,list2 = list_node([13, 14, 15, 16, 17, 18, 19, 20])), list_node([0, 1, 2, 13, 14, 15, 16, 17, 18, 19, 20, 10, 11, 12]))\n assert is_same_list(candidate(list1 = list_node([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]),a = 8,b = 20,list2 = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000])), list_node([0, 1, 2, 3, 4, 5, 6, 7, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 21, 22, 23, 24, 25, 26, 27, 28, 29]))\n assert is_same_list(candidate(list1 = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),a = 15,b = 30,list2 = list_node([2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(list1 = list_node([3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]),a = 8,b = 15,list2 = list_node([99, 199, 299, 399, 499, 599, 699, 799, 899, 999])), list_node([3, 6, 9, 12, 15, 18, 21, 24, 99, 199, 299, 399, 499, 599, 699, 799, 899, 999, 51, 54, 57, 60]))\n assert is_same_list(candidate(list1 = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45]),a = 6,b = 18,list2 = list_node([101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125])), list_node([1, 3, 5, 7, 9, 11, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 39, 41, 43, 45]))\n assert is_same_list(candidate(list1 = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]),a = 5,b = 15,list2 = list_node([550, 650, 750, 850, 950, 1050, 1150, 1250, 1350, 1450, 1550, 1650])), list_node([100, 200, 300, 400, 500, 550, 650, 750, 850, 950, 1050, 1150, 1250, 1350, 1450, 1550, 1650, 1700, 1800, 1900, 2000]))\n assert is_same_list(candidate(list1 = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]),a = 5,b = 12,list2 = list_node([10000, 20000, 30000])), list_node([100, 200, 300, 400, 500, 10000, 20000, 30000, 1400, 1500]))\n assert is_same_list(candidate(list1 = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]),a = 6,b = 12,list2 = list_node([100, 200, 300, 400, 500])), list_node([1, 3, 5, 7, 9, 11, 100, 200, 300, 400, 500, 27, 29, 31]))\n assert is_same_list(candidate(list1 = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]),a = 4,b = 19,list2 = list_node([20000, 20001, 20002, 20003, 20004, 20005, 20006, 20007, 20008, 20009, 20010, 20011, 20012, 20013, 20014])), list_node([2, 4, 6, 8, 20000, 20001, 20002, 20003, 20004, 20005, 20006, 20007, 20008, 20009, 20010, 20011, 20012, 20013, 20014]))\n assert is_same_list(candidate(list1 = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),a = 2,b = 18,list2 = list_node([2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2])), list_node([1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]),a = 3,b = 8,list2 = list_node([13, 14, 15, 16, 17, 18, 19])), list_node([1, 2, 3, 13, 14, 15, 16, 17, 18, 19, 10, 11, 12]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100]),a = 1,b = 9,list2 = list_node([500, 600, 700])), list_node([10, 500, 600, 700]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100]),a = 1,b = 8,list2 = list_node([1000, 2000, 3000])), list_node([10, 1000, 2000, 3000, 100]))\n assert is_same_list(candidate(list1 = list_node([0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]),a = 4,b = 8,list2 = list_node([100, 101, 102, 103, 104, 105, 106, 107])), list_node([0, 2, 4, 6, 100, 101, 102, 103, 104, 105, 106, 107, 18, 20]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]),a = 5,b = 10,list2 = list_node([151, 152, 153, 154, 155, 156])), list_node([10, 20, 30, 40, 50, 151, 152, 153, 154, 155, 156, 120, 130, 140, 150]))\n assert is_same_list(candidate(list1 = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),a = 10,b = 19,list2 = list_node([2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(list1 = list_node([11, 22, 33, 44, 55, 66, 77, 88, 99, 111, 222, 333, 444, 555, 666, 777, 888, 999, 1111, 2222, 3333, 4444, 5555]),a = 3,b = 18,list2 = list_node([6666, 7777, 8888, 9999, 10000, 11000])), list_node([11, 22, 33, 6666, 7777, 8888, 9999, 10000, 11000, 2222, 3333, 4444, 5555]))\n assert is_same_list(candidate(list1 = list_node([0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]),a = 3,b = 7,list2 = list_node([3, 5, 7, 9, 11])), list_node([0, 2, 4, 3, 5, 7, 9, 11, 16, 18, 20]))\n assert is_same_list(candidate(list1 = list_node([101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515]),a = 6,b = 12,list2 = list_node([9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111])), list_node([101, 202, 303, 404, 505, 606, 9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111, 1414, 1515]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]),a = 5,b = 14,list2 = list_node([500, 600, 700, 800, 900, 1000, 1100, 1200, 1300])), list_node([10, 20, 30, 40, 50, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 160, 170, 180, 190, 200]))\n assert is_same_list(candidate(list1 = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]),a = 4,b = 8,list2 = list_node([22, 24, 26, 28, 30, 32, 34])), list_node([1, 3, 5, 7, 22, 24, 26, 28, 30, 32, 34, 19, 21]))\n assert is_same_list(candidate(list1 = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]),a = 5,b = 12,list2 = list_node([1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007])), list_node([1, 3, 5, 7, 9, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 27, 29]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]),a = 15,b = 24,list2 = list_node([31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43])), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 26, 27, 28, 29, 30]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]),a = 8,b = 20,list2 = list_node([31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44])), list_node([1, 2, 3, 4, 5, 6, 7, 8, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 22, 23, 24, 25, 26, 27, 28, 29, 30]))\n assert is_same_list(candidate(list1 = list_node([5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),a = 2,b = 13,list2 = list_node([21, 22, 23, 24, 25, 26, 27])), list_node([5, 6, 21, 22, 23, 24, 25, 26, 27, 19, 20]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),a = 7,b = 13,list2 = list_node([10000, 20000, 30000, 40000, 50000, 60000, 70000])), list_node([1, 2, 3, 4, 5, 6, 7, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 15, 16, 17, 18, 19, 20]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),a = 2,b = 7,list2 = list_node([11, 12, 13, 14, 15, 16])), list_node([1, 2, 11, 12, 13, 14, 15, 16, 9, 10]))\n assert is_same_list(candidate(list1 = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]),a = 3,b = 17,list2 = list_node([10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009])), list_node([1, 3, 5, 10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009, 37, 39]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]),a = 3,b = 17,list2 = list_node([2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015])), list_node([10, 20, 30, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 190, 200]))\n assert is_same_list(candidate(list1 = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]),a = 8,b = 20,list2 = list_node([51, 53, 55, 57, 59, 61, 63, 65])), list_node([1, 3, 5, 7, 9, 11, 13, 15, 51, 53, 55, 57, 59, 61, 63, 65, 43, 45, 47, 49]))\n assert is_same_list(candidate(list1 = list_node([11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132]),a = 5,b = 10,list2 = list_node([2000, 3000, 4000, 5000, 6000, 7000, 8000])), list_node([11, 22, 33, 44, 55, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 132]))\n assert is_same_list(candidate(list1 = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65]),a = 5,b = 9,list2 = list_node([1000, 2000, 3000, 4000])), list_node([5, 10, 15, 20, 25, 1000, 2000, 3000, 4000, 55, 60, 65]))\n assert is_same_list(candidate(list1 = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),a = 4,b = 15,list2 = list_node([2, 2, 2, 2, 2, 2, 2, 2, 2])), list_node([1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1]))\n assert is_same_list(candidate(list1 = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300]),a = 5,b = 9,list2 = list_node([1400, 1500, 1600])), list_node([100, 200, 300, 400, 500, 1400, 1500, 1600, 1100, 1200, 1300]))\n assert is_same_list(candidate(list1 = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]),a = 4,b = 8,list2 = list_node([100, 200, 300, 400, 500, 600, 700])), list_node([5, 10, 15, 20, 100, 200, 300, 400, 500, 600, 700, 50, 55]))\n assert is_same_list(candidate(list1 = list_node([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),a = 2,b = 7,list2 = list_node([100, 200, 300, 400, 500, 600])), list_node([0, 1, 100, 200, 300, 400, 500, 600, 8, 9, 10]))\n assert is_same_list(candidate(list1 = list_node([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),a = 5,b = 10,list2 = list_node([100, 200, 300, 400, 500, 600])), list_node([0, 1, 2, 3, 4, 100, 200, 300, 400, 500, 600, 11, 12, 13, 14, 15, 16, 17, 18, 19]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]),a = 6,b = 13,list2 = list_node([65, 75, 85, 95, 105, 115, 125, 135, 145, 155])), list_node([10, 20, 30, 40, 50, 60, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 150, 160, 170, 180, 190, 200]))\n assert is_same_list(candidate(list1 = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50]),a = 1,b = 6,list2 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])), list_node([5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 40, 45, 50]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]),a = 5,b = 8,list2 = list_node([55, 65, 75, 85, 95])), list_node([10, 20, 30, 40, 50, 55, 65, 75, 85, 95, 100, 110, 120]))\n assert is_same_list(candidate(list1 = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50]),a = 7,b = 18,list2 = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21])), list_node([2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 40, 42, 44, 46, 48, 50]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]),a = 10,b = 20,list2 = list_node([500, 501, 502, 503, 504, 505, 506, 507, 508, 509])), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 22, 23, 24, 25, 26, 27, 28, 29, 30]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]),a = 4,b = 8,list2 = list_node([111, 121, 131, 141])), list_node([10, 20, 30, 40, 111, 121, 131, 141, 100, 110]))\n assert is_same_list(candidate(list1 = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]),a = 4,b = 9,list2 = list_node([100, 200, 300, 400, 500, 600])), list_node([1, 3, 5, 7, 100, 200, 300, 400, 500, 600, 21, 23, 25]))\n assert is_same_list(candidate(list1 = list_node([99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]),a = 5,b = 15,list2 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])), list_node([99, 98, 97, 96, 95, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 83, 82, 81, 80]))\n assert is_same_list(candidate(list1 = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1]),a = 2,b = 6,list2 = list_node([0, 0, 0, 0, 0, 0])), list_node([9, 8, 0, 0, 0, 0, 0, 0, 2, 1]))\n assert is_same_list(candidate(list1 = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]),a = 3,b = 7,list2 = list_node([1010, 1020, 1030, 1040, 1050])), list_node([100, 200, 300, 1010, 1020, 1030, 1040, 1050, 900, 1000]))\n assert is_same_list(candidate(list1 = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100]),a = 3,b = 6,list2 = list_node([1000, 2000, 3000, 4000, 5000])), list_node([10, 20, 30, 1000, 2000, 3000, 4000, 5000, 80, 90, 100]))\n assert is_same_list(candidate(list1 = list_node([101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120]),a = 5,b = 15,list2 = list_node([121, 122, 123, 124, 125, 126, 127, 128, 129, 130])), list_node([101, 102, 103, 104, 105, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 117, 118, 119, 120]))\n assert is_same_list(candidate(list1 = list_node([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),a = 5,b = 12,list2 = list_node([1000, 1001, 1002, 1003, 1004])), list_node([0, 1, 2, 3, 4, 1000, 1001, 1002, 1003, 1004, 13, 14, 15, 16, 17, 18, 19]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),a = 3,b = 11,list2 = list_node([20, 21, 22, 23, 24, 25, 26])), list_node([1, 2, 3, 20, 21, 22, 23, 24, 25, 26, 13, 14, 15]))\n assert is_same_list(candidate(list1 = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]),a = 10,b = 15,list2 = list_node([101, 102, 103, 104, 105, 106, 107, 108, 109, 110])), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 17, 18, 19, 20, 21, 22, 23, 24, 25]))\n assert is_same_list(candidate(list1 = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]),a = 9,b = 14,list2 = list_node([21, 23, 25, 27, 29, 31, 33])), list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 21, 23, 25, 27, 29, 31, 33, 32, 34, 36, 38, 40]))\n assert is_same_list(candidate(list1 = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]),a = 3,b = 17,list2 = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500])), list_node([9, 8, 7, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, -9, -10]))\n assert is_same_list(candidate(list1 = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65]),a = 4,b = 9,list2 = list_node([1000, 1001, 1002, 1003, 1004, 1005])), list_node([5, 10, 15, 20, 1000, 1001, 1002, 1003, 1004, 1005, 55, 60, 65]))\n assert is_same_list(candidate(list1 = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),a = 3,b = 10,list2 = list_node([2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2])), list_node([1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1]))\n assert is_same_list(candidate(list1 = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]),a = 4,b = 16,list2 = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20])), list_node([1, 3, 5, 7, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 35, 37, 39]))\n assert is_same_list(candidate(list1 = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]),a = 7,b = 20,list2 = list_node([1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015])), list_node([1, 3, 5, 7, 9, 11, 13, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 43, 45, 47, 49]))\n assert is_same_list(candidate(list1 = list_node([1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000]),a = 4,b = 10,list2 = list_node([16000, 17000, 18000, 19000])), list_node([1000, 2000, 3000, 4000, 16000, 17000, 18000, 19000, 12000, 13000, 14000, 15000]))\n assert is_same_list(candidate(list1 = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]),a = 6,b = 15,list2 = list_node([1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009])), list_node([5, 10, 15, 20, 25, 30, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 85, 90, 95, 100]))\n assert is_same_list(candidate(list1 = list_node([100, 200, 300, 400, 500, 600, 700, 800, 900]),a = 2,b = 7,list2 = list_node([1000, 1001, 1002, 1003, 1004])), list_node([100, 200, 1000, 1001, 1002, 1003, 1004, 900]))\n assert is_same_list(candidate(list1 = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]),a = 2,b = 9,list2 = list_node([65, 70, 75, 80, 85, 90, 95, 100])), list_node([5, 10, 65, 70, 75, 80, 85, 90, 95, 100, 55, 60]))\n assert is_same_list(candidate(list1 = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26]),a = 4,b = 10,list2 = list_node([50, 100, 150, 200, 250])), list_node([2, 4, 6, 8, 50, 100, 150, 200, 250, 24, 26]))\n"}, "metadata": {"canonical_parameter_names": ["list1", "a", "b", "list2"], "leetcode_dataset_entry_point": "Solution().mergeInBetween", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "ListNode* mergeInBetween(ListNode* list1, int a, int b, ListNode* list2) {", "container": "Solution", "callable": "mergeInBetween", "parameters": [{"name": "list1", "type": "ListNode*"}, {"name": "a", "type": "int"}, {"name": "b", "type": "int"}, {"name": "list2", "type": "ListNode*"}], "return_type": "ListNode*", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1671, "task_id": "minimum-number-of-removals-to-make-mountain-array", "difficulty": "Hard", "problem_description": "You may recall that an array arr is a mountain array if and only if:\n\narr.length >= 3\nThere exists some index i (0-indexed) with 0 < i < arr.length - 1 such that:\n\t\narr[0] < arr[1] < ... < arr[i - 1] < arr[i]\narr[i] > arr[i + 1] > ... > arr[arr.length - 1]\n\n\n\nGiven an integer array nums​​​, return the minimum number of elements to remove to make nums​​​ a mountain array.\n \nExample 1:\n\nInput: nums = [1,3,1]\nOutput: 0\nExplanation: The array itself is a mountain array so we do not need to remove any elements.\n\nExample 2:\n\nInput: nums = [2,1,1,5,6,2,3,1]\nOutput: 3\nExplanation: One solution is to remove the elements at indices 0, 1, and 5, making the array nums = [1,5,6,3,1].\n\n \nConstraints:\n\n3 <= nums.length <= 1000\n1 <= nums[i] <= 109\nIt is guaranteed that you can make a mountain array out of nums.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 1]) == 0\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [100, 92, 89, 77, 74, 66, 64, 66, 64]) == 6\n assert candidate(nums = [1, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [4, 3, 2, 1, 1, 2, 3, 1]) == 4\n assert candidate(nums = [2, 1, 1, 5, 6, 2, 3, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 4, 3, 2, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 1, 5, 7, 6, 3, 2]) == 1\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [9, 8, 1, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [1, 3, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 2, 1, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 10, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12]) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 14, 12, 10, 8, 6, 4, 2, 3, 5, 7, 9, 11]) == 5\n assert candidate(nums = [20, 40, 30, 50, 60, 70, 35, 10, 5, 45, 65, 75, 25, 55, 85, 95, 15, 25, 35, 45]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 8, 6, 4, 2]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 36\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 7\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 3, 2, 1, 0]) == 1\n assert candidate(nums = [10, 20, 15, 20, 25, 30, 25, 20, 15, 10, 5, 10, 15, 20]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [9, 8, 7, 6, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 54\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 40\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]) == 14\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 2, 1, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 27\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [1, 3, 5, 7, 9, 7, 5, 3, 1, 3, 5, 7, 9, 7, 5, 3, 1]) == 8\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 15, 25, 35, 45, 55, 65, 75, 85, 95, 100, 5, 10, 15]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 24\n assert candidate(nums = [4, 3, 2, 1, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == 0\n assert candidate(nums = [2, 3, 1, 4, 3, 2, 5, 4, 3, 2, 1, 6, 7, 8, 7, 6, 5, 4, 3]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3\n assert candidate(nums = [1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3]) == 3\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0, -1, -2, -1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, -1, -2, -1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, -1, -2, -1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, -1, -2, -1, 0, 1, 2, 3, 4, 5]) == 46\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 29\n assert candidate(nums = [1, 5, 3, 7, 5, 9, 7, 11, 9, 13, 11, 15, 13, 17, 15, 19, 17]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 14\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 20\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 11\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15, 14, 16, 15]) == 13\n assert candidate(nums = [1, 5, 3, 4, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 13\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 14\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 0\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91, 11, 90, 12, 89, 13, 88]) == 12\n assert candidate(nums = [1, 5, 3, 4, 6, 7, 8, 9, 10, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 10\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums = [3, 5, 4, 5, 4, 3, 5, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 5]) == 12\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 37\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 125, 120, 115, 110, 105, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15]) == 7\n assert candidate(nums = [1, 1000000000, 999999999, 1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumMountainRemovals", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumMountainRemovals(vector& nums) {", "container": "Solution", "callable": "minimumMountainRemovals", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1672, "task_id": "richest-customer-wealth", "difficulty": "Easy", "problem_description": "You are given an m x n integer grid accounts where accounts[i][j] is the amount of money the i​​​​​​​​​​​th​​​​ customer has in the j​​​​​​​​​​​th​​​​ bank. Return the wealth that the richest customer has.\nA customer's wealth is the amount of money they have in all their bank accounts. The richest customer is the customer that has the maximum wealth.\n \nExample 1:\n\nInput: accounts = [[1,2,3],[3,2,1]]\nOutput: 6\nExplanation:\n1st customer has wealth = 1 + 2 + 3 = 6\n2nd customer has wealth = 3 + 2 + 1 = 6\nBoth customers are considered the richest with a wealth of 6 each, so return 6.\n\nExample 2:\n\nInput: accounts = [[1,5],[7,3],[3,5]]\nOutput: 10\nExplanation: \n1st customer has wealth = 6\n2nd customer has wealth = 10 \n3rd customer has wealth = 8\nThe 2nd customer is the richest with a wealth of 10.\nExample 3:\n\nInput: accounts = [[2,8,7],[7,1,3],[1,9,5]]\nOutput: 17\n\n \nConstraints:\n\nm == accounts.length\nn == accounts[i].length\n1 <= m, n <= 50\n1 <= accounts[i][j] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(accounts = [[10, 20, 30], [1, 2, 3], [100, 200, 300]]) == 600\n assert candidate(accounts = [[10, 10], [20, 20], [30, 30], [40, 40]]) == 80\n assert candidate(accounts = [[100, 100], [50, 50, 50, 50]]) == 200\n assert candidate(accounts = [[100], [100], [100]]) == 100\n assert candidate(accounts = [[5, 5, 5], [15], [10, 10]]) == 20\n assert candidate(accounts = [[10, 20, 30], [5, 15, 25], [1, 2, 3]]) == 60\n assert candidate(accounts = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 3\n assert candidate(accounts = [[50, 50], [25, 75], [75, 25], [100]]) == 100\n assert candidate(accounts = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == 25\n assert candidate(accounts = [[50, 50], [50, 50], [50, 50]]) == 100\n assert candidate(accounts = [[10, 20, 30], [5, 15, 25], [1, 2, 3, 4, 5]]) == 60\n assert candidate(accounts = [[1, 2], [3, 4], [5, 6], [7, 8]]) == 15\n assert candidate(accounts = [[1, 5], [7, 3], [3, 5]]) == 10\n assert candidate(accounts = [[10, 10, 10], [5, 5, 5], [1, 1, 1]]) == 30\n assert candidate(accounts = [[1], [2], [3]]) == 3\n assert candidate(accounts = [[2, 8, 7], [7, 1, 3], [1, 9, 5]]) == 17\n assert candidate(accounts = [[100, 100], [50, 50, 50], [25, 25, 25, 25]]) == 200\n assert candidate(accounts = [[1, 2, 3], [3, 2, 1]]) == 6\n assert candidate(accounts = [[1], [2], [3], [4], [5]]) == 5\n assert candidate(accounts = [[45, 45, 10], [30, 30, 30], [20, 20, 20, 20], [10, 10, 10, 10, 10]]) == 100\n assert candidate(accounts = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]]) == 190\n assert candidate(accounts = [[1, 100, 1], [10, 50, 10], [100, 1, 100], [50, 10, 50]]) == 201\n assert candidate(accounts = [[100, 100, 100, 100, 100], [50, 50, 50, 50], [25, 25, 25, 25, 25], [125, 125]]) == 500\n assert candidate(accounts = [[1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 7\n assert candidate(accounts = [[99, 1, 2, 3], [4, 5, 6, 99], [7, 8, 9, 10]]) == 114\n assert candidate(accounts = [[5, 5, 5, 5, 5], [1, 1, 1, 1, 100], [10, 10, 10, 10, 10], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]) == 104\n assert candidate(accounts = [[10, 20, 30, 40, 50], [90, 80, 70, 60, 50], [1, 2, 3, 4, 5]]) == 350\n assert candidate(accounts = [[50, 1, 50], [1, 50, 50], [50, 50, 1], [50, 1, 50], [1, 50, 50], [50, 50, 1]]) == 101\n assert candidate(accounts = [[10, 10, 10, 10, 10], [9, 9, 9, 9, 9, 9], [8, 8, 8, 8, 8, 8, 8], [7, 7, 7, 7, 7, 7, 7, 7]]) == 56\n assert candidate(accounts = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 150\n assert candidate(accounts = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 2, 3, 4, 5]]) == 150\n assert candidate(accounts = [[99, 1, 1, 1, 1], [1, 99, 1, 1, 1], [1, 1, 99, 1, 1], [1, 1, 1, 99, 1], [1, 1, 1, 1, 99]]) == 103\n assert candidate(accounts = [[90, 5], [5, 90], [45, 55], [55, 45], [75, 25], [25, 75], [60, 40], [40, 60]]) == 100\n assert candidate(accounts = [[50, 50, 50], [25, 25, 25, 25], [100], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 150\n assert candidate(accounts = [[100], [100, 100], [100, 100, 100], [100, 100, 100, 100], [100, 100, 100, 100, 100], [100, 100, 100, 100, 100, 100], [100, 100, 100, 100, 100, 100, 100]]) == 700\n assert candidate(accounts = [[10, 20, 30], [50, 10, 20], [30, 30, 30], [25, 25, 25, 25]]) == 100\n assert candidate(accounts = [[1, 100], [100, 1], [50, 50], [25, 25, 25, 25]]) == 101\n assert candidate(accounts = [[50, 100, 150, 200, 250], [1, 2, 3, 4, 5], [99, 98, 97, 96, 95], [500, 400, 300, 200, 100]]) == 1500\n assert candidate(accounts = [[100, 100, 100, 100, 100], [99, 99, 99, 99, 99], [98, 98, 98, 98, 98], [97, 97, 97, 97, 97], [96, 96, 96, 96, 96]]) == 500\n assert candidate(accounts = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]]) == 30\n assert candidate(accounts = [[90, 10, 10], [10, 90, 10], [10, 10, 90], [30, 30, 30], [20, 20, 20, 20, 10]]) == 110\n assert candidate(accounts = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [4, 4, 4, 4, 4], [5, 5, 5, 5, 5]]) == 25\n assert candidate(accounts = [[99, 1], [1, 99], [50, 50], [25, 25, 25, 25]]) == 100\n assert candidate(accounts = [[10, 20, 30], [50, 60, 70], [80, 90, 100], [10, 10, 10]]) == 270\n assert candidate(accounts = [[50, 50, 50, 50], [100, 200, 300, 400], [5, 10, 15, 20, 25]]) == 1000\n assert candidate(accounts = [[45, 45, 45, 45, 45, 45], [90, 90, 90], [22, 22, 22, 22, 22, 22, 22, 22, 22, 22]]) == 270\n assert candidate(accounts = [[10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40], [50, 50, 50], [60, 60, 60], [70, 70, 70], [80, 80, 80], [90, 90, 90], [100, 100, 100]]) == 300\n assert candidate(accounts = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]]) == 190\n assert candidate(accounts = [[42], [42, 42], [42, 42, 42], [42, 42, 42, 42], [42, 42, 42, 42, 42]]) == 210\n assert candidate(accounts = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]]) == 30\n assert candidate(accounts = [[90, 10, 1], [1, 99, 1], [50, 50, 50], [75, 25, 0], [25, 25, 25, 25]]) == 150\n assert candidate(accounts = [[99, 1], [1, 99], [49, 51], [51, 49], [50, 50]]) == 100\n assert candidate(accounts = [[30, 20, 10], [10, 20, 30], [20, 30, 10], [30, 10, 20], [10, 30, 20]]) == 60\n assert candidate(accounts = [[50, 50, 50], [50, 50, 50], [50, 50, 50], [50, 50, 50], [50, 50, 50]]) == 150\n assert candidate(accounts = [[50, 50], [25, 25, 25, 25], [100, 0], [0, 100], [20, 20, 20, 20, 20]]) == 100\n assert candidate(accounts = [[100], [200], [300], [400], [500], [600], [700], [800], [900], [1000]]) == 1000\n assert candidate(accounts = [[99, 1], [98, 2], [97, 3], [96, 4], [95, 5], [94, 6], [93, 7], [92, 8], [91, 9], [90, 10]]) == 100\n assert candidate(accounts = [[99, 1], [100, 100], [50, 50, 1], [25, 25, 25, 25]]) == 200\n assert candidate(accounts = [[50], [50, 50], [50, 50, 50], [50, 50, 50, 50], [50, 50, 50, 50, 50]]) == 250\n assert candidate(accounts = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]]) == 90\n assert candidate(accounts = [[1, 99], [2, 98], [3, 97], [4, 96], [5, 95]]) == 100\n assert candidate(accounts = [[50, 50, 50], [25, 25, 25, 25], [10, 10, 10, 10, 10, 10]]) == 150\n assert candidate(accounts = [[45, 55], [46, 54], [47, 53], [48, 52], [49, 51]]) == 100\n assert candidate(accounts = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [10, 9, 8, 7, 6], [6, 7, 8, 9, 10]]) == 40\n assert candidate(accounts = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 55\n assert candidate(accounts = [[99, 1, 100], [100, 1, 99], [50, 50, 50]]) == 200\n assert candidate(accounts = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 55\n assert candidate(accounts = [[100, 100, 100, 100, 100], [90, 90, 90, 90, 90, 90], [80, 80, 80, 80, 80, 80, 80], [70, 70, 70, 70, 70, 70, 70, 70]]) == 560\n assert candidate(accounts = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 120\n assert candidate(accounts = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]]) == 500\n assert candidate(accounts = [[1], [1, 1], [1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 10\n assert candidate(accounts = [[100, 0, 0, 0, 0], [0, 100, 0, 0, 0], [0, 0, 100, 0, 0], [0, 0, 0, 100, 0], [0, 0, 0, 0, 100]]) == 100\n assert candidate(accounts = [[100, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 100, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 100, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 100, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 100, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 100, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 100, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 100, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 100, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 100]]) == 109\n assert candidate(accounts = [[1], [2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14, 15]]) == 65\n assert candidate(accounts = [[100, 200, 300, 400], [99, 88, 77, 66], [1, 2, 3, 4]]) == 1000\n assert candidate(accounts = [[100, 100, 100, 100, 100], [99, 99, 99, 99, 99, 99], [50, 50, 50, 50, 50, 50, 50], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 594\n assert candidate(accounts = [[90, 90, 90, 90, 90], [80, 80, 80, 80, 80], [70, 70, 70, 70, 70], [60, 60, 60, 60, 60], [50, 50, 50, 50, 50]]) == 450\n assert candidate(accounts = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12], [13], [14], [15], [16], [17], [18], [19], [20]]) == 20\n assert candidate(accounts = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]) == 40\n assert candidate(accounts = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 2, 3, 4, 5], [50, 40, 30, 20, 10]]) == 150\n assert candidate(accounts = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]]) == 100\n assert candidate(accounts = [[10, 10, 10, 10], [20, 20, 20, 20], [30, 30, 30, 30], [40, 40, 40, 40]]) == 160\n assert candidate(accounts = [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 100\n assert candidate(accounts = [[50, 50, 50], [25, 25, 25, 25, 25], [100, 0], [0, 100, 0], [33, 33, 33, 1]]) == 150\n assert candidate(accounts = [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [20, 20, 20, 20, 20], [30, 30, 30, 30, 30, 30]]) == 180\n"}, "metadata": {"canonical_parameter_names": ["accounts"], "leetcode_dataset_entry_point": "Solution().maximumWealth", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumWealth(vector>& accounts) {", "container": "Solution", "callable": "maximumWealth", "parameters": [{"name": "accounts", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1673, "task_id": "find-the-most-competitive-subsequence", "difficulty": "Medium", "problem_description": "Given an integer array nums and a positive integer k, return the most competitive subsequence of nums of size k.\nAn array's subsequence is a resulting sequence obtained by erasing some (possibly zero) elements from the array.\nWe define that a subsequence a is more competitive than a subsequence b (of the same length) if in the first position where a and b differ, subsequence a has a number less than the corresponding number in b. For example, [1,3,4] is more competitive than [1,3,5] because the first position they differ is at the final number, and 4 is less than 5.\n \nExample 1:\n\nInput: nums = [3,5,2,6], k = 2\nOutput: [2,6]\nExplanation: Among the set of every possible subsequence: {[3,5], [3,2], [3,6], [5,2], [5,6], [2,6]}, [2,6] is the most competitive.\n\nExample 2:\n\nInput: nums = [2,4,3,3,5,4,9,6], k = 4\nOutput: [2,3,3,4]\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i] <= 109\n1 <= k <= nums.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 9, 8, 7, 6, 5, 4, 3, 2],k = 1) == [1]\n assert candidate(nums = [2, 4, 3, 3, 5, 4, 9, 6],k = 4) == [2, 3, 3, 4]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == [5, 4, 3, 2, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7],k = 3) == [1, 2, 3]\n assert candidate(nums = [1, 3, 1, 1, 2, 3, 1],k = 4) == [1, 1, 1, 1]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],k = 3) == [3, 2, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7],k = 5) == [1, 2, 3, 4, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == [1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == [1, 2, 3]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1],k = 2) == [1, 1]\n assert candidate(nums = [3, 5, 2, 6],k = 2) == [2, 6]\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 2) == [1, 2]\n assert candidate(nums = [1, 3, 1, 3, 1, 3, 1],k = 2) == [1, 1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == [9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 5) == [4, 3, 2, 1, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 8, 9, 10],k = 5) == [2, 1, 8, 9, 10]\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 5) == [50, 40, 30, 20, 10]\n assert candidate(nums = [1, 9, 1, 9, 1, 9, 1, 9, 1, 9],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == [1, 2, 3, 4, 5]\n assert candidate(nums = [100, 200, 150, 250, 300, 100, 200, 300, 100, 200],k = 6) == [100, 100, 200, 300, 100, 200]\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2],k = 5) == [1, 1, 2, 1, 2]\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 6) == [1, 1, 2, 3, 4, 5]\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10],k = 10) == [5, 6, 7, 8, 9, 1, 2, 3, 4, 10]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 8, 9],k = 5) == [3, 2, 1, 8, 9]\n assert candidate(nums = [5, 1, 4, 3, 2, 6, 7, 8, 9, 10],k = 5) == [1, 2, 6, 7, 8]\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10],k = 7) == [5, 6, 1, 2, 3, 4, 10]\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1],k = 4) == [1, 1, 1, 1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == [10, 20, 30, 40, 50]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 5) == [4, 3, 2, 1, 0]\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 3) == [10, 10, 10]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 4) == [1, 1, 2, 3]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == [2, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == [1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1],k = 3) == [1, 1, 1]\n assert candidate(nums = [9, 1, 9, 2, 9, 3, 9, 4, 9, 5],k = 5) == [1, 2, 3, 4, 5]\n assert candidate(nums = [10, 5, 6, 3, 2, 1, 8, 7],k = 3) == [1, 8, 7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],k = 5) == [1, 2, 3, 4, 0]\n assert candidate(nums = [5, 3, 1, 2, 4, 6, 8, 7, 9, 0],k = 5) == [1, 2, 4, 6, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 7) == [1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [8, 6, 9, 2, 5, 7, 8, 8],k = 4) == [2, 5, 7, 8]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 3) == [1, 2, 3]\n assert candidate(nums = [1, 3, 1, 1, 2, 3, 4, 1, 5, 6],k = 3) == [1, 1, 1]\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 10) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 5) == [3, 3, 3, 3, 3]\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == [3, 2, 1]\n assert candidate(nums = [1, 3, 1, 1, 2, 3, 1, 2, 3, 1],k = 4) == [1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1],k = 4) == [1, 1, 1, 1]\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10],k = 5) == [1, 6, 7, 8, 9]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9],k = 6) == [1, 1, 2, 3, 5, 9]\n assert candidate(nums = [1, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == [1, 2, 1]\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6],k = 5) == [1, 2, 3, 4, 5]\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10],k = 7) == [1, 2, 3, 4, 6, 5, 10]\n assert candidate(nums = [5, 3, 1, 2, 4, 1, 3, 2, 1, 4, 2, 3],k = 6) == [1, 1, 1, 4, 2, 3]\n assert candidate(nums = [5, 1, 4, 3, 5, 9, 2, 1, 4, 7, 8, 1],k = 7) == [1, 2, 1, 4, 7, 8, 1]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 8) == [1, 1, 2, 2, 3, 3, 4, 4]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7],k = 8) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(nums = [100, 200, 150, 100, 50, 250, 300, 200, 150],k = 5) == [50, 250, 300, 200, 150]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == [0, 0, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 3) == [1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 10) == [0, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 7) == [10, 20, 30, 40, 50, 60, 70]\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],k = 5) == [10, 10, 10, 10, 10]\n assert candidate(nums = [1, 5, 4, 3, 2, 6],k = 3) == [1, 2, 6]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 7) == [3, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [5, 6, 1, 2, 3, 4, 10, 9, 8, 7],k = 4) == [1, 2, 3, 4]\n assert candidate(nums = [8, 9, 7, 6, 5, 4, 3, 2, 1],k = 4) == [4, 3, 2, 1]\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],k = 6) == [1, 1, 1, 1, 2, 3]\n assert candidate(nums = [5, 1, 1, 1, 5, 1, 1, 1, 5, 1, 1, 1, 5],k = 6) == [1, 1, 1, 1, 1, 1]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == [5, 5, 5, 5, 5]\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 0],k = 5) == [1, 2, 3, 4, 0]\n assert candidate(nums = [7, 1, 5, 3, 6, 4],k = 3) == [1, 3, 4]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [7, 14, 4, 14, 13, 2, 6, 13],k = 5) == [4, 13, 2, 6, 13]\n assert candidate(nums = [1, 3, 2, 3, 1, 2, 4, 3, 2, 1],k = 4) == [1, 1, 2, 1]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],k = 6) == [1, 2, 4, 6, 8, 10]\n assert candidate(nums = [5, 1, 9, 7, 3, 8, 2, 4, 6],k = 4) == [1, 2, 4, 6]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 5) == [1, 1, 2, 2, 3]\n assert candidate(nums = [8, 6, 5, 7, 3, 4, 1, 2, 9, 0],k = 4) == [1, 2, 9, 0]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 4) == [1, 1, 2, 2]\n assert candidate(nums = [4, 3, 5, 1, 2, 3, 6, 7, 8, 9],k = 5) == [1, 2, 3, 6, 7]\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9],k = 5) == [1, 6, 7, 8, 9]\n assert candidate(nums = [4, 3, 2, 1, 2, 3, 4, 3, 2, 1],k = 5) == [1, 2, 3, 2, 1]\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5, 0],k = 6) == [1, 2, 3, 4, 5, 0]\n assert candidate(nums = [1, 3, 2, 1, 2, 1, 3, 2, 1],k = 3) == [1, 1, 1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5],k = 10) == [4, 3, 2, 1, 0, 9, 8, 7, 6, 5]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 15) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 9, 1, 9, 1, 9, 1, 9, 1, 9],k = 3) == [1, 1, 1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],k = 6) == [0, 1, 2, 3, 4, 5]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5) == [100, 200, 300, 400, 500]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],k = 3) == [1, 2, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 10) == [0, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, 8, 9],k = 5) == [2, 1, 0, 8, 9]\n assert candidate(nums = [1, 3, 2, 4, 1, 2, 3, 1, 2, 3],k = 4) == [1, 1, 1, 2]\n assert candidate(nums = [5, 2, 6, 3, 4, 1],k = 2) == [2, 1]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 5) == [7, 7, 7, 7, 7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],k = 12) == [1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0],k = 5) == [4, 3, 2, 1, 0]\n assert candidate(nums = [5, 3, 1, 4, 2, 6, 8, 7, 9, 0, 11, 10, 12, 13, 14],k = 10) == [1, 2, 6, 7, 0, 11, 10, 12, 13, 14]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().mostCompetitive", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector mostCompetitive(vector& nums, int k) {", "container": "Solution", "callable": "mostCompetitive", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1674, "task_id": "minimum-moves-to-make-array-complementary", "difficulty": "Medium", "problem_description": "You are given an integer array nums of even length n and an integer limit. In one move, you can replace any integer from nums with another integer between 1 and limit, inclusive.\nThe array nums is complementary if for all indices i (0-indexed), nums[i] + nums[n - 1 - i] equals the same number. For example, the array [1,2,3,4] is complementary because for all indices i, nums[i] + nums[n - 1 - i] = 5.\nReturn the minimum number of moves required to make nums complementary.\n \nExample 1:\n\nInput: nums = [1,2,4,3], limit = 4\nOutput: 1\nExplanation: In 1 move, you can change nums to [1,2,2,3] (underlined elements are changed).\nnums[0] + nums[3] = 1 + 3 = 4.\nnums[1] + nums[2] = 2 + 2 = 4.\nnums[2] + nums[1] = 2 + 2 = 4.\nnums[3] + nums[0] = 3 + 1 = 4.\nTherefore, nums[i] + nums[n-1-i] = 4 for every i, so nums is complementary.\n\nExample 2:\n\nInput: nums = [1,2,2,1], limit = 2\nOutput: 2\nExplanation: In 2 moves, you can change nums to [2,2,2,2]. You cannot change any number to 3 since 3 > limit.\n\nExample 3:\n\nInput: nums = [1,2,1,2], limit = 2\nOutput: 0\nExplanation: nums is already complementary.\n\n \nConstraints:\n\nn == nums.length\n2 <= n <= 105\n1 <= nums[i] <= limit <= 105\nn is even.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, 3, 3, 3],limit = 5) == 0\n assert candidate(nums = [1, 1, 1, 1],limit = 10) == 0\n assert candidate(nums = [5, 3, 5, 3],limit = 10) == 0\n assert candidate(nums = [1, 5, 5, 1],limit = 5) == 2\n assert candidate(nums = [1, 2, 2, 1],limit = 2) == 2\n assert candidate(nums = [100000, 1, 100000, 1],limit = 100000) == 0\n assert candidate(nums = [100000, 1, 1, 100000],limit = 100000) == 2\n assert candidate(nums = [100000, 1, 1, 100000, 1, 1, 100000, 1],limit = 100000) == 1\n assert candidate(nums = [3, 5, 5, 3],limit = 5) == 1\n assert candidate(nums = [1, 1, 1, 1],limit = 1) == 0\n assert candidate(nums = [1, 5, 9, 13],limit = 15) == 0\n assert candidate(nums = [1, 3, 5, 7],limit = 10) == 0\n assert candidate(nums = [2, 5, 6, 5, 2, 2],limit = 7) == 2\n assert candidate(nums = [1, 9, 9, 1, 1, 9, 9, 1],limit = 9) == 4\n assert candidate(nums = [10, 1, 10, 1],limit = 10) == 0\n assert candidate(nums = [100000, 100000, 100000, 100000],limit = 100000) == 0\n assert candidate(nums = [10, 15, 15, 10],limit = 20) == 1\n assert candidate(nums = [2, 3, 4, 3, 2, 1],limit = 6) == 2\n assert candidate(nums = [1, 9, 9, 1],limit = 10) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6],limit = 6) == 0\n assert candidate(nums = [10, 1, 1, 10],limit = 10) == 2\n assert candidate(nums = [5, 5, 5, 5],limit = 10) == 0\n assert candidate(nums = [50000, 50000, 50000, 50000],limit = 100000) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6],limit = 7) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5],limit = 5) == 0\n assert candidate(nums = [1, 3, 2, 4],limit = 5) == 0\n assert candidate(nums = [1, 2, 4, 3],limit = 4) == 1\n assert candidate(nums = [5, 5, 5, 5],limit = 5) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3],limit = 6) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3],limit = 3) == 0\n assert candidate(nums = [1, 2, 1, 2],limit = 2) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],limit = 20) == 0\n assert candidate(nums = [1, 100000, 50000, 50000, 100000, 1],limit = 100000) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 2) == 0\n assert candidate(nums = [30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000, 30000],limit = 60000) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],limit = 6) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],limit = 16) == 0\n assert candidate(nums = [25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000],limit = 50000) == 0\n assert candidate(nums = [100000, 1, 2, 99999, 3, 99998, 4, 99997],limit = 100000) == 3\n assert candidate(nums = [1, 100000, 1, 100000, 2, 99999, 2, 99999],limit = 100000) == 2\n assert candidate(nums = [100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1],limit = 100000) == 0\n assert candidate(nums = [1, 100000, 100000, 1],limit = 100000) == 2\n assert candidate(nums = [10000, 90000, 20000, 80000, 30000, 70000],limit = 100000) == 2\n assert candidate(nums = [25000, 25001, 25002, 24999, 25003, 24998, 25004, 24997],limit = 50000) == 3\n assert candidate(nums = [30000, 70000, 40000, 60000, 50000, 50000, 40000, 60000, 30000, 70000],limit = 100000) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],limit = 30) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],limit = 21) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],limit = 100) == 0\n assert candidate(nums = [99999, 1, 99999, 1, 99999, 1],limit = 100000) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],limit = 12) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],limit = 10) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 10) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80],limit = 80) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 100000) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 50, 40, 30, 20, 10, 1],limit = 100) == 5\n assert candidate(nums = [1, 99999, 99999, 1, 1, 99999, 99999, 1, 1, 99999, 99999, 1],limit = 100000) == 6\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4],limit = 4) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 10) == 0\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 30) == 0\n assert candidate(nums = [5, 3, 5, 3, 2, 8, 8, 2],limit = 10) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 1) == 0\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3],limit = 6) == 0\n assert candidate(nums = [1, 2, 3, 3, 2, 1, 4, 4, 3, 3, 2, 2, 1, 1],limit = 5) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 2) == 0\n assert candidate(nums = [25, 75, 25, 75, 25, 75, 25, 75, 25, 75, 25, 75, 25, 75, 25, 75],limit = 100) == 0\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],limit = 100) == 0\n assert candidate(nums = [50000, 1, 50000, 1, 50000, 1, 50000, 1],limit = 100000) == 0\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42],limit = 84) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 5) == 0\n assert candidate(nums = [1, 100000, 1, 100000],limit = 100000) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],limit = 15) == 0\n assert candidate(nums = [10000, 20000, 30000, 40000, 40000, 30000, 20000, 10000],limit = 50000) == 3\n assert candidate(nums = [99999, 1, 1, 99999],limit = 100000) == 2\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6],limit = 10) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],limit = 13) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 400, 300, 200, 100],limit = 500) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],limit = 20) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 1) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 11) == 9\n assert candidate(nums = [90000, 10000, 80000, 20000, 70000, 30000, 60000, 40000],limit = 100000) == 3\n assert candidate(nums = [1, 5, 9, 13, 17, 21],limit = 22) == 0\n assert candidate(nums = [50000, 40000, 30000, 20000, 10000, 10000, 20000, 30000, 40000, 50000],limit = 100000) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],limit = 110) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],limit = 5) == 0\n assert candidate(nums = [1, 99999, 99998, 2, 99997, 3, 99996, 4],limit = 100000) == 3\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11],limit = 12) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],limit = 20) == 0\n assert candidate(nums = [100000, 1, 99999, 2, 99998, 3, 99997, 4, 99996, 5],limit = 100000) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 10) == 0\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000],limit = 50000) == 0\n assert candidate(nums = [99999, 99998, 1, 2, 3, 4, 5, 6],limit = 100000) == 3\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],limit = 5) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 10) == 0\n assert candidate(nums = [50, 51, 52, 49, 53, 48, 54, 47],limit = 100) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],limit = 16) == 0\n assert candidate(nums = [1, 99999, 2, 99998, 3, 99997, 4, 99996],limit = 100000) == 3\n assert candidate(nums = [100000, 1, 2, 99998, 3, 99997, 4, 99996],limit = 100000) == 3\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],limit = 100000) == 0\n assert candidate(nums = [1, 2, 3, 2, 3, 2, 3, 2, 3, 2],limit = 5) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],limit = 25) == 0\n assert candidate(nums = [10000, 90000, 10000, 90000, 10000, 90000, 10000, 90000],limit = 100000) == 0\n assert candidate(nums = [10, 20, 30, 40, 40, 30, 20, 10],limit = 50) == 3\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40],limit = 50) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],limit = 110) == 9\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],limit = 21) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],limit = 15) == 0\n assert candidate(nums = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999],limit = 100000) == 0\n assert candidate(nums = [3, 7, 11, 11, 7, 3],limit = 14) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],limit = 15) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800],limit = 900) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],limit = 20) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],limit = 10) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "limit"], "leetcode_dataset_entry_point": "Solution().minMoves", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minMoves(vector& nums, int limit) {", "container": "Solution", "callable": "minMoves", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "limit", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1675, "task_id": "minimize-deviation-in-array", "difficulty": "Hard", "problem_description": "You are given an array nums of n positive integers.\nYou can perform two types of operations on any element of the array any number of times:\n\nIf the element is even, divide it by 2.\n\n\t\nFor example, if the array is [1,2,3,4], then you can do this operation on the last element, and the array will be [1,2,3,2].\n\n\nIf the element is odd, multiply it by 2.\n\t\nFor example, if the array is [1,2,3,4], then you can do this operation on the first element, and the array will be [2,2,3,4].\n\n\n\nThe deviation of the array is the maximum difference between any two elements in the array.\nReturn the minimum deviation the array can have after performing some number of operations.\n \nExample 1:\n\nInput: nums = [1,2,3,4]\nOutput: 1\nExplanation: You can transform the array to [1,2,3,2], then to [2,2,3,2], then the deviation will be 3 - 2 = 1.\n\nExample 2:\n\nInput: nums = [4,1,5,20,3]\nOutput: 3\nExplanation: You can transform the array after two operations to [4,2,5,5,3], then the deviation will be 5 - 2 = 3.\n\nExample 3:\n\nInput: nums = [2,10,8]\nOutput: 3\n\n \nConstraints:\n\nn == nums.length\n2 <= n <= 5 * 104\n1 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1000000000]) == 1953123\n assert candidate(nums = [3, 9, 6, 12]) == 3\n assert candidate(nums = [3, 9, 7, 3]) == 3\n assert candidate(nums = [2, 10, 8]) == 3\n assert candidate(nums = [5, 3, 11, 24, 2]) == 9\n assert candidate(nums = [1000000000, 1, 1000000000]) == 1953123\n assert candidate(nums = [1, 3, 5, 7, 9]) == 7\n assert candidate(nums = [15, 15, 15, 15]) == 0\n assert candidate(nums = [1, 2, 3, 4]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50]) == 15\n assert candidate(nums = [6, 1, 3, 4, 2, 8]) == 1\n assert candidate(nums = [8, 12, 24, 6]) == 1\n assert candidate(nums = [6, 10, 18, 24]) == 4\n assert candidate(nums = [4, 1, 5, 20, 3]) == 3\n assert candidate(nums = [7, 4, 1, 8, 12]) == 5\n assert candidate(nums = [10, 10, 10]) == 0\n assert candidate(nums = [3, 5, 6, 10, 15]) == 9\n assert candidate(nums = [10, 4, 3, 5]) == 2\n assert candidate(nums = [7, 4, 3, 7]) == 3\n assert candidate(nums = [1, 2, 9, 16]) == 7\n assert candidate(nums = [5, 17, 100, 1]) == 23\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 29\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 29\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == 10\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 275\n assert candidate(nums = [1024, 2048, 3072, 4096, 5120, 6144, 7168, 8192, 9216, 10240, 11264, 12288, 13312, 14336, 15360, 16384, 17408, 18432, 19456, 20480]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 7\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515, 1616, 1717, 1818, 1919, 2020]) == 1717\n assert candidate(nums = [999999999, 1000000000, 999999998, 1000000001, 999999997, 1000000002]) == 5\n assert candidate(nums = [1000000001, 1000000002, 1000000003, 1000000004, 1000000005]) == 4\n assert candidate(nums = [17, 23, 31, 37, 41, 43, 47, 53, 59, 61]) == 28\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 13\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 27\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555]) == 765432099\n assert candidate(nums = [1000000, 900000, 800000, 700000, 600000, 500000, 400000, 300000, 200000, 100000]) == 12500\n assert candidate(nums = [2, 14, 18, 26, 34, 42, 50, 58, 66, 74]) == 35\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 0\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150]) == 135\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == 105\n assert candidate(nums = [64, 32, 16, 8, 4, 2, 1, 2, 4, 8, 16, 32, 64]) == 0\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997]) == 3\n assert candidate(nums = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78]) == 37\n assert candidate(nums = [1, 1000000000, 2, 500000000, 3, 333333333, 4, 250000000, 5, 200000000]) == 333333331\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000]) == 0\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220]) == 187\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 45\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 17\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990]) == 9\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000]) == 31250\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 69\n assert candidate(nums = [123456789, 987654321, 456789123, 321987654, 654321987, 789123456]) == 740740743\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165]) == 143\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125]) == 0\n assert candidate(nums = [1, 1000000000, 2, 2000000000, 3, 3000000000, 4, 4000000000, 5, 5000000000, 6, 6000000000, 7, 7000000000, 8, 8000000000, 9, 9000000000]) == 17578123\n assert candidate(nums = [1, 1000000000, 2, 500000000, 3, 1500000000]) == 5859373\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2]) == 0\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 51\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195]) == 169\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32]) == 13\n assert candidate(nums = [2, 6, 18, 54, 162, 486, 1458, 4374, 13122, 39366, 118098, 354294, 1062882, 3188646, 9565938]) == 4782967\n assert candidate(nums = [13579, 24681, 35791, 46813, 57915, 68137, 79159, 81379, 91591, 113791]) == 86633\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500]) == 525\n assert candidate(nums = [1023, 2047, 4095, 8191, 16383]) == 14337\n assert candidate(nums = [5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625]) == 9765615\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 17\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049]) == 59043\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 275\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 39\n assert candidate(nums = [13, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 71\n assert candidate(nums = [1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010]) == 9\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 65\n assert candidate(nums = [1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287]) == 522241\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996]) == 4\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 0\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 0\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 21\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996]) == 999999997\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 85\n assert candidate(nums = [5, 15, 25, 35, 45, 55]) == 45\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 37\n assert candidate(nums = [2147483647, 2147483646, 2147483645, 2147483644, 2147483643]) == 4\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995]) == 4\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5]) == 1953123\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90]) == 63\n assert candidate(nums = [1024, 2048, 512, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5]) == 1953123\n assert candidate(nums = [1023, 2046, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 1021\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 0\n assert candidate(nums = [9, 18, 27, 36, 45, 54]) == 27\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(nums = [83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181]) == 84\n assert candidate(nums = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34]) == 9\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824]) == 0\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010]) == 707\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 65\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumDeviation", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumDeviation(vector& nums) {", "container": "Solution", "callable": "minimumDeviation", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1678, "task_id": "goal-parser-interpretation", "difficulty": "Easy", "problem_description": "You own a Goal Parser that can interpret a string command. The command consists of an alphabet of \"G\", \"()\" and/or \"(al)\" in some order. The Goal Parser will interpret \"G\" as the string \"G\", \"()\" as the string \"o\", and \"(al)\" as the string \"al\". The interpreted strings are then concatenated in the original order.\nGiven the string command, return the Goal Parser's interpretation of command.\n \nExample 1:\n\nInput: command = \"G()(al)\"\nOutput: \"Goal\"\nExplanation: The Goal Parser interprets the command as follows:\nG -> G\n() -> o\n(al) -> al\nThe final concatenated result is \"Goal\".\n\nExample 2:\n\nInput: command = \"G()()()()(al)\"\nOutput: \"Gooooal\"\n\nExample 3:\n\nInput: command = \"(al)G(al)()()G\"\nOutput: \"alGalooG\"\n\n \nConstraints:\n\n1 <= command.length <= 100\ncommand consists of \"G\", \"()\", and/or \"(al)\" in some order.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(command = \"G()()()()(al)\") == \"Gooooal\"\n assert candidate(command = \"G\") == \"G\"\n assert candidate(command = \"()\") == \"o\"\n assert candidate(command = \"(al)G(al)()()G\") == \"alGalooG\"\n assert candidate(command = \"G()(G)()\") == \"Go(G)o\"\n assert candidate(command = \"G(al)G(al)\") == \"GalGal\"\n assert candidate(command = \"G()(al)\") == \"Goal\"\n assert candidate(command = \"()()()()\") == \"oooo\"\n assert candidate(command = \"G()G(al)G()\") == \"GoGalGo\"\n assert candidate(command = \"G(al)G(al)G(al)\") == \"GalGalGal\"\n assert candidate(command = \"(al)(al)(al)\") == \"alalal\"\n assert candidate(command = \"(al)\") == \"al\"\n assert candidate(command = \"(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"alGalGalGalGalGalGalGal\"\n assert candidate(command = \"G(al)()()G(al)()()G(al)()()\") == \"GalooGalooGaloo\"\n assert candidate(command = \"G(al)(al)G(al)(al)G(al)(al)\") == \"GalalGalalGalal\"\n assert candidate(command = \"()()()()G(al)G(al)G(al)G(al)\") == \"ooooGalGalGalGal\"\n assert candidate(command = \"()()()G(al)G(al)G(al)G(al)G(al)G(al)\") == \"oooGalGalGalGalGalGal\"\n assert candidate(command = \"()G(al)G()G(al)()\") == \"oGalGoGalo\"\n assert candidate(command = \"()G(al)()G(al)()G(al)()\") == \"oGaloGaloGalo\"\n assert candidate(command = \"G()G()G()G()G()G()G()G()G()G()G()G()G()G()G(al)\") == \"GoGoGoGoGoGoGoGoGoGoGoGoGoGoGal\"\n assert candidate(command = \"G(al)(al)(al)\") == \"Galalal\"\n assert candidate(command = \"()(G(al)G(al))(G(al)G(al))\") == \"o(GalGal)(GalGal)\"\n assert candidate(command = \"G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"GalGalGalGalGalGalGalGal\"\n assert candidate(command = \"()G(al)G(al)G(al)G(al)G(al)G(al)\") == \"oGalGalGalGalGalGal\"\n assert candidate(command = \"G(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"GalGalGalGalGalGalGal\"\n assert candidate(command = \"G(al)G()G(al)G()G(al)\") == \"GalGoGalGoGal\"\n assert candidate(command = \"(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"alGalGalGalGalGalGalGalGalGal\"\n assert candidate(command = \"G()(al)G()(al)G()(al)\") == \"GoalGoalGoal\"\n assert candidate(command = \"(al)G(al)()G(al)()G(al)()G(al)()G(al)()\") == \"alGaloGaloGaloGaloGalo\"\n assert candidate(command = \"(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"alGalGalGalGalGalGal\"\n assert candidate(command = \"()G(al)G()G(al)\") == \"oGalGoGal\"\n assert candidate(command = \"(al)G(al)()()G(al)G(al)()()G(al)G(al)()()G\") == \"alGalooGalGalooGalGalooG\"\n assert candidate(command = \"G(al)G(al)G(al)G(al)G(al)\") == \"GalGalGalGalGal\"\n assert candidate(command = \"G(al)(al)(al)(al)\") == \"Galalalal\"\n assert candidate(command = \"(al)G(al)(G(al)(G(al)G(al)))G(al)\") == \"alGal(Gal(GalGal))Gal\"\n assert candidate(command = \"G()()G()()G()()\") == \"GooGooGoo\"\n assert candidate(command = \"G(al)()G(al)()G(al)()G(al)()G(al)()\") == \"GaloGaloGaloGaloGalo\"\n assert candidate(command = \"G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()\") == \"GaloGaloGaloGaloGaloGaloGaloGaloGaloGaloGalo\"\n assert candidate(command = \"G()G()G(al)(al)G()\") == \"GoGoGalalGo\"\n assert candidate(command = \"G(al)G(al)()()G(al)G(al)G(al)\") == \"GalGalooGalGalGal\"\n assert candidate(command = \"G()(G()(G()(G())))\") == \"Go(Go(Go(Go)))\"\n assert candidate(command = \"()G()G(al)()G(al)()G(al)\") == \"oGoGaloGaloGal\"\n assert candidate(command = \"()G()()G()()G()()G(al)G()\") == \"oGooGooGooGalGo\"\n assert candidate(command = \"G(al)G(al)G(al)G(al)\") == \"GalGalGalGal\"\n assert candidate(command = \"G()(al)G()(al)G()(al)G()(al)\") == \"GoalGoalGoalGoal\"\n assert candidate(command = \"G()()()()(al)G(al)G(al)G(al)\") == \"GooooalGalGalGal\"\n assert candidate(command = \"G(al)G(al)()()G(al)G(al)()()\") == \"GalGalooGalGaloo\"\n assert candidate(command = \"G()(G(al))(G(al))G()(G(al))(G(al))\") == \"Go(Gal)(Gal)Go(Gal)(Gal)\"\n assert candidate(command = \"(al)(al)G(al)(al)G(al)(al)\") == \"alalGalalGalal\"\n assert candidate(command = \"G(al)(al)(al)G\") == \"GalalalG\"\n assert candidate(command = \"(al)G(al)()G(al)()G(al)()G(al)()\") == \"alGaloGaloGaloGalo\"\n assert candidate(command = \"G(al)(al)(al)G(al)(al)(al)G(al)(al)(al)G\") == \"GalalalGalalalGalalalG\"\n assert candidate(command = \"G(al)(G(al)G(al))(G(al))\") == \"Gal(GalGal)(Gal)\"\n assert candidate(command = \"G()(G(al))G()(G(al))\") == \"Go(Gal)Go(Gal)\"\n assert candidate(command = \"G()G()G()G()G()G()G()G()\") == \"GoGoGoGoGoGoGoGo\"\n assert candidate(command = \"G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()\") == \"GaloGaloGaloGaloGaloGalo\"\n assert candidate(command = \"()()()G(al)G(al)G(al)()()()\") == \"oooGalGalGalooo\"\n assert candidate(command = \"(al)()G(al)()G(al)G(al)\") == \"aloGaloGalGal\"\n assert candidate(command = \"(al)(al)(al)(al)G(al)G()\") == \"alalalalGalGo\"\n assert candidate(command = \"(al)(G)(al)(G)(al)(G)(al)\") == \"al(G)al(G)al(G)al\"\n assert candidate(command = \"G(al)(al)G(al)\") == \"GalalGal\"\n assert candidate(command = \"(al)G(al)G(al)G(al)G(al)G(al)\") == \"alGalGalGalGalGal\"\n assert candidate(command = \"()G(al)G(al)G(al)G(al)G(al)\") == \"oGalGalGalGalGal\"\n assert candidate(command = \"G(al)G()(al)G()(al)G()(al)G()\") == \"GalGoalGoalGoalGo\"\n assert candidate(command = \"G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"GalGalGalGalGalGalGalGalGalGal\"\n assert candidate(command = \"G()(G()(G)())\") == \"Go(Go(G)o)\"\n assert candidate(command = \"()()()()()()()()()()()()()()()()()()()()()G(al)\") == \"oooooooooooooooooooooGal\"\n assert candidate(command = \"G(al)()G(al)()G(al)()G(al)()G(al)\") == \"GaloGaloGaloGaloGal\"\n assert candidate(command = \"(al)G(al)(al)G(al)G\") == \"alGalalGalG\"\n assert candidate(command = \"G(al)G(al)G(al)G(al)G(al)G(al)\") == \"GalGalGalGalGalGal\"\n assert candidate(command = \"G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"GalGalGalGalGalGalGalGalGal\"\n assert candidate(command = \"(al)()G(al)()G(al)()G(al)()\") == \"aloGaloGaloGalo\"\n assert candidate(command = \"G(al)(G()(G)(G)())G(al)\") == \"Gal(Go(G)(G)o)Gal\"\n assert candidate(command = \"G()G(al)G()G(al)\") == \"GoGalGoGal\"\n assert candidate(command = \"(al)(al)(al)G(al)\") == \"alalalGal\"\n assert candidate(command = \"G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"GalGalGalGalGalGalGalGalGalGalGalGal\"\n assert candidate(command = \"(al)G(al)G(al)G(al)G(al)\") == \"alGalGalGalGal\"\n assert candidate(command = \"(al)(G(al))(G(al))(G(al))(G(al))(G(al))\") == \"al(Gal)(Gal)(Gal)(Gal)(Gal)\"\n assert candidate(command = \"()()()()()G(al)()()\") == \"oooooGaloo\"\n assert candidate(command = \"()G(al)()G(al)()\") == \"oGaloGalo\"\n assert candidate(command = \"(al)(al)(al)(al)(al)(al)(al)(al)\") == \"alalalalalalalal\"\n assert candidate(command = \"()()()()(al)()()()(al)()()()\") == \"ooooaloooalooo\"\n assert candidate(command = \"G(al)G()G(al)G()G(al)G()\") == \"GalGoGalGoGalGo\"\n assert candidate(command = \"G()(G()(G()(G)())())\") == \"Go(Go(Go(G)o)o)\"\n assert candidate(command = \"G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()G(al)()\") == \"GaloGaloGaloGaloGaloGaloGaloGalo\"\n assert candidate(command = \"G(al)(al)G(al)G(al)\") == \"GalalGalGal\"\n assert candidate(command = \"G(al)(G(al))(G(al))(G(al))G(al)\") == \"Gal(Gal)(Gal)(Gal)Gal\"\n assert candidate(command = \"G()()()()(al)G(al)G(al)G(al)G(al)\") == \"GooooalGalGalGalGal\"\n assert candidate(command = \"G()(G()(G()(G()())))\") == \"Go(Go(Go(Goo)))\"\n assert candidate(command = \"G(al)()G(al)()G(al)()G(al)()G(al)G(al)\") == \"GaloGaloGaloGaloGalGal\"\n assert candidate(command = \"(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)G(al)\") == \"alGalGalGalGalGalGalGalGalGalGalGal\"\n assert candidate(command = \"G()G()G()G()G()G()G()G()G()G()G()G()G()G()G()G()\") == \"GoGoGoGoGoGoGoGoGoGoGoGoGoGoGoGo\"\n assert candidate(command = \"(al)()()()()()()()()()()()()()()()()()()()()()()()()()()()()\") == \"aloooooooooooooooooooooooooooo\"\n assert candidate(command = \"G()G()G()G()G(al)G(al)G(al)\") == \"GoGoGoGoGalGalGal\"\n assert candidate(command = \"()()()()()()()()()()G(al)G(al)G(al)G(al)G(al)\") == \"ooooooooooGalGalGalGalGal\"\n"}, "metadata": {"canonical_parameter_names": ["command"], "leetcode_dataset_entry_point": "Solution().interpret", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string interpret(string command) {", "container": "Solution", "callable": "interpret", "parameters": [{"name": "command", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1679, "task_id": "max-number-of-k-sum-pairs", "difficulty": "Medium", "problem_description": "You are given an integer array nums and an integer k.\nIn one operation, you can pick two numbers from the array whose sum equals k and remove them from the array.\nReturn the maximum number of operations you can perform on the array.\n \nExample 1:\n\nInput: nums = [1,2,3,4], k = 5\nOutput: 2\nExplanation: Starting with nums = [1,2,3,4]:\n- Remove numbers 1 and 4, then nums = [2,3]\n- Remove numbers 2 and 3, then nums = []\nThere are no more pairs that sum up to 5, hence a total of 2 operations.\nExample 2:\n\nInput: nums = [3,1,3,4,3], k = 6\nOutput: 1\nExplanation: Starting with nums = [3,1,3,4,3]:\n- Remove the first two 3's, then nums = [1,4,3]\nThere are no more pairs that sum up to 6, hence a total of 1 operation.\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 109\n1 <= k <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, 1, 3, 4, 3],k = 6) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 5\n assert candidate(nums = [1000000000],k = 1000000000) == 0\n assert candidate(nums = [1, 5, 4, 2, 9, 6, 5, 3, 4, 7, 8, 10],k = 11) == 5\n assert candidate(nums = [1, 3, 5, 7, 9],k = 10) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5],k = 10) == 3\n assert candidate(nums = [1, 5, 7, 8, 2, 6, 3, 4],k = 9) == 4\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1000000000],k = 2000000000) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 11) == 5\n assert candidate(nums = [5, 5, 5, 5, 5],k = 10) == 2\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 4) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 4\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3],k = 3) == 3\n assert candidate(nums = [1, 2, 3, 4],k = 5) == 2\n assert candidate(nums = [1, 3, 2, 2, 2, 3, 1],k = 4) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 10) == 4\n assert candidate(nums = [1, 3, 2, 2, 2, 3, 1],k = 4) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 26) == 12\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 30) == 7\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 42) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14],k = 15) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 21) == 20\n assert candidate(nums = [1, 3, 3, 5, 7, 7, 5, 9, 9, 11, 11, 13],k = 12) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 21) == 10\n assert candidate(nums = [1, 5, 7, 3, 5, 7, 9, 11, 13, 15],k = 12) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 7\n assert candidate(nums = [1, 3, 2, 2, 2, 2, 2, 3, 1, 3, 3, 2, 2, 2, 3, 2, 2, 1, 3, 2],k = 4) == 8\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 11) == 10\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1000000000],k = 1000000001) == 1\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],k = 100) == 5\n assert candidate(nums = [1, 5, 7, 1, 5, 7, 1, 5, 7, 1, 5, 7, 1, 5, 7, 1, 5, 7, 1, 5, 7],k = 6) == 7\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 300) == 5\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],k = 16) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 6) == 25\n assert candidate(nums = [999999999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1000000000) == 1\n assert candidate(nums = [1, 5, 7, 1, 5, 9, 5, 5, 5, 5],k = 10) == 4\n assert candidate(nums = [5, 1, 4, 8, 6, 9, 7, 2, 3, 10],k = 15) == 3\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195],k = 200) == 10\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8],k = 6) == 6\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 20) == 7\n assert candidate(nums = [1000000000, 1000000000, 1, 1, 2, 2, 999999999, 999999999],k = 2000000000) == 1\n assert candidate(nums = [1, 5, 4, 2, 8, 6, 7, 3, 9],k = 10) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 300) == 11\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],k = 400) == 21\n assert candidate(nums = [1000000000, 1, 1000000000, 2, 3, 999999999, 3, 2],k = 2000000000) == 1\n assert candidate(nums = [2, 5, 4, 4, 1, 3, 4, 4, 1, 4, 4, 1, 2, 1, 2, 2, 3, 2, 4, 2],k = 6) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 21) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 21) == 30\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 300) == 11\n assert candidate(nums = [2, 4, 3, 5, 7, 8, 1, 9, 10, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 31) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 32) == 8\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 27) == 7\n assert candidate(nums = [3, 6, 3, 3, 6, 6, 3, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6],k = 9) == 15\n assert candidate(nums = [10, 15, 3, 7, 11, 15, 0, 7, 6, 10, 3, 11, 1],k = 15) == 1\n assert candidate(nums = [1, 5, 7, 1, 5, 9, 7, 5, 11, 1],k = 10) == 2\n assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 12) == 7\n assert candidate(nums = [1000000000, 1, 999999999, 2, 999999998, 3, 999999997, 4],k = 1000000001) == 4\n assert candidate(nums = [1000000000, 1000000000, 1, 1, 2, 2, 3, 3],k = 2000000000) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 16\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 11) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 41) == 20\n assert candidate(nums = [3, 1, 3, 4, 3, 5, 6, 2, 3, 1],k = 6) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],k = 50) == 12\n assert candidate(nums = [1, 5, 7, -1, 5],k = 6) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 16) == 7\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 18) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 20) == 5\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 1000000000, 999999999, 1],k = 2000000000) == 1\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maxOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxOperations(vector& nums, int k) {", "container": "Solution", "callable": "maxOperations", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1680, "task_id": "concatenation-of-consecutive-binary-numbers", "difficulty": "Medium", "problem_description": "Given an integer n, return the decimal value of the binary string formed by concatenating the binary representations of 1 to n in order, modulo 109 + 7.\n \nExample 1:\n\nInput: n = 1\nOutput: 1\nExplanation: \"1\" in binary corresponds to the decimal value 1. \n\nExample 2:\n\nInput: n = 3\nOutput: 27\nExplanation: In binary, 1, 2, and 3 corresponds to \"1\", \"10\", and \"11\".\nAfter concatenating them, we have \"11011\", which corresponds to the decimal value 27.\n\nExample 3:\n\nInput: n = 12\nOutput: 505379714\nExplanation: The concatenation results in \"1101110010111011110001001101010111100\".\nThe decimal value of that is 118505380540.\nAfter modulo 109 + 7, the result is 505379714.\n\n \nConstraints:\n\n1 <= n <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 27\n assert candidate(n = 100000) == 757631812\n assert candidate(n = 100) == 310828084\n assert candidate(n = 12) == 505379714\n assert candidate(n = 10000) == 356435599\n assert candidate(n = 20) == 632668867\n assert candidate(n = 1) == 1\n assert candidate(n = 1000) == 499361981\n assert candidate(n = 10) == 462911642\n assert candidate(n = 5) == 1765\n assert candidate(n = 15000) == 760107204\n assert candidate(n = 99999) == 880407397\n assert candidate(n = 12345) == 836722104\n assert candidate(n = 67890) == 121883656\n assert candidate(n = 32767) == 351669993\n assert candidate(n = 90000) == 333354001\n assert candidate(n = 50000) == 305317209\n assert candidate(n = 60000) == 841047212\n assert candidate(n = 30000) == 789968936\n assert candidate(n = 80000) == 801174769\n assert candidate(n = 8192) == 853721666\n assert candidate(n = 65536) == 273282097\n assert candidate(n = 5000) == 754628255\n assert candidate(n = 75000) == 363627085\n assert candidate(n = 40000) == 162370743\n assert candidate(n = 65535) == 183542430\n assert candidate(n = 500) == 715412131\n assert candidate(n = 25000) == 110872861\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().concatenatedBinary", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int concatenatedBinary(int n) {", "container": "Solution", "callable": "concatenatedBinary", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1681, "task_id": "minimum-incompatibility", "difficulty": "Hard", "problem_description": "You are given an integer array nums​​​ and an integer k. You are asked to distribute this array into k subsets of equal size such that there are no two equal elements in the same subset.\nA subset's incompatibility is the difference between the maximum and minimum elements in that array.\nReturn the minimum possible sum of incompatibilities of the k subsets after distributing the array optimally, or return -1 if it is not possible.\nA subset is a group integers that appear in the array with no particular order.\n \nExample 1:\n\nInput: nums = [1,2,1,4], k = 2\nOutput: 4\nExplanation: The optimal distribution of subsets is [1,2] and [1,4].\nThe incompatibility is (2-1) + (4-1) = 4.\nNote that [1,1] and [2,4] would result in a smaller sum, but the first subset contains 2 equal elements.\nExample 2:\n\nInput: nums = [6,3,8,1,3,1,2,2], k = 4\nOutput: 6\nExplanation: The optimal distribution of subsets is [1,2], [2,3], [6,8], and [1,3].\nThe incompatibility is (2-1) + (3-2) + (8-6) + (3-1) = 6.\n\nExample 3:\n\nInput: nums = [5,3,3,6,3,3], k = 3\nOutput: -1\nExplanation: It is impossible to distribute nums into 3 subsets where no two elements are equal in the same subset.\n\n \nConstraints:\n\n1 <= k <= nums.length <= 16\nnums.length is divisible by k\n1 <= nums[i] <= nums.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 1) == 15\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 8) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8],k = 4) == 4\n assert candidate(nums = [6, 3, 8, 1, 3, 1, 2, 2],k = 4) == 6\n assert candidate(nums = [1, 2, 1, 4],k = 2) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8],k = 2) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 4) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 16) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4],k = 4) == 4\n assert candidate(nums = [5, 3, 3, 6, 3, 3],k = 3) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1],k = 1) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 2) == 14\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4],k = 8) == 0\n assert candidate(nums = [1, 2, 3, 3, 4, 5, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14],k = 2) == 18\n assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 4) == 12\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7],k = 4) == 14\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17],k = 4) == 12\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3],k = 3) == -1\n assert candidate(nums = [1, 2, 3, 4, 4, 4, 5, 6, 6, 7, 7, 8, 9, 10, 11, 12],k = 3) == -1\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],k = 6) == 10\n assert candidate(nums = [1, 2, 3, 3, 3, 3, 4, 5, 5, 6, 6, 7, 8, 8, 9, 10],k = 2) == -1\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 6) == 9\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 9],k = 7) == 9\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6],k = 4) == 14\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 1],k = 2) == 14\n assert candidate(nums = [2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9],k = 6) == 9\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17],k = 8) == 8\n assert candidate(nums = [3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6],k = 4) == 12\n assert candidate(nums = [1, 1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 9, 10, 11],k = 4) == 15\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 2) == 14\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 7],k = 2) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15],k = 5) == -1\n assert candidate(nums = [1, 3, 2, 6, 4, 5, 7, 8, 10, 9, 12, 11, 14, 13, 16, 15],k = 4) == 12\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 2) == 20\n assert candidate(nums = [1, 2, 2, 2, 3, 4, 5, 5, 6, 6, 6, 7, 8, 8, 9, 9],k = 3) == -1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 9],k = 4) == 13\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 14],k = 4) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12, 14, 15, 16],k = 6) == 9\n assert candidate(nums = [1, 1, 2, 2, 3, 4, 4, 5, 5, 6, 7, 8, 8, 9, 10, 11],k = 3) == -1\n assert candidate(nums = [1, 3, 3, 4, 5, 5, 6, 7, 7, 8, 8, 9, 10, 10, 11, 12],k = 4) == 15\n assert candidate(nums = [1, 3, 3, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15, 17, 17],k = 8) == 16\n assert candidate(nums = [1, 3, 3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15, 17],k = 4) == 24\n assert candidate(nums = [1, 2, 3, 4, 4, 5, 6, 6, 7, 8, 9, 9, 10, 11, 12, 12],k = 8) == 11\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 6],k = 4) == -1\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 13],k = 4) == 17\n assert candidate(nums = [2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5],k = 5) == -1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8],k = 4) == 13\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 4) == 13\n assert candidate(nums = [1, 1, 1, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 11, 11],k = 4) == 22\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],k = 4) == 13\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 4) == 12\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 6) == 8\n assert candidate(nums = [2, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 8, 8, 9],k = 3) == -1\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9],k = 8) == 8\n assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16],k = 4) == 16\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 7],k = 8) == 8\n assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == -1\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 6],k = 4) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],k = 8) == 8\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 3) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8],k = 8) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 9, 10, 11, 12, 13, 13],k = 4) == 16\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 5, 6, 6, 7, 8, 9, 9, 10, 10],k = 5) == -1\n assert candidate(nums = [3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6],k = 2) == -1\n assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 2) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 11, 11, 12, 13],k = 4) == 15\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 8) == 9\n assert candidate(nums = [6, 3, 8, 1, 3, 1, 2, 2, 4, 5, 7, 9, 10, 11, 12, 13],k = 4) == 13\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9],k = 2) == 14\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 5) == 17\n assert candidate(nums = [2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],k = 4) == 12\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 9) == 10\n assert candidate(nums = [1, 2, 3, 4, 4, 5, 6, 7, 8, 8, 9, 10, 11, 12, 13, 13],k = 4) == 16\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],k = 2) == -1\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 9) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15],k = 8) == 9\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 10, 10, 11],k = 4) == 14\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 4) == 16\n assert candidate(nums = [2, 2, 3, 4, 5, 5, 6, 6, 7, 8, 9, 10, 10, 11, 12, 12],k = 8) == 10\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 7],k = 4) == 12\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4],k = 4) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == -1\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17],k = 2) == 14\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6],k = 3) == -1\n assert candidate(nums = [1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9],k = 3) == -1\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9],k = 3) == -1\n assert candidate(nums = [1, 3, 3, 3, 3, 5, 5, 5, 7, 7, 7, 7, 9, 9, 9, 9],k = 2) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 12, 13, 14, 15, 16],k = 8) == 9\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],k = 1) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8],k = 4) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 7, 8, 9, 9, 10, 10, 11, 12, 13],k = 4) == 13\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minimumIncompatibility", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumIncompatibility(vector& nums, int k) {", "container": "Solution", "callable": "minimumIncompatibility", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1684, "task_id": "count-the-number-of-consistent-strings", "difficulty": "Easy", "problem_description": "You are given a string allowed consisting of distinct characters and an array of strings words. A string is consistent if all characters in the string appear in the string allowed.\nReturn the number of consistent strings in the array words.\n \nExample 1:\n\nInput: allowed = \"ab\", words = [\"ad\",\"bd\",\"aaab\",\"baa\",\"badab\"]\nOutput: 2\nExplanation: Strings \"aaab\" and \"baa\" are consistent since they only contain characters 'a' and 'b'.\n\nExample 2:\n\nInput: allowed = \"abc\", words = [\"a\",\"b\",\"c\",\"ab\",\"ac\",\"bc\",\"abc\"]\nOutput: 7\nExplanation: All strings are consistent.\n\nExample 3:\n\nInput: allowed = \"cad\", words = [\"cc\",\"acd\",\"b\",\"ba\",\"bac\",\"bad\",\"ac\",\"d\"]\nOutput: 4\nExplanation: Strings \"cc\", \"acd\", \"ac\", and \"d\" are consistent.\n\n \nConstraints:\n\n1 <= words.length <= 104\n1 <= allowed.length <= 26\n1 <= words[i].length <= 10\nThe characters in allowed are distinct.\nwords[i] and allowed contain only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(allowed = \"ijkl\",words = ['i', 'j', 'k', 'l', 'ij', 'ik', 'il', 'jk', 'jl', 'kl', 'ijkl']) == 11\n assert candidate(allowed = \"abcdef\",words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef']) == 6\n assert candidate(allowed = \"cad\",words = ['cc', 'acd', 'b', 'ba', 'bac', 'bad', 'ac', 'd']) == 4\n assert candidate(allowed = \"gh\",words = ['g', 'h', 'gh']) == 3\n assert candidate(allowed = \"xyz\",words = ['xy', 'yz', 'xzy', 'zxy', 'zyx', 'xyz']) == 6\n assert candidate(allowed = \"xyz\",words = ['x', 'y', 'z', 'xy', 'xz', 'yz', 'xyz']) == 7\n assert candidate(allowed = \"uvw\",words = ['u', 'v', 'w', 'uv', 'uw', 'vw', 'uvw']) == 7\n assert candidate(allowed = \"mnop\",words = ['m', 'n', 'o', 'p', 'mn', 'mo', 'mp', 'no', 'np', 'op', 'mno', 'mnp', 'mop', 'nop', 'mnop']) == 15\n assert candidate(allowed = \"mnop\",words = ['m', 'n', 'o', 'p', 'mn', 'mo', 'mp', 'no', 'np', 'op', 'mno', 'mnp', 'mop', 'nop', 'mnop']) == 15\n assert candidate(allowed = \"ab\",words = ['ad', 'bd', 'aaab', 'baa', 'badab']) == 2\n assert candidate(allowed = \"abc\",words = ['a', 'b', 'c', 'ab', 'ac', 'bc', 'abc']) == 7\n assert candidate(allowed = \"qrst\",words = ['qr', 'qs', 'qt', 'rs', 'rt', 'st', 'qrs', 'qrt', 'qst', 'rst', 'qrst']) == 11\n assert candidate(allowed = \"qwerty\",words = ['q', 'w', 'e', 'r', 't', 'y', 'qw', 'we', 'er', 'rt', 'ty', 'yq', 'qr', 're', 'et', 'ty', 'yr', 're', 'et', 'ty', 'qwer', 'wert', 'erty', 'rtye', 'tyer', 'yert', 'erty', 'rtye', 'tyer', 'yert']) == 30\n assert candidate(allowed = \"xyz\",words = ['xzy', 'zyx', 'xyzz', 'zyzzx', 'xzyzyx', 'zyzxzy', 'xyzxyz', 'zyxzyxzyx']) == 8\n assert candidate(allowed = \"abcdef\",words = ['abc', 'bcd', 'cde', 'def', 'abcf', 'bcde', 'cdef', 'abcdef', 'af', 'bf', 'cf', 'df', 'ef', 'f', 'a', 'b', 'c', 'd', 'e']) == 19\n assert candidate(allowed = \"abcdefg\",words = ['abc', 'def', 'ghi', 'abcd', 'efg', 'abdefg', 'abcdef', 'abcdefg', 'xyz']) == 7\n assert candidate(allowed = \"mnopqr\",words = ['mnop', 'opqr', 'mnqr', 'mpqr', 'mnoq', 'mnpq', 'mnopq', 'mnopqr', 'mnoqr', 'mnopqr', 'qrmpno', 'rpmnqo', 'qrmp', 'mnpqr', 'pqmno']) == 15\n assert candidate(allowed = \"xyz\",words = ['x', 'y', 'z', 'xy', 'xz', 'yz', 'xyz', 'xyzz', 'zxy', 'yxz', 'zyx', 'zzz']) == 12\n assert candidate(allowed = \"abcdef\",words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'fedcba', 'defabc', 'cbadef', 'abcdefg', 'abcdefh', 'abcdefi', 'abcdefj', 'abcdefk', 'abcdefl', 'abcdefm', 'abef', 'acd', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz', 'ab', 'bc', 'cd', 'de', 'ef', 'fg', 'gh', 'hi', 'ij', 'jk', 'kl', 'lm', 'mn', 'no', 'op', 'pq', 'qr', 'rs', 'st', 'tu', 'uv', 'vw', 'wx', 'xy', 'yz', 'za', 'abab', 'acac', 'adad', 'aeae', 'afaf', 'agag', 'ahah', 'aiai', 'ajaj', 'akak', 'alal', 'amam', 'anan', 'aoao', 'apap', 'aqaq', 'arar', 'asas', 'atat', 'auau', 'avav', 'awaw', 'axax', 'ayay', 'azaz']) == 24\n assert candidate(allowed = \"tuvwxy\",words = ['tuv', 'uvw', 'vwx', 'wxy', 'tuvw', 'uvwx', 'vwx', 'wxy', 'tuvwx', 'uvwxy', 'tuvwxy', 'tuvwxyu', 'tuvwxyv', 'tuvwxyw', 'tuvwxyx', 'tuvwxyy']) == 16\n assert candidate(allowed = \"ijklmno\",words = ['ijkl', 'ijkm', 'ilkn', 'ijln', 'ikln', 'jklm', 'jkmn', 'jlmn', 'klnm', 'ijklmnop', 'ijklmnoi', 'ijklmnopq', 'ijklmnopqrstuvwxyz', 'ijklmnolikj', 'ijklmnlijklmn', 'mnopijk', 'mnopilkmn']) == 12\n assert candidate(allowed = \"mnopqrstuvw\",words = ['mnop', 'qrstuv', 'w', 'mnopqr', 'stuvw', 'mnopqrstuvw', 'mnopqrstuvww', 'mnopqrstuvwww', 'mnopqrstuvwq', 'mnopqrstuvwqq', 'mnopqrstuvwrr', 'mnopqrstuvwsss', 'mnopqrstuvwttt', 'mnopqrstuvwuuu', 'mnopqrstuvwvvv', 'mnopqrstuvwwww']) == 16\n assert candidate(allowed = \"qrstuv\",words = ['qrst', 'uv', 'qrs', 'tu', 'rqs', 'vut', 'qrtuv', 'tuvqr', 'usvrtq', 'rqstuv', 'uvtqrs', 'qrsutv', 'rqvstu']) == 13\n assert candidate(allowed = \"pqrs\",words = ['pq', 'qr', 'rs', 'sp', 'pqrs', 'prqs', 'psrq', 'sqrp', 'rqps', 'rspq', 'pqs', 'qsr', 'rsq', 'spq', 'qrp', 'rps', 'sqr', 'prq', 'qsp', 'rqs', 'spr', 'psr', 'qrs', 'rsq', 'spq', 'pqr', 'qrs', 'rsp', 'spr', 'psr', 'srp', 'rps', 'qsp', 'psq']) == 34\n assert candidate(allowed = \"mnopqr\",words = ['mno', 'mnp', 'mqr', 'npr', 'opq', 'orq', 'pqr', 'mnop', 'mnoq', 'mnopqr', 'pqor', 'nopr', 'mnopq', 'nopqr', 'mnopqrs', 'mnoprq', 'mnopqrr', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs', 'mnopqrs']) == 16\n assert candidate(allowed = \"jklm\",words = ['jj', 'kk', 'll', 'mm', 'jk', 'jl', 'jm', 'kl', 'km', 'lm', 'jkl', 'jkm', 'jlm', 'klm', 'jklm', 'jkll', 'jjkkllmm', 'klmklm', 'jkljkl', 'mnop', 'qrst', 'uvwxy', 'z']) == 19\n assert candidate(allowed = \"klmnopqrstuvwxyz\",words = ['klmnopqrstuvwxyzz', 'klmnopqrstuvwxzz', 'klmnopqrstuvwxxz', 'klmnopqrstuvvvvv', 'klmnopqrsssssss', 'klmnopqqqqqqqq', 'klllllllllll', 'kkkkkkkkkkkk', 'jjjjjjjjjjjj', 'iiiiiiiiiiii', 'hhhhhhhhhhhh', 'gggggggggggg', 'ffffffffffff', 'eeeeeeeeeeee', 'dddddddddddd', 'cccccccccc', 'bbbbbbbbbb', 'aaaaaaaaaa']) == 8\n assert candidate(allowed = \"mno\",words = ['m', 'n', 'o', 'mn', 'no', 'om', 'mno', 'mon', 'nom', 'omn', 'nmo', 'nom', 'omn', 'mon', 'mno', 'mno', 'nom', 'omn', 'mon', 'mno', 'nom', 'omn', 'mon', 'mno', 'nom', 'omn', 'mon', 'mno', 'nom', 'omn', 'mon', 'mno']) == 32\n assert candidate(allowed = \"abcdefghij\",words = ['abcdefghij', 'abcdefghijk', 'abcdefghi', 'abcdefg', 'abcde', 'abcd', 'abc', 'ab', 'a', 'jihgfedcba', 'abcdefghijabcdefghij', 'abcdefghijabcdefghijk', 'abcdefghijabcdefghi', 'abcdefghijabcdefg', 'abcdefghijabcde', 'abcdefghijabcd', 'abcdefghijabc', 'abcdefghijab', 'abcdefghija']) == 17\n assert candidate(allowed = \"ijkl\",words = ['ij', 'kl', 'ik', 'jl', 'ikl', 'jkl', 'ijk', 'ijkl', 'ijl', 'ikjl', 'likj', 'ljk', 'lkij', 'lijk', 'ilkj', 'lkji']) == 16\n assert candidate(allowed = \"xyz\",words = ['xy', 'yz', 'xz', 'xyz', 'zyx', 'yxz', 'xzy', 'zy', 'yx', 'zx']) == 10\n assert candidate(allowed = \"xyz\",words = ['x', 'y', 'z', 'xy', 'xz', 'yz', 'xyz', 'xzy', 'yzx', 'zyx', 'zyz', 'zxz', 'yzy', 'xyx', 'xxy', 'xxz', 'xyy', 'xzz', 'yyy', 'yzz', 'zzz']) == 21\n assert candidate(allowed = \"abcdefghij\",words = ['abcdefghij', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'ab', 'cd', 'ef', 'gh', 'ij', 'abcd', 'efgh', 'ijkl', 'abcdefghi', 'abcdefgh', 'abcdefg', 'abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a', 'abcdefghijk', 'abcdefghijj', 'abcdefghiij', 'abcdefghhij', 'abcdefghiiij']) == 31\n assert candidate(allowed = \"xyz\",words = ['xyzzy', 'zyx', 'zxyx', 'zzyzxzy', 'xyzabc', 'xzyz']) == 5\n assert candidate(allowed = \"fv\",words = ['f', 'v', 'fv', 'vf', 'ff', 'vv', 'ffff', 'vvvv', 'fvfv', 'vfvf', 'fvvf', 'vvff', 'fvff', 'vvvf', 'fvvv', 'ffvv', 'f', 'v', 'fv', 'vf', 'ff', 'vv', 'ffff', 'vvvv', 'fvfv', 'vfvf', 'fvvf', 'vvff', 'fvff', 'vvvf', 'fvvv', 'ffvv', 'f', 'v', 'fv', 'vf', 'ff', 'vv', 'ffff', 'vvvv']) == 40\n assert candidate(allowed = \"qrst\",words = ['qqqq', 'rrrr', 'ssss', 'tttt', 'qqrr', 'qqss', 'qqtt', 'rrss', 'rrtt', 'sstt', 'qqrrss', 'qqrrtt', 'qqsstt', 'rrsstt', 'qqrrsstt', 'qqrrssttt']) == 16\n assert candidate(allowed = \"abcdefghij\",words = ['abcdefghij', 'abcdefghi', 'abcdefgh', 'abcdefg', 'abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a', 'abcdefghijabcdefghij', 'abcdefghijabcdefgh', 'abcdefghijabcdef', 'abcdefghijabcd', 'abcdefghijabc', 'abcdefghijab', 'abcdefghija']) == 17\n assert candidate(allowed = \"xyz\",words = ['xy', 'xz', 'yz', 'xyz', 'xx', 'yy', 'zz', 'xyx', 'yzy', 'zxz', 'xyxy', 'xzyz', 'yzxy', 'xyzx', 'xzyzx', 'yzxyz', 'xyzyx', 'zxyxz', 'yxzyz', 'zyxzy']) == 20\n assert candidate(allowed = \"abcdef\",words = ['a', 'b', 'c', 'd', 'e', 'f', 'ab', 'cd', 'ef', 'abc', 'def', 'abcdef', 'abcdefg', 'abcdefabc']) == 13\n assert candidate(allowed = \"qrstuv\",words = ['qrst', 'qrsu', 'rstuv', 'qrstu', 'quv', 'qrs', 'qrtuv', 'qru', 'quvtsr', 'quvz']) == 9\n assert candidate(allowed = \"abcdef\",words = ['abc', 'def', 'abcdef', 'aabbcc', 'ddeeff', 'abcdeff', 'abcdefg']) == 6\n assert candidate(allowed = \"ijklmnop\",words = ['ijkl', 'mnop', 'ijkm', 'klnm', 'ijlmo', 'ijkmnop', 'ijklmnopq', 'ijklmno', 'ijklnop']) == 8\n assert candidate(allowed = \"jklmno\",words = ['jk', 'kl', 'lm', 'mn', 'no', 'jkl', 'klm', 'lmn', 'mno', 'jklm', 'klmn', 'lmno', 'jklmo', 'klmno', 'jklmno', 'jklmnou', 'klmnop', 'jklmnop']) == 15\n assert candidate(allowed = \"abcdef\",words = ['abc', 'def', 'abcd', 'abef', 'acdf', 'bcde', 'acde', 'bcdf', 'abcf', 'abcdef', 'afecbd', 'fedcba']) == 12\n assert candidate(allowed = \"qrst\",words = ['q', 'r', 's', 't', 'qr', 'qs', 'qt', 'rs', 'rt', 'st', 'qrs', 'qrt', 'qst', 'rst', 'qrst']) == 15\n assert candidate(allowed = \"wxyz\",words = ['w', 'x', 'y', 'z', 'wx', 'wxyz', 'xy', 'yz', 'wxy', 'wxyz', 'wxzy', 'xywz', 'yzwx', 'zxyw']) == 14\n assert candidate(allowed = \"abcd\",words = ['a', 'b', 'c', 'd', 'ab', 'bc', 'cd', 'da', 'abc', 'bcd', 'cda', 'dab', 'abcd', 'bcda', 'cdab', 'dabc', 'abdc', 'bacd', 'cabd', 'dabc', 'acbd', 'badc', 'cabd', 'dacb', 'acdb', 'bdac', 'cadb', 'dbac', 'dcab', 'dcba']) == 30\n assert candidate(allowed = \"xyz\",words = ['xyzz', 'zyx', 'zxy', 'xxxyyyzzz', 'zzzz', 'yyyxxx', 'abc', 'xyzzyx', 'zzzxxx', 'xyxyxy']) == 9\n assert candidate(allowed = \"abcdef\",words = ['abc', 'def', 'abcdef', 'abcd', 'abcf', 'defa', 'bcde', 'fabc', 'aabbccdd', 'fedcba']) == 10\n assert candidate(allowed = \"qz\",words = ['qqqz', 'zqq', 'q', 'z', 'zzzz', 'qqqq', 'qzqz', 'zqzq', 'zzzq', 'zqqz']) == 10\n assert candidate(allowed = \"xyz\",words = ['xy', 'yz', 'xz', 'xyz', 'xzy', 'yxz', 'zxy', 'zyx', 'yzz', 'zzz']) == 10\n assert candidate(allowed = \"jkl\",words = ['j', 'k', 'l', 'jk', 'kl', 'lj', 'jkl', 'klj', 'lkj', 'kjl', 'jlk', 'lk', 'kj', 'jl', 'kl', 'jk', 'lj', 'kl', 'jl', 'kj', 'jl', 'kj', 'lk', 'jk', 'kl', 'jl', 'kj', 'lk', 'jk', 'kl', 'jl', 'kj']) == 32\n assert candidate(allowed = \"mnopqr\",words = ['mnop', 'mnopqr', 'mnopq', 'mnopqrs', 'mnopqrst', 'mnopqrstuv', 'mnopqrstu', 'mnopqrst', 'mnopqrstuvw', 'mnopqrstuvwx', 'mnopqrstuvwxy', 'mnopqrstuvwxyz', 'mno', 'pqrs', 'qrst', 'uvwx', 'vwxyz']) == 4\n assert candidate(allowed = \"uvw\",words = ['uvw', 'uv', 'uw', 'vw', 'u', 'v', 'w', 'uvvw', 'uwwv', 'vwwu', 'vvvuuuwww', 'wuvuvuvuv']) == 12\n assert candidate(allowed = \"mnopqr\",words = ['mnop', 'nopq', 'opqr', 'mnopq', 'nopqr', 'mnopqr', 'mnopqr', 'mnopqrs', 'mnopqrst', 'mnopqrstu', 'mnopqrstuv', 'mnopqrstuvw', 'mnopqrstuvwx', 'mnopqrstuvwxy', 'mnopqrstuvwxyz']) == 7\n assert candidate(allowed = \"abcdefghij\",words = ['abcde', 'fghij', 'abcdefghij', 'abcdefghi', 'efgij', 'hijabc', 'defghij', 'bcdefghij', 'abcdefghijk', 'ijabcdefgh', 'abcdeffghij', 'abcdefghijj', 'jihgfedcba', 'abcdefghijkk', 'abcdefghijjj']) == 13\n assert candidate(allowed = \"abcdef\",words = ['abc', 'def', 'abcdef', 'abcd', 'defg', 'fedcba', 'aabbccddeeff', 'zzzzz']) == 6\n assert candidate(allowed = \"abcdefghij\",words = ['abcdefghij', 'abcdefghi', 'abcdefgh', 'abcdefg', 'abcdef', 'abcde', 'abcd', 'abc', 'ab', 'a', 'abcdefghijk', 'abcdefghijj', 'abcdefghiij', 'abcdefghhij', 'abcdefghiiij', 'abcdefghijjj', 'abcdefghiiijj', 'abcdefghijjjj', 'abcdefghiiijjj', 'abcdefghijjjjj', 'abcdefghijjjjjj', 'abcdefghijjjjjjj', 'abcdefghijjjjjjjj', 'abcdefghijjjjjjjjj', 'abcdefghijjjjjjjjjj', 'abcdefghijjjjjjjjjjj', 'abcdefghijjjjjjjjjjjj', 'abcdefghijjjjjjjjjjjjj']) == 27\n assert candidate(allowed = \"abcdefg\",words = ['a', 'ab', 'abc', 'abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgi', 'abcdefgh', 'abcdefgabcdefg']) == 8\n assert candidate(allowed = \"pqrstuvw\",words = ['pqrs', 'qrst', 'rstu', 'stuv', 'tuvw', 'pqrsrstuvw', 'uvws', 'uvwpqr', 'rstuvwq', 'pqrstuvwz', 'uvwstu', 'qrpstu', 'vwstupqr']) == 12\n assert candidate(allowed = \"pqrst\",words = ['p', 'q', 'r', 's', 't', 'pq', 'qr', 'rs', 'st', 'pqrs', 'qrst', 'pqrst', 'pqrs', 'pqst', 'prst', 'qrstu', 'pqrstv']) == 15\n assert candidate(allowed = \"tuvwxy\",words = ['tu', 'tv', 'tw', 'tx', 'ty', 'tvwxy', 'uwxyt', 'wxtyv', 'xytuw', 'tuvxy', 'wxytv', 'xyzut', 'ytuvwx', 'uvxtyw', 'tuvwxyuvwx', 'txyuvw', 'ytxwuv', 'utxwvy', 'wxuytv', 'tvxyw', 'tuvwxytvwx', 'tuvwxytuvwxy']) == 21\n assert candidate(allowed = \"lmnopq\",words = ['lmn', 'opq', 'lmnop', 'lmnopq', 'pqonm', 'qlmnp', 'pqlno', 'opqmn', 'nopql', 'mnopq', 'lmnopqrr', 'plmqon', 'opqlnm', 'qponml', 'mnopql']) == 14\n assert candidate(allowed = \"xyz\",words = ['xx', 'yy', 'zz', 'xy', 'yz', 'zx', 'xyz', 'zxy', 'yxz']) == 9\n assert candidate(allowed = \"xyz\",words = ['xzy', 'zyx', 'zyzx', 'xxxyyyzzz', 'xzyxzyxzy']) == 5\n assert candidate(allowed = \"mnopqrstuvwxyz\",words = ['mnopqrstuvwxyz', 'mnopqrstuvwxy', 'mnopqrstuvwx', 'mnopqrstuvw', 'mnopqrstu', 'mnopqrst', 'mnopqrs', 'mnopqr', 'mnopq', 'mnop', 'mno', 'mn', 'm', 'nopqrstuvwxyz', 'opqrstuvwxy', 'pqrstuvwx', 'qrstuvw', 'rstuv', 'stuv', 'tuv', 'uv', 'v', 'mnopqrstuvwxyza', 'nopqrstuvwxyzb', 'mnopqrstuvwxc', 'mnopqrstuvxd', 'mnopqrstvxe', 'mnopqrsvxf', 'mnopqrvxg', 'mnopqruxh', 'mnopquxi', 'mnopqxi', 'mnopxi', 'mnoxi', 'moxi', 'moxi', 'oxi', 'oxi', 'oxiz', 'mnoxyz', 'mnopxyz', 'mnopqxyz', 'mnopqrxyz', 'mnopqrstxyz', 'mnopqrstuxyz', 'mnopqrstuvxyz', 'mnopqrstuvwxyz', 'mnopqrstuvwxyzabc', 'mnopqrstuvwxyzabcd', 'mnopqrstuvwxyzabcde', 'mnopqrstuvwxyzabcdef', 'mnopqrstuvwxyzabcdefg']) == 30\n"}, "metadata": {"canonical_parameter_names": ["allowed", "words"], "leetcode_dataset_entry_point": "Solution().countConsistentStrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countConsistentStrings(string allowed, vector& words) {", "container": "Solution", "callable": "countConsistentStrings", "parameters": [{"name": "allowed", "type": "string"}, {"name": "words", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1685, "task_id": "sum-of-absolute-differences-in-a-sorted-array", "difficulty": "Medium", "problem_description": "You are given an integer array nums sorted in non-decreasing order.\nBuild and return an integer array result with the same length as nums such that result[i] is equal to the summation of absolute differences between nums[i] and all the other elements in the array.\nIn other words, result[i] is equal to sum(|nums[i]-nums[j]|) where 0 <= j < nums.length and j != i (0-indexed).\n \nExample 1:\n\nInput: nums = [2,3,5]\nOutput: [4,3,5]\nExplanation: Assuming the arrays are 0-indexed, then\nresult[0] = |2-2| + |2-3| + |2-5| = 0 + 1 + 3 = 4,\nresult[1] = |3-2| + |3-3| + |3-5| = 1 + 0 + 2 = 3,\nresult[2] = |5-2| + |5-3| + |5-5| = 3 + 2 + 0 = 5.\n\nExample 2:\n\nInput: nums = [1,4,6,8,10]\nOutput: [24,15,13,15,21]\n\n \nConstraints:\n\n2 <= nums.length <= 105\n1 <= nums[i] <= nums[i + 1] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [100, 200, 300, 400, 500]) == [1000, 700, 600, 700, 1000]\n assert candidate(nums = [1, 1, 1, 1]) == [0, 0, 0, 0]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 4, 6, 8, 10]) == [24, 15, 13, 15, 21]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [45, 37, 31, 27, 25, 25, 27, 31, 37, 45]\n assert candidate(nums = [2, 3, 5]) == [4, 3, 5]\n assert candidate(nums = [1, 100, 1000, 10000, 100000]) == [111096, 110799, 109899, 118899, 388899]\n assert candidate(nums = [1, 2, 3, 100, 101, 102, 103, 104, 105, 106]) == [717, 709, 703, 315, 313, 313, 315, 319, 325, 333]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000]) == [1111104, 1111059, 1110789, 1109889, 1118889, 1388889, 5888889]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 5, 5, 10, 10, 15, 15, 15, 20, 20, 20, 20]) == [100, 100, 100, 70, 70, 60, 60, 60, 80, 80, 80, 80]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == [19000, 17200, 15600, 14200, 13000, 12000, 11200, 10600, 10200, 10000, 10000, 10200, 10600, 11200, 12000, 13000, 14200, 15600, 17200, 19000]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == [1111111101, 1111111029, 1111110489, 1111106889, 1111088889, 1111088889, 1112888889, 1148888889, 1688888889, 8888888889]\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == [441, 369, 309, 269, 249, 249, 269, 309, 369, 449]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == [45000, 37000, 31000, 27000, 25000, 25000, 27000, 31000, 37000, 45000]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [950, 860, 780, 710, 650, 600, 560, 530, 510, 500, 500, 510, 530, 560, 600, 650, 710, 780, 860, 950]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == [570, 516, 468, 426, 390, 360, 336, 318, 306, 300, 300, 306, 318, 336, 360, 390, 426, 468, 516, 570]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [135, 117, 101, 87, 75, 65, 57, 51, 47, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45]\n assert candidate(nums = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [10, 10, 10, 11, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]) == [137, 137, 137, 123, 123, 113, 105, 99, 95, 93, 93, 95, 99, 105, 113, 123, 135, 149, 165, 183]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == [380, 344, 312, 284, 260, 240, 224, 212, 204, 200, 200, 204, 212, 224, 240, 260, 284, 312, 344, 380]\n assert candidate(nums = [5, 11, 17, 23, 29, 35, 41, 47, 53, 59, 65, 71, 77, 83, 89, 95, 101]) == [816, 726, 648, 582, 528, 486, 456, 438, 432, 438, 456, 486, 528, 582, 648, 726, 816]\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == [30, 30, 30, 30, 30, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 30, 30, 30, 30, 30]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == [1900, 1720, 1560, 1420, 1300, 1200, 1120, 1060, 1020, 1000, 1000, 1020, 1060, 1120, 1200, 1300, 1420, 1560, 1720, 1900]\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == [210, 194, 176, 160, 150, 150, 164, 196, 250, 330]\n assert candidate(nums = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [5490, 4599, 3899, 3399, 3099, 2999, 3099, 3399, 3899, 4599, 5499]\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == [210, 194, 176, 160, 150, 150, 164, 196, 250, 330]\n assert candidate(nums = [3, 3, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 9, 9, 9, 9, 11, 11, 11, 11]) == [80, 80, 80, 80, 56, 56, 56, 56, 48, 48, 48, 48, 56, 56, 56, 56, 80, 80, 80, 80]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [90, 90, 74, 74, 62, 62, 54, 54, 50, 50, 50, 50, 54, 54, 62, 62, 74, 74, 90, 90]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == [32752, 32739, 32717, 32681, 32625, 32545, 32449, 32385, 32513, 33281, 35841, 43009, 61441, 106497, 212993]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [20, 20, 14, 14, 12, 12, 14, 14, 20, 20]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [210, 184, 162, 144, 130, 120, 114, 112, 114, 120, 130, 144, 162, 184, 210]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == [210, 184, 162, 144, 130, 120, 114, 112, 114, 120, 130, 144, 162, 184, 210]\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]) == [2567, 2554, 2543, 2525, 2504, 2479, 2455, 2442, 2463, 2565, 2840, 3463, 4759, 7322, 12223]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [450, 370, 310, 270, 250, 250, 270, 310, 370, 450]\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == [2850, 2796, 2716, 2618, 2510, 2400, 2296, 2206, 2138, 2100, 2100, 2146, 2246, 2408, 2640, 2950, 3346, 3836, 4428, 5130]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [90, 90, 74, 74, 62, 62, 54, 54, 50, 50, 50, 50, 54, 54, 62, 62, 74, 74, 90, 90]\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7]) == [15, 15, 15, 15, 15, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8]) == [130, 102, 102, 78, 78, 78, 60, 60, 60, 60, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 60, 60, 60, 60, 60, 80, 80, 80, 80, 80]\n assert candidate(nums = [5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7]) == [12, 12, 12, 12, 8, 8, 8, 8, 12, 12, 12, 12]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [90, 74, 62, 54, 50, 50, 54, 62, 74, 90]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000]) == [111105, 111069, 110889, 110889, 128889, 488889]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5]) == [24, 15, 15, 10, 10, 10, 11, 11, 11, 11, 20]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [45, 37, 31, 27, 25, 25, 27, 31, 37, 45]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [2026, 2010, 1986, 1954, 1922, 1922, 2050, 2562, 4098, 8194]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == [1900, 1720, 1560, 1420, 1300, 1200, 1120, 1060, 1020, 1000, 1000, 1020, 1060, 1120, 1200, 1300, 1420, 1560, 1720, 1900]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == [380, 344, 312, 284, 260, 240, 224, 212, 204, 200, 200, 204, 212, 224, 240, 260, 284, 312, 344, 380]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [300, 277, 256, 237, 220, 205, 192, 181, 172, 165, 160, 157, 156, 157, 160, 165, 172, 181, 192, 205, 220, 237, 256, 277, 300]\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 5, 6]) == [24, 17, 17, 14, 13, 14, 14, 14, 21]\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [540, 459, 389, 339, 309, 299, 309, 339, 389, 459, 549]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150]) == [2175, 2035, 1905, 1785, 1675, 1575, 1485, 1405, 1335, 1275, 1225, 1185, 1155, 1135, 1125, 1125, 1135, 1155, 1185, 1225, 1275, 1335, 1405, 1485, 1575, 1675, 1785, 1905, 2035, 2175]\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == [15, 15, 15, 15, 15, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == [20, 12, 12, 8, 8, 8, 10, 10, 10, 10]\n assert candidate(nums = [5000, 5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008, 5009, 5010, 5011, 5012, 5013, 5014, 5015, 5016, 5017, 5018, 5019]) == [190, 172, 156, 142, 130, 120, 112, 106, 102, 100, 100, 102, 106, 112, 120, 130, 142, 156, 172, 190]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == [275, 230, 195, 170, 155, 150, 155, 170, 195, 230, 275]\n assert candidate(nums = [1, 2, 5, 7, 9, 11, 13, 16, 18, 20, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49]) == [437, 419, 371, 343, 319, 299, 283, 265, 257, 253, 253, 259, 271, 289, 313, 343, 379, 421, 469, 523]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [1050, 920, 810, 720, 650, 600, 570, 560, 570, 600, 650, 720, 810, 920, 1050]\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [540, 459, 389, 339, 309, 299, 309, 339, 389, 459, 549]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == [45000, 37000, 31000, 27000, 25000, 25000, 27000, 31000, 37000, 45000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [190, 172, 156, 142, 130, 120, 112, 106, 102, 100, 100, 102, 106, 112, 120, 130, 142, 156, 172, 190]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == [1013, 1005, 993, 977, 961, 961, 1025, 1281, 2049, 4097]\n assert candidate(nums = [1, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == [549990, 459999, 389999, 339999, 309999, 299999, 309999, 339999, 389999, 459999, 549999]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [190, 172, 156, 142, 130, 120, 112, 106, 102, 100, 100, 102, 106, 112, 120, 130, 142, 156, 172, 190]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [105, 92, 81, 72, 65, 60, 57, 56, 57, 60, 65, 72, 81, 92, 105]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().getSumAbsoluteDifferences", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector getSumAbsoluteDifferences(vector& nums) {", "container": "Solution", "callable": "getSumAbsoluteDifferences", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1686, "task_id": "stone-game-vi", "difficulty": "Medium", "problem_description": "Alice and Bob take turns playing a game, with Alice starting first.\nThere are n stones in a pile. On each player's turn, they can remove a stone from the pile and receive points based on the stone's value. Alice and Bob may value the stones differently.\nYou are given two integer arrays of length n, aliceValues and bobValues. Each aliceValues[i] and bobValues[i] represents how Alice and Bob, respectively, value the ith stone.\nThe winner is the person with the most points after all the stones are chosen. If both players have the same amount of points, the game results in a draw. Both players will play optimally. Both players know the other's values.\nDetermine the result of the game, and:\n\nIf Alice wins, return 1.\nIf Bob wins, return -1.\nIf the game results in a draw, return 0.\n\n \nExample 1:\n\nInput: aliceValues = [1,3], bobValues = [2,1]\nOutput: 1\nExplanation:\nIf Alice takes stone 1 (0-indexed) first, Alice will receive 3 points.\nBob can only choose stone 0, and will only receive 2 points.\nAlice wins.\n\nExample 2:\n\nInput: aliceValues = [1,2], bobValues = [3,1]\nOutput: 0\nExplanation:\nIf Alice takes stone 0, and Bob takes stone 1, they will both have 1 point.\nDraw.\n\nExample 3:\n\nInput: aliceValues = [2,4,3], bobValues = [1,6,7]\nOutput: -1\nExplanation:\nRegardless of how Alice plays, Bob will be able to have more points than Alice.\nFor example, if Alice takes stone 1, Bob can take stone 2, and Alice takes stone 0, Alice will have 6 points to Bob's 7.\nBob wins.\n\n \nConstraints:\n\nn == aliceValues.length == bobValues.length\n1 <= n <= 105\n1 <= aliceValues[i], bobValues[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(aliceValues = [1, 2],bobValues = [3, 1]) == 0\n assert candidate(aliceValues = [1, 2, 3, 4, 5],bobValues = [5, 4, 3, 2, 1]) == 1\n assert candidate(aliceValues = [9, 9, 9, 9, 9],bobValues = [1, 1, 1, 1, 1]) == 1\n assert candidate(aliceValues = [5, 3, 1, 4],bobValues = [4, 1, 2, 3]) == 1\n assert candidate(aliceValues = [10, 20, 30],bobValues = [30, 20, 10]) == 1\n assert candidate(aliceValues = [1, 3],bobValues = [2, 1]) == 1\n assert candidate(aliceValues = [2, 2, 2, 2, 2],bobValues = [3, 3, 3, 3, 3]) == 0\n assert candidate(aliceValues = [1, 1, 1, 1],bobValues = [1, 1, 1, 1]) == 0\n assert candidate(aliceValues = [1, 1, 1, 1, 1],bobValues = [9, 9, 9, 9, 9]) == -1\n assert candidate(aliceValues = [7, 8, 9],bobValues = [9, 8, 7]) == 1\n assert candidate(aliceValues = [2, 4, 3],bobValues = [1, 6, 7]) == -1\n assert candidate(aliceValues = [10, 10, 10, 10],bobValues = [10, 10, 10, 10]) == 0\n assert candidate(aliceValues = [5, 3, 8, 2],bobValues = [4, 1, 7, 3]) == 1\n assert candidate(aliceValues = [100, 100, 100],bobValues = [100, 100, 100]) == 1\n assert candidate(aliceValues = [99, 98, 97],bobValues = [1, 2, 3]) == 1\n assert candidate(aliceValues = [100, 1, 1, 1],bobValues = [1, 100, 1, 1]) == 0\n assert candidate(aliceValues = [30, 20, 10],bobValues = [10, 20, 30]) == 1\n assert candidate(aliceValues = [5, 5, 5, 5],bobValues = [5, 5, 5, 5]) == 0\n assert candidate(aliceValues = [1, 1, 1, 1, 1],bobValues = [1, 1, 1, 1, 1]) == 1\n assert candidate(aliceValues = [99, 1, 99, 1, 99, 1],bobValues = [1, 99, 1, 99, 1, 99]) == 0\n assert candidate(aliceValues = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100],bobValues = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 0\n assert candidate(aliceValues = [80, 70, 60, 50, 40, 30, 20, 10],bobValues = [10, 20, 30, 40, 50, 60, 70, 80]) == 0\n assert candidate(aliceValues = [99, 50, 25, 10, 5],bobValues = [1, 1, 1, 1, 1]) == 1\n assert candidate(aliceValues = [100, 50, 25, 12, 6],bobValues = [5, 20, 40, 60, 80]) == 1\n assert candidate(aliceValues = [100, 1, 100, 1, 100],bobValues = [1, 100, 1, 100, 1]) == 1\n assert candidate(aliceValues = [5, 8, 7, 12, 9],bobValues = [4, 6, 5, 10, 7]) == 1\n assert candidate(aliceValues = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],bobValues = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(aliceValues = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],bobValues = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 1\n assert candidate(aliceValues = [3, 2, 3, 4, 5],bobValues = [5, 4, 3, 2, 3]) == 1\n assert candidate(aliceValues = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],bobValues = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(aliceValues = [100, 1, 1, 1, 1, 1, 1, 1, 1, 1],bobValues = [1, 1, 1, 1, 1, 1, 1, 1, 1, 100]) == 0\n assert candidate(aliceValues = [50, 30, 20],bobValues = [1, 20, 30]) == 1\n assert candidate(aliceValues = [100, 99, 98, 97, 96],bobValues = [95, 94, 93, 92, 91]) == 1\n assert candidate(aliceValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],bobValues = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(aliceValues = [5, 5, 5, 5],bobValues = [6, 6, 6, 6]) == -1\n assert candidate(aliceValues = [1, 5, 9, 13, 17],bobValues = [16, 12, 8, 4, 0]) == 1\n assert candidate(aliceValues = [23, 45, 67, 89, 10],bobValues = [10, 89, 67, 45, 23]) == 1\n assert candidate(aliceValues = [23, 45, 67, 89, 12],bobValues = [12, 89, 67, 45, 23]) == 1\n assert candidate(aliceValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],bobValues = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(aliceValues = [50, 30, 20, 10, 1],bobValues = [10, 20, 30, 40, 50]) == 1\n assert candidate(aliceValues = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],bobValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(aliceValues = [99, 98, 97, 96, 95],bobValues = [1, 2, 3, 4, 5]) == 1\n assert candidate(aliceValues = [50, 50, 50, 50, 50],bobValues = [50, 50, 50, 50, 50]) == 1\n assert candidate(aliceValues = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],bobValues = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5]) == 0\n assert candidate(aliceValues = [5, 2, 3, 3, 4],bobValues = [4, 3, 2, 3, 5]) == 1\n assert candidate(aliceValues = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],bobValues = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 1\n assert candidate(aliceValues = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],bobValues = [75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 1\n assert candidate(aliceValues = [100, 50, 25, 10, 5],bobValues = [5, 10, 25, 50, 100]) == 1\n assert candidate(aliceValues = [30, 20, 10, 50, 40, 60, 70],bobValues = [70, 60, 50, 40, 30, 20, 10]) == 1\n assert candidate(aliceValues = [50, 50, 50],bobValues = [100, 100, 100]) == 0\n assert candidate(aliceValues = [99, 1, 98, 2, 97, 3, 96, 4, 95, 5],bobValues = [5, 95, 4, 96, 3, 97, 2, 98, 1, 99]) == 0\n assert candidate(aliceValues = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86],bobValues = [86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 1\n assert candidate(aliceValues = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],bobValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(aliceValues = [100, 100, 100, 100, 100],bobValues = [99, 99, 99, 99, 99]) == 1\n assert candidate(aliceValues = [80, 20, 60, 40, 100, 50, 70],bobValues = [70, 50, 100, 60, 20, 40, 80]) == 1\n assert candidate(aliceValues = [7, 14, 21, 28, 35, 42],bobValues = [6, 12, 18, 24, 30, 36]) == 1\n assert candidate(aliceValues = [10, 10, 10, 10],bobValues = [20, 20, 20, 20]) == -1\n assert candidate(aliceValues = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],bobValues = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 0\n assert candidate(aliceValues = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],bobValues = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(aliceValues = [100, 90, 80, 70, 60],bobValues = [60, 70, 80, 90, 100]) == 1\n assert candidate(aliceValues = [100, 100, 1, 1, 1],bobValues = [1, 1, 100, 100, 100]) == 1\n assert candidate(aliceValues = [2, 4, 6, 8, 10],bobValues = [1, 3, 5, 7, 9]) == 1\n assert candidate(aliceValues = [5, 15, 25, 35, 45, 55],bobValues = [55, 45, 35, 25, 15, 5]) == 0\n assert candidate(aliceValues = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],bobValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(aliceValues = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],bobValues = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 0\n assert candidate(aliceValues = [100, 100, 100, 100, 100],bobValues = [50, 50, 50, 50, 50]) == 1\n assert candidate(aliceValues = [90, 20, 30, 10, 50],bobValues = [50, 90, 10, 30, 20]) == 1\n assert candidate(aliceValues = [10, 10, 10, 10, 10, 10],bobValues = [9, 9, 9, 9, 9, 9]) == 1\n assert candidate(aliceValues = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],bobValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(aliceValues = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],bobValues = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(aliceValues = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],bobValues = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(aliceValues = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],bobValues = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1\n assert candidate(aliceValues = [100, 1, 2, 3, 4],bobValues = [1, 100, 2, 3, 4]) == 1\n assert candidate(aliceValues = [100, 1, 50, 25, 75],bobValues = [90, 99, 5, 20, 70]) == 1\n assert candidate(aliceValues = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],bobValues = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 0\n assert candidate(aliceValues = [90, 90, 90, 90, 90, 90, 90, 90, 90, 90],bobValues = [91, 91, 91, 91, 91, 91, 91, 91, 91, 91]) == -1\n assert candidate(aliceValues = [2, 3, 5, 7, 11],bobValues = [11, 7, 5, 3, 2]) == 1\n assert candidate(aliceValues = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],bobValues = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(aliceValues = [30, 30, 30, 30, 30],bobValues = [30, 30, 30, 30, 30]) == 1\n assert candidate(aliceValues = [30, 20, 10],bobValues = [10, 20, 30]) == 1\n assert candidate(aliceValues = [10, 1, 10, 1, 10, 1, 10, 1],bobValues = [1, 10, 1, 10, 1, 10, 1, 10]) == 0\n assert candidate(aliceValues = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],bobValues = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 0\n assert candidate(aliceValues = [1, 3, 5, 7, 9, 11, 13],bobValues = [2, 4, 6, 8, 10, 12, 14]) == 1\n assert candidate(aliceValues = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],bobValues = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == -1\n assert candidate(aliceValues = [10, 20, 30, 40, 50],bobValues = [50, 40, 30, 20, 10]) == 1\n assert candidate(aliceValues = [50, 50, 50, 50, 50],bobValues = [40, 40, 40, 40, 60]) == 1\n assert candidate(aliceValues = [50, 40, 30, 20, 10, 10, 20, 30, 40, 50],bobValues = [10, 20, 30, 40, 50, 50, 40, 30, 20, 10]) == 0\n assert candidate(aliceValues = [99, 1, 2, 3, 4],bobValues = [4, 3, 2, 1, 99]) == 1\n assert candidate(aliceValues = [50, 40, 30, 20, 10],bobValues = [10, 20, 30, 40, 50]) == 1\n assert candidate(aliceValues = [10, 30, 20, 50, 40],bobValues = [40, 20, 30, 10, 50]) == 1\n assert candidate(aliceValues = [50, 50, 50, 50, 50],bobValues = [50, 50, 50, 50, 51]) == 1\n assert candidate(aliceValues = [5, 15, 25, 35, 45, 55, 65],bobValues = [65, 55, 45, 35, 25, 15, 5]) == 1\n assert candidate(aliceValues = [10, 20, 30, 40, 50],bobValues = [50, 40, 30, 20, 10]) == 1\n assert candidate(aliceValues = [50, 25, 50, 75, 25],bobValues = [75, 50, 25, 25, 50]) == 1\n assert candidate(aliceValues = [1, 1, 1, 2, 2, 2, 3, 3, 3],bobValues = [3, 3, 3, 2, 2, 2, 1, 1, 1]) == 1\n assert candidate(aliceValues = [100, 1, 1, 1, 1],bobValues = [1, 1, 1, 1, 100]) == 1\n assert candidate(aliceValues = [90, 80, 70, 60, 50, 40, 30, 20, 10],bobValues = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 1\n assert candidate(aliceValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],bobValues = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(aliceValues = [90, 10, 90, 10, 90],bobValues = [10, 90, 10, 90, 10]) == 1\n assert candidate(aliceValues = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],bobValues = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(aliceValues = [42, 23, 17, 5, 99],bobValues = [99, 5, 17, 23, 42]) == 1\n assert candidate(aliceValues = [100, 50, 1, 1, 1, 1, 1, 1, 1, 1],bobValues = [1, 1, 99, 99, 99, 99, 99, 99, 99, 99]) == -1\n assert candidate(aliceValues = [30, 40, 50, 60, 70, 80, 90, 100, 110, 120],bobValues = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1\n assert candidate(aliceValues = [70, 60, 50, 40, 30, 20, 10],bobValues = [10, 20, 30, 40, 50, 60, 70]) == 1\n assert candidate(aliceValues = [90, 10, 20, 30, 40, 50, 60, 70, 80],bobValues = [10, 90, 80, 70, 60, 50, 40, 30, 20]) == 1\n assert candidate(aliceValues = [100],bobValues = [1]) == 1\n"}, "metadata": {"canonical_parameter_names": ["aliceValues", "bobValues"], "leetcode_dataset_entry_point": "Solution().stoneGameVI", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int stoneGameVI(vector& aliceValues, vector& bobValues) {", "container": "Solution", "callable": "stoneGameVI", "parameters": [{"name": "aliceValues", "type": "vector&"}, {"name": "bobValues", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1687, "task_id": "delivering-boxes-from-storage-to-ports", "difficulty": "Hard", "problem_description": "You have the task of delivering some boxes from storage to their ports using only one ship. However, this ship has a limit on the number of boxes and the total weight that it can carry.\nYou are given an array boxes, where boxes[i] = [ports​​i​, weighti], and three integers portsCount, maxBoxes, and maxWeight.\n\nports​​i is the port where you need to deliver the ith box and weightsi is the weight of the ith box.\nportsCount is the number of ports.\nmaxBoxes and maxWeight are the respective box and weight limits of the ship.\n\nThe boxes need to be delivered in the order they are given. The ship will follow these steps:\n\nThe ship will take some number of boxes from the boxes queue, not violating the maxBoxes and maxWeight constraints.\nFor each loaded box in order, the ship will make a trip to the port the box needs to be delivered to and deliver it. If the ship is already at the correct port, no trip is needed, and the box can immediately be delivered.\nThe ship then makes a return trip to storage to take more boxes from the queue.\n\nThe ship must end at storage after all the boxes have been delivered.\nReturn the minimum number of trips the ship needs to make to deliver all boxes to their respective ports.\n \nExample 1:\n\nInput: boxes = [[1,1],[2,1],[1,1]], portsCount = 2, maxBoxes = 3, maxWeight = 3\nOutput: 4\nExplanation: The optimal strategy is as follows: \n- The ship takes all the boxes in the queue, goes to port 1, then port 2, then port 1 again, then returns to storage. 4 trips.\nSo the total number of trips is 4.\nNote that the first and third boxes cannot be delivered together because the boxes need to be delivered in order (i.e. the second box needs to be delivered at port 2 before the third box).\n\nExample 2:\n\nInput: boxes = [[1,2],[3,3],[3,1],[3,1],[2,4]], portsCount = 3, maxBoxes = 3, maxWeight = 6\nOutput: 6\nExplanation: The optimal strategy is as follows: \n- The ship takes the first box, goes to port 1, then returns to storage. 2 trips.\n- The ship takes the second, third and fourth boxes, goes to port 3, then returns to storage. 2 trips.\n- The ship takes the fifth box, goes to port 2, then returns to storage. 2 trips.\nSo the total number of trips is 2 + 2 + 2 = 6.\n\nExample 3:\n\nInput: boxes = [[1,4],[1,2],[2,1],[2,1],[3,2],[3,4]], portsCount = 3, maxBoxes = 6, maxWeight = 7\nOutput: 6\nExplanation: The optimal strategy is as follows:\n- The ship takes the first and second boxes, goes to port 1, then returns to storage. 2 trips.\n- The ship takes the third and fourth boxes, goes to port 2, then returns to storage. 2 trips.\n- The ship takes the fifth and sixth boxes, goes to port 3, then returns to storage. 2 trips.\nSo the total number of trips is 2 + 2 + 2 = 6.\n\n \nConstraints:\n\n1 <= boxes.length <= 105\n1 <= portsCount, maxBoxes, maxWeight <= 105\n1 <= ports​​i <= portsCount\n1 <= weightsi <= maxWeight\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(boxes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],portsCount = 1,maxBoxes = 5,maxWeight = 5) == 4\n assert candidate(boxes = [[2, 2], [2, 2], [3, 3], [3, 3], [4, 4], [4, 4]],portsCount = 4,maxBoxes = 2,maxWeight = 4) == 10\n assert candidate(boxes = [[1, 2], [2, 2], [1, 2], [2, 2], [1, 2]],portsCount = 2,maxBoxes = 3,maxWeight = 6) == 7\n assert candidate(boxes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],portsCount = 5,maxBoxes = 1,maxWeight = 5) == 10\n assert candidate(boxes = [[1, 5], [1, 5], [1, 5], [2, 5], [2, 5], [2, 5]],portsCount = 2,maxBoxes = 2,maxWeight = 10) == 7\n assert candidate(boxes = [[1, 5], [2, 5], [1, 5], [2, 5], [1, 5], [2, 5]],portsCount = 2,maxBoxes = 2,maxWeight = 10) == 9\n assert candidate(boxes = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]],portsCount = 15,maxBoxes = 5,maxWeight = 15) == 18\n assert candidate(boxes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],portsCount = 5,maxBoxes = 5,maxWeight = 15) == 12\n assert candidate(boxes = [[1, 2], [2, 2], [1, 2], [2, 2], [1, 2], [2, 2], [1, 2], [2, 2], [1, 2], [2, 2]],portsCount = 2,maxBoxes = 4,maxWeight = 10) == 13\n assert candidate(boxes = [[1, 1], [2, 1], [1, 1]],portsCount = 2,maxBoxes = 3,maxWeight = 3) == 4\n assert candidate(boxes = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1]],portsCount = 5,maxBoxes = 5,maxWeight = 5) == 6\n assert candidate(boxes = [[1, 100], [2, 100], [3, 100], [4, 100], [5, 100]],portsCount = 5,maxBoxes = 5,maxWeight = 500) == 6\n assert candidate(boxes = [[2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [2, 2], [3, 3]],portsCount = 5,maxBoxes = 3,maxWeight = 10) == 10\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],portsCount = 5,maxBoxes = 3,maxWeight = 30) == 7\n assert candidate(boxes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],portsCount = 9,maxBoxes = 3,maxWeight = 15) == 13\n assert candidate(boxes = [[1, 5], [2, 3], [3, 2], [2, 1], [1, 4]],portsCount = 3,maxBoxes = 5,maxWeight = 15) == 6\n assert candidate(boxes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],portsCount = 1,maxBoxes = 2,maxWeight = 2) == 6\n assert candidate(boxes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],portsCount = 1,maxBoxes = 3,maxWeight = 5) == 4\n assert candidate(boxes = [[1, 4], [1, 2], [2, 1], [2, 1], [3, 2], [3, 4]],portsCount = 3,maxBoxes = 6,maxWeight = 7) == 6\n assert candidate(boxes = [[1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [3, 3], [4, 4], [4, 4], [5, 5], [5, 5]],portsCount = 5,maxBoxes = 3,maxWeight = 5) == 16\n assert candidate(boxes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],portsCount = 10,maxBoxes = 10,maxWeight = 55) == 11\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10]],portsCount = 3,maxBoxes = 2,maxWeight = 20) == 5\n assert candidate(boxes = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]],portsCount = 5,maxBoxes = 2,maxWeight = 10) == 8\n assert candidate(boxes = [[1, 3], [1, 3], [1, 3], [1, 3], [1, 3]],portsCount = 1,maxBoxes = 3,maxWeight = 9) == 4\n assert candidate(boxes = [[1, 3], [2, 5], [3, 7], [4, 9]],portsCount = 4,maxBoxes = 2,maxWeight = 12) == 7\n assert candidate(boxes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],portsCount = 5,maxBoxes = 2,maxWeight = 5) == 9\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],portsCount = 5,maxBoxes = 5,maxWeight = 50) == 6\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],portsCount = 5,maxBoxes = 5,maxWeight = 25) == 8\n assert candidate(boxes = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]],portsCount = 5,maxBoxes = 2,maxWeight = 5) == 10\n assert candidate(boxes = [[5, 5], [4, 4], [3, 3], [2, 2], [1, 1]],portsCount = 5,maxBoxes = 5,maxWeight = 15) == 6\n assert candidate(boxes = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2]],portsCount = 5,maxBoxes = 2,maxWeight = 4) == 8\n assert candidate(boxes = [[1, 5], [2, 2], [3, 3], [1, 1]],portsCount = 3,maxBoxes = 3,maxWeight = 11) == 6\n assert candidate(boxes = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [7, 3], [8, 3], [9, 3], [10, 3]],portsCount = 10,maxBoxes = 10,maxWeight = 30) == 11\n assert candidate(boxes = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3]],portsCount = 5,maxBoxes = 5,maxWeight = 15) == 6\n assert candidate(boxes = [[1, 3], [2, 2], [3, 1]],portsCount = 3,maxBoxes = 5,maxWeight = 6) == 4\n assert candidate(boxes = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],portsCount = 10,maxBoxes = 1,maxWeight = 1) == 20\n assert candidate(boxes = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3]],portsCount = 5,maxBoxes = 5,maxWeight = 15) == 12\n assert candidate(boxes = [[1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [3, 3], [4, 4], [4, 4], [5, 5], [5, 5]],portsCount = 5,maxBoxes = 2,maxWeight = 4) == 0\n assert candidate(boxes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],portsCount = 1,maxBoxes = 5,maxWeight = 10) == 4\n assert candidate(boxes = [[1, 3], [2, 2], [1, 4], [2, 2], [3, 1]],portsCount = 3,maxBoxes = 3,maxWeight = 10) == 7\n assert candidate(boxes = [[1, 5], [1, 5], [1, 5], [1, 5], [1, 5]],portsCount = 1,maxBoxes = 5,maxWeight = 25) == 2\n assert candidate(boxes = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]],portsCount = 10,maxBoxes = 5,maxWeight = 10) == 12\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],portsCount = 5,maxBoxes = 5,maxWeight = 30) == 7\n assert candidate(boxes = [[1, 5], [2, 5], [3, 5], [4, 5]],portsCount = 4,maxBoxes = 4,maxWeight = 20) == 5\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [1, 10], [2, 10], [3, 10]],portsCount = 3,maxBoxes = 3,maxWeight = 20) == 9\n assert candidate(boxes = [[1, 5], [1, 5], [2, 5], [2, 5], [3, 5], [3, 5]],portsCount = 3,maxBoxes = 3,maxWeight = 15) == 6\n assert candidate(boxes = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],portsCount = 5,maxBoxes = 2,maxWeight = 100) == 8\n assert candidate(boxes = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]],portsCount = 1,maxBoxes = 5,maxWeight = 15) == 2\n assert candidate(boxes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],portsCount = 1,maxBoxes = 5,maxWeight = 5) == 2\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],portsCount = 5,maxBoxes = 5,maxWeight = 40) == 7\n assert candidate(boxes = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5]],portsCount = 10,maxBoxes = 5,maxWeight = 15) == 2\n assert candidate(boxes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]],portsCount = 7,maxBoxes = 4,maxWeight = 8) == 12\n assert candidate(boxes = [[1, 3], [1, 3], [2, 3], [2, 3], [3, 3], [3, 3]],portsCount = 3,maxBoxes = 4,maxWeight = 9) == 6\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],portsCount = 5,maxBoxes = 1,maxWeight = 10) == 10\n assert candidate(boxes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],portsCount = 5,maxBoxes = 5,maxWeight = 15) == 6\n assert candidate(boxes = [[2, 3], [2, 3], [3, 2], [3, 2], [3, 2]],portsCount = 3,maxBoxes = 2,maxWeight = 5) == 7\n assert candidate(boxes = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5]],portsCount = 5,maxBoxes = 10,maxWeight = 50) == 11\n assert candidate(boxes = [[1, 5], [2, 2], [3, 1], [4, 4], [5, 3]],portsCount = 5,maxBoxes = 2,maxWeight = 10) == 8\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [2, 10], [1, 10]],portsCount = 3,maxBoxes = 2,maxWeight = 20) == 8\n assert candidate(boxes = [[1, 3], [2, 3], [3, 3], [2, 3], [1, 3]],portsCount = 3,maxBoxes = 2,maxWeight = 9) == 8\n assert candidate(boxes = [[1, 2], [3, 3], [3, 1], [3, 1], [2, 4]],portsCount = 3,maxBoxes = 3,maxWeight = 6) == 6\n assert candidate(boxes = [[1, 5], [2, 5], [1, 5], [2, 5], [1, 5], [2, 5], [1, 5], [2, 5], [1, 5], [2, 5]],portsCount = 2,maxBoxes = 5,maxWeight = 25) == 12\n assert candidate(boxes = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],portsCount = 5,maxBoxes = 2,maxWeight = 20) == 8\n assert candidate(boxes = [[1, 5], [2, 3], [3, 2], [4, 1], [2, 2]],portsCount = 4,maxBoxes = 5,maxWeight = 10) == 7\n assert candidate(boxes = [[1, 3], [2, 2], [3, 2], [4, 2], [5, 2]],portsCount = 5,maxBoxes = 3,maxWeight = 5) == 8\n assert candidate(boxes = [[1, 5], [2, 5], [1, 5], [2, 5], [1, 5]],portsCount = 2,maxBoxes = 3,maxWeight = 15) == 7\n assert candidate(boxes = [[1, 5], [2, 6], [3, 7]],portsCount = 3,maxBoxes = 2,maxWeight = 12) == 5\n assert candidate(boxes = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],portsCount = 10,maxBoxes = 10,maxWeight = 10) == 11\n assert candidate(boxes = [[2, 5], [2, 4], [5, 1], [5, 1], [5, 1], [1, 5], [1, 5], [1, 5], [1, 5], [5, 1]],portsCount = 5,maxBoxes = 5,maxWeight = 10) == 10\n assert candidate(boxes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],portsCount = 1,maxBoxes = 2,maxWeight = 2) == 6\n assert candidate(boxes = [[1, 5], [2, 3], [3, 2], [4, 1], [2, 2]],portsCount = 4,maxBoxes = 4,maxWeight = 10) == 7\n assert candidate(boxes = [[1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [3, 3]],portsCount = 3,maxBoxes = 3,maxWeight = 10) == 6\n assert candidate(boxes = [[1, 10], [1, 10], [1, 10], [1, 10]],portsCount = 1,maxBoxes = 2,maxWeight = 20) == 4\n assert candidate(boxes = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],portsCount = 10,maxBoxes = 5,maxWeight = 5) == 12\n assert candidate(boxes = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]],portsCount = 5,maxBoxes = 1,maxWeight = 5) == 10\n assert candidate(boxes = [[2, 10], [2, 10], [3, 10], [3, 10]],portsCount = 3,maxBoxes = 3,maxWeight = 20) == 4\n"}, "metadata": {"canonical_parameter_names": ["boxes", "portsCount", "maxBoxes", "maxWeight"], "leetcode_dataset_entry_point": "Solution().boxDelivering", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int boxDelivering(vector>& boxes, int portsCount, int maxBoxes, int maxWeight) {", "container": "Solution", "callable": "boxDelivering", "parameters": [{"name": "boxes", "type": "vector>&"}, {"name": "portsCount", "type": "int"}, {"name": "maxBoxes", "type": "int"}, {"name": "maxWeight", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1688, "task_id": "count-of-matches-in-tournament", "difficulty": "Easy", "problem_description": "You are given an integer n, the number of teams in a tournament that has strange rules:\n\nIf the current number of teams is even, each team gets paired with another team. A total of n / 2 matches are played, and n / 2 teams advance to the next round.\nIf the current number of teams is odd, one team randomly advances in the tournament, and the rest gets paired. A total of (n - 1) / 2 matches are played, and (n - 1) / 2 + 1 teams advance to the next round.\n\nReturn the number of matches played in the tournament until a winner is decided.\n \nExample 1:\n\nInput: n = 7\nOutput: 6\nExplanation: Details of the tournament: \n- 1st Round: Teams = 7, Matches = 3, and 4 teams advance.\n- 2nd Round: Teams = 4, Matches = 2, and 2 teams advance.\n- 3rd Round: Teams = 2, Matches = 1, and 1 team is declared the winner.\nTotal number of matches = 3 + 2 + 1 = 6.\n\nExample 2:\n\nInput: n = 14\nOutput: 13\nExplanation: Details of the tournament:\n- 1st Round: Teams = 14, Matches = 7, and 7 teams advance.\n- 2nd Round: Teams = 7, Matches = 3, and 4 teams advance.\n- 3rd Round: Teams = 4, Matches = 2, and 2 teams advance.\n- 4th Round: Teams = 2, Matches = 1, and 1 team is declared the winner.\nTotal number of matches = 7 + 3 + 2 + 1 = 13.\n\n \nConstraints:\n\n1 <= n <= 200\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == 2\n assert candidate(n = 100) == 99\n assert candidate(n = 14) == 13\n assert candidate(n = 200) == 199\n assert candidate(n = 17) == 16\n assert candidate(n = 2) == 1\n assert candidate(n = 199) == 198\n assert candidate(n = 1) == 0\n assert candidate(n = 7) == 6\n assert candidate(n = 13) == 12\n assert candidate(n = 97) == 96\n assert candidate(n = 63) == 62\n assert candidate(n = 29) == 28\n assert candidate(n = 45) == 44\n assert candidate(n = 135) == 134\n assert candidate(n = 183) == 182\n assert candidate(n = 49) == 48\n assert candidate(n = 130) == 129\n assert candidate(n = 163) == 162\n assert candidate(n = 111) == 110\n assert candidate(n = 10) == 9\n assert candidate(n = 197) == 196\n assert candidate(n = 50) == 49\n assert candidate(n = 157) == 156\n assert candidate(n = 5) == 4\n assert candidate(n = 123) == 122\n assert candidate(n = 59) == 58\n assert candidate(n = 87) == 86\n assert candidate(n = 173) == 172\n assert candidate(n = 4) == 3\n assert candidate(n = 99) == 98\n assert candidate(n = 16) == 15\n assert candidate(n = 177) == 176\n assert candidate(n = 64) == 63\n assert candidate(n = 33) == 32\n assert candidate(n = 143) == 142\n assert candidate(n = 98) == 97\n assert candidate(n = 73) == 72\n assert candidate(n = 133) == 132\n assert candidate(n = 175) == 174\n assert candidate(n = 128) == 127\n assert candidate(n = 101) == 100\n assert candidate(n = 181) == 180\n assert candidate(n = 8) == 7\n assert candidate(n = 131) == 130\n assert candidate(n = 27) == 26\n assert candidate(n = 169) == 168\n assert candidate(n = 32) == 31\n assert candidate(n = 149) == 148\n assert candidate(n = 127) == 126\n assert candidate(n = 81) == 80\n assert candidate(n = 150) == 149\n assert candidate(n = 151) == 150\n assert candidate(n = 198) == 197\n assert candidate(n = 11) == 10\n assert candidate(n = 15) == 14\n assert candidate(n = 189) == 188\n assert candidate(n = 85) == 84\n assert candidate(n = 31) == 30\n assert candidate(n = 25) == 24\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().numberOfMatches", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numberOfMatches(int n) {", "container": "Solution", "callable": "numberOfMatches", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1689, "task_id": "partitioning-into-minimum-number-of-deci-binary-numbers", "difficulty": "Medium", "problem_description": "A decimal number is called deci-binary if each of its digits is either 0 or 1 without any leading zeros. For example, 101 and 1100 are deci-binary, while 112 and 3001 are not.\nGiven a string n that represents a positive decimal integer, return the minimum number of positive deci-binary numbers needed so that they sum up to n.\n \nExample 1:\n\nInput: n = \"32\"\nOutput: 3\nExplanation: 10 + 11 + 11 = 32\n\nExample 2:\n\nInput: n = \"82734\"\nOutput: 8\n\nExample 3:\n\nInput: n = \"27346209830709182346\"\nOutput: 9\n\n \nConstraints:\n\n1 <= n.length <= 105\nn consists of only digits.\nn does not contain any leading zeros and represents a positive integer.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = \"9876543210\") == 9\n assert candidate(n = \"111\") == 1\n assert candidate(n = \"123456789\") == 9\n assert candidate(n = \"1\") == 1\n assert candidate(n = \"82734\") == 8\n assert candidate(n = \"32\") == 3\n assert candidate(n = \"11111\") == 1\n assert candidate(n = \"555555555\") == 5\n assert candidate(n = \"9\") == 9\n assert candidate(n = \"27346209830709182346\") == 9\n assert candidate(n = \"1000000000\") == 1\n assert candidate(n = \"55555\") == 5\n assert candidate(n = \"987654321\") == 9\n assert candidate(n = \"987654321098765432109876543210\") == 9\n assert candidate(n = \"1999199919991999199919991999199919991999199919991999\") == 9\n assert candidate(n = \"11111111112222222222333333333333444444444444555555555\") == 5\n assert candidate(n = \"111999888777666555444333222111\") == 9\n assert candidate(n = \"8888888888888888888888888888888888888888\") == 8\n assert candidate(n = \"87654321098765432109\") == 9\n assert candidate(n = \"999999999\") == 9\n assert candidate(n = \"11111111111111111111\") == 1\n assert candidate(n = \"11111111111111111111111111111111111111111111111111111111111111111111111111111111111\") == 1\n assert candidate(n = \"999999999999999999999999999999\") == 9\n assert candidate(n = \"44444444444444444444444444444444444444444444444444\") == 4\n assert candidate(n = \"101010101010101010101010101010\") == 1\n assert candidate(n = \"5432105432105432105432105432105432105432105432105432\") == 5\n assert candidate(n = \"10000000000000000000\") == 1\n assert candidate(n = \"19191919191919191919\") == 9\n assert candidate(n = \"77777777777777777777777777777777777777777777777777\") == 7\n assert candidate(n = \"222222222222222222222222222222222222222222222222222\") == 2\n assert candidate(n = \"99999999999999999999\") == 9\n assert candidate(n = \"8456391728391657813265813265\") == 9\n assert candidate(n = \"9999999999\") == 9\n assert candidate(n = \"918273645091827364509182736450\") == 9\n assert candidate(n = \"12345678901234567890\") == 9\n assert candidate(n = \"9999111199991111999911119999111199991111999911119999\") == 9\n assert candidate(n = \"19191919191919191919191919191919191919191919191919191919191919191919191919191919\") == 9\n assert candidate(n = \"10000000000000000000000000000000000000000000\") == 1\n assert candidate(n = \"55555555555555555555\") == 5\n assert candidate(n = \"888888888888888888888888888888888888888888888888888\") == 8\n assert candidate(n = \"99999\") == 9\n assert candidate(n = \"1111111111\") == 1\n assert candidate(n = \"987654321012345678987654321\") == 9\n assert candidate(n = \"10101010101010101010101010101010\") == 1\n assert candidate(n = \"24681357924681357924\") == 9\n assert candidate(n = \"123456789876543210000000000000000000000000000000000\") == 9\n assert candidate(n = \"12345678987654321\") == 9\n assert candidate(n = \"10101010101010101010\") == 1\n assert candidate(n = \"111222333444555666777888999\") == 9\n assert candidate(n = \"18181818181818181818\") == 8\n assert candidate(n = \"13579135791357913579\") == 9\n assert candidate(n = \"101010101010101010101010101\") == 1\n assert candidate(n = \"100000000000000000000000000000\") == 1\n assert candidate(n = \"765432101023456765432101023456765432101023456765432\") == 7\n assert candidate(n = \"8765432109876543210987654321\") == 9\n assert candidate(n = \"918273645432187654321\") == 9\n assert candidate(n = \"2468135791113151719\") == 9\n assert candidate(n = \"1234567890\") == 9\n assert candidate(n = \"22222222222222222222\") == 2\n assert candidate(n = \"98765432109876543210\") == 9\n assert candidate(n = \"123123123123123123123123123\") == 3\n assert candidate(n = \"191919191919191919191919191919191919191919191919191\") == 9\n assert candidate(n = \"24680246802468024680\") == 8\n assert candidate(n = \"111122223333444455556666777788889999\") == 9\n assert candidate(n = \"50505050505050505050505050505050505050505050\") == 5\n assert candidate(n = \"123456789012345678901234567890\") == 9\n assert candidate(n = \"50000000000000000005\") == 5\n assert candidate(n = \"5555555555\") == 5\n assert candidate(n = \"192837465056473829109876543210\") == 9\n assert candidate(n = \"87654321987654321098\") == 9\n assert candidate(n = \"90000000000000000000900000000000000000000009\") == 9\n assert candidate(n = \"987654321987654321987654321987654321\") == 9\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().minPartitions", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minPartitions(string n) {", "container": "Solution", "callable": "minPartitions", "parameters": [{"name": "n", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1690, "task_id": "stone-game-vii", "difficulty": "Medium", "problem_description": "Alice and Bob take turns playing a game, with Alice starting first.\nThere are n stones arranged in a row. On each player's turn, they can remove either the leftmost stone or the rightmost stone from the row and receive points equal to the sum of the remaining stones' values in the row. The winner is the one with the higher score when there are no stones left to remove.\nBob found that he will always lose this game (poor Bob, he always loses), so he decided to minimize the score's difference. Alice's goal is to maximize the difference in the score.\nGiven an array of integers stones where stones[i] represents the value of the ith stone from the left, return the difference in Alice and Bob's score if they both play optimally.\n \nExample 1:\n\nInput: stones = [5,3,1,4,2]\nOutput: 6\nExplanation: \n- Alice removes 2 and gets 5 + 3 + 1 + 4 = 13 points. Alice = 13, Bob = 0, stones = [5,3,1,4].\n- Bob removes 5 and gets 3 + 1 + 4 = 8 points. Alice = 13, Bob = 8, stones = [3,1,4].\n- Alice removes 3 and gets 1 + 4 = 5 points. Alice = 18, Bob = 8, stones = [1,4].\n- Bob removes 1 and gets 4 points. Alice = 18, Bob = 12, stones = [4].\n- Alice removes 4 and gets 0 points. Alice = 18, Bob = 12, stones = [].\nThe score difference is 18 - 12 = 6.\n\nExample 2:\n\nInput: stones = [7,90,5,1,100,10,10,2]\nOutput: 122\n \nConstraints:\n\nn == stones.length\n2 <= n <= 1000\n1 <= stones[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(stones = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 30\n assert candidate(stones = [2, 3, 4, 1, 5, 6, 7, 8, 9, 10]) == 28\n assert candidate(stones = [1, 2, 3, 4, 5]) == 6\n assert candidate(stones = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 30\n assert candidate(stones = [7, 90, 5, 1, 100, 10, 10, 2]) == 122\n assert candidate(stones = [1, 2, 3, 100, 4, 5, 6, 7, 8, 9]) == 123\n assert candidate(stones = [10, 20, 30, 40, 50]) == 60\n assert candidate(stones = [1, 100, 1, 100, 1, 100]) == 300\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 30\n assert candidate(stones = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(stones = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 30\n assert candidate(stones = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 5000\n assert candidate(stones = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 15\n assert candidate(stones = [3, 9, 4, 2, 10, 3, 2, 5]) == 22\n assert candidate(stones = [5, 3, 1, 4, 2]) == 6\n assert candidate(stones = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == 210\n assert candidate(stones = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 210\n assert candidate(stones = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 105\n assert candidate(stones = [500, 250, 750, 1000, 125, 375, 875, 625, 300, 700, 150, 450, 900, 550, 200, 600, 800, 400, 950, 100]) == 5950\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 40\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 156\n assert candidate(stones = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 110\n assert candidate(stones = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5, 600, 6, 700, 7, 800, 8, 900, 9, 1000, 10]) == 5500\n assert candidate(stones = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 56\n assert candidate(stones = [500, 2, 100, 400, 3, 800, 7, 600, 9, 50]) == 1852\n assert candidate(stones = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == 9900\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 1100\n assert candidate(stones = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993]) == 7972\n assert candidate(stones = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200]) == 2000\n assert candidate(stones = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 650\n assert candidate(stones = [5, 2, 9, 4, 6, 3, 8, 1, 7, 10]) == 35\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 450\n assert candidate(stones = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975]) == 11844\n assert candidate(stones = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 600\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 420\n assert candidate(stones = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 5600\n assert candidate(stones = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5, 600, 6, 700, 7, 800, 8, 900, 9, 1000, 10, 1100, 11, 1200, 12, 1300, 13, 1400, 14, 1500, 15]) == 12000\n assert candidate(stones = [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 136\n assert candidate(stones = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 1010101010\n assert candidate(stones = [500, 400, 300, 200, 100, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5]) == 696\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 650\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 650\n assert candidate(stones = [2, 1, 3, 4, 1, 5, 7, 8, 1, 9, 6, 10, 12, 11, 13, 14, 15, 16, 17, 18]) == 96\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1000]) == 7\n assert candidate(stones = [500, 250, 750, 125, 625, 375, 875, 125, 625, 375, 875, 125, 625, 375, 875, 125, 625, 375, 875, 125]) == 7250\n assert candidate(stones = [500, 250, 750, 200, 1000, 150, 300, 850, 600, 400]) == 3150\n assert candidate(stones = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 3000\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 110\n assert candidate(stones = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600]) == 7200\n assert candidate(stones = [999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1, 999, 1]) == 9990\n assert candidate(stones = [200, 300, 100, 400, 500, 150, 250, 350, 450, 550]) == 1850\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 450\n assert candidate(stones = [50, 20, 30, 10, 40, 60, 70, 80, 90, 100]) == 280\n assert candidate(stones = [1, 10, 100, 1000, 10, 1, 1000, 100, 10, 1, 10, 100, 1000, 10, 1, 100, 100, 10, 1, 10, 100]) == 1342\n assert candidate(stones = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 50\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 830\n assert candidate(stones = [5, 1, 3, 2, 4, 6, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15]) == 72\n assert candidate(stones = [10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 1]) == 1010101010\n assert candidate(stones = [5, 25, 5, 25, 5, 25, 5, 25, 5, 25, 5, 25, 5, 25, 5]) == 35\n assert candidate(stones = [100, 50, 25, 12, 6, 3, 1, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 5526\n assert candidate(stones = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 699050\n assert candidate(stones = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 75\n assert candidate(stones = [100, 200, 300, 400, 500, 400, 300, 200, 100, 50, 40, 30, 20, 10, 1]) == 1090\n assert candidate(stones = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991, 11, 990, 12, 989, 13, 988, 14, 987, 15, 986]) == 14895\n assert candidate(stones = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2]) == 14\n assert candidate(stones = [500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1, 1, 3, 6, 12, 25, 50, 100, 200, 300, 400, 500]) == 1597\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(stones = [50, 10, 50, 10, 50, 10, 50, 10, 50, 10]) == 250\n assert candidate(stones = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 30\n assert candidate(stones = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 550\n assert candidate(stones = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996]) == 4990\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(stones = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 4500\n assert candidate(stones = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == 490\n assert candidate(stones = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946]) == 17710\n assert candidate(stones = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991]) == 9955\n assert candidate(stones = [100, 50, 25, 12, 6, 3, 1, 0, 1, 3, 6, 12, 25, 50, 100]) == 130\n assert candidate(stones = [1000, 1, 999, 2, 998, 3, 997, 4, 996, 5, 995, 6, 994, 7, 993, 8, 992, 9, 991, 10]) == 9955\n assert candidate(stones = [1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000]) == 10000\n assert candidate(stones = [999, 1, 998, 2, 997, 3, 996, 4, 995, 5, 994, 6, 993, 7, 8]) == 28\n assert candidate(stones = [300, 100, 250, 150, 200, 50, 100, 300, 250, 150, 200, 50, 100]) == 800\n assert candidate(stones = [100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100]) == 350\n assert candidate(stones = [5, 3, 1, 4, 2, 5, 3, 1, 4, 2, 5, 3, 1, 4, 2, 5, 3, 1, 4, 2, 5, 3, 1, 4, 2, 5, 3, 1, 4, 2]) == 48\n assert candidate(stones = [1000, 1, 2, 1000, 3, 1000, 4, 1000, 5, 1000, 6, 1000, 7, 1000, 8, 1000, 9, 1000, 10, 1000]) == 9001\n assert candidate(stones = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 560\n assert candidate(stones = [1, 10, 100, 1000, 10, 100, 1000, 10, 100, 1000, 10, 100, 1000, 10, 100]) == 2230\n assert candidate(stones = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3030\n assert candidate(stones = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 105\n assert candidate(stones = [145, 135, 125, 115, 105, 95, 85, 75, 65, 55, 45, 35, 25, 15, 5]) == 525\n assert candidate(stones = [100, 200, 300, 400, 500, 1, 2, 3, 4, 5, 1000, 2000, 3000, 4000, 5000]) == 6609\n assert candidate(stones = [999, 1, 998, 2, 997, 3, 996, 4, 995, 5]) == 4985\n assert candidate(stones = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]) == 10101010\n assert candidate(stones = [100, 50, 200, 150, 250, 100, 300, 50, 200, 150, 250, 100, 300]) == 600\n assert candidate(stones = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 16\n assert candidate(stones = [700, 100, 500, 200, 600, 300, 400, 800, 900, 100, 200, 300, 400, 500, 600]) == 2300\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 410\n assert candidate(stones = [999, 1, 998, 2, 997, 3, 996, 4, 995, 5, 994, 6, 993, 7, 992]) == 28\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 560\n assert candidate(stones = [50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 141\n assert candidate(stones = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(stones = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 60\n assert candidate(stones = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145]) == 525\n assert candidate(stones = [1500, 1400, 1300, 1200, 1100, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 5600\n assert candidate(stones = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 10\n assert candidate(stones = [314, 159, 265, 358, 979, 323, 846, 264, 338, 327, 950, 288, 419, 716, 939]) == 2435\n assert candidate(stones = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 105\n assert candidate(stones = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]) == 29\n assert candidate(stones = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 1, 2, 4, 8, 16]) == 674\n"}, "metadata": {"canonical_parameter_names": ["stones"], "leetcode_dataset_entry_point": "Solution().stoneGameVII", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int stoneGameVII(vector& stones) {", "container": "Solution", "callable": "stoneGameVII", "parameters": [{"name": "stones", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1691, "task_id": "maximum-height-by-stacking-cuboids", "difficulty": "Hard", "problem_description": "Given n cuboids where the dimensions of the ith cuboid is cuboids[i] = [widthi, lengthi, heighti] (0-indexed). Choose a subset of cuboids and place them on each other.\nYou can place cuboid i on cuboid j if widthi <= widthj and lengthi <= lengthj and heighti <= heightj. You can rearrange any cuboid's dimensions by rotating it to put it on another cuboid.\nReturn the maximum height of the stacked cuboids.\n \nExample 1:\n\n\nInput: cuboids = [[50,45,20],[95,37,53],[45,23,12]]\nOutput: 190\nExplanation:\nCuboid 1 is placed on the bottom with the 53x37 side facing down with height 95.\nCuboid 0 is placed next with the 45x20 side facing down with height 50.\nCuboid 2 is placed next with the 23x12 side facing down with height 45.\nThe total height is 95 + 50 + 45 = 190.\n\nExample 2:\n\nInput: cuboids = [[38,25,45],[76,35,3]]\nOutput: 76\nExplanation:\nYou can't place any of the cuboids on the other.\nWe choose cuboid 1 and rotate it so that the 35x3 side is facing down and its height is 76.\n\nExample 3:\n\nInput: cuboids = [[7,11,17],[7,17,11],[11,7,17],[11,17,7],[17,7,11],[17,11,7]]\nOutput: 102\nExplanation:\nAfter rearranging the cuboids, you can see that all cuboids have the same dimension.\nYou can place the 11x7 side down on all cuboids so their heights are 17.\nThe maximum height of stacked cuboids is 6 * 17 = 102.\n\n \nConstraints:\n\nn == cuboids.length\n1 <= n <= 100\n1 <= widthi, lengthi, heighti <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(cuboids = [[4, 6, 7], [1, 2, 3], [4, 5, 6], [10, 12, 32]]) == 48\n assert candidate(cuboids = [[10, 10, 10], [5, 5, 5], [20, 20, 20]]) == 35\n assert candidate(cuboids = [[1, 1, 1], [2, 2, 2], [3, 3, 3]]) == 6\n assert candidate(cuboids = [[50, 45, 20], [95, 37, 53], [45, 23, 12]]) == 190\n assert candidate(cuboids = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == 18\n assert candidate(cuboids = [[38, 25, 45], [76, 35, 3]]) == 76\n assert candidate(cuboids = [[10, 10, 10], [9, 9, 9], [8, 8, 8], [7, 7, 7], [6, 6, 6]]) == 40\n assert candidate(cuboids = [[100, 100, 1], [100, 100, 1], [100, 100, 1]]) == 300\n assert candidate(cuboids = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 4\n assert candidate(cuboids = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4]]) == 10\n assert candidate(cuboids = [[1, 2, 2], [3, 4, 4], [5, 6, 6]]) == 12\n assert candidate(cuboids = [[10, 10, 10], [9, 9, 9], [8, 8, 8], [7, 7, 7]]) == 34\n assert candidate(cuboids = [[10, 10, 10], [9, 9, 9], [8, 8, 8]]) == 27\n assert candidate(cuboids = [[7, 11, 17], [7, 17, 11], [11, 7, 17], [11, 17, 7], [17, 7, 11], [17, 11, 7]]) == 102\n assert candidate(cuboids = [[1, 1, 100], [1, 1, 100], [1, 1, 100]]) == 300\n assert candidate(cuboids = [[100, 100, 100], [99, 99, 99], [98, 98, 98]]) == 297\n assert candidate(cuboids = [[10, 20, 30], [30, 20, 10], [20, 10, 30]]) == 90\n assert candidate(cuboids = [[10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40], [50, 50, 50], [60, 60, 60]]) == 210\n assert candidate(cuboids = [[3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 11]]) == 56\n assert candidate(cuboids = [[9, 8, 7], [6, 5, 4], [3, 2, 1], [12, 11, 10], [15, 14, 13]]) == 45\n assert candidate(cuboids = [[10, 10, 10], [20, 20, 20], [15, 15, 15], [25, 25, 25], [30, 30, 30]]) == 100\n assert candidate(cuboids = [[20, 20, 20], [20, 20, 15], [20, 15, 10], [15, 10, 5]]) == 75\n assert candidate(cuboids = [[3, 4, 5], [1, 2, 6], [4, 5, 3], [5, 3, 4], [6, 2, 1]]) == 15\n assert candidate(cuboids = [[50, 50, 50], [49, 49, 49], [48, 48, 48], [47, 47, 47], [46, 46, 46], [45, 45, 45], [44, 44, 44]]) == 329\n assert candidate(cuboids = [[10, 1, 1], [9, 2, 2], [8, 3, 3], [7, 4, 4], [6, 5, 5], [5, 6, 6], [4, 7, 7], [3, 8, 8], [2, 9, 9], [1, 10, 10], [10, 9, 8], [9, 8, 7], [8, 7, 6], [7, 6, 5], [6, 5, 4], [5, 4, 3], [4, 3, 2], [3, 2, 1], [2, 1, 10], [1, 10, 9]]) == 64\n assert candidate(cuboids = [[30, 20, 10], [20, 10, 5], [10, 5, 2], [5, 2, 1], [2, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 70\n assert candidate(cuboids = [[20, 30, 40], [40, 30, 20], [10, 5, 15], [5, 10, 15]]) == 110\n assert candidate(cuboids = [[1, 3, 5], [1, 4, 6], [1, 5, 7], [2, 4, 8], [2, 5, 9], [3, 5, 11]]) == 39\n assert candidate(cuboids = [[10, 10, 10], [9, 9, 9], [8, 8, 8], [7, 7, 7], [6, 6, 6], [5, 5, 5], [4, 4, 4], [3, 3, 3], [2, 2, 2], [1, 1, 1]]) == 55\n assert candidate(cuboids = [[10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40], [50, 50, 50], [60, 60, 60], [70, 70, 70], [80, 80, 80]]) == 360\n assert candidate(cuboids = [[60, 50, 40], [50, 40, 30], [40, 30, 20], [30, 20, 10], [20, 10, 5], [10, 5, 2], [5, 2, 1]]) == 215\n assert candidate(cuboids = [[1, 3, 2], [2, 1, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8]]) == 33\n assert candidate(cuboids = [[1, 2, 2], [2, 2, 1], [2, 1, 2], [2, 2, 3], [3, 2, 2], [2, 3, 2]]) == 15\n assert candidate(cuboids = [[10, 20, 30], [15, 25, 40], [20, 30, 50], [25, 40, 60], [30, 50, 70]]) == 250\n assert candidate(cuboids = [[10, 11, 12], [12, 10, 11], [11, 12, 10], [10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40]]) == 136\n assert candidate(cuboids = [[1, 2, 3], [3, 2, 1], [2, 1, 3], [1, 3, 2], [3, 1, 2], [2, 3, 1]]) == 18\n assert candidate(cuboids = [[3, 6, 5], [4, 4, 7], [5, 6, 7], [3, 5, 8], [2, 3, 4]]) == 18\n assert candidate(cuboids = [[99, 99, 99], [98, 98, 98], [97, 97, 97], [96, 96, 96], [95, 95, 95], [94, 94, 94]]) == 579\n assert candidate(cuboids = [[50, 40, 30], [40, 30, 20], [30, 20, 10], [20, 10, 5], [10, 5, 1], [9, 8, 7], [8, 7, 6], [7, 6, 5], [6, 5, 4], [5, 4, 3], [4, 3, 2], [3, 2, 1]]) == 165\n assert candidate(cuboids = [[20, 30, 40], [10, 20, 30], [15, 25, 35], [5, 10, 15], [25, 35, 45]]) == 165\n assert candidate(cuboids = [[8, 8, 8], [9, 9, 9], [7, 7, 7], [6, 6, 6], [10, 10, 10]]) == 40\n assert candidate(cuboids = [[10, 20, 30], [20, 30, 10], [30, 10, 20], [10, 10, 10]]) == 100\n assert candidate(cuboids = [[10, 20, 30], [5, 15, 25], [40, 60, 70], [15, 25, 5]]) == 150\n assert candidate(cuboids = [[2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8]]) == 30\n assert candidate(cuboids = [[40, 50, 60], [20, 30, 40], [10, 20, 30], [5, 10, 15], [25, 35, 45]]) == 190\n assert candidate(cuboids = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 1, 1], [2, 2, 2], [3, 3, 3]]) == 22\n assert candidate(cuboids = [[50, 30, 20], [40, 25, 15], [60, 35, 25], [70, 40, 30], [80, 45, 35]]) == 300\n assert candidate(cuboids = [[10, 20, 30], [30, 20, 10], [20, 30, 10], [10, 30, 20], [30, 10, 20], [20, 10, 30]]) == 180\n assert candidate(cuboids = [[1, 2, 3], [3, 2, 1], [2, 1, 3], [3, 1, 2], [1, 3, 2], [2, 3, 1], [4, 5, 6], [6, 5, 4], [5, 4, 6], [6, 4, 5], [5, 6, 4], [4, 6, 5]]) == 54\n assert candidate(cuboids = [[20, 20, 20], [19, 19, 19], [18, 18, 18], [17, 17, 17], [16, 16, 16], [15, 15, 15]]) == 105\n assert candidate(cuboids = [[10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40], [50, 50, 50]]) == 150\n assert candidate(cuboids = [[1, 1, 100], [1, 100, 1], [100, 1, 1], [1, 1, 50], [1, 50, 1], [50, 1, 1]]) == 450\n assert candidate(cuboids = [[5, 5, 5], [5, 5, 6], [5, 5, 7], [5, 5, 8], [5, 5, 9]]) == 35\n assert candidate(cuboids = [[7, 8, 9], [9, 10, 11], [12, 13, 14], [15, 16, 17], [18, 19, 20]]) == 71\n assert candidate(cuboids = [[10, 10, 10], [10, 10, 5], [10, 5, 10], [5, 10, 10], [10, 5, 5], [5, 10, 5], [5, 5, 10]]) == 70\n assert candidate(cuboids = [[50, 45, 20], [95, 37, 53], [45, 23, 12], [53, 37, 95], [23, 12, 45], [12, 45, 23]]) == 375\n assert candidate(cuboids = [[90, 10, 10], [10, 90, 10], [10, 10, 90], [45, 45, 45], [60, 60, 60], [80, 80, 80]]) == 270\n assert candidate(cuboids = [[5, 12, 2], [2, 9, 12], [12, 3, 4], [8, 6, 10], [7, 12, 5], [1, 15, 15], [15, 1, 15], [15, 15, 1]]) == 45\n assert candidate(cuboids = [[5, 3, 1], [7, 5, 3], [9, 7, 5], [11, 9, 7], [13, 11, 9], [15, 13, 11]]) == 60\n assert candidate(cuboids = [[7, 3, 1], [8, 4, 2], [9, 5, 3], [10, 6, 4], [11, 7, 5], [12, 8, 6]]) == 57\n assert candidate(cuboids = [[10, 10, 10], [15, 15, 15], [20, 20, 20], [25, 25, 25], [30, 30, 30], [35, 35, 35], [40, 40, 40], [45, 45, 45]]) == 220\n assert candidate(cuboids = [[8, 1, 6], [3, 5, 7], [4, 9, 2], [2, 6, 8], [5, 7, 3], [9, 4, 1]]) == 18\n assert candidate(cuboids = [[30, 20, 10], [25, 20, 10], [20, 15, 5], [15, 10, 5], [10, 6, 3], [5, 3, 1]]) == 105\n assert candidate(cuboids = [[50, 45, 20], [95, 37, 53], [45, 23, 12], [60, 60, 60], [10, 10, 10], [20, 20, 20], [30, 30, 30]]) == 200\n assert candidate(cuboids = [[5, 12, 17], [3, 8, 9], [1, 2, 3], [6, 7, 8], [4, 10, 11], [2, 5, 6]]) == 46\n assert candidate(cuboids = [[1, 2, 3], [3, 2, 1], [2, 1, 3], [3, 1, 2], [2, 3, 1], [1, 3, 2]]) == 18\n assert candidate(cuboids = [[100, 1, 1], [99, 2, 2], [98, 3, 3], [97, 4, 4], [96, 5, 5], [95, 6, 6], [94, 7, 7], [93, 8, 8], [92, 9, 9], [91, 10, 10]]) == 100\n assert candidate(cuboids = [[5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5]]) == 30\n assert candidate(cuboids = [[8, 8, 8], [7, 7, 9], [6, 6, 10], [5, 5, 11], [4, 4, 12], [3, 3, 13], [2, 2, 14], [1, 1, 15]]) == 15\n assert candidate(cuboids = [[10, 20, 30], [20, 30, 40], [30, 40, 50], [40, 50, 60], [50, 60, 70]]) == 250\n assert candidate(cuboids = [[100, 50, 25], [50, 25, 12], [25, 12, 6], [12, 6, 3], [6, 3, 1], [3, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 199\n assert candidate(cuboids = [[10, 20, 30], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == 57\n assert candidate(cuboids = [[4, 6, 7], [1, 2, 3], [4, 5, 6], [10, 12, 32], [1, 1, 4]]) == 49\n assert candidate(cuboids = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6]]) == 21\n assert candidate(cuboids = [[7, 11, 17], [11, 7, 17], [17, 11, 7], [7, 17, 11], [11, 17, 7], [17, 7, 11], [7, 11, 17], [11, 7, 17], [17, 11, 7]]) == 153\n assert candidate(cuboids = [[20, 20, 20], [10, 10, 10], [30, 30, 30], [15, 15, 15]]) == 75\n assert candidate(cuboids = [[1, 1, 100], [2, 2, 99], [3, 3, 98], [4, 4, 97], [5, 5, 96], [6, 6, 95]]) == 100\n assert candidate(cuboids = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8]]) == 33\n assert candidate(cuboids = [[8, 8, 8], [8, 8, 7], [8, 7, 6], [7, 6, 5], [6, 5, 4], [5, 4, 3], [4, 3, 2], [3, 2, 1]]) == 49\n assert candidate(cuboids = [[3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]]) == 52\n assert candidate(cuboids = [[1, 2, 3], [3, 2, 1], [2, 3, 1], [1, 3, 2], [3, 1, 2], [2, 1, 3]]) == 18\n assert candidate(cuboids = [[10, 12, 3], [1, 3, 5], [6, 7, 8], [5, 4, 3], [7, 8, 9], [8, 9, 10]]) == 37\n assert candidate(cuboids = [[5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5], [5, 5, 5]]) == 40\n assert candidate(cuboids = [[9, 8, 7], [8, 7, 6], [7, 6, 5], [6, 5, 4], [5, 4, 3], [4, 3, 2], [3, 2, 1]]) == 42\n assert candidate(cuboids = [[23, 28, 32], [28, 32, 23], [32, 23, 28], [11, 29, 31], [29, 31, 11], [31, 11, 29], [12, 16, 24], [16, 24, 12], [24, 12, 16], [16, 24, 14]]) == 192\n assert candidate(cuboids = [[15, 12, 8], [8, 12, 15], [12, 15, 8], [9, 10, 7], [7, 10, 9], [10, 7, 9]]) == 75\n assert candidate(cuboids = [[1, 1, 10], [1, 2, 9], [1, 3, 8], [1, 4, 7], [1, 5, 6], [1, 6, 5], [1, 7, 4], [1, 8, 3], [1, 9, 2], [1, 10, 1]]) == 20\n assert candidate(cuboids = [[30, 50, 70], [20, 40, 60], [10, 30, 50], [5, 15, 25], [1, 2, 3]]) == 208\n assert candidate(cuboids = [[9, 18, 36], [18, 36, 72], [36, 72, 144], [72, 144, 288], [144, 288, 576], [288, 576, 1152]]) == 2268\n assert candidate(cuboids = [[25, 15, 10], [15, 10, 5], [10, 5, 2], [5, 3, 1], [3, 2, 1], [2, 1, 1], [1, 1, 1]]) == 61\n assert candidate(cuboids = [[12, 34, 56], [34, 12, 78], [56, 78, 12], [78, 12, 34]]) == 290\n assert candidate(cuboids = [[100, 1, 1], [1, 100, 1], [1, 1, 100], [99, 2, 2], [2, 99, 2], [2, 2, 99], [50, 50, 50], [75, 75, 75]]) == 300\n assert candidate(cuboids = [[3, 4, 5], [3, 3, 3], [3, 5, 5], [2, 3, 4], [2, 2, 2], [1, 1, 1], [1, 2, 3]]) == 18\n assert candidate(cuboids = [[15, 10, 5], [10, 8, 4], [5, 4, 2], [30, 20, 10], [20, 15, 5], [10, 6, 3]]) == 90\n assert candidate(cuboids = [[5, 4, 3], [4, 3, 2], [3, 2, 1], [2, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 18\n assert candidate(cuboids = [[1, 1, 1], [1, 2, 2], [2, 2, 2], [1, 3, 3], [2, 3, 3], [3, 3, 3], [1, 4, 4], [2, 4, 4], [3, 4, 4], [4, 4, 4]]) == 22\n assert candidate(cuboids = [[10, 20, 30], [30, 20, 10], [20, 10, 30], [10, 30, 20], [30, 10, 20], [20, 30, 10]]) == 180\n assert candidate(cuboids = [[5, 5, 5], [10, 10, 10], [15, 15, 15], [20, 20, 20], [25, 25, 25]]) == 75\n assert candidate(cuboids = [[5, 20, 30], [20, 30, 5], [30, 5, 20], [5, 30, 20], [30, 20, 5], [20, 5, 30]]) == 180\n assert candidate(cuboids = [[10, 10, 10], [9, 9, 9], [8, 8, 8], [7, 7, 7], [6, 6, 6], [5, 5, 5], [4, 4, 4], [3, 3, 3], [2, 2, 2], [1, 1, 1]]) == 55\n assert candidate(cuboids = [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1], [1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4]]) == 26\n assert candidate(cuboids = [[4, 5, 6], [6, 5, 4], [7, 8, 9], [9, 8, 7], [1, 2, 3], [3, 2, 1]]) == 36\n assert candidate(cuboids = [[40, 40, 40], [30, 30, 30], [20, 20, 20], [10, 10, 10], [5, 5, 5], [1, 1, 1], [40, 30, 20], [30, 20, 10], [20, 10, 5], [10, 5, 1]]) == 141\n assert candidate(cuboids = [[9, 9, 9], [8, 8, 8], [7, 7, 7], [6, 6, 6], [5, 5, 5], [4, 4, 4], [3, 3, 3], [2, 2, 2], [1, 1, 1]]) == 45\n assert candidate(cuboids = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9]]) == 42\n assert candidate(cuboids = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21], [22, 23, 24]]) == 108\n assert candidate(cuboids = [[10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40], [50, 50, 50], [60, 60, 60], [70, 70, 70], [80, 80, 80], [90, 90, 90], [100, 100, 100]]) == 550\n assert candidate(cuboids = [[10, 20, 30], [20, 30, 40], [30, 40, 50], [40, 50, 60], [50, 60, 70], [60, 70, 80], [70, 80, 90], [80, 90, 100]]) == 520\n"}, "metadata": {"canonical_parameter_names": ["cuboids"], "leetcode_dataset_entry_point": "Solution().maxHeight", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxHeight(vector>& cuboids) {", "container": "Solution", "callable": "maxHeight", "parameters": [{"name": "cuboids", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1694, "task_id": "reformat-phone-number", "difficulty": "Easy", "problem_description": "You are given a phone number as a string number. number consists of digits, spaces ' ', and/or dashes '-'.\nYou would like to reformat the phone number in a certain manner. Firstly, remove all spaces and dashes. Then, group the digits from left to right into blocks of length 3 until there are 4 or fewer digits. The final digits are then grouped as follows:\n\n2 digits: A single block of length 2.\n3 digits: A single block of length 3.\n4 digits: Two blocks of length 2 each.\n\nThe blocks are then joined by dashes. Notice that the reformatting process should never produce any blocks of length 1 and produce at most two blocks of length 2.\nReturn the phone number after formatting.\n \nExample 1:\n\nInput: number = \"1-23-45 6\"\nOutput: \"123-456\"\nExplanation: The digits are \"123456\".\nStep 1: There are more than 4 digits, so group the next 3 digits. The 1st block is \"123\".\nStep 2: There are 3 digits remaining, so put them in a single block of length 3. The 2nd block is \"456\".\nJoining the blocks gives \"123-456\".\n\nExample 2:\n\nInput: number = \"123 4-567\"\nOutput: \"123-45-67\"\nExplanation: The digits are \"1234567\".\nStep 1: There are more than 4 digits, so group the next 3 digits. The 1st block is \"123\".\nStep 2: There are 4 digits left, so split them into two blocks of length 2. The blocks are \"45\" and \"67\".\nJoining the blocks gives \"123-45-67\".\n\nExample 3:\n\nInput: number = \"123 4-5678\"\nOutput: \"123-456-78\"\nExplanation: The digits are \"12345678\".\nStep 1: The 1st block is \"123\".\nStep 2: The 2nd block is \"456\".\nStep 3: There are 2 digits left, so put them in a single block of length 2. The 3rd block is \"78\".\nJoining the blocks gives \"123-456-78\".\n\n \nConstraints:\n\n2 <= number.length <= 100\nnumber consists of digits and the characters '-' and ' '.\nThere are at least two digits in number.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(number = \"12 345 678\") == \"123-456-78\"\n assert candidate(number = \"1234-5678-9012\") == \"123-456-789-012\"\n assert candidate(number = \"12 345 678 90\") == \"123-456-78-90\"\n assert candidate(number = \"123456789\") == \"123-456-789\"\n assert candidate(number = \"12 345 678 901\") == \"123-456-789-01\"\n assert candidate(number = \"12 345-6789\") == \"123-456-789\"\n assert candidate(number = \"123456789012\") == \"123-456-789-012\"\n assert candidate(number = \"1234567890123\") == \"123-456-789-01-23\"\n assert candidate(number = \"12-345 67-89--01\") == \"123-456-789-01\"\n assert candidate(number = \"1234\") == \"12-34\"\n assert candidate(number = \"1 2 3 4 5 6 7 8 9 0\") == \"123-456-78-90\"\n assert candidate(number = \"1234567\") == \"123-45-67\"\n assert candidate(number = \"1 234 567 8901\") == \"123-456-789-01\"\n assert candidate(number = \"123 4567\") == \"123-45-67\"\n assert candidate(number = \"12 345 6789\") == \"123-456-789\"\n assert candidate(number = \"1-23-45 6\") == \"123-456\"\n assert candidate(number = \"12\") == \"12\"\n assert candidate(number = \"1234567890\") == \"123-456-78-90\"\n assert candidate(number = \"123 4-5678\") == \"123-456-78\"\n assert candidate(number = \"123 4-567\") == \"123-45-67\"\n assert candidate(number = \"123-4567890123\") == \"123-456-789-01-23\"\n assert candidate(number = \"1 234-567 890\") == \"123-456-78-90\"\n assert candidate(number = \"123-456-7890\") == \"123-456-78-90\"\n assert candidate(number = \"123\") == \"123\"\n assert candidate(number = \"123-456-789-012-345-678-901-234-567-890\") == \"123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"12 34-56-78-90\") == \"123-456-78-90\"\n assert candidate(number = \"12345 67890 123456 7890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"12345678901234567890123\") == \"123-456-789-012-345-678-901-23\"\n assert candidate(number = \"1-2-3-4-5-6-7-8-9-0-1-2-3\") == \"123-456-789-01-23\"\n assert candidate(number = \"1234-5678-9012-3456-7890-12\") == \"123-456-789-012-345-678-90-12\"\n assert candidate(number = \"1234-5678-9012-3456-7890-1234\") == \"123-456-789-012-345-678-901-234\"\n assert candidate(number = \" 1-23-45-67-89-01-23 \") == \"123-456-789-01-23\"\n assert candidate(number = \"12345678-90123456-78901234\") == \"123-456-789-012-345-678-901-234\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234567890 1234567890 12\") == \"123-456-789-012-345-678-901-234-567-890-123-456-789-012-345-678-90-12\"\n assert candidate(number = \"123 4567 890 1234 56\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"123-456-789-012-345-678-901-234-56\") == \"123-456-789-012-345-678-901-234-56\"\n assert candidate(number = \"123 456 7890 1234567890 1234567890 123\") == \"123-456-789-012-345-678-901-234-567-890-123\"\n assert candidate(number = \"12345678901234567890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"12345678901234567890123456789012345\") == \"123-456-789-012-345-678-901-234-567-890-123-45\"\n assert candidate(number = \"12 34 56 78 90 12 34 56\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"1234567890-12345-678-9\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"1-234-56789-012345\") == \"123-456-789-012-345\"\n assert candidate(number = \"123 456 7890 12345 678 90\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"1234567890123456789012\") == \"123-456-789-012-345-678-90-12\"\n assert candidate(number = \"12-345-6789-012345-6789\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"12 3456 789 012 3456 78\") == \"123-456-789-012-345-678\"\n assert candidate(number = \"1-23-45-67-89-01-23-45-67-89-01-23\") == \"123-456-789-012-345-678-901-23\"\n assert candidate(number = \"1 2345678901234567890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"123 456 789 012 345 678 901 234\") == \"123-456-789-012-345-678-901-234\"\n assert candidate(number = \"1-2-3-4-5-6-7-8-9-0-1-2-3-4-5-6-7-8-9-0-1\") == \"123-456-789-012-345-678-901\"\n assert candidate(number = \"12 345 678 901 234 567\") == \"123-456-789-012-345-67\"\n assert candidate(number = \"12345678901234567890123456789012345678\") == \"123-456-789-012-345-678-901-234-567-890-123-456-78\"\n assert candidate(number = \"12345678901234567890123456789012\") == \"123-456-789-012-345-678-901-234-567-890-12\"\n assert candidate(number = \"1234 5678 9012 3456 7890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"1 234 567 890 123 456 789 012 345\") == \"123-456-789-012-345-678-901-23-45\"\n assert candidate(number = \"123-45678901234567890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234567890\") == \"123-456-789-012-345-678-901-234-567-890-123-456-78-90\"\n assert candidate(number = \"123-45 67-89 01 2\") == \"123-456-789-012\"\n assert candidate(number = \"1 2 3 4 5 6 7 8 9 0 1 2 3 4 5\") == \"123-456-789-012-345\"\n assert candidate(number = \"1234567890 123 4567 890 1234\") == \"123-456-789-012-345-678-901-234\"\n assert candidate(number = \"1234-567890-1234567890-12345\") == \"123-456-789-012-345-678-901-23-45\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890\") == \"123-456-789-012-345-678-901-234-567-890-123-456-789-012-345-678-901-234-567-890-123-456-789-012-345-678-901-234-567-890-123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"1-2-3-4-5-6-7-8-9-0-1-2-3-4-5-6-7-8-9\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"123456789012345678901234567890123456\") == \"123-456-789-012-345-678-901-234-567-890-123-456\"\n assert candidate(number = \"1234567890-1234567890-1234\") == \"123-456-789-012-345-678-901-234\"\n assert candidate(number = \"12345-6789-0123-456\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"12-345-678-90\") == \"123-456-78-90\"\n assert candidate(number = \"-12 34 56 78 90 -\") == \"123-456-78-90\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890\") == \"123-456-789-012-345-678-901-234-567-890-123-456-789-012-345-678-901-234-567-890-123-456-789-012-345-678-901-234-567-890-123-456-78-90\"\n assert candidate(number = \"123 456-789-0123-4567-8901\") == \"123-456-789-012-345-678-901\"\n assert candidate(number = \"12-345-678-901-234\") == \"123-456-789-012-34\"\n assert candidate(number = \"1234567890-1234567890-1234567890\") == \"123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"12 345 678 901 234 56\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"123-456-7890-1234-567\") == \"123-456-789-012-345-67\"\n assert candidate(number = \"123 4567 8901 2345\") == \"123-456-789-012-345\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234\") == \"123-456-789-012-345-678-901-234-567-890-12-34\"\n assert candidate(number = \"1-23-456-7890-1234\") == \"123-456-789-012-34\"\n assert candidate(number = \"123456789-0123456789-0123456789-0123\") == \"123-456-789-012-345-678-901-234-567-890-123\"\n assert candidate(number = \"123 456 7890 1234567890 123456\") == \"123-456-789-012-345-678-901-234-56\"\n assert candidate(number = \"123-4567890123456789012345678901234567890\") == \"123-456-789-012-345-678-901-234-567-890-123-456-78-90\"\n assert candidate(number = \"12-345-67890123456789\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"1 23 456 7890 1234567890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"1234567890-1234567890-1234567890-1234567890\") == \"123-456-789-012-345-678-901-234-567-890-123-456-78-90\"\n assert candidate(number = \"1234-56789-012345-678\") == \"123-456-789-012-345-678\"\n assert candidate(number = \"-1-23-456-7890-12345-6789\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"-1-2-3-4-5-6-7-8-9-0-\") == \"123-456-78-90\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234567890 1234567890 123\") == \"123-456-789-012-345-678-901-234-567-890-123-456-789-012-345-678-901-23\"\n assert candidate(number = \"12-34-56-78-90-12-34-56-78-90-12-34\") == \"123-456-789-012-345-678-901-234\"\n assert candidate(number = \"1234567890 1234567890 1234\") == \"123-456-789-012-345-678-901-234\"\n assert candidate(number = \"123-4567-8901-2345-6789-012\") == \"123-456-789-012-345-678-90-12\"\n assert candidate(number = \"123 456 7890 123 456 7890 123 456 7890\") == \"123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234567890 123\") == \"123-456-789-012-345-678-901-234-567-890-123-456-789-01-23\"\n assert candidate(number = \"-12- 345-678-9012-3456-\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"1-23-45-67-89-01\") == \"123-456-789-01\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234567890 12\") == \"123-456-789-012-345-678-901-234-567-890-123-456-789-012\"\n assert candidate(number = \"12345 67890 1234 56\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"12-345-67-89-01-23\") == \"123-456-789-01-23\"\n assert candidate(number = \"1234567890-123456-789\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"1-23-45 67-890\") == \"123-456-78-90\"\n assert candidate(number = \"-1--2--3--4--5--6--7--8--9--0-\") == \"123-456-78-90\"\n assert candidate(number = \"123-456-789-012-345-678\") == \"123-456-789-012-345-678\"\n assert candidate(number = \"123 456 789 012\") == \"123-456-789-012\"\n assert candidate(number = \"123456789012345678901234567890\") == \"123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"123-456 789-012 345-678\") == \"123-456-789-012-345-678\"\n assert candidate(number = \"1-23-45-67-89-01-23-45-67-89-01\") == \"123-456-789-012-345-678-901\"\n assert candidate(number = \"123456789-0123456789012345\") == \"123-456-789-012-345-678-901-23-45\"\n assert candidate(number = \"123 456789 01234 567\") == \"123-456-789-012-345-67\"\n assert candidate(number = \"123-4567-8901-2345-6789-0123\") == \"123-456-789-012-345-678-901-23\"\n assert candidate(number = \"1234-5678-9012-3456-7890-1234-56\") == \"123-456-789-012-345-678-901-234-56\"\n assert candidate(number = \"1-234 567-89 0\") == \"123-456-78-90\"\n assert candidate(number = \"1 2 3 4 5 6 7 8 9 0 1 2 3\") == \"123-456-789-01-23\"\n assert candidate(number = \"1-2-3-4-5-6-7-8-9-0-1-2-3-4-5-6-7-8-9-0\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"1234-5678-9012-3456\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"123456789-0123456789\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"123 456 7890 1234567890 123\") == \"123-456-789-012-345-678-901-23\"\n assert candidate(number = \"-123-456-789-012-345-678-90\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"12 34 56 78 90 12 34 56 78\") == \"123-456-789-012-345-678\"\n assert candidate(number = \"123-456-789-012-3456-7890-123\") == \"123-456-789-012-345-678-901-23\"\n assert candidate(number = \"1234567890 1234567890 1234567890\") == \"123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"12-34-56-78-90-12-34\") == \"123-456-789-012-34\"\n assert candidate(number = \"1234567890123456789012345678901234\") == \"123-456-789-012-345-678-901-234-567-890-12-34\"\n assert candidate(number = \"123-4567-89012345-6789\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"1-2-3-4-5-6-7-8-9-0-1-2-3-4\") == \"123-456-789-012-34\"\n assert candidate(number = \"1-2-3-4-5-6-7-8-9\") == \"123-456-789\"\n assert candidate(number = \"123-4567-89012-3456\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"12 34 56 78 90 12 34\") == \"123-456-789-012-34\"\n assert candidate(number = \"123-456-789-012-345-6789-0123-4567-8901\") == \"123-456-789-012-345-678-901-234-567-89-01\"\n assert candidate(number = \"123456789012345678901234567890123\") == \"123-456-789-012-345-678-901-234-567-890-123\"\n assert candidate(number = \"123 456 789 012 345 678 9012\") == \"123-456-789-012-345-678-90-12\"\n assert candidate(number = \"123-456-789-012-345-678-90\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"-123-456-789-012-345-678-901-\") == \"123-456-789-012-345-678-901\"\n assert candidate(number = \"1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890\") == \"123-456-789-012-345-678-901-234-567-890-123-456-789-012-345-678-901-234-567-890-123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"1234567890-1234567890-1234567890-1234\") == \"123-456-789-012-345-678-901-234-567-890-12-34\"\n assert candidate(number = \"123 456 7890 1234 5678\") == \"123-456-789-012-345-678\"\n assert candidate(number = \"123 4567 8901 2345 6789 0123\") == \"123-456-789-012-345-678-901-23\"\n assert candidate(number = \"1234 5678 9012 3456\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"12345 67890 123 456 7890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"1-2-3-4-5-6-7-8-9-0\") == \"123-456-78-90\"\n assert candidate(number = \"1 234 567 890 123 456 789 012\") == \"123-456-789-012-345-678-90-12\"\n assert candidate(number = \"12345-67890-12345-67890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"12-345 678 901-234\") == \"123-456-789-012-34\"\n assert candidate(number = \"123-4567-8901-2345-6789-0123-4567-8901-2345\") == \"123-456-789-012-345-678-901-234-567-890-123-45\"\n assert candidate(number = \"12 34 56 78 90 12 34 56 78 90 12 34 56 78 90\") == \"123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"1234-567890-1234567-890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"123 4567 89012 3456 789\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"12 34 567 890 123-4\") == \"123-456-789-012-34\"\n assert candidate(number = \"123 456 789 012 345\") == \"123-456-789-012-345\"\n assert candidate(number = \"123 4567 890 123 45 6789\") == \"123-456-789-012-345-67-89\"\n assert candidate(number = \"12-34-56-78-90-12-34-56-78\") == \"123-456-789-012-345-678\"\n assert candidate(number = \"1234567890-1234-5678901234\") == \"123-456-789-012-345-678-901-234\"\n assert candidate(number = \"123-45-678901234567890\") == \"123-456-789-012-345-678-90\"\n assert candidate(number = \"12-34-56-78-90-12-34-56\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"123 456 789 012 345 678 901 234 567 890\") == \"123-456-789-012-345-678-901-234-567-890\"\n assert candidate(number = \"1-23-45-67-89-01-23-45-67\") == \"123-456-789-012-345-67\"\n assert candidate(number = \"12-345-678-9012-34\") == \"123-456-789-012-34\"\n assert candidate(number = \"12-345-6789-0123-4567-8901-2345-6789\") == \"123-456-789-012-345-678-901-234-567-89\"\n assert candidate(number = \"12345-6789-01234-5678-90123\") == \"123-456-789-012-345-678-901-23\"\n assert candidate(number = \"1234567890123456\") == \"123-456-789-012-34-56\"\n assert candidate(number = \"123-456-7890-123456\") == \"123-456-789-012-34-56\"\n"}, "metadata": {"canonical_parameter_names": ["number"], "leetcode_dataset_entry_point": "Solution().reformatNumber", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string reformatNumber(string number) {", "container": "Solution", "callable": "reformatNumber", "parameters": [{"name": "number", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1695, "task_id": "maximum-erasure-value", "difficulty": "Medium", "problem_description": "You are given an array of positive integers nums and want to erase a subarray containing unique elements. The score you get by erasing the subarray is equal to the sum of its elements.\nReturn the maximum score you can get by erasing exactly one subarray.\nAn array b is called to be a subarray of a if it forms a contiguous subsequence of a, that is, if it is equal to a[l],a[l+1],...,a[r] for some (l,r).\n \nExample 1:\n\nInput: nums = [4,2,4,5,6]\nOutput: 17\nExplanation: The optimal subarray here is [2,4,5,6].\n\nExample 2:\n\nInput: nums = [5,2,1,2,5,2,1,2,5]\nOutput: 8\nExplanation: The optimal subarray here is [5,2,1] or [1,2,5].\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6]) == 18\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == 6\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 1, 1]) == 55\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 4, 6]) == 15\n assert candidate(nums = [1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [10, 5, 2, 7, 8, 7, 4, 5]) == 32\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 6, 5, 7, 8, 9, 8, 10]) == 35\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [1, 2, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996]) == 49990\n assert candidate(nums = [1, 2, 3, 4, 3, 5, 6, 7, 8, 9]) == 42\n assert candidate(nums = [1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(nums = [9, 9, 9, 9, 10, 9, 9, 9]) == 19\n assert candidate(nums = [4, 2, 4, 5, 6]) == 17\n assert candidate(nums = [5, 2, 1, 2, 5, 2, 1, 2, 5]) == 8\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 11\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == 2500\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(nums = [2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 19\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == 21\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 110\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 99955\n assert candidate(nums = [400, 300, 200, 100, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 12000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1]) == 595\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12, 13, 14, 15, 15]) == 54\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 55\n assert candidate(nums = [3, 1, 2, 4, 5, 6, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 324\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 550\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 1810\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 465\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 210\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 99955\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 10000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5]) == 45\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 3\n assert candidate(nums = [1, 2, 3, 1, 4, 5, 6, 2, 3, 7, 8, 9, 10, 1, 2, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 450\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 210\n assert candidate(nums = [1, 2, 3, 4, 3, 5, 6, 5, 7, 8, 9, 8, 10, 11, 10, 12, 13, 12, 14, 15]) == 54\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 639\n assert candidate(nums = [1, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 324\n assert candidate(nums = [1, 10000, 2, 9999, 3, 9998, 4, 9997, 5, 9996, 6, 9995, 7, 9994, 8, 9993, 9, 9992, 10, 9991]) == 100010\n assert candidate(nums = [2, 3, 1, 4, 5, 6, 1, 2, 3, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 4, 6, 8, 10, 3, 5, 7, 9, 1]) == 55\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 1810\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 465\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 10000]) == 99955\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12]) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 325\n assert candidate(nums = [9999, 10000, 9999, 10000, 9999, 10000, 9999, 10000, 9999, 10000, 9999, 10000]) == 19999\n assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == 31\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 66\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7]) == 34\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 204\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [3, 1, 2, 4, 5, 3, 6, 7, 8, 9, 1, 2, 3, 4]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 55\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 39\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 19\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7]) == 55\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 1275\n assert candidate(nums = [100, 200, 100, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 12000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [2, 2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 2, 2, 2, 2]) == 819\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200]) == 300\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 7\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000]) == 5000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [5000, 5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008, 5009, 5000]) == 50045\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981]) == 199810\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == 150\n assert candidate(nums = [3, 1, 2, 4, 2, 3, 5, 6, 7, 8, 9, 1]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 55\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1, 3, 2, 1, 4, 2, 3, 1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 820\n assert candidate(nums = [1, 10, 100, 1000, 10000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 10, 100, 1000, 10000, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 11155\n assert candidate(nums = [5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2, 5, 2]) == 7\n assert candidate(nums = [10, 9, 8, 7, 6, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maximumUniqueSubarray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumUniqueSubarray(vector& nums) {", "container": "Solution", "callable": "maximumUniqueSubarray", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1696, "task_id": "jump-game-vi", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums and an integer k.\nYou are initially standing at index 0. In one move, you can jump at most k steps forward without going outside the boundaries of the array. That is, you can jump from index i to any index in the range [i + 1, min(n - 1, i + k)] inclusive.\nYou want to reach the last index of the array (index n - 1). Your score is the sum of all nums[j] for each index j you visited in the array.\nReturn the maximum score you can get.\n \nExample 1:\n\nInput: nums = [1,-1,-2,4,-7,3], k = 2\nOutput: 7\nExplanation: You can choose your jumps forming the subsequence [1,-1,4,3] (underlined above). The sum is 7.\n\nExample 2:\n\nInput: nums = [10,-5,-2,4,0,3], k = 3\nOutput: 17\nExplanation: You can choose your jumps forming the subsequence [10,4,3] (underlined above). The sum is 17.\n\nExample 3:\n\nInput: nums = [1,-5,-20,4,-1,3,-6,-3], k = 2\nOutput: 0\n\n \nConstraints:\n\n1 <= nums.length, k <= 105\n-104 <= nums[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 55\n assert candidate(nums = [1, -1, -2, 4, -7, 3],k = 2) == 7\n assert candidate(nums = [10, -5, -2, 4, 0, 3],k = 3) == 17\n assert candidate(nums = [-1, -2, -3, -4, -5],k = 4) == -6\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 50\n assert candidate(nums = [-10000, -10000, -10000, -10000, -10000],k = 2) == -30000\n assert candidate(nums = [-1, -2, -3, -4, -5],k = 2) == -9\n assert candidate(nums = [5, -1, 5],k = 2) == 10\n assert candidate(nums = [1],k = 1) == 1\n assert candidate(nums = [5, 4, 3, 2, 1],k = 1) == 15\n assert candidate(nums = [100, -100, 100, -100, 100],k = 2) == 300\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000],k = 5) == 50000\n assert candidate(nums = [5, 6, -4, 2, 1],k = 3) == 14\n assert candidate(nums = [1, -5, -20, 4, -1, 3, -6, -3],k = 2) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == 15\n assert candidate(nums = [-5, -1, -5],k = 1) == -11\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],k = 2) == 4000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 55\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 2) == 9\n assert candidate(nums = [1000, -500, 2000, -100, 4000, -200, 3000, -300, 5000, -400],k = 5) == 14600\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 5) == -16\n assert candidate(nums = [1, -10, 5, 6, -4, -5, 10, 1, 2],k = 4) == 25\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 55\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 4) == -19\n assert candidate(nums = [5, -1, -2, -3, -4, -5, 6, -1, 2, -3, -4, -5, 10],k = 5) == 22\n assert candidate(nums = [1000, -2000, 3000, -4000, 5000, -6000, 7000, -8000, 9000],k = 6) == 25000\n assert candidate(nums = [10, 20, 30, 40, 50, -60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 4) == 1140\n assert candidate(nums = [3, 2, -6, 5, 0, -3, 2, 1],k = 3) == 13\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 2) == 5500\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 550\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 55\n assert candidate(nums = [10000, -5000, 5000, 6000, -2000, 3000, 7000, -8000, 4000, 10000],k = 5) == 45000\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10],k = 4) == 29\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 5) == 9\n assert candidate(nums = [1000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000],k = 10) == 2000\n assert candidate(nums = [-10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000],k = 5) == 40000\n assert candidate(nums = [1, -10, 5, 6, -2, 3, 7, -8, 4, 10],k = 3) == 36\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 1) == 550\n assert candidate(nums = [10000, -9999, 10000, -9999, 10000, -9999, 10000, -9999, 10000, -9999],k = 2) == 40001\n assert candidate(nums = [5, -1, 3, -2, 7, 1, -4, 8, -3, 2],k = 4) == 26\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == 0\n assert candidate(nums = [3, -2, -2, 2, -1, 2, 1, -5, 4],k = 3) == 12\n assert candidate(nums = [100, -100, 100, -100, 100, -100, 100],k = 2) == 400\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],k = 5) == 4000\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500],k = 3) == 1000\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 4) == 7\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 10) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 210\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 15) == 1\n assert candidate(nums = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10],k = 2) == 55\n assert candidate(nums = [3, -1, 2, -5, 6, 2, -1, 4],k = 4) == 17\n assert candidate(nums = [1, -5, 4, 2, -2, -1, 3, 1, -1, 2, -3, 4, -5, 6],k = 3) == 23\n assert candidate(nums = [5, -10, 4, -2, 3, 100, -100, 200, -200, 300],k = 4) == 612\n assert candidate(nums = [10, 5, 2, 7, 8, 9, 3, 5, 2, 1, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5],k = 3) == 102\n assert candidate(nums = [10, -5, -20, 4, -1, 3, -6, -3, 5, 2],k = 4) == 24\n assert candidate(nums = [1, -10, 100, -1000, 10000],k = 3) == 10101\n assert candidate(nums = [-1, -5, -2, -4, -10, -20],k = 2) == -27\n assert candidate(nums = [5, -10, 15, -20, 25, -30, 35, -40, 45, -50, 55, -60, 65, -70, 75, -80],k = 5) == 240\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 15\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],k = 3) == -220\n assert candidate(nums = [3, -1, -1, -1, 10, 5],k = 2) == 17\n assert candidate(nums = [10, -1, 10, -1, 10, -1, 10, -1, 10, -1],k = 5) == 49\n assert candidate(nums = [3, -1, 2, 1, -4, 2, 3, -5, 4],k = 4) == 15\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 12, -12, 6, -6],k = 4) == 187\n assert candidate(nums = [1, -5, 10, 20, -30, 5, 15],k = 4) == 51\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 55\n assert candidate(nums = [1000, -1000, 500, -500, 250, -250, 125, -125, 62, -62, 31, -31],k = 5) == 1937\n assert candidate(nums = [5, 3, 2, 1, 7, 6, 4, 8, 9],k = 3) == 45\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],k = 10) == -110\n assert candidate(nums = [1, -10, 2, -20, 3, -30, 4, -40, 5, -50],k = 4) == -35\n assert candidate(nums = [100, -50, 200, -300, 400, -500, 600, -700, 800],k = 3) == 2100\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 2) == 4\n assert candidate(nums = [100, -50, -100, 200, -300, 400, 500],k = 3) == 1200\n assert candidate(nums = [10000, -5000, 2000, -1000, 5000, 2000, -2000, 3000, 4000, -1000],k = 3) == 25000\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20],k = 5) == 109\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 20\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 2) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 210\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],k = 5) == 50\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 20) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 55\n assert candidate(nums = [10, -10, 10, -10, 10, -10, 10, -10, 10, -10],k = 2) == 40\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 4) == 10\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -110, -120, -130, -140, -150],k = 3) == -460\n assert candidate(nums = [100, 200, 300, 400, 500],k = 5) == 1500\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 5) == 1000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == 55\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maxResult", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxResult(vector& nums, int k) {", "container": "Solution", "callable": "maxResult", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1697, "task_id": "checking-existence-of-edge-length-limited-paths", "difficulty": "Hard", "problem_description": "An undirected graph of n nodes is defined by edgeList, where edgeList[i] = [ui, vi, disi] denotes an edge between nodes ui and vi with distance disi. Note that there may be multiple edges between two nodes.\nGiven an array queries, where queries[j] = [pj, qj, limitj], your task is to determine for each queries[j] whether there is a path between pj and qj such that each edge on the path has a distance strictly less than limitj .\nReturn a boolean array answer, where answer.length == queries.length and the jth value of answer is true if there is a path for queries[j] is true, and false otherwise.\n \nExample 1:\n\n\nInput: n = 3, edgeList = [[0,1,2],[1,2,4],[2,0,8],[1,0,16]], queries = [[0,1,2],[0,2,5]]\nOutput: [false,true]\nExplanation: The above figure shows the given graph. Note that there are two overlapping edges between 0 and 1 with distances 2 and 16.\nFor the first query, between 0 and 1 there is no path where each distance is less than 2, thus we return false for this query.\nFor the second query, there is a path (0 -> 1 -> 2) of two edges with distances less than 5, thus we return true for this query.\n\nExample 2:\n\n\nInput: n = 5, edgeList = [[0,1,10],[1,2,5],[2,3,9],[3,4,13]], queries = [[0,4,14],[1,4,13]]\nOutput: [true,false]\nExplanation: The above figure shows the given graph.\n\n \nConstraints:\n\n2 <= n <= 105\n1 <= edgeList.length, queries.length <= 105\nedgeList[i].length == 3\nqueries[j].length == 3\n0 <= ui, vi, pj, qj <= n - 1\nui != vi\npj != qj\n1 <= disi, limitj <= 109\nThere may be multiple edges between two nodes.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3,edgeList = [[0, 1, 2], [1, 2, 4], [2, 0, 8], [1, 0, 16]],queries = [[0, 1, 2], [0, 2, 5]]) == [False, True]\n assert candidate(n = 7,edgeList = [[0, 1, 5], [1, 2, 7], [2, 3, 10], [3, 4, 3], [4, 5, 2], [5, 6, 6], [6, 0, 1]],queries = [[0, 6, 8], [3, 5, 4]]) == [True, True]\n assert candidate(n = 6,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5]],queries = [[0, 5, 6], [0, 5, 10], [0, 5, 3]]) == [True, True, False]\n assert candidate(n = 7,edgeList = [[0, 1, 9], [0, 2, 3], [1, 3, 2], [2, 3, 8], [2, 4, 6], [3, 4, 5], [3, 5, 7], [4, 5, 1]],queries = [[0, 4, 8], [1, 2, 4], [3, 5, 6]]) == [True, False, True]\n assert candidate(n = 6,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5]],queries = [[0, 5, 6], [1, 4, 5], [2, 3, 4]]) == [True, True, True]\n assert candidate(n = 4,edgeList = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 0, 20]],queries = [[0, 3, 15], [1, 2, 8]]) == [False, False]\n assert candidate(n = 2,edgeList = [[0, 1, 1]],queries = [[0, 1, 2], [0, 1, 1]]) == [True, False]\n assert candidate(n = 6,edgeList = [[0, 1, 4], [1, 2, 3], [2, 3, 1], [3, 4, 5], [4, 5, 6]],queries = [[0, 5, 10], [1, 4, 8]]) == [True, True]\n assert candidate(n = 4,edgeList = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 0, 1]],queries = [[0, 3, 2], [1, 2, 1]]) == [True, False]\n assert candidate(n = 4,edgeList = [[0, 1, 3], [1, 2, 1], [2, 3, 2], [3, 0, 4]],queries = [[0, 2, 4], [1, 3, 5]]) == [True, True]\n assert candidate(n = 5,edgeList = [[0, 1, 10], [1, 2, 5], [2, 3, 9], [3, 4, 13]],queries = [[0, 4, 14], [1, 4, 13]]) == [True, False]\n assert candidate(n = 10,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [0, 9, 5]],queries = [[0, 9, 4], [0, 9, 5], [0, 9, 6], [0, 9, 7], [0, 9, 8]]) == [False, False, True, True, True]\n assert candidate(n = 12,edgeList = [[0, 1, 100], [1, 2, 200], [2, 3, 300], [3, 4, 400], [4, 5, 500], [5, 6, 600], [6, 7, 700], [7, 8, 800], [8, 9, 900], [9, 10, 1000], [10, 11, 1100], [11, 0, 1200], [0, 2, 150], [2, 4, 250], [4, 6, 350], [6, 8, 450], [8, 10, 550], [10, 1, 650], [1, 3, 750], [3, 5, 850], [5, 7, 950], [7, 9, 1050], [9, 11, 1150], [11, 3, 1250]],queries = [[0, 11, 700], [2, 10, 550], [4, 8, 400], [6, 0, 250]]) == [False, False, False, False]\n assert candidate(n = 6,edgeList = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 0, 5], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 5, 10], [4, 0, 10], [5, 1, 10]],queries = [[0, 3, 6], [1, 4, 7], [2, 5, 8]]) == [True, True, True]\n assert candidate(n = 50,edgeList = [[0, 1, 100], [1, 2, 200], [2, 3, 300], [3, 4, 400], [4, 5, 500], [5, 6, 600], [6, 7, 700], [7, 8, 800], [8, 9, 900], [9, 10, 1000], [10, 11, 1100], [11, 12, 1200], [12, 13, 1300], [13, 14, 1400], [14, 15, 1500], [15, 16, 1600], [16, 17, 1700], [17, 18, 1800], [18, 19, 1900], [19, 20, 2000], [20, 21, 2100], [21, 22, 2200], [22, 23, 2300], [23, 24, 2400], [24, 25, 2500], [25, 26, 2600], [26, 27, 2700], [27, 28, 2800], [28, 29, 2900], [29, 30, 3000], [30, 31, 3100], [31, 32, 3200], [32, 33, 3300], [33, 34, 3400], [34, 35, 3500], [35, 36, 3600], [36, 37, 3700], [37, 38, 3800], [38, 39, 3900], [39, 40, 4000], [40, 41, 4100], [41, 42, 4200], [42, 43, 4300], [43, 44, 4400], [44, 45, 4500], [45, 46, 4600], [46, 47, 4700], [47, 48, 4800], [48, 49, 4900], [49, 0, 5000]],queries = [[0, 49, 5010], [1, 48, 5020], [2, 47, 5030], [3, 46, 5040], [4, 45, 5050], [5, 44, 5060], [6, 43, 5070], [7, 42, 5080], [8, 41, 5090], [9, 40, 5100], [10, 39, 5110], [11, 38, 5120], [12, 37, 5130], [13, 36, 5140], [14, 35, 5150], [15, 34, 5160], [16, 33, 5170], [17, 32, 5180], [18, 31, 5190], [19, 30, 5200], [20, 29, 5210], [21, 28, 5220], [22, 27, 5230], [23, 26, 5240], [24, 25, 5250], [0, 25, 2600], [1, 24, 2700], [2, 23, 2800], [3, 22, 2900], [4, 21, 3000], [5, 20, 3100], [6, 19, 3200], [7, 18, 3300], [8, 17, 3400], [9, 16, 3500], [10, 15, 3600], [11, 14, 3700], [12, 13, 3800]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 20,edgeList = [[0, 1, 2], [1, 2, 4], [2, 3, 6], [3, 4, 8], [4, 5, 10], [5, 6, 12], [6, 7, 14], [7, 8, 16], [8, 9, 18], [9, 10, 20], [10, 11, 22], [11, 12, 24], [12, 13, 26], [13, 14, 28], [14, 15, 30], [15, 16, 32], [16, 17, 34], [17, 18, 36], [18, 19, 38]],queries = [[0, 19, 40], [1, 18, 39], [2, 17, 38], [3, 16, 37], [4, 15, 36], [5, 14, 35], [6, 13, 34], [7, 12, 33], [8, 11, 32], [9, 10, 31]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 15,edgeList = [[0, 1, 100], [1, 2, 200], [2, 3, 300], [3, 4, 400], [4, 5, 500], [5, 6, 600], [6, 7, 700], [7, 8, 800], [8, 9, 900], [9, 10, 1000], [10, 11, 1100], [11, 12, 1200], [12, 13, 1300], [13, 14, 1400], [14, 0, 1500]],queries = [[0, 14, 1200], [1, 13, 1100], [2, 12, 1000], [3, 11, 900], [4, 10, 800]]) == [False, False, False, False, False]\n assert candidate(n = 6,edgeList = [[0, 1, 100], [0, 2, 200], [1, 3, 300], [2, 3, 400], [1, 4, 500], [2, 5, 600], [3, 5, 700]],queries = [[0, 5, 800], [0, 5, 400], [0, 3, 350], [0, 4, 600]]) == [True, False, True, True]\n assert candidate(n = 12,edgeList = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [0, 4, 10], [4, 5, 20], [5, 6, 25], [6, 7, 30], [7, 8, 35], [8, 9, 40], [9, 10, 45], [10, 11, 50], [0, 11, 60]],queries = [[0, 11, 65], [0, 11, 55], [0, 5, 25], [5, 10, 45]]) == [True, True, True, False]\n assert candidate(n = 8,edgeList = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 0, 80], [0, 3, 5], [1, 4, 15], [2, 5, 25], [3, 6, 35], [4, 7, 45], [5, 0, 55], [6, 1, 65], [7, 2, 75]],queries = [[0, 7, 40], [2, 6, 35], [4, 0, 60], [1, 5, 75]]) == [False, False, True, True]\n assert candidate(n = 10,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [0, 9, 10]],queries = [[0, 9, 5], [0, 9, 15], [2, 7, 6]]) == [False, True, False]\n assert candidate(n = 8,edgeList = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [0, 7, 9], [0, 6, 10], [1, 5, 11], [2, 4, 12]],queries = [[0, 7, 8], [1, 5, 9], [2, 4, 10], [3, 6, 11], [0, 5, 12], [1, 6, 13], [2, 7, 14], [0, 4, 15], [3, 5, 16], [0, 6, 17]]) == [False, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10,edgeList = [[0, 1, 2], [0, 2, 3], [1, 2, 4], [2, 3, 5], [3, 4, 6], [4, 5, 7], [5, 6, 8], [6, 7, 9], [7, 8, 10], [8, 9, 11], [9, 0, 12]],queries = [[0, 9, 13], [1, 8, 15], [2, 7, 17], [3, 6, 19], [4, 5, 21]]) == [True, True, True, True, True]\n assert candidate(n = 10,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9]],queries = [[0, 9, 10], [0, 5, 6], [3, 7, 5]]) == [True, True, False]\n assert candidate(n = 25,edgeList = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 8, 80], [8, 9, 90], [9, 10, 100], [10, 11, 110], [11, 12, 120], [12, 13, 130], [13, 14, 140], [14, 15, 150], [15, 16, 160], [16, 17, 170], [17, 18, 180], [18, 19, 190], [19, 20, 200], [20, 21, 210], [21, 22, 220], [22, 23, 230], [23, 24, 240], [0, 24, 250]],queries = [[0, 24, 200], [0, 24, 251], [2, 23, 225], [5, 20, 160]]) == [False, True, False, False]\n assert candidate(n = 10,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10]],queries = [[0, 9, 11], [2, 6, 6], [1, 8, 15]]) == [True, False, True]\n assert candidate(n = 15,edgeList = [[0, 1, 100], [1, 2, 200], [2, 3, 150], [3, 4, 250], [4, 5, 300], [5, 6, 350], [6, 7, 400], [7, 8, 450], [8, 9, 500], [9, 10, 550], [10, 11, 600], [11, 12, 650], [12, 13, 700], [13, 14, 750]],queries = [[0, 14, 800], [1, 13, 900], [2, 12, 1000], [3, 11, 1100], [4, 10, 1200], [5, 9, 1300]]) == [True, True, True, True, True, True]\n assert candidate(n = 10,edgeList = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 0, 1]],queries = [[0, 9, 15], [2, 6, 8], [4, 7, 12]]) == [True, True, True]\n assert candidate(n = 20,edgeList = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40], [8, 9, 45], [9, 10, 50], [10, 11, 55], [11, 12, 60], [12, 13, 65], [13, 14, 70], [14, 15, 75], [15, 16, 80], [16, 17, 85], [17, 18, 90], [18, 19, 95], [19, 0, 100]],queries = [[0, 19, 200], [5, 15, 150], [10, 15, 100]]) == [True, True, True]\n assert candidate(n = 10,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10], [0, 5, 11], [5, 1, 12]],queries = [[0, 9, 11], [1, 8, 10], [2, 7, 9], [3, 6, 8], [4, 5, 7]]) == [True, True, True, True, True]\n assert candidate(n = 11,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [0, 10, 11]],queries = [[0, 10, 12], [0, 10, 6], [0, 5, 8], [5, 10, 7], [2, 8, 9], [3, 7, 10]]) == [True, False, True, False, True, True]\n assert candidate(n = 20,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [19, 0, 20]],queries = [[0, 19, 15], [1, 18, 14], [2, 17, 13], [3, 16, 12], [4, 15, 11]]) == [False, False, False, False, False]\n assert candidate(n = 50,edgeList = [[0, 1, 5], [1, 2, 15], [2, 3, 25], [3, 4, 35], [4, 5, 45], [5, 6, 55], [6, 7, 65], [7, 8, 75], [8, 9, 85], [9, 10, 95], [10, 11, 105], [11, 12, 115], [12, 13, 125], [13, 14, 135], [14, 15, 145], [15, 16, 155], [16, 17, 165], [17, 18, 175], [18, 19, 185], [19, 20, 195], [20, 21, 205], [21, 22, 215], [22, 23, 225], [23, 24, 235], [24, 25, 245], [25, 26, 255], [26, 27, 265], [27, 28, 275], [28, 29, 285], [29, 30, 295], [30, 31, 305], [31, 32, 315], [32, 33, 325], [33, 34, 335], [34, 35, 345], [35, 36, 355], [36, 37, 365], [37, 38, 375], [38, 39, 385], [39, 40, 395], [40, 41, 405], [41, 42, 415], [42, 43, 425], [43, 44, 435], [44, 45, 445], [45, 46, 455], [46, 47, 465], [47, 48, 475], [48, 49, 485]],queries = [[0, 49, 500], [10, 30, 310], [20, 40, 410]]) == [True, True, True]\n assert candidate(n = 20,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [0, 19, 20]],queries = [[0, 19, 10], [0, 19, 21], [2, 18, 15], [5, 15, 10]]) == [False, True, False, False]\n assert candidate(n = 50,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [19, 20, 20], [20, 21, 21], [21, 22, 22], [22, 23, 23], [23, 24, 24], [24, 25, 25], [25, 26, 26], [26, 27, 27], [27, 28, 28], [28, 29, 29], [29, 30, 30], [30, 31, 31], [31, 32, 32], [32, 33, 33], [33, 34, 34], [34, 35, 35], [35, 36, 36], [36, 37, 37], [37, 38, 38], [38, 39, 39], [39, 40, 40], [40, 41, 41], [41, 42, 42], [42, 43, 43], [43, 44, 44], [44, 45, 45], [45, 46, 46], [46, 47, 47], [47, 48, 48], [48, 49, 49], [0, 49, 50]],queries = [[0, 49, 40], [0, 49, 51], [2, 48, 45], [5, 45, 30]]) == [False, True, False, False]\n assert candidate(n = 15,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15], [0, 2, 16], [2, 4, 17], [4, 6, 18], [6, 8, 19], [8, 10, 20], [10, 12, 21], [12, 14, 22], [14, 1, 23], [1, 3, 24], [3, 5, 25], [5, 7, 26], [7, 9, 27], [9, 11, 28], [11, 13, 29], [13, 0, 30]],queries = [[0, 14, 15], [2, 12, 13], [4, 10, 11], [6, 8, 9], [8, 6, 8], [10, 4, 10], [12, 2, 16], [14, 0, 14]]) == [True, True, True, True, False, False, True, False]\n assert candidate(n = 20,edgeList = [[0, 1, 100], [1, 2, 200], [2, 3, 300], [3, 4, 400], [4, 5, 500], [5, 6, 600], [6, 7, 700], [7, 8, 800], [8, 9, 900], [9, 10, 1000], [10, 11, 1100], [11, 12, 1200], [12, 13, 1300], [13, 14, 1400], [14, 15, 1500], [15, 16, 1600], [16, 17, 1700], [17, 18, 1800], [18, 19, 1900], [0, 19, 2000]],queries = [[0, 19, 1900], [0, 19, 2000], [1, 18, 3800], [2, 17, 5400], [3, 16, 6900]]) == [False, True, True, True, True]\n assert candidate(n = 15,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15], [0, 7, 20], [1, 8, 21], [2, 9, 22], [3, 10, 23], [4, 11, 24], [5, 12, 25], [6, 13, 26], [7, 14, 27], [8, 0, 28], [9, 1, 29], [10, 2, 30], [11, 3, 31], [12, 4, 32], [13, 5, 33], [14, 6, 34]],queries = [[0, 14, 16], [1, 13, 17], [2, 12, 18], [3, 11, 19], [4, 10, 20], [5, 9, 21], [6, 8, 22], [7, 0, 23], [8, 1, 24], [9, 2, 25], [10, 3, 26], [11, 4, 27], [12, 5, 28], [13, 6, 29], [0, 7, 35], [1, 8, 36], [2, 9, 37], [3, 10, 38], [4, 11, 39], [5, 12, 40], [6, 13, 41], [7, 14, 42]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 15,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [0, 14, 15]],queries = [[0, 14, 10], [0, 14, 16], [2, 12, 8]]) == [False, True, False]\n assert candidate(n = 10,edgeList = [[0, 1, 1], [0, 2, 3], [1, 2, 2], [3, 4, 5], [4, 5, 4], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9]],queries = [[0, 9, 10], [2, 5, 5], [4, 7, 12], [1, 8, 15]]) == [False, False, True, False]\n assert candidate(n = 8,edgeList = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 4, 4], [1, 5, 5], [2, 6, 6], [2, 7, 7], [3, 4, 8], [3, 5, 9], [4, 6, 10], [5, 7, 11]],queries = [[0, 7, 12], [1, 6, 10], [2, 5, 9], [3, 4, 8], [0, 4, 7]]) == [True, True, True, True, True]\n assert candidate(n = 15,edgeList = [[0, 1, 100], [1, 2, 200], [2, 3, 300], [3, 4, 400], [4, 5, 500], [5, 6, 600], [6, 7, 700], [7, 8, 800], [8, 9, 900], [9, 10, 1000], [10, 11, 1100], [11, 12, 1200], [12, 13, 1300], [13, 14, 1400]],queries = [[0, 14, 1500], [5, 10, 800], [3, 7, 600]]) == [True, False, False]\n assert candidate(n = 15,edgeList = [[0, 1, 20], [1, 2, 30], [2, 3, 40], [3, 4, 50], [4, 5, 60], [5, 6, 70], [6, 7, 80], [7, 8, 90], [8, 9, 100], [9, 10, 110], [10, 11, 120], [11, 12, 130], [12, 13, 140], [13, 14, 150], [14, 0, 160]],queries = [[0, 14, 300], [3, 7, 200], [6, 10, 150]]) == [True, True, True]\n assert candidate(n = 15,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15]],queries = [[0, 7, 8], [1, 8, 9], [2, 9, 10], [3, 10, 11], [4, 11, 12], [5, 12, 13], [6, 13, 14]]) == [True, True, True, True, True, True, True]\n assert candidate(n = 10,edgeList = [[0, 1, 3], [1, 2, 2], [2, 3, 1], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [0, 9, 10]],queries = [[0, 9, 9], [0, 9, 11], [1, 8, 15], [2, 7, 20]]) == [False, True, True, True]\n assert candidate(n = 20,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [19, 0, 20]],queries = [[0, 10, 11], [1, 11, 12], [2, 12, 13], [3, 13, 14], [4, 14, 15], [5, 15, 16], [6, 16, 17], [7, 17, 18], [8, 18, 19], [9, 19, 20]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10,edgeList = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 0, 1], [0, 9, 2], [1, 8, 2], [2, 7, 2], [3, 6, 2], [4, 5, 2]],queries = [[0, 4, 2], [5, 9, 2], [3, 7, 2]]) == [True, True, True]\n assert candidate(n = 8,edgeList = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [2, 3, 4], [1, 4, 5], [2, 5, 6], [3, 6, 7], [4, 7, 8], [5, 7, 9]],queries = [[0, 7, 15], [1, 6, 10], [2, 5, 7], [3, 4, 4]]) == [True, True, True, False]\n assert candidate(n = 7,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6]],queries = [[0, 6, 7], [0, 5, 6], [0, 4, 5], [0, 3, 4], [0, 2, 3], [0, 1, 2]]) == [True, True, True, True, True, True]\n assert candidate(n = 15,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14]],queries = [[0, 14, 15], [1, 13, 25], [2, 12, 30], [3, 11, 35], [4, 10, 40]]) == [True, True, True, True, True]\n assert candidate(n = 8,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8], [0, 2, 3], [1, 3, 4], [2, 4, 5], [3, 5, 6], [4, 6, 7], [5, 7, 8]],queries = [[0, 7, 9], [1, 6, 10], [2, 5, 11]]) == [True, True, True]\n assert candidate(n = 12,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 0, 12]],queries = [[0, 6, 7], [1, 7, 8], [2, 8, 9], [3, 9, 10], [4, 10, 11], [5, 11, 12]]) == [True, True, True, True, True, True]\n assert candidate(n = 9,edgeList = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [0, 8, 9], [1, 7, 10], [2, 6, 11], [3, 5, 12]],queries = [[0, 8, 13], [1, 7, 11], [2, 6, 9], [3, 5, 7]]) == [True, True, True, True]\n assert candidate(n = 12,edgeList = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 8, 80], [8, 9, 90], [9, 10, 100], [10, 11, 110], [11, 0, 120], [0, 6, 130], [1, 7, 140], [2, 8, 150], [3, 9, 160], [4, 10, 170], [5, 11, 180]],queries = [[0, 11, 125], [1, 10, 135], [2, 9, 145], [3, 8, 155], [4, 7, 165], [5, 6, 175], [0, 7, 185], [1, 8, 195], [2, 11, 205], [3, 0, 215]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 20,edgeList = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 8, 80], [8, 9, 90], [9, 10, 100], [10, 11, 110], [11, 12, 120], [12, 13, 130], [13, 14, 140], [14, 15, 150], [15, 16, 160], [16, 17, 170], [17, 18, 180], [18, 19, 190], [19, 0, 200]],queries = [[0, 19, 210], [1, 18, 220], [2, 17, 230], [3, 16, 240], [4, 15, 250], [5, 14, 260], [6, 13, 270], [7, 12, 280], [8, 11, 290], [9, 10, 300]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10,edgeList = [[0, 1, 3], [1, 2, 1], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 0, 2]],queries = [[0, 9, 15], [2, 5, 12], [1, 8, 6]]) == [True, True, False]\n assert candidate(n = 20,edgeList = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 8, 80], [8, 9, 90], [9, 10, 100], [10, 11, 110], [11, 12, 120], [12, 13, 130], [13, 14, 140], [14, 15, 150], [15, 16, 160], [16, 17, 170], [17, 18, 180], [18, 19, 190]],queries = [[0, 19, 200], [5, 15, 120], [3, 10, 80]]) == [True, False, False]\n assert candidate(n = 10,edgeList = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10]],queries = [[0, 9, 11], [0, 9, 5], [0, 4, 10]]) == [True, False, True]\n assert candidate(n = 10,edgeList = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40], [8, 9, 45], [9, 0, 50], [0, 5, 55], [5, 1, 60], [1, 6, 65], [6, 2, 70], [2, 7, 75]],queries = [[0, 9, 60], [1, 8, 55], [2, 7, 50], [3, 6, 45], [4, 5, 40]]) == [True, True, True, True, True]\n assert candidate(n = 18,edgeList = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40], [8, 9, 45], [9, 10, 50], [10, 11, 55], [11, 12, 60], [12, 13, 65], [13, 14, 70], [14, 15, 75], [15, 16, 80], [16, 17, 85], [17, 0, 90], [0, 8, 95], [1, 9, 100], [2, 10, 105], [3, 11, 110], [4, 12, 115], [5, 13, 120], [6, 14, 125], [7, 15, 130], [8, 16, 135], [9, 17, 140], [10, 0, 145], [11, 1, 150], [12, 2, 155], [13, 3, 160], [14, 4, 165], [15, 5, 170], [16, 6, 175], [17, 7, 180]],queries = [[0, 17, 175], [1, 16, 180], [2, 15, 185], [3, 14, 190], [4, 13, 195], [5, 12, 200], [6, 11, 205], [7, 10, 210], [8, 9, 215], [0, 15, 220], [1, 14, 225], [2, 13, 230], [3, 12, 235], [4, 11, 240], [5, 10, 245], [6, 9, 250], [7, 8, 255], [0, 14, 260], [1, 13, 265], [2, 12, 270], [3, 11, 275], [4, 10, 280], [5, 9, 285], [6, 8, 290], [0, 13, 295], [1, 12, 300], [2, 11, 305], [3, 10, 310], [4, 9, 315], [5, 8, 320], [0, 12, 325], [1, 11, 330], [2, 10, 335], [3, 9, 340], [4, 8, 345], [0, 11, 350], [1, 10, 355], [2, 9, 360], [3, 8, 365], [0, 10, 370], [1, 9, 375], [2, 8, 380], [0, 9, 385], [1, 8, 390], [0, 8, 395]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 15,edgeList = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [2, 4, 40], [3, 5, 50], [4, 6, 60], [5, 7, 70], [6, 8, 80], [7, 9, 90], [8, 10, 100], [9, 11, 110], [10, 12, 120], [11, 13, 130], [12, 14, 140]],queries = [[0, 14, 150], [0, 14, 75], [0, 7, 85], [7, 14, 110]]) == [True, False, True, False]\n assert candidate(n = 6,edgeList = [[0, 1, 20], [1, 2, 30], [2, 3, 40], [3, 4, 50], [4, 5, 60], [5, 0, 70], [0, 2, 15], [2, 4, 25], [4, 1, 35], [1, 3, 45], [3, 5, 55], [5, 2, 65]],queries = [[0, 5, 50], [1, 4, 40], [2, 3, 30]]) == [False, True, False]\n"}, "metadata": {"canonical_parameter_names": ["n", "edgeList", "queries"], "leetcode_dataset_entry_point": "Solution().distanceLimitedPathsExist", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector distanceLimitedPathsExist(int n, vector>& edgeList, vector>& queries) {", "container": "Solution", "callable": "distanceLimitedPathsExist", "parameters": [{"name": "n", "type": "int"}, {"name": "edgeList", "type": "vector>&"}, {"name": "queries", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1700, "task_id": "number-of-students-unable-to-eat-lunch", "difficulty": "Easy", "problem_description": "The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers 0 and 1 respectively. All students stand in a queue. Each student either prefers square or circular sandwiches.\nThe number of sandwiches in the cafeteria is equal to the number of students. The sandwiches are placed in a stack. At each step:\n\nIf the student at the front of the queue prefers the sandwich on the top of the stack, they will take it and leave the queue.\nOtherwise, they will leave it and go to the queue's end.\n\nThis continues until none of the queue students want to take the top sandwich and are thus unable to eat.\nYou are given two integer arrays students and sandwiches where sandwiches[i] is the type of the i​​​​​​th sandwich in the stack (i = 0 is the top of the stack) and students[j] is the preference of the j​​​​​​th student in the initial queue (j = 0 is the front of the queue). Return the number of students that are unable to eat.\n \nExample 1:\n\nInput: students = [1,1,0,0], sandwiches = [0,1,0,1]\nOutput: 0 \nExplanation:\n- Front student leaves the top sandwich and returns to the end of the line making students = [1,0,0,1].\n- Front student leaves the top sandwich and returns to the end of the line making students = [0,0,1,1].\n- Front student takes the top sandwich and leaves the line making students = [0,1,1] and sandwiches = [1,0,1].\n- Front student leaves the top sandwich and returns to the end of the line making students = [1,1,0].\n- Front student takes the top sandwich and leaves the line making students = [1,0] and sandwiches = [0,1].\n- Front student leaves the top sandwich and returns to the end of the line making students = [0,1].\n- Front student takes the top sandwich and leaves the line making students = [1] and sandwiches = [1].\n- Front student takes the top sandwich and leaves the line making students = [] and sandwiches = [].\nHence all students are able to eat.\n\nExample 2:\n\nInput: students = [1,1,1,0,0,1], sandwiches = [1,0,0,0,1,1]\nOutput: 3\n\n \nConstraints:\n\n1 <= students.length, sandwiches.length <= 100\nstudents.length == sandwiches.length\nsandwiches[i] is 0 or 1.\nstudents[i] is 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(students = [0, 1, 0, 1],sandwiches = [1, 0, 1, 0]) == 0\n assert candidate(students = [1, 1, 1, 0, 0, 1],sandwiches = [1, 0, 0, 0, 1, 1]) == 3\n assert candidate(students = [0, 0, 1, 1],sandwiches = [1, 1, 0, 0]) == 0\n assert candidate(students = [1, 0, 1, 0],sandwiches = [0, 1, 0, 1]) == 0\n assert candidate(students = [0, 0, 0, 0],sandwiches = [0, 0, 0, 0]) == 0\n assert candidate(students = [0, 1, 0, 1],sandwiches = [0, 1, 0, 1]) == 0\n assert candidate(students = [1, 1, 0, 0],sandwiches = [0, 1, 0, 1]) == 0\n assert candidate(students = [1, 1, 1, 1],sandwiches = [1, 1, 1, 1]) == 0\n assert candidate(students = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 1, 1, 0, 0, 0, 0, 1, 1],sandwiches = [0, 0, 0, 1, 1, 1, 0, 1, 1]) == 0\n assert candidate(students = [1, 0, 0, 1, 1, 0, 0, 1],sandwiches = [1, 1, 1, 1, 0, 0, 0, 0]) == 0\n assert candidate(students = [1, 0, 0, 1, 0, 1, 1, 0],sandwiches = [1, 1, 0, 0, 1, 1, 0, 0]) == 0\n assert candidate(students = [1, 1, 1, 1, 0, 0, 0, 0, 0, 0],sandwiches = [0, 0, 0, 0, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(students = [0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 1, 0, 0, 1, 0, 1, 0, 0, 1],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 1, 0, 0, 1, 0, 1, 0],sandwiches = [0, 0, 1, 0, 1, 1, 0, 1]) == 0\n assert candidate(students = [0, 1, 1, 1, 0, 1, 0, 0, 1, 0],sandwiches = [0, 1, 0, 1, 1, 1, 1, 0, 0, 0]) == 0\n assert candidate(students = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],sandwiches = [0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0]) == 0\n assert candidate(students = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1],sandwiches = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0]) == 2\n assert candidate(students = [1, 0, 0, 1, 1, 0, 1, 0, 0, 1],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0],sandwiches = [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) == 0\n assert candidate(students = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0],sandwiches = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]) == 0\n assert candidate(students = [1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1],sandwiches = [1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1]) == 0\n assert candidate(students = [1, 1, 1, 0, 0, 0, 0, 1, 1],sandwiches = [1, 0, 0, 0, 1, 0, 0, 1, 0]) == 3\n assert candidate(students = [0, 1, 1, 0, 0, 1, 1, 0, 0, 1],sandwiches = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0]) == 0\n assert candidate(students = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1],sandwiches = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 2\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0],sandwiches = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(students = [1, 1, 0, 0, 1, 1, 0, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0],sandwiches = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0]) == 0\n assert candidate(students = [1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1],sandwiches = [0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],sandwiches = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 0\n assert candidate(students = [1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1],sandwiches = [1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 0, 0, 1, 1, 1, 1, 0, 0, 0],sandwiches = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0]) == 3\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(students = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0],sandwiches = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]) == 0\n assert candidate(students = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sandwiches = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(students = [0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 1\n assert candidate(students = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1],sandwiches = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 2\n assert candidate(students = [1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0],sandwiches = [0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1]) == 0\n assert candidate(students = [0, 1, 1, 0, 1, 0, 0, 1],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [1, 1, 0, 0, 1, 1, 0, 0, 0]) == 0\n assert candidate(students = [0, 0, 0, 0, 1, 1, 1, 1, 1, 1],sandwiches = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0]) == 0\n assert candidate(students = [0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0],sandwiches = [1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0],sandwiches = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 0, 0, 1, 0, 0, 1, 1, 0, 1],sandwiches = [0, 1, 1, 0, 1, 1, 0, 1, 0, 0]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 0, 1, 1, 0, 0, 1, 1],sandwiches = [0, 0, 1, 1, 0, 0, 1, 1]) == 0\n assert candidate(students = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 1, 0, 0, 1, 0, 0, 1, 1, 0],sandwiches = [0, 0, 1, 1, 0, 0, 1, 1, 0, 0]) == 1\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0],sandwiches = [1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]) == 4\n assert candidate(students = [1, 1, 0, 0, 0, 0, 1, 1],sandwiches = [1, 1, 0, 0, 0, 0, 1, 1]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1],sandwiches = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == 0\n assert candidate(students = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1],sandwiches = [1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(students = [1, 1, 0, 0, 1, 0, 1, 1, 0, 0],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 0, 0, 1, 1, 0, 0, 1],sandwiches = [1, 0, 1, 0, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1],sandwiches = [1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0]) == 1\n assert candidate(students = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1],sandwiches = [0, 1, 0, 1, 0, 1, 0]) == 1\n assert candidate(students = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1],sandwiches = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(students = [1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 1],sandwiches = [1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0]) == 1\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [0, 0, 1, 1, 0, 0, 1, 1, 1]) == 0\n assert candidate(students = [0, 1, 1, 0, 1, 1, 0, 0, 1],sandwiches = [1, 1, 0, 0, 1, 1, 0, 0, 1]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 1, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 0, 1, 1, 0, 0, 0, 1],sandwiches = [0, 1, 1, 0, 0, 0, 1, 1]) == 0\n assert candidate(students = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],sandwiches = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(students = [0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1],sandwiches = [1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1]) == 0\n assert candidate(students = [1, 1, 0, 0, 1, 1, 0, 0],sandwiches = [0, 0, 1, 1, 0, 0, 1, 1]) == 0\n assert candidate(students = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],sandwiches = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(students = [0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0],sandwiches = [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0],sandwiches = [1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0]) == 0\n assert candidate(students = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sandwiches = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 69\n assert candidate(students = [1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0],sandwiches = [0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1]) == 0\n assert candidate(students = [0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(students = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],sandwiches = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(students = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],sandwiches = [0, 0, 0, 0, 1, 1, 1, 1, 0, 0]) == 1\n"}, "metadata": {"canonical_parameter_names": ["students", "sandwiches"], "leetcode_dataset_entry_point": "Solution().countStudents", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countStudents(vector& students, vector& sandwiches) {", "container": "Solution", "callable": "countStudents", "parameters": [{"name": "students", "type": "vector&"}, {"name": "sandwiches", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1701, "task_id": "average-waiting-time", "difficulty": "Medium", "problem_description": "There is a restaurant with a single chef. You are given an array customers, where customers[i] = [arrivali, timei]:\n\narrivali is the arrival time of the ith customer. The arrival times are sorted in non-decreasing order.\ntimei is the time needed to prepare the order of the ith customer.\n\nWhen a customer arrives, he gives the chef his order, and the chef starts preparing it once he is idle. The customer waits till the chef finishes preparing his order. The chef does not prepare food for more than one customer at a time. The chef prepares food for customers in the order they were given in the input.\nReturn the average waiting time of all customers. Solutions within 10-5 from the actual answer are considered accepted.\n \nExample 1:\n\nInput: customers = [[1,2],[2,5],[4,3]]\nOutput: 5.00000\nExplanation:\n1) The first customer arrives at time 1, the chef takes his order and starts preparing it immediately at time 1, and finishes at time 3, so the waiting time of the first customer is 3 - 1 = 2.\n2) The second customer arrives at time 2, the chef takes his order and starts preparing it at time 3, and finishes at time 8, so the waiting time of the second customer is 8 - 2 = 6.\n3) The third customer arrives at time 4, the chef takes his order and starts preparing it at time 8, and finishes at time 11, so the waiting time of the third customer is 11 - 4 = 7.\nSo the average waiting time = (2 + 6 + 7) / 3 = 5.\n\nExample 2:\n\nInput: customers = [[5,2],[5,4],[10,3],[20,1]]\nOutput: 3.25000\nExplanation:\n1) The first customer arrives at time 5, the chef takes his order and starts preparing it immediately at time 5, and finishes at time 7, so the waiting time of the first customer is 7 - 5 = 2.\n2) The second customer arrives at time 5, the chef takes his order and starts preparing it at time 7, and finishes at time 11, so the waiting time of the second customer is 11 - 5 = 6.\n3) The third customer arrives at time 10, the chef takes his order and starts preparing it at time 11, and finishes at time 14, so the waiting time of the third customer is 14 - 10 = 4.\n4) The fourth customer arrives at time 20, the chef takes his order and starts preparing it immediately at time 20, and finishes at time 21, so the waiting time of the fourth customer is 21 - 20 = 1.\nSo the average waiting time = (2 + 6 + 4 + 1) / 4 = 3.25.\n\n \nConstraints:\n\n1 <= customers.length <= 105\n1 <= arrivali, timei <= 104\narrivali <= arrivali+1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(customers = [[5, 2], [5, 4], [10, 3], [20, 1]]) == 3.25\n assert candidate(customers = [[1, 1], [1, 1], [1, 1], [1, 1]]) == 2.5\n assert candidate(customers = [[1, 1], [1, 1], [1, 1]]) == 2.0\n assert candidate(customers = [[1, 3], [2, 3], [6, 3], [10, 3]]) == 3.75\n assert candidate(customers = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 5.0\n assert candidate(customers = [[1, 3], [2, 3], [6, 3]]) == 4.0\n assert candidate(customers = [[1, 2], [2, 5], [4, 3]]) == 5.0\n assert candidate(customers = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]]) == 28.0\n assert candidate(customers = [[2, 3], [6, 3], [10, 3], [15, 3]]) == 3.0\n assert candidate(customers = [[1, 5], [2, 2], [3, 3], [4, 4], [5, 5]]) == 9.0\n assert candidate(customers = [[1, 10], [10, 10], [20, 10], [30, 10], [40, 10]]) == 10.8\n assert candidate(customers = [[1, 3], [2, 2], [3, 1]]) == 3.6666666666666665\n assert candidate(customers = [[10, 5], [15, 2], [20, 3], [30, 1]]) == 2.75\n assert candidate(customers = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == 5.5\n assert candidate(customers = [[1, 1000], [1010, 500], [1510, 250], [1760, 125], [1885, 62], [1947, 31], [1978, 15], [1993, 7], [1999, 3], [2001, 1]]) == 199.7\n assert candidate(customers = [[1, 1], [3, 1], [5, 1], [7, 1], [9, 1], [11, 1], [13, 1], [15, 1], [17, 1], [19, 1], [21, 1], [23, 1], [25, 1], [27, 1], [29, 1]]) == 1.0\n assert candidate(customers = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 35.0\n assert candidate(customers = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]]) == 1.0\n assert candidate(customers = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [110, 11], [120, 12], [130, 13], [140, 14], [150, 15]]) == 9.333333333333334\n assert candidate(customers = [[1, 100], [101, 50], [151, 200], [251, 100], [351, 300], [451, 150], [601, 50], [651, 100], [751, 250], [851, 50]]) == 320.0\n assert candidate(customers = [[1, 5], [2, 3], [3, 4], [10, 2], [15, 5], [20, 1], [25, 3], [30, 4], [35, 2], [40, 5]]) == 4.7\n assert candidate(customers = [[1, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 2], [4, 3], [4, 4], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5]]) == 13.692307692307692\n assert candidate(customers = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 14.0\n assert candidate(customers = [[1, 5], [2, 3], [3, 4], [4, 2], [5, 6], [6, 1]]) == 10.833333333333334\n assert candidate(customers = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2], [11, 2], [12, 2], [13, 2], [14, 2], [15, 2], [16, 2], [17, 2], [18, 2], [19, 2], [20, 2]]) == 11.5\n assert candidate(customers = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [11, 10], [12, 10], [13, 10], [14, 10], [15, 10], [16, 10], [17, 10], [18, 10], [19, 10], [20, 10], [21, 10], [22, 10], [23, 10], [24, 10], [25, 10], [26, 10], [27, 10], [28, 10], [29, 10], [30, 10]]) == 140.5\n assert candidate(customers = [[1, 10000], [10001, 10000], [20001, 10000], [30001, 10000], [40001, 10000], [50001, 10000], [60001, 10000], [70001, 10000], [80001, 10000], [90001, 10000]]) == 10000.0\n assert candidate(customers = [[1, 1000], [2000, 1000], [3000, 1000], [4000, 1000], [5000, 1000], [6000, 1000]]) == 1000.0\n assert candidate(customers = [[1, 2], [2, 3], [3, 2], [4, 3], [5, 2], [6, 3], [7, 2], [8, 3], [9, 2], [10, 3], [11, 2], [12, 3], [13, 2], [14, 3], [15, 2], [16, 3], [17, 2], [18, 3], [19, 2], [20, 3]]) == 16.5\n assert candidate(customers = [[1, 3], [2, 4], [5, 2], [6, 1], [8, 6], [10, 3], [11, 2]]) == 7.0\n assert candidate(customers = [[1, 3], [2, 2], [4, 3], [5, 4], [6, 2], [8, 1], [10, 5]]) == 6.857142857142857\n assert candidate(customers = [[10, 30], [20, 20], [30, 10], [40, 5], [50, 2], [60, 1], [70, 3], [80, 4], [90, 2], [100, 5], [110, 1], [120, 3], [130, 4], [140, 2], [150, 5]]) == 15.2\n assert candidate(customers = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20], [21, 21], [22, 22], [23, 23], [24, 24], [25, 25], [26, 26], [27, 27], [28, 28], [29, 29], [30, 30]]) == 150.83333333333334\n assert candidate(customers = [[100, 50], [150, 20], [200, 30], [250, 10], [300, 40], [350, 5], [400, 15]]) == 24.285714285714285\n assert candidate(customers = [[1, 1], [3, 3], [3, 3], [3, 3], [5, 5], [5, 5], [7, 7], [7, 7], [9, 9], [9, 9]]) == 18.0\n assert candidate(customers = [[5, 3], [6, 4], [8, 2], [9, 5], [12, 3], [15, 1], [18, 2], [20, 4], [25, 3], [30, 1]]) == 6.9\n assert candidate(customers = [[100, 100], [200, 50], [300, 25], [400, 12], [500, 6]]) == 38.6\n assert candidate(customers = [[10, 10], [10, 20], [10, 30], [10, 40], [10, 50], [10, 60], [10, 70], [10, 80], [10, 90], [10, 100]]) == 220.0\n assert candidate(customers = [[1, 100], [101, 50], [151, 25], [201, 10], [251, 5], [301, 1]]) == 31.833333333333332\n assert candidate(customers = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == 8.0\n assert candidate(customers = [[5, 10], [10, 10], [15, 10], [20, 10], [25, 10], [30, 10], [35, 10], [40, 10], [45, 10], [50, 10]]) == 32.5\n assert candidate(customers = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20]]) == 77.0\n assert candidate(customers = [[1, 1], [2, 1], [2, 1], [3, 1], [3, 1], [4, 1], [4, 1], [5, 1], [5, 1]]) == 2.7777777777777777\n assert candidate(customers = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19]]) == 34.0\n assert candidate(customers = [[1, 20], [1, 15], [2, 10], [2, 5], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == 45.0\n assert candidate(customers = [[1, 1], [100, 100], [200, 100], [300, 100], [400, 100], [500, 100], [600, 100], [700, 100], [800, 100], [900, 100]]) == 90.1\n assert candidate(customers = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]]) == 6.5\n assert candidate(customers = [[1, 1000], [2, 1000], [3, 1000], [4, 1000], [5, 1000], [6, 1000], [7, 1000], [8, 1000], [9, 1000], [10, 1000]]) == 5495.5\n assert candidate(customers = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]]) == 529.0\n assert candidate(customers = [[1, 5], [3, 7], [5, 2], [10, 1], [12, 3], [15, 2], [18, 5]]) == 7.428571428571429\n assert candidate(customers = [[5, 10], [15, 15], [25, 20], [35, 25], [45, 30], [55, 35], [65, 40], [75, 45], [85, 50]]) == 76.66666666666667\n assert candidate(customers = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1], [16, 1], [17, 1], [18, 1], [19, 1], [20, 1]]) == 1.0\n assert candidate(customers = [[1, 10000], [10001, 1], [20002, 1], [30003, 1], [40004, 1], [50005, 1], [60006, 1], [70007, 1], [80008, 1], [90009, 1]]) == 1000.9\n assert candidate(customers = [[1, 100], [1, 90], [1, 80], [1, 70], [1, 60], [1, 50], [1, 40], [1, 30], [1, 20], [1, 10]]) == 385.0\n assert candidate(customers = [[5, 3], [5, 2], [5, 4], [5, 1], [5, 5]]) == 8.4\n assert candidate(customers = [[2, 5], [2, 5], [2, 5], [2, 5], [2, 5], [2, 5], [2, 5], [2, 5], [2, 5], [2, 5]]) == 27.5\n assert candidate(customers = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 17.5\n assert candidate(customers = [[1, 100], [20, 50], [40, 30], [60, 20], [80, 10], [100, 5], [120, 3], [140, 2], [160, 1]]) == 111.33333333333333\n assert candidate(customers = [[1, 10], [5, 10], [10, 10], [15, 10], [20, 10], [25, 10], [30, 10], [35, 10], [40, 10], [45, 10], [50, 10], [55, 10], [60, 10], [65, 10], [70, 10], [75, 10], [80, 10], [85, 10], [90, 10], [95, 10]]) == 58.45\n assert candidate(customers = [[1, 5], [6, 10], [12, 15], [18, 20], [24, 25], [30, 30], [36, 35], [42, 40], [48, 45], [54, 50]]) == 83.9\n assert candidate(customers = [[1, 1], [2, 2], [3, 2], [4, 1], [5, 2], [6, 3], [7, 1], [8, 2], [9, 3], [10, 1], [11, 2], [12, 3], [13, 1], [14, 2], [15, 3]]) == 7.466666666666667\n assert candidate(customers = [[1, 100], [101, 100], [201, 100], [301, 100], [401, 100], [501, 100], [601, 100], [701, 100], [801, 100], [901, 100]]) == 100.0\n assert candidate(customers = [[100, 50], [200, 25], [300, 12], [400, 6], [500, 3], [600, 1], [700, 2], [800, 4], [900, 1]]) == 11.555555555555555\n assert candidate(customers = [[1, 1000], [1001, 1000], [2001, 1000], [3001, 1000], [4001, 1000], [5001, 1000]]) == 1000.0\n assert candidate(customers = [[1, 1], [3, 2], [6, 3], [10, 4], [15, 5], [21, 6], [28, 7], [36, 8], [45, 9], [55, 10]]) == 5.5\n assert candidate(customers = [[1, 10], [10, 10], [20, 10], [30, 10], [40, 10], [50, 10]]) == 10.833333333333334\n assert candidate(customers = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]) == 21.0\n assert candidate(customers = [[1, 5], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5]]) == 8.333333333333334\n assert candidate(customers = [[1, 10000], [1, 10000], [1, 10000], [1, 10000], [1, 10000], [1, 10000], [1, 10000], [1, 10000], [1, 10000], [1, 10000]]) == 55000.0\n assert candidate(customers = [[1, 1], [2, 2], [4, 4], [8, 8], [16, 16], [32, 32], [64, 64], [128, 128], [256, 256], [512, 512]]) == 102.3\n assert candidate(customers = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 22.0\n assert candidate(customers = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600]]) == 800.0\n assert candidate(customers = [[1, 100], [101, 50], [151, 20], [201, 10], [251, 5], [301, 1], [351, 2], [401, 3], [451, 4]]) == 21.666666666666668\n assert candidate(customers = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]) == 215.5\n assert candidate(customers = [[1, 1000], [1001, 1000], [2001, 1000], [3001, 1000], [4001, 1000]]) == 1000.0\n assert candidate(customers = [[1, 5000], [100, 2000], [2000, 3000], [3000, 1000], [4000, 4000], [5000, 5000], [6000, 6000], [7000, 7000], [8000, 8000], [9000, 9000], [10000, 10000]]) == 20355.454545454544\n assert candidate(customers = [[1, 2], [3, 3], [6, 2], [8, 1], [10, 3], [15, 4]]) == 2.5\n assert candidate(customers = [[1, 1], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2], [11, 2], [12, 2], [13, 2], [14, 2], [15, 2], [16, 2], [17, 2], [18, 2], [19, 2], [20, 2]]) == 10.5\n assert candidate(customers = [[1, 1000], [1001, 500], [1501, 250], [2001, 125], [2501, 62], [3001, 31], [3501, 15], [4001, 7], [4501, 3], [5001, 1]]) == 199.4\n assert candidate(customers = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50]]) == 50.0\n assert candidate(customers = [[1000, 1], [2000, 1], [3000, 1], [4000, 1], [5000, 1], [6000, 1], [7000, 1], [8000, 1], [9000, 1], [10000, 1]]) == 1.0\n assert candidate(customers = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]) == 31.0\n assert candidate(customers = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22]]) == 42.0\n assert candidate(customers = [[1, 10], [11, 10], [21, 10], [31, 10], [41, 10], [51, 10], [61, 10], [71, 10], [81, 10], [91, 10]]) == 10.0\n assert candidate(customers = [[1000, 100], [2000, 200], [3000, 300], [4000, 400], [5000, 500], [6000, 600], [7000, 700], [8000, 800], [9000, 900], [10000, 1000]]) == 550.0\n assert candidate(customers = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21]]) == 40.5\n assert candidate(customers = [[1, 1], [2, 100], [3, 200], [4, 300], [5, 400], [6, 500], [7, 600], [8, 700], [9, 800], [10, 900]]) == 1646.5\n assert candidate(customers = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28], [29, 30]]) == 76.66666666666667\n assert candidate(customers = [[1, 1000], [2000, 500], [3000, 300], [4000, 200], [5000, 100], [6000, 50], [7000, 30], [8000, 20], [9000, 10], [10000, 5], [11000, 3], [12000, 2], [13000, 1]]) == 170.84615384615384\n assert candidate(customers = [[100, 100], [200, 100], [300, 100], [400, 100], [500, 100], [600, 100], [700, 100], [800, 100], [900, 100], [1000, 100]]) == 100.0\n assert candidate(customers = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == 38.333333333333336\n assert candidate(customers = [[1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5]]) == 27.5\n"}, "metadata": {"canonical_parameter_names": ["customers"], "leetcode_dataset_entry_point": "Solution().averageWaitingTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "double averageWaitingTime(vector>& customers) {", "container": "Solution", "callable": "averageWaitingTime", "parameters": [{"name": "customers", "type": "vector>&"}], "return_type": "double", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1702, "task_id": "maximum-binary-string-after-change", "difficulty": "Medium", "problem_description": "You are given a binary string binary consisting of only 0's or 1's. You can apply each of the following operations any number of times:\n\nOperation 1: If the number contains the substring \"00\", you can replace it with \"10\".\n\n\t\nFor example, \"00010\" -> \"10010\"\n\n\nOperation 2: If the number contains the substring \"10\", you can replace it with \"01\".\n\t\nFor example, \"00010\" -> \"00001\"\n\n\n\nReturn the maximum binary string you can obtain after any number of operations. Binary string x is greater than binary string y if x's decimal representation is greater than y's decimal representation.\n \nExample 1:\n\nInput: binary = \"000110\"\nOutput: \"111011\"\nExplanation: A valid transformation sequence can be:\n\"000110\" -> \"000101\" \n\"000101\" -> \"100101\" \n\"100101\" -> \"110101\" \n\"110101\" -> \"110011\" \n\"110011\" -> \"111011\"\n\nExample 2:\n\nInput: binary = \"01\"\nOutput: \"01\"\nExplanation: \"01\" cannot be transformed any further.\n\n \nConstraints:\n\n1 <= binary.length <= 105\nbinary consist of '0' and '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(binary = \"01010101010\") == \"11111011111\"\n assert candidate(binary = \"01\") == \"01\"\n assert candidate(binary = \"000001\") == \"111101\"\n assert candidate(binary = \"1111\") == \"1111\"\n assert candidate(binary = \"10101010101010101010\") == \"11111111110111111111\"\n assert candidate(binary = \"000000000\") == \"111111110\"\n assert candidate(binary = \"010101\") == \"110111\"\n assert candidate(binary = \"111000011\") == \"111111011\"\n assert candidate(binary = \"00110011\") == \"11101111\"\n assert candidate(binary = \"00000\") == \"11110\"\n assert candidate(binary = \"000000\") == \"111110\"\n assert candidate(binary = \"1100101\") == \"1111011\"\n assert candidate(binary = \"001001\") == \"111011\"\n assert candidate(binary = \"101010\") == \"111011\"\n assert candidate(binary = \"0000\") == \"1110\"\n assert candidate(binary = \"0101010101\") == \"1111011111\"\n assert candidate(binary = \"000111000\") == \"111110111\"\n assert candidate(binary = \"10101010\") == \"11110111\"\n assert candidate(binary = \"1100110011\") == \"1111101111\"\n assert candidate(binary = \"0101010\") == \"1110111\"\n assert candidate(binary = \"111000\") == \"111110\"\n assert candidate(binary = \"0001010101\") == \"1111101111\"\n assert candidate(binary = \"000001111\") == \"111101111\"\n assert candidate(binary = \"111111\") == \"111111\"\n assert candidate(binary = \"00001111\") == \"11101111\"\n assert candidate(binary = \"11001000101\") == \"11111110111\"\n assert candidate(binary = \"0010101\") == \"1110111\"\n assert candidate(binary = \"11001100\") == \"11111011\"\n assert candidate(binary = \"11110000\") == \"11111110\"\n assert candidate(binary = \"011110\") == \"101111\"\n assert candidate(binary = \"110010\") == \"111101\"\n assert candidate(binary = \"000110\") == \"111011\"\n assert candidate(binary = \"100100100\") == \"111111011\"\n assert candidate(binary = \"1000000\") == \"1111110\"\n assert candidate(binary = \"11111\") == \"11111\"\n assert candidate(binary = \"100000000001\") == \"111111111101\"\n assert candidate(binary = \"10101001010100101\") == \"11111111101111111\"\n assert candidate(binary = \"00000000000000000000111111111111\") == \"11111111111111111110111111111111\"\n assert candidate(binary = \"01111111111111111111111111111111\") == \"01111111111111111111111111111111\"\n assert candidate(binary = \"00000000000000000\") == \"11111111111111110\"\n assert candidate(binary = \"01001001001001001\") == \"11111111110111111\"\n assert candidate(binary = \"0000000000\") == \"1111111110\"\n assert candidate(binary = \"0000111100001111\") == \"1111111011111111\"\n assert candidate(binary = \"000001111000001111000001111000001111000001111\") == \"111111111111111111111111011111111111111111111\"\n assert candidate(binary = \"001001001001001001001001001001001001001001001001001001\") == \"111111111111111111111111111111111110111111111111111111\"\n assert candidate(binary = \"000000000000\") == \"111111111110\"\n assert candidate(binary = \"11111011111011111011111011111011111011111011111\") == \"11111111111011111111111111111111111111111111111\"\n assert candidate(binary = \"10010010010010010\") == \"11111111111011111\"\n assert candidate(binary = \"111001001001001000\") == \"111111111111101111\"\n assert candidate(binary = \"00000011100000\") == \"11111111110111\"\n assert candidate(binary = \"111111111111111111111111111111111111111111111111111111111111111111111111\") == \"111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(binary = \"00011001100110011\") == \"11111111011111111\"\n assert candidate(binary = \"010101010101010101010\") == \"111111111101111111111\"\n assert candidate(binary = \"00010101010100\") == \"11111111011111\"\n assert candidate(binary = \"000000000000000000000000000000000000000000000000000000000000000000000000\") == \"111111111111111111111111111111111111111111111111111111111111111111111110\"\n assert candidate(binary = \"000000000000000000000000000000000000000000000000000000000000000000000000000011111111111111111111111111111111111111111111111111111111111111111111111111111\") == \"111111111111111111111111111111111111111111111111111111111111111111111111111011111111111111111111111111111111111111111111111111111111111111111111111111111\"\n assert candidate(binary = \"1010101010101010101010101010101010101010101010101010101010101010\") == \"1111111111111111111111111111111101111111111111111111111111111111\"\n assert candidate(binary = \"11111100000000111\") == \"11111111111110111\"\n assert candidate(binary = \"01010101010101010101\") == \"11111111101111111111\"\n assert candidate(binary = \"10101010101010101010101010101010\") == \"11111111111111110111111111111111\"\n assert candidate(binary = \"0000111111110000\") == \"1111111011111111\"\n assert candidate(binary = \"00000000000011111111111111111111\") == \"11111111111011111111111111111111\"\n assert candidate(binary = \"001010101010\") == \"111111011111\"\n assert candidate(binary = \"1111111111111111\") == \"1111111111111111\"\n assert candidate(binary = \"1010101010\") == \"1111101111\"\n assert candidate(binary = \"0101010101010101\") == \"1111111011111111\"\n assert candidate(binary = \"00001111000011110000111100001111\") == \"11111111111111101111111111111111\"\n assert candidate(binary = \"0000000000000000000000000001\") == \"1111111111111111111111111101\"\n assert candidate(binary = \"11111111111111111111\") == \"11111111111111111111\"\n assert candidate(binary = \"000011110000\") == \"111111101111\"\n assert candidate(binary = \"000010101010101010101010101010101010101010101010\") == \"111111111111111111111111101111111111111111111111\"\n assert candidate(binary = \"11011011011011011\") == \"11111101111111111\"\n assert candidate(binary = \"00000010000000100000001000000010000000100000001\") == \"11111111111111111111111111111111111111110111111\"\n assert candidate(binary = \"11111100000000000000000000000000\") == \"11111111111111111111111111111110\"\n assert candidate(binary = \"11000000000000000000\") == \"11111111111111111110\"\n assert candidate(binary = \"1010101010101010\") == \"1111111101111111\"\n assert candidate(binary = \"110011001100\") == \"111111101111\"\n assert candidate(binary = \"00001111000011110000\") == \"11111111111011111111\"\n assert candidate(binary = \"00011110101010101010101010101010101010101010101\") == \"11111111111111111111110111111111111111111111111\"\n assert candidate(binary = \"11100001010101010100001111100001111000011110000\") == \"11111111111111111111111111101111111111111111111\"\n assert candidate(binary = \"001100110011\") == \"111110111111\"\n assert candidate(binary = \"01001001001001001001\") == \"11111111111101111111\"\n assert candidate(binary = \"0000001111110000001111\") == \"1111111111101111111111\"\n assert candidate(binary = \"111111111110\") == \"111111111110\"\n assert candidate(binary = \"00000000000001111\") == \"11111111111101111\"\n assert candidate(binary = \"101010100000\") == \"111111110111\"\n assert candidate(binary = \"11111111111111111\") == \"11111111111111111\"\n assert candidate(binary = \"00000000000000000000000000000000000000000000\") == \"11111111111111111111111111111111111111111110\"\n assert candidate(binary = \"00001010101010100\") == \"11111111110111111\"\n assert candidate(binary = \"01010101010101010\") == \"11111111011111111\"\n assert candidate(binary = \"10101010101010101\") == \"11111111011111111\"\n assert candidate(binary = \"0101010101010101010101010101010101010101010101010101\") == \"1111111111111111111111111011111111111111111111111111\"\n assert candidate(binary = \"00000000000000000000000000000001\") == \"11111111111111111111111111111101\"\n assert candidate(binary = \"010101010101010101010101010101010101010101010101\") == \"111111111111111111111110111111111111111111111111\"\n assert candidate(binary = \"1100000000000011\") == \"1111111111111011\"\n assert candidate(binary = \"11111111111111111111111111111111111111111111\") == \"11111111111111111111111111111111111111111111\"\n assert candidate(binary = \"00000000010000000000000000000000\") == \"11111111111111111111111111111101\"\n assert candidate(binary = \"11001100110011001\") == \"11111111101111111\"\n assert candidate(binary = \"101010101010101010101\") == \"111111111101111111111\"\n assert candidate(binary = \"111100001111\") == \"111111101111\"\n assert candidate(binary = \"00000000000000000000000000000000000000000000000000000000\") == \"11111111111111111111111111111111111111111111111111111110\"\n assert candidate(binary = \"1100110011001100\") == \"1111111110111111\"\n assert candidate(binary = \"111111111111\") == \"111111111111\"\n assert candidate(binary = \"0001100010001000\") == \"1111111111101111\"\n assert candidate(binary = \"0000000000000111111\") == \"1111111111110111111\"\n assert candidate(binary = \"1110000110001100\") == \"1111111111101111\"\n assert candidate(binary = \"111111111\") == \"111111111\"\n assert candidate(binary = \"0000000000000000000000000000000000000000000000000000000000000000000000000000\") == \"1111111111111111111111111111111111111111111111111111111111111111111111111110\"\n assert candidate(binary = \"11111111111111111111111111111111111111111111111111111111\") == \"11111111111111111111111111111111111111111111111111111111\"\n assert candidate(binary = \"1001001001001\") == \"1111111101111\"\n assert candidate(binary = \"000000000000000000000000000000000000000000000000\") == \"111111111111111111111111111111111111111111111110\"\n assert candidate(binary = \"010101010101\") == \"111110111111\"\n assert candidate(binary = \"00100100100100100100100100100100\") == \"11111111111111111111101111111111\"\n assert candidate(binary = \"11110000000000000\") == \"11111111111111110\"\n assert candidate(binary = \"11110000111100001111000011110000111100001111\") == \"11111111111111111111111011111111111111111111\"\n assert candidate(binary = \"0011001100110011\") == \"1111111011111111\"\n assert candidate(binary = \"11000000110000001100000011000000\") == \"11111111111111111111111110111111\"\n assert candidate(binary = \"01010101010101010101010101010101\") == \"11111111111111101111111111111111\"\n assert candidate(binary = \"111111111111111111111111111111111111111111111111\") == \"111111111111111111111111111111111111111111111111\"\n assert candidate(binary = \"00000000000000000000\") == \"11111111111111111110\"\n assert candidate(binary = \"110101010101\") == \"111111011111\"\n assert candidate(binary = \"01001010100101001\") == \"11111111101111111\"\n assert candidate(binary = \"1010101010101010101010101010101010101010101010101010\") == \"1111111111111111111111111101111111111111111111111111\"\n assert candidate(binary = \"0110110110110\") == \"1111011111111\"\n assert candidate(binary = \"00000000000000000000000000000000000000000000000000000000000000000000000\") == \"11111111111111111111111111111111111111111111111111111111111111111111110\"\n assert candidate(binary = \"11111111111111111111111111111110\") == \"11111111111111111111111111111110\"\n assert candidate(binary = \"0000000000000000\") == \"1111111111111110\"\n assert candidate(binary = \"1100101010100001\") == \"1111111111011111\"\n assert candidate(binary = \"01101101101101101\") == \"11111011111111111\"\n assert candidate(binary = \"11111111111111111111000000000000\") == \"11111111111111111111111111111110\"\n assert candidate(binary = \"11111111111111110\") == \"11111111111111110\"\n assert candidate(binary = \"000100010001\") == \"111111110111\"\n assert candidate(binary = \"1111111111\") == \"1111111111\"\n"}, "metadata": {"canonical_parameter_names": ["binary"], "leetcode_dataset_entry_point": "Solution().maximumBinaryString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string maximumBinaryString(string binary) {", "container": "Solution", "callable": "maximumBinaryString", "parameters": [{"name": "binary", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1703, "task_id": "minimum-adjacent-swaps-for-k-consecutive-ones", "difficulty": "Hard", "problem_description": "You are given an integer array, nums, and an integer k. nums comprises of only 0's and 1's. In one move, you can choose two adjacent indices and swap their values.\nReturn the minimum number of moves required so that nums has k consecutive 1's.\n \nExample 1:\n\nInput: nums = [1,0,0,1,0,1], k = 2\nOutput: 1\nExplanation: In 1 move, nums could be [1,0,0,0,1,1] and have 2 consecutive 1's.\n\nExample 2:\n\nInput: nums = [1,0,0,0,0,0,1,1], k = 3\nOutput: 5\nExplanation: In 5 moves, the leftmost 1 can be shifted right until nums = [0,0,0,0,0,1,1,1].\n\nExample 3:\n\nInput: nums = [1,1,0,1], k = 2\nOutput: 0\nExplanation: nums already has 2 consecutive 1's.\n\n \nConstraints:\n\n1 <= nums.length <= 105\nnums[i] is 0 or 1.\n1 <= k <= sum(nums)\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 0, 1, 1, 1, 0, 0, 1, 1, 1],k = 4) == 2\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 3) == 6\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 1],k = 3) == 5\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1],k = 4) == 4\n assert candidate(nums = [1, 1, 1, 1, 1],k = 3) == 0\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 5) == 6\n assert candidate(nums = [0, 0, 1, 0, 1, 0, 1, 0, 1],k = 3) == 2\n assert candidate(nums = [0, 0, 1, 0, 1, 1, 0, 0, 1],k = 3) == 1\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1],k = 5) == 6\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1],k = 3) == 2\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 3) == 2\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1],k = 4) == 4\n assert candidate(nums = [1, 1, 0, 1],k = 2) == 0\n assert candidate(nums = [0, 0, 1, 0, 1, 0, 1, 0, 1],k = 4) == 4\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1],k = 4) == 4\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0],k = 2) == 1\n assert candidate(nums = [1, 0, 0, 1, 0, 1],k = 2) == 1\n assert candidate(nums = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],k = 6) == 18\n assert candidate(nums = [1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 7) == 33\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1],k = 4) == 6\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1],k = 3) == 12\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],k = 9) == 54\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0],k = 7) == 16\n assert candidate(nums = [0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1],k = 4) == 6\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0],k = 4) == 28\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 10) == 75\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1],k = 3) == 0\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 3) == 10\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0],k = 3) == 6\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 5) == 24\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1],k = 6) == 9\n assert candidate(nums = [0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0],k = 5) == 5\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1],k = 6) == 14\n assert candidate(nums = [1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1],k = 6) == 13\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1],k = 4) == 6\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 5) == 12\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 6) == 9\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 6) == inf\n assert candidate(nums = [0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 5) == 12\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1],k = 6) == 20\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 8) == 16\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0],k = 5) == 15\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 7) == 12\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 12) == 36\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 5) == 6\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 8) == 32\n assert candidate(nums = [1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1],k = 4) == 4\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 10) == 25\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 4) == 4\n assert candidate(nums = [1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1],k = 9) == 18\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 4) == 20\n assert candidate(nums = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 5) == 24\n assert candidate(nums = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 5) == 5\n assert candidate(nums = [0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0],k = 5) == 12\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 6) == 9\n assert candidate(nums = [0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0],k = 4) == 5\n assert candidate(nums = [0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 9) == 20\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 2) == 9\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 4) == 20\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 6) == 9\n assert candidate(nums = [0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 4) == 4\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 6) == 9\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 5) == 12\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1],k = 6) == 15\n assert candidate(nums = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],k = 6) == 24\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 7) == 24\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 3) == 4\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 7) == 12\n assert candidate(nums = [1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 10) == 25\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 7) == 24\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 7) == 24\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 6) == 9\n assert candidate(nums = [1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1],k = 5) == 36\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1],k = 4) == 3\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 3) == 51\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1],k = 9) == 40\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 5) == 12\n assert candidate(nums = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 6) == 27\n assert candidate(nums = [0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 7) == 36\n assert candidate(nums = [1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 8) == 46\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 15) == 56\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0],k = 5) == 15\n assert candidate(nums = [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],k = 5) == 27\n assert candidate(nums = [0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1],k = 5) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 10) == 0\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 2) == 14\n assert candidate(nums = [1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 11) == 30\n assert candidate(nums = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 7) == 24\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0],k = 6) == 26\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 8) == 16\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 5) == 6\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 9) == 20\n assert candidate(nums = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1],k = 8) == inf\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 10) == 25\n assert candidate(nums = [0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0],k = 10) == 50\n assert candidate(nums = [1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1],k = 4) == 8\n assert candidate(nums = [1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1],k = 5) == 15\n assert candidate(nums = [1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 8) == 15\n assert candidate(nums = [0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0],k = 3) == 10\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minMoves", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minMoves(vector& nums, int k) {", "container": "Solution", "callable": "minMoves", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1704, "task_id": "determine-if-string-halves-are-alike", "difficulty": "Easy", "problem_description": "You are given a string s of even length. Split this string into two halves of equal lengths, and let a be the first half and b be the second half.\nTwo strings are alike if they have the same number of vowels ('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'). Notice that s contains uppercase and lowercase letters.\nReturn true if a and b are alike. Otherwise, return false.\n \nExample 1:\n\nInput: s = \"book\"\nOutput: true\nExplanation: a = \"bo\" and b = \"ok\". a has 1 vowel and b has 1 vowel. Therefore, they are alike.\n\nExample 2:\n\nInput: s = \"textbook\"\nOutput: false\nExplanation: a = \"text\" and b = \"book\". a has 1 vowel whereas b has 2. Therefore, they are not alike.\nNotice that the vowel o is counted twice.\n\n \nConstraints:\n\n2 <= s.length <= 1000\ns.length is even.\ns consists of uppercase and lowercase letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"UFO\") == False\n assert candidate(s = \"aAeEiIoOuU\") == True\n assert candidate(s = \"Leetcode\") == True\n assert candidate(s = \"abcdefgihjklmno\") == False\n assert candidate(s = \"Regal\") == True\n assert candidate(s = \"Reinholdmes\") == True\n assert candidate(s = \"AbCdEfGh\") == True\n assert candidate(s = \"textbook\") == False\n assert candidate(s = \"cOdInGQuEsTiOn\") == False\n assert candidate(s = \"pYthOnPrOgRaMmInG\") == False\n assert candidate(s = \"AaEeIiOoUu\") == True\n assert candidate(s = \"leetcode\") == True\n assert candidate(s = \"Eve\") == False\n assert candidate(s = \"racecar\") == False\n assert candidate(s = \"VoIcE\") == True\n assert candidate(s = \"Madam\") == True\n assert candidate(s = \"abcdefgH\") == True\n assert candidate(s = \"Margelet\") == False\n assert candidate(s = \"book\") == True\n assert candidate(s = \"Uncopyrightable\") == True\n assert candidate(s = \"DAD\") == False\n assert candidate(s = \"MerryChristmas\") == False\n assert candidate(s = \"ComputerScience\") == False\n assert candidate(s = \"ArtificialIntelligence\") == False\n assert candidate(s = \"aAbBcCdDeEfFgG\") == True\n assert candidate(s = \"Supercalifragilisticexpialidocious\") == False\n assert candidate(s = \"InDiCoRn\") == False\n assert candidate(s = \"vowelvowelvowelvowelvowelvowel\") == True\n assert candidate(s = \"LyoPHiNiC\") == False\n assert candidate(s = \"VowelCOnsonAnt\") == False\n assert candidate(s = \"SyNtHeSiS\") == False\n assert candidate(s = \"CoMpUterScIeNcE\") == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == True\n assert candidate(s = \"Pneumonoultramicroscopicsilicovolcanoconiosis\") == False\n assert candidate(s = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\") == False\n assert candidate(s = \"bBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == True\n assert candidate(s = \"Supercalifragilisticexpialidocioussuper\") == False\n assert candidate(s = \"EqUiVaLeNt\") == False\n assert candidate(s = \"unevenNumberOfVowels\") == True\n assert candidate(s = \"MachineLearning\") == True\n assert candidate(s = \"QuantumComputing\") == True\n assert candidate(s = \"Pneumonoultramicroscopicsilicovolcanoconioses\") == False\n assert candidate(s = \"DeViScIoN\") == True\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYz\") == False\n assert candidate(s = \"CoRaL\") == True\n assert candidate(s = \"Internationalization\") == True\n assert candidate(s = \"CaSeInSeNsItIvE\") == True\n assert candidate(s = \"EvEnAnDdOuD\") == False\n assert candidate(s = \"CoMpLeX\") == True\n assert candidate(s = \"AbcDeFgHiJkLmNoPqRsTuVwXyZ\") == False\n assert candidate(s = \"Electroencephalographies\") == True\n assert candidate(s = \"fAcEtImE\") == True\n assert candidate(s = \"AnALoGuIzAtIoN\") == True\n assert candidate(s = \"sImPlEVoWaElStRiNg\") == True\n assert candidate(s = \"OpenAIChatGPT\") == False\n assert candidate(s = \"Incomprehensibility\") == False\n assert candidate(s = \"ThEoReTiCaL\") == False\n assert candidate(s = \"VoWaElCoUnTiNg\") == True\n assert candidate(s = \"SiMpLy\") == False\n assert candidate(s = \"Electroencephalography\") == False\n assert candidate(s = \"Honorificabilitudinitatibus\") == False\n assert candidate(s = \"ConsonantsToo\") == True\n assert candidate(s = \"abcdefghijABCDEFGHIJ\") == True\n assert candidate(s = \"METHINKSITISLIKEALITTLEIODEUCALYPTUS\") == False\n assert candidate(s = \"Alphabetization\") == False\n assert candidate(s = \"HumanComputerInteraction\") == True\n assert candidate(s = \"AmOrAnGe\") == True\n assert candidate(s = \"balancedString\") == False\n assert candidate(s = \"EuPoCrAtIc\") == False\n assert candidate(s = \"MississippiRiverOdd\") == False\n assert candidate(s = \"RoMaNiCa\") == True\n assert candidate(s = \"aAaAaAaAaAbBbBbBbB\") == False\n assert candidate(s = \"MiwEldrom\") == False\n assert candidate(s = \"AQuickBrownFoxJumpsOverTheLazyDog\") == False\n assert candidate(s = \"MaRiNo\") == False\n assert candidate(s = \"CloudComputing\") == False\n assert candidate(s = \"DataScienceAndML\") == False\n assert candidate(s = \"Hippopotomonstrosesquippedaliophobia\") == False\n assert candidate(s = \"ImAgInAtIoN\") == True\n assert candidate(s = \"Pseudopseudohypoparathyroidism\") == True\n assert candidate(s = \"PaLInDoRoMa\") == True\n assert candidate(s = \"DatabaseManagement\") == True\n assert candidate(s = \"ComplexExample\") == False\n assert candidate(s = \"sYmMeTrIcVoWaEl\") == False\n assert candidate(s = \"QwErTyUiOpAsDfGhJkLzXcVbNm\") == False\n assert candidate(s = \"cOmPlExStRiNgWitHaLoTOfVoWels\") == False\n assert candidate(s = \"AlEpInAtIoN\") == True\n assert candidate(s = \"AEIOUaeiouAEIOUaeiou\") == True\n assert candidate(s = \"Environmental\") == False\n assert candidate(s = \"SyMmEtrY\") == False\n assert candidate(s = \"PaLInDrOmE\") == True\n assert candidate(s = \"Interpolation\") == False\n assert candidate(s = \"Floccinaucinihilipilifications\") == True\n assert candidate(s = \"AlphabetSymmetry\") == False\n assert candidate(s = \"BiChRoChO\") == True\n assert candidate(s = \"SoftwareEngineering\") == True\n assert candidate(s = \"Mississippi\") == False\n assert candidate(s = \"NaturalLanguageProcessing\") == True\n assert candidate(s = \"VowelsInBoth\") == True\n assert candidate(s = \"FLUtTuAtIoNs\") == False\n assert candidate(s = \"SuPeRaLpHaBeT\") == False\n assert candidate(s = \"MaLiNoUs\") == True\n assert candidate(s = \"InternetOfThings\") == False\n assert candidate(s = \"PeRuKkIa\") == True\n assert candidate(s = \"TrAnSaPoRt\") == False\n assert candidate(s = \"OddAndEven\") == True\n assert candidate(s = \"aEiOuUoIeA\") == True\n assert candidate(s = \"Alphabetical\") == False\n assert candidate(s = \"VowelsAEIOUaeiou\") == False\n assert candidate(s = \"aEiOuUeIoA\") == True\n assert candidate(s = \"SeNtEnCe\") == False\n assert candidate(s = \"RepetitionRepetition\") == True\n assert candidate(s = \"MississippiRiver\") == True\n assert candidate(s = \"Vowelsareeverywhere\") == False\n assert candidate(s = \"vowelvowelvowelvowel\") == True\n assert candidate(s = \"DataStructure\") == True\n assert candidate(s = \"MississippiRiverside\") == False\n assert candidate(s = \"aeiouAEIOUaeiouAEIOU\") == True\n assert candidate(s = \"XiLoPhOnE\") == False\n assert candidate(s = \"Floccinaucinihilipilification\") == False\n assert candidate(s = \"PythonCoding\") == False\n assert candidate(s = \"VowelsAreVowels\") == True\n assert candidate(s = \"aEiOuUaEiO\") == True\n assert candidate(s = \"NotSoBalanced\") == False\n assert candidate(s = \"Engineering\") == False\n assert candidate(s = \"SuBiT\") == True\n assert candidate(s = \"ProgrammingIsFun\") == False\n assert candidate(s = \"aEiOuAeIoU\") == True\n assert candidate(s = \"Alphabetically\") == False\n assert candidate(s = \"PyThOnIsFuN\") == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == False\n assert candidate(s = \"AnNiHaLiLaToR\") == True\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(s = \"consonantsAEIOUconsonants\") == False\n assert candidate(s = \"Thyroparathyroidectomized\") == False\n assert candidate(s = \"EvenlyDistributed\") == True\n assert candidate(s = \"DataAnalysis\") == False\n assert candidate(s = \"CyberSecurity\") == False\n assert candidate(s = \"VoCaBuLaRy\") == True\n assert candidate(s = \"AEIOUaeiou\") == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(s = \"CaThODoRiC\") == True\n assert candidate(s = \"AlGoRiThM\") == False\n assert candidate(s = \"Antidisestablishmentarianism\") == False\n assert candidate(s = \"CoNtRoVeRtEdbUt\") == False\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == False\n assert candidate(s = \"BaLaNcEd\") == False\n assert candidate(s = \"BlockchainTechnology\") == True\n assert candidate(s = \"SystemAnalysis\") == True\n assert candidate(s = \"VowelsAndConsonants\") == True\n assert candidate(s = \"hAlFVaLuEs\") == False\n assert candidate(s = \"AlphabetSoup\") == False\n assert candidate(s = \"Unbelievable\") == True\n assert candidate(s = \"SplittingStrings\") == False\n assert candidate(s = \"GrApHiTe\") == False\n assert candidate(s = \"AnAgrAm\") == False\n assert candidate(s = \"evenNumberOfVowels\") == False\n assert candidate(s = \"RoTiCoRn\") == False\n assert candidate(s = \"bYtEcOdE\") == False\n assert candidate(s = \"BigDataAnalytics\") == False\n assert candidate(s = \"FLYINGDUCK\") == True\n assert candidate(s = \"ComplexityAnalysis\") == True\n assert candidate(s = \"VowelsAreEven\") == False\n assert candidate(s = \"cHiCaGo\") == True\n assert candidate(s = \"PythonIsAwesome\") == False\n assert candidate(s = \"FeBrIfIoN\") == False\n assert candidate(s = \"Electroencephalographically\") == True\n assert candidate(s = \"mIxEdCaSeTeStStRiNg\") == False\n assert candidate(s = \"ProgrammingLanguage\") == True\n assert candidate(s = \"MississippiUniversity\") == False\n assert candidate(s = \"equalvowelcounts\") == False\n assert candidate(s = \"EnvironmentalStudies\") == True\n assert candidate(s = \"InDeXeS\") == False\n assert candidate(s = \"Supercalifragilisticexpialidociousxyz\") == False\n assert candidate(s = \"xyzXYZxyzXYZ\") == True\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().halvesAreAlike", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool halvesAreAlike(string s) {", "container": "Solution", "callable": "halvesAreAlike", "parameters": [{"name": "s", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1705, "task_id": "maximum-number-of-eaten-apples", "difficulty": "Medium", "problem_description": "There is a special kind of apple tree that grows apples every day for n days. On the ith day, the tree grows apples[i] apples that will rot after days[i] days, that is on day i + days[i] the apples will be rotten and cannot be eaten. On some days, the apple tree does not grow any apples, which are denoted by apples[i] == 0 and days[i] == 0.\nYou decided to eat at most one apple a day (to keep the doctors away). Note that you can keep eating after the first n days.\nGiven two integer arrays days and apples of length n, return the maximum number of apples you can eat.\n \nExample 1:\n\nInput: apples = [1,2,3,5,2], days = [3,2,1,4,2]\nOutput: 7\nExplanation: You can eat 7 apples:\n- On the first day, you eat an apple that grew on the first day.\n- On the second day, you eat an apple that grew on the second day.\n- On the third day, you eat an apple that grew on the second day. After this day, the apples that grew on the third day rot.\n- On the fourth to the seventh days, you eat apples that grew on the fourth day.\n\nExample 2:\n\nInput: apples = [3,0,0,0,0,2], days = [3,0,0,0,0,2]\nOutput: 5\nExplanation: You can eat 5 apples:\n- On the first to the third day you eat apples that grew on the first day.\n- Do nothing on the fouth and fifth days.\n- On the sixth and seventh days you eat apples that grew on the sixth day.\n\n \nConstraints:\n\nn == apples.length == days.length\n1 <= n <= 2 * 104\n0 <= apples[i], days[i] <= 2 * 104\ndays[i] = 0 if and only if apples[i] = 0.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(apples = [0, 0, 0, 0],days = [0, 0, 0, 0]) == 0\n assert candidate(apples = [1, 3, 2],days = [3, 5, 2]) == 6\n assert candidate(apples = [5, 5, 5, 5, 5],days = [1, 2, 3, 4, 5]) == 9\n assert candidate(apples = [5, 5, 5, 5, 5],days = [1, 1, 1, 1, 1]) == 5\n assert candidate(apples = [0, 0, 0, 5, 0, 6],days = [0, 0, 0, 5, 0, 4]) == 6\n assert candidate(apples = [5, 4, 3, 2, 1],days = [1, 2, 3, 4, 5]) == 8\n assert candidate(apples = [1, 2, 3, 5, 2],days = [3, 2, 1, 4, 2]) == 7\n assert candidate(apples = [3, 0, 0, 0, 0, 2],days = [3, 0, 0, 0, 0, 2]) == 5\n assert candidate(apples = [2, 1, 10],days = [2, 10, 1]) == 4\n assert candidate(apples = [4, 2, 2, 3, 1],days = [3, 2, 10, 1, 2]) == 7\n assert candidate(apples = [0, 0, 0, 0, 0],days = [0, 0, 0, 0, 0]) == 0\n assert candidate(apples = [20, 0, 0, 0, 0, 0, 0, 0, 0, 0],days = [10, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 10\n assert candidate(apples = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1000],days = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(apples = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0],days = [2, 0, 2, 0, 2, 0, 2, 0, 2, 0]) == 10\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == 20\n assert candidate(apples = [3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0],days = [10, 9, 8, 0, 0, 0, 0, 0, 0, 0, 0]) == 6\n assert candidate(apples = [10, 20, 30, 40, 50],days = [1, 2, 3, 4, 5]) == 9\n assert candidate(apples = [3, 2, 1, 0, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0],days = [5, 4, 3, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 5]) == 12\n assert candidate(apples = [10, 0, 20, 0, 30, 0, 40, 0, 50, 0],days = [5, 0, 4, 0, 3, 0, 2, 0, 1, 0]) == 9\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(apples = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],days = [2, 0, 2, 0, 2, 0, 2, 0, 2, 0]) == 5\n assert candidate(apples = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],days = [2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0]) == 10\n assert candidate(apples = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],days = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 79\n assert candidate(apples = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(apples = [10, 20, 0, 0, 15, 10],days = [5, 5, 0, 0, 3, 3]) == 8\n assert candidate(apples = [3, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1],days = [2, 0, 0, 5, 0, 0, 0, 0, 0, 0, 2, 2]) == 6\n assert candidate(apples = [0, 0, 10, 0, 0, 0, 0, 0, 10, 0],days = [0, 0, 1, 0, 0, 0, 0, 0, 2, 0]) == 3\n assert candidate(apples = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(apples = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 18\n assert candidate(apples = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],days = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(apples = [1, 3, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],days = [2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 4\n assert candidate(apples = [5, 4, 3, 2, 1],days = [5, 4, 3, 2, 1]) == 5\n assert candidate(apples = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],days = [20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 2\n assert candidate(apples = [3, 0, 4, 0, 0, 5, 0, 0, 6, 0, 0, 7],days = [2, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 6]) == 17\n assert candidate(apples = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],days = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(apples = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],days = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(apples = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 29\n assert candidate(apples = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],days = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 19\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(apples = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],days = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(apples = [10, 15, 0, 20, 25, 0, 0, 30],days = [3, 4, 0, 5, 6, 0, 0, 7]) == 14\n assert candidate(apples = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10],days = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10]) == 27\n assert candidate(apples = [10, 0, 10, 0, 10, 0, 10],days = [3, 0, 3, 0, 3, 0, 3]) == 9\n assert candidate(apples = [3, 2, 1, 0, 0, 4, 2, 1, 0, 1],days = [2, 2, 2, 0, 0, 3, 2, 2, 0, 1]) == 9\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 20\n assert candidate(apples = [4, 0, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0],days = [5, 0, 4, 3, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0]) == 9\n assert candidate(apples = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0],days = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0]) == 13\n assert candidate(apples = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 100, 100],days = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 15, 15]) == 17\n assert candidate(apples = [2, 4, 6, 8, 10],days = [1, 2, 3, 4, 5]) == 9\n assert candidate(apples = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0],days = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(apples = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],days = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 13\n assert candidate(apples = [5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],days = [10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 5\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(apples = [10, 0, 5, 0, 0, 15],days = [10, 0, 4, 0, 0, 3]) == 10\n assert candidate(apples = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(apples = [5, 0, 0, 5, 0, 5, 0, 5, 0, 5],days = [1, 0, 0, 2, 0, 3, 0, 4, 0, 5]) == 12\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(apples = [2, 3, 1, 0, 0, 0, 0, 4, 5, 6, 0, 0, 0, 0, 7],days = [2, 2, 2, 0, 0, 0, 0, 3, 3, 3, 0, 0, 0, 0, 4]) == 13\n assert candidate(apples = [10, 0, 10, 0, 10, 0, 10, 0, 10, 0],days = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 12\n assert candidate(apples = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],days = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(apples = [10, 20, 0, 0, 15, 10, 5],days = [5, 4, 0, 0, 6, 3, 2]) == 10\n assert candidate(apples = [10, 0, 20, 0, 30, 0, 40, 0, 50, 0, 60, 0, 70, 0, 80, 0, 90, 0, 100, 0],days = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0, 5, 0]) == 23\n assert candidate(apples = [0, 0, 0, 0, 0, 10, 10, 10, 10, 10, 0, 0, 0, 0, 0],days = [0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0]) == 7\n assert candidate(apples = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 32\n assert candidate(apples = [1, 2, 0, 4, 5, 0, 0, 6, 7, 0, 0, 8, 9],days = [3, 2, 0, 4, 5, 0, 0, 2, 3, 0, 0, 2, 3]) == 15\n assert candidate(apples = [100, 100, 100, 100, 100],days = [5, 5, 5, 5, 5]) == 9\n assert candidate(apples = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],days = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(apples = [2, 3, 1, 5, 4, 2, 3, 1, 1, 1, 1],days = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 17\n assert candidate(apples = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],days = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(apples = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100],days = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n"}, "metadata": {"canonical_parameter_names": ["apples", "days"], "leetcode_dataset_entry_point": "Solution().eatenApples", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int eatenApples(vector& apples, vector& days) {", "container": "Solution", "callable": "eatenApples", "parameters": [{"name": "apples", "type": "vector&"}, {"name": "days", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1706, "task_id": "where-will-the-ball-fall", "difficulty": "Medium", "problem_description": "You have a 2-D grid of size m x n representing a box, and you have n balls. The box is open on the top and bottom sides.\nEach cell in the box has a diagonal board spanning two corners of the cell that can redirect a ball to the right or to the left.\n\nA board that redirects the ball to the right spans the top-left corner to the bottom-right corner and is represented in the grid as 1.\nA board that redirects the ball to the left spans the top-right corner to the bottom-left corner and is represented in the grid as -1.\n\nWe drop one ball at the top of each column of the box. Each ball can get stuck in the box or fall out of the bottom. A ball gets stuck if it hits a \"V\" shaped pattern between two boards or if a board redirects the ball into either wall of the box.\nReturn an array answer of size n where answer[i] is the column that the ball falls out of at the bottom after dropping the ball from the ith column at the top, or -1 if the ball gets stuck in the box.\n \nExample 1:\n\n\nInput: grid = [[1,1,1,-1,-1],[1,1,1,-1,-1],[-1,-1,-1,1,1],[1,1,1,1,-1],[-1,-1,-1,-1,-1]]\nOutput: [1,-1,-1,-1,-1]\nExplanation: This example is shown in the photo.\nBall b0 is dropped at column 0 and falls out of the box at column 1.\nBall b1 is dropped at column 1 and will get stuck in the box between column 2 and 3 and row 1.\nBall b2 is dropped at column 2 and will get stuck on the box between column 2 and 3 and row 0.\nBall b3 is dropped at column 3 and will get stuck on the box between column 2 and 3 and row 0.\nBall b4 is dropped at column 4 and will get stuck on the box between column 2 and 3 and row 1.\n\nExample 2:\n\nInput: grid = [[-1]]\nOutput: [-1]\nExplanation: The ball gets stuck against the left wall.\n\nExample 3:\n\nInput: grid = [[1,1,1,1,1,1],[-1,-1,-1,-1,-1,-1],[1,1,1,1,1,1],[-1,-1,-1,-1,-1,-1]]\nOutput: [0,1,2,3,4,-1]\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 100\ngrid[i][j] is 1 or -1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == [-1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[-1, -1, -1], [-1, -1, -1], [-1, -1, -1]]) == [-1, -1, -1]\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [-1, -1, -1]]) == [1, -1, -1]\n assert candidate(grid = [[1, 1, 1, -1, -1], [1, 1, 1, -1, -1], [-1, -1, -1, 1, 1], [1, 1, 1, 1, -1], [-1, -1, -1, -1, -1]]) == [1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1], [1, 1, -1, 1, 1], [-1, 1, 1, -1, 1], [1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1]\n assert candidate(grid = [[-1]]) == [-1]\n assert candidate(grid = [[1, 1, -1, -1], [1, 1, -1, -1], [-1, -1, 1, 1], [-1, -1, 1, 1]]) == [-1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1], [-1, 1, -1, 1, -1], [1, -1, 1, -1, 1], [-1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1]]) == [0, 1, 2, 3, 4, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, -1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, 1, -1, -1, -1, -1], [1, 1, 1, 1, -1, 1, 1, 1, 1, 1], [1, -1, -1, 1, 1, -1, 1, -1, -1, 1]]) == [-1, 1, 4, -1, -1, -1, -1, 7, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, -1, -1], [-1, -1, -1, 1, 1, -1], [1, 1, -1, -1, 1, 1], [1, -1, 1, -1, -1, 1], [-1, 1, -1, 1, 1, -1]]) == [-1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [1, -1, -1, 1, 1, -1, -1, 1, 1, -1], [-1, 1, 1, -1, -1, 1, 1, -1, -1, 1]]) == [-1, -1, -1, 2, -1, -1, -1, 6, -1, -1]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [-1, -1, 1, 1, -1, -1, 1, 1, -1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, -1, -1, -1, 1, -1], [1, -1, 1, -1, 1, 1, 1], [-1, 1, 1, -1, 1, 1, -1], [1, -1, 1, 1, -1, 1, 1], [-1, 1, -1, -1, 1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, -1, -1, -1, 1, 1, 1, -1], [-1, -1, -1, 1, 1, 1, -1, -1, -1, 1], [1, 1, 1, -1, -1, -1, 1, 1, 1, -1], [-1, -1, -1, 1, 1, 1, -1, -1, -1, 1]]) == [0, 1, -1, -1, 4, 5, 6, 7, -1, -1]\n assert candidate(grid = [[-1, -1, 1, 1, -1, -1, 1, 1, -1, -1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [-1, -1, 1, 1, -1, -1, 1, 1, -1, -1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1]]) == [-1, 1, 2, -1, -1, 5, 6, -1, -1, 9]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, -1]\n assert candidate(grid = [[-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [-1, -1, 1, 1, -1, -1, 1, 1, -1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, 1, 1, 1, -1, -1, -1, -1, 1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, -1, 1, 1, -1, -1, 1, 1, -1], [1, -1, -1, 1, 1, -1, -1, 1, 1, -1], [-1, 1, 1, -1, -1, 1, 1, -1, -1, 1], [-1, 1, 1, -1, -1, 1, 1, -1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1], [-1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1], [-1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, 8, -1, -1]\n assert candidate(grid = [[-1, -1, -1, 1, 1, 1, 1, 1, 1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]]) == [4, 5, -1, -1, -1, -1, -1, -1, -1, -1, 6]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, 1, -1], [1, -1, 1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, 1, -1, 1, -1], [1, 1, -1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, -1, -1, 1, 1, -1, -1, 1, 1], [-1, -1, -1, 1, 1, -1, -1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1]]) == [-1, 0, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1], [1, -1, -1, 1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, 1, -1, -1, 1, 1, -1, 1], [-1, 1, -1, 1, -1, -1, 1, 1, -1, 1], [1, -1, 1, 1, -1, -1, 1, 1, -1, 1], [-1, 1, -1, 1, -1, -1, 1, 1, -1, 1], [1, -1, 1, 1, -1, -1, 1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1], [1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1], [1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, -1, -1, 1], [-1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 18, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1], [1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1], [-1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1]]) == [-1, -1, -1, 2, -1, -1, -1, 6, -1, 10, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, -1, -1, 1, 1, 1, 1], [-1, -1, -1, 1, 1, -1, -1, -1, 1, 1], [1, 1, -1, -1, 1, 1, 1, 1, -1, -1], [1, -1, 1, -1, -1, 1, 1, -1, 1, -1]]) == [-1, -1, 6, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [-1, -1, 1, 1, -1, -1, 1, 1, -1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, -1, -1, -1, 1], [1, -1, 1, -1, 1, 1], [-1, 1, 1, -1, 1, 1], [1, -1, 1, 1, -1, 1], [-1, 1, -1, -1, 1, 1]]) == [-1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, -1]\n assert candidate(grid = [[1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1], [1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1], [-1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1]]) == [-1, 2, -1, -1, 3, 6, 7, -1, -1, -1, 11, -1, -1, -1, -1, 18, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[-1, -1, -1, -1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, -1, -1, -1, -1, 1, 1], [-1, -1, -1, -1, 1, 1, 1, 1, -1, -1], [1, 1, 1, 1, -1, -1, -1, -1, 1, 1], [-1, -1, -1, -1, 1, 1, 1, 1, -1, -1]]) == [-1, 0, 1, 2, 5, 6, 7, 8, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, -1, -1, -1, -1, 1, 1], [1, -1, -1, -1, 1, 1, 1, 1, -1, -1], [-1, 1, 1, 1, -1, -1, -1, -1, 1, 1], [1, -1, -1, -1, 1, 1, 1, 1, -1, -1]]) == [-1, 1, 2, -1, -1, 5, 6, 7, 8, -1]\n assert candidate(grid = [[1, -1, 1, 1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, 1], [-1, -1, 1, -1, 1, 1, -1, 1, 1, -1, 1, -1, -1, 1, -1, -1], [1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, 1], [-1, -1, 1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 9, -1, -1, -1, -1, -1, -1, -1, -1, 18]\n assert candidate(grid = [[1, 1, 1, -1, -1, -1, 1, 1, 1], [1, -1, -1, 1, 1, -1, -1, 1, -1], [-1, 1, -1, -1, 1, -1, 1, -1, 1], [1, 1, -1, 1, -1, 1, -1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, -1, -1, -1, -1, -1], [1, 1, 1, 1, 1, -1, -1, -1, -1, -1]]) == [4, -1, -1, -1, -1, -1, -1, -1, -1, 5]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, -1, -1, 1], [1, -1, 1, 1, -1, -1, 1, 1, -1], [-1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, 1, -1, 1, -1, 1, 1, -1], [-1, 1, -1, -1, 1, -1, 1, -1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [1, -1, 1, 1, -1, 1, -1, 1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[-1, -1, -1, -1, 1, 1, 1, 1, -1, -1], [-1, -1, 1, 1, 1, 1, -1, -1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, 1, -1, 1, -1, 1, -1, 1, -1]]) == [-1, -1, 0, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1], [-1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1], [1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1], [-1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, -1, 1, 1]]) == [0, 1, -1, -1, 4, 5, 6, -1, -1, 9, 10, 11, -1, -1, 14, 15, 16, -1, -1, 19]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, -1, -1]\n assert candidate(grid = [[1, 1, 1, -1, -1, -1, 1, 1, 1, -1], [-1, -1, -1, 1, 1, 1, -1, -1, -1, 1], [1, 1, 1, -1, -1, -1, 1, 1, 1, -1], [-1, -1, -1, 1, 1, 1, -1, -1, -1, 1], [1, 1, 1, -1, -1, -1, 1, 1, 1, -1]]) == [1, 2, -1, -1, 3, 4, 7, 8, -1, -1]\n assert candidate(grid = [[1, -1, 1, 1, -1, -1, 1, 1, -1, 1], [1, -1, 1, -1, 1, -1, 1, -1, 1, -1], [-1, -1, 1, 1, -1, 1, -1, -1, 1, -1], [1, 1, -1, -1, 1, -1, 1, -1, -1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(grid = [[1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1], [1, 1, -1, -1, 1, 1, -1, -1, 1, 1]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().findBall", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector findBall(vector>& grid) {", "container": "Solution", "callable": "findBall", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1707, "task_id": "maximum-xor-with-an-element-from-array", "difficulty": "Hard", "problem_description": "You are given an array nums consisting of non-negative integers. You are also given a queries array, where queries[i] = [xi, mi].\nThe answer to the ith query is the maximum bitwise XOR value of xi and any element of nums that does not exceed mi. In other words, the answer is max(nums[j] XOR xi) for all j such that nums[j] <= mi. If all elements in nums are larger than mi, then the answer is -1.\nReturn an integer array answer where answer.length == queries.length and answer[i] is the answer to the ith query.\n \nExample 1:\n\nInput: nums = [0,1,2,3,4], queries = [[3,1],[1,3],[5,6]]\nOutput: [3,3,7]\nExplanation:\n1) 0 and 1 are the only two integers not greater than 1. 0 XOR 3 = 3 and 1 XOR 3 = 2. The larger of the two is 3.\n2) 1 XOR 2 = 3.\n3) 5 XOR 2 = 7.\n\nExample 2:\n\nInput: nums = [5,2,4,6,6,3], queries = [[12,4],[8,1],[6,3]]\nOutput: [15,-1,5]\n\n \nConstraints:\n\n1 <= nums.length, queries.length <= 105\nqueries[i].length == 2\n0 <= nums[j], xi, mi <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 4, 8, 16],queries = [[10, 15], [30, 20], [5, 5]]) == [14, 31, 7]\n assert candidate(nums = [100, 200, 300, 400],queries = [[150, 250], [10, 100], [450, 500]]) == [242, 110, 422]\n assert candidate(nums = [7, 8, 9],queries = [[1, 5], [6, 8], [10, 12]]) == [-1, 14, 13]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[1, 10], [2, 5], [3, 3], [4, 4], [5, 2], [6, 6], [7, 7], [8, 8], [9, 9], [10, 1]]) == [11, 7, 2, 7, 7, 7, 6, 15, 15, 11]\n assert candidate(nums = [1000000000],queries = [[1000000000, 1000000000], [999999999, 999999999]]) == [0, -1]\n assert candidate(nums = [5, 2, 4, 6, 6, 3],queries = [[12, 4], [8, 1], [6, 3]]) == [15, -1, 5]\n assert candidate(nums = [0, 1, 2, 3, 4],queries = [[3, 1], [1, 3], [5, 6]]) == [3, 3, 7]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],queries = [[9, 10], [99, 100], [999, 1000], [9999, 10000], [99999, 100000], [999999, 1000000], [9999999, 10000000], [99999999, 100000000], [999999999, 1000000000], [0, 1]]) == [8, 105, 1005, 10091, 106895, 1008943, 10031327, 100311743, 1047472383, 1]\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],queries = [[1000000000, 999999999], [999999998, 999999997], [999999996, 999999995], [999999995, 1000000000]]) == [1023, 3, -1, 1019]\n assert candidate(nums = [1, 1, 1, 1, 1],queries = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]]) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 0], [1, 0], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]]) == [-1, -1, 3, 2, 5, 4, 7, 6, 9, 8]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],queries = [[7, 7], [7, 6], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [7, 13], [7, 14], [7, 15]]) == [0, -1, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384],queries = [[1024, 2047], [2048, 4095], [4096, 8191], [8192, 16383], [16384, 32767], [32768, 16384], [65536, 8192]]) == [0, 3072, 6144, 12288, 24576, 49152, 73728]\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991],queries = [[1000000000, 999999999], [999999998, 999999997], [999999996, 999999995], [999999994, 999999993], [999999992, 999999991], [999999990, 999999989], [999999988, 999999987], [999999986, 999999985], [999999984, 999999983], [999999982, 999999981]]) == [1023, 9, 11, 13, 15, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 150, 200, 250, 300, 350, 400],queries = [[10, 100], [150, 200], [250, 300], [350, 400], [400, 450], [500, 550]]) == [110, 242, 470, 456, 500, 400]\n assert candidate(nums = [1024, 2048, 3072, 4096, 5120, 6144, 7168, 8192, 9216],queries = [[512, 1024], [1536, 2048], [2560, 3072], [3584, 4096], [4608, 5120], [5632, 6144], [6656, 7168], [7680, 8192], [8704, 9216]]) == [1536, 3584, 3584, 7680, 7680, 7680, 7680, 15872, 15872]\n assert candidate(nums = [2147483647, 2147483646, 2147483645, 2147483644, 2147483643],queries = [[2147483647, 2147483647], [2147483646, 2147483646], [2147483645, 2147483645], [2147483644, 2147483644], [2147483643, 2147483643]]) == [4, 5, 6, 7, 0]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[10, 90], [20, 80], [30, 70], [40, 60], [50, 50], [60, 40], [70, 30], [80, 20], [90, 10], [100, 0]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],queries = [[0, 31], [1, 30], [2, 29], [3, 28], [4, 27], [5, 26], [6, 25], [7, 24], [8, 23], [9, 22], [10, 21], [11, 20], [12, 19], [13, 18], [14, 17], [15, 16]]) == [31, 28, 31, 26, 31, 28, 31, 22, 31, 28, 31, 26, 31, 28, 31, 14]\n assert candidate(nums = [1000000000, 900000000, 800000000, 700000000, 600000000],queries = [[1000000000, 1000000000], [900000000, 900000000], [800000000, 800000000], [700000000, 700000000], [600000000, 600000000], [500000000, 500000000]]) == [408521728, 471715328, 208424448, 175792384, 0, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[50, 350], [150, 450], [250, 550], [350, 650], [450, 750], [550, 850], [650, 950], [750, 1050], [850, 1150], [950, 1250]]) == [286, 442, 470, 774, 922, 978, 934, 962, 922, 978]\n assert candidate(nums = [1000000000, 1000000001, 1000000002, 1000000003, 1000000004],queries = [[1000000000, 1000000004], [1000000001, 1000000002], [1000000002, 1000000001], [1000000003, 1000000003], [1000000004, 1000000000]]) == [4, 3, 3, 3, 4]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],queries = [[1024, 512], [512, 256], [256, 128], [128, 64], [64, 32], [32, 16], [16, 8], [8, 4], [4, 2], [2, 1], [1, 1]]) == [1536, 768, 384, 192, 96, 48, 24, 12, 6, 3, 0]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [0, 3, 2, 7, 6, 7, 6, 15, 14, 15]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[2, 1], [4, 3], [6, 5], [8, 7], [10, 9], [12, 11], [14, 13], [16, 15], [18, 17], [20, 19]]) == [3, 7, 7, 15, 15, 15, 15, 31, 31, 31]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576],queries = [[0, 1], [1, 2], [3, 4], [7, 8], [15, 16], [31, 32], [63, 64], [127, 128], [255, 256], [511, 512], [1023, 1024], [2047, 2048], [4095, 4096], [8191, 8192], [16383, 16384], [32767, 32768], [65535, 65536], [131071, 131072], [262143, 262144], [524287, 524288], [1048575, 1048576]]) == [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],queries = [[1, 2], [3, 4], [7, 8], [15, 16], [31, 32], [63, 64], [127, 128], [255, 256], [511, 512], [1023, 1024]]) == [3, 7, 15, 31, 63, 127, 255, 511, 1023, 1022]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],queries = [[2, 1], [4, 3], [6, 5], [8, 7], [10, 9], [12, 11], [14, 13], [16, 15], [18, 17], [20, 19], [22, 21], [24, 23], [26, 25], [28, 27], [30, 29], [32, 31]]) == [3, 7, 7, 15, 15, 15, 15, 31, 31, 31, 31, 31, 31, 31, 31, 63]\n assert candidate(nums = [23, 31, 12, 22, 19, 30, 27, 14, 29, 25],queries = [[10, 30], [35, 35], [23, 23], [19, 20], [30, 31]]) == [29, 62, 27, 31, 18]\n assert candidate(nums = [1000000000, 900000000, 800000000, 700000000, 600000000, 500000000, 400000000, 300000000, 200000000, 100000000],queries = [[1100000000, 1000000000], [950000000, 900000000], [850000000, 800000000], [750000000, 700000000], [650000000, 600000000], [550000000, 500000000], [450000000, 400000000], [350000000, 300000000], [250000000, 200000000], [150000000, 100000000]]) == [2047500544, 1030371456, 960641664, 1029026944, 997413760, 1023750272, 522687872, 523719040, 185815936, 218443904]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[5, 10], [15, 25], [25, 35], [35, 45], [45, 55], [55, 65], [65, 75], [75, 85], [85, 95], [95, 105]]) == [15, 27, 19, 61, 57, 61, 125, 121, 125, 119]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[50, 150], [250, 350], [450, 550], [650, 750], [850, 950], [1050, 1150]]) == [86, 470, 422, 934, 922, 2034]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000],queries = [[1, 5], [10, 50], [100, 500], [1000, 5000], [10000, 50000], [100000, 500000], [1000000, 1500000]]) == [0, 11, 110, 1001, 10100, 106928, 1008976]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],queries = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15], [17, 17], [19, 19]]) == [-1, 1, 7, 5, 15, 15, 15, 13, 31, 31]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [5, 100], [105, 100]]) == [0, 30, 20, 60, 56, 54, 122, 120, 114, 122, 97, 125]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[2, 10], [4, 20], [6, 30], [8, 40], [10, 50], [12, 60], [14, 70], [16, 80], [18, 90], [20, 100]]) == [11, 23, 23, 27, 27, 31, 31, 31, 31, 31]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == [0, 2, 6, 6, 14, 14, 14, 14, 30, 30]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],queries = [[1, 1], [5, 10], [50, 100], [500, 1000], [5000, 10000], [50000, 100000], [500000, 1000000], [5000000, 10000000], [50000000, 100000000], [500000000, 1000000000]]) == [0, 15, 86, 540, 13464, 83440, 582496, 13950400, 118428032, 643280640]\n assert candidate(nums = [31, 30, 29, 28, 27, 26, 25, 24, 23, 22],queries = [[32, 31], [33, 30], [34, 29], [35, 28], [36, 27], [37, 26], [38, 25], [39, 24], [40, 23], [41, 22]]) == [63, 63, 63, 63, 63, 63, 63, 63, 63, 63]\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109],queries = [[100, 100], [101, 101], [102, 102], [103, 103], [104, 104], [105, 105], [106, 106], [107, 107], [108, 108], [109, 109]]) == [0, 1, 3, 3, 15, 15, 15, 15, 11, 11]\n assert candidate(nums = [123, 456, 789, 101, 202, 303, 404, 505],queries = [[100, 200], [300, 400], [500, 600], [700, 800], [800, 700], [900, 1000]]) == [31, 486, 401, 915, 1002, 1023]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[5, 50], [15, 30], [25, 40], [35, 60], [45, 70], [55, 80], [65, 90], [75, 100], [85, 20], [95, 10]]) == [55, 27, 49, 61, 107, 113, 125, 121, 95, 85]\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],queries = [[500, 1024], [256, 256], [1025, 1025], [10, 20], [2, 3]]) == [1524, 384, 1537, 26, 3]\n assert candidate(nums = [2147483647, 2147483646, 2147483645, 2147483644, 2147483643],queries = [[1, 2147483647], [2, 2147483646], [3, 2147483645], [4, 2147483644], [5, 2147483643]]) == [2147483647, 2147483647, 2147483647, 2147483647, 2147483646]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],queries = [[1, 1], [2, 2], [3, 4], [5, 8], [9, 16], [17, 32], [33, 64], [65, 128], [129, 256], [257, 512], [513, 1024], [1025, 2048], [2049, 4096], [4097, 8192], [8193, 16384], [16385, 32768]]) == [0, 3, 7, 13, 25, 49, 97, 193, 385, 769, 1537, 3073, 6145, 12289, 24577, 49153]\n assert candidate(nums = [50, 40, 30, 20, 10],queries = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60], [65, 70], [75, 80], [85, 90], [95, 100]]) == [15, 27, 19, 61, 57, 61, 115, 121, 125, 119]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[101, 99], [201, 199], [301, 299], [401, 399], [501, 499], [601, 599], [701, 699], [801, 799], [901, 899], [1001, 999]]) == [-1, 173, 485, 501, 401, 969, 913, 1001, 993, 909]\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384],queries = [[512, 1024], [1536, 2048], [2560, 4096], [4608, 8192], [8704, 16384], [32768, 65536]]) == [1536, 3584, 6656, 12800, 25088, 49152]\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930],queries = [[100, 123], [400, 456], [700, 789], [100000, 101112], [130000, 131415], [160000, 161718], [190000, 192021], [220000, 222324], [250000, 252627], [280000, 282930]]) == [31, 491, 884, 100200, 260743, 261112, 224456, 219931, 250757, 499475]\n assert candidate(nums = [100, 150, 200, 250, 300, 350, 400, 450, 500],queries = [[50, 100], [250, 350], [375, 400], [500, 500], [100, 99]]) == [86, 470, 481, 400, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [1, 3, 3, 7, 7, 7, 7, 15, 15, 15]\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99],queries = [[8, 9], [17, 18], [26, 27], [35, 36], [44, 45], [53, 54], [62, 63], [71, 72], [80, 81], [89, 90], [98, 99]]) == [1, 24, 19, 56, 62, 60, 55, 120, 125, 125, 121]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],queries = [[999, 1000], [1999, 2000], [2999, 3000], [3999, 4000], [4999, 5000], [5999, 6000], [6999, 7000], [7999, 8000], [8999, 9000], [9999, 10000]]) == [15, 1063, 3175, 3191, 7207, 7383, 7303, 7383, 15463, 15447]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100], [11, 100], [12, 100], [13, 100], [14, 100], [15, 100], [16, 100], [17, 100], [18, 100], [19, 100], [20, 100]]) == [11, 22, 29, 44, 55, 58, 65, 88, 89, 110, 111, 104, 105, 106, 107, 116, 117, 118, 119, 112]\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],queries = [[8, 9], [17, 18], [26, 27], [35, 36], [44, 45], [53, 54], [62, 63], [71, 72], [80, 81], [89, 90], [91, 90]]) == [1, 24, 19, 56, 62, 60, 55, 120, 125, 125, 127]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[2, 5], [4, 9], [6, 13], [8, 17], [10, 19], [12, 21], [14, 23], [16, 25], [18, 27], [20, 29]]) == [7, 13, 15, 25, 27, 31, 31, 31, 31, 31]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],queries = [[10, 9], [7, 6], [1, 10], [8, 5], [0, 0]]) == [15, 6, 8, 13, -1]\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021],queries = [[122, 123], [455, 456], [788, 789], [101111, 101112], [131414, 131415], [161717, 161718], [192020, 192021], [200000, 210000]]) == [1, 444, 879, 101183, 232366, 261453, 222444, 200277]\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000],queries = [[1000000000, 1000000000], [500000000, 500000000], [250000000, 250000000], [125000000, 125000000], [62500000, 62500000], [31250000, 31250000], [15625000, 15625000]]) == [1021940544, 510970272, 255485136, 127742568, 56084360, 20102520, 0]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[1, 15], [2, 14], [3, 13], [4, 12], [5, 11], [6, 10], [7, 9], [8, 8], [9, 7], [10, 6], [11, 5], [12, 4], [13, 3], [14, 2], [15, 1]]) == [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],queries = [[2, 10], [4, 12], [6, 14], [8, 16], [10, 18], [12, 20], [14, 22], [16, 24], [18, 26], [20, 28], [22, 30], [24, 10], [26, 12], [28, 14], [30, 16]]) == [11, 15, 15, 15, 27, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31]\n assert candidate(nums = [100, 200, 300, 400, 500],queries = [[150, 200], [250, 350], [350, 450], [50, 150], [450, 500]]) == [242, 470, 406, 86, 422]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],queries = [[1, 1000000000], [2, 100000000], [3, 10000000], [4, 1000000], [5, 100000], [6, 10000], [7, 1000], [8, 100], [9, 10], [10, 1]]) == [1000000001, 100000002, 10000003, 1000004, 100005, 10006, 1007, 108, 8, 11]\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],queries = [[1000000000, 1000000000], [1, 1000000000], [1000000000, 999999999], [1, 999999999], [1000000000, 999999998]]) == [1023, 1000000001, 1023, 999999999, 1022]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],queries = [[1, 2], [2, 4], [3, 8], [4, 16], [5, 32], [6, 64], [7, 128], [8, 256], [9, 512], [10, 1024], [11, 2048], [12, 4096], [13, 8192], [14, 16384], [15, 32768]]) == [3, 6, 11, 20, 37, 70, 135, 264, 521, 1034, 2059, 4108, 8205, 16398, 16399]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],queries = [[1, 1], [2, 2], [4, 4], [8, 8], [16, 16], [32, 32], [64, 64], [128, 128], [256, 256], [512, 512], [1024, 1024], [2048, 2048], [4096, 4096], [8192, 8192], [16384, 16384], [32768, 16384]]) == [0, 3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152]\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109],queries = [[11, 30], [22, 40], [33, 50], [44, 60], [55, 70], [66, 80], [77, 90], [88, 100], [99, 110], [100, 120]]) == [30, 54, 52, 57, 118, 116, 123, 120, 118, 113]\n assert candidate(nums = [8, 4, 2, 1, 16, 32, 64, 128, 256, 512],queries = [[7, 8], [3, 4], [1, 2], [15, 16], [31, 32], [63, 64], [127, 128], [255, 256], [511, 512], [1023, 1024]]) == [15, 7, 3, 31, 63, 127, 255, 511, 1023, 1022]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],queries = [[2, 3], [5, 6], [8, 9], [11, 12], [14, 15], [17, 18], [20, 21], [23, 24], [26, 27], [29, 30], [31, 32]]) == [1, 6, 14, 13, 13, 30, 29, 30, 28, 30, 28]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[15, 10], [25, 20], [35, 30], [45, 40], [55, 50], [65, 60], [75, 70], [85, 80], [95, 90], [105, 100]]) == [5, 19, 61, 57, 61, 125, 121, 125, 119, 125]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],queries = [[1, 1], [2, 2], [3, 4], [5, 8], [9, 16], [17, 32], [33, 64], [65, 128], [129, 256], [257, 512]]) == [0, 3, 7, 13, 25, 49, 97, 193, 385, 769]\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996],queries = [[1000000000, 999999999], [999999998, 999999998], [999999997, 999999996], [999999996, 999999995]]) == [1023, 3, 1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],queries = [[2, 10], [4, 12], [6, 14], [8, 16], [10, 18], [12, 20], [14, 22], [16, 24], [18, 26], [20, 28], [22, 30], [24, 32], [26, 34], [28, 36], [30, 38]]) == [11, 15, 15, 15, 27, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31]\n assert candidate(nums = [123456789, 987654321, 135792468, 246813579, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666],queries = [[100000000, 300000000], [200000000, 400000000], [300000000, 500000000], [400000000, 600000000], [500000000, 700000000], [600000000, 800000000], [700000000, 900000000], [800000000, 1000000000], [900000000, 1100000000], [1000000000, 1200000000]]) == [233694804, 406159701, 525840523, 919248611, 1020297187, 968812828, 979854421, 1014057813, 1035791956, 1023779271]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[1, 1], [2, 1], [0, 1], [10, 1], [100, 1]]) == [0, 3, 1, 11, 101]\n assert candidate(nums = [23, 45, 67, 89, 111, 135, 159, 183, 207, 231],queries = [[22, 23], [44, 45], [66, 67], [88, 89], [110, 111], [134, 135], [158, 159], [182, 183], [206, 207], [230, 231]]) == [1, 59, 111, 117, 121, 233, 241, 245, 227, 241]\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110],queries = [[100, 105], [101, 101], [102, 103], [103, 107], [104, 104], [105, 108], [106, 106], [107, 109], [108, 110], [109, 100], [110, 102]]) == [13, 1, 3, 15, 15, 15, 15, 15, 11, 9, 11]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[99, 100], [150, 300], [250, 250], [350, 400], [450, 500], [550, 600], [650, 700], [750, 800], [850, 900], [950, 1000]]) == [7, 442, 158, 406, 422, 978, 934, 962, 922, 978]\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],queries = [[1, 2], [2, 3], [3, 5], [4, 7], [5, 11], [6, 13], [7, 17], [8, 19], [9, 23], [10, 29]]) == [3, 1, 6, 7, 14, 13, 22, 27, 30, 29]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],queries = [[3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21], [21, 23]]) == [7, 7, 15, 15, 15, 15, 31, 31, 31, 31]\n"}, "metadata": {"canonical_parameter_names": ["nums", "queries"], "leetcode_dataset_entry_point": "Solution().maximizeXor", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector maximizeXor(vector& nums, vector>& queries) {", "container": "Solution", "callable": "maximizeXor", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "queries", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1710, "task_id": "maximum-units-on-a-truck", "difficulty": "Easy", "problem_description": "You are assigned to put some amount of boxes onto one truck. You are given a 2D array boxTypes, where boxTypes[i] = [numberOfBoxesi, numberOfUnitsPerBoxi]:\n\nnumberOfBoxesi is the number of boxes of type i.\nnumberOfUnitsPerBoxi is the number of units in each box of the type i.\n\nYou are also given an integer truckSize, which is the maximum number of boxes that can be put on the truck. You can choose any boxes to put on the truck as long as the number of boxes does not exceed truckSize.\nReturn the maximum total number of units that can be put on the truck.\n \nExample 1:\n\nInput: boxTypes = [[1,3],[2,2],[3,1]], truckSize = 4\nOutput: 8\nExplanation: There are:\n- 1 box of the first type that contains 3 units.\n- 2 boxes of the second type that contain 2 units each.\n- 3 boxes of the third type that contain 1 unit each.\nYou can take all the boxes of the first and second types, and one box of the third type.\nThe total number of units will be = (1 * 3) + (2 * 2) + (1 * 1) = 8.\n\nExample 2:\n\nInput: boxTypes = [[5,10],[2,5],[4,7],[3,9]], truckSize = 10\nOutput: 91\n\n \nConstraints:\n\n1 <= boxTypes.length <= 1000\n1 <= numberOfBoxesi, numberOfUnitsPerBoxi <= 1000\n1 <= truckSize <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(boxTypes = [[1, 3], [2, 2], [3, 1]],truckSize = 4) == 8\n assert candidate(boxTypes = [[1, 1], [2, 2], [3, 3], [4, 4]],truckSize = 1) == 4\n assert candidate(boxTypes = [[2, 1], [4, 4], [3, 3]],truckSize = 5) == 19\n assert candidate(boxTypes = [[10, 1], [20, 2], [30, 3]],truckSize = 50) == 130\n assert candidate(boxTypes = [[5, 10], [2, 5], [4, 7], [3, 9]],truckSize = 10) == 91\n assert candidate(boxTypes = [[1, 100], [2, 99], [3, 98], [4, 97]],truckSize = 10) == 980\n assert candidate(boxTypes = [[10, 1], [5, 2], [3, 3]],truckSize = 10) == 21\n assert candidate(boxTypes = [[100, 1], [99, 2], [98, 3], [97, 4]],truckSize = 200) == 692\n assert candidate(boxTypes = [[10, 1]],truckSize = 10) == 10\n assert candidate(boxTypes = [[1, 1000], [1000, 1]],truckSize = 500) == 1499\n assert candidate(boxTypes = [[1, 100], [2, 90], [3, 80], [4, 70], [5, 60]],truckSize = 10) == 800\n assert candidate(boxTypes = [[5, 5], [5, 5], [5, 5], [5, 5]],truckSize = 15) == 75\n assert candidate(boxTypes = [[2, 1], [3, 2], [4, 3], [5, 4], [6, 5]],truckSize = 15) == 62\n assert candidate(boxTypes = [[2, 1000], [1, 900], [2, 800], [1, 700], [2, 600], [1, 500], [2, 400], [1, 300], [2, 200], [1, 100]],truckSize = 10) == 7300\n assert candidate(boxTypes = [[9, 1], [8, 2], [7, 3], [6, 4], [5, 5], [4, 6], [3, 7], [2, 8], [1, 9]],truckSize = 20) == 115\n assert candidate(boxTypes = [[5, 10], [1, 15], [3, 12], [2, 14], [4, 8]],truckSize = 15) == 161\n assert candidate(boxTypes = [[7, 10], [5, 3], [2, 6], [8, 1]],truckSize = 20) == 103\n assert candidate(boxTypes = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5]],truckSize = 15) == 35\n assert candidate(boxTypes = [[5, 10], [4, 20], [3, 30], [2, 40], [1, 50]],truckSize = 15) == 350\n assert candidate(boxTypes = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],truckSize = 5) == 40\n assert candidate(boxTypes = [[9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]],truckSize = 30) == 174\n assert candidate(boxTypes = [[999, 1], [1, 999], [500, 500], [250, 250], [125, 125]],truckSize = 1000) == 329248\n assert candidate(boxTypes = [[1, 5], [2, 3], [3, 2], [4, 1]],truckSize = 10) == 21\n assert candidate(boxTypes = [[50, 10], [100, 9], [150, 8], [200, 7], [250, 6], [300, 5]],truckSize = 800) == 5750\n assert candidate(boxTypes = [[50, 5], [30, 6], [20, 7]],truckSize = 100) == 570\n assert candidate(boxTypes = [[3, 100], [2, 200], [1, 300], [5, 400]],truckSize = 5) == 2000\n assert candidate(boxTypes = [[20, 5], [15, 10], [10, 15], [5, 20], [1, 25]],truckSize = 35) == 445\n assert candidate(boxTypes = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000]],truckSize = 20) == 18900\n assert candidate(boxTypes = [[10, 10], [10, 20], [10, 30], [10, 40], [10, 50]],truckSize = 40) == 1400\n assert candidate(boxTypes = [[50, 10], [30, 20], [20, 30], [10, 40], [5, 50]],truckSize = 120) == 2350\n assert candidate(boxTypes = [[200, 1], [100, 2], [150, 3], [50, 4], [250, 5]],truckSize = 500) == 2000\n assert candidate(boxTypes = [[100, 1], [50, 2], [25, 3], [10, 4], [5, 5], [1, 6]],truckSize = 150) == 305\n assert candidate(boxTypes = [[20, 25], [15, 30], [10, 35], [5, 40]],truckSize = 50) == 1500\n assert candidate(boxTypes = [[10, 10], [5, 7], [15, 5], [20, 3]],truckSize = 25) == 185\n assert candidate(boxTypes = [[50, 10], [30, 20], [20, 30], [10, 40]],truckSize = 100) == 2000\n assert candidate(boxTypes = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],truckSize = 150) == 5500\n assert candidate(boxTypes = [[1, 900], [2, 800], [3, 700], [4, 600], [5, 500], [6, 400], [7, 300], [8, 200], [9, 100]],truckSize = 15) == 9500\n assert candidate(boxTypes = [[1, 999], [2, 998], [3, 997], [4, 996], [5, 995], [6, 994], [7, 993], [8, 992], [9, 991], [10, 990]],truckSize = 20) == 19915\n assert candidate(boxTypes = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]],truckSize = 55) == 220\n assert candidate(boxTypes = [[30, 20], [20, 15], [10, 10], [40, 5], [50, 2]],truckSize = 100) == 1200\n assert candidate(boxTypes = [[10, 30], [20, 20], [30, 10], [40, 5], [50, 1]],truckSize = 60) == 1000\n assert candidate(boxTypes = [[50, 10], [40, 20], [30, 30], [20, 40], [10, 50]],truckSize = 120) == 3200\n assert candidate(boxTypes = [[500, 1000], [400, 900], [300, 800], [200, 700], [100, 600]],truckSize = 1200) == 1100000\n assert candidate(boxTypes = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],truckSize = 150) == 1450\n assert candidate(boxTypes = [[100, 10], [200, 9], [150, 8], [50, 7], [25, 6]],truckSize = 300) == 2800\n assert candidate(boxTypes = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],truckSize = 50) == 215\n assert candidate(boxTypes = [[500, 100], [300, 200], [200, 300], [100, 400]],truckSize = 800) == 180000\n assert candidate(boxTypes = [[50, 100], [25, 200], [75, 50], [100, 250]],truckSize = 200) == 36250\n assert candidate(boxTypes = [[1, 999], [999, 1]],truckSize = 1000) == 1998\n assert candidate(boxTypes = [[7, 9], [7, 8], [7, 7], [7, 6], [7, 5], [7, 4], [7, 3], [7, 2], [7, 1]],truckSize = 20) == 161\n assert candidate(boxTypes = [[3, 8], [5, 7], [2, 9], [6, 10], [4, 5]],truckSize = 15) == 130\n assert candidate(boxTypes = [[5, 10], [4, 20], [3, 30], [2, 40], [1, 50], [1, 60], [1, 70], [1, 80], [1, 90], [1, 100]],truckSize = 20) == 750\n assert candidate(boxTypes = [[50, 20], [100, 15], [150, 10], [200, 5], [250, 1]],truckSize = 500) == 5000\n assert candidate(boxTypes = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996]],truckSize = 15) == 14960\n assert candidate(boxTypes = [[5, 10], [5, 20], [5, 30], [5, 40], [5, 50], [5, 60], [5, 70], [5, 80], [5, 90], [5, 100]],truckSize = 25) == 2000\n assert candidate(boxTypes = [[10, 1000], [9, 900], [8, 800], [7, 700], [6, 600], [5, 500], [4, 400], [3, 300], [2, 200], [1, 100]],truckSize = 25) == 22900\n assert candidate(boxTypes = [[100, 5], [200, 2], [50, 10], [150, 3]],truckSize = 350) == 1550\n assert candidate(boxTypes = [[50, 100], [40, 99], [30, 98], [20, 97], [10, 96], [5, 95]],truckSize = 160) == 15275\n assert candidate(boxTypes = [[1, 500], [1, 400], [1, 300], [1, 200], [1, 100]],truckSize = 2) == 900\n assert candidate(boxTypes = [[3, 9], [2, 8], [5, 7], [1, 6], [4, 5]],truckSize = 15) == 104\n assert candidate(boxTypes = [[10, 20], [20, 10], [30, 5], [40, 2], [50, 1]],truckSize = 100) == 630\n assert candidate(boxTypes = [[300, 1], [200, 2], [100, 3], [50, 4], [25, 5]],truckSize = 700) == 1325\n assert candidate(boxTypes = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996]],truckSize = 15) == 14960\n assert candidate(boxTypes = [[5, 15], [10, 12], [20, 9], [30, 7], [40, 5], [50, 3]],truckSize = 150) == 920\n assert candidate(boxTypes = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],truckSize = 500) == 3740\n assert candidate(boxTypes = [[5, 15], [20, 3], [5, 20], [10, 7]],truckSize = 25) == 260\n assert candidate(boxTypes = [[100, 10], [50, 20], [20, 30], [10, 40]],truckSize = 200) == 3000\n assert candidate(boxTypes = [[100, 2], [200, 3], [300, 4], [400, 5], [500, 6]],truckSize = 1000) == 5400\n assert candidate(boxTypes = [[100, 1], [50, 2], [25, 3], [12, 4], [6, 5], [3, 6], [1, 7]],truckSize = 200) == 378\n assert candidate(boxTypes = [[50, 10], [40, 9], [30, 8], [20, 7], [10, 6], [5, 5], [1, 4]],truckSize = 160) == 1329\n assert candidate(boxTypes = [[100, 500], [50, 1000], [10, 2000]],truckSize = 200) == 120000\n assert candidate(boxTypes = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]],truckSize = 50) == 374\n assert candidate(boxTypes = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],truckSize = 500) == 37400\n assert candidate(boxTypes = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],truckSize = 10) == 55\n assert candidate(boxTypes = [[1, 500], [2, 400], [3, 300], [4, 200], [5, 100]],truckSize = 10) == 3000\n assert candidate(boxTypes = [[30, 4], [10, 20], [15, 5]],truckSize = 50) == 375\n assert candidate(boxTypes = [[100, 10], [200, 9], [300, 8], [400, 7]],truckSize = 1000) == 8000\n assert candidate(boxTypes = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],truckSize = 1) == 50\n assert candidate(boxTypes = [[10, 100], [5, 200], [3, 300], [2, 400], [1, 500]],truckSize = 20) == 4100\n assert candidate(boxTypes = [[10, 5], [5, 10], [15, 3]],truckSize = 18) == 109\n assert candidate(boxTypes = [[10, 5], [20, 8], [30, 2], [5, 9]],truckSize = 40) == 265\n assert candidate(boxTypes = [[10, 10], [20, 9], [30, 8], [40, 7], [50, 6], [60, 5], [70, 4], [80, 3], [90, 2], [100, 1]],truckSize = 250) == 1560\n assert candidate(boxTypes = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5]],truckSize = 30) == 120\n assert candidate(boxTypes = [[1, 1000], [2, 900], [3, 800], [4, 700], [5, 600], [6, 500], [7, 400], [8, 300], [9, 200], [10, 100]],truckSize = 15) == 11000\n assert candidate(boxTypes = [[10, 100], [20, 200], [30, 300], [40, 400], [50, 500], [60, 600], [70, 700], [80, 800], [90, 900]],truckSize = 300) == 230000\n assert candidate(boxTypes = [[500, 500], [500, 500], [500, 500]],truckSize = 1000) == 500000\n assert candidate(boxTypes = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5]],truckSize = 1000) == 4400\n assert candidate(boxTypes = [[50, 20], [30, 15], [40, 10], [20, 5]],truckSize = 100) == 1650\n assert candidate(boxTypes = [[10, 5], [20, 3], [30, 4], [40, 2], [50, 1]],truckSize = 100) == 310\n assert candidate(boxTypes = [[10, 500], [20, 450], [30, 400], [40, 350], [50, 300], [60, 250], [70, 200], [80, 150], [90, 100], [100, 50]],truckSize = 200) == 67500\n assert candidate(boxTypes = [[3, 2], [2, 5], [6, 1], [10, 3]],truckSize = 12) == 40\n assert candidate(boxTypes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],truckSize = 30) == 266\n assert candidate(boxTypes = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5], [10, 6], [9, 7], [8, 8], [7, 9], [6, 10]],truckSize = 50) == 340\n assert candidate(boxTypes = [[100, 10], [200, 5], [300, 1]],truckSize = 500) == 2200\n assert candidate(boxTypes = [[1, 100], [10, 90], [100, 80], [1000, 70], [10000, 60]],truckSize = 5000) == 312340\n assert candidate(boxTypes = [[10, 5], [9, 4], [8, 3], [7, 2], [6, 1]],truckSize = 20) == 89\n assert candidate(boxTypes = [[100, 1], [100, 2], [100, 3], [100, 4], [100, 5]],truckSize = 250) == 1050\n assert candidate(boxTypes = [[50, 10], [50, 20], [50, 30], [50, 40], [50, 50]],truckSize = 150) == 6000\n assert candidate(boxTypes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],truckSize = 15) == 145\n assert candidate(boxTypes = [[50, 1], [200, 2], [100, 3], [30, 4], [10, 5]],truckSize = 250) == 690\n assert candidate(boxTypes = [[1, 1000], [1, 999], [1, 998], [1, 997], [1, 996], [1, 995], [1, 994], [1, 993], [1, 992], [1, 991]],truckSize = 10) == 9955\n assert candidate(boxTypes = [[10, 100], [20, 90], [30, 80], [40, 70], [50, 60]],truckSize = 200) == 11000\n assert candidate(boxTypes = [[100, 100], [90, 90], [80, 80], [70, 70], [60, 60], [50, 50]],truckSize = 500) == 35500\n assert candidate(boxTypes = [[20, 1], [20, 2], [20, 3], [20, 4], [20, 5], [20, 6], [20, 7], [20, 8], [20, 9], [20, 10]],truckSize = 100) == 800\n"}, "metadata": {"canonical_parameter_names": ["boxTypes", "truckSize"], "leetcode_dataset_entry_point": "Solution().maximumUnits", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumUnits(vector>& boxTypes, int truckSize) {", "container": "Solution", "callable": "maximumUnits", "parameters": [{"name": "boxTypes", "type": "vector>&"}, {"name": "truckSize", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1711, "task_id": "count-good-meals", "difficulty": "Medium", "problem_description": "A good meal is a meal that contains exactly two different food items with a sum of deliciousness equal to a power of two.\nYou can pick any two different foods to make a good meal.\nGiven an array of integers deliciousness where deliciousness[i] is the deliciousness of the i​​​​​​th​​​​​​​​ item of food, return the number of different good meals you can make from this list modulo 109 + 7.\nNote that items with different indices are considered different even if they have the same deliciousness value.\n \nExample 1:\n\nInput: deliciousness = [1,3,5,7,9]\nOutput: 4\nExplanation: The good meals are (1,3), (1,7), (3,5) and, (7,9).\nTheir respective sums are 4, 8, 8, and 16, all of which are powers of 2.\n\nExample 2:\n\nInput: deliciousness = [1,1,1,3,3,3,7]\nOutput: 15\nExplanation: The good meals are (1,1) with 3 ways, (1,3) with 9 ways, and (1,7) with 3 ways.\n \nConstraints:\n\n1 <= deliciousness.length <= 105\n0 <= deliciousness[i] <= 220\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 0\n assert candidate(deliciousness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(deliciousness = [2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 15\n assert candidate(deliciousness = [0, 0, 0, 0, 0, 0]) == 0\n assert candidate(deliciousness = [0, 0]) == 0\n assert candidate(deliciousness = [2, 2, 2, 3, 3, 3, 4, 4, 4]) == 6\n assert candidate(deliciousness = [1048576, 1048576, 524288, 524288, 262144, 262144]) == 3\n assert candidate(deliciousness = [1]) == 0\n assert candidate(deliciousness = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(deliciousness = [1048576, 1048576]) == 1\n assert candidate(deliciousness = [13, 100, 13]) == 0\n assert candidate(deliciousness = [1, 3, 5, 7, 9]) == 4\n assert candidate(deliciousness = [1, 1, 1, 3, 3, 3, 7]) == 15\n assert candidate(deliciousness = [1, 0, 0, 0, 0]) == 4\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32]) == 0\n assert candidate(deliciousness = [1023, 1024, 512, 512, 256, 256, 128, 128, 64, 64, 32, 32, 16, 16, 8, 8, 4, 4, 2, 2, 1, 1]) == 12\n assert candidate(deliciousness = [1048576, 1, 1, 1, 1]) == 6\n assert candidate(deliciousness = [1, 1048575, 1048575, 1048576]) == 2\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 0\n assert candidate(deliciousness = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]) == 5\n assert candidate(deliciousness = [1, 100000, 200000, 300000, 400000]) == 0\n assert candidate(deliciousness = [220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, 220]) == 0\n assert candidate(deliciousness = [0, 0, 0, 0]) == 0\n assert candidate(deliciousness = [1048576, 1048576]) == 1\n assert candidate(deliciousness = [2, 2, 2, 2, 2]) == 10\n assert candidate(deliciousness = [1, 1048575]) == 1\n assert candidate(deliciousness = [0, 0, 0, 0, 0, 0, 1, 3, 5, 7, 9]) == 10\n assert candidate(deliciousness = [31, 1, 4, 3, 12, 13, 8, 16, 7]) == 5\n assert candidate(deliciousness = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(deliciousness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(deliciousness = [1048575, 1048576, 524287, 524288, 262143, 262144, 131071, 131072, 65535, 65536, 32767, 32768, 16383, 16384, 8191, 8192, 4095, 4096, 2047, 2048, 1023, 1024, 511, 512, 255, 256, 127, 128, 63, 64, 31, 32, 15, 16, 7, 8, 3, 4, 1, 2, 0, 0, 0, 0, 0, 0]) == 145\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 0\n assert candidate(deliciousness = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(deliciousness = [1048575, 1048574, 1048573, 1048572, 1048571, 1048570]) == 0\n assert candidate(deliciousness = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 28\n assert candidate(deliciousness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 11\n assert candidate(deliciousness = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 30, 30, 30, 31, 31, 31]) == 249\n assert candidate(deliciousness = [2097151, 1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 20\n assert candidate(deliciousness = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987]) == 3\n assert candidate(deliciousness = [5, 1, 4, 3, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == 15\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 0\n assert candidate(deliciousness = [21, 1, 17, 3, 9, 18, 25, 33]) == 1\n assert candidate(deliciousness = [1023, 1024, 2047, 2048, 3071, 3072, 4095, 4096]) == 1\n assert candidate(deliciousness = [1023, 1024, 1025, 2047, 2048, 2049, 4095, 4096, 4097]) == 3\n assert candidate(deliciousness = [1, 1048575, 2097151, 4194303, 8388607, 16777215, 33554431, 67108863, 134217727, 268435455]) == 9\n assert candidate(deliciousness = [1023, 1024, 2047, 2048, 4095, 4096, 8191, 8192]) == 0\n assert candidate(deliciousness = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127]) == 0\n assert candidate(deliciousness = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 14\n assert candidate(deliciousness = [5, 15, 1, 3, 7, 9, 11, 13]) == 7\n assert candidate(deliciousness = [1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047, 2047]) == 0\n assert candidate(deliciousness = [1048575, 1048576, 2097151, 2097152, 4194303, 4194304]) == 0\n assert candidate(deliciousness = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == 19\n assert candidate(deliciousness = [1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575]) == 0\n assert candidate(deliciousness = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0]) == 10\n assert candidate(deliciousness = [1023, 1024, 2047, 2048, 4095, 4096]) == 0\n assert candidate(deliciousness = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151]) == 21\n assert candidate(deliciousness = [21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845]) == 0\n assert candidate(deliciousness = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000]) == 0\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 0\n assert candidate(deliciousness = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 0\n assert candidate(deliciousness = [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 16\n assert candidate(deliciousness = [1, 1048575, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2]) == 1\n assert candidate(deliciousness = [0, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845]) == 0\n assert candidate(deliciousness = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 15\n assert candidate(deliciousness = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512]) == 10\n assert candidate(deliciousness = [1, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 13\n assert candidate(deliciousness = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946]) == 3\n assert candidate(deliciousness = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 0\n assert candidate(deliciousness = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 100\n assert candidate(deliciousness = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128]) == 0\n assert candidate(deliciousness = [3, 5, 7, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 154\n assert candidate(deliciousness = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]) == 5\n assert candidate(deliciousness = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 90\n assert candidate(deliciousness = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 0\n assert candidate(deliciousness = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 12\n assert candidate(deliciousness = [220, 440, 880, 1760, 3520, 7040, 14080, 28160, 56320, 112640, 225280, 450560, 901120, 1802240, 3604480, 7208960, 14417920, 28835840, 57671680, 115343360]) == 0\n assert candidate(deliciousness = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]) == 0\n assert candidate(deliciousness = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(deliciousness = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767]) == 61\n assert candidate(deliciousness = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 0\n assert candidate(deliciousness = [1, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == 11\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 0\n assert candidate(deliciousness = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 19\n assert candidate(deliciousness = [31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 26\n assert candidate(deliciousness = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 65\n assert candidate(deliciousness = [1, 1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]) == 41\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 0\n assert candidate(deliciousness = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 26\n assert candidate(deliciousness = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128]) == 8\n assert candidate(deliciousness = [15, 9, 8, 7, 3, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 135\n assert candidate(deliciousness = [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1, 1, 1]) == 6\n assert candidate(deliciousness = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 190\n assert candidate(deliciousness = [22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22]) == 0\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 0\n assert candidate(deliciousness = [524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0]) == 20\n assert candidate(deliciousness = [65535, 65536, 131071, 131072, 262143, 262144]) == 0\n assert candidate(deliciousness = [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(deliciousness = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597]) == 3\n assert candidate(deliciousness = [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 12\n assert candidate(deliciousness = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072]) == 0\n"}, "metadata": {"canonical_parameter_names": ["deliciousness"], "leetcode_dataset_entry_point": "Solution().countPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countPairs(vector& deliciousness) {", "container": "Solution", "callable": "countPairs", "parameters": [{"name": "deliciousness", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1712, "task_id": "ways-to-split-array-into-three-subarrays", "difficulty": "Medium", "problem_description": "A split of an integer array is good if:\n\nThe array is split into three non-empty contiguous subarrays - named left, mid, right respectively from left to right.\nThe sum of the elements in left is less than or equal to the sum of the elements in mid, and the sum of the elements in mid is less than or equal to the sum of the elements in right.\n\nGiven nums, an array of non-negative integers, return the number of good ways to split nums. As the number may be too large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: nums = [1,1,1]\nOutput: 1\nExplanation: The only good way to split nums is [1] [1] [1].\nExample 2:\n\nInput: nums = [1,2,2,2,5,0]\nOutput: 3\nExplanation: There are three good ways of splitting nums:\n[1] [2] [2,2,5,0]\n[1] [2,2] [2,5,0]\n[1,2] [2,2] [5,0]\n\nExample 3:\n\nInput: nums = [3,2,1]\nOutput: 0\nExplanation: There is no good way to split nums.\n \nConstraints:\n\n3 <= nums.length <= 105\n0 <= nums[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10000, 10000, 10000]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 12\n assert candidate(nums = [1, 3, 2, 3, 1, 1, 1, 3, 2, 3]) == 9\n assert candidate(nums = [9, 4, 2, 5, 1]) == 0\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 8\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 15\n assert candidate(nums = [1, 3, 2, 4, 1, 2, 3, 4]) == 6\n assert candidate(nums = [1, 1, 1]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 8\n assert candidate(nums = [10, 4, -8, 7]) == 0\n assert candidate(nums = [10, 10, 10, 10, 10]) == 2\n assert candidate(nums = [1, 3, 1, 1, 2]) == 1\n assert candidate(nums = [3, 2, 1]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0]) == 6\n assert candidate(nums = [1, 2, 2, 2, 5, 0]) == 3\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 2]) == 0\n assert candidate(nums = [1, 3, 2, 2, 1, 1]) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 160\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 50\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5]) == 74\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 36\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 292\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 37\n assert candidate(nums = [1000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000]) == 34\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 463\n assert candidate(nums = [10000, 10000, 10000, 10000, 0, 10000, 10000, 10000, 10000]) == 7\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 184\n assert candidate(nums = [10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10]) == 4\n assert candidate(nums = [15000, 14000, 13000, 12000, 11000, 10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 4\n assert candidate(nums = [1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1, 1000, 1]) == 28\n assert candidate(nums = [1, 3, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 163\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 171\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 16\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000]) == 37\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 320\n assert candidate(nums = [1, 3, 2, 4, 2, 3, 4, 2, 5, 1]) == 9\n assert candidate(nums = [9, 3, 5, 7, 3, 5, 7, 3, 5, 7, 3, 5, 7, 3, 5, 7, 3, 5, 7, 3]) == 26\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 33\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100]) == 108\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 33\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 1\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 36\n assert candidate(nums = [50000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 33\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 110\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 24\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 16\n assert candidate(nums = [100, 50, 50, 25, 25, 25, 25, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 3\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000, 130000, 140000, 150000, 160000, 170000, 180000, 190000, 200000]) == 70\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 37\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 16\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 8\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 53\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == 71\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 406\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 33\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 8\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 184\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 16\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 171\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 71\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 50000]) == 16\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 33\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 385\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 91\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 36\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 163\n assert candidate(nums = [1, 3, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 39\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == 31\n assert candidate(nums = [5, 1, 4, 2, 2, 1]) == 1\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 75\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 75\n assert candidate(nums = [1, 10000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 31\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1]) == 17\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 154\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985, 9984, 9983, 9982, 9981, 9980]) == 27\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 70\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 16\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 21\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 161\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 70\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 19\n assert candidate(nums = [100, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 46\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 37\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 21\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().waysToSplit", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int waysToSplit(vector& nums) {", "container": "Solution", "callable": "waysToSplit", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1713, "task_id": "minimum-operations-to-make-a-subsequence", "difficulty": "Hard", "problem_description": "You are given an array target that consists of distinct integers and another integer array arr that can have duplicates.\nIn one operation, you can insert any integer at any position in arr. For example, if arr = [1,4,1,2], you can add 3 in the middle and make it [1,4,3,1,2]. Note that you can insert the integer at the very beginning or end of the array.\nReturn the minimum number of operations needed to make target a subsequence of arr.\nA subsequence of an array is a new array generated from the original array by deleting some elements (possibly none) without changing the remaining elements' relative order. For example, [2,7,4] is a subsequence of [4,2,3,7,2,1,4] (the underlined elements), while [2,4,2] is not.\n \nExample 1:\n\nInput: target = [5,1,3], arr = [9,4,2,3,4]\nOutput: 2\nExplanation: You can add 5 and 1 in such a way that makes arr = [5,9,4,1,2,3,4], then target will be a subsequence of arr.\n\nExample 2:\n\nInput: target = [6,4,8,1,3,2], arr = [4,7,6,2,3,8,6,1]\nOutput: 3\n\n \nConstraints:\n\n1 <= target.length, arr.length <= 105\n1 <= target[i], arr[i] <= 109\ntarget contains no duplicates.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(target = [1, 2, 3, 4, 5],arr = [5, 4, 3, 2, 1]) == 4\n assert candidate(target = [3, 1, 5, 8, 9],arr = [1, 5, 3, 8, 9]) == 1\n assert candidate(target = [1],arr = [1, 1, 1, 1]) == 0\n assert candidate(target = [6, 4, 8, 1, 3, 2],arr = [4, 7, 6, 2, 3, 8, 6, 1]) == 3\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(target = [1, 2, 3],arr = [1, 2, 3, 1, 2, 3]) == 0\n assert candidate(target = [1, 3, 5, 7],arr = [2, 4, 6, 8]) == 4\n assert candidate(target = [1, 2, 3, 4, 5],arr = [1, 2, 3, 4, 5]) == 0\n assert candidate(target = [1, 3, 5, 7, 9],arr = [2, 4, 6, 8, 10]) == 5\n assert candidate(target = [1, 2, 3],arr = [4, 5, 6]) == 3\n assert candidate(target = [10, 20, 30],arr = [10, 15, 20, 25, 30]) == 0\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 4\n assert candidate(target = [1],arr = [1]) == 0\n assert candidate(target = [10, 20, 30, 40],arr = [10, 20, 5, 30, 40]) == 0\n assert candidate(target = [100, 200, 300],arr = [1, 2, 3, 100, 200, 300]) == 0\n assert candidate(target = [1, 2, 3],arr = [3, 2, 1]) == 2\n assert candidate(target = [5, 1, 3],arr = [9, 4, 2, 3, 4]) == 2\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(target = [100, 200, 300, 400, 500],arr = [100, 500, 200, 400, 300, 100, 500, 200, 400, 300]) == 1\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 12\n assert candidate(target = [1, 2, 3, 4, 5],arr = [2, 3, 1, 4, 5, 2, 3, 1, 4, 5, 2, 3, 1, 4, 5]) == 0\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 0\n assert candidate(target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(target = [100, 200, 300, 400, 500],arr = [50, 150, 250, 350, 450, 550, 650, 100, 200, 300, 400, 500]) == 0\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(target = [7, 14, 21, 28, 35],arr = [35, 28, 21, 14, 7, 35, 28, 21, 14, 7]) == 3\n assert candidate(target = [1, 2, 3, 4, 5],arr = [3, 1, 2, 4, 5, 3, 1, 2, 4, 5, 3, 1, 2, 4, 5, 3, 1, 2, 4, 5]) == 0\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(target = [1, 3, 5, 7, 9],arr = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9]) == 0\n assert candidate(target = [1, 3, 2, 4],arr = [4, 3, 2, 1, 1, 2, 3, 4]) == 1\n assert candidate(target = [7, 11, 13, 17, 19, 23, 29, 31],arr = [19, 23, 31, 7, 11, 13, 17, 29, 37, 41, 43, 47]) == 3\n assert candidate(target = [7, 11, 15, 20, 25, 30, 35, 40, 45, 50],arr = [50, 45, 40, 35, 30, 25, 20, 15, 11, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 21, 22, 23, 24, 26, 27, 28, 29, 31, 32, 33, 34, 36, 37, 38, 39, 41, 42, 43, 44, 46, 47, 48, 49]) == 9\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 0\n assert candidate(target = [1, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41],arr = [41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 1, 43, 45, 47, 49, 51]) == 19\n assert candidate(target = [5, 3, 8, 12, 9, 11],arr = [3, 5, 8, 12, 9, 11, 14, 15, 16, 17, 18, 19]) == 1\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],arr = [10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 0\n assert candidate(target = [1000000000, 999999999, 999999998, 999999997, 999999996],arr = [999999998, 999999997, 999999996, 1000000000, 999999999]) == 2\n assert candidate(target = [7, 5, 3, 1],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 10, 20, 30, 40, 50]) == 5\n assert candidate(target = [1, 2, 3, 4, 5],arr = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 2\n assert candidate(target = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],arr = [1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30]) == 10\n assert candidate(target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],arr = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 9\n assert candidate(target = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 1, 9, 7, 3, 2, 8]) == 4\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 19\n assert candidate(target = [1, 2, 3, 4, 5],arr = [5, 1, 3, 2, 4]) == 2\n assert candidate(target = [5, 3, 8, 6, 2, 7, 4, 1],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == 1\n assert candidate(target = [1, 10, 100, 1000, 10000, 100000],arr = [10, 100, 1000, 10000, 100000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(target = [1, 5, 9, 13, 17, 21],arr = [21, 17, 13, 9, 5, 1, 14, 10, 6, 2, 18, 12, 8, 4]) == 5\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [10, 90, 20, 80, 30, 70, 40, 60, 50, 100]) == 4\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 8\n assert candidate(target = [5, 1, 4, 2, 3],arr = [1, 5, 4, 2, 3, 1, 5, 4, 2, 3, 1, 5, 4, 2, 3, 1, 5, 4, 2, 3]) == 0\n assert candidate(target = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],arr = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 0\n assert candidate(target = [10, 20, 30, 40, 50, 60],arr = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 0\n assert candidate(target = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991],arr = [1000000000, 999999998, 999999996, 999999994, 999999992, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],arr = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 11, 12, 13, 14, 15, 0, 16, 17]) == 4\n assert candidate(target = [1, 10, 100, 1000, 10000],arr = [1, 1, 1, 1, 10, 10, 10, 10, 100, 100, 100, 100, 1000, 1000, 1000, 1000, 10000, 10000, 10000, 10000]) == 0\n assert candidate(target = [1, 5, 10, 15, 20],arr = [1, 1, 1, 1, 1, 1, 5, 5, 5, 5, 5, 10, 10, 10, 15, 15, 20]) == 0\n assert candidate(target = [100, 200, 300, 400, 500],arr = [500, 400, 300, 200, 100, 150, 250, 350, 450, 550]) == 4\n assert candidate(target = [100, 200, 300, 400, 500],arr = [100, 100, 100, 100, 100, 200, 200, 200, 200, 200, 300, 300, 300, 400, 500]) == 0\n assert candidate(target = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]) == 0\n assert candidate(target = [1, 5, 3, 4, 2],arr = [2, 3, 1, 4, 5, 1, 2, 3, 4, 5]) == 1\n assert candidate(target = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],arr = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 40, 35, 30, 25, 20, 15, 10, 5, 2, 1]) == 1\n assert candidate(target = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],arr = [9, 7, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 5]) == 6\n assert candidate(target = [7, 5, 3, 1],arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 3\n assert candidate(target = [1, 3, 5, 7, 9],arr = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9]) == 0\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(target = [1, 4, 7, 10, 13, 16, 19],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 0\n assert candidate(target = [1, 2, 3, 4, 5],arr = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 0\n assert candidate(target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],arr = [59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 0\n assert candidate(target = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],arr = [100, 300, 500, 700, 200, 400, 600, 800, 100, 300, 500, 700]) == 5\n assert candidate(target = [5, 1, 2, 6, 3, 7, 4, 8, 9],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2\n assert candidate(target = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],arr = [3, 5, 1, 6, 2, 9, 4, 1, 5, 3, 5]) == 7\n assert candidate(target = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 1, 2, 3, 4, 5]) == 0\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 8\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(target = [10, 20, 30, 40, 50],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == 0\n assert candidate(target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],arr = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == 9\n assert candidate(target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 10\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 0\n assert candidate(target = [23, 1, 7, 11, 2, 14, 6],arr = [7, 14, 4, 14, 13, 2, 6, 1, 23, 13]) == 4\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(target = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],arr = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 2, 91, 87, 85, 81, 77, 75, 74, 72, 69, 65, 64, 62, 58, 57, 55, 52, 50, 49, 48, 46, 45, 44, 42, 40, 39, 38, 36, 35, 34, 33, 32, 30, 28, 27, 26, 25, 24, 22, 21, 20, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(target = [5, 3, 8, 12, 7],arr = [12, 8, 3, 7, 5, 12, 8, 3, 7, 5]) == 2\n assert candidate(target = [2, 1, 4, 3, 6, 5, 8, 7],arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 4\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],arr = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 24\n assert candidate(target = [5, 1, 3, 2, 4, 6],arr = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]) == 1\n assert candidate(target = [100, 200, 300, 400, 500, 600, 700, 800, 900],arr = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == 9\n assert candidate(target = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],arr = [500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500]) == 4\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(target = [1, 2, 3, 4, 5],arr = [5, 1, 4, 2, 3, 1, 5, 2, 4, 3, 1, 5, 2, 4, 3]) == 0\n assert candidate(target = [100, 200, 300, 400, 500],arr = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 200, 300, 400, 500]) == 0\n assert candidate(target = [1, 2, 3, 4, 5],arr = [3, 1, 2, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 0\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 9\n assert candidate(target = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],arr = [5, 6, 10, 11, 15, 16, 20, 21, 25, 26, 30, 31, 35, 36, 40, 41, 45, 46, 50, 51]) == 0\n assert candidate(target = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],arr = [5, 15, 25, 35, 45, 55, 65, 10, 20, 30, 40, 50]) == 4\n assert candidate(target = [1, 2, 3, 4, 5],arr = [5, 1, 4, 2, 3, 5, 1, 4, 2, 3, 5, 1, 4, 2, 3, 5, 1, 4, 2, 3]) == 0\n assert candidate(target = [10, 20, 30, 40, 50],arr = [10, 25, 30, 35, 50, 40]) == 2\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],arr = [1, 3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14]) == 7\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr = [10, 8, 6, 4, 2, 1, 3, 5, 7, 9]) == 5\n assert candidate(target = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],arr = [27, 24, 21, 18, 15, 12, 9, 6, 3, 30, 27, 24, 21, 18, 15, 12, 9, 6, 3]) == 8\n assert candidate(target = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],arr = [1, 9, 17, 25, 33, 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 5, 13, 21, 29, 37]) == 4\n assert candidate(target = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],arr = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 110, 120]) == 9\n"}, "metadata": {"canonical_parameter_names": ["target", "arr"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minOperations(vector& target, vector& arr) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "target", "type": "vector&"}, {"name": "arr", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1716, "task_id": "calculate-money-in-leetcode-bank", "difficulty": "Easy", "problem_description": "Hercy wants to save money for his first car. He puts money in the Leetcode bank every day.\nHe starts by putting in $1 on Monday, the first day. Every day from Tuesday to Sunday, he will put in $1 more than the day before. On every subsequent Monday, he will put in $1 more than the previous Monday. \nGiven n, return the total amount of money he will have in the Leetcode bank at the end of the nth day.\n \nExample 1:\n\nInput: n = 4\nOutput: 10\nExplanation: After the 4th day, the total is 1 + 2 + 3 + 4 = 10.\n\nExample 2:\n\nInput: n = 10\nOutput: 37\nExplanation: After the 10th day, the total is (1 + 2 + 3 + 4 + 5 + 6 + 7) + (2 + 3 + 4) = 37. Notice that on the 2nd Monday, Hercy only puts in $2.\n\nExample 3:\n\nInput: n = 20\nOutput: 96\nExplanation: After the 20th day, the total is (1 + 2 + 3 + 4 + 5 + 6 + 7) + (2 + 3 + 4 + 5 + 6 + 7 + 8) + (3 + 4 + 5 + 6 + 7 + 8) = 96.\n\n \nConstraints:\n\n1 <= n <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 30) == 165\n assert candidate(n = 4) == 10\n assert candidate(n = 20) == 96\n assert candidate(n = 1) == 1\n assert candidate(n = 1000) == 74926\n assert candidate(n = 7) == 28\n assert candidate(n = 10) == 37\n assert candidate(n = 29) == 159\n assert candidate(n = 63) == 504\n assert candidate(n = 210) == 3885\n assert candidate(n = 49) == 343\n assert candidate(n = 125) == 1551\n assert candidate(n = 21) == 105\n assert candidate(n = 70) == 595\n assert candidate(n = 100) == 1060\n assert candidate(n = 50) == 351\n assert candidate(n = 300) == 7476\n assert candidate(n = 28) == 154\n assert candidate(n = 60) == 462\n assert candidate(n = 56) == 420\n assert candidate(n = 40) == 250\n assert candidate(n = 600) == 27810\n assert candidate(n = 99) == 1044\n assert candidate(n = 98) == 1029\n assert candidate(n = 2) == 3\n assert candidate(n = 365) == 10791\n assert candidate(n = 80) == 732\n assert candidate(n = 700) == 37450\n assert candidate(n = 8) == 30\n assert candidate(n = 250) == 5335\n assert candidate(n = 777) == 45843\n assert candidate(n = 999) == 74778\n assert candidate(n = 22) == 109\n assert candidate(n = 35) == 210\n assert candidate(n = 140) == 1890\n assert candidate(n = 91) == 910\n assert candidate(n = 150) == 2127\n assert candidate(n = 15) == 66\n assert candidate(n = 180) == 2940\n assert candidate(n = 899) == 60870\n assert candidate(n = 85) == 811\n assert candidate(n = 200) == 3552\n assert candidate(n = 14) == 63\n assert candidate(n = 400) == 12826\n assert candidate(n = 120) == 1446\n assert candidate(n = 500) == 19602\n assert candidate(n = 52) == 370\n assert candidate(n = 90) == 891\n assert candidate(n = 25) == 127\n assert candidate(n = 84) == 798\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().totalMoney", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int totalMoney(int n) {", "container": "Solution", "callable": "totalMoney", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1717, "task_id": "maximum-score-from-removing-substrings", "difficulty": "Medium", "problem_description": "You are given a string s and two integers x and y. You can perform two types of operations any number of times.\n\nRemove substring \"ab\" and gain x points.\n\n\t\nFor example, when removing \"ab\" from \"cabxbae\" it becomes \"cxbae\".\n\n\nRemove substring \"ba\" and gain y points.\n\t\nFor example, when removing \"ba\" from \"cabxbae\" it becomes \"cabxe\".\n\n\n\nReturn the maximum points you can gain after applying the above operations on s.\n \nExample 1:\n\nInput: s = \"cdbcbbaaabab\", x = 4, y = 5\nOutput: 19\nExplanation:\n- Remove the \"ba\" underlined in \"cdbcbbaaabab\". Now, s = \"cdbcbbaaab\" and 5 points are added to the score.\n- Remove the \"ab\" underlined in \"cdbcbbaaab\". Now, s = \"cdbcbbaa\" and 4 points are added to the score.\n- Remove the \"ba\" underlined in \"cdbcbbaa\". Now, s = \"cdbcba\" and 5 points are added to the score.\n- Remove the \"ba\" underlined in \"cdbcba\". Now, s = \"cdbc\" and 5 points are added to the score.\nTotal score = 5 + 4 + 5 + 5 = 19.\nExample 2:\n\nInput: s = \"aabbaaxybbaabb\", x = 5, y = 4\nOutput: 20\n\n \nConstraints:\n\n1 <= s.length <= 105\n1 <= x, y <= 104\ns consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"ababababababababababababababababababababab\",x = 1,y = 1) == 21\n assert candidate(s = \"abbaabba\",x = 7,y = 8) == 31\n assert candidate(s = \"abababab\",x = 10,y = 10) == 40\n assert candidate(s = \"ababab\",x = 10,y = 10) == 30\n assert candidate(s = \"babaabab\",x = 3,y = 2) == 11\n assert candidate(s = \"aabbcc\",x = 2,y = 2) == 4\n assert candidate(s = \"babaabab\",x = 10,y = 5) == 35\n assert candidate(s = \"abcde\",x = 1,y = 2) == 1\n assert candidate(s = \"baabaa\",x = 3,y = 2) == 5\n assert candidate(s = \"aaaaabbbbb\",x = 7,y = 8) == 35\n assert candidate(s = \"ba\",x = 1,y = 1) == 1\n assert candidate(s = \"aabbcc\",x = 1,y = 1) == 2\n assert candidate(s = \"ab\",x = 1,y = 1) == 1\n assert candidate(s = \"abbaabba\",x = 7,y = 3) == 24\n assert candidate(s = \"abcabcabcabc\",x = 2,y = 3) == 8\n assert candidate(s = \"abababab\",x = 1,y = 1) == 4\n assert candidate(s = \"aabbaaxybbaabb\",x = 5,y = 4) == 20\n assert candidate(s = \"ababababab\",x = 1,y = 1) == 5\n assert candidate(s = \"abcde\",x = 10,y = 20) == 10\n assert candidate(s = \"\",x = 100,y = 200) == 0\n assert candidate(s = \"babaabab\",x = 2,y = 3) == 11\n assert candidate(s = \"cdbcbbaaabab\",x = 4,y = 5) == 19\n assert candidate(s = \"abcde\",x = 100,y = 200) == 100\n assert candidate(s = \"baabbaabba\",x = 500,y = 500) == 2500\n assert candidate(s = \"\",x = 100,y = 100) == 0\n assert candidate(s = \"\",x = 1,y = 1) == 0\n assert candidate(s = \"bbbbbbaaaa\",x = 8,y = 7) == 28\n assert candidate(s = \"ababababab\",x = 1000,y = 1000) == 5000\n assert candidate(s = \"babaab\",x = 10,y = 5) == 25\n assert candidate(s = \"aaaabbbbbaaaaabbbb\",x = 10,y = 15) == 115\n assert candidate(s = \"babababababababababababab\",x = 7,y = 3) == 84\n assert candidate(s = \"abababababababab\",x = 10000,y = 10000) == 80000\n assert candidate(s = \"babbbabbbabbbabbbabbbabb\",x = 15,y = 25) == 150\n assert candidate(s = \"ababbaabababababab\",x = 6,y = 7) == 62\n assert candidate(s = \"aabbaabbaabbba\",x = 1000,y = 1000) == 7000\n assert candidate(s = \"bbabaabababbabaabababbba\",x = 100,y = 50) == 1050\n assert candidate(s = \"babababababa\",x = 10,y = 15) == 90\n assert candidate(s = \"abbaabbaabba\",x = 3,y = 2) == 17\n assert candidate(s = \"bbbbbaaaabbbbbaaaabbbb\",x = 4,y = 6) == 48\n assert candidate(s = \"bbaabbbaaabbba\",x = 10,y = 5) == 55\n assert candidate(s = \"babababababa\",x = 7,y = 7) == 42\n assert candidate(s = \"baabababababab\",x = 5,y = 5) == 35\n assert candidate(s = \"bababababababababababa\",x = 20,y = 20) == 220\n assert candidate(s = \"bababababababababababababababababababababa\",x = 2,y = 3) == 63\n assert candidate(s = \"babababaabababababababab\",x = 1000,y = 1000) == 12000\n assert candidate(s = \"aaaabbbbbaaaaabbbb\",x = 6,y = 9) == 69\n assert candidate(s = \"babaabababab\",x = 1000,y = 500) == 5500\n assert candidate(s = \"abbbabbaaa\",x = 10,y = 5) == 35\n assert candidate(s = \"ababababababababababababababababababababababababa\",x = 1,y = 10000) == 240000\n assert candidate(s = \"aaaaaabbaaabbaaa\",x = 5,y = 5) == 20\n assert candidate(s = \"babbbbabbbbabbbbabbb\",x = 12,y = 15) == 60\n assert candidate(s = \"abababababbababbaabab\",x = 4,y = 4) == 40\n assert candidate(s = \"ababbbbaababba\",x = 100,y = 200) == 1100\n assert candidate(s = \"bbabababababababbaa\",x = 8,y = 6) == 68\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbb\",x = 100,y = 100) == 1000\n assert candidate(s = \"abababababababababababababababab\",x = 10000,y = 1) == 160000\n assert candidate(s = \"abbaabbaabba\",x = 10,y = 20) == 110\n assert candidate(s = \"zazbzabzbabzbabz\",x = 5,y = 6) == 17\n assert candidate(s = \"bababbbabababa\",x = 1,y = 10000) == 60000\n assert candidate(s = \"abababababababababababababababababab\",x = 2,y = 1) == 36\n assert candidate(s = \"aabbbaaabbbaaabbbaaabbbaa\",x = 15,y = 5) == 170\n assert candidate(s = \"bbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaa\",x = 1000,y = 500) == 12000\n assert candidate(s = \"bbaabbabababbaabba\",x = 10,y = 5) == 75\n assert candidate(s = \"ababababababababababababababababababababababababababababa\",x = 10000,y = 10000) == 280000\n assert candidate(s = \"xyzababxyzbaaxyzbaxyz\",x = 15,y = 10) == 50\n assert candidate(s = \"zababxyzab\",x = 4,y = 5) == 13\n assert candidate(s = \"abbbabbbabbbabbbabbbabbb\",x = 20,y = 10) == 120\n assert candidate(s = \"aabbbaaabbbaaabbbaab\",x = 7,y = 3) == 66\n assert candidate(s = \"abababababababababababababababab\",x = 10,y = 10) == 160\n assert candidate(s = \"babababababababa\",x = 1,y = 2) == 16\n assert candidate(s = \"ababababababababababababab\",x = 1,y = 1) == 13\n assert candidate(s = \"abababababababababababababababab\",x = 90,y = 100) == 1590\n assert candidate(s = \"abbbbaabbbbaabbbbaab\",x = 200,y = 300) == 2000\n assert candidate(s = \"abababababababababababababababababababababababababababab\",x = 1,y = 1) == 28\n assert candidate(s = \"abababababababababababababababab\",x = 50,y = 50) == 800\n assert candidate(s = \"babaabababab\",x = 10,y = 15) == 85\n assert candidate(s = \"abbbabababba\",x = 500,y = 400) == 2400\n assert candidate(s = \"babaababbaab\",x = 10,y = 5) == 55\n assert candidate(s = \"xyxzyzyzxzyz\",x = 100,y = 200) == 0\n assert candidate(s = \"ababbaababba\",x = 3,y = 2) == 17\n assert candidate(s = \"ababababababababababababababababab\",x = 1,y = 1) == 17\n assert candidate(s = \"xyxyxyxyxy\",x = 3,y = 3) == 0\n assert candidate(s = \"ababababababababababababababababababababababababababababa\",x = 2,y = 3) == 84\n assert candidate(s = \"babababababababababababababababa\",x = 1000,y = 500) == 15500\n assert candidate(s = \"abbaabbaabbaabbaabbaabbaabbaabba\",x = 25,y = 30) == 475\n assert candidate(s = \"ababababababababababab\",x = 5,y = 5) == 55\n assert candidate(s = \"abababababababababababababababab\",x = 1,y = 100) == 1501\n assert candidate(s = \"abaabbaabbabab\",x = 10000,y = 1) == 70000\n assert candidate(s = \"babbababbababbababbababb\",x = 5,y = 4) == 45\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",x = 1000,y = 2000) == 0\n assert candidate(s = \"bababababababababa\",x = 1,y = 2) == 18\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbbbaaaaaaaaaaabbbbbbbbbbbbb\",x = 15,y = 25) == 425\n assert candidate(s = \"bbaabbababababababababab\",x = 1,y = 9999) == 109989\n assert candidate(s = \"abbaabbaabbaabba\",x = 10,y = 10) == 80\n assert candidate(s = \"aabbaaabaabbaaabaabbaabb\",x = 1,y = 1) == 10\n assert candidate(s = \"bbbababbaabbababbaabbbaabababbbabababababababa\",x = 8000,y = 9000) == 180000\n assert candidate(s = \"babababababababababababababababa\",x = 7,y = 7) == 112\n assert candidate(s = \"babababababababababababababababababababababababababababa\",x = 1000,y = 1000) == 28000\n assert candidate(s = \"abababababababababababababababab\",x = 10,y = 9) == 160\n assert candidate(s = \"bbababababababababababababababab\",x = 100,y = 90) == 1500\n assert candidate(s = \"abbaabbaabbaabbaabbaabbaabbaabba\",x = 6,y = 4) == 94\n assert candidate(s = \"ababbbababababba\",x = 20,y = 15) == 135\n assert candidate(s = \"babbbbabbbbabbaa\",x = 8,y = 6) == 36\n assert candidate(s = \"abbaabbaabbaabbaabba\",x = 8,y = 3) == 75\n assert candidate(s = \"aabababababa\",x = 20,y = 15) == 100\n assert candidate(s = \"ababbaababbaababba\",x = 7,y = 9) == 79\n assert candidate(s = \"ababbbabababbaababababab\",x = 20,y = 10) == 210\n assert candidate(s = \"ababbbbaabab\",x = 5,y = 10) == 45\n assert candidate(s = \"bbbbbaaaaabbbbbbaaaaabbbbb\",x = 1000,y = 500) == 10000\n assert candidate(s = \"baaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbb\",x = 500,y = 1000) == 12500\n assert candidate(s = \"babababababababa\",x = 1,y = 100) == 800\n assert candidate(s = \"bbaaabaaaaba\",x = 20,y = 10) == 60\n assert candidate(s = \"ababababababababababababab\",x = 7,y = 8) == 103\n assert candidate(s = \"aabbbaababaababbbbababba\",x = 3,y = 2) == 32\n assert candidate(s = \"baaababababababaabaababb\",x = 10,y = 20) == 200\n assert candidate(s = \"babababababababaabab\",x = 3,y = 2) == 29\n assert candidate(s = \"bababababababababababababababa\",x = 1,y = 2) == 30\n assert candidate(s = \"abbbbbbbbbaaaaaaaa\",x = 20,y = 18) == 164\n assert candidate(s = \"baabbaabbaabbaabbaabbaabbaabbaab\",x = 30,y = 25) == 475\n assert candidate(s = \"abcabcabcabc\",x = 5,y = 5) == 20\n assert candidate(s = \"ababababababababab\",x = 100,y = 1) == 900\n assert candidate(s = \"baabbaabbaabbaabbaab\",x = 4,y = 3) == 39\n assert candidate(s = \"bbaaabbaaabbaa\",x = 1,y = 10000) == 60000\n assert candidate(s = \"bbbbbaaaaabbbbbaaaaabbbbbaaaaa\",x = 100,y = 1) == 1005\n assert candidate(s = \"abababababababababababa\",x = 50,y = 25) == 550\n assert candidate(s = \"aababababaab\",x = 100,y = 100) == 500\n assert candidate(s = \"babababababa\",x = 2000,y = 2000) == 12000\n assert candidate(s = \"babbbabbaabababbababbaabbbbaabab\",x = 20,y = 15) == 255\n assert candidate(s = \"babababababaab\",x = 8,y = 7) == 55\n assert candidate(s = \"babababababababa\",x = 100,y = 90) == 790\n assert candidate(s = \"aabbbaabbaabbbaabbaabbba\",x = 2,y = 3) == 31\n assert candidate(s = \"babababababababababababababababababa\",x = 1,y = 2) == 36\n assert candidate(s = \"aabbaabbccddeeffgg\",x = 10,y = 20) == 60\n assert candidate(s = \"aaaabbbbbaaaaabbb\",x = 5,y = 3) == 38\n assert candidate(s = \"ababbaababbaab\",x = 6,y = 4) == 40\n assert candidate(s = \"babaababababba\",x = 3,y = 2) == 20\n assert candidate(s = \"abababababababababababab\",x = 9999,y = 1) == 119988\n assert candidate(s = \"baabaabaabaabaabaabaabaabaabaabaab\",x = 5000,y = 4000) == 59000\n assert candidate(s = \"abababababababababab\",x = 1,y = 2) == 19\n assert candidate(s = \"bababababa\",x = 2,y = 3) == 15\n assert candidate(s = \"abbaabbaabbaabbaabbaabba\",x = 10,y = 15) == 175\n assert candidate(s = \"babababababababababababababababababababababababa\",x = 5000,y = 4000) == 119000\n assert candidate(s = \"bbaabaaaabbbbbaaaab\",x = 3,y = 2) == 25\n assert candidate(s = \"ababababababababababababababababababababababababa\",x = 2000,y = 2000) == 48000\n assert candidate(s = \"baababababababababababababababab\",x = 4,y = 4) == 64\n assert candidate(s = \"babababababababababababababababababababababababababababa\",x = 3,y = 2) == 83\n assert candidate(s = \"ababbbabaabbbbab\",x = 7,y = 3) == 42\n assert candidate(s = \"abbaabbaabbaabbaabbaabbaabbaabba\",x = 1000,y = 1000) == 16000\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",x = 1000,y = 2000) == 2000\n assert candidate(s = \"abbbabaababaabbaaaabbbbaaabbabab\",x = 5,y = 6) == 93\n assert candidate(s = \"abababababababababababababababab\",x = 1000,y = 1000) == 16000\n assert candidate(s = \"babababababababababababa\",x = 5,y = 5) == 60\n assert candidate(s = \"ababaababbabbaab\",x = 3,y = 4) == 30\n assert candidate(s = \"babababababababababababababababababababababababababababa\",x = 8,y = 5) == 221\n"}, "metadata": {"canonical_parameter_names": ["s", "x", "y"], "leetcode_dataset_entry_point": "Solution().maximumGain", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumGain(string s, int x, int y) {", "container": "Solution", "callable": "maximumGain", "parameters": [{"name": "s", "type": "string"}, {"name": "x", "type": "int"}, {"name": "y", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1718, "task_id": "construct-the-lexicographically-largest-valid-sequence", "difficulty": "Medium", "problem_description": "Given an integer n, find a sequence with elements in the range [1, n] that satisfies all of the following:\n\nThe integer 1 occurs once in the sequence.\nEach integer between 2 and n occurs twice in the sequence.\nFor every integer i between 2 and n, the distance between the two occurrences of i is exactly i.\n\nThe distance between two numbers on the sequence, a[i] and a[j], is the absolute difference of their indices, |j - i|.\nReturn the lexicographically largest sequence. It is guaranteed that under the given constraints, there is always a solution. \nA sequence a is lexicographically larger than a sequence b (of the same length) if in the first position where a and b differ, sequence a has a number greater than the corresponding number in b. For example, [0,1,9,0] is lexicographically larger than [0,1,5,6] because the first position they differ is at the third number, and 9 is greater than 5.\n \nExample 1:\n\nInput: n = 3\nOutput: [3,1,2,3,2]\nExplanation: [2,3,2,1,3] is also a valid sequence, but [3,1,2,3,2] is the lexicographically largest valid sequence.\n\nExample 2:\n\nInput: n = 5\nOutput: [5,3,1,4,3,5,2,4,2]\n\n \nConstraints:\n\n1 <= n <= 20\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3) == [3, 1, 2, 3, 2]\n assert candidate(n = 15) == [15, 13, 14, 10, 8, 12, 5, 3, 11, 9, 3, 5, 8, 10, 13, 15, 14, 12, 9, 11, 7, 4, 6, 1, 2, 4, 2, 7, 6]\n assert candidate(n = 4) == [4, 2, 3, 2, 4, 3, 1]\n assert candidate(n = 20) == [20, 18, 19, 15, 13, 17, 10, 16, 7, 5, 3, 14, 12, 3, 5, 7, 10, 13, 15, 18, 20, 19, 17, 16, 12, 14, 11, 9, 4, 6, 8, 2, 4, 2, 1, 6, 9, 11, 8]\n assert candidate(n = 2) == [2, 1, 2]\n assert candidate(n = 1) == [1]\n assert candidate(n = 10) == [10, 8, 6, 9, 3, 1, 7, 3, 6, 8, 10, 5, 9, 7, 4, 2, 5, 2, 4]\n assert candidate(n = 5) == [5, 3, 1, 4, 3, 5, 2, 4, 2]\n assert candidate(n = 8) == [8, 6, 4, 2, 7, 2, 4, 6, 8, 5, 3, 7, 1, 3, 5]\n assert candidate(n = 11) == [11, 9, 10, 6, 4, 1, 7, 8, 4, 6, 9, 11, 10, 7, 5, 8, 2, 3, 2, 5, 3]\n assert candidate(n = 12) == [12, 10, 11, 7, 5, 3, 8, 9, 3, 5, 7, 10, 12, 11, 8, 6, 9, 2, 4, 2, 1, 6, 4]\n assert candidate(n = 16) == [16, 14, 15, 11, 9, 13, 6, 4, 12, 10, 1, 4, 6, 9, 11, 14, 16, 15, 13, 10, 12, 8, 5, 7, 2, 3, 2, 5, 3, 8, 7]\n assert candidate(n = 14) == [14, 12, 13, 9, 7, 11, 4, 1, 10, 8, 4, 7, 9, 12, 14, 13, 11, 8, 10, 6, 3, 5, 2, 3, 2, 6, 5]\n assert candidate(n = 17) == [17, 15, 16, 12, 10, 14, 7, 5, 3, 13, 11, 3, 5, 7, 10, 12, 15, 17, 16, 14, 9, 11, 13, 8, 6, 2, 1, 2, 4, 9, 6, 8, 4]\n assert candidate(n = 18) == [18, 16, 17, 13, 11, 15, 8, 14, 4, 2, 12, 2, 4, 10, 8, 11, 13, 16, 18, 17, 15, 14, 12, 10, 9, 7, 5, 3, 6, 1, 3, 5, 7, 9, 6]\n assert candidate(n = 13) == [13, 11, 12, 8, 6, 4, 9, 10, 1, 4, 6, 8, 11, 13, 12, 9, 7, 10, 3, 5, 2, 3, 2, 7, 5]\n assert candidate(n = 6) == [6, 4, 2, 5, 2, 4, 6, 3, 5, 1, 3]\n assert candidate(n = 7) == [7, 5, 3, 6, 4, 3, 5, 7, 4, 6, 2, 1, 2]\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().constructDistancedSequence", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector constructDistancedSequence(int n) {", "container": "Solution", "callable": "constructDistancedSequence", "parameters": [{"name": "n", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1719, "task_id": "number-of-ways-to-reconstruct-a-tree", "difficulty": "Hard", "problem_description": "You are given an array pairs, where pairs[i] = [xi, yi], and:\n\nThere are no duplicates.\nxi < yi\n\nLet ways be the number of rooted trees that satisfy the following conditions:\n\nThe tree consists of nodes whose values appeared in pairs.\nA pair [xi, yi] exists in pairs if and only if xi is an ancestor of yi or yi is an ancestor of xi.\nNote: the tree does not have to be a binary tree.\n\nTwo ways are considered to be different if there is at least one node that has different parents in both ways.\nReturn:\n\n0 if ways == 0\n1 if ways == 1\n2 if ways > 1\n\nA rooted tree is a tree that has a single root node, and all edges are oriented to be outgoing from the root.\nAn ancestor of a node is any node on the path from the root to that node (excluding the node itself). The root has no ancestors.\n \nExample 1:\n\n\nInput: pairs = [[1,2],[2,3]]\nOutput: 1\nExplanation: There is exactly one valid rooted tree, which is shown in the above figure.\n\nExample 2:\n\n\nInput: pairs = [[1,2],[2,3],[1,3]]\nOutput: 2\nExplanation: There are multiple valid rooted trees. Three of them are shown in the above figures.\n\nExample 3:\n\nInput: pairs = [[1,2],[2,3],[2,4],[1,5]]\nOutput: 0\nExplanation: There are no valid rooted trees.\n \nConstraints:\n\n1 <= pairs.length <= 105\n1 <= xi < yi <= 500\nThe elements in pairs are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [3, 5], [4, 5]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [1, 5]]) == 0\n assert candidate(pairs = [[1, 3], [2, 3], [3, 4], [4, 5]]) == 0\n assert candidate(pairs = [[1, 2], [3, 4]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3]]) == 1\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [3, 5]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 0\n assert candidate(pairs = [[1, 3], [2, 3], [4, 5]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [1, 4]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]) == 2\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [1, 5]]) == 1\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [4, 5]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [1, 3]]) == 2\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [1, 5]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [6, 12], [7, 13], [7, 14], [8, 15], [8, 16]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [3, 13], [4, 14], [4, 15], [4, 16], [4, 17], [5, 18], [5, 19], [5, 20], [5, 21], [6, 22], [6, 23], [6, 24], [7, 25], [7, 26], [7, 27], [8, 28], [8, 29], [8, 30], [9, 31], [9, 32], [9, 33], [10, 34], [10, 35], [10, 36], [11, 37], [11, 38], [11, 39], [12, 40], [12, 41], [12, 42], [13, 43], [13, 44], [13, 45], [14, 46], [14, 47], [14, 48], [15, 49], [15, 50], [15, 51]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [9, 17], [10, 18], [11, 19], [12, 20]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 11], [6, 12], [7, 13], [7, 14], [8, 15], [8, 16], [9, 17], [9, 18], [10, 19], [10, 20], [11, 21], [11, 22], [12, 23], [12, 24], [13, 25], [13, 26], [14, 27], [14, 28], [15, 29], [15, 30], [16, 31], [16, 32], [17, 33], [17, 34], [18, 35], [18, 36], [19, 37], [19, 38], [20, 39], [20, 40], [21, 41], [21, 42], [22, 43], [22, 44], [23, 45], [23, 46], [24, 47], [24, 48]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17], [12, 18]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [4, 15], [4, 16], [5, 17], [5, 18], [5, 19], [5, 20], [6, 21], [6, 22], [6, 23], [6, 24], [7, 25], [7, 26]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 11], [6, 12], [7, 13], [7, 14], [8, 15], [8, 16], [9, 17], [9, 18], [10, 19], [10, 20], [11, 21], [11, 22], [12, 23], [12, 24]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 0\n assert candidate(pairs = [[1, 12], [1, 11], [1, 10], [1, 9], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2]]) == 1\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [3, 11], [4, 12], [4, 13], [4, 14], [5, 15], [5, 16], [5, 17], [6, 18], [6, 19], [7, 20], [7, 21], [8, 22], [8, 23], [9, 24], [9, 25], [10, 26], [10, 27], [11, 28], [11, 29], [12, 30], [12, 31], [13, 32], [13, 33], [14, 34], [14, 35], [15, 36], [15, 37], [16, 38], [16, 39], [17, 40], [17, 41]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [6, 8], [6, 9], [7, 10], [7, 11]]) == 0\n assert candidate(pairs = [[1, 6], [6, 7], [6, 8], [1, 9], [9, 10], [9, 11], [1, 12], [12, 13], [12, 14]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [10, 23], [11, 24], [11, 25], [12, 26], [12, 27]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [4, 5], [1, 6], [6, 7], [6, 8], [8, 9], [9, 10], [1, 11], [11, 12], [12, 13]]) == 0\n assert candidate(pairs = [[1, 3], [3, 5], [5, 7], [3, 6], [6, 8], [1, 2], [2, 4], [4, 9], [9, 10]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [10, 23], [11, 24], [11, 25], [12, 26], [12, 27], [13, 28], [13, 29], [14, 30], [14, 31], [15, 32], [15, 33]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [2, 5], [3, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21], [10, 22], [10, 23]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16], [12, 17], [13, 18], [14, 19], [15, 20], [16, 21], [17, 22], [18, 23], [19, 24], [20, 25], [21, 26], [22, 27], [23, 28], [24, 29], [25, 30], [26, 31], [27, 32], [28, 33], [29, 34], [30, 35], [31, 36], [32, 37], [33, 38], [34, 39], [35, 40], [36, 41], [37, 42], [38, 43], [39, 44], [40, 45], [41, 46], [42, 47], [43, 48], [44, 49], [45, 50]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [6, 12], [7, 13], [7, 14], [8, 15], [8, 16], [9, 17], [9, 18], [10, 19], [11, 20], [11, 21], [12, 22], [12, 23], [13, 24], [13, 25], [14, 26], [14, 27], [15, 28], [15, 29], [16, 30], [16, 31], [17, 32], [17, 33], [18, 34], [18, 35], [19, 36], [19, 37], [20, 38], [20, 39], [21, 40], [21, 41], [22, 42], [22, 43], [23, 44], [23, 45]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [5, 16], [6, 17], [6, 18], [6, 19], [7, 20], [7, 21], [7, 22], [8, 23], [8, 24], [8, 25], [9, 26], [9, 27], [9, 28], [10, 29], [10, 30], [10, 31]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [3, 11], [3, 12], [4, 13], [4, 14], [4, 15], [4, 16], [5, 17], [5, 18], [5, 19], [5, 20], [6, 21], [6, 22], [6, 23], [6, 24], [7, 25], [7, 26], [7, 27], [7, 28], [8, 29], [8, 30], [8, 31], [8, 32]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [5, 11], [6, 12]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 11], [6, 12]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16], [12, 17], [13, 18], [14, 19], [15, 20]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 16], [8, 17]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [3, 13], [4, 14], [4, 15], [4, 16], [4, 17], [5, 18], [5, 19], [5, 20], [5, 21]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30], [15, 31], [16, 32], [16, 33], [17, 34], [17, 35], [18, 36], [18, 37], [19, 38], [19, 39], [20, 40], [20, 41], [21, 42], [21, 43]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20], [17, 21], [18, 22], [19, 23], [20, 24], [21, 25], [22, 26], [23, 27], [24, 28], [25, 29], [26, 30], [27, 31], [28, 32], [29, 33], [30, 34]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [1, 5], [5, 6], [6, 7], [1, 8], [8, 9], [9, 10], [10, 11]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 10], [3, 11], [3, 12], [3, 13], [4, 14], [4, 15], [4, 16], [4, 17], [5, 18], [5, 19], [5, 20], [5, 21], [6, 22], [6, 23], [6, 24], [6, 25], [7, 26], [7, 27], [7, 28], [7, 29], [8, 30], [8, 31], [8, 32], [8, 33], [9, 34], [9, 35], [9, 36], [9, 37], [10, 38], [10, 39], [10, 40], [10, 41]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [10, 19], [11, 20], [12, 21], [13, 22], [14, 23], [15, 24], [16, 25], [17, 26], [18, 27], [19, 28], [20, 29], [21, 30], [22, 31], [23, 32], [24, 33], [25, 34], [26, 35], [27, 36], [28, 37], [29, 38], [30, 39], [31, 40]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [3, 5], [3, 6], [4, 7], [4, 8], [5, 9], [5, 10], [6, 11], [6, 12], [7, 13], [7, 14], [8, 15], [8, 16]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30], [15, 31], [15, 32], [16, 33], [16, 34], [17, 35], [17, 36], [18, 37], [18, 38], [19, 39], [19, 40], [20, 41], [20, 42], [21, 43], [21, 44], [22, 45], [22, 46], [23, 47], [23, 48], [24, 49], [24, 50]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [5, 16], [6, 17], [6, 18], [6, 19], [7, 20], [7, 21], [7, 22], [8, 23], [8, 24]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16], [12, 17], [13, 18], [14, 19], [15, 20], [16, 21], [17, 22], [18, 23], [19, 24], [20, 25]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25], [24, 26], [25, 27], [26, 28], [27, 29], [28, 30]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30], [15, 31]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [6, 8], [6, 9], [7, 10], [7, 11], [10, 12], [11, 13]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [14, 27], [15, 28], [16, 29], [17, 30], [18, 31], [19, 32], [20, 33]]) == 0\n assert candidate(pairs = [[1, 3], [1, 2], [3, 5], [3, 6], [3, 7], [2, 4], [2, 8], [2, 9], [4, 10], [4, 11], [8, 12], [8, 13], [9, 14], [9, 15], [14, 16], [15, 17]]) == 0\n assert candidate(pairs = [[1, 6], [1, 7], [1, 8], [2, 6], [3, 7], [4, 8], [5, 8], [5, 6], [5, 7]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [1, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [2, 4], [2, 5], [3, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [5, 13]]) == 0\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == 0\n assert candidate(pairs = [[1, 6], [6, 7], [1, 2], [1, 3], [1, 4], [1, 5], [5, 8], [8, 9]]) == 0\n assert candidate(pairs = [[1, 3], [3, 5], [5, 7], [7, 9], [1, 4], [4, 6], [6, 8], [8, 10], [1, 11], [11, 12], [12, 13], [13, 14]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30]]) == 0\n assert candidate(pairs = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30], [15, 31], [16, 32], [16, 33], [17, 34], [17, 35], [18, 36], [18, 37], [19, 38], [19, 39], [20, 40], [20, 41], [21, 42], [21, 43], [22, 44], [22, 45], [23, 46], [23, 47], [24, 48], [24, 49], [25, 50], [25, 51]]) == 0\n assert candidate(pairs = [[1, 15], [1, 14], [1, 13], [1, 12], [1, 11], [1, 10], [1, 9], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2]]) == 1\n"}, "metadata": {"canonical_parameter_names": ["pairs"], "leetcode_dataset_entry_point": "Solution().checkWays", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int checkWays(vector>& pairs) {", "container": "Solution", "callable": "checkWays", "parameters": [{"name": "pairs", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1720, "task_id": "decode-xored-array", "difficulty": "Easy", "problem_description": "There is a hidden integer array arr that consists of n non-negative integers.\nIt was encoded into another integer array encoded of length n - 1, such that encoded[i] = arr[i] XOR arr[i + 1]. For example, if arr = [1,0,2,1], then encoded = [1,2,3].\nYou are given the encoded array. You are also given an integer first, that is the first element of arr, i.e. arr[0].\nReturn the original array arr. It can be proved that the answer exists and is unique.\n \nExample 1:\n\nInput: encoded = [1,2,3], first = 1\nOutput: [1,0,2,1]\nExplanation: If arr = [1,0,2,1], then first = 1 and encoded = [1 XOR 0, 0 XOR 2, 2 XOR 1] = [1,2,3]\n\nExample 2:\n\nInput: encoded = [6,2,7,3], first = 4\nOutput: [4,2,0,7,4]\n\n \nConstraints:\n\n2 <= n <= 104\nencoded.length == n - 1\n0 <= encoded[i] <= 105\n0 <= first <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(encoded = [10, 5, 15],first = 0) == [0, 10, 15, 0]\n assert candidate(encoded = [0, 0, 0],first = 7) == [7, 7, 7, 7]\n assert candidate(encoded = [9, 5, 6],first = 0) == [0, 9, 12, 10]\n assert candidate(encoded = [10, 5, 15, 20],first = 0) == [0, 10, 15, 0, 20]\n assert candidate(encoded = [3, 1, 2],first = 0) == [0, 3, 2, 0]\n assert candidate(encoded = [12345, 67890, 13579, 24680],first = 98765) == [98765, 111092, 47302, 36301, 60837]\n assert candidate(encoded = [1, 2, 3],first = 1) == [1, 0, 2, 1]\n assert candidate(encoded = [6, 2, 7, 3],first = 4) == [4, 2, 0, 7, 4]\n assert candidate(encoded = [0, 0, 0, 0],first = 5) == [5, 5, 5, 5, 5]\n assert candidate(encoded = [3, 1],first = 5) == [5, 6, 7]\n assert candidate(encoded = [10, 5, 15],first = 3) == [3, 9, 12, 3]\n assert candidate(encoded = [0, 0, 0],first = 5) == [5, 5, 5, 5]\n assert candidate(encoded = [3, 1],first = 2) == [2, 1, 0]\n assert candidate(encoded = [7, 9, 14, 2, 6],first = 8) == [8, 15, 6, 8, 10, 12]\n assert candidate(encoded = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],first = 0) == [0, 65535, 32768, 49151, 40960, 45055, 43008, 44031, 43520, 43775, 43648, 43711, 43680, 43695, 43688, 43691, 43690]\n assert candidate(encoded = [255, 128, 64, 32, 16, 8, 4, 2, 1],first = 255) == [255, 0, 128, 192, 224, 240, 248, 252, 254, 255]\n assert candidate(encoded = [255, 0, 255, 0, 255],first = 1) == [1, 254, 254, 1, 1, 254]\n assert candidate(encoded = [88, 99, 22, 15, 77, 44, 55, 11, 33, 66],first = 3) == [3, 91, 56, 46, 33, 108, 64, 119, 124, 93, 31]\n assert candidate(encoded = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048],first = 1) == [1, 0, 2, 6, 14, 30, 62, 126, 254, 510, 1022, 2046, 4094]\n assert candidate(encoded = [5, 5, 5, 5, 5],first = 10) == [10, 15, 10, 15, 10, 15]\n assert candidate(encoded = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],first = 1) == [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]\n assert candidate(encoded = [255, 128, 64, 32, 16, 8, 4, 2, 1],first = 0) == [0, 255, 127, 63, 31, 15, 7, 3, 1, 0]\n assert candidate(encoded = [8, 12, 5, 10, 15],first = 7) == [7, 15, 3, 6, 12, 3]\n assert candidate(encoded = [99, 142, 55, 231, 78, 102, 184, 33, 201, 127],first = 23) == [23, 116, 250, 205, 42, 100, 2, 186, 155, 82, 45]\n assert candidate(encoded = [15, 9, 12, 5, 6, 3, 14, 10],first = 8) == [8, 7, 14, 2, 7, 1, 2, 12, 6]\n assert candidate(encoded = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],first = 1) == [1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1]\n assert candidate(encoded = [123, 246, 369, 492, 615, 738, 861, 984],first = 100) == [100, 31, 233, 408, 116, 531, 241, 940, 116]\n assert candidate(encoded = [7, 9, 3, 10, 8],first = 2) == [2, 5, 12, 15, 5, 13]\n assert candidate(encoded = [12, 4, 6, 5, 11, 3],first = 8) == [8, 4, 0, 6, 3, 8, 11]\n assert candidate(encoded = [13, 26, 52, 104, 208, 416, 832, 1664, 3328, 6656],first = 7) == [7, 10, 16, 36, 76, 156, 316, 636, 1276, 2556, 5116]\n assert candidate(encoded = [15, 6, 9, 12, 23, 45],first = 10) == [10, 5, 3, 10, 6, 17, 60]\n assert candidate(encoded = [123456, 987654, 13579, 24680],first = 111111) == [111111, 20551, 1000001, 1013578, 988962]\n assert candidate(encoded = [100000, 50000, 25000, 12500, 6250, 3125],first = 15625) == [15625, 113577, 96505, 72017, 76165, 78319, 81370]\n assert candidate(encoded = [4, 13, 5, 10, 3, 7, 1],first = 9) == [9, 13, 0, 5, 15, 12, 11, 10]\n assert candidate(encoded = [256, 512, 1024, 2048, 4096, 8192, 16384, 32768],first = 128) == [128, 384, 896, 1920, 3968, 8064, 16256, 32640, 65408]\n assert candidate(encoded = [100, 200, 50, 250, 10, 300, 150, 225],first = 42) == [42, 78, 134, 180, 78, 68, 360, 510, 287]\n assert candidate(encoded = [5, 10, 15, 20, 25, 30, 35, 40, 45],first = 0) == [0, 5, 15, 0, 20, 13, 19, 48, 24, 53]\n assert candidate(encoded = [0, 0, 0, 0, 0],first = 0) == [0, 0, 0, 0, 0, 0]\n assert candidate(encoded = [255, 128, 64, 32, 16],first = 1) == [1, 254, 126, 62, 30, 14]\n assert candidate(encoded = [10, 10, 10, 10, 10, 10, 10, 10, 10],first = 10) == [10, 0, 10, 0, 10, 0, 10, 0, 10, 0]\n assert candidate(encoded = [0, 1, 0, 1, 0],first = 1) == [1, 1, 0, 0, 1, 1]\n assert candidate(encoded = [8, 3, 12, 5, 9],first = 6) == [6, 14, 13, 1, 4, 13]\n assert candidate(encoded = [99, 101, 97, 95, 103, 109, 100, 98, 94, 96, 92],first = 100) == [100, 7, 98, 3, 92, 59, 86, 50, 80, 14, 110, 50]\n assert candidate(encoded = [14, 7, 11, 12],first = 3) == [3, 13, 10, 1, 13]\n assert candidate(encoded = [31, 41, 59, 26, 53, 58, 97, 93, 23, 84, 62, 64, 33, 83, 27, 95, 8, 4],first = 271) == [271, 272, 313, 258, 280, 301, 279, 374, 299, 316, 360, 342, 278, 311, 356, 383, 288, 296, 300]\n assert candidate(encoded = [2, 3, 1, 4, 5],first = 7) == [7, 5, 6, 7, 3, 6]\n assert candidate(encoded = [231, 45, 67, 89, 101, 123, 145],first = 99) == [99, 132, 169, 234, 179, 214, 173, 60]\n assert candidate(encoded = [7, 5, 3, 1, 9, 11, 13, 15, 17, 19],first = 2) == [2, 5, 0, 3, 2, 11, 0, 13, 2, 19, 0]\n assert candidate(encoded = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],first = 2048) == [2048, 3072, 3584, 3840, 3968, 4032, 4064, 4080, 4088, 4092, 4094, 4095]\n assert candidate(encoded = [8, 6, 10, 12, 14, 16, 18, 20],first = 4) == [4, 12, 10, 0, 12, 2, 18, 0, 20]\n assert candidate(encoded = [2, 3, 2, 3, 2, 3],first = 1) == [1, 3, 0, 2, 1, 3, 0]\n assert candidate(encoded = [8, 13, 7, 10, 15],first = 2) == [2, 10, 7, 0, 10, 5]\n assert candidate(encoded = [7, 7, 7, 7, 7, 7, 7, 7],first = 3) == [3, 4, 3, 4, 3, 4, 3, 4, 3]\n assert candidate(encoded = [14, 11, 7, 15],first = 2) == [2, 12, 7, 0, 15]\n assert candidate(encoded = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36],first = 3) == [3, 0, 6, 15, 3, 12, 30, 11, 19, 8, 22, 55, 19]\n assert candidate(encoded = [98765, 43210, 12345, 67890, 54321, 89012, 21043],first = 78901) == [78901, 46584, 7474, 11531, 74809, 126984, 43964, 63887]\n assert candidate(encoded = [7, 13, 14, 12, 17],first = 9) == [9, 14, 3, 13, 1, 16]\n assert candidate(encoded = [16, 32, 64, 128, 256, 512],first = 8) == [8, 24, 56, 120, 248, 504, 1016]\n assert candidate(encoded = [25, 15, 10, 13, 7, 4],first = 8) == [8, 17, 30, 20, 25, 30, 26]\n assert candidate(encoded = [128, 64, 32, 16, 8, 4, 2, 1],first = 255) == [255, 127, 63, 31, 15, 7, 3, 1, 0]\n assert candidate(encoded = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],first = 5) == [5, 0, 10, 5, 17, 8, 22, 53, 29, 48, 2]\n assert candidate(encoded = [255, 128, 64, 32, 16, 8, 4, 2, 1],first = 0) == [0, 255, 127, 63, 31, 15, 7, 3, 1, 0]\n assert candidate(encoded = [1000, 500, 250, 125, 62, 31, 15],first = 1) == [1, 1001, 541, 743, 666, 676, 699, 692]\n assert candidate(encoded = [15, 24, 32, 16, 8, 4, 2],first = 1) == [1, 14, 22, 54, 38, 46, 42, 40]\n assert candidate(encoded = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0],first = 65536) == [65536, 131071, 98304, 114687, 106496, 110591, 108544, 109567, 109056, 109311, 109184, 109247, 109216, 109231, 109224, 109227, 109226, 109226]\n assert candidate(encoded = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],first = 0) == [0, 1, 2, 5, 10, 21, 42, 85, 170, 341, 682]\n assert candidate(encoded = [101010, 101010, 101010, 101010, 101010, 101010],first = 101010) == [101010, 0, 101010, 0, 101010, 0, 101010]\n assert candidate(encoded = [1, 2, 4, 8, 16, 32, 64, 128],first = 256) == [256, 257, 259, 263, 271, 287, 319, 383, 511]\n assert candidate(encoded = [8, 2, 6, 4, 2, 6, 4],first = 7) == [7, 15, 13, 11, 15, 13, 11, 15]\n assert candidate(encoded = [1023, 2047, 4095, 8191, 16383, 32767, 65535],first = 1) == [1, 1022, 1025, 3070, 5121, 11262, 21505, 44030]\n assert candidate(encoded = [2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42],first = 1) == [1, 3, 5, 15, 1, 19, 5, 31, 1, 35, 5, 47]\n assert candidate(encoded = [100000, 50000, 25000, 12500, 6250, 3125],first = 1) == [1, 100001, 83441, 74841, 70797, 68839, 65746]\n assert candidate(encoded = [123, 456, 789, 101112, 131415, 161718, 192021],first = 222324) == [222324, 222223, 222663, 222930, 191530, 60797, 170699, 29918]\n assert candidate(encoded = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80],first = 1) == [1, 4, 14, 1, 21, 12, 18, 49, 25, 52, 6, 49, 13, 76, 10, 65, 17]\n assert candidate(encoded = [1, 0, 1, 0, 1, 0, 1, 0],first = 0) == [0, 1, 1, 0, 0, 1, 1, 0, 0]\n assert candidate(encoded = [3, 5, 6, 1, 7, 4, 2, 8, 0],first = 3) == [3, 0, 5, 3, 2, 5, 1, 3, 11, 11]\n assert candidate(encoded = [9, 5, 7, 3, 8, 6, 2, 4, 1, 0],first = 11) == [11, 2, 7, 0, 3, 11, 13, 15, 11, 10, 10]\n assert candidate(encoded = [0, 1, 0, 1, 0, 1, 0, 1],first = 1) == [1, 1, 0, 0, 1, 1, 0, 0, 1]\n assert candidate(encoded = [2, 3, 1, 4, 5, 6, 7, 8, 9],first = 1) == [1, 3, 0, 1, 5, 0, 6, 1, 9, 0]\n assert candidate(encoded = [30, 15, 25, 35, 45, 55, 65],first = 5) == [5, 27, 20, 13, 46, 3, 52, 117]\n assert candidate(encoded = [23, 54, 12, 9, 17, 33, 20],first = 15) == [15, 24, 46, 34, 43, 58, 27, 15]\n assert candidate(encoded = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97],first = 1) == [1, 100001, 83441, 74841, 70797, 68839, 65746, 67272, 67013, 66627, 66688, 66785]\n assert candidate(encoded = [4, 6, 5, 7, 10, 13],first = 2) == [2, 6, 0, 5, 2, 8, 5]\n assert candidate(encoded = [100000, 90000, 80000, 70000, 60000],first = 50000) == [50000, 83440, 6752, 74464, 13200, 55792]\n assert candidate(encoded = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],first = 3) == [3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6]\n assert candidate(encoded = [12345, 67890, 12345, 67890, 12345],first = 98765) == [98765, 111092, 47302, 35071, 98765, 111092]\n assert candidate(encoded = [98765, 43210, 67890, 12345, 54321, 90123],first = 65432) == [65432, 97877, 120479, 57261, 61332, 15269, 89006]\n assert candidate(encoded = [25, 17, 31, 18, 29, 14],first = 10) == [10, 19, 2, 29, 15, 18, 28]\n assert candidate(encoded = [13, 11, 7, 14, 28, 16, 32],first = 8) == [8, 5, 14, 9, 7, 27, 11, 43]\n assert candidate(encoded = [14, 22, 36, 52, 72, 96, 124],first = 1) == [1, 15, 25, 61, 9, 65, 33, 93]\n assert candidate(encoded = [99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111],first = 10000) == [10000, 106895, 64183, 120166, 53516, 2063, 42387, 10150, 29032, 23055]\n assert candidate(encoded = [12, 15, 2, 8, 17, 5],first = 3) == [3, 15, 0, 2, 10, 27, 30]\n assert candidate(encoded = [4, 3, 2, 1],first = 5) == [5, 1, 2, 0, 1]\n assert candidate(encoded = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],first = 1) == [1, 0, 3, 4, 11, 20, 43, 84, 171, 340, 683]\n assert candidate(encoded = [2047, 4094, 2047, 4094, 2047, 4094, 2047],first = 4095) == [4095, 2048, 2046, 1, 4095, 2048, 2046, 1]\n assert candidate(encoded = [13, 9, 16, 22, 10, 19, 7, 12],first = 4) == [4, 9, 0, 16, 6, 12, 31, 24, 20]\n assert candidate(encoded = [32767, 16383, 8191, 4095, 2047],first = 1024) == [1024, 31743, 17408, 23551, 21504, 21503]\n"}, "metadata": {"canonical_parameter_names": ["encoded", "first"], "leetcode_dataset_entry_point": "Solution().decode", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector decode(vector& encoded, int first) {", "container": "Solution", "callable": "decode", "parameters": [{"name": "encoded", "type": "vector&"}, {"name": "first", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1721, "task_id": "swapping-nodes-in-a-linked-list", "difficulty": "Medium", "problem_description": "You are given the head of a linked list, and an integer k.\nReturn the head of the linked list after swapping the values of the kth node from the beginning and the kth node from the end (the list is 1-indexed).\n \nExample 1:\n\n\nInput: head = [1,2,3,4,5], k = 2\nOutput: [1,4,3,2,5]\n\nExample 2:\n\nInput: head = [7,9,6,6,7,8,3,0,9,5], k = 5\nOutput: [7,9,6,6,8,7,3,0,9,5]\n\n \nConstraints:\n\nThe number of nodes in the list is n.\n1 <= k <= n <= 105\n0 <= Node.val <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert is_same_list(candidate(head = list_node([100, 0, 1, 0, 100]),k = 3), list_node([100, 0, 1, 0, 100]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100]),k = 10), list_node([100, 20, 30, 40, 50, 60, 70, 80, 90, 10]))\n assert is_same_list(candidate(head = list_node([100, 99, 98, 97, 96, 95]),k = 3), list_node([100, 99, 97, 98, 96, 95]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),k = 10), list_node([10, 2, 3, 4, 5, 6, 7, 8, 9, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3]),k = 3), list_node([3, 2, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5]),k = 2), list_node([1, 4, 3, 2, 5]))\n assert is_same_list(candidate(head = list_node([7, 9, 6, 6, 7, 8, 3, 0, 9, 5]),k = 5), list_node([7, 9, 6, 6, 8, 7, 3, 0, 9, 5]))\n assert is_same_list(candidate(head = list_node([1, 2]),k = 1), list_node([2, 1]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100]),k = 3), list_node([10, 20, 80, 40, 50, 60, 70, 30, 90, 100]))\n assert is_same_list(candidate(head = list_node([1]),k = 1), list_node([1]))\n assert is_same_list(candidate(head = list_node([100, 90]),k = 1), list_node([90, 100]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),k = 5), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]),k = 20), list_node([1, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 20]))\n assert is_same_list(candidate(head = list_node([5, 4, 3, 2, 1]),k = 5), list_node([1, 4, 3, 2, 5]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]),k = 9), list_node([10, 20, 30, 40, 90, 60, 70, 80, 50, 100, 110, 120, 130]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]),k = 15), list_node([29, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),k = 6), list_node([1, 2, 3, 4, 5, 15, 7, 8, 9, 10, 11, 12, 13, 14, 6, 16, 17, 18, 19, 20]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),k = 15), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([42]),k = 1), list_node([42]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]),k = 6), list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),k = 10), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),k = 5), list_node([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]))\n assert is_same_list(candidate(head = list_node([2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]),k = 10), list_node([2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),k = 2), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([1, 0, 2, 0, 3, 0, 4, 0, 5, 0]),k = 4), list_node([1, 0, 2, 4, 3, 0, 0, 0, 5, 0]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),k = 10), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),k = 11), list_node([11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),k = 1), list_node([11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),k = 20), list_node([20, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),k = 5), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]),k = 15), list_node([1, 29, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 3, 31]))\n assert is_same_list(candidate(head = list_node([21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]),k = 5), list_node([21, 20, 19, 18, 5, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 17, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),k = 10), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20]))\n assert is_same_list(candidate(head = list_node([2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]),k = 10), list_node([2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 11, 13, 14, 15, 16, 17, 18, 19, 20, 21]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]),k = 10), list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 21, 19, 23, 25, 27, 29, 31, 33, 35, 37, 39]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]),k = 1), list_node([150, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 10]))\n assert is_same_list(candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]),k = 10), list_node([10, 1, 8, 7, 6, 5, 4, 3, 2, 9, 0]))\n assert is_same_list(candidate(head = list_node([5, 4, 3, 2, 1]),k = 1), list_node([1, 4, 3, 2, 5]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),k = 7), list_node([1, 2, 3, 4, 5, 6, 9, 8, 7, 10, 11, 12, 13, 14, 15]))\n assert is_same_list(candidate(head = list_node([50, 40, 30, 20, 10]),k = 3), list_node([50, 40, 30, 20, 10]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),k = 16), list_node([1, 2, 3, 4, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 5, 17, 18, 19, 20]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]),k = 5), list_node([1, 3, 5, 7, 31, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 9, 33, 35, 37, 39]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]),k = 9), list_node([10, 20, 30, 40, 50, 60, 90, 80, 70, 100, 110, 120, 130, 140, 150]))\n assert is_same_list(candidate(head = list_node([0, 1, 0, 2, 0, 3, 0, 4, 0, 5]),k = 3), list_node([0, 1, 4, 2, 0, 3, 0, 0, 0, 5]))\n assert is_same_list(candidate(head = list_node([50, 50, 50, 50, 50, 50, 50, 50, 50, 50]),k = 5), list_node([50, 50, 50, 50, 50, 50, 50, 50, 50, 50]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1]),k = 9), list_node([1, 8, 7, 6, 5, 4, 3, 2, 9]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]),k = 14), list_node([10, 140, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 20, 150]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),k = 5), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([2, 3, 1, 4, 5, 6, 7, 8, 9]),k = 7), list_node([2, 3, 7, 4, 5, 6, 1, 8, 9]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),k = 3), list_node([1, 2, 9, 4, 5, 6, 7, 8, 3, 10, 11]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),k = 1), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([42, 42, 42, 42, 42, 42]),k = 3), list_node([42, 42, 42, 42, 42, 42]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]),k = 20), list_node([1, 20, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 21]))\n assert is_same_list(candidate(head = list_node([5, 4, 3, 2, 1]),k = 5), list_node([1, 4, 3, 2, 5]))\n assert is_same_list(candidate(head = list_node([1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1]),k = 5), list_node([1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19]),k = 10), list_node([19, 3, 5, 7, 9, 11, 13, 15, 17, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),k = 8), list_node([1, 2, 8, 4, 5, 6, 7, 3, 9, 10]))\n assert is_same_list(candidate(head = list_node([5, 3, 1, 4, 2]),k = 4), list_node([5, 4, 1, 3, 2]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]),k = 7), list_node([10, 20, 30, 40, 50, 60, 90, 80, 70, 100, 110, 120, 130, 140, 150]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]),k = 10), list_node([9, 8, 7, 6, 5, 0, 3, 2, 1, 4, -1, -2, -3, -4, -5]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),k = 3), list_node([1, 2, 9, 4, 5, 6, 7, 8, 3, 10, 11]))\n assert is_same_list(candidate(head = list_node([8, 6, 4, 2, 0, 2, 4, 6, 8]),k = 5), list_node([8, 6, 4, 2, 0, 2, 4, 6, 8]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]),k = 16), list_node([1, 3, 5, 7, 31, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 9, 33, 35, 37, 39]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),k = 5), list_node([1, 2, 3, 4, 16, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 5, 17, 18, 19, 20]))\n assert is_same_list(candidate(head = list_node([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),k = 10), list_node([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]),k = 5), list_node([9, 8, 7, 6, -6, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, 5, -7, -8, -9, -10]))\n assert is_same_list(candidate(head = list_node([5]),k = 1), list_node([5]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]),k = 7), list_node([10, 20, 30, 40, 50, 60, 90, 80, 70, 100, 110, 120, 130, 140, 150]))\n assert is_same_list(candidate(head = list_node([99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]),k = 1), list_node([85, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 99]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),k = 1), list_node([10, 2, 3, 4, 5, 6, 7, 8, 9, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),k = 5), list_node([1, 2, 3, 4, 6, 5, 7, 8, 9, 10]))\n assert is_same_list(candidate(head = list_node([50, 40, 30, 20, 10]),k = 5), list_node([10, 40, 30, 20, 50]))\n assert is_same_list(candidate(head = list_node([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]),k = 15), list_node([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]))\n assert is_same_list(candidate(head = list_node([5, 1, 9, 7, 4, 6, 2, 3]),k = 4), list_node([5, 1, 9, 4, 7, 6, 2, 3]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),k = 3), list_node([1, 2, 8, 4, 5, 6, 7, 3, 9, 10]))\n assert is_same_list(candidate(head = list_node([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),k = 20), list_node([0, 19, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 1, 20]))\n assert is_same_list(candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]),k = 15), list_node([10, 9, 8, 7, 6, 6, 4, 3, 2, 1, 10, 9, 8, 7, 5, 5, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]),k = 20), list_node([1, 2, 3, 4, 5, 20, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 6, 21, 22, 23, 24, 25]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),k = 15), list_node([15, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),k = 10), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3]),k = 2), list_node([1, 2, 3]))\n assert is_same_list(candidate(head = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20]),k = 5), list_node([2, 4, 6, 8, 12, 10, 14, 16, 18, 20]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]),k = 20), list_node([2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90]),k = 4), list_node([10, 20, 30, 60, 50, 40, 70, 80, 90]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),k = 1), list_node([15, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),k = 3), list_node([1, 2, 13, 4, 5, 6, 7, 8, 9, 10, 11, 12, 3, 14, 15]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),k = 7), list_node([1, 2, 3, 4, 5, 6, 9, 8, 7, 10, 11, 12, 13, 14, 15]))\n assert is_same_list(candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]),k = 7), list_node([10, 9, 8, 7, 6, 5, 1, 3, 2, 4, 0, -1, -2, -3, -4, -5]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]),k = 6), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]))\n assert is_same_list(candidate(head = list_node([23, 12, 34, 45, 56, 67, 78, 89, 90, 101, 112, 123]),k = 12), list_node([123, 12, 34, 45, 56, 67, 78, 89, 90, 101, 112, 23]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),k = 15), list_node([1, 2, 3, 4, 5, 15, 7, 8, 9, 10, 11, 12, 13, 14, 6, 16, 17, 18, 19, 20]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]),k = 13), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]),k = 15), list_node([-5, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, 9]))\n assert is_same_list(candidate(head = list_node([50, 40, 30, 20, 10]),k = 1), list_node([10, 40, 30, 20, 50]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]),k = 3), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]),k = 1), list_node([1, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 20]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100]),k = 5), list_node([10, 20, 30, 40, 60, 50, 70, 80, 90, 100]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1]),k = 3), list_node([9, 8, 3, 6, 5, 4, 7, 2, 1]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]),k = 4), list_node([10, 20, 30, 100, 50, 60, 70, 80, 90, 40, 110, 120, 130]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),k = 8), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]))\n assert is_same_list(candidate(head = list_node([25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]),k = 12), list_node([25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 12, 13, 14, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]),k = 10), list_node([100, 99, 98, 97, 96, 95, 94, 93, 92, 90, 91, 89, 88, 87, 86, 85, 84, 83, 82, 81]))\n"}, "metadata": {"canonical_parameter_names": ["head", "k"], "leetcode_dataset_entry_point": "Solution().swapNodes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "ListNode* swapNodes(ListNode* head, int k) {", "container": "Solution", "callable": "swapNodes", "parameters": [{"name": "head", "type": "ListNode*"}, {"name": "k", "type": "int"}], "return_type": "ListNode*", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1722, "task_id": "minimize-hamming-distance-after-swap-operations", "difficulty": "Medium", "problem_description": "You are given two integer arrays, source and target, both of length n. You are also given an array allowedSwaps where each allowedSwaps[i] = [ai, bi] indicates that you are allowed to swap the elements at index ai and index bi (0-indexed) of array source. Note that you can swap elements at a specific pair of indices multiple times and in any order.\nThe Hamming distance of two arrays of the same length, source and target, is the number of positions where the elements are different. Formally, it is the number of indices i for 0 <= i <= n-1 where source[i] != target[i] (0-indexed).\nReturn the minimum Hamming distance of source and target after performing any amount of swap operations on array source.\n \nExample 1:\n\nInput: source = [1,2,3,4], target = [2,1,4,5], allowedSwaps = [[0,1],[2,3]]\nOutput: 1\nExplanation: source can be transformed the following way:\n- Swap indices 0 and 1: source = [2,1,3,4]\n- Swap indices 2 and 3: source = [2,1,4,3]\nThe Hamming distance of source and target is 1 as they differ in 1 position: index 3.\n\nExample 2:\n\nInput: source = [1,2,3,4], target = [1,3,2,4], allowedSwaps = []\nOutput: 2\nExplanation: There are no allowed swaps.\nThe Hamming distance of source and target is 2 as they differ in 2 positions: index 1 and index 2.\n\nExample 3:\n\nInput: source = [5,1,2,4,3], target = [1,5,4,2,3], allowedSwaps = [[0,4],[4,2],[1,3],[1,4]]\nOutput: 0\n\n \nConstraints:\n\nn == source.length == target.length\n1 <= n <= 105\n1 <= source[i], target[i] <= 105\n0 <= allowedSwaps.length <= 105\nallowedSwaps[i].length == 2\n0 <= ai, bi <= n - 1\nai != bi\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(source = [4, 3, 2, 1],target = [1, 2, 3, 4],allowedSwaps = [[0, 3], [1, 2], [0, 1], [2, 3]]) == 0\n assert candidate(source = [4, 3, 2, 1],target = [1, 2, 3, 4],allowedSwaps = [[0, 2], [1, 3]]) == 4\n assert candidate(source = [1, 1, 1, 1],target = [1, 1, 1, 1],allowedSwaps = [[0, 1], [1, 2], [2, 3]]) == 0\n assert candidate(source = [1, 2, 3, 4],target = [1, 3, 2, 4],allowedSwaps = []) == 2\n assert candidate(source = [1, 2, 3, 4],target = [2, 1, 4, 5],allowedSwaps = [[0, 1], [2, 3]]) == 1\n assert candidate(source = [5, 1, 2, 4, 3],target = [1, 5, 4, 2, 3],allowedSwaps = [[0, 4], [4, 2], [1, 3], [1, 4]]) == 0\n assert candidate(source = [4, 5, 6],target = [6, 4, 5],allowedSwaps = [[0, 1], [1, 2]]) == 0\n assert candidate(source = [10, 20, 30],target = [30, 20, 10],allowedSwaps = [[0, 2]]) == 0\n assert candidate(source = [1, 1, 1, 1],target = [2, 2, 2, 2],allowedSwaps = [[0, 1], [1, 2], [2, 3]]) == 4\n assert candidate(source = [1, 2, 2, 1],target = [2, 1, 1, 2],allowedSwaps = [[0, 1], [2, 3], [1, 2]]) == 0\n assert candidate(source = [1, 3, 5, 7, 9],target = [9, 7, 5, 3, 1],allowedSwaps = [[0, 4], [1, 3], [2, 2]]) == 0\n assert candidate(source = [1, 2, 2, 1, 3, 3, 4, 4],target = [4, 4, 3, 3, 2, 2, 1, 1],allowedSwaps = [[0, 6], [1, 7], [2, 5], [3, 4], [0, 1], [2, 3], [4, 5], [6, 7]]) == 2\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10],allowedSwaps = [[0, 2], [2, 4], [4, 6], [6, 8], [1, 3], [3, 5], [5, 7], [7, 9]]) == 4\n assert candidate(source = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],target = [5, 9, 2, 6, 5, 3, 5, 3, 1, 4, 1],allowedSwaps = [[0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5]]) == 8\n assert candidate(source = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 0\n assert candidate(source = [7, 8, 9, 10, 11, 12, 13],target = [13, 12, 11, 10, 9, 8, 7],allowedSwaps = [[0, 6], [1, 5], [2, 4], [3, 3]]) == 0\n assert candidate(source = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 5], [1, 6], [2, 3], [3, 2], [4, 1], [5, 0]]) == 0\n assert candidate(source = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],target = [99991, 99992, 99993, 99994, 99995, 99996, 99997, 99998, 99999, 100000],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 0\n assert candidate(source = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 10\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 2], [1, 3]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 0\n assert candidate(source = [7, 8, 9, 10, 11, 12],target = [12, 11, 10, 9, 8, 7],allowedSwaps = [[0, 5], [1, 4], [2, 3]]) == 0\n assert candidate(source = [1, 3, 5, 7, 9, 11],target = [11, 9, 7, 5, 3, 1],allowedSwaps = [[0, 5], [1, 4], [2, 3]]) == 0\n assert candidate(source = [1, 3, 5, 7, 9, 11, 13, 15],target = [15, 13, 11, 9, 7, 5, 3, 1],allowedSwaps = [[0, 7], [1, 6], [2, 5], [3, 4]]) == 0\n assert candidate(source = [10, 20, 30, 40, 50, 60, 70, 80, 90],target = [90, 80, 70, 60, 50, 40, 30, 20, 10],allowedSwaps = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4]]) == 0\n assert candidate(source = [5, 5, 5, 5, 5, 5],target = [5, 5, 5, 5, 5, 5],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 0\n assert candidate(source = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 0\n assert candidate(source = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],allowedSwaps = []) == 10\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 1], [2, 3], [4, 6]]) == 0\n assert candidate(source = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],target = [8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1],allowedSwaps = [[0, 15], [1, 14], [2, 13], [3, 12], [4, 11], [5, 10], [6, 9], [7, 8], [0, 7], [1, 6], [2, 5], [3, 4]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],allowedSwaps = [[0, 1]]) == 9\n assert candidate(source = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1],allowedSwaps = [[0, 4], [1, 3], [2, 8], [5, 7], [6, 9]]) == 8\n assert candidate(source = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]]) == 0\n assert candidate(source = [1, 1, 1, 1, 1, 1, 1, 1],target = [2, 2, 2, 2, 2, 2, 2, 2],allowedSwaps = [[0, 1], [2, 3], [4, 5], [6, 7]]) == 8\n assert candidate(source = [10, 20, 30, 40, 50, 60],target = [60, 20, 50, 40, 30, 10],allowedSwaps = [[0, 5], [2, 4], [0, 2]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = [9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 8], [1, 7], [2, 6], [3, 5]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 0\n assert candidate(source = [10, 20, 30, 40, 50],target = [50, 40, 30, 20, 10],allowedSwaps = [[0, 4], [1, 3], [2, 2]]) == 0\n assert candidate(source = [1, 1, 1, 1, 1, 1],target = [2, 2, 2, 2, 2, 2],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 6\n assert candidate(source = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],allowedSwaps = []) == 0\n assert candidate(source = [7, 8, 9, 10, 11, 12, 13],target = [13, 12, 11, 10, 9, 8, 7],allowedSwaps = [[0, 6], [1, 5], [2, 4], [0, 3]]) == 0\n assert candidate(source = [10, 20, 30, 40, 50],target = [50, 40, 30, 20, 10],allowedSwaps = [[0, 4], [1, 3]]) == 0\n assert candidate(source = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],allowedSwaps = []) == 10\n assert candidate(source = [1, 1, 2, 2, 3, 3],target = [3, 3, 2, 2, 1, 1],allowedSwaps = [[0, 2], [0, 4], [1, 3], [1, 5]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 0\n assert candidate(source = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],allowedSwaps = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == 20\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 7], [1, 6], [2, 5], [3, 4]]) == 0\n assert candidate(source = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],allowedSwaps = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 10\n assert candidate(source = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [1, 5], [2, 6], [3, 7], [0, 8], [1, 9], [2, 5], [3, 6], [4, 7]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],allowedSwaps = [[0, 1], [1, 9], [9, 8]]) == 7\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 1], [2, 3], [4, 6], [7, 8]]) == 0\n assert candidate(source = [3, 2, 1, 4, 5],target = [5, 4, 3, 2, 1],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = [20, 1, 19, 2, 18, 3, 17, 4, 16, 5, 15, 6, 14, 7, 13, 8, 12, 9, 11, 10],allowedSwaps = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 16\n assert candidate(source = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 10\n assert candidate(source = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 0\n assert candidate(source = [4, 1, 3, 2],target = [2, 3, 1, 4],allowedSwaps = [[0, 1], [1, 2], [2, 3], [0, 2], [1, 3]]) == 0\n assert candidate(source = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 1], [2, 3], [4, 6], [7, 8]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],allowedSwaps = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [0, 13], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [0, 13], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7]]) == 0\n assert candidate(source = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],target = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 12\n assert candidate(source = [7, 8, 9, 10, 11, 12],target = [10, 11, 12, 7, 8, 9],allowedSwaps = [[0, 3], [1, 4], [2, 5]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 0\n assert candidate(source = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],allowedSwaps = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 10\n assert candidate(source = [1, 1, 1, 1, 1],target = [1, 1, 1, 1, 1],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [1, 5], [2, 6], [3, 7]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],target = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9],allowedSwaps = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) == 0\n assert candidate(source = [10, 20, 30, 40, 50, 60],target = [60, 50, 40, 30, 20, 10],allowedSwaps = [[0, 5], [1, 4], [2, 3]]) == 0\n assert candidate(source = [1, 1, 2, 2, 3, 3, 4, 4],target = [4, 4, 3, 3, 2, 2, 1, 1],allowedSwaps = [[0, 6], [1, 7], [2, 5], [3, 4]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9],target = [9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 8], [1, 7], [2, 6], [3, 5]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],target = [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 15], [1, 14], [2, 13], [3, 12], [4, 11], [5, 10], [6, 9], [7, 8]]) == 0\n assert candidate(source = [100000, 90000, 80000, 70000],target = [70000, 80000, 90000, 100000],allowedSwaps = [[0, 3], [1, 2], [0, 1], [2, 3]]) == 0\n assert candidate(source = [4, 4, 4, 4, 4],target = [1, 2, 3, 4, 5],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 4\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],allowedSwaps = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [10, 2, 9, 3, 8, 4, 7, 5, 6, 1],allowedSwaps = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == 5\n assert candidate(source = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]]) == 10\n assert candidate(source = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14],target = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5],allowedSwaps = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 1], [2, 3], [4, 8], [5, 7]]) == 0\n assert candidate(source = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],allowedSwaps = []) == 0\n assert candidate(source = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],allowedSwaps = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 10\n"}, "metadata": {"canonical_parameter_names": ["source", "target", "allowedSwaps"], "leetcode_dataset_entry_point": "Solution().minimumHammingDistance", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumHammingDistance(vector& source, vector& target, vector>& allowedSwaps) {", "container": "Solution", "callable": "minimumHammingDistance", "parameters": [{"name": "source", "type": "vector&"}, {"name": "target", "type": "vector&"}, {"name": "allowedSwaps", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1723, "task_id": "find-minimum-time-to-finish-all-jobs", "difficulty": "Hard", "problem_description": "You are given an integer array jobs, where jobs[i] is the amount of time it takes to complete the ith job.\nThere are k workers that you can assign jobs to. Each job should be assigned to exactly one worker. The working time of a worker is the sum of the time it takes to complete all jobs assigned to them. Your goal is to devise an optimal assignment such that the maximum working time of any worker is minimized.\nReturn the minimum possible maximum working time of any assignment. \n \nExample 1:\n\nInput: jobs = [3,2,3], k = 3\nOutput: 3\nExplanation: By assigning each person one job, the maximum time is 3.\n\nExample 2:\n\nInput: jobs = [1,2,4,7,8], k = 2\nOutput: 11\nExplanation: Assign the jobs the following way:\nWorker 1: 1, 2, 8 (working time = 1 + 2 + 8 = 11)\nWorker 2: 4, 7 (working time = 4 + 7 = 11)\nThe maximum working time is 11.\n \nConstraints:\n\n1 <= k <= jobs.length <= 12\n1 <= jobs[i] <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(jobs = [1, 2, 4, 7, 8],k = 2) == 11\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 4) == 20\n assert candidate(jobs = [6, 5, 4, 3, 2, 1],k = 6) == 6\n assert candidate(jobs = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 20\n assert candidate(jobs = [10, 20, 30, 40, 50, 60],k = 3) == 70\n assert candidate(jobs = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 12) == 10\n assert candidate(jobs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 4) == 3\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 6) == 13\n assert candidate(jobs = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],k = 6) == 18\n assert candidate(jobs = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 6) == 10\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 12) == 120\n assert candidate(jobs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 12) == 1\n assert candidate(jobs = [3, 2, 3],k = 3) == 3\n assert candidate(jobs = [5, 5, 3, 2, 4, 1],k = 3) == 7\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 3) == 26\n assert candidate(jobs = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == 15\n assert candidate(jobs = [12, 3, 5, 8, 9, 4, 7, 6, 2, 10, 11, 1],k = 5) == 16\n assert candidate(jobs = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 6) == 100\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 5) == 160\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 7) == 12\n assert candidate(jobs = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000],k = 2) == 39000\n assert candidate(jobs = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, 0],k = 4) == 140\n assert candidate(jobs = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 2) == 18\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 7) == 120\n assert candidate(jobs = [10000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],k = 4) == 10000000\n assert candidate(jobs = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24],k = 4) == 40\n assert candidate(jobs = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],k = 3) == 130\n assert candidate(jobs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 4) == 36\n assert candidate(jobs = [3, 7, 1, 10, 5, 2, 8, 6, 4, 9, 11, 12],k = 5) == 16\n assert candidate(jobs = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],k = 4) == 11\n assert candidate(jobs = [10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000],k = 6) == 20000000\n assert candidate(jobs = [12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12],k = 6) == 24\n assert candidate(jobs = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 1) == 36\n assert candidate(jobs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],k = 5) == 1600\n assert candidate(jobs = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 8) == 12\n assert candidate(jobs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 12) == 23\n assert candidate(jobs = [30, 15, 40, 10, 25, 5, 60, 45, 20, 50, 55, 35],k = 5) == 80\n assert candidate(jobs = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],k = 1) == 12000000\n assert candidate(jobs = [20, 10, 30, 25, 15, 5, 40, 35, 50, 100, 200, 50],k = 3) == 200\n assert candidate(jobs = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14],k = 3) == 28\n assert candidate(jobs = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55],k = 6) == 56\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 4) == 200\n assert candidate(jobs = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],k = 6) == 65\n assert candidate(jobs = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],k = 4) == 38\n assert candidate(jobs = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 6) == 4\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 2) == 390\n assert candidate(jobs = [9, 8, 7, 6, 5, 4, 3, 2, 1, 12, 11, 10],k = 4) == 20\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 2) == 39\n assert candidate(jobs = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84],k = 4) == 140\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 1) == 78\n assert candidate(jobs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],k = 11) == 1200\n assert candidate(jobs = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 7) == 12\n assert candidate(jobs = [1000, 1000, 1000, 1000, 2000, 2000, 2000, 2000, 3000, 3000, 3000, 3000],k = 8) == 3000\n assert candidate(jobs = [30, 20, 10, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 4) == 200\n assert candidate(jobs = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 3) == 8\n assert candidate(jobs = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36],k = 4) == 60\n assert candidate(jobs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 5) == 30\n assert candidate(jobs = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 3) == 12\n assert candidate(jobs = [2, 5, 10, 17, 26, 37, 50, 65, 82, 101, 122, 145],k = 4) == 168\n assert candidate(jobs = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 8) == 4\n assert candidate(jobs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],k = 12) == 1200\n assert candidate(jobs = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000],k = 2) == 39000\n assert candidate(jobs = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84],k = 6) == 91\n assert candidate(jobs = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 6) == 13\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 2) == 390\n assert candidate(jobs = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048],k = 5) == 2048\n assert candidate(jobs = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 12, 11],k = 6) == 13\n assert candidate(jobs = [1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000, 1000, 2000],k = 4) == 5000\n assert candidate(jobs = [7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1],k = 2) == 17\n assert candidate(jobs = [10000000, 10000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 10000000\n assert candidate(jobs = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37],k = 3) == 66\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 3) == 260\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 4) == 200\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 12) == 12\n assert candidate(jobs = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 8) == 20\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 3) == 260\n assert candidate(jobs = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 8) == 14\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 4) == 20\n assert candidate(jobs = [3, 5, 7, 12, 4, 8, 9, 11, 6, 10, 2, 1],k = 3) == 26\n assert candidate(jobs = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3],k = 5) == 11\n assert candidate(jobs = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],k = 3) == 14\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 12) == 120\n assert candidate(jobs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],k = 4) == 36\n assert candidate(jobs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],k = 6) == 1300\n assert candidate(jobs = [10000000, 1000000, 100000, 10000, 1000, 100, 10, 1, 1, 1, 1, 1],k = 7) == 10000000\n assert candidate(jobs = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5],k = 6) == 7\n assert candidate(jobs = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],k = 4) == 11\n assert candidate(jobs = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115],k = 5) == 150\n assert candidate(jobs = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048],k = 3) == 2048\n assert candidate(jobs = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1],k = 5) == 10\n assert candidate(jobs = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 26\n assert candidate(jobs = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, 11],k = 4) == 20\n assert candidate(jobs = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 6) == 14\n assert candidate(jobs = [7, 2, 8, 9, 4, 3, 6, 1, 5, 10, 11, 12],k = 3) == 26\n assert candidate(jobs = [10000000, 1000000, 100000, 10000, 1000, 100, 10, 1, 1, 1, 1, 1],k = 3) == 10000000\n assert candidate(jobs = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 3) == 40\n assert candidate(jobs = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],k = 4) == 8\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 12) == 12\n assert candidate(jobs = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],k = 8) == 60\n assert candidate(jobs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 6) == 130\n assert candidate(jobs = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 5) == 18\n assert candidate(jobs = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],k = 4) == 14\n assert candidate(jobs = [9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 20, 25],k = 5) == 25\n assert candidate(jobs = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],k = 3) == 56\n assert candidate(jobs = [5, 7, 12, 18, 23, 30, 37, 40, 45, 50, 55, 60],k = 3) == 128\n assert candidate(jobs = [10000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],k = 5) == 10000000\n assert candidate(jobs = [10000000, 9000000, 8000000, 7000000, 6000000, 5000000, 4000000, 3000000, 2000000, 1000000, 100000, 10000],k = 6) == 10000000\n assert candidate(jobs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],k = 1) == 78\n assert candidate(jobs = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144],k = 9) == 144\n assert candidate(jobs = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37],k = 5) == 40\n assert candidate(jobs = [10000000, 5000000, 2500000, 1250000, 625000, 312500, 156250, 78125, 39062, 19531, 9765, 4882],k = 3) == 10000000\n"}, "metadata": {"canonical_parameter_names": ["jobs", "k"], "leetcode_dataset_entry_point": "Solution().minimumTimeRequired", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumTimeRequired(vector& jobs, int k) {", "container": "Solution", "callable": "minimumTimeRequired", "parameters": [{"name": "jobs", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1725, "task_id": "number-of-rectangles-that-can-form-the-largest-square", "difficulty": "Easy", "problem_description": "You are given an array rectangles where rectangles[i] = [li, wi] represents the ith rectangle of length li and width wi.\\r\n\\r\nYou can cut the ith rectangle to form a square with a side length of k if both k <= li and k <= wi. For example, if you have a rectangle [4,6], you can cut it to get a square with a side length of at most 4.\\r\n\\r\nLet maxLen be the side length of the largest square you can obtain from any of the given rectangles.\\r\n\\r\nReturn the number of rectangles that can make a square with a side length of maxLen.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: rectangles = [[5,8],[3,9],[5,12],[16,5]]\\r\nOutput: 3\\r\nExplanation: The largest squares you can get from each rectangle are of lengths [5,3,5,5].\\r\nThe largest possible square is of length 5, and you can get it out of 3 rectangles.\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: rectangles = [[2,3],[3,7],[4,3],[3,7]]\\r\nOutput: 3\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= rectangles.length <= 1000\\r\n\trectangles[i].length == 2\\r\n\t1 <= li, wi <= 109\\r\n\tli != wi\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rectangles = [[1, 2], [2, 1], [3, 4], [4, 3]]) == 2\n assert candidate(rectangles = [[2, 3], [3, 7], [4, 3], [3, 7]]) == 3\n assert candidate(rectangles = [[1000000000, 1000000000], [999999999, 999999999], [1, 1]]) == 1\n assert candidate(rectangles = [[5, 8], [3, 9], [5, 12], [16, 5]]) == 3\n assert candidate(rectangles = [[10, 20], [20, 10], [5, 5], [15, 15]]) == 1\n assert candidate(rectangles = [[100, 200], [200, 100], [150, 150], [250, 250], [50, 50], [250, 300], [300, 250], [300, 300], [350, 350]]) == 1\n assert candidate(rectangles = [[7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == 1\n assert candidate(rectangles = [[10, 1], [1, 10], [20, 2], [2, 20], [30, 3], [3, 30], [40, 4], [4, 40], [50, 5], [5, 50]]) == 2\n assert candidate(rectangles = [[9, 1], [8, 2], [7, 3], [6, 4], [5, 5], [4, 6], [3, 7], [2, 8], [1, 9]]) == 1\n assert candidate(rectangles = [[100, 200], [200, 100], [150, 150], [140, 160], [160, 140], [130, 170], [120, 180], [180, 120], [170, 130]]) == 1\n assert candidate(rectangles = [[500000000, 500000000], [400000000, 600000000], [600000000, 400000000], [300000000, 700000000], [700000000, 300000000], [200000000, 800000000], [800000000, 200000000]]) == 1\n assert candidate(rectangles = [[100, 100], [101, 101], [102, 102], [103, 103], [104, 104], [105, 105], [106, 106], [107, 107], [108, 108], [109, 109]]) == 1\n assert candidate(rectangles = [[50, 20], [20, 50], [40, 40], [30, 30], [25, 25], [25, 35], [35, 25], [30, 20]]) == 1\n assert candidate(rectangles = [[5, 10], [10, 5], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == 1\n assert candidate(rectangles = [[8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == 1\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 10], [10, 1]]) == 1\n assert candidate(rectangles = [[999999999, 1], [1, 999999999], [500000000, 500000000], [500000000, 500000000], [500000000, 500000000], [100000000, 100000000], [100000000, 100000000], [100000000, 100000000], [100000000, 100000000]]) == 3\n assert candidate(rectangles = [[5, 5], [5, 4], [4, 5], [3, 3], [2, 2], [1, 1]]) == 1\n assert candidate(rectangles = [[10, 10], [15, 5], [20, 20], [5, 15]]) == 1\n assert candidate(rectangles = [[10, 20], [20, 10], [15, 15], [12, 12], [18, 18], [18, 19], [19, 18]]) == 3\n assert candidate(rectangles = [[1, 999999999], [2, 999999998], [3, 999999997], [4, 999999996], [5, 999999995]]) == 1\n assert candidate(rectangles = [[1, 999999999], [2, 999999998], [3, 999999997], [4, 999999996], [5, 999999995]]) == 1\n assert candidate(rectangles = [[2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2]]) == 20\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 1], [2, 2], [3, 3]]) == 1\n assert candidate(rectangles = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10], [1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10]]) == 1\n assert candidate(rectangles = [[10, 15], [12, 12], [8, 8], [12, 12], [15, 10], [11, 11]]) == 2\n assert candidate(rectangles = [[1000, 999], [999, 1000], [998, 998], [997, 997], [996, 996], [995, 995], [994, 994], [993, 993], [992, 992], [991, 991]]) == 2\n assert candidate(rectangles = [[2, 4], [4, 2], [3, 6], [6, 3], [4, 8], [8, 4], [5, 10], [10, 5], [6, 12], [12, 6], [7, 14], [14, 7], [8, 16], [16, 8], [9, 18], [18, 9], [10, 20], [20, 10]]) == 2\n assert candidate(rectangles = [[100, 200], [200, 100], [150, 150], [250, 250], [250, 200], [200, 250], [300, 300]]) == 1\n assert candidate(rectangles = [[1, 1000000000], [1000000000, 1], [2, 500000000], [500000000, 2]]) == 2\n assert candidate(rectangles = [[3, 1], [1, 3], [4, 2], [2, 4], [5, 3], [3, 5], [6, 4], [4, 6], [7, 5], [5, 7], [8, 6], [6, 8]]) == 2\n assert candidate(rectangles = [[7, 3], [3, 7], [4, 4], [5, 5], [5, 6], [6, 5]]) == 3\n assert candidate(rectangles = [[1, 1000000000], [1000000000, 1], [500000000, 500000000], [1000000000, 1000000000], [500000000, 1000000000]]) == 1\n assert candidate(rectangles = [[10, 20], [20, 10], [15, 15], [12, 12], [8, 8], [8, 12], [12, 8]]) == 1\n assert candidate(rectangles = [[10, 20], [20, 10], [15, 15], [12, 18], [18, 12]]) == 1\n assert candidate(rectangles = [[5, 5], [3, 3], [2, 2], [4, 4], [6, 6], [6, 6], [6, 7], [7, 6]]) == 4\n assert candidate(rectangles = [[500000000, 500000000], [600000000, 600000000], [500000000, 400000000], [400000000, 500000000]]) == 1\n assert candidate(rectangles = [[1000, 1000], [999, 999], [998, 998], [997, 997], [996, 996], [995, 995], [994, 994], [993, 993], [992, 992], [991, 991]]) == 1\n assert candidate(rectangles = [[500, 400], [300, 300], [450, 500], [400, 400], [450, 450], [400, 500]]) == 2\n assert candidate(rectangles = [[1, 1000000000], [1000000000, 1], [500000000, 500000000], [500000000, 500000001], [500000001, 500000000]]) == 3\n assert candidate(rectangles = [[2, 3], [3, 2], [4, 5], [5, 4], [6, 7], [7, 6], [8, 9], [9, 8], [10, 11], [11, 10]]) == 2\n assert candidate(rectangles = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == 3\n assert candidate(rectangles = [[100, 200], [101, 199], [102, 198], [103, 197], [104, 196], [105, 195], [106, 194], [107, 193], [108, 192], [109, 191], [110, 190]]) == 1\n assert candidate(rectangles = [[10, 1], [1, 10], [5, 5], [5, 5], [2, 2]]) == 2\n assert candidate(rectangles = [[10, 20], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19]]) == 1\n assert candidate(rectangles = [[500, 500], [499, 501], [498, 502], [497, 503], [496, 504], [495, 505], [494, 506], [493, 507], [492, 508], [491, 509]]) == 1\n assert candidate(rectangles = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]]) == 1\n assert candidate(rectangles = [[10, 5], [9, 4], [8, 3], [7, 2], [6, 1], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10], [11, 11], [12, 12]]) == 1\n assert candidate(rectangles = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]]) == 20\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]]) == 1\n assert candidate(rectangles = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5]]) == 5\n assert candidate(rectangles = [[8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8]]) == 12\n assert candidate(rectangles = [[1, 1000000000], [1000000000, 1], [2, 999999998], [999999998, 2], [3, 999999996], [999999996, 3], [4, 999999994], [999999994, 4], [5, 999999992], [999999992, 5]]) == 2\n assert candidate(rectangles = [[10, 20], [15, 15], [20, 10], [30, 30], [25, 25]]) == 1\n assert candidate(rectangles = [[300, 400], [400, 300], [250, 250], [250, 250], [250, 250], [250, 250], [100, 100]]) == 2\n assert candidate(rectangles = [[500000000, 500000000], [400000000, 400000000], [300000000, 300000000], [200000000, 200000000], [100000000, 100000000]]) == 1\n assert candidate(rectangles = [[999999999, 1000000000], [1000000000, 999999999], [1, 1000000000], [1000000000, 1], [2, 999999999], [999999999, 2], [3, 999999998], [999999998, 3], [4, 999999997], [999999997, 4]]) == 2\n assert candidate(rectangles = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]]) == 2\n assert candidate(rectangles = [[7, 10], [10, 7], [8, 10], [10, 8], [9, 9], [6, 11], [11, 6], [5, 12], [12, 5], [4, 13], [13, 4]]) == 1\n assert candidate(rectangles = [[10, 20], [20, 10], [15, 15], [25, 25], [5, 5], [25, 30], [30, 25]]) == 3\n assert candidate(rectangles = [[2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 1\n assert candidate(rectangles = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [100, 100], [200, 200], [300, 300]]) == 1\n assert candidate(rectangles = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]]) == 15\n assert candidate(rectangles = [[100, 200], [50, 50], [50, 50], [75, 75], [75, 75], [75, 75]]) == 1\n assert candidate(rectangles = [[2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8], [10, 9], [11, 10], [12, 11], [13, 12], [1, 12], [12, 1]]) == 1\n assert candidate(rectangles = [[1000, 1000], [999, 1001], [1001, 999], [1002, 1002], [1003, 1003], [1004, 1004]]) == 1\n assert candidate(rectangles = [[500000000, 1000000000], [1000000000, 500000000], [300000000, 300000000], [200000000, 200000000]]) == 2\n assert candidate(rectangles = [[11, 12], [12, 11], [13, 14], [14, 13], [15, 16], [16, 15], [17, 18], [18, 17], [19, 20], [20, 19]]) == 2\n assert candidate(rectangles = [[10, 20], [20, 10], [15, 15], [15, 15], [15, 15], [5, 5], [5, 5], [5, 5], [5, 5]]) == 3\n assert candidate(rectangles = [[10, 20], [20, 10], [30, 40], [40, 30], [50, 60], [60, 50], [70, 80], [80, 70], [90, 100], [100, 90]]) == 2\n assert candidate(rectangles = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]]) == 1\n assert candidate(rectangles = [[200000000, 200000000], [199999999, 200000001], [199999998, 200000002], [199999997, 200000003], [199999996, 200000004]]) == 1\n assert candidate(rectangles = [[20, 20], [19, 19], [18, 18], [17, 17], [16, 16], [15, 15], [14, 14], [13, 13], [12, 12], [11, 11], [10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == 1\n assert candidate(rectangles = [[50, 70], [70, 50], [60, 60], [40, 80], [80, 40]]) == 1\n assert candidate(rectangles = [[999999999, 1000000000], [1000000000, 999999999], [999999998, 999999998], [1000000001, 1000000001], [999999997, 999999997]]) == 1\n assert candidate(rectangles = [[15, 20], [20, 15], [25, 30], [30, 25], [35, 40], [40, 35], [45, 50], [50, 45]]) == 2\n assert candidate(rectangles = [[5, 10], [10, 5], [15, 20], [20, 15], [25, 30], [30, 25], [35, 40], [40, 35]]) == 2\n assert candidate(rectangles = [[1000000000, 1000000000], [999999999, 999999999], [999999998, 999999998], [999999997, 999999997], [999999996, 999999996]]) == 1\n assert candidate(rectangles = [[3, 4], [4, 3], [5, 5], [5, 5], [5, 5], [5, 6], [6, 5], [6, 6], [6, 6], [6, 6], [7, 7], [7, 7], [7, 7], [7, 7], [7, 7], [7, 8], [8, 7], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8], [8, 8]]) == 7\n assert candidate(rectangles = [[10, 20], [20, 10], [15, 15], [14, 16], [16, 14], [13, 17]]) == 1\n assert candidate(rectangles = [[10, 10], [9, 11], [11, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2]]) == 1\n assert candidate(rectangles = [[1000000000, 1], [1000000000, 2], [1000000000, 3], [1000000000, 4], [1000000000, 5]]) == 1\n assert candidate(rectangles = [[8, 9], [9, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == 2\n"}, "metadata": {"canonical_parameter_names": ["rectangles"], "leetcode_dataset_entry_point": "Solution().countGoodRectangles", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countGoodRectangles(vector>& rectangles) {", "container": "Solution", "callable": "countGoodRectangles", "parameters": [{"name": "rectangles", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1726, "task_id": "tuple-with-same-product", "difficulty": "Medium", "problem_description": "Given an array nums of distinct positive integers, return the number of tuples (a, b, c, d) such that a * b = c * d where a, b, c, and d are elements of nums, and a != b != c != d.\n \nExample 1:\n\nInput: nums = [2,3,4,6]\nOutput: 8\nExplanation: There are 8 valid tuples:\n(2,6,3,4) , (2,6,4,3) , (6,2,3,4) , (6,2,4,3)\n(3,4,2,6) , (4,3,2,6) , (3,4,6,2) , (4,3,6,2)\n\nExample 2:\n\nInput: nums = [1,2,4,5,10]\nOutput: 16\nExplanation: There are 16 valid tuples:\n(1,10,2,5) , (1,10,5,2) , (10,1,2,5) , (10,1,5,2)\n(2,5,1,10) , (2,5,10,1) , (5,2,1,10) , (5,2,10,1)\n(2,10,4,5) , (2,10,5,4) , (10,2,4,5) , (10,2,5,4)\n(4,5,2,10) , (4,5,10,2) , (5,4,2,10) , (5,4,10,2)\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n1 <= nums[i] <= 104\nAll elements in nums are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 16\n assert candidate(nums = [7, 8, 9, 14, 21]) == 0\n assert candidate(nums = [7, 11, 13, 19, 23, 29, 31]) == 0\n assert candidate(nums = [2, 5, 10, 15, 20]) == 0\n assert candidate(nums = [2, 4, 8, 16, 32, 64]) == 56\n assert candidate(nums = [7, 8, 14, 21]) == 0\n assert candidate(nums = [2, 3, 4, 6]) == 8\n assert candidate(nums = [8, 12, 16, 20, 24]) == 8\n assert candidate(nums = [1, 2, 4, 5, 10]) == 16\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 72\n assert candidate(nums = [1, 10, 100, 1000]) == 8\n assert candidate(nums = [2, 3, 5, 7, 11, 13]) == 0\n assert candidate(nums = [10, 20, 30, 60]) == 8\n assert candidate(nums = [1, 3, 5, 7, 9, 11]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 72\n assert candidate(nums = [10, 15, 20, 30, 40, 50, 60, 75, 100, 150, 200, 300, 500, 1000]) == 600\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140]) == 536\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 72\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 72\n assert candidate(nums = [1, 3, 9, 27, 81, 243, 729]) == 104\n assert candidate(nums = [1, 6, 9, 18, 27, 54, 81]) == 48\n assert candidate(nums = [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049]) == 560\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120]) == 784\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 136\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240]) == 1664\n assert candidate(nums = [3, 5, 15, 25, 45, 75, 125, 150, 225, 250, 375, 500, 625, 750, 1125, 1250, 1875, 2500, 3125, 3750, 5625, 6250, 9375, 12500, 18750, 31250, 93750]) == 4624\n assert candidate(nums = [3, 6, 9, 12, 18, 27, 36, 54, 72, 108]) == 256\n assert candidate(nums = [10, 20, 40, 50, 80, 100, 160, 200, 250, 400, 500, 800, 1000, 1600, 2000, 2500, 4000, 5000, 8000, 10000]) == 2784\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]) == 184\n assert candidate(nums = [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683]) == 400\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225]) == 248\n assert candidate(nums = [5, 10, 15, 25, 50, 75, 125, 250, 375, 625]) == 176\n assert candidate(nums = [12, 15, 20, 25, 30, 60, 100, 150]) == 40\n assert candidate(nums = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90]) == 240\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 136\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683]) == 272\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220]) == 536\n assert candidate(nums = [2, 6, 12, 18, 36, 72, 108, 216, 324, 432, 648, 1296]) == 472\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 400\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969]) == 1288\n assert candidate(nums = [13, 169, 182, 221, 260, 299, 338, 416, 507, 520, 598, 754, 780, 952, 1098, 1170, 1232, 1300, 1595, 1638, 1904, 2196, 2340, 2600, 3190, 3276, 3808, 4392, 4680, 5200, 6380, 6552, 7616, 8784, 9360, 10400, 12760, 13104, 15232, 17568, 18720, 20800, 25520, 26208, 30464, 35136, 37440, 41600, 51040, 52416, 60928, 70272, 74880, 83200, 102080, 104832, 121856, 140544, 149760, 166400, 204160, 209664, 243712, 281088, 299520, 332800, 408320, 419328, 487424, 562176, 599040, 665600, 816640, 838656, 974848, 1124352, 1198080, 1331200, 1633280, 1677312, 1949696, 2248704, 2396160, 2662400, 3266560, 3354624, 3899392, 4497408, 4792320, 5324800, 6533120, 6709248, 7798784, 8994816, 9584640, 10649600, 13066240, 13418496, 15597568, 17989632, 19169280, 21299200, 26132480, 26836992, 31195136, 35979264, 38338560, 42598400, 52264960, 53673984, 62390272, 71958528, 76677120, 85196800, 104529920, 107347968, 124780544, 143917056, 153354240, 170393600, 209059840, 214695936, 249561088, 287834112, 306708480, 340787200, 418119680, 429391872, 499122176, 575668224, 613416960, 681574400, 836239360, 858783744, 998244352, 1151336448, 1226833920, 1363148800]) == 359800\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 400\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 32, 48, 64]) == 112\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120]) == 248\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]) == 0\n assert candidate(nums = [2, 5, 10, 25, 50, 125, 250, 625, 1250, 3125, 6250]) == 400\n assert candidate(nums = [1, 2, 3, 4, 6, 8, 12, 24]) == 128\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323, 4782969, 14348907]) == 1624\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132]) == 136\n assert candidate(nums = [1, 3, 9, 27, 81, 243, 729]) == 104\n assert candidate(nums = [1, 2, 3, 4, 6, 8, 12, 24]) == 128\n assert candidate(nums = [2, 3, 6, 12, 24, 48, 96, 192, 384, 768]) == 272\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175]) == 968\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 72\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96]) == 304\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100]) == 968\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625]) == 968\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209]) == 408\n assert candidate(nums = [2, 3, 5, 6, 10, 15, 30]) == 48\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154]) == 184\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 2464\n assert candidate(nums = [12, 15, 20, 24, 30, 36, 40, 45, 48, 60, 72, 80, 90, 120, 144, 180, 240, 360, 720]) == 1592\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049]) == 400\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220, 231, 242, 253, 264, 275, 286, 297, 308, 319, 330, 341, 352, 363, 374, 385, 396, 407, 418, 429, 440, 451, 462, 473, 484, 495]) == 4592\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168, 174, 180]) == 1664\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 60, 100]) == 56\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == 536\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 248\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 1288\n assert candidate(nums = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230, 253, 276, 299, 322, 345, 368, 391, 414, 437, 460, 483, 506, 529, 552, 575, 598, 621, 644, 667, 690, 713, 736, 759, 782, 805, 828, 851, 874, 897, 920, 943, 966, 989, 1012]) == 4200\n assert candidate(nums = [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683]) == 400\n assert candidate(nums = [10, 15, 30, 45, 60, 90, 120, 135, 180, 225]) == 144\n assert candidate(nums = [1, 5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625, 48828125, 244140625]) == 1000\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260]) == 536\n assert candidate(nums = [5, 10, 15, 25, 50, 75, 125, 250, 375, 625]) == 176\n assert candidate(nums = [12, 15, 18, 20, 24, 30, 36, 40, 45, 48, 60, 72, 80, 90, 120, 144, 150, 180, 200, 240, 300, 360, 400, 450, 720, 900]) == 4112\n assert candidate(nums = [5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625]) == 400\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75]) == 968\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561]) == 176\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == 248\n assert candidate(nums = [5, 10, 15, 20, 25, 50, 100, 200]) == 72\n assert candidate(nums = [5, 10, 15, 20, 25, 50, 75, 100]) == 64\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98]) == 184\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 20, 24, 30, 40, 60, 120]) == 1168\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60]) == 72\n assert candidate(nums = [2, 5, 10, 20, 25, 50, 100, 125, 250, 500, 1000, 2500, 5000]) == 608\n assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190, 209, 228, 247, 266, 285, 304, 323, 342, 361, 380, 399, 418, 437, 456, 475, 494, 513, 532, 551, 570, 589, 608, 627, 646, 665, 684, 703, 722, 741, 760]) == 3432\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132]) == 136\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 560\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608]) == 4920\n assert candidate(nums = [29, 58, 87, 116, 145, 174, 203, 232, 261, 290, 319, 348, 377, 406, 435, 464, 493, 522, 551, 580, 609, 638, 667, 696, 725, 754, 783, 812, 841, 870, 899, 928, 957, 986, 1015, 1044, 1073, 1102, 1131, 1160, 1189, 1218, 1247, 1276, 1305, 1334, 1363, 1392, 1421, 1450, 1479, 1508, 1537, 1566, 1595, 1624]) == 7912\n assert candidate(nums = [2, 5, 10, 20, 25, 50, 100, 125, 200, 250, 500, 1000]) == 472\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208]) == 304\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255, 272, 289, 306, 323, 340, 357, 374, 391, 408, 425]) == 968\n assert candidate(nums = [2, 5, 10, 20, 25, 50, 100, 125, 200, 250, 500, 1000, 1250, 2000, 2500, 5000, 10000]) == 1584\n assert candidate(nums = [12, 18, 24, 36, 48, 72, 96, 144, 216, 288, 432, 576, 720, 864, 1152, 1728, 2160, 2592, 3456, 4320]) == 1840\n assert candidate(nums = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 3552\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192]) == 1000\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049]) == 400\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260, 273, 286, 299, 312, 325, 338, 351, 364, 377, 390]) == 1664\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255, 272, 289, 306, 323, 340]) == 536\n assert candidate(nums = [2, 5, 10, 25, 50, 125, 250, 625]) == 128\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60]) == 248\n assert candidate(nums = [5, 10, 15, 20, 25, 50, 100, 200]) == 72\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().tupleSameProduct", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int tupleSameProduct(vector& nums) {", "container": "Solution", "callable": "tupleSameProduct", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1727, "task_id": "largest-submatrix-with-rearrangements", "difficulty": "Medium", "problem_description": "You are given a binary matrix matrix of size m x n, and you are allowed to rearrange the columns of the matrix in any order.\nReturn the area of the largest submatrix within matrix where every element of the submatrix is 1 after reordering the columns optimally.\n \nExample 1:\n\n\nInput: matrix = [[0,0,1],[1,1,1],[1,0,1]]\nOutput: 4\nExplanation: You can rearrange the columns as shown above.\nThe largest submatrix of 1s, in bold, has an area of 4.\n\nExample 2:\n\n\nInput: matrix = [[1,0,1,0,1]]\nOutput: 3\nExplanation: You can rearrange the columns as shown above.\nThe largest submatrix of 1s, in bold, has an area of 3.\n\nExample 3:\n\nInput: matrix = [[1,1,0],[1,0,1]]\nOutput: 2\nExplanation: Notice that you must rearrange entire columns, and there is no way to make a submatrix of 1s larger than an area of 2.\n\n \nConstraints:\n\nm == matrix.length\nn == matrix[i].length\n1 <= m * n <= 105\nmatrix[i][j] is either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[0, 1], [1, 0]]) == 1\n assert candidate(matrix = [[1, 1, 0], [1, 0, 1]]) == 2\n assert candidate(matrix = [[0, 0, 1], [1, 1, 1], [1, 0, 1]]) == 4\n assert candidate(matrix = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 12\n assert candidate(matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(matrix = [[1, 0, 1, 0, 1]]) == 3\n assert candidate(matrix = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 9\n assert candidate(matrix = [[1, 1, 1, 1], [1, 0, 1, 0], [1, 1, 1, 0]]) == 6\n assert candidate(matrix = [[1, 1, 0, 0, 1, 1], [1, 0, 1, 1, 0, 1], [0, 1, 1, 0, 1, 1], [1, 1, 0, 1, 1, 0], [0, 0, 1, 1, 0, 1]]) == 4\n assert candidate(matrix = [[1, 0, 1, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 12\n assert candidate(matrix = [[1, 1, 1, 0, 0], [0, 0, 1, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 4\n assert candidate(matrix = [[1, 0, 0, 0, 0, 0, 1, 0, 1, 1], [0, 1, 1, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 15\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 20\n assert candidate(matrix = [[1, 1, 1, 0, 1, 1, 1], [0, 1, 1, 1, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1]]) == 9\n assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 1], [0, 1, 1, 1], [1, 1, 1, 1]]) == 6\n assert candidate(matrix = [[1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0], [0, 1, 1, 0, 1, 1], [1, 0, 0, 1, 0, 1]]) == 4\n assert candidate(matrix = [[1, 0, 1, 0, 1, 1], [1, 1, 1, 0, 1, 0], [1, 0, 1, 1, 1, 1]]) == 9\n assert candidate(matrix = [[1, 1, 1, 1], [1, 0, 0, 0], [1, 1, 0, 1], [0, 0, 1, 1], [1, 1, 1, 1]]) == 4\n assert candidate(matrix = [[1, 1, 0, 0, 1, 1, 1], [1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 1, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 0, 0]]) == 8\n assert candidate(matrix = [[1, 1, 1, 0, 0], [0, 0, 1, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 0, 1, 1]]) == 4\n assert candidate(matrix = [[1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 1, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 1, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1]]) == 5\n assert candidate(matrix = [[1, 1, 1, 0, 0], [0, 1, 1, 1, 0], [1, 0, 1, 1, 1]]) == 4\n assert candidate(matrix = [[0, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 16\n assert candidate(matrix = [[1, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 0, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 0, 1, 1, 1]]) == 12\n assert candidate(matrix = [[1, 1, 1, 1, 0], [1, 0, 1, 1, 1], [1, 1, 0, 1, 1], [1, 1, 1, 1, 1]]) == 9\n assert candidate(matrix = [[1, 0, 0, 1, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 1], [1, 1, 1, 0, 1]]) == 9\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 1, 0, 1, 1], [1, 0, 1, 1, 1], [0, 0, 1, 1, 1], [1, 1, 1, 1, 1]]) == 10\n assert candidate(matrix = [[1, 1, 1, 0, 0, 1], [0, 1, 1, 1, 1, 0], [1, 1, 0, 1, 1, 1], [1, 0, 1, 0, 1, 0]]) == 6\n assert candidate(matrix = [[1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1], [1, 1, 1, 1, 1, 1], [0, 1, 1, 0, 0, 1]]) == 6\n assert candidate(matrix = [[0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1]]) == 4\n assert candidate(matrix = [[0, 1, 1, 1], [1, 1, 0, 1], [1, 0, 1, 1], [1, 1, 1, 0]]) == 4\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 0, 0, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 12\n assert candidate(matrix = [[1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1, 1]]) == 6\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == 9\n assert candidate(matrix = [[1, 1, 0, 0, 1, 1], [0, 1, 1, 1, 1, 0], [1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 0, 1]]) == 5\n assert candidate(matrix = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 15\n assert candidate(matrix = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 1, 1], [1, 1, 1, 1, 1]]) == 9\n assert candidate(matrix = [[1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1]]) == 6\n assert candidate(matrix = [[1, 1, 1, 0, 1], [0, 1, 1, 1, 1], [1, 1, 0, 1, 1], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1]]) == 9\n assert candidate(matrix = [[0, 1, 1, 0], [1, 1, 1, 1], [1, 0, 1, 1]]) == 6\n assert candidate(matrix = [[0, 0, 0, 0], [0, 1, 1, 0], [1, 1, 1, 1], [0, 1, 1, 0], [1, 1, 1, 1]]) == 8\n assert candidate(matrix = [[0, 0, 1, 1], [1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 0]]) == 4\n assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 5\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1], [1, 0, 1, 1, 1, 0], [1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1]]) == 10\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 0], [0, 1, 1, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 10\n assert candidate(matrix = [[1, 1, 0, 0, 1], [0, 1, 1, 1, 1], [1, 0, 1, 1, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]]) == 9\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 30\n assert candidate(matrix = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == 1\n assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 6\n assert candidate(matrix = [[1, 1, 1, 1], [1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 0]]) == 6\n assert candidate(matrix = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 3\n assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 4\n assert candidate(matrix = [[1, 0, 0, 1], [0, 1, 1, 0], [1, 1, 1, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == 4\n assert candidate(matrix = [[1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 1, 0, 1, 1], [1, 0, 1, 0, 1], [0, 1, 1, 1, 0]]) == 6\n assert candidate(matrix = [[1, 1, 1, 0, 0], [1, 1, 1, 0, 0], [0, 1, 1, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 1, 1]]) == 6\n assert candidate(matrix = [[0, 0, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 0, 1], [0, 1, 1, 1, 1]]) == 9\n assert candidate(matrix = [[0, 0, 0, 1, 1, 1], [0, 1, 1, 0, 1, 0], [1, 0, 1, 0, 0, 1], [1, 1, 1, 1, 0, 0]]) == 4\n assert candidate(matrix = [[1, 1, 1], [1, 0, 1], [1, 1, 1], [1, 0, 1], [1, 1, 1], [1, 0, 1]]) == 12\n assert candidate(matrix = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1], [0, 0, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 12\n assert candidate(matrix = [[1, 1, 0, 1, 0, 1], [0, 1, 1, 1, 1, 0], [1, 0, 1, 0, 1, 1], [0, 1, 1, 1, 0, 1], [1, 1, 1, 1, 1, 0], [0, 0, 0, 1, 1, 1], [1, 1, 0, 1, 1, 1]]) == 6\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 0, 1]]) == 6\n assert candidate(matrix = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == 3\n assert candidate(matrix = [[1, 0, 1, 1, 1], [1, 1, 1, 0, 1], [0, 1, 1, 1, 1]]) == 6\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 10\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 9\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 8\n assert candidate(matrix = [[1, 0, 1, 1], [0, 1, 0, 1], [1, 1, 0, 0], [1, 1, 1, 1]]) == 4\n assert candidate(matrix = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 20\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 12\n assert candidate(matrix = [[1, 0, 0, 1, 1], [1, 1, 1, 1, 0], [0, 1, 1, 1, 1], [1, 1, 0, 1, 1]]) == 6\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 1, 0, 0, 0, 0, 0, 1, 1, 1], [1, 1, 1, 0, 0, 0, 1, 1, 1, 1]]) == 10\n assert candidate(matrix = [[0, 1, 1, 1, 0], [1, 1, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]]) == 4\n assert candidate(matrix = [[1, 1, 1, 1, 1], [0, 1, 1, 1, 1], [1, 0, 1, 1, 1], [1, 1, 0, 1, 1], [1, 1, 1, 0, 1]]) == 9\n assert candidate(matrix = [[0, 0, 0, 1, 1], [1, 1, 1, 1, 1], [0, 1, 0, 1, 1], [1, 0, 1, 0, 1]]) == 6\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1]]) == 12\n assert candidate(matrix = [[1, 1, 1, 1], [1, 0, 1, 0], [0, 1, 1, 1], [1, 1, 0, 1]]) == 4\n assert candidate(matrix = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0]]) == 7\n assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1]]) == 9\n assert candidate(matrix = [[1, 1, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 1, 1], [1, 0, 1, 0]]) == 4\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 1, 0, 0, 1], [1, 1, 1, 0, 1], [1, 0, 1, 1, 1]]) == 10\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1], [1, 0, 1, 1, 1, 1], [1, 1, 0, 1, 1, 1], [1, 1, 1, 0, 1, 1], [1, 1, 1, 1, 0, 1]]) == 12\n assert candidate(matrix = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 5\n assert candidate(matrix = [[0, 0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 1, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0, 1, 0], [1, 0, 0, 1, 0, 1, 0, 1]]) == 5\n"}, "metadata": {"canonical_parameter_names": ["matrix"], "leetcode_dataset_entry_point": "Solution().largestSubmatrix", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int largestSubmatrix(vector>& matrix) {", "container": "Solution", "callable": "largestSubmatrix", "parameters": [{"name": "matrix", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1728, "task_id": "cat-and-mouse-ii", "difficulty": "Hard", "problem_description": "A game is played by a cat and a mouse named Cat and Mouse.\nThe environment is represented by a grid of size rows x cols, where each element is a wall, floor, player (Cat, Mouse), or food.\n\nPlayers are represented by the characters 'C'(Cat),'M'(Mouse).\nFloors are represented by the character '.' and can be walked on.\nWalls are represented by the character '#' and cannot be walked on.\nFood is represented by the character 'F' and can be walked on.\nThere is only one of each character 'C', 'M', and 'F' in grid.\n\nMouse and Cat play according to the following rules:\n\nMouse moves first, then they take turns to move.\nDuring each turn, Cat and Mouse can jump in one of the four directions (left, right, up, down). They cannot jump over the wall nor outside of the grid.\ncatJump, mouseJump are the maximum lengths Cat and Mouse can jump at a time, respectively. Cat and Mouse can jump less than the maximum length.\nStaying in the same position is allowed.\nMouse can jump over Cat.\n\nThe game can end in 4 ways:\n\nIf Cat occupies the same position as Mouse, Cat wins.\nIf Cat reaches the food first, Cat wins.\nIf Mouse reaches the food first, Mouse wins.\nIf Mouse cannot get to the food within 1000 turns, Cat wins.\n\nGiven a rows x cols matrix grid and two integers catJump and mouseJump, return true if Mouse can win the game if both Cat and Mouse play optimally, otherwise return false.\n \nExample 1:\n\n\nInput: grid = [\"####F\",\"#C...\",\"M....\"], catJump = 1, mouseJump = 2\nOutput: true\nExplanation: Cat cannot catch Mouse on its turn nor can it get the food before Mouse.\n\nExample 2:\n\n\nInput: grid = [\"M.C...F\"], catJump = 1, mouseJump = 4\nOutput: true\n\nExample 3:\n\nInput: grid = [\"M.C...F\"], catJump = 1, mouseJump = 3\nOutput: false\n\n \nConstraints:\n\nrows == grid.length\ncols = grid[i].length\n1 <= rows, cols <= 8\ngrid[i][j] consist only of characters 'C', 'M', 'F', '.', and '#'.\nThere is only one of each character 'C', 'M', and 'F' in grid.\n1 <= catJump, mouseJump <= 8\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = ['...M.', '.F#C.', '.....'],catJump = 2,mouseJump = 2) == True\n assert candidate(grid = ['M....', '.....', 'C.F..'],catJump = 1,mouseJump = 1) == False\n assert candidate(grid = ['C.......', '........', '........', '........', '........', '........', '........', '.......M'],catJump = 5,mouseJump = 5) == False\n assert candidate(grid = ['M......', '#F.C.#.'],catJump = 2,mouseJump = 3) == False\n assert candidate(grid = ['M....', '.F.C.', '.....'],catJump = 1,mouseJump = 1) == True\n assert candidate(grid = ['M....', '.#C..', '..#F.', '.....'],catJump = 3,mouseJump = 1) == False\n assert candidate(grid = ['M....', '.....', '.F.C.'],catJump = 1,mouseJump = 1) == False\n assert candidate(grid = ['M.C...F'],catJump = 1,mouseJump = 4) == True\n assert candidate(grid = ['####F', '#C...', 'M....'],catJump = 1,mouseJump = 2) == True\n assert candidate(grid = ['M......', '.......', '..F....', '....C..'],catJump = 3,mouseJump = 4) == True\n assert candidate(grid = ['MC..F', '.....', '.....'],catJump = 2,mouseJump = 2) == False\n assert candidate(grid = ['M.C...F'],catJump = 1,mouseJump = 3) == False\n assert candidate(grid = ['M...F', '#..C.', '......'],catJump = 2,mouseJump = 1) == False\n assert candidate(grid = ['MC..F', '#####'],catJump = 2,mouseJump = 2) == False\n assert candidate(grid = ['.......', '.#....#', '.#....#', '.#.....', '.#....#', '.#....#', 'C......'],catJump = 5,mouseJump = 3) == True\n assert candidate(grid = ['M...', '....', '#...', 'C.F.'],catJump = 1,mouseJump = 3) == True\n assert candidate(grid = ['M....', '.....', '#C.F.', '.....', '.....'],catJump = 3,mouseJump = 2) == False\n assert candidate(grid = ['M...#', '...C.', '.....', '.....', '..F..'],catJump = 2,mouseJump = 2) == True\n assert candidate(grid = ['M....', '.....', '.....', '..C..', '...F.'],catJump = 1,mouseJump = 4) == True\n assert candidate(grid = ['M.....', '......', '......', '......', '......', '......', '...F..', '....C.'],catJump = 4,mouseJump = 2) == False\n assert candidate(grid = ['M...F', '.#C.#', '...#.', '.....', '....#'],catJump = 2,mouseJump = 3) == True\n assert candidate(grid = ['M......', '.......', '.......', '....#..', '....C..', '.......', '....F..'],catJump = 4,mouseJump = 2) == False\n assert candidate(grid = ['M....', '.....', '.....', '...C.', '..#F.'],catJump = 1,mouseJump = 1) == False\n assert candidate(grid = ['M......', '.......', '.......', '......#', '....C..', '.......', '....F..'],catJump = 2,mouseJump = 4) == False\n assert candidate(grid = ['M......', '.......', '.....#C', '......#', '.......', '#F.....', '.......'],catJump = 3,mouseJump = 3) == True\n assert candidate(grid = ['.......', '.M.....', '.#C..#.', '.#F..#.', '.#.....', '.#.....', '.......'],catJump = 4,mouseJump = 2) == False\n assert candidate(grid = ['M.......', '........', '........', '........', '........', '.....C..', '........', '........', '.......F'],catJump = 4,mouseJump = 4) == False\n assert candidate(grid = ['M...F', '..#C.', '.....', '.....', '.....'],catJump = 1,mouseJump = 1) == False\n assert candidate(grid = ['M........', '........#', '.........', '#........', '........C', '.........', '.......F.'],catJump = 7,mouseJump = 2) == False\n assert candidate(grid = ['.......', '.#....#', '.#....#', '.#C.M#.', '.#....#', '.#....#', '.......'],catJump = 3,mouseJump = 3) == False\n assert candidate(grid = ['M......', '.#....#', '..#F...', '#......', '......C'],catJump = 4,mouseJump = 1) == False\n assert candidate(grid = ['######', '#M...#', '#.#F#.', '#.....', '######'],catJump = 2,mouseJump = 3) == False\n assert candidate(grid = ['M.......', '........', '.####...', '.....#..', '......#F', '........', '........', '.....C..'],catJump = 2,mouseJump = 1) == False\n assert candidate(grid = ['M......', '.......', '.......', '......#', '....C..', '.......', '....F..'],catJump = 4,mouseJump = 2) == False\n assert candidate(grid = ['M........', '.........', '.........', '.........', '.........', '.........', '......C..', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', 'F........'],catJump = 7,mouseJump = 7) == True\n assert candidate(grid = ['M....', '.....', '...C.', '#####', '....F'],catJump = 2,mouseJump = 1) == False\n assert candidate(grid = ['M....', '.....', '.....', '.....', '#....', 'C....', '..F..'],catJump = 4,mouseJump = 3) == False\n assert candidate(grid = ['M....', '.....', '....C', '....F', '.....'],catJump = 1,mouseJump = 1) == False\n assert candidate(grid = ['M........', '.........', '.........', '.........', '.........', '.........', '........C', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', 'F........'],catJump = 5,mouseJump = 5) == True\n assert candidate(grid = ['M.....', '......', '......', '......', '......', '......', '...F..', '..C...'],catJump = 4,mouseJump = 2) == False\n assert candidate(grid = ['M....#.', '.#....#', '.#....#', '.#.....', '.#....#', '.#....#', '.F....C'],catJump = 3,mouseJump = 4) == False\n assert candidate(grid = ['M....', '.#C..', '..#F.', '.....'],catJump = 3,mouseJump = 2) == False\n assert candidate(grid = ['.......', '.......', '.......', '...C...', '...M...', '.......', '...F...'],catJump = 5,mouseJump = 5) == True\n assert candidate(grid = ['M..#....', '......#.', '......#C', '......#.', '......#.', '......F.', '........'],catJump = 3,mouseJump = 3) == False\n assert candidate(grid = ['M....', '.####', '..F..', '....C'],catJump = 2,mouseJump = 1) == False\n assert candidate(grid = ['M....F...', '.#..#....', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........'],catJump = 1,mouseJump = 1) == False\n assert candidate(grid = ['M.F....', '......C', '......#', '........', '........'],catJump = 3,mouseJump = 2) == True\n assert candidate(grid = ['M....', '.####', '..F..', '....C'],catJump = 1,mouseJump = 1) == False\n assert candidate(grid = ['M........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', 'F........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', 'C........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........'],catJump = 8,mouseJump = 8) == False\n assert candidate(grid = ['M....', '.....', '.F.C.', '.....', '.....'],catJump = 3,mouseJump = 3) == False\n assert candidate(grid = ['M....', '#....', '..C..', '....F', '.....'],catJump = 2,mouseJump = 2) == False\n assert candidate(grid = ['.......', '.#....#', '.#....#', '.#.....', '.#....#', '.#....#', 'F......'],catJump = 3,mouseJump = 3) == False\n assert candidate(grid = ['M......', '.......', '.......', '....C..', '.......', '.......', '......F'],catJump = 2,mouseJump = 3) == False\n assert candidate(grid = ['.........', '.........', '.........', '.........', '........C', '........M', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', '.........', 'F........'],catJump = 6,mouseJump = 6) == True\n assert candidate(grid = ['M.......', '........', '........', '...F....', '........', '........', '........', '.......C'],catJump = 6,mouseJump = 2) == False\n assert candidate(grid = ['M....', '#..C.', '...#F', '....#', '.....'],catJump = 2,mouseJump = 2) == False\n assert candidate(grid = ['M....', '.....', '#....', '..C..', '...F.'],catJump = 3,mouseJump = 1) == False\n"}, "metadata": {"canonical_parameter_names": ["grid", "catJump", "mouseJump"], "leetcode_dataset_entry_point": "Solution().canMouseWin", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool canMouseWin(vector& grid, int catJump, int mouseJump) {", "container": "Solution", "callable": "canMouseWin", "parameters": [{"name": "grid", "type": "vector&"}, {"name": "catJump", "type": "int"}, {"name": "mouseJump", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1732, "task_id": "find-the-highest-altitude", "difficulty": "Easy", "problem_description": "There is a biker going on a road trip. The road trip consists of n + 1 points at different altitudes. The biker starts his trip on point 0 with altitude equal 0.\nYou are given an integer array gain of length n where gain[i] is the net gain in altitude between points i​​​​​​ and i + 1 for all (0 <= i < n). Return the highest altitude of a point.\n \nExample 1:\n\nInput: gain = [-5,1,5,0,-7]\nOutput: 1\nExplanation: The altitudes are [0,-5,-4,1,1,-6]. The highest is 1.\n\nExample 2:\n\nInput: gain = [-4,-3,-2,-1,4,3,2]\nOutput: 0\nExplanation: The altitudes are [0,-4,-7,-9,-10,-6,-3,-1]. The highest is 0.\n\n \nConstraints:\n\nn == gain.length\n1 <= n <= 100\n-100 <= gain[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(gain = [4, 3, 2, 1, 0, -1, -2, -3, -4]) == 10\n assert candidate(gain = [-1, -2, -3, -4]) == 0\n assert candidate(gain = [-10, -20, -30, -40, -50]) == 0\n assert candidate(gain = [1, 2, 3, 4, 5, 6, 7, 8, 9, 100]) == 145\n assert candidate(gain = [-1, 1, -1, 1, -1, 1]) == 0\n assert candidate(gain = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(gain = [-5, -4, -3, -2, -1]) == 0\n assert candidate(gain = [5, 5, 5, 5]) == 20\n assert candidate(gain = [-100, 50, -50, 100, -100]) == 0\n assert candidate(gain = [-100, 100, -100, 100, -100]) == 0\n assert candidate(gain = [100, -100, 100, -100, 100]) == 100\n assert candidate(gain = [1, 2, 3, 4, 5]) == 15\n assert candidate(gain = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -100]) == 0\n assert candidate(gain = [-1, -2, -3, -4, -5]) == 0\n assert candidate(gain = [1, -1, 1, -1, 1, -1]) == 1\n assert candidate(gain = [-50, 50, -25, 25, -12, 12]) == 0\n assert candidate(gain = [10, 20, 30, 40, 50]) == 150\n assert candidate(gain = [0, 0, 0, 0, 0]) == 0\n assert candidate(gain = [100, -50, 50, -100, 50]) == 100\n assert candidate(gain = [100, -100, 50, -50, 25, -25]) == 100\n assert candidate(gain = [100, -100, 100, -100]) == 100\n assert candidate(gain = [-5, 1, 5, 0, -7]) == 1\n assert candidate(gain = [0, 0, 0, 0]) == 0\n assert candidate(gain = [50, 50, 50, 50, 50]) == 250\n assert candidate(gain = [-4, -3, -2, -1, 4, 3, 2]) == 0\n assert candidate(gain = [23, -15, 42, -5, 0, 17, -30, 29]) == 62\n assert candidate(gain = [-10, -20, 30, 40, -50, 60, -70, 80, -90, 100]) == 70\n assert candidate(gain = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(gain = [10, -5, 15, -20, 25, -30, 35, -40]) == 30\n assert candidate(gain = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 0\n assert candidate(gain = [100, -100, 100, -100, 100, -100, 100, -100]) == 100\n assert candidate(gain = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5]) == 50\n assert candidate(gain = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20]) == 10\n assert candidate(gain = [100, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -98]) == 100\n assert candidate(gain = [10, -5, 3, 2, -3, 4, -2, 5, -6, 1]) == 14\n assert candidate(gain = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(gain = [100, -1, 99, -2, 98, -3, 97, -4, 96, -5, 95, -6, 94, -7, 93, -8, 92, -9, 91, -10]) == 910\n assert candidate(gain = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 15\n assert candidate(gain = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 55\n assert candidate(gain = [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1]) == 0\n assert candidate(gain = [10, -5, 3, 2, -3, 4, -1, -2, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16]) == 18\n assert candidate(gain = [5, -3, 20, -20, 30, -10, 15, -5, 25, -15, 10, -5, 30, -30, 40]) == 87\n assert candidate(gain = [10, 15, 20, 25, 30, 35, 40, 45, 50, -100]) == 270\n assert candidate(gain = [50, -20, 30, -10, 40, -5, 60, -25, 70, -10]) == 190\n assert candidate(gain = [0, 25, -25, 50, -50, 100, -100]) == 100\n assert candidate(gain = [20, 30, -10, -40, 50, 10, -20, 30, -40, 50]) == 80\n assert candidate(gain = [5, 10, 15, 20, 25, -5, -10, -15, -20, -25, 5, 10, 15, 20, 25, -5, -10, -15, -20, -25]) == 75\n assert candidate(gain = [99, -50, 50, -100, 100, -99, 99, -49, 49, -51, 51, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5]) == 99\n assert candidate(gain = [100, -25, 25, -50, 50, -75, 75, -100, 100]) == 100\n assert candidate(gain = [10, -5, 3, -2, 8, -4, 6, -3, 5, -1, 7, -2, 9, -4, 11, -5, 13, -6, 15, -7]) == 55\n assert candidate(gain = [5, 5, 5, 5, 5, -5, -5, -5, -5, -5, 10, 10, -10, -10, 15]) == 25\n assert candidate(gain = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11]) == 210\n assert candidate(gain = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(gain = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == 5\n assert candidate(gain = [100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100]) == 100\n assert candidate(gain = [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5]) == 0\n assert candidate(gain = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20]) == 10\n assert candidate(gain = [1, 2, 3, 4, 5, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, -5, -4, -3, -2, -1]) == 15\n assert candidate(gain = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, 50, -50, 40, -40, 30, -30, 20, -20, 10, -10]) == 150\n assert candidate(gain = [-5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5]) == 0\n assert candidate(gain = [0, 20, -10, 5, -3, 15, -10]) == 27\n assert candidate(gain = [10, -5, 3, 8, -2, 15, -7, 20]) == 42\n assert candidate(gain = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(gain = [-10, -20, -30, -40, -50, 10, 20, 30, 40, 50, -1, -2, -3, -4, -5, 1, 2, 3, 4, 5]) == 0\n assert candidate(gain = [-5, -10, -15, 20, 25, -30, 35, -40, 45, -50, 55, -60, 65, -70, 75, -80, 85, -90, 95]) == 50\n assert candidate(gain = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 50\n assert candidate(gain = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100, -110, 120, -130, 140, -150]) == 70\n assert candidate(gain = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100]) == 50\n assert candidate(gain = [99, -99, 98, -98, 97, -97, 96, -96, 95, -95]) == 99\n assert candidate(gain = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23, 24, -25, 26, -27, 28, -29, 30]) == 15\n assert candidate(gain = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 0\n assert candidate(gain = [5, 10, 15, 20, 25, 30, -5, -10, -15, -20, -25, -30]) == 105\n assert candidate(gain = [100, -50, 50, -100, 100, -100, 50, -50, 25, -25, 75, -75, 125, -125, 62, -62, 31, -31, 15, -15]) == 125\n assert candidate(gain = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 5\n assert candidate(gain = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100, 110, -120, 130, -140, 150, -160, 170, -180, 190, -200]) == 100\n assert candidate(gain = [100, -50, 25, -12, 50, -25, 60, -30, 70, -35, 80, -40, 90, -45, 100]) == 338\n assert candidate(gain = [-10, 10, -10, 10, -10, 10, -10, 10, -10, 10]) == 0\n assert candidate(gain = [20, -10, 30, -15, 40, -20, 50, -25, 60, -30, 70, -35, 80, -40, 90]) == 265\n assert candidate(gain = [10, -10, 20, -20, 30, -30, 40, -40, 50]) == 50\n assert candidate(gain = [2, 3, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23, 24, -25]) == 17\n assert candidate(gain = [-50, 25, -25, 50, -50, 75, -100, 125]) == 50\n assert candidate(gain = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -15, -20, -25, -30, -35, -40, -45, -50]) == 275\n assert candidate(gain = [-10, -20, -30, -40, -50, 50, 40, 30, 20, 10]) == 0\n assert candidate(gain = [1, 1, 1, 1, 1, 1, 1, 1, 1, -10]) == 9\n assert candidate(gain = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(gain = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 10\n assert candidate(gain = [-50, 0, 50, 0, -50, 0, 50, 0, -50, 0, 50, 0, -50, 0, 50]) == 0\n assert candidate(gain = [0, 20, -10, 30, -20, 10, -30, 40, -50, 60]) == 50\n assert candidate(gain = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100]) == 50\n assert candidate(gain = [100, -50, 50, -50, 100, -50, 50, -50, 100]) == 200\n assert candidate(gain = [100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99, 100, -99]) == 114\n assert candidate(gain = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9]) == 9\n assert candidate(gain = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 10\n assert candidate(gain = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20, 21, -22, 23, -24, 25, -26, 27, -28, 29, -30]) == 15\n assert candidate(gain = [5, -5, 10, -10, 15, -15, 20, -20, 25, -25]) == 25\n assert candidate(gain = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == 210\n assert candidate(gain = [10, -20, 30, -40, 50, -60, 70]) == 40\n assert candidate(gain = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 50\n assert candidate(gain = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5, 1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 15\n assert candidate(gain = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 55\n assert candidate(gain = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23, 24, -25, 26, -27, 28, -29, 30, -30]) == 15\n assert candidate(gain = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 10\n assert candidate(gain = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 0\n assert candidate(gain = [100, -99, 98, -97, 96, -95, 94, -93, 92, -91, 90, -89, 88, -87, 86, -85, 84, -83, 82, -81, 80]) == 100\n assert candidate(gain = [2, 4, -3, 1, -2, 1, 5, -4, 3, -1, 0, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 12\n assert candidate(gain = [100, -50, 50, -100, 50, -50, 100, -100, 50, -50]) == 100\n assert candidate(gain = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(gain = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100, -10, 20, -30, 40, -50, 60, -70, 80, -90, 100]) == 100\n assert candidate(gain = [-50, 50, -50, 50, -50, 50, -50, 50]) == 0\n assert candidate(gain = [-1, 3, -2, 4, -3, 5, -4, 6, -5, 7]) == 10\n"}, "metadata": {"canonical_parameter_names": ["gain"], "leetcode_dataset_entry_point": "Solution().largestAltitude", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int largestAltitude(vector& gain) {", "container": "Solution", "callable": "largestAltitude", "parameters": [{"name": "gain", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1733, "task_id": "minimum-number-of-people-to-teach", "difficulty": "Medium", "problem_description": "On a social network consisting of m users and some friendships between users, two users can communicate with each other if they know a common language.\nYou are given an integer n, an array languages, and an array friendships where:\n\nThere are n languages numbered 1 through n,\nlanguages[i] is the set of languages the i​​​​​​th​​​​ user knows, and\nfriendships[i] = [u​​​​​​i​​​, v​​​​​​i] denotes a friendship between the users u​​​​​​​​​​​i​​​​​ and vi.\n\nYou can choose one language and teach it to some users so that all friends can communicate with each other. Return the minimum number of users you need to teach.\nNote that friendships are not transitive, meaning if x is a friend of y and y is a friend of z, this doesn't guarantee that x is a friend of z.\n \nExample 1:\n\nInput: n = 2, languages = [[1],[2],[1,2]], friendships = [[1,2],[1,3],[2,3]]\nOutput: 1\nExplanation: You can either teach user 1 the second language or user 2 the first language.\n\nExample 2:\n\nInput: n = 3, languages = [[2],[1,3],[1,2],[3]], friendships = [[1,4],[1,2],[3,4],[2,3]]\nOutput: 2\nExplanation: Teach the third language to users 1 and 3, yielding two users to teach.\n\n \nConstraints:\n\n2 <= n <= 500\nlanguages.length == m\n1 <= m <= 500\n1 <= languages[i].length <= n\n1 <= languages[i][j] <= n\n1 <= u​​​​​​i < v​​​​​​i <= languages.length\n1 <= friendships.length <= 500\nAll tuples (u​​​​​i, v​​​​​​i) are unique\nlanguages[i] contains only unique values\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,languages = [[1], [2], [3], [4]],friendships = [[1, 2], [2, 3], [3, 4], [4, 1]]) == 3\n assert candidate(n = 3,languages = [[1, 2], [2, 3], [3, 1]],friendships = [[1, 2], [2, 3], [3, 1]]) == 0\n assert candidate(n = 5,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [1, 5]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5]]) == 0\n assert candidate(n = 2,languages = [[1], [2], [1, 2]],friendships = [[1, 2], [1, 3], [2, 3]]) == 1\n assert candidate(n = 4,languages = [[1, 3], [2, 4], [1, 2], [3, 4]],friendships = [[1, 2], [2, 3], [3, 4]]) == 2\n assert candidate(n = 4,languages = [[1], [2], [3], [4]],friendships = [[1, 2], [2, 3], [3, 4], [1, 4]]) == 3\n assert candidate(n = 5,languages = [[1], [2], [3], [4], [5]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5]]) == 4\n assert candidate(n = 3,languages = [[2], [1, 3], [1, 2], [3]],friendships = [[1, 4], [1, 2], [3, 4], [2, 3]]) == 2\n assert candidate(n = 2,languages = [[1, 2], [1, 2]],friendships = [[1, 2]]) == 0\n assert candidate(n = 3,languages = [[1, 2, 3], [2, 3], [1, 3]],friendships = [[1, 2], [2, 3], [1, 3]]) == 0\n assert candidate(n = 5,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == 0\n assert candidate(n = 4,languages = [[1, 2], [3, 4], [1, 3], [2, 4]],friendships = [[1, 2], [1, 3], [2, 3], [3, 4]]) == 2\n assert candidate(n = 5,languages = [[1], [2], [3], [4], [5]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == 4\n assert candidate(n = 4,languages = [[1], [2], [3], [4]],friendships = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]) == 3\n assert candidate(n = 10,languages = [[1, 2, 3], [4, 5], [6, 7], [8, 9], [10]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [2, 4], [3, 5]]) == 4\n assert candidate(n = 6,languages = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 1], [6, 2]],friendships = [[1, 2], [3, 4], [5, 6]]) == 4\n assert candidate(n = 4,languages = [[1, 2], [2, 3], [3, 4], [4, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 1], [1, 3], [2, 4], [1, 4], [2, 3], [1, 2], [3, 4]]) == 2\n assert candidate(n = 10,languages = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 1], [10, 1, 2]],friendships = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 3\n assert candidate(n = 12,languages = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10], [11], [12]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 1]]) == 11\n assert candidate(n = 6,languages = [[1], [2], [3], [4], [5], [6]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 1], [6, 2]]) == 5\n assert candidate(n = 3,languages = [[1, 3], [2], [1, 2], [3, 2]],friendships = [[1, 2], [1, 3], [2, 3], [2, 4], [3, 4]]) == 1\n assert candidate(n = 9,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 1], [9, 2]]) == 7\n assert candidate(n = 5,languages = [[1, 2, 3], [4, 5], [1, 4], [2, 5], [3]],friendships = [[1, 4], [2, 5], [3, 5], [1, 3], [2, 4]]) == 1\n assert candidate(n = 3,languages = [[1], [2], [3], [1, 2], [2, 3], [1, 3]],friendships = [[1, 2], [2, 3], [1, 3], [4, 5], [5, 6], [4, 6]]) == 2\n assert candidate(n = 10,languages = [[1, 2, 3], [4, 5], [6, 7, 8], [9, 10], [1, 5, 9], [2, 6, 10], [3, 7, 4], [8, 1]],friendships = [[1, 2], [3, 4], [5, 6], [7, 8], [1, 5], [2, 6], [3, 7], [4, 8], [5, 7], [6, 8]]) == 5\n assert candidate(n = 8,languages = [[1], [2], [3], [4], [5], [6], [7], [8]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 1], [8, 2]]) == 7\n assert candidate(n = 8,languages = [[1, 2], [3, 4], [5, 6], [7, 8], [1, 3], [2, 4], [5, 7], [6, 8]],friendships = [[1, 3], [2, 4], [5, 7], [6, 8], [1, 5], [2, 6], [3, 7], [4, 8]]) == 6\n assert candidate(n = 8,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 1], [8, 2]]) == 6\n assert candidate(n = 4,languages = [[1, 2], [3, 4], [2, 3], [1, 4]],friendships = [[1, 2], [2, 3], [3, 4], [4, 1]]) == 2\n assert candidate(n = 9,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]]) == 0\n assert candidate(n = 5,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == 0\n assert candidate(n = 7,languages = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 1], [7, 1, 2]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 1], [7, 2]]) == 0\n assert candidate(n = 10,languages = [[1, 3, 5], [2, 4, 6], [1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [1, 4], [2, 5], [3, 6]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]]) == 7\n assert candidate(n = 10,languages = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == 9\n assert candidate(n = 5,languages = [[1], [2], [3], [4], [5]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [2, 4], [3, 5], [4, 1], [5, 2]]) == 4\n assert candidate(n = 3,languages = [[1], [1, 3], [2], [2, 3], [3]],friendships = [[1, 3], [2, 3], [4, 5]]) == 1\n assert candidate(n = 10,languages = [[1, 3, 5], [2, 4, 6], [1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 1], [2, 3, 4]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == 6\n assert candidate(n = 10,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == 0\n assert candidate(n = 15,languages = [[1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8], [5, 6, 7, 8, 9], [6, 7, 8, 9, 10], [7, 8, 9, 10, 11], [8, 9, 10, 11, 12], [9, 10, 11, 12, 13], [10, 11, 12, 13, 14], [11, 12, 13, 14, 15], [1, 2, 3, 4, 5], [2, 3, 4, 5, 6], [3, 4, 5, 6, 7], [4, 5, 6, 7, 8]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 1], [15, 2]]) == 2\n assert candidate(n = 5,languages = [[1], [2], [3], [4], [5], [1, 2], [3, 4], [4, 5], [1, 3], [2, 5]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 7\n assert candidate(n = 7,languages = [[1, 2], [3, 4], [5, 6], [7], [1, 3], [2, 4], [5, 7]],friendships = [[1, 3], [1, 5], [1, 7], [2, 4], [2, 6], [3, 5], [3, 7], [4, 6], [4, 7], [5, 6]]) == 5\n assert candidate(n = 5,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [2, 4], [3, 5], [4, 1], [5, 2]]) == 3\n assert candidate(n = 10,languages = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]],friendships = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 9\n assert candidate(n = 7,languages = [[1, 2, 3, 4], [5, 6], [7], [1, 2], [3, 4], [5, 6], [7]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1]]) == 5\n assert candidate(n = 4,languages = [[1, 2], [2, 3], [3, 4], [4, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 1]]) == 0\n assert candidate(n = 7,languages = [[1], [2], [3], [4], [5], [6], [7]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 1], [7, 2]]) == 6\n assert candidate(n = 8,languages = [[1], [1], [1], [1], [2], [2], [2], [2]],friendships = [[1, 5], [2, 6], [3, 7], [4, 8]]) == 4\n assert candidate(n = 7,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1]],friendships = [[1, 3], [3, 5], [5, 7], [7, 2], [2, 4], [4, 6]]) == 5\n assert candidate(n = 7,languages = [[1], [2], [3], [1, 4], [5, 6], [6, 7], [7]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1]]) == 4\n assert candidate(n = 5,languages = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 1], [5, 1, 2]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == 0\n assert candidate(n = 7,languages = [[1, 3, 5], [2, 4, 6], [1, 2, 3], [4, 5, 6], [1, 4, 7], [2, 5, 7], [3, 6, 7]],friendships = [[1, 2], [3, 4], [5, 6], [7, 1], [2, 5], [4, 7], [6, 3]]) == 2\n assert candidate(n = 6,languages = [[1], [2], [3], [4], [5], [6]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]) == 5\n assert candidate(n = 4,languages = [[1, 2], [2, 3], [3, 4], [1, 4]],friendships = [[1, 2], [2, 3], [3, 4], [1, 4]]) == 0\n assert candidate(n = 6,languages = [[1], [2], [3], [4], [5], [6]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]) == 5\n assert candidate(n = 6,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]) == 0\n assert candidate(n = 3,languages = [[1, 2], [2, 3], [1, 3]],friendships = [[1, 2], [2, 3], [1, 3], [1, 2], [2, 3], [1, 3]]) == 0\n assert candidate(n = 3,languages = [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]],friendships = [[1, 2], [2, 3], [3, 4], [4, 1]]) == 0\n assert candidate(n = 4,languages = [[1, 2], [3, 4], [2, 3], [1, 4], [1, 3]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [1, 5]]) == 2\n assert candidate(n = 4,languages = [[1, 2, 3], [2, 3, 4], [3, 4, 1], [4, 1, 2]],friendships = [[1, 2], [2, 3], [3, 4], [4, 1]]) == 0\n assert candidate(n = 5,languages = [[1, 2, 3, 4, 5]],friendships = [[1, 1], [1, 1], [1, 1]]) == 0\n assert candidate(n = 4,languages = [[1, 2], [2, 3], [3, 4], [1, 4]],friendships = [[1, 2], [2, 3], [3, 4], [4, 1], [1, 3], [2, 4]]) == 2\n assert candidate(n = 10,languages = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]],friendships = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 9\n assert candidate(n = 8,languages = [[1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [1, 8]]) == 1\n assert candidate(n = 6,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [1, 6]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [1, 6], [1, 3], [2, 4], [3, 5], [4, 6], [1, 5], [2, 6]]) == 4\n assert candidate(n = 5,languages = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [1, 2], [4, 5]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [1, 5]]) == 2\n assert candidate(n = 5,languages = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 1], [5, 1, 2]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == 0\n assert candidate(n = 10,languages = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]]) == 0\n assert candidate(n = 6,languages = [[1, 2, 3], [4, 5, 6], [1, 4], [2, 5], [3, 6], [1, 2, 3, 4, 5, 6]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [1, 3], [2, 4], [3, 5], [4, 6], [1, 5], [2, 6]]) == 3\n assert candidate(n = 6,languages = [[1], [2], [3], [4], [5], [6]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 1], [6, 2]]) == 5\n assert candidate(n = 12,languages = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [1, 4, 7, 10], [2, 5, 8, 11], [3, 6, 9, 12], [1, 5, 9, 12], [2, 6, 10, 11], [3, 4, 7, 8], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]],friendships = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [6, 12], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [8, 9], [8, 10], [8, 11], [8, 12], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12]]) == 7\n assert candidate(n = 7,languages = [[1], [2], [3], [4], [5], [6], [7]],friendships = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 1], [7, 2]]) == 6\n assert candidate(n = 8,languages = [[1, 2], [3, 4], [5, 6], [7, 8], [1, 3], [2, 4], [5, 7], [6, 8]],friendships = [[1, 2], [3, 4], [5, 6], [7, 8], [1, 3], [2, 4], [5, 7], [6, 8]]) == 6\n assert candidate(n = 5,languages = [[1, 2], [3, 4], [1, 3], [2, 5], [4, 5]],friendships = [[1, 2], [3, 4], [2, 3], [4, 5], [1, 3]]) == 2\n"}, "metadata": {"canonical_parameter_names": ["n", "languages", "friendships"], "leetcode_dataset_entry_point": "Solution().minimumTeachings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumTeachings(int n, vector>& languages, vector>& friendships) {", "container": "Solution", "callable": "minimumTeachings", "parameters": [{"name": "n", "type": "int"}, {"name": "languages", "type": "vector>&"}, {"name": "friendships", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1734, "task_id": "decode-xored-permutation", "difficulty": "Medium", "problem_description": "There is an integer array perm that is a permutation of the first n positive integers, where n is always odd.\nIt was encoded into another integer array encoded of length n - 1, such that encoded[i] = perm[i] XOR perm[i + 1]. For example, if perm = [1,3,2], then encoded = [2,1].\nGiven the encoded array, return the original array perm. It is guaranteed that the answer exists and is unique.\n \nExample 1:\n\nInput: encoded = [3,1]\nOutput: [1,2,3]\nExplanation: If perm = [1,2,3], then encoded = [1 XOR 2,2 XOR 3] = [3,1]\n\nExample 2:\n\nInput: encoded = [6,5,4,6]\nOutput: [2,4,1,5,3]\n\n \nConstraints:\n\n3 <= n < 105\nn is odd.\nencoded.length == n - 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(encoded = [15, 8, 12, 4, 1]) == [11, 4, 12, 0, 4, 5]\n assert candidate(encoded = [1, 7, 6, 5, 4, 3]) == [1, 0, 7, 1, 4, 0, 3]\n assert candidate(encoded = [6, 5, 4, 6]) == [2, 4, 1, 5, 3]\n assert candidate(encoded = [8, 12, 4, 6, 1, 3, 5]) == [1, 9, 5, 1, 7, 6, 5, 0]\n assert candidate(encoded = [2, 3, 1, 4, 7]) == [0, 2, 1, 0, 4, 3]\n assert candidate(encoded = [8, 13, 10, 3, 7, 12, 9]) == [10, 2, 15, 5, 6, 1, 13, 4]\n assert candidate(encoded = [2, 3, 1, 6, 7, 0]) == [5, 7, 4, 5, 3, 4, 4]\n assert candidate(encoded = [1, 5, 7]) == [1, 0, 5, 2]\n assert candidate(encoded = [8, 9, 10, 11, 12, 13, 14]) == [7, 15, 6, 12, 7, 11, 6, 8]\n assert candidate(encoded = [7, 8, 9, 10, 11, 12]) == [14, 9, 1, 8, 2, 9, 5]\n assert candidate(encoded = [15, 10, 5, 2, 1, 4]) == [12, 3, 9, 12, 14, 15, 11]\n assert candidate(encoded = [2, 3, 2]) == [7, 5, 6, 4]\n assert candidate(encoded = [1, 0, 1, 0, 1]) == [7, 6, 6, 7, 7, 6]\n assert candidate(encoded = [7, 3, 5]) == [7, 0, 3, 6]\n assert candidate(encoded = [1, 6, 5, 4, 3, 2]) == [0, 1, 7, 2, 6, 5, 7]\n assert candidate(encoded = [2, 3, 1, 4, 5]) == [0, 2, 1, 0, 4, 1]\n assert candidate(encoded = [3, 1]) == [1, 2, 3]\n assert candidate(encoded = [123, 234, 345, 456, 567, 678, 789, 890, 901, 1002]) == [788, 879, 901, 732, 788, 291, 901, 144, 1002, 111, 901]\n assert candidate(encoded = [14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58]) == [9, 7, 21, 3, 25, 7, 37, 3, 41, 7, 53, 3, 57]\n assert candidate(encoded = [15, 10, 5, 3, 2, 1, 4]) == [0, 15, 5, 0, 3, 1, 0, 4]\n assert candidate(encoded = [5, 10, 15, 20, 25, 30, 35]) == [8, 13, 7, 8, 28, 5, 27, 56]\n assert candidate(encoded = [2, 15, 18, 17, 20, 23, 22, 25, 28]) == [27, 25, 22, 4, 21, 1, 22, 0, 25, 5]\n assert candidate(encoded = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [3, 2, 0, 3, 7, 2, 4, 3, 11, 2, 8, 3, 15, 2, 12, 3, 19, 2, 16, 3, 23, 2, 20, 3, 27, 2]\n assert candidate(encoded = [77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198]) == [95, 18, 74, 41, 71, 62, 186, 53, 175, 10, 186, 1, 199]\n assert candidate(encoded = [9, 20, 27, 34, 41, 48, 55]) == [14, 7, 19, 8, 42, 3, 51, 4]\n assert candidate(encoded = [7, 2, 5, 8, 3, 6, 1, 4, 9]) == [3, 4, 6, 3, 11, 8, 14, 15, 11, 2]\n assert candidate(encoded = [65, 131, 263, 527, 1055, 2111, 4223, 8447, 16895, 33791, 67583, 135167]) == [173645, 173580, 173711, 173960, 173447, 172440, 174503, 178648, 170279, 186584, 154407, 220376, 86823]\n assert candidate(encoded = [7, 18, 27, 34, 41, 48, 55]) == [8, 15, 29, 6, 36, 13, 61, 10]\n assert candidate(encoded = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441, 1594323]) == [583287, 583284, 583293, 583270, 583223, 583364, 582685, 584854, 587063, 571860, 548733, 715910, 194423, 1746084]\n assert candidate(encoded = [2, 7, 13, 18, 24, 30, 36, 42, 48, 54, 60]) == [27, 25, 30, 19, 1, 25, 7, 35, 9, 57, 15, 51]\n assert candidate(encoded = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39]) == [39, 36, 35, 40, 39, 52, 35, 56, 39, 4, 35]\n assert candidate(encoded = [31, 34, 37, 40, 43, 46, 49]) == [44, 51, 17, 52, 28, 55, 25, 40]\n assert candidate(encoded = [255, 222, 199, 176, 153, 130, 107, 84]) == [185, 70, 152, 95, 239, 118, 244, 159, 203]\n assert candidate(encoded = [19, 22, 25, 28, 31, 34, 37]) == [32, 51, 37, 60, 32, 63, 29, 56]\n assert candidate(encoded = [15, 22, 13, 20, 9, 16, 11]) == [26, 21, 3, 14, 26, 19, 3, 8]\n assert candidate(encoded = [100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650]) == [93, 57, 175, 103, 157, 433, 239, 383, 189, 329, 879, 311, 957]\n assert candidate(encoded = [15, 22, 3, 26, 11, 28, 7, 30, 13, 32, 9, 34, 5, 36, 1]) == [56, 55, 33, 34, 56, 51, 47, 40, 54, 59, 27, 18, 48, 53, 17, 16]\n assert candidate(encoded = [8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [3267, 4924, 7363, 6972, 6339, 6460, 6595, 6588, 6531, 6556, 6547, 6548, 6551, 6550]\n assert candidate(encoded = [4, 12, 8, 16, 10, 18, 14]) == [6, 2, 14, 6, 22, 28, 14, 0]\n assert candidate(encoded = [42, 35, 26, 15, 4, 17, 38, 67, 114, 181, 278, 399]) == [325, 367, 332, 342, 345, 349, 332, 362, 297, 347, 494, 248, 375]\n assert candidate(encoded = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [968, 940, 868, 584, 984, 556, 116, 712, 488, 620, 388]\n assert candidate(encoded = [255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245]) == [250, 5, 251, 6, 250, 1, 251, 2, 250, 13, 251, 14]\n assert candidate(encoded = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304]) == [2796223, 2796219, 2796211, 2796195, 2796163, 2796227, 2796099, 2796355, 2795843, 2796867, 2794819, 2798915, 2790723, 2807107, 2774339, 2839875, 2708803, 2970947, 2446659, 3495235, 1398083, 5592387]\n assert candidate(encoded = [12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78]) == [14, 2, 12, 28, 14, 26, 12, 20, 14, 18, 12, 44, 14, 42, 12, 36, 14, 34, 12, 60, 14, 58, 12, 52, 14, 50, 12, 76, 14, 74, 12, 68, 14, 66, 12]\n assert candidate(encoded = [24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64]) == [16, 8, 20, 52, 16, 56, 20, 36, 16, 40, 20, 84]\n assert candidate(encoded = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == [11, 14, 9, 0, 11, 6, 9, 24, 11, 30, 9, 16]\n assert candidate(encoded = [5, 8, 11, 14, 17, 20, 23, 26, 29, 32]) == [40, 45, 37, 46, 32, 49, 37, 50, 40, 53, 21]\n assert candidate(encoded = [17, 19, 21, 23, 25, 27, 29, 31]) == [1, 16, 3, 22, 1, 24, 3, 30, 1]\n assert candidate(encoded = [5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [19, 22, 17, 24, 19, 30, 17, 0, 19, 6, 17, 8, 19, 14]\n assert candidate(encoded = [99, 198, 297, 396, 495, 594, 693, 792, 891, 990, 1089]) == [978, 945, 887, 606, 978, 573, 111, 730, 450, 697, 359, 1318]\n assert candidate(encoded = [2047, 4094, 2047, 4094, 2047, 4094, 2047, 4094, 2047, 4094, 2047]) == [4082, 2061, 2035, 12, 4082, 2061, 2035, 12, 4082, 2061, 2035, 12]\n assert candidate(encoded = [2, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576, 49152, 98304, 196608, 393216, 786432, 1572864]) == [2097151, 2097149, 2097147, 2097143, 2097135, 2097119, 2097087, 2097023, 2096895, 2096639, 2096127, 2095103, 2093055, 2088959, 2080767, 2064383, 2031615, 1966079, 1835007, 1572863, 1048575]\n assert candidate(encoded = [30, 10, 20, 15, 25, 12, 22, 17, 27, 14, 24, 19, 29, 16, 26]) == [5, 27, 17, 5, 10, 19, 31, 9, 24, 3, 13, 21, 6, 27, 11, 17]\n assert candidate(encoded = [255, 128, 64, 32, 16, 8, 4, 2, 1]) == [161, 94, 222, 158, 190, 174, 166, 162, 160, 161]\n assert candidate(encoded = [15, 22, 33, 46, 59, 74, 91, 110, 131, 154]) == [134, 137, 159, 190, 144, 171, 225, 186, 212, 87, 205]\n assert candidate(encoded = [14, 11, 12, 15, 16, 19, 20, 23, 24, 27]) == [27, 21, 30, 18, 29, 13, 30, 10, 29, 5, 30]\n assert candidate(encoded = [31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575]) == [838849, 838878, 838881, 838814, 838753, 839070, 839265, 838046, 837217, 842142, 845409, 825758, 812641, 891294, 943713, 629150, 419425]\n assert candidate(encoded = [11, 24, 29, 36, 43, 50, 57]) == [6, 13, 21, 8, 44, 7, 53, 12]\n assert candidate(encoded = [13, 22, 31, 40, 49, 58, 67]) == [12, 1, 23, 8, 32, 17, 43, 104]\n assert candidate(encoded = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85]) == [35, 38, 44, 35, 55, 46, 48, 19, 59, 22, 36, 19, 47, 110, 40, 99, 51, 102]\n assert candidate(encoded = [14, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == [5, 11, 29, 9, 27, 11, 5, 9, 3, 11, 13, 9, 11]\n assert candidate(encoded = [7, 14, 21, 28, 35, 42, 49]) == [48, 55, 57, 44, 48, 19, 57, 8]\n assert candidate(encoded = [127, 63, 31, 15, 7, 3, 1]) == [59, 68, 123, 100, 107, 108, 111, 110]\n assert candidate(encoded = [27, 24, 21, 18, 15, 12, 9, 6, 3]) == [11, 16, 8, 29, 15, 0, 12, 5, 3, 0]\n assert candidate(encoded = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [409, 614, 921, 870, 793, 806, 825, 822, 817, 818, 819]\n assert candidate(encoded = [31, 28, 33, 30, 35, 32, 37]) == [42, 53, 41, 8, 22, 53, 21, 48]\n assert candidate(encoded = [15, 23, 19, 21, 17, 13, 9, 5, 1]) == [1, 14, 25, 10, 31, 14, 3, 10, 15, 14]\n assert candidate(encoded = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, 6, 14, 7, 13, 6, 10, 7, 9, 6, 22, 7, 21, 6, 18, 7, 17, 6, 30, 7, 29, 6, 26, 7, 25]\n assert candidate(encoded = [5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77]) == [29, 24, 17, 28, 13, 24, 1, 28, 61, 24, 49, 28, 45, 24, 33, 28, 93, 24, 81, 28]\n assert candidate(encoded = [4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [1639, 2456, 3687, 3480, 3175, 3224, 3303, 3288, 3271, 3272, 3279, 3276, 3277]\n assert candidate(encoded = [25, 30, 35, 40, 45, 50, 55]) == [12, 21, 11, 40, 0, 45, 31, 40]\n assert candidate(encoded = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34]) == [33, 37, 35, 43, 33, 45, 35, 51, 33, 53, 35, 59, 33, 61, 35, 3, 33]\n assert candidate(encoded = [32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [13091, 19676, 29475, 27868, 25379, 25820, 26403, 26332, 26147, 26204, 26211, 26236, 26227, 26228, 26231, 26230]\n assert candidate(encoded = [3, 10, 17, 24, 31, 38, 45]) == [60, 63, 53, 36, 60, 35, 5, 40]\n assert candidate(encoded = [13, 23, 37, 55, 77, 103, 133, 167, 205, 247, 293, 343, 397]) == [335, 322, 341, 368, 327, 266, 365, 488, 335, 386, 373, 80, 263, 138]\n assert candidate(encoded = [14, 23, 32, 41, 50, 59, 68]) == [13, 3, 20, 52, 29, 47, 20, 80]\n assert candidate(encoded = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [3, 26, 2, 21, 3, 22, 2, 17, 3, 18, 2, 13, 3, 14, 2, 9, 3, 10, 2, 5, 3, 6, 2, 1, 3, 2]\n assert candidate(encoded = [10, 20, 15, 25, 30, 22, 28, 19, 29, 12]) == [4, 14, 26, 21, 12, 18, 4, 24, 11, 22, 26]\n assert candidate(encoded = [23, 45, 12, 34, 56, 78, 90, 112, 134]) == [58, 45, 0, 12, 46, 22, 88, 2, 114, 244]\n assert candidate(encoded = [15, 22, 30, 39, 45, 51, 57, 63, 69]) == [54, 57, 47, 49, 22, 59, 8, 49, 14, 75]\n assert candidate(encoded = [3, 9, 15, 21, 27, 33, 39]) == [53, 54, 63, 48, 37, 62, 31, 56]\n assert candidate(encoded = [13, 26, 52, 104, 208, 416, 832, 1664, 3328, 6656, 13312, 26624, 53248, 106496, 212992, 425984, 851968, 1703936, 3407872, 6815744, 13631488, 27262976, 54525952, 109051904, 218103808, 436207616, 872415232, 1744830464, 3489660928, 6979321856, 13958643712, 27917287424, 55834574848, 111669149696, 223338299392, 446676598784, 893353197568, 1786706395136, 3573412790272]) == [2015771317626, 2015771317623, 2015771317613, 2015771317593, 2015771317553, 2015771317729, 2015771317313, 2015771318017, 2015771316609, 2015771319425, 2015771313793, 2015771325057, 2015771302529, 2015771347585, 2015771257473, 2015771437697, 2015771077249, 2015771798145, 2015770356353, 2015773239937, 2015767472769, 2015779007105, 2015755938433, 2015802075777, 2015709801089, 2015894350465, 2015525251713, 2016263449217, 2014787054209, 2017739844225, 2011834264193, 2023645424257, 2000023104129, 2047267744385, 1952778463873, 2141757024897, 1763799902849, 1420202519169, 1007885658753, 4031542635137]\n assert candidate(encoded = [5, 12, 19, 26, 33, 40, 47]) == [54, 51, 63, 44, 54, 23, 63, 16]\n assert candidate(encoded = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == [8, 10, 14, 8, 0, 10, 6, 8, 24, 10, 30, 8]\n assert candidate(encoded = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143]) == [197, 206, 216, 249, 213, 226, 160, 237, 181, 214, 184, 193, 69, 202]\n assert candidate(encoded = [63, 66, 69, 72, 75, 78, 81]) == [76, 115, 49, 116, 60, 119, 57, 104]\n assert candidate(encoded = [29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == [109, 112, 111, 74, 99, 72, 103, 82, 105, 84, 23, 80]\n assert candidate(encoded = [1023, 511, 255, 127, 63, 31, 15, 7]) == [409, 614, 921, 870, 793, 806, 825, 822, 817]\n assert candidate(encoded = [31, 30, 29, 28, 27, 26, 25, 24, 23]) == [11, 20, 10, 23, 11, 16, 10, 19, 11, 28]\n assert candidate(encoded = [13, 29, 61, 125, 253, 509, 1021, 2045, 4093, 8189, 16381, 32765, 65533, 131077, 262149]) == [157301, 157304, 157285, 157272, 157221, 157400, 157477, 156888, 156453, 158936, 160549, 150744, 144165, 183512, 52445, 314584]\n assert candidate(encoded = [9, 19, 31, 45, 61, 79, 99, 121, 145, 171, 199, 229, 261, 295, 331]) == [369, 376, 363, 372, 345, 356, 299, 328, 305, 416, 267, 460, 297, 44, 267, 64]\n assert candidate(encoded = [31, 14, 17, 9, 22, 15, 26, 11, 24]) == [8, 23, 25, 8, 1, 23, 24, 2, 9, 17]\n assert candidate(encoded = [4, 13, 12, 15, 10, 19, 18, 21, 14, 23, 22]) == [31, 27, 22, 26, 21, 31, 12, 30, 11, 5, 18, 4]\n assert candidate(encoded = [7, 13, 21, 31, 43, 57, 73, 91, 111, 133, 157, 183, 211, 241, 273]) == [163, 164, 169, 188, 163, 136, 177, 248, 163, 204, 73, 212, 99, 176, 65, 336]\n assert candidate(encoded = [15, 22, 17, 24, 19, 26, 21, 28, 23]) == [3, 12, 26, 11, 19, 0, 26, 15, 19, 4]\n assert candidate(encoded = [2, 3, 1, 6, 5, 4, 11, 10, 9, 16, 15, 14, 21, 20, 19]) == [17, 19, 16, 17, 23, 18, 22, 29, 23, 30, 14, 1, 15, 26, 14, 29]\n assert candidate(encoded = [15, 20, 17, 23, 18, 24, 19]) == [19, 28, 8, 25, 14, 28, 4, 23]\n assert candidate(encoded = [31, 29, 27, 25, 23, 21, 19, 17, 15]) == [11, 20, 9, 18, 11, 28, 9, 26, 11, 4]\n assert candidate(encoded = [65, 68, 71, 74, 77, 80, 83]) == [86, 23, 83, 20, 94, 19, 67, 16]\n assert candidate(encoded = [15, 20, 25, 30, 35, 40, 45, 50, 55]) == [27, 20, 0, 25, 7, 36, 12, 33, 19, 36]\n assert candidate(encoded = [100, 200, 50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == [639, 539, 723, 737, 631, 653, 979, 529, 55, 701, 83, 769, 183]\n assert candidate(encoded = [127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101]) == [122, 5, 123, 6, 122, 1, 123, 2, 122, 13, 123, 14, 122, 9, 123, 10, 122, 21, 123, 22, 122, 17, 123, 18, 122, 29, 123, 30]\n assert candidate(encoded = [16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == [6553, 9830, 14745, 13926, 12697, 12902, 13209, 13158, 13081, 13094, 13113, 13110, 13105, 13106, 13107]\n assert candidate(encoded = [127, 130, 133, 136, 139, 142, 145]) == [140, 243, 113, 244, 124, 247, 121, 232]\n assert candidate(encoded = [5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45]) == [5, 0, 9, 4, 21, 0, 25, 4, 37, 0, 41, 4]\n assert candidate(encoded = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120]) == [1, 2, 4, 13, 1, 14, 28, 9, 17, 10, 20, 53, 17, 54, 28, 49, 1, 50, 4, 61, 1, 62, 124, 57, 113, 58, 116, 37, 113, 38, 124, 33, 65, 34, 68, 45, 65, 46, 92, 41, 81]\n assert candidate(encoded = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047]) == [831, 830, 829, 826, 821, 810, 789, 874, 917, 618, 405, 1642]\n assert candidate(encoded = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == [1, 101, 6, 100, 5, 101, 58, 100, 57, 101, 62, 100, 61, 101, 50, 100, 49]\n assert candidate(encoded = [31, 14, 7, 3, 1, 0, 2, 6, 14, 30, 62, 126, 254]) == [100, 123, 117, 114, 113, 112, 112, 114, 116, 122, 100, 90, 36, 218]\n assert candidate(encoded = [15, 27, 18, 23, 31, 45, 56, 67, 78]) == [105, 102, 125, 111, 120, 103, 74, 114, 49, 127]\n"}, "metadata": {"canonical_parameter_names": ["encoded"], "leetcode_dataset_entry_point": "Solution().decode", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector decode(vector& encoded) {", "container": "Solution", "callable": "decode", "parameters": [{"name": "encoded", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1736, "task_id": "latest-time-by-replacing-hidden-digits", "difficulty": "Easy", "problem_description": "You are given a string time in the form of hh:mm, where some of the digits in the string are hidden (represented by ?).\nThe valid times are those inclusively between 00:00 and 23:59.\nReturn the latest valid time you can get from time by replacing the hidden digits.\n \nExample 1:\n\nInput: time = \"2?:?0\"\nOutput: \"23:50\"\nExplanation: The latest hour beginning with the digit '2' is 23 and the latest minute ending with the digit '0' is 50.\n\nExample 2:\n\nInput: time = \"0?:3?\"\nOutput: \"09:39\"\n\nExample 3:\n\nInput: time = \"1?:22\"\nOutput: \"19:22\"\n\n \nConstraints:\n\ntime is in the format hh:mm.\nIt is guaranteed that you can produce a valid time from the given string.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(time = \"?3:?0\") == \"23:50\"\n assert candidate(time = \"1?:22\") == \"19:22\"\n assert candidate(time = \"1?:??\") == \"19:59\"\n assert candidate(time = \"0?:59\") == \"09:59\"\n assert candidate(time = \"23:?9\") == \"23:59\"\n assert candidate(time = \"00:?0\") == \"00:50\"\n assert candidate(time = \"2?:5?\") == \"23:59\"\n assert candidate(time = \"2?:?0\") == \"23:50\"\n assert candidate(time = \"?:?:??\") == \"2:?:9?\"\n assert candidate(time = \"00:??\") == \"00:59\"\n assert candidate(time = \"1?:?5\") == \"19:55\"\n assert candidate(time = \"?9:5?\") == \"19:59\"\n assert candidate(time = \"??:??\") == \"23:59\"\n assert candidate(time = \"12:3?\") == \"12:39\"\n assert candidate(time = \"??:00\") == \"23:00\"\n assert candidate(time = \"0?:3?\") == \"09:39\"\n assert candidate(time = \"1?:?9\") == \"19:59\"\n assert candidate(time = \"00:?5\") == \"00:55\"\n assert candidate(time = \"?9:59\") == \"19:59\"\n assert candidate(time = \"2?:59\") == \"23:59\"\n assert candidate(time = \"12:?5\") == \"12:55\"\n assert candidate(time = \"1?:3?\") == \"19:39\"\n assert candidate(time = \"20:??\") == \"20:59\"\n assert candidate(time = \"?4:2?\") == \"14:29\"\n assert candidate(time = \"2?:3?\") == \"23:39\"\n assert candidate(time = \"??:45\") == \"23:45\"\n assert candidate(time = \"23:?0\") == \"23:50\"\n assert candidate(time = \"??:09\") == \"23:09\"\n assert candidate(time = \"0?:2?\") == \"09:29\"\n assert candidate(time = \"?4:?4\") == \"14:54\"\n assert candidate(time = \"23:?5\") == \"23:55\"\n assert candidate(time = \"23:?7\") == \"23:57\"\n assert candidate(time = \"20:?9\") == \"20:59\"\n assert candidate(time = \"?3:?2\") == \"23:52\"\n assert candidate(time = \"0?:?4\") == \"09:54\"\n assert candidate(time = \"?3:?8\") == \"23:58\"\n assert candidate(time = \"???:59\") == \"23?:59\"\n assert candidate(time = \"2??:5?\") == \"23?:5?\"\n assert candidate(time = \"2?:1?\") == \"23:19\"\n assert candidate(time = \"22:?8\") == \"22:58\"\n assert candidate(time = \"0?:?9\") == \"09:59\"\n assert candidate(time = \"2?:??\") == \"23:59\"\n assert candidate(time = \"0?:?2\") == \"09:52\"\n assert candidate(time = \"02:?7\") == \"02:57\"\n assert candidate(time = \"1?:?8\") == \"19:58\"\n assert candidate(time = \"09:?5\") == \"09:55\"\n assert candidate(time = \"???:??\") == \"23?:9?\"\n assert candidate(time = \"09:?3\") == \"09:53\"\n assert candidate(time = \"?2:?7\") == \"22:57\"\n assert candidate(time = \"1?:4?\") == \"19:49\"\n assert candidate(time = \"2?:0?\") == \"23:09\"\n assert candidate(time = \"??:59\") == \"23:59\"\n assert candidate(time = \"23:?4\") == \"23:54\"\n assert candidate(time = \"2??:3?\") == \"23?:3?\"\n assert candidate(time = \"0??:30\") == \"09?:30\"\n assert candidate(time = \"0?:?5\") == \"09:55\"\n assert candidate(time = \"0?:4?\") == \"09:49\"\n assert candidate(time = \"09:5?\") == \"09:59\"\n assert candidate(time = \"1?:?0\") == \"19:50\"\n assert candidate(time = \"00:?9\") == \"00:59\"\n assert candidate(time = \"2?:?5\") == \"23:55\"\n assert candidate(time = \"1?:5?\") == \"19:59\"\n assert candidate(time = \"19:?9\") == \"19:59\"\n assert candidate(time = \"1?:?4\") == \"19:54\"\n assert candidate(time = \"1?:0?\") == \"19:09\"\n assert candidate(time = \"2?:4?\") == \"23:49\"\n assert candidate(time = \"?0:?5\") == \"20:55\"\n assert candidate(time = \"??:?9\") == \"23:59\"\n assert candidate(time = \"???:00\") == \"23?:00\"\n assert candidate(time = \"?9:?8\") == \"19:58\"\n assert candidate(time = \"?3:?9\") == \"23:59\"\n assert candidate(time = \"0?:5?\") == \"09:59\"\n assert candidate(time = \"2?:?4\") == \"23:54\"\n assert candidate(time = \"?9:?9\") == \"19:59\"\n assert candidate(time = \"2?:00\") == \"23:00\"\n assert candidate(time = \"?2:3?\") == \"22:39\"\n assert candidate(time = \"0?:??\") == \"09:59\"\n assert candidate(time = \"?4:?8\") == \"14:58\"\n assert candidate(time = \"0?:?0\") == \"09:50\"\n assert candidate(time = \"20:?4\") == \"20:54\"\n assert candidate(time = \"1?:59\") == \"19:59\"\n assert candidate(time = \"0?:0?\") == \"09:09\"\n assert candidate(time = \"23:??\") == \"23:59\"\n assert candidate(time = \"?0:?0\") == \"20:50\"\n assert candidate(time = \"0?:1?\") == \"09:19\"\n assert candidate(time = \"1?:2?\") == \"19:29\"\n assert candidate(time = \"0?:?8\") == \"09:58\"\n assert candidate(time = \"19:?8\") == \"19:58\"\n assert candidate(time = \"?2:?5\") == \"22:55\"\n assert candidate(time = \"0?:45\") == \"09:45\"\n assert candidate(time = \"2?:?9\") == \"23:59\"\n assert candidate(time = \"?3:5?\") == \"23:59\"\n assert candidate(time = \"23:?8\") == \"23:58\"\n assert candidate(time = \"09:??\") == \"09:59\"\n assert candidate(time = \"2?:?8\") == \"23:58\"\n assert candidate(time = \"2?:2?\") == \"23:29\"\n"}, "metadata": {"canonical_parameter_names": ["time"], "leetcode_dataset_entry_point": "Solution().maximumTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string maximumTime(string time) {", "container": "Solution", "callable": "maximumTime", "parameters": [{"name": "time", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1737, "task_id": "change-minimum-characters-to-satisfy-one-of-three-conditions", "difficulty": "Medium", "problem_description": "You are given two strings a and b that consist of lowercase letters. In one operation, you can change any character in a or b to any lowercase letter.\nYour goal is to satisfy one of the following three conditions:\n\nEvery letter in a is strictly less than every letter in b in the alphabet.\nEvery letter in b is strictly less than every letter in a in the alphabet.\nBoth a and b consist of only one distinct letter.\n\nReturn the minimum number of operations needed to achieve your goal.\n \nExample 1:\n\nInput: a = \"aba\", b = \"caa\"\nOutput: 2\nExplanation: Consider the best way to make each condition true:\n1) Change b to \"ccc\" in 2 operations, then every letter in a is less than every letter in b.\n2) Change a to \"bbb\" and b to \"aaa\" in 3 operations, then every letter in b is less than every letter in a.\n3) Change a to \"aaa\" and b to \"aaa\" in 2 operations, then a and b consist of one distinct letter.\nThe best way was done in 2 operations (either condition 1 or condition 3).\n\nExample 2:\n\nInput: a = \"dabadd\", b = \"cda\"\nOutput: 3\nExplanation: The best way is to make condition 1 true by changing b to \"eee\".\n\n \nConstraints:\n\n1 <= a.length, b.length <= 105\na and b consist only of lowercase letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(a = \"abc\",b = \"bcd\") == 2\n assert candidate(a = \"aba\",b = \"caa\") == 2\n assert candidate(a = \"xyzz\",b = \"zzzz\") == 2\n assert candidate(a = \"abcd\",b = \"dcba\") == 4\n assert candidate(a = \"aaaabbbb\",b = \"ccccdddd\") == 0\n assert candidate(a = \"xyz\",b = \"abc\") == 0\n assert candidate(a = \"abc\",b = \"def\") == 0\n assert candidate(a = \"abcdefghijklmnopqrstuvwxyz\",b = \"abcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(a = \"zzz\",b = \"aaa\") == 0\n assert candidate(a = \"abc\",b = \"abc\") == 3\n assert candidate(a = \"a\",b = \"z\") == 0\n assert candidate(a = \"aaa\",b = \"zzz\") == 0\n assert candidate(a = \"abacabadabacaba\",b = \"zzzyzxzyzxzyzxz\") == 0\n assert candidate(a = \"aabbcc\",b = \"bbccdd\") == 4\n assert candidate(a = \"xyz\",b = \"xyz\") == 3\n assert candidate(a = \"abcdefghijklmnopqrstuvwxyz\",b = \"zyxwvutsrqponmlkjihgfedcba\") == 26\n assert candidate(a = \"xyz\",b = \"zyx\") == 3\n assert candidate(a = \"aaa\",b = \"bbb\") == 0\n assert candidate(a = \"dabadd\",b = \"cda\") == 3\n assert candidate(a = \"a\",b = \"b\") == 0\n assert candidate(a = \"aaaa\",b = \"bbbb\") == 0\n assert candidate(a = \"aaaaabbbbbccccc\",b = \"cccccbbaaaa\") == 11\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"aaaaa\") == 0\n assert candidate(a = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",b = \"zyxwvutsrqponmlkjihgfedcba\") == 27\n assert candidate(a = \"qwert\",b = \"asdfg\") == 2\n assert candidate(a = \"ababababababababababababababab\",b = \"bababababababababababababababa\") == 30\n assert candidate(a = \"algorithm\",b = \"datastructure\") == 7\n assert candidate(a = \"abcabcabcabcabcabcabcabcabcabc\",b = \"zzzzyyyxxxwwwwvvvvuuuuttttssssrrrrqqqqppppooooonnnnmmmmmlllllkkkkkjjjjjiiiii\") == 0\n assert candidate(a = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\",b = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\") == 0\n assert candidate(a = \"abcdabcdabcdabcdabcd\",b = \"dcbaabcdabcdabcdabcd\") == 20\n assert candidate(a = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbcb\",b = \"abadabadabadabadabadabadabadabadabadabadabadabadabadabadabadabadabadabadabadab\") == 39\n assert candidate(a = \"aaabbbcccddd\",b = \"eefffgggg\") == 0\n assert candidate(a = \"aaaaaaaaaabbbbbbbbbbbccccccccc\",b = \"zzzzzzzzzzzyyyyyyyyyyxxxxxxxxxx\") == 0\n assert candidate(a = \"abababababababababab\",b = \"babababababababababa\") == 20\n assert candidate(a = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 25\n assert candidate(a = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabb\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(a = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",b = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == 52\n assert candidate(a = \"mnopmnopmnopmnopmnop\",b = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == 0\n assert candidate(a = \"abacabadabacabadabacaba\",b = \"zyxzyxzyxzyxzyxzyxzyxzyx\") == 0\n assert candidate(a = \"aaaaa\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(a = \"aaaaaabbbbccccdddd\",b = \"eeeeefffffggggghhhhh\") == 0\n assert candidate(a = \"abcdefg\",b = \"hijklmnopqrstuvwxyz\") == 0\n assert candidate(a = \"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj\",b = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\") == 0\n assert candidate(a = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 2\n assert candidate(a = \"mississippi\",b = \"bababababa\") == 0\n assert candidate(a = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\",b = \"pppppppppppppppppppppppppppppppppppppppppp\") == 0\n assert candidate(a = \"mnop\",b = \"qrst\") == 0\n assert candidate(a = \"qazwsxedcrfvtgbyhnujmikolp\",b = \"ploikmjhunbygvtfredcxswqaz\") == 26\n assert candidate(a = \"hello\",b = \"world\") == 3\n assert candidate(a = \"mno\",b = \"jkl\") == 0\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(a = \"hellohellohello\",b = \"worldworldworld\") == 9\n assert candidate(a = \"mmmmmmmmmmmmmmmmmmmmmm\",b = \"nnnnnnnnnnnnnnnnnnnnnn\") == 0\n assert candidate(a = \"aabaaaacaba\",b = \"bcdef\") == 2\n assert candidate(a = \"zzzzzzzzzz\",b = \"aaaaaaaaaa\") == 0\n assert candidate(a = \"aaaaaaaaaaaaaabbbbbbbbbbbbbbcccccccccccccccccdddddddddddddddd\",b = \"eeeeeeeeeeeeeeeeffffffffgggggggggggggggggghhhhhhhhhhhhhhhhhiiiiiiiiiiiiiiiiii\") == 0\n assert candidate(a = \"qwertqwertqwert\",b = \"mnbvmnbvmnbv\") == 6\n assert candidate(a = \"aaaabbbbccccddddeeeeffffgggghhhhiiii\",b = \"jkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == 0\n assert candidate(a = \"qwertyuiop\",b = \"poiuytrewq\") == 10\n assert candidate(a = \"mno\",b = \"mnpq\") == 2\n assert candidate(a = \"llllllllllllllllllllllllllllllllllllllll\",b = \"kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk\") == 0\n assert candidate(a = \"programming\",b = \"contest\") == 4\n assert candidate(a = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",b = \"zzxxwwvvutssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == 48\n assert candidate(a = \"xyzzzzzxyzzzzz\",b = \"zzzzzxyzzzzzxy\") == 8\n assert candidate(a = \"zzzzz\",b = \"aaaaa\") == 0\n assert candidate(a = \"zzzzzzzzzzzzzz\",b = \"aaaaaaaaaaaaaa\") == 0\n assert candidate(a = \"ababababababababababababababababab\",b = \"bababababababababababababababababa\") == 34\n assert candidate(a = \"ppppqqqqqqrrrrrrsssssss\",b = \"tttttuuuuuuuuvvvvvvvvvvvvv\") == 0\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 0\n assert candidate(a = \"qwerttyuiiopasdfghjklzzxcvbnm\",b = \"mnbvcxzlkjhgfdsapoiuytrewq\") == 26\n assert candidate(a = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 2\n assert candidate(a = \"python\",b = \"java\") == 2\n assert candidate(a = \"pqrstuv\",b = \"mnopq\") == 2\n assert candidate(a = \"abcdefghijklmnopqrstuvwxyz\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(a = \"acabcbacbacbacbaca\",b = \"bdadbdadbdadbdad\") == 8\n assert candidate(a = \"abcdefghijklmnopqrstu\",b = \"vwxyzvwxyzvwxyzvwxyz\") == 0\n assert candidate(a = \"abcdefghijklmnop\",b = \"zyxwvutsrqponmlkjihgfedcba\") == 16\n assert candidate(a = \"abcdefghijklmnopqrstuvwxyz\",b = \"abcdefghijklmnopqrstuvwxy\") == 25\n assert candidate(a = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",b = \"defdefdefdefdefdefdefdefdefdefdefdefdefdefdefdefdefdef\") == 0\n assert candidate(a = \"abcabcabcabcabcabcabcabcabcabc\",b = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == 0\n assert candidate(a = \"aabbaacc\",b = \"zzzzyyxx\") == 0\n assert candidate(a = \"aaaabbbbcccc\",b = \"ccccbbbbaaaa\") == 12\n assert candidate(a = \"abcdefg\",b = \"zzzzzzz\") == 0\n assert candidate(a = \"abcdefghijklmnopqrstuvwxy\",b = \"zyxwvutsrqponmlkjihgfedcba\") == 25\n assert candidate(a = \"acacacacacacacacacacacacacacaca\",b = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc\") == 15\n assert candidate(a = \"mnop\",b = \"qrstuvwxyza\") == 1\n assert candidate(a = \"abcdabcdabcd\",b = \"xyzxyzxyzxyz\") == 0\n assert candidate(a = \"abacabadabacaba\",b = \"zyxzyxzyxzyxzyxzyx\") == 0\n assert candidate(a = \"same\",b = \"same\") == 4\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 0\n assert candidate(a = \"mnopqrstu\",b = \"vwxyzijkl\") == 4\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"abcdefghijklmnopqrstuvwxyz\") == 1\n assert candidate(a = \"mnopqrstuvwxy\",b = \"abcdefghijklmnopqrstuvwxyz\") == 14\n assert candidate(a = \"abcdabcabc\",b = \"zyxzxyzxyz\") == 0\n assert candidate(a = \"abacabadabacabad\",b = \"zyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyx\") == 0\n assert candidate(a = \"abcabcabcabcabcabcabcabcabcabc\",b = \"abcabcabcabcabcabcabcabcabcabc\") == 30\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(a = \"abcdefghijklm\",b = \"nopqrstuvwxyz\") == 0\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 0\n assert candidate(a = \"mnopqrstuvwxyzmnopqrstu\",b = \"abcdefghijklmnopqrstuabcdefghijklmnopqrstu\") == 18\n assert candidate(a = \"aaabbbcccdddeeefffggghhhhiiiiijjjjjjkkkkkkkllllllllmmmmmmmmmmm\",b = \"mnopqrstuvwxyzmnopqrstuvwxyzmnopqrstuvwxyzmnopqrstuvwxyz\") == 4\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 0\n assert candidate(a = \"aaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccdddddddddddddddddddddd\",b = \"eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\") == 0\n assert candidate(a = \"xyxzyzxzyzxzyzxzyz\",b = \"zyxzyzxzyzxzyzxzyx\") == 18\n assert candidate(a = \"abcdefghijklmnop\",b = \"qrstuvwxyz\") == 0\n assert candidate(a = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",b = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(a = \"xyzz\",b = \"abcd\") == 0\n assert candidate(a = \"racecar\",b = \"madam\") == 5\n assert candidate(a = \"abcdefghijklmnopqrstu\",b = \"vwxyzabcdefghijklmnopqrstu\") == 21\n assert candidate(a = \"qwe\",b = \"qwer\") == 3\n assert candidate(a = \"pppppppppppppppppppppppppppppppppppppppppp\",b = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\") == 0\n assert candidate(a = \"mnbvcxzlkjhgfdsapoiuytrewq\",b = \"qwertyuiopasdfghjklzxcvbnm\") == 26\n assert candidate(a = \"abcdabcdabcd\",b = \"dcbaabcdabcd\") == 12\n assert candidate(a = \"aaaaabbbbb\",b = \"bbbbbccccc\") == 5\n assert candidate(a = \"aaabbbcccdddeeefffggghhhiii\",b = \"kkklllmmmnnnooopppqqqrrrssstttuuuvvv\") == 0\n assert candidate(a = \"aaaaaaaaaaaaaaaaaaaaaaa\",b = \"bbbbbbbbbbbbbbbbbbbbbbbbb\") == 0\n assert candidate(a = \"abacabadabacabadabacabad\",b = \"zzzzyyyyxxxxyyyyzzzz\") == 0\n assert candidate(a = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",b = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeeeddccbbbaa\") == 52\n assert candidate(a = \"abacabadabacaba\",b = \"zzzyyyxxxwwwwvvvvuuuuuuttttttsssssrrrrrqqqqqqpppppoonnnnmmmllllkkkkjjjjiiiihhhhhgggggffffffeeeeeeeedddddccccbbbaaaa\") == 10\n assert candidate(a = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",b = \"zzzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == 52\n assert candidate(a = \"mnopqrstuvwxyz\",b = \"abcdefghijklm\") == 1\n assert candidate(a = \"one\",b = \"two\") == 1\n assert candidate(a = \"qwertyuiopasdfghjklzxcvbnm\",b = \"qwertyuiopasdfghjklzxcvbnm\") == 26\n assert candidate(a = \"mississippi\",b = \"delaware\") == 3\n assert candidate(a = \"abcdefghijklmnopqrstuvwxyz\",b = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 1\n assert candidate(a = \"abc\",b = \"xyz\") == 0\n assert candidate(a = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",b = \"abcdefghijklmnopqrstuvwxyz\") == 27\n assert candidate(a = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",b = \"mnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnopmnop\") == 0\n"}, "metadata": {"canonical_parameter_names": ["a", "b"], "leetcode_dataset_entry_point": "Solution().minCharacters", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minCharacters(string a, string b) {", "container": "Solution", "callable": "minCharacters", "parameters": [{"name": "a", "type": "string"}, {"name": "b", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1738, "task_id": "find-kth-largest-xor-coordinate-value", "difficulty": "Medium", "problem_description": "You are given a 2D matrix of size m x n, consisting of non-negative integers. You are also given an integer k.\nThe value of coordinate (a, b) of the matrix is the XOR of all matrix[i][j] where 0 <= i <= a < m and 0 <= j <= b < n (0-indexed).\nFind the kth largest value (1-indexed) of all the coordinates of matrix.\n \nExample 1:\n\nInput: matrix = [[5,2],[1,6]], k = 1\nOutput: 7\nExplanation: The value of coordinate (0,1) is 5 XOR 2 = 7, which is the largest value.\n\nExample 2:\n\nInput: matrix = [[5,2],[1,6]], k = 2\nOutput: 5\nExplanation: The value of coordinate (0,0) is 5 = 5, which is the 2nd largest value.\n\nExample 3:\n\nInput: matrix = [[5,2],[1,6]], k = 3\nOutput: 4\nExplanation: The value of coordinate (1,0) is 5 XOR 1 = 4, which is the 3rd largest value.\n \nConstraints:\n\nm == matrix.length\nn == matrix[i].length\n1 <= m, n <= 1000\n0 <= matrix[i][j] <= 106\n1 <= k <= m * n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[5, 2, 3], [1, 6, 4]],k = 5) == 4\n assert candidate(matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]],k = 9) == 0\n assert candidate(matrix = [[5, 2, 3], [1, 6, 4], [7, 8, 9]],k = 9) == 0\n assert candidate(matrix = [[10, 12, 3], [1, 6, 4], [7, 8, 9]],k = 4) == 10\n assert candidate(matrix = [[10, 20], [30, 40]],k = 1) == 40\n assert candidate(matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],k = 5) == 2\n assert candidate(matrix = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],k = 4) == 1\n assert candidate(matrix = [[0, 0], [0, 0]],k = 1) == 0\n assert candidate(matrix = [[5, 2], [1, 6]],k = 1) == 7\n assert candidate(matrix = [[5, 2, 3], [1, 6, 4]],k = 1) == 7\n assert candidate(matrix = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],k = 9) == 0\n assert candidate(matrix = [[1, 2], [3, 4], [5, 6]],k = 6) == 1\n assert candidate(matrix = [[5, 2], [1, 6]],k = 3) == 4\n assert candidate(matrix = [[5, 2], [1, 6]],k = 2) == 5\n assert candidate(matrix = [[1, 2], [3, 4], [5, 6]],k = 4) == 3\n assert candidate(matrix = [[1000000, 999999, 999998], [999997, 999996, 999995], [999994, 999993, 999992]],k = 6) == 126\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [11, 10, 9, 8, 7, 6, 5, 4, 3, 2]],k = 25) == 2\n assert candidate(matrix = [[5, 8, 9, 12, 15], [14, 11, 10, 7, 4], [3, 6, 7, 10, 13], [12, 15, 14, 11, 8], [1, 4, 5, 8, 11]],k = 18) == 5\n assert candidate(matrix = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]],k = 5) == 1\n assert candidate(matrix = [[100, 200, 300], [400, 500, 600], [700, 800, 900], [1000, 1100, 1200]],k = 10) == 172\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]],k = 25) == 0\n assert candidate(matrix = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]],k = 10) == 0\n assert candidate(matrix = [[9, 10, 11], [12, 13, 14], [15, 16, 17], [18, 19, 20]],k = 8) == 8\n assert candidate(matrix = [[8, 6, 2, 5, 8, 4, 9], [4, 5, 5, 6, 9, 8, 9], [7, 3, 8, 7, 5, 6, 2], [4, 3, 1, 2, 3, 4, 5], [5, 6, 7, 8, 9, 0, 1]],k = 15) == 11\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 50) == 0\n assert candidate(matrix = [[1, 3, 5, 7, 9, 11, 13], [15, 17, 19, 21, 23, 25, 27], [29, 31, 33, 35, 37, 39, 41]],k = 12) == 14\n assert candidate(matrix = [[25, 10, 15, 20], [5, 30, 35, 40], [45, 50, 55, 60], [65, 70, 75, 80]],k = 15) == 8\n assert candidate(matrix = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]],k = 13) == 0\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],k = 25) == 1\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64]],k = 30) == 7\n assert candidate(matrix = [[3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5], [3, 5, 8, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4], [3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9], [7, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5]],k = 18) == 9\n assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],k = 1) == 0\n assert candidate(matrix = [[9, 18, 27, 36, 45], [44, 35, 26, 17, 8], [7, 16, 25, 34, 43], [42, 33, 24, 15, 6], [5, 14, 23, 32, 41]],k = 20) == 8\n assert candidate(matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],k = 10) == 3\n assert candidate(matrix = [[1000000, 999999, 999998], [999997, 999996, 999995], [999994, 999993, 999992]],k = 9) == 123\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],k = 30) == 0\n assert candidate(matrix = [[5, 2, 15, 6, 3], [10, 1, 4, 7, 8], [3, 1, 9, 2, 12], [6, 14, 11, 13, 5], [1, 15, 8, 6, 7]],k = 20) == 6\n assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],k = 16) == 0\n assert candidate(matrix = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100]],k = 8) == 20\n assert candidate(matrix = [[7, 1, 4, 2], [9, 6, 3, 8], [5, 0, 10, 12], [15, 11, 14, 13]],k = 7) == 8\n assert candidate(matrix = [[2, 4, 6, 8, 10], [12, 14, 16, 18, 20], [22, 24, 26, 28, 30], [32, 34, 36, 38, 40], [42, 44, 46, 48, 50]],k = 14) == 8\n assert candidate(matrix = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [4, 4, 4, 4, 4], [5, 5, 5, 5, 5]],k = 12) == 1\n assert candidate(matrix = [[5, 2, 15, 10], [1, 6, 8, 3], [12, 4, 7, 9], [14, 11, 13, 5]],k = 10) == 6\n assert candidate(matrix = [[8, 12, 7, 3, 15], [9, 6, 11, 14, 4], [13, 8, 2, 5, 9], [1, 10, 7, 12, 8], [6, 4, 14, 3, 13]],k = 13) == 7\n assert candidate(matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]],k = 1) == 0\n assert candidate(matrix = [[999999, 999999, 999999], [999999, 999999, 999999], [999999, 999999, 999999]],k = 9) == 0\n assert candidate(matrix = [[13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]],k = 14) == 12\n assert candidate(matrix = [[15, 9, 12, 3], [11, 6, 4, 14], [7, 8, 9, 13], [2, 5, 10, 1]],k = 7) == 8\n assert candidate(matrix = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],k = 10) == 1\n assert candidate(matrix = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]],k = 10) == 8\n assert candidate(matrix = [[3, 4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14], [15, 16, 17, 18]],k = 15) == 0\n assert candidate(matrix = [[1, 0, 0, 1, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]],k = 12) == 1\n assert candidate(matrix = [[31, 41, 59, 26, 53], [58, 97, 93, 23, 84], [62, 64, 33, 83, 27], [95, 25, 43, 30, 48], [67, 47, 54, 90, 88]],k = 17) == 31\n assert candidate(matrix = [[256, 512, 1024], [128, 256, 512], [64, 128, 256]],k = 5) == 640\n assert candidate(matrix = [[3, 1, 2], [4, 1, 1], [5, 10, 6]],k = 6) == 3\n assert candidate(matrix = [[3, 6, 9, 12], [4, 7, 10, 13], [5, 8, 11, 14]],k = 7) == 5\n assert candidate(matrix = [[3, 8, 1], [9, 11, 13], [4, 7, 12]],k = 6) == 10\n assert candidate(matrix = [[1000000, 0, 0, 0, 0, 0, 0], [0, 1000000, 0, 0, 0, 0, 0], [0, 0, 1000000, 0, 0, 0, 0], [0, 0, 0, 1000000, 0, 0, 0], [0, 0, 0, 0, 1000000, 0, 0], [0, 0, 0, 0, 0, 1000000, 0], [0, 0, 0, 0, 0, 0, 1000000]],k = 25) == 1000000\n assert candidate(matrix = [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24]],k = 25) == 0\n assert candidate(matrix = [[9, 8, 7, 6, 5, 4], [3, 2, 1, 0, 9, 8], [7, 6, 5, 4, 3, 2], [1, 0, 9, 8, 7, 6], [5, 4, 3, 2, 1, 0]],k = 30) == 0\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 25) == 0\n assert candidate(matrix = [[9, 11, 13, 15, 17, 19, 21], [23, 25, 27, 29, 31, 33, 35], [37, 39, 41, 43, 45, 47, 49]],k = 25) == 0\n assert candidate(matrix = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]],k = 14) == 0\n assert candidate(matrix = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],k = 20) == 1\n assert candidate(matrix = [[1000000, 999999, 999998, 999997], [999996, 999995, 999994, 999993], [999992, 999991, 999990, 999989]],k = 6) == 124\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 1) == 1\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],k = 20) == 7\n assert candidate(matrix = [[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]],k = 15) == 5\n assert candidate(matrix = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11], [4, 6, 8, 10, 12], [5, 7, 9, 11, 13]],k = 13) == 4\n assert candidate(matrix = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]],k = 25) == 0\n assert candidate(matrix = [[1000000, 999999, 999998, 999997, 999996], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],k = 15) == 1000000\n assert candidate(matrix = [[7, 7, 7], [7, 7, 7], [7, 7, 7]],k = 4) == 7\n assert candidate(matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],k = 1) == 15\n assert candidate(matrix = [[1000000, 999999, 999998, 999997], [999996, 999995, 999994, 999993], [999992, 999991, 999990, 999989], [999988, 999987, 999986, 999985]],k = 10) == 120\n assert candidate(matrix = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]],k = 3) == 7\n assert candidate(matrix = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [6, 7, 8, 9, 10], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15]],k = 10) == 4\n assert candidate(matrix = [[1000000, 200000, 30000], [4000, 5000, 6000], [70, 80, 900]],k = 8) == 799482\n assert candidate(matrix = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [60, 70, 80, 90, 100], [55, 65, 75, 85, 95]],k = 15) == 10\n assert candidate(matrix = [[42, 42, 42, 42, 42], [42, 42, 42, 42, 42], [42, 42, 42, 42, 42], [42, 42, 42, 42, 42], [42, 42, 42, 42, 42]],k = 15) == 0\n assert candidate(matrix = [[2, 4, 6, 8, 10, 12], [14, 16, 18, 20, 22, 24], [26, 28, 30, 32, 34, 36]],k = 17) == 2\n assert candidate(matrix = [[15, 14, 13, 12], [11, 10, 9, 8], [7, 6, 5, 4], [3, 2, 1, 0]],k = 10) == 0\n assert candidate(matrix = [[23, 56, 12, 78], [34, 89, 56, 45], [12, 34, 56, 78], [89, 56, 23, 12]],k = 10) == 47\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],k = 25) == 0\n assert candidate(matrix = [[100, 200, 300], [400, 500, 600], [700, 800, 900]],k = 5) == 384\n assert candidate(matrix = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [20, 22, 24, 26, 28]],k = 12) == 7\n assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]],k = 16) == 0\n assert candidate(matrix = [[3, 5, 11, 13], [8, 2, 12, 7], [4, 6, 9, 15], [1, 10, 3, 8]],k = 6) == 11\n"}, "metadata": {"canonical_parameter_names": ["matrix", "k"], "leetcode_dataset_entry_point": "Solution().kthLargestValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int kthLargestValue(vector>& matrix, int k) {", "container": "Solution", "callable": "kthLargestValue", "parameters": [{"name": "matrix", "type": "vector>&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1739, "task_id": "building-boxes", "difficulty": "Hard", "problem_description": "You have a cubic storeroom where the width, length, and height of the room are all equal to n units. You are asked to place n boxes in this room where each box is a cube of unit side length. There are however some rules to placing the boxes:\n\nYou can place the boxes anywhere on the floor.\nIf box x is placed on top of the box y, then each side of the four vertical sides of the box y must either be adjacent to another box or to a wall.\n\nGiven an integer n, return the minimum possible number of boxes touching the floor.\n \nExample 1:\n\n\nInput: n = 3\nOutput: 3\nExplanation: The figure above is for the placement of the three boxes.\nThese boxes are placed in the corner of the room, where the corner is on the left side.\n\nExample 2:\n\n\nInput: n = 4\nOutput: 3\nExplanation: The figure above is for the placement of the four boxes.\nThese boxes are placed in the corner of the room, where the corner is on the left side.\n\nExample 3:\n\n\nInput: n = 10\nOutput: 6\nExplanation: The figure above is for the placement of the ten boxes.\nThese boxes are placed in the corner of the room, where the corner is on the back side.\n \nConstraints:\n\n1 <= n <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 8) == 6\n assert candidate(n = 3) == 3\n assert candidate(n = 100) == 34\n assert candidate(n = 15) == 9\n assert candidate(n = 4) == 3\n assert candidate(n = 1000000) == 16443\n assert candidate(n = 20) == 10\n assert candidate(n = 1) == 1\n assert candidate(n = 1000000000) == 1650467\n assert candidate(n = 1000) == 161\n assert candidate(n = 10) == 6\n assert candidate(n = 329) == 75\n assert candidate(n = 344) == 77\n assert candidate(n = 729) == 130\n assert candidate(n = 567890) == 11279\n assert candidate(n = 324) == 75\n assert candidate(n = 300) == 71\n assert candidate(n = 333) == 76\n assert candidate(n = 316) == 74\n assert candidate(n = 23) == 12\n assert candidate(n = 303) == 72\n assert candidate(n = 334) == 76\n assert candidate(n = 35) == 15\n assert candidate(n = 347) == 77\n assert candidate(n = 5000) == 474\n assert candidate(n = 567890123) == 1131581\n assert candidate(n = 4913) == 464\n assert candidate(n = 200) == 53\n assert candidate(n = 500000000) == 1039682\n assert candidate(n = 313) == 73\n assert candidate(n = 500) == 100\n assert candidate(n = 317) == 74\n assert candidate(n = 3375) == 365\n assert candidate(n = 897543210) == 1535456\n assert candidate(n = 341) == 76\n assert candidate(n = 216) == 55\n assert candidate(n = 50000) == 2210\n assert candidate(n = 987654) == 16287\n assert candidate(n = 314) == 73\n assert candidate(n = 318) == 74\n assert candidate(n = 100000) == 3536\n assert candidate(n = 25) == 13\n assert candidate(n = 350) == 77\n assert candidate(n = 5000000) == 48159\n assert candidate(n = 325) == 75\n assert candidate(n = 305) == 72\n assert candidate(n = 123456789) == 408968\n assert candidate(n = 999999) == 16443\n assert candidate(n = 308) == 73\n assert candidate(n = 12167) == 857\n assert candidate(n = 342) == 77\n assert candidate(n = 666) == 120\n assert candidate(n = 315) == 74\n assert candidate(n = 999999999) == 1650467\n assert candidate(n = 2000) == 252\n assert candidate(n = 250000000) == 654763\n assert candidate(n = 30) == 14\n assert candidate(n = 23456789) == 135151\n assert candidate(n = 345) == 77\n assert candidate(n = 336) == 76\n assert candidate(n = 9261) == 719\n assert candidate(n = 311) == 73\n assert candidate(n = 310) == 73\n assert candidate(n = 337) == 76\n assert candidate(n = 343) == 77\n assert candidate(n = 339) == 76\n assert candidate(n = 320) == 74\n assert candidate(n = 332) == 76\n assert candidate(n = 987654321) == 1636751\n assert candidate(n = 307) == 72\n assert candidate(n = 309) == 73\n assert candidate(n = 500000) == 10365\n assert candidate(n = 328) == 75\n assert candidate(n = 348) == 77\n assert candidate(n = 304) == 72\n assert candidate(n = 1500) == 208\n assert candidate(n = 2197) == 272\n assert candidate(n = 1331) == 191\n assert candidate(n = 319) == 74\n assert candidate(n = 125) == 39\n assert candidate(n = 321) == 74\n assert candidate(n = 6859) == 586\n assert candidate(n = 50) == 20\n assert candidate(n = 323) == 75\n assert candidate(n = 331) == 75\n assert candidate(n = 40) == 18\n assert candidate(n = 327) == 75\n assert candidate(n = 349) == 77\n assert candidate(n = 10000) == 756\n assert candidate(n = 335) == 76\n assert candidate(n = 302) == 72\n assert candidate(n = 312) == 73\n assert candidate(n = 330) == 75\n assert candidate(n = 322) == 74\n assert candidate(n = 338) == 76\n assert candidate(n = 306) == 72\n assert candidate(n = 326) == 75\n assert candidate(n = 301) == 71\n assert candidate(n = 123456) == 4068\n assert candidate(n = 346) == 77\n assert candidate(n = 340) == 76\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().minimumBoxes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumBoxes(int n) {", "container": "Solution", "callable": "minimumBoxes", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1742, "task_id": "maximum-number-of-balls-in-a-box", "difficulty": "Easy", "problem_description": "You are working in a ball factory where you have n balls numbered from lowLimit up to highLimit inclusive (i.e., n == highLimit - lowLimit + 1), and an infinite number of boxes numbered from 1 to infinity.\nYour job at this factory is to put each ball in the box with a number equal to the sum of digits of the ball's number. For example, the ball number 321 will be put in the box number 3 + 2 + 1 = 6 and the ball number 10 will be put in the box number 1 + 0 = 1.\nGiven two integers lowLimit and highLimit, return the number of balls in the box with the most balls.\n \nExample 1:\n\nInput: lowLimit = 1, highLimit = 10\nOutput: 2\nExplanation:\nBox Number: 1 2 3 4 5 6 7 8 9 10 11 ...\nBall Count: 2 1 1 1 1 1 1 1 1 0 0 ...\nBox 1 has the most number of balls with 2 balls.\nExample 2:\n\nInput: lowLimit = 5, highLimit = 15\nOutput: 2\nExplanation:\nBox Number: 1 2 3 4 5 6 7 8 9 10 11 ...\nBall Count: 1 1 1 1 2 2 1 1 1 0 0 ...\nBoxes 5 and 6 have the most number of balls with 2 balls in each.\n\nExample 3:\n\nInput: lowLimit = 19, highLimit = 28\nOutput: 2\nExplanation:\nBox Number: 1 2 3 4 5 6 7 8 9 10 11 12 ...\nBall Count: 0 1 1 1 1 1 1 1 1 2 0 0 ...\nBox 10 has the most number of balls with 2 balls.\n\n \nConstraints:\n\n1 <= lowLimit <= highLimit <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(lowLimit = 999,highLimit = 1000) == 1\n assert candidate(lowLimit = 1000,highLimit = 10000) == 615\n assert candidate(lowLimit = 50000,highLimit = 50500) == 44\n assert candidate(lowLimit = 99,highLimit = 999) == 70\n assert candidate(lowLimit = 500,highLimit = 550) == 6\n assert candidate(lowLimit = 9999,highLimit = 100000) == 5520\n assert candidate(lowLimit = 1,highLimit = 10) == 2\n assert candidate(lowLimit = 100,highLimit = 200) == 10\n assert candidate(lowLimit = 99,highLimit = 199) == 10\n assert candidate(lowLimit = 1,highLimit = 100) == 10\n assert candidate(lowLimit = 1,highLimit = 20) == 3\n assert candidate(lowLimit = 10,highLimit = 100) == 9\n assert candidate(lowLimit = 50,highLimit = 150) == 10\n assert candidate(lowLimit = 5,highLimit = 15) == 2\n assert candidate(lowLimit = 19,highLimit = 28) == 2\n assert candidate(lowLimit = 45678,highLimit = 98765) == 3544\n assert candidate(lowLimit = 40000,highLimit = 50000) == 670\n assert candidate(lowLimit = 10000,highLimit = 20000) == 670\n assert candidate(lowLimit = 33333,highLimit = 44444) == 782\n assert candidate(lowLimit = 67890,highLimit = 67990) == 11\n assert candidate(lowLimit = 54321,highLimit = 54421) == 10\n assert candidate(lowLimit = 88888,highLimit = 88988) == 10\n assert candidate(lowLimit = 100,highLimit = 100) == 1\n assert candidate(lowLimit = 99999,highLimit = 100000) == 1\n assert candidate(lowLimit = 9995,highLimit = 10005) == 1\n assert candidate(lowLimit = 43210,highLimit = 43250) == 5\n assert candidate(lowLimit = 99995,highLimit = 100005) == 1\n assert candidate(lowLimit = 30000,highLimit = 35000) == 365\n assert candidate(lowLimit = 98765,highLimit = 98865) == 10\n assert candidate(lowLimit = 54321,highLimit = 54341) == 3\n assert candidate(lowLimit = 11111,highLimit = 11115) == 1\n assert candidate(lowLimit = 10000,highLimit = 99999) == 5520\n assert candidate(lowLimit = 66666,highLimit = 66766) == 10\n assert candidate(lowLimit = 77777,highLimit = 77800) == 3\n assert candidate(lowLimit = 99990,highLimit = 100000) == 1\n assert candidate(lowLimit = 11111,highLimit = 11200) == 9\n assert candidate(lowLimit = 5000,highLimit = 6000) == 75\n assert candidate(lowLimit = 56789,highLimit = 56800) == 2\n assert candidate(lowLimit = 55555,highLimit = 66666) == 782\n assert candidate(lowLimit = 9990,highLimit = 10000) == 1\n assert candidate(lowLimit = 12345,highLimit = 54321) == 2854\n assert candidate(lowLimit = 50000,highLimit = 50100) == 10\n assert candidate(lowLimit = 23456,highLimit = 23460) == 1\n assert candidate(lowLimit = 500,highLimit = 5000) == 340\n assert candidate(lowLimit = 5000,highLimit = 5100) == 10\n assert candidate(lowLimit = 90000,highLimit = 95000) == 365\n assert candidate(lowLimit = 10000,highLimit = 100000) == 5520\n assert candidate(lowLimit = 9999,highLimit = 10000) == 1\n assert candidate(lowLimit = 999,highLimit = 1009) == 1\n assert candidate(lowLimit = 12345,highLimit = 12395) == 6\n assert candidate(lowLimit = 1,highLimit = 99999) == 6000\n assert candidate(lowLimit = 12345,highLimit = 12345) == 1\n assert candidate(lowLimit = 1,highLimit = 1000) == 75\n assert candidate(lowLimit = 22222,highLimit = 22322) == 10\n assert candidate(lowLimit = 12345,highLimit = 67890) == 3699\n assert candidate(lowLimit = 56789,highLimit = 56799) == 2\n assert candidate(lowLimit = 100,highLimit = 1000) == 70\n assert candidate(lowLimit = 11111,highLimit = 22222) == 754\n assert candidate(lowLimit = 77777,highLimit = 77877) == 10\n assert candidate(lowLimit = 100000,highLimit = 100000) == 1\n assert candidate(lowLimit = 250,highLimit = 750) == 46\n assert candidate(lowLimit = 30000,highLimit = 40000) == 670\n assert candidate(lowLimit = 99900,highLimit = 100100) == 10\n assert candidate(lowLimit = 100000,highLimit = 100050) == 6\n assert candidate(lowLimit = 12345,highLimit = 12445) == 11\n assert candidate(lowLimit = 5000,highLimit = 5050) == 6\n assert candidate(lowLimit = 995,highLimit = 1005) == 1\n assert candidate(lowLimit = 1000,highLimit = 1050) == 6\n assert candidate(lowLimit = 33333,highLimit = 33433) == 10\n assert candidate(lowLimit = 1234,highLimit = 5678) == 344\n assert candidate(lowLimit = 8888,highLimit = 8900) == 2\n assert candidate(lowLimit = 11111,highLimit = 11211) == 10\n assert candidate(lowLimit = 999,highLimit = 1001) == 1\n assert candidate(lowLimit = 67890,highLimit = 78900) == 749\n assert candidate(lowLimit = 20000,highLimit = 30000) == 670\n assert candidate(lowLimit = 50000,highLimit = 51000) == 75\n assert candidate(lowLimit = 99,highLimit = 101) == 1\n assert candidate(lowLimit = 88888,highLimit = 99999) == 736\n assert candidate(lowLimit = 1234,highLimit = 1244) == 2\n assert candidate(lowLimit = 44444,highLimit = 55555) == 785\n assert candidate(lowLimit = 300,highLimit = 600) == 28\n assert candidate(lowLimit = 12345,highLimit = 12355) == 2\n assert candidate(lowLimit = 70000,highLimit = 80000) == 670\n assert candidate(lowLimit = 88888,highLimit = 88999) == 11\n assert candidate(lowLimit = 20000,highLimit = 25000) == 365\n assert candidate(lowLimit = 123,highLimit = 456) == 33\n"}, "metadata": {"canonical_parameter_names": ["lowLimit", "highLimit"], "leetcode_dataset_entry_point": "Solution().countBalls", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countBalls(int lowLimit, int highLimit) {", "container": "Solution", "callable": "countBalls", "parameters": [{"name": "lowLimit", "type": "int"}, {"name": "highLimit", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1743, "task_id": "restore-the-array-from-adjacent-pairs", "difficulty": "Medium", "problem_description": "There is an integer array nums that consists of n unique elements, but you have forgotten it. However, you do remember every pair of adjacent elements in nums.\nYou are given a 2D integer array adjacentPairs of size n - 1 where each adjacentPairs[i] = [ui, vi] indicates that the elements ui and vi are adjacent in nums.\nIt is guaranteed that every adjacent pair of elements nums[i] and nums[i+1] will exist in adjacentPairs, either as [nums[i], nums[i+1]] or [nums[i+1], nums[i]]. The pairs can appear in any order.\nReturn the original array nums. If there are multiple solutions, return any of them.\n \nExample 1:\n\nInput: adjacentPairs = [[2,1],[3,4],[3,2]]\nOutput: [1,2,3,4]\nExplanation: This array has all its adjacent pairs in adjacentPairs.\nNotice that adjacentPairs[i] may not be in left-to-right order.\n\nExample 2:\n\nInput: adjacentPairs = [[4,-2],[1,4],[-3,1]]\nOutput: [-2,4,1,-3]\nExplanation: There can be negative numbers.\nAnother solution is [-3,1,4,-2], which would also be accepted.\n\nExample 3:\n\nInput: adjacentPairs = [[100000,-100000]]\nOutput: [100000,-100000]\n\n \nConstraints:\n\nnums.length == n\nadjacentPairs.length == n - 1\nadjacentPairs[i].length == 2\n2 <= n <= 105\n-105 <= nums[i], ui, vi <= 105\nThere exists some nums that has adjacentPairs as its pairs.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(adjacentPairs = [[-1, 0], [0, 1], [1, 2], [2, 3], [3, -2]]) == [-1, 0, 1, 2, 3, -2]\n assert candidate(adjacentPairs = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60]]) == [10, 20, 30, 40, 50, 60]\n assert candidate(adjacentPairs = [[2, 1], [3, 4], [3, 2]]) == [1, 2, 3, 4]\n assert candidate(adjacentPairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700]]) == [100, 200, 300, 400, 500, 600, 700]\n assert candidate(adjacentPairs = [[-1, -2], [-2, -3], [-3, -4], [-4, -5], [-5, -6]]) == [-1, -2, -3, -4, -5, -6]\n assert candidate(adjacentPairs = [[-1, 2], [2, 3], [3, 4], [4, 5]]) == [-1, 2, 3, 4, 5]\n assert candidate(adjacentPairs = [[5, 1], [1, 2], [2, 3], [3, 4]]) == [5, 1, 2, 3, 4]\n assert candidate(adjacentPairs = [[100000, -100000]]) == [100000, -100000]\n assert candidate(adjacentPairs = [[5, 3], [3, 1], [1, 2], [2, 4], [4, 6]]) == [5, 3, 1, 2, 4, 6]\n assert candidate(adjacentPairs = [[-1, 0], [0, 1], [1, 2], [-2, -1]]) == [2, 1, 0, -1, -2]\n assert candidate(adjacentPairs = [[4, -2], [1, 4], [-3, 1]]) == [-2, 4, 1, -3]\n assert candidate(adjacentPairs = [[1, 6], [2, 3], [3, 4], [4, 5], [5, 6]]) == [1, 6, 5, 4, 3, 2]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == [1, 2, 3, 4, 5, 6]\n assert candidate(adjacentPairs = [[-1, 0], [0, 1], [1, 2], [2, 3], [3, 4]]) == [-1, 0, 1, 2, 3, 4]\n assert candidate(adjacentPairs = [[1, 6], [6, 8], [8, 3], [3, 7], [7, 2], [2, 5], [5, 4]]) == [1, 6, 8, 3, 7, 2, 5, 4]\n assert candidate(adjacentPairs = [[-1, 1], [-2, -1], [-3, -2], [4, -3], [5, 4], [6, 5], [7, 6]]) == [1, -1, -2, -3, 4, 5, 6, 7]\n assert candidate(adjacentPairs = [[-10, -20], [-20, -30], [-30, -40], [-40, -50], [-50, -60]]) == [-10, -20, -30, -40, -50, -60]\n assert candidate(adjacentPairs = [[-10000, 10000], [10000, 20000], [20000, -10000], [-20000, -10000], [30000, 20000], [30000, 40000]]) == [-20000, -10000, 20000, 10000, -10000, 20000, 10000]\n assert candidate(adjacentPairs = [[-5, -4], [-4, -3], [-3, -2], [-2, -1], [-1, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]\n assert candidate(adjacentPairs = [[100000, -100000], [99999, 100000], [-99999, -100000], [88888, 99999], [-88888, -99999]]) == [88888, 99999, 100000, -100000, -99999, -88888]\n assert candidate(adjacentPairs = [[-1, -2], [-2, -3], [-3, -4], [-4, -5], [-5, -6], [-6, -7], [-7, -8], [-8, -9], [-9, -10]]) == [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]\n assert candidate(adjacentPairs = [[-5, 0], [0, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55], [55, 60], [60, 65], [65, 70], [70, 75], [75, 80], [80, 85], [85, 90]]) == [-5, 0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90]\n assert candidate(adjacentPairs = [[-10, -20], [-20, -30], [-30, -40], [-40, -50], [-50, -60], [-60, -70], [-70, -80], [-80, -90], [-90, -100]]) == [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]\n assert candidate(adjacentPairs = [[-10, -9], [-9, -8], [-8, -7], [-7, -6], [-6, -5], [-5, -4], [-4, -3], [-3, -2], [-2, -1], [-1, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(adjacentPairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000], [1000, 1100], [1100, 1200], [1200, 1300], [1300, 1400], [1400, 1500]]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(adjacentPairs = [[1, 2], [3, 4], [5, 6], [1, 3], [4, 5]]) == [2, 1, 3, 4, 5, 6]\n assert candidate(adjacentPairs = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110], [110, 120]]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]\n assert candidate(adjacentPairs = [[100000, -100000], [-99999, 100000], [-99998, -99999], [-99997, -99998], [-99996, -99997], [-99995, -99996], [-99994, -99995], [-99993, -99994], [-99992, -99993], [-99991, -99992]]) == [-100000, 100000, -99999, -99998, -99997, -99996, -99995, -99994, -99993, -99992, -99991]\n assert candidate(adjacentPairs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(adjacentPairs = [[5, 15], [15, 25], [25, 35], [35, 45], [45, 55], [55, 65], [65, 75], [75, 85], [85, 95], [95, 105]]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]\n assert candidate(adjacentPairs = [[50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110], [110, 120], [120, 130], [130, 140], [140, 150]]) == [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]\n assert candidate(adjacentPairs = [[-5, 0], [0, 5], [5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [-5, -10], [-10, -15], [-15, -20], [-20, -25], [-25, -30], [-30, -35], [-35, -40], [-40, -45], [-45, -50]]) == [50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 0, -5, -10, -15, -20, -25, -30, -35, -40, -45, -50]\n assert candidate(adjacentPairs = [[-5, -4], [-4, -3], [-3, -2], [-2, -1], [-1, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]\n assert candidate(adjacentPairs = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21], [21, 23], [23, 25], [25, 27], [27, 29], [29, 31], [31, 33], [33, 35], [35, 37], [37, 39]]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]\n assert candidate(adjacentPairs = [[100000, 99999], [99998, 99999], [99997, 99998], [99996, 99997], [99995, 99996]]) == [100000, 99999, 99998, 99997, 99996, 99995]\n assert candidate(adjacentPairs = [[-10, -20], [-20, -30], [-30, -40], [-40, -50], [-50, -60], [-60, -70], [-70, -80], [-80, -90]]) == [-10, -20, -30, -40, -50, -60, -70, -80, -90]\n assert candidate(adjacentPairs = [[-1, 1], [-2, -1], [-3, -2], [-4, -3], [-5, -4], [-6, -5], [-7, -6], [-8, -7], [-9, -8], [-10, -9]]) == [1, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]\n assert candidate(adjacentPairs = [[10, 5], [5, -10], [-10, 15], [15, -15], [20, 10], [25, 20], [30, 25], [35, 30], [40, 35], [45, 40], [50, 45]]) == [-15, 15, -10, 5, 10, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(adjacentPairs = [[1, 2], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8], [10, 9], [11, 10], [12, 11], [13, 12], [14, 13], [15, 14], [16, 15], [17, 16], [18, 17], [19, 18], [20, 19]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(adjacentPairs = [[1, 2], [3, 2], [5, 4], [4, 3], [7, 6], [6, 5], [9, 8], [8, 7], [11, 10], [10, 9]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(adjacentPairs = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21]]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(adjacentPairs = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21], [21, 23], [23, 25], [25, 27], [27, 29]]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]\n assert candidate(adjacentPairs = [[5, 3], [3, 1], [1, -2], [-2, -4], [-4, -6], [-6, -8], [-8, -10], [-10, -12], [-12, -14], [-14, -16], [-16, -18], [-18, -20], [-20, -22], [-22, -24], [-24, -26]]) == [5, 3, 1, -2, -4, -6, -8, -10, -12, -14, -16, -18, -20, -22, -24, -26]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(adjacentPairs = [[1, -1], [-1, 2], [2, -2], [-2, 3], [3, -3], [-3, 4], [4, -4], [-4, 5], [5, -5], [-5, 6], [6, -6], [-6, 7], [7, -7], [-7, 8], [8, -8], [-8, 9], [9, -9], [-9, 10], [10, -10]]) == [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]\n assert candidate(adjacentPairs = [[-1, 100], [100, 200], [200, -300], [-300, 400], [400, 500]]) == [-1, 100, 200, -300, 400, 500]\n assert candidate(adjacentPairs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 0]]) == [0, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(adjacentPairs = [[-1, -2], [-2, -3], [-3, -4], [-4, -5], [-5, -6], [-6, -7], [-7, -8], [-8, -9], [-9, -10], [-10, -11], [-11, -12]]) == [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12]\n assert candidate(adjacentPairs = [[500, 1000], [1000, 1500], [1500, 2000], [2000, 2500], [2500, 3000], [3000, 3500], [3500, 4000], [4000, 4500], [4500, 5000], [5000, 5500], [5500, 6000], [6000, 6500], [6500, 7000], [7000, 7500], [7500, 8000], [8000, 8500], [8500, 9000], [9000, 9500], [9500, 10000]]) == [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000]\n assert candidate(adjacentPairs = [[1, 5], [5, 9], [9, 13], [13, 17], [17, 21], [21, 25], [25, 29], [29, 33], [33, 37], [37, 41]]) == [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41]\n assert candidate(adjacentPairs = [[-10, -20], [-20, -30], [-30, -40], [-40, -50], [-50, -60], [-60, -70], [-70, -80], [-80, -90], [-90, -100]]) == [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]\n assert candidate(adjacentPairs = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55]]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]\n assert candidate(adjacentPairs = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21], [21, 23], [23, 25], [25, 27], [27, 29], [29, 31], [31, 33], [33, 35], [35, 37], [37, 39], [39, 41]]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]\n assert candidate(adjacentPairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000]]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(adjacentPairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000], [100, 150], [150, 250], [250, 350], [350, 450], [450, 550], [550, 650], [650, 750], [750, 850], [850, 950], [950, 1050]]) == [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 150, 250, 350, 450, 550, 650, 750, 850, 950, 1050]\n assert candidate(adjacentPairs = [[10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55], [55, 60], [60, 65], [65, 70]]) == [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70]\n assert candidate(adjacentPairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000]]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(adjacentPairs = [[100000, 90000], [80000, 90000], [70000, 80000], [60000, 70000], [50000, 60000]]) == [100000, 90000, 80000, 70000, 60000, 50000]\n assert candidate(adjacentPairs = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(adjacentPairs = [[-50000, -40000], [-30000, -40000], [-20000, -30000], [-10000, -20000], [0, -10000]]) == [-50000, -40000, -30000, -20000, -10000, 0]\n assert candidate(adjacentPairs = [[-1, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30]]) == [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(adjacentPairs = [[-99999, 99999], [99999, -99998], [-99998, 99998], [99998, -99997], [-99997, 99997], [99997, -99996], [-99996, 99996], [99996, -99995]]) == [-99999, 99999, -99998, 99998, -99997, 99997, -99996, 99996, -99995]\n assert candidate(adjacentPairs = [[-5, 0], [-4, -5], [-3, -4], [-2, -3], [-1, -2], [0, -1], [1, 0], [2, 1], [3, 2], [4, 3], [5, 4]]) == [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, 0]\n assert candidate(adjacentPairs = [[0, 1], [2, 1], [4, 3], [3, 2], [6, 5], [5, 4], [8, 7], [7, 6], [10, 9], [9, 8], [12, 11], [11, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(adjacentPairs = [[-1, 2], [2, -3], [-3, 4], [4, -5], [-5, 6], [6, -7], [-7, 8], [8, -9], [-9, 10], [10, -11], [-11, 12], [12, -13], [-13, 14], [14, -15], [-15, 16], [16, -17], [-17, 18], [18, -19], [-19, 20]]) == [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [2, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2]\n assert candidate(adjacentPairs = [[-1, 0], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(adjacentPairs = [[-100, -99], [-99, -98], [-98, -97], [-97, -96], [-96, -95], [-95, -94], [-94, -93], [-93, -92], [-92, -91], [-91, -90], [-90, -89], [-89, -88], [-88, -87], [-87, -86], [-86, -85], [-85, -84], [-84, -83], [-83, -82], [-82, -81], [-81, -80]]) == [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80]\n assert candidate(adjacentPairs = [[1, 6], [6, 11], [11, 16], [16, 21], [21, 26], [26, 31], [31, 36], [36, 41], [41, 46], [46, 51]]) == [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51]\n assert candidate(adjacentPairs = [[-100000, -90000], [-90000, -80000], [-80000, -70000], [-70000, -60000], [-60000, -50000], [-50000, -40000], [-40000, -30000], [-30000, -20000], [-20000, -10000], [-10000, 0], [0, 10000], [10000, 20000], [20000, 30000], [30000, 40000], [40000, 50000], [50000, 60000], [60000, 70000], [70000, 80000], [80000, 90000], [90000, 100000]]) == [-100000, -90000, -80000, -70000, -60000, -50000, -40000, -30000, -20000, -10000, 0, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(adjacentPairs = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [2, 3], [4, 5], [6, 7], [8, 9]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(adjacentPairs = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110]]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]\n assert candidate(adjacentPairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n"}, "metadata": {"canonical_parameter_names": ["adjacentPairs"], "leetcode_dataset_entry_point": "Solution().restoreArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector restoreArray(vector>& adjacentPairs) {", "container": "Solution", "callable": "restoreArray", "parameters": [{"name": "adjacentPairs", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1744, "task_id": "can-you-eat-your-favorite-candy-on-your-favorite-day", "difficulty": "Medium", "problem_description": "You are given a (0-indexed) array of positive integers candiesCount where candiesCount[i] represents the number of candies of the ith type you have. You are also given a 2D array queries where queries[i] = [favoriteTypei, favoriteDayi, dailyCapi].\nYou play a game with the following rules:\n\nYou start eating candies on day 0.\nYou cannot eat any candy of type i unless you have eaten all candies of type i - 1.\nYou must eat at least one candy per day until you have eaten all the candies.\n\nConstruct a boolean array answer such that answer.length == queries.length and answer[i] is true if you can eat a candy of type favoriteTypei on day favoriteDayi without eating more than dailyCapi candies on any day, and false otherwise. Note that you can eat different types of candy on the same day, provided that you follow rule 2.\nReturn the constructed array answer.\n \nExample 1:\n\nInput: candiesCount = [7,4,5,3,8], queries = [[0,2,2],[4,2,4],[2,13,1000000000]]\nOutput: [true,false,true]\nExplanation:\n1- If you eat 2 candies (type 0) on day 0 and 2 candies (type 0) on day 1, you will eat a candy of type 0 on day 2.\n2- You can eat at most 4 candies each day.\n If you eat 4 candies every day, you will eat 4 candies (type 0) on day 0 and 4 candies (type 0 and type 1) on day 1.\n On day 2, you can only eat 4 candies (type 1 and type 2), so you cannot eat a candy of type 4 on day 2.\n3- If you eat 1 candy each day, you will eat a candy of type 2 on day 13.\n\nExample 2:\n\nInput: candiesCount = [5,2,6,4,1], queries = [[3,1,2],[4,10,3],[3,10,100],[4,100,30],[1,3,1]]\nOutput: [false,true,true,false,false]\n\n \nConstraints:\n\n1 <= candiesCount.length <= 105\n1 <= candiesCount[i] <= 105\n1 <= queries.length <= 105\nqueries[i].length == 3\n0 <= favoriteTypei < candiesCount.length\n0 <= favoriteDayi <= 109\n1 <= dailyCapi <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(candiesCount = [7, 4, 5, 3, 8],queries = [[0, 2, 2], [4, 2, 4], [2, 13, 1000000000]]) == [True, False, True]\n assert candidate(candiesCount = [5, 2, 6, 4, 1],queries = [[3, 1, 2], [4, 10, 3], [3, 10, 100], [4, 100, 30], [1, 3, 1]]) == [False, True, True, False, False]\n assert candidate(candiesCount = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 0, 1], [1, 1, 2], [2, 3, 3], [3, 6, 4], [4, 10, 5], [5, 15, 6], [6, 21, 7], [7, 28, 8], [8, 36, 9], [9, 45, 10]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [1000000, 500000, 250000, 125000, 62500],queries = [[0, 999999, 1000000], [1, 1499999, 500000], [2, 1999999, 250000], [3, 2499999, 125000], [4, 2999999, 62500]]) == [True, True, False, False, False]\n assert candidate(candiesCount = [10, 20, 30, 40, 50],queries = [[0, 0, 10], [1, 1, 20], [2, 2, 30], [3, 3, 40], [4, 4, 50], [0, 5, 5], [1, 10, 10], [2, 15, 15], [3, 20, 20], [4, 25, 25]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],queries = [[0, 0, 1], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1]]) == [True, False, False, False, False, False, False, False, False, False]\n assert candidate(candiesCount = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 1, 1], [1, 3, 2], [2, 6, 3], [3, 10, 4], [4, 15, 5], [5, 21, 6], [6, 28, 7], [7, 36, 8], [8, 45, 9], [9, 55, 10]]) == [False, False, False, False, False, False, False, False, False, False]\n assert candidate(candiesCount = [999999, 999999, 999999, 999999],queries = [[0, 100000, 999999], [1, 200000, 999999], [2, 300000, 999999], [3, 400000, 999999], [0, 300000, 333333], [1, 400000, 333333], [2, 500000, 333333], [3, 600000, 333333]]) == [True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 0, 10], [1, 10, 20], [2, 30, 30], [3, 60, 40], [4, 100, 50], [5, 150, 60], [6, 210, 70], [7, 280, 80], [8, 360, 90], [9, 450, 100]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [100000, 200000, 300000, 400000, 500000],queries = [[0, 50000, 1000], [1, 100000, 2000], [2, 150000, 3000], [3, 200000, 4000], [4, 250000, 5000]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 0, 1], [1, 1, 2], [2, 2, 3], [3, 3, 4], [4, 4, 5], [5, 5, 6], [6, 6, 7], [7, 7, 8], [8, 8, 9], [9, 9, 10]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [5, 4, 3, 2, 1],queries = [[0, 0, 1], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [0, 4, 10], [1, 3, 10], [2, 2, 10], [3, 1, 10], [4, 0, 10]]) == [True, False, False, False, False, True, True, True, True, False]\n assert candidate(candiesCount = [10, 20, 30, 40, 50],queries = [[4, 49, 50], [3, 29, 40], [2, 19, 30], [1, 9, 20], [0, 9, 10]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 5, 5], [1, 15, 15], [2, 30, 25], [3, 45, 35], [4, 60, 45], [5, 75, 55], [6, 90, 65], [7, 105, 75], [8, 120, 85], [9, 135, 95]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [100, 200, 300, 400, 500],queries = [[0, 99, 100], [1, 199, 200], [2, 299, 300], [3, 399, 400], [4, 499, 500], [0, 1, 50], [1, 1, 100], [2, 1, 150], [3, 1, 200], [4, 1, 250]]) == [True, True, True, True, True, True, True, False, False, False]\n assert candidate(candiesCount = [100, 200, 300, 400, 500],queries = [[0, 99, 100], [1, 199, 200], [2, 299, 300], [3, 399, 400], [4, 499, 500]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [100000000, 200000000, 300000000, 400000000, 500000000],queries = [[0, 100000000, 150000000], [4, 900000000, 1000000000], [2, 500000000, 350000000]]) == [False, True, True]\n assert candidate(candiesCount = [1000000, 500000, 250000, 125000, 62500, 31250],queries = [[0, 500000, 100000], [5, 500000, 100000], [2, 750000, 50000], [4, 875000, 31250]]) == [True, True, True, True]\n assert candidate(candiesCount = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],queries = [[0, 1000000000, 1000000000], [4, 4000000000, 1000000000], [2, 2500000000, 500000000]]) == [False, True, True]\n assert candidate(candiesCount = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],queries = [[0, 10000, 1000], [1, 20000, 2000], [2, 30000, 3000], [3, 40000, 4000], [4, 50000, 5000], [5, 60000, 6000], [6, 70000, 7000], [7, 80000, 8000], [8, 90000, 9000], [9, 100000, 10000]]) == [False, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 0, 10], [1, 1, 10], [2, 2, 10], [3, 3, 10], [4, 4, 10], [5, 5, 10], [6, 6, 10], [7, 7, 10], [8, 8, 10], [9, 9, 10]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000, 500000],queries = [[0, 499999, 500000], [1, 999999, 500000], [2, 1499999, 500000], [3, 1999999, 500000], [4, 2499999, 500000], [5, 2999999, 500000], [6, 3499999, 500000], [7, 3999999, 500000], [8, 4499999, 500000], [9, 4999999, 500000]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [1000000, 999999, 1000000, 999999, 1000000],queries = [[0, 1000000, 500000], [1, 1999998, 999999], [2, 2999999, 1000000], [3, 3999997, 1000000], [4, 4999999, 1000000]]) == [False, True, False, True, False]\n assert candidate(candiesCount = [100000000, 200000000, 150000000, 300000000, 250000000],queries = [[0, 50000000, 50000000], [1, 100000000, 100000000], [2, 150000000, 150000000], [3, 200000000, 200000000], [4, 250000000, 250000000]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [50000, 100000, 150000, 200000, 250000, 300000, 350000, 400000, 450000, 500000],queries = [[0, 0, 100000], [1, 100000, 200000], [2, 300000, 300000], [3, 600000, 400000], [4, 1000000, 500000], [5, 1500000, 600000], [6, 2100000, 700000], [7, 2800000, 800000], [8, 3600000, 900000], [9, 4500000, 1000000]]) == [True, True, False, False, False, False, False, False, False, False]\n assert candidate(candiesCount = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],queries = [[0, 0, 1], [1, 1, 10], [2, 11, 100], [3, 111, 1000], [4, 1111, 10000], [5, 11111, 100000], [6, 111111, 1000000], [7, 1111111, 10000000], [8, 11111111, 100000000], [9, 111111111, 1000000000]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 8, 80], [8, 9, 90], [9, 10, 100], [0, 99, 1000], [1, 199, 1000], [2, 299, 1000], [3, 399, 1000], [4, 499, 1000], [5, 599, 1000], [6, 699, 1000], [7, 799, 1000], [8, 899, 1000], [9, 999, 1000]]) == [True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False]\n assert candidate(candiesCount = [10, 20, 30, 40, 50],queries = [[0, 5, 10], [1, 15, 10], [2, 25, 10], [3, 35, 10], [4, 45, 10], [0, 9, 9], [1, 19, 9], [2, 29, 9], [3, 39, 9], [4, 49, 9], [0, 1, 1], [1, 11, 1], [2, 21, 1], [3, 31, 1], [4, 41, 1]]) == [True, True, True, True, True, True, True, True, True, True, True, True, False, False, False]\n assert candidate(candiesCount = [100000000, 200000000, 300000000, 400000000, 500000000],queries = [[0, 99999999, 100000000], [4, 1499999999, 150000000], [2, 299999999, 300000000]]) == [True, True, True]\n assert candidate(candiesCount = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 0, 1], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1], [10, 10, 1], [11, 11, 1], [12, 12, 1], [13, 13, 1], [14, 14, 1], [15, 15, 1], [16, 16, 1], [17, 17, 1], [18, 18, 1], [19, 19, 1]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [1, 10, 100, 1000, 10000],queries = [[0, 0, 1], [1, 1, 10], [2, 2, 100], [3, 3, 1000], [4, 4, 10000], [0, 5, 5], [1, 10, 10], [2, 15, 15], [3, 20, 20], [4, 25, 25]]) == [True, True, True, True, True, False, True, True, True, False]\n assert candidate(candiesCount = [1000000, 1000000, 1000000, 1000000, 1000000],queries = [[0, 100000, 200000], [1, 200000, 300000], [2, 300000, 400000], [3, 400000, 500000], [4, 500000, 600000]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [1000, 1000, 1000, 1000, 1000],queries = [[0, 0, 1], [1, 500, 1000], [2, 1000, 1000], [3, 1500, 1000], [4, 2000, 1000]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],queries = [[0, 0, 1], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1]]) == [True, False, False, False, False, False, False, False, False, False]\n assert candidate(candiesCount = [9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[0, 0, 1], [1, 1, 2], [2, 3, 3], [3, 6, 4], [4, 10, 5], [5, 15, 6], [6, 21, 7], [7, 28, 8], [8, 36, 9]]) == [True, False, False, True, True, True, True, True, True]\n assert candidate(candiesCount = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],queries = [[0, 0, 1], [1, 1, 1], [2, 3, 1], [3, 6, 1], [4, 10, 1], [5, 15, 1], [6, 21, 1], [7, 28, 1], [8, 36, 1], [9, 45, 1]]) == [True, False, False, False, False, False, False, False, False, False]\n assert candidate(candiesCount = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[0, 99, 100], [1, 199, 200], [2, 299, 300], [3, 399, 400], [4, 499, 500], [5, 599, 600], [6, 699, 700], [7, 799, 800], [8, 899, 900], [9, 999, 1000]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 0, 10], [9, 494, 100], [5, 150, 60], [2, 30, 30], [8, 315, 90]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 0, 1], [9, 44, 10], [3, 9, 4], [5, 14, 5], [8, 35, 9]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [1000000000, 1000000000, 1000000000],queries = [[0, 500000000, 500000000], [1, 1500000000, 500000000], [2, 2500000000, 500000000]]) == [True, True, True]\n assert candidate(candiesCount = [100, 200, 300, 400, 500],queries = [[0, 0, 100], [1, 100, 200], [2, 300, 300], [3, 600, 400], [4, 1000, 500]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],queries = [[0, 500000, 2000000], [1, 1000000, 2000000], [2, 1500000, 2000000], [3, 2000000, 2000000], [4, 2500000, 2000000], [5, 3000000, 2000000], [6, 3500000, 2000000], [7, 4000000, 2000000], [8, 4500000, 2000000], [9, 5000000, 2000000]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[0, 1, 50], [1, 51, 100], [2, 151, 150], [3, 301, 200], [4, 501, 250], [5, 751, 300], [6, 1051, 350], [7, 1401, 400], [8, 1801, 450], [9, 2251, 500]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [10, 20, 30, 40, 50],queries = [[0, 0, 5], [1, 4, 10], [2, 19, 15], [3, 34, 20], [4, 49, 25]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [1000000000, 999999999, 888888888, 777777777, 666666666],queries = [[0, 1000000000, 500000000], [4, 1000000000, 200000000], [2, 500000000, 100000000]]) == [False, True, True]\n assert candidate(candiesCount = [1000000, 1000000, 1000000],queries = [[0, 100000, 1000], [1, 200000, 500000], [2, 500000, 1]]) == [True, True, False]\n assert candidate(candiesCount = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 0, 1], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [50, 50, 50, 50, 50],queries = [[0, 24, 50], [1, 49, 50], [2, 74, 50], [3, 99, 50], [4, 124, 50], [0, 25, 25], [1, 50, 25], [2, 75, 25], [3, 100, 25], [4, 125, 25]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],queries = [[0, 0, 100], [1, 199, 200], [2, 399, 300], [3, 599, 400], [4, 799, 500], [5, 999, 600], [6, 1199, 700], [7, 1399, 800], [8, 1599, 900], [9, 1799, 1000]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [10, 20, 30, 40, 50],queries = [[0, 0, 10], [1, 10, 20], [2, 30, 30], [3, 60, 40], [4, 100, 50]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [1000000, 500000, 250000, 125000, 62500],queries = [[0, 999999, 1000000], [1, 1499999, 500000], [2, 374999, 250000], [3, 499999, 125000], [4, 593749, 62500]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [100, 200, 300, 400, 500],queries = [[0, 0, 1], [1, 100, 100], [2, 200, 150], [3, 300, 200], [4, 400, 250]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [1, 1, 1, 1, 1],queries = [[0, 0, 1], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1]]) == [True, True, True, True, True]\n assert candidate(candiesCount = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],queries = [[0, 1000, 500], [1, 3000, 1000], [2, 5000, 1500], [3, 7000, 2000], [4, 9000, 2500], [5, 11000, 3000], [6, 13000, 3500], [7, 15000, 4000], [8, 17000, 4500], [9, 19000, 5000]]) == [False, False, True, True, True, True, True, True, True, True]\n assert candidate(candiesCount = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],queries = [[0, 0, 1], [1, 10, 10], [2, 110, 100], [3, 1110, 1000], [4, 11110, 10000], [5, 111110, 100000], [6, 1111110, 1000000], [7, 11111110, 10000000], [8, 111111110, 100000000], [9, 1111111110, 1000000000]]) == [True, True, True, True, True, True, True, True, True, True]\n"}, "metadata": {"canonical_parameter_names": ["candiesCount", "queries"], "leetcode_dataset_entry_point": "Solution().canEat", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector canEat(vector& candiesCount, vector>& queries) {", "container": "Solution", "callable": "canEat", "parameters": [{"name": "candiesCount", "type": "vector&"}, {"name": "queries", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1745, "task_id": "palindrome-partitioning-iv", "difficulty": "Hard", "problem_description": "Given a string s, return true if it is possible to split the string s into three non-empty palindromic substrings. Otherwise, return false.​​​​​\nA string is said to be palindrome if it the same string when reversed.\n \nExample 1:\n\nInput: s = \"abcbdd\"\nOutput: true\nExplanation: \"abcbdd\" = \"a\" + \"bcb\" + \"dd\", and all three substrings are palindromes.\n\nExample 2:\n\nInput: s = \"bcbddxy\"\nOutput: false\nExplanation: s cannot be split into 3 palindromes.\n\n \nConstraints:\n\n3 <= s.length <= 2000\ns​​​​​​ consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcba\") == True\n assert candidate(s = \"abcdcba\") == True\n assert candidate(s = \"aabbaa\") == True\n assert candidate(s = \"aaaaa\") == True\n assert candidate(s = \"abacdfgdcaba\") == False\n assert candidate(s = \"aabbbaa\") == True\n assert candidate(s = \"noonnoon\") == True\n assert candidate(s = \"aaa\") == True\n assert candidate(s = \"aabb\") == True\n assert candidate(s = \"racecar\") == True\n assert candidate(s = \"abba\") == True\n assert candidate(s = \"noon\") == True\n assert candidate(s = \"deeee\") == True\n assert candidate(s = \"abc\") == True\n assert candidate(s = \"abcbdd\") == True\n assert candidate(s = \"abcd\") == False\n assert candidate(s = \"aabbcc\") == True\n assert candidate(s = \"madamimadam\") == True\n assert candidate(s = \"aabaacaab\") == True\n assert candidate(s = \"bcbddxy\") == False\n assert candidate(s = \"aabbccddeeeffgghhii\") == False\n assert candidate(s = \"aabbccddeeefffggghhhiiii\") == False\n assert candidate(s = \"kayakmadamracecar\") == True\n assert candidate(s = \"levelracecar\") == False\n assert candidate(s = \"civicnooncivicnoon\") == False\n assert candidate(s = \"aaaaaabbaaaaa\") == True\n assert candidate(s = \"madamnoonmadamnoonmadam\") == True\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == True\n assert candidate(s = \"rotordetartratedrotor\") == True\n assert candidate(s = \"tattarrattatmadamracecar\") == True\n assert candidate(s = \"abcabcabc\") == False\n assert candidate(s = \"rotorlevelrotor\") == True\n assert candidate(s = \"deifiedcivicdeified\") == True\n assert candidate(s = \"rotorrefer\") == False\n assert candidate(s = \"madamadam\") == True\n assert candidate(s = \"aaaabbbbcccc\") == True\n assert candidate(s = \"levellevellevellevellevellevel\") == True\n assert candidate(s = \"deifieddeifieddeified\") == True\n assert candidate(s = \"xyzzyxabcba\") == False\n assert candidate(s = \"tacocatdeified\") == False\n assert candidate(s = \"leveloneone\") == False\n assert candidate(s = \"aabbccddeeefffggghhhhiiiiijjjjkkkkllllmmmmnnnnoooo\") == False\n assert candidate(s = \"levelmadamrotor\") == True\n assert candidate(s = \"abccbaabccba\") == True\n assert candidate(s = \"abcdmadamracecar\") == False\n assert candidate(s = \"levellevellevellevel\") == True\n assert candidate(s = \"repaperdeified\") == False\n assert candidate(s = \"noonnoonnoonnoon\") == True\n assert candidate(s = \"racecarlevel\") == False\n assert candidate(s = \"revilerleveldeified\") == False\n assert candidate(s = \"aabbaabbaa\") == True\n assert candidate(s = \"deifieddeifieddeifieddeifieddeified\") == True\n assert candidate(s = \"kayakracecarkayak\") == True\n assert candidate(s = \"abbbcbbaabbcbba\") == False\n assert candidate(s = \"levelrotorabcddcba\") == True\n assert candidate(s = \"aabbccddeeeffgghhiiiii\") == False\n assert candidate(s = \"leveldeifiedlevel\") == True\n assert candidate(s = \"noonnoonnoonnoonnoonnoon\") == True\n assert candidate(s = \"abacabaabacabaabacabaabacaba\") == True\n assert candidate(s = \"rotorreferrotorrefer\") == False\n assert candidate(s = \"abccbaabccbaabccba\") == True\n assert candidate(s = \"abacdfgdcabaaa\") == False\n assert candidate(s = \"aabbaccd\") == False\n assert candidate(s = \"aabbccddeeefffggghhhiiiiijjjjkkkkllllmmmmnnnnooooppppqqqrrrssstttuuuuvvvwwwxxxxyyyyzzzz\") == False\n assert candidate(s = \"madammadammadam\") == True\n assert candidate(s = \"racecarracecarracecar\") == True\n assert candidate(s = \"madammadam\") == True\n assert candidate(s = \"aibohphobiamadamaibohphobia\") == True\n assert candidate(s = \"racecarbanana\") == True\n assert candidate(s = \"abaabbab\") == True\n assert candidate(s = \"racecarabacaba\") == False\n assert candidate(s = \"abcdeedcba\") == True\n assert candidate(s = \"aabbccddeeeeddcbaabbccdd\") == False\n assert candidate(s = \"deeeeefeee\") == True\n assert candidate(s = \"rotorleveldeifiedleveldeifiedrotor\") == False\n assert candidate(s = \"aabbccddeeeeedddccbbaa\") == False\n assert candidate(s = \"abccbaabccbaabccbaabccbaabccbaabccbaabccbaabccba\") == True\n assert candidate(s = \"deifiedcivic\") == False\n assert candidate(s = \"abcbaabcbabcba\") == True\n assert candidate(s = \"civicracecar\") == False\n assert candidate(s = \"wasitacaroracatisaw\") == True\n assert candidate(s = \"rotorcentralpalindromerotor\") == False\n assert candidate(s = \"abcdcbaabdcbaabcdcba\") == False\n assert candidate(s = \"aibohphobia\") == True\n assert candidate(s = \"leveldeifiedcivic\") == True\n assert candidate(s = \"referredder\") == False\n assert candidate(s = \"level\") == True\n assert candidate(s = \"aabbccdd\") == False\n assert candidate(s = \"rotorleveltwol\") == False\n assert candidate(s = \"levellevellevel\") == True\n assert candidate(s = \"rotorpusher\") == False\n assert candidate(s = \"abccbaabc\") == False\n assert candidate(s = \"referreferrefer\") == True\n assert candidate(s = \"xyzyzyxyz\") == True\n assert candidate(s = \"madamrotorlevel\") == True\n assert candidate(s = \"madam\") == True\n assert candidate(s = \"mammadmam\") == False\n assert candidate(s = \"ababababababa\") == True\n assert candidate(s = \"racecarlevelmadam\") == True\n assert candidate(s = \"abababab\") == False\n assert candidate(s = \"civiccivicciviccivicciviccivic\") == True\n assert candidate(s = \"wasitacaroracitisawreferredder\") == False\n assert candidate(s = \"xxyyxyyxxyyxyyxxyyxyy\") == True\n assert candidate(s = \"abababa\") == True\n assert candidate(s = \"racecarracecarracecarracecarracecar\") == True\n assert candidate(s = \"referredderreferredderreferredder\") == False\n assert candidate(s = \"levelonevenflow\") == False\n assert candidate(s = \"referreferreferreferreferrefer\") == True\n assert candidate(s = \"deifiedrotor\") == False\n assert candidate(s = \"abcbaababcbcabcba\") == False\n assert candidate(s = \"banana\") == False\n assert candidate(s = \"levelonevenone\") == False\n assert candidate(s = \"rotorrotorrotorrotorrotor\") == True\n assert candidate(s = \"aabbccddeeffgg\") == False\n assert candidate(s = \"detartrated\") == True\n assert candidate(s = \"abbcbba\") == True\n assert candidate(s = \"aabbabba\") == True\n assert candidate(s = \"racecarannakayak\") == True\n assert candidate(s = \"amanaplanacanalpanama\") == True\n assert candidate(s = \"refermadamrefermadam\") == False\n assert candidate(s = \"racecarleveldadlevel\") == False\n assert candidate(s = \"abbaeaeabba\") == True\n assert candidate(s = \"racecarracecar\") == True\n assert candidate(s = \"rotorreferredder\") == True\n assert candidate(s = \"noonnoonnoon\") == True\n assert candidate(s = \"levelrefercivic\") == True\n assert candidate(s = \"deified\") == True\n assert candidate(s = \"abbaabbaabba\") == True\n assert candidate(s = \"levelmadamatadammadam\") == False\n assert candidate(s = \"abcdedcba\") == True\n assert candidate(s = \"rotormadamrotor\") == True\n assert candidate(s = \"rotorrotorrotor\") == True\n assert candidate(s = \"xyxzyxyxzyx\") == False\n assert candidate(s = \"rotorresistor\") == False\n assert candidate(s = \"xylophonelevel\") == False\n assert candidate(s = \"deifiedrotordeified\") == True\n assert candidate(s = \"racecarrotorrotorcarcerac\") == False\n assert candidate(s = \"abccbaabcba\") == False\n assert candidate(s = \"noonnoonnoonnoonnoonnoonnoonnoonnoonnoonnoonnoonnoon\") == True\n assert candidate(s = \"abcddcba\") == True\n assert candidate(s = \"civic\") == True\n assert candidate(s = \"rotor\") == True\n assert candidate(s = \"civicnoon\") == False\n assert candidate(s = \"madamatadammadam\") == False\n assert candidate(s = \"repaperrepaperrepaper\") == True\n assert candidate(s = \"rotorracecarracecar\") == True\n assert candidate(s = \"civicciviccivic\") == True\n assert candidate(s = \"rotorabanana\") == False\n assert candidate(s = \"aabbccddeeefff\") == False\n assert candidate(s = \"referdeifiedrefer\") == True\n assert candidate(s = \"rotorotator\") == True\n assert candidate(s = \"aabbccddeeffgghh\") == False\n assert candidate(s = \"leveltwol\") == False\n assert candidate(s = \"rotorresistorresistor\") == False\n assert candidate(s = \"levelracecarlevel\") == True\n assert candidate(s = \"rotordetartratedleveldeifiedrotor\") == False\n assert candidate(s = \"madammadammadammadammadam\") == True\n assert candidate(s = \"deifiedrotorlevel\") == True\n assert candidate(s = \"refercivicrefer\") == True\n assert candidate(s = \"abccbaabccbaabccbaabccbaabccba\") == True\n assert candidate(s = \"leveldeified\") == False\n assert candidate(s = \"rotorlevelmadam\") == True\n assert candidate(s = \"neveroddoreven\") == True\n assert candidate(s = \"redividerleveldeified\") == True\n assert candidate(s = \"refer\") == True\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().checkPartitioning", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool checkPartitioning(string s) {", "container": "Solution", "callable": "checkPartitioning", "parameters": [{"name": "s", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1748, "task_id": "sum-of-unique-elements", "difficulty": "Easy", "problem_description": "You are given an integer array nums. The unique elements of an array are the elements that appear exactly once in the array.\nReturn the sum of all the unique elements of nums.\n \nExample 1:\n\nInput: nums = [1,2,3,2]\nOutput: 4\nExplanation: The unique elements are [1,3], and the sum is 4.\n\nExample 2:\n\nInput: nums = [1,1,1,1,1]\nOutput: 0\nExplanation: There are no unique elements, and the sum is 0.\n\nExample 3:\n\nInput: nums = [1,2,3,4,5]\nOutput: 15\nExplanation: The unique elements are [1,2,3,4,5], and the sum is 15.\n\n \nConstraints:\n\n1 <= nums.length <= 100\n1 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10]) == 54\n assert candidate(nums = [10, 20, 20, 10, 30]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50]) == 150\n assert candidate(nums = [1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [100, 100, 99, 98, 97, 96, 95]) == 485\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 955\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 8, 8, 8]) == 0\n assert candidate(nums = [1, 2]) == 3\n assert candidate(nums = [1, 2, 3, 2]) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6]) == 10\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5]) == 1\n assert candidate(nums = [7]) == 7\n assert candidate(nums = [5]) == 5\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 100]) == 4895\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 594\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 155\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 650\n assert candidate(nums = [50, 50, 50, 50, 50, 51, 52, 52, 53, 53, 53, 54, 55, 55, 55, 55]) == 105\n assert candidate(nums = [10, 20, 20, 30, 30, 40, 50, 60, 60, 70, 80, 80, 90, 100]) == 360\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5050\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 5050\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10]) == 37\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20]) == 0\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 0\n assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 40\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 8, 9, 10, 10, 11]) == 42\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50]) == 400\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75]) == 2175\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 9, 10]) == 40\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 4\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 51, 52, 53, 54, 55]) == 265\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 0\n assert candidate(nums = [1, 2, 3, 2, 1, 4, 5, 6, 7, 6, 5, 8, 9, 10, 9, 8, 11, 12, 13, 12, 11, 14, 15, 16, 15, 14, 17, 18, 19, 18, 17, 20, 21, 22, 21, 20, 23, 24, 25, 24, 23]) == 119\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 955\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5]) == 195\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50]) == 0\n assert candidate(nums = [7, 7, 7, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 12, 12, 13, 13, 13]) == 0\n assert candidate(nums = [50, 50, 50, 51, 52, 53, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70]) == 1157\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 650\n assert candidate(nums = [2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 465\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 1\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30]) == 490\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 465\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 325\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6]) == 7\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [99, 99, 98, 98, 97, 97, 96, 96, 95, 95, 94, 94, 93, 93, 92, 92, 91, 91]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 1050\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 0\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90]) == 855\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 11, 12, 13, 14, 15, 15, 14, 13, 12, 11]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 5, 10]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [50, 50, 50, 50, 50, 51, 52, 53, 54, 55]) == 265\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5]) == 195\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 6, 7]) == 22\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 400\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 7, 8, 8, 9, 10, 11, 12, 12, 13]) == 56\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12, 13, 14, 14, 15, 15, 16, 16, 17, 18, 18, 19, 20, 20]) == 85\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5050\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 100, 99]) == 756\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 200\n assert candidate(nums = [10, 10, 10, 20, 20, 30, 30, 30, 40, 40, 40, 40, 50, 50, 50, 50, 50]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 1\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 19, 20, 20]) == 100\n assert candidate(nums = [10, 20, 10, 20, 30, 40, 30, 40, 50, 60, 50, 60, 70, 80, 70, 80, 90, 100, 90, 100]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 40\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 60, 70]) == 130\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80]) == 2015\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 0\n assert candidate(nums = [50, 50, 50, 50, 50, 49, 48, 47, 46, 45]) == 235\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sumOfUnique", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int sumOfUnique(vector& nums) {", "container": "Solution", "callable": "sumOfUnique", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1749, "task_id": "maximum-absolute-sum-of-any-subarray", "difficulty": "Medium", "problem_description": "You are given an integer array nums. The absolute sum of a subarray [numsl, numsl+1, ..., numsr-1, numsr] is abs(numsl + numsl+1 + ... + numsr-1 + numsr).\nReturn the maximum absolute sum of any (possibly empty) subarray of nums.\nNote that abs(x) is defined as follows:\n\nIf x is a negative integer, then abs(x) = -x.\nIf x is a non-negative integer, then abs(x) = x.\n\n \nExample 1:\n\nInput: nums = [1,-3,2,3,-4]\nOutput: 5\nExplanation: The subarray [2,3] has absolute sum = abs(2+3) = abs(5) = 5.\n\nExample 2:\n\nInput: nums = [2,-5,1,-4,3,-2]\nOutput: 8\nExplanation: The subarray [-5,1,-4] has absolute sum = abs(-5+1-4) = abs(-8) = 8.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n-104 <= nums[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [-10000, 10000, -10000, 10000]) == 10000\n assert candidate(nums = [1, -3, 2, 3, -4]) == 5\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [2, -5, 1, -4, 3, -2]) == 8\n assert candidate(nums = [10000, -10000, 10000, -10000, 10000]) == 10000\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 15\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [-1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [-10000, 10000, -10000, 10000, -10000]) == 10000\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, -15, 6, 7, 8, 9, 10, -25, 11, 12, 13, 14, 15]) == 80\n assert candidate(nums = [10, 20, -30, 40, -50, 60, -70, 80, -90, 100]) == 100\n assert candidate(nums = [5, 1, -2, 4, -1, -3, 6, -2, 1]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [-100, 101, -102, 103, -104, 105, -106, 107]) == 107\n assert candidate(nums = [100, -50, 25, -10, 5, -2, 1]) == 100\n assert candidate(nums = [-1, -2, -3, -4, -5, 5, 4, 3, 2, 1, -1, -2, -3, -4, -5, 5, 4, 3, 2, 1]) == 15\n assert candidate(nums = [5, -1, 3, -2, 4, -3, 6, -4, 7, -5]) == 15\n assert candidate(nums = [1000, -500, 250, -125, 62, -31, 15, -7, 3, -1]) == 1000\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000]) == 1000\n assert candidate(nums = [1, 2, 3, -6, 1, 2, 3, -6, 1, 2, 3, -6]) == 6\n assert candidate(nums = [5000, 4000, 3000, 2000, 1000, -5000, -4000, -3000, -2000, -1000]) == 15000\n assert candidate(nums = [10000, 0, 0, 0, 0, 0, 0, 0, 0, 0, -10000]) == 10000\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -55]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 55\n assert candidate(nums = [43, 44, -87, 45, 46, 47, -135, 48, 49, 50, 51, -195, 52, 53, 54, 55, 56, -260, 57, 58]) == 276\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500]) == 500\n assert candidate(nums = [1, 2, 3, 4, 5, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, -5, -4, -3, -2, -1]) == 15\n assert candidate(nums = [10, 20, 30, -60, 40, 50, -100, 60, 70, 80, -230, 90, 100, 110, -340, 120]) == 340\n assert candidate(nums = [-5, -4, -3, -2, -1, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [5000, -1200, 3000, -1500, 2000, -1000, 4000]) == 10300\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 20\n assert candidate(nums = [10000, -9999, 10000, -9999, 10000, -9999, 10000, -9999]) == 10003\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20]) == 20\n assert candidate(nums = [5, -1, 4, -2, 3, -3, 2, -2, 1, -1, 0, 1, -1, 2, -2, 3, -3, 4, -4, 5]) == 11\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 1\n assert candidate(nums = [-5, 10, -15, 20, -25, 30, -35, 40]) == 40\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [-5, 4, -3, 7, -8, 2, -6, 1, 9, -4]) == 12\n assert candidate(nums = [26, -27, 28, -29, 30, -31, 32, -33, 34, -35, 36, -37, 38, -39, 40, -41, 42, -43, 44, -45, 46, -47, 48, -49, 50]) == 50\n assert candidate(nums = [10, -3, 20, -40, 50, -60, 70, -80, 90]) == 90\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 50\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16]) == 16\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100, -110, 120, -130, 140, -150, 160, -170, 180, -190, 200]) == 200\n assert candidate(nums = [1, -10, 100, -1000, 10000, -100000, 1000000, -10000000, 100000000, -1000000000]) == 1000000000\n assert candidate(nums = [23, -24, 25, -26, 27, -28, 29, -30, 31, -32, 33, -34, 35, -36, 37, -38, 39, -40, 41, -42]) == 42\n assert candidate(nums = [1, -100, 100, -50, 50, -25, 25, -12, 12, -6, 6]) == 100\n assert candidate(nums = [2, 3, -5, 4, 2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12]) == 13\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100]) == 100\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400]) == 400\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 15\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 5\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7]) == 7\n assert candidate(nums = [5000, -2000, 1500, -1000, 800, -700, 600, -500, 400, -300]) == 5000\n assert candidate(nums = [-10000, -10000, 20000, -10000, -10000, 20000, -10000, -10000, 20000, -10000, -10000, 20000]) == 20000\n assert candidate(nums = [-3000, 4500, -5000, 6000, -7000, 8000, -9000]) == 9000\n assert candidate(nums = [-100, 200, -300, 400, -500, 600, -700, 800, -900, 1000]) == 1000\n assert candidate(nums = [500, -500, 500, -500, 500, -500, 500, -500, 500, -500]) == 500\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13]) == 13\n assert candidate(nums = [0, -1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20]) == 20\n assert candidate(nums = [1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 10\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 10\n assert candidate(nums = [3, 2, 1, 0, -1, -2, -3, 0, 3, 2, 1, 0, -1, -2, -3]) == 6\n assert candidate(nums = [9999, -9998, 9997, -9996, 9995, -9994, 9993, -9992, 9991, -9990]) == 9999\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 1\n assert candidate(nums = [10000, 9000, 8000, -7000, -6000, -5000, 4000, 3000, 2000, -1000]) == 27000\n assert candidate(nums = [10000, 10000, -20000, 10000, 10000, -20000, 10000, 10000, -20000, 10000, 10000, -20000]) == 20000\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 10\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == 5\n assert candidate(nums = [5, -1, 3, -2, 7, -8, 2, -6, 4]) == 12\n assert candidate(nums = [100, 200, 300, -600, 400, 500, -1400, 600, 700, 800, 900, 1000]) == 4000\n assert candidate(nums = [-10, -20, -30, 60, -40, -50, 100, -60, -70, -80, 230, -90, -100, -110, 340, -120]) == 340\n assert candidate(nums = [-100, -200, -300, -400, -500, 1500, -600, -700, -800, -900, -1000]) == 4000\n assert candidate(nums = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000, 100, 200, 300, 400, 500]) == 5500\n assert candidate(nums = [5, -1, 4, -2, 3, -3, 2, -4, 1, -5, 0, 6, -6, 7, -7, 8, -8, 9, -9, 10]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000, 100, -200, 300, -400, 500]) == 1200\n assert candidate(nums = [9000, 9000, -18000, 9000, 9000, -18000, 9000, 9000]) == 18000\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 1\n assert candidate(nums = [10000, -9000, 8000, -7000, 6000, -5000, 4000, -3000, 2000, -1000]) == 10000\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10]) == 10\n assert candidate(nums = [-5000, 6000, -7000, 8000, -9000, 10000, -11000, 12000, -13000, 14000]) == 14000\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == 10\n assert candidate(nums = [-5000, 5000, 0, -5000, 5000, 0, -5000, 5000, 0]) == 5000\n assert candidate(nums = [1, 2, 3, 4, 5, -5, -4, -3, -2, -1]) == 15\n assert candidate(nums = [10000, -10000, 10000, -10000, 10000, -10000]) == 10000\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, 20, -21, 22, -23, 24, -25]) == 41\n assert candidate(nums = [5000, -2000, 1000, -500, 250, -125, 62, -31, 15, -7, 3, -1]) == 5000\n assert candidate(nums = [10000, 10000, 10000, -10000, -10000, -10000, 10000]) == 30000\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, -15, 6, 7, 8, 9, 10]) == 40\n assert candidate(nums = [1000, -2000, 3000, -4000, 5000]) == 5000\n assert candidate(nums = [100, 200, 300, 400, 500, -1500, 600, 700, 800, 900, 1000]) == 4000\n assert candidate(nums = [-9999, 9998, -9997, 9996, -9995, 9994]) == 9999\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 5\n assert candidate(nums = [-20, 19, -18, 17, -16, 15, -14, 13, -12, 11, -10, 9, -8, 7, -6, 5, -4, 3, -2, 1]) == 20\n assert candidate(nums = [100, -1, 200, -2, 300, -3, 400, -4, 500, -5]) == 1490\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1, 0, 1]) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100, -110]) == 110\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15]) == 15\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, 20, -21, 22]) == 40\n assert candidate(nums = [10000, -9999, 9998, -9997, 9996, -9995, 9994, -9993, 9992, -9991]) == 10000\n assert candidate(nums = [5, -3, 8, -1, 4, -7, 9, -2, 6, -10]) == 19\n assert candidate(nums = [10000, -9999, 9998, -9997, 9996, -9995, 9994]) == 10000\n assert candidate(nums = [5, -3, 8, -6, 2, -4, 7, -9, 1, -1]) == 10\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxAbsoluteSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxAbsoluteSum(vector& nums) {", "container": "Solution", "callable": "maxAbsoluteSum", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1750, "task_id": "minimum-length-of-string-after-deleting-similar-ends", "difficulty": "Medium", "problem_description": "Given a string s consisting only of characters 'a', 'b', and 'c'. You are asked to apply the following algorithm on the string any number of times:\n\nPick a non-empty prefix from the string s where all the characters in the prefix are equal.\nPick a non-empty suffix from the string s where all the characters in this suffix are equal.\nThe prefix and the suffix should not intersect at any index.\nThe characters from the prefix and suffix must be the same.\nDelete both the prefix and the suffix.\n\nReturn the minimum length of s after performing the above operation any number of times (possibly zero times).\n \nExample 1:\n\nInput: s = \"ca\"\nOutput: 2\nExplanation: You can't remove any characters, so the string stays as is.\n\nExample 2:\n\nInput: s = \"cabaabac\"\nOutput: 0\nExplanation: An optimal sequence of operations is:\n- Take prefix = \"c\" and suffix = \"c\" and remove them, s = \"abaaba\".\n- Take prefix = \"a\" and suffix = \"a\" and remove them, s = \"baab\".\n- Take prefix = \"b\" and suffix = \"b\" and remove them, s = \"aa\".\n- Take prefix = \"a\" and suffix = \"a\" and remove them, s = \"\".\nExample 3:\n\nInput: s = \"aabccabba\"\nOutput: 3\nExplanation: An optimal sequence of operations is:\n- Take prefix = \"aa\" and suffix = \"a\" and remove them, s = \"bccabb\".\n- Take prefix = \"b\" and suffix = \"bb\" and remove them, s = \"cca\".\n\n \nConstraints:\n\n1 <= s.length <= 105\ns only consists of characters 'a', 'b', and 'c'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcba\") == 1\n assert candidate(s = \"ca\") == 2\n assert candidate(s = \"abac\") == 4\n assert candidate(s = \"aabccabba\") == 3\n assert candidate(s = \"aabbaa\") == 0\n assert candidate(s = \"aaaaa\") == 0\n assert candidate(s = \"aababbaa\") == 1\n assert candidate(s = \"cabaabac\") == 0\n assert candidate(s = \"aabbccbaa\") == 0\n assert candidate(s = \"aaa\") == 0\n assert candidate(s = \"abcabc\") == 6\n assert candidate(s = \"aabbbcccbbaa\") == 0\n assert candidate(s = \"aababa\") == 1\n assert candidate(s = \"aabcccbaa\") == 0\n assert candidate(s = \"abc\") == 3\n assert candidate(s = \"abbaccaa\") == 5\n assert candidate(s = \"aaaa\") == 0\n assert candidate(s = \"abccba\") == 0\n assert candidate(s = \"aaabaaa\") == 1\n assert candidate(s = \"aabbcc\") == 6\n assert candidate(s = \"abca\") == 2\n assert candidate(s = \"cccccc\") == 0\n assert candidate(s = \"abababababababababababababababababababababababababababababababababababababab\") == 76\n assert candidate(s = \"aabacccbaa\") == 4\n assert candidate(s = \"abacabacabacabacabacabacabacabacabacabacab\") == 42\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiii\") == 36\n assert candidate(s = \"aabbbcccbbbbaa\") == 0\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\") == 66\n assert candidate(s = \"ccabbbcccabbbcccabbbcc\") == 18\n assert candidate(s = \"abccbaabccbaabccbaabccba\") == 0\n assert candidate(s = \"acabacabacabacabacabacabacabacab\") == 32\n assert candidate(s = \"cccaaaaabbb\") == 11\n assert candidate(s = \"aaaabbbbccccaaaabbbbcccc\") == 24\n assert candidate(s = \"aaabbbbbbbbccccccaaa\") == 14\n assert candidate(s = \"cbabcbabcb\") == 10\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\") == 76\n assert candidate(s = \"bbbbbbaaaaa\") == 11\n assert candidate(s = \"abcabcabc\") == 9\n assert candidate(s = \"aaaabaaaabaaa\") == 0\n assert candidate(s = \"abcabcabcabc\") == 12\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbccccc\") == 24\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiiiiiiiiiiiiiiiiiiiiii\") == 56\n assert candidate(s = \"abccbaabcbaabccba\") == 1\n assert candidate(s = \"abacabacabaacaba\") == 1\n assert candidate(s = \"aaabaaaabbaaaabaa\") == 0\n assert candidate(s = \"abacaabacaabaca\") == 13\n assert candidate(s = \"aabbbccccdddeeeccccbbbaaa\") == 6\n assert candidate(s = \"abacbacbacbacbacba\") == 14\n assert candidate(s = \"aaaabaaaabaaaabaaa\") == 1\n assert candidate(s = \"aabccccbbaa\") == 0\n assert candidate(s = \"aaaabbbbcccc\") == 12\n assert candidate(s = \"aabccbaaab\") == 10\n assert candidate(s = \"aaabbbcccbbbbaaa\") == 0\n assert candidate(s = \"aabbccddeeffeeddccbaabbaaabcabcabc\") == 34\n assert candidate(s = \"aabbbcccbbaaaabbbcccbbaaa\") == 0\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiiiiiii\") == 41\n assert candidate(s = \"abbbbaaaaabbbaaaaabbbb\") == 22\n assert candidate(s = \"cccaaaaabbbcccbaaabccbaaabccbaaabccbaa\") == 38\n assert candidate(s = \"bbbbaaaaabbbb\") == 0\n assert candidate(s = \"abccbaabccba\") == 0\n assert candidate(s = \"aaabaaaabbbaaa\") == 0\n assert candidate(s = \"aaaabbbbbbccccccdddddd\") == 22\n assert candidate(s = \"abacabacaba\") == 1\n assert candidate(s = \"aaabaaaabaaaabaaa\") == 1\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabba\") == 0\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabc\") == 36\n assert candidate(s = \"abacaba\") == 1\n assert candidate(s = \"cccbbbaaa\") == 9\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbbccccccccccdddddddddd\") == 41\n assert candidate(s = \"abcbaabcbacba\") == 7\n assert candidate(s = \"aaabaaaabba\") == 0\n assert candidate(s = \"aabbaabbaabbaabb\") == 16\n assert candidate(s = \"aaaabbbbccccddddccccdddd\") == 24\n assert candidate(s = \"abcabcabcabcabcabcabc\") == 21\n assert candidate(s = \"ccabbbccbbbbcabcabbbccabc\") == 22\n assert candidate(s = \"cccccccccccccccccccccc\") == 0\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 99\n assert candidate(s = \"acaacacaacac\") == 12\n assert candidate(s = \"aaabbbcccbbbaaa\") == 0\n assert candidate(s = \"abcbaabcbaabcbaabcbaabcbaabcbaabcba\") == 1\n assert candidate(s = \"abccbaabccbaabccba\") == 0\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\") == 71\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 30\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabb\") == 32\n assert candidate(s = \"aaaaabbbbbcccccaaaa\") == 10\n assert candidate(s = \"aabbbccccdddddeeecccbbbbaaa\") == 8\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 48\n assert candidate(s = \"ababbababbababb\") == 15\n assert candidate(s = \"aabbbcccdddeeeeeeccccbbbaa\") == 9\n assert candidate(s = \"aabbccddeedccbbaa\") == 0\n assert candidate(s = \"aabbbcccbaa\") == 0\n assert candidate(s = \"acaacaaca\") == 1\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 93\n assert candidate(s = \"aabbaaabbbaaabbbaaabbaa\") == 0\n assert candidate(s = \"accbabcbaccbacc\") == 15\n assert candidate(s = \"abcabcabcabcabcabc\") == 18\n assert candidate(s = \"abcbaabcba\") == 0\n assert candidate(s = \"aabbccbbccbbccaa\") == 12\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 0\n assert candidate(s = \"aaaabbbcccbbbaaa\") == 0\n assert candidate(s = \"cbbccbbcc\") == 0\n assert candidate(s = \"abacbacbacbacbacbacbac\") == 22\n assert candidate(s = \"aaaaabccccbaaaa\") == 0\n assert candidate(s = \"aaaabbbbccccddddeee\") == 19\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiiiiiiiiiii\") == 45\n assert candidate(s = \"ccccaaaabbbbaaaa\") == 16\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbbccccccccccddddddddddeeeeeeeeeeeeeeefffffffff\") == 65\n assert candidate(s = \"aaabbbcccbbbbaaabbbcccbbbbaaa\") == 0\n assert candidate(s = \"ababababababababababab\") == 22\n assert candidate(s = \"aaaabbbbccccccaaaabbbb\") == 22\n assert candidate(s = \"aabbaaabbbaaabbbaaabbaaa\") == 0\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbbccccccccccddddddddddeeeeeeeeeeeeeeefffffffffgggggggggghhhhhhhhhhhiiiiiiiiiii\") == 97\n assert candidate(s = \"aabbaabbccddeeffeeddccbaabbaa\") == 0\n assert candidate(s = \"abababababababababab\") == 20\n assert candidate(s = \"aaaabccccbbbbaaaa\") == 0\n assert candidate(s = \"aabbbbccccbbbbaaa\") == 0\n assert candidate(s = \"aabbccddeedccbbaaa\") == 0\n assert candidate(s = \"abacabadabacaba\") == 1\n assert candidate(s = \"aabaaabaaa\") == 0\n assert candidate(s = \"aabbccddeeeedddccbaabb\") == 22\n assert candidate(s = \"aabccccbaa\") == 0\n assert candidate(s = \"acccba\") == 4\n assert candidate(s = \"abacbacbacbacbaba\") == 11\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 42\n assert candidate(s = \"aaaabbbaaabbbbaaaabbbaaaa\") == 0\n assert candidate(s = \"abacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabacabac\") == 96\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 90\n assert candidate(s = \"aaabbbcccbbaaa\") == 0\n assert candidate(s = \"aabbccddeeffgg\") == 14\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii\") == 82\n assert candidate(s = \"ccbaaaabbbcccbaaaabbbccc\") == 0\n assert candidate(s = \"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\") == 0\n assert candidate(s = \"aabbaabbccddccbbbaa\") == 10\n assert candidate(s = \"cccccccccccccccccc\") == 0\n assert candidate(s = \"aaaabbaaabbbaaaa\") == 0\n assert candidate(s = \"aabbaabbaabbaabbaabb\") == 20\n assert candidate(s = \"aaaaabbbbbccccdddddccccbbbaaaaa\") == 0\n assert candidate(s = \"ababaababa\") == 0\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 0\n assert candidate(s = \"abcbaabcbaabcba\") == 1\n assert candidate(s = \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\") == 0\n assert candidate(s = \"aabbaaccbbbaa\") == 4\n assert candidate(s = \"ccccccc\") == 0\n assert candidate(s = \"aaabbbcccdddeeecccccbbbaaa\") == 6\n assert candidate(s = \"aabbccddeeecccbbbaa\") == 5\n assert candidate(s = \"abccbaabcba\") == 0\n assert candidate(s = \"ababababab\") == 10\n assert candidate(s = \"aaaabbbbccccddddccccddddeeeeffff\") == 32\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiiiiiiiiiiiiiiiiiiiiiiiiiii\") == 61\n assert candidate(s = \"ccccaaaabbbbcccc\") == 8\n assert candidate(s = \"aabbccddeedccbbaaabbccddeedccbbaa\") == 0\n assert candidate(s = \"babbacabacababb\") == 1\n assert candidate(s = \"ccccccabbbbbbbcc\") == 8\n assert candidate(s = \"abcabcabcabcabcabcabcabc\") == 24\n assert candidate(s = \"aabbaabbccbbccbbccaa\") == 16\n assert candidate(s = \"aaabbbcccbaabbbcccbaaabbb\") == 25\n assert candidate(s = \"ababa\") == 1\n assert candidate(s = \"acaabaaaca\") == 1\n assert candidate(s = \"aabbccbbccbbccbbccaa\") == 16\n assert candidate(s = \"ccccbaaaabbbcccbaaaabbbccc\") == 0\n assert candidate(s = \"aaaabbbcccdddeeecccbbbbaaaa\") == 6\n assert candidate(s = \"aaabaaabaaabaaabaaabaaabaaabaaabaaabaaabaaabaaabaaabaaabaaabaaabaaabaaab\") == 72\n assert candidate(s = \"aaaaabbbbbccccccccbbbbbbaaaaa\") == 0\n assert candidate(s = \"ccabbaacc\") == 0\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiiiiiiiiiiiiiiiii\") == 51\n assert candidate(s = \"aabbccddeedccbbaaacccccccccccbbbbaaa\") == 12\n assert candidate(s = \"acbacbacbacbacba\") == 14\n assert candidate(s = \"abcabcabcabcabc\") == 15\n assert candidate(s = \"ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc\") == 0\n assert candidate(s = \"caabaccaabaaccaaa\") == 17\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minimumLength", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumLength(string s) {", "container": "Solution", "callable": "minimumLength", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1751, "task_id": "maximum-number-of-events-that-can-be-attended-ii", "difficulty": "Hard", "problem_description": "You are given an array of events where events[i] = [startDayi, endDayi, valuei]. The ith event starts at startDayi and ends at endDayi, and if you attend this event, you will receive a value of valuei. You are also given an integer k which represents the maximum number of events you can attend.\nYou can only attend one event at a time. If you choose to attend an event, you must attend the entire event. Note that the end day is inclusive: that is, you cannot attend two events where one of them starts and the other ends on the same day.\nReturn the maximum sum of values that you can receive by attending events.\n \nExample 1:\n\n\nInput: events = [[1,2,4],[3,4,3],[2,3,1]], k = 2\nOutput: 7\nExplanation: Choose the green events, 0 and 1 (0-indexed) for a total value of 4 + 3 = 7.\nExample 2:\n\n\nInput: events = [[1,2,4],[3,4,3],[2,3,10]], k = 2\nOutput: 10\nExplanation: Choose event 2 for a total value of 10.\nNotice that you cannot attend any other event as they overlap, and that you do not have to attend k events.\nExample 3:\n\n\nInput: events = [[1,1,1],[2,2,2],[3,3,3],[4,4,4]], k = 3\nOutput: 9\nExplanation: Although the events do not overlap, you can only attend 3 events. Pick the highest valued three.\n \nConstraints:\n\n1 <= k <= events.length\n1 <= k * events.length <= 106\n1 <= startDayi <= endDayi <= 109\n1 <= valuei <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(events = [[1, 5, 4], [11, 15, 1], [8, 10, 2], [2, 11, 6]],k = 3) == 7\n assert candidate(events = [[2, 8, 6], [4, 9, 10], [6, 8, 3]],k = 2) == 10\n assert candidate(events = [[1, 5, 3], [1, 5, 6], [6, 10, 5], [2, 9, 4]],k = 2) == 11\n assert candidate(events = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500]],k = 3) == 900\n assert candidate(events = [[1, 2, 7], [2, 3, 10], [3, 4, 3], [1, 5, 5], [6, 7, 1]],k = 4) == 11\n assert candidate(events = [[1, 2, 4], [3, 5, 1], [5, 6, 2], [6, 7, 3]],k = 3) == 8\n assert candidate(events = [[1, 5, 3], [1, 5, 6], [6, 10, 5], [2, 9, 8]],k = 2) == 11\n assert candidate(events = [[1, 5, 3], [1, 5, 6], [6, 10, 5], [2, 7, 8], [9, 10, 4]],k = 3) == 12\n assert candidate(events = [[1, 5, 3], [1, 5, 6], [6, 6, 5], [2, 7, 9]],k = 3) == 11\n assert candidate(events = [[2, 8, 6], [2, 9, 9], [1, 6, 1], [3, 5, 5], [1, 5, 3]],k = 2) == 9\n assert candidate(events = [[1, 2, 100], [2, 3, 100], [3, 4, 100]],k = 1) == 100\n assert candidate(events = [[1, 5, 3], [1, 5, 6], [1, 5, 5], [2, 3, 5], [2, 3, 5]],k = 1) == 6\n assert candidate(events = [[1, 2, 4], [3, 4, 3], [2, 3, 1]],k = 2) == 7\n assert candidate(events = [[1, 2, 3], [4, 5, 4], [1, 5, 5]],k = 2) == 7\n assert candidate(events = [[1, 2, 4], [3, 4, 3], [2, 3, 10]],k = 2) == 10\n assert candidate(events = [[1, 3, 5], [2, 4, 6], [3, 5, 7], [4, 6, 8]],k = 2) == 13\n assert candidate(events = [[1, 5, 3], [1, 5, 6], [1, 5, 5]],k = 2) == 6\n assert candidate(events = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4]],k = 3) == 9\n assert candidate(events = [[1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10]],k = 5) == 50\n assert candidate(events = [[1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [1, 7, 6], [1, 8, 7], [1, 9, 8], [1, 10, 9], [2, 11, 10], [3, 12, 11], [4, 13, 12], [5, 14, 13], [6, 15, 14]],k = 5) == 18\n assert candidate(events = [[1, 3, 10], [2, 4, 20], [3, 5, 30], [4, 6, 40], [5, 7, 50], [6, 8, 60], [7, 9, 70], [8, 10, 80], [9, 11, 90], [10, 12, 100], [11, 13, 110], [12, 14, 120]],k = 4) == 300\n assert candidate(events = [[1, 1000000000, 1], [1, 1000000000, 2], [1, 1000000000, 3], [1, 1000000000, 4], [1, 1000000000, 5]],k = 5) == 5\n assert candidate(events = [[1, 2, 10], [10, 11, 10], [20, 21, 10], [30, 31, 10], [40, 41, 10], [50, 51, 10], [60, 61, 10], [70, 71, 10], [80, 81, 10], [90, 91, 10]],k = 5) == 50\n assert candidate(events = [[1, 1000000000, 1000000], [2, 999999999, 999999], [3, 888888888, 888888], [4, 777777777, 777777], [5, 666666666, 666666]],k = 3) == 1000000\n assert candidate(events = [[1, 10, 100], [11, 20, 200], [21, 30, 300], [15, 25, 150], [26, 35, 250]],k = 4) == 600\n assert candidate(events = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500], [6, 7, 600], [7, 8, 700], [8, 9, 800], [9, 10, 900], [10, 11, 1000], [11, 12, 1100], [12, 13, 1200], [13, 14, 1300]],k = 7) == 4900\n assert candidate(events = [[1, 10, 10], [2, 9, 8], [3, 8, 6], [4, 7, 4], [5, 6, 2]],k = 5) == 10\n assert candidate(events = [[1, 1, 1000000], [2, 2, 999999], [3, 3, 999998], [4, 4, 999997], [5, 5, 999996], [6, 6, 999995], [7, 7, 999994], [8, 8, 999993], [9, 9, 999992], [10, 10, 999991]],k = 5) == 4999990\n assert candidate(events = [[1, 2, 10], [3, 4, 20], [2, 3, 15], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40], [8, 9, 45], [9, 10, 50], [10, 11, 55]],k = 4) == 160\n assert candidate(events = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [1, 6, 6], [1, 7, 7], [1, 8, 8], [1, 9, 9], [1, 10, 10]],k = 1) == 10\n assert candidate(events = [[1, 1, 1000], [2, 2, 2000], [3, 3, 3000], [4, 4, 4000], [5, 5, 5000], [6, 6, 6000], [7, 7, 7000], [8, 8, 8000], [9, 9, 9000]],k = 5) == 35000\n assert candidate(events = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100], [11, 12, 110], [12, 13, 120], [13, 14, 130], [14, 15, 140]],k = 7) == 560\n assert candidate(events = [[1, 10, 5], [2, 9, 6], [3, 8, 7], [4, 7, 8], [5, 6, 9], [11, 20, 10], [12, 19, 11], [13, 18, 12], [14, 17, 13], [15, 16, 14]],k = 4) == 23\n assert candidate(events = [[1, 3, 1000], [2, 5, 1000], [3, 7, 1000], [4, 8, 1000], [5, 10, 1000], [6, 11, 1000], [7, 12, 1000], [8, 13, 1000], [9, 14, 1000], [10, 15, 1000]],k = 5) == 3000\n assert candidate(events = [[1, 2, 1000000], [2, 3, 999999], [3, 4, 999998], [4, 5, 999997], [5, 6, 999996], [6, 7, 999995], [7, 8, 999994], [8, 9, 999993], [9, 10, 999992]],k = 5) == 4999980\n assert candidate(events = [[1, 10, 100], [11, 20, 200], [21, 30, 300], [31, 40, 400], [41, 50, 500], [51, 60, 600]],k = 3) == 1500\n assert candidate(events = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100], [11, 12, 110]],k = 6) == 360\n assert candidate(events = [[1, 10, 10], [2, 9, 20], [3, 8, 30], [4, 7, 40], [5, 6, 50], [1, 10, 60], [2, 9, 70], [3, 8, 80], [4, 7, 90], [5, 6, 100]],k = 5) == 100\n assert candidate(events = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100]],k = 5) == 300\n assert candidate(events = [[1, 1000000000, 1000000], [2, 999999999, 900000], [3, 999999998, 800000], [4, 999999997, 700000], [5, 999999996, 600000], [6, 999999995, 500000], [7, 999999994, 400000], [8, 999999993, 300000], [9, 999999992, 200000], [10, 999999991, 100000]],k = 5) == 1000000\n assert candidate(events = [[1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10], [1, 2, 10]],k = 5) == 10\n assert candidate(events = [[1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [1, 7, 6], [1, 8, 7], [1, 9, 8], [1, 10, 9]],k = 2) == 9\n assert candidate(events = [[1, 2, 5], [3, 5, 10], [5, 7, 15], [7, 9, 20], [9, 11, 25], [11, 13, 30]],k = 4) == 65\n assert candidate(events = [[1, 3, 50], [2, 4, 60], [3, 5, 70], [4, 6, 80], [5, 7, 90], [6, 8, 100], [7, 9, 110], [8, 10, 120], [9, 11, 130], [10, 12, 140]],k = 3) == 330\n assert candidate(events = [[1, 2, 1], [3, 4, 2], [5, 6, 3], [7, 8, 4], [9, 10, 5], [11, 12, 6], [13, 14, 7], [15, 16, 8], [17, 18, 9], [19, 20, 10], [21, 22, 11], [23, 24, 12]],k = 6) == 57\n assert candidate(events = [[1, 10, 5], [2, 9, 10], [3, 8, 15], [4, 7, 20], [5, 6, 25], [6, 5, 30], [7, 4, 35], [8, 3, 40], [9, 2, 45], [10, 1, 50]],k = 5) == 200\n assert candidate(events = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10], [11, 11, 11], [12, 12, 12], [13, 13, 13]],k = 13) == 91\n assert candidate(events = [[1, 10, 1], [2, 10, 2], [3, 10, 3], [4, 10, 4], [5, 10, 5], [6, 10, 6], [7, 10, 7], [8, 10, 8], [9, 10, 9], [1, 20, 10], [11, 20, 11], [21, 30, 12], [31, 40, 13], [41, 50, 14]],k = 5) == 59\n assert candidate(events = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500], [6, 7, 600], [7, 8, 700], [8, 9, 800], [9, 10, 900]],k = 4) == 2400\n assert candidate(events = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]],k = 5) == 40\n assert candidate(events = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500], [6, 7, 600], [7, 8, 700], [8, 9, 800], [9, 10, 900], [10, 11, 1000], [11, 12, 1100], [12, 13, 1200], [13, 14, 1300]],k = 6) == 4800\n assert candidate(events = [[1, 10, 100], [2, 5, 200], [3, 8, 300], [6, 12, 400], [9, 15, 500]],k = 3) == 800\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10]],k = 10) == 30\n assert candidate(events = [[1, 10, 1], [11, 20, 2], [21, 30, 3], [31, 40, 4], [41, 50, 5], [51, 60, 6], [61, 70, 7], [71, 80, 8], [81, 90, 9]],k = 9) == 45\n assert candidate(events = [[1, 1000000000, 1000000], [2, 999999999, 2000000], [3, 999999998, 3000000], [4, 999999997, 4000000]],k = 2) == 4000000\n assert candidate(events = [[1, 2, 4], [1, 2, 3], [1, 2, 2], [1, 2, 1], [3, 4, 5], [3, 4, 6], [5, 6, 7], [5, 6, 8]],k = 3) == 18\n assert candidate(events = [[1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10]],k = 9) == 50\n assert candidate(events = [[1, 1000000000, 1], [2, 1000000000, 2], [3, 1000000000, 3], [4, 1000000000, 4], [5, 1000000000, 5]],k = 3) == 5\n assert candidate(events = [[1, 2, 1000000], [10, 11, 999999], [20, 21, 999998], [30, 31, 999997], [40, 41, 999996], [50, 51, 999995], [60, 61, 999994], [70, 71, 999993], [80, 81, 999992], [90, 91, 999991]],k = 10) == 9999955\n assert candidate(events = [[1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [1, 7, 6], [1, 8, 7], [1, 9, 8], [1, 10, 9], [1, 11, 10], [1, 12, 11], [1, 13, 12], [1, 14, 13], [1, 15, 14]],k = 7) == 14\n assert candidate(events = [[1, 5, 1], [1, 5, 2], [1, 5, 3], [1, 5, 4], [1, 5, 5], [1, 5, 6], [1, 5, 7], [1, 5, 8], [1, 5, 9], [1, 5, 10], [1, 5, 11], [1, 5, 12], [1, 5, 13], [1, 5, 14], [1, 5, 15]],k = 5) == 15\n assert candidate(events = [[1, 10, 10], [11, 20, 20], [21, 30, 30], [31, 40, 40], [41, 50, 50], [51, 60, 60], [61, 70, 70], [71, 80, 80], [81, 90, 90], [91, 100, 100]],k = 10) == 550\n assert candidate(events = [[1, 3, 100], [2, 5, 200], [3, 6, 300], [4, 7, 400], [5, 8, 500], [6, 9, 600]],k = 3) == 800\n assert candidate(events = [[1, 2, 1], [3, 4, 2], [5, 6, 3], [7, 8, 4], [9, 10, 5], [11, 12, 6], [13, 14, 7], [15, 16, 8], [17, 18, 9], [19, 20, 10]],k = 5) == 40\n assert candidate(events = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100], [11, 12, 110], [12, 13, 120]],k = 10) == 420\n assert candidate(events = [[1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [2, 3, 6], [2, 4, 7], [2, 5, 8], [2, 6, 9], [3, 4, 10], [3, 5, 11], [3, 6, 12], [4, 5, 13], [4, 6, 14], [5, 6, 15]],k = 3) == 26\n assert candidate(events = [[1, 2, 1], [1, 2, 1], [1, 2, 1], [1, 2, 1], [1, 2, 1], [1, 2, 1], [1, 2, 1], [1, 2, 1], [1, 2, 1], [1, 2, 1]],k = 5) == 1\n assert candidate(events = [[1, 1, 100], [1, 1, 200], [1, 1, 300], [1, 1, 400], [1, 1, 500], [1, 1, 600], [1, 1, 700], [1, 1, 800], [1, 1, 900], [1, 1, 1000]],k = 5) == 1000\n assert candidate(events = [[1, 5, 5], [5, 10, 10], [10, 15, 15], [15, 20, 20], [20, 25, 25], [25, 30, 30], [30, 35, 35]],k = 3) == 75\n assert candidate(events = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [2, 2, 1], [2, 3, 2], [2, 4, 3], [2, 5, 4], [3, 3, 1], [3, 4, 2], [3, 5, 3], [4, 4, 1], [4, 5, 2], [5, 5, 1]],k = 3) == 5\n assert candidate(events = [[5, 10, 15], [5, 7, 10], [7, 12, 20], [9, 15, 18], [10, 17, 12], [13, 20, 30], [14, 20, 25]],k = 3) == 50\n assert candidate(events = [[1, 10, 1], [2, 9, 2], [3, 8, 3], [4, 7, 4], [5, 6, 5], [11, 20, 6], [12, 19, 7], [13, 18, 8], [14, 17, 9], [15, 16, 10]],k = 5) == 15\n assert candidate(events = [[1, 3, 100], [2, 5, 200], [3, 6, 300], [4, 7, 400], [5, 8, 500], [6, 9, 600]],k = 4) == 800\n assert candidate(events = [[1, 1000000000, 1000000], [1000000001, 2000000000, 2000000], [2000000001, 3000000000, 3000000]],k = 2) == 5000000\n assert candidate(events = [[1, 1, 100], [2, 2, 200], [3, 3, 300], [4, 4, 400], [5, 5, 500], [6, 6, 600], [7, 7, 700], [8, 8, 800], [9, 9, 900], [10, 10, 1000]],k = 10) == 5500\n assert candidate(events = [[1, 5, 5], [6, 10, 10], [11, 15, 15], [16, 20, 20], [21, 25, 25], [26, 30, 30], [31, 35, 35], [36, 40, 40], [41, 45, 45], [46, 50, 50]],k = 5) == 200\n assert candidate(events = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100], [11, 12, 110], [12, 13, 120]],k = 6) == 420\n assert candidate(events = [[1, 1000000000, 1], [1, 1000000000, 2], [1, 1000000000, 3], [1, 1000000000, 4], [1, 1000000000, 5]],k = 2) == 5\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9]],k = 5) == 25\n assert candidate(events = [[1, 5, 5], [2, 6, 6], [3, 7, 7], [4, 8, 8], [5, 9, 9], [6, 10, 10], [7, 11, 11], [8, 12, 12], [9, 13, 13], [10, 14, 14]],k = 3) == 23\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15]],k = 7) == 63\n assert candidate(events = [[1, 1000000000, 1], [1000000000, 1000000000, 1000000]],k = 1) == 1000000\n assert candidate(events = [[1, 2, 1], [1, 2, 2], [1, 2, 3], [2, 3, 4], [2, 3, 5], [2, 3, 6], [3, 4, 7], [3, 4, 8], [3, 4, 9], [4, 5, 10]],k = 3) == 16\n assert candidate(events = [[1, 10, 5], [2, 9, 10], [3, 8, 15], [4, 7, 20], [5, 6, 25], [6, 5, 30]],k = 3) == 30\n assert candidate(events = [[1, 3, 50], [2, 5, 20], [4, 6, 40], [6, 9, 60], [8, 11, 80], [10, 12, 30]],k = 3) == 170\n assert candidate(events = [[1, 2, 1000000], [2, 3, 1000000], [3, 4, 1000000], [4, 5, 1000000], [5, 6, 1000000], [6, 7, 1000000]],k = 3) == 3000000\n assert candidate(events = [[1, 2, 100], [3, 4, 200], [5, 6, 300], [7, 8, 400], [9, 10, 500], [11, 12, 600], [13, 14, 700], [15, 16, 800], [17, 18, 900]],k = 5) == 3500\n assert candidate(events = [[1, 3, 10], [2, 5, 20], [3, 7, 30], [4, 8, 40], [5, 9, 50], [6, 10, 60], [7, 11, 70], [8, 12, 80], [9, 13, 90]],k = 4) == 140\n assert candidate(events = [[1, 10, 100], [11, 20, 200], [21, 30, 300], [31, 40, 400], [41, 50, 500], [51, 60, 600], [61, 70, 700], [71, 80, 800], [81, 90, 900], [91, 100, 1000]],k = 5) == 4000\n assert candidate(events = [[1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [1, 7, 6], [1, 8, 7], [1, 9, 8], [1, 10, 9], [1, 11, 10]],k = 5) == 10\n assert candidate(events = [[1, 2, 1000], [2, 3, 2000], [3, 4, 3000], [4, 5, 4000], [5, 6, 5000], [6, 7, 6000], [7, 8, 7000], [8, 9, 8000], [9, 10, 9000]],k = 9) == 25000\n assert candidate(events = [[1, 10, 1], [2, 9, 2], [3, 8, 3], [4, 7, 4], [5, 6, 5], [6, 5, 6], [7, 4, 7], [8, 3, 8], [9, 2, 9], [10, 1, 10]],k = 5) == 40\n assert candidate(events = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [1, 6, 6], [1, 7, 7], [1, 8, 8], [1, 9, 9], [1, 10, 10], [1, 11, 11], [1, 12, 12], [1, 13, 13], [1, 14, 14], [1, 15, 15]],k = 15) == 15\n assert candidate(events = [[1, 10, 100], [11, 20, 200], [21, 30, 300], [31, 40, 400], [41, 50, 500], [51, 60, 600], [61, 70, 700], [71, 80, 800], [81, 90, 900], [91, 100, 1000]],k = 3) == 2700\n assert candidate(events = [[1, 20, 100], [2, 15, 80], [3, 10, 60], [4, 5, 40], [5, 6, 20], [6, 7, 10], [7, 8, 5], [8, 9, 3], [9, 10, 2], [10, 11, 1], [11, 12, 2], [12, 13, 3], [13, 14, 5], [14, 15, 10], [15, 16, 20], [16, 17, 40], [17, 18, 60], [18, 19, 80], [19, 20, 100]],k = 10) == 247\n assert candidate(events = [[1, 10, 10], [2, 9, 11], [3, 8, 12], [4, 7, 13], [5, 6, 14], [6, 5, 15], [7, 4, 16], [8, 3, 17], [9, 2, 18], [10, 1, 19]],k = 5) == 85\n assert candidate(events = [[1, 3, 5], [2, 5, 8], [4, 6, 6], [6, 8, 3], [5, 7, 10], [7, 9, 4]],k = 4) == 15\n assert candidate(events = [[1, 2, 100], [3, 5, 150], [6, 8, 200], [9, 11, 250], [12, 14, 300], [15, 17, 350]],k = 4) == 1100\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10]],k = 5) == 30\n assert candidate(events = [[1, 100, 1000], [2, 99, 900], [3, 98, 800], [4, 97, 700], [5, 96, 600], [6, 95, 500], [7, 94, 400], [8, 93, 300], [9, 92, 200], [10, 91, 100]],k = 5) == 1000\n assert candidate(events = [[1, 100, 1], [50, 150, 10], [100, 200, 50], [150, 250, 100], [200, 300, 200], [250, 350, 500], [300, 400, 1000], [350, 450, 2000], [400, 500, 5000]],k = 5) == 5550\n assert candidate(events = [[1, 2, 5], [1, 2, 5], [1, 2, 5], [1, 2, 5], [1, 2, 5], [1, 2, 5], [1, 2, 5]],k = 4) == 5\n assert candidate(events = [[1, 50, 500], [51, 100, 400], [101, 150, 300], [151, 200, 200], [201, 250, 100]],k = 3) == 1200\n assert candidate(events = [[1, 10, 50], [11, 20, 100], [21, 30, 150], [31, 40, 200], [41, 50, 250]],k = 3) == 600\n assert candidate(events = [[1, 3, 5], [2, 4, 6], [3, 5, 7], [4, 6, 8], [5, 7, 9], [6, 8, 10], [7, 9, 11], [8, 10, 12], [9, 11, 13]],k = 4) == 30\n assert candidate(events = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10], [11, 11, 11], [12, 12, 12], [13, 13, 13], [14, 14, 14]],k = 7) == 77\n assert candidate(events = [[1, 2, 50], [1, 3, 40], [1, 4, 30], [1, 5, 20], [1, 6, 10], [2, 7, 60], [3, 8, 70], [4, 9, 80], [5, 10, 90], [6, 11, 100]],k = 4) == 150\n assert candidate(events = [[1, 2, 10], [1, 2, 20], [1, 2, 30], [1, 2, 40], [1, 2, 50], [1, 2, 60], [1, 2, 70], [1, 2, 80], [1, 2, 90], [1, 2, 100]],k = 3) == 100\n"}, "metadata": {"canonical_parameter_names": ["events", "k"], "leetcode_dataset_entry_point": "Solution().maxValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxValue(vector>& events, int k) {", "container": "Solution", "callable": "maxValue", "parameters": [{"name": "events", "type": "vector>&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1752, "task_id": "check-if-array-is-sorted-and-rotated", "difficulty": "Easy", "problem_description": "Given an array nums, return true if the array was originally sorted in non-decreasing order, then rotated some number of positions (including zero). Otherwise, return false.\nThere may be duplicates in the original array.\nNote: An array A rotated by x positions results in an array B of the same length such that B[i] == A[(i+x) % A.length] for every valid index i.\n \nExample 1:\n\nInput: nums = [3,4,5,1,2]\nOutput: true\nExplanation: [1,2,3,4,5] is the original sorted array.\nYou can rotate the array by x = 3 positions to begin on the element of value 3: [3,4,5,1,2].\n\nExample 2:\n\nInput: nums = [2,1,3,4]\nOutput: false\nExplanation: There is no sorted array once rotated that can make nums.\n\nExample 3:\n\nInput: nums = [1,2,3]\nOutput: true\nExplanation: [1,2,3] is the original sorted array.\nYou can rotate the array by x = 0 positions (i.e. no rotation) to make nums.\n\n\n\n \n\n\n \n\n \n \n\n\n\n\n\n \nConstraints:\n\n1 <= nums.length <= 100\n1 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [4, 5, 6, 7, 0, 1, 2]) == True\n assert candidate(nums = [2, 1, 3, 4]) == False\n assert candidate(nums = [1, 3, 2]) == False\n assert candidate(nums = [4, 5, 6, 1, 2, 3]) == True\n assert candidate(nums = [1, 3, 5, 7, 2, 4, 6, 8]) == False\n assert candidate(nums = [2, 2, 1, 1, 1]) == True\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [2, 1, 2]) == True\n assert candidate(nums = [1, 2, 3]) == True\n assert candidate(nums = [1, 1, 1]) == True\n assert candidate(nums = [2, 3, 4, 5, 1]) == True\n assert candidate(nums = [0, 1, 2, 4, 5, 6, 7]) == True\n assert candidate(nums = [5, 1, 2, 3, 4]) == True\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == True\n assert candidate(nums = [100, 1, 100, 100]) == True\n assert candidate(nums = [3, 4, 5, 1, 2]) == True\n assert candidate(nums = [1, 2, 3, 4, 5]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [1, 3, 2, 4, 5]) == False\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 1, 3]) == False\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == True\n assert candidate(nums = [3, 3, 4, 4, 5, 5, 1, 1, 2, 2]) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == True\n assert candidate(nums = [6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [1, 3, 4, 5, 6, 7, 8, 9, 10, 2]) == False\n assert candidate(nums = [5, 5, 5, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == True\n assert candidate(nums = [3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == False\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3]) == True\n assert candidate(nums = [7, 8, 9, 10, 1, 2, 3, 4, 5, 6]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [2, 3, 4, 5, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [9, 1, 2, 3, 4, 5, 6, 7, 8]) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 1, 2, 3, 3, 3]) == True\n assert candidate(nums = [6, 7, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [2, 3, 4, 5, 1, 2, 3, 4, 5]) == False\n assert candidate(nums = [1, 2, 1]) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 1, 2, 3, 4, 5]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == False\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 10, 1, 2, 3]) == True\n assert candidate(nums = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1, 2]) == True\n assert candidate(nums = [7, 8, 9, 1, 2, 3, 4, 5, 6]) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4]) == True\n assert candidate(nums = [1, 3, 2, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1]) == False\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == True\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == True\n assert candidate(nums = [1, 2, 3, 2, 1]) == False\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 1, 2]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1]) == True\n assert candidate(nums = [8, 9, 1, 2, 3, 4, 5, 6, 7]) == True\n assert candidate(nums = [30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == True\n assert candidate(nums = [99, 100, 1, 2, 3, 4, 5, 6, 7, 8, 98]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 2]) == False\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1]) == True\n assert candidate(nums = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5]) == False\n assert candidate(nums = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2]) == True\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == True\n assert candidate(nums = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4]) == True\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == False\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 2, 4, 6, 8, 10]) == False\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 10, 1, 2]) == True\n assert candidate(nums = [5, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == True\n assert candidate(nums = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4]) == True\n assert candidate(nums = [9, 10, 11, 12, 13, 5, 6, 7, 8]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 1]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [20, 20, 20, 19, 19, 19, 18, 18, 18, 17, 17, 17, 16, 16, 16, 15, 15, 15, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == False\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 1, 2]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 1, 2, 3]) == False\n assert candidate(nums = [33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]) == True\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(nums = [2, 3, 1, 2, 3]) == False\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == False\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 2, 3]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == True\n assert candidate(nums = [1, 3, 2, 2, 3, 4, 5]) == False\n assert candidate(nums = [100, 1, 100, 100, 100]) == True\n assert candidate(nums = [5, 6, 7, 8, 1, 2, 3, 4, 5, 6]) == False\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 99]) == True\n assert candidate(nums = [99, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98]) == True\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == False\n assert candidate(nums = [3, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(nums = [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 1]) == True\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 1]) == True\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2]) == False\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3]) == False\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 1, 1]) == True\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 1, 3, 3, 3]) == True\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 1]) == True\n assert candidate(nums = [9, 10, 1, 2, 3, 4, 5, 6, 7, 8]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1]) == False\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]) == True\n assert candidate(nums = [4, 5, 6, 7, 0, 1, 2, 3]) == True\n assert candidate(nums = [99, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == True\n assert candidate(nums = [3, 4, 5, 2, 1]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 3, 3, 3, 3]) == False\n assert candidate(nums = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [8, 9, 9, 9, 1, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [3, 1, 2]) == True\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 1, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 1]) == True\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]) == True\n assert candidate(nums = [2, 2, 2, 2, 1, 2, 2, 2, 2]) == True\n assert candidate(nums = [9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == False\n assert candidate(nums = [3, 4, 5, 1, 1, 2, 2]) == True\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1, 1]) == True\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3]) == True\n assert candidate(nums = [6, 7, 8, 9, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(nums = [2, 2, 2, 2, 1, 2, 2, 2, 2, 2]) == True\n assert candidate(nums = [4, 5, 6, 7, 8, 1, 2, 3]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == False\n assert candidate(nums = [6, 10, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [8, 9, 10, 1, 2, 3, 4, 5, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(nums = [100, 1, 100, 100, 100, 100]) == True\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]) == True\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == False\n assert candidate(nums = [5, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(nums = [9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1]) == True\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().check", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool check(vector& nums) {", "container": "Solution", "callable": "check", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1753, "task_id": "maximum-score-from-removing-stones", "difficulty": "Medium", "problem_description": "You are playing a solitaire game with three piles of stones of sizes a​​​​​​, b,​​​​​​ and c​​​​​​ respectively. Each turn you choose two different non-empty piles, take one stone from each, and add 1 point to your score. The game stops when there are fewer than two non-empty piles (meaning there are no more available moves).\nGiven three integers a​​​​​, b,​​​​​ and c​​​​​, return the maximum score you can get.\n \nExample 1:\n\nInput: a = 2, b = 4, c = 6\nOutput: 6\nExplanation: The starting state is (2, 4, 6). One optimal set of moves is:\n- Take from 1st and 3rd piles, state is now (1, 4, 5)\n- Take from 1st and 3rd piles, state is now (0, 4, 4)\n- Take from 2nd and 3rd piles, state is now (0, 3, 3)\n- Take from 2nd and 3rd piles, state is now (0, 2, 2)\n- Take from 2nd and 3rd piles, state is now (0, 1, 1)\n- Take from 2nd and 3rd piles, state is now (0, 0, 0)\nThere are fewer than two non-empty piles, so the game ends. Total: 6 points.\n\nExample 2:\n\nInput: a = 4, b = 4, c = 6\nOutput: 7\nExplanation: The starting state is (4, 4, 6). One optimal set of moves is:\n- Take from 1st and 2nd piles, state is now (3, 3, 6)\n- Take from 1st and 3rd piles, state is now (2, 3, 5)\n- Take from 1st and 3rd piles, state is now (1, 3, 4)\n- Take from 1st and 3rd piles, state is now (0, 3, 3)\n- Take from 2nd and 3rd piles, state is now (0, 2, 2)\n- Take from 2nd and 3rd piles, state is now (0, 1, 1)\n- Take from 2nd and 3rd piles, state is now (0, 0, 0)\nThere are fewer than two non-empty piles, so the game ends. Total: 7 points.\n\nExample 3:\n\nInput: a = 1, b = 8, c = 8\nOutput: 8\nExplanation: One optimal set of moves is to take from the 2nd and 3rd piles for 8 turns until they are empty.\nAfter that, there are fewer than two non-empty piles, so the game ends.\n\n \nConstraints:\n\n1 <= a, b, c <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(a = 10,b = 10,c = 1) == 10\n assert candidate(a = 5,b = 7,c = 9) == 10\n assert candidate(a = 5,b = 5,c = 5) == 7\n assert candidate(a = 1,b = 8,c = 8) == 8\n assert candidate(a = 3,b = 3,c = 3) == 4\n assert candidate(a = 100000,b = 1,c = 1) == 2\n assert candidate(a = 100000,b = 100000,c = 100000) == 150000\n assert candidate(a = 4,b = 4,c = 6) == 7\n assert candidate(a = 30,b = 60,c = 90) == 90\n assert candidate(a = 1,b = 1,c = 100000) == 2\n assert candidate(a = 50000,b = 50000,c = 1) == 50000\n assert candidate(a = 10,b = 10,c = 10) == 15\n assert candidate(a = 2,b = 4,c = 6) == 6\n assert candidate(a = 5,b = 10,c = 15) == 15\n assert candidate(a = 20,b = 30,c = 40) == 45\n assert candidate(a = 7,b = 7,c = 14) == 14\n assert candidate(a = 10,b = 1,c = 1) == 2\n assert candidate(a = 7,b = 14,c = 10) == 15\n assert candidate(a = 1,b = 1,c = 2) == 2\n assert candidate(a = 7,b = 8,c = 9) == 12\n assert candidate(a = 33333,b = 33333,c = 33334) == 50000\n assert candidate(a = 50000,b = 50000,c = 50001) == 75000\n assert candidate(a = 1000,b = 1000,c = 1000) == 1500\n assert candidate(a = 80,b = 80,c = 40) == 100\n assert candidate(a = 7,b = 14,c = 21) == 21\n assert candidate(a = 10,b = 15,c = 20) == 22\n assert candidate(a = 150000,b = 50000,c = 100000) == 150000\n assert candidate(a = 5000,b = 5001,c = 5002) == 7501\n assert candidate(a = 33333,b = 66666,c = 100000) == 99999\n assert candidate(a = 50000,b = 1,c = 1) == 2\n assert candidate(a = 60000,b = 20000,c = 20000) == 40000\n assert candidate(a = 99999,b = 1,c = 1) == 2\n assert candidate(a = 5,b = 5,c = 100) == 10\n assert candidate(a = 80000,b = 80000,c = 1) == 80000\n assert candidate(a = 99998,b = 99999,c = 100000) == 149998\n assert candidate(a = 20,b = 20,c = 20) == 30\n assert candidate(a = 50000,b = 40000,c = 30000) == 60000\n assert candidate(a = 10000,b = 10000,c = 1) == 10000\n assert candidate(a = 5,b = 5,c = 10) == 10\n assert candidate(a = 10000,b = 10000,c = 10000) == 15000\n assert candidate(a = 42,b = 27,c = 19) == 44\n assert candidate(a = 45000,b = 45000,c = 10000) == 50000\n assert candidate(a = 2,b = 2,c = 100000) == 4\n assert candidate(a = 25,b = 25,c = 24) == 37\n assert candidate(a = 500,b = 500,c = 1500) == 1000\n assert candidate(a = 100,b = 200,c = 300) == 300\n assert candidate(a = 15,b = 15,c = 15) == 22\n assert candidate(a = 25,b = 75,c = 125) == 100\n assert candidate(a = 20,b = 20,c = 21) == 30\n assert candidate(a = 20000,b = 30000,c = 10000) == 30000\n assert candidate(a = 20,b = 40,c = 60) == 60\n assert candidate(a = 12345,b = 67890,c = 11111) == 23456\n assert candidate(a = 80000,b = 10000,c = 10000) == 20000\n assert candidate(a = 12345,b = 67890,c = 54321) == 66666\n assert candidate(a = 5,b = 15,c = 20) == 20\n assert candidate(a = 2,b = 2,c = 3) == 3\n assert candidate(a = 1,b = 1,c = 200000) == 2\n assert candidate(a = 100,b = 100,c = 101) == 150\n assert candidate(a = 3,b = 3,c = 9) == 6\n assert candidate(a = 15,b = 25,c = 35) == 37\n assert candidate(a = 50000,b = 50000,c = 99999) == 99999\n assert candidate(a = 10000,b = 20000,c = 30000) == 30000\n assert candidate(a = 10000,b = 5000,c = 5000) == 10000\n assert candidate(a = 25000,b = 25000,c = 50000) == 50000\n assert candidate(a = 99999,b = 99998,c = 99997) == 149997\n assert candidate(a = 75,b = 25,c = 50) == 75\n assert candidate(a = 1,b = 2,c = 3) == 3\n assert candidate(a = 10,b = 20,c = 30) == 30\n assert candidate(a = 3,b = 9,c = 9) == 10\n assert candidate(a = 15,b = 10,c = 5) == 15\n assert candidate(a = 30,b = 5,c = 25) == 30\n assert candidate(a = 50,b = 50,c = 100) == 100\n assert candidate(a = 100,b = 100,c = 100) == 150\n assert candidate(a = 99999,b = 99999,c = 99999) == 149998\n assert candidate(a = 100,b = 100,c = 1) == 100\n assert candidate(a = 50000,b = 49999,c = 49998) == 74998\n assert candidate(a = 50,b = 25,c = 25) == 50\n assert candidate(a = 98765,b = 43210,c = 54321) == 97531\n assert candidate(a = 5000,b = 5000,c = 10000) == 10000\n assert candidate(a = 55,b = 15,c = 35) == 50\n assert candidate(a = 33333,b = 33334,c = 33335) == 50001\n assert candidate(a = 10000,b = 10000,c = 5000) == 12500\n assert candidate(a = 30,b = 50,c = 20) == 50\n assert candidate(a = 30,b = 30,c = 30) == 45\n assert candidate(a = 60000,b = 40000,c = 20000) == 60000\n assert candidate(a = 1,b = 1,c = 1) == 1\n assert candidate(a = 8,b = 8,c = 8) == 12\n assert candidate(a = 100000,b = 50000,c = 50000) == 100000\n"}, "metadata": {"canonical_parameter_names": ["a", "b", "c"], "leetcode_dataset_entry_point": "Solution().maximumScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumScore(int a, int b, int c) {", "container": "Solution", "callable": "maximumScore", "parameters": [{"name": "a", "type": "int"}, {"name": "b", "type": "int"}, {"name": "c", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1754, "task_id": "largest-merge-of-two-strings", "difficulty": "Medium", "problem_description": "You are given two strings word1 and word2. You want to construct a string merge in the following way: while either word1 or word2 are non-empty, choose one of the following options:\n\nIf word1 is non-empty, append the first character in word1 to merge and delete it from word1.\n\n\t\nFor example, if word1 = \"abc\" and merge = \"dv\", then after choosing this operation, word1 = \"bc\" and merge = \"dva\".\n\n\nIf word2 is non-empty, append the first character in word2 to merge and delete it from word2.\n\t\nFor example, if word2 = \"abc\" and merge = \"\", then after choosing this operation, word2 = \"bc\" and merge = \"a\".\n\n\n\nReturn the lexicographically largest merge you can construct.\nA string a is lexicographically larger than a string b (of the same length) if in the first position where a and b differ, a has a character strictly larger than the corresponding character in b. For example, \"abcd\" is lexicographically larger than \"abcc\" because the first position they differ is at the fourth character, and d is greater than c.\n \nExample 1:\n\nInput: word1 = \"cabaa\", word2 = \"bcaaa\"\nOutput: \"cbcabaaaaa\"\nExplanation: One way to get the lexicographically largest merge is:\n- Take from word1: merge = \"c\", word1 = \"abaa\", word2 = \"bcaaa\"\n- Take from word2: merge = \"cb\", word1 = \"abaa\", word2 = \"caaa\"\n- Take from word2: merge = \"cbc\", word1 = \"abaa\", word2 = \"aaa\"\n- Take from word1: merge = \"cbca\", word1 = \"baa\", word2 = \"aaa\"\n- Take from word1: merge = \"cbcab\", word1 = \"aa\", word2 = \"aaa\"\n- Append the remaining 5 a's from word1 and word2 at the end of merge.\n\nExample 2:\n\nInput: word1 = \"abcabc\", word2 = \"abdcaba\"\nOutput: \"abdcabcabcaba\"\n\n \nConstraints:\n\n1 <= word1.length, word2.length <= 3000\nword1 and word2 consist only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word1 = \"lexicographically\",word2 = \"largestmerge\") == \"llexicogrargestmergeaphically\"\n assert candidate(word1 = \"zyxw\",word2 = \"abcd\") == \"zyxwabcd\"\n assert candidate(word1 = \"abcdabcd\",word2 = \"zyxwzyxw\") == \"zyxwzyxwabcdabcd\"\n assert candidate(word1 = \"leetcode\",word2 = \"challenge\") == \"leetcodechallenge\"\n assert candidate(word1 = \"aaaab\",word2 = \"aaabb\") == \"aaabbaaaab\"\n assert candidate(word1 = \"lexicographic\",word2 = \"merge\") == \"mlexiergecographic\"\n assert candidate(word1 = \"aaaa\",word2 = \"bbbb\") == \"bbbbaaaa\"\n assert candidate(word1 = \"abcabc\",word2 = \"abdcaba\") == \"abdcabcabcaba\"\n assert candidate(word1 = \"abc\",word2 = \"defghijklmnopqrstuvwxyz\") == \"defghijklmnopqrstuvwxyzabc\"\n assert candidate(word1 = \"z\",word2 = \"z\") == \"zz\"\n assert candidate(word1 = \"hello\",word2 = \"world\") == \"worlhellod\"\n assert candidate(word1 = \"abcd\",word2 = \"zyxw\") == \"zyxwabcd\"\n assert candidate(word1 = \"leetcode\",word2 = \"etco\") == \"leteetcodeco\"\n assert candidate(word1 = \"xy\",word2 = \"xy\") == \"xyxy\"\n assert candidate(word1 = \"cabaa\",word2 = \"bcaaa\") == \"cbcabaaaaa\"\n assert candidate(word1 = \"aabbcc\",word2 = \"bbccdd\") == \"bbccddaabbcc\"\n assert candidate(word1 = \"zzz\",word2 = \"zzz\") == \"zzzzzz\"\n assert candidate(word1 = \"a\",word2 = \"b\") == \"ba\"\n assert candidate(word1 = \"aaaaa\",word2 = \"bbbbb\") == \"bbbbbaaaaa\"\n assert candidate(word1 = \"aabbcc\",word2 = \"abcabc\") == \"abcabcaabbcc\"\n assert candidate(word1 = \"xyz\",word2 = \"xyz\") == \"xyzxyz\"\n assert candidate(word1 = \"abcd\",word2 = \"efgh\") == \"efghabcd\"\n assert candidate(word1 = \"abcd\",word2 = \"dcba\") == \"dcbabcda\"\n assert candidate(word1 = \"same\",word2 = \"same\") == \"ssameame\"\n assert candidate(word1 = \"abcdabcd\",word2 = \"abcde\") == \"abcdeabcdabcd\"\n assert candidate(word1 = \"bca\",word2 = \"cab\") == \"cbcaba\"\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcbabcdefghijklmnopqrstuvwxyza\"\n assert candidate(word1 = \"mississippi\",word2 = \"missouri\") == \"mmissourississippii\"\n assert candidate(word1 = \"zzzzzzzz\",word2 = \"zzzzzzzz\") == \"zzzzzzzzzzzzzzzz\"\n assert candidate(word1 = \"complexity\",word2 = \"similarity\") == \"similcomplexityarity\"\n assert candidate(word1 = \"xyzzzzzzzzzzzzzzzz\",word2 = \"xyzzzzzzzzzzzzzz\") == \"xyzzzzzzzzzzzzzzzzxyzzzzzzzzzzzzzz\"\n assert candidate(word1 = \"aaaabbbbccccdddd\",word2 = \"aaaabbbbccccdddd\") == \"aaaabbbbccccddddaaaabbbbccccdddd\"\n assert candidate(word1 = \"zzzzzzz\",word2 = \"zzzzzzzz\") == \"zzzzzzzzzzzzzzz\"\n assert candidate(word1 = \"aaaaaaa\",word2 = \"bbbbbbb\") == \"bbbbbbbaaaaaaa\"\n assert candidate(word1 = \"zzzzz\",word2 = \"zzzz\") == \"zzzzzzzzz\"\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzzyyxxwwvvuuttssrrqqponmlkjihgfedcbbaa\") == \"zzzyyxxwwvvuuttssrrqqponmlkjihgfedcbbaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzaa\"\n assert candidate(word1 = \"zyxwvut\",word2 = \"utsrqponmlkjihgfedcba\") == \"zyxwvuuttsrqponmlkjihgfedcba\"\n assert candidate(word1 = \"pqrstuvwxyz\",word2 = \"nopqrstuvwxyz\") == \"pqrstuvwxyznopqrstuvwxyz\"\n assert candidate(word1 = \"zzzzzz\",word2 = \"zzzzzz\") == \"zzzzzzzzzzzz\"\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"feebdccbaa\") == \"feebdccbaabbccddeeffaa\"\n assert candidate(word1 = \"cccccccc\",word2 = \"dddddddd\") == \"ddddddddcccccccc\"\n assert candidate(word1 = \"a\",word2 = \"z\") == \"za\"\n assert candidate(word1 = \"aabbcc\",word2 = \"aaabbb\") == \"aabbccaaabbb\"\n assert candidate(word1 = \"abcdxyz\",word2 = \"xyzabcd\") == \"xyzabcdxyzabcd\"\n assert candidate(word1 = \"python\",word2 = \"java\") == \"pytjhonava\"\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"abcabcabc\") == \"abcdabcdabcdabcabcabc\"\n assert candidate(word1 = \"sameprefix\",word2 = \"sameprefixsuffix\") == \"ssameprefixsuffixameprefix\"\n assert candidate(word1 = \"abcdefghij\",word2 = \"jihgfedcba\") == \"jihgfedcbabcdefghija\"\n assert candidate(word1 = \"onetwothreefour\",word2 = \"fivesixseveneightnine\") == \"onfivetwothresixseveneightnineefoure\"\n assert candidate(word1 = \"racecar\",word2 = \"racecar\") == \"rracecaracecar\"\n assert candidate(word1 = \"abcdabcdabcdabcdabcdabcd\",word2 = \"zyxwzyxwzyxwzyxwzyxwzyxw\") == \"zyxwzyxwzyxwzyxwzyxwzyxwabcdabcdabcdabcdabcdabcd\"\n assert candidate(word1 = \"xyxzyzyzyx\",word2 = \"zyzyzyzyxz\") == \"zyzyzyzyxzxyxzyzyzyx\"\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"xyzxyzxyzxyzxyz\") == \"xyzxyzxyzxyzxyzabacabadabacaba\"\n assert candidate(word1 = \"xyzz\",word2 = \"yxzz\") == \"yxzzxyzz\"\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"zyxwzyxwzyxw\") == \"zyxwzyxwzyxwabcdabcdabcd\"\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"zzzzyyyxxx\") == \"zzzzyyyxxxaabbccddeeff\"\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"zzyyxxwwvvuu\") == \"zzyyxxwwvvuuaabbccddeeff\"\n assert candidate(word1 = \"abcdefg\",word2 = \"hijklmnop\") == \"hijklmnopabcdefg\"\n assert candidate(word1 = \"banana\",word2 = \"bandana\") == \"bbandanananaa\"\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"dcbaabcdabcd\") == \"dcbabcdabcdabcdaabcdabcd\"\n assert candidate(word1 = \"abracadabra\",word2 = \"alakazam\") == \"alakazamabracadabra\"\n assert candidate(word1 = \"aaaabbbbcccc\",word2 = \"bbbbaaaacccc\") == \"bbbbaaaaccccaaaabbbbcccc\"\n assert candidate(word1 = \"leetcode\",word2 = \"edocteel\") == \"leetedocteelcode\"\n assert candidate(word1 = \"aaaaaaaabbbbbbbbcccccccc\",word2 = \"ccccccccbbbbbbbbbaaaaaaa\") == \"ccccccccbbbbbbbbbaaaaaaaabbbbbbbbccccccccaaaaaaa\"\n assert candidate(word1 = \"abcdxyz\",word2 = \"zyxcba\") == \"zyxcbabcdxyza\"\n assert candidate(word1 = \"ababababab\",word2 = \"bababababa\") == \"babababababababababa\"\n assert candidate(word1 = \"equalequal\",word2 = \"equal\") == \"equequalequalal\"\n assert candidate(word1 = \"abcabcabc\",word2 = \"abcabcabc\") == \"abcabcabcabcabcabc\"\n assert candidate(word1 = \"zzzzzzyyyy\",word2 = \"yyyyzzzzzz\") == \"zzzzzzyyyyzzzzzzyyyy\"\n assert candidate(word1 = \"racecar\",word2 = \"race\") == \"rracecarace\"\n assert candidate(word1 = \"programming\",word2 = \"challenges\") == \"progrchammingallenges\"\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcbaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzza\"\n assert candidate(word1 = \"abcdxyz\",word2 = \"zyxwvut\") == \"zyxwvutabcdxyz\"\n assert candidate(word1 = \"abacaxi\",word2 = \"abacax\") == \"abacaxiabacax\"\n assert candidate(word1 = \"aaaaaabbbbb\",word2 = \"cccccdddddeeeee\") == \"cccccdddddeeeeeaaaaaabbbbb\"\n assert candidate(word1 = \"abcdefg\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == \"zyxwvutsrqponmlkjihgfedcbabcdefga\"\n assert candidate(word1 = \"samecharacters\",word2 = \"samecharacters\") == \"ssamecharamecharactersacters\"\n assert candidate(word1 = \"abababababab\",word2 = \"babababababa\") == \"babababababababababababa\"\n assert candidate(word1 = \"aaaaab\",word2 = \"bbbaaa\") == \"bbbaaaaabaaa\"\n assert candidate(word1 = \"aabbbccc\",word2 = \"aabbcc\") == \"aabbccaabbbccc\"\n assert candidate(word1 = \"zzzzz\",word2 = \"zzzzzz\") == \"zzzzzzzzzzz\"\n assert candidate(word1 = \"\",word2 = \"abc\") == \"abc\"\n assert candidate(word1 = \"abcdefghijk\",word2 = \"abcdefghijl\") == \"abcdefghijlabcdefghijk\"\n assert candidate(word1 = \"nestednested\",word2 = \"nested\") == \"nnestesteednestedd\"\n assert candidate(word1 = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",word2 = \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\") == \"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n assert candidate(word1 = \"abcde\",word2 = \"edcba\") == \"edcbabcdea\"\n assert candidate(word1 = \"supercalifragilisticexpialidocious\",word2 = \"antidisestablishmentarianism\") == \"supercantidisestalifragilisticexpialidociousablishmentarianism\"\n assert candidate(word1 = \"xyzz\",word2 = \"zzxy\") == \"zzxyzzxy\"\n assert candidate(word1 = \"xyzz\",word2 = \"zzx\") == \"zzxyzzx\"\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"zzzzyyyxxxwwvvuuttssrrqqppoonnmmllkkjjiihghffeeddccbbaa\") == \"zzzzyyyxxxwwvvuuttssrrqqppoonnmmllkkjjiihghffeeddccbbaabbccddeeffaa\"\n assert candidate(word1 = \"abababab\",word2 = \"babababa\") == \"babababababababa\"\n assert candidate(word1 = \"xylophone\",word2 = \"xylophon\") == \"xyxyloplophonhone\"\n assert candidate(word1 = \"abc\",word2 = \"\") == \"abc\"\n assert candidate(word1 = \"abcdabcdabcdabcd\",word2 = \"zyxwzyxwzyxwzyxw\") == \"zyxwzyxwzyxwzyxwabcdabcdabcdabcd\"\n assert candidate(word1 = \"zzzz\",word2 = \"zzzz\") == \"zzzzzzzz\"\n assert candidate(word1 = \"longwordone\",word2 = \"longwordtwo\") == \"lonlongworgwordtwodone\"\n assert candidate(word1 = \"aaaaaaaaaaaa\",word2 = \"bbbbbbbbbbba\") == \"bbbbbbbbbbbaaaaaaaaaaaaa\"\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"dcba\") == \"dcbabcdabcdabcda\"\n assert candidate(word1 = \"aaaabbbbcccc\",word2 = \"ddddccccbbbaaaa\") == \"ddddccccbbbaaaabbbbccccaaaa\"\n assert candidate(word1 = \"leetcode\",word2 = \"contest\") == \"leetcontestcode\"\n assert candidate(word1 = \"pneumonoultramicroscopicsilicovolcanoconiosis\",word2 = \"zoology\") == \"zpoonlogyeumonoultramicroscopicsilicovolcanoconiosis\"\n assert candidate(word1 = \"abcdabcdb\",word2 = \"abcdabcdb\") == \"abcdabcdbabcdabcdb\"\n assert candidate(word1 = \"amazing\",word2 = \"algorithm\") == \"amazingalgorithm\"\n assert candidate(word1 = \"b\",word2 = \"a\") == \"ba\"\n assert candidate(word1 = \"qwerqwerqwer\",word2 = \"qwertyuiop\") == \"qwqwertyuioperqwerqwer\"\n assert candidate(word1 = \"onesmallstring\",word2 = \"averylongstringwithmanycharactersandvariouslengthsandcombinations\") == \"onesmaverylongstringwithmanycharallstringactersandvariouslengthsandcombinations\"\n assert candidate(word1 = \"banana\",word2 = \"apple\") == \"bappleanana\"\n assert candidate(word1 = \"abcde\",word2 = \"fghij\") == \"fghijabcde\"\n assert candidate(word1 = \"zyxwvutsrqponmlkjihgfedcba\",word2 = \"abcdefghijklmnopqrstuvwxyz\") == \"zyxwvutsrqponmlkjihgfedcbabcdefghijklmnopqrstuvwxyza\"\n assert candidate(word1 = \"zzyzxzyzxzy\",word2 = \"xyxyxyxyxyx\") == \"zzyzxzyzxzyxyxyxyxyxyx\"\n assert candidate(word1 = \"aabbcc\",word2 = \"bbccaa\") == \"bbccaabbccaa\"\n assert candidate(word1 = \"appleapple\",word2 = \"banana\") == \"bappleappleanana\"\n assert candidate(word1 = \"abcdef\",word2 = \"fghijk\") == \"fghijkabcdef\"\n assert candidate(word1 = \"zzzzyyyyxxx\",word2 = \"zzzyyyyxx\") == \"zzzzzzzyyyyyyyyxxxxx\"\n assert candidate(word1 = \"aaaaaabbbb\",word2 = \"bbbbbaaaa\") == \"bbbbbaaaaaabbbbaaaa\"\n assert candidate(word1 = \"aaaaaa\",word2 = \"bbbbbbbb\") == \"bbbbbbbbaaaaaa\"\n assert candidate(word1 = \"lexicographically\",word2 = \"mergeable\") == \"mlexiergecographicallyable\"\n assert candidate(word1 = \"abcabcabc\",word2 = \"cbacbacba\") == \"cbacbacbabcabcabca\"\n assert candidate(word1 = \"samestart\",word2 = \"samestart\") == \"ssamestartamestart\"\n assert candidate(word1 = \"zzzzzzzzzz\",word2 = \"zzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzz\"\n assert candidate(word1 = \"abcdexyz\",word2 = \"zyxwvuts\") == \"zyxwvutsabcdexyz\"\n assert candidate(word1 = \"abcdefg\",word2 = \"ghijklm\") == \"ghijklmabcdefg\"\n assert candidate(word1 = \"longwordone\",word2 = \"evenlongerwordtwo\") == \"longworevenlongerwordtwodone\"\n assert candidate(word1 = \"aaaab\",word2 = \"aaabaaa\") == \"aaabaaaabaaa\"\n assert candidate(word1 = \"abcdabcd\",word2 = \"dcbaabcd\") == \"dcbabcdabcdaabcd\"\n assert candidate(word1 = \"pneumonoultramicroscopicsilicovolcanoconiosis\",word2 = \"supercalifragilisticexpialidocious\") == \"suppneumonoultrercamicroscopicsilicovolcanoconiosisalifragilisticexpialidocious\"\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"aabbccddeegf\") == \"aabbccddeegfaabbccddeeff\"\n assert candidate(word1 = \"zyxzyxzyx\",word2 = \"zyxzyxzyx\") == \"zzyyxzyxzyxzyxzyxx\"\n assert candidate(word1 = \"overlapover\",word2 = \"overlap\") == \"ovoverlerlapoverap\"\n assert candidate(word1 = \"aebcdefghijklmnopqrstuvwxyz\",word2 = \"zxcvbnmlkjihgfedcbaeb\") == \"zxcvbnmlkjihgfedcbaebcdefghijklmnopqrstuvwxyzaeb\"\n assert candidate(word1 = \"abcdef\",word2 = \"fedcba\") == \"fedcbabcdefa\"\n assert candidate(word1 = \"aaaabbbbcccc\",word2 = \"ddddeeeeffff\") == \"ddddeeeeffffaaaabbbbcccc\"\n assert candidate(word1 = \"hellohellohello\",word2 = \"worldworld\") == \"worlhellohellohellodworld\"\n assert candidate(word1 = \"abcabcabcabc\",word2 = \"abcabc\") == \"abcabcabcabcabcabc\"\n assert candidate(word1 = \"zzzz\",word2 = \"zzz\") == \"zzzzzzz\"\n assert candidate(word1 = \"xyzzzzzzzzzzzz\",word2 = \"yyyyyyyyyyyyyy\") == \"yyyyyyyyyyyyyyxyzzzzzzzzzzzz\"\n assert candidate(word1 = \"aabaaa\",word2 = \"baabaa\") == \"baabaabaaaaa\"\n assert candidate(word1 = \"aaaaaaaaaabbbbbbbbbbcccccccccc\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\") == \"zzzzzzzzzzzzzzzzzzzzzzzzzzaaaaaaaaaabbbbbbbbbbcccccccccc\"\n"}, "metadata": {"canonical_parameter_names": ["word1", "word2"], "leetcode_dataset_entry_point": "Solution().largestMerge", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string largestMerge(string word1, string word2) {", "container": "Solution", "callable": "largestMerge", "parameters": [{"name": "word1", "type": "string"}, {"name": "word2", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1755, "task_id": "closest-subsequence-sum", "difficulty": "Hard", "problem_description": "You are given an integer array nums and an integer goal.\nYou want to choose a subsequence of nums such that the sum of its elements is the closest possible to goal. That is, if the sum of the subsequence's elements is sum, then you want to minimize the absolute difference abs(sum - goal).\nReturn the minimum possible value of abs(sum - goal).\nNote that a subsequence of an array is an array formed by removing some elements (possibly all or none) of the original array.\n \nExample 1:\n\nInput: nums = [5,-7,3,5], goal = 6\nOutput: 0\nExplanation: Choose the whole array as a subsequence, with a sum of 6.\nThis is equal to the goal, so the absolute difference is 0.\n\nExample 2:\n\nInput: nums = [7,-9,15,-2], goal = -5\nOutput: 1\nExplanation: Choose the subsequence [7,-9,-2], with a sum of -4.\nThe absolute difference is abs(-4 - (-5)) = abs(1) = 1, which is the minimum.\n\nExample 3:\n\nInput: nums = [1,2,3], goal = -7\nOutput: 7\n\n \nConstraints:\n\n1 <= nums.length <= 40\n-107 <= nums[i] <= 107\n-109 <= goal <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],goal = 10) == 0\n assert candidate(nums = [-10, -20, -30, -40, -50],goal = -100) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],goal = 100) == 0\n assert candidate(nums = [10, 22, 9, -24, -33, 21, 4, 19, 29, -14, 34, 10, -11, 8, -8, -7, 13, 24, -29, -10, -28, 10, -32, -23, 7, 31, 2, 25, -31, -40, -4, -23],goal = 100) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],goal = 15) == 0\n assert candidate(nums = [7, -9, 15, -2],goal = -5) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],goal = 25) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],goal = 10) == 0\n assert candidate(nums = [10000000, -10000000, 10000000, -10000000],goal = 0) == 0\n assert candidate(nums = [10000000, -10000000, 5000000, -5000000],goal = 0) == 0\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],goal = -255) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],goal = 20) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],goal = 0) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5],goal = -15) == 0\n assert candidate(nums = [1, 2, 3],goal = -7) == 7\n assert candidate(nums = [5, -7, 3, 5],goal = 6) == 0\n assert candidate(nums = [10000000, -10000000],goal = 0) == 0\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16],goal = 0) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],goal = 0) == 0\n assert candidate(nums = [-10, 10, -20, 20, -30, 30, -40, 40, -50, 50, -60, 60, -70, 70, -80, 80, -90, 90, -100, 100],goal = -500) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35, -36, -37, -38, -39, -40],goal = -1000) == 180\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],goal = 900) == 80\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80],goal = 5) == 5\n assert candidate(nums = [-1000, 1000, -500, 500, -250, 250, -125, 125, -62, 62, -31, 31, -15, 15, -7, 7, -3, 3, -1, 1],goal = -1000) == 0\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],goal = -450) == 0\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],goal = 0) == 0\n assert candidate(nums = [10000000, -10000000, 5000000, -5000000, 2500000, -2500000],goal = 3000000) == 500000\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20],goal = 50) == 0\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, -1000000, -2000000, -3000000, -4000000, -5000000, -6000000, -7000000, -8000000, -9000000, -10000000],goal = 20000000) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],goal = 500) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],goal = 100) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000],goal = 10000) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],goal = 10000) == 0\n assert candidate(nums = [10000000, -5000000, 3000000, -2000000, 1500000, -1000000, 750000, -500000, 250000, -125000, 62500, -31250, 15625, -7812, 3906, -1953, 976, -488, 244, -122],goal = 0) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100],goal = 50) == 0\n assert candidate(nums = [-10000, -20000, -30000, -40000, -50000, 10000, 20000, 30000, 40000, 50000],goal = -50000) == 0\n assert candidate(nums = [7, 3, 8, 4, 6, 2, 5, 1, 10, 9],goal = 42) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],goal = 100) == 0\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946],goal = 5000) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],goal = 1500) == 0\n assert candidate(nums = [5, -3, 1, 7, -9, 10, -20, 15, -1, 4, 8, -6, 2, 11, -7, 13, -5, 9, -12, 6, 14, -4, 16, -8, 12, -11, 17, -13, 18, -9, 19, -14, 20, -15, 21, -16, 22, -17, 23, -18],goal = 50) == 0\n assert candidate(nums = [-100, 100, -200, 200, -300, 300, -400, 400, -500, 500, -600, 600, -700, 700, -800, 800, -900, 900, -1000, 1000],goal = 0) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],goal = -15) == 0\n assert candidate(nums = [-10000000, 20000000, -10000000, 20000000, -10000000, 20000000, -10000000, 20000000, -10000000, 20000000, -10000000, 20000000, -10000000, 20000000, -10000000, 20000000, -10000000, 20000000, -10000000, 20000000],goal = 15000000) == 5000000\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8],goal = 1) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, -5, -10, -15, -20, -25, -30, -35, -40, -45, -50],goal = 0) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],goal = 800) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60],goal = 5) == 5\n assert candidate(nums = [5, -7, 3, 5, 9, -1, 2, -3, 8],goal = 6) == 0\n assert candidate(nums = [10000000, -10000000, 20000000, -20000000, 30000000, -30000000, 40000000, -40000000],goal = 0) == 0\n assert candidate(nums = [10000000, -5000000, 2500000, -1250000, 625000, -312500, 156250, -78125, 39062, -19531, 9765, -4882, 2441, -1220, 610, -305, 152, -76, 38, -19, 9, -4, 2, -1],goal = 5000000) == 0\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, -5, -15, -25, -35, -45, -55, -65, -75, -85, -95, -105],goal = 250) == 0\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],goal = 0) == 0\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7, 5, 1, 0],goal = 123) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],goal = 300) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20],goal = -100) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20],goal = 5) == 0\n assert candidate(nums = [10000000, -10000000, 5000000, -5000000, 2500000, -2500000, 1250000, -1250000, 625000, -625000, 312500, -312500, 156250, -156250, 78125, -78125],goal = 0) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],goal = 1) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],goal = 2000) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],goal = 1) == 0\n assert candidate(nums = [10000000, 9000000, 8000000, 7000000, 6000000, 5000000, 4000000, 3000000, 2000000, 1000000, -1000000, -2000000, -3000000, -4000000, -5000000, -6000000, -7000000, -8000000, -9000000, -10000000],goal = 5000000) == 0\n assert candidate(nums = [3, -1, 4, 1, 5, -9, 2, 6, 5, 3, -5, 7, -7, 8, -8, 9, -9, 10, -10],goal = 0) == 0\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],goal = 1000000) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1],goal = 50) == 30\n assert candidate(nums = [-10000000, 10000000, -5000000, 5000000, 2500000, -2500000, 1250000, -1250000],goal = 1234567) == 15433\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10, -11, 11, -12, 12, -13, 13, -14, 14, -15, 15, -16, 16, -17, 17, -18, 18, -19, 19, -20, 20],goal = 0) == 0\n assert candidate(nums = [1000000, -1000000, 2000000, -2000000, 3000000, -3000000, 4000000, -4000000, 5000000, -5000000, 6000000, -6000000, 7000000, -7000000, 8000000, -8000000, 9000000, -9000000, 10000000, -10000000],goal = 5000000) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50],goal = 0) == 0\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900, 1000, -1000],goal = 500) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],goal = 1000) == 180\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],goal = -1000) == 1000\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15, 16, -16, 17, -17, 18, -18, 19, -19, 20, -20],goal = 0) == 0\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10, -11, 11, -12, 12, -13, 13, -14, 14, -15, 15],goal = 50) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],goal = 0) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20],goal = -30) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20],goal = -50) == 0\n assert candidate(nums = [10000000, -10000000, 5000000, -5000000, 2500000, -2500000, 1250000, -1250000],goal = 0) == 0\n assert candidate(nums = [-10000, 10000, -20000, 20000, -30000, 30000, -40000, 40000, -50000, 50000, -60000, 60000, -70000, 70000, -80000, 80000, -90000, 90000, -100000, 100000],goal = 0) == 0\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23, 24, -25, 26, -27, 28, -29, 30, -31, 32, -33, 34, -35, 36, -37, 38, -39, 40],goal = 0) == 0\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7, 5, 1, 0],goal = 150) == 0\n assert candidate(nums = [9999999, 8888888, 7777777, 6666666, 5555555, 4444444, 3333333, 2222222, 1111111, -1111111, -2222222, -3333333, -4444444, -5555555, -6666666, -7777777, -8888888, -9999999],goal = 123456789) == 73456794\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946],goal = 10000) == 0\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20],goal = 5) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],goal = 1000) == 100\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20, -21, -22, -23, -24, -25, -26, -27, -28, -29, -30, -31, -32, -33, -34, -35, -36, -37, -38, -39, -40],goal = -1) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],goal = 1234) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],goal = 1) == 0\n assert candidate(nums = [10000000, -10000000, 20000000, -20000000, 30000000],goal = 15000000) == 5000000\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],goal = 10) == 0\n assert candidate(nums = [10000000, -10000000, 5000000, -5000000, 2500000, -2500000],goal = 0) == 0\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20, -21, 22, -23, 24, -25, 26, -27, 28, -29, 30],goal = -150) == 0\n assert candidate(nums = [1000000, -1000000, 500000, -500000, 250000, -250000],goal = 0) == 0\n assert candidate(nums = [10000, -10000, 20000, -20000, 30000, -30000, 40000, -40000, 50000, -50000],goal = 25000) == 5000\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],goal = 500) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],goal = 450) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],goal = 999) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],goal = 500) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "goal"], "leetcode_dataset_entry_point": "Solution().minAbsDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minAbsDifference(vector& nums, int goal) {", "container": "Solution", "callable": "minAbsDifference", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "goal", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1758, "task_id": "minimum-changes-to-make-alternating-binary-string", "difficulty": "Easy", "problem_description": "You are given a string s consisting only of the characters '0' and '1'. In one operation, you can change any '0' to '1' or vice versa.\nThe string is called alternating if no two adjacent characters are equal. For example, the string \"010\" is alternating, while the string \"0100\" is not.\nReturn the minimum number of operations needed to make s alternating.\n \nExample 1:\n\nInput: s = \"0100\"\nOutput: 1\nExplanation: If you change the last character to '1', s will be \"0101\", which is alternating.\n\nExample 2:\n\nInput: s = \"10\"\nOutput: 0\nExplanation: s is already alternating.\n\nExample 3:\n\nInput: s = \"1111\"\nOutput: 2\nExplanation: You need two operations to reach \"0101\" or \"1010\".\n\n \nConstraints:\n\n1 <= s.length <= 104\ns[i] is either '0' or '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1111\") == 2\n assert candidate(s = \"101010\") == 0\n assert candidate(s = \"111000\") == 2\n assert candidate(s = \"1101101101\") == 4\n assert candidate(s = \"001100\") == 3\n assert candidate(s = \"10\") == 0\n assert candidate(s = \"110011\") == 3\n assert candidate(s = \"0100\") == 1\n assert candidate(s = \"0110101010\") == 2\n assert candidate(s = \"010101\") == 0\n assert candidate(s = \"0000\") == 2\n assert candidate(s = \"000111\") == 2\n assert candidate(s = \"101010101010101010\") == 0\n assert candidate(s = \"1100110011001100110011001100110011\") == 17\n assert candidate(s = \"01010101010101010\") == 0\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111111111111\") == 30\n assert candidate(s = \"10101101010110101010\") == 7\n assert candidate(s = \"00000000000000000000000000000000\") == 16\n assert candidate(s = \"111110000111110000111110000111110000111110000111110000\") == 27\n assert candidate(s = \"1100110011001100\") == 8\n assert candidate(s = \"010101010101010101010101\") == 0\n assert candidate(s = \"111000111000111\") == 5\n assert candidate(s = \"0110101010101010\") == 2\n assert candidate(s = \"101010101010101010101010\") == 0\n assert candidate(s = \"1010101010101001\") == 2\n assert candidate(s = \"101010101010101010101\") == 0\n assert candidate(s = \"1000111010010101\") == 8\n assert candidate(s = \"0000000000\") == 5\n assert candidate(s = \"1100110011\") == 5\n assert candidate(s = \"111000111000111000111000111000\") == 10\n assert candidate(s = \"11110000000000001111\") == 10\n assert candidate(s = \"0000000000000000\") == 8\n assert candidate(s = \"11001100110011001100110011001100\") == 16\n assert candidate(s = \"1010101010101010\") == 0\n assert candidate(s = \"110011001100\") == 6\n assert candidate(s = \"110011001100110011\") == 9\n assert candidate(s = \"010101010110\") == 2\n assert candidate(s = \"0011001100110011\") == 8\n assert candidate(s = \"000001111000001111000011110000111100001111000011110000\") == 27\n assert candidate(s = \"1010100101010101010101010101010101\") == 6\n assert candidate(s = \"11111000001111100000\") == 8\n assert candidate(s = \"0101010101010101010101010101010101\") == 0\n assert candidate(s = \"100100100100100100100100\") == 12\n assert candidate(s = \"00110011001100110011001100110011\") == 16\n assert candidate(s = \"0110110110110110\") == 8\n assert candidate(s = \"10110101010101010101\") == 3\n assert candidate(s = \"1010010101010101\") == 4\n assert candidate(s = \"0101011010101010\") == 6\n assert candidate(s = \"010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"0011001100110\") == 6\n assert candidate(s = \"11111111111111111111\") == 10\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001\") == 26\n assert candidate(s = \"00001111111111110000\") == 10\n assert candidate(s = \"1111111111111111\") == 8\n assert candidate(s = \"01010101010\") == 0\n assert candidate(s = \"111000111000111000111000111000111000111000111000111000111\") == 19\n assert candidate(s = \"001100110011\") == 6\n assert candidate(s = \"11010011\") == 3\n assert candidate(s = \"00011100011100011100011100011100\") == 11\n assert candidate(s = \"011011011011011011011011\") == 12\n assert candidate(s = \"00000111110000011111\") == 8\n assert candidate(s = \"111000111000111000111\") == 7\n assert candidate(s = \"11001100110011001100\") == 10\n assert candidate(s = \"01010101010101010101010101010101\") == 0\n assert candidate(s = \"10010010010010010010\") == 9\n assert candidate(s = \"1010101010101010101010101010\") == 0\n assert candidate(s = \"1110000111000011\") == 8\n assert candidate(s = \"01110111011101110111\") == 5\n assert candidate(s = \"111100001111\") == 6\n assert candidate(s = \"1101101101101101\") == 7\n assert candidate(s = \"01100110011001100110\") == 10\n assert candidate(s = \"00110011001100\") == 7\n assert candidate(s = \"010101010101\") == 0\n assert candidate(s = \"1111111111111111111111111111\") == 14\n assert candidate(s = \"0101010101010101\") == 0\n assert candidate(s = \"0001110001\") == 3\n assert candidate(s = \"11111111111111111111111111111111\") == 16\n assert candidate(s = \"00000000\") == 4\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"01100110011001100110011001100110011\") == 17\n assert candidate(s = \"0101010101\") == 0\n assert candidate(s = \"1001001001001001001001001001001001\") == 17\n assert candidate(s = \"00001111000011110000111100001111\") == 16\n assert candidate(s = \"10101010101010101\") == 0\n assert candidate(s = \"111000111\") == 3\n assert candidate(s = \"000000000000000000000000000000000000000000000000000000000000\") == 30\n assert candidate(s = \"0111000111000111\") == 5\n assert candidate(s = \"0001111000111100\") == 8\n assert candidate(s = \"1010101010101\") == 0\n assert candidate(s = \"00000000000000000000\") == 10\n assert candidate(s = \"1111000011110000\") == 8\n assert candidate(s = \"10101010101010101010101010101010\") == 0\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"010010010010\") == 6\n assert candidate(s = \"0111000101101010\") == 8\n assert candidate(s = \"0110110110110\") == 6\n assert candidate(s = \"01010101010101\") == 0\n assert candidate(s = \"001100110011001100110\") == 10\n assert candidate(s = \"1001001001001\") == 6\n assert candidate(s = \"010101010101010101010\") == 0\n assert candidate(s = \"1111111111\") == 5\n assert candidate(s = \"0110011001100110\") == 8\n assert candidate(s = \"1100110011001100110011001100110011001100110011001100110011001100\") == 32\n assert candidate(s = \"1001100110011001\") == 8\n assert candidate(s = \"01010101010101010101\") == 0\n assert candidate(s = \"11111111\") == 4\n assert candidate(s = \"1101001100\") == 4\n assert candidate(s = \"0001110001110001110001\") == 7\n assert candidate(s = \"110000111100001111000011110000\") == 15\n assert candidate(s = \"01101101101101101101\") == 9\n assert candidate(s = \"10101010101010101010\") == 0\n assert candidate(s = \"01010010101001010101\") == 7\n assert candidate(s = \"1101010101\") == 1\n assert candidate(s = \"111000111000111000111000\") == 8\n assert candidate(s = \"0000000000000000000000000000\") == 14\n assert candidate(s = \"000111000111000\") == 5\n assert candidate(s = \"0000111100001111\") == 8\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minOperations(string s) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1759, "task_id": "count-number-of-homogenous-substrings", "difficulty": "Medium", "problem_description": "Given a string s, return the number of homogenous substrings of s. Since the answer may be too large, return it modulo 109 + 7.\nA string is homogenous if all the characters of the string are the same.\nA substring is a contiguous sequence of characters within a string.\n \nExample 1:\n\nInput: s = \"abbcccaa\"\nOutput: 13\nExplanation: The homogenous substrings are listed as below:\n\"a\" appears 3 times.\n\"aa\" appears 1 time.\n\"b\" appears 2 times.\n\"bb\" appears 1 time.\n\"c\" appears 3 times.\n\"cc\" appears 2 times.\n\"ccc\" appears 1 time.\n3 + 1 + 2 + 1 + 3 + 2 + 1 = 13.\nExample 2:\n\nInput: s = \"xy\"\nOutput: 2\nExplanation: The homogenous substrings are \"x\" and \"y\".\nExample 3:\n\nInput: s = \"zzzzz\"\nOutput: 15\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists of lowercase letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaabbbccc\") == 18\n assert candidate(s = \"aabbccddeeefffggghhhiiii\") == 46\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 26\n assert candidate(s = \"xy\") == 2\n assert candidate(s = \"aabbaa\") == 9\n assert candidate(s = \"aaaaa\") == 15\n assert candidate(s = \"pppppppppp\") == 55\n assert candidate(s = \"abcdeffffff\") == 26\n assert candidate(s = \"a\") == 1\n assert candidate(s = \"qqqqqwwweeeerrrrtttttyyyyyuuuuuiooooo\") == 102\n assert candidate(s = \"abcabcabc\") == 9\n assert candidate(s = \"ababababab\") == 10\n assert candidate(s = \"abcde\") == 5\n assert candidate(s = \"ababababa\") == 9\n assert candidate(s = \"zzzzyyyyxxxwwwwvvvvuuuuttttsrrrqqqppoonnmlkjihgfedcba\") == 101\n assert candidate(s = \"ccccccccc\") == 45\n assert candidate(s = \"abbcccaa\") == 13\n assert candidate(s = \"abcd\") == 4\n assert candidate(s = \"zzzzz\") == 15\n assert candidate(s = \"ababab\") == 6\n assert candidate(s = \"aaaaaabb\") == 24\n assert candidate(s = \"aabbccddeeeeffff\") == 32\n assert candidate(s = \"abcabcabcabcabcabcabc\") == 21\n assert candidate(s = \"aabbbccccdddd\") == 29\n assert candidate(s = \"mmmmmlllllkkkkkkjjjjjjjjiiiiiiiiiiiihhhhhhhhhhhh\") == 243\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1326\n assert candidate(s = \"aaabaaaabaaaaabaaaaaaabaaaaaaaabaaaaaaaaabaaaaaaaaaabaaaaaaaaaa\") == 257\n assert candidate(s = \"aaaaaaaaaabbbbbbbbccccccccddddddddeeeeeeeee\") == 208\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 903\n assert candidate(s = \"aabbcccddddeeeee\") == 37\n assert candidate(s = \"pppppqqqqqqrrrrrrsssssstttttuuuuuuvvvvvvvvvwwwwwwwww\") == 204\n assert candidate(s = \"aabbbcccc\") == 19\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 676\n assert candidate(s = \"aaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaa\") == 252\n assert candidate(s = \"mmmmmmmmmmmmmmmnnnnnnnnnnnnnnnoooooooooooopppppppppppp\") == 396\n assert candidate(s = \"aabbccddeeefffggg\") == 30\n assert candidate(s = \"abcabcabcabc\") == 12\n assert candidate(s = \"aaabbaaaabbaaa\") == 28\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbcccccccccc\") == 165\n assert candidate(s = \"aabbccddeeefffggghhhh\") == 40\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 277140\n assert candidate(s = \"zzzzyyyyzzzz\") == 30\n assert candidate(s = \"aaaaabbbbccccc\") == 40\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 29403\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyz\") == 24\n assert candidate(s = \"aabbccddeeeeffffggggghhhhiiiii\") == 72\n assert candidate(s = \"pppppppppppppppppppppppppppppppppp\") == 595\n assert candidate(s = \"ababababababababababababababab\") == 30\n assert candidate(s = \"aaaaabbbbccccdddddeeeee\") == 65\n assert candidate(s = \"aabbccddeeefffggghhhhiiiiijjjjjkkkkklllllmmmmmnnnnnooooo\") == 145\n assert candidate(s = \"pppppppppppppppppppppppppppppppppppppppppppqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\") == 1892\n assert candidate(s = \"ppppppppppppppppppppppp\") == 276\n assert candidate(s = \"xyzzyzxzyzxyz\") == 14\n assert candidate(s = \"ababababababab\") == 14\n assert candidate(s = \"aabbccddeeeefffghhhiiiijjjjkkkkllllmmmmmnnnnnooooo\") == 120\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyza\") == 27\n assert candidate(s = \"aabbccddeeefffggghhhiiiijjjjkkkkllllmmmmmnnnnnooooooo\") == 134\n assert candidate(s = \"aaaaaaaaabbbbbbbbbbcccccccccc\") == 155\n assert candidate(s = \"zzzzzyyyxxxwwwwvvvvuuuuu\") == 62\n assert candidate(s = \"aabbccddeeeeffffggggghhhiiijjjkkklllmmnnooopppqqqrrsssttuuuvvvwwwwwxxxxxyyyyyzzzz\") == 180\n assert candidate(s = \"abcdefffffffffffffffffffffffffghijklmnopqrstuvwxyz\") == 350\n assert candidate(s = \"abcdabcdbcdabcd\") == 15\n assert candidate(s = \"aabbbbccccc\") == 28\n assert candidate(s = \"aaaaaaaaaaaabbaaaaaaa\") == 109\n assert candidate(s = \"aabbbccccc\") == 24\n assert candidate(s = \"xyxyxyxyxyxyxyx\") == 15\n assert candidate(s = \"aabbaaabbbaaa\") == 24\n assert candidate(s = \"aabbaaabbcccddeee\") == 30\n assert candidate(s = \"aabbccddeeffgg\") == 21\n assert candidate(s = \"aaaaabbbbbbbbbbcccccccccc\") == 125\n assert candidate(s = \"pppppppppppppppppppppppppppppppppppppppp\") == 820\n assert candidate(s = \"aabbaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 84\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 160\n assert candidate(s = \"qwerqwerqwerqwerqwerqwerqwer\") == 28\n assert candidate(s = \"aaabbaaa\") == 15\n assert candidate(s = \"aaabbaaabbaaa\") == 24\n assert candidate(s = \"abcabcabcabcabc\") == 15\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 21736\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1275\n assert candidate(s = \"abcdefg\") == 7\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().countHomogenous", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countHomogenous(string s) {", "container": "Solution", "callable": "countHomogenous", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1760, "task_id": "minimum-limit-of-balls-in-a-bag", "difficulty": "Medium", "problem_description": "You are given an integer array nums where the ith bag contains nums[i] balls. You are also given an integer maxOperations.\nYou can perform the following operation at most maxOperations times:\n\nTake any bag of balls and divide it into two new bags with a positive number of balls.\n\n\t\nFor example, a bag of 5 balls can become two new bags of 1 and 4 balls, or two new bags of 2 and 3 balls.\n\n\n\nYour penalty is the maximum number of balls in a bag. You want to minimize your penalty after the operations.\nReturn the minimum possible penalty after performing the operations.\n \nExample 1:\n\nInput: nums = [9], maxOperations = 2\nOutput: 3\nExplanation: \n- Divide the bag with 9 balls into two bags of sizes 6 and 3. [9] -> [6,3].\n- Divide the bag with 6 balls into two bags of sizes 3 and 3. [6,3] -> [3,3,3].\nThe bag with the most number of balls has 3 balls, so your penalty is 3 and you should return 3.\n\nExample 2:\n\nInput: nums = [2,4,8,2], maxOperations = 4\nOutput: 2\nExplanation:\n- Divide the bag with 8 balls into two bags of sizes 4 and 4. [2,4,8,2] -> [2,4,4,4,2].\n- Divide the bag with 4 balls into two bags of sizes 2 and 2. [2,4,4,4,2] -> [2,2,2,4,4,2].\n- Divide the bag with 4 balls into two bags of sizes 2 and 2. [2,2,2,4,4,2] -> [2,2,2,2,2,4,2].\n- Divide the bag with 4 balls into two bags of sizes 2 and 2. [2,2,2,2,2,4,2] -> [2,2,2,2,2,2,2,2].\nThe bag with the most number of balls has 2 balls, so your penalty is 2, and you should return 2.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= maxOperations, nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5],maxOperations = 10) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],maxOperations = 9) == 5\n assert candidate(nums = [1000000000],maxOperations = 1) == 500000000\n assert candidate(nums = [3, 3, 3, 3],maxOperations = 0) == 3\n assert candidate(nums = [1, 2, 3, 4, 5],maxOperations = 5) == 2\n assert candidate(nums = [100, 100, 100, 100],maxOperations = 10) == 34\n assert candidate(nums = [1, 1, 1, 1, 1],maxOperations = 0) == 1\n assert candidate(nums = [1000000000],maxOperations = 999999999) == 1\n assert candidate(nums = [1000000000],maxOperations = 1000000000) == 1\n assert candidate(nums = [7, 17],maxOperations = 2) == 7\n assert candidate(nums = [9],maxOperations = 2) == 3\n assert candidate(nums = [10, 20, 30, 40, 50],maxOperations = 10) == 10\n assert candidate(nums = [2, 4, 8, 2],maxOperations = 4) == 2\n assert candidate(nums = [1000000000, 1000000000],maxOperations = 1) == 1000000000\n assert candidate(nums = [10, 10, 10],maxOperations = 6) == 4\n assert candidate(nums = [10, 10, 10],maxOperations = 3) == 5\n assert candidate(nums = [7, 14, 21, 28],maxOperations = 3) == 14\n assert candidate(nums = [1, 1, 1, 1],maxOperations = 2) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],maxOperations = 5) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maxOperations = 5) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],maxOperations = 5) == 50\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1000000000],maxOperations = 9) == 100000000\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],maxOperations = 25) == 180\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000],maxOperations = 30) == 3449\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maxOperations = 29) == 1\n assert candidate(nums = [1000000000, 1000000000, 1000000000],maxOperations = 3) == 500000000\n assert candidate(nums = [999999999, 1],maxOperations = 1) == 500000000\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],maxOperations = 9) == 100\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000],maxOperations = 10) == 142857143\n assert candidate(nums = [999, 999, 999, 999, 999, 999, 999, 999, 999, 999],maxOperations = 5) == 999\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000],maxOperations = 3) == 333333334\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000],maxOperations = 5) == 250000000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],maxOperations = 20) == 44\n assert candidate(nums = [10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],maxOperations = 9) == 100000000\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],maxOperations = 15) == 10\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995],maxOperations = 10) == 333333333\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],maxOperations = 10) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],maxOperations = 14) == 5\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],maxOperations = 50) == 18\n assert candidate(nums = [1000000000],maxOperations = 0) == 1000000000\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],maxOperations = 50) == 3\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],maxOperations = 19) == 1000\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],maxOperations = 10) == 500\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],maxOperations = 9) == 50\n assert candidate(nums = [1000000000, 500000000, 250000000],maxOperations = 3) == 333333334\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],maxOperations = 10) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],maxOperations = 15) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],maxOperations = 30) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maxOperations = 0) == 1\n assert candidate(nums = [1, 1000000000, 1],maxOperations = 1000000000) == 1\n assert candidate(nums = [999999999, 999999999, 999999999, 999999999, 999999999],maxOperations = 5) == 500000000\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9],maxOperations = 5) == 166666667\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],maxOperations = 19) == 7\n assert candidate(nums = [999999999, 999999999, 999999999, 999999999, 999999999],maxOperations = 10) == 333333333\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],maxOperations = 50) == 10000\n assert candidate(nums = [1, 1, 1, 1, 1000000000],maxOperations = 999999) == 1000\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],maxOperations = 30) == 6\n assert candidate(nums = [1000000000, 1000000000, 1000000000],maxOperations = 2999999997) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],maxOperations = 20) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],maxOperations = 20) == 20\n assert candidate(nums = [999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999, 999999999],maxOperations = 4999999995) == 2\n assert candidate(nums = [1000000000, 500000000, 250000000, 125000000, 62500000, 31250000, 15625000, 7812500, 3906250, 1953125],maxOperations = 10) == 142857143\n assert candidate(nums = [500000000, 500000000, 500000000, 500000000, 500000000],maxOperations = 1000000) == 2500\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],maxOperations = 15) == 7\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],maxOperations = 50) == 9\n assert candidate(nums = [500000000, 500000000, 500000000, 500000000, 500000000],maxOperations = 10) == 166666667\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],maxOperations = 30) == 50\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],maxOperations = 45) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],maxOperations = 10) == 4\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],maxOperations = 20) == 5\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],maxOperations = 15) == 114\n assert candidate(nums = [999999999, 999999999, 999999999, 999999999],maxOperations = 4) == 500000000\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],maxOperations = 20) == 5\n assert candidate(nums = [2, 3, 6, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],maxOperations = 100) == 6\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],maxOperations = 50) == 1171\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],maxOperations = 20) == 19\n assert candidate(nums = [100, 200, 300, 400, 500],maxOperations = 15) == 84\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],maxOperations = 10) == 74\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maxOperations = 5) == 1\n assert candidate(nums = [999999999, 999999998, 999999997],maxOperations = 2) == 999999997\n assert candidate(nums = [100, 200, 300, 400, 500],maxOperations = 50) == 29\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],maxOperations = 5) == 5\n assert candidate(nums = [999999999, 999999999, 999999999, 999999999, 999999999, 999999999],maxOperations = 10) == 500000000\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000],maxOperations = 5) == 500000\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000],maxOperations = 9999999990) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],maxOperations = 45) == 100\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000],maxOperations = 10) == 10000000\n assert candidate(nums = [500000000, 500000000, 500000000, 500000000],maxOperations = 3) == 500000000\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000],maxOperations = 50) == 28572\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],maxOperations = 100) == 500\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],maxOperations = 20) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],maxOperations = 0) == 10\n assert candidate(nums = [1000000000, 1000000000, 1000000000],maxOperations = 2) == 1000000000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maxOperations = 30) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],maxOperations = 10) == 350\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],maxOperations = 9) == 8\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],maxOperations = 25) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maxOperations = 9) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],maxOperations = 10) == 7\n"}, "metadata": {"canonical_parameter_names": ["nums", "maxOperations"], "leetcode_dataset_entry_point": "Solution().minimumSize", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumSize(vector& nums, int maxOperations) {", "container": "Solution", "callable": "minimumSize", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "maxOperations", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1761, "task_id": "minimum-degree-of-a-connected-trio-in-a-graph", "difficulty": "Hard", "problem_description": "You are given an undirected graph. You are given an integer n which is the number of nodes in the graph and an array edges, where each edges[i] = [ui, vi] indicates that there is an undirected edge between ui and vi.\nA connected trio is a set of three nodes where there is an edge between every pair of them.\nThe degree of a connected trio is the number of edges where one endpoint is in the trio, and the other is not.\nReturn the minimum degree of a connected trio in the graph, or -1 if the graph has no connected trios.\n \nExample 1:\n\n\nInput: n = 6, edges = [[1,2],[1,3],[3,2],[4,1],[5,2],[3,6]]\nOutput: 3\nExplanation: There is exactly one trio, which is [1,2,3]. The edges that form its degree are bolded in the figure above.\n\nExample 2:\n\n\nInput: n = 7, edges = [[1,3],[4,1],[4,3],[2,5],[5,6],[6,7],[7,5],[2,6]]\nOutput: 0\nExplanation: There are exactly three trios:\n1) [1,4,3] with degree 0.\n2) [2,5,6] with degree 2.\n3) [5,6,7] with degree 2.\n\n \nConstraints:\n\n2 <= n <= 400\nedges[i].length == 2\n1 <= edges.length <= n * (n-1) / 2\n1 <= ui, vi <= n\nui != vi\nThere are no repeated edges.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,edges = [[1, 2], [1, 3], [2, 3]]) == 0\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 3\n assert candidate(n = 400,edges = [[1, 2], [2, 3], [3, 1]]) == 0\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [7, 8], [8, 9], [9, 7], [10, 1]]) == 0\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [5, 6], [6, 4], [7, 8]]) == 0\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [7, 8]]) == 0\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [3, 2], [4, 1], [5, 2], [3, 6]]) == 3\n assert candidate(n = 3,edges = [[1, 2], [2, 3], [3, 1]]) == 0\n assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 1], [1, 4], [4, 5], [5, 1]]) == 2\n assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 4], [4, 5]]) == -1\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8]]) == 0\n assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [2, 4], [3, 5]]) == 4\n assert candidate(n = 4,edges = [[1, 2], [2, 3], [3, 4]]) == -1\n assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == -1\n assert candidate(n = 7,edges = [[1, 3], [4, 1], [4, 3], [2, 5], [5, 6], [6, 7], [7, 5], [2, 6]]) == 0\n assert candidate(n = 5,edges = [[1, 2], [2, 3], [3, 1], [3, 4], [4, 5]]) == 1\n assert candidate(n = 3,edges = [[1, 2], [2, 3]]) == -1\n assert candidate(n = 4,edges = [[1, 2], [2, 3], [3, 1], [1, 4], [2, 4], [3, 4]]) == 3\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [6, 7], [7, 8], [5, 7], [6, 8], [4, 7], [4, 8]]) == 0\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [7, 10], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12], [1, 10], [2, 11], [3, 12]]) == 9\n assert candidate(n = 100,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 20], [20, 19], [1, 100], [100, 50], [50, 25], [25, 75], [75, 50], [50, 1], [2, 50], [3, 50], [4, 50], [5, 50], [6, 50], [7, 50], [8, 50], [9, 50], [10, 50], [11, 50], [12, 50], [13, 50], [14, 50], [15, 50], [16, 50], [17, 50], [18, 50], [19, 50], [21, 50], [22, 50], [23, 50], [24, 50], [25, 50], [26, 50], [27, 50], [28, 50], [29, 50], [30, 50], [31, 50], [32, 50], [33, 50], [34, 50], [35, 50], [36, 50], [37, 50], [38, 50], [39, 50], [40, 50], [41, 50], [42, 50], [43, 50], [44, 50], [45, 50], [46, 50], [47, 50], [48, 50], [49, 50], [51, 50], [52, 50], [53, 50], [54, 50], [55, 50], [56, 50], [57, 50], [58, 50], [59, 50], [60, 50], [61, 50], [62, 50], [63, 50], [64, 50], [65, 50], [66, 50], [67, 50], [68, 50], [69, 50], [70, 50], [71, 50], [72, 50], [73, 50], [74, 50], [75, 50], [76, 50], [77, 50], [78, 50], [79, 50], [80, 50], [81, 50], [82, 50], [83, 50], [84, 50], [85, 50], [86, 50], [87, 50], [88, 50], [89, 50], [90, 50], [91, 50], [92, 50], [93, 50], [94, 50], [95, 50], [96, 50], [97, 50], [98, 50], [99, 50], [100, 99]]) == 3\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 1], [2, 5], [3, 5]]) == 5\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 3], [2, 4], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [5, 6], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [8, 9], [8, 10], [8, 11], [8, 12], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [14, 15], [14, 16], [14, 17], [14, 18], [15, 16], [15, 17], [15, 18], [16, 17], [16, 18], [17, 18], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [20, 21], [20, 22], [20, 23], [20, 24], [21, 22], [21, 23], [21, 24], [22, 23], [22, 24], [23, 24], [1, 13], [2, 14], [3, 15], [4, 16], [5, 17], [6, 18], [7, 19], [8, 20], [9, 21], [10, 22], [11, 23], [12, 24]]) == 12\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19], [11, 20], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19], [10, 20]]) == 9\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1]]) == 6\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10]]) == 3\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12], [13, 14], [13, 15], [13, 16], [14, 15], [14, 16], [15, 16], [17, 18], [17, 19], [17, 20], [18, 19], [18, 20], [19, 20], [1, 5], [2, 6], [3, 7], [4, 8], [1, 9], [2, 10], [3, 11], [4, 12], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20]]) == 6\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1], [1, 3], [4, 6], [2, 7], [5, 8]]) == 3\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12], [13, 14], [13, 15], [13, 16], [14, 15], [14, 16], [15, 16], [17, 18], [17, 19], [17, 20], [18, 19], [18, 20], [19, 20], [21, 22], [21, 23], [21, 24], [22, 23], [22, 24], [23, 24], [25, 26], [25, 27], [25, 28], [26, 27], [26, 28], [27, 28], [29, 30]]) == 3\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [1, 5], [2, 5], [3, 5], [4, 5], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8]]) == 3\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12], [13, 14], [13, 15], [13, 16], [14, 15], [14, 16], [15, 16], [17, 18], [17, 19], [17, 20], [18, 19], [18, 20], [19, 20], [21, 22], [21, 23], [21, 24], [22, 23], [22, 24], [23, 24], [25, 26], [25, 27], [25, 28], [26, 27], [26, 28], [27, 28], [29, 30], [1, 5], [2, 6], [3, 7], [4, 8], [1, 9], [2, 10], [3, 11], [4, 12], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20], [17, 21], [18, 22], [19, 23], [20, 24], [21, 25], [22, 26], [23, 27], [24, 28], [25, 29], [26, 30]]) == 7\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 1], [20, 2]]) == 6\n assert candidate(n = 35,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 4], [3, 5], [3, 6], [3, 7], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [8, 14], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [10, 11], [10, 12], [10, 13], [10, 14], [11, 12], [11, 13], [11, 14], [12, 13], [12, 14], [13, 14], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [15, 21], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [17, 18], [17, 19], [17, 20], [17, 21], [18, 19], [18, 20], [18, 21], [19, 20], [19, 21], [20, 21], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [22, 28], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [24, 25], [24, 26], [24, 27], [24, 28], [25, 26], [25, 27], [25, 28], [26, 27], [26, 28], [27, 28], [29, 30], [29, 31], [29, 32], [29, 33], [29, 34], [29, 35], [30, 31], [30, 32], [30, 33], [30, 34], [30, 35], [31, 32], [31, 33], [31, 34], [31, 35], [32, 33], [32, 34], [32, 35], [33, 34], [33, 35], [34, 35], [1, 15], [2, 16], [3, 17], [4, 18], [5, 19], [6, 20], [7, 21], [8, 22], [9, 23], [10, 24], [11, 25], [12, 26], [13, 27], [14, 28], [15, 29], [16, 30], [17, 31], [18, 32], [19, 33], [20, 34], [21, 35]]) == 15\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1], [2, 5], [3, 5], [4, 7], [5, 7], [6, 9], [7, 9], [8, 11], [9, 11], [10, 13], [11, 13], [12, 14], [13, 14]]) == 5\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15], [16, 17], [16, 18], [16, 19], [17, 18], [17, 19], [18, 19], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9]]) == 3\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 20], [20, 19], [1, 4], [2, 5], [3, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17], [12, 18], [13, 19], [14, 20], [1, 16], [2, 17], [3, 18], [4, 19], [5, 20]]) == 5\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1]]) == 3\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [1, 5], [2, 5], [3, 5]]) == 5\n assert candidate(n = 40,edges = [[1, 2], [1, 3], [2, 3], [4, 5], [4, 6], [5, 6], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 20], [20, 21], [21, 19], [22, 23], [23, 24], [24, 22], [25, 26], [26, 27], [27, 25], [28, 29], [29, 30], [30, 28], [31, 32], [32, 33], [33, 31], [34, 35], [35, 36], [36, 34], [37, 38], [38, 39], [39, 37], [40, 1]]) == 0\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [14, 15], [14, 16], [14, 17], [14, 18], [14, 19], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20]]) == 12\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12], [13, 14], [13, 15], [13, 16], [14, 15], [14, 16], [15, 16], [17, 18], [17, 19], [17, 20], [18, 19], [18, 20], [19, 20]]) == 3\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [1, 4], [2, 5], [3, 6], [1, 7], [2, 8], [3, 8]]) == 3\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 20], [20, 1], [20, 19]]) == 0\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [12, 13], [14, 15]]) == 3\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 1], [9, 2], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 1], [8, 2], [9, 3]]) == 12\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [7, 10], [8, 9], [8, 10], [9, 10]]) == 6\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [3, 5], [4, 5]]) == 4\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [7, 10], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [11, 14], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15]]) == 6\n assert candidate(n = 25,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 14], [14, 15], [15, 11], [16, 17], [17, 18], [18, 19], [19, 20], [20, 16], [21, 22], [22, 23], [23, 24], [24, 25], [25, 21], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [11, 16], [12, 17], [13, 18], [14, 19], [15, 20], [21, 2], [22, 3], [23, 4], [24, 5], [25, 1]]) == -1\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 5], [4, 6], [4, 7], [4, 8], [5, 6], [5, 7], [5, 8], [5, 9], [6, 7], [6, 8], [6, 9], [6, 10], [7, 8], [7, 9], [7, 10], [7, 11], [8, 9], [8, 10], [8, 11], [8, 12], [9, 10], [9, 11], [9, 12], [9, 13], [10, 11], [10, 12], [10, 13], [10, 14], [11, 12], [11, 13], [11, 14], [11, 15], [12, 13], [12, 14], [12, 15], [12, 16], [13, 14], [13, 15], [13, 16], [13, 17], [14, 15], [14, 16], [14, 17], [14, 18], [15, 16], [15, 17], [15, 18], [15, 19], [16, 17], [16, 18], [16, 19], [16, 20], [17, 18], [17, 19], [17, 20], [17, 21], [18, 19], [18, 20], [18, 21], [18, 22], [19, 20], [19, 21], [19, 22], [19, 23], [20, 21], [20, 22], [20, 23], [20, 24], [21, 22], [21, 23], [21, 24], [21, 25], [22, 23], [22, 24], [22, 25], [23, 24], [23, 25], [24, 25], [25, 1]]) == 10\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 1], [10, 2]]) == 4\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [6, 7], [8, 9], [8, 10], [9, 10], [11, 12], [11, 13], [12, 13], [1, 5], [3, 6], [4, 8], [7, 11]]) == 1\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [6, 7], [6, 8], [6, 9], [6, 10], [6, 11], [7, 8], [7, 9], [7, 10], [7, 11], [7, 12], [8, 9], [8, 10], [8, 11], [8, 12], [8, 13], [9, 10], [9, 11], [9, 12], [9, 13], [9, 14], [10, 11], [10, 12], [10, 13], [10, 14], [10, 15], [11, 12], [11, 13], [11, 14], [11, 15], [11, 16], [12, 13], [12, 14], [12, 15], [12, 16], [12, 17], [13, 14], [13, 15], [13, 16], [13, 17], [13, 18], [14, 15], [14, 16], [14, 17], [14, 18], [14, 19], [15, 16], [15, 17], [15, 18], [15, 19], [15, 20], [16, 17], [16, 18], [16, 19], [16, 20], [16, 21], [17, 18], [17, 19], [17, 20], [17, 21], [17, 22], [18, 19], [18, 20], [18, 21], [18, 22], [18, 23], [19, 20], [19, 21], [19, 22], [19, 23], [19, 24], [20, 21], [20, 22], [20, 23], [20, 24], [20, 25], [21, 22], [21, 23], [21, 24], [21, 25], [21, 26], [22, 23], [22, 24], [22, 25], [22, 26], [22, 27], [23, 24], [23, 25], [23, 26], [23, 27], [23, 28], [24, 25], [24, 26], [24, 27], [24, 28], [24, 29], [25, 26], [25, 27], [25, 28], [25, 29], [25, 30], [26, 27], [26, 28], [26, 29], [26, 30], [27, 28], [27, 29], [27, 30], [28, 29], [28, 30], [29, 30], [30, 1]]) == 13\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [1, 4], [2, 5], [3, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 13], [11, 14], [12, 15]]) == 6\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [2, 5], [3, 4], [3, 6], [4, 5], [5, 6], [6, 7], [7, 8], [8, 4]]) == 4\n assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 20], [20, 21], [21, 19], [22, 23], [23, 24], [24, 22], [25, 26], [26, 27], [27, 25], [28, 29], [29, 30], [30, 28]]) == 0\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 6], [3, 4], [3, 7], [4, 8], [5, 6], [6, 7], [7, 8]]) == 6\n assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 20], [20, 21], [21, 19], [22, 23], [23, 24], [24, 22], [25, 26], [26, 27], [27, 25], [28, 29], [29, 30], [30, 28], [1, 13], [2, 14], [3, 15], [4, 16], [5, 17], [6, 18], [7, 19], [8, 20], [9, 21], [10, 22], [11, 23], [12, 24], [1, 25], [2, 26], [3, 27], [4, 28], [5, 29], [6, 30]]) == 3\n assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14], [14, 15], [15, 13], [16, 17], [17, 18], [18, 16], [19, 20], [20, 1], [20, 19], [21, 22], [22, 23], [23, 21], [24, 25], [25, 26], [26, 24], [27, 28], [28, 29], [29, 27], [30, 21], [30, 25]]) == 0\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10], [9, 11], [9, 12], [10, 11], [10, 12], [11, 12], [1, 5], [2, 6], [3, 7], [4, 8], [1, 9], [2, 10], [3, 11], [4, 12]]) == 6\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [12, 13], [14, 15], [14, 16], [14, 17], [15, 16], [15, 17], [16, 17], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15], [11, 16], [12, 17], [1, 14], [2, 15], [3, 16], [4, 17], [5, 11], [6, 12], [7, 13], [8, 14], [9, 15], [10, 16], [11, 17]]) == 11\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 1]]) == 5\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 1], [2, 5], [3, 5], [4, 7], [5, 7], [6, 9], [7, 9], [8, 11], [9, 11]]) == 5\n assert candidate(n = 40,edges = [[1, 2], [2, 3], [1, 3], [4, 5], [5, 6], [4, 6], [7, 8], [8, 9], [7, 9], [10, 11], [11, 12], [10, 12], [13, 14], [14, 15], [13, 15], [16, 17], [17, 18], [16, 18], [19, 20], [20, 21], [19, 21], [22, 23], [23, 24], [22, 24], [25, 26], [26, 27], [25, 27], [28, 29], [29, 30], [28, 30], [31, 32], [32, 33], [31, 33], [34, 35], [35, 36], [34, 36], [37, 38], [38, 39], [37, 39], [40, 1], [2, 4], [3, 5], [6, 8], [7, 9], [10, 12], [11, 13], [14, 16], [15, 17], [18, 20], [19, 21], [22, 24], [23, 25], [26, 28], [27, 29], [30, 32], [31, 33], [34, 36], [35, 37], [38, 40], [39, 1]]) == 3\n"}, "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().minTrioDegree", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minTrioDegree(int n, vector>& edges) {", "container": "Solution", "callable": "minTrioDegree", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1763, "task_id": "longest-nice-substring", "difficulty": "Easy", "problem_description": "A string s is nice if, for every letter of the alphabet that s contains, it appears both in uppercase and lowercase. For example, \"abABB\" is nice because 'A' and 'a' appear, and 'B' and 'b' appear. However, \"abA\" is not because 'b' appears, but 'B' does not.\nGiven a string s, return the longest substring of s that is nice. If there are multiple, return the substring of the earliest occurrence. If there are none, return an empty string.\n \nExample 1:\n\nInput: s = \"YazaAay\"\nOutput: \"aAa\"\nExplanation: \"aAa\" is a nice string because 'A/a' is the only letter of the alphabet in s, and both 'A' and 'a' appear.\n\"aAa\" is the longest nice substring.\n\nExample 2:\n\nInput: s = \"Bb\"\nOutput: \"Bb\"\nExplanation: \"Bb\" is a nice string because both 'B' and 'b' appear. The whole string is a substring.\n\nExample 3:\n\nInput: s = \"c\"\nOutput: \"\"\nExplanation: There are no nice substrings.\n\n \nConstraints:\n\n1 <= s.length <= 100\ns consists of uppercase and lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"Bb\") == \"Bb\"\n assert candidate(s = \"aAbBcCdDeEfFgG\") == \"aAbBcCdDeEfFgG\"\n assert candidate(s = \"c\") == \"\"\n assert candidate(s = \"aBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"BbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\"\n assert candidate(s = \"abcdefgHIJKlmnopQRStuVwxYZ\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"\"\n assert candidate(s = \"\") == \"\"\n assert candidate(s = \"aAaBbCc\") == \"aAaBbCc\"\n assert candidate(s = \"QwertyuiopASDFGHJKLzxcvbnmMNBVCXZLKJHGFDSAPOIUYTREWq\") == \"zxcvbnmMNBVCXZ\"\n assert candidate(s = \"aaAAbbBBccCC\") == \"aaAAbbBBccCC\"\n assert candidate(s = \"aA\") == \"aA\"\n assert candidate(s = \"dDcCbBaA\") == \"dDcCbBaA\"\n assert candidate(s = \"AabbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"CcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\"\n assert candidate(s = \"aAb\") == \"aA\"\n assert candidate(s = \"aAbBcC\") == \"aAbBcC\"\n assert candidate(s = \"YazaAay\") == \"aAa\"\n assert candidate(s = \"dDfFgG\") == \"dDfFgG\"\n assert candidate(s = \"mnopQRstuvQR\") == \"\"\n assert candidate(s = \"aBcDef\") == \"\"\n assert candidate(s = \"abABB\") == \"abABB\"\n assert candidate(s = \"AbcDEdEfghIjklmNoPqRsTuVwXyZ\") == \"\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"\"\n assert candidate(s = \"abABcdCDefEF\") == \"abABcdCDefEF\"\n assert candidate(s = \"aabBcC\") == \"bBcC\"\n assert candidate(s = \"AaBbCcDd\") == \"AaBbCcDd\"\n assert candidate(s = \"xyzXYZ\") == \"xyzXYZ\"\n assert candidate(s = \"abcD\") == \"\"\n assert candidate(s = \"abcABCdefDEFghGHijIJklKLmnopMNOPqrstQRSTuvUVwxWXyzYZ\") == \"abcABCdefDEFghGHijIJklKLmnopMNOPqrstQRSTuvUVwxWXyzYZ\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZzZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaAxyzXYZ\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZzZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaAxyzXYZ\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefgHIJKLmnopQRstuvWxyz\") == \"\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbB\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbB\"\n assert candidate(s = \"aBcD\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzabcdEFGH\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzabcdEFGH\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmM\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmM\"\n assert candidate(s = \"xyzXYZaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"xyzXYZaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\"\n assert candidate(s = \"xyzXYZaBcDedCbAz\") == \"xyzXYZ\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaBbCcdDeE\") == \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaBbCcdDeE\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzabcdefghijklmnopqrstuvwxyzaA\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzabcdefghijklmnopqrstuvwxyzaA\"\n assert candidate(s = \"aabbCCddEEffGGhhIIjjKKllMMnnOOppQQrrSSttuUvVwWxXyYzZ\") == \"uUvVwWxXyYzZ\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYz\") == \"\"\n assert candidate(s = \"abcdEFGHijklMNOpQRstUVwxyzZ\") == \"zZ\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAxyzXYZ\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAxyzXYZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"abABcdCDefEFGghHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"abABcdCDefEFGghHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaA\"\n assert candidate(s = \"abcdEFGhijKLMnopQRStuVwXYz\") == \"\"\n assert candidate(s = \"abcdefGhijklMnopqrstuvwxyz\") == \"\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaBcDeFgHiJkLmNoPqRsTuVwXyZ\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzXYZ\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzXYZ\"\n assert candidate(s = \"abcdefABCDefghijklmnoMNOPQRSTuvwxyXYZ\") == \"mnoMNO\"\n assert candidate(s = \"abcdEFGHijklMNOPqrstUVWXyzABCDefghIJKLmnopQRstuVWXyz\") == \"\"\n assert candidate(s = \"aBcDabcdABCD\") == \"aBcDabcdABCD\"\n assert candidate(s = \"xYzZyXaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwW\") == \"xYzZyXaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwW\"\n assert candidate(s = \"aBcDEfGhIjKlMnOpQrStUvWxYz\") == \"\"\n assert candidate(s = \"xyzXYZabcABCdefDEFghijGHIJklmnopqrQRSTUVWstuvUVW\") == \"xyzXYZabcABCdefDEFghijGHIJ\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzmnopQRstuVWXyz\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzmnopQRstuVWXyz\"\n assert candidate(s = \"bBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaA\") == \"bBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaA\"\n assert candidate(s = \"abcdefABCDefgHIJKlMNOPqrSTUVwxYZaBcDefGhIjKlMnoPqrStUvWxYz\") == \"\"\n assert candidate(s = \"abABcdCDefEFghGHijIJklKLmnopMNOPqrstuvwxyzZXYwvuUVtsrSRQPONMLKJIHgfedcbaABab\") == \"abABcdCDefEFghGHijIJklKLmnopMNOP\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAxyzXYZabcABCdefDEFghGHIjklKLmnopqrQRstuvUVwxyzXYZ\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAxyzXYZabcABCdefDEFghGHIjklKLmnopqrQRstuvUVwxyzXYZ\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyz\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"QwErTyUiOpAsDfGhJkLzXcVbNm\") == \"\"\n assert candidate(s = \"abcdefghijABCDEFGHIJKLmnopqrstuvwxyz\") == \"abcdefghijABCDEFGHIJ\"\n assert candidate(s = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\") == \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZxyzXYZ\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZxyzXYZ\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZbB\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZbB\"\n assert candidate(s = \"aaabBBcccAAbbbCCC\") == \"aaabBBcccAAbbbCCC\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZzZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZzZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\"\n assert candidate(s = \"abcdefgHIJKLmnopQRstuvWxyzabcdefgHIJKLmnopQRstuvWxyz\") == \"\"\n assert candidate(s = \"aBcDabcdABCDzzZZyyYYxxXXwwWWvvVVuuUUttTTssSSrrQQppOOmmLLkkJJiiHHggFFddBBAA\") == \"aBcDabcdABCDzzZZyyYYxxXXwwWWvvVVuuUUttTTssSS\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbB\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaAbB\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n assert candidate(s = \"aaAaAaBbBbBbCcCcCc\") == \"aaAaAaBbBbBbCcCcCc\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZabcdEFGHijklMNOPqrstUVWXyz\") == \"\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaaBBccDDeeffGghhiiJjkkLLmmNnoopPqqRrssTtuUvvWwXxyYzz\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaaBBccDDeeffGghhiiJjkkLLmmNnoopPqqRrssTtuUvvWwXxyYzz\"\n assert candidate(s = \"bAcBdCd\") == \"\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZxyzXYZabcABCdefDEFghiGHIjklJKLmnoMNOpqrPQRstuSTUvVwWxyXYzZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZxyzXYZabcABCdefDEFghiGHIjklJKLmnoMNOpqrPQRstuSTUvVwWxyXYzZ\"\n assert candidate(s = \"zZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"zZyYxXwWvVuUtTsSrRpPqQoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\"\n assert candidate(s = \"abcABCxyzXYZdefDEF\") == \"abcABCxyzXYZdefDEF\"\n assert candidate(s = \"abAcBdCdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"EeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZabcDEF\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZabcDEF\"\n assert candidate(s = \"aAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzABCdef\") == \"aAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzABCdef\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZbB\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZbB\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyY\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyY\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAa\") == \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAa\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaBbCcdDeEfffGgHHiiJjKKllMMnnOOPPqqRRsstttUUvvWWxxYYzzZZ\") == \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaBbCcdDeE\"\n assert candidate(s = \"abcABCdefDEFghGHIjklKLmnopqrQRstuvUVwxyzXYZ\") == \"abcABCdefDEFghGH\"\n assert candidate(s = \"abABcdCDefEFghGHijIJklKLmnopMNOPqrstuvwxyzZXYwvuUVtsrSRQPONMLKJIHgfedcba\") == \"abABcdCDefEFghGHijIJklKLmnopMNOP\"\n assert candidate(s = \"abcdefABCDefgHIJKlMNOPqrSTUVwxYZ\") == \"\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzmnopqrQRST\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzmnopqrQRST\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZabcdEfghijklmnopqrstuVwxy\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZabcdEfghijklmnopqrstuVwxy\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZa\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZa\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZcC\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZcC\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZbBaAcCdD\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZbBaAcCdD\"\n assert candidate(s = \"zZyYxXwWvVuUtTsSrRpPoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"zZyYxXwWvVuUtTsSrRpPoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\"\n assert candidate(s = \"xYzZyXaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"xYzZyXaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbCc\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbCc\"\n assert candidate(s = \"abcABCdefDEFgGhHijIJklKLmMnopNOPqrQRstSTuUVwWXyYzZ\") == \"abcABCdefDEFgGhHijIJklKLmMnopNOPqrQRstSTuU\"\n assert candidate(s = \"AbcDeFgHiJklMnopqrStuvWxyzZ\") == \"zZ\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\") == \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaA\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzXxYyZz\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzXxYyZz\"\n assert candidate(s = \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaBbCcdDeEfffGg\") == \"aAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaAaBbCcdDeE\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"abcdefABCDEFxyzXYZuvwUVWqQrRsStTuUvVwWxXyYzZ\") == \"abcdefABCDEFxyzXYZuvwUVWqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"abcdEFGHijklMNOPqrSTUVwxyz\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\"\n assert candidate(s = \"abcXYZabcXYZabcXYZ\") == \"\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"abcdEFGHijklMNOPqrstUVWXyzabcdEFGHijklMNOPqrstUVWXyz\") == \"\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAA\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzmnopQRstuVWXyzABCdefGHIjklMNOpQRstuVWXyz\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzmnopQRstuVWXyzABCdefGHIjklMNOpQRstuVWXyz\"\n assert candidate(s = \"aaBBccDDeeFFggHHiiJJKkllMMnnOoPPqqRRssTTuuVVwwXXyyZZ\") == \"Kk\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAbCdEfGhIjKlMnOpQrStUvWxYz\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAbCdEfGhIjKlMnOpQrStUvWxYz\"\n assert candidate(s = \"xyzXYZabcABCdefDEFghiGHIjklJKLmnoMNOpqrPQRstuSTUvVwWxyXYzZ\") == \"xyzXYZabcABCdefDEFghiGHIjklJKLmnoMNOpqrPQRstuSTUvVwWxyXYzZ\"\n assert candidate(s = \"AbcDefGhiJklMnoPqrStuVwxYzABCdefGHIjklMNOpQRstuVWXyz\") == \"\"\n assert candidate(s = \"abcdEFGHijklMNOPqrstUVWXyz\") == \"\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaA\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefgHIJKLmnopQRstuvWxyz\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbC\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzAaBbC\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzABCD\") == \"\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"aBcDeFgHiJkLmNoPqRsTuVwXyZaAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaA\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaA\"\n assert candidate(s = \"aBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZaBcDeFgHiJkLmNoPqRsTuVwXyZ\") == \"\"\n assert candidate(s = \"abcdefgHIJKLmnopQRstUVwXYZ\") == \"\"\n assert candidate(s = \"abcdEFGHijkLmnopQRstUVwxYZ\") == \"\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZab\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZab\"\n assert candidate(s = \"abcdefgHIJKLmnopQRstuvWxyz\") == \"\"\n assert candidate(s = \"abcdefgHIJKLmnopQRstuvWxyzab\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzabcdefghijklmnopqrstuvwxyza\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzabcdefghijklmnopqrstuvwxyza\"\n assert candidate(s = \"aaBBccDDeeFFggHHiiJJKkllMMnnOoPPqqRRssTTuuVVwwXXyyZZaaBBccDDeeFFggHHiiJJKkllMMnnOoPPqqRRssTTuuVVwwXXyyZZ\") == \"Kk\"\n assert candidate(s = \"abcdefGHIJkLmnopQRstuvWXYZ\") == \"\"\n assert candidate(s = \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzABCDEF\") == \"AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzABCDEF\"\n assert candidate(s = \"xXyYzZwWvVuUtTsSrRqQpPoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"xXyYzZwWvVuUtTsSrRqQpPoOnNmMlLkKjJiIhHgGfFeEdDcCbBaA\"\n assert candidate(s = \"AbCdEfGhIjKlMnOpQrStUvWxYzAbCdEfGhIjKlMnOpQrStUvWxYz\") == \"\"\n assert candidate(s = \"aBcDcBaEeFfEgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\") == \"EeFfEgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzABCDEFGHIJKLMNOPQRSTUVWXYZ\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n assert candidate(s = \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaabbCCddeeffGG\") == \"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZaabbCCddeeffGG\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaA\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaAaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzAaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzxyzyxwvutVUtUrRqQpPnNmMlLkKjJiIhHgGfFeEdDcCbBaA\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().longestNiceSubstring", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string longestNiceSubstring(string s) {", "container": "Solution", "callable": "longestNiceSubstring", "parameters": [{"name": "s", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1764, "task_id": "form-array-by-concatenating-subarrays-of-another-array", "difficulty": "Medium", "problem_description": "You are given a 2D integer array groups of length n. You are also given an integer array nums.\nYou are asked if you can choose n disjoint subarrays from the array nums such that the ith subarray is equal to groups[i] (0-indexed), and if i > 0, the (i-1)th subarray appears before the ith subarray in nums (i.e. the subarrays must be in the same order as groups).\nReturn true if you can do this task, and false otherwise.\nNote that the subarrays are disjoint if and only if there is no index k such that nums[k] belongs to more than one subarray. A subarray is a contiguous sequence of elements within an array.\n \nExample 1:\n\nInput: groups = [[1,-1,-1],[3,-2,0]], nums = [1,-1,0,1,-1,-1,3,-2,0]\nOutput: true\nExplanation: You can choose the 0th subarray as [1,-1,0,1,-1,-1,3,-2,0] and the 1st one as [1,-1,0,1,-1,-1,3,-2,0].\nThese subarrays are disjoint as they share no common nums[k] element.\n\nExample 2:\n\nInput: groups = [[10,-2],[1,2,3,4]], nums = [1,2,3,4,10,-2]\nOutput: false\nExplanation: Note that choosing the subarrays [1,2,3,4,10,-2] and [1,2,3,4,10,-2] is incorrect because they are not in the same order as in groups.\n[10,-2] must come before [1,2,3,4].\n\nExample 3:\n\nInput: groups = [[1,2,3],[3,4]], nums = [7,7,1,2,3,4,7,7]\nOutput: false\nExplanation: Note that choosing the subarrays [7,7,1,2,3,4,7,7] and [7,7,1,2,3,4,7,7] is invalid because they are not disjoint.\nThey share a common elements nums[4] (0-indexed).\n\n \nConstraints:\n\ngroups.length == n\n1 <= n <= 103\n1 <= groups[i].length, sum(groups[i].length) <= 103\n1 <= nums.length <= 103\n-107 <= groups[i][j], nums[k] <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(groups = [[1, 2, 3]],nums = [1, 2, 3, 1, 2, 3]) == True\n assert candidate(groups = [[1, 2], [3, 4]],nums = [1, 2, 4, 3]) == False\n assert candidate(groups = [[5, 5, 5], [5]],nums = [5, 5, 5, 5]) == True\n assert candidate(groups = [[1, 1, 1], [1, 1]],nums = [1, 1, 1, 1]) == False\n assert candidate(groups = [[1, 2], [3, 4]],nums = [1, 2, 3, 4]) == True\n assert candidate(groups = [[1, 2], [2, 1]],nums = [1, 2, 2, 1]) == True\n assert candidate(groups = [[-1, -2, -3], [-3, -2, -1]],nums = [-1, -2, -3, -3, -2, -1]) == True\n assert candidate(groups = [[1, -1, -1], [3, -2, 0]],nums = [1, -1, 0, 1, -1, -1, 3, -2, 0]) == True\n assert candidate(groups = [[1, 2, 3], [1, 2, 3]],nums = [1, 2, 3, 1, 2, 3]) == True\n assert candidate(groups = [[1]],nums = [1]) == True\n assert candidate(groups = [[1, 2], [3, 4]],nums = [1, 2, 5, 3, 4]) == True\n assert candidate(groups = [[1], [2], [3]],nums = [3, 2, 1]) == False\n assert candidate(groups = [[1, 1, 1, 1], [1, 1]],nums = [1, 1, 1, 1]) == False\n assert candidate(groups = [[1], [2], [3]],nums = [1, 2, 3]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4]],nums = [7, 7, 1, 2, 3, 4, 7, 7]) == False\n assert candidate(groups = [[5, 5]],nums = [5, 5, 5, 5]) == True\n assert candidate(groups = [[10, -2], [1, 2, 3, 4]],nums = [1, 2, 3, 4, 10, -2]) == False\n assert candidate(groups = [[1]],nums = [2]) == False\n assert candidate(groups = [[1, 2], [2, 3]],nums = [1, 2, 2, 3]) == True\n assert candidate(groups = [[1, 2], [3, 4]],nums = [1, 2, 3, 4, 5, 6]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4]],nums = [1, 2, 3, 4]) == False\n assert candidate(groups = [[1, 2], [3, 4], [5, 6]],nums = [1, 2, 3, 4, 5, 6]) == True\n assert candidate(groups = [[100, 200], [200, 300], [300, 400]],nums = [100, 200, 200, 300, 300, 400]) == True\n assert candidate(groups = [[100, 200], [300, 400], [500, 600]],nums = [100, 200, 300, 400, 500, 600, 100, 200]) == True\n assert candidate(groups = [[0, 0, 0, 0], [0]],nums = [0, 0, 0, 0, 0, 0, 0, 0]) == True\n assert candidate(groups = [[10, 20, 30], [30, 40, 50], [50, 60, 70]],nums = [10, 20, 30, 40, 50, 60, 70]) == False\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 2, 3]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 2, 3, 1, 2, 3, 4, 5, 6, 4, 5, 6, 7, 8, 9, 7, 8, 9]) == True\n assert candidate(groups = [[9, 8, 7], [8, 7, 6], [7, 6, 5]],nums = [9, 8, 7, 8, 7, 6, 7, 6, 5]) == True\n assert candidate(groups = [[1, 1, 1], [2, 2, 2], [3, 3, 3]],nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],nums = [1, 2, 3, 4, 5, 6, 7]) == False\n assert candidate(groups = [[1, 1, 1], [1, 1, 1]],nums = [1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(groups = [[-1, -2, -3], [-3, -4, -5], [-5, -6, -7]],nums = [-1, -2, -3, -3, -4, -5, -5, -6, -7]) == True\n assert candidate(groups = [[1, 1, 1], [1, 1], [1]],nums = [1, 1, 1, 1, 1]) == False\n assert candidate(groups = [[0, 1], [1, 2], [2, 3], [3, 4]],nums = [0, 1, 1, 2, 2, 3, 3, 4]) == True\n assert candidate(groups = [[-1, -2, -3], [-4, -5], [-6, -7, -8, -9]],nums = [-1, -2, -3, 0, -4, -5, 1, -6, -7, -8, -9]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5]],nums = [1, 2, 3, 99, 3, 4, 5]) == True\n assert candidate(groups = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5]],nums = [1, 2, 2, 3, 3, 4, 4, 5, 5]) == True\n assert candidate(groups = [[1, 2, 3], [1, 2, 3], [1, 2, 3]],nums = [1, 2, 3, 4, 5, 1, 2, 3, 6, 7, 8, 1, 2, 3]) == True\n assert candidate(groups = [[-1, -2, -3], [-3, -2, -1], [0, 0, 0]],nums = [-1, -2, -3, 0, 0, 0, -3, -2, -1]) == False\n assert candidate(groups = [[1, 2, 3], [1, 2, 3, 4], [4, 5]],nums = [1, 2, 3, 1, 2, 3, 4, 4, 5]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5], [2, 3, 4], [3, 4, 5, 6]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5]],nums = [1, 2, 2, 3, 3, 4, 4, 5]) == True\n assert candidate(groups = [[-1, -2, -3], [-4, -5, -6]],nums = [-1, -2, -3, -4, -5, -6, -1, -2, -3, -4, -5, -6]) == True\n assert candidate(groups = [[1, 2, 3], [3, 2, 1], [2, 1, 3]],nums = [1, 2, 3, 3, 2, 1, 2, 1, 3]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9]],nums = [1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9]) == True\n assert candidate(groups = [[10, 20, 30], [40, 50], [60, 70, 80]],nums = [5, 10, 20, 30, 15, 40, 50, 25, 60, 70, 80]) == True\n assert candidate(groups = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(groups = [[1, 1, 1], [2, 2, 2], [3, 3, 3]],nums = [1, 1, 1, 2, 2, 2, 3, 3, 3]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5]],nums = [1, 2, 2, 3, 3, 4, 99, 4, 5]) == True\n assert candidate(groups = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]],nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5], [5, 6, 7]],nums = [1, 2, 3, 3, 4, 5, 5, 6, 7]) == True\n assert candidate(groups = [[9, 8, 7], [6, 5, 4], [3, 2, 1]],nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(groups = [[1, 2, 3], [2, 3, 4], [3, 4, 5]],nums = [1, 2, 3, 2, 3, 4, 3, 4, 5]) == True\n assert candidate(groups = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == True\n assert candidate(groups = [[1], [2], [3], [4], [5]],nums = [1, 0, 2, 0, 3, 0, 4, 0, 5]) == True\n assert candidate(groups = [[1, 2, 3], [1, 2], [1]],nums = [1, 2, 3, 1, 2, 1]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1]],nums = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4]],nums = [1, 2, 3, 4, 5, 3, 4]) == False\n assert candidate(groups = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [1, 1, 1]],nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1]) == True\n assert candidate(groups = [[1, 1], [2, 2], [1, 1], [2, 2]],nums = [1, 1, 2, 2, 1, 1, 2, 2]) == True\n assert candidate(groups = [[1, 2, 3], [1, 2, 3], [1, 2, 3]],nums = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == True\n assert candidate(groups = [[-10, -20, -30], [-40, -50, -60], [-70, -80, -90]],nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == True\n assert candidate(groups = [[1, 2, 3, 4], [5, 6, 7], [8, 9]],nums = [1, 2, 3, 4, 10, 11, 5, 6, 7, 12, 8, 9]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5]],nums = [1, 2, 3, 4, 5, 2, 3, 4, 5]) == False\n assert candidate(groups = [[1, 2, 3, 4, 5], [5, 6, 7], [8, 9]],nums = [1, 2, 3, 4, 5, 5, 6, 7, 8, 9]) == True\n assert candidate(groups = [[-1, -2, -3], [-3, -2, -1], [1, 2, 3]],nums = [-1, -2, -3, -3, -2, -1, 1, 2, 3]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5], [5, 6, 7, 8, 9], [9, 10, 11, 12, 13]],nums = [1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 9, 10, 11, 12, 13]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6]) == True\n assert candidate(groups = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5]],nums = [1, 2, 3, 3, 4, 5]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4]],nums = [1, 2, 3, 4, 5]) == False\n assert candidate(groups = [[-1, -2, -3], [-4, -5], [-6, -7, -8]],nums = [-1, -2, -3, 0, -4, -5, 0, -6, -7, -8]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9]],nums = [1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9]) == True\n assert candidate(groups = [[10, 20, 30], [20, 30, 40], [30, 40, 50]],nums = [10, 20, 30, 20, 30, 40, 30, 40, 50]) == True\n assert candidate(groups = [[1, 2], [3, 4], [5, 6], [7, 8]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == True\n assert candidate(groups = [[1, 1, 1], [1, 1], [1]],nums = [1, 1, 1, 1, 1, 1]) == True\n assert candidate(groups = [[100, 200], [200, 300], [300, 400], [400, 500]],nums = [100, 200, 200, 300, 300, 400, 400, 500]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [1, 2, 3], [4, 5, 6]],nums = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]) == True\n assert candidate(groups = [[-1, -2, -3], [-2, -3, -4], [-3, -4, -5]],nums = [-1, -2, -3, -2, -3, -4, -3, -4, -5]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5]],nums = [1, 2, 3, 4, 5]) == False\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 2, 3, 10, 4, 5, 6, 11, 7, 8, 9]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5], [5, 6, 7]],nums = [1, 2, 3, 4, 5, 6, 7]) == False\n assert candidate(groups = [[100, 200], [300, 400, 500], [600]],nums = [50, 100, 200, 150, 300, 400, 500, 200, 600]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4]],nums = [1, 2, 2, 3, 3, 4, 4]) == True\n assert candidate(groups = [[1, 2], [3, 4], [1, 2]],nums = [1, 2, 3, 4, 1, 2]) == True\n assert candidate(groups = [[1, 1, 1, 1], [1, 1], [1]],nums = [1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(groups = [[1, 2, 3], [1, 2, 3], [1, 2, 3]],nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(groups = [[1, 2, 3], [1, 2], [2, 3]],nums = [1, 2, 3, 1, 2, 2, 3]) == True\n assert candidate(groups = [[9, 8, 7], [6, 5, 4], [3, 2, 1]],nums = [9, 8, 7, 0, 6, 5, 4, 0, 3, 2, 1]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5], [5, 6, 7]],nums = [1, 2, 3, 3, 4, 5, 5, 6, 7]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 2, 3, 9, 8, 7, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(groups = [[1, 1, 1], [1, 1], [1]],nums = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == True\n assert candidate(groups = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == True\n assert candidate(groups = [[10000000], [9999999], [8888888], [7777777]],nums = [10000000, 9999999, 8888888, 7777777]) == True\n assert candidate(groups = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == True\n assert candidate(groups = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]],nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == True\n assert candidate(groups = [[5, 5, 5, 5], [5, 5, 5], [5, 5], [5]],nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == True\n assert candidate(groups = [[1], [2], [3], [4], [5]],nums = [1, 2, 3, 4, 5]) == True\n assert candidate(groups = [[-10, -20, -30], [-40, -50], [-60, -70, -80]],nums = [-10, -20, -30, -40, -50, -60, -70, -80]) == True\n assert candidate(groups = [[1], [2], [3], [4], [5]],nums = [1, 2, 3, 4, 5]) == True\n assert candidate(groups = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],nums = [1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(groups = [[1, 2], [3, 4, 5, 6], [7, 8]],nums = [1, 2, 3, 4, 5, 6, 7, 8]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(groups = [[10, 20, 30, 40], [50, 60, 70, 80]],nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == True\n assert candidate(groups = [[1, 2], [2, 1], [1, 2], [2, 1]],nums = [1, 2, 2, 1, 1, 2, 2, 1]) == True\n assert candidate(groups = [[-10, -20, -30], [-30, -20, -10]],nums = [-10, -20, -30, -30, -20, -10]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15, 16, 17, 18]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == True\n assert candidate(groups = [[-1, 0, 1], [-2, 0, 2]],nums = [-1, 0, 1, -2, 0, 2, -1, 0, 1]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5], [5, 6, 7]],nums = [99, 1, 2, 3, 99, 3, 4, 5, 99, 5, 6, 7]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 2, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5]],nums = [1, 2, 3, 3, 4, 5]) == True\n assert candidate(groups = [[1, 2, 3], [1, 2, 3], [1, 2, 3]],nums = [1, 2, 3, 1, 2, 3, 1, 2, 3]) == True\n assert candidate(groups = [[1, 2, 3], [3, 2, 1], [1, 2, 3]],nums = [1, 2, 3, 3, 2, 1, 1, 2, 3]) == True\n assert candidate(groups = [[7, 8, 9], [1, 2, 3], [4, 5, 6]],nums = [7, 8, 9, 1, 2, 3, 4, 5, 6]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6]],nums = [1, 2, 3, 0, 0, 4, 5, 6]) == True\n assert candidate(groups = [[-1, -2, -3], [0, 1, 2], [-3, -2, -1]],nums = [-1, -2, -3, 0, 1, 2, -3, -2, -1]) == True\n assert candidate(groups = [[1, 2, 3], [2, 3, 4]],nums = [1, 2, 3, 4]) == False\n assert candidate(groups = [[9, 8, 7, 6, 5], [4, 3, 2, 1], [0, -1, -2, -3, -4]],nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4]) == True\n assert candidate(groups = [[100, 200, 300], [400, 500], [600]],nums = [100, 200, 300, 400, 500, 600]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [1, 2, 3, 0, 4, 5, 6, 0, 7, 8, 9]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6]],nums = [1, 2, 3, 99, 4, 5, 6]) == True\n assert candidate(groups = [[1, 1, 1, 1], [1, 1, 1], [1, 1], [1]],nums = [1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(groups = [[1, 2, 3], [3, 2, 1]],nums = [1, 2, 3, 3, 2, 1, 1, 2, 3, 3, 2, 1]) == True\n assert candidate(groups = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]],nums = [0, 1, 2, 3, 4, 0, 5, 6, 7, 8, 0, 9, 10, 11, 12]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]],nums = [1, 2, 3, 4, 5, 11, 12, 6, 7, 8, 9, 10]) == True\n assert candidate(groups = [[1, -1], [1, -1]],nums = [1, -1, 1, -1, 1, -1]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [2, 3, 4, 5, 6, 7, 8, 9, 10], [3, 4, 5, 6, 7, 8, 9, 10, 11]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5, 6, 7, 8, 9, 10, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == True\n assert candidate(groups = [[1, 2], [2, 3], [3, 4], [4, 5]],nums = [1, 2, 3, 4, 5]) == False\n assert candidate(groups = [[1, 2, 3], [4, 5, 6]],nums = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]) == True\n assert candidate(groups = [[1], [2], [3], [4], [5], [6]],nums = [1, 2, 3, 4, 5, 6]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [0, 1, 2, 3, 0, 4, 5, 6, 0, 7, 8, 9]) == True\n assert candidate(groups = [[100, 200, 300], [400, 500], [600, 700, 800, 900]],nums = [100, 200, 300, 400, 500, 600, 700, 800, 900]) == True\n assert candidate(groups = [[1, 1], [1, 1], [1, 1]],nums = [1, 1, 1, 1, 1, 1]) == True\n assert candidate(groups = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],nums = [7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6]) == True\n assert candidate(groups = [[1, 2, 3, 4, 5], [6, 7, 8, 9]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(groups = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(groups = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == True\n"}, "metadata": {"canonical_parameter_names": ["groups", "nums"], "leetcode_dataset_entry_point": "Solution().canChoose", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool canChoose(vector>& groups, vector& nums) {", "container": "Solution", "callable": "canChoose", "parameters": [{"name": "groups", "type": "vector>&"}, {"name": "nums", "type": "vector&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1765, "task_id": "map-of-highest-peak", "difficulty": "Medium", "problem_description": "You are given an integer matrix isWater of size m x n that represents a map of land and water cells.\n\nIf isWater[i][j] == 0, cell (i, j) is a land cell.\nIf isWater[i][j] == 1, cell (i, j) is a water cell.\n\nYou must assign each cell a height in a way that follows these rules:\n\nThe height of each cell must be non-negative.\nIf the cell is a water cell, its height must be 0.\nAny two adjacent cells must have an absolute height difference of at most 1. A cell is adjacent to another cell if the former is directly north, east, south, or west of the latter (i.e., their sides are touching).\n\nFind an assignment of heights such that the maximum height in the matrix is maximized.\nReturn an integer matrix height of size m x n where height[i][j] is cell (i, j)'s height. If there are multiple solutions, return any of them.\n \nExample 1:\n\n\nInput: isWater = [[0,1],[0,0]]\nOutput: [[1,0],[2,1]]\nExplanation: The image shows the assigned heights of each cell.\nThe blue cell is the water cell, and the green cells are the land cells.\n\nExample 2:\n\n\nInput: isWater = [[0,0,1],[1,0,0],[0,0,0]]\nOutput: [[1,1,0],[0,1,1],[1,2,2]]\nExplanation: A height of 2 is the maximum possible height of any assignment.\nAny height assignment that has a maximum height of 2 while still meeting the rules will also be accepted.\n\n \nConstraints:\n\nm == isWater.length\nn == isWater[i].length\n1 <= m, n <= 1000\nisWater[i][j] is 0 or 1.\nThere is at least one water cell.\n\n \nNote: This question is the same as 542: https://leetcode.com/problems/01-matrix/\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(isWater = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == [[2, 1, 2], [1, 0, 1], [2, 1, 2]]\n assert candidate(isWater = [[0, 1], [0, 0]]) == [[1, 0], [2, 1]]\n assert candidate(isWater = [[1, 1], [1, 1]]) == [[0, 0], [0, 0]]\n assert candidate(isWater = [[0, 0, 1], [1, 0, 0], [0, 0, 0]]) == [[1, 1, 0], [0, 1, 1], [1, 2, 2]]\n assert candidate(isWater = [[0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [1, 0, 0, 0]]) == [[3, 2, 1, 0], [2, 1, 0, 1], [1, 0, 1, 2], [0, 1, 2, 3]]\n assert candidate(isWater = [[1, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == [[0, 1, 2, 3], [1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == [[4, 3, 2, 3, 2, 3, 4], [3, 2, 1, 2, 1, 2, 3], [2, 1, 0, 1, 0, 1, 2], [3, 2, 1, 2, 1, 2, 3], [4, 3, 2, 3, 2, 3, 4]]\n assert candidate(isWater = [[0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 1]]) == [[4, 3, 2, 1, 0, 1, 2, 3, 4], [3, 4, 3, 2, 1, 2, 3, 4, 3], [2, 3, 4, 3, 2, 3, 4, 3, 2], [1, 2, 3, 4, 3, 4, 3, 2, 1], [0, 1, 2, 3, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == [[3, 2, 1, 2, 3], [2, 1, 0, 1, 2], [1, 0, 1, 0, 1], [2, 1, 0, 1, 2], [3, 2, 1, 2, 3]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 4], [1, 2, 1, 2, 3, 3], [2, 1, 0, 1, 2, 2], [3, 2, 1, 2, 2, 1], [4, 3, 2, 2, 1, 0]]\n assert candidate(isWater = [[1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1]]) == [[0, 1, 2, 1, 0, 1, 2, 1, 0], [1, 2, 3, 2, 1, 2, 3, 2, 1], [2, 3, 4, 3, 2, 3, 4, 3, 2], [3, 4, 5, 4, 3, 4, 5, 4, 3], [4, 5, 6, 5, 4, 5, 6, 5, 4], [3, 4, 5, 4, 3, 4, 5, 4, 3], [2, 3, 4, 3, 2, 3, 4, 3, 2], [1, 2, 3, 2, 1, 2, 3, 2, 1], [0, 1, 2, 1, 0, 1, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[5, 4, 3, 2, 1, 0, 1, 2, 3, 4], [6, 5, 4, 3, 2, 1, 2, 3, 4, 5], [7, 6, 5, 4, 3, 2, 3, 4, 5, 6], [8, 7, 6, 5, 4, 3, 4, 5, 6, 7], [9, 8, 7, 6, 5, 4, 5, 6, 7, 8], [10, 9, 8, 7, 6, 5, 6, 7, 8, 9], [11, 10, 9, 8, 7, 6, 7, 8, 9, 10], [12, 11, 10, 9, 8, 7, 8, 9, 10, 11]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[7, 6, 5, 4, 5, 6, 7, 8, 9, 10], [6, 5, 4, 3, 4, 5, 6, 7, 8, 9], [5, 4, 3, 2, 3, 4, 5, 6, 7, 8], [4, 3, 2, 1, 2, 3, 4, 5, 6, 7], [3, 2, 1, 0, 1, 2, 3, 4, 5, 6], [4, 3, 2, 1, 2, 3, 4, 5, 6, 7], [5, 4, 3, 2, 3, 4, 5, 6, 7, 8], [6, 5, 4, 3, 4, 5, 6, 7, 8, 9], [7, 6, 5, 4, 5, 6, 7, 8, 9, 10], [8, 7, 6, 5, 6, 7, 8, 9, 10, 11]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9, 8], [2, 3, 4, 5, 6, 7, 8, 9, 8, 7], [3, 4, 5, 6, 7, 8, 9, 8, 7, 6], [4, 5, 6, 7, 8, 9, 8, 7, 6, 5], [5, 6, 7, 8, 9, 8, 7, 6, 5, 4], [6, 7, 8, 9, 8, 7, 6, 5, 4, 3], [7, 8, 9, 8, 7, 6, 5, 4, 3, 2], [8, 9, 8, 7, 6, 5, 4, 3, 2, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[8, 7, 6, 5, 4, 5, 6, 7, 8, 9], [7, 6, 5, 4, 3, 4, 5, 6, 7, 8], [6, 5, 4, 3, 2, 3, 4, 5, 6, 7], [5, 4, 3, 2, 1, 2, 3, 4, 5, 6], [4, 3, 2, 1, 0, 1, 2, 3, 4, 5], [5, 4, 3, 2, 1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 4, 5, 6, 7, 8]]\n assert candidate(isWater = [[0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[3, 2, 1, 0, 1, 2, 3, 4, 5, 6], [2, 1, 0, 1, 2, 3, 4, 5, 6, 7], [1, 0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]\n assert candidate(isWater = [[0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0], [0, 1, 0, 1, 0], [0, 0, 0, 0, 0]]) == [[2, 1, 2, 1, 2], [1, 0, 1, 0, 1], [2, 1, 2, 1, 2], [1, 0, 1, 0, 1], [2, 1, 2, 1, 2]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == [[10, 9, 8, 7, 6, 7, 8, 9], [9, 8, 7, 6, 5, 6, 7, 8], [8, 7, 6, 5, 4, 5, 6, 7], [7, 6, 5, 4, 3, 4, 5, 6], [6, 5, 4, 3, 2, 3, 4, 5], [5, 4, 3, 2, 1, 2, 3, 4], [4, 3, 2, 1, 0, 1, 2, 3], [5, 4, 3, 2, 1, 2, 3, 4]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[2, 1, 2, 1, 2, 3], [1, 0, 1, 0, 1, 2], [2, 1, 2, 1, 2, 3], [1, 0, 1, 0, 1, 2], [2, 1, 2, 1, 2, 3]]\n assert candidate(isWater = [[1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4], [1, 2, 3, 4, 3], [2, 3, 4, 3, 2], [3, 4, 3, 2, 1], [4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[4, 3, 2, 3, 2, 3], [3, 2, 1, 2, 1, 2], [2, 1, 0, 1, 0, 1], [3, 2, 1, 2, 1, 2], [4, 3, 2, 3, 2, 3], [5, 4, 3, 4, 3, 4]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0]]) == [[4, 3, 2, 3, 4, 3, 2, 3, 4, 5], [3, 2, 1, 2, 3, 2, 1, 2, 3, 4], [2, 1, 0, 1, 2, 1, 0, 1, 2, 3], [3, 2, 1, 2, 3, 2, 1, 2, 3, 4], [3, 2, 1, 2, 3, 2, 1, 2, 3, 4], [2, 1, 0, 1, 2, 1, 0, 1, 2, 3], [3, 2, 1, 2, 3, 2, 1, 2, 3, 4], [4, 3, 2, 3, 2, 3, 2, 3, 4, 5], [5, 4, 3, 2, 1, 2, 3, 4, 5, 6], [4, 3, 2, 1, 0, 1, 2, 3, 4, 5]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 4, 5, 4, 3, 4, 5], [5, 4, 3, 2, 3, 4, 3, 2, 3, 4], [4, 3, 2, 1, 2, 3, 2, 1, 2, 3], [3, 2, 1, 0, 1, 2, 1, 0, 1, 2], [4, 3, 2, 1, 2, 3, 2, 1, 2, 3], [4, 3, 2, 1, 2, 3, 2, 1, 2, 3], [3, 2, 1, 0, 1, 2, 1, 0, 1, 2], [4, 3, 2, 1, 2, 3, 2, 1, 2, 3]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 4], [1, 2, 3, 4, 4, 3], [2, 3, 4, 4, 3, 2], [3, 4, 4, 3, 2, 1], [4, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 3, 4, 5, 6], [5, 4, 3, 2, 2, 3, 4, 5], [4, 3, 2, 1, 1, 2, 3, 4], [3, 2, 1, 0, 0, 1, 2, 3], [3, 2, 1, 0, 0, 1, 2, 3], [4, 3, 2, 1, 1, 2, 3, 4], [5, 4, 3, 2, 2, 3, 4, 5]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [8, 7, 6, 5, 4, 3, 2, 1, 0, 1], [7, 6, 5, 4, 3, 2, 1, 0, 1, 2], [6, 5, 4, 3, 2, 1, 0, 1, 2, 3], [5, 4, 3, 2, 1, 0, 1, 2, 3, 4], [4, 3, 2, 1, 0, 1, 2, 3, 4, 5], [3, 2, 1, 0, 1, 2, 3, 4, 5, 6], [2, 1, 0, 1, 2, 3, 4, 5, 6, 7], [1, 0, 1, 2, 3, 4, 5, 6, 7, 8], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 2, 3, 4], [1, 2, 1, 2, 1, 2, 3], [2, 1, 0, 1, 0, 1, 2], [3, 2, 1, 0, 1, 2, 3], [2, 1, 0, 1, 0, 1, 2], [3, 2, 1, 2, 1, 2, 1], [4, 3, 2, 3, 2, 1, 0]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 3, 4, 5, 6, 7], [2, 3, 4, 3, 2, 3, 4, 5, 6], [3, 4, 3, 2, 1, 2, 3, 4, 5], [4, 3, 2, 1, 0, 1, 2, 3, 4], [5, 4, 3, 2, 1, 2, 3, 4, 3], [6, 5, 4, 3, 2, 3, 4, 3, 2], [7, 6, 5, 4, 3, 4, 3, 2, 1], [8, 7, 6, 5, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 4], [2, 3, 4, 5, 4, 3], [3, 4, 5, 4, 3, 2], [4, 5, 4, 3, 2, 1], [5, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 5, 4], [1, 2, 3, 4, 5, 4, 3], [2, 3, 4, 5, 4, 3, 2], [3, 4, 5, 4, 3, 2, 1], [4, 5, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0]]) == [[2, 1, 0, 1, 2, 2], [1, 2, 1, 2, 2, 1], [0, 1, 2, 2, 1, 0], [1, 2, 1, 2, 2, 1], [2, 1, 0, 1, 2, 2]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 4, 5], [5, 4, 3, 2, 3, 4], [4, 3, 2, 1, 2, 3], [3, 2, 1, 0, 1, 2], [4, 3, 2, 1, 2, 3], [5, 4, 3, 2, 3, 4]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0]]) == [[5, 4, 3, 2, 1, 0], [4, 3, 2, 1, 0, 1], [3, 2, 1, 0, 1, 2], [2, 1, 0, 1, 2, 3], [1, 0, 1, 2, 3, 4], [0, 1, 2, 3, 4, 5]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [[5, 4, 3, 2, 1, 0, 1, 2, 3, 4], [5, 4, 3, 2, 2, 1, 2, 3, 4, 5], [4, 3, 2, 1, 2, 2, 3, 4, 5, 4], [3, 2, 1, 0, 1, 2, 3, 4, 4, 3], [4, 3, 2, 1, 2, 3, 4, 4, 3, 2], [5, 4, 3, 2, 3, 4, 4, 3, 2, 1], [6, 5, 4, 3, 4, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[4, 3, 2, 3, 4, 5], [3, 2, 1, 2, 3, 4], [2, 1, 0, 1, 2, 3], [3, 2, 1, 2, 3, 4], [4, 3, 2, 3, 4, 5]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 4, 5, 6, 7, 8], [5, 4, 3, 2, 3, 4, 5, 6, 7], [4, 3, 2, 1, 2, 3, 4, 5, 6], [3, 2, 1, 0, 1, 2, 3, 4, 5], [4, 3, 2, 1, 2, 3, 4, 5, 6], [5, 4, 3, 2, 3, 4, 5, 6, 7], [6, 5, 4, 3, 4, 5, 6, 7, 8], [7, 6, 5, 4, 5, 6, 7, 8, 9], [8, 7, 6, 5, 6, 7, 8, 9, 10]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2], [18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3], [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5], [21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6], [22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7], [23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8], [24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9], [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10], [26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11], [27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12], [28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13], [29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14], [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15]]\n assert candidate(isWater = [[0, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 0]]) == [[2, 1, 2, 3, 4], [1, 0, 1, 2, 3], [2, 1, 2, 1, 2], [3, 2, 1, 0, 1], [4, 3, 2, 1, 2]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 4, 3, 2, 1, 0], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 7, 6, 5, 4, 3], [3, 4, 5, 6, 7, 7, 6, 5, 4, 3], [2, 3, 4, 5, 6, 6, 5, 4, 3, 2], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [0, 1, 2, 3, 4, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == [[2, 1, 2, 3, 3, 2, 1, 2], [1, 0, 1, 2, 2, 1, 0, 1], [2, 1, 2, 3, 3, 2, 1, 2], [3, 2, 3, 4, 4, 3, 2, 3], [2, 1, 2, 3, 3, 2, 1, 2], [1, 0, 1, 2, 2, 1, 0, 1], [2, 1, 2, 3, 3, 2, 1, 2], [3, 2, 3, 4, 4, 3, 2, 3]]\n assert candidate(isWater = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == [[5, 4, 3, 4, 5], [4, 3, 2, 3, 4], [3, 2, 1, 2, 3], [2, 1, 0, 1, 2], [3, 2, 1, 2, 3]]\n assert candidate(isWater = [[0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == [[3, 2, 1, 2, 3], [2, 1, 0, 1, 2], [3, 2, 1, 2, 3], [4, 3, 2, 3, 4], [5, 4, 3, 4, 5]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 3, 2, 1, 0], [1, 2, 3, 4, 4, 3, 2, 1], [2, 3, 4, 5, 5, 4, 3, 2], [3, 4, 5, 6, 6, 5, 4, 3], [3, 4, 5, 6, 6, 5, 4, 3], [2, 3, 4, 5, 5, 4, 3, 2], [1, 2, 3, 4, 4, 3, 2, 1], [0, 1, 2, 3, 3, 2, 1, 0]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7, 6], [2, 3, 4, 5, 6, 7, 6, 5], [3, 4, 5, 6, 7, 6, 5, 4], [4, 5, 6, 7, 6, 5, 4, 3], [5, 6, 7, 6, 5, 4, 3, 2], [6, 7, 6, 5, 4, 3, 2, 1], [7, 6, 5, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == [[2, 1, 1, 1, 1, 2], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [2, 1, 1, 1, 1, 2]]\n assert candidate(isWater = [[1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1]]) == [[0, 1, 2, 1, 0], [1, 2, 3, 2, 1], [1, 2, 3, 2, 1], [0, 1, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6], [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7], [6, 5, 4, 5, 4, 3, 2, 3, 4, 5, 6, 7, 8], [5, 4, 3, 4, 5, 4, 3, 4, 5, 6, 7, 8, 9], [4, 3, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 10], [3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [4, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [5, 4, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [6, 5, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 2, 1, 0], [7, 6, 5, 4, 3, 2, 1], [8, 7, 6, 5, 4, 3, 2], [9, 8, 7, 6, 5, 4, 3], [10, 9, 8, 7, 6, 5, 4], [11, 10, 9, 8, 7, 6, 5]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[4, 3, 2, 2, 3, 4], [3, 2, 1, 1, 2, 3], [2, 1, 0, 0, 1, 2], [2, 1, 0, 0, 1, 2], [3, 2, 1, 1, 2, 3], [4, 3, 2, 2, 3, 4]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 4, 5, 6], [5, 4, 3, 2, 3, 4, 5], [4, 3, 2, 1, 2, 3, 4], [3, 2, 1, 0, 1, 2, 3], [4, 3, 2, 1, 2, 3, 4], [5, 4, 3, 2, 3, 4, 5]]\n assert candidate(isWater = [[1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1]]) == [[0, 1, 0, 1, 0, 1, 0], [1, 2, 1, 2, 1, 2, 1], [0, 1, 0, 1, 0, 1, 0], [1, 2, 1, 2, 1, 2, 1], [0, 1, 0, 1, 0, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[4, 3, 2, 1, 0, 1], [3, 2, 3, 2, 1, 2], [2, 1, 2, 3, 2, 3], [1, 0, 1, 2, 3, 4], [2, 1, 2, 3, 4, 5]]\n assert candidate(isWater = [[0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1], [1, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0]]) == [[4, 3, 2, 1, 0, 1], [3, 2, 1, 0, 1, 2], [2, 1, 0, 1, 0, 1], [1, 0, 1, 2, 1, 0], [0, 1, 0, 1, 2, 1], [1, 2, 1, 0, 1, 2]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 3, 3, 4, 5, 6], [5, 4, 3, 2, 2, 2, 3, 4, 5], [4, 3, 2, 1, 1, 1, 2, 3, 4], [3, 2, 1, 0, 0, 0, 1, 2, 3], [3, 2, 1, 0, 0, 0, 1, 2, 3], [3, 2, 1, 0, 0, 0, 1, 2, 3], [4, 3, 2, 1, 1, 1, 2, 3, 4], [5, 4, 3, 2, 2, 2, 3, 4, 5], [6, 5, 4, 3, 3, 3, 4, 5, 6]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 4, 3, 2, 1, 0], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 7, 6, 5, 4, 3], [4, 5, 6, 7, 8, 8, 7, 6, 5, 4], [4, 5, 6, 7, 8, 8, 7, 6, 5, 4], [3, 4, 5, 6, 7, 7, 6, 5, 4, 3], [2, 3, 4, 5, 6, 6, 5, 4, 3, 2], [1, 2, 3, 4, 5, 5, 4, 3, 2, 1], [0, 1, 2, 3, 4, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[3, 2, 3, 2, 3, 4], [2, 1, 2, 1, 2, 3], [1, 0, 1, 0, 1, 2], [2, 1, 2, 1, 2, 3], [3, 2, 3, 2, 3, 4]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 0], [1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3], [4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4], [5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 5], [6, 7, 8, 9, 10, 11, 12, 13, 12, 11, 10, 9, 8, 7, 6], [7, 8, 9, 10, 11, 12, 13, 14, 13, 12, 11, 10, 9, 8, 7], [6, 7, 8, 9, 10, 11, 12, 13, 12, 11, 10, 9, 8, 7, 6], [5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 5], [4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4], [3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3], [2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2], [1, 2, 3, 4, 5, 6, 7, 8, 7, 6, 5, 4, 3, 2, 1], [0, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == [[1, 0, 1, 2, 3, 3, 4], [2, 1, 2, 3, 3, 2, 3], [3, 2, 3, 3, 2, 1, 2], [4, 3, 3, 2, 1, 0, 1], [5, 4, 4, 3, 2, 1, 2], [6, 5, 5, 4, 3, 2, 3]]\n assert candidate(isWater = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]\n assert candidate(isWater = [[0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == [[3, 2, 1, 2, 3], [2, 1, 0, 1, 2], [3, 2, 1, 2, 3], [4, 3, 2, 3, 4]]\n assert candidate(isWater = [[0, 1, 0, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 1]]) == [[1, 0, 1, 2, 3], [1, 1, 2, 3, 3], [0, 1, 2, 3, 2], [1, 2, 3, 2, 1], [2, 3, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 2, 1, 0, 1, 2, 3], [7, 6, 5, 4, 3, 2, 1, 2, 3, 4], [8, 7, 6, 5, 4, 3, 2, 3, 4, 5], [9, 8, 7, 6, 5, 4, 3, 4, 5, 6], [10, 9, 8, 7, 6, 5, 4, 5, 6, 7], [11, 10, 9, 8, 7, 6, 5, 6, 7, 8], [12, 11, 10, 9, 8, 7, 6, 7, 8, 9], [13, 12, 11, 10, 9, 8, 7, 8, 9, 10]]\n assert candidate(isWater = [[0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0]]) == [[4, 3, 2, 1, 0, 1, 2, 3, 4], [3, 4, 3, 2, 1, 2, 3, 4, 3], [2, 3, 4, 3, 2, 3, 4, 3, 2], [1, 2, 3, 4, 3, 4, 3, 2, 1], [0, 1, 2, 3, 4, 3, 2, 1, 0], [1, 2, 3, 4, 3, 4, 3, 2, 1], [2, 3, 4, 3, 2, 3, 4, 3, 2], [3, 4, 3, 2, 1, 2, 3, 4, 3], [4, 3, 2, 1, 0, 1, 2, 3, 4]]\n assert candidate(isWater = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == [[0, 1, 2, 3, 4, 5, 6, 7, 8, 7], [1, 2, 3, 4, 5, 6, 7, 8, 7, 6], [2, 3, 4, 5, 6, 7, 8, 7, 6, 5], [3, 4, 5, 6, 7, 8, 7, 6, 5, 4], [4, 5, 6, 7, 8, 7, 6, 5, 4, 3], [5, 6, 7, 8, 7, 6, 5, 4, 3, 2], [6, 7, 8, 7, 6, 5, 4, 3, 2, 1], [7, 8, 7, 6, 5, 4, 3, 2, 1, 0]]\n assert candidate(isWater = [[1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1]]) == [[0, 1, 2, 1, 0], [1, 2, 3, 2, 1], [2, 3, 4, 3, 2], [1, 2, 3, 2, 1], [0, 1, 2, 1, 0]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[10, 9, 8, 7, 6, 5, 4, 5, 6, 7, 6, 5, 4, 5, 6, 7, 8, 9, 10, 11], [9, 8, 7, 6, 5, 4, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 7, 8, 9, 10], [8, 7, 6, 5, 4, 3, 2, 3, 4, 5, 4, 3, 2, 3, 4, 5, 6, 7, 8, 9], [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8], [6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 3, 4, 5, 4, 3, 2, 3, 4, 5, 6, 7, 8, 9], [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8], [6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 3, 4, 5, 4, 3, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 4, 5, 6, 5, 4, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 5, 6, 7, 6, 5, 4, 5, 6, 7, 8, 9, 10, 11], [11, 10, 9, 8, 7, 6, 5, 6, 7, 8, 7, 6, 5, 6, 7, 8, 9, 10, 11, 12], [12, 11, 10, 9, 8, 7, 6, 7, 8, 9, 8, 7, 6, 7, 8, 9, 10, 11, 12, 13], [13, 12, 11, 10, 9, 8, 7, 8, 9, 10, 9, 8, 7, 8, 9, 10, 11, 12, 13, 14], [14, 13, 12, 11, 10, 9, 8, 9, 10, 11, 10, 9, 8, 9, 10, 11, 12, 13, 14, 15], [15, 14, 13, 12, 11, 10, 9, 10, 11, 12, 11, 10, 9, 10, 11, 12, 13, 14, 15, 16], [16, 15, 14, 13, 12, 11, 10, 11, 12, 13, 12, 11, 10, 11, 12, 13, 14, 15, 16, 17], [17, 16, 15, 14, 13, 12, 11, 12, 13, 14, 13, 12, 11, 12, 13, 14, 15, 16, 17, 18]]\n assert candidate(isWater = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == [[6, 5, 4, 3, 4, 5, 6, 7], [5, 4, 3, 2, 3, 4, 5, 6], [4, 3, 2, 1, 2, 3, 4, 5], [3, 2, 1, 0, 1, 2, 3, 4], [4, 3, 2, 1, 2, 3, 4, 5], [5, 4, 3, 2, 3, 4, 5, 6], [6, 5, 4, 3, 4, 5, 6, 7], [7, 6, 5, 4, 5, 6, 7, 8]]\n"}, "metadata": {"canonical_parameter_names": ["isWater"], "leetcode_dataset_entry_point": "Solution().highestPeak", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector> highestPeak(vector>& isWater) {", "container": "Solution", "callable": "highestPeak", "parameters": [{"name": "isWater", "type": "vector>&"}], "return_type": "vector>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1766, "task_id": "tree-of-coprimes", "difficulty": "Hard", "problem_description": "There is a tree (i.e., a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges. Each node has a value associated with it, and the root of the tree is node 0.\nTo represent this tree, you are given an integer array nums and a 2D array edges. Each nums[i] represents the ith node's value, and each edges[j] = [uj, vj] represents an edge between nodes uj and vj in the tree.\nTwo values x and y are coprime if gcd(x, y) == 1 where gcd(x, y) is the greatest common divisor of x and y.\nAn ancestor of a node i is any other node on the shortest path from node i to the root. A node is not considered an ancestor of itself.\nReturn an array ans of size n, where ans[i] is the closest ancestor to node i such that nums[i] and nums[ans[i]] are coprime, or -1 if there is no such ancestor.\n \nExample 1:\n\n\nInput: nums = [2,3,3,2], edges = [[0,1],[1,2],[1,3]]\nOutput: [-1,0,0,1]\nExplanation: In the above figure, each node's value is in parentheses.\n- Node 0 has no coprime ancestors.\n- Node 1 has only one ancestor, node 0. Their values are coprime (gcd(2,3) == 1).\n- Node 2 has two ancestors, nodes 1 and 0. Node 1's value is not coprime (gcd(3,3) == 3), but node 0's\n value is (gcd(2,3) == 1), so node 0 is the closest valid ancestor.\n- Node 3 has two ancestors, nodes 1 and 0. It is coprime with node 1 (gcd(3,2) == 1), so node 1 is its\n closest valid ancestor.\n\nExample 2:\n\n\nInput: nums = [5,6,10,2,3,6,15], edges = [[0,1],[0,2],[1,3],[1,4],[2,5],[2,6]]\nOutput: [-1,0,-1,0,0,0,-1]\n\n \nConstraints:\n\nnums.length == n\n1 <= nums[i] <= 50\n1 <= n <= 105\nedges.length == n - 1\nedges[j].length == 2\n0 <= uj, vj < n\nuj != vj\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 3, 3, 2],edges = [[0, 1], [1, 2], [1, 3]]) == [-1, 0, 0, 1]\n assert candidate(nums = [5, 6, 10, 2, 3, 6, 15],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]]) == [-1, 0, -1, 0, 0, 0, -1]\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4]\n assert candidate(nums = [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4]\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 5, 1, 11],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]\n assert candidate(nums = [15, 10, 5, 2, 3, 6, 15, 30, 45, 60],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [5, 8], [6, 9]]) == [-1, -1, -1, 0, 1, 2, -1, -1, -1, -1]\n assert candidate(nums = [49, 42, 35, 28, 21, 14, 7, 1, 49, 42],edges = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [6, 8], [6, 9]]) == [-1, -1, -1, -1, -1, -1, -1, 3, -1, -1]\n assert candidate(nums = [7, 11, 13, 5, 3, 2, 8, 9, 10, 12],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 4, 2]\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30], [15, 31], [15, 32], [16, 33], [16, 34], [17, 35], [17, 36], [18, 37], [18, 38], [19, 39], [19, 40]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14]]) == [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, -1, -1, -1]\n assert candidate(nums = [12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [3, 9, 27, 81, 3, 9, 27, 3, 9, 27],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [4, 9]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [15, 10, 6, 9, 12, 18, 21, 30, 24, 33],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [41, 37, 43, 47, 29, 31, 37, 41, 43, 47, 29, 31, 37, 41, 43, 47, 29, 31, 37, 41],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 1, 2, 5, 6, 6, 7, 7, 8, 8, 9]\n assert candidate(nums = [47, 43, 41, 37, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]\n assert candidate(nums = [31, 37, 41, 43, 47, 53, 59, 61, 67, 71],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [5, 8], [6, 9]]) == [-1, 0, 0, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(nums = [47, 37, 41, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6]\n assert candidate(nums = [2, 3, 5, 2, 3, 5, 2, 3, 5, 2, 3, 5, 2, 3, 5, 2, 3, 5, 2, 3, 5],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20]]) == [-1, 0, 0, 1, 0, 0, 2, 3, 3, 4, 0, 0, 5, 6, 6, 7, 3, 3, 8, 9, 9]\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30], [15, 31], [15, 32], [16, 33], [16, 34], [17, 35], [17, 36], [18, 37], [18, 38], [19, 39], [19, 40], [20, 41], [20, 42], [21, 43], [21, 44], [22, 45], [22, 46], [23, 47], [23, 48], [24, 49], [24, 50]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [7, 5, 6, 3, 5, 3, 7, 11, 13, 17],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [5, 8], [6, 9]]) == [-1, 0, 0, 1, 0, 0, 2, 3, 5, 6]\n assert candidate(nums = [30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]]) == [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4]\n assert candidate(nums = [29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19]]) == [-1, 0, 0, 1, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11]]) == [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4]\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [5, 8], [6, 9]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [41, 43, 47, 37, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2],edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14]]) == [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6]\n"}, "metadata": {"canonical_parameter_names": ["nums", "edges"], "leetcode_dataset_entry_point": "Solution().getCoprimes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector getCoprimes(vector& nums, vector>& edges) {", "container": "Solution", "callable": "getCoprimes", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "edges", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1768, "task_id": "merge-strings-alternately", "difficulty": "Easy", "problem_description": "You are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1. If a string is longer than the other, append the additional letters onto the end of the merged string.\\r\n\\r\nReturn the merged string.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: word1 = \"abc\", word2 = \"pqr\"\\r\nOutput: \"apbqcr\"\\r\nExplanation: The merged string will be merged as so:\\r\nword1: a b c\\r\nword2: p q r\\r\nmerged: a p b q c r\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: word1 = \"ab\", word2 = \"pqrs\"\\r\nOutput: \"apbqrs\"\\r\nExplanation: Notice that as word2 is longer, \"rs\" is appended to the end.\\r\nword1: a b \\r\nword2: p q r s\\r\nmerged: a p b q r s\\r\n\\r\n\\r\nExample 3:\\r\n\\r\n\\r\nInput: word1 = \"abcd\", word2 = \"pq\"\\r\nOutput: \"apbqcd\"\\r\nExplanation: Notice that as word1 is longer, \"cd\" is appended to the end.\\r\nword1: a b c d\\r\nword2: p q \\r\nmerged: a p b q c d\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= word1.length, word2.length <= 100\\r\n\tword1 and word2 consist of lowercase English letters.\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word1 = \"a\",word2 = \"b\") == \"ab\"\n assert candidate(word1 = \"abcd\",word2 = \"pq\") == \"apbqcd\"\n assert candidate(word1 = \"ab\",word2 = \"pqrs\") == \"apbqrs\"\n assert candidate(word1 = \"\",word2 = \"uvw\") == \"uvw\"\n assert candidate(word1 = \"x\",word2 = \"y\") == \"xy\"\n assert candidate(word1 = \"hello\",word2 = \"world\") == \"hweolrllod\"\n assert candidate(word1 = \"a\",word2 = \"bcd\") == \"abcd\"\n assert candidate(word1 = \"abcde\",word2 = \"fgh\") == \"afbgchde\"\n assert candidate(word1 = \"abc\",word2 = \"pqr\") == \"apbqcr\"\n assert candidate(word1 = \"abcd\",word2 = \"e\") == \"aebcd\"\n assert candidate(word1 = \"xyz\",word2 = \"\") == \"xyz\"\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(word1 = \"a\",word2 = \"bcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(word1 = \"thisisateststring\",word2 = \"anotheronehere\") == \"tahniostihseartoensethsetrreing\"\n assert candidate(word1 = \"aabbccdd\",word2 = \"eeffgg\") == \"aeaebfbfcgcgdd\"\n assert candidate(word1 = \"complex\",word2 = \"strings\") == \"csotmrpilnegxs\"\n assert candidate(word1 = \"xyz\",word2 = \"abcde\") == \"xaybzcde\"\n assert candidate(word1 = \"abcdefgh\",word2 = \"ijkl\") == \"aibjckdlefgh\"\n assert candidate(word1 = \"abcdefghijk\",word2 = \"lmnopqrstuvwxyz\") == \"albmcndoepfqgrhsitjukvwxyz\"\n assert candidate(word1 = \"abcdefghij\",word2 = \"klmnopqrstuvwxyz\") == \"akblcmdneofpgqhrisjtuvwxyz\"\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxy\",word2 = \"z\") == \"azbcdefghijklmnopqrstuvwxy\"\n assert candidate(word1 = \"quick\",word2 = \"brownfox\") == \"qburiocwknfox\"\n assert candidate(word1 = \"onetwothreefour\",word2 = \"five\") == \"ofnievtewothreefour\"\n assert candidate(word1 = \"overlap\",word2 = \"lapping\") == \"olvaeprplianpg\"\n assert candidate(word1 = \"\",word2 = \"\") == \"\"\n assert candidate(word1 = \"python\",word2 = \"java\") == \"pjyatvhaon\"\n assert candidate(word1 = \"abcdefgh\",word2 = \"ijklmnopqrstuv\") == \"aibjckdlemfngohpqrstuv\"\n assert candidate(word1 = \"different\",word2 = \"length\") == \"dliefnfgetrhent\"\n assert candidate(word1 = \"abcdefghij\",word2 = \"klmnopqrst\") == \"akblcmdneofpgqhrisjt\"\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"zyxwzyxwzyxw\") == \"azbycxdwazbycxdwazbycxdw\"\n assert candidate(word1 = \"longerfirstword\",word2 = \"short\") == \"lsohnogretrfirstword\"\n assert candidate(word1 = \"abcdefg\",word2 = \"hijklmnop\") == \"ahbicjdkelfmgnop\"\n assert candidate(word1 = \"abcdef\",word2 = \"ghijklmnopqrstuvwxyz\") == \"agbhcidjekflmnopqrstuvwxyz\"\n assert candidate(word1 = \"xyz\",word2 = \"abcdefg\") == \"xaybzcdefg\"\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"efghefghefghefgh\") == \"aebfcgdhaebfcgdhaebfcgdhefgh\"\n assert candidate(word1 = \"short\",word2 = \"longersecondword\") == \"slhoonrgtersecondword\"\n assert candidate(word1 = \"\",word2 = \"notempty\") == \"notempty\"\n assert candidate(word1 = \"notempty\",word2 = \"\") == \"notempty\"\n assert candidate(word1 = \"\",word2 = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"gggghhhhiiii\") == \"agagbgbgchchdhdheieififi\"\n assert candidate(word1 = \"\",word2 = \"abcde\") == \"abcde\"\n assert candidate(word1 = \"a1b2c3d4\",word2 = \"e5f6g7\") == \"ae15bf26cg37d4\"\n assert candidate(word1 = \"oddlength\",word2 = \"evenlengths\") == \"oedvdelnelnegntghths\"\n assert candidate(word1 = \"same\",word2 = \"size\") == \"ssaimzee\"\n assert candidate(word1 = \"abcdefg\",word2 = \"hijklmnopqrstuvwxyz\") == \"ahbicjdkelfmgnopqrstuvwxyz\"\n assert candidate(word1 = \"aabbccddeeffgghhiijj\",word2 = \"kkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"akakblblcmcmdndneoeofpfpgqgqhrhrisisjtjtuuvvwwxxyyzz\"\n assert candidate(word1 = \"hello\",word2 = \"worldwide\") == \"hweolrllodwide\"\n assert candidate(word1 = \"xyzxyzxyz\",word2 = \"abcabcabc\") == \"xaybzcxaybzcxaybzc\"\n assert candidate(word1 = \"abcdxyz\",word2 = \"efghwvu\") == \"aebfcgdhxwyvzu\"\n assert candidate(word1 = \"short\",word2 = \"averylongstring\") == \"sahvoerrtylongstring\"\n assert candidate(word1 = \"hello\",word2 = \"worldthisisaverylongstring\") == \"hweolrllodthisisaverylongstring\"\n assert candidate(word1 = \"abcdefg\",word2 = \"hijkl\") == \"ahbicjdkelfg\"\n assert candidate(word1 = \"abcdef\",word2 = \"ghijklmnop\") == \"agbhcidjekflmnop\"\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"xyzxyzxyzxyz\") == \"axbyczdxaybzcxdyazbxcydz\"\n assert candidate(word1 = \"averyveryverylongword\",word2 = \"short\") == \"asvheorrytveryverylongword\"\n assert candidate(word1 = \"longerword\",word2 = \"short\") == \"lsohnogretrword\"\n assert candidate(word1 = \"hello\",word2 = \"world!\") == \"hweolrllod!\"\n assert candidate(word1 = \"nonempty\",word2 = \"\") == \"nonempty\"\n assert candidate(word1 = \"longstringwithmorecharacters\",word2 = \"shortstr\") == \"lsohnogrsttsrtirngwithmorecharacters\"\n assert candidate(word1 = \"abcdef\",word2 = \"zyxwvu\") == \"azbycxdwevfu\"\n assert candidate(word1 = \"onlyone\",word2 = \"\") == \"onlyone\"\n assert candidate(word1 = \"xyz\",word2 = \"uvw\") == \"xuyvzw\"\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"zzzzyyyxxww\") == \"azazbzbzcycydydxexewfwf\"\n assert candidate(word1 = \"abcdefgh\",word2 = \"ijklmnop\") == \"aibjckdlemfngohp\"\n assert candidate(word1 = \"onetwothree\",word2 = \"four\") == \"ofnoeutrwothree\"\n assert candidate(word1 = \"aabbcc\",word2 = \"ddeeff\") == \"adadbebecfcf\"\n assert candidate(word1 = \"aabbccddeeffgghhiijj\",word2 = \"zzzzzzzzzz\") == \"azazbzbzczczdzdzezezffgghhiijj\"\n assert candidate(word1 = \"abacaxi\",word2 = \"manga\") == \"ambaancgaaxi\"\n assert candidate(word1 = \"onetwothreefour\",word2 = \"fivesix\") == \"ofnievtewsoitxhreefour\"\n assert candidate(word1 = \"one\",word2 = \"twothreefour\") == \"otnweothreefour\"\n assert candidate(word1 = \"alphanumeric123\",word2 = \"characters!@#\") == \"aclhpahraancutmeerrsi!c@1#23\"\n assert candidate(word1 = \"\",word2 = \"nonempty\") == \"nonempty\"\n assert candidate(word1 = \"xyz\",word2 = \"wvutsrqponmlkjihgfedcba\") == \"xwyvzutsrqponmlkjihgfedcba\"\n assert candidate(word1 = \"abcde\",word2 = \"\") == \"abcde\"\n assert candidate(word1 = \"short\",word2 = \"averyverylongwordindeed\") == \"sahvoerrtyverylongwordindeed\"\n assert candidate(word1 = \"xy\",word2 = \"abcdefghijk\") == \"xaybcdefghijk\"\n assert candidate(word1 = \"onetwothree\",word2 = \"fourfivesix\") == \"ofnoeutrwfoitvherseiex\"\n assert candidate(word1 = \"python\",word2 = \"programming\") == \"ppyrtohgornamming\"\n assert candidate(word1 = \"verylongwordthatgoesonandone\",word2 = \"short\") == \"vsehroyrltongwordthatgoesonandone\"\n assert candidate(word1 = \"xyz\",word2 = \"abcdef\") == \"xaybzcdef\"\n assert candidate(word1 = \"merge\",word2 = \"these\") == \"mtehregsee\"\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"z\") == \"azbcdefghijklmnopqrstuvwxyz\"\n assert candidate(word1 = \"xyzlmnop\",word2 = \"qrstuvwx\") == \"xqyrzsltmunvowpx\"\n assert candidate(word1 = \"abcdefgh\",word2 = \"ijklmno\") == \"aibjckdlemfngoh\"\n assert candidate(word1 = \"short\",word2 = \"averyveryverylongword\") == \"sahvoerrtyveryverylongword\"\n assert candidate(word1 = \"averyverylongwordindeed\",word2 = \"short\") == \"asvheorrytverylongwordindeed\"\n assert candidate(word1 = \"equal\",word2 = \"equal\") == \"eeqquuaall\"\n assert candidate(word1 = \"ab\",word2 = \"cd\") == \"acbd\"\n assert candidate(word1 = \"short\",word2 = \"averylongstringthatweneedtocheck\") == \"sahvoerrtylongstringthatweneedtocheck\"\n assert candidate(word1 = \"same\",word2 = \"same\") == \"ssaammee\"\n assert candidate(word1 = \"abcd\",word2 = \"\") == \"abcd\"\n assert candidate(word1 = \"thisisaverylongstring\",word2 = \"hello\") == \"thheilsliosaverylongstring\"\n"}, "metadata": {"canonical_parameter_names": ["word1", "word2"], "leetcode_dataset_entry_point": "Solution().mergeAlternately", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string mergeAlternately(string word1, string word2) {", "container": "Solution", "callable": "mergeAlternately", "parameters": [{"name": "word1", "type": "string"}, {"name": "word2", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1769, "task_id": "minimum-number-of-operations-to-move-all-balls-to-each-box", "difficulty": "Medium", "problem_description": "You have n boxes. You are given a binary string boxes of length n, where boxes[i] is '0' if the ith box is empty, and '1' if it contains one ball.\nIn one operation, you can move one ball from a box to an adjacent box. Box i is adjacent to box j if abs(i - j) == 1. Note that after doing so, there may be more than one ball in some boxes.\nReturn an array answer of size n, where answer[i] is the minimum number of operations needed to move all the balls to the ith box.\nEach answer[i] is calculated considering the initial state of the boxes.\n \nExample 1:\n\nInput: boxes = \"110\"\nOutput: [1,1,3]\nExplanation: The answer for each box is as follows:\n1) First box: you will have to move one ball from the second box to the first box in one operation.\n2) Second box: you will have to move one ball from the first box to the second box in one operation.\n3) Third box: you will have to move one ball from the first box to the third box in two operations, and move one ball from the second box to the third box in one operation.\n\nExample 2:\n\nInput: boxes = \"001011\"\nOutput: [11,8,5,4,3,4]\n \nConstraints:\n\nn == boxes.length\n1 <= n <= 2000\nboxes[i] is either '0' or '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(boxes = \"0101010101\") == [25, 20, 17, 14, 13, 12, 13, 14, 17, 20]\n assert candidate(boxes = \"001011\") == [11, 8, 5, 4, 3, 4]\n assert candidate(boxes = \"000111000\") == [12, 9, 6, 3, 2, 3, 6, 9, 12]\n assert candidate(boxes = \"111000\") == [3, 2, 3, 6, 9, 12]\n assert candidate(boxes = \"01010101\") == [16, 12, 10, 8, 8, 8, 10, 12]\n assert candidate(boxes = \"1000000001\") == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(boxes = \"1010101010\") == [20, 17, 14, 13, 12, 13, 14, 17, 20, 25]\n assert candidate(boxes = \"1001001001001\") == [30, 27, 24, 21, 20, 19, 18, 19, 20, 21, 24, 27, 30]\n assert candidate(boxes = \"101010\") == [6, 5, 4, 5, 6, 9]\n assert candidate(boxes = \"1001001\") == [9, 8, 7, 6, 7, 8, 9]\n assert candidate(boxes = \"010101010101\") == [36, 30, 26, 22, 20, 18, 18, 18, 20, 22, 26, 30]\n assert candidate(boxes = \"11111\") == [10, 7, 6, 7, 10]\n assert candidate(boxes = \"1111\") == [6, 4, 4, 6]\n assert candidate(boxes = \"111100001111\") == [44, 38, 34, 32, 32, 32, 32, 32, 32, 34, 38, 44]\n assert candidate(boxes = \"111000111\") == [24, 20, 18, 18, 18, 18, 18, 20, 24]\n assert candidate(boxes = \"0000\") == [0, 0, 0, 0]\n assert candidate(boxes = \"1111111111\") == [45, 37, 31, 27, 25, 25, 27, 31, 37, 45]\n assert candidate(boxes = \"110\") == [1, 1, 3]\n assert candidate(boxes = \"00000\") == [0, 0, 0, 0, 0]\n assert candidate(boxes = \"1000001\") == [6, 6, 6, 6, 6, 6, 6]\n assert candidate(boxes = \"000111\") == [12, 9, 6, 3, 2, 3]\n assert candidate(boxes = \"0000011111000001111100000\") == [120, 110, 100, 90, 80, 70, 62, 56, 52, 50, 50, 50, 50, 50, 50, 50, 52, 56, 62, 70, 80, 90, 100, 110, 120]\n assert candidate(boxes = \"000000111111000000111111\") == [174, 162, 150, 138, 126, 114, 102, 92, 84, 78, 74, 72, 72, 72, 72, 72, 72, 72, 72, 74, 78, 84, 92, 102]\n assert candidate(boxes = \"0101010101010101010101010101\") == [196, 182, 170, 158, 148, 138, 130, 122, 116, 110, 106, 102, 100, 98, 98, 98, 100, 102, 106, 110, 116, 122, 130, 138, 148, 158, 170, 182]\n assert candidate(boxes = \"0101010101010101010101010101010101010101010101010101\") == [676, 650, 626, 602, 580, 558, 538, 518, 500, 482, 466, 450, 436, 422, 410, 398, 388, 378, 370, 362, 356, 350, 346, 342, 340, 338, 338, 338, 340, 342, 346, 350, 356, 362, 370, 378, 388, 398, 410, 422, 436, 450, 466, 482, 500, 518, 538, 558, 580, 602, 626, 650]\n assert candidate(boxes = \"01010101010101010101010101010101010101010101010101\") == [625, 600, 577, 554, 533, 512, 493, 474, 457, 440, 425, 410, 397, 384, 373, 362, 353, 344, 337, 330, 325, 320, 317, 314, 313, 312, 313, 314, 317, 320, 325, 330, 337, 344, 353, 362, 373, 384, 397, 410, 425, 440, 457, 474, 493, 512, 533, 554, 577, 600]\n assert candidate(boxes = \"1001001001001001001001001001001001001001001001001001\") == [459, 443, 427, 411, 397, 383, 369, 357, 345, 333, 323, 313, 303, 295, 287, 279, 273, 267, 261, 257, 253, 249, 247, 245, 243, 243, 243, 243, 245, 247, 249, 253, 257, 261, 267, 273, 279, 287, 295, 303, 313, 323, 333, 345, 357, 369, 383, 397, 411, 427, 443, 459]\n assert candidate(boxes = \"1000100010001\") == [24, 22, 20, 18, 16, 16, 16, 16, 16, 18, 20, 22, 24]\n assert candidate(boxes = \"111000111000111000111\") == [120, 110, 102, 96, 90, 84, 78, 74, 72, 72, 72, 72, 72, 74, 78, 84, 90, 96, 102, 110, 120]\n assert candidate(boxes = \"1101100110011001\") == [61, 54, 49, 44, 41, 40, 39, 38, 39, 42, 45, 48, 53, 60, 67, 74]\n assert candidate(boxes = \"111101010101010101010101010101010101010101010101\") == [578, 554, 532, 512, 494, 476, 460, 444, 430, 416, 404, 392, 382, 372, 364, 356, 350, 344, 340, 336, 334, 332, 332, 332, 334, 336, 340, 344, 350, 356, 364, 372, 382, 392, 404, 416, 430, 444, 460, 476, 494, 512, 532, 552, 574, 596, 620, 644]\n assert candidate(boxes = \"00001111110000\") == [39, 33, 27, 21, 15, 11, 9, 9, 11, 15, 21, 27, 33, 39]\n assert candidate(boxes = \"0000000000000000000000000000000000000000000000001\") == [48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(boxes = \"111000111000111\") == [63, 56, 51, 48, 45, 42, 39, 38, 39, 42, 45, 48, 51, 56, 63]\n assert candidate(boxes = \"00000000000000000000000100000000000000000000000\") == [23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]\n assert candidate(boxes = \"0001000100010001000100010001\") == [105, 98, 91, 84, 79, 74, 69, 64, 61, 58, 55, 52, 51, 50, 49, 48, 49, 50, 51, 52, 55, 58, 61, 64, 69, 74, 79, 84]\n assert candidate(boxes = \"100000000000000000000000000000000000000000000000001\") == [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]\n assert candidate(boxes = \"0000000000000000000000000000000000000000000000000001\") == [51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(boxes = \"10101010101010101010101010101010101010101010\") == [462, 442, 422, 404, 386, 370, 354, 340, 326, 314, 302, 292, 282, 274, 266, 260, 254, 250, 246, 244, 242, 242, 242, 244, 246, 250, 254, 260, 266, 274, 282, 292, 302, 314, 326, 340, 354, 370, 386, 404, 422, 442, 462, 484]\n assert candidate(boxes = \"000010001000100010001\") == [60, 55, 50, 45, 40, 37, 34, 31, 28, 27, 26, 25, 24, 25, 26, 27, 28, 31, 34, 37, 40]\n assert candidate(boxes = \"00101010101010101010101010101\") == [210, 196, 182, 170, 158, 148, 138, 130, 122, 116, 110, 106, 102, 100, 98, 98, 98, 100, 102, 106, 110, 116, 122, 130, 138, 148, 158, 170, 182]\n assert candidate(boxes = \"011100000111000001110000011100000\") == [168, 156, 146, 138, 132, 126, 120, 114, 108, 102, 98, 96, 96, 96, 96, 96, 96, 96, 98, 102, 108, 114, 120, 126, 132, 138, 146, 156, 168, 180, 192, 204, 216]\n assert candidate(boxes = \"110001100011000\") == [33, 29, 27, 25, 23, 21, 21, 23, 25, 27, 29, 33, 39, 45, 51]\n assert candidate(boxes = \"10101010101010101010\") == [90, 82, 74, 68, 62, 58, 54, 52, 50, 50, 50, 52, 54, 58, 62, 68, 74, 82, 90, 100]\n assert candidate(boxes = \"010010001000010000010000001000000000\") == [71, 65, 61, 57, 53, 51, 49, 47, 45, 45, 45, 45, 45, 45, 47, 49, 51, 53, 55, 57, 61, 65, 69, 73, 77, 81, 85, 91, 97, 103, 109, 115, 121, 127, 133, 139]\n assert candidate(boxes = \"11100000000111100000001111\") == [147, 138, 131, 126, 121, 116, 111, 106, 101, 96, 91, 86, 83, 82, 83, 86, 89, 92, 95, 98, 101, 104, 107, 112, 119, 128]\n assert candidate(boxes = \"0010001000100010001\") == [50, 45, 40, 37, 34, 31, 28, 27, 26, 25, 24, 25, 26, 27, 28, 31, 34, 37, 40]\n assert candidate(boxes = \"10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\") == [112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112]\n assert candidate(boxes = \"1010101010101010101010101\") == [156, 145, 134, 125, 116, 109, 102, 97, 92, 89, 86, 85, 84, 85, 86, 89, 92, 97, 102, 109, 116, 125, 134, 145, 156]\n assert candidate(boxes = \"111100000011110000001111\") == [138, 128, 120, 114, 110, 106, 102, 98, 94, 90, 86, 84, 84, 86, 90, 94, 98, 102, 106, 110, 114, 120, 128, 138]\n assert candidate(boxes = \"1010101010101010101010101010101010101010\") == [380, 362, 344, 328, 312, 298, 284, 272, 260, 250, 240, 232, 224, 218, 212, 208, 204, 202, 200, 200, 200, 202, 204, 208, 212, 218, 224, 232, 240, 250, 260, 272, 284, 298, 312, 328, 344, 362, 380, 400]\n assert candidate(boxes = \"101010101010101010101010101010101010101010101010101010101010\") == [870, 842, 814, 788, 762, 738, 714, 692, 670, 650, 630, 612, 594, 578, 562, 548, 534, 522, 510, 500, 490, 482, 474, 468, 462, 458, 454, 452, 450, 450, 450, 452, 454, 458, 462, 468, 474, 482, 490, 500, 510, 522, 534, 548, 562, 578, 594, 612, 630, 650, 670, 692, 714, 738, 762, 788, 814, 842, 870, 900]\n assert candidate(boxes = \"001001001001001001001001001001001001001001001001001001001\") == [551, 532, 513, 496, 479, 462, 447, 432, 417, 404, 391, 378, 367, 356, 345, 336, 327, 318, 311, 304, 297, 292, 287, 282, 279, 276, 273, 272, 271, 270, 271, 272, 273, 276, 279, 282, 287, 292, 297, 304, 311, 318, 327, 336, 345, 356, 367, 378, 391, 404, 417, 432, 447, 462, 479, 496, 513]\n assert candidate(boxes = \"1101101101101101101101101101101101101101101101101101101101101101101101101101101101101101\") == [2552, 2495, 2440, 2385, 2332, 2281, 2230, 2181, 2134, 2087, 2042, 1999, 1956, 1915, 1876, 1837, 1800, 1765, 1730, 1697, 1666, 1635, 1606, 1579, 1552, 1527, 1504, 1481, 1460, 1441, 1422, 1405, 1390, 1375, 1362, 1351, 1340, 1331, 1324, 1317, 1312, 1309, 1306, 1305, 1306, 1307, 1310, 1315, 1320, 1327, 1336, 1345, 1356, 1369, 1382, 1397, 1414, 1431, 1450, 1471, 1492, 1515, 1540, 1565, 1592, 1621, 1650, 1681, 1714, 1747, 1782, 1819, 1856, 1895, 1936, 1977, 2020, 2065, 2110, 2157, 2206, 2255, 2306, 2359, 2412, 2467, 2524, 2581]\n assert candidate(boxes = \"10100101001010010100101001010010\") == [192, 181, 170, 161, 152, 143, 136, 129, 124, 119, 114, 111, 108, 107, 106, 105, 106, 107, 110, 113, 116, 121, 126, 133, 140, 147, 156, 165, 176, 187, 198, 211]\n assert candidate(boxes = \"1001001001001001001001001001\") == [135, 127, 119, 111, 105, 99, 93, 89, 85, 81, 79, 77, 75, 75, 75, 75, 77, 79, 81, 85, 89, 93, 99, 105, 111, 119, 127, 135]\n assert candidate(boxes = \"0001000010000100001\") == [42, 38, 34, 30, 28, 26, 24, 22, 20, 20, 20, 20, 20, 20, 22, 24, 26, 28, 30]\n assert candidate(boxes = \"0000100000000100000001\") == [38, 35, 32, 29, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(boxes = \"100000000000000000001\") == [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(boxes = \"101001010010100101001010\") == [110, 102, 94, 88, 82, 76, 72, 68, 66, 64, 62, 62, 62, 64, 66, 68, 72, 76, 82, 88, 94, 102, 110, 120]\n assert candidate(boxes = \"1111000011110000111100001111\") == [216, 202, 190, 180, 172, 164, 156, 148, 140, 134, 130, 128, 128, 128, 128, 128, 128, 130, 134, 140, 148, 156, 164, 172, 180, 190, 202, 216]\n assert candidate(boxes = \"110100100100110\") == [44, 39, 36, 33, 32, 31, 30, 31, 32, 33, 36, 39, 42, 47, 54]\n assert candidate(boxes = \"1111111111111111111111111111111111111111111111111111\") == [1326, 1276, 1228, 1182, 1138, 1096, 1056, 1018, 982, 948, 916, 886, 858, 832, 808, 786, 766, 748, 732, 718, 706, 696, 688, 682, 678, 676, 676, 678, 682, 688, 696, 706, 718, 732, 748, 766, 786, 808, 832, 858, 886, 916, 948, 982, 1018, 1056, 1096, 1138, 1182, 1228, 1276, 1326]\n assert candidate(boxes = \"0000000000101010101010101010101010100000000\") == [286, 273, 260, 247, 234, 221, 208, 195, 182, 169, 156, 145, 134, 125, 116, 109, 102, 97, 92, 89, 86, 85, 84, 85, 86, 89, 92, 97, 102, 109, 116, 125, 134, 145, 156, 169, 182, 195, 208, 221, 234, 247, 260]\n assert candidate(boxes = \"10011001100110011001100110011\") == [217, 204, 191, 178, 167, 158, 149, 140, 133, 128, 123, 118, 115, 114, 113, 112, 113, 116, 119, 122, 127, 134, 141, 148, 157, 168, 179, 190, 203]\n assert candidate(boxes = \"11111111100000000111111110000000011111111\") == [492, 469, 448, 429, 412, 397, 384, 373, 364, 357, 350, 343, 336, 329, 322, 315, 308, 301, 296, 293, 292, 293, 296, 301, 308, 317, 326, 335, 344, 353, 362, 371, 380, 389, 400, 413, 428, 445, 464, 485, 508]\n assert candidate(boxes = \"1010101010101010\") == [56, 50, 44, 40, 36, 34, 32, 32, 32, 34, 36, 40, 44, 50, 56, 64]\n assert candidate(boxes = \"0000110000000000110000000000110000000000110000000000110000000000110000000000110000000000\") == [567, 553, 539, 525, 511, 499, 489, 479, 469, 459, 449, 439, 429, 419, 409, 399, 389, 381, 375, 369, 363, 357, 351, 345, 339, 333, 327, 321, 315, 311, 309, 307, 305, 303, 301, 299, 297, 295, 293, 291, 289, 289, 291, 293, 295, 297, 299, 301, 303, 305, 307, 309, 311, 315, 321, 327, 333, 339, 345, 351, 357, 363, 369, 375, 381, 389, 399, 409, 419, 429, 439, 449, 459, 469, 479, 489, 499, 511, 525, 539, 553, 567, 581, 595, 609, 623, 637, 651]\n assert candidate(boxes = \"00000000000111111111100000000000\") == [155, 145, 135, 125, 115, 105, 95, 85, 75, 65, 55, 45, 37, 31, 27, 25, 25, 27, 31, 37, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155]\n assert candidate(boxes = \"01001010010100101001010010100101001010010100101001\") == [500, 480, 462, 444, 426, 410, 394, 380, 366, 352, 340, 328, 318, 308, 298, 290, 282, 276, 270, 264, 260, 256, 254, 252, 250, 250, 250, 252, 254, 256, 260, 264, 270, 276, 282, 290, 298, 308, 318, 328, 340, 352, 366, 380, 394, 410, 426, 444, 462, 480]\n assert candidate(boxes = \"101010101010101010101010\") == [132, 122, 112, 104, 96, 90, 84, 80, 76, 74, 72, 72, 72, 74, 76, 80, 84, 90, 96, 104, 112, 122, 132, 144]\n assert candidate(boxes = \"11110000111100001111000011110000111100001111000011110000\") == [714, 688, 664, 642, 622, 602, 582, 562, 542, 524, 508, 494, 482, 470, 458, 446, 434, 424, 416, 410, 406, 402, 398, 394, 390, 388, 388, 390, 394, 398, 402, 406, 410, 416, 424, 434, 446, 458, 470, 482, 494, 508, 524, 542, 562, 582, 602, 622, 642, 664, 688, 714, 742, 770, 798, 826]\n assert candidate(boxes = \"10000000001000000000100000000010000000001\") == [100, 97, 94, 91, 88, 85, 82, 79, 76, 73, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 73, 76, 79, 82, 85, 88, 91, 94, 97, 100]\n assert candidate(boxes = \"0000011111100000\") == [45, 39, 33, 27, 21, 15, 11, 9, 9, 11, 15, 21, 27, 33, 39, 45]\n assert candidate(boxes = \"11100000000000000000000000000000000000001\") == [43, 41, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, 117]\n assert candidate(boxes = \"110011001100110011001100110011001100\") == [297, 281, 267, 253, 239, 227, 217, 207, 197, 189, 183, 177, 171, 167, 165, 163, 161, 161, 163, 165, 167, 171, 177, 183, 189, 197, 207, 217, 227, 239, 253, 267, 281, 297, 315, 333]\n assert candidate(boxes = \"01010101010101010101010101010101\") == [256, 240, 226, 212, 200, 188, 178, 168, 160, 152, 146, 140, 136, 132, 130, 128, 128, 128, 130, 132, 136, 140, 146, 152, 160, 168, 178, 188, 200, 212, 226, 240]\n assert candidate(boxes = \"11111111111111111111111111111111\") == [496, 466, 438, 412, 388, 366, 346, 328, 312, 298, 286, 276, 268, 262, 258, 256, 256, 258, 262, 268, 276, 286, 298, 312, 328, 346, 366, 388, 412, 438, 466, 496]\n assert candidate(boxes = \"111111111111111111111111111111111111111111111111\") == [1128, 1082, 1038, 996, 956, 918, 882, 848, 816, 786, 758, 732, 708, 686, 666, 648, 632, 618, 606, 596, 588, 582, 578, 576, 576, 578, 582, 588, 596, 606, 618, 632, 648, 666, 686, 708, 732, 758, 786, 816, 848, 882, 918, 956, 996, 1038, 1082, 1128]\n assert candidate(boxes = \"10000001000001\") == [20, 19, 18, 17, 16, 15, 14, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(boxes = \"00000000000000000000000000000000000000000000000000000000000000000000000000000001\") == [79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(boxes = \"10000000000000000000000000000001\") == [31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31]\n assert candidate(boxes = \"1000010000100001000010000100001\") == [105, 100, 95, 90, 85, 80, 77, 74, 71, 68, 65, 64, 63, 62, 61, 60, 61, 62, 63, 64, 65, 68, 71, 74, 77, 80, 85, 90, 95, 100, 105]\n assert candidate(boxes = \"111000111000111000111000111000111000\") == [288, 272, 258, 246, 234, 222, 210, 200, 192, 186, 180, 174, 168, 164, 162, 162, 162, 162, 162, 164, 168, 174, 180, 186, 192, 200, 210, 222, 234, 246, 258, 272, 288, 306, 324, 342]\n assert candidate(boxes = \"00000000000000000001111111111111111111\") == [532, 513, 494, 475, 456, 437, 418, 399, 380, 361, 342, 323, 304, 285, 266, 247, 228, 209, 190, 171, 154, 139, 126, 115, 106, 99, 94, 91, 90, 91, 94, 99, 106, 115, 126, 139, 154, 171]\n"}, "metadata": {"canonical_parameter_names": ["boxes"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector minOperations(string boxes) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "boxes", "type": "string"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1770, "task_id": "maximum-score-from-performing-multiplication-operations", "difficulty": "Hard", "problem_description": "You are given two 0-indexed integer arrays nums and multipliers of size n and m respectively, where n >= m.\nYou begin with a score of 0. You want to perform exactly m operations. On the ith operation (0-indexed) you will:\n\nChoose one integer x from either the start or the end of the array nums.\nAdd multipliers[i] * x to your score.\n \nNote that multipliers[0] corresponds to the first operation, multipliers[1] to the second operation, and so on.\n\n\nRemove x from nums.\n\nReturn the maximum score after performing m operations.\n \nExample 1:\n\nInput: nums = [1,2,3], multipliers = [3,2,1]\nOutput: 14\nExplanation: An optimal solution is as follows:\n- Choose from the end, [1,2,3], adding 3 * 3 = 9 to the score.\n- Choose from the end, [1,2], adding 2 * 2 = 4 to the score.\n- Choose from the end, [1], adding 1 * 1 = 1 to the score.\nThe total score is 9 + 4 + 1 = 14.\nExample 2:\n\nInput: nums = [-5,-3,-3,-2,7,1], multipliers = [-10,-5,3,4,6]\nOutput: 102\nExplanation: An optimal solution is as follows:\n- Choose from the start, [-5,-3,-3,-2,7,1], adding -5 * -10 = 50 to the score.\n- Choose from the start, [-3,-3,-2,7,1], adding -3 * -5 = 15 to the score.\n- Choose from the start, [-3,-2,7,1], adding -3 * 3 = -9 to the score.\n- Choose from the end, [-2,7,1], adding 1 * 4 = 4 to the score.\n- Choose from the end, [-2,7], adding 7 * 6 = 42 to the score. \nThe total score is 50 + 15 - 9 + 4 + 42 = 102.\n\n \nConstraints:\n\nn == nums.length\nm == multipliers.length\n1 <= m <= 300\nm <= n <= 105 \n-1000 <= nums[i], multipliers[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],multipliers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 385\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],multipliers = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 385\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],multipliers = [10, 9, 8, 7, 6]) == 330\n assert candidate(nums = [-1, -2, -3, -4, -5, -6],multipliers = [-1, -2, -3, -4, -5, -6]) == 91\n assert candidate(nums = [-3, -2, -1, 1, 2, 3],multipliers = [1, -1, 1, -1, 1, -1]) == 12\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],multipliers = [1, 2, 3, 4, 5]) == 101\n assert candidate(nums = [100, 200, 300],multipliers = [1, 2]) == 700\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],multipliers = [9, 8, 7]) == 194\n assert candidate(nums = [5, -2, 5, -3, 5, 5],multipliers = [-1, 1, -1, 1, -1, 1]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],multipliers = [1, 2, 3, 4]) == 80\n assert candidate(nums = [-5, -3, -3, -2, 7, 1],multipliers = [-10, -5, 3, 4, 6]) == 102\n assert candidate(nums = [1],multipliers = [1]) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5],multipliers = [-1, -2, -3]) == 23\n assert candidate(nums = [-1, -2, -3, -4, -5],multipliers = [1, 2, 3, 4, 5]) == -35\n assert candidate(nums = [10, 20, 30, 40, 50],multipliers = [5, 4, 3, 2, 1]) == 550\n assert candidate(nums = [10, 20, 30, 40, 50],multipliers = [1, 2, 3, 4, 5]) == 550\n assert candidate(nums = [1, 2, 3, 4, 5, 6],multipliers = [1, 2, 3]) == 28\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],multipliers = [1, 2, 3, 4]) == 71\n assert candidate(nums = [1, 2, 3],multipliers = [3, 2, 1]) == 14\n assert candidate(nums = [9, 8, 7, 6, 5],multipliers = [-1, -2, -3]) == -37\n assert candidate(nums = [-1, -2, -3, -4, -5],multipliers = [-1, -2, -3, -4, -5]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5],multipliers = [1, 2, 3]) == 23\n assert candidate(nums = [5, 7, 3, 8, 6],multipliers = [3, 2, 4]) == 60\n assert candidate(nums = [5, 3, 8, 4, 9, 2, 7, 1, 6, 0],multipliers = [10, -20, 30, -40, 50]) == 540\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],multipliers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == -10\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000],multipliers = [10, -20, 30, -40, 50]) == 115000\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12],multipliers = [10, 9, 8, 7, 6, 5]) == 105\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 38500\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250],multipliers = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55250\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [5, 3, 8, 1, 6, 9, 2, 7, 4, 10],multipliers = [-1, 2, -3, 4, -5, 6]) == 75\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],multipliers = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 75\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],multipliers = [10, -9, 8, -7, 6, -5, 4, -3, 2, -1]) == 205\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],multipliers = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == -5550\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],multipliers = [-1, -2, -3, -4, -5]) == 185\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],multipliers = [-1, 1, -1, 1, -1, 1]) == 6000\n assert candidate(nums = [1, 100, 1000, 10000, 100000, 1000000],multipliers = [10, 20, 30, 40, 50]) == 50432010\n assert candidate(nums = [5, -3, 8, 2, -7, 6, 1, 4, -9, 11],multipliers = [3, -2, 7, 5, -8, 6]) == 234\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 21250\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],multipliers = [5, 4, 3, 2, 1]) == -350\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000],multipliers = [10, -20, 30, -40, 50]) == 115000\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],multipliers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],multipliers = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == -220\n assert candidate(nums = [-100, -200, -300, 400, 500, 600, -700, 800, -900],multipliers = [10, 20, 30, 40, 50, 60, 70]) == 77000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],multipliers = [-1, -1, -1, -1, -1]) == -5\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],multipliers = [1, 2, 3, 4, 5, 6, 7]) == 52\n assert candidate(nums = [-100, 100, -200, 200, -300, 300, -400, 400, -500, 500],multipliers = [1, -1, 1, -1, 1, -1]) == 2400\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],multipliers = [1, -1, 1, -1, 1]) == 1\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],multipliers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],multipliers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 800\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],multipliers = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],multipliers = [1, -1, 1, -1, 1]) == 240\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],multipliers = [5, 10, 15, 20, 25]) == 925\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],multipliers = [29, 27, 25, 23, 21]) == 3165\n assert candidate(nums = [5, 3, 8, 10, 15, 1, 4, 7],multipliers = [10, 20, 30, 40, 50]) == 1500\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],multipliers = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == -30500\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],multipliers = [-1, 2, -3, 4, -5]) == 110\n assert candidate(nums = [5, 2, 1, 4, 3],multipliers = [-1, -2, -3]) == -12\n assert candidate(nums = [500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000, 1000, 900, 800, 700],multipliers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 35400\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],multipliers = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],multipliers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == -22000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],multipliers = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 2485\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],multipliers = [10, 20, 30, 40, 50]) == -5000\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],multipliers = [-10, 9, -8, 7, -6, 5, -4, 3, -2, 1]) == 480\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10],multipliers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 85\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],multipliers = [10, 20, 30, 40, 50]) == 2150\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],multipliers = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == -22000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],multipliers = [1, -1, 1, -1, 1, -1, 1]) == 48\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],multipliers = [-5, 10, -15, 20, -25, 30]) == 4625\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],multipliers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 155\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],multipliers = [15, 14, 13, 12, 11]) == 855\n assert candidate(nums = [-10, 10, -20, 20, -30, 30, -40, 40, -50, 50],multipliers = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 300\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],multipliers = [20, 19, 18, 17, 16, 15, 14]) == 2051\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],multipliers = [1, 2, 3, 4, 5, 6]) == 15300\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700],multipliers = [1, -2, 3, -4, 5]) == 7500\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100],multipliers = [1, 2, -3, 4, -5]) == 1030\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100],multipliers = [100, -50, 25, -12, 6]) == 9630\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 821\n assert candidate(nums = [-5, -10, -15, -20, -25, -30, -35, -40, -45, -50],multipliers = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 1925\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],multipliers = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 200\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],multipliers = [1, 2, 3, 4, 5]) == 7000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],multipliers = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 700\n assert candidate(nums = [-5, 3, -1, 2, -4, 6, -7, 8, -9, 10],multipliers = [1, -1, 1, -1, 1, -1]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 2670\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15],multipliers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -8\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],multipliers = [1, -1, 2, -2, 3]) == 4700\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],multipliers = [1, 2, 3, 4, 5, 6]) == 161\n assert candidate(nums = [5, 1, 4, 3, 2, 6, 7, 8, 9, 10],multipliers = [10, -10, 20, -20, 30]) == 450\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000],multipliers = [1, -1, 1, -1, 1, -1]) == 4100\n assert candidate(nums = [1000, -1000, 2000, -2000, 3000, -3000, 4000, -4000, 5000, -5000, 6000, -6000, 7000, -7000, 8000, -8000, 9000, -9000, 10000, -10000],multipliers = [100, -99, 98, -97, 96, -95, 94, -93, 92, -91, 90, -89, 88, -87, 86, -85, 84, -83, 82, -81]) == 10195000\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 0, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 26800\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],multipliers = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 0\n assert candidate(nums = [5, 3, 8, -2, 6, 7, -4, 10, 15, -20],multipliers = [1, 2, 3, 4, 5, 6, 7, 8]) == 242\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],multipliers = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 75\n assert candidate(nums = [300, -100, 200, -200, 500, -300, 400, -400, 600, -500],multipliers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 61000\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],multipliers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],multipliers = [-30, -29, -28, -27, -26, -25, -24, -23, -22, -21]) == -1320\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],multipliers = [2, -3, 4, -5, 6]) == 211\n assert candidate(nums = [50, 25, 75, 100, -50, -25, -75, -100, 200, 150, 175, 200],multipliers = [10, -5, 2, -1, 3, -2]) == 2750\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],multipliers = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == -220\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],multipliers = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 3850\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],multipliers = [-1, -2, -3, -4, -5]) == -550\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10],multipliers = [-1, 1, -1, 1, -1, 1, -1, 1]) == 50\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],multipliers = [5, -5, 4, -4, 3, -3]) == 87\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],multipliers = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == -334\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],multipliers = [100, -100, 100, -100, 100]) == 500000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],multipliers = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == -120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1081\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == -1540\n assert candidate(nums = [5, 3, 8, -2, 6, 7, -4, 10],multipliers = [1, 2, 3, 4, 5]) == 77\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20],multipliers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],multipliers = [1, 2, 3, 4, 5]) == 1850\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980],multipliers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 54666\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],multipliers = [1, -1, 1, -1, 1]) == 0\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000],multipliers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],multipliers = [-1, -2, -3, -4, -5]) == 1150\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100],multipliers = [1, 2, 3, 4, 5]) == 600\n"}, "metadata": {"canonical_parameter_names": ["nums", "multipliers"], "leetcode_dataset_entry_point": "Solution().maximumScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumScore(vector& nums, vector& multipliers) {", "container": "Solution", "callable": "maximumScore", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "multipliers", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1771, "task_id": "maximize-palindrome-length-from-subsequences", "difficulty": "Hard", "problem_description": "You are given two strings, word1 and word2. You want to construct a string in the following manner:\n\nChoose some non-empty subsequence subsequence1 from word1.\nChoose some non-empty subsequence subsequence2 from word2.\nConcatenate the subsequences: subsequence1 + subsequence2, to make the string.\n\nReturn the length of the longest palindrome that can be constructed in the described manner. If no palindromes can be constructed, return 0.\nA subsequence of a string s is a string that can be made by deleting some (possibly none) characters from s without changing the order of the remaining characters.\nA palindrome is a string that reads the same forward as well as backward.\n \nExample 1:\n\nInput: word1 = \"cacb\", word2 = \"cbba\"\nOutput: 5\nExplanation: Choose \"ab\" from word1 and \"cba\" from word2 to make \"abcba\", which is a palindrome.\nExample 2:\n\nInput: word1 = \"ab\", word2 = \"ab\"\nOutput: 3\nExplanation: Choose \"ab\" from word1 and \"a\" from word2 to make \"aba\", which is a palindrome.\nExample 3:\n\nInput: word1 = \"aa\", word2 = \"bb\"\nOutput: 0\nExplanation: You cannot construct a palindrome from the described method, so return 0.\n \nConstraints:\n\n1 <= word1.length, word2.length <= 1000\nword1 and word2 consist of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word1 = \"race\",word2 = \"car\") == 7\n assert candidate(word1 = \"a\",word2 = \"a\") == 2\n assert candidate(word1 = \"aabb\",word2 = \"bbcc\") == 4\n assert candidate(word1 = \"race\",word2 = \"care\") == 7\n assert candidate(word1 = \"abcde\",word2 = \"edcba\") == 10\n assert candidate(word1 = \"madam\",word2 = \"madam\") == 10\n assert candidate(word1 = \"aabb\",word2 = \"bbaa\") == 8\n assert candidate(word1 = \"xyz\",word2 = \"zyx\") == 6\n assert candidate(word1 = \"palindrome\",word2 = \"emordnilap\") == 20\n assert candidate(word1 = \"abcabc\",word2 = \"cbacba\") == 12\n assert candidate(word1 = \"aa\",word2 = \"bb\") == 0\n assert candidate(word1 = \"hello\",word2 = \"world\") == 5\n assert candidate(word1 = \"abcdxyz\",word2 = \"zyxcba\") == 12\n assert candidate(word1 = \"cacb\",word2 = \"cbba\") == 5\n assert candidate(word1 = \"mnop\",word2 = \"pqrs\") == 2\n assert candidate(word1 = \"noon\",word2 = \"noon\") == 8\n assert candidate(word1 = \"level\",word2 = \"deified\") == 5\n assert candidate(word1 = \"a\",word2 = \"b\") == 0\n assert candidate(word1 = \"noon\",word2 = \"moon\") == 7\n assert candidate(word1 = \"abcba\",word2 = \"abcba\") == 10\n assert candidate(word1 = \"abcd\",word2 = \"dcba\") == 8\n assert candidate(word1 = \"abc\",word2 = \"def\") == 0\n assert candidate(word1 = \"ab\",word2 = \"ab\") == 3\n assert candidate(word1 = \"xyzzxyzzxyzz\",word2 = \"zzzyzxzzzyzxzzzyx\") == 25\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == 52\n assert candidate(word1 = \"abacax\",word2 = \"xcabab\") == 10\n assert candidate(word1 = \"deeee\",word2 = \"eee\") == 7\n assert candidate(word1 = \"abcdefghij\",word2 = \"jihgfedcbajihgfedcba\") == 21\n assert candidate(word1 = \"madam\",word2 = \"rotor\") == 0\n assert candidate(word1 = \"aabbccddeeff\",word2 = \"ffeeddccbbaa\") == 24\n assert candidate(word1 = \"level\",word2 = \"leve\") == 8\n assert candidate(word1 = \"palindrome\",word2 = \"emordnilapracecar\") == 20\n assert candidate(word1 = \"longestpalindrome\",word2 = \"emordnilapstgnol\") == 30\n assert candidate(word1 = \"racecar\",word2 = \"level\") == 3\n assert candidate(word1 = \"step on no pets\",word2 = \"step on no pets\") == 30\n assert candidate(word1 = \"aabbaa\",word2 = \"ccddeee\") == 0\n assert candidate(word1 = \"abc\",word2 = \"cba\") == 6\n assert candidate(word1 = \"xyzzyx\",word2 = \"zyxzyz\") == 7\n assert candidate(word1 = \"abcdxyz\",word2 = \"zyxcdb\") == 10\n assert candidate(word1 = \"xyx\",word2 = \"xyx\") == 6\n assert candidate(word1 = \"abcdefghij\",word2 = \"jihgfedcba\") == 20\n assert candidate(word1 = \"racecar\",word2 = \"racecar\") == 14\n assert candidate(word1 = \"b\",word2 = \"b\") == 2\n assert candidate(word1 = \"abcdefgh\",word2 = \"hgfedcba\") == 16\n assert candidate(word1 = \"level\",word2 = \"level\") == 10\n assert candidate(word1 = \"aabbccddeeffgg\",word2 = \"ggffeeddccbbaa\") == 28\n assert candidate(word1 = \"aabaaa\",word2 = \"aaabaa\") == 12\n assert candidate(word1 = \"abacaxaba\",word2 = \"xyzzyx\") == 6\n assert candidate(word1 = \"abcdefg\",word2 = \"gfedcba\") == 14\n assert candidate(word1 = \"uniqueletters\",word2 = \"stretteleunik\") == 20\n assert candidate(word1 = \"aaa\",word2 = \"bbb\") == 0\n assert candidate(word1 = \"abcxyz\",word2 = \"zyxcba\") == 12\n assert candidate(word1 = \"abacdfgdcaba\",word2 = \"abacdfgdcaba\") == 22\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"dcbaabcdabcd\") == 14\n assert candidate(word1 = \"aabbaa\",word2 = \"aaabba\") == 11\n assert candidate(word1 = \"aabbccdd\",word2 = \"ddccbbaa\") == 16\n assert candidate(word1 = \"aaaaaa\",word2 = \"bbbbbb\") == 0\n assert candidate(word1 = \"ababababab\",word2 = \"bababababa\") == 20\n assert candidate(word1 = \"step\",word2 = \"onests\") == 7\n assert candidate(word1 = \"abcd\",word2 = \"zyxw\") == 0\n assert candidate(word1 = \"ababab\",word2 = \"bababa\") == 12\n assert candidate(word1 = \"abacaba\",word2 = \"bcbcbcb\") == 9\n assert candidate(word1 = \"palindromeconstruction\",word2 = \"noitcitsnocemordnilap\") == 40\n assert candidate(word1 = \"abcd\",word2 = \"dcbaabcd\") == 8\n assert candidate(word1 = \"racecar\",word2 = \"car\") == 7\n assert candidate(word1 = \"deified\",word2 = \"deified\") == 14\n assert candidate(word1 = \"abcdefg\",word2 = \"hgfedcba\") == 15\n assert candidate(word1 = \"complexstring\",word2 = \"gnirtsxlpmoc\") == 24\n assert candidate(word1 = \"noonnoon\",word2 = \"noonnoon\") == 16\n assert candidate(word1 = \"thisisatest\",word2 = \"tsetasitisth\") == 18\n assert candidate(word1 = \"abcdxyz\",word2 = \"zyxwvut\") == 6\n assert candidate(word1 = \"mnopqr\",word2 = \"rstuvw\") == 2\n assert candidate(word1 = \"racecar\",word2 = \"carrace\") == 9\n assert candidate(word1 = \"aabbccdd\",word2 = \"aabbccdd\") == 6\n assert candidate(word1 = \"abababa\",word2 = \"bababab\") == 13\n assert candidate(word1 = \"aaaaabbbbb\",word2 = \"bbbbbbaaaa\") == 19\n assert candidate(word1 = \"xyzz\",word2 = \"zzxy\") == 6\n assert candidate(word1 = \"abcabcabcabc\",word2 = \"cbacbacbacba\") == 24\n assert candidate(word1 = \"ab\",word2 = \"bbaa\") == 5\n assert candidate(word1 = \"qwertyuiop\",word2 = \"poiuytrewq\") == 20\n assert candidate(word1 = \"aaaaabbbbb\",word2 = \"bbbbbbaaaaa\") == 21\n assert candidate(word1 = \"zzzz\",word2 = \"zzzz\") == 8\n assert candidate(word1 = \"xyx\",word2 = \"yxy\") == 5\n assert candidate(word1 = \"repaper\",word2 = \"repaper\") == 14\n assert candidate(word1 = \"reviled\",word2 = \"devil\") == 6\n assert candidate(word1 = \"abcdef\",word2 = \"fedcbaxyz\") == 12\n assert candidate(word1 = \"mississippi\",word2 = \"ississippim\") == 18\n assert candidate(word1 = \"abcdabc\",word2 = \"cbadcbad\") == 14\n assert candidate(word1 = \"rotor\",word2 = \"rotor\") == 10\n assert candidate(word1 = \"abcdabc\",word2 = \"cbadacb\") == 12\n assert candidate(word1 = \"zyxwvutsrqponmlkjihgfedcba\",word2 = \"abcdefghijklmnopqrstuvwxyz\") == 52\n assert candidate(word1 = \"aabbccddeeffgg\",word2 = \"ggffeeddccbaa\") == 26\n assert candidate(word1 = \"xxyyzz\",word2 = \"zzxyyx\") == 10\n assert candidate(word1 = \"xyzyx\",word2 = \"xzyyx\") == 8\n assert candidate(word1 = \"aabbcc\",word2 = \"ccbbaa\") == 12\n assert candidate(word1 = \"pneumonoultramicroscopicsilicovolcanoconiosis\",word2 = \"sinoconiovacolcosilicropicoviscounmoneup\") == 49\n assert candidate(word1 = \"aaaabbbb\",word2 = \"bbbbcccc\") == 8\n assert candidate(word1 = \"pqrstu\",word2 = \"utsrqp\") == 12\n assert candidate(word1 = \"mamad\",word2 = \"adam\") == 7\n assert candidate(word1 = \"abcabcabc\",word2 = \"cbacbacba\") == 18\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"abacabadabacaba\") == 30\n assert candidate(word1 = \"refer\",word2 = \"refer\") == 10\n assert candidate(word1 = \"redder\",word2 = \"redder\") == 12\n assert candidate(word1 = \"abacdfgdcaba\",word2 = \"gfdcbba\") == 15\n assert candidate(word1 = \"abcdefghijk\",word2 = \"kjihgfedcba\") == 22\n assert candidate(word1 = \"mnopqr\",word2 = \"rqponm\") == 12\n assert candidate(word1 = \"aabbaa\",word2 = \"bbccbb\") == 6\n assert candidate(word1 = \"thisisaverylongwordtoseetifthelongestpalindrome\",word2 = \"emordnilapelongethtofeesavaloydnevasiht\") == 58\n assert candidate(word1 = \"xyzzxy\",word2 = \"zyxzyxzyx\") == 13\n assert candidate(word1 = \"overlappingword\",word2 = \"drowgnalppero\") == 20\n assert candidate(word1 = \"ab\",word2 = \"ba\") == 4\n assert candidate(word1 = \"zxcvbnmasdfghjkl\",word2 = \"lkjhgfdsamnbvcxz\") == 32\n assert candidate(word1 = \"aaaaa\",word2 = \"bbbbb\") == 0\n assert candidate(word1 = \"racecar\",word2 = \"civic\") == 5\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zz yy xx ww vv uu tt ss rr qq pp oo nn mm ll kk jj ii hh gg ff ee dd cc bb aa\") == 104\n assert candidate(word1 = \"abcdef\",word2 = \"fedcba\") == 12\n assert candidate(word1 = \"pqr\",word2 = \"rstuv\") == 2\n assert candidate(word1 = \"xyz\",word2 = \"zyxcba\") == 6\n assert candidate(word1 = \"c\",word2 = \"c\") == 2\n assert candidate(word1 = \"abcabcabcabcabc\",word2 = \"cbacbacbacbacba\") == 30\n"}, "metadata": {"canonical_parameter_names": ["word1", "word2"], "leetcode_dataset_entry_point": "Solution().longestPalindrome", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int longestPalindrome(string word1, string word2) {", "container": "Solution", "callable": "longestPalindrome", "parameters": [{"name": "word1", "type": "string"}, {"name": "word2", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1773, "task_id": "count-items-matching-a-rule", "difficulty": "Easy", "problem_description": "You are given an array items, where each items[i] = [typei, colori, namei] describes the type, color, and name of the ith item. You are also given a rule represented by two strings, ruleKey and ruleValue.\nThe ith item is said to match the rule if one of the following is true:\n\nruleKey == \"type\" and ruleValue == typei.\nruleKey == \"color\" and ruleValue == colori.\nruleKey == \"name\" and ruleValue == namei.\n\nReturn the number of items that match the given rule.\n \nExample 1:\n\nInput: items = [[\"phone\",\"blue\",\"pixel\"],[\"computer\",\"silver\",\"lenovo\"],[\"phone\",\"gold\",\"iphone\"]], ruleKey = \"color\", ruleValue = \"silver\"\nOutput: 1\nExplanation: There is only one item matching the given rule, which is [\"computer\",\"silver\",\"lenovo\"].\n\nExample 2:\n\nInput: items = [[\"phone\",\"blue\",\"pixel\"],[\"computer\",\"silver\",\"phone\"],[\"phone\",\"gold\",\"iphone\"]], ruleKey = \"type\", ruleValue = \"phone\"\nOutput: 2\nExplanation: There are only two items matching the given rule, which are [\"phone\",\"blue\",\"pixel\"] and [\"phone\",\"gold\",\"iphone\"]. Note that the item [\"computer\",\"silver\",\"phone\"] does not match.\n \nConstraints:\n\n1 <= items.length <= 104\n1 <= typei.length, colori.length, namei.length, ruleValue.length <= 10\nruleKey is equal to either \"type\", \"color\", or \"name\".\nAll strings consist only of lowercase letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'harley'], ['car', 'green', 'lambo']],ruleKey = \"color\",ruleValue = \"red\") == 1\n assert candidate(items = [['phone', 'blue', 'pixel'], ['computer', 'silver', 'phone'], ['phone', 'gold', 'iphone']],ruleKey = \"type\",ruleValue = \"phone\") == 2\n assert candidate(items = [['laptop', 'black', 'dell'], ['phone', 'black', 'samsung'], ['tablet', 'black', 'ipad']],ruleKey = \"color\",ruleValue = \"black\") == 3\n assert candidate(items = [['laptop', 'black', 'dell'], ['phone', 'white', 'samsung'], ['tablet', 'gray', 'apple']],ruleKey = \"name\",ruleValue = \"apple\") == 1\n assert candidate(items = [['shirt', 'white', 't-shirt'], ['pants', 'black', 'jeans'], ['shirt', 'white', 'dress-shirt']],ruleKey = \"type\",ruleValue = \"shirt\") == 2\n assert candidate(items = [['laptop', 'black', 'dell'], ['tablet', 'white', 'samsung'], ['laptop', 'silver', 'macbook']],ruleKey = \"name\",ruleValue = \"dell\") == 1\n assert candidate(items = [['shoe', 'white', 'nike'], ['shirt', 'black', 'adidas'], ['shoe', 'black', 'puma']],ruleKey = \"type\",ruleValue = \"shoe\") == 2\n assert candidate(items = [['book', 'red', 'novel'], ['pen', 'blue', 'ballpoint'], ['notebook', 'red', 'blank']],ruleKey = \"name\",ruleValue = \"blank\") == 1\n assert candidate(items = [['phone', 'blue', 'pixel'], ['computer', 'silver', 'lenovo'], ['phone', 'gold', 'iphone']],ruleKey = \"color\",ruleValue = \"silver\") == 1\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini']],ruleKey = \"color\",ruleValue = \"red\") == 2\n assert candidate(items = [['laptop', 'black', 'dell'], ['laptop', 'gray', 'hp'], ['desktop', 'black', 'asus']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['book', 'brown', 'alice'], ['pen', 'blue', 'bic'], ['notebook', 'white', 'staples']],ruleKey = \"type\",ruleValue = \"book\") == 1\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'harley'], ['car', 'red', 'lamborghini']],ruleKey = \"name\",ruleValue = \"ferrari\") == 1\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'red', 'yamaha'], ['truck', 'blue', 'ford']],ruleKey = \"type\",ruleValue = \"red\") == 0\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini']],ruleKey = \"name\",ruleValue = \"ferrari\") == 1\n assert candidate(items = [['book', 'red', 'novel'], ['pen', 'blue', 'ballpoint'], ['book', 'brown', 'textbook']],ruleKey = \"type\",ruleValue = \"book\") == 2\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['smartphone', 'blue', 'samsung galaxy s20'], ['smartphone', 'black', 'iphone 12'], ['smartphone', 'red', 'huawei p30'], ['smartphone', 'black', 'google pixel 4'], ['smartphone', 'blue', 'oneplus 8t']],ruleKey = \"name\",ruleValue = \"iphone 12\") == 1\n assert candidate(items = [['camera', 'black', 'canon'], ['camera', 'silver', 'nikon'], ['camera', 'black', 'sony'], ['camera', 'gold', 'fujifilm'], ['camera', 'black', 'olympus']],ruleKey = \"name\",ruleValue = \"sony\") == 1\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'blue', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartwatch', 'black', 'apple'], ['smartphone', 'red', 'motorola']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['electronics', 'black', 'headphone'], ['electronics', 'silver', 'earbuds'], ['electronics', 'white', 'speakers'], ['electronics', 'blue', 'microphone']],ruleKey = \"type\",ruleValue = \"electronics\") == 4\n assert candidate(items = [['toys', 'yellow', 'balloon'], ['toys', 'red', 'car'], ['toys', 'blue', 'doll'], ['toys', 'green', 'teddy'], ['toys', 'yellow', 'block']],ruleKey = \"color\",ruleValue = \"yellow\") == 2\n assert candidate(items = [['computer', 'silver', 'dell'], ['computer', 'black', 'apple'], ['computer', 'silver', 'hp'], ['computer', 'black', 'asus'], ['computer', 'silver', 'lenovo'], ['computer', 'black', 'microsoft']],ruleKey = \"color\",ruleValue = \"silver\") == 3\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini'], ['bicycle', 'black', 'trek'], ['motorcycle', 'green', 'harley'], ['car', 'blue', 'porsche'], ['bike', 'red', 'giagiua']],ruleKey = \"color\",ruleValue = \"red\") == 3\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'blue', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartwatch', 'black', 'apple'], ['laptop', 'gray', 'hp']],ruleKey = \"type\",ruleValue = \"laptop\") == 2\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini'], ['truck', 'black', 'volvo'], ['motorcycle', 'red', 'honda'], ['car', 'blue', 'tesla']],ruleKey = \"color\",ruleValue = \"red\") == 3\n assert candidate(items = [['shirt', 'blue', 'nike'], ['pants', 'blue', 'adidas'], ['shoes', 'blue', 'puma'], ['hat', 'blue', 'reebok'], ['shirt', 'blue', 'nike']],ruleKey = \"name\",ruleValue = \"nike\") == 2\n assert candidate(items = [['electronics', 'black', 'smartphone'], ['electronics', 'blue', 'laptop'], ['electronics', 'black', 'tablet'], ['electronics', 'red', 'smartwatch'], ['electronics', 'black', 'television']],ruleKey = \"type\",ruleValue = \"electronics\") == 5\n assert candidate(items = [['book', 'brown', 'tolkien'], ['book', 'blue', 'harry_potter'], ['magazine', 'black', 'national_geographic'], ['book', 'blue', 'twilight'], ['magazine', 'white', 'forbes']],ruleKey = \"name\",ruleValue = \"blue\") == 0\n assert candidate(items = [['chair', 'brown', 'ikea'], ['table', 'white', 'ikea'], ['couch', 'gray', 'ikea'], ['desk', 'black', 'ikea'], ['lamp', 'silver', 'ikea']],ruleKey = \"brand\",ruleValue = \"ikea\") == 5\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini'], ['motorcycle', 'black', 'honda'], ['car', 'red', 'tesla']],ruleKey = \"type\",ruleValue = \"car\") == 3\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartwatch', 'gold', 'fitbit'], ['laptop', 'gray', 'hp']],ruleKey = \"type\",ruleValue = \"laptop\") == 2\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini'], ['bike', 'red', 'ducati'], ['car', 'blue', 'toyota'], ['bike', 'white', 'honda']],ruleKey = \"name\",ruleValue = \"red\") == 0\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartwatch', 'gold', 'fitbit'], ['laptop', 'gray', 'hp'], ['laptop', 'black', 'macbook']],ruleKey = \"type\",ruleValue = \"laptop\") == 3\n assert candidate(items = [['book', 'blue', 'fiction'], ['book', 'red', 'nonfiction'], ['book', 'blue', 'science'], ['book', 'green', 'history'], ['book', 'blue', 'fantasy']],ruleKey = \"name\",ruleValue = \"nonfiction\") == 1\n assert candidate(items = [['smartphone', 'blue', 'samsung'], ['smartphone', 'blue', 'googlepixel'], ['smartphone', 'black', 'iphone'], ['smartphone', 'blue', 'oneplus']],ruleKey = \"name\",ruleValue = \"googlepixel\") == 1\n assert candidate(items = [['chair', 'white', 'ikea'], ['sofa', 'brown', 'ikea'], ['table', 'brown', 'ikea'], ['lamp', 'white', 'ikea'], ['shelf', 'brown', 'ikea'], ['cabinet', 'white', 'ikea']],ruleKey = \"type\",ruleValue = \"ikea\") == 0\n assert candidate(items = [['television', 'black', 'samsung'], ['refrigerator', 'white', 'whirlpool'], ['microwave', 'black', 'frigidaire'], ['washer', 'stainless', 'lg']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['apparel', 'black', 'jacket'], ['apparel', 'white', 'shirt'], ['apparel', 'red', 'pants'], ['apparel', 'blue', 'hat']],ruleKey = \"type\",ruleValue = \"apparel\") == 4\n assert candidate(items = [['camera', 'black', 'nikon'], ['camera', 'silver', 'canon'], ['camera', 'gold', 'leica'], ['camera', 'black', 'olympus'], ['camera', 'white', 'fujifilm']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['toy', 'green', 'car'], ['toy', 'red', 'doll'], ['toy', 'blue', 'block'], ['toy', 'green', 'train'], ['toy', 'red', 'helicopter'], ['toy', 'blue', 'truck']],ruleKey = \"type\",ruleValue = \"toy\") == 6\n assert candidate(items = [['laptop', 'silver', 'macbook'], ['smartphone', 'gold', 'iphone'], ['tablet', 'rose gold', 'ipad'], ['watch', 'black', 'apple watch'], ['charger', 'white', 'anker']],ruleKey = \"type\",ruleValue = \"laptop\") == 1\n assert candidate(items = [['phone', 'blue', 'pixel'], ['computer', 'silver', 'lenovo'], ['phone', 'gold', 'iphone'], ['tablet', 'black', 'samsung'], ['smartwatch', 'black', 'fitbit'], ['laptop', 'blue', 'macbook']],ruleKey = \"color\",ruleValue = \"blue\") == 2\n assert candidate(items = [['smartphone', 'red', 'iphone'], ['smartphone', 'black', 'galaxy'], ['smartphone', 'white', 'nokia'], ['smartphone', 'black', 'oneplus'], ['smartphone', 'red', 'motorola'], ['smartphone', 'blue', 'huawei'], ['smartphone', 'red', 'oppo'], ['smartphone', 'green', 'realme']],ruleKey = \"name\",ruleValue = \"red\") == 0\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartwatch', 'gold', 'fitbit'], ['laptop', 'gray', 'hp'], ['laptop', 'black', 'macbook'], ['laptop', 'gray', 'asus']],ruleKey = \"name\",ruleValue = \"laptop\") == 0\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad'], ['laptop', 'white', 'macbook'], ['smartphone', 'blue', 'googlepixel']],ruleKey = \"type\",ruleValue = \"laptop\") == 2\n assert candidate(items = [['book', 'blue', 'harry_potter'], ['book', 'green', 'the_lord_of_the_rings'], ['book', 'blue', 'pride_and_prejudice'], ['book', 'red', 'the_hobbit'], ['book', 'blue', '1984']],ruleKey = \"color\",ruleValue = \"blue\") == 3\n assert candidate(items = [['dress', 'pink', 'prada'], ['shoes', 'black', 'gucci'], ['bag', 'brown', 'lv'], ['jacket', 'blue', 'dolce_gabbana'], ['hat', 'black', 'versace']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['watch', 'black', 'rolex'], ['watch', 'white', 'omega'], ['watch', 'gold', 'patekphilippue'], ['watch', 'silver', 'seiko'], ['watch', 'black', 'titan']],ruleKey = \"name\",ruleValue = \"seiko\") == 1\n assert candidate(items = [['house', 'white', 'mansions'], ['house', 'blue', 'cottages'], ['apartment', 'gray', 'flats'], ['condo', 'white', 'duplex'], ['townhouse', 'blue', 'terraced'], ['house', 'white', 'bungalows'], ['apartment', 'gray', 'penthouse'], ['condo', 'blue', 'villa'], ['townhouse', 'white', 'villas'], ['house', 'gray', 'detached']],ruleKey = \"type\",ruleValue = \"house\") == 4\n assert candidate(items = [['smartphone', 'red', 'iphone'], ['smartphone', 'black', 'galaxy'], ['smartphone', 'white', 'nokia'], ['smartphone', 'black', 'oneplus'], ['smartphone', 'red', 'motorola']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini'], ['motorcycle', 'green', 'harley'], ['truck', 'black', 'ford']],ruleKey = \"type\",ruleValue = \"car\") == 2\n assert candidate(items = [['shirt', 'blue', 'tshirt'], ['jeans', 'blue', 'levis'], ['shirt', 'green', 'polo'], ['shorts', 'blue', 'nike'], ['pants', 'blue', 'adidas'], ['shirt', 'blue', 'reebok']],ruleKey = \"color\",ruleValue = \"blue\") == 5\n assert candidate(items = [['shirt', 'blue', 'nike'], ['pants', 'red', 'adidas'], ['hat', 'blue', 'reebok'], ['jacket', 'green', 'nike'], ['shoes', 'black', 'puma']],ruleKey = \"name\",ruleValue = \"nike\") == 2\n assert candidate(items = [['television', 'black', 'samsung'], ['television', 'silver', 'lg'], ['television', 'gray', 'tcl'], ['television', 'black', 'sony'], ['television', 'red', 'panasonic']],ruleKey = \"type\",ruleValue = \"television\") == 5\n assert candidate(items = [['car', 'red', 'ferrari'], ['car', 'blue', 'ford'], ['car', 'red', 'lamborghini'], ['truck', 'black', 'mercedes'], ['car', 'red', 'tesla']],ruleKey = \"color\",ruleValue = \"red\") == 3\n assert candidate(items = [['kitchenware', 'white', 'plate'], ['kitchenware', 'blue', 'spoon'], ['kitchenware', 'white', 'bowl'], ['kitchenware', 'red', 'fork'], ['kitchenware', 'white', 'knife']],ruleKey = \"color\",ruleValue = \"white\") == 3\n assert candidate(items = [['shirt', 'blue', 'nike'], ['pants', 'blue', 'adidas'], ['shoes', 'black', 'reebok'], ['hat', 'red', 'nike'], ['jacket', 'blue', 'puma'], ['watch', 'silver', 'rolex'], ['belt', 'brown', 'gucci'], ['scarf', 'red', 'h&m'], ['glasses', 'black', 'rayban'], ['sunglasses', 'red', 'polo'], ['boots', 'blue', 'converse'], ['sandals', 'white', 'havaianas'], ['t-shirt', 'red', 'nike'], ['bag', 'black', 'louisvuitton'], ['cap', 'gray', 'nike']],ruleKey = \"name\",ruleValue = \"nike\") == 4\n assert candidate(items = [['shirt', 'blue', 'tshirt'], ['jeans', 'blue', 'levis'], ['shirt', 'green', 'polo'], ['shorts', 'blue', 'nike'], ['pants', 'blue', 'adidas']],ruleKey = \"name\",ruleValue = \"nike\") == 1\n assert candidate(items = [['phone', 'blue', 'pixel'], ['computer', 'silver', 'lenovo'], ['phone', 'gold', 'iphone'], ['tv', 'black', 'samsung'], ['monitor', 'silver', 'dell'], ['laptop', 'gray', 'hp'], ['phone', 'black', 'nokia'], ['tablet', 'gold', 'ipad']],ruleKey = \"type\",ruleValue = \"phone\") == 3\n assert candidate(items = [['book', 'red', 'pride_and_prejudice'], ['book', 'blue', 'the_little_prince'], ['book', 'green', 'to_kill_a_mockingbird'], ['book', 'red', '1984'], ['book', 'yellow', 'moby_dick']],ruleKey = \"color\",ruleValue = \"red\") == 2\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini'], ['truck', 'white', 'ford'], ['car', 'black', 'tesla'], ['car', 'red', 'bmw']],ruleKey = \"color\",ruleValue = \"red\") == 3\n assert candidate(items = [['electronics', 'white', 'samsung'], ['electronics', 'black', 'lg'], ['electronics', 'silver', 'sony'], ['electronics', 'black', 'toshiba'], ['electronics', 'white', 'panasonic']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini'], ['truck', 'white', 'ford'], ['car', 'black', 'tesla']],ruleKey = \"color\",ruleValue = \"red\") == 2\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartwatch', 'gold', 'fitbit'], ['laptop', 'gray', 'hp']],ruleKey = \"name\",ruleValue = \"dell\") == 1\n assert candidate(items = [['tv', 'black', 'samsung'], ['tv', 'white', 'lg'], ['tv', 'silver', 'sony'], ['tv', 'black', 'toshiba'], ['tv', 'white', 'vizio']],ruleKey = \"color\",ruleValue = \"white\") == 2\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini'], ['truck', 'white', 'ford'], ['car', 'black', 'tesla'], ['car', 'red', 'bmw'], ['truck', 'black', 'chevrolet']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['toy', 'red', 'car'], ['toy', 'blue', 'doll'], ['toy', 'green', 'car'], ['toy', 'red', 'ball'], ['toy', 'green', 'doll'], ['toy', 'blue', 'ball']],ruleKey = \"name\",ruleValue = \"car\") == 2\n assert candidate(items = [['dog', 'black', 'labrador'], ['cat', 'white', 'siamese'], ['dog', 'brown', 'golden_retriever'], ['bird', 'blue', 'parakeet'], ['fish', 'red', 'goldfish']],ruleKey = \"type\",ruleValue = \"dog\") == 2\n assert candidate(items = [['clothing', 'blue', 'shirt'], ['clothing', 'red', 't-shirt'], ['clothing', 'blue', 'jeans'], ['clothing', 'green', 'pants'], ['clothing', 'blue', 'jacket'], ['clothing', 'yellow', 'shorts'], ['clothing', 'blue', 'hat']],ruleKey = \"color\",ruleValue = \"blue\") == 4\n assert candidate(items = [['chair', 'brown', 'leather'], ['table', 'white', 'wood'], ['lamp', 'black', 'glass'], ['sofa', 'gray', 'cotton'], ['rug', 'blue', 'carpet'], ['cabinet', 'black', 'oak'], ['bed', 'white', 'sheets'], ['mirror', 'silver', 'frame'], ['shelf', 'black', 'metal']],ruleKey = \"color\",ruleValue = \"black\") == 3\n assert candidate(items = [['shirt', 'blue', 'nike'], ['shirt', 'red', 'adidas'], ['shirt', 'blue', 'puma'], ['shirt', 'green', 'reebok'], ['shirt', 'blue', 'underarmour']],ruleKey = \"name\",ruleValue = \"puma\") == 1\n assert candidate(items = [['book', 'red', 'harrypotter'], ['pen', 'blue', 'bic'], ['book', 'red', 'twilight'], ['notebook', 'white', 'blank'], ['book', 'green', 'thehobbit'], ['book', 'red', 'catch22'], ['marker', 'blue', 'sharpie'], ['book', 'red', 'prideandprejudice']],ruleKey = \"name\",ruleValue = \"red\") == 0\n assert candidate(items = [['mouse', 'black', 'logitech'], ['mouse', 'white', 'razer'], ['mouse', 'blue', 'corsair'], ['mouse', 'black', 'microsoft'], ['mouse', 'black', 'steelseries']],ruleKey = \"color\",ruleValue = \"black\") == 3\n assert candidate(items = [['shirt', 'white', 'nike'], ['pants', 'blue', 'adidas'], ['shoes', 'black', 'puma'], ['hat', 'white', 'reebok'], ['socks', 'blue', 'nike']],ruleKey = \"color\",ruleValue = \"blue\") == 2\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'red', 'ducati'], ['motorcycle', 'red', 'harley_davidson'], ['scooter', 'red', 'vespa'], ['convertible', 'red', 'porsche']],ruleKey = \"color\",ruleValue = \"red\") == 5\n assert candidate(items = [['couch', 'brown', 'sofa'], ['chair', 'black', 'office'], ['table', 'brown', 'dining'], ['lamp', 'black', 'reading'], ['cabinet', 'brown', 'kitchen']],ruleKey = \"color\",ruleValue = \"brown\") == 3\n assert candidate(items = [['keyboard', 'black', 'logitech'], ['keyboard', 'white', 'razer'], ['keyboard', 'blue', 'corsair'], ['keyboard', 'black', 'microsoft'], ['keyboard', 'black', 'filco']],ruleKey = \"type\",ruleValue = \"keyboard\") == 5\n assert candidate(items = [['shirt', 'blue', 'nike'], ['pants', 'blue', 'adidas'], ['shoes', 'black', 'reebok'], ['hat', 'red', 'nike'], ['jacket', 'blue', 'puma'], ['watch', 'silver', 'rolex'], ['belt', 'brown', 'gucci']],ruleKey = \"name\",ruleValue = \"nike\") == 2\n assert candidate(items = [['laptop', 'black', 'dell'], ['laptop', 'gray', 'hp'], ['desktop', 'black', 'asus'], ['monitor', 'black', 'dell'], ['laptop', 'silver', 'lenovo']],ruleKey = \"type\",ruleValue = \"laptop\") == 3\n assert candidate(items = [['shirt', 'blue', 'tshirt'], ['jeans', 'blue', 'levis'], ['shirt', 'green', 'polo'], ['shorts', 'blue', 'nike'], ['pants', 'blue', 'adidas']],ruleKey = \"color\",ruleValue = \"blue\") == 4\n assert candidate(items = [['camera', 'black', 'canon'], ['smartphone', 'white', 'iphone'], ['tablet', 'gold', 'ipad'], ['smartwatch', 'black', 'applewatch'], ['laptop', 'silver', 'macbook']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['furniture', 'brown', 'table'], ['furniture', 'white', 'sofa'], ['furniture', 'brown', 'chair'], ['furniture', 'black', 'cabinet'], ['furniture', 'white', 'lamp'], ['furniture', 'brown', 'dresser']],ruleKey = \"color\",ruleValue = \"brown\") == 3\n assert candidate(items = [['computer', 'black', 'macbook'], ['smartwatch', 'silver', 'apple'], ['tablet', 'white', 'samsung'], ['laptop', 'blue', 'dell'], ['desktop', 'black', 'asus'], ['computer', 'silver', 'lenovo'], ['smartwatch', 'white', 'fitbit'], ['tablet', 'black', 'xiaomi']],ruleKey = \"color\",ruleValue = \"white\") == 2\n assert candidate(items = [['camera', 'black', 'canon'], ['camera', 'silver', 'nikon'], ['lens', 'black', 'canon'], ['camera', 'white', 'sony'], ['tripod', 'gray', 'benro'], ['camera', 'black', 'fujifilm']],ruleKey = \"brand\",ruleValue = \"canon\") == 2\n assert candidate(items = [['book', 'green', 'encyclopedia'], ['book', 'red', 'dictionary'], ['book', 'blue', 'novel'], ['book', 'green', 'textbook'], ['book', 'red', 'guide']],ruleKey = \"color\",ruleValue = \"green\") == 2\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini'], ['bicycle', 'black', 'trek'], ['motorcycle', 'green', 'harley']],ruleKey = \"color\",ruleValue = \"red\") == 2\n assert candidate(items = [['headphones', 'black', 'sony'], ['headphones', 'black', 'apple'], ['headphones', 'black', 'sennheiser'], ['headphones', 'black', 'bose'], ['headphones', 'black', 'jaybird']],ruleKey = \"color\",ruleValue = \"black\") == 5\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini'], ['truck', 'black', 'ford'], ['bicycle', 'green', 'giant']],ruleKey = \"color\",ruleValue = \"red\") == 2\n assert candidate(items = [['toy', 'red', 'car'], ['toy', 'blue', 'doll'], ['toy', 'red', 'truck'], ['toy', 'yellow', 'balloon'], ['toy', 'blue', 'teddybear'], ['toy', 'red', 'firetruck']],ruleKey = \"type\",ruleValue = \"toy\") == 6\n assert candidate(items = [['camera', 'black', 'nikon'], ['phone', 'black', 'iphone'], ['tablet', 'black', 'ipad'], ['smartwatch', 'black', 'applewatch'], ['laptop', 'black', 'macbook']],ruleKey = \"color\",ruleValue = \"black\") == 5\n assert candidate(items = [['sneakers', 'white', 'nike'], ['tshirt', 'blue', 'adidas'], ['jeans', 'black', 'puma'], ['hat', 'red', 'nike'], ['pants', 'blue', 'reebok']],ruleKey = \"name\",ruleValue = \"nike\") == 2\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini'], ['bike', 'red', 'ducati'], ['car', 'blue', 'toyota'], ['bike', 'white', 'honda'], ['car', 'red', 'mustang'], ['bike', 'black', 'ktm']],ruleKey = \"type\",ruleValue = \"bike\") == 4\n assert candidate(items = [['computer', 'black', 'macbook'], ['smartwatch', 'silver', 'apple'], ['tablet', 'white', 'samsung'], ['laptop', 'blue', 'dell'], ['desktop', 'black', 'asus']],ruleKey = \"type\",ruleValue = \"computer\") == 1\n assert candidate(items = [['monitor', 'black', 'asus'], ['monitor', 'white', 'dell'], ['monitor', 'blue', 'benq'], ['monitor', 'silver', 'acer'], ['monitor', 'black', 'lg']],ruleKey = \"type\",ruleValue = \"monitor\") == 5\n assert candidate(items = [['smartphone', 'black', 'samsung'], ['smartphone', 'blue', 'iphone'], ['smartphone', 'black', 'google'], ['smartphone', 'red', 'oneplus'], ['smartphone', 'black', 'zte']],ruleKey = \"color\",ruleValue = \"black\") == 3\n assert candidate(items = [['shirt', 'black', 'nike'], ['jeans', 'blue', 'levis'], ['jacket', 'brown', 'adidas'], ['shoes', 'white', 'nike'], ['hat', 'black', 'nike'], ['socks', 'blue', 'addidas'], ['gloves', 'brown', 'adidas'], ['shorts', 'white', 'levis']],ruleKey = \"color\",ruleValue = \"black\") == 2\n assert candidate(items = [['laptop', 'black', 'dell'], ['smartphone', 'black', 'samsung'], ['tablet', 'silver', 'ipad'], ['smartphone', 'blue', 'huawei'], ['laptop', 'red', 'macbook']],ruleKey = \"type\",ruleValue = \"smartphone\") == 2\n assert candidate(items = [['phone', 'blue', 'pixel'], ['computer', 'silver', 'lenovo'], ['phone', 'gold', 'iphone'], ['phone', 'black', 'samsung'], ['laptop', 'gray', 'hp'], ['tablet', 'silver', 'ipad']],ruleKey = \"type\",ruleValue = \"phone\") == 3\n assert candidate(items = [['laptop', 'black', 'dell'], ['laptop', 'gray', 'hp'], ['desktop', 'black', 'asus'], ['laptop', 'black', 'lenovo'], ['desktop', 'black', 'acer']],ruleKey = \"color\",ruleValue = \"black\") == 4\n assert candidate(items = [['car', 'red', 'ferrari'], ['bike', 'blue', 'yamaha'], ['car', 'red', 'lamborghini'], ['truck', 'white', 'ford'], ['car', 'black', 'tesla']],ruleKey = \"name\",ruleValue = \"tesla\") == 1\n assert candidate(items = [['shirt', 'blue', 'tshirt'], ['jeans', 'blue', 'levis'], ['shirt', 'green', 'polo'], ['shorts', 'blue', 'nike'], ['pants', 'blue', 'adidas'], ['shirt', 'blue', 'reebok'], ['shirt', 'blue', 'puma']],ruleKey = \"name\",ruleValue = \"blue\") == 0\n assert candidate(items = [['tv', 'black', 'samsung'], ['fridge', 'white', 'lg'], ['microwave', 'black', 'whirlpool'], ['stove', 'black', 'bosch']],ruleKey = \"color\",ruleValue = \"black\") == 3\n assert candidate(items = [['vehicle', 'red', 'ferrari'], ['vehicle', 'blue', 'lamborghini'], ['vehicle', 'red', 'porsche'], ['vehicle', 'black', 'ferrari'], ['vehicle', 'red', 'mustang']],ruleKey = \"name\",ruleValue = \"ferrari\") == 2\n assert candidate(items = [['shirt', 'blue', 'nike'], ['pants', 'blue', 'adidas'], ['hat', 'blue', 'puma'], ['socks', 'green', 'reebok'], ['jacket', 'blue', 'the north face']],ruleKey = \"color\",ruleValue = \"blue\") == 4\n assert candidate(items = [['bed', 'wood', 'ikea'], ['sofa', 'leather', 'furniture_king'], ['chair', 'plastic', 'home_decor'], ['lamp', 'metal', 'ikea'], ['table', 'glass', 'ikea']],ruleKey = \"brand\",ruleValue = \"ikea\") == 3\n assert candidate(items = [['phone', 'blue', 'pixel'], ['phone', 'blue', 'galaxy'], ['phone', 'blue', 'nokia'], ['phone', 'blue', 'oneplus'], ['phone', 'blue', 'google'], ['phone', 'blue', 'xiaomi'], ['phone', 'blue', 'htc']],ruleKey = \"name\",ruleValue = \"google\") == 1\n assert candidate(items = [['smartwatch', 'silver', 'apple'], ['smartwatch', 'gold', 'rolex'], ['bracelet', 'silver', 'tissot'], ['pendant', 'gold', 'omega'], ['bracelet', 'silver', 'casio']],ruleKey = \"name\",ruleValue = \"silver\") == 0\n"}, "metadata": {"canonical_parameter_names": ["items", "ruleKey", "ruleValue"], "leetcode_dataset_entry_point": "Solution().countMatches", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countMatches(vector>& items, string ruleKey, string ruleValue) {", "container": "Solution", "callable": "countMatches", "parameters": [{"name": "items", "type": "vector>&"}, {"name": "ruleKey", "type": "string"}, {"name": "ruleValue", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1774, "task_id": "closest-dessert-cost", "difficulty": "Medium", "problem_description": "You would like to make dessert and are preparing to buy the ingredients. You have n ice cream base flavors and m types of toppings to choose from. You must follow these rules when making your dessert:\n\nThere must be exactly one ice cream base.\nYou can add one or more types of topping or have no toppings at all.\nThere are at most two of each type of topping.\n\nYou are given three inputs:\n\nbaseCosts, an integer array of length n, where each baseCosts[i] represents the price of the ith ice cream base flavor.\ntoppingCosts, an integer array of length m, where each toppingCosts[i] is the price of one of the ith topping.\ntarget, an integer representing your target price for dessert.\n\nYou want to make a dessert with a total cost as close to target as possible.\nReturn the closest possible cost of the dessert to target. If there are multiple, return the lower one.\n \nExample 1:\n\nInput: baseCosts = [1,7], toppingCosts = [3,4], target = 10\nOutput: 10\nExplanation: Consider the following combination (all 0-indexed):\n- Choose base 1: cost 7\n- Take 1 of topping 0: cost 1 x 3 = 3\n- Take 0 of topping 1: cost 0 x 4 = 0\nTotal: 7 + 3 + 0 = 10.\n\nExample 2:\n\nInput: baseCosts = [2,3], toppingCosts = [4,5,100], target = 18\nOutput: 17\nExplanation: Consider the following combination (all 0-indexed):\n- Choose base 1: cost 3\n- Take 1 of topping 0: cost 1 x 4 = 4\n- Take 2 of topping 1: cost 2 x 5 = 10\n- Take 0 of topping 2: cost 0 x 100 = 0\nTotal: 3 + 4 + 10 + 0 = 17. You cannot make a dessert with a total cost of 18.\n\nExample 3:\n\nInput: baseCosts = [3,10], toppingCosts = [2,5], target = 9\nOutput: 8\nExplanation: It is possible to make desserts with cost 8 and 10. Return 8 as it is the lower cost.\n\n \nConstraints:\n\nn == baseCosts.length\nm == toppingCosts.length\n1 <= n, m <= 10\n1 <= baseCosts[i], toppingCosts[i] <= 104\n1 <= target <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(baseCosts = [10, 20],toppingCosts = [1, 2, 3],target = 15) == 15\n assert candidate(baseCosts = [5, 9],toppingCosts = [2, 3, 7],target = 15) == 15\n assert candidate(baseCosts = [1, 7],toppingCosts = [3, 4],target = 10) == 10\n assert candidate(baseCosts = [10, 20, 30],toppingCosts = [1, 2, 3, 4, 5],target = 25) == 25\n assert candidate(baseCosts = [4, 8],toppingCosts = [1, 3],target = 15) == 15\n assert candidate(baseCosts = [5],toppingCosts = [1, 2, 3],target = 8) == 8\n assert candidate(baseCosts = [4],toppingCosts = [1, 2, 3],target = 8) == 8\n assert candidate(baseCosts = [10, 20],toppingCosts = [5, 15, 25],target = 50) == 50\n assert candidate(baseCosts = [1],toppingCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 10) == 10\n assert candidate(baseCosts = [5, 8],toppingCosts = [6, 1, 2],target = 20) == 20\n assert candidate(baseCosts = [10],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 20) == 20\n assert candidate(baseCosts = [2, 3],toppingCosts = [4, 5, 100],target = 18) == 17\n assert candidate(baseCosts = [3, 10],toppingCosts = [2, 5],target = 9) == 8\n assert candidate(baseCosts = [4, 8, 12, 16, 20],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 30) == 30\n assert candidate(baseCosts = [50, 75, 100, 125],toppingCosts = [10, 15, 20, 25, 30],target = 300) == 300\n assert candidate(baseCosts = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],toppingCosts = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 1023) == 1023\n assert candidate(baseCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 1500) == 1500\n assert candidate(baseCosts = [1234, 5678, 9101],toppingCosts = [111, 222, 333, 444, 555, 666],target = 10000) == 10007\n assert candidate(baseCosts = [5000, 7500, 10000],toppingCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 15000) == 15000\n assert candidate(baseCosts = [1000, 2000, 3000, 4000, 5000],toppingCosts = [50, 100, 150, 200, 250, 300, 350],target = 10000) == 7800\n assert candidate(baseCosts = [15, 25, 35, 45],toppingCosts = [2, 4, 6, 8, 10],target = 50) == 49\n assert candidate(baseCosts = [100, 200, 300, 400],toppingCosts = [10, 20, 30, 40, 50],target = 500) == 500\n assert candidate(baseCosts = [123, 456, 789],toppingCosts = [987, 654, 321, 654, 321, 987],target = 1000) == 1086\n assert candidate(baseCosts = [10, 20, 30, 40, 50],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 150) == 150\n assert candidate(baseCosts = [1000, 2000, 3000, 4000, 5000],toppingCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 7500) == 7500\n assert candidate(baseCosts = [1, 5, 10, 15],toppingCosts = [3, 6, 9, 12],target = 30) == 30\n assert candidate(baseCosts = [7, 14, 21],toppingCosts = [3, 6, 9, 12, 15, 18],target = 30) == 30\n assert candidate(baseCosts = [500, 1000, 1500],toppingCosts = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],target = 3000) == 3000\n assert candidate(baseCosts = [1000, 2000],toppingCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 5000) == 5000\n assert candidate(baseCosts = [8, 16, 24],toppingCosts = [2, 4, 6, 8, 10, 12, 14, 16],target = 35) == 34\n assert candidate(baseCosts = [1000, 2000, 3000, 4000, 5000],toppingCosts = [100, 200, 300, 400, 500],target = 12345) == 8000\n assert candidate(baseCosts = [3, 6, 9, 12, 15],toppingCosts = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 1024) == 1024\n assert candidate(baseCosts = [300, 600, 900],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 1200) == 1200\n assert candidate(baseCosts = [1, 2, 3, 4, 5],toppingCosts = [5, 10, 15, 20, 25],target = 50) == 50\n assert candidate(baseCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 50) == 50\n assert candidate(baseCosts = [100, 200, 300],toppingCosts = [50, 75, 100, 125, 150],target = 600) == 600\n assert candidate(baseCosts = [1, 10000],toppingCosts = [5000, 3000, 2000, 1000, 500, 100],target = 9000) == 9001\n assert candidate(baseCosts = [15, 25, 35],toppingCosts = [5, 7, 11, 13, 17],target = 50) == 50\n assert candidate(baseCosts = [100, 150, 200, 250],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90],target = 750) == 750\n assert candidate(baseCosts = [999, 1999, 2999],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 5000) == 3109\n assert candidate(baseCosts = [1, 1, 1, 1, 1],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 25) == 25\n assert candidate(baseCosts = [150, 250, 350],toppingCosts = [5, 15, 25, 35, 45, 55],target = 400) == 400\n assert candidate(baseCosts = [2000, 4000, 6000],toppingCosts = [100, 200, 300, 400, 500],target = 7000) == 7000\n assert candidate(baseCosts = [1, 10, 100],toppingCosts = [9, 90, 900, 9000],target = 10000) == 10000\n assert candidate(baseCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 1000) == 1000\n assert candidate(baseCosts = [7500, 8000],toppingCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 15000) == 15000\n assert candidate(baseCosts = [15, 25, 35, 45],toppingCosts = [1, 2, 3, 4, 5, 6, 7],target = 30) == 30\n assert candidate(baseCosts = [10, 20, 30],toppingCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 45) == 45\n assert candidate(baseCosts = [1, 1, 1, 1, 1],toppingCosts = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = 100) == 101\n assert candidate(baseCosts = [1000, 2000, 3000, 4000, 5000],toppingCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 10000) == 10000\n assert candidate(baseCosts = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 100) == 100\n assert candidate(baseCosts = [5000, 7000, 9000],toppingCosts = [1000, 2000, 3000, 4000],target = 18000) == 18000\n assert candidate(baseCosts = [500, 250],toppingCosts = [100, 200, 300, 400, 500],target = 1000) == 1000\n assert candidate(baseCosts = [10000],toppingCosts = [10000, 10000, 10000, 10000, 10000],target = 50000) == 50000\n assert candidate(baseCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 500) == 210\n assert candidate(baseCosts = [100, 200, 300],toppingCosts = [10, 20, 30, 40, 50, 60],target = 500) == 500\n assert candidate(baseCosts = [1000, 2000, 3000],toppingCosts = [500, 100, 250, 125, 75],target = 4500) == 4500\n assert candidate(baseCosts = [123, 456, 789],toppingCosts = [11, 22, 33, 44, 55, 66, 77, 88, 99],target = 1000) == 998\n assert candidate(baseCosts = [5, 10, 15, 20, 25],toppingCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 20) == 20\n assert candidate(baseCosts = [9999],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10000) == 10000\n assert candidate(baseCosts = [123, 456, 789],toppingCosts = [987, 654, 321, 123, 456, 789, 100, 200, 300],target = 2000) == 2000\n assert candidate(baseCosts = [500, 501, 502],toppingCosts = [250, 251, 252, 253],target = 1000) == 1000\n assert candidate(baseCosts = [777, 888],toppingCosts = [55, 44, 33, 22, 11, 1, 2, 3, 4, 5],target = 2000) == 1248\n assert candidate(baseCosts = [10, 20, 30, 40, 50],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 25) == 25\n assert candidate(baseCosts = [10, 20, 30, 40, 50],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 50) == 50\n assert candidate(baseCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],toppingCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 10) == 10\n assert candidate(baseCosts = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],toppingCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 30) == 30\n assert candidate(baseCosts = [123, 456, 789],toppingCosts = [11, 22, 33, 44, 55],target = 700) == 698\n assert candidate(baseCosts = [100, 200, 300, 400],toppingCosts = [10, 20, 30, 40, 50, 60],target = 750) == 750\n assert candidate(baseCosts = [100, 200],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 500) == 310\n assert candidate(baseCosts = [1000, 1001, 1002, 1003],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10000) == 1113\n assert candidate(baseCosts = [23, 45, 67, 89, 10],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 200) == 199\n assert candidate(baseCosts = [5, 10, 15, 20],toppingCosts = [1, 3, 5, 7, 9, 11, 13],target = 40) == 40\n assert candidate(baseCosts = [100, 200, 300, 400, 500],toppingCosts = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = 1000) == 1000\n assert candidate(baseCosts = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],toppingCosts = [2, 4, 6, 8, 10],target = 50) == 49\n assert candidate(baseCosts = [100, 200, 300, 400],toppingCosts = [10, 20, 30, 40, 50, 60],target = 1500) == 820\n assert candidate(baseCosts = [100, 200, 300, 400],toppingCosts = [50, 10, 15, 20, 25, 30, 35, 40, 45, 55],target = 1500) == 1050\n assert candidate(baseCosts = [1, 2, 3, 4, 5],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 100) == 101\n assert candidate(baseCosts = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],toppingCosts = [500, 1500, 2500, 3500],target = 7500) == 7500\n assert candidate(baseCosts = [2000, 3000, 4000, 5000],toppingCosts = [50, 100, 150, 200, 250],target = 8500) == 6500\n assert candidate(baseCosts = [50, 100, 150, 200, 250, 300],toppingCosts = [5, 10, 15, 20, 25, 30],target = 750) == 510\n assert candidate(baseCosts = [100, 200],toppingCosts = [50, 25, 10, 5, 1],target = 300) == 300\n assert candidate(baseCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],toppingCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 5000) == 5001\n assert candidate(baseCosts = [1000, 2000, 3000],toppingCosts = [500, 1000, 1500, 2000, 2500],target = 6000) == 6000\n assert candidate(baseCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 50) == 50\n assert candidate(baseCosts = [800, 1600, 2400],toppingCosts = [100, 200, 300, 400, 500, 600],target = 3000) == 3000\n assert candidate(baseCosts = [5000, 10000],toppingCosts = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000],target = 20000) == 20000\n assert candidate(baseCosts = [1000, 2000, 3000],toppingCosts = [500, 100, 250, 150, 200],target = 4500) == 4500\n assert candidate(baseCosts = [4, 8, 12, 16, 20],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 45) == 45\n assert candidate(baseCosts = [1, 2, 3, 4, 5],toppingCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 500) == 501\n assert candidate(baseCosts = [50, 60, 70, 80, 90],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 150) == 150\n assert candidate(baseCosts = [100, 200, 300],toppingCosts = [50, 75, 100, 125, 150],target = 500) == 500\n assert candidate(baseCosts = [5000],toppingCosts = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000],target = 20000) == 20000\n assert candidate(baseCosts = [10, 20],toppingCosts = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],target = 1000) == 1000\n assert candidate(baseCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],toppingCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 500) == 210\n assert candidate(baseCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],toppingCosts = [9999],target = 10000) == 10000\n assert candidate(baseCosts = [5, 10],toppingCosts = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = 15) == 15\n assert candidate(baseCosts = [500, 1000, 1500],toppingCosts = [5, 10, 15, 20, 25, 30, 35, 40],target = 2000) == 1860\n assert candidate(baseCosts = [999, 1000],toppingCosts = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 4000) == 4000\n"}, "metadata": {"canonical_parameter_names": ["baseCosts", "toppingCosts", "target"], "leetcode_dataset_entry_point": "Solution().closestCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int closestCost(vector& baseCosts, vector& toppingCosts, int target) {", "container": "Solution", "callable": "closestCost", "parameters": [{"name": "baseCosts", "type": "vector&"}, {"name": "toppingCosts", "type": "vector&"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1775, "task_id": "equal-sum-arrays-with-minimum-number-of-operations", "difficulty": "Medium", "problem_description": "You are given two arrays of integers nums1 and nums2, possibly of different lengths. The values in the arrays are between 1 and 6, inclusive.\nIn one operation, you can change any integer's value in any of the arrays to any value between 1 and 6, inclusive.\nReturn the minimum number of operations required to make the sum of values in nums1 equal to the sum of values in nums2. Return -1​​​​​ if it is not possible to make the sum of the two arrays equal.\n \nExample 1:\n\nInput: nums1 = [1,2,3,4,5,6], nums2 = [1,1,2,2,2,2]\nOutput: 3\nExplanation: You can make the sums of nums1 and nums2 equal with 3 operations. All indices are 0-indexed.\n- Change nums2[0] to 6. nums1 = [1,2,3,4,5,6], nums2 = [6,1,2,2,2,2].\n- Change nums1[5] to 1. nums1 = [1,2,3,4,5,1], nums2 = [6,1,2,2,2,2].\n- Change nums1[2] to 2. nums1 = [1,2,2,4,5,1], nums2 = [6,1,2,2,2,2].\n\nExample 2:\n\nInput: nums1 = [1,1,1,1,1,1,1], nums2 = [6]\nOutput: -1\nExplanation: There is no way to decrease the sum of nums1 or to increase the sum of nums2 to make them equal.\n\nExample 3:\n\nInput: nums1 = [6,6], nums2 = [1]\nOutput: 3\nExplanation: You can make the sums of nums1 and nums2 equal with 3 operations. All indices are 0-indexed. \n- Change nums1[0] to 2. nums1 = [2,6], nums2 = [1].\n- Change nums1[1] to 2. nums1 = [2,2], nums2 = [1].\n- Change nums2[0] to 4. nums1 = [2,2], nums2 = [4].\n\n \nConstraints:\n\n1 <= nums1.length, nums2.length <= 105\n1 <= nums1[i], nums2[i] <= 6\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6]) == 0\n assert candidate(nums1 = [3, 3, 3, 3],nums2 = [2, 2, 2, 2]) == 1\n assert candidate(nums1 = [1, 1],nums2 = [6, 6]) == 2\n assert candidate(nums1 = [6, 6, 6],nums2 = [1, 1]) == 4\n assert candidate(nums1 = [1, 1, 2],nums2 = [6, 6, 6]) == 3\n assert candidate(nums1 = [1, 1],nums2 = [6, 6, 6]) == 4\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums1 = [1, 2],nums2 = [5, 6]) == 2\n assert candidate(nums1 = [6, 6, 6],nums2 = [1, 1, 1]) == 3\n assert candidate(nums1 = [3, 3, 3],nums2 = [3, 3, 3]) == 0\n assert candidate(nums1 = [2, 3, 4],nums2 = [5, 5, 5]) == 2\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1],nums2 = [6]) == -1\n assert candidate(nums1 = [6],nums2 = [1]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [1, 1, 2, 2, 2, 2]) == 3\n assert candidate(nums1 = [3, 3, 3],nums2 = [2, 2, 2]) == 1\n assert candidate(nums1 = [6, 6],nums2 = [1]) == 3\n assert candidate(nums1 = [2, 2, 2],nums2 = [5, 5, 5]) == 3\n assert candidate(nums1 = [3, 3, 3],nums2 = [2, 2, 2, 2]) == 1\n assert candidate(nums1 = [1],nums2 = [6]) == 1\n assert candidate(nums1 = [1, 1, 1],nums2 = [6, 6, 6]) == 3\n assert candidate(nums1 = [3],nums2 = [3]) == 0\n assert candidate(nums1 = [1, 3, 5],nums2 = [2, 4, 6]) == 1\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6]) == 2\n assert candidate(nums1 = [5, 5],nums2 = [1, 1]) == 2\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [1, 1, 1, 1]) == 4\n assert candidate(nums1 = [3, 3, 3, 3],nums2 = [1, 6, 1, 6]) == 1\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 6\n assert candidate(nums1 = [1, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 2]) == 5\n assert candidate(nums1 = [6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6],nums2 = [1, 2, 3, 4, 5, 6]) == 3\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums1 = [1, 6, 1, 6, 1, 6],nums2 = [6, 1, 6, 1, 6, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],nums2 = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == 1\n assert candidate(nums1 = [1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5],nums2 = [6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 2]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 58\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums1 = [4, 5, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 8\n assert candidate(nums1 = [1, 3, 5, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 1\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6]) == 6\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums1 = [1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == -1\n assert candidate(nums1 = [2, 3, 4, 5, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 9\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [2, 3, 4, 5, 6]) == 4\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1],nums2 = [6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6]) == 5\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5]) == 11\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 6\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 5\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 18\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6]) == 6\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 7\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 12\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 0\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2],nums2 = [2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3]) == 1\n assert candidate(nums1 = [1, 3, 5, 1, 3, 5, 1, 3, 5],nums2 = [2, 4, 6, 2, 4, 6, 2, 4, 6]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(nums1 = [1, 6, 1, 6, 1, 6],nums2 = [2, 5, 2, 5, 2, 5]) == 0\n assert candidate(nums1 = [6, 5, 4, 3, 2, 1, 1, 2, 3, 4],nums2 = [1, 2, 3, 4, 5, 6, 6, 5, 4, 3]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 7\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [6, 6, 6, 6, 1, 1, 1, 1]) == 1\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 10\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [1, 2, 3, 4, 5, 6, 6, 6, 6]) == 3\n assert candidate(nums1 = [2, 3, 4, 5, 6],nums2 = [1, 1, 1, 1]) == 4\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 131\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5]) == 2\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3],nums2 = [2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 6, 6, 6],nums2 = [3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1],nums2 = [6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 15\n assert candidate(nums1 = [1, 6, 1, 6, 1, 6, 1, 6, 1, 6],nums2 = [6, 1, 6, 1, 6, 1, 6, 1, 6, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 6]) == 2\n assert candidate(nums1 = [1, 1, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 9\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 30\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 28\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 14\n assert candidate(nums1 = [2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 3, 4, 5, 6]) == 3\n assert candidate(nums1 = [5, 5, 5, 5, 5],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(nums1 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 11\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 8\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6]) == 5\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6]) == 4\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1],nums2 = [6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6]) == 0\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 3\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [3, 3, 3, 3, 3, 3]) == 1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 33\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 21\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3],nums2 = [4, 4, 4, 4, 4, 4, 4]) == 3\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [2, 3, 4, 5, 6, 1]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 15\n assert candidate(nums1 = [4, 4, 4, 4, 4, 4, 4],nums2 = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums1 = [6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(nums1 = [4, 4, 4, 4, 4, 4],nums2 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(nums1 = [6, 4, 2, 6, 4, 2, 6, 4, 2],nums2 = [1, 3, 5, 1, 3, 5, 1, 3, 5]) == 2\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [5, 5, 5, 5, 5, 5]) == 3\n assert candidate(nums1 = [1, 3, 5, 1, 3, 5, 1, 3, 5, 1, 3, 5],nums2 = [2, 4, 6, 2, 4, 6, 2, 4, 6, 2, 4, 6]) == 3\n assert candidate(nums1 = [2, 3, 4],nums2 = [1, 5, 6, 6]) == 2\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [6, 6, 6, 6, 6]) == 2\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [6, 6, 6, 6, 6, 6]) == 5\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 15\n assert candidate(nums1 = [1, 3, 5],nums2 = [2, 4, 6]) == 1\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 7\n assert candidate(nums1 = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 20\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],nums2 = [6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5],nums2 = [1, 1, 1, 1, 1, 1, 1]) == 6\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 8\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5],nums2 = [1, 1, 1, 1, 1, 1]) == 5\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6, 6, 6, 6, 6, 6, 6]) == 7\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [4, 4, 5, 5, 6, 6]) == 4\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [6]) == -1\n assert candidate(nums1 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 8\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [4, 5, 6, 6, 6, 6, 6]) == 5\n assert candidate(nums1 = [6, 6, 6, 6, 6, 6],nums2 = [1, 1, 1, 1, 1, 1]) == 6\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minOperations(vector& nums1, vector& nums2) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums1", "type": "vector&"}, {"name": "nums2", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1776, "task_id": "car-fleet-ii", "difficulty": "Hard", "problem_description": "There are n cars traveling at different speeds in the same direction along a one-lane road. You are given an array cars of length n, where cars[i] = [positioni, speedi] represents:\n\npositioni is the distance between the ith car and the beginning of the road in meters. It is guaranteed that positioni < positioni+1.\nspeedi is the initial speed of the ith car in meters per second.\n\nFor simplicity, cars can be considered as points moving along the number line. Two cars collide when they occupy the same position. Once a car collides with another car, they unite and form a single car fleet. The cars in the formed fleet will have the same position and the same speed, which is the initial speed of the slowest car in the fleet.\nReturn an array answer, where answer[i] is the time, in seconds, at which the ith car collides with the next car, or -1 if the car does not collide with the next car. Answers within 10-5 of the actual answers are accepted.\n \nExample 1:\n\nInput: cars = [[1,2],[2,1],[4,3],[7,2]]\nOutput: [1.00000,-1.00000,3.00000,-1.00000]\nExplanation: After exactly one second, the first car will collide with the second car, and form a car fleet with speed 1 m/s. After exactly 3 seconds, the third car will collide with the fourth car, and form a car fleet with speed 2 m/s.\n\nExample 2:\n\nInput: cars = [[3,4],[5,4],[6,3],[9,1]]\nOutput: [2.00000,1.00000,1.50000,-1.00000]\n\n \nConstraints:\n\n1 <= cars.length <= 105\n1 <= positioni, speedi <= 106\npositioni < positioni+1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(cars = [[1, 4], [2, 3], [3, 2], [4, 1]]) == [1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[1, 5], [3, 2], [5, 1]]) == [0.6666666666666666, 2.0, -1]\n assert candidate(cars = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [-1, -1, -1, -1, -1]\n assert candidate(cars = [[3, 4], [5, 4], [6, 3], [9, 1]]) == [2.0, 1.0, 1.5, -1]\n assert candidate(cars = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == [-1, -1, -1, -1, -1]\n assert candidate(cars = [[5, 10], [10, 5], [15, 2], [20, 1]]) == [1.0, 1.6666666666666667, 5.0, -1]\n assert candidate(cars = [[1, 10], [3, 8], [5, 6], [7, 4], [9, 2]]) == [1.0, 1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]]) == [-1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 2], [2, 1], [4, 3], [7, 2]]) == [1.0, -1, 3.0, -1]\n assert candidate(cars = [[10, 10], [8, 5], [6, 3], [4, 2], [2, 1]]) == [-0.8888888888888888, -1.5, -2.0, -2.0, -1]\n assert candidate(cars = [[10, 2], [20, 1], [30, 3], [40, 2]]) == [10.0, -1, 10.0, -1]\n assert candidate(cars = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[5, 10], [15, 8], [20, 7], [25, 6], [30, 5]]) == [5.0, 5.0, 5.0, 5.0, -1]\n assert candidate(cars = [[10, 5], [20, 4], [30, 3], [40, 2], [50, 1]]) == [10.0, 10.0, 10.0, 10.0, -1]\n assert candidate(cars = [[10, 5], [15, 3], [20, 2], [25, 1]]) == [2.5, 5.0, 5.0, -1]\n assert candidate(cars = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [1.0, 1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[1, 10], [3, 6], [5, 5], [7, 4]]) == [0.5, 2.0, 2.0, -1]\n assert candidate(cars = [[1, 20], [2, 18], [3, 16], [4, 14], [5, 12], [6, 10], [7, 8], [8, 6], [9, 4], [10, 2]]) == [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -1]\n assert candidate(cars = [[2, 9], [5, 7], [8, 6], [11, 4], [14, 2], [17, 1]]) == [1.5, 1.8, 1.5, 1.5, 3.0, -1]\n assert candidate(cars = [[10, 5], [20, 15], [30, 10], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45]]) == [-1, 2.0, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[10, 90], [20, 80], [30, 70], [40, 60], [50, 50], [60, 40], [70, 30], [80, 20], [90, 10], [100, 1]]) == [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.1111111111111112, -1]\n assert candidate(cars = [[1, 100], [10, 90], [20, 80], [30, 70], [40, 60], [50, 50], [60, 40], [70, 30], [80, 20], [90, 10]]) == [0.9, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[50, 100], [150, 90], [250, 80], [350, 70], [450, 60], [550, 50], [650, 40], [750, 30], [850, 20], [950, 10]]) == [10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, -1]\n assert candidate(cars = [[1, 100], [5, 80], [10, 60], [15, 40], [20, 20], [25, 0], [30, 20], [35, 40], [40, 60], [45, 80]]) == [0.2, 0.25, 0.25, 0.25, 0.25, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 25], [3, 24], [5, 23], [7, 22], [9, 21], [11, 20], [13, 19], [15, 18], [17, 17], [19, 16], [21, 15]]) == [2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1]\n assert candidate(cars = [[1, 10], [10, 9], [19, 8], [28, 7], [37, 6], [46, 5], [55, 4], [64, 3], [73, 2], [82, 1]]) == [9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, 9.0, -1]\n assert candidate(cars = [[1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11], [11, 10], [12, 9], [13, 8], [14, 7], [15, 6], [16, 5], [17, 4], [18, 3], [19, 2], [20, 1]]) == [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [12, 10], [14, 9], [16, 8], [18, 7], [20, 6], [22, 5], [24, 4], [26, 3], [28, 2], [30, 1]]) == [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1]\n assert candidate(cars = [[1, 100], [2, 90], [3, 80], [4, 70], [5, 60], [6, 50], [7, 40], [8, 30], [9, 20], [10, 10]]) == [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, -1]\n assert candidate(cars = [[1, 50], [10, 45], [20, 40], [30, 35], [40, 30], [50, 25], [60, 20], [70, 15], [80, 10], [90, 5]]) == [1.8, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1]\n assert candidate(cars = [[1, 5], [2, 10], [3, 15], [4, 20], [5, 25], [6, 30], [7, 35], [8, 40], [9, 45], [10, 50]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 10], [4, 8], [7, 6], [10, 4], [13, 2], [16, 1]]) == [1.5, 1.5, 1.5, 1.5, 3.0, -1]\n assert candidate(cars = [[1, 8], [3, 7], [5, 6], [7, 5], [9, 4], [11, 3], [13, 2], [15, 1]]) == [2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1]\n assert candidate(cars = [[1, 30], [4, 20], [7, 15], [10, 10], [13, 8], [16, 6], [19, 4], [22, 2], [25, 1]]) == [0.3, 0.6, 0.6, 1.5, 1.5, 1.5, 1.5, 3.0, -1]\n assert candidate(cars = [[1, 100], [10, 95], [20, 90], [30, 85], [40, 80], [50, 75], [60, 70], [70, 65], [80, 60], [90, 55]]) == [1.8, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1]\n assert candidate(cars = [[1, 15], [2, 25], [3, 35], [4, 45], [5, 55], [6, 65], [7, 75], [8, 85], [9, 95], [10, 105]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 5], [4, 4], [7, 3], [10, 2], [13, 1]]) == [3.0, 3.0, 3.0, 3.0, -1]\n assert candidate(cars = [[1, 100], [20, 50], [30, 30], [40, 20], [50, 10], [60, 1]]) == [0.38, 0.5, 1.0, 1.0, 1.1111111111111112, -1]\n assert candidate(cars = [[1, 15], [2, 10], [4, 5], [6, 4], [8, 3], [10, 2], [12, 1]]) == [0.2, 0.4, 2.0, 2.0, 2.0, 2.0, -1]\n assert candidate(cars = [[1, 3], [2, 2], [3, 1], [4, 4], [5, 5], [6, 6]]) == [1.0, 1.0, -1, -1, -1, -1]\n assert candidate(cars = [[1, 200], [11, 180], [21, 160], [31, 140], [41, 120], [51, 100], [61, 80], [71, 60], [81, 40], [91, 20]]) == [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -1]\n assert candidate(cars = [[1, 5], [3, 4], [5, 3], [7, 2], [9, 1], [11, 10], [13, 9], [15, 8], [17, 7], [19, 6]]) == [2.0, 2.0, 2.0, 2.0, -1, 2.0, 2.0, 2.0, 2.0, -1]\n assert candidate(cars = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 9], [2, 8], [3, 7], [5, 6], [8, 5], [13, 4], [20, 3], [28, 2], [37, 1], [46, 0]]) == [1.0, 1.0, 2.0, 3.0, 5.0, 7.0, 8.0, 9.0, 9.0, -1]\n assert candidate(cars = [[1, 20], [4, 18], [7, 16], [10, 14], [13, 12], [16, 10], [19, 8], [22, 6], [25, 4], [28, 2], [31, 1]]) == [1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 3.0, -1]\n assert candidate(cars = [[1, 100000], [2, 99000], [3, 98000], [4, 97000], [5, 96000], [6, 95000], [7, 94000], [8, 93000], [9, 92000], [10, 91000]]) == [0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, 0.001, -1]\n assert candidate(cars = [[1, 100], [5, 80], [10, 60], [15, 40], [20, 20], [25, 10]]) == [0.2, 0.25, 0.25, 0.25, 0.5, -1]\n assert candidate(cars = [[1, 30], [2, 25], [3, 20], [5, 15], [8, 10], [13, 5], [20, 2], [28, 1]]) == [0.2, 0.2, 0.4, 0.6, 1.0, 2.3333333333333335, 8.0, -1]\n assert candidate(cars = [[1, 12], [3, 10], [5, 8], [7, 6], [9, 4], [11, 2]]) == [1.0, 1.0, 1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 50], [2, 49], [3, 48], [4, 47], [5, 46], [6, 45], [7, 44], [8, 43], [9, 42], [10, 41]]) == [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[1, 5], [6, 10], [11, 5], [16, 10], [21, 5], [26, 10], [31, 5], [36, 10], [41, 5], [46, 10]]) == [-1, 1.0, -1, 1.0, -1, 1.0, -1, 1.0, -1, -1]\n assert candidate(cars = [[1, 200], [2, 190], [3, 180], [4, 170], [5, 160], [6, 150], [7, 140], [8, 130], [9, 120], [10, 110]]) == [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, -1]\n assert candidate(cars = [[1, 6], [3, 5], [5, 4], [7, 3], [9, 2], [11, 1], [13, 5], [15, 4], [17, 3], [19, 2], [21, 1]]) == [2.0, 2.0, 2.0, 2.0, 2.0, -1, 2.0, 2.0, 2.0, 2.0, -1]\n assert candidate(cars = [[1, 15], [5, 14], [10, 13], [15, 12], [20, 11], [25, 10], [30, 9], [35, 8], [40, 7], [45, 6], [50, 5], [55, 4], [60, 3], [65, 2], [70, 1]]) == [4.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, -1]\n assert candidate(cars = [[1, 10], [5, 10], [10, 10], [15, 10], [20, 10], [25, 10], [30, 10], [35, 10], [40, 10], [45, 10]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 3], [5, 2], [10, 1], [15, 4], [20, 3], [25, 2], [30, 1]]) == [4.0, 5.0, -1, 5.0, 5.0, 5.0, -1]\n assert candidate(cars = [[1, 10], [2, 9], [5, 8], [8, 7], [13, 6], [18, 5], [24, 4], [30, 3], [36, 2], [42, 1]]) == [1.0, 3.0, 3.0, 5.0, 5.0, 6.0, 6.0, 6.0, 6.0, -1]\n assert candidate(cars = [[1, 2], [2, 3], [3, 5], [4, 8], [5, 13], [6, 21], [7, 34], [8, 55], [9, 89], [10, 144]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 2], [3, 5], [5, 10], [7, 3], [9, 8], [11, 6], [13, 7], [15, 4]]) == [-1, 2.0, 0.2857142857142857, -1, 1.0, 2.0, 0.6666666666666666, -1]\n assert candidate(cars = [[3, 12], [6, 10], [9, 8], [12, 6], [15, 4], [18, 2], [21, 1]]) == [1.5, 1.5, 1.5, 1.5, 1.5, 3.0, -1]\n assert candidate(cars = [[1, 10], [4, 9], [10, 8], [15, 7], [20, 6], [25, 5], [30, 4], [35, 3], [40, 2], [45, 1]]) == [3.0, 5.125, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, -1]\n assert candidate(cars = [[1, 20], [4, 18], [10, 16], [15, 14], [20, 12], [25, 10], [30, 8], [35, 6], [40, 4], [45, 2]]) == [1.5, 2.5625, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, -1]\n assert candidate(cars = [[1, 1], [10, 2], [20, 3], [30, 4], [40, 5], [50, 6], [60, 7], [70, 8], [80, 9], [90, 10]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 50], [5, 40], [10, 30], [16, 20], [23, 10], [31, 5], [40, 3], [50, 1]]) == [0.4, 0.5, 0.6, 0.7, 1.6, 4.5, 5.0, -1]\n assert candidate(cars = [[1, 1000], [2, 900], [3, 800], [4, 700], [5, 600], [6, 500], [7, 400], [8, 300], [9, 200], [10, 100]]) == [0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, -1]\n assert candidate(cars = [[1, 20], [2, 18], [3, 16], [5, 14], [8, 12], [13, 10], [20, 8], [28, 6], [37, 4], [46, 2]]) == [0.5, 0.5, 1.0, 1.5, 2.5, 3.5, 4.0, 4.5, 4.5, -1]\n assert candidate(cars = [[1, 10], [2, 20], [3, 15], [4, 25], [5, 20], [6, 30], [7, 25], [8, 35], [9, 30], [10, 40]]) == [-1, 0.2, -1, 0.2, -1, 0.2, -1, 0.2, -1, -1]\n assert candidate(cars = [[1, 10], [3, 9], [5, 8], [7, 7], [9, 6], [11, 5], [13, 4], [15, 3], [17, 2], [19, 1], [21, 0.5]]) == [2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 4.0, -1]\n assert candidate(cars = [[10, 10], [20, 9], [30, 8], [40, 7], [50, 6], [60, 5], [70, 4], [80, 3], [90, 2], [100, 1]]) == [10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, -1]\n assert candidate(cars = [[1, 10], [11, 9], [21, 8], [31, 7], [41, 6], [51, 5], [61, 4], [71, 3], [81, 2], [91, 1]]) == [10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, 10.0, -1]\n assert candidate(cars = [[1, 10], [3, 10], [5, 10], [7, 10], [9, 10], [11, 10], [13, 10], [15, 10], [17, 10], [19, 10], [21, 10]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 0.5], [7, 0.25]]) == [1.0, 1.0, 1.0, 1.0, 2.0, 4.0, -1]\n assert candidate(cars = [[1, 30], [2, 29], [3, 28], [4, 27], [5, 26], [6, 25], [7, 24], [8, 23], [9, 22], [10, 21]]) == [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[10, 10], [25, 9], [40, 8], [55, 7], [70, 6], [85, 5], [100, 4], [115, 3], [130, 2], [145, 1]]) == [15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, 15.0, -1]\n assert candidate(cars = [[1, 2], [5, 4], [9, 6], [13, 8], [17, 10], [21, 12], [25, 14], [29, 16], [33, 18], [37, 20]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 1], [100000, 100000], [200000, 99999], [300000, 99998], [400000, 99997], [500000, 99996]]) == [-1, 100000.0, 100000.0, 100000.0, 100000.0, -1]\n assert candidate(cars = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996], [6, 995], [7, 994], [8, 993], [9, 992], [10, 991]]) == [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[1, 50], [3, 45], [6, 40], [10, 35], [15, 30], [21, 25], [28, 20], [36, 15], [45, 10], [55, 5]]) == [0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, -1]\n assert candidate(cars = [[1, 100], [5, 90], [10, 80], [15, 70], [20, 60], [25, 50], [30, 40], [35, 30], [40, 20], [45, 10]]) == [0.4, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -1]\n assert candidate(cars = [[1, 10], [11, 9.99999], [21, 9.99998], [31, 9.99997], [41, 9.99996], [51, 9.99995], [61, 9.99994], [71, 9.99993], [81, 9.99992], [91, 9.99991]]) == [999999.9999786458, 999999.9999490399, 999999.999860222, 1000000.0000023306, 999999.9999934488, 999999.9999786458, 999999.9999490399, 999999.999860222, 1000000.0000378577, -1]\n assert candidate(cars = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [11, 90], [12, 89], [13, 88], [14, 87], [15, 86], [16, 85], [17, 84], [18, 83], [19, 82], [20, 81]]) == [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[1, 15], [5, 10], [9, 7], [13, 4], [17, 2], [21, 1], [25, 3], [29, 6], [33, 9], [37, 12]]) == [0.8, 1.3333333333333333, 1.3333333333333333, 2.0, 4.0, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 100], [20, 90], [30, 80], [40, 70], [50, 60], [60, 50], [70, 40], [80, 30], [90, 20], [100, 10]]) == [1.1, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[10, 5], [20, 5], [30, 5], [40, 5], [50, 5], [60, 5], [70, 5], [80, 5], [90, 5], [100, 5]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 150], [4, 130], [7, 110], [10, 90], [13, 70], [16, 50], [19, 30], [22, 10]]) == [0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, -1]\n assert candidate(cars = [[1, 10], [3, 9], [6, 8], [10, 7], [15, 6], [21, 5], [28, 4], [36, 3], [45, 2], [55, 1]]) == [2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, -1]\n assert candidate(cars = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [11, 90], [12, 89], [13, 88], [14, 87], [15, 86], [16, 85], [17, 84], [18, 83], [19, 82], [20, 81], [21, 80], [22, 79], [23, 78], [24, 77], [25, 76], [26, 75], [27, 74], [28, 73], [29, 72], [30, 71]]) == [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, -1]\n assert candidate(cars = [[1, 30], [4, 28], [7, 26], [10, 24], [13, 22], [16, 20], [19, 18], [22, 16], [25, 14], [28, 12], [31, 10], [34, 8], [37, 6], [40, 4], [43, 2]]) == [1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, -1]\n assert candidate(cars = [[1, 5], [5, 10], [9, 5], [13, 10], [17, 5], [21, 10], [25, 5], [29, 10], [33, 5], [37, 10]]) == [-1, 0.8, -1, 0.8, -1, 0.8, -1, 0.8, -1, -1]\n assert candidate(cars = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(cars = [[1, 10], [2, 9.5], [3, 9], [4, 8.5], [5, 8], [6, 7.5], [7, 7], [8, 6.5], [9, 6], [10, 5.5], [11, 5]]) == [2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, -1]\n assert candidate(cars = [[1, 15], [4, 12], [7, 9], [10, 6], [13, 3], [16, 2], [19, 1]]) == [1.0, 1.0, 1.0, 1.0, 3.0, 3.0, -1]\n"}, "metadata": {"canonical_parameter_names": ["cars"], "leetcode_dataset_entry_point": "Solution().getCollisionTimes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector getCollisionTimes(vector>& cars) {", "container": "Solution", "callable": "getCollisionTimes", "parameters": [{"name": "cars", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1779, "task_id": "find-nearest-point-that-has-the-same-x-or-y-coordinate", "difficulty": "Easy", "problem_description": "You are given two integers, x and y, which represent your current location on a Cartesian grid: (x, y). You are also given an array points where each points[i] = [ai, bi] represents that a point exists at (ai, bi). A point is valid if it shares the same x-coordinate or the same y-coordinate as your location.\nReturn the index (0-indexed) of the valid point with the smallest Manhattan distance from your current location. If there are multiple, return the valid point with the smallest index. If there are no valid points, return -1.\nThe Manhattan distance between two points (x1, y1) and (x2, y2) is abs(x1 - x2) + abs(y1 - y2).\n \nExample 1:\n\nInput: x = 3, y = 4, points = [[1,2],[3,1],[2,4],[2,3],[4,4]]\nOutput: 2\nExplanation: Of all the points, only [3,1], [2,4] and [4,4] are valid. Of the valid points, [2,4] and [4,4] have the smallest Manhattan distance from your current location, with a distance of 1. [2,4] has the smallest index, so return 2.\nExample 2:\n\nInput: x = 3, y = 4, points = [[3,4]]\nOutput: 0\nExplanation: The answer is allowed to be on the same location as your current location.\nExample 3:\n\nInput: x = 3, y = 4, points = [[2,3]]\nOutput: -1\nExplanation: There are no valid points.\n \nConstraints:\n\n1 <= points.length <= 104\npoints[i].length == 2\n1 <= x, y, ai, bi <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(x = 3,y = 4,points = [[3, 4]]) == 0\n assert candidate(x = 5,y = 5,points = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4]]) == 3\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4]]) == -1\n assert candidate(x = 3,y = 4,points = [[2, 3]]) == -1\n assert candidate(x = 1,y = 1,points = [[1, 1], [1, 2], [1, 3], [2, 1], [3, 1]]) == 0\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == -1\n assert candidate(x = 1,y = 1,points = [[1, 1], [1, 2], [2, 1], [2, 2]]) == 0\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4], [5, 5]]) == -1\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 9\n assert candidate(x = 100,y = 100,points = [[50, 100], [100, 50], [150, 100], [100, 150]]) == 0\n assert candidate(x = 5,y = 5,points = [[1, 1], [5, 5], [3, 3], [4, 4]]) == 1\n assert candidate(x = 5,y = 5,points = [[5, 5], [5, 6], [6, 5], [6, 6]]) == 0\n assert candidate(x = 1,y = 10,points = [[1, 1], [1, 2], [1, 3], [1, 4]]) == 3\n assert candidate(x = 5,y = 5,points = [[1, 5], [5, 1], [5, 9], [9, 5], [5, 5]]) == 4\n assert candidate(x = 5,y = 5,points = [[5, 1], [5, 2], [5, 3], [5, 4], [1, 5], [2, 5], [3, 5], [4, 5]]) == 3\n assert candidate(x = 5,y = 5,points = [[10, 10], [5, 5], [1, 1]]) == 1\n assert candidate(x = 1,y = 1,points = [[1, 2], [1, 3], [1, 4], [2, 1], [3, 1]]) == 0\n assert candidate(x = 5,y = 5,points = [[5, 5], [6, 6], [7, 7]]) == 0\n assert candidate(x = 10,y = 10,points = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == -1\n assert candidate(x = 2,y = 3,points = [[2, 3], [1, 1], [3, 3], [4, 4]]) == 0\n assert candidate(x = 10,y = 1,points = [[1, 1], [2, 1], [3, 1], [4, 1]]) == 3\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 2], [3, 3], [4, 4]]) == -1\n assert candidate(x = 3,y = 4,points = [[1, 2], [3, 1], [2, 4], [2, 3], [4, 4]]) == 2\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 2], [3, 3], [10, 10]]) == 3\n assert candidate(x = 5,y = 5,points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 4\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1]]) == 0\n assert candidate(x = 1,y = 1,points = [[1, 1], [1, 1], [1, 1], [1, 1]]) == 0\n assert candidate(x = 7,y = 7,points = [[6, 7], [7, 6], [7, 8], [8, 7]]) == 0\n assert candidate(x = 3,y = 3,points = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 4], [3, 5], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5]]) == 7\n assert candidate(x = 50,y = 50,points = [[49, 50], [51, 50], [50, 49], [50, 51], [48, 50], [52, 50], [50, 48], [50, 52]]) == 0\n assert candidate(x = 7,y = 8,points = [[7, 1], [1, 8], [7, 9], [9, 8], [7, 7], [8, 8]]) == 2\n assert candidate(x = 100,y = 100,points = [[99, 100], [100, 99], [101, 100], [100, 101], [98, 100], [100, 98]]) == 0\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 1], [4, 4], [5, 5], [1, 3], [3, 1]]) == 2\n assert candidate(x = 1,y = 2,points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [1, 2]]) == 9\n assert candidate(x = 7,y = 7,points = [[1, 1], [1, 7], [7, 1], [7, 7], [2, 2], [6, 6], [3, 3], [5, 5], [4, 4], [8, 8]]) == 3\n assert candidate(x = 2000,y = 2000,points = [[2000, 1999], [1999, 2000], [2000, 2001], [2001, 2000], [2000, 2000], [2000, 2002], [2002, 2000]]) == 4\n assert candidate(x = 20,y = 20,points = [[20, 19], [19, 20], [21, 20], [20, 21], [20, 20], [19, 19]]) == 4\n assert candidate(x = 5,y = 5,points = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]]) == 3\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1]]) == 0\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [1, 1]]) == 5\n assert candidate(x = 7,y = 7,points = [[1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [8, 7], [9, 7], [10, 7], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 8], [7, 9], [7, 10]]) == 5\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 1], [1, 2], [2, 1]]) == 9\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 10], [10, 2], [5, 5], [10, 10], [1, 10], [10, 1]]) == 4\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 2], [3, 3], [10, 1], [10, 2], [10, 3], [1, 10], [2, 10], [3, 10]]) == 5\n assert candidate(x = 100,y = 100,points = [[100, 100], [100, 99], [99, 100], [100, 101], [101, 100], [99, 99], [101, 101]]) == 0\n assert candidate(x = 5000,y = 5000,points = [[5000, 4999], [4999, 5000], [5000, 5001], [5001, 5000], [4999, 4999], [5001, 5001]]) == 0\n assert candidate(x = 5000,y = 5000,points = [[4999, 5000], [5000, 4999], [5001, 5000], [5000, 5001], [5000, 5000]]) == 4\n assert candidate(x = 2000,y = 3000,points = [[2000, 2999], [2000, 3001], [1999, 3000], [2001, 3000], [2000, 3000]]) == 4\n assert candidate(x = 20,y = 20,points = [[20, 1], [1, 20], [19, 20], [20, 19], [20, 18], [20, 17], [20, 16], [20, 15], [20, 14], [20, 13], [20, 12], [20, 11], [20, 10], [20, 9], [20, 8], [20, 7], [20, 6], [20, 5], [20, 4], [20, 3], [20, 2]]) == 2\n assert candidate(x = 20,y = 20,points = [[15, 20], [20, 15], [25, 20], [20, 25], [10, 10], [30, 30]]) == 0\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [3, 4], [4, 3], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 0\n assert candidate(x = 7,y = 7,points = [[7, 1], [1, 7], [7, 2], [2, 7], [7, 3], [3, 7], [7, 4], [4, 7], [7, 5], [5, 7], [7, 6], [6, 7], [7, 7]]) == 12\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [1, 2], [2, 1]]) == 4\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [1, 2], [2, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7]]) == 4\n assert candidate(x = 2,y = 2,points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 1\n assert candidate(x = 1,y = 100,points = [[1, 50], [1, 60], [1, 70], [1, 80], [1, 90], [2, 100], [3, 100], [4, 100], [5, 100], [6, 100]]) == 5\n assert candidate(x = 5,y = 5,points = [[5, 6], [6, 5], [5, 4], [4, 5], [5, 5], [5, 3], [3, 5], [5, 7], [7, 5]]) == 4\n assert candidate(x = 1000,y = 1000,points = [[1000, 1000], [999, 1000], [1000, 999], [999, 999], [998, 998], [997, 997], [996, 996], [995, 995], [994, 994], [993, 993]]) == 0\n assert candidate(x = 12,y = 15,points = [[10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19]]) == 2\n assert candidate(x = 1,y = 10000,points = [[1, 1], [1, 2], [1, 3], [1, 9999], [1, 10000], [1, 10001], [1, 9998]]) == 4\n assert candidate(x = 7,y = 7,points = [[7, 8], [8, 7], [6, 7], [7, 6], [7, 9], [9, 7], [7, 7], [7, 5], [5, 7]]) == 6\n assert candidate(x = 20,y = 25,points = [[15, 25], [25, 20], [20, 15], [20, 30], [30, 20], [20, 20]]) == 0\n assert candidate(x = 10,y = 10,points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [10, 9], [8, 7], [6, 5], [4, 3], [2, 1]]) == 4\n assert candidate(x = 30,y = 40,points = [[30, 35], [25, 40], [30, 45], [35, 40], [30, 40], [25, 35]]) == 4\n assert candidate(x = 10,y = 10,points = [[5, 10], [15, 10], [10, 5], [10, 15], [10, 10]]) == 4\n assert candidate(x = 1,y = 1,points = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2]]) == -1\n assert candidate(x = 1,y = 1,points = [[2, 1], [3, 1], [4, 1], [5, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20]]) == 0\n assert candidate(x = 9,y = 9,points = [[9, 1], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [9, 9], [9, 10]]) == 8\n assert candidate(x = 3,y = 3,points = [[1, 3], [3, 1], [2, 3], [3, 2], [3, 3], [4, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9]]) == 4\n assert candidate(x = 9999,y = 9999,points = [[9998, 9998], [9997, 9997], [9996, 9996], [9995, 9995], [9994, 9994], [9999, 9998], [9999, 9997], [9999, 9996], [9999, 9995], [9999, 9994], [9998, 9999], [9997, 9999], [9996, 9999], [9995, 9999], [9994, 9999]]) == 5\n assert candidate(x = 5,y = 5,points = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [1, 5], [2, 5], [3, 5], [4, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]]) == 3\n assert candidate(x = 10000,y = 1,points = [[9999, 1], [10001, 1], [10000, 2], [10000, 100], [10000, 99], [10000, 10000], [10000, 9999]]) == 0\n assert candidate(x = 5000,y = 5000,points = [[1, 1], [10000, 10000], [5000, 1], [1, 5000], [5000, 5000], [4999, 4999], [5001, 5001]]) == 4\n assert candidate(x = 100,y = 1,points = [[50, 1], [60, 1], [70, 1], [80, 1], [90, 1], [100, 2], [100, 3], [100, 4], [100, 5], [100, 6]]) == 5\n assert candidate(x = 5000,y = 5000,points = [[4999, 5000], [5001, 5000], [5000, 4999], [5000, 5001], [4998, 5000], [5002, 5000], [5000, 4998], [5000, 5002]]) == 0\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1], [1, 6], [6, 1]]) == 0\n assert candidate(x = 50,y = 50,points = [[50, 50], [50, 49], [49, 50], [50, 48], [48, 50], [50, 47], [47, 50], [50, 46], [46, 50], [50, 45], [45, 50]]) == 0\n assert candidate(x = 2500,y = 7500,points = [[2500, 7499], [2500, 7501], [2499, 7500], [2501, 7500], [2498, 7500], [2502, 7500], [2500, 7498], [2500, 7502]]) == 0\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 1]]) == 4\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 1], [2, 2], [3, 3]]) == 4\n assert candidate(x = 10,y = 10,points = [[5, 10], [10, 5], [10, 15], [15, 10], [10, 10], [11, 10], [10, 11], [9, 10], [10, 9]]) == 4\n assert candidate(x = 5,y = 5,points = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]]) == 3\n assert candidate(x = 6,y = 6,points = [[5, 6], [6, 5], [7, 6], [6, 7], [6, 6], [5, 5], [7, 7], [5, 7], [7, 5]]) == 4\n assert candidate(x = 1,y = 1,points = [[2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1], [1, 6], [6, 1]]) == 9\n assert candidate(x = 1,y = 10000,points = [[1, 1], [1, 9999], [1, 10001], [2, 10000], [1, 2], [1, 100], [1, 99], [1, 9998], [1, 10002]]) == 1\n assert candidate(x = 10,y = 10,points = [[10, 1], [1, 10], [10, 10], [5, 5], [10, 9], [9, 10]]) == 2\n assert candidate(x = 15,y = 20,points = [[10, 20], [15, 10], [20, 15], [15, 20], [10, 10], [20, 20]]) == 3\n assert candidate(x = 2,y = 2,points = [[2, 1], [1, 2], [3, 2], [2, 3], [1, 1], [3, 1], [1, 3], [3, 3], [2, 4], [4, 2], [4, 3], [3, 4], [4, 4]]) == 0\n assert candidate(x = 5,y = 5,points = [[5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [6, 5], [7, 5], [8, 5], [9, 5]]) == 0\n assert candidate(x = 3,y = 3,points = [[1, 3], [2, 3], [4, 3], [5, 3], [6, 3], [7, 3], [8, 3], [9, 3], [10, 3], [3, 1], [3, 2], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10]]) == 1\n assert candidate(x = 7,y = 7,points = [[5, 7], [6, 8], [7, 9], [8, 6], [9, 5], [7, 7], [7, 8], [8, 7]]) == 5\n assert candidate(x = 100,y = 100,points = [[100, 50], [50, 100], [100, 60], [60, 100], [100, 70], [70, 100], [100, 80], [80, 100], [100, 90], [90, 100]]) == 8\n assert candidate(x = 10000,y = 1,points = [[1, 1], [2, 1], [3, 1], [9999, 1], [10000, 1], [10001, 1], [9998, 1]]) == 4\n assert candidate(x = 7,y = 7,points = [[1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [8, 7], [9, 7], [10, 7]]) == 5\n assert candidate(x = 5000,y = 5000,points = [[5000, 5000], [5001, 5000], [4999, 5000], [5000, 5001], [5000, 4999]]) == 0\n assert candidate(x = 1,y = 1,points = [[1, 2], [2, 1], [1, 1], [1, 0], [0, 1]]) == 2\n assert candidate(x = 100,y = 100,points = [[99, 100], [100, 99], [100, 101], [101, 100], [98, 100], [100, 98], [99, 99], [101, 101]]) == 0\n assert candidate(x = 100,y = 100,points = [[50, 100], [100, 50], [150, 100], [100, 150], [100, 100]]) == 4\n assert candidate(x = 500,y = 500,points = [[500, 1], [1, 500], [500, 499], [499, 500], [10, 10], [490, 490], [50, 50], [1, 1], [500, 500]]) == 8\n assert candidate(x = 100,y = 100,points = [[100, 1], [1, 100], [99, 100], [100, 99], [10, 10], [90, 90], [50, 50], [1, 1], [100, 100]]) == 8\n assert candidate(x = 50,y = 50,points = [[50, 1], [50, 99], [1, 50], [99, 50], [50, 2], [2, 50], [50, 3], [3, 50], [50, 4], [4, 50]]) == 8\n assert candidate(x = 5000,y = 5000,points = [[4999, 4999], [5001, 5001], [4998, 5000], [5000, 4998], [5000, 5001], [5001, 5000], [4999, 5001], [5001, 4999]]) == 4\n assert candidate(x = 10,y = 10,points = [[1, 1], [2, 2], [3, 3], [10, 5], [5, 10], [10, 10]]) == 5\n assert candidate(x = 100,y = 100,points = [[99, 100], [100, 99], [98, 100], [100, 98], [99, 99], [101, 100], [100, 101]]) == 0\n assert candidate(x = 5000,y = 5000,points = [[1, 1], [10000, 10000], [5000, 1], [1, 5000], [5000, 5001], [5001, 5000]]) == 4\n assert candidate(x = 100,y = 100,points = [[100, 99], [99, 100], [101, 100], [100, 101], [100, 100]]) == 4\n assert candidate(x = 10,y = 10,points = [[10, 10], [9, 10], [10, 9], [11, 10], [10, 11], [9, 9], [11, 11]]) == 0\n assert candidate(x = 7,y = 7,points = [[6, 7], [8, 7], [7, 6], [7, 8], [5, 7], [7, 5], [9, 7], [7, 9], [7, 7], [6, 6], [8, 8]]) == 8\n assert candidate(x = 7,y = 3,points = [[7, 8], [7, 2], [6, 3], [8, 3], [7, 0], [7, 6], [5, 3], [9, 3]]) == 1\n assert candidate(x = 10000,y = 1,points = [[9999, 1], [10000, 2], [10001, 1], [1, 10000], [10000, 1], [10000, 3], [9998, 1]]) == 4\n assert candidate(x = 5000,y = 5000,points = [[5000, 5001], [5001, 5000], [4999, 5000], [5000, 4999], [5000, 5000], [1, 1], [10000, 10000]]) == 4\n assert candidate(x = 50,y = 50,points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]]) == 4\n assert candidate(x = 3,y = 3,points = [[1, 3], [2, 3], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [4, 3], [5, 3]]) == 4\n assert candidate(x = 10000,y = 10000,points = [[10000, 9999], [9999, 10000], [10000, 10000], [5000, 5000]]) == 2\n assert candidate(x = 25,y = 25,points = [[25, 10], [10, 25], [25, 15], [15, 25], [25, 20], [20, 25], [25, 5], [5, 25], [25, 30], [30, 25]]) == 4\n assert candidate(x = 15,y = 20,points = [[15, 1], [1, 20], [15, 3], [3, 20], [15, 4], [4, 20], [15, 5], [5, 20], [15, 6], [6, 20]]) == 9\n assert candidate(x = 1,y = 10000,points = [[1, 9999], [2, 10000], [1, 10001], [10000, 1], [1, 1], [10000, 10000], [1, 9998]]) == 0\n assert candidate(x = 20,y = 15,points = [[15, 20], [20, 15], [10, 10], [25, 25], [5, 5], [30, 30], [15, 15], [20, 20]]) == 1\n assert candidate(x = 3,y = 3,points = [[3, 2], [2, 3], [3, 4], [4, 3], [3, 1], [1, 3], [3, 5], [5, 3], [3, 6], [6, 3], [3, 0], [0, 3], [3, 7], [7, 3]]) == 0\n assert candidate(x = 10,y = 10,points = [[10, 1], [1, 10], [10, 10], [9, 10], [10, 9]]) == 2\n assert candidate(x = 8,y = 7,points = [[8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [8, 9], [8, 10]]) == 6\n"}, "metadata": {"canonical_parameter_names": ["x", "y", "points"], "leetcode_dataset_entry_point": "Solution().nearestValidPoint", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int nearestValidPoint(int x, int y, vector>& points) {", "container": "Solution", "callable": "nearestValidPoint", "parameters": [{"name": "x", "type": "int"}, {"name": "y", "type": "int"}, {"name": "points", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1780, "task_id": "check-if-number-is-a-sum-of-powers-of-three", "difficulty": "Medium", "problem_description": "Given an integer n, return true if it is possible to represent n as the sum of distinct powers of three. Otherwise, return false.\nAn integer y is a power of three if there exists an integer x such that y == 3x.\n \nExample 1:\n\nInput: n = 12\nOutput: true\nExplanation: 12 = 31 + 32\n\nExample 2:\n\nInput: n = 91\nOutput: true\nExplanation: 91 = 30 + 32 + 34\n\nExample 3:\n\nInput: n = 21\nOutput: false\n\n \nConstraints:\n\n1 <= n <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 59049) == True\n assert candidate(n = 3) == True\n assert candidate(n = 729) == True\n assert candidate(n = 12) == True\n assert candidate(n = 243) == True\n assert candidate(n = 21) == False\n assert candidate(n = 4782969) == True\n assert candidate(n = 19683) == True\n assert candidate(n = 1594323) == True\n assert candidate(n = 40) == True\n assert candidate(n = 59048) == False\n assert candidate(n = 1093) == True\n assert candidate(n = 10000000) == False\n assert candidate(n = 100000) == False\n assert candidate(n = 27) == True\n assert candidate(n = 6561) == True\n assert candidate(n = 3645) == False\n assert candidate(n = 2187) == True\n assert candidate(n = 177147) == True\n assert candidate(n = 91) == True\n assert candidate(n = 81) == True\n assert candidate(n = 531441) == True\n assert candidate(n = 1000000) == False\n assert candidate(n = 1000001) == False\n assert candidate(n = 9) == True\n assert candidate(n = 98415) == False\n assert candidate(n = 1) == True\n assert candidate(n = 10) == True\n assert candidate(n = 89076) == False\n assert candidate(n = 9999999) == False\n assert candidate(n = 98416) == False\n assert candidate(n = 39856) == False\n assert candidate(n = 1640261) == False\n assert candidate(n = 59050) == True\n assert candidate(n = 9876543) == False\n assert candidate(n = 32804) == False\n assert candidate(n = 819) == True\n assert candidate(n = 14348907) == True\n assert candidate(n = 9841) == True\n assert candidate(n = 8) == False\n assert candidate(n = 810000) == False\n assert candidate(n = 8191) == False\n assert candidate(n = 72900) == False\n assert candidate(n = 524880) == False\n assert candidate(n = 7290) == True\n assert candidate(n = 11) == False\n assert candidate(n = 1048575) == False\n assert candidate(n = 59250) == False\n assert candidate(n = 109355) == False\n assert candidate(n = 10935) == False\n assert candidate(n = 98414) == False\n assert candidate(n = 2391484) == True\n assert candidate(n = 88572) == True\n assert candidate(n = 32805) == False\n assert candidate(n = 88573) == True\n assert candidate(n = 50000) == False\n assert candidate(n = 1049755) == False\n assert candidate(n = 590490) == True\n assert candidate(n = 4) == True\n assert candidate(n = 98411) == False\n assert candidate(n = 6560) == False\n assert candidate(n = 4100) == False\n assert candidate(n = 19684) == True\n assert candidate(n = 531442) == True\n assert candidate(n = 49308) == False\n assert candidate(n = 39858) == False\n assert candidate(n = 59047) == False\n assert candidate(n = 99018) == False\n assert candidate(n = 98409) == False\n assert candidate(n = 58324) == False\n assert candidate(n = 48619) == False\n assert candidate(n = 69192) == False\n assert candidate(n = 369059) == False\n assert candidate(n = 4052555) == False\n assert candidate(n = 1291401) == False\n assert candidate(n = 98413) == False\n assert candidate(n = 3486784400) == False\n assert candidate(n = 14348908) == True\n assert candidate(n = 131220) == False\n assert candidate(n = 437400) == False\n assert candidate(n = 2) == False\n assert candidate(n = 4000000) == False\n assert candidate(n = 981) == True\n assert candidate(n = 97656) == False\n assert candidate(n = 3986) == False\n assert candidate(n = 19682) == False\n assert candidate(n = 797162) == False\n assert candidate(n = 656100) == False\n assert candidate(n = 3486784401) == True\n assert candidate(n = 45927) == False\n assert candidate(n = 79134) == False\n assert candidate(n = 1234567) == False\n assert candidate(n = 3125) == False\n assert candidate(n = 2097152) == False\n assert candidate(n = 98410) == False\n assert candidate(n = 99999) == False\n assert candidate(n = 728997) == False\n assert candidate(n = 405224) == False\n assert candidate(n = 31259) == False\n assert candidate(n = 119050) == False\n assert candidate(n = 104976) == False\n assert candidate(n = 546789) == False\n assert candidate(n = 39366) == False\n assert candidate(n = 40000) == False\n assert candidate(n = 29524) == True\n assert candidate(n = 98412) == False\n assert candidate(n = 400) == False\n assert candidate(n = 32806) == False\n assert candidate(n = 3188646) == False\n assert candidate(n = 123456) == False\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().checkPowersOfThree", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool checkPowersOfThree(int n) {", "container": "Solution", "callable": "checkPowersOfThree", "parameters": [{"name": "n", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1781, "task_id": "sum-of-beauty-of-all-substrings", "difficulty": "Medium", "problem_description": "The beauty of a string is the difference in frequencies between the most frequent and least frequent characters.\n\nFor example, the beauty of \"abaacc\" is 3 - 1 = 2.\n\nGiven a string s, return the sum of beauty of all of its substrings.\n \nExample 1:\n\nInput: s = \"aabcb\"\nOutput: 5\nExplanation: The substrings with non-zero beauty are [\"aab\",\"aabc\",\"aabcb\",\"abcb\",\"bcb\"], each with beauty equal to 1.\nExample 2:\n\nInput: s = \"aabcbaa\"\nOutput: 17\n\n \nConstraints:\n\n1 <= s.length <= 500\ns consists of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"xyzzxyzzxyzz\") == 87\n assert candidate(s = \"aaabbbccc\") == 29\n assert candidate(s = \"aabcb\") == 5\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(s = \"abcdedcba\") == 16\n assert candidate(s = \"a\") == 0\n assert candidate(s = \"abcabcabc\") == 16\n assert candidate(s = \"zzzz\") == 0\n assert candidate(s = \"aabcbaa\") == 17\n assert candidate(s = \"pqrspqrspqrspqrs\") == 63\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\") == 0\n assert candidate(s = \"xyzxyzxyz\") == 16\n assert candidate(s = \"abcdabcdabcd\") == 30\n assert candidate(s = \"abc\") == 0\n assert candidate(s = \"xyzzxyzz\") == 25\n assert candidate(s = \"abcd\") == 0\n assert candidate(s = \"aabbccddeeff\") == 40\n assert candidate(s = \"zzzzz\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 950\n assert candidate(s = \"abcdefg\") == 0\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiii\") == 1112\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghij\") == 432\n assert candidate(s = \"pqrstuvwxyzabcdefghijklmno\") == 0\n assert candidate(s = \"abccbaabccbaabccbaabccba\") == 222\n assert candidate(s = \"verycomplicatedstringwithrepeatedcharactersrepeatedrepeated\") == 5556\n assert candidate(s = \"mississippimississippimississippimississippi\") == 4387\n assert candidate(s = \"abracadabra\") == 64\n assert candidate(s = \"abacabadabacabadabacabadabacabad\") == 2236\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacaba\") == 11131\n assert candidate(s = \"abcabcabcabc\") == 33\n assert candidate(s = \"xzyxzxyzxyz\") == 34\n assert candidate(s = \"abcdefabcdeabcdeabcde\") == 183\n assert candidate(s = \"aabacababa\") == 66\n assert candidate(s = \"zzzzzzzzzz\") == 0\n assert candidate(s = \"abcdefghijklmabcdefghijklm\") == 90\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 1170\n assert candidate(s = \"abababababababababababababababab\") == 240\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabc\") == 456\n assert candidate(s = \"mississippiissiippiisppiiiiiiii\") == 1732\n assert candidate(s = \"abacabadabacabadabacabadabacaba\") == 2047\n assert candidate(s = \"thisisaverylongandcomplicatedstringwithvariouscharacters\") == 2645\n assert candidate(s = \"mnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == 325\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 513\n assert candidate(s = \"kayak\") == 4\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 261\n assert candidate(s = \"xyzzzzxyzzzzxyzzzzxyzzzz\") == 1254\n assert candidate(s = \"ababababababab\") == 42\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyza\") == 1\n assert candidate(s = \"abcdefabcdefabcdefabcdefabcdefabcdef\") == 400\n assert candidate(s = \"abcdabcdabcdabcd\") == 63\n assert candidate(s = \"level\") == 4\n assert candidate(s = \"ppppppppppppppppppppppppppppppppppqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\") == 13090\n assert candidate(s = \"xyzzyxzyxzyzyx\") == 87\n assert candidate(s = \"pqrsrstsrqpqrs\") == 102\n assert candidate(s = \"madam\") == 4\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 1053\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwerty\") == 21\n assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 2450\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggg\") == 630\n assert candidate(s = \"abacabadabacaba\") == 231\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\") == 702\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabadabacabad\") == 44628\n assert candidate(s = \"xyzzazxzy\") == 45\n assert candidate(s = \"abababababababababababababababababababababababab\") == 552\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbcccccccccc\") == 1275\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 1350\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjaabbccddeeffgghhiijjaabbccddeeffgghhiijj\") == 2118\n assert candidate(s = \"bananaananabananananabananananananananananananana\") == 7610\n assert candidate(s = \"mnbvcxzlkjhgfdsapoiuytrewq\") == 0\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"banana\") == 8\n assert candidate(s = \"xyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzzxyzz\") == 11722\n assert candidate(s = \"mnopqrsmnopqrsmnopqrsmnopqrsmnopqrsmnopqrsmnopqrsmnopqrs\") == 1071\n assert candidate(s = \"aabbccddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxxyyyzzz\") == 4312\n assert candidate(s = \"aaaaabbbbccccddddeeeffffggghhh\") == 782\n assert candidate(s = \"nnnnoonnmnmlmllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll\") == 33629\n assert candidate(s = \"aaaabbbbccccdddd\") == 162\n assert candidate(s = \"abacabadabacabadabacabad\") == 948\n assert candidate(s = \"deified\") == 9\n assert candidate(s = \"zzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"repaper\") == 9\n assert candidate(s = \"xyzzzzzxyzzzzzxyzzzzzxyzzzzzxyzzzzzxyzzzzzxyzzzzzxyzzzzz\") == 17541\n assert candidate(s = \"aabbaaabbbaaabbaaaabbbaaabbaaaabbbaaabbaaaabbbaaabbaaaab\") == 5129\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzzzzzzzzzzzzzzzzz\") == 11950\n assert candidate(s = \"aabbccddeeffgghhiijjanmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == 1979\n assert candidate(s = \"abababababababababababab\") == 132\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\") == 350\n assert candidate(s = \"rotor\") == 4\n assert candidate(s = \"racecar\") == 9\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\") == 320\n assert candidate(s = \"abcabcabcabcabcabcabcabc\") == 161\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 350\n assert candidate(s = \"reviled\") == 4\n assert candidate(s = \"mnopqrnopqmonmnopq\") == 145\n assert candidate(s = \"abacabadaba\") == 85\n assert candidate(s = \"mississippi\") == 64\n assert candidate(s = \"aaaaabbbbccccddddeeeffffgggghhhhiiiiijjjjkkkkllllmmmmmnnnnnooooo\") == 4941\n assert candidate(s = \"abcabcabcabcabc\") == 56\n assert candidate(s = \"xyzzzzzxyzzzzzxyzzzzz\") == 936\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"refer\") == 4\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().beautySum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int beautySum(string s) {", "container": "Solution", "callable": "beautySum", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1782, "task_id": "count-pairs-of-nodes", "difficulty": "Hard", "problem_description": "You are given an undirected graph defined by an integer n, the number of nodes, and a 2D integer array edges, the edges in the graph, where edges[i] = [ui, vi] indicates that there is an undirected edge between ui and vi. You are also given an integer array queries.\nLet incident(a, b) be defined as the number of edges that are connected to either node a or b.\nThe answer to the jth query is the number of pairs of nodes (a, b) that satisfy both of the following conditions:\n\na < b\nincident(a, b) > queries[j]\n\nReturn an array answers such that answers.length == queries.length and answers[j] is the answer of the jth query.\nNote that there can be multiple edges between the same two nodes.\n \nExample 1:\n\n\nInput: n = 4, edges = [[1,2],[2,4],[1,3],[2,3],[2,1]], queries = [2,3]\nOutput: [6,5]\nExplanation: The calculations for incident(a, b) are shown in the table above.\nThe answers for each of the queries are as follows:\n- answers[0] = 6. All the pairs have an incident(a, b) value greater than 2.\n- answers[1] = 5. All the pairs except (3, 4) have an incident(a, b) value greater than 3.\n\nExample 2:\n\nInput: n = 5, edges = [[1,5],[1,5],[3,4],[2,5],[1,3],[5,1],[2,3],[2,5]], queries = [1,2,3,4,5]\nOutput: [10,10,9,8,6]\n\n \nConstraints:\n\n2 <= n <= 2 * 104\n1 <= edges.length <= 105\n1 <= ui, vi <= n\nui != vi\n1 <= queries.length <= 20\n0 <= queries[j] < edges.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,edges = [[1, 2], [2, 4], [1, 3], [2, 3], [2, 1]],queries = [2, 3]) == [6, 5]\n assert candidate(n = 5,edges = [[1, 5], [1, 5], [3, 4], [2, 5], [1, 3], [5, 1], [2, 3], [2, 5]],queries = [1, 2, 3, 4, 5]) == [10, 10, 9, 8, 6]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [7, 10], [8, 9], [8, 10], [9, 10]],queries = [5, 10, 15]) == [45, 8, 0]\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20]],queries = [3, 4, 5, 6]) == [190, 187, 183, 148]\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [12, 13], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14], [10, 15]],queries = [7, 8, 9, 10, 11]) == [75, 69, 24, 0, 0]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]],queries = [3, 5, 7, 9]) == [41, 33, 1, 0]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8], [9, 10]],queries = [5, 6, 7]) == [16, 0, 0]\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]],queries = [1, 5, 9]) == [45, 0, 0]\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 3], [2, 4], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [5, 6], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 7]],queries = [3, 8, 13]) == [176, 15, 0]\n assert candidate(n = 100,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 1], [10, 2], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 1], [9, 2], [10, 3], [1, 4], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 1], [8, 2], [9, 3], [10, 4]],queries = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [945, 945, 945, 945, 945, 945, 945, 765, 45, 45, 45]\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [4, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16], [4, 17], [4, 18], [4, 19], [4, 20], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [5, 11], [5, 12], [5, 13], [5, 14], [5, 15], [5, 16], [5, 17], [5, 18], [5, 19], [5, 20]],queries = [5, 15, 25, 35, 45]) == [190, 85, 10, 10, 0]\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1], [1, 8], [2, 9], [3, 10], [4, 11], [5, 12], [6, 13], [7, 14], [8, 15]],queries = [10, 12, 14]) == [12, 0, 0]\n assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25], [24, 26], [25, 27], [26, 28], [27, 29], [28, 30], [29, 1], [30, 2]],queries = [15, 20, 25, 30, 35]) == [0, 0, 0, 0, 0]\n assert candidate(n = 25,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [1, 25], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25]],queries = [4, 9, 14]) == [300, 0, 0]\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15], [14, 16], [15, 16], [15, 17], [16, 17], [16, 18], [17, 18], [17, 19], [18, 19], [19, 20], [19, 21], [20, 21], [20, 22], [20, 23], [21, 22], [21, 23], [22, 23], [22, 24], [22, 25], [23, 24], [23, 25], [24, 25]],queries = [6, 12, 18, 24]) == [283, 0, 0, 0]\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10], [2, 5], [3, 7], [4, 8], [5, 9], [6, 10]],queries = [4, 5, 6, 7, 8]) == [43, 28, 4, 0, 0]\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [2, 30], [3, 29], [4, 28], [5, 27], [6, 26], [7, 25], [8, 24], [9, 23], [10, 22], [11, 21], [12, 20], [13, 19], [14, 18], [15, 17], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16]],queries = [20, 25, 30, 35, 40, 45]) == [29, 29, 14, 0, 0, 0]\n assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [1, 30], [2, 29], [3, 28], [4, 27], [5, 26], [6, 25], [7, 24], [8, 23], [9, 22], [10, 21], [11, 20], [12, 19], [13, 18], [14, 17], [15, 16]],queries = [0, 5, 10, 15, 20, 25, 30]) == [435, 338, 0, 0, 0, 0, 0]\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [12, 13], [13, 14], [13, 15], [14, 15], [14, 16], [15, 16], [15, 17], [16, 17], [16, 18], [17, 18], [17, 19], [18, 19], [19, 20], [20, 1]],queries = [5, 10, 15, 20]) == [184, 0, 0, 0]\n assert candidate(n = 50,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39], [39, 40], [40, 41], [41, 42], [42, 43], [43, 44], [44, 45], [45, 46], [46, 47], [47, 48], [48, 49], [49, 50], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25], [24, 26], [25, 27], [26, 28], [27, 29], [28, 30], [29, 31], [30, 32], [31, 33], [32, 34], [33, 35], [34, 36], [35, 37], [36, 38], [37, 39], [38, 40], [39, 41], [40, 42], [41, 43], [42, 44], [43, 45], [44, 46], [45, 47], [46, 48], [47, 49], [48, 50]],queries = [10, 20, 30, 40, 50]) == [0, 0, 0, 0, 0]\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 1], [12, 2]],queries = [3, 4, 5, 6, 7]) == [66, 66, 66, 66, 42]\n assert candidate(n = 25,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25], [24, 1], [25, 2], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15], [13, 16], [14, 17], [15, 18], [16, 19], [17, 20], [18, 21], [19, 22], [20, 23], [21, 24], [22, 25], [23, 1], [24, 2], [25, 3]],queries = [10, 15, 20, 25, 30]) == [300, 0, 0, 0, 0]\n assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 1], [1, 13], [2, 14], [3, 15], [4, 16], [5, 17], [6, 18], [7, 19], [8, 20], [9, 21], [10, 22], [11, 23], [12, 24], [13, 25], [14, 26], [15, 27], [16, 28], [17, 29], [18, 30], [19, 1], [20, 2], [21, 3], [22, 4], [23, 5], [24, 6], [25, 7], [26, 8], [27, 9], [28, 10], [29, 11], [30, 12]],queries = [20, 40, 60, 80, 100]) == [0, 0, 0, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1], [1, 8], [2, 9], [3, 10], [4, 11], [5, 12], [6, 13], [7, 14], [8, 15], [9, 1], [10, 2], [11, 3], [12, 4], [13, 5], [14, 6], [15, 7]],queries = [10, 15, 20, 25]) == [0, 0, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [1, 2], [1, 3], [2, 3], [2, 3], [2, 4], [3, 4], [3, 5], [4, 5], [4, 6], [5, 6], [5, 7], [6, 7], [6, 8], [7, 8], [7, 9], [8, 9], [8, 10], [9, 10], [9, 11], [10, 11], [10, 12], [11, 12], [11, 13], [12, 13], [12, 14], [13, 14], [13, 15], [14, 15]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [105, 105, 105, 104, 102, 89, 51, 17, 0, 0]\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],queries = [3, 4, 5, 6, 7, 8]) == [136, 0, 0, 0, 0, 0]\n assert candidate(n = 18,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 1], [18, 2]],queries = [5, 10, 15, 20]) == [153, 0, 0, 0]\n assert candidate(n = 25,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [1, 25], [1, 24], [2, 23], [2, 22], [3, 21], [3, 20], [4, 19], [4, 18], [5, 17], [5, 16], [6, 15], [6, 14], [7, 13], [7, 12], [8, 11], [8, 10], [9, 9], [10, 8], [11, 7], [12, 6], [13, 5], [14, 4], [15, 3], [16, 2], [17, 1]],queries = [15, 20, 25, 30, 35]) == [0, 0, 0, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [8, 15], [1, 15], [2, 15], [3, 15], [4, 15]],queries = [8, 9, 10, 11]) == [6, 0, 0, 0]\n assert candidate(n = 100,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 5], [2, 6], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39], [39, 40], [40, 41], [41, 42], [42, 43], [43, 44], [44, 45], [45, 46], [46, 47], [47, 48], [48, 49], [49, 50], [50, 51], [51, 52], [52, 53], [53, 54], [54, 55], [55, 56], [56, 57], [57, 58], [58, 59], [59, 60], [60, 61], [61, 62], [62, 63], [63, 64], [64, 65], [65, 66], [66, 67], [67, 68], [68, 69], [69, 70], [70, 71], [71, 72], [72, 73], [73, 74], [74, 75], [75, 76], [76, 77], [77, 78], [78, 79], [79, 80], [80, 81], [81, 82], [82, 83], [83, 84], [84, 85], [85, 86], [86, 87], [87, 88], [88, 89], [89, 90], [90, 91], [91, 92], [92, 93], [93, 94], [94, 95], [95, 96], [96, 97], [97, 98], [98, 99], [99, 100]],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(n = 25,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 1], [1, 12], [2, 13], [3, 14], [4, 15], [5, 16], [6, 17], [7, 18], [8, 19], [9, 20], [10, 21], [11, 22], [12, 23], [13, 24], [14, 25], [15, 1], [16, 2], [17, 3], [18, 4], [19, 5], [20, 6], [21, 7], [22, 8], [23, 9], [24, 10], [25, 11]],queries = [15, 30, 45, 60, 75]) == [0, 0, 0, 0, 0]\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 16], [13, 17], [14, 18], [15, 19], [16, 20]],queries = [5, 10, 15, 20, 25]) == [187, 0, 0, 0, 0]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [7, 10], [8, 9], [8, 10], [9, 10]],queries = [5, 10, 15]) == [45, 8, 0]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],queries = [5, 6, 7]) == [8, 0, 0]\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19], [10, 20]],queries = [10, 20, 30, 40]) == [0, 0, 0, 0]\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11]],queries = [10, 15, 20, 25, 30]) == [0, 0, 0, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 3], [2, 4], [2, 5], [2, 6], [3, 4], [3, 5], [3, 6], [3, 7], [4, 5], [4, 6], [4, 7], [4, 8], [5, 6], [5, 7], [5, 8], [5, 9], [6, 7], [6, 8], [6, 9], [6, 10], [7, 8], [7, 9], [7, 10], [7, 11], [8, 9], [8, 10], [8, 11], [8, 12], [9, 10], [9, 11], [9, 12], [9, 13], [10, 11], [10, 12], [10, 13], [10, 14], [11, 12], [11, 13], [11, 14], [11, 15], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15]],queries = [10, 20, 30, 40]) == [91, 0, 0, 0]\n assert candidate(n = 8,edges = [[1, 2], [1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [3, 6], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 8]],queries = [1, 2, 3, 4, 5]) == [28, 28, 28, 28, 28]\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [1, 12], [2, 13], [3, 14], [4, 15], [5, 16], [6, 17], [7, 18], [8, 19], [9, 20]],queries = [10, 15, 20, 25]) == [0, 0, 0, 0]\n assert candidate(n = 30,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [6, 8], [6, 9], [7, 8], [7, 9], [8, 9], [8, 10], [8, 11], [9, 10], [9, 11], [10, 11], [10, 12], [10, 13], [11, 12], [11, 13], [12, 13], [12, 14], [12, 15], [13, 14], [13, 15], [14, 15], [14, 16], [15, 16], [15, 17], [16, 17], [16, 18], [17, 18], [17, 19], [18, 19], [19, 20], [19, 21], [20, 21], [20, 22], [20, 23], [21, 22], [21, 23], [22, 23], [22, 24], [22, 25], [23, 24], [23, 25], [24, 25], [24, 26], [24, 27], [25, 26], [25, 27], [26, 27], [26, 28], [26, 29], [27, 28], [27, 29], [28, 29], [28, 30], [29, 30]],queries = [7, 14, 21, 28]) == [360, 0, 0, 0]\n assert candidate(n = 25,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25], [24, 1], [25, 2]],queries = [15, 20, 25, 30]) == [0, 0, 0, 0]\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]],queries = [5, 10, 15]) == [36, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 3], [2, 4], [2, 5], [3, 4], [3, 5], [4, 5], [4, 6], [4, 7], [5, 6], [5, 7], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1]],queries = [4, 8, 12, 16]) == [76, 1, 0, 0]\n assert candidate(n = 30,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 21], [20, 22], [21, 23], [22, 24], [23, 25], [24, 26], [25, 27], [26, 28], [27, 29], [28, 30]],queries = [5, 10, 15]) == [432, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [1, 15]],queries = [2, 7, 12]) == [105, 0, 0]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 5], [2, 6], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]],queries = [5, 6, 7]) == [19, 4, 0]\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10]],queries = [5, 10, 15]) == [24, 7, 0]\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 1], [15, 2], [1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15], [13, 1], [14, 2], [15, 3]],queries = [10, 15, 20, 25, 30]) == [105, 0, 0, 0, 0]\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11]],queries = [0, 5, 10, 15, 20]) == [190, 128, 0, 0, 0]\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [1, 15], [2, 14], [3, 13], [4, 12], [5, 11], [6, 10], [7, 9]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [105, 105, 104, 98, 50, 0, 0, 0, 0, 0]\n"}, "metadata": {"canonical_parameter_names": ["n", "edges", "queries"], "leetcode_dataset_entry_point": "Solution().countPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector countPairs(int n, vector>& edges, vector& queries) {", "container": "Solution", "callable": "countPairs", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "vector>&"}, {"name": "queries", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1784, "task_id": "check-if-binary-string-has-at-most-one-segment-of-ones", "difficulty": "Easy", "problem_description": "Given a binary string s ​​​​​without leading zeros, return true​​​ if s contains at most one contiguous segment of ones. Otherwise, return false.\n \nExample 1:\n\nInput: s = \"1001\"\nOutput: false\nExplanation: The ones do not form a contiguous segment.\n\nExample 2:\n\nInput: s = \"110\"\nOutput: true\n \nConstraints:\n\n1 <= s.length <= 100\ns[i]​​​​ is either '0' or '1'.\ns[0] is '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1111\") == True\n assert candidate(s = \"1000001\") == False\n assert candidate(s = \"111\") == True\n assert candidate(s = \"11110000\") == True\n assert candidate(s = \"100000\") == True\n assert candidate(s = \"11000\") == True\n assert candidate(s = \"111000\") == True\n assert candidate(s = \"1001001\") == False\n assert candidate(s = \"1111111111\") == True\n assert candidate(s = \"100001\") == False\n assert candidate(s = \"1000000000\") == True\n assert candidate(s = \"101\") == False\n assert candidate(s = \"10\") == True\n assert candidate(s = \"110\") == True\n assert candidate(s = \"110001\") == False\n assert candidate(s = \"1010101010\") == False\n assert candidate(s = \"1\") == True\n assert candidate(s = \"1100111\") == False\n assert candidate(s = \"101010\") == False\n assert candidate(s = \"111110000\") == True\n assert candidate(s = \"1001\") == False\n assert candidate(s = \"11001\") == False\n assert candidate(s = \"101010101010101\") == False\n assert candidate(s = \"1000000000000000000000000000000000000000000000000000001\") == False\n assert candidate(s = \"11110000001\") == False\n assert candidate(s = \"111000111000111000111000111000111000111000111000111\") == False\n assert candidate(s = \"111000111000111000\") == False\n assert candidate(s = \"1000000000000000000000000001\") == False\n assert candidate(s = \"10101010101010101010101010101010101010101010101010\") == False\n assert candidate(s = \"1000010001000100\") == False\n assert candidate(s = \"10000000000000000000000000000000000000000000000001\") == False\n assert candidate(s = \"1111111\") == True\n assert candidate(s = \"111000111000111\") == False\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111\") == True\n assert candidate(s = \"111111111111111111111\") == True\n assert candidate(s = \"1100110011\") == False\n assert candidate(s = \"11100000000000\") == True\n assert candidate(s = \"1010101010101010\") == False\n assert candidate(s = \"10000000000000000000\") == True\n assert candidate(s = \"111100000000\") == True\n assert candidate(s = \"11110001\") == False\n assert candidate(s = \"1111111111111110000000000001111111111111\") == False\n assert candidate(s = \"11110000111100001111\") == False\n assert candidate(s = \"101010101010\") == False\n assert candidate(s = \"111000000000000000000\") == True\n assert candidate(s = \"111111111111110000000000000\") == True\n assert candidate(s = \"100000000000100000\") == False\n assert candidate(s = \"100000000000\") == True\n assert candidate(s = \"1110001\") == False\n assert candidate(s = \"100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\") == False\n assert candidate(s = \"1111111111111111\") == True\n assert candidate(s = \"1001001001\") == False\n assert candidate(s = \"1000000000000000000000000000000000000001\") == False\n assert candidate(s = \"100000000000000000000000000000000000000000000000000000\") == True\n assert candidate(s = \"1111111000000\") == True\n assert candidate(s = \"111011101110111011101\") == False\n assert candidate(s = \"1001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001001\") == False\n assert candidate(s = \"100000000000000000001\") == False\n assert candidate(s = \"11100000000111\") == False\n assert candidate(s = \"100000000001\") == False\n assert candidate(s = \"1001001001001001\") == False\n assert candidate(s = \"100000000000000\") == True\n assert candidate(s = \"1100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011\") == False\n assert candidate(s = \"10000000001\") == False\n assert candidate(s = \"111000111000\") == False\n assert candidate(s = \"10111000110\") == False\n assert candidate(s = \"111100001111\") == False\n assert candidate(s = \"100010001000100010001\") == False\n assert candidate(s = \"1000000000000000\") == True\n assert candidate(s = \"111110111111\") == False\n assert candidate(s = \"111111000000\") == True\n assert candidate(s = \"11011011011011011011\") == False\n assert candidate(s = \"1000000000000000000000000000000000000000000000000001\") == False\n assert candidate(s = \"11010101010101\") == False\n assert candidate(s = \"11111000001\") == False\n assert candidate(s = \"10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\") == True\n assert candidate(s = \"1000100010\") == False\n assert candidate(s = \"1110000000000001\") == False\n assert candidate(s = \"10000000100000001\") == False\n assert candidate(s = \"100000010000001000000\") == False\n assert candidate(s = \"10000100001\") == False\n assert candidate(s = \"1110000000\") == True\n assert candidate(s = \"11111111111111111111111111111111111111111111111111\") == True\n assert candidate(s = \"111111111111111111111111111111111111111111111111111111\") == True\n assert candidate(s = \"10101010101010101\") == False\n assert candidate(s = \"11100000000000000000000000000000000000000000000000\") == True\n assert candidate(s = \"1111000011110000\") == False\n assert candidate(s = \"10101010101010101010101010101010\") == False\n assert candidate(s = \"1111100000\") == True\n assert candidate(s = \"1111000000001111\") == False\n assert candidate(s = \"11110000100001110000\") == False\n assert candidate(s = \"111000000000000000000000000000000000000000000000001110000000000000000000000000000000000000000000000000000111\") == False\n assert candidate(s = \"1101101101\") == False\n assert candidate(s = \"1001001001001\") == False\n assert candidate(s = \"1110111100001\") == False\n assert candidate(s = \"110001000000\") == False\n assert candidate(s = \"111111111100\") == True\n assert candidate(s = \"1100000000000001\") == False\n assert candidate(s = \"10000000000000000000000000000000000000000000000000\") == True\n assert candidate(s = \"11001100110011\") == False\n assert candidate(s = \"1110000000000000000000000000000000000000000000000000\") == True\n assert candidate(s = \"11000001111\") == False\n assert candidate(s = \"11111111110000000000000000000000000000000000000000\") == True\n assert candidate(s = \"1111000011\") == False\n assert candidate(s = \"10101010101010101010\") == False\n assert candidate(s = \"10000111111110\") == False\n assert candidate(s = \"10000111110001\") == False\n assert candidate(s = \"10101010101010\") == False\n assert candidate(s = \"1000001000001000001\") == False\n assert candidate(s = \"1000000010000\") == False\n assert candidate(s = \"10000000000001\") == False\n assert candidate(s = \"11100001\") == False\n assert candidate(s = \"1000000000000001\") == False\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().checkOnesSegment", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool checkOnesSegment(string s) {", "container": "Solution", "callable": "checkOnesSegment", "parameters": [{"name": "s", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1785, "task_id": "minimum-elements-to-add-to-form-a-given-sum", "difficulty": "Medium", "problem_description": "You are given an integer array nums and two integers limit and goal. The array nums has an interesting property that abs(nums[i]) <= limit.\nReturn the minimum number of elements you need to add to make the sum of the array equal to goal. The array must maintain its property that abs(nums[i]) <= limit.\nNote that abs(x) equals x if x >= 0, and -x otherwise.\n \nExample 1:\n\nInput: nums = [1,-1,1], limit = 3, goal = -4\nOutput: 2\nExplanation: You can add -2 and -3, then the sum of the array will be 1 - 1 + 1 - 2 - 3 = -4.\n\nExample 2:\n\nInput: nums = [1,-10,9,1], limit = 100, goal = 0\nOutput: 1\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= limit <= 106\n-limit <= nums[i] <= limit\n-109 <= goal <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, -1, 1],limit = 3,goal = -4) == 2\n assert candidate(nums = [1, 2, 3],limit = 1,goal = 6) == 0\n assert candidate(nums = [1, -10, 9, 1],limit = 100,goal = 0) == 1\n assert candidate(nums = [0, 0, 0],limit = 1,goal = 3) == 3\n assert candidate(nums = [0, 0, 0, 0],limit = 5,goal = 10) == 2\n assert candidate(nums = [2, 2, 2],limit = 2,goal = 6) == 0\n assert candidate(nums = [-3, -2, -1],limit = 1,goal = -9) == 3\n assert candidate(nums = [-5, -5, -5],limit = 5,goal = 15) == 6\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],limit = 5,goal = 50) == 10\n assert candidate(nums = [10, -10, 20, -20, 30, -30],limit = 15,goal = 0) == 0\n assert candidate(nums = [500000, -250000, 125000, -62500, 31250, -15625],limit = 100000,goal = 1000000) == 7\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000],limit = 100000,goal = 1500000) == 0\n assert candidate(nums = [999999, -999999, 999998, -999998, 999997, -999997],limit = 1000000,goal = -1000000) == 1\n assert candidate(nums = [1000000, -1000000, 500000, -500000],limit = 1000000,goal = 0) == 0\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],limit = 2,goal = -15) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 1,goal = -10) == 20\n assert candidate(nums = [5, 10, 15, 20, 25],limit = 10,goal = 100) == 3\n assert candidate(nums = [1, -2, 3, -4, 5],limit = 2,goal = -10) == 7\n assert candidate(nums = [100, -100, 200, -200, 300, -300],limit = 100,goal = -1500) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 3,goal = 0) == 19\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000],limit = 1000000,goal = 0) == 5\n assert candidate(nums = [5, -5, 5, -5, 5, -5],limit = 5,goal = 10) == 2\n assert candidate(nums = [999999, 999999, 999999],limit = 1000000,goal = -2999997) == 6\n assert candidate(nums = [5, 10, -15, 20, -25, 30, -35, 40, -45, 50],limit = 10,goal = 100) == 7\n assert candidate(nums = [999999, -999999, 999999, -999999, 999999, -999999],limit = 1000000,goal = 0) == 0\n assert candidate(nums = [-5, -4, -3, -2, -1],limit = 3,goal = 15) == 10\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],limit = 1,goal = -20) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 1,goal = 55) == 0\n assert candidate(nums = [1000000, -1000000, 1000000],limit = 1000000,goal = 3000000) == 2\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],limit = 3,goal = -50) == 2\n assert candidate(nums = [123456, -654321, 111111, -222222, 333333, -444444],limit = 500000,goal = -1000000) == 1\n assert candidate(nums = [999999, 999998, 999997, 999996],limit = 999999,goal = 3999990) == 0\n assert candidate(nums = [1000000, -1000000, 500000],limit = 1000000,goal = 0) == 1\n assert candidate(nums = [1000, -1000, 1000, -1000],limit = 1000,goal = 1000) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 10,goal = 55) == 0\n assert candidate(nums = [5, -5, 5, -5, 5],limit = 10,goal = -15) == 2\n assert candidate(nums = [10, -10, 20, -20, 30, -30],limit = 5,goal = 15) == 3\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000],limit = 100000,goal = 1000000) == 5\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],limit = 1,goal = -5) == 5\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 1,goal = -15) == 30\n assert candidate(nums = [-1000000, -2000000, -3000000],limit = 1000000,goal = -10000000) == 4\n assert candidate(nums = [100, -50, 25],limit = 100,goal = 200) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 1,goal = 15) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],limit = 50,goal = 500) == 1\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5],limit = 5,goal = -10) == 2\n assert candidate(nums = [100, -100, 50, -50],limit = 50,goal = 0) == 0\n assert candidate(nums = [1000000, -1000000, 500000],limit = 1000000,goal = 1000000) == 1\n assert candidate(nums = [123456, -123456, 234567, -234567],limit = 100000,goal = -345678) == 4\n assert candidate(nums = [-1, -2, -3, -4, -5],limit = 3,goal = -15) == 0\n assert candidate(nums = [123456, -654321, 789012, -321098],limit = 100000,goal = 500000) == 6\n assert candidate(nums = [-100, 100, -100, 100],limit = 100,goal = 0) == 0\n assert candidate(nums = [-100000, 100000, -100000, 100000, -100000],limit = 100000,goal = 50000) == 2\n assert candidate(nums = [1000000, -1000000, 500000, -500000],limit = 100000,goal = 0) == 0\n assert candidate(nums = [100, 200, 300, 400, 500],limit = 100,goal = 1500) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 5,goal = 50) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],limit = 1,goal = 5) == 5\n assert candidate(nums = [-100000, 50000, 25000, -12500, 6250],limit = 10000,goal = -100000) == 7\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000],limit = 100000,goal = 600000) == 1\n assert candidate(nums = [1000, -1000, 2000, -2000, 3000],limit = 1000,goal = 5000) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 1,goal = 10) == 0\n assert candidate(nums = [5, -5, 5, -5],limit = 5,goal = 10) == 2\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],limit = 1,goal = 1) == 1\n assert candidate(nums = [-5, 5, -5, 5, -5],limit = 5,goal = 0) == 1\n assert candidate(nums = [1000000],limit = 500000,goal = 2000000) == 2\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],limit = 10,goal = 0) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 5,goal = 10) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],limit = 10,goal = 0) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],limit = 1,goal = 0) == 0\n assert candidate(nums = [-999999, -999999, -999999],limit = 1000000,goal = 2999997) == 6\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],limit = 1,goal = -15) == 5\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],limit = 3,goal = 0) == 19\n assert candidate(nums = [-1, -1, -1, -1, -1],limit = 3,goal = 5) == 4\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],limit = 2,goal = 0) == 0\n assert candidate(nums = [1, -1, 1, -1, 1],limit = 1,goal = -1) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],limit = 50,goal = 0) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 5,goal = 55) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 2,goal = 20) == 3\n assert candidate(nums = [-5, 3, 2, -4, 1],limit = 5,goal = -10) == 2\n assert candidate(nums = [999999, -999999, 999999, -999999, 999999],limit = 1000000,goal = 4999995) == 4\n assert candidate(nums = [-100, 100, -100, 100, -100],limit = 50,goal = 0) == 2\n assert candidate(nums = [1, 2, 3, 4, 5],limit = 2,goal = 0) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 3,goal = 55) == 0\n assert candidate(nums = [1000000, 1000000, 1000000],limit = 500000,goal = 500000) == 5\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],limit = 5,goal = -55) == 0\n assert candidate(nums = [-1, 0, 1],limit = 1,goal = -1000000) == 1000000\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],limit = 2,goal = -30) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 3,goal = 20) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 1,goal = 5) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 1,goal = 20) == 10\n assert candidate(nums = [-999999, -999999, -999999, -999999, -999999],limit = 1000000,goal = -5000000) == 1\n assert candidate(nums = [1, -2, 3, -4, 5],limit = 5,goal = 0) == 1\n assert candidate(nums = [999999, 999999, 999999, 999999, 999999],limit = 1000000,goal = 5000000) == 1\n assert candidate(nums = [-1000000, -1000000, -1000000, -1000000, -1000000],limit = 1000000,goal = 0) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],limit = 10,goal = 5) == 1\n assert candidate(nums = [123456, -234567, 345678, -456789, 567890],limit = 100000,goal = 123456789) == 1232\n assert candidate(nums = [-999999, -999998, -999997, -999996],limit = 999999,goal = -3999990) == 0\n assert candidate(nums = [-10, 20, -30, 40],limit = 15,goal = 0) == 2\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],limit = 10,goal = -55) == 0\n assert candidate(nums = [1000000, 2000000, 3000000],limit = 1000000,goal = 10000000) == 4\n assert candidate(nums = [500000, 500000, 500000, 500000, 500000],limit = 1000000,goal = 500000) == 2\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],limit = 1000000,goal = 10000000) == 10\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],limit = 100,goal = 500) == 5\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],limit = 2,goal = -20) == 5\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],limit = 5,goal = 0) == 11\n assert candidate(nums = [-10, -20, -30, -40, -50],limit = 10,goal = 150) == 30\n assert candidate(nums = [10, 20, 30, 40, 50],limit = 5,goal = 150) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "limit", "goal"], "leetcode_dataset_entry_point": "Solution().minElements", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minElements(vector& nums, int limit, int goal) {", "container": "Solution", "callable": "minElements", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "limit", "type": "int"}, {"name": "goal", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1786, "task_id": "number-of-restricted-paths-from-first-to-last-node", "difficulty": "Medium", "problem_description": "There is an undirected weighted connected graph. You are given a positive integer n which denotes that the graph has n nodes labeled from 1 to n, and an array edges where each edges[i] = [ui, vi, weighti] denotes that there is an edge between nodes ui and vi with weight equal to weighti.\nA path from node start to node end is a sequence of nodes [z0, z1, z2, ..., zk] such that z0 = start and zk = end and there is an edge between zi and zi+1 where 0 <= i <= k-1.\nThe distance of a path is the sum of the weights on the edges of the path. Let distanceToLastNode(x) denote the shortest distance of a path between node n and node x. A restricted path is a path that also satisfies that distanceToLastNode(zi) > distanceToLastNode(zi+1) where 0 <= i <= k-1.\nReturn the number of restricted paths from node 1 to node n. Since that number may be too large, return it modulo 109 + 7.\n \nExample 1:\n\n\nInput: n = 5, edges = [[1,2,3],[1,3,3],[2,3,1],[1,4,2],[5,2,2],[3,5,1],[5,4,10]]\nOutput: 3\nExplanation: Each circle contains the node number in black and its distanceToLastNode value in blue. The three restricted paths are:\n1) 1 --> 2 --> 5\n2) 1 --> 2 --> 3 --> 5\n3) 1 --> 3 --> 5\n\nExample 2:\n\n\nInput: n = 7, edges = [[1,3,1],[4,1,2],[7,3,4],[2,5,3],[5,6,1],[6,7,2],[7,5,3],[2,6,4]]\nOutput: 1\nExplanation: Each circle contains the node number in black and its distanceToLastNode value in blue. The only restricted path is 1 --> 3 --> 7.\n\n \nConstraints:\n\n1 <= n <= 2 * 104\nn - 1 <= edges.length <= 4 * 104\nedges[i].length == 3\n1 <= ui, vi <= n\nui != vi\n1 <= weighti <= 105\nThere is at most one edge between any two nodes.\nThere is at least one path between any two nodes.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 1, 4]]) == 1\n assert candidate(n = 3,edges = [[1, 2, 5], [1, 3, 6], [2, 3, 1]]) == 2\n assert candidate(n = 7,edges = [[1, 3, 1], [4, 1, 2], [7, 3, 4], [2, 5, 3], [5, 6, 1], [6, 7, 2], [7, 5, 3], [2, 6, 4]]) == 1\n assert candidate(n = 6,edges = [[1, 2, 2], [1, 3, 4], [2, 4, 3], [3, 4, 1], [4, 5, 2], [5, 6, 1]]) == 2\n assert candidate(n = 5,edges = [[1, 2, 3], [1, 3, 3], [2, 3, 1], [1, 4, 2], [5, 2, 2], [3, 5, 1], [5, 4, 10]]) == 3\n assert candidate(n = 25,edges = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1], [19, 20, 1], [20, 21, 1], [21, 22, 1], [22, 23, 1], [23, 24, 1], [24, 25, 1], [1, 25, 5], [2, 24, 5], [3, 23, 5], [4, 22, 5], [5, 21, 5], [6, 20, 5], [7, 19, 5], [8, 18, 5], [9, 17, 5], [10, 16, 5], [11, 15, 5], [12, 14, 5], [13, 13, 5]]) == 1\n assert candidate(n = 15,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [1, 15, 15]]) == 1\n assert candidate(n = 12,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [1, 3, 12], [2, 4, 13], [3, 5, 14], [4, 6, 15], [5, 7, 16], [6, 8, 17], [7, 9, 18], [8, 10, 19], [9, 11, 20], [10, 12, 21], [1, 4, 22], [2, 5, 23], [3, 6, 24], [4, 7, 25], [5, 8, 26], [6, 9, 27], [7, 10, 28], [8, 11, 29], [9, 12, 30]]) == 504\n assert candidate(n = 10,edges = [[1, 2, 5], [2, 3, 4], [3, 4, 3], [4, 5, 2], [5, 6, 1], [6, 7, 6], [7, 8, 5], [8, 9, 4], [9, 10, 3]]) == 1\n assert candidate(n = 20,edges = [[1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [19, 20, 20], [1, 20, 10], [2, 19, 10], [3, 18, 10], [4, 17, 10], [5, 16, 10], [6, 15, 10], [7, 14, 10], [8, 13, 10], [9, 12, 10], [10, 11, 10]]) == 1\n assert candidate(n = 10,edges = [[1, 2, 1], [1, 3, 4], [2, 4, 2], [3, 4, 1], [4, 5, 3], [5, 6, 2], [6, 7, 1], [7, 8, 2], [8, 9, 3], [9, 10, 1]]) == 2\n assert candidate(n = 8,edges = [[1, 2, 5], [2, 3, 4], [3, 4, 3], [4, 5, 2], [5, 6, 1], [6, 7, 6], [7, 8, 7], [8, 1, 8], [2, 5, 9], [3, 6, 10], [4, 7, 11], [1, 8, 12]]) == 2\n assert candidate(n = 10,edges = [[1, 2, 2], [2, 3, 3], [3, 4, 1], [4, 5, 2], [5, 6, 1], [6, 7, 3], [7, 8, 2], [8, 9, 1], [9, 10, 2], [1, 10, 5]]) == 1\n assert candidate(n = 50,edges = [[1, 2, 1000], [2, 3, 2000], [3, 4, 3000], [4, 5, 4000], [5, 6, 5000], [6, 7, 6000], [7, 8, 7000], [8, 9, 8000], [9, 10, 9000], [10, 11, 10000], [11, 12, 11000], [12, 13, 12000], [13, 14, 13000], [14, 15, 14000], [15, 16, 15000], [16, 17, 16000], [17, 18, 17000], [18, 19, 18000], [19, 20, 19000], [20, 21, 20000], [21, 22, 21000], [22, 23, 22000], [23, 24, 23000], [24, 25, 24000], [25, 26, 25000], [26, 27, 26000], [27, 28, 27000], [28, 29, 28000], [29, 30, 29000], [30, 31, 30000], [31, 32, 31000], [32, 33, 32000], [33, 34, 33000], [34, 35, 34000], [35, 36, 35000], [36, 37, 36000], [37, 38, 37000], [38, 39, 38000], [39, 40, 39000], [40, 41, 40000], [41, 42, 41000], [42, 43, 42000], [43, 44, 43000], [44, 45, 44000], [45, 46, 45000], [46, 47, 46000], [47, 48, 47000], [48, 49, 48000], [49, 50, 49000]]) == 1\n assert candidate(n = 15,edges = [[1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40], [8, 9, 45], [9, 10, 50], [10, 11, 55], [11, 12, 60], [12, 13, 65], [13, 14, 70], [14, 15, 75]]) == 1\n assert candidate(n = 15,edges = [[1, 2, 5], [1, 3, 3], [2, 4, 7], [3, 4, 2], [4, 5, 5], [5, 6, 4], [6, 7, 8], [7, 8, 2], [8, 9, 1], [9, 10, 2], [10, 11, 3], [11, 12, 1], [12, 13, 5], [13, 14, 4], [14, 15, 6]]) == 1\n assert candidate(n = 8,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [1, 3, 8], [2, 4, 9], [3, 5, 10], [4, 6, 11], [5, 7, 12], [6, 8, 13]]) == 21\n assert candidate(n = 10,edges = [[1, 2, 4], [1, 3, 3], [2, 4, 2], [3, 4, 1], [4, 5, 5], [5, 6, 3], [6, 7, 2], [7, 8, 1], [8, 9, 4], [9, 10, 5], [2, 5, 3], [3, 6, 4], [5, 8, 2], [6, 9, 1]]) == 4\n assert candidate(n = 15,edges = [[1, 2, 2], [1, 3, 3], [2, 4, 5], [3, 5, 4], [4, 6, 1], [5, 7, 2], [6, 8, 3], [7, 9, 4], [8, 10, 5], [9, 11, 1], [10, 12, 2], [11, 13, 3], [12, 14, 4], [13, 15, 5], [4, 7, 2], [5, 8, 1], [6, 9, 4], [7, 10, 3], [8, 11, 2], [9, 12, 1], [10, 13, 4], [11, 14, 5], [12, 15, 1]]) == 7\n assert candidate(n = 30,edges = [[1, 2, 5], [2, 3, 4], [3, 4, 1], [4, 5, 3], [5, 6, 2], [6, 7, 4], [7, 8, 3], [8, 9, 5], [9, 10, 4], [10, 11, 2], [11, 12, 1], [12, 13, 3], [13, 14, 2], [14, 15, 4], [15, 16, 1], [16, 17, 2], [17, 18, 3], [18, 19, 2], [19, 20, 1], [20, 21, 5], [21, 22, 4], [22, 23, 3], [23, 24, 2], [24, 25, 4], [25, 26, 3], [26, 27, 5], [27, 28, 1], [28, 29, 2], [29, 30, 3], [30, 1, 4]]) == 1\n assert candidate(n = 25,edges = [[1, 2, 20], [1, 3, 10], [2, 4, 5], [2, 5, 15], [3, 6, 1], [3, 7, 20], [4, 8, 25], [4, 9, 1], [5, 9, 30], [5, 10, 1], [6, 11, 10], [6, 12, 25], [7, 12, 15], [7, 13, 1], [8, 14, 20], [9, 14, 5], [10, 14, 10], [11, 15, 25], [11, 16, 1], [12, 16, 30], [12, 17, 5], [13, 17, 10], [14, 18, 15], [15, 18, 1], [16, 19, 20], [17, 19, 30], [18, 20, 10], [19, 20, 25], [20, 21, 1], [21, 22, 5], [22, 23, 10], [23, 24, 15], [24, 25, 20]]) == 2\n assert candidate(n = 30,edges = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500], [6, 7, 600], [7, 8, 700], [8, 9, 800], [9, 10, 900], [10, 11, 1000], [11, 12, 1100], [12, 13, 1200], [13, 14, 1300], [14, 15, 1400], [15, 16, 1500], [16, 17, 1600], [17, 18, 1700], [18, 19, 1800], [19, 20, 1900], [20, 21, 2000], [21, 22, 2100], [22, 23, 2200], [23, 24, 2300], [24, 25, 2400], [25, 26, 2500], [26, 27, 2600], [27, 28, 2700], [28, 29, 2800], [29, 30, 2900]]) == 1\n assert candidate(n = 8,edges = [[1, 2, 5], [1, 3, 6], [2, 4, 2], [3, 5, 4], [4, 5, 3], [4, 6, 1], [5, 7, 2], [6, 8, 3], [7, 8, 1], [2, 3, 4], [4, 7, 6], [5, 6, 2], [3, 8, 5], [2, 6, 3]]) == 8\n assert candidate(n = 20,edges = [[1, 2, 2], [1, 3, 1], [2, 4, 3], [2, 5, 4], [3, 6, 5], [3, 7, 6], [4, 8, 7], [4, 9, 8], [5, 10, 9], [5, 11, 10], [6, 12, 11], [6, 13, 12], [7, 14, 13], [7, 15, 14], [8, 16, 15], [9, 17, 16], [10, 18, 17], [11, 19, 18], [12, 20, 19], [13, 18, 20], [14, 19, 11], [15, 20, 12], [16, 17, 13], [17, 18, 14], [18, 19, 15], [19, 20, 16]]) == 2\n assert candidate(n = 15,edges = [[1, 2, 10], [2, 3, 5], [3, 4, 15], [4, 5, 20], [5, 6, 25], [6, 7, 30], [7, 8, 35], [8, 9, 40], [9, 10, 45], [10, 11, 50], [11, 12, 55], [12, 13, 60], [13, 14, 65], [14, 15, 70], [1, 3, 5], [2, 4, 5], [3, 5, 5], [4, 6, 5], [5, 7, 5], [6, 8, 5], [7, 9, 5], [8, 10, 5], [9, 11, 5], [10, 12, 5], [11, 13, 5], [12, 14, 5], [13, 15, 5]]) == 1\n assert candidate(n = 10,edges = [[1, 2, 4], [1, 3, 2], [2, 4, 1], [2, 5, 6], [3, 5, 3], [4, 6, 2], [5, 6, 1], [6, 7, 5], [6, 8, 3], [7, 9, 4], [8, 9, 2], [9, 10, 1]]) == 6\n assert candidate(n = 20,edges = [[1, 2, 2], [1, 3, 1], [2, 4, 3], [2, 5, 4], [3, 5, 2], [4, 6, 5], [4, 7, 6], [5, 6, 7], [5, 8, 8], [6, 9, 1], [7, 9, 2], [8, 10, 3], [9, 10, 4], [10, 11, 5], [11, 12, 6], [11, 13, 7], [12, 14, 8], [13, 14, 9], [14, 15, 10], [15, 16, 1], [16, 17, 2], [16, 18, 3], [17, 19, 4], [18, 19, 5], [19, 20, 6]]) == 24\n assert candidate(n = 20,edges = [[1, 2, 10], [2, 3, 9], [3, 4, 8], [4, 5, 7], [5, 6, 6], [6, 7, 5], [7, 8, 4], [8, 9, 3], [9, 10, 2], [10, 11, 1], [11, 12, 2], [12, 13, 3], [13, 14, 4], [14, 15, 5], [15, 16, 6], [16, 17, 7], [17, 18, 8], [18, 19, 9], [19, 20, 10], [1, 20, 15], [2, 19, 16], [3, 18, 17], [4, 17, 18], [5, 16, 19], [6, 15, 20]]) == 1\n assert candidate(n = 15,edges = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100], [11, 12, 110], [12, 13, 120], [13, 14, 130], [14, 15, 140], [1, 3, 15], [3, 5, 25], [5, 7, 35], [7, 9, 45], [9, 11, 55], [11, 13, 65], [13, 15, 75], [2, 4, 25], [4, 6, 35], [6, 8, 45], [8, 10, 55], [10, 12, 65], [12, 14, 75], [2, 5, 30], [5, 8, 40], [8, 11, 50], [11, 14, 60], [3, 6, 35], [6, 9, 45], [9, 12, 55], [12, 15, 65], [4, 7, 45], [7, 10, 55], [10, 13, 65], [4, 8, 50], [8, 12, 60], [8, 13, 65], [10, 14, 75], [10, 15, 80], [5, 9, 55], [9, 13, 70], [5, 10, 60], [10, 15, 90]]) == 174\n assert candidate(n = 12,edges = [[1, 2, 5], [1, 3, 3], [2, 4, 2], [3, 4, 1], [4, 5, 4], [5, 6, 5], [6, 7, 4], [7, 8, 3], [8, 9, 2], [9, 10, 1], [10, 11, 6], [11, 12, 7]]) == 2\n assert candidate(n = 10,edges = [[1, 2, 5], [2, 3, 10], [3, 4, 15], [4, 5, 20], [5, 6, 25], [6, 7, 30], [7, 8, 35], [8, 9, 40], [9, 10, 45], [1, 3, 2], [3, 5, 3], [5, 7, 4], [7, 9, 5], [2, 4, 7], [4, 6, 8], [6, 8, 9], [8, 10, 11], [1, 4, 6], [4, 7, 7], [7, 10, 8]]) == 3\n assert candidate(n = 20,edges = [[1, 2, 10], [1, 3, 20], [2, 4, 15], [3, 4, 5], [4, 5, 25], [5, 6, 10], [6, 7, 30], [7, 8, 15], [8, 9, 5], [9, 10, 25], [10, 11, 10], [11, 12, 30], [12, 13, 15], [13, 14, 5], [14, 15, 25], [15, 16, 10], [16, 17, 30], [17, 18, 15], [18, 19, 5], [19, 20, 25]]) == 2\n assert candidate(n = 50,edges = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1], [19, 20, 1], [20, 21, 1], [21, 22, 1], [22, 23, 1], [23, 24, 1], [24, 25, 1], [25, 26, 1], [26, 27, 1], [27, 28, 1], [28, 29, 1], [29, 30, 1], [30, 31, 1], [31, 32, 1], [32, 33, 1], [33, 34, 1], [34, 35, 1], [35, 36, 1], [36, 37, 1], [37, 38, 1], [38, 39, 1], [39, 40, 1], [40, 41, 1], [41, 42, 1], [42, 43, 1], [43, 44, 1], [44, 45, 1], [45, 46, 1], [46, 47, 1], [47, 48, 1], [48, 49, 1], [49, 50, 1], [1, 50, 10], [2, 49, 10], [3, 48, 10], [4, 47, 10], [5, 46, 10], [6, 45, 10], [7, 44, 10], [8, 43, 10], [9, 42, 10], [10, 41, 10], [11, 40, 10], [12, 39, 10], [13, 38, 10], [14, 37, 10], [15, 36, 10], [16, 35, 10], [17, 34, 10], [18, 33, 10], [19, 32, 10], [20, 31, 10], [21, 30, 10], [22, 29, 10], [23, 28, 10], [24, 27, 10], [25, 26, 10]]) == 1\n assert candidate(n = 15,edges = [[1, 2, 10], [1, 3, 20], [2, 4, 5], [2, 5, 7], [3, 5, 3], [4, 6, 2], [4, 7, 8], [5, 7, 1], [5, 8, 6], [6, 9, 4], [7, 9, 3], [8, 10, 1], [9, 10, 5], [10, 11, 3], [11, 12, 4], [12, 13, 1], [12, 14, 7], [13, 15, 2], [14, 15, 6]]) == 5\n assert candidate(n = 20,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 1], [4, 5, 3], [5, 6, 2], [6, 7, 4], [7, 8, 1], [8, 9, 2], [9, 10, 3], [10, 11, 2], [11, 12, 1], [12, 13, 3], [13, 14, 2], [14, 15, 4], [15, 16, 1], [16, 17, 2], [17, 18, 3], [18, 19, 2], [19, 20, 1], [20, 1, 5]]) == 1\n assert candidate(n = 20,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15], [16, 17, 16], [17, 18, 17], [18, 19, 18], [19, 20, 19], [1, 3, 3], [3, 5, 5], [5, 7, 7], [7, 9, 9], [9, 11, 11], [11, 13, 13], [13, 15, 15], [15, 17, 17], [17, 19, 19], [2, 4, 4], [4, 6, 6], [6, 8, 8], [8, 10, 10], [10, 12, 12], [12, 14, 14], [14, 16, 16], [16, 18, 18], [2, 5, 5], [5, 8, 8], [8, 11, 11], [11, 14, 14], [14, 17, 17], [3, 6, 6], [6, 9, 9], [9, 12, 12], [12, 15, 15], [12, 16, 16], [15, 18, 18], [4, 7, 7], [7, 10, 10], [10, 13, 13], [10, 14, 14], [13, 16, 16], [6, 11, 11], [11, 16, 16], [11, 17, 17], [7, 12, 12], [12, 17, 17], [12, 18, 18]]) == 494\n assert candidate(n = 20,edges = [[1, 2, 2], [1, 3, 3], [2, 4, 1], [2, 5, 4], [3, 6, 5], [3, 7, 7], [4, 8, 8], [4, 9, 9], [5, 9, 2], [5, 10, 3], [6, 11, 6], [6, 12, 10], [7, 12, 4], [7, 13, 5], [8, 14, 3], [9, 14, 4], [10, 14, 7], [11, 15, 1], [11, 16, 2], [12, 16, 3], [12, 17, 8], [13, 17, 9], [14, 18, 6], [15, 18, 5], [16, 19, 4], [17, 19, 3], [18, 20, 10], [19, 20, 7]]) == 6\n assert candidate(n = 20,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15], [16, 17, 16], [17, 18, 17], [18, 19, 18], [19, 20, 19]]) == 1\n assert candidate(n = 10,edges = [[1, 2, 5], [1, 3, 3], [2, 4, 2], [2, 5, 6], [3, 4, 1], [3, 6, 4], [4, 7, 7], [5, 7, 8], [5, 8, 2], [6, 8, 3], [7, 9, 5], [8, 9, 6], [8, 10, 9], [9, 10, 10]]) == 2\n assert candidate(n = 50,edges = [[1, 2, 5], [2, 3, 4], [3, 4, 1], [4, 5, 3], [5, 6, 2], [6, 7, 4], [7, 8, 3], [8, 9, 5], [9, 10, 4], [10, 11, 2], [11, 12, 1], [12, 13, 3], [13, 14, 2], [14, 15, 4], [15, 16, 1], [16, 17, 2], [17, 18, 3], [18, 19, 2], [19, 20, 1], [20, 21, 5], [21, 22, 4], [22, 23, 3], [23, 24, 2], [24, 25, 4], [25, 26, 3], [26, 27, 5], [27, 28, 1], [28, 29, 2], [29, 30, 3], [30, 31, 4], [31, 32, 5], [32, 33, 4], [33, 34, 3], [34, 35, 2], [35, 36, 1], [36, 37, 2], [37, 38, 3], [38, 39, 2], [39, 40, 1], [40, 41, 5], [41, 42, 4], [42, 43, 3], [43, 44, 2], [44, 45, 4], [45, 46, 3], [46, 47, 5], [47, 48, 1], [48, 49, 2], [49, 50, 3], [50, 1, 4]]) == 1\n assert candidate(n = 15,edges = [[1, 2, 10], [1, 3, 5], [2, 4, 3], [2, 5, 4], [3, 6, 2], [3, 7, 6], [4, 8, 7], [4, 9, 8], [5, 9, 3], [5, 10, 1], [6, 11, 5], [6, 12, 3], [7, 12, 2], [7, 13, 9], [8, 14, 5], [9, 14, 6], [10, 14, 4], [11, 15, 7], [12, 15, 8], [13, 15, 3]]) == 4\n assert candidate(n = 50,edges = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1], [19, 20, 1], [20, 21, 1], [21, 22, 1], [22, 23, 1], [23, 24, 1], [24, 25, 1], [25, 26, 1], [26, 27, 1], [27, 28, 1], [28, 29, 1], [29, 30, 1], [30, 31, 1], [31, 32, 1], [32, 33, 1], [33, 34, 1], [34, 35, 1], [35, 36, 1], [36, 37, 1], [37, 38, 1], [38, 39, 1], [39, 40, 1], [40, 41, 1], [41, 42, 1], [42, 43, 1], [43, 44, 1], [44, 45, 1], [45, 46, 1], [46, 47, 1], [47, 48, 1], [48, 49, 1], [49, 50, 1], [1, 50, 50]]) == 2\n assert candidate(n = 15,edges = [[1, 2, 2], [2, 3, 3], [3, 4, 2], [4, 5, 1], [5, 6, 2], [6, 7, 3], [7, 8, 4], [8, 9, 2], [9, 10, 1], [10, 11, 3], [11, 12, 2], [12, 13, 1], [13, 14, 3], [14, 15, 2], [15, 1, 5]]) == 1\n assert candidate(n = 10,edges = [[1, 2, 2], [1, 3, 4], [2, 4, 3], [3, 4, 1], [4, 5, 2], [5, 6, 1], [6, 7, 5], [7, 8, 1], [8, 9, 4], [9, 10, 3], [10, 1, 7]]) == 1\n assert candidate(n = 10,edges = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [1, 10, 5], [2, 8, 4], [3, 9, 3], [4, 7, 2], [5, 6, 1]]) == 1\n"}, "metadata": {"canonical_parameter_names": ["n", "edges"], "leetcode_dataset_entry_point": "Solution().countRestrictedPaths", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countRestrictedPaths(int n, vector>& edges) {", "container": "Solution", "callable": "countRestrictedPaths", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1787, "task_id": "make-the-xor-of-all-segments-equal-to-zero", "difficulty": "Hard", "problem_description": "You are given an array nums​​​ and an integer k​​​​​. The XOR of a segment [left, right] where left <= right is the XOR of all the elements with indices between left and right, inclusive: nums[left] XOR nums[left+1] XOR ... XOR nums[right].\nReturn the minimum number of elements to change in the array such that the XOR of all segments of size k​​​​​​ is equal to zero.\n \nExample 1:\n\nInput: nums = [1,2,0,3,0], k = 1\nOutput: 3\nExplanation: Modify the array from [1,2,0,3,0] to from [0,0,0,0,0].\n\nExample 2:\n\nInput: nums = [3,4,5,2,1,7,3,4,7], k = 3\nOutput: 3\nExplanation: Modify the array from [3,4,5,2,1,7,3,4,7] to [3,4,7,3,4,7,3,4,7].\n\nExample 3:\n\nInput: nums = [1,2,4,1,2,5,1,2,6], k = 3\nOutput: 3\nExplanation: Modify the array from [1,2,4,1,2,5,1,2,6] to [1,2,3,1,2,3,1,2,3].\n \nConstraints:\n\n1 <= k <= nums.length <= 2000\n​​​​​​0 <= nums[i] < 210\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == 0\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 5) == 6\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5],k = 5) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],k = 4) == 4\n assert candidate(nums = [3, 4, 5, 2, 1, 7, 3, 4, 7],k = 3) == 3\n assert candidate(nums = [0, 0, 0, 0, 0],k = 2) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 2) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 10\n assert candidate(nums = [1, 2, 4, 1, 2, 5, 1, 2, 6],k = 3) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1],k = 6) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 2) == 9\n assert candidate(nums = [1, 1, 1, 1, 1],k = 5) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 1) == 10\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 10) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90],k = 2) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 9) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17],k = 3) == 7\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 4) == 6\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 6) == 0\n assert candidate(nums = [1, 3, 5, 7, 9],k = 5) == 1\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 10) == 0\n assert candidate(nums = [1, 2, 0, 3, 0],k = 1) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 4) == 11\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 5\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 10) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 10) == 11\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 6) == 5\n assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 4) == 12\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19],k = 8) == 30\n assert candidate(nums = [3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1],k = 2) == 15\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 3) == 24\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 0\n assert candidate(nums = [255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240],k = 5) == 12\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 15) == 6\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 5) == 10\n assert candidate(nums = [31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31],k = 15) == 2\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],k = 5) == 16\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6],k = 5) == 14\n assert candidate(nums = [13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 13, 12, 11],k = 4) == 24\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 15\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7],k = 8) == 26\n assert candidate(nums = [1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023],k = 15) == 1\n assert candidate(nums = [5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6, 5, 6],k = 3) == 22\n assert candidate(nums = [1023, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 3) == 9\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4],k = 7) == 21\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 17) == 5\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 8) == 8\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0],k = 3) == 42\n assert candidate(nums = [511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540],k = 15) == 16\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 18) == 5\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 10) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 9, 8, 7, 6, 5, 4],k = 5) == 24\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7, 5, 1, 0, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 8, 9, 9, 8, 6, 2, 8, 0, 3, 4, 8, 2, 5, 3, 4, 2, 1, 1, 7, 0, 6, 7, 9],k = 13) == 69\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 7) == 23\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15],k = 10) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3],k = 5) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 10) == 31\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 8\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 15) == 0\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 20) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 11) == 69\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 20) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 6) == 7\n assert candidate(nums = [5, 7, 9, 11, 13, 5, 7, 9, 11, 13],k = 5) == 2\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],k = 5) == 27\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0, 8, 7, 6, 5, 4, 3, 2, 1, 0, 8, 7, 6, 5, 4, 3, 2, 1, 0, 8, 7, 6],k = 5) == 25\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 10) == 0\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15],k = 5) == 23\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],k = 10) == 11\n assert candidate(nums = [512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],k = 5) == 12\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 6\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 8) == 24\n assert candidate(nums = [8, 4, 2, 1, 0, 1, 2, 4, 8, 4, 2, 1, 0, 1, 2, 4, 8, 4, 2, 1],k = 5) == 13\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],k = 20) == 20\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 7) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],k = 5) == 26\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 3) == 15\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 3) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 4) == 16\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200],k = 17) == 184\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],k = 15) == 16\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1, 0, 255, 128, 64, 32, 16, 8, 4, 2, 1, 0, 255, 128, 64, 32, 16, 8, 4, 2, 1, 0],k = 10) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 11\n assert candidate(nums = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4],k = 7) == 13\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],k = 7) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 15\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 12) == 38\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],k = 10) == 20\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14],k = 6) == 22\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175, 182, 189, 196, 203, 210],k = 15) == 15\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12],k = 10) == 11\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2],k = 7) == 19\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 8) == 0\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 3) == 10\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9],k = 10) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0],k = 10) == 3\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390],k = 15) == 24\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1, 0, 255, 128, 64, 32, 16, 8, 4, 2, 1, 0, 255, 128, 64, 32, 16, 8, 4, 2, 1, 0],k = 7) == 23\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 25) == 1\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 16\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30],k = 8) == 52\n assert candidate(nums = [17, 255, 8, 19, 7, 23, 15, 42, 99, 1023, 22, 31, 56, 78, 90, 111, 132, 153, 174, 195],k = 7) == 13\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60],k = 10) == 21\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0],k = 6) == 5\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 7) == 24\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0, 1, 3, 7, 15, 31, 63, 127, 255, 511],k = 10) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 5) == 25\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minChanges", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minChanges(vector& nums, int k) {", "container": "Solution", "callable": "minChanges", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1790, "task_id": "check-if-one-string-swap-can-make-strings-equal", "difficulty": "Easy", "problem_description": "You are given two strings s1 and s2 of equal length. A string swap is an operation where you choose two indices in a string (not necessarily different) and swap the characters at these indices.\nReturn true if it is possible to make both strings equal by performing at most one string swap on exactly one of the strings. Otherwise, return false.\n \nExample 1:\n\nInput: s1 = \"bank\", s2 = \"kanb\"\nOutput: true\nExplanation: For example, swap the first character with the last character of s2 to make \"bank\".\n\nExample 2:\n\nInput: s1 = \"attack\", s2 = \"defend\"\nOutput: false\nExplanation: It is impossible to make them equal with one string swap.\n\nExample 3:\n\nInput: s1 = \"kelb\", s2 = \"kelb\"\nOutput: true\nExplanation: The two strings are already equal, so no string swap operation is required.\n\n \nConstraints:\n\n1 <= s1.length, s2.length <= 100\ns1.length == s2.length\ns1 and s2 consist of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s1 = \"attack\",s2 = \"defend\") == False\n assert candidate(s1 = \"bank\",s2 = \"kanb\") == True\n assert candidate(s1 = \"abcde\",s2 = \"abced\") == True\n assert candidate(s1 = \"abcd\",s2 = \"abdc\") == True\n assert candidate(s1 = \"aaa\",s2 = \"aaa\") == True\n assert candidate(s1 = \"kelb\",s2 = \"kelb\") == True\n assert candidate(s1 = \"aabb\",s2 = \"abab\") == True\n assert candidate(s1 = \"abcd\",s2 = \"dcba\") == False\n assert candidate(s1 = \"algorithm\",s2 = \"logarithm\") == False\n assert candidate(s1 = \"almost\",s2 = \"almost\") == True\n assert candidate(s1 = \"abcdefg\",s2 = \"ghfedcb\") == False\n assert candidate(s1 = \"xyzabc\",s2 = \"yzabxc\") == False\n assert candidate(s1 = \"abcdefg\",s2 = \"fedcbag\") == False\n assert candidate(s1 = \"abcdefg\",s2 = \"abcdefx\") == False\n assert candidate(s1 = \"aaaaabbbb\",s2 = \"bbbbaaaa\") == False\n assert candidate(s1 = \"aabbcc\",s2 = \"ccbaab\") == False\n assert candidate(s1 = \"aabbcc\",s2 = \"aabbbc\") == False\n assert candidate(s1 = \"abacabadabacaba\",s2 = \"babacabadabacab\") == False\n assert candidate(s1 = \"mississippi\",s2 = \"missisppi\") == False\n assert candidate(s1 = \"aabbcc\",s2 = \"ccbbaa\") == False\n assert candidate(s1 = \"programming\",s2 = \"programminj\") == False\n assert candidate(s1 = \"samestr\",s2 = \"strsame\") == False\n assert candidate(s1 = \"hello\",s2 = \"hlelo\") == True\n assert candidate(s1 = \"abcdefg\",s2 = \"gfedcba\") == False\n assert candidate(s1 = \"abababab\",s2 = \"babababa\") == False\n assert candidate(s1 = \"abracadabra\",s2 = \"abracadabrb\") == False\n assert candidate(s1 = \"mississippi\",s2 = \"mississipsp\") == False\n assert candidate(s1 = \"palindrome\",s2 = \"lpadnrimoe\") == False\n assert candidate(s1 = \"aabbcc\",s2 = \"ccabba\") == False\n assert candidate(s1 = \"mississippi\",s2 = \"mississipip\") == True\n assert candidate(s1 = \"abcdefg\",s2 = \"abcdefg\") == True\n assert candidate(s1 = \"aabbcc\",s2 = \"bbaacc\") == False\n assert candidate(s1 = \"abcdexyz\",s2 = \"xyzabcde\") == False\n assert candidate(s1 = \"abcdxyz\",s2 = \"abczyxd\") == False\n assert candidate(s1 = \"abcdefgh\",s2 = \"hgfedcba\") == False\n assert candidate(s1 = \"abcde\",s2 = \"abcde\") == True\n assert candidate(s1 = \"banana\",s2 = \"anana\") == False\n assert candidate(s1 = \"ab\",s2 = \"ba\") == True\n assert candidate(s1 = \"hello\",s2 = \"olleh\") == False\n assert candidate(s1 = \"hello\",s2 = \"hallo\") == False\n assert candidate(s1 = \"abcdef\",s2 = \"abcfed\") == True\n assert candidate(s1 = \"abcdefg\",s2 = \"abcdefgh\") == True\n assert candidate(s1 = \"qwertyuiop\",s2 = \"qewrtyuipo\") == False\n assert candidate(s1 = \"mississippi\",s2 = \"mississippa\") == False\n assert candidate(s1 = \"programming\",s2 = \"prorgamming\") == True\n assert candidate(s1 = \"abcdefg\",s2 = \"abdecfg\") == False\n assert candidate(s1 = \"noon\",s2 = \"nnon\") == False\n assert candidate(s1 = \"hello\",s2 = \"ohell\") == False\n assert candidate(s1 = \"hello\",s2 = \"hxllo\") == False\n assert candidate(s1 = \"aaaabbbb\",s2 = \"bbbbaaaa\") == False\n assert candidate(s1 = \"abc\",s2 = \"acb\") == True\n assert candidate(s1 = \"hello\",s2 = \"lehho\") == False\n assert candidate(s1 = \"abcdexyz\",s2 = \"abcdefyz\") == False\n assert candidate(s1 = \"python\",s2 = \"pythno\") == True\n assert candidate(s1 = \"abracadabra\",s2 = \"abracadabra\") == True\n assert candidate(s1 = \"abcdefgh\",s2 = \"bcadefgh\") == False\n assert candidate(s1 = \"abacabadabacaba\",s2 = \"abacabadabacaba\") == True\n assert candidate(s1 = \"hello\",s2 = \"bello\") == False\n assert candidate(s1 = \"hello\",s2 = \"heoll\") == True\n assert candidate(s1 = \"abcdefghij\",s2 = \"abcdefghjk\") == False\n assert candidate(s1 = \"unique\",s2 = \"unqieu\") == False\n assert candidate(s1 = \"abcdabcd\",s2 = \"dcbaabcd\") == False\n assert candidate(s1 = \"abacax\",s2 = \"abacxa\") == True\n assert candidate(s1 = \"abcdefghij\",s2 = \"abcdefghij\") == True\n assert candidate(s1 = \"algorithm\",s2 = \"algorithn\") == False\n assert candidate(s1 = \"algorithm\",s2 = \"aloritghm\") == False\n assert candidate(s1 = \"abcdefg\",s2 = \"abcdegf\") == True\n assert candidate(s1 = \"aabbcc\",s2 = \"aaccbb\") == False\n assert candidate(s1 = \"almost\",s2 = \"alosmt\") == False\n assert candidate(s1 = \"racecar\",s2 = \"racecar\") == True\n assert candidate(s1 = \"mississippi\",s2 = \"mmissisippi\") == False\n assert candidate(s1 = \"abcdefgh\",s2 = \"efghabcd\") == False\n assert candidate(s1 = \"xyzz\",s2 = \"zzxy\") == False\n assert candidate(s1 = \"palindrome\",s2 = \"palindorme\") == True\n assert candidate(s1 = \"abcdef\",s2 = \"abcdef\") == True\n assert candidate(s1 = \"ab\",s2 = \"ab\") == True\n assert candidate(s1 = \"abcdef\",s2 = \"abcdeg\") == False\n assert candidate(s1 = \"oneone\",s2 = \"noonoe\") == False\n assert candidate(s1 = \"abcxyz\",s2 = \"xyzabc\") == False\n assert candidate(s1 = \"abac\",s2 = \"caba\") == False\n assert candidate(s1 = \"xyz\",s2 = \"zyx\") == True\n assert candidate(s1 = \"abracadabra\",s2 = \"abracadbrba\") == False\n assert candidate(s1 = \"abac\",s2 = \"abca\") == True\n assert candidate(s1 = \"same\",s2 = \"same\") == True\n assert candidate(s1 = \"abcdefgh\",s2 = \"abcdefgh\") == True\n assert candidate(s1 = \"abcdef\",s2 = \"fedcba\") == False\n assert candidate(s1 = \"abcdefghij\",s2 = \"abcdefghji\") == True\n assert candidate(s1 = \"abcde\",s2 = \"edcba\") == False\n assert candidate(s1 = \"swapping\",s2 = \"swapgnip\") == False\n assert candidate(s1 = \"aabbccdd\",s2 = \"ddccbbaa\") == False\n assert candidate(s1 = \"xyzz\",s2 = \"zyzz\") == False\n assert candidate(s1 = \"algorithm\",s2 = \"algorjthm\") == False\n assert candidate(s1 = \"xyzz\",s2 = \"zyxz\") == True\n assert candidate(s1 = \"aabbcc\",s2 = \"aabbdc\") == False\n assert candidate(s1 = \"abcdefghijk\",s2 = \"abcdefghijl\") == False\n assert candidate(s1 = \"ababab\",s2 = \"bababa\") == False\n assert candidate(s1 = \"abab\",s2 = \"baba\") == False\n assert candidate(s1 = \"mambo\",s2 = \"mambp\") == False\n assert candidate(s1 = \"abcdef\",s2 = \"abcdfe\") == True\n assert candidate(s1 = \"abdc\",s2 = \"abcd\") == True\n assert candidate(s1 = \"xyzz\",s2 = \"zyzx\") == True\n assert candidate(s1 = \"aabb\",s2 = \"bbaa\") == False\n assert candidate(s1 = \"same\",s2 = \"emsa\") == False\n assert candidate(s1 = \"abcdxyz\",s2 = \"abcdzyx\") == True\n assert candidate(s1 = \"mississippi\",s2 = \"mmississippi\") == False\n assert candidate(s1 = \"python\",s2 = \"ytonph\") == False\n assert candidate(s1 = \"xyzxyz\",s2 = \"zyxzyx\") == False\n assert candidate(s1 = \"aaaa\",s2 = \"aaaa\") == True\n"}, "metadata": {"canonical_parameter_names": ["s1", "s2"], "leetcode_dataset_entry_point": "Solution().areAlmostEqual", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool areAlmostEqual(string s1, string s2) {", "container": "Solution", "callable": "areAlmostEqual", "parameters": [{"name": "s1", "type": "string"}, {"name": "s2", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1791, "task_id": "find-center-of-star-graph", "difficulty": "Easy", "problem_description": "There is an undirected star graph consisting of n nodes labeled from 1 to n. A star graph is a graph where there is one center node and exactly n - 1 edges that connect the center node with every other node.\nYou are given a 2D integer array edges where each edges[i] = [ui, vi] indicates that there is an edge between the nodes ui and vi. Return the center of the given star graph.\n \nExample 1:\n\n\nInput: edges = [[1,2],[2,3],[4,2]]\nOutput: 2\nExplanation: As shown in the figure above, node 2 is connected to every other node, so 2 is the center.\n\nExample 2:\n\nInput: edges = [[1,2],[5,1],[1,3],[1,4]]\nOutput: 1\n\n \nConstraints:\n\n3 <= n <= 105\nedges.length == n - 1\nedges[i].length == 2\n1 <= ui, vi <= n\nui != vi\nThe given edges represent a valid star graph.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(edges = [[10, 20], [10, 30], [10, 40], [10, 50], [10, 60]]) == 10\n assert candidate(edges = [[3, 1], [1, 2], [1, 4], [1, 5]]) == 1\n assert candidate(edges = [[7, 3], [7, 4], [7, 2], [7, 5], [7, 6], [7, 1]]) == 7\n assert candidate(edges = [[10, 5], [10, 8], [10, 3], [10, 1]]) == 10\n assert candidate(edges = [[4, 3], [5, 3], [2, 3], [1, 3]]) == 3\n assert candidate(edges = [[1, 2], [2, 3], [4, 2]]) == 2\n assert candidate(edges = [[1, 2], [5, 1], [1, 3], [1, 4]]) == 1\n assert candidate(edges = [[3, 1], [2, 1]]) == 1\n assert candidate(edges = [[3, 1], [3, 2], [3, 4], [3, 5]]) == 3\n assert candidate(edges = [[7, 4], [7, 5], [7, 3], [7, 1], [7, 2]]) == 7\n assert candidate(edges = [[3, 5], [3, 1], [3, 2], [3, 6]]) == 3\n assert candidate(edges = [[5, 1], [1, 2], [1, 3], [1, 4], [7, 1]]) == 1\n assert candidate(edges = [[6, 4], [6, 5], [6, 2], [6, 3]]) == 6\n assert candidate(edges = [[10, 3], [10, 2], [10, 5], [10, 1], [10, 4]]) == 10\n assert candidate(edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15]]) == 1\n assert candidate(edges = [[100000, 1], [100000, 2], [100000, 3], [100000, 4], [100000, 5], [100000, 6], [100000, 7], [100000, 8], [100000, 9], [100000, 10], [100000, 11], [100000, 12], [100000, 13], [100000, 14], [100000, 15]]) == 100000\n assert candidate(edges = [[99999, 1], [99999, 2], [99999, 3], [99999, 4], [99999, 5], [99999, 6], [99999, 7], [99999, 8], [99999, 9], [99999, 10], [99999, 11], [99999, 12], [99999, 13], [99999, 14], [99999, 15], [99999, 16], [99999, 17], [99999, 18], [99999, 19], [99999, 20]]) == 99999\n assert candidate(edges = [[55555, 1], [55555, 2], [55555, 3], [55555, 4], [55555, 5], [55555, 6], [55555, 7], [55555, 8], [55555, 9], [55555, 10], [55555, 11], [55555, 12], [55555, 13], [55555, 14], [55555, 15], [55555, 16], [55555, 17], [55555, 18], [55555, 19], [55555, 20], [55555, 21], [55555, 22], [55555, 23], [55555, 24], [55555, 25]]) == 55555\n assert candidate(edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39], [39, 40], [40, 41], [41, 42], [42, 43], [43, 44], [44, 45], [45, 46], [46, 47], [47, 48], [48, 49], [49, 50], [50, 1]]) == 2\n assert candidate(edges = [[2, 1], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19], [2, 20], [2, 21], [2, 22], [2, 23], [2, 24], [2, 25], [2, 26], [2, 27], [2, 28], [2, 29], [2, 30], [2, 31], [2, 32], [2, 33], [2, 34], [2, 35], [2, 36], [2, 37], [2, 38], [2, 39], [2, 40], [2, 41], [2, 42], [2, 43], [2, 44], [2, 45], [2, 46], [2, 47], [2, 48], [2, 49], [2, 50], [2, 51], [2, 52], [2, 53], [2, 54], [2, 55], [2, 56], [2, 57], [2, 58], [2, 59], [2, 60]]) == 2\n assert candidate(edges = [[1, 200000], [200000, 2], [200000, 3], [200000, 4], [200000, 5], [200000, 6], [200000, 7], [200000, 8], [200000, 9], [200000, 10], [200000, 11], [200000, 12], [200000, 13], [200000, 14], [200000, 15], [200000, 16], [200000, 17], [200000, 18], [200000, 19], [200000, 20]]) == 200000\n assert candidate(edges = [[10, 100], [100, 11], [100, 12], [100, 13], [100, 14], [100, 15], [100, 16], [100, 17], [100, 18], [100, 19], [100, 20], [100, 21], [100, 22], [100, 23], [100, 24], [100, 25], [100, 26], [100, 27], [100, 28], [100, 29], [100, 30], [100, 31], [100, 32], [100, 33], [100, 34], [100, 35], [100, 36], [100, 37], [100, 38], [100, 39], [100, 40], [100, 41], [100, 42], [100, 43], [100, 44], [100, 45], [100, 46], [100, 47], [100, 48], [100, 49], [100, 50], [100, 51], [100, 52], [100, 53], [100, 54], [100, 55], [100, 56], [100, 57], [100, 58], [100, 59], [100, 60], [100, 61], [100, 62], [100, 63], [100, 64], [100, 65], [100, 66], [100, 67], [100, 68], [100, 69], [100, 70], [100, 71], [100, 72], [100, 73], [100, 74], [100, 75], [100, 76], [100, 77], [100, 78], [100, 79], [100, 80], [100, 81], [100, 82], [100, 83], [100, 84], [100, 85], [100, 86], [100, 87], [100, 88], [100, 89], [100, 90], [100, 91], [100, 92], [100, 93], [100, 94], [100, 95], [100, 96], [100, 97], [100, 98], [100, 99], [100, 100]]) == 100\n assert candidate(edges = [[1000, 2], [1000, 3], [1000, 4], [1000, 5], [1000, 6], [1000, 7], [1000, 8], [1000, 9], [1000, 10], [1000, 11], [1000, 12], [1000, 13], [1000, 14], [1000, 15], [1000, 16], [1000, 17], [1000, 18], [1000, 19], [1000, 20], [1000, 21], [1000, 22], [1000, 23], [1000, 24], [1000, 25], [1000, 26], [1000, 27], [1000, 28], [1000, 29], [1000, 30]]) == 1000\n assert candidate(edges = [[25000, 24999], [25000, 24998], [25000, 24997], [25000, 24996], [25000, 24995], [25000, 24994], [25000, 24993], [25000, 24992], [25000, 24991], [25000, 24990], [25000, 24989], [25000, 24988], [25000, 24987], [25000, 24986], [25000, 24985], [25000, 24984], [25000, 24983], [25000, 24982], [25000, 24981], [25000, 24980]]) == 25000\n assert candidate(edges = [[500, 250], [500, 125], [500, 375], [500, 625], [500, 875], [500, 150], [500, 300], [500, 450], [500, 600], [500, 750], [500, 900], [500, 275], [500, 325], [500, 375], [500, 425], [500, 475]]) == 500\n assert candidate(edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30]]) == 1\n assert candidate(edges = [[99999, 1], [99999, 2], [99999, 3], [99999, 4], [99999, 5], [99999, 6], [99999, 7], [99999, 8], [99999, 9], [99999, 10], [99999, 11], [99999, 12], [99999, 13], [99999, 14], [99999, 15]]) == 99999\n assert candidate(edges = [[99999, 1], [99999, 2], [99999, 3], [99999, 4], [99999, 5], [99999, 6], [99999, 7], [99999, 8], [99999, 9], [99999, 10], [99999, 11], [99999, 12], [99999, 13], [99999, 14], [99999, 15], [99999, 16], [99999, 17], [99999, 18], [99999, 19], [99999, 20], [99999, 21], [99999, 22], [99999, 23], [99999, 24], [99999, 25], [99999, 26], [99999, 27], [99999, 28], [99999, 29], [99999, 30], [99999, 31], [99999, 32], [99999, 33], [99999, 34], [99999, 35], [99999, 36], [99999, 37], [99999, 38], [99999, 39], [99999, 40], [99999, 41], [99999, 42], [99999, 43], [99999, 44], [99999, 45], [99999, 46], [99999, 47], [99999, 48], [99999, 49], [99999, 50]]) == 99999\n assert candidate(edges = [[100000, 1], [100000, 2], [100000, 3], [100000, 4], [100000, 5], [100000, 6], [100000, 7], [100000, 8], [100000, 9], [100000, 10], [100000, 11], [100000, 12], [100000, 13], [100000, 14], [100000, 15], [100000, 16], [100000, 17], [100000, 18], [100000, 19], [100000, 20]]) == 100000\n assert candidate(edges = [[99, 1], [99, 2], [99, 3], [99, 4], [99, 5], [99, 6], [99, 7], [99, 8], [99, 9], [99, 10]]) == 99\n assert candidate(edges = [[1, 99999], [2, 99999], [3, 99999], [4, 99999], [5, 99999], [6, 99999], [7, 99999], [8, 99999], [9, 99999]]) == 99999\n assert candidate(edges = [[1000, 500], [1000, 600], [1000, 700], [1000, 800], [1000, 900], [1000, 200], [1000, 300], [1000, 400], [1000, 100], [1000, 150], [1000, 250], [1000, 350], [1000, 450], [1000, 550], [1000, 650], [1000, 750], [1000, 850], [1000, 950], [1000, 1000], [1000, 1100], [1000, 1200], [1000, 1300], [1000, 1400]]) == 1000\n assert candidate(edges = [[23456, 12345], [23456, 22345], [23456, 32345], [23456, 42345], [23456, 52345], [23456, 62345], [23456, 72345], [23456, 82345], [23456, 92345], [23456, 102345]]) == 23456\n assert candidate(edges = [[3, 1], [3, 2], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [3, 18], [3, 19], [3, 20], [3, 21], [3, 22], [3, 23], [3, 24], [3, 25], [3, 26], [3, 27], [3, 28], [3, 29], [3, 30], [3, 31], [3, 32], [3, 33], [3, 34], [3, 35], [3, 36], [3, 37], [3, 38], [3, 39], [3, 40], [3, 41], [3, 42], [3, 43], [3, 44], [3, 45], [3, 46], [3, 47], [3, 48], [3, 49], [3, 50], [3, 51], [3, 52], [3, 53], [3, 54], [3, 55], [3, 56], [3, 57], [3, 58], [3, 59], [3, 60], [3, 61], [3, 62], [3, 63], [3, 64], [3, 65], [3, 66], [3, 67], [3, 68], [3, 69], [3, 70], [3, 71], [3, 72], [3, 73], [3, 74], [3, 75], [3, 76], [3, 77], [3, 78], [3, 79], [3, 80], [3, 81], [3, 82], [3, 83], [3, 84], [3, 85], [3, 86], [3, 87], [3, 88], [3, 89], [3, 90], [3, 91], [3, 92], [3, 93], [3, 94], [3, 95], [3, 96], [3, 97], [3, 98], [3, 99], [3, 100]]) == 3\n assert candidate(edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1]]) == 2\n assert candidate(edges = [[10000, 9999], [10000, 5000], [10000, 2500], [10000, 7500], [10000, 6250], [10000, 8750], [10000, 3125], [10000, 6875], [10000, 1875], [10000, 8125], [10000, 9375], [10000, 1250], [10000, 3750], [10000, 6250], [10000, 8750], [10000, 4375], [10000, 7500], [10000, 21875], [10000, 8125], [10000, 5625]]) == 10000\n assert candidate(edges = [[67890, 54321], [67890, 23456], [67890, 34567], [67890, 45678], [67890, 56789], [67890, 68901], [67890, 79012], [67890, 80123], [67890, 91234], [67890, 10234], [67890, 11345], [67890, 12456], [67890, 13567], [67890, 14678], [67890, 15789], [67890, 16890], [67890, 17901], [67890, 18012], [67890, 19123], [67890, 20234]]) == 67890\n assert candidate(edges = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30]]) == 1\n assert candidate(edges = [[2, 1], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15]]) == 2\n assert candidate(edges = [[50, 1], [50, 2], [50, 3], [50, 4], [50, 5], [50, 6], [50, 7], [50, 8], [50, 9], [50, 10], [50, 11], [50, 12], [50, 13], [50, 14], [50, 15]]) == 50\n assert candidate(edges = [[50000, 1], [50000, 50001], [50000, 50002], [50000, 50003], [50000, 50004]]) == 50000\n assert candidate(edges = [[100, 50], [100, 25], [100, 75], [100, 20], [100, 80], [100, 90], [100, 10], [100, 40], [100, 60], [100, 30]]) == 100\n assert candidate(edges = [[100, 50], [100, 99], [100, 23], [100, 75], [100, 1000], [100, 10], [100, 30], [100, 60], [100, 40], [100, 80]]) == 100\n assert candidate(edges = [[99999, 99998], [99999, 99997], [99999, 99996], [99999, 99995], [99999, 99994], [99999, 99993], [99999, 99992], [99999, 99991], [99999, 99990], [99999, 99989], [99999, 99988], [99999, 99987], [99999, 99986], [99999, 99985], [99999, 99984], [99999, 99983], [99999, 99982], [99999, 99981], [99999, 99980]]) == 99999\n assert candidate(edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == 2\n assert candidate(edges = [[50000, 50001], [50000, 50002], [50000, 50003], [50000, 50004], [50000, 50005], [50000, 50006], [50000, 50007], [50000, 50008], [50000, 50009], [50000, 50010]]) == 50000\n assert candidate(edges = [[50, 1], [50, 51], [50, 52], [50, 53], [50, 54], [50, 55], [50, 56], [50, 57], [50, 58], [50, 59], [50, 60], [50, 61], [50, 62], [50, 63], [50, 64], [50, 65]]) == 50\n assert candidate(edges = [[50000, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20], [1, 21], [1, 22], [1, 23], [1, 24], [1, 25], [1, 26], [1, 27], [1, 28], [1, 29], [1, 30], [1, 31], [1, 32], [1, 33], [1, 34], [1, 35], [1, 36], [1, 37], [1, 38], [1, 39], [1, 40], [1, 41], [1, 42], [1, 43], [1, 44], [1, 45], [1, 46], [1, 47], [1, 48], [1, 49], [1, 50]]) == 1\n assert candidate(edges = [[50, 1], [50, 2], [50, 3], [50, 4], [50, 5], [50, 6], [50, 7], [50, 8], [50, 9], [50, 10], [50, 11], [50, 12], [50, 13], [50, 14], [50, 15], [50, 16], [50, 17], [50, 18], [50, 19], [50, 20]]) == 50\n assert candidate(edges = [[100000, 99999], [100000, 99998], [100000, 99997], [100000, 99996], [100000, 99995], [100000, 1], [100000, 2], [100000, 3], [100000, 4]]) == 100000\n assert candidate(edges = [[50000, 1], [50000, 2], [50000, 3], [50000, 4], [50000, 5], [50000, 6], [50000, 7], [50000, 8], [50000, 9], [50000, 10]]) == 50000\n assert candidate(edges = [[500, 1000], [1000, 1500], [1000, 2000], [1000, 3000], [1000, 4000], [1000, 5000], [1000, 6000], [1000, 7000], [1000, 8000], [1000, 9000], [1000, 11000]]) == 1000\n assert candidate(edges = [[100000, 99999], [100000, 99998], [100000, 99997], [100000, 1]]) == 100000\n assert candidate(edges = [[30, 1], [30, 2], [30, 3], [30, 4], [30, 5], [30, 6], [30, 7], [30, 8], [30, 9], [30, 10], [30, 11], [30, 12], [30, 13], [30, 14], [30, 15], [30, 16], [30, 17], [30, 18], [30, 19], [30, 20], [30, 21], [30, 22], [30, 23], [30, 24], [30, 25], [30, 26], [30, 27], [30, 28], [30, 29]]) == 30\n assert candidate(edges = [[200000, 1], [200000, 2], [200000, 3], [200000, 4], [200000, 5], [200000, 6], [200000, 7], [200000, 8], [200000, 9], [200000, 10], [200000, 11], [200000, 12], [200000, 13], [200000, 14], [200000, 15], [200000, 16], [200000, 17], [200000, 18], [200000, 19], [200000, 20], [200000, 21], [200000, 22], [200000, 23], [200000, 24], [200000, 25], [200000, 26], [200000, 27], [200000, 28], [200000, 29], [200000, 30], [200000, 31], [200000, 32], [200000, 33], [200000, 34], [200000, 35], [200000, 36], [200000, 37], [200000, 38], [200000, 39], [200000, 40]]) == 200000\n assert candidate(edges = [[2, 1], [2, 4], [3, 2], [2, 6], [5, 2], [7, 2], [8, 2], [9, 2], [10, 2]]) == 2\n assert candidate(edges = [[100, 1], [100, 2], [100, 3], [100, 4], [100, 5], [100, 6], [100, 7], [100, 8], [100, 9], [100, 10], [100, 11], [100, 12], [100, 13], [100, 14], [100, 15], [100, 16], [100, 17], [100, 18], [100, 19], [100, 20], [100, 21], [100, 22], [100, 23], [100, 24], [100, 25], [100, 26], [100, 27], [100, 28], [100, 29], [100, 30], [100, 31], [100, 32], [100, 33], [100, 34], [100, 35], [100, 36], [100, 37], [100, 38], [100, 39], [100, 40], [100, 41], [100, 42], [100, 43], [100, 44], [100, 45], [100, 46], [100, 47], [100, 48], [100, 49], [100, 50]]) == 100\n assert candidate(edges = [[100000, 1], [100000, 2], [100000, 3], [100000, 4], [100000, 5], [100000, 6], [100000, 7], [100000, 8], [100000, 9], [100000, 10]]) == 100000\n"}, "metadata": {"canonical_parameter_names": ["edges"], "leetcode_dataset_entry_point": "Solution().findCenter", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int findCenter(vector>& edges) {", "container": "Solution", "callable": "findCenter", "parameters": [{"name": "edges", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1792, "task_id": "maximum-average-pass-ratio", "difficulty": "Medium", "problem_description": "There is a school that has classes of students and each class will be having a final exam. You are given a 2D integer array classes, where classes[i] = [passi, totali]. You know beforehand that in the ith class, there are totali total students, but only passi number of students will pass the exam.\nYou are also given an integer extraStudents. There are another extraStudents brilliant students that are guaranteed to pass the exam of any class they are assigned to. You want to assign each of the extraStudents students to a class in a way that maximizes the average pass ratio across all the classes.\nThe pass ratio of a class is equal to the number of students of the class that will pass the exam divided by the total number of students of the class. The average pass ratio is the sum of pass ratios of all the classes divided by the number of the classes.\nReturn the maximum possible average pass ratio after assigning the extraStudents students. Answers within 10-5 of the actual answer will be accepted.\n \nExample 1:\n\nInput: classes = [[1,2],[3,5],[2,2]], extraStudents = 2\nOutput: 0.78333\nExplanation: You can assign the two extra students to the first class. The average pass ratio will be equal to (3/4 + 3/5 + 2/2) / 3 = 0.78333.\n\nExample 2:\n\nInput: classes = [[2,4],[3,9],[4,5],[2,10]], extraStudents = 4\nOutput: 0.53485\n\n \nConstraints:\n\n1 <= classes.length <= 105\nclasses[i].length == 2\n1 <= passi <= totali <= 105\n1 <= extraStudents <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(classes = [[5, 10], [6, 10], [7, 10]],extraStudents = 1) == 0.6151515151515151\n assert candidate(classes = [[2, 4], [3, 9], [4, 5], [2, 10]],extraStudents = 4) == 0.5348484848484849\n assert candidate(classes = [[1, 1], [1, 1], [1, 1]],extraStudents = 1) == 1.0\n assert candidate(classes = [[1, 2], [3, 5], [2, 2]],extraStudents = 2) == 0.7833333333333333\n assert candidate(classes = [[10, 20], [20, 30], [30, 40]],extraStudents = 5) == 0.6722222222222222\n assert candidate(classes = [[5, 5], [10, 10]],extraStudents = 10) == 1.0\n assert candidate(classes = [[1, 1], [1, 2], [1, 3]],extraStudents = 3) == 0.7555555555555555\n assert candidate(classes = [[99, 100], [999, 1000], [9999, 10000]],extraStudents = 1000) == 0.999331746031746\n assert candidate(classes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],extraStudents = 10) == 1.0\n assert candidate(classes = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]],extraStudents = 10) == 0.6842857142857143\n assert candidate(classes = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000]],extraStudents = 45) == 0.7958742756361804\n assert candidate(classes = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],extraStudents = 15) == 0.2273449131513648\n assert candidate(classes = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],extraStudents = 15) == 0.8571428571428571\n assert candidate(classes = [[1, 100], [10, 1000], [100, 10000], [1000, 100000]],extraStudents = 1000) == 0.3008176852167975\n assert candidate(classes = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],extraStudents = 50) == 0.6412325174825175\n assert candidate(classes = [[99, 100], [999, 1000], [9999, 10000], [99999, 100000]],extraStudents = 10) == 0.9974497727272728\n assert candidate(classes = [[5, 10], [10, 20], [15, 30], [20, 40], [25, 50]],extraStudents = 25) == 0.5977592214345788\n assert candidate(classes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],extraStudents = 1000) == 1.0\n assert candidate(classes = [[1000, 2000], [1500, 3000], [2000, 4000], [2500, 5000], [3000, 6000]],extraStudents = 1000) == 0.5350170085037467\n assert candidate(classes = [[1, 3], [2, 6], [3, 9], [4, 12], [5, 15]],extraStudents = 10) == 0.4884670884670885\n assert candidate(classes = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],extraStudents = 10) == 0.4164285714285715\n assert candidate(classes = [[1, 100], [10, 100], [50, 100]],extraStudents = 50) == 0.3296191939890711\n assert candidate(classes = [[100, 200], [150, 250], [200, 300], [250, 350]],extraStudents = 50) == 0.6452380952380952\n assert candidate(classes = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6]],extraStudents = 5) == 0.4371428571428571\n assert candidate(classes = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],extraStudents = 50) == 1.0\n assert candidate(classes = [[10000, 10001], [20000, 20001], [30000, 30001], [40000, 40001]],extraStudents = 1000) == 0.9999501925188506\n assert candidate(classes = [[50, 100], [75, 150], [125, 250], [200, 400], [300, 600], [450, 900]],extraStudents = 300) == 0.5992478200634347\n assert candidate(classes = [[5, 8], [5, 8], [5, 8], [5, 8], [5, 8]],extraStudents = 20) == 0.75\n assert candidate(classes = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]],extraStudents = 100) == 0.8541887125220459\n assert candidate(classes = [[99, 100], [98, 100], [97, 100], [96, 100], [95, 100]],extraStudents = 5) == 0.9704761904761904\n assert candidate(classes = [[99999, 100000], [50000, 100000], [25000, 50000], [10000, 20000]],extraStudents = 5000) == 0.6499975\n assert candidate(classes = [[1, 100000], [2, 100000], [3, 100000]],extraStudents = 100000) == 0.2500150000093752\n assert candidate(classes = [[100, 200], [200, 500], [300, 800], [400, 1000]],extraStudents = 100) == 0.4604967738352485\n assert candidate(classes = [[1, 2], [3, 6], [5, 10], [7, 14], [9, 18]],extraStudents = 15) == 0.6531926406926407\n assert candidate(classes = [[1, 100000], [2, 100000], [3, 100000], [4, 100000], [5, 100000]],extraStudents = 100000) == 0.16669166670370508\n assert candidate(classes = [[10000, 20000], [5000, 10000], [2500, 5000], [1000, 2000], [500, 1000], [250, 500], [100, 200], [50, 100], [25, 50], [10, 20]],extraStudents = 10000) == 0.7885364227868774\n assert candidate(classes = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],extraStudents = 5) == 1.0\n assert candidate(classes = [[50, 100], [150, 300], [250, 500], [350, 700]],extraStudents = 150) == 0.5803610885401075\n assert candidate(classes = [[1, 1], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]],extraStudents = 20) == 0.9074074074074074\n assert candidate(classes = [[9, 10], [99, 100], [999, 1000], [9999, 10000], [99999, 100000]],extraStudents = 50000) == 0.9999456354114968\n assert candidate(classes = [[99, 100], [98, 100], [97, 100], [96, 100], [95, 100], [94, 100], [93, 100], [92, 100], [91, 100], [90, 100]],extraStudents = 10) == 0.945917211328976\n assert candidate(classes = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11]],extraStudents = 10) == 0.3255194805194805\n assert candidate(classes = [[50, 100], [100, 200], [150, 300], [200, 400]],extraStudents = 100) == 0.567861188343116\n assert candidate(classes = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],extraStudents = 9) == 0.341005291005291\n assert candidate(classes = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],extraStudents = 5) == 0.7966666666666666\n assert candidate(classes = [[10, 11], [20, 22], [30, 33], [40, 44]],extraStudents = 5) == 0.9161931818181818\n assert candidate(classes = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60]],extraStudents = 15) == 0.7535606060606062\n assert candidate(classes = [[1, 3], [2, 5], [3, 7], [4, 9]],extraStudents = 5) == 0.528968253968254\n assert candidate(classes = [[1, 1000], [10, 1000], [100, 1000], [1000, 1000]],extraStudents = 100) == 0.30143093489681594\n assert candidate(classes = [[10, 15], [20, 25], [30, 35], [40, 45], [50, 55], [60, 65]],extraStudents = 100) == 0.9114219114219114\n assert candidate(classes = [[1, 100], [20, 50], [30, 40], [40, 60]],extraStudents = 10) == 0.4822964571623233\n assert candidate(classes = [[1, 100000], [100000, 100000], [100000, 100000], [100000, 100000], [1, 100000]],extraStudents = 100000) == 0.733336\n assert candidate(classes = [[5, 6], [10, 12], [15, 18], [20, 24], [25, 30]],extraStudents = 50) == 0.8996095210091154\n assert candidate(classes = [[1, 2], [2, 4], [3, 8], [4, 16], [5, 32], [6, 64], [7, 128], [8, 256], [9, 512]],extraStudents = 256) == 0.56112903154186\n assert candidate(classes = [[99999, 100000], [99998, 100000], [99997, 100000]],extraStudents = 3) == 0.999980000299991\n assert candidate(classes = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],extraStudents = 100) == 0.29977994676131325\n assert candidate(classes = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],extraStudents = 45) == 0.5812816812816812\n assert candidate(classes = [[1, 3], [2, 5], [3, 7], [4, 9], [5, 11]],extraStudents = 5) == 0.5140836940836941\n assert candidate(classes = [[100, 200], [200, 300], [50, 150], [250, 500], [100, 250]],extraStudents = 50) == 0.5133333333333333\n assert candidate(classes = [[1, 2], [1, 3], [1, 4], [1, 5]],extraStudents = 5) == 0.5\n assert candidate(classes = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20]],extraStudents = 5) == 0.5488095238095239\n assert candidate(classes = [[1000, 10000], [2000, 20000], [3000, 30000], [4000, 40000]],extraStudents = 2000) == 0.1375\n assert candidate(classes = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],extraStudents = 200) == 0.638637428727642\n assert candidate(classes = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],extraStudents = 50) == 0.9128787878787878\n assert candidate(classes = [[100, 101], [200, 201], [300, 301], [400, 401], [500, 501]],extraStudents = 500) == 0.9974701296361822\n assert candidate(classes = [[1, 100000], [2, 100000], [3, 100000], [4, 100000], [5, 100000]],extraStudents = 500000) == 0.5000150000250008\n assert candidate(classes = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2]],extraStudents = 5) == 0.5833333333333333\n assert candidate(classes = [[1, 100000], [100000, 200000], [1, 100000], [1, 100000]],extraStudents = 50000) == 0.23214928570379018\n assert candidate(classes = [[50, 100], [40, 80], [30, 60], [20, 40], [10, 20]],extraStudents = 20) == 0.554287556415216\n assert candidate(classes = [[1, 2], [2, 5], [3, 10], [4, 20], [5, 50], [6, 100], [7, 200], [8, 500], [9, 1000], [10, 10000]],extraStudents = 5000) == 0.7736090641036538\n assert candidate(classes = [[1, 1000], [1, 2000], [1, 3000], [1, 4000], [1, 5000]],extraStudents = 1500) == 0.14190236063451128\n assert candidate(classes = [[10, 20], [20, 40], [30, 60], [40, 80]],extraStudents = 20) == 0.56785944551902\n assert candidate(classes = [[99, 100], [199, 200], [299, 300], [399, 400], [499, 500]],extraStudents = 1000) == 0.998\n assert candidate(classes = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000]],extraStudents = 4500) == 0.5002246672081883\n assert candidate(classes = [[10000, 100000], [20000, 100000], [30000, 100000], [40000, 100000]],extraStudents = 10000) == 0.27058853870831734\n assert candidate(classes = [[1, 100], [1, 100], [1, 100], [1, 100], [1, 100]],extraStudents = 500) == 0.505\n assert candidate(classes = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],extraStudents = 5) == 1.0\n assert candidate(classes = [[1, 10], [2, 15], [3, 20], [4, 25], [5, 30]],extraStudents = 15) == 0.2816248934356351\n assert candidate(classes = [[10, 20], [15, 25], [20, 30], [25, 35]],extraStudents = 10) == 0.6633597883597884\n assert candidate(classes = [[1, 100], [10, 100], [100, 100], [1000, 1000], [10000, 10000]],extraStudents = 10000) == 0.9925924392888745\n assert candidate(classes = [[1, 100000], [100000, 100000], [50000, 100000]],extraStudents = 50000) == 0.6114404678259185\n assert candidate(classes = [[10, 20], [15, 30], [5, 15], [25, 50]],extraStudents = 15) == 0.55\n assert candidate(classes = [[10000, 100000], [20000, 100000], [30000, 100000], [40000, 100000], [50000, 100000], [60000, 100000], [70000, 100000], [80000, 100000], [90000, 100000], [100000, 100000]],extraStudents = 10000) == 0.5582354154833269\n assert candidate(classes = [[50, 100], [40, 80], [30, 60], [20, 40], [10, 20]],extraStudents = 30) == 0.5707749766573296\n assert candidate(classes = [[1, 100000], [1, 100000], [1, 100000], [1, 100000], [1, 100000]],extraStudents = 100000) == 0.166675\n assert candidate(classes = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],extraStudents = 100) == 0.9415395787944808\n assert candidate(classes = [[10, 100], [20, 200], [30, 300], [40, 400], [50, 500]],extraStudents = 50) == 0.16025231286795627\n assert candidate(classes = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6]],extraStudents = 15) == 0.5976190476190476\n assert candidate(classes = [[50, 100], [75, 150], [25, 75], [10, 50]],extraStudents = 20) == 0.44060351413292587\n assert candidate(classes = [[1, 100], [2, 100], [3, 100], [4, 100], [5, 100]],extraStudents = 250) == 0.3533647454875556\n assert candidate(classes = [[50000, 100000], [40000, 100000], [30000, 100000], [20000, 100000], [10000, 100000]],extraStudents = 50000) == 0.3696598823228846\n assert candidate(classes = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20]],extraStudents = 100) == 0.7595597403486419\n assert candidate(classes = [[3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],extraStudents = 3) == 0.8464285714285715\n assert candidate(classes = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],extraStudents = 9) == 0.8504850088183421\n assert candidate(classes = [[10, 12], [20, 25], [30, 35], [40, 45], [50, 55]],extraStudents = 30) == 0.8916472416472416\n assert candidate(classes = [[1, 2], [2, 4], [4, 8], [8, 16], [16, 32]],extraStudents = 64) == 0.7993434343434344\n assert candidate(classes = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],extraStudents = 100) == 0.49407730392552046\n assert candidate(classes = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7]],extraStudents = 21) == 0.5919612794612795\n assert candidate(classes = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],extraStudents = 500) == 0.5672899020682859\n assert candidate(classes = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],extraStudents = 10) == 0.8541887125220459\n assert candidate(classes = [[999, 1000], [998, 1000], [997, 1000], [996, 1000], [995, 1000]],extraStudents = 10) == 0.997009900990099\n"}, "metadata": {"canonical_parameter_names": ["classes", "extraStudents"], "leetcode_dataset_entry_point": "Solution().maxAverageRatio", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "double maxAverageRatio(vector>& classes, int extraStudents) {", "container": "Solution", "callable": "maxAverageRatio", "parameters": [{"name": "classes", "type": "vector>&"}, {"name": "extraStudents", "type": "int"}], "return_type": "double", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1793, "task_id": "maximum-score-of-a-good-subarray", "difficulty": "Hard", "problem_description": "You are given an array of integers nums (0-indexed) and an integer k.\nThe score of a subarray (i, j) is defined as min(nums[i], nums[i+1], ..., nums[j]) * (j - i + 1). A good subarray is a subarray where i <= k <= j.\nReturn the maximum possible score of a good subarray.\n \nExample 1:\n\nInput: nums = [1,4,3,7,4,5], k = 3\nOutput: 15\nExplanation: The optimal subarray is (1, 5) with a score of min(4,3,7,4,5) * (5-1+1) = 3 * 5 = 15. \n\nExample 2:\n\nInput: nums = [5,5,4,5,4,1,1,1], k = 0\nOutput: 20\nExplanation: The optimal subarray is (0, 4) with a score of min(5,5,4,5,4) * (4-0+1) = 4 * 5 = 20.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 2 * 104\n0 <= k < nums.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 5, 4, 5, 4, 1, 1, 1],k = 0) == 20\n assert candidate(nums = [10, 10, 10, 10, 10],k = 2) == 50\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == 25\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100],k = 4) == 10\n assert candidate(nums = [9, 7, 5, 3, 1],k = 2) == 15\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 5) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 30\n assert candidate(nums = [1, 2, 3, 4, 5],k = 2) == 9\n assert candidate(nums = [2, 1, 3, 4, 5, 6, 7, 8, 9],k = 2) == 21\n assert candidate(nums = [1, 4, 3, 7, 4, 5],k = 3) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 7, 5, 3, 1],k = 4) == 25\n assert candidate(nums = [100, 200, 300, 400, 500, 400, 300, 200, 100],k = 4) == 1500\n assert candidate(nums = [10, 20, 30, 40, 50],k = 2) == 90\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 30\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 4) == 54\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1],k = 3) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 30\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 30\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9, 10, 1, 2, 3, 4, 5],k = 9) == 18\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 7) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5],k = 25) == 69\n assert candidate(nums = [1, 20000, 2, 19999, 3, 19998, 4, 19997, 5, 19996, 6],k = 5) == 19998\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 20\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 200\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 110\n assert candidate(nums = [5, 15, 10, 20, 25, 30, 35, 40, 45, 50],k = 3) == 140\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 55\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 12) == 150\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 9) == 200000\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 9) == 110\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 4) == 1000\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 19\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 110\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 20\n assert candidate(nums = [20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000],k = 10) == 400000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 300\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 1, 5, 4, 3, 2, 1, 2, 3, 4, 5, 1, 5, 4, 3, 2, 1, 2, 3, 4, 5, 1, 5, 4, 3, 2, 1, 2, 3, 4, 5],k = 15) == 44\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5],k = 4) == 19\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9],k = 9) == 30\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 10) == 1000\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],k = 6) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1],k = 9) == 10\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 7) == 64\n assert candidate(nums = [10, 20, 30, 40, 50, 40, 30, 20, 10, 5],k = 5) == 150\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 10) == 55\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 15) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],k = 7) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 40, 30, 20, 10, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 9) == 300\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == 55\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],k = 5) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 6) == 420\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 11) == 55\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 20) == 44\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12],k = 5) == 24\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 10) == 200\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 1) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],k = 9) == 99\n assert candidate(nums = [100, 50, 25, 12, 6, 3, 2, 1, 2, 3, 6, 12, 25, 50, 100],k = 7) == 15\n assert candidate(nums = [5, 5, 4, 4, 4, 5, 5, 4, 4, 4, 5, 5, 4, 4, 4, 5, 5, 4, 4, 4, 5, 5, 4, 4, 4, 5, 5, 4, 4, 4],k = 12) == 120\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 14) == 55\n assert candidate(nums = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6],k = 4) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 10) == 30\n assert candidate(nums = [10, 20, 30, 40, 50, 40, 30, 20, 10],k = 4) == 150\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5],k = 10) == 55\n assert candidate(nums = [10, 10, 10, 10, 10, 1, 1, 1, 1, 1],k = 5) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 100],k = 9) == 100\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12],k = 10) == 66\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 20) == 169\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 12) == 128\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 100],k = 4) == 15\n assert candidate(nums = [10, 20, 30, 40, 50, 40, 30, 20, 10, 5, 10, 20, 30, 40, 50, 40, 30, 20, 10, 5],k = 15) == 150\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81],k = 10) == 1620\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],k = 5) == 10\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 5, 6, 4, 7, 3, 8, 2, 9, 1, 10],k = 9) == 39\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 8) == 18\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 64\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990],k = 5) == 109890\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 20) == 38\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],k = 5) == 910\n assert candidate(nums = [60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5],k = 5) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 20) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4],k = 10) == 20\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 15) == 100\n assert candidate(nums = [3, 3, 3, 1, 2, 3, 2, 1, 3, 3, 3, 3],k = 5) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 110\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],k = 5) == 21\n assert candidate(nums = [20000, 19000, 18000, 17000, 16000, 15000, 14000, 13000, 12000, 11000, 10000],k = 10) == 110000\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81],k = 15) == 1620\n assert candidate(nums = [1, 5, 4, 3, 2, 1, 2, 3, 4, 5, 1, 5, 4, 3, 2, 1, 2, 3, 4, 5, 1, 5, 4, 3, 2, 1, 2, 3, 4, 5],k = 25) == 30\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6],k = 4) == 10\n assert candidate(nums = [10000, 20000, 10000, 20000, 10000, 20000, 10000, 20000, 10000, 20000, 10000],k = 7) == 110000\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 8) == 18\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 15) == 80\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5],k = 15) == 210\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 4) == 300\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maximumScore", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumScore(vector& nums, int k) {", "container": "Solution", "callable": "maximumScore", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1796, "task_id": "second-largest-digit-in-a-string", "difficulty": "Easy", "problem_description": "Given an alphanumeric string s, return the second largest numerical digit that appears in s, or -1 if it does not exist.\nAn alphanumeric string is a string consisting of lowercase English letters and digits.\n \nExample 1:\n\nInput: s = \"dfa12321afd\"\nOutput: 2\nExplanation: The digits that appear in s are [1, 2, 3]. The second largest digit is 2.\n\nExample 2:\n\nInput: s = \"abc1111\"\nOutput: -1\nExplanation: The digits that appear in s are [1]. There is no second largest digit. \n\n \nConstraints:\n\n1 <= s.length <= 500\ns consists of only lowercase English letters and digits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"9876543210\") == 8\n assert candidate(s = \"same1same1same1\") == -1\n assert candidate(s = \"abcdefghij0\") == -1\n assert candidate(s = \"abc1111\") == -1\n assert candidate(s = \"1a\") == -1\n assert candidate(s = \"1234567890\") == 8\n assert candidate(s = \"dfa12321afd\") == 2\n assert candidate(s = \"a1\") == -1\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0\") == 8\n assert candidate(s = \"11223344556677889900\") == 8\n assert candidate(s = \"noDigitsHere\") == -1\n assert candidate(s = \"unique9\") == -1\n assert candidate(s = \"a1a2a3a4a5a6a7a8a9a0\") == 8\n assert candidate(s = \"no digits here\") == -1\n assert candidate(s = \"0000000000\") == -1\n assert candidate(s = \"9999999999\") == -1\n assert candidate(s = \"00000000001111111111\") == 0\n assert candidate(s = \"1001\") == 0\n assert candidate(s = \"abcdefg\") == -1\n assert candidate(s = \"a9b8c7d6e5f4g3h2i1j0\") == 8\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz0\") == -1\n assert candidate(s = \"0a0b0c0d0e0f0g0h0i0j0k0l0m0n0o0p0q0r0s0t0u0v0w0x0y0z0\") == -1\n assert candidate(s = \"abcd1abcd2abcd3abcd4abcd5abcd6abcd7abcd8abcd9abcd0\") == 8\n assert candidate(s = \"9a8b7c6d5e4f3g2h1i0\") == 8\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\") == 8\n assert candidate(s = \"abc123xyz123\") == 2\n assert candidate(s = \"9876543210abc9876543210\") == 8\n assert candidate(s = \"9223372036854775807\") == 8\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0p9o8n7m6l5k4j3i2h1g0f9e8d7c6b5a4\") == 8\n assert candidate(s = \"1234567890abcdefghijklmnopqrstuvwxyz\") == 8\n assert candidate(s = \"1234567890abcdefghij0123456789\") == 8\n assert candidate(s = \"99887766554433221100\") == 8\n assert candidate(s = \"abcdefghij01234567890\") == 8\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\") == 8\n assert candidate(s = \"abc123abc123abc123\") == 2\n assert candidate(s = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == -1\n assert candidate(s = \"abc123xyz123abc123\") == 2\n assert candidate(s = \"1234567890abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz\") == 8\n assert candidate(s = \"1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == -1\n assert candidate(s = \"123abc456def789ghi123\") == 8\n assert candidate(s = \"1\") == -1\n assert candidate(s = \"a1b1c2d2e3f3g4h4i5j5k6l6m7n7o8p8q9r0\") == 8\n assert candidate(s = \"1223344556677889900\") == 8\n assert candidate(s = \"1234123412341234\") == 3\n assert candidate(s = \"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\") == 0\n assert candidate(s = \"abc123123123abc123123\") == 2\n assert candidate(s = \"000000000000000000000\") == -1\n assert candidate(s = \"123456789098765432101234567890\") == 8\n assert candidate(s = \"a1b1c2d2e3f3g4h4i5j5\") == 4\n assert candidate(s = \"1111111111222222222233333333334444444444555555555566666666667777777777888888888899999999990000000000\") == 8\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6\") == 8\n assert candidate(s = \"1234567890123456789012345678901234567890\") == 8\n assert candidate(s = \"999888777666555444333222111000\") == 8\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0a1b2c3d4e5f6g7h8i9j0a1b2c3d4e5f6g7h8i9j0\") == 8\n assert candidate(s = \"9876543210abcdefghijklmnopqrstuvwxyz\") == 8\n assert candidate(s = \"99999999999999999999\") == -1\n assert candidate(s = \"012345678901234567890123456789\") == 8\n assert candidate(s = \"10011001100110011001100110011001100110011001\") == 0\n assert candidate(s = \"1234567890abcdefghijk\") == 8\n assert candidate(s = \"abcdefghij0123456789\") == 8\n assert candidate(s = \"5555555555\") == -1\n assert candidate(s = \"55555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555\") == -1\n assert candidate(s = \"987654321009876543210987654321098765432109876543210\") == 8\n assert candidate(s = \"1234567890abcdefghij1234567890\") == 8\n assert candidate(s = \"12345678901234567890\") == 8\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij012345678901234567890123456789\") == 8\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz1234567890\") == 8\n assert candidate(s = \"98765432109876543210\") == 8\n assert candidate(s = \"1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z11\") == -1\n assert candidate(s = \"111222333444555666777888999\") == 8\n assert candidate(s = \"999999999999999999999999999999999999999999999999\") == -1\n assert candidate(s = \"abcdefg1234567890\") == 8\n assert candidate(s = \"5555555555555\") == -1\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghij012345678901234567890123456789\") == 8\n assert candidate(s = \"a1b2c2d3e3f4g4h5i5j6k6l7m7n8o8p9q9r0\") == 8\n assert candidate(s = \"zzzzz99999\") == -1\n assert candidate(s = \"a1b1c1d1e1f1g1h1i1j1\") == -1\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0p\") == 8\n assert candidate(s = \"9876543210abcdefg\") == 8\n assert candidate(s = \"98765432100123456789\") == 8\n assert candidate(s = \"0000000000000000000000000000000000000000000000000\") == -1\n assert candidate(s = \"abc123xyz456\") == 5\n assert candidate(s = \"123456789012345678901234567890123456789012345678901234567890\") == 8\n assert candidate(s = \"1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4x5y6z7\") == 8\n assert candidate(s = \"zzzzzzzzzzzzzzzzz9zzzzzzzzzzzzzzzz8\") == 8\n assert candidate(s = \"aabbccddeeffgghhii123456789\") == 8\n assert candidate(s = \"0123456789\") == 8\n assert candidate(s = \"abcdefghij1234567890\") == 8\n assert candidate(s = \"abcabcabc123123123\") == 2\n assert candidate(s = \"zzz9zzz8zzz7zzz6zzz5zzz4zzz3zzz2zzz1zzz0zzz\") == 8\n assert candidate(s = \"5555555555555555\") == -1\n assert candidate(s = \"a1b\") == -1\n assert candidate(s = \"1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t\") == 8\n assert candidate(s = \"111222333444555666777888999000\") == 8\n assert candidate(s = \"zzz999zzz888zzz\") == 8\n assert candidate(s = \"0000000000000111111111111222222222222333333333\") == 2\n assert candidate(s = \"abcd1234567890abcd\") == 8\n assert candidate(s = \"123abc123abc123\") == 2\n assert candidate(s = \"123abc456def789ghi0jkl\") == 8\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0a1b2c3d4e5f6g7h8i9j0\") == 8\n assert candidate(s = \"00000000000000000000\") == -1\n assert candidate(s = \"abcdefghij012345678909876543210\") == 8\n assert candidate(s = \"123456789012345678901234567890\") == 8\n assert candidate(s = \"9999999999999999999999999999\") == -1\n assert candidate(s = \"987654321098765432109876543210\") == 8\n assert candidate(s = \"abc123xyz987\") == 8\n assert candidate(s = \"0000111122223333444455556666777788889999\") == 8\n assert candidate(s = \"555555555555555555555555555555555555\") == -1\n assert candidate(s = \"1a1b2c2d3e3f4g4h5i5j6k6l7m7n8o8p9q9r0s0t1u2v3w4x5y6z7\") == 8\n assert candidate(s = \"1122334455667788990011223344556677889900\") == 8\n assert candidate(s = \"0123456789abcdefghij0123456789\") == 8\n assert candidate(s = \"1a2b3c4d5e6f7g8h9i0j\") == 8\n assert candidate(s = \"1111111111111111111112\") == 1\n assert candidate(s = \"1234567890abcdefghijabcdefghijabcdefghijabcdefghij012345678901234567890123456789\") == 8\n assert candidate(s = \"1234567890abcdefghij\") == 8\n assert candidate(s = \"122222222222222222222\") == 1\n assert candidate(s = \"123123123123123123123123123123123\") == 2\n assert candidate(s = \"9999999999888888888877777777766666666555555554444444433333333222222221111111100000000\") == 8\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz9876543210\") == 8\n assert candidate(s = \"a9b8c7d6e5f4g3h2i1\") == 8\n assert candidate(s = \"111122223333444455556666777788889999\") == 8\n assert candidate(s = \"abcdefghij9876543210\") == 8\n assert candidate(s = \"99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999\") == -1\n assert candidate(s = \"abcd1234efgh5678ijkl90mnop\") == 8\n assert candidate(s = \"123123123123123\") == 2\n assert candidate(s = \"9876543210abcdefghij0123456789\") == 8\n assert candidate(s = \"5555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555\") == -1\n assert candidate(s = \"zz9zz8zz7zz6zz5zz4zz3zz2zz1zz0zz\") == 8\n assert candidate(s = \"12345678901234567890abcdefghijabcdefghijabcdefghijabcdefghij012345678901234567890123456789\") == 8\n assert candidate(s = \"0102030405060708090\") == 8\n assert candidate(s = \"abc1234567890\") == 8\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().secondHighest", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int secondHighest(string s) {", "container": "Solution", "callable": "secondHighest", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1798, "task_id": "maximum-number-of-consecutive-values-you-can-make", "difficulty": "Medium", "problem_description": "You are given an integer array coins of length n which represents the n coins that you own. The value of the ith coin is coins[i]. You can make some value x if you can choose some of your n coins such that their values sum up to x.\nReturn the maximum number of consecutive integer values that you can make with your coins starting from and including 0.\nNote that you may have multiple coins of the same value.\n \nExample 1:\n\nInput: coins = [1,3]\nOutput: 2\nExplanation: You can make the following values:\n- 0: take []\n- 1: take [1]\nYou can make 2 consecutive integer values starting from 0.\nExample 2:\n\nInput: coins = [1,1,1,4]\nOutput: 8\nExplanation: You can make the following values:\n- 0: take []\n- 1: take [1]\n- 2: take [1,1]\n- 3: take [1,1,1]\n- 4: take [4]\n- 5: take [4,1]\n- 6: take [4,1,1]\n- 7: take [4,1,1,1]\nYou can make 8 consecutive integer values starting from 0.\nExample 3:\n\nInput: coins = [1,4,10,3,1]\nOutput: 20\n \nConstraints:\n\ncoins.length == n\n1 <= n <= 4 * 104\n1 <= coins[i] <= 4 * 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(coins = [1, 3]) == 2\n assert candidate(coins = [1, 2, 5]) == 4\n assert candidate(coins = [2, 2, 2, 2]) == 1\n assert candidate(coins = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 56\n assert candidate(coins = [1]) == 2\n assert candidate(coins = [1, 4, 10, 3, 1]) == 20\n assert candidate(coins = [40000, 40000, 40000, 40000]) == 1\n assert candidate(coins = [4, 3, 2, 1]) == 11\n assert candidate(coins = [100, 200, 300, 400, 500]) == 1\n assert candidate(coins = [1, 2, 3, 4, 5]) == 16\n assert candidate(coins = [1, 1, 1, 1, 1]) == 6\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1024\n assert candidate(coins = [1, 1, 3, 4]) == 10\n assert candidate(coins = [1, 2, 5, 10]) == 4\n assert candidate(coins = [100, 400, 200, 300]) == 1\n assert candidate(coins = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 1\n assert candidate(coins = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 21\n assert candidate(coins = [2]) == 1\n assert candidate(coins = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(coins = [10000, 20000, 30000, 40000]) == 1\n assert candidate(coins = [100, 400, 1, 1, 1]) == 4\n assert candidate(coins = [2, 2, 3, 3, 3, 4]) == 1\n assert candidate(coins = [1, 1, 3, 4, 10]) == 20\n assert candidate(coins = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 56\n assert candidate(coins = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == 84\n assert candidate(coins = [1, 1, 1, 4]) == 8\n assert candidate(coins = [2, 4, 6, 8]) == 1\n assert candidate(coins = [1, 1, 2, 2, 3, 3]) == 13\n assert candidate(coins = [40000]) == 1\n assert candidate(coins = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 2\n assert candidate(coins = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 1\n assert candidate(coins = [1, 2, 5, 10, 20, 50, 100]) == 4\n assert candidate(coins = [5, 7, 11, 13, 17, 19, 23, 29, 31]) == 1\n assert candidate(coins = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 31\n assert candidate(coins = [2, 3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144]) == 1\n assert candidate(coins = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 1\n assert candidate(coins = [1, 2, 3, 6, 12, 24, 48, 96, 192, 384, 768, 1536]) == 3073\n assert candidate(coins = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000]) == 4\n assert candidate(coins = [1, 5, 10, 25, 50, 100, 200, 500, 1000]) == 2\n assert candidate(coins = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 1\n assert candidate(coins = [3, 6, 9, 12, 15, 18, 21, 24, 27]) == 1\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 2048\n assert candidate(coins = [2, 3, 6, 12, 24, 48, 96, 192, 384, 768]) == 1\n assert candidate(coins = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 111\n assert candidate(coins = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 5, 5, 5, 5, 5]) == 41\n assert candidate(coins = [1, 3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576]) == 2\n assert candidate(coins = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 1\n assert candidate(coins = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 73\n assert candidate(coins = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256]) == 1023\n assert candidate(coins = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 2\n assert candidate(coins = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]) == 1597\n assert candidate(coins = [1, 2, 3, 6, 11, 20, 37, 68, 129, 254]) == 532\n assert candidate(coins = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(coins = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 1\n assert candidate(coins = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(coins = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 821\n assert candidate(coins = [100, 200, 200, 300, 400, 400, 400, 500, 600, 600, 700, 800, 800, 900, 1000]) == 1\n assert candidate(coins = [2, 2, 3, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 7]) == 1\n assert candidate(coins = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 46\n assert candidate(coins = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 1\n assert candidate(coins = [10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 56\n assert candidate(coins = [1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 2\n assert candidate(coins = [1, 10, 100, 1000, 10000, 100000, 1000000]) == 2\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 1048576\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 8192\n assert candidate(coins = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000]) == 4\n assert candidate(coins = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 1\n assert candidate(coins = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 2\n assert candidate(coins = [10, 25, 50, 100, 200, 500, 1000, 2000, 5000, 10000]) == 1\n assert candidate(coins = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]) == 144\n assert candidate(coins = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 121\n assert candidate(coins = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 1\n assert candidate(coins = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 1\n assert candidate(coins = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 166\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64]) == 128\n assert candidate(coins = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 111\n assert candidate(coins = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 2\n assert candidate(coins = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210]) == 2\n assert candidate(coins = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 1\n assert candidate(coins = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 1\n assert candidate(coins = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == 2\n assert candidate(coins = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946]) == 28656\n assert candidate(coins = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 213\n assert candidate(coins = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 26\n assert candidate(coins = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 1\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 32768\n assert candidate(coins = [1, 2, 3, 4, 5, 10, 20, 50, 100, 200]) == 46\n assert candidate(coins = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128]) == 511\n assert candidate(coins = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7, 5, 1, 0, 5, 8, 2, 0, 9, 7, 4, 9, 4, 4, 5, 9, 2, 3, 0, 7, 8, 1, 6, 4, 0, 6, 2, 8, 6, 2, 0, 4, 9, 6, 2, 4, 9]) == 395\n assert candidate(coins = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16]) == 63\n assert candidate(coins = [1, 2, 4, 8, 16, 32, 64, 128]) == 256\n assert candidate(coins = [1, 10, 100, 1000, 10000, 100000]) == 2\n assert candidate(coins = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1\n assert candidate(coins = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 164\n assert candidate(coins = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 151\n assert candidate(coins = [4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8]) == 1\n assert candidate(coins = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000]) == 4\n assert candidate(coins = [1, 5, 10, 25, 50, 100, 200, 500, 1000, 2000, 5000, 10000]) == 2\n"}, "metadata": {"canonical_parameter_names": ["coins"], "leetcode_dataset_entry_point": "Solution().getMaximumConsecutive", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int getMaximumConsecutive(vector& coins) {", "container": "Solution", "callable": "getMaximumConsecutive", "parameters": [{"name": "coins", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1800, "task_id": "maximum-ascending-subarray-sum", "difficulty": "Easy", "problem_description": "Given an array of positive integers nums, return the maximum possible sum of an strictly increasing subarray in nums.\nA subarray is defined as a contiguous sequence of numbers in an array.\n \nExample 1:\n\nInput: nums = [10,20,30,5,10,50]\nOutput: 65\nExplanation: [5,10,50] is the ascending subarray with the maximum sum of 65.\n\nExample 2:\n\nInput: nums = [10,20,30,40,50]\nOutput: 150\nExplanation: [10,20,30,40,50] is the ascending subarray with the maximum sum of 150.\n\nExample 3:\n\nInput: nums = [12,17,15,13,10,11,12]\nOutput: 33\nExplanation: [10,11,12] is the ascending subarray with the maximum sum of 33.\n\n \nConstraints:\n\n1 <= nums.length <= 100\n1 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [100, 99, 98, 97, 96]) == 100\n assert candidate(nums = [10, 9, 2, 5, 3, 7, 101, 18]) == 111\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [10]) == 10\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [100, 1, 2, 3, 100, 2, 3, 100]) == 106\n assert candidate(nums = [100]) == 100\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6]) == 10\n assert candidate(nums = [10, 20, 30, 40, 50]) == 150\n assert candidate(nums = [1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 1, 2, 1, 2]) == 3\n assert candidate(nums = [5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [10, 20, 30, 5, 10, 50]) == 65\n assert candidate(nums = [100, 99, 100, 98, 97, 96, 95, 101, 102, 103]) == 401\n assert candidate(nums = [12, 17, 15, 13, 10, 11, 12]) == 33\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 5]) == 14\n assert candidate(nums = [100, 100, 100]) == 100\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 175\n assert candidate(nums = [5, 10, 9, 15, 20, 25, 20, 30, 40, 50]) == 140\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 40, 41, 42, 43, 44]) == 605\n assert candidate(nums = [5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7, 5, 6, 7]) == 18\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 6\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 166\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [50, 1, 2, 3, 4, 50, 5, 6, 7, 8, 9, 50, 10, 11, 12, 13, 14, 15, 50, 16, 17, 18, 19, 20]) == 125\n assert candidate(nums = [30, 20, 10, 21, 22, 23, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(nums = [10, 20, 15, 25, 30, 22, 35, 40, 38, 45, 50]) == 133\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 240\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 6\n assert candidate(nums = [1, 3, 2, 4, 5, 3, 6, 7, 8, 6, 9, 10, 11, 10]) == 36\n assert candidate(nums = [10, 20, 10, 20, 30, 20, 30, 40, 50, 40, 60]) == 140\n assert candidate(nums = [1, 2, 3, 4, 3, 4, 5, 6, 5, 7, 8, 9, 10, 8, 9, 10, 11]) == 39\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 10, 100, 1000, 10, 1, 2, 3, 4, 5]) == 1111\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 400\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92]) == 100\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12]) == 23\n assert candidate(nums = [1, 3, 5, 2, 4, 6, 3, 5, 7, 4, 6, 8, 5, 7, 9]) == 21\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 100\n assert candidate(nums = [20, 30, 25, 35, 40, 35, 45, 50, 45, 55, 60, 55, 65, 70, 65, 75, 80]) == 220\n assert candidate(nums = [5, 10, 15, 20, 25, 1, 2, 3, 4, 5, 30, 35, 40, 45, 50, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 215\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125]) == 2925\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 18\n assert candidate(nums = [1, 2, 3, 2, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5]) == 41\n assert candidate(nums = [10, 20, 30, 25, 35, 40, 35, 45, 50, 45, 55, 60, 55, 65, 70, 65, 75, 80, 75, 85, 90]) == 250\n assert candidate(nums = [1, 10, 11, 2, 20, 21, 3, 30, 31, 4, 40, 41, 5, 50, 51, 6, 60, 61, 7, 70, 71]) == 148\n assert candidate(nums = [33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 747\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 3, 4, 5, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 1, 1, 1, 1]) == 55\n assert candidate(nums = [3, 2, 1, 10, 20, 30, 25, 35, 45, 55]) == 160\n assert candidate(nums = [10, 20, 15, 25, 30, 20, 35, 40, 50, 45, 60]) == 145\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 110\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9]) == 30\n assert candidate(nums = [10, 20, 15, 30, 40, 25, 50, 60, 35, 70, 80, 45, 90, 100, 55, 110, 120, 65, 130, 140, 75]) == 335\n assert candidate(nums = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 624\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 225\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 110\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 10, 20, 15, 25, 30, 20, 35, 40]) == 95\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [10, 20, 15, 25, 30, 20, 35, 40, 30, 45, 50]) == 125\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 550\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 100\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [100, 99, 98, 97, 96, 101, 102, 103, 104, 105]) == 611\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 100\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 1, 2, 3, 4, 5, 10, 15, 20]) == 105\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30]) == 50\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 165\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 156\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 100\n assert candidate(nums = [9, 10, 11, 8, 12, 13, 14, 7, 15, 16, 17, 18, 6, 19, 20, 21, 22, 23, 5, 24, 25, 26, 27, 28]) == 135\n assert candidate(nums = [5, 6, 3, 8, 9, 10, 7, 8, 9]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 325\n assert candidate(nums = [30, 31, 32, 33, 34, 35, 15, 16, 17, 18, 19, 20, 21]) == 195\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 22\n assert candidate(nums = [5, 6, 7, 8, 9, 5, 6, 7, 10, 11, 12, 13]) == 64\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10, 11, 12, 13, 14, 1, 2, 3, 4, 5]) == 70\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(nums = [50, 40, 30, 20, 10, 20, 30, 40, 50, 60]) == 210\n assert candidate(nums = [10, 20, 10, 20, 30, 40, 30, 40, 50, 60]) == 180\n assert candidate(nums = [10, 20, 30, 25, 40, 50, 60, 55, 70, 80]) == 205\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12, 13, 14, 14]) == 39\n assert candidate(nums = [5, 1, 2, 3, 4, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [2, 3, 6, 6, 5, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 11, 12, 5, 6, 7]) == 68\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [5, 3, 7, 8, 2, 6, 9, 11, 10, 15]) == 28\n assert candidate(nums = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 1, 2, 3, 4, 5]) == 605\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 110\n assert candidate(nums = [10, 20, 30, 25, 26, 27, 28, 29, 30, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 275\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 100\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 12, 14, 16]) == 72\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 8, 9, 10, 11, 12]) == 50\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 9, 11, 10]) == 32\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 315\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8, 9, 8, 9, 10, 11, 12, 11, 12]) == 50\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 4, 5, 6, 7, 8, 6, 7, 8, 9, 10, 11]) == 51\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(nums = [1, 3, 5, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 20, 30]) == 61\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 200\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 200\n assert candidate(nums = [10, 15, 20, 25, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == 150\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(nums = [100, 99, 98, 97, 96, 1, 2, 3, 4, 5]) == 100\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8, 9, 8, 9, 10, 11, 10, 11, 12, 13, 12, 13, 14, 15]) == 54\n assert candidate(nums = [3, 5, 4, 6, 7, 8, 6, 7, 8, 9, 10, 8, 9, 10, 11, 12, 10, 11, 12, 13, 14]) == 60\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxAscendingSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxAscendingSum(vector& nums) {", "container": "Solution", "callable": "maxAscendingSum", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1801, "task_id": "number-of-orders-in-the-backlog", "difficulty": "Medium", "problem_description": "You are given a 2D integer array orders, where each orders[i] = [pricei, amounti, orderTypei] denotes that amounti orders have been placed of type orderTypei at the price pricei. The orderTypei is:\\r\n\\r\n\\r\n\t0 if it is a batch of buy orders, or\\r\n\t1 if it is a batch of sell orders.\\r\n\\r\n\\r\nNote that orders[i] represents a batch of amounti independent orders with the same price and order type. All orders represented by orders[i] will be placed before all orders represented by orders[i+1] for all valid i.\\r\n\\r\nThere is a backlog that consists of orders that have not been executed. The backlog is initially empty. When an order is placed, the following happens:\\r\n\\r\n\\r\n\tIf the order is a buy order, you look at the sell order with the smallest price in the backlog. If that sell order's price is smaller than or equal to the current buy order's price, they will match and be executed, and that sell order will be removed from the backlog. Else, the buy order is added to the backlog.\\r\n\tVice versa, if the order is a sell order, you look at the buy order with the largest price in the backlog. If that buy order's price is larger than or equal to the current sell order's price, they will match and be executed, and that buy order will be removed from the backlog. Else, the sell order is added to the backlog.\\r\n\\r\n\\r\nReturn the total amount of orders in the backlog after placing all the orders from the input. Since this number can be large, return it modulo 109 + 7.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: orders = [[10,5,0],[15,2,1],[25,1,1],[30,4,0]]\\r\nOutput: 6\\r\nExplanation: Here is what happens with the orders:\\r\n- 5 orders of type buy with price 10 are placed. There are no sell orders, so the 5 orders are added to the backlog.\\r\n- 2 orders of type sell with price 15 are placed. There are no buy orders with prices larger than or equal to 15, so the 2 orders are added to the backlog.\\r\n- 1 order of type sell with price 25 is placed. There are no buy orders with prices larger than or equal to 25 in the backlog, so this order is added to the backlog.\\r\n- 4 orders of type buy with price 30 are placed. The first 2 orders are matched with the 2 sell orders of the least price, which is 15 and these 2 sell orders are removed from the backlog. The 3rd order is matched with the sell order of the least price, which is 25 and this sell order is removed from the backlog. Then, there are no more sell orders in the backlog, so the 4th order is added to the backlog.\\r\nFinally, the backlog has 5 buy orders with price 10, and 1 buy order with price 30. So the total number of orders in the backlog is 6.\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: orders = [[7,1000000000,1],[15,3,0],[5,999999995,0],[5,1,1]]\\r\nOutput: 999999984\\r\nExplanation: Here is what happens with the orders:\\r\n- 109 orders of type sell with price 7 are placed. There are no buy orders, so the 109 orders are added to the backlog.\\r\n- 3 orders of type buy with price 15 are placed. They are matched with the 3 sell orders with the least price which is 7, and those 3 sell orders are removed from the backlog.\\r\n- 999999995 orders of type buy with price 5 are placed. The least price of a sell order is 7, so the 999999995 orders are added to the backlog.\\r\n- 1 order of type sell with price 5 is placed. It is matched with the buy order of the highest price, which is 5, and that buy order is removed from the backlog.\\r\nFinally, the backlog has (1000000000-3) sell orders with price 7, and (999999995-1) buy orders with price 5. So the total number of orders = 1999999991, which is equal to 999999984 % (109 + 7).\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= orders.length <= 105\\r\n\torders[i].length == 3\\r\n\t1 <= pricei, amounti <= 109\\r\n\torderTypei is either 0 or 1.\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(orders = [[7, 1000000000, 1], [15, 3, 0], [5, 999999995, 0], [5, 1, 1]]) == 999999984\n assert candidate(orders = [[1, 10, 0], [1, 10, 1], [1, 10, 0], [1, 10, 1]]) == 0\n assert candidate(orders = [[100, 1, 0], [200, 2, 0], [300, 3, 1], [400, 4, 1]]) == 10\n assert candidate(orders = [[1, 1, 0], [1, 1, 1], [1, 1, 0], [1, 1, 1]]) == 0\n assert candidate(orders = [[5, 5, 0], [5, 5, 1], [5, 5, 0], [5, 5, 1]]) == 0\n assert candidate(orders = [[100, 100, 0], [100, 100, 1], [101, 100, 0], [99, 100, 1]]) == 0\n assert candidate(orders = [[1, 10, 0], [2, 10, 0], [3, 10, 1], [4, 10, 1]]) == 40\n assert candidate(orders = [[5, 5, 0], [4, 4, 1], [3, 3, 0], [2, 2, 1], [1, 1, 0]]) == 3\n assert candidate(orders = [[100, 10, 0], [200, 15, 0], [100, 5, 1], [200, 20, 1]]) == 20\n assert candidate(orders = [[5, 5, 0], [5, 5, 1]]) == 0\n assert candidate(orders = [[10, 5, 0], [15, 2, 1], [25, 1, 1], [30, 4, 0]]) == 6\n assert candidate(orders = [[100, 1, 0], [99, 2, 0], [98, 3, 0], [97, 4, 1], [96, 5, 1]]) == 3\n assert candidate(orders = [[5, 10, 0], [5, 5, 1], [5, 5, 0], [5, 3, 1]]) == 7\n assert candidate(orders = [[1, 10, 0], [2, 20, 1], [3, 30, 0], [4, 40, 1]]) == 60\n assert candidate(orders = [[100, 10, 0], [99, 9, 1], [98, 8, 0], [97, 7, 1], [96, 6, 0]]) == 8\n assert candidate(orders = [[10, 10, 0], [10, 10, 0], [10, 10, 1], [10, 10, 1]]) == 0\n assert candidate(orders = [[50, 10, 0], [40, 15, 0], [30, 20, 0], [20, 25, 1], [10, 30, 1], [5, 35, 1], [3, 40, 1], [2, 45, 1], [1, 50, 1]]) == 180\n assert candidate(orders = [[10, 5, 0], [20, 5, 0], [30, 5, 0], [40, 5, 0], [10, 5, 1], [20, 5, 1], [30, 5, 1], [40, 5, 1], [5, 5, 0], [35, 5, 1]]) == 30\n assert candidate(orders = [[1, 1000000000, 0], [1, 1000000000, 0], [1, 1000000000, 1], [1, 1000000000, 1], [1, 1000000000, 0], [1, 1000000000, 1]]) == 0\n assert candidate(orders = [[1000000000, 1, 0], [1000000000, 1, 0], [1000000000, 1, 0], [1000000000, 1, 1], [1000000000, 1, 1], [1000000000, 1, 1]]) == 0\n assert candidate(orders = [[10, 5, 0], [9, 5, 0], [8, 5, 0], [7, 5, 0], [6, 5, 0], [6, 5, 1], [7, 5, 1], [8, 5, 1], [9, 5, 1], [10, 5, 1]]) == 20\n assert candidate(orders = [[1000000000, 1, 0], [999999999, 2, 0], [999999998, 3, 0], [999999997, 4, 1], [999999996, 5, 1], [999999995, 6, 1]]) == 9\n assert candidate(orders = [[1, 1000000000, 0], [1000000000, 1, 1], [2, 999999999, 0], [999999999, 2, 1], [3, 999999998, 0], [999999998, 3, 1], [4, 999999997, 0], [999999997, 4, 1]]) == 999999983\n assert candidate(orders = [[1000000000, 1, 0], [999999999, 2, 0], [999999998, 3, 0], [999999997, 4, 1], [999999996, 5, 1]]) == 3\n assert candidate(orders = [[1, 1000, 0], [2, 2000, 1], [3, 3000, 0], [4, 4000, 1], [5, 5000, 0], [6, 6000, 1], [7, 7000, 0], [8, 8000, 1], [9, 9000, 0], [10, 10000, 1]]) == 15000\n assert candidate(orders = [[1000, 1, 0], [1000, 2, 0], [1000, 3, 0], [1000, 1, 1], [1000, 2, 1], [1000, 3, 1]]) == 0\n assert candidate(orders = [[10, 100, 0], [20, 50, 1], [15, 30, 0], [25, 20, 1], [5, 10, 0], [30, 5, 1]]) == 215\n assert candidate(orders = [[100, 10, 0], [90, 5, 1], [80, 15, 0], [70, 20, 1], [60, 25, 0], [50, 30, 1]]) == 5\n assert candidate(orders = [[999999999, 50000, 0], [1, 50000, 1], [999999998, 50000, 0], [2, 50000, 1], [999999997, 50000, 0], [3, 50000, 1]]) == 0\n assert candidate(orders = [[1, 1000000000, 0], [2, 999999999, 0], [3, 999999998, 0], [4, 999999997, 0], [5, 999999996, 0], [5, 999999996, 1], [4, 999999997, 1], [3, 999999998, 1], [2, 999999999, 1], [1, 1000000000, 1]]) == 0\n assert candidate(orders = [[10, 10, 0], [20, 20, 1], [15, 15, 0], [16, 16, 1], [14, 14, 0], [17, 17, 1]]) == 92\n assert candidate(orders = [[10, 1, 0], [9, 2, 0], [8, 3, 0], [7, 4, 0], [6, 5, 1], [5, 6, 1], [4, 7, 1], [3, 8, 1], [2, 9, 1], [1, 10, 1]]) == 35\n assert candidate(orders = [[1000, 1000000, 0], [1001, 1000000, 0], [1002, 1000000, 0], [999, 1000000, 1], [998, 1000000, 1], [997, 1000000, 1]]) == 0\n assert candidate(orders = [[10, 10, 0], [20, 10, 1], [15, 10, 0], [25, 10, 1], [10, 10, 0], [20, 10, 1], [15, 10, 0], [25, 10, 1], [10, 10, 0], [20, 10, 1], [15, 10, 0], [25, 10, 1], [10, 10, 0], [20, 10, 1], [15, 10, 0], [25, 10, 1]]) == 160\n assert candidate(orders = [[1, 1000000000, 0], [2, 1000000000, 1], [3, 1000000000, 0], [4, 1000000000, 1], [5, 1000000000, 0], [6, 1000000000, 1]]) == 999999993\n assert candidate(orders = [[10, 1000, 0], [20, 1000, 0], [30, 1000, 0], [40, 1000, 1], [50, 1000, 1], [60, 1000, 1], [70, 1000, 0], [80, 1000, 1], [90, 1000, 0]]) == 5000\n assert candidate(orders = [[10, 5, 0], [20, 10, 0], [30, 15, 0], [40, 20, 0], [50, 25, 0], [10, 5, 1], [20, 10, 1], [30, 15, 1], [40, 20, 1], [50, 25, 1]]) == 60\n assert candidate(orders = [[10, 5, 0], [20, 5, 0], [30, 5, 0], [40, 5, 0], [15, 5, 1], [25, 5, 1], [35, 5, 1], [45, 5, 1]]) == 20\n assert candidate(orders = [[1, 1000000000, 0], [2, 1000000000, 0], [3, 1000000000, 0], [1, 1000000000, 1], [2, 1000000000, 1], [3, 1000000000, 1]]) == 999999993\n assert candidate(orders = [[10, 1, 0], [11, 2, 0], [12, 3, 0], [13, 4, 1], [14, 5, 1], [15, 6, 1], [16, 7, 1], [17, 8, 0], [18, 9, 0], [19, 10, 0]]) == 11\n assert candidate(orders = [[10, 1, 0], [10, 2, 0], [10, 3, 0], [10, 4, 1], [10, 5, 1], [10, 6, 1], [10, 7, 1], [10, 8, 0], [10, 9, 0], [10, 10, 0]]) == 11\n assert candidate(orders = [[5, 1, 0], [5, 2, 0], [5, 3, 0], [5, 4, 0], [5, 5, 1], [5, 4, 1], [5, 3, 1], [5, 2, 1], [5, 1, 1]]) == 5\n assert candidate(orders = [[100, 5, 0], [90, 10, 0], [80, 15, 0], [70, 20, 0], [60, 25, 0], [50, 30, 1], [40, 35, 1], [30, 40, 1], [20, 45, 1], [10, 50, 1]]) == 125\n assert candidate(orders = [[10, 1000, 0], [10, 900, 0], [10, 800, 0], [10, 700, 1], [10, 600, 1], [10, 500, 1], [10, 400, 1]]) == 500\n assert candidate(orders = [[10, 5, 0], [10, 5, 1], [10, 5, 0], [10, 5, 1], [10, 5, 0], [10, 5, 1], [10, 5, 0], [10, 5, 1]]) == 0\n assert candidate(orders = [[1, 999999999, 0], [1, 999999999, 0], [1, 999999999, 0], [1, 999999999, 0], [2, 999999999, 1], [2, 999999999, 1], [2, 999999999, 1], [2, 999999999, 1]]) == 999999943\n assert candidate(orders = [[10, 1, 0], [9, 2, 0], [8, 3, 0], [7, 4, 1], [6, 5, 1], [5, 6, 0], [4, 7, 0], [3, 8, 1], [2, 9, 1], [1, 10, 0]]) == 17\n assert candidate(orders = [[5, 100, 0], [10, 100, 1], [15, 100, 0], [20, 100, 1], [25, 100, 0], [30, 100, 1]]) == 200\n assert candidate(orders = [[10, 5, 0], [10, 5, 0], [10, 5, 0], [10, 5, 1], [10, 5, 1], [10, 5, 1], [10, 5, 0], [10, 5, 1], [10, 5, 0], [10, 5, 1]]) == 0\n assert candidate(orders = [[100, 100, 1], [90, 200, 1], [80, 300, 1], [70, 400, 0], [60, 500, 0], [50, 600, 0]]) == 2100\n assert candidate(orders = [[1000000000, 1, 0], [999999999, 1, 0], [999999998, 1, 0], [999999997, 1, 1], [999999996, 1, 1], [999999995, 1, 1]]) == 0\n assert candidate(orders = [[10, 1, 0], [20, 2, 0], [30, 3, 0], [40, 4, 0], [50, 5, 0], [10, 1, 1], [20, 2, 1], [30, 3, 1], [40, 4, 1], [50, 5, 1]]) == 12\n assert candidate(orders = [[1, 1000000000, 0], [1000000000, 1, 1], [500000000, 2, 0], [1000000000, 999999999, 1], [1, 1, 0]]) == 999999996\n assert candidate(orders = [[1, 1000000000, 0], [2, 1000000000, 1], [3, 1000000000, 0], [4, 1000000000, 1], [5, 1000000000, 0], [6, 1000000000, 1]]) == 999999993\n assert candidate(orders = [[100, 1000, 0], [999, 500, 1], [998, 750, 1], [1000, 1000, 0], [999, 250, 0]]) == 1000\n assert candidate(orders = [[100, 1, 0], [99, 2, 0], [98, 3, 0], [97, 4, 1], [96, 5, 1], [95, 6, 0], [94, 7, 1], [93, 8, 0], [92, 9, 1]]) == 5\n assert candidate(orders = [[1, 1000000000, 0], [1, 1000000000, 0], [1, 1000000000, 0], [1, 1000000000, 1], [1, 1000000000, 1], [1, 1000000000, 1]]) == 0\n assert candidate(orders = [[100, 1, 0], [99, 2, 0], [98, 3, 0], [97, 4, 1], [96, 5, 1], [95, 6, 0], [94, 7, 0], [93, 8, 1], [92, 9, 1]]) == 7\n assert candidate(orders = [[100, 100, 0], [200, 200, 0], [300, 300, 0], [400, 400, 0], [500, 500, 1], [600, 600, 1], [700, 700, 1], [800, 800, 1], [900, 900, 1], [1000, 1000, 1]]) == 5500\n assert candidate(orders = [[10, 5, 0], [20, 10, 0], [30, 15, 0], [5, 1, 1], [15, 2, 1], [25, 3, 1]]) == 24\n assert candidate(orders = [[100, 100, 0], [99, 150, 0], [98, 200, 0], [97, 250, 1], [96, 300, 1], [95, 350, 1]]) == 450\n assert candidate(orders = [[1, 1, 0], [2, 1, 0], [3, 1, 0], [4, 1, 0], [5, 1, 0], [6, 1, 0], [7, 1, 0], [8, 1, 0], [9, 1, 0], [10, 1, 0], [1, 1, 1], [2, 1, 1], [3, 1, 1], [4, 1, 1], [5, 1, 1], [6, 1, 1], [7, 1, 1], [8, 1, 1], [9, 1, 1], [10, 1, 1]]) == 10\n assert candidate(orders = [[1000000000, 1, 0], [1, 1, 1], [500000000, 1, 0], [500000000, 1, 1], [1000000000, 1, 0], [1, 1, 1]]) == 0\n assert candidate(orders = [[100, 100, 0], [90, 200, 0], [80, 300, 0], [70, 400, 1], [60, 500, 1], [50, 600, 1]]) == 900\n assert candidate(orders = [[10, 1, 0], [20, 2, 0], [10, 1, 1], [20, 2, 1], [30, 3, 0], [25, 2, 1], [15, 1, 0], [5, 1, 1]]) == 1\n assert candidate(orders = [[100, 5, 0], [200, 10, 0], [150, 5, 1], [160, 5, 1], [200, 20, 0], [150, 10, 1]]) == 15\n assert candidate(orders = [[10, 10, 0], [20, 10, 0], [30, 10, 0], [40, 10, 0], [50, 10, 0], [10, 10, 1], [20, 10, 1], [30, 10, 1], [40, 10, 1], [50, 10, 1], [10, 10, 0], [20, 10, 0], [30, 10, 0], [40, 10, 0], [50, 10, 0], [10, 10, 1], [20, 10, 1], [30, 10, 1], [40, 10, 1], [50, 10, 1]]) == 60\n assert candidate(orders = [[100, 1, 0], [90, 2, 0], [80, 3, 0], [70, 4, 1], [60, 5, 1], [50, 6, 1], [40, 7, 1], [30, 8, 1], [20, 9, 1], [10, 10, 1]]) == 43\n assert candidate(orders = [[1, 1, 0], [2, 1, 0], [3, 1, 0], [4, 1, 0], [5, 1, 0], [5, 1, 1], [4, 1, 1], [3, 1, 1], [2, 1, 1], [1, 1, 1]]) == 0\n assert candidate(orders = [[1000000000, 1, 0], [999999999, 2, 0], [999999998, 3, 0], [999999997, 4, 1], [999999996, 5, 1], [999999995, 6, 0], [999999994, 7, 0], [999999993, 8, 1], [999999992, 9, 1]]) == 7\n assert candidate(orders = [[10, 100, 0], [20, 50, 0], [30, 200, 1], [15, 150, 1], [25, 100, 0], [35, 100, 1]]) == 400\n assert candidate(orders = [[1, 1, 0], [1, 1, 1], [1, 1, 0], [1, 1, 1], [1, 1, 0], [1, 1, 1]]) == 0\n assert candidate(orders = [[1, 1, 0], [2, 2, 0], [3, 3, 0], [4, 4, 0], [5, 5, 0], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1]]) == 12\n assert candidate(orders = [[100, 5, 0], [100, 5, 0], [100, 5, 1], [100, 5, 1], [100, 5, 0], [100, 5, 1]]) == 0\n assert candidate(orders = [[5, 1, 0], [6, 1, 0], [7, 1, 0], [8, 1, 0], [9, 1, 0], [10, 1, 1], [11, 1, 1], [12, 1, 1], [13, 1, 1], [14, 1, 1]]) == 10\n assert candidate(orders = [[10, 10, 0], [20, 20, 0], [30, 30, 0], [40, 40, 0], [50, 50, 0], [10, 1, 1], [20, 2, 1], [30, 3, 1], [40, 4, 1], [50, 5, 1]]) == 135\n assert candidate(orders = [[50, 10, 0], [50, 15, 0], [50, 20, 0], [50, 25, 1], [50, 30, 1], [50, 35, 1], [50, 40, 1], [50, 45, 1], [50, 50, 1]]) == 180\n assert candidate(orders = [[100, 50, 0], [100, 50, 0], [100, 50, 0], [100, 50, 1], [100, 50, 1], [100, 50, 1]]) == 0\n assert candidate(orders = [[10, 5, 0], [20, 5, 0], [30, 5, 0], [10, 5, 1], [20, 5, 1], [30, 5, 1], [15, 5, 0], [25, 5, 0], [35, 5, 0]]) == 15\n assert candidate(orders = [[10, 1, 0], [10, 1, 1], [11, 1, 0], [9, 1, 1], [12, 1, 0], [8, 1, 1], [13, 1, 0], [7, 1, 1]]) == 0\n assert candidate(orders = [[1, 1000000000, 0], [2, 1000000000, 0], [3, 1000000000, 0], [4, 1000000000, 1], [5, 1000000000, 1], [6, 1000000000, 1]]) == 999999965\n assert candidate(orders = [[10, 10, 0], [10, 10, 1], [10, 10, 0], [10, 10, 1], [10, 10, 0], [10, 10, 1], [10, 10, 0], [10, 10, 1], [10, 10, 0], [10, 10, 1]]) == 0\n assert candidate(orders = [[1, 1000000000, 0], [2, 999999999, 0], [3, 999999998, 0], [4, 999999997, 1], [5, 999999996, 1], [6, 999999995, 1], [7, 999999994, 1], [8, 999999993, 0], [9, 999999992, 0], [10, 999999991, 0]]) == 999999982\n assert candidate(orders = [[50, 10, 0], [40, 20, 0], [30, 30, 0], [20, 40, 0], [10, 50, 0], [10, 60, 1], [20, 70, 1], [30, 80, 1], [40, 90, 1], [50, 100, 1], [15, 5, 0], [25, 5, 0], [35, 5, 0], [45, 5, 0], [55, 5, 0]]) == 335\n assert candidate(orders = [[100, 10, 0], [90, 10, 0], [80, 10, 0], [70, 10, 0], [60, 10, 0], [50, 10, 1], [40, 10, 1], [30, 10, 1], [20, 10, 1], [10, 10, 1]]) == 0\n assert candidate(orders = [[10, 5, 0], [20, 5, 0], [30, 5, 0], [15, 10, 1], [25, 10, 1], [35, 10, 1], [10, 5, 0], [20, 5, 0], [30, 5, 0], [15, 10, 1], [25, 10, 1], [35, 10, 1]]) == 50\n assert candidate(orders = [[100, 100000000, 0], [90, 200000000, 0], [80, 300000000, 1], [70, 400000000, 1], [60, 500000000, 0]]) == 900000000\n assert candidate(orders = [[100, 500, 0], [90, 500, 0], [80, 500, 0], [70, 500, 1], [60, 500, 1], [50, 500, 1]]) == 0\n assert candidate(orders = [[10, 1, 0], [10, 2, 1], [10, 3, 0], [10, 4, 1], [10, 5, 0]]) == 3\n assert candidate(orders = [[1, 1000000000, 0], [2, 500000000, 1], [3, 300000000, 0], [4, 200000000, 1], [5, 400000000, 0]]) == 1000000000\n assert candidate(orders = [[100, 5, 0], [101, 3, 0], [102, 2, 0], [99, 5, 1], [98, 6, 1], [97, 7, 1]]) == 8\n assert candidate(orders = [[500, 10, 0], [500, 10, 1], [500, 5, 0], [500, 5, 1], [500, 3, 0], [500, 3, 1]]) == 0\n assert candidate(orders = [[50, 10, 0], [60, 15, 0], [70, 20, 0], [40, 5, 1], [55, 10, 1], [65, 15, 1], [50, 10, 1], [60, 15, 1], [70, 20, 1]]) == 50\n assert candidate(orders = [[10, 1, 0], [20, 1, 1], [30, 1, 0], [40, 1, 1], [50, 1, 0], [60, 1, 1], [70, 1, 0], [80, 1, 1], [90, 1, 0]]) == 1\n assert candidate(orders = [[10, 10, 0], [9, 20, 0], [8, 30, 0], [7, 40, 1], [6, 50, 1], [5, 60, 1]]) == 90\n assert candidate(orders = [[20, 5, 0], [15, 3, 0], [10, 2, 1], [5, 1, 1], [15, 4, 0], [10, 6, 1]]) == 3\n assert candidate(orders = [[100, 1, 0], [200, 1, 0], [300, 1, 0], [400, 1, 0], [500, 1, 0], [150, 1, 1], [250, 1, 1], [350, 1, 1], [450, 1, 1], [550, 1, 1]]) == 6\n assert candidate(orders = [[999999999, 1, 0], [999999998, 2, 0], [999999997, 3, 0], [999999996, 4, 1], [999999995, 5, 1]]) == 3\n assert candidate(orders = [[10, 1, 0], [10, 1, 1], [10, 1, 0], [10, 1, 1], [10, 1, 0], [10, 1, 1], [10, 1, 0], [10, 1, 1], [10, 1, 0], [10, 1, 1]]) == 0\n assert candidate(orders = [[100, 500, 0], [90, 400, 0], [80, 300, 0], [70, 200, 1], [60, 100, 1], [50, 50, 1], [40, 50, 1], [30, 100, 1], [20, 200, 1]]) == 500\n assert candidate(orders = [[100, 100000, 0], [200, 200000, 0], [150, 50000, 1], [175, 75000, 1]]) == 175000\n assert candidate(orders = [[1000000000, 1, 0], [999999999, 1, 0], [999999998, 1, 0], [999999997, 1, 0], [999999996, 1, 0], [999999995, 1, 1], [999999994, 1, 1], [999999993, 1, 1], [999999992, 1, 1], [999999991, 1, 1]]) == 0\n assert candidate(orders = [[1, 1, 0], [2, 2, 0], [3, 3, 0], [4, 4, 0], [5, 5, 0], [6, 6, 0], [7, 7, 0], [8, 8, 0], [9, 9, 0], [10, 10, 0], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1], [10, 10, 1]]) == 54\n assert candidate(orders = [[5, 10, 0], [10, 20, 0], [15, 30, 0], [20, 10, 1], [25, 20, 1], [30, 30, 1]]) == 120\n assert candidate(orders = [[100, 10, 0], [90, 5, 1], [80, 3, 0], [70, 2, 1], [60, 4, 0], [50, 1, 1]]) == 9\n assert candidate(orders = [[10, 1, 0], [20, 1, 0], [30, 1, 0], [40, 1, 0], [50, 1, 0], [10, 1, 1], [20, 1, 1], [30, 1, 1], [40, 1, 1], [50, 1, 1]]) == 4\n assert candidate(orders = [[1, 1000000000, 1], [1000000000, 1, 0], [2, 1000000000, 1], [999999999, 1, 0], [3, 1000000000, 1]]) == 999999984\n assert candidate(orders = [[1, 10, 0], [2, 10, 0], [3, 10, 0], [4, 10, 1], [5, 10, 1], [6, 10, 1], [7, 10, 1], [8, 10, 1], [9, 10, 1]]) == 90\n assert candidate(orders = [[100, 1, 0], [100, 1, 0], [100, 1, 0], [100, 1, 1], [100, 1, 1], [100, 1, 1], [100, 1, 0], [100, 1, 0], [100, 1, 0], [100, 1, 1], [100, 1, 1], [100, 1, 1], [100, 1, 0], [100, 1, 0], [100, 1, 0], [100, 1, 1], [100, 1, 1], [100, 1, 1]]) == 0\n assert candidate(orders = [[100, 10, 0], [90, 20, 0], [80, 30, 0], [70, 40, 0], [60, 50, 0], [50, 60, 1], [40, 70, 1], [30, 80, 1], [20, 90, 1], [10, 100, 1]]) == 250\n assert candidate(orders = [[1, 1000000000, 0], [2, 1000000000, 0], [3, 1000000000, 1], [4, 1000000000, 1], [5, 1000000000, 0]]) == 999999986\n assert candidate(orders = [[1, 1, 0], [2, 2, 1], [3, 3, 0], [4, 4, 1], [5, 5, 0], [6, 6, 1], [7, 7, 0], [8, 8, 1], [9, 9, 0], [10, 10, 1]]) == 15\n assert candidate(orders = [[50, 10, 0], [40, 15, 0], [30, 20, 0], [20, 25, 1], [10, 30, 1], [15, 35, 0], [25, 40, 1]]) == 65\n"}, "metadata": {"canonical_parameter_names": ["orders"], "leetcode_dataset_entry_point": "Solution().getNumberOfBacklogOrders", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int getNumberOfBacklogOrders(vector>& orders) {", "container": "Solution", "callable": "getNumberOfBacklogOrders", "parameters": [{"name": "orders", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1802, "task_id": "maximum-value-at-a-given-index-in-a-bounded-array", "difficulty": "Medium", "problem_description": "You are given three positive integers: n, index, and maxSum. You want to construct an array nums (0-indexed) that satisfies the following conditions:\n\nnums.length == n\nnums[i] is a positive integer where 0 <= i < n.\nabs(nums[i] - nums[i+1]) <= 1 where 0 <= i < n-1.\nThe sum of all the elements of nums does not exceed maxSum.\nnums[index] is maximized.\n\nReturn nums[index] of the constructed array.\nNote that abs(x) equals x if x >= 0, and -x otherwise.\n \nExample 1:\n\nInput: n = 4, index = 2, maxSum = 6\nOutput: 2\nExplanation: nums = [1,2,2,1] is one array that satisfies all the conditions.\nThere are no arrays that satisfy all the conditions and have nums[2] == 3, so 2 is the maximum nums[2].\n\nExample 2:\n\nInput: n = 6, index = 1, maxSum = 10\nOutput: 3\n\n \nConstraints:\n\n1 <= n <= maxSum <= 109\n0 <= index < n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1,index = 0,maxSum = 1) == 1\n assert candidate(n = 10,index = 5,maxSum = 50) == 7\n assert candidate(n = 6,index = 1,maxSum = 10) == 3\n assert candidate(n = 1000000000,index = 500000000,maxSum = 1000000000) == 1\n assert candidate(n = 4,index = 2,maxSum = 6) == 2\n assert candidate(n = 20,index = 10,maxSum = 210) == 15\n assert candidate(n = 1000000000,index = 999999999,maxSum = 2000000000) == 44721\n assert candidate(n = 7,index = 3,maxSum = 20) == 4\n assert candidate(n = 1000000000,index = 1,maxSum = 1200000000) == 19999\n assert candidate(n = 100000,index = 0,maxSum = 10000000) == 4450\n assert candidate(n = 9,index = 4,maxSum = 25) == 5\n assert candidate(n = 1000,index = 500,maxSum = 500000) == 750\n assert candidate(n = 1000000000,index = 999999999,maxSum = 1000000000) == 1\n assert candidate(n = 20,index = 10,maxSum = 200) == 15\n assert candidate(n = 999999999,index = 999999998,maxSum = 2000000000) == 44721\n assert candidate(n = 100,index = 50,maxSum = 5000) == 75\n assert candidate(n = 1000000000,index = 500000000,maxSum = 2500000000) == 38730\n assert candidate(n = 4,index = 1,maxSum = 10) == 3\n assert candidate(n = 1000,index = 500,maxSum = 100000) == 315\n assert candidate(n = 750000000,index = 375000000,maxSum = 1500000000) == 27387\n assert candidate(n = 100000,index = 99999,maxSum = 10000000) == 4450\n assert candidate(n = 1000000,index = 500000,maxSum = 10000000) == 3001\n assert candidate(n = 500000000,index = 499999999,maxSum = 1500000000) == 44721\n assert candidate(n = 999999999,index = 0,maxSum = 999999999) == 1\n assert candidate(n = 999999999,index = 499999999,maxSum = 10000000000) == 94869\n assert candidate(n = 1000000000,index = 0,maxSum = 1000000000) == 1\n assert candidate(n = 50,index = 24,maxSum = 1225) == 37\n assert candidate(n = 100,index = 50,maxSum = 5050) == 75\n assert candidate(n = 9,index = 4,maxSum = 45) == 7\n assert candidate(n = 35,index = 17,maxSum = 3000) == 94\n assert candidate(n = 10000,index = 4999,maxSum = 1000000) == 995\n assert candidate(n = 9,index = 4,maxSum = 100) == 13\n assert candidate(n = 20,index = 0,maxSum = 50) == 8\n assert candidate(n = 1000000000,index = 1,maxSum = 2500000000) == 54771\n assert candidate(n = 750000000,index = 375000000,maxSum = 1800000000) == 32404\n assert candidate(n = 50,index = 25,maxSum = 500) == 22\n assert candidate(n = 500,index = 250,maxSum = 150000) == 425\n assert candidate(n = 2000000000,index = 1000000000,maxSum = 3000000000) == 31623\n assert candidate(n = 100,index = 50,maxSum = 10000) == 125\n assert candidate(n = 300000000,index = 150000000,maxSum = 1500000000) == 34642\n assert candidate(n = 5,index = 2,maxSum = 15) == 4\n assert candidate(n = 1000000000,index = 0,maxSum = 2000000000) == 44721\n assert candidate(n = 50,index = 24,maxSum = 1275) == 38\n assert candidate(n = 200,index = 100,maxSum = 2000) == 43\n assert candidate(n = 1,index = 0,maxSum = 1000000000) == 1000000000\n assert candidate(n = 1000000000,index = 500000000,maxSum = 10000000000) == 94869\n assert candidate(n = 8,index = 3,maxSum = 30) == 5\n assert candidate(n = 12,index = 6,maxSum = 75) == 9\n assert candidate(n = 10,index = 0,maxSum = 36) == 7\n assert candidate(n = 50,index = 24,maxSum = 5000) == 112\n assert candidate(n = 20,index = 19,maxSum = 50) == 8\n assert candidate(n = 500000000,index = 250000000,maxSum = 1000000000) == 22361\n assert candidate(n = 2,index = 1,maxSum = 3) == 2\n assert candidate(n = 1000000000,index = 1,maxSum = 2000000000) == 44720\n assert candidate(n = 15,index = 7,maxSum = 120) == 11\n assert candidate(n = 500000000,index = 1,maxSum = 1500000000) == 44720\n assert candidate(n = 500000000,index = 250000000,maxSum = 1500000000) == 31623\n assert candidate(n = 10,index = 0,maxSum = 100) == 14\n assert candidate(n = 15,index = 7,maxSum = 500) == 37\n assert candidate(n = 50,index = 25,maxSum = 1000) == 32\n assert candidate(n = 3,index = 1,maxSum = 15) == 5\n assert candidate(n = 25,index = 12,maxSum = 1500) == 66\n assert candidate(n = 7,index = 3,maxSum = 25) == 5\n assert candidate(n = 10,index = 9,maxSum = 100) == 14\n assert candidate(n = 3,index = 1,maxSum = 1000000000) == 333333334\n assert candidate(n = 500,index = 250,maxSum = 2000) == 39\n assert candidate(n = 20,index = 19,maxSum = 200) == 19\n assert candidate(n = 500000,index = 250000,maxSum = 100000000) == 9975\n assert candidate(n = 800000000,index = 400000000,maxSum = 1600000000) == 28285\n assert candidate(n = 15,index = 7,maxSum = 100) == 10\n assert candidate(n = 200,index = 100,maxSum = 20100) == 150\n assert candidate(n = 999999999,index = 499999999,maxSum = 999999999) == 1\n assert candidate(n = 200000000,index = 100000000,maxSum = 500000000) == 17321\n assert candidate(n = 1000000,index = 999999,maxSum = 2000000) == 1414\n assert candidate(n = 1000000000,index = 1,maxSum = 1000000000) == 1\n assert candidate(n = 500000000,index = 0,maxSum = 1200000000) == 37417\n assert candidate(n = 999999999,index = 0,maxSum = 1500000000) == 31623\n assert candidate(n = 10,index = 4,maxSum = 55) == 8\n assert candidate(n = 100,index = 50,maxSum = 1000) == 31\n assert candidate(n = 10,index = 9,maxSum = 25) == 6\n assert candidate(n = 10,index = 9,maxSum = 36) == 7\n assert candidate(n = 100000,index = 50000,maxSum = 5000000) == 2214\n assert candidate(n = 10,index = 0,maxSum = 50) == 9\n assert candidate(n = 2,index = 1,maxSum = 6) == 3\n assert candidate(n = 10,index = 0,maxSum = 25) == 6\n assert candidate(n = 150,index = 75,maxSum = 100000) == 704\n assert candidate(n = 2,index = 1,maxSum = 1000000000) == 500000000\n assert candidate(n = 5,index = 2,maxSum = 17) == 4\n assert candidate(n = 1000000000,index = 500000000,maxSum = 1000000001) == 2\n assert candidate(n = 500000000,index = 250000000,maxSum = 800000000) == 17321\n assert candidate(n = 5,index = 2,maxSum = 20) == 5\n assert candidate(n = 7,index = 3,maxSum = 50) == 8\n"}, "metadata": {"canonical_parameter_names": ["n", "index", "maxSum"], "leetcode_dataset_entry_point": "Solution().maxValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxValue(int n, int index, int maxSum) {", "container": "Solution", "callable": "maxValue", "parameters": [{"name": "n", "type": "int"}, {"name": "index", "type": "int"}, {"name": "maxSum", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1803, "task_id": "count-pairs-with-xor-in-a-range", "difficulty": "Hard", "problem_description": "Given a (0-indexed) integer array nums and two integers low and high, return the number of nice pairs.\\r\n\\r\nA nice pair is a pair (i, j) where 0 <= i < j < nums.length and low <= (nums[i] XOR nums[j]) <= high.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: nums = [1,4,2,7], low = 2, high = 6\\r\nOutput: 6\\r\nExplanation: All nice pairs (i, j) are as follows:\\r\n - (0, 1): nums[0] XOR nums[1] = 5 \\r\n - (0, 2): nums[0] XOR nums[2] = 3\\r\n - (0, 3): nums[0] XOR nums[3] = 6\\r\n - (1, 2): nums[1] XOR nums[2] = 6\\r\n - (1, 3): nums[1] XOR nums[3] = 3\\r\n - (2, 3): nums[2] XOR nums[3] = 5\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: nums = [9,8,4,2,1], low = 5, high = 14\\r\nOutput: 8\\r\nExplanation: All nice pairs (i, j) are as follows:\\r\n​​​​​ - (0, 2): nums[0] XOR nums[2] = 13\\r\n  - (0, 3): nums[0] XOR nums[3] = 11\\r\n  - (0, 4): nums[0] XOR nums[4] = 8\\r\n  - (1, 2): nums[1] XOR nums[2] = 12\\r\n  - (1, 3): nums[1] XOR nums[3] = 10\\r\n  - (1, 4): nums[1] XOR nums[4] = 9\\r\n  - (2, 3): nums[2] XOR nums[3] = 6\\r\n  - (2, 4): nums[2] XOR nums[4] = 5\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= nums.length <= 2 * 104\\r\n\t1 <= nums[i] <= 2 * 104\\r\n\t1 <= low <= high <= 2 * 104\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 5, 7, 9],low = 1,high = 10) == 8\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9],low = 3,high = 7) == 10\n assert candidate(nums = [10, 20, 30, 40, 50],low = 15,high = 25) == 1\n assert candidate(nums = [9, 8, 4, 2, 1],low = 5,high = 14) == 8\n assert candidate(nums = [1, 4, 2, 7],low = 2,high = 6) == 6\n assert candidate(nums = [5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000],low = 5000,high = 15000) == 6\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021, 222324],low = 1000,high = 20000) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80],low = 2,high = 60) == 486\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],low = 1,high = 524288) == 0\n assert candidate(nums = [2468, 3579, 4682, 5793, 6824, 7935, 8246, 9357, 24689, 35790, 46821, 57932, 68243, 79354, 82465, 93576, 24687, 35798, 46829, 57930],low = 1000,high = 7000) == 20\n assert candidate(nums = [31415, 92653, 58979, 32384, 62643, 38327],low = 10000,high = 50000) == 8\n assert candidate(nums = [8, 14, 23, 41, 56, 72],low = 10,high = 50) == 7\n assert candidate(nums = [8, 15, 3, 11, 2, 9, 13],low = 4,high = 12) == 13\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],low = 3,high = 12) == 70\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],low = 1,high = 10000) == 89\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000],low = 1000,high = 12000) == 77\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],low = 2,high = 10) == 60\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048],low = 5,high = 1000) == 36\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 1024, 512, 256, 128],low = 1,high = 256) == 35\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],low = 2,high = 16) == 64\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993],low = 1,high = 10) == 21\n assert candidate(nums = [32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],low = 100,high = 20000) == 82\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],low = 2,high = 6) == 35\n assert candidate(nums = [1023, 2047, 3071, 4095, 5119, 6143, 7167, 8191, 9215, 10239],low = 500,high = 5000) == 17\n assert candidate(nums = [82, 164, 328, 656, 1312, 2624, 5248, 10496, 20992, 41984, 83968, 167936, 335872, 671744],low = 20000,high = 100000) == 16\n assert candidate(nums = [54321, 12345, 67890, 98765, 43210, 24680, 13579, 86420, 75310, 97531],low = 10000,high = 50000) == 31\n assert candidate(nums = [2, 3, 1, 6, 7, 5, 4, 8],low = 3,high = 9) == 16\n assert candidate(nums = [1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999],low = 2000,high = 8000) == 18\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],low = 3,high = 15) == 18\n assert candidate(nums = [15000, 20000, 25000, 30000, 35000, 40000],low = 5000,high = 15000) == 3\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],low = 10,high = 50) == 102\n assert candidate(nums = [6, 2, 3, 8, 10, 12, 15, 18],low = 1,high = 10) == 14\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],low = 20,high = 80) == 92\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],low = 5,high = 35) == 336\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31],low = 5,high = 20) == 15\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096],low = 10,high = 2000) == 51\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225],low = 50,high = 200) == 63\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],low = 0,high = 1) == 45\n assert candidate(nums = [16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],low = 1,high = 1000) == 45\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],low = 50000,high = 150000) == -24\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],low = 1,high = 20) == 86\n assert candidate(nums = [15, 3, 8, 7, 10, 12, 13, 14],low = 5,high = 15) == 18\n assert candidate(nums = [100, 150, 200, 250, 300, 350, 400],low = 50,high = 200) == 7\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 10101, 20202, 30303, 40404, 50505],low = 500,high = 2000) == 20\n assert candidate(nums = [31, 14, 7, 28, 21, 1, 2, 4, 8, 16],low = 5,high = 25) == 33\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],low = 5,high = 25) == 125\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],low = 0,high = 0) == 190\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],low = 5,high = 25) == 42\n assert candidate(nums = [20000, 19999, 19998, 19997, 19996, 19995, 19994, 19993, 19992, 19991],low = 100,high = 200) == 0\n assert candidate(nums = [10000, 20000, 15000, 25000, 12000, 18000, 22000, 16000, 14000, 21000],low = 5000,high = 15000) == 12\n assert candidate(nums = [12345, 67890, 13579, 24680, 98765],low = 50000,high = 100000) == -3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],low = 1,high = 10) == 80\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],low = 1,high = 512) == 36\n assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39],low = 2,high = 15) == 13\n assert candidate(nums = [1234, 2345, 3456, 4567, 5678, 6789, 7890],low = 1000,high = 5000) == 11\n assert candidate(nums = [32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63],low = 5000,high = 15000) == 9\n assert candidate(nums = [16384, 8192, 4096, 2048, 1024],low = 2000,high = 7000) == 3\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072],low = 10000,high = 100000) == 11\n assert candidate(nums = [123, 456, 789, 101112, 131415],low = 100,high = 500) == 3\n assert candidate(nums = [24, 48, 72, 96, 120, 144, 168, 192, 216, 240],low = 20,high = 100) == 16\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],low = 5,high = 200) == 27\n assert candidate(nums = [8191, 4095, 2047, 1023, 511],low = 1500,high = 3000) == 2\n assert candidate(nums = [123, 456, 789, 101, 112, 134, 156, 178, 190, 212],low = 50,high = 150) == 6\n assert candidate(nums = [10001, 20002, 30003, 40004, 50005, 60006, 70007, 80008, 90009],low = 10000,high = 90000) == 10\n assert candidate(nums = [5000, 10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000],low = 10000,high = 40000) == 23\n assert candidate(nums = [16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],low = 1,high = 10000) == 89\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],low = 1,high = 30) == 211\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],low = 0,high = 0) == 45\n assert candidate(nums = [11111, 22222, 33333, 44444, 55555, 66666, 77777, 88888, 99999, 100000],low = 20000,high = 80000) == 0\n assert candidate(nums = [1024, 2048, 3072, 4096, 5120, 6144, 7168],low = 1024,high = 6144) == 18\n assert candidate(nums = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127],low = 1000,high = 20000) == 23\n assert candidate(nums = [9876, 5432, 10987, 6543, 2019, 8765, 4321, 7654, 3210, 1111],low = 1000,high = 5000) == 14\n assert candidate(nums = [20000, 15000, 10000, 5000, 2500, 1250, 625],low = 1000,high = 5000) == 4\n assert candidate(nums = [123, 234, 345, 456, 567, 678, 789, 890, 901, 1012, 1113, 1214, 1315, 1416, 1517, 1618, 1719, 1820, 1921, 2022],low = 100,high = 500) == 41\n assert candidate(nums = [12345, 12346, 12347, 12348, 12349, 12350, 12351, 12352, 12353, 12354],low = 1,high = 5) == 18\n assert candidate(nums = [23, 5, 7, 9, 11, 13, 17, 19, 21, 23],low = 3,high = 15) == 14\n assert candidate(nums = [5000, 10000, 15000, 20000, 500, 1000, 1500, 2000],low = 100,high = 5000) == 8\n assert candidate(nums = [8, 13, 14, 30, 15, 17, 9],low = 3,high = 12) == 7\n assert candidate(nums = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150, 155, 160],low = 10,high = 70) == 149\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],low = 10,high = 40) == 37\n assert candidate(nums = [12345, 67890, 24680, 13579, 86420, 97531, 43210, 54321, 65432, 76543],low = 10000,high = 19000) == 6\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],low = 500,high = 1000) == 9\n assert candidate(nums = [12345, 67890, 13579, 24680, 97531, 86420, 11111, 22222, 33333, 44444],low = 10000,high = 50000) == 31\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],low = 10,high = 100) == 17\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],low = 100,high = 1000) == 90\n assert candidate(nums = [32768, 65535, 1, 2, 3, 4, 5, 6, 7, 8],low = 100,high = 1000) == 0\n assert candidate(nums = [32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63],low = 128,high = 256) == 3\n assert candidate(nums = [1023, 511, 255, 127, 63],low = 100,high = 500) == 5\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096],low = 1,high = 5000) == 76\n assert candidate(nums = [20000, 19000, 18000, 17000, 16000, 15000, 14000, 13000, 12000, 11000, 10000, 9000, 8000, 7000, 6000],low = 500,high = 10000) == 43\n assert candidate(nums = [123, 234, 345, 456, 567, 678, 789, 890, 901, 1012, 1113, 1214, 1315, 1416, 1517],low = 100,high = 1000) == 51\n assert candidate(nums = [9876, 6543, 3210, 1234, 5678, 8765, 5432, 2109, 4321],low = 1000,high = 10000) == 23\n assert candidate(nums = [1234, 5678, 91011, 121314, 151617, 181920, 212223],low = 5000,high = 15000) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],low = 15,high = 55) == 21\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],low = 2,high = 18) == 28\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],low = 1,high = 15) == 24\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],low = 2,high = 10) == 63\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],low = 100,high = 500) == 20\n assert candidate(nums = [18, 17, 32, 31, 16, 15, 8, 7, 4, 3, 2, 1],low = 4,high = 12) == 14\n assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189, 210],low = 20,high = 100) == 15\n"}, "metadata": {"canonical_parameter_names": ["nums", "low", "high"], "leetcode_dataset_entry_point": "Solution().countPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countPairs(vector& nums, int low, int high) {", "container": "Solution", "callable": "countPairs", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "low", "type": "int"}, {"name": "high", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1805, "task_id": "number-of-different-integers-in-a-string", "difficulty": "Easy", "problem_description": "You are given a string word that consists of digits and lowercase English letters.\nYou will replace every non-digit character with a space. For example, \"a123bc34d8ef34\" will become \" 123  34 8  34\". Notice that you are left with some integers that are separated by at least one space: \"123\", \"34\", \"8\", and \"34\".\nReturn the number of different integers after performing the replacement operations on word.\nTwo integers are considered different if their decimal representations without any leading zeros are different.\n \nExample 1:\n\nInput: word = \"a123bc34d8ef34\"\nOutput: 3\nExplanation: The three different integers are \"123\", \"34\", and \"8\". Notice that \"34\" is only counted once.\n\nExample 2:\n\nInput: word = \"leet1234code234\"\nOutput: 2\n\nExample 3:\n\nInput: word = \"a1b01c001\"\nOutput: 1\nExplanation: The three integers \"1\", \"01\", and \"001\" all represent the same integer because\nthe leading zeros are ignored when comparing their decimal values.\n\n \nConstraints:\n\n1 <= word.length <= 1000\nword consists of digits and lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"a1b2c3d4e5f6g7h8i9j0\") == 10\n assert candidate(word = \"a123bc34d8ef34\") == 3\n assert candidate(word = \"a1a2a3a4a5a6a7a8a9a0\") == 10\n assert candidate(word = \"100leetcode\") == 1\n assert candidate(word = \"a1a1a1\") == 1\n assert candidate(word = \"0a001b002\") == 3\n assert candidate(word = \"12345\") == 1\n assert candidate(word = \"1a2b3c4d5e6f7g8h9i0j\") == 10\n assert candidate(word = \"00000\") == 1\n assert candidate(word = \"0a001b1c1\") == 2\n assert candidate(word = \"111222333444555666777888999000\") == 1\n assert candidate(word = \"leet1234code234\") == 2\n assert candidate(word = \"1234567890\") == 1\n assert candidate(word = \"000111222333444555666777888999000\") == 1\n assert candidate(word = \"11223344556677889900\") == 1\n assert candidate(word = \"a1b1c1\") == 1\n assert candidate(word = \"1a2b3c4d5e6f7g8h9i0j1\") == 10\n assert candidate(word = \"abc\") == 0\n assert candidate(word = \"22o22o22o\") == 1\n assert candidate(word = \"a1b01c001\") == 1\n assert candidate(word = \"a001b002c003\") == 3\n assert candidate(word = \"a001001b1001c001001\") == 1\n assert candidate(word = \"1a2b3c4d5\") == 5\n assert candidate(word = \"0a0b0c0\") == 1\n assert candidate(word = \"0abc00abc000abc0000abc\") == 1\n assert candidate(word = \"1a10a100a1000a10000a1\") == 5\n assert candidate(word = \"123abc456def789ghi123jkl456mno789pqr\") == 3\n assert candidate(word = \"abc123xyz456abc123xyz456abc123xyz456\") == 2\n assert candidate(word = \"0001abc002def03ghi0004\") == 4\n assert candidate(word = \"same123same123same123same\") == 1\n assert candidate(word = \"1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == 1\n assert candidate(word = \"mixed123with456numbers789\") == 3\n assert candidate(word = \"000111000222000333000444000555000\") == 1\n assert candidate(word = \"1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t\") == 10\n assert candidate(word = \"123abc456def789ghi123jkl456mno789pqr001s002t003u\") == 6\n assert candidate(word = \"123abc321def234ghi432jkl543mno654pqrs765tuvw876xyz987\") == 9\n assert candidate(word = \"1a2a3a4a5a6a7a8a9a0a1a2a3a4a5a6a7a8a9a0a1a2a3a4a5a6a7a8a9a0a1a2a3a4a5a6a7a8a9a0a\") == 10\n assert candidate(word = \"1a11a111a1111a11111a111111\") == 6\n assert candidate(word = \"9876543210a123456789b0987654321c\") == 3\n assert candidate(word = \"aaa123bbb123ccc123ddd123eee123\") == 1\n assert candidate(word = \"a0b00c000d0000e00000f000000g0000000h00000000i00000000j000000000\") == 1\n assert candidate(word = \"z9z8z7z6z5z4z3z2z1z0z9z8z7z6z5z4z3z2z1z0\") == 10\n assert candidate(word = \"a1b2c3d4e5f6g7h8i9j0a01b02c03d04e05f06g07h08i09j00\") == 10\n assert candidate(word = \"a10000b1000c100d10e1f0g00h000i0000j00000k\") == 6\n assert candidate(word = \"1a10a100a1000a10000a100000a1000000a10000000a100000000\") == 9\n assert candidate(word = \"1000000000000000000000000000000\") == 1\n assert candidate(word = \"123xyz456xyz789xyz123xyz\") == 3\n assert candidate(word = \"111111111111111111111111111111111111111111111111111111111111111111111111111111111111\") == 1\n assert candidate(word = \"100000a200000b300000c400000d500000e600000f700000g800000h900000\") == 9\n assert candidate(word = \"leading0s123trailing0s456\") == 3\n assert candidate(word = \"0001000200030004000500060007000800090000000100020003\") == 1\n assert candidate(word = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6\") == 10\n assert candidate(word = \"same123same123same123\") == 1\n assert candidate(word = \"1a001b0001c00001d000001e0000001f00000001g000000001\") == 1\n assert candidate(word = \"0101010101010101010101010101010101010101010101010101010101010101010101010101010101010\") == 1\n assert candidate(word = \"aaaa111bbbb222cccc333dddd444\") == 4\n assert candidate(word = \"a1b2c3d4e5f6g7h8i9j0a1b2c3d4e5f6g7h8i9j0\") == 10\n assert candidate(word = \"a0b00c000d0000\") == 1\n assert candidate(word = \"abc0abc00abc000abc0000abc000000abc0000000abc00000000abc000000000abc0000000000\") == 1\n assert candidate(word = \"leading000trailing\") == 1\n assert candidate(word = \"many000123manymany000456many000789many\") == 3\n assert candidate(word = \"a1000b1000c1000d1000e1000f1000g1000h1000i1000j1000\") == 1\n assert candidate(word = \"abc0def00ghi000jkl0000mno00000pqr000000stu\") == 1\n assert candidate(word = \"0000123456789000000000123456789000000012345678900000001234567890\") == 1\n assert candidate(word = \"0abc00abc000abc0000abc00000\") == 1\n assert candidate(word = \"0001000000001000000001\") == 1\n assert candidate(word = \"12345abc54321abc12345\") == 2\n assert candidate(word = \"repeated000repeated000repeated\") == 1\n assert candidate(word = \"z999y999x999w998v997u996\") == 4\n assert candidate(word = \"123abc321def456ghi654jkl789mno987pqr012stu210vwx321yz456\") == 8\n assert candidate(word = \"a1b01c001d0001e00001f10g100\") == 3\n assert candidate(word = \"000000000000000001\") == 1\n assert candidate(word = \"9a8b7c6d5e4f3g2h1i0j9k8l7m6n5o4p3q2r1s0\") == 10\n assert candidate(word = \"9876543210abcdefgh0987654321\") == 2\n assert candidate(word = \"9876543210zyxwvutsrqponmlkjihgfedcba9876543210\") == 1\n assert candidate(word = \"xyz001abc002def003ghi004jkl005\") == 5\n assert candidate(word = \"000000000012345678900000000\") == 1\n assert candidate(word = \"000abc0000def1234gh5678\") == 3\n assert candidate(word = \"a1b2c3d4e5f6g7h8i9j0a00b002c003d004e005f006g007h008i009j000\") == 10\n assert candidate(word = \"a1b01c001d0001e00001f000001g0000001h00000001\") == 1\n assert candidate(word = \"1a01b002c0003d00004e000005f0000006g00000007h000000008i0000000009j0\") == 10\n assert candidate(word = \"123abc456def789ghi0jklm00nopqr000stu0000vwx00000yz\") == 4\n assert candidate(word = \"abc123xyz456def789ghi10jkl11mno12pqr13stu14vwx15\") == 9\n assert candidate(word = \"000001000002000003000004000005000006000007000008000009\") == 1\n assert candidate(word = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == 1\n assert candidate(word = \"abc123xyz456def789ghi001jkl234mno567pqr890stu0vwx123y0z456\") == 8\n assert candidate(word = \"abc123xyz456def456ghi789\") == 3\n assert candidate(word = \"a0b00c000d0000e00000f\") == 1\n assert candidate(word = \"a1b2c3d4e5f6g7h8i9j0a000b0002c0003d0004e0005f0006g0007h0008i0009j0000\") == 10\n assert candidate(word = \"99999zzz88888xxx7777yyy6666\") == 4\n assert candidate(word = \"12345678901234567890123456789012345678901234567890123456789012345678901234567890\") == 1\n assert candidate(word = \"abc123xyz456abc123\") == 2\n assert candidate(word = \"abc123xyz456def123\") == 2\n assert candidate(word = \"a1b10c100d1000e10000f100000g1000000h10000000i100000000j1000000000\") == 10\n assert candidate(word = \"1234567890abcdefghijklmnopqrstuvwxyz0987654321\") == 2\n assert candidate(word = \"0000000000000000000000000\") == 1\n assert candidate(word = \"00000000000000000000000000000000000000000000000001\") == 1\n assert candidate(word = \"010abc0010def00010ghi\") == 1\n assert candidate(word = \"123abc123def123ghi123jkl123mno123pqrs123tuvw123xyz123\") == 1\n assert candidate(word = \"000000000000000000000000000000000000000000000000000000000000000000000000000000000000\") == 1\n assert candidate(word = \"abc123def456ghi789jkl0123\") == 3\n assert candidate(word = \"123456789a987654321b123456789c987654321d123456789e987654321f123456789g\") == 2\n assert candidate(word = \"00123456789000\") == 1\n assert candidate(word = \"0a00b000c0000d00000e000000f0000000g00000000h000000000i000000000j0\") == 1\n assert candidate(word = \"a0b00c000d0000e00000f000000g0000000h00000000i0\") == 1\n assert candidate(word = \"a1b01c001d100e0001f10\") == 3\n assert candidate(word = \"99999999999999999999999999999999999999999999999999999999999999999999999999999999999\") == 1\n assert candidate(word = \"abc001abc01abc1\") == 1\n assert candidate(word = \"a100000000b100000001c100000002d100000003e100000004f100000005\") == 6\n assert candidate(word = \"100000000000000000000000000000000000000000000000000000001\") == 1\n assert candidate(word = \"0012300abc045600def0123\") == 3\n assert candidate(word = \"00123004560078900100000000000000000000000000000000\") == 1\n assert candidate(word = \"9876543210qwertyuiopasdfghjklzxcvbnm\") == 1\n assert candidate(word = \"a0b0c00d000e0000f00000g000000h0000000i00000000j000000000\") == 1\n assert candidate(word = \"123abc456def789ghi0jkl123mno456pqr789stu0vwxyz\") == 4\n assert candidate(word = \"1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4x5y6z7\") == 10\n assert candidate(word = \"abc123456def654321ghi123456\") == 2\n assert candidate(word = \"abc1def2ghi3jkl4mno5pqr6stu7vwx8yz90123456789\") == 9\n assert candidate(word = \"0a123b456c789d0123\") == 4\n assert candidate(word = \"a123b456c789d012e345f678g901\") == 7\n assert candidate(word = \"00100a001b001c\") == 2\n assert candidate(word = \"abc1abc01abc001abc0001abc00001abc000001abc0000001\") == 1\n assert candidate(word = \"abc001xyz01abc100\") == 2\n assert candidate(word = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\") == 10\n"}, "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().numDifferentIntegers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numDifferentIntegers(string word) {", "container": "Solution", "callable": "numDifferentIntegers", "parameters": [{"name": "word", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1806, "task_id": "minimum-number-of-operations-to-reinitialize-a-permutation", "difficulty": "Medium", "problem_description": "You are given an even integer n​​​​​​. You initially have a permutation perm of size n​​ where perm[i] == i​ (0-indexed)​​​​.\nIn one operation, you will create a new array arr, and for each i:\n\nIf i % 2 == 0, then arr[i] = perm[i / 2].\nIf i % 2 == 1, then arr[i] = perm[n / 2 + (i - 1) / 2].\n\nYou will then assign arr​​​​ to perm.\nReturn the minimum non-zero number of operations you need to perform on perm to return the permutation to its initial value.\n \nExample 1:\n\nInput: n = 2\nOutput: 1\nExplanation: perm = [0,1] initially.\nAfter the 1st operation, perm = [0,1]\nSo it takes only 1 operation.\n\nExample 2:\n\nInput: n = 4\nOutput: 2\nExplanation: perm = [0,1,2,3] initially.\nAfter the 1st operation, perm = [0,2,1,3]\nAfter the 2nd operation, perm = [0,1,2,3]\nSo it takes only 2 operations.\n\nExample 3:\n\nInput: n = 6\nOutput: 4\n\n \nConstraints:\n\n2 <= n <= 1000\nn​​​​​​ is even.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 8) == 3\n assert candidate(n = 4) == 2\n assert candidate(n = 12) == 10\n assert candidate(n = 14) == 12\n assert candidate(n = 16) == 4\n assert candidate(n = 18) == 8\n assert candidate(n = 6) == 4\n assert candidate(n = 2) == 1\n assert candidate(n = 20) == 18\n assert candidate(n = 100) == 30\n assert candidate(n = 500) == 166\n assert candidate(n = 1000) == 36\n assert candidate(n = 10) == 6\n assert candidate(n = 896) == 356\n assert candidate(n = 992) == 495\n assert candidate(n = 988) == 138\n assert candidate(n = 50) == 21\n assert candidate(n = 300) == 132\n assert candidate(n = 384) == 191\n assert candidate(n = 600) == 299\n assert candidate(n = 64) == 6\n assert candidate(n = 72) == 35\n assert candidate(n = 192) == 95\n assert candidate(n = 888) == 443\n assert candidate(n = 1024) == 10\n assert candidate(n = 128) == 7\n assert candidate(n = 22) == 6\n assert candidate(n = 46) == 12\n assert candidate(n = 256) == 8\n assert candidate(n = 768) == 348\n assert candidate(n = 32) == 5\n assert candidate(n = 48) == 23\n assert candidate(n = 800) == 184\n assert candidate(n = 200) == 99\n assert candidate(n = 400) == 18\n assert candidate(n = 512) == 9\n assert candidate(n = 750) == 318\n assert candidate(n = 998) == 332\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().reinitializePermutation", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int reinitializePermutation(int n) {", "container": "Solution", "callable": "reinitializePermutation", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1807, "task_id": "evaluate-the-bracket-pairs-of-a-string", "difficulty": "Medium", "problem_description": "You are given a string s that contains some bracket pairs, with each pair containing a non-empty key.\n\nFor example, in the string \"(name)is(age)yearsold\", there are two bracket pairs that contain the keys \"name\" and \"age\".\n\nYou know the values of a wide range of keys. This is represented by a 2D string array knowledge where each knowledge[i] = [keyi, valuei] indicates that key keyi has a value of valuei.\nYou are tasked to evaluate all of the bracket pairs. When you evaluate a bracket pair that contains some key keyi, you will:\n\nReplace keyi and the bracket pair with the key's corresponding valuei.\nIf you do not know the value of the key, you will replace keyi and the bracket pair with a question mark \"?\" (without the quotation marks).\n\nEach key will appear at most once in your knowledge. There will not be any nested brackets in s.\nReturn the resulting string after evaluating all of the bracket pairs.\n \nExample 1:\n\nInput: s = \"(name)is(age)yearsold\", knowledge = [[\"name\",\"bob\"],[\"age\",\"two\"]]\nOutput: \"bobistwoyearsold\"\nExplanation:\nThe key \"name\" has a value of \"bob\", so replace \"(name)\" with \"bob\".\nThe key \"age\" has a value of \"two\", so replace \"(age)\" with \"two\".\n\nExample 2:\n\nInput: s = \"hi(name)\", knowledge = [[\"a\",\"b\"]]\nOutput: \"hi?\"\nExplanation: As you do not know the value of the key \"name\", replace \"(name)\" with \"?\".\n\nExample 3:\n\nInput: s = \"(a)(a)(a)aaa\", knowledge = [[\"a\",\"yes\"]]\nOutput: \"yesyesyesaaa\"\nExplanation: The same key can appear multiple times.\nThe key \"a\" has a value of \"yes\", so replace all occurrences of \"(a)\" with \"yes\".\nNotice that the \"a\"s not in a bracket pair are not evaluated.\n\n \nConstraints:\n\n1 <= s.length <= 105\n0 <= knowledge.length <= 105\nknowledge[i].length == 2\n1 <= keyi.length, valuei.length <= 10\ns consists of lowercase English letters and round brackets '(' and ')'.\nEvery open bracket '(' in s will have a corresponding close bracket ')'.\nThe key in each bracket pair of s will be non-empty.\nThere will not be any nested bracket pairs in s.\nkeyi and valuei consist of lowercase English letters.\nEach keyi in knowledge is unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"(a)(a)(a)aaa\",knowledge = [['a', 'yes']]) == \"yesyesyesaaa\"\n assert candidate(s = \"(a)(b)(c)(d)\",knowledge = [['a', '1'], ['b', '2'], ['c', '3']]) == \"123?\"\n assert candidate(s = \"hi(name)\",knowledge = [['a', 'b']]) == \"hi?\"\n assert candidate(s = \"(a)(a)(a)aaa\",knowledge = [['a', 'yes']]) == \"yesyesyesaaa\"\n assert candidate(s = \"\",knowledge = []) == \"\"\n assert candidate(s = \"noknowledgehere\",knowledge = []) == \"noknowledgehere\"\n assert candidate(s = \"no(brackets)here\",knowledge = []) == \"no?here\"\n assert candidate(s = \"hi(name)\",knowledge = [['a', 'b']]) == \"hi?\"\n assert candidate(s = \"(nested)but(not)really\",knowledge = [['nested', 'nested'], ['not', 'not']]) == \"nestedbutnotreally\"\n assert candidate(s = \"(key1)(key2)(key3)\",knowledge = [['key1', 'value1'], ['key2', 'value2']]) == \"value1value2?\"\n assert candidate(s = \"this(is)a(test)\",knowledge = [['is', 'was'], ['test', 'trial']]) == \"thiswasatrial\"\n assert candidate(s = \"(name)is(age)yearsold\",knowledge = [['name', 'bob'], ['age', 'two']]) == \"bobistwoyearsold\"\n assert candidate(s = \"(key1)(key2)\",knowledge = [['key1', 'value1'], ['key2', 'value2']]) == \"value1value2\"\n assert candidate(s = \"(single)\",knowledge = [['single', 'one']]) == \"one\"\n assert candidate(s = \"(last)one\",knowledge = [['last', 'final']]) == \"finalone\"\n assert candidate(s = \"single\",knowledge = [['single', 'word']]) == \"single\"\n assert candidate(s = \"hello\",knowledge = []) == \"hello\"\n assert candidate(s = \"(unknown)key\",knowledge = [['known', 'value']]) == \"?key\"\n assert candidate(s = \"(name)is(age)yearsold\",knowledge = [['name', 'bob'], ['age', 'two']]) == \"bobistwoyearsold\"\n assert candidate(s = \"(key1)(key2)(key3)\",knowledge = [['key1', 'val1'], ['key2', 'val2'], ['key3', 'val3']]) == \"val1val2val3\"\n assert candidate(s = \"(book)written(by)(author)\",knowledge = [['book', '1984'], ['author', 'George']]) == \"1984written?George\"\n assert candidate(s = \"(city)(in)(country)\",knowledge = [['city', 'Tokyo'], ['country', 'Japan']]) == \"Tokyo?Japan\"\n assert candidate(s = \"(nested)(key)(nested)\",knowledge = [['key', 'value'], ['nested', 'deep']]) == \"deepvaluedeep\"\n assert candidate(s = \"(ingredient)requiresto(cooktime)mins\",knowledge = [['ingredient', 'Cookies'], ['cooktime', '15']]) == \"Cookiesrequiresto15mins\"\n assert candidate(s = \"(one)(two)(three)(four)(five)\",knowledge = [['one', '1'], ['two', '2'], ['three', '3'], ['four', '4']]) == \"1234?\"\n assert candidate(s = \"(customer)(order)at(store)\",knowledge = [['customer', 'Alice'], ['order', 'Order123']]) == \"AliceOrder123at?\"\n assert candidate(s = \"(keyA)and(keyB)and(keyC)and(keyD)\",knowledge = [['keyA', 'valA'], ['keyB', 'valB']]) == \"valAandvalBand?and?\"\n assert candidate(s = \"(key)with(missing)knowledge\",knowledge = [['key', 'value1'], ['missing', 'value2'], ['knowledge', 'value3']]) == \"value1withvalue2knowledge\"\n assert candidate(s = \"(greeting)(world)(planet)\",knowledge = [['greeting', 'hello'], ['world', 'earth'], ['planet', 'mars']]) == \"helloearthmars\"\n assert candidate(s = \"(this)(is)(a)(test)(string)(with)(multiple)(keys)\",knowledge = [['this', 'it'], ['is', 'be'], ['a', 'an'], ['test', 'example'], ['string', 'sequence'], ['with', 'having'], ['multiple', 'several'], ['keys', 'identifiers']]) == \"itbeanexamplesequencehavingseveralidentifiers\"\n assert candidate(s = \"(language)programmingis(fun)\",knowledge = [['language', 'python'], ['fun', 'awesome']]) == \"pythonprogrammingisawesome\"\n assert candidate(s = \"(fruit)(vegetable)\",knowledge = [['fruit', 'apple'], ['vegetable', 'carrot']]) == \"applecarrot\"\n assert candidate(s = \"(animal)lives(in)(habitat)\",knowledge = [['animal', 'tiger'], ['habitat', 'jungle']]) == \"tigerlives?jungle\"\n assert candidate(s = \"(name)has(age)yearsand(occupation)\",knowledge = [['name', 'Alice'], ['age', '30']]) == \"Alicehas30yearsand?\"\n assert candidate(s = \"(longkey)(anotherkey)(yetanotherkey)\",knowledge = [['longkey', 'averylongvalue'], ['anotherkey', 'shortval'], ['yetanotherkey', 'value']]) == \"averylongvalueshortvalvalue\"\n assert candidate(s = \"(language)is(cool)\",knowledge = [['language', 'Python'], ['cool', 'awesome']]) == \"Pythonisawesome\"\n assert candidate(s = \"(first)and(last)name\",knowledge = [['first', 'john'], ['last', 'doe']]) == \"johnanddoename\"\n assert candidate(s = \"(name)is(living)(in)(city)\",knowledge = [['name', 'bob'], ['in', 'at'], ['city', 'london']]) == \"bobis?atlondon\"\n assert candidate(s = \"(animal)(eats)(food)\",knowledge = [['animal', 'lion'], ['food', 'meat']]) == \"lion?meat\"\n assert candidate(s = \"(user)likes(to)(eat)(food)\",knowledge = [['user', 'alice'], ['eat', 'enjoy'], ['food', 'pizza']]) == \"alicelikes?enjoypizza\"\n assert candidate(s = \"(prefix)middle(suffix)\",knowledge = [['prefix', 'start'], ['suffix', 'end']]) == \"startmiddleend\"\n assert candidate(s = \"(flower)grows(in)(soil)\",knowledge = [['flower', 'rose'], ['soil', 'dirt']]) == \"rosegrows?dirt\"\n assert candidate(s = \"(first)nameis(last)name\",knowledge = [['first', 'john'], ['last', 'doe']]) == \"johnnameisdoename\"\n assert candidate(s = \"(longkey1)and(longkey2)and(longkey3)and(longkey4)\",knowledge = [['longkey1', 'value1'], ['longkey2', 'value2'], ['longkey3', 'value3'], ['longkey4', 'value4']]) == \"value1andvalue2andvalue3andvalue4\"\n assert candidate(s = \"(department)islocatedat(address)\",knowledge = [['department', 'Sales'], ['address', '123BusinessSt']]) == \"Salesislocatedat123BusinessSt\"\n assert candidate(s = \"(name)has(a)(pet)\",knowledge = [['name', 'Mary'], ['pet', 'dog']]) == \"Maryhas?dog\"\n assert candidate(s = \"(drink)is(served)in(glass)\",knowledge = [['drink', 'water'], ['glass', 'big']]) == \"wateris?inbig\"\n assert candidate(s = \"prefix(key1)middle(key2)suffix\",knowledge = [['key1', 'value1'], ['key2', 'value2']]) == \"prefixvalue1middlevalue2suffix\"\n assert candidate(s = \"(key1)(key2)(key1)\",knowledge = [['key1', 'value1'], ['key2', 'value2']]) == \"value1value2value1\"\n assert candidate(s = \"(item1)(item2)(item3)(item4)\",knowledge = [['item1', 'itemA'], ['item2', 'itemB'], ['item4', 'itemD']]) == \"itemAitemB?itemD\"\n assert candidate(s = \"(greeting)world\",knowledge = [['greeting', 'hello'], ['farewell', 'bye']]) == \"helloworld\"\n assert candidate(s = \"(user)(name)livesin(city)with(zip)\",knowledge = [['user', 'John'], ['city', 'San Francisco'], ['zip', '94111']]) == \"John?livesinSan Franciscowith94111\"\n assert candidate(s = \"(person)(from)(place)isvisiting(placeofinterest)\",knowledge = [['person', 'Bob'], ['from', 'LosAngeles'], ['place', 'SanFrancisco'], ['placeofinterest', 'Alcatraz']]) == \"BobLosAngelesSanFranciscoisvisitingAlcatraz\"\n assert candidate(s = \"(longkeyname)is(longervaluename)\",knowledge = [['longkeyname', 'longervaluename']]) == \"longervaluenameis?\"\n assert candidate(s = \"(name)has(a)(pet)(dog)\",knowledge = [['name', 'john'], ['pet', 'dog'], ['dog', 'buddy']]) == \"johnhas?dogbuddy\"\n assert candidate(s = \"(key1)and(key2)and(key3)and(key4)and(key5)\",knowledge = [['key1', 'value1'], ['key2', 'value2'], ['key3', 'value3'], ['key4', 'value4']]) == \"value1andvalue2andvalue3andvalue4and?\"\n assert candidate(s = \"(prefix)_(suffix)\",knowledge = [['prefix', 'start'], ['suffix', 'end']]) == \"start_end\"\n assert candidate(s = \"(number)plus(number)equals(twice_number)\",knowledge = [['number', '10'], ['twice_number', '20']]) == \"10plus10equals20\"\n assert candidate(s = \"(name)livesat(address)andworksat(company)\",knowledge = [['name', 'Alice'], ['address', 'Wonderland'], ['company', 'TechCorp']]) == \"AlicelivesatWonderlandandworksatTechCorp\"\n assert candidate(s = \"(repeated)(key)(repeated)(key)\",knowledge = [['key', 'value']]) == \"?value?value\"\n assert candidate(s = \"(planet)(orbits)around(star)\",knowledge = [['planet', 'Earth'], ['star', 'Sun']]) == \"Earth?aroundSun\"\n assert candidate(s = \"(item)isavaliablefrom(date)\",knowledge = [['item', 'Smartphone'], ['date', '2023-12-15']]) == \"Smartphoneisavaliablefrom2023-12-15\"\n assert candidate(s = \"(conference)heldon(date)\",knowledge = [['conference', 'GDC'], ['date', '2024-03-19']]) == \"GDCheldon2024-03-19\"\n assert candidate(s = \"(first)(second)(third)(fourth)\",knowledge = [['first', 'one'], ['second', 'two'], ['third', 'three']]) == \"onetwothree?\"\n assert candidate(s = \"(color)(animal)\",knowledge = [['color', 'blue'], ['animal', 'dog'], ['bird', 'sparrow']]) == \"bluedog\"\n assert candidate(s = \"(firstName)(lastName)isfrom(city)in(country)\",knowledge = [['firstName', 'Alice'], ['lastName', 'Wonderland'], ['city', 'Wonderland'], ['country', 'Fantasia']]) == \"AliceWonderlandisfromWonderlandinFantasia\"\n assert candidate(s = \"(product)costs(dollars)and(euros)\",knowledge = [['product', 'Laptop'], ['dollars', '1200'], ['euros', '1020']]) == \"Laptopcosts1200and1020\"\n assert candidate(s = \"(nested)but(notreally)nested\",knowledge = [['nested', 'deep'], ['notreally', 'shallow']]) == \"deepbutshallownested\"\n assert candidate(s = \"(first)(last)(age)\",knowledge = [['first', 'john'], ['last', 'doe'], ['age', 'thirty']]) == \"johndoethirty\"\n assert candidate(s = \"(city)(has)(many)(buildings)\",knowledge = [['city', 'newyork'], ['many', 'lots']]) == \"newyork?lots?\"\n assert candidate(s = \"(language)(framework)\",knowledge = [['language', 'Python'], ['framework', 'Django'], ['version', '3.9']]) == \"PythonDjango\"\n assert candidate(s = \"(model)releasedon(year)\",knowledge = [['model', 'iPhone15'], ['year', '2023']]) == \"iPhone15releasedon2023\"\n assert candidate(s = \"(multiple)(keys)(here)\",knowledge = [['multiple', 'many'], ['keys', 'some'], ['here', 'there']]) == \"manysomethere\"\n assert candidate(s = \"(username)lastloggedin(on)\",knowledge = [['username', 'Alice'], ['on', '2023-10-01']]) == \"Alicelastloggedin2023-10-01\"\n assert candidate(s = \"(planet)is(almost)full\",knowledge = [['planet', 'Earth'], ['almost', 'not'], ['full', 'occupied']]) == \"Earthisnotfull\"\n assert candidate(s = \"(person)loves(to)(eat)\",knowledge = [['person', 'John'], ['eat', 'pizza']]) == \"Johnloves?pizza\"\n assert candidate(s = \"(car)is(fast)and(economical)\",knowledge = [['car', 'Ferrari'], ['fast', 'very'], ['economical', 'not']]) == \"Ferrariisveryandnot\"\n assert candidate(s = \"(key1)and(key2)and(key3)and(key4)\",knowledge = [['key1', 'value1'], ['key2', 'value2'], ['key4', 'value4']]) == \"value1andvalue2and?andvalue4\"\n assert candidate(s = \"(part1)(part2)(part3)\",knowledge = [['part1', 'first'], ['part2', 'second'], ['part3', 'third']]) == \"firstsecondthird\"\n assert candidate(s = \"(color)(is)(used)in(art)\",knowledge = [['color', 'red'], ['used', 'frequently']]) == \"red?frequentlyin?\"\n assert candidate(s = \"(key1)is(key2)and(key3)is(key4)\",knowledge = [['key1', 'value1'], ['key2', 'value2'], ['key3', 'value3']]) == \"value1isvalue2andvalue3is?\"\n assert candidate(s = \"(name)from(country)is(visitor)\",knowledge = [['name', 'Bob'], ['country', 'USA']]) == \"BobfromUSAis?\"\n assert candidate(s = \"(prefix)example(suffix)\",knowledge = [['prefix', 'pre'], ['suffix', 'post']]) == \"preexamplepost\"\n assert candidate(s = \"(unknown)(key)(not)(present)\",knowledge = [['present', 'available']]) == \"???available\"\n assert candidate(s = \"(unknown)(key1)(unknown)(key2)(unknown)\",knowledge = [['key1', 'value1'], ['key2', 'value2']]) == \"?value1?value2?\"\n assert candidate(s = \"(book)writtenby(author)publishedby(publisher)\",knowledge = [['book', 'GreatExpectations'], ['author', 'CharlesDickens'], ['publisher', 'ChapmanandHall']]) == \"GreatExpectationswrittenbyCharlesDickenspublishedbyChapmanandHall\"\n assert candidate(s = \"(instrument)plays(music)\",knowledge = [['instrument', 'guitar'], ['music', 'beautiful']]) == \"guitarplaysbeautiful\"\n assert candidate(s = \"(prefix)(middle)(suffix)\",knowledge = [['prefix', 'pre'], ['middle', 'mid'], ['suffix', 'suf']]) == \"premidsuf\"\n assert candidate(s = \"(fruit)are(sweet)and(healthy)\",knowledge = [['fruit', 'apples'], ['sweet', 'very'], ['healthy', 'indeed']]) == \"applesareveryandindeed\"\n assert candidate(s = \"(repeated)repeated(repeated)\",knowledge = [['repeated', 'again']]) == \"againrepeatedagain\"\n assert candidate(s = \"(planet)(moon)orbiting(planet)\",knowledge = [['planet', 'Earth'], ['moon', 'Moon']]) == \"EarthMoonorbitingEarth\"\n assert candidate(s = \"(key1)(key1)(key1)(key1)(key1)\",knowledge = [['key1', 'repeat']]) == \"repeatrepeatrepeatrepeatrepeat\"\n assert candidate(s = \"(key1)is(key2)yearsold(key3)\",knowledge = [['key1', 'bob'], ['key2', 'two']]) == \"bobistwoyearsold?\"\n assert candidate(s = \"(greeting)everyone(my)name(is)(unknown)\",knowledge = [['greeting', 'hi'], ['my', 'my']]) == \"hieveryonemyname??\"\n assert candidate(s = \"(bird)can(fly)high\",knowledge = [['bird', 'eagle'], ['fly', 'soar']]) == \"eaglecansoarhigh\"\n assert candidate(s = \"(country)has(a)(capital)\",knowledge = [['country', 'India'], ['capital', 'Delhi']]) == \"Indiahas?Delhi\"\n assert candidate(s = \"(a)(b)(c)(d)(e)(f)\",knowledge = [['a', 'one'], ['b', 'two'], ['c', 'three'], ['d', 'four'], ['e', 'five'], ['f', 'six']]) == \"onetwothreefourfivesix\"\n assert candidate(s = \"(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)(o)(p)(q)(r)(s)(t)(u)(v)(w)(x)(y)(z)\",knowledge = [['a', 'A'], ['b', 'B'], ['c', 'C'], ['d', 'D'], ['e', 'E'], ['f', 'F'], ['g', 'G'], ['h', 'H'], ['i', 'I'], ['j', 'J'], ['k', 'K'], ['l', 'L'], ['m', 'M'], ['n', 'N'], ['o', 'O'], ['p', 'P'], ['q', 'Q'], ['r', 'R'], ['s', 'S'], ['t', 'T'], ['u', 'U'], ['v', 'V'], ['w', 'W'], ['x', 'X'], ['y', 'Y'], ['z', 'Z']]) == \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n assert candidate(s = \"(color)(of)the(sky)\",knowledge = [['color', 'blue'], ['sky', 'beautiful']]) == \"blue?thebeautiful\"\n assert candidate(s = \"(name)is(unknown)but(age)yearsold\",knowledge = [['name', 'alice'], ['age', '30']]) == \"aliceis?but30yearsold\"\n assert candidate(s = \"(product)priceis(price)and(quantity)itemsareavailable\",knowledge = [['product', 'laptop'], ['price', '1000'], ['quantity', '5']]) == \"laptoppriceis1000and5itemsareavailable\"\n assert candidate(s = \"(item)costs(amount)currency\",knowledge = [['item', 'book'], ['amount', '10'], ['currency', 'dollars']]) == \"bookcosts10currency\"\n assert candidate(s = \"(a)(b)(c)(d)(e)\",knowledge = [['a', 'alpha'], ['b', 'beta'], ['c', 'gamma'], ['d', 'delta'], ['e', 'epsilon']]) == \"alphabetagammadeltaepsilon\"\n assert candidate(s = \"(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)(o)(p)(q)(r)(s)(t)(u)(v)(w)(x)(y)(z)\",knowledge = [['a', 'a'], ['b', 'b'], ['c', 'c'], ['d', 'd'], ['e', 'e'], ['f', 'f'], ['g', 'g'], ['h', 'h'], ['i', 'i'], ['j', 'j'], ['k', 'k'], ['l', 'l'], ['m', 'm'], ['n', 'n'], ['o', 'o'], ['p', 'p'], ['q', 'q'], ['r', 'r'], ['s', 's'], ['t', 't'], ['u', 'u'], ['v', 'v'], ['w', 'w'], ['x', 'x'], ['y', 'y'], ['z', 'z']]) == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"(repeated)(repeated)(repeated)\",knowledge = [['repeated', 'rep']]) == \"repreprep\"\n assert candidate(s = \"(key1)and(key2)and(key3)and(key4)and(key5)and(key6)and(key7)\",knowledge = [['key1', 'value1'], ['key2', 'value2'], ['key3', 'value3'], ['key4', 'value4'], ['key5', 'value5'], ['key6', 'value6'], ['key7', 'value7']]) == \"value1andvalue2andvalue3andvalue4andvalue5andvalue6andvalue7\"\n assert candidate(s = \"(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)\",knowledge = [['a', 'one'], ['b', 'two'], ['c', 'three'], ['d', 'four'], ['e', 'five'], ['f', 'six'], ['g', 'seven'], ['h', 'eight'], ['i', 'nine'], ['j', 'ten']]) == \"onetwothreefourfivesixseveneightnineten\"\n assert candidate(s = \"(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)\",knowledge = [['a', 'yes'], ['b', 'no'], ['c', 'maybe'], ['d', 'sure'], ['e', 'never'], ['f', 'always'], ['g', 'often'], ['h', 'rarely'], ['i', 'sometimes'], ['j', 'usually']]) == \"yesnomaybesureneveralwaysoftenrarelysometimesusually\"\n assert candidate(s = \"(user)hasposted(numberofposts)times\",knowledge = [['user', 'Charlie'], ['numberofposts', '250']]) == \"Charliehasposted250times\"\n assert candidate(s = \"(complex)(string)(with)(multiple)(keys)\",knowledge = [['complex', 'com'], ['string', 'str'], ['with', 'wi'], ['multiple', 'mul'], ['keys', 'ke']]) == \"comstrwimulke\"\n assert candidate(s = \"(key1)is(key2)yearsold(key3)and(key4)livesin(key5)\",knowledge = [['key1', 'bob'], ['key2', 'two'], ['key5', 'NYC']]) == \"bobistwoyearsold?and?livesinNYC\"\n assert candidate(s = \"(a)(b)(c)(d)(e)(f)\",knowledge = [['a', 'alpha'], ['b', 'beta'], ['c', 'gamma'], ['d', 'delta'], ['e', 'epsilon']]) == \"alphabetagammadeltaepsilon?\"\n assert candidate(s = \"(nested)brackets(are)not(allowed)\",knowledge = [['nested', 'nested'], ['brackets', 'brackets'], ['not', 'not']]) == \"nestedbrackets?not?\"\n"}, "metadata": {"canonical_parameter_names": ["s", "knowledge"], "leetcode_dataset_entry_point": "Solution().evaluate", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string evaluate(string s, vector>& knowledge) {", "container": "Solution", "callable": "evaluate", "parameters": [{"name": "s", "type": "string"}, {"name": "knowledge", "type": "vector>&"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1808, "task_id": "maximize-number-of-nice-divisors", "difficulty": "Hard", "problem_description": "You are given a positive integer primeFactors. You are asked to construct a positive integer n that satisfies the following conditions:\\r\n\\r\n\\r\n The number of prime factors of n (not necessarily distinct) is at most primeFactors.\\r\n The number of nice divisors of n is maximized. Note that a divisor of n is nice if it is divisible by every prime factor of n. For example, if n = 12, then its prime factors are [2,2,3], then 6 and 12 are nice divisors, while 3 and 4 are not.\\r\n\\r\n\\r\nReturn the number of nice divisors of n. Since that number can be too large, return it modulo 109 + 7.\\r\n\\r\nNote that a prime number is a natural number greater than 1 that is not a product of two smaller natural numbers. The prime factors of a number n is a list of prime numbers such that their product equals n.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: primeFactors = 5\\r\nOutput: 6\\r\nExplanation: 200 is a valid value of n.\\r\nIt has 5 prime factors: [2,2,2,5,5], and it has 6 nice divisors: [10,20,40,50,100,200].\\r\nThere is not other value of n that has at most 5 prime factors and more nice divisors.\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: primeFactors = 8\\r\nOutput: 18\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= primeFactors <= 109\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(primeFactors = 1) == 1\n assert candidate(primeFactors = 3) == 3\n assert candidate(primeFactors = 2) == 2\n"}, "metadata": {"canonical_parameter_names": ["primeFactors"], "leetcode_dataset_entry_point": "Solution().maxNiceDivisors", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxNiceDivisors(int primeFactors) {", "container": "Solution", "callable": "maxNiceDivisors", "parameters": [{"name": "primeFactors", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1812, "task_id": "determine-color-of-a-chessboard-square", "difficulty": "Easy", "problem_description": "You are given coordinates, a string that represents the coordinates of a square of the chessboard. Below is a chessboard for your reference.\n\nReturn true if the square is white, and false if the square is black.\nThe coordinate will always represent a valid chessboard square. The coordinate will always have the letter first, and the number second.\n \nExample 1:\n\nInput: coordinates = \"a1\"\nOutput: false\nExplanation: From the chessboard above, the square with coordinates \"a1\" is black, so return false.\n\nExample 2:\n\nInput: coordinates = \"h3\"\nOutput: true\nExplanation: From the chessboard above, the square with coordinates \"h3\" is white, so return true.\n\nExample 3:\n\nInput: coordinates = \"c7\"\nOutput: false\n\n \nConstraints:\n\ncoordinates.length == 2\n'a' <= coordinates[0] <= 'h'\n'1' <= coordinates[1] <= '8'\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(coordinates = \"d5\") == True\n assert candidate(coordinates = \"e4\") == True\n assert candidate(coordinates = \"b8\") == False\n assert candidate(coordinates = \"b2\") == False\n assert candidate(coordinates = \"a1\") == False\n assert candidate(coordinates = \"g8\") == True\n assert candidate(coordinates = \"e5\") == False\n assert candidate(coordinates = \"d4\") == False\n assert candidate(coordinates = \"g2\") == True\n assert candidate(coordinates = \"e6\") == True\n assert candidate(coordinates = \"f6\") == False\n assert candidate(coordinates = \"h3\") == True\n assert candidate(coordinates = \"f4\") == False\n assert candidate(coordinates = \"c7\") == False\n assert candidate(coordinates = \"d3\") == True\n assert candidate(coordinates = \"g7\") == False\n assert candidate(coordinates = \"a7\") == False\n assert candidate(coordinates = \"c8\") == True\n assert candidate(coordinates = \"f2\") == False\n assert candidate(coordinates = \"f1\") == True\n assert candidate(coordinates = \"g1\") == False\n assert candidate(coordinates = \"b3\") == True\n assert candidate(coordinates = \"h5\") == True\n assert candidate(coordinates = \"e1\") == False\n assert candidate(coordinates = \"p2\") == False\n assert candidate(coordinates = \"a5\") == False\n assert candidate(coordinates = \"d7\") == True\n assert candidate(coordinates = \"g5\") == False\n assert candidate(coordinates = \"b6\") == False\n assert candidate(coordinates = \"f5\") == True\n assert candidate(coordinates = \"h1\") == True\n assert candidate(coordinates = \"j7\") == True\n assert candidate(coordinates = \"e3\") == False\n assert candidate(coordinates = \"c3\") == False\n assert candidate(coordinates = \"g4\") == True\n assert candidate(coordinates = \"a4\") == True\n assert candidate(coordinates = \"v1\") == True\n assert candidate(coordinates = \"d6\") == False\n assert candidate(coordinates = \"b1\") == True\n assert candidate(coordinates = \"g6\") == True\n assert candidate(coordinates = \"h6\") == False\n assert candidate(coordinates = \"c1\") == False\n assert candidate(coordinates = \"h7\") == True\n assert candidate(coordinates = \"r8\") == False\n assert candidate(coordinates = \"b7\") == True\n assert candidate(coordinates = \"c4\") == True\n assert candidate(coordinates = \"c2\") == True\n assert candidate(coordinates = \"f3\") == True\n assert candidate(coordinates = \"h4\") == False\n assert candidate(coordinates = \"n5\") == True\n assert candidate(coordinates = \"d8\") == False\n assert candidate(coordinates = \"b4\") == False\n assert candidate(coordinates = \"a8\") == True\n assert candidate(coordinates = \"a3\") == False\n assert candidate(coordinates = \"e2\") == True\n assert candidate(coordinates = \"e7\") == False\n assert candidate(coordinates = \"f7\") == True\n assert candidate(coordinates = \"d2\") == False\n assert candidate(coordinates = \"a2\") == True\n assert candidate(coordinates = \"b5\") == True\n assert candidate(coordinates = \"c5\") == False\n assert candidate(coordinates = \"h8\") == False\n assert candidate(coordinates = \"a6\") == True\n assert candidate(coordinates = \"m4\") == True\n assert candidate(coordinates = \"z9\") == True\n assert candidate(coordinates = \"h2\") == False\n assert candidate(coordinates = \"t3\") == True\n assert candidate(coordinates = \"x5\") == True\n assert candidate(coordinates = \"g3\") == False\n assert candidate(coordinates = \"l6\") == False\n assert candidate(coordinates = \"d1\") == True\n assert candidate(coordinates = \"f8\") == False\n assert candidate(coordinates = \"e8\") == True\n assert candidate(coordinates = \"c6\") == True\n"}, "metadata": {"canonical_parameter_names": ["coordinates"], "leetcode_dataset_entry_point": "Solution().squareIsWhite", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool squareIsWhite(string coordinates) {", "container": "Solution", "callable": "squareIsWhite", "parameters": [{"name": "coordinates", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1813, "task_id": "sentence-similarity-iii", "difficulty": "Medium", "problem_description": "You are given two strings sentence1 and sentence2, each representing a sentence composed of words. A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each word consists of only uppercase and lowercase English characters.\nTwo sentences s1 and s2 are considered similar if it is possible to insert an arbitrary sentence (possibly empty) inside one of these sentences such that the two sentences become equal. Note that the inserted sentence must be separated from existing words by spaces.\nFor example,\n\ns1 = \"Hello Jane\" and s2 = \"Hello my name is Jane\" can be made equal by inserting \"my name is\" between \"Hello\" and \"Jane\" in s1.\ns1 = \"Frog cool\" and s2 = \"Frogs are cool\" are not similar, since although there is a sentence \"s are\" inserted into s1, it is not separated from \"Frog\" by a space.\n\nGiven two sentences sentence1 and sentence2, return true if sentence1 and sentence2 are similar. Otherwise, return false.\n \nExample 1:\n\nInput: sentence1 = \"My name is Haley\", sentence2 = \"My Haley\"\nOutput: true\nExplanation:\nsentence2 can be turned to sentence1 by inserting \"name is\" between \"My\" and \"Haley\".\n\nExample 2:\n\nInput: sentence1 = \"of\", sentence2 = \"A lot of words\"\nOutput: false\nExplanation:\nNo single sentence can be inserted inside one of the sentences to make it equal to the other.\n\nExample 3:\n\nInput: sentence1 = \"Eating right now\", sentence2 = \"Eating\"\nOutput: true\nExplanation:\nsentence2 can be turned to sentence1 by inserting \"right now\" at the end of the sentence.\n\n \nConstraints:\n\n1 <= sentence1.length, sentence2.length <= 100\nsentence1 and sentence2 consist of lowercase and uppercase English letters and spaces.\nThe words in sentence1 and sentence2 are separated by a single space.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(sentence1 = \"Similar sentences\",sentence2 = \"Similar similar sentences\") == True\n assert candidate(sentence1 = \"Start end\",sentence2 = \"Start middle end\") == True\n assert candidate(sentence1 = \"Eating right now\",sentence2 = \"Eating\") == True\n assert candidate(sentence1 = \"A quick brown fox\",sentence2 = \"A quick brown fox jumps over the lazy dog\") == True\n assert candidate(sentence1 = \"Quick brown fox\",sentence2 = \"Quick brown fox jumps over the lazy dog\") == True\n assert candidate(sentence1 = \"of\",sentence2 = \"A lot of words\") == False\n assert candidate(sentence1 = \"Similarity check\",sentence2 = \"check Similarity\") == False\n assert candidate(sentence1 = \"Similar sentences\",sentence2 = \"Sentences Similar\") == False\n assert candidate(sentence1 = \"Similar sentences\",sentence2 = \"Similar very very similar sentences\") == True\n assert candidate(sentence1 = \"Python is great\",sentence2 = \"Python is very very great\") == True\n assert candidate(sentence1 = \"One two three\",sentence2 = \"One three\") == True\n assert candidate(sentence1 = \"Python is great\",sentence2 = \"is great\") == True\n assert candidate(sentence1 = \"Similar sentences\",sentence2 = \"Sentences that are Similar\") == False\n assert candidate(sentence1 = \"One\",sentence2 = \"One two three\") == True\n assert candidate(sentence1 = \"One\",sentence2 = \"One\") == True\n assert candidate(sentence1 = \"Test\",sentence2 = \"Test test\") == True\n assert candidate(sentence1 = \"Single\",sentence2 = \"Single word\") == True\n assert candidate(sentence1 = \"Test test test\",sentence2 = \"Test test test test\") == True\n assert candidate(sentence1 = \"Python programming\",sentence2 = \"programming\") == True\n assert candidate(sentence1 = \"This is a test\",sentence2 = \"This is\") == True\n assert candidate(sentence1 = \"A B C\",sentence2 = \"A B X C\") == True\n assert candidate(sentence1 = \"One two three\",sentence2 = \"One two three four\") == True\n assert candidate(sentence1 = \"Similar sentences\",sentence2 = \"Similar very similar sentences\") == True\n assert candidate(sentence1 = \"My name is Haley\",sentence2 = \"My Haley\") == True\n assert candidate(sentence1 = \"Same Same Same\",sentence2 = \"Same\") == True\n assert candidate(sentence1 = \"This is a test\",sentence2 = \"This is a dummy test\") == True\n assert candidate(sentence1 = \"Same same\",sentence2 = \"Same same same\") == True\n assert candidate(sentence1 = \"Overlap here\",sentence2 = \"Overlap word here\") == True\n assert candidate(sentence1 = \"Hello World\",sentence2 = \"World\") == True\n assert candidate(sentence1 = \"Hello World\",sentence2 = \"Hello\") == True\n assert candidate(sentence1 = \"Same same\",sentence2 = \"Same same\") == True\n assert candidate(sentence1 = \"Hello World\",sentence2 = \"Hello amazing World\") == True\n assert candidate(sentence1 = \"This is a test\",sentence2 = \"This is a simple test\") == True\n assert candidate(sentence1 = \"First Second Third\",sentence2 = \"First Third\") == True\n assert candidate(sentence1 = \"Match here\",sentence2 = \"Match something here\") == True\n assert candidate(sentence1 = \"Hello World\",sentence2 = \"Hello from the World\") == True\n assert candidate(sentence1 = \"Alice in Wonderland\",sentence2 = \"Alice is in Wonderland\") == True\n assert candidate(sentence1 = \"Left Right\",sentence2 = \"Left Middle Right\") == True\n assert candidate(sentence1 = \"The quick brown fox\",sentence2 = \"The quick brown fox jumps over\") == True\n assert candidate(sentence1 = \"To be or not to be that is the question\",sentence2 = \"To be that is the question\") == True\n assert candidate(sentence1 = \"The world is a stage\",sentence2 = \"The world is a stage and all the men and women merely players\") == True\n assert candidate(sentence1 = \"One two three\",sentence2 = \"One two insert three\") == True\n assert candidate(sentence1 = \"The quick brown fox\",sentence2 = \"The quick brown fox jumps\") == True\n assert candidate(sentence1 = \"No pain no gain\",sentence2 = \"No pain no gain but sometimes the pain is not worth the gain\") == True\n assert candidate(sentence1 = \"Let us play\",sentence2 = \"Let us play a game\") == True\n assert candidate(sentence1 = \"Mary had a little lamb\",sentence2 = \"Mary lamb\") == True\n assert candidate(sentence1 = \"All roads lead to Rome\",sentence2 = \"All roads lead to Rome but not all roads are the same\") == True\n assert candidate(sentence1 = \"Unique words only\",sentence2 = \"Unique unique words only\") == True\n assert candidate(sentence1 = \"Quick brown fox jumps over the lazy dog\",sentence2 = \"Quick brown fox jumps over the lazy quick brown dog\") == True\n assert candidate(sentence1 = \"a b c d e f g h i j\",sentence2 = \"a b c X Y Z d e f g h i j\") == True\n assert candidate(sentence1 = \"OnlyOneWordHere\",sentence2 = \"Only One Word Here\") == False\n assert candidate(sentence1 = \"Actions speak louder than words\",sentence2 = \"Actions speak\") == True\n assert candidate(sentence1 = \"One two three four five\",sentence2 = \"One two four five\") == True\n assert candidate(sentence1 = \"Python programming is fun\",sentence2 = \"Python programming is very fun\") == True\n assert candidate(sentence1 = \"Actions speak louder than words\",sentence2 = \"Actions speak louder than words but intentions matter\") == True\n assert candidate(sentence1 = \"Python is fun\",sentence2 = \"Python programming is really fun\") == False\n assert candidate(sentence1 = \"OpenAI is great\",sentence2 = \"OpenAI is indeed indeed great\") == True\n assert candidate(sentence1 = \"Do or do not there is no try\",sentence2 = \"Do or do not there is no no try\") == True\n assert candidate(sentence1 = \"Quick brown fox jumps over the lazy dog\",sentence2 = \"Quick fox jumps over the lazy dog\") == True\n assert candidate(sentence1 = \"Time flies when you are having fun\",sentence2 = \"Time flies\") == True\n assert candidate(sentence1 = \"The world is a book and those who do not travel read only one page\",sentence2 = \"The world is a book and those who do not travel read only one chapter\") == False\n assert candidate(sentence1 = \"Python programming is fun and effective\",sentence2 = \"Python programming effective\") == True\n assert candidate(sentence1 = \"Complex complex case\",sentence2 = \"Complex even more complex case\") == True\n assert candidate(sentence1 = \"Time heals all wounds\",sentence2 = \"Time heals all wounds but time is also a thief\") == True\n assert candidate(sentence1 = \"SingleWord\",sentence2 = \"SingleWord\") == True\n assert candidate(sentence1 = \"The cat sat on the mat\",sentence2 = \"The cat sat on the blue mat\") == True\n assert candidate(sentence1 = \"First and last\",sentence2 = \"First something in the middle last\") == False\n assert candidate(sentence1 = \"Once upon a time\",sentence2 = \"Once upon a time in a land far far away\") == True\n assert candidate(sentence1 = \"I think therefore I am\",sentence2 = \"I think therefore I am six\") == True\n assert candidate(sentence1 = \"Single word match\",sentence2 = \"Single word match\") == True\n assert candidate(sentence1 = \"Silence is golden\",sentence2 = \"Silence is golden in the morning\") == True\n assert candidate(sentence1 = \"A quick brown fox jumps\",sentence2 = \"A quick brown fox quick brown fox jumps\") == True\n assert candidate(sentence1 = \"Complex problem solving\",sentence2 = \"Complex problem problem solving\") == True\n assert candidate(sentence1 = \"Short\",sentence2 = \"Short and sweet\") == True\n assert candidate(sentence1 = \"a\",sentence2 = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\") == True\n assert candidate(sentence1 = \"Overlap at end\",sentence2 = \"Continue overlap at end\") == False\n assert candidate(sentence1 = \"Happy birthday\",sentence2 = \"Happy birthday dear\") == True\n assert candidate(sentence1 = \"First word last word\",sentence2 = \"First first word last word\") == True\n assert candidate(sentence1 = \"To be or not to be\",sentence2 = \"To be or not to be that is the question\") == True\n assert candidate(sentence1 = \"May the force be with you\",sentence2 = \"May the force\") == True\n assert candidate(sentence1 = \"Python programming is fun\",sentence2 = \"Python programming is really really fun\") == True\n assert candidate(sentence1 = \"Alibaba Cloud offers various cloud services\",sentence2 = \"Alibaba Cloud offers cloud computing and storage services\") == False\n assert candidate(sentence1 = \"The early morning sun was a beautiful sight\",sentence2 = \"The early morning sun was a beautiful golden sight\") == True\n assert candidate(sentence1 = \"This is a long sentence with multiple words in it\",sentence2 = \"This long sentence with multiple words in it\") == True\n assert candidate(sentence1 = \"Lorem ipsum dolor sit amet\",sentence2 = \"Lorem ipsum dolor sit amet consectetur adipiscing elit\") == True\n assert candidate(sentence1 = \"Hello from the other side\",sentence2 = \"Hello from this side\") == False\n assert candidate(sentence1 = \"One two three\",sentence2 = \"One two X Y Z three\") == True\n assert candidate(sentence1 = \"Beginning middle end\",sentence2 = \"Beginning middle middle middle end\") == True\n assert candidate(sentence1 = \"Unique sentence\",sentence2 = \"Unique special sentence\") == True\n assert candidate(sentence1 = \"The quick brown fox jumps over the lazy dog\",sentence2 = \"The quick brown fox jumps over the lazy\") == True\n assert candidate(sentence1 = \"Start with a sentence\",sentence2 = \"Start with a really long sentence\") == True\n assert candidate(sentence1 = \"Python is fun\",sentence2 = \"Python is an amazing and fun language\") == False\n assert candidate(sentence1 = \"All your base are belong to us\",sentence2 = \"All base are belong to us\") == True\n assert candidate(sentence1 = \"Longer sentence with multiple words\",sentence2 = \"Longer sentence with even more multiple words\") == True\n assert candidate(sentence1 = \"She sells sea shells by the sea shore\",sentence2 = \"She sells green sea shells by the sea shore\") == True\n assert candidate(sentence1 = \"Complex algorithm design and analysis\",sentence2 = \"Complex algorithm\") == True\n assert candidate(sentence1 = \"In the middle\",sentence2 = \"In the middle of nowhere\") == True\n assert candidate(sentence1 = \"First Last\",sentence2 = \"First in between Last\") == True\n assert candidate(sentence1 = \"I love to code\",sentence2 = \"I love to code code code\") == True\n assert candidate(sentence1 = \"Unique words only\",sentence2 = \"Unique words in between only\") == True\n assert candidate(sentence1 = \"The quick brown fox\",sentence2 = \"The quick brown fox jumps over the lazy dog\") == True\n assert candidate(sentence1 = \"Single\",sentence2 = \"Single single single\") == True\n assert candidate(sentence1 = \"Life is a journey\",sentence2 = \"Life is a journey not a destination\") == True\n assert candidate(sentence1 = \"A B C D E\",sentence2 = \"A B X Y Z C D E\") == True\n assert candidate(sentence1 = \"The rain in Spain stays mainly in the plain\",sentence2 = \"The rain in Spain falls mainly in the plain\") == False\n assert candidate(sentence1 = \"A quick movement of the enemy will jeopardize six gunboats\",sentence2 = \"A quick movement of the enemy will jeopardize\") == True\n assert candidate(sentence1 = \"Short\",sentence2 = \"Very very short\") == False\n assert candidate(sentence1 = \"Do or do not there is no try\",sentence2 = \"Do or do not there is no other way\") == False\n assert candidate(sentence1 = \"Python programming is fun\",sentence2 = \"Python programming is very very fun\") == True\n assert candidate(sentence1 = \"Start coding\",sentence2 = \"Start coding today\") == True\n assert candidate(sentence1 = \"Happy new year\",sentence2 = \"Happy new new new year\") == True\n assert candidate(sentence1 = \"I love programming in Python\",sentence2 = \"I love programming in Java Python\") == True\n assert candidate(sentence1 = \"Actions speak louder than words\",sentence2 = \"Actions speak louder than words but words can inspire actions\") == True\n assert candidate(sentence1 = \"Python is great\",sentence2 = \"Programming in Python is great\") == True\n assert candidate(sentence1 = \"Data engineering and data science\",sentence2 = \"Data engineering\") == True\n assert candidate(sentence1 = \"One two three four\",sentence2 = \"One two five six seven eight three four\") == True\n assert candidate(sentence1 = \"I love coding\",sentence2 = \"I love coding in Python\") == True\n assert candidate(sentence1 = \"Prefix and suffix\",sentence2 = \"Prefix and more words suffix\") == True\n assert candidate(sentence1 = \"One two three four\",sentence2 = \"One two three four five six\") == True\n assert candidate(sentence1 = \"The quick brown fox jumps over the lazy dog\",sentence2 = \"The quick brown fox jumps over lazy dog\") == True\n assert candidate(sentence1 = \"Catch me if you can\",sentence2 = \"Catch me\") == True\n assert candidate(sentence1 = \"This is a complex example\",sentence2 = \"This is an extremely complex example\") == False\n assert candidate(sentence1 = \"Match start\",sentence2 = \"Match start middle\") == True\n assert candidate(sentence1 = \"x y z\",sentence2 = \"a b c x y z\") == True\n assert candidate(sentence1 = \"This is a test\",sentence2 = \"This is only a test\") == True\n assert candidate(sentence1 = \"The quick brown fox jumps over the lazy dog\",sentence2 = \"The quick brown fox jumps high over the lazy dog\") == True\n assert candidate(sentence1 = \"Python is great\",sentence2 = \"Python is the best language great\") == True\n assert candidate(sentence1 = \"The cat in the hat sat on the mat\",sentence2 = \"The cat sat on the mat\") == True\n assert candidate(sentence1 = \"The pen is mightier than the sword\",sentence2 = \"The pen is mightier than the sword but silence is golden\") == True\n assert candidate(sentence1 = \"Machine learning is transforming industries\",sentence2 = \"Machine learning transforming industries\") == True\n assert candidate(sentence1 = \"The quick brown fox\",sentence2 = \"The quick brown lazy dog\") == False\n assert candidate(sentence1 = \"One two three\",sentence2 = \"One two two three\") == True\n assert candidate(sentence1 = \"This is a test\",sentence2 = \"This is a longer test sentence\") == False\n assert candidate(sentence1 = \"Insert this sentence\",sentence2 = \"Insert some words this sentence\") == True\n assert candidate(sentence1 = \"An apple a day keeps the doctor away\",sentence2 = \"An apple a day\") == True\n assert candidate(sentence1 = \"Learning new things every day\",sentence2 = \"Learning new things every single day\") == True\n assert candidate(sentence1 = \"Match end\",sentence2 = \"Middle match end\") == False\n assert candidate(sentence1 = \"Silence is golden\",sentence2 = \"Silence is golden but sometimes it's better to speak your mind\") == True\n assert candidate(sentence1 = \"Test\",sentence2 = \"Test test test\") == True\n assert candidate(sentence1 = \"A B C D E\",sentence2 = \"A B C X Y Z D E\") == True\n assert candidate(sentence1 = \"Start with this\",sentence2 = \"Start with something in the middle this\") == True\n assert candidate(sentence1 = \"Qwen is a large language model\",sentence2 = \"Qwen is a language model\") == True\n assert candidate(sentence1 = \"The cat sat on the mat\",sentence2 = \"The cat sat on the brown mat\") == True\n assert candidate(sentence1 = \"Last word\",sentence2 = \"Last last last word\") == True\n assert candidate(sentence1 = \"Python is great for data science\",sentence2 = \"Python is great\") == True\n assert candidate(sentence1 = \"Quick brown fox jumps over the lazy dog\",sentence2 = \"Quick brown fox quickly jumps over the lazy dog\") == True\n assert candidate(sentence1 = \"It is a truth universally acknowledged\",sentence2 = \"It is a universally acknowledged\") == True\n assert candidate(sentence1 = \"Start and finish\",sentence2 = \"Start middle and finish\") == True\n assert candidate(sentence1 = \"SingleWord\",sentence2 = \"SingleWordInserted\") == False\n assert candidate(sentence1 = \"End with a sentence\",sentence2 = \"End with a sentence and more words\") == True\n assert candidate(sentence1 = \"Overlap at start\",sentence2 = \"Overlap at start and continue\") == True\n assert candidate(sentence1 = \"We hold these truths to be self evident\",sentence2 = \"We hold these self evident\") == True\n assert candidate(sentence1 = \"Once upon a time in a land far far away\",sentence2 = \"Once upon a time\") == True\n assert candidate(sentence1 = \"Java is a high level programming language\",sentence2 = \"Java is a high level programming language that is platform independent\") == True\n assert candidate(sentence1 = \"Similar beginning and end\",sentence2 = \"Similar beginning with extra words and end\") == True\n assert candidate(sentence1 = \"Hello from the other side\",sentence2 = \"Hello from the very very other side\") == True\n assert candidate(sentence1 = \"Quick brown fox jumps over lazy dog\",sentence2 = \"Quick brown fox jumps over the lazy dog\") == True\n assert candidate(sentence1 = \"Silence is golden\",sentence2 = \"Silence\") == True\n assert candidate(sentence1 = \"Middle insertion is key\",sentence2 = \"Middle insertion of some text is key\") == True\n assert candidate(sentence1 = \"To be or not to be that is the question\",sentence2 = \"To be or not to be\") == True\n assert candidate(sentence1 = \"This is a simple test\",sentence2 = \"This is an extremely simple and detailed test\") == False\n assert candidate(sentence1 = \"It was the best of times it was the worst of times\",sentence2 = \"It was the best of times\") == True\n assert candidate(sentence1 = \"Quick brown fox jumps over the lazy dog\",sentence2 = \"Quick brown fox jumps over the lazy brown dog\") == True\n assert candidate(sentence1 = \"Learning new things is fun\",sentence2 = \"Learning fun\") == True\n assert candidate(sentence1 = \"Life is a journey not a destination\",sentence2 = \"Life is a journey of ups and downs not a destination\") == True\n assert candidate(sentence1 = \"She sells sea shells by the sea shore\",sentence2 = \"She sells sea\") == True\n assert candidate(sentence1 = \"In the beginning God created the heaven and the earth\",sentence2 = \"In the beginning God created the earth\") == True\n assert candidate(sentence1 = \"Insert sentence here\",sentence2 = \"Insert sentence in the middle sentence here\") == True\n assert candidate(sentence1 = \"End with this\",sentence2 = \"End with this and something more\") == True\n assert candidate(sentence1 = \"Python is fun\",sentence2 = \"Python is very very fun\") == True\n assert candidate(sentence1 = \"Advanced machine learning techniques\",sentence2 = \"Advanced machine learning deep learning techniques\") == True\n assert candidate(sentence1 = \"Hello from the other side\",sentence2 = \"Hello from the other side my old friend\") == True\n assert candidate(sentence1 = \"Single word\",sentence2 = \"Single single word\") == True\n assert candidate(sentence1 = \"Time heals all wounds\",sentence2 = \"Time heals all wounds but sometimes it's better to face them head on\") == True\n assert candidate(sentence1 = \"One two three four five\",sentence2 = \"One two six seven eight nine five\") == False\n assert candidate(sentence1 = \"Same at the start\",sentence2 = \"Same at the start but different end\") == True\n assert candidate(sentence1 = \"All animals are equal\",sentence2 = \"All animals are equal but some animals are more equal than others\") == True\n assert candidate(sentence1 = \"The rain in Spain stays mainly in the plain\",sentence2 = \"The rain in Spain stays\") == True\n assert candidate(sentence1 = \"Multiple words in between\",sentence2 = \"Multiple multiple words in between\") == True\n assert candidate(sentence1 = \"Natural language processing is fascinating\",sentence2 = \"Natural language processing\") == True\n assert candidate(sentence1 = \"Hello my friend\",sentence2 = \"Hello my dear friend\") == True\n assert candidate(sentence1 = \"This is a test\",sentence2 = \"This is an amazing test\") == False\n assert candidate(sentence1 = \"Front and back\",sentence2 = \"Front middle back\") == False\n assert candidate(sentence1 = \"Complex sentences are fun\",sentence2 = \"Complex sentences with more words in between are fun\") == True\n assert candidate(sentence1 = \"Alice went to the market\",sentence2 = \"Alice went to the market to buy apples\") == True\n assert candidate(sentence1 = \"The early morning light\",sentence2 = \"The early morning light is so peaceful\") == True\n assert candidate(sentence1 = \"Same same same\",sentence2 = \"Same Same\") == False\n assert candidate(sentence1 = \"Same at the end\",sentence2 = \"Different start same at the end\") == False\n assert candidate(sentence1 = \"Beautiful day in the neighborhood\",sentence2 = \"Beautiful day in the beautiful neighborhood\") == True\n assert candidate(sentence1 = \"First second third\",sentence2 = \"First first first second third\") == True\n assert candidate(sentence1 = \"Hello from the other side\",sentence2 = \"Hello\") == True\n assert candidate(sentence1 = \"I have a dream\",sentence2 = \"I have a dream that one day this nation will rise up and live out the true meaning of its creed\") == True\n assert candidate(sentence1 = \"May the force be with you\",sentence2 = \"May the be with you\") == True\n assert candidate(sentence1 = \"OpenAI develops AI models\",sentence2 = \"OpenAI develops cutting edge AI models\") == True\n assert candidate(sentence1 = \"May the Force be with you\",sentence2 = \"May the Force be with you always\") == True\n assert candidate(sentence1 = \"Keep it simple\",sentence2 = \"Keep it simple stupid\") == True\n assert candidate(sentence1 = \"A short sentence\",sentence2 = \"A very very very short sentence\") == True\n"}, "metadata": {"canonical_parameter_names": ["sentence1", "sentence2"], "leetcode_dataset_entry_point": "Solution().areSentencesSimilar", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool areSentencesSimilar(string sentence1, string sentence2) {", "container": "Solution", "callable": "areSentencesSimilar", "parameters": [{"name": "sentence1", "type": "string"}, {"name": "sentence2", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1814, "task_id": "count-nice-pairs-in-an-array", "difficulty": "Medium", "problem_description": "You are given an array nums that consists of non-negative integers. Let us define rev(x) as the reverse of the non-negative integer x. For example, rev(123) = 321, and rev(120) = 21. A pair of indices (i, j) is nice if it satisfies all of the following conditions:\n\n0 <= i < j < nums.length\nnums[i] + rev(nums[j]) == nums[j] + rev(nums[i])\n\nReturn the number of nice pairs of indices. Since that number can be too large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: nums = [42,11,1,97]\nOutput: 2\nExplanation: The two pairs are:\n - (0,3) : 42 + rev(97) = 42 + 79 = 121, 97 + rev(42) = 97 + 24 = 121.\n - (1,2) : 11 + rev(1) = 11 + 1 = 12, 1 + rev(11) = 1 + 11 = 12.\n\nExample 2:\n\nInput: nums = [13,10,35,24,76]\nOutput: 4\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 45\n assert candidate(nums = [100, 200, 300, 400]) == 0\n assert candidate(nums = [123, 321, 213, 132, 231, 312]) == 2\n assert candidate(nums = [123, 321, 213, 132]) == 1\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333]) == 3\n assert candidate(nums = [987654321, 123456789, 234567890, 345678901]) == 0\n assert candidate(nums = [123, 321, 120, 21]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500]) == 0\n assert candidate(nums = [13, 10, 35, 24, 76]) == 4\n assert candidate(nums = [1, 1, 1, 1]) == 6\n assert candidate(nums = [10, 100, 1000, 10000]) == 0\n assert candidate(nums = [0, 0, 0, 0]) == 6\n assert candidate(nums = [100, 10, 1]) == 0\n assert candidate(nums = [42, 11, 1, 97]) == 2\n assert candidate(nums = [0, 0, 0, 0, 0]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5]) == 10\n assert candidate(nums = [100000, 100001, 100002, 100003, 100004, 100005, 100006, 100007, 100008, 100009]) == 0\n assert candidate(nums = [1234, 2341, 3412, 4123, 5678, 6785, 7856, 8567]) == 8\n assert candidate(nums = [123, 132, 213, 231, 312, 321, 111, 222, 333, 444, 555, 666, 777, 888, 999, 101, 202, 303, 404, 505]) == 93\n assert candidate(nums = [11, 111, 1111, 11111, 111111, 1111111, 11111111, 111111111, 1111111111]) == 36\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000]) == 0\n assert candidate(nums = [123, 321, 213, 132, 231, 312, 123, 321]) == 4\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111, 0]) == 45\n assert candidate(nums = [1122, 2211, 3344, 4433, 5566, 6655, 7788, 8877]) == 12\n assert candidate(nums = [1001, 1010, 1100, 1111, 2002, 2020, 2200, 2222]) == 6\n assert candidate(nums = [564, 465, 654, 645, 546, 456]) == 2\n assert candidate(nums = [101010101, 202020202, 303030303, 404040404, 505050505, 606060606, 707070707, 808080808, 909090909]) == 36\n assert candidate(nums = [123, 456, 789, 1234, 5678, 9012, 3456, 7890, 12345, 67890]) == 7\n assert candidate(nums = [999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111]) == 36\n assert candidate(nums = [101, 101, 101, 101, 101, 101, 101, 101, 101, 101]) == 45\n assert candidate(nums = [111111, 222222, 333333, 444444, 555555, 666666]) == 15\n assert candidate(nums = [1001, 1101, 1201, 1301, 1401, 1501, 1601, 1701, 1801, 1901]) == 0\n assert candidate(nums = [123456789, 234567890, 345678901, 456789012, 567890123, 678901234, 789012345, 890123456, 901234567, 111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999]) == 40\n assert candidate(nums = [121, 131, 141, 151, 161, 171, 181, 191, 202, 212, 222, 232, 242, 252, 262, 272, 282, 292, 303, 313, 323, 333, 343, 353, 363, 373, 383, 393, 404, 414, 424, 434, 444, 454, 464, 474, 484, 494, 505, 515, 525, 535, 545, 555, 565, 575, 585, 595, 606, 616, 626, 636, 646, 656, 666, 676, 686, 696, 707, 717, 727, 737, 747, 757, 767, 777, 787, 797, 808, 818, 828, 838, 848, 858, 868, 878, 888, 898, 909, 919, 929, 939, 949, 959, 969, 979, 989, 999]) == 3828\n assert candidate(nums = [123456789, 987654321, 111111111, 222222222, 333333333, 444444444, 555555555]) == 10\n assert candidate(nums = [123456789, 234567890, 345678901, 456789012, 567890123, 678901234, 789012345, 890123456, 901234567, 101234567]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 45\n assert candidate(nums = [1001, 1010, 1100, 1, 10, 100]) == 1\n assert candidate(nums = [1000000000, 1000000001, 1000000002, 1000000003, 1000000004]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 45\n assert candidate(nums = [1000000007, 7000000001, 123456789, 987654321, 1000000000]) == 0\n assert candidate(nums = [12345, 54321, 1234, 4321, 123, 321, 12, 21, 1, 0]) == 1\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999]) == 36\n assert candidate(nums = [12345, 54321, 12345, 54321, 12345, 54321, 12345, 54321]) == 12\n assert candidate(nums = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111]) == 36\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000]) == 0\n assert candidate(nums = [987, 789, 897, 798, 978, 879, 987, 789, 897, 798]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 36\n assert candidate(nums = [500000000, 400000000, 300000000, 200000000, 100000000, 50000000, 40000000, 30000000, 20000000, 10000000, 5000000, 4000000, 3000000, 2000000, 1000000, 500000, 400000, 300000, 200000, 100000]) == 0\n assert candidate(nums = [999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111, 0]) == 45\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999]) == 36\n assert candidate(nums = [1234, 4321, 1111, 2222, 3333, 4444, 5555]) == 10\n assert candidate(nums = [123, 234, 345, 456, 567, 678, 789, 890, 901]) == 22\n assert candidate(nums = [121, 1221, 12221, 122221, 1222221, 12222221, 122222221, 1222222221, 12222222221]) == 36\n assert candidate(nums = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999]) == 28\n assert candidate(nums = [120, 210, 102, 201, 321, 123, 312, 213, 432, 234]) == 8\n assert candidate(nums = [9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999]) == 36\n assert candidate(nums = [1, 11, 111, 1111, 11111, 111111, 1111111, 11111111, 111111111, 1111111111, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 45\n assert candidate(nums = [123, 321, 213, 132, 312, 231]) == 2\n assert candidate(nums = [123456789, 987654321, 12345678, 87654321, 1234567, 7654321, 123456, 654321, 12345, 54321, 1234, 4321, 123, 321, 12, 21, 1, 0]) == 1\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009, 11011, 22022, 33033, 44044, 55055, 66066, 77077, 88088, 99099, 11111, 22222, 33333, 44444, 55555, 66666, 77777, 88888, 99999]) == 351\n assert candidate(nums = [10001, 10101, 11001, 11111, 20002, 20202, 22002, 22222]) == 15\n assert candidate(nums = [1230, 3210, 2130, 1320, 3120, 2310]) == 0\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999, 1]) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 45\n assert candidate(nums = [123, 321, 213, 312, 132, 231, 456, 654, 546, 465, 789, 987, 897, 798, 101, 11, 22, 33, 44, 55, 66, 77, 88, 99]) == 64\n assert candidate(nums = [999999999, 100000000, 111111111, 222222222, 333333333, 444444444, 555555555]) == 15\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999, 123456789]) == 36\n assert candidate(nums = [1001, 1010, 1100, 100, 10, 1, 11, 111, 1111]) == 10\n assert candidate(nums = [1234, 4321, 5678, 8765, 9012, 2109, 3456, 6543]) == 6\n assert candidate(nums = [123456, 654321, 123456, 654321, 123456, 654321]) == 6\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993]) == 0\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999, 1000000000]) == 36\n assert candidate(nums = [12321, 13231, 21312, 31213, 41114, 51015, 60906, 70807, 80708, 90609]) == 45\n assert candidate(nums = [12345, 54321, 23451, 123456, 654321, 213456, 111111, 222222, 333333, 444444]) == 6\n assert candidate(nums = [1000000000, 999999999, 888888888, 777777777, 666666666, 555555555, 444444444, 333333333, 222222222, 111111111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 171\n assert candidate(nums = [1111, 2222, 3333, 4444, 5555, 6666, 7777, 8888, 9999]) == 36\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999, 1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == 153\n assert candidate(nums = [1234, 4321, 3412, 2143, 2341, 3142, 1324, 4231, 4123, 2413, 3214, 1423]) == 1\n assert candidate(nums = [1, 21, 12, 11, 22, 202, 220, 101, 110, 111, 2002, 2200, 2020, 1001, 1100, 1010, 10001, 10101, 11001]) == 45\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996]) == 0\n assert candidate(nums = [100000000, 200000000, 300000000, 400000000, 500000000, 600000000, 700000000, 800000000, 900000000, 1000000000]) == 0\n assert candidate(nums = [123, 321, 456, 654, 789, 987, 101, 110, 111]) == 7\n assert candidate(nums = [123, 321, 213, 132, 231, 312, 4321, 1234, 1111, 2222, 3333]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 45\n assert candidate(nums = [1001, 1010, 1100, 2002, 2020, 2200, 3003, 3030, 3300]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 435\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990]) == 0\n assert candidate(nums = [1000001, 2000002, 3000003, 4000004, 5000005, 6000006, 7000007, 8000008, 9000009]) == 36\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006, 7007, 8008, 9009]) == 36\n assert candidate(nums = [100001, 100010, 100100, 101000, 110000, 100002, 100020, 100200, 102000, 120000]) == 0\n assert candidate(nums = [123456789, 987654321, 234567890, 890123456, 345678901, 765432109, 456789012, 654321098, 567890123, 345678901]) == 3\n assert candidate(nums = [112233, 332211, 221133, 113322, 445566, 665544, 556644]) == 3\n assert candidate(nums = [1000000007, 7000000001, 1100000001, 1000000011, 1000001001]) == 0\n assert candidate(nums = [1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 0\n assert candidate(nums = [12, 21, 13, 31, 23, 32, 14, 41, 24, 42, 34, 43]) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 0\n assert candidate(nums = [100001, 100101, 101001, 101101, 110001, 110101, 111001, 111101]) == 2\n assert candidate(nums = [999999999, 999999998, 999999997, 999999996, 999999995]) == 0\n assert candidate(nums = [900000000, 800000000, 700000000, 600000000, 500000000, 400000000, 300000000, 200000000, 100000000]) == 0\n assert candidate(nums = [123456789, 123456790, 123456788, 123456791, 123456787, 123456792, 123456786, 123456793, 123456785, 123456794]) == 0\n assert candidate(nums = [111111111, 222222222, 333333333, 444444444, 555555555, 666666666, 777777777, 888888888, 999999999]) == 36\n assert candidate(nums = [1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 0\n assert candidate(nums = [123, 321, 213, 132, 312, 231, 101, 110, 10, 1]) == 5\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010]) == 36\n assert candidate(nums = [123456789, 987654321, 234567890, 345678901, 456789012, 567890123, 678901234, 789012345, 890123456, 901234567]) == 4\n assert candidate(nums = [1122334455, 2233445566, 3344556677, 4455667788, 5566778899, 6677889900, 7788990011, 8899001122, 9900112233, 1011223344, 2122334455, 3222334455, 4322334455, 5422334455, 6522334455, 7622334455, 8722334455, 9822334455, 10922334455]) == 13\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countNicePairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countNicePairs(vector& nums) {", "container": "Solution", "callable": "countNicePairs", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1815, "task_id": "maximum-number-of-groups-getting-fresh-donuts", "difficulty": "Hard", "problem_description": "There is a donuts shop that bakes donuts in batches of batchSize. They have a rule where they must serve all of the donuts of a batch before serving any donuts of the next batch. You are given an integer batchSize and an integer array groups, where groups[i] denotes that there is a group of groups[i] customers that will visit the shop. Each customer will get exactly one donut.\nWhen a group visits the shop, all customers of the group must be served before serving any of the following groups. A group will be happy if they all get fresh donuts. That is, the first customer of the group does not receive a donut that was left over from the previous group.\nYou can freely rearrange the ordering of the groups. Return the maximum possible number of happy groups after rearranging the groups.\n \nExample 1:\n\nInput: batchSize = 3, groups = [1,2,3,4,5,6]\nOutput: 4\nExplanation: You can arrange the groups as [6,2,4,5,1,3]. Then the 1st, 2nd, 4th, and 6th groups will be happy.\n\nExample 2:\n\nInput: batchSize = 4, groups = [1,3,2,5,2,2,1,6]\nOutput: 4\n\n \nConstraints:\n\n1 <= batchSize <= 9\n1 <= groups.length <= 30\n1 <= groups[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(batchSize = 7,groups = [7, 14, 21, 28, 35, 42, 49]) == 7\n assert candidate(batchSize = 2,groups = [2, 2, 2, 2, 2, 2]) == 6\n assert candidate(batchSize = 7,groups = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 12\n assert candidate(batchSize = 4,groups = [4, 8, 12, 16, 20]) == 5\n assert candidate(batchSize = 9,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 5\n assert candidate(batchSize = 7,groups = [7, 14, 21, 28, 35, 42]) == 6\n assert candidate(batchSize = 3,groups = [1, 2, 3, 4, 5, 6]) == 4\n assert candidate(batchSize = 4,groups = [1, 3, 2, 5, 2, 2, 1, 6]) == 4\n assert candidate(batchSize = 3,groups = [3, 6, 9, 12, 15]) == 5\n assert candidate(batchSize = 5,groups = [5, 10, 15, 20, 25]) == 5\n assert candidate(batchSize = 8,groups = [8, 16, 24, 32, 40, 48, 56, 64, 72]) == 9\n assert candidate(batchSize = 1,groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(batchSize = 5,groups = [1, 2, 3, 4, 5]) == 3\n assert candidate(batchSize = 5,groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(batchSize = 9,groups = [9, 18, 27, 36, 45, 54, 63, 72, 81]) == 9\n assert candidate(batchSize = 3,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 10\n assert candidate(batchSize = 8,groups = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 15\n assert candidate(batchSize = 5,groups = [5, 5, 5, 5, 5, 5]) == 6\n assert candidate(batchSize = 7,groups = [7, 14, 21, 28, 35, 42, 49, 56]) == 8\n assert candidate(batchSize = 9,groups = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(batchSize = 9,groups = [9, 9, 9, 9, 9, 9, 9, 9, 9]) == 9\n assert candidate(batchSize = 2,groups = [1, 2, 3, 4, 5]) == 4\n assert candidate(batchSize = 6,groups = [6, 12, 18, 24, 30, 36, 42, 48, 54]) == 9\n assert candidate(batchSize = 8,groups = [8, 16, 24, 32, 40, 48, 56, 64]) == 8\n assert candidate(batchSize = 5,groups = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150]) == 30\n assert candidate(batchSize = 9,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 11\n assert candidate(batchSize = 8,groups = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 8\n assert candidate(batchSize = 3,groups = [1000000000, 2000000000, 3000000000, 4000000000, 5000000000]) == 3\n assert candidate(batchSize = 7,groups = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 11\n assert candidate(batchSize = 6,groups = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60]) == 10\n assert candidate(batchSize = 5,groups = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 30\n assert candidate(batchSize = 4,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]) == 19\n assert candidate(batchSize = 9,groups = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90]) == 10\n assert candidate(batchSize = 7,groups = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147]) == 21\n assert candidate(batchSize = 8,groups = [4, 7, 9, 12, 14, 15, 18, 20, 22, 23, 25, 26, 27, 29, 31, 32]) == 8\n assert candidate(batchSize = 2,groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(batchSize = 5,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(batchSize = 7,groups = [14, 28, 42, 56, 70, 84, 98, 112, 126, 140, 154, 168, 182]) == 13\n assert candidate(batchSize = 9,groups = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126]) == 14\n assert candidate(batchSize = 6,groups = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252, 264, 276, 288, 300, 312, 324, 336, 348, 360]) == 30\n assert candidate(batchSize = 5,groups = [8, 9, 10, 11, 12, 13, 14, 15]) == 5\n assert candidate(batchSize = 5,groups = [5, 10, 15, 20, 25, 30, 35, 40]) == 8\n assert candidate(batchSize = 9,groups = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180, 189, 198, 207, 216, 225, 234, 243, 252, 261, 270]) == 30\n assert candidate(batchSize = 5,groups = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 6\n assert candidate(batchSize = 6,groups = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90]) == 15\n assert candidate(batchSize = 4,groups = [5, 8, 10, 11, 13, 16, 17, 19, 21, 22, 25, 28, 30]) == 8\n assert candidate(batchSize = 8,groups = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80]) == 10\n assert candidate(batchSize = 2,groups = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 21\n assert candidate(batchSize = 5,groups = [2, 3, 7, 8, 10, 12, 15, 17]) == 5\n assert candidate(batchSize = 3,groups = [9, 15, 2, 7, 8, 11, 13, 4, 1]) == 6\n assert candidate(batchSize = 4,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 13\n assert candidate(batchSize = 3,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 20\n assert candidate(batchSize = 6,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 7\n assert candidate(batchSize = 5,groups = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165]) == 9\n assert candidate(batchSize = 8,groups = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 3\n assert candidate(batchSize = 9,groups = [1, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112]) == 8\n assert candidate(batchSize = 5,groups = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 6\n assert candidate(batchSize = 5,groups = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 10\n assert candidate(batchSize = 7,groups = [1, 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 78, 85, 92]) == 2\n assert candidate(batchSize = 9,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]) == 20\n assert candidate(batchSize = 5,groups = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == 6\n assert candidate(batchSize = 5,groups = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300]) == 30\n assert candidate(batchSize = 3,groups = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40]) == 5\n assert candidate(batchSize = 7,groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(batchSize = 4,groups = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 8\n assert candidate(batchSize = 8,groups = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119]) == 10\n assert candidate(batchSize = 6,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 6\n assert candidate(batchSize = 4,groups = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 6\n assert candidate(batchSize = 5,groups = [2, 4, 6, 8, 10, 12, 14, 16]) == 5\n assert candidate(batchSize = 9,groups = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 6\n assert candidate(batchSize = 9,groups = [8, 7, 6, 5, 4, 3, 2, 1, 9, 18, 27, 36, 45, 54, 63, 72, 81]) == 13\n assert candidate(batchSize = 4,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 9\n assert candidate(batchSize = 4,groups = [13, 19, 22, 29, 31, 37, 41, 43, 47, 53, 59]) == 6\n assert candidate(batchSize = 9,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 8\n assert candidate(batchSize = 3,groups = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10\n assert candidate(batchSize = 9,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 14\n assert candidate(batchSize = 8,groups = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104]) == 13\n assert candidate(batchSize = 8,groups = [15, 22, 33, 44, 55, 66, 77, 88, 99]) == 5\n assert candidate(batchSize = 8,groups = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96]) == 12\n assert candidate(batchSize = 6,groups = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 30\n assert candidate(batchSize = 4,groups = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]) == 10\n assert candidate(batchSize = 6,groups = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65]) == 8\n assert candidate(batchSize = 8,groups = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120]) == 15\n assert candidate(batchSize = 5,groups = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 9\n assert candidate(batchSize = 6,groups = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72]) == 12\n assert candidate(batchSize = 9,groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4]) == 7\n assert candidate(batchSize = 7,groups = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175, 182, 189, 196, 203, 210]) == 30\n assert candidate(batchSize = 9,groups = [81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93]) == 7\n assert candidate(batchSize = 5,groups = [2, 3, 4, 1, 5, 6, 7, 8, 9]) == 5\n assert candidate(batchSize = 8,groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4\n assert candidate(batchSize = 3,groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(batchSize = 9,groups = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 8\n assert candidate(batchSize = 5,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 9\n assert candidate(batchSize = 6,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 18\n assert candidate(batchSize = 8,groups = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112]) == 9\n assert candidate(batchSize = 6,groups = [12, 24, 36, 48, 60, 72, 84, 96, 108]) == 9\n assert candidate(batchSize = 3,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39]) == 13\n assert candidate(batchSize = 7,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75]) == 14\n assert candidate(batchSize = 9,groups = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91]) == 2\n assert candidate(batchSize = 8,groups = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240]) == 30\n assert candidate(batchSize = 9,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 5\n assert candidate(batchSize = 6,groups = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51]) == 7\n assert candidate(batchSize = 6,groups = [11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59]) == 6\n assert candidate(batchSize = 3,groups = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109]) == 7\n assert candidate(batchSize = 3,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]) == 30\n assert candidate(batchSize = 4,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 10\n assert candidate(batchSize = 3,groups = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(batchSize = 9,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 16\n assert candidate(batchSize = 5,groups = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85]) == 17\n assert candidate(batchSize = 6,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 7\n assert candidate(batchSize = 7,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 9\n assert candidate(batchSize = 7,groups = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4]) == 10\n assert candidate(batchSize = 3,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 20\n assert candidate(batchSize = 7,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 9\n assert candidate(batchSize = 5,groups = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 15\n assert candidate(batchSize = 3,groups = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 8\n assert candidate(batchSize = 4,groups = [9, 13, 17, 21, 25, 29, 33, 37, 41, 45]) == 3\n assert candidate(batchSize = 4,groups = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 8\n assert candidate(batchSize = 7,groups = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112]) == 16\n assert candidate(batchSize = 9,groups = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180]) == 20\n assert candidate(batchSize = 9,groups = [8, 17, 26, 35, 44, 53, 62, 71, 80, 89, 98, 107, 116, 125, 134, 143, 152]) == 2\n assert candidate(batchSize = 9,groups = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 11\n assert candidate(batchSize = 5,groups = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 20\n assert candidate(batchSize = 3,groups = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36]) == 12\n assert candidate(batchSize = 5,groups = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n"}, "metadata": {"canonical_parameter_names": ["batchSize", "groups"], "leetcode_dataset_entry_point": "Solution().maxHappyGroups", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxHappyGroups(int batchSize, vector& groups) {", "container": "Solution", "callable": "maxHappyGroups", "parameters": [{"name": "batchSize", "type": "int"}, {"name": "groups", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1816, "task_id": "truncate-sentence", "difficulty": "Easy", "problem_description": "A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each of the words consists of only uppercase and lowercase English letters (no punctuation).\n\nFor example, \"Hello World\", \"HELLO\", and \"hello world hello world\" are all sentences.\n\nYou are given a sentence s​​​​​​ and an integer k​​​​​​. You want to truncate s​​​​​​ such that it contains only the first k​​​​​​ words. Return s​​​​​​ after truncating it.\n \nExample 1:\n\nInput: s = \"Hello how are you Contestant\", k = 4\nOutput: \"Hello how are you\"\nExplanation:\nThe words in s are [\"Hello\", \"how\" \"are\", \"you\", \"Contestant\"].\nThe first 4 words are [\"Hello\", \"how\", \"are\", \"you\"].\nHence, you should return \"Hello how are you\".\n\nExample 2:\n\nInput: s = \"What is the solution to this problem\", k = 4\nOutput: \"What is the solution\"\nExplanation:\nThe words in s are [\"What\", \"is\" \"the\", \"solution\", \"to\", \"this\", \"problem\"].\nThe first 4 words are [\"What\", \"is\", \"the\", \"solution\"].\nHence, you should return \"What is the solution\".\nExample 3:\n\nInput: s = \"chopper is not a tanuki\", k = 5\nOutput: \"chopper is not a tanuki\"\n\n \nConstraints:\n\n1 <= s.length <= 500\nk is in the range [1, the number of words in s].\ns consist of only lowercase and uppercase English letters and spaces.\nThe words in s are separated by a single space.\nThere are no leading or trailing spaces.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"I love to code\",k = 3) == \"I love to\"\n assert candidate(s = \"Python is great\",k = 2) == \"Python is\"\n assert candidate(s = \"Python programming is fun\",k = 2) == \"Python programming\"\n assert candidate(s = \"A quick brown fox jumps over the lazy dog\",k = 3) == \"A quick brown\"\n assert candidate(s = \"I love programming in Python\",k = 3) == \"I love programming\"\n assert candidate(s = \"Hello how are you Contestant\",k = 4) == \"Hello how are you\"\n assert candidate(s = \"Python is a great programming language\",k = 2) == \"Python is\"\n assert candidate(s = \"chopper is not a tanuki\",k = 5) == \"chopper is not a tanuki\"\n assert candidate(s = \"Python is fun\",k = 2) == \"Python is\"\n assert candidate(s = \"I love programming\",k = 1) == \"I\"\n assert candidate(s = \"What is the solution to this problem\",k = 4) == \"What is the solution\"\n assert candidate(s = \"I love solving problems\",k = 3) == \"I love solving\"\n assert candidate(s = \"It does not matter how slowly you go as long as you do not stop\",k = 9) == \"It does not matter how slowly you go as\"\n assert candidate(s = \"The road to success is always under construction\",k = 7) == \"The road to success is always under\"\n assert candidate(s = \"The best way to predict your future is to create it\",k = 8) == \"The best way to predict your future is\"\n assert candidate(s = \"This is a test sentence to check the functionality of the code\",k = 9) == \"This is a test sentence to check the functionality\"\n assert candidate(s = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",k = 5) == \"a b c d e\"\n assert candidate(s = \"In computer science, the art of programming is the science of abstraction\",k = 8) == \"In computer science, the art of programming is\"\n assert candidate(s = \"A journey of a thousand miles begins with a single step\",k = 8) == \"A journey of a thousand miles begins with\"\n assert candidate(s = \"Believe you can and you're halfway there\",k = 5) == \"Believe you can and you're\"\n assert candidate(s = \"Keep it simple stupid\",k = 5) == \"Keep it simple stupid\"\n assert candidate(s = \"To be or not to be that is the question\",k = 10) == \"To be or not to be that is the question\"\n assert candidate(s = \"May the Force be with you young Jedi\",k = 6) == \"May the Force be with you\"\n assert candidate(s = \"Short sentence\",k = 2) == \"Short sentence\"\n assert candidate(s = \"The only way to do great work is to love what you do\",k = 7) == \"The only way to do great work\"\n assert candidate(s = \"Honesty is the best policy\",k = 4) == \"Honesty is the best\"\n assert candidate(s = \"In the middle of difficulty lies opportunity\",k = 4) == \"In the middle of\"\n assert candidate(s = \"Natural language processing has become a cornerstone of modern technology\",k = 9) == \"Natural language processing has become a cornerstone of modern\"\n assert candidate(s = \"One two three four five six seven eight nine ten\",k = 10) == \"One two three four five six seven eight nine ten\"\n assert candidate(s = \"You miss 100 percent of the shots you don t take Wayne Gretzky\",k = 11) == \"You miss 100 percent of the shots you don t take\"\n assert candidate(s = \"OpenAI GPT-4 can generate human-like text based on the input it receives\",k = 7) == \"OpenAI GPT-4 can generate human-like text based\"\n assert candidate(s = \"One two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen\",k = 10) == \"One two three four five six seven eight nine ten\"\n assert candidate(s = \"What you get by achieving your goals is not as important as what you become by achieving your goals\",k = 12) == \"What you get by achieving your goals is not as important as\"\n assert candidate(s = \"Debugging is twice as hard as writing the code in the first place\",k = 7) == \"Debugging is twice as hard as writing\"\n assert candidate(s = \"Python programming is fun and challenging\",k = 10) == \"Python programming is fun and challenging\"\n assert candidate(s = \"A journey of a thousand miles begins with a single step\",k = 7) == \"A journey of a thousand miles begins\"\n assert candidate(s = \"Success is not final success is to be able to continue to try\",k = 8) == \"Success is not final success is to be\"\n assert candidate(s = \"OneWordOnly\",k = 1) == \"OneWordOnly\"\n assert candidate(s = \"Data Science and Machine Learning\",k = 3) == \"Data Science and\"\n assert candidate(s = \"Life is what happens when you are busy making other plans\",k = 7) == \"Life is what happens when you are\"\n assert candidate(s = \"The early morning sun is warm and welcoming\",k = 7) == \"The early morning sun is warm and\"\n assert candidate(s = \"To be or not to be that is the question\",k = 7) == \"To be or not to be that\"\n assert candidate(s = \"Short but tricky\",k = 2) == \"Short but\"\n assert candidate(s = \"The early bird catches the worm\",k = 5) == \"The early bird catches the\"\n assert candidate(s = \"Final complex sentence with multiple words indeed\",k = 7) == \"Final complex sentence with multiple words indeed\"\n assert candidate(s = \"The best way to predict the future is to invent it\",k = 9) == \"The best way to predict the future is to\"\n assert candidate(s = \"VeryLongWordWithoutSpacesIsAlsoAcceptedButNotTypicalInSentences\",k = 1) == \"VeryLongWordWithoutSpacesIsAlsoAcceptedButNotTypicalInSentences\"\n assert candidate(s = \"Do not judge a book by its cover\",k = 7) == \"Do not judge a book by its\"\n assert candidate(s = \"All that glitters is not gold only the good do well by gold\",k = 9) == \"All that glitters is not gold only the good\"\n assert candidate(s = \"All that glitters is not gold\",k = 5) == \"All that glitters is not\"\n assert candidate(s = \"To be or not to be that is the question\",k = 5) == \"To be or not to\"\n assert candidate(s = \"Edge case with k equal to the number of words here\",k = 9) == \"Edge case with k equal to the number of\"\n assert candidate(s = \"Multiple words with mixed CASE Words\",k = 4) == \"Multiple words with mixed\"\n assert candidate(s = \"Programming in Python is both fun and educational\",k = 6) == \"Programming in Python is both fun\"\n assert candidate(s = \"A journey of a thousand miles begins with a single step\",k = 6) == \"A journey of a thousand miles\"\n assert candidate(s = \"Success is not final success is courage to continue\",k = 7) == \"Success is not final success is courage\"\n assert candidate(s = \"In the beginning God created the heavens and the earth\",k = 6) == \"In the beginning God created the\"\n assert candidate(s = \"Programming in Python is very rewarding\",k = 5) == \"Programming in Python is very\"\n assert candidate(s = \"You can lead a horse to water but you cannot make it drink\",k = 11) == \"You can lead a horse to water but you cannot make\"\n assert candidate(s = \"Another example with different words\",k = 3) == \"Another example with\"\n assert candidate(s = \"A B C D E F G H I J K L M N O P Q R S T U V W X Y Z\",k = 10) == \"A B C D E F G H I J\"\n assert candidate(s = \"The quick brown fox jumps over the lazy dog\",k = 9) == \"The quick brown fox jumps over the lazy dog\"\n assert candidate(s = \"MixedCASE Words In Sentences Should Be Handled\",k = 5) == \"MixedCASE Words In Sentences Should\"\n assert candidate(s = \"Well done is better than well said\",k = 5) == \"Well done is better than\"\n assert candidate(s = \"The quick brown fox jumps over the lazy dog\",k = 7) == \"The quick brown fox jumps over the\"\n assert candidate(s = \"Yet another test to ensure correctness\",k = 5) == \"Yet another test to ensure\"\n assert candidate(s = \"Edge case test with exact words count\",k = 6) == \"Edge case test with exact words\"\n assert candidate(s = \"SingleWord\",k = 1) == \"SingleWord\"\n assert candidate(s = \"Hello World from the other side of the universe\",k = 8) == \"Hello World from the other side of the\"\n assert candidate(s = \"In the middle of every difficulty lies opportunity\",k = 8) == \"In the middle of every difficulty lies opportunity\"\n assert candidate(s = \"One two three four five six seven eight nine ten\",k = 5) == \"One two three four five\"\n assert candidate(s = \"With great power comes great responsibility\",k = 5) == \"With great power comes great\"\n assert candidate(s = \"Multiple Spaces Between Words Are Not Allowed\",k = 5) == \"Multiple Spaces Between Words Are\"\n assert candidate(s = \"Multiple spaces should not be here but for testing purposes we will add them\",k = 10) == \"Multiple spaces should not be here but for testing purposes\"\n assert candidate(s = \"An apple a day keeps the doctor away\",k = 8) == \"An apple a day keeps the doctor away\"\n assert candidate(s = \"Sometimes the journey is more important than the destination\",k = 9) == \"Sometimes the journey is more important than the destination\"\n assert candidate(s = \"Sometimes you just want to have a long sentence to test the truncation functionality of the code\",k = 15) == \"Sometimes you just want to have a long sentence to test the truncation functionality of\"\n assert candidate(s = \"A quick brown fox jumps over the lazy dog\",k = 9) == \"A quick brown fox jumps over the lazy dog\"\n assert candidate(s = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",k = 26) == \"a b c d e f g h i j k l m n o p q r s t u v w x y z\"\n assert candidate(s = \"This is a very long sentence that we need to truncate to the first few words\",k = 7) == \"This is a very long sentence that\"\n assert candidate(s = \"May the force be with you\",k = 5) == \"May the force be with\"\n assert candidate(s = \"In the heart of the night the fireflies dance\",k = 8) == \"In the heart of the night the fireflies\"\n assert candidate(s = \"ManyManyWordsInOneSentenceWithoutSpacesButAllowedByConstraintsIfWeRemoveSpacesThenThisWillBeAVeryLongListofWords\",k = 5) == \"ManyManyWordsInOneSentenceWithoutSpacesButAllowedByConstraintsIfWeRemoveSpacesThenThisWillBeAVeryLongListofWords\"\n assert candidate(s = \"To be or not to be that is the question\",k = 6) == \"To be or not to be\"\n assert candidate(s = \"Better late than never\",k = 4) == \"Better late than never\"\n assert candidate(s = \"Actions speak louder than words\",k = 4) == \"Actions speak louder than\"\n assert candidate(s = \"Keep calm and carry on\",k = 3) == \"Keep calm and\"\n assert candidate(s = \"Lorem ipsum dolor sit amet consectetur adipiscing elit\",k = 7) == \"Lorem ipsum dolor sit amet consectetur adipiscing\"\n assert candidate(s = \"This is a longer sentence to test the functionality\",k = 7) == \"This is a longer sentence to test\"\n assert candidate(s = \"Software design is all about managing complexity\",k = 7) == \"Software design is all about managing complexity\"\n assert candidate(s = \"May the Force be with you\",k = 3) == \"May the Force\"\n assert candidate(s = \"Data structures and algorithms are the building blocks of software development\",k = 8) == \"Data structures and algorithms are the building blocks\"\n assert candidate(s = \"An algorithm must be seen to be believed\",k = 5) == \"An algorithm must be seen\"\n assert candidate(s = \"This is a test for truncating the sentence at exactly the word limit\",k = 10) == \"This is a test for truncating the sentence at exactly\"\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().truncateSentence", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string truncateSentence(string s, int k) {", "container": "Solution", "callable": "truncateSentence", "parameters": [{"name": "s", "type": "string"}, {"name": "k", "type": "int"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1817, "task_id": "finding-the-users-active-minutes", "difficulty": "Medium", "problem_description": "You are given the logs for users' actions on LeetCode, and an integer k. The logs are represented by a 2D integer array logs where each logs[i] = [IDi, timei] indicates that the user with IDi performed an action at the minute timei.\nMultiple users can perform actions simultaneously, and a single user can perform multiple actions in the same minute.\nThe user active minutes (UAM) for a given user is defined as the number of unique minutes in which the user performed an action on LeetCode. A minute can only be counted once, even if multiple actions occur during it.\nYou are to calculate a 1-indexed array answer of size k such that, for each j (1 <= j <= k), answer[j] is the number of users whose UAM equals j.\nReturn the array answer as described above.\n \nExample 1:\n\nInput: logs = [[0,5],[1,2],[0,2],[0,5],[1,3]], k = 5\nOutput: [0,2,0,0,0]\nExplanation:\nThe user with ID=0 performed actions at minutes 5, 2, and 5 again. Hence, they have a UAM of 2 (minute 5 is only counted once).\nThe user with ID=1 performed actions at minutes 2 and 3. Hence, they have a UAM of 2.\nSince both users have a UAM of 2, answer[2] is 2, and the remaining answer[j] values are 0.\n\nExample 2:\n\nInput: logs = [[1,1],[2,2],[2,3]], k = 4\nOutput: [1,1,0,0]\nExplanation:\nThe user with ID=1 performed a single action at minute 1. Hence, they have a UAM of 1.\nThe user with ID=2 performed actions at minutes 2 and 3. Hence, they have a UAM of 2.\nThere is one user with a UAM of 1 and one with a UAM of 2.\nHence, answer[1] = 1, answer[2] = 1, and the remaining values are 0.\n\n \nConstraints:\n\n1 <= logs.length <= 104\n0 <= IDi <= 109\n1 <= timei <= 105\nk is in the range [The maximum UAM for a user, 105].\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],k = 3) == [0, 0, 3]\n assert candidate(logs = [[10, 1], [11, 2], [10, 2], [11, 3], [10, 3], [11, 4]],k = 4) == [0, 0, 2, 0]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]],k = 5) == [0, 0, 0, 0, 1]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3]],k = 3) == [0, 0, 2]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1]],k = 1) == [4]\n assert candidate(logs = [[1, 1], [2, 2], [2, 3]],k = 4) == [1, 1, 0, 0]\n assert candidate(logs = [[10, 10], [10, 10], [10, 11], [11, 12]],k = 3) == [1, 1, 0]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],k = 5) == [5, 0, 0, 0, 0]\n assert candidate(logs = [[0, 10], [0, 10], [1, 10], [1, 11], [1, 12]],k = 3) == [1, 0, 1]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4]],k = 4) == [4, 0, 0, 0]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],k = 5) == [5, 0, 0, 0, 0]\n assert candidate(logs = [[0, 5], [1, 2], [0, 2], [0, 5], [1, 3]],k = 5) == [0, 2, 0, 0, 0]\n assert candidate(logs = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]],k = 1) == [1]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1]],k = 1) == [5]\n assert candidate(logs = [[10, 10], [10, 10], [10, 11], [10, 12], [11, 10], [11, 11]],k = 3) == [0, 1, 1]\n assert candidate(logs = [[10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10], [100, 10], [110, 10], [120, 10], [130, 10], [140, 10], [150, 10]],k = 1) == [15]\n assert candidate(logs = [[100, 1], [101, 1], [102, 2], [103, 2], [104, 3], [105, 3], [106, 4], [107, 4], [108, 5], [109, 5]],k = 5) == [10, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],k = 10) == [0, 0, 0, 0, 1, 0, 0, 0, 0, 1]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10]],k = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [0, 16], [1, 17], [2, 18], [3, 19], [4, 20]],k = 15) == [10, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15]],k = 5) == [5, 5, 0, 0, 0]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],k = 5) == [5, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],k = 3) == [0, 0, 4]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5]],k = 5) == [0, 0, 0, 0, 2]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],k = 10) == [10, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3], [5, 1], [5, 2], [5, 3]],k = 3) == [0, 0, 5]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 2], [2, 3], [3, 4], [4, 5], [5, 1]],k = 2) == [0, 5]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [0, 4], [1, 5], [2, 6], [0, 7], [1, 8], [2, 9], [0, 10], [1, 11], [2, 12], [0, 13], [1, 14], [2, 15]],k = 5) == [0, 0, 0, 0, 3]\n assert candidate(logs = [[5, 1], [5, 1], [5, 1], [5, 1], [5, 1], [6, 2], [6, 2], [6, 2], [6, 3], [6, 4], [6, 5], [7, 3], [7, 3], [7, 3], [7, 3], [7, 3], [7, 3], [7, 3], [7, 3], [8, 4], [8, 4], [8, 4], [8, 4], [8, 4], [8, 4], [8, 4], [8, 4], [8, 4], [8, 4]],k = 5) == [3, 0, 0, 1, 0]\n assert candidate(logs = [[1, 1], [1, 1], [1, 1], [1, 2], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5]],k = 5) == [0, 0, 1, 1, 1]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [2, 10], [2, 11], [2, 12], [2, 13], [2, 14], [2, 15], [2, 16], [2, 17], [2, 18], [2, 19]],k = 10) == [0, 0, 0, 0, 1, 0, 0, 0, 1, 1]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15]],k = 15) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[100, 1], [101, 1], [102, 2], [103, 2], [104, 2], [105, 3], [106, 3], [107, 3], [108, 4], [109, 4]],k = 4) == [10, 0, 0, 0]\n assert candidate(logs = [[0, 1], [1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [4, 14], [4, 15]],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(logs = [[0, 10], [1, 20], [0, 10], [1, 25], [2, 30], [3, 35], [4, 40], [5, 45], [6, 50], [7, 55], [8, 60], [9, 65]],k = 10) == [9, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2], [11, 3], [12, 3], [13, 3], [14, 3], [15, 3]],k = 3) == [15, 0, 0]\n assert candidate(logs = [[9, 1], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [9, 9], [9, 10], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]],k = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 2]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10]],k = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 2]\n assert candidate(logs = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [0, 1100], [1, 1200], [2, 1300], [3, 1400], [4, 1500], [5, 1600], [6, 1700], [7, 1800], [8, 1900], [9, 2000]],k = 10) == [0, 10, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[10, 5], [10, 5], [10, 6], [10, 7], [11, 5], [11, 6], [11, 7], [12, 5], [12, 6], [12, 7], [13, 5], [13, 6], [13, 7]],k = 3) == [0, 0, 4]\n assert candidate(logs = [[0, 10], [1, 10], [2, 10], [0, 11], [1, 11], [2, 11], [0, 12], [1, 12], [2, 12]],k = 3) == [0, 0, 3]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1]],k = 1) == [10]\n assert candidate(logs = [[100, 1], [100, 2], [100, 3], [100, 4], [100, 5], [101, 1], [101, 2], [101, 3], [101, 4], [101, 5], [102, 1], [102, 2], [102, 3], [102, 4], [102, 5], [103, 1], [103, 2], [103, 3], [103, 4], [103, 5]],k = 5) == [0, 0, 0, 0, 4]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [0, 11], [1, 12], [2, 13], [3, 14], [4, 15], [5, 16], [6, 17], [7, 18], [8, 19], [9, 20]],k = 10) == [0, 10, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[0, 5], [0, 5], [0, 5], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 1], [2, 1], [2, 2]],k = 5) == [1, 1, 0, 1, 0]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [0, 4], [1, 5], [2, 6], [3, 7], [4, 8]],k = 5) == [0, 0, 0, 5, 0]\n assert candidate(logs = [[99, 99], [99, 100], [99, 101], [99, 102], [99, 103], [99, 104], [99, 105]],k = 7) == [0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [110, 11], [120, 12], [130, 13], [140, 14], [150, 15]],k = 15) == [15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],k = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 2]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5]],k = 10) == [0, 0, 0, 0, 1, 0, 0, 0, 0, 1]\n assert candidate(logs = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5]],k = 5) == [0, 0, 0, 0, 3]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [0, 3], [1, 3], [2, 3], [3, 3], [4, 3]],k = 3) == [0, 0, 5]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15]],k = 15) == [0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[10, 100], [11, 101], [10, 101], [11, 102], [12, 102], [13, 103], [13, 104], [14, 104], [14, 105], [15, 106], [15, 106], [15, 107]],k = 5) == [1, 5, 0, 0, 0]\n assert candidate(logs = [[0, 10], [0, 10], [0, 11], [1, 12], [1, 12], [1, 13], [2, 14], [2, 15], [2, 15], [2, 16]],k = 4) == [0, 2, 1, 0]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]],k = 2) == [0, 11]\n assert candidate(logs = [[0, 1], [0, 1], [0, 1], [0, 1], [0, 1]],k = 1) == [1]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]],k = 20) == [20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5]],k = 5) == [0, 0, 0, 0, 2]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5]],k = 5) == [0, 0, 0, 0, 3]\n assert candidate(logs = [[0, 1], [0, 2], [1, 1], [1, 2], [2, 1], [2, 2], [3, 1], [3, 2], [4, 1], [4, 2], [5, 1], [5, 2]],k = 2) == [0, 6]\n assert candidate(logs = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5], [11, 5], [12, 5], [13, 5], [14, 5]],k = 1) == [15]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [0, 11]],k = 11) == [9, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [0, 2], [1, 2], [2, 2], [3, 2], [4, 2], [0, 3], [1, 3], [2, 3], [3, 3], [4, 3], [0, 4], [1, 4], [2, 4], [3, 4], [4, 4], [0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [0, 6], [1, 6], [2, 6], [3, 6], [4, 6]],k = 6) == [0, 0, 0, 0, 0, 5]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],k = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [0, 2], [1, 2], [2, 2], [0, 3], [1, 3], [2, 3], [0, 4], [1, 4], [2, 4], [0, 5], [1, 5], [2, 5], [0, 6], [1, 6], [2, 6]],k = 6) == [0, 0, 0, 0, 0, 3]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [1, 3], [1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5]],k = 5) == [0, 0, 1, 1, 1]\n assert candidate(logs = [[10, 1], [10, 2], [10, 3], [20, 1], [20, 2], [30, 1], [30, 2], [30, 3], [40, 1], [40, 2], [40, 3], [50, 1], [50, 2], [50, 3], [60, 1], [60, 2]],k = 3) == [0, 2, 4]\n assert candidate(logs = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [1, 11], [2, 11], [3, 11], [4, 11], [5, 11], [1, 12], [2, 12], [3, 12], [4, 12], [5, 12]],k = 3) == [0, 0, 5]\n assert candidate(logs = [[0, 1], [0, 2], [0, 1], [0, 2], [0, 1], [0, 2], [0, 1], [0, 2], [0, 1], [0, 2], [0, 3], [0, 4]],k = 5) == [0, 0, 0, 1, 0]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 1], [1, 2], [2, 3], [3, 4], [4, 5]],k = 2) == [5, 0]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3], [5, 1], [5, 2], [5, 3], [6, 1], [6, 2], [6, 3]],k = 3) == [0, 0, 7]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5]],k = 10) == [0, 0, 0, 0, 1, 0, 0, 0, 0, 1]\n assert candidate(logs = [[1, 1], [2, 2], [2, 2], [2, 3], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4], [4, 4], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]],k = 4) == [4, 1, 0, 0]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [4, 1], [4, 2], [4, 3], [4, 4]],k = 4) == [0, 0, 0, 4]\n assert candidate(logs = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]],k = 1) == [15]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15], [1, 16], [1, 17], [1, 18], [1, 19], [1, 20]],k = 20) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1], [0, 1]],k = 1) == [1]\n assert candidate(logs = [[1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [3, 3], [3, 4], [3, 4], [4, 5], [4, 5], [4, 5], [5, 6], [5, 7], [5, 8], [6, 9]],k = 5) == [4, 1, 1, 0, 0]\n assert candidate(logs = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4], [4, 4], [4, 4], [5, 5], [5, 5], [5, 5], [5, 5], [5, 5]],k = 1) == [5]\n assert candidate(logs = [[0, 5], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5]],k = 1) == [10]\n assert candidate(logs = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [3, 11], [4, 12], [4, 13], [4, 14], [4, 15], [4, 16]],k = 6) == [0, 2, 1, 1, 1, 0]\n assert candidate(logs = [[10, 10], [10, 10], [20, 20], [20, 21], [20, 22], [30, 30], [30, 30], [30, 31]],k = 3) == [1, 1, 1]\n assert candidate(logs = [[0, 1], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6]],k = 6) == [1, 0, 1, 1, 1, 1]\n assert candidate(logs = [[1, 1], [1, 2], [2, 1], [2, 2], [3, 1], [3, 2], [4, 1], [4, 2], [5, 1], [5, 2], [6, 1], [6, 2], [7, 1], [7, 2], [8, 1], [8, 2], [9, 1], [9, 2], [10, 1], [10, 2]],k = 2) == [0, 10]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8]],k = 8) == [0, 0, 0, 0, 1, 0, 1, 1]\n assert candidate(logs = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [1, 16]],k = 6) == [0, 0, 4, 1, 0, 0]\n assert candidate(logs = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [10, 11], [20, 12], [30, 13], [40, 14], [50, 15], [60, 16], [70, 17], [80, 18], [90, 19], [100, 20]],k = 10) == [0, 10, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3]],k = 3) == [0, 0, 5]\n assert candidate(logs = [[0, 1], [0, 1], [0, 1], [0, 2], [0, 2], [0, 2], [0, 3], [0, 3], [0, 3], [0, 4], [0, 4], [0, 4], [0, 5], [0, 5], [0, 5]],k = 5) == [0, 0, 0, 0, 1]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [0, 11], [1, 12], [2, 13], [3, 14], [4, 15]],k = 3) == [0, 0, 5]\n assert candidate(logs = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]],k = 15) == [15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10], [3, 11], [3, 12], [3, 13], [3, 14], [3, 15], [3, 16], [3, 17], [4, 18], [4, 19], [4, 20]],k = 7) == [1, 0, 2, 0, 0, 1, 1]\n assert candidate(logs = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5]],k = 5) == [0, 0, 1, 1, 1]\n assert candidate(logs = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [0, 11], [1, 12], [2, 13], [3, 14], [4, 15]],k = 5) == [0, 0, 5, 0, 0]\n assert candidate(logs = [[1, 1], [1, 1], [1, 2], [2, 1], [2, 1], [2, 2], [2, 3], [3, 1], [3, 1], [3, 2], [3, 3], [3, 4]],k = 4) == [0, 1, 1, 1]\n assert candidate(logs = [[0, 1], [0, 1], [1, 1], [1, 1], [2, 1], [2, 1], [3, 1], [3, 1], [4, 1], [4, 1]],k = 1) == [5]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5]],k = 5) == [0, 0, 0, 0, 3]\n assert candidate(logs = [[10, 10], [20, 10], [10, 20], [20, 20], [10, 30], [20, 40], [30, 50]],k = 5) == [1, 0, 2, 0, 0]\n assert candidate(logs = [[1, 1], [1, 1], [1, 1], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 2], [4, 1], [4, 2], [4, 3], [4, 4]],k = 4) == [1, 1, 1, 1]\n assert candidate(logs = [[100, 1], [101, 2], [102, 3], [103, 4], [104, 5], [105, 6], [106, 7], [107, 8], [108, 9], [109, 10]],k = 10) == [10, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(logs = [[0, 1], [0, 2], [1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]],k = 3) == [0, 1, 3]\n assert candidate(logs = [[1, 1], [1, 1], [1, 1], [1, 2], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],k = 10) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1], [16, 1], [17, 1], [18, 1], [19, 1], [20, 1]],k = 1) == [20]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [0, 10], [0, 11], [0, 12], [0, 13], [0, 14], [0, 15], [0, 16], [0, 17], [0, 18], [0, 19], [0, 20]],k = 20) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(logs = [[0, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],k = 1) == [11]\n assert candidate(logs = [[1, 1], [2, 1], [3, 1], [1, 2], [2, 2], [3, 2], [1, 3], [2, 3], [3, 3], [1, 4], [2, 4], [3, 4], [1, 5], [2, 5], [3, 5], [1, 6], [2, 6], [3, 6], [1, 7], [2, 7], [3, 7]],k = 7) == [0, 0, 0, 0, 0, 0, 3]\n assert candidate(logs = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5]],k = 5) == [0, 0, 0, 0, 3]\n"}, "metadata": {"canonical_parameter_names": ["logs", "k"], "leetcode_dataset_entry_point": "Solution().findingUsersActiveMinutes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector findingUsersActiveMinutes(vector>& logs, int k) {", "container": "Solution", "callable": "findingUsersActiveMinutes", "parameters": [{"name": "logs", "type": "vector>&"}, {"name": "k", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1818, "task_id": "minimum-absolute-sum-difference", "difficulty": "Medium", "problem_description": "You are given two positive integer arrays nums1 and nums2, both of length n.\nThe absolute sum difference of arrays nums1 and nums2 is defined as the sum of |nums1[i] - nums2[i]| for each 0 <= i < n (0-indexed).\nYou can replace at most one element of nums1 with any other element in nums1 to minimize the absolute sum difference.\nReturn the minimum absolute sum difference after replacing at most one element in the array nums1. Since the answer may be large, return it modulo 109 + 7.\n|x| is defined as:\n\nx if x >= 0, or\n-x if x < 0.\n\n \nExample 1:\n\nInput: nums1 = [1,7,5], nums2 = [2,3,5]\nOutput: 3\nExplanation: There are two possible optimal solutions:\n- Replace the second element with the first: [1,7,5] => [1,1,5], or\n- Replace the second element with the third: [1,7,5] => [1,5,5].\nBoth will yield an absolute sum difference of |1-2| + (|1-3| or |5-3|) + |5-5| = 3.\n\nExample 2:\n\nInput: nums1 = [2,4,6,8,10], nums2 = [2,4,6,8,10]\nOutput: 0\nExplanation: nums1 is equal to nums2 so no replacement is needed. This will result in an \nabsolute sum difference of 0.\n\nExample 3:\n\nInput: nums1 = [1,10,4,4,2,7], nums2 = [9,3,5,1,7,4]\nOutput: 20\nExplanation: Replace the first element with the second: [1,10,4,4,2,7] => [10,10,4,4,2,7].\nThis yields an absolute sum difference of |10-9| + |10-3| + |4-5| + |4-1| + |2-7| + |7-4| = 20\n\n \nConstraints:\n\nn == nums1.length\nn == nums2.length\n1 <= n <= 105\n1 <= nums1[i], nums2[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [100000, 100000, 100000],nums2 = [1, 1, 1]) == 299997\n assert candidate(nums1 = [1, 7, 5],nums2 = [2, 3, 5]) == 3\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [1, 1, 1, 1]) == 16\n assert candidate(nums1 = [100000, 100000, 100000],nums2 = [1, 1, 1]) == 299997\n assert candidate(nums1 = [1, 10, 4, 4, 2, 7],nums2 = [9, 3, 5, 1, 7, 4]) == 20\n assert candidate(nums1 = [2, 4, 6, 8, 10],nums2 = [2, 4, 6, 8, 10]) == 0\n assert candidate(nums1 = [1, 2, 3],nums2 = [6, 5, 4]) == 7\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 8\n assert candidate(nums1 = [100000, 1, 100000],nums2 = [1, 100000, 1]) == 199998\n assert candidate(nums1 = [1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000],nums2 = [100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1]) == 899991\n assert candidate(nums1 = [100000, 99999, 99998, 99997],nums2 = [1, 2, 3, 4]) == 399981\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 25\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1]) == 15\n assert candidate(nums1 = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 999881\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 999945\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 90\n assert candidate(nums1 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 945\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == 5\n assert candidate(nums1 = [100000, 99999, 99998, 99997, 99996],nums2 = [1, 2, 3, 4, 5]) == 499971\n assert candidate(nums1 = [100000, 100000, 100000, 100000],nums2 = [1, 100000, 100000, 1]) == 199998\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 41\n assert candidate(nums1 = [50000, 50000, 50000, 50000, 50000],nums2 = [1, 2, 3, 4, 5]) == 249985\n assert candidate(nums1 = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996],nums2 = [100000, 1, 99999, 2, 99998, 3, 99997, 4, 99996, 5]) == 899951\n assert candidate(nums1 = [100000, 1, 50000, 75000],nums2 = [50000, 99999, 1, 100000]) == 125000\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(nums1 = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],nums2 = [90, 80, 70, 60, 50, 40, 30, 20, 10, 1]) == 409\n assert candidate(nums1 = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996],nums2 = [100000, 1, 99999, 2, 99998, 3, 99997, 4, 99996, 5]) == 899951\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [45, 40, 35, 30, 25, 20, 15, 10, 5, 1]) == 204\n assert candidate(nums1 = [50000, 50000, 50000, 50000, 50000],nums2 = [1, 1, 1, 1, 1]) == 249995\n assert candidate(nums1 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],nums2 = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3]) == 10\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [1, 3, 6, 8, 11, 13, 16, 18, 21, 23]) == 130\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 98\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999]) == 999980\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 499936\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [1, 2, 3, 4, 5]) == 95\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 36\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 16\n assert candidate(nums1 = [100000, 100000, 100000],nums2 = [90000, 90000, 90000]) == 30000\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 210\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],nums2 = [150, 250, 350, 450, 550, 650, 750, 850, 950, 1050]) == 500\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 41\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 50\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 32\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],nums2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 41\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 181\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == 82\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45]) == 25\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5]) == 8\n assert candidate(nums1 = [1, 10, 100, 1000, 10000, 100000],nums2 = [100000, 10000, 1000, 100, 10, 1]) == 121779\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 486\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 410\n assert candidate(nums1 = [100, 100, 100, 100, 100],nums2 = [10, 90, 110, 10, 90]) == 210\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 999990\n assert candidate(nums1 = [100000, 100000, 100000, 100000],nums2 = [1, 1, 1, 1]) == 399996\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == 50\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 67\n assert candidate(nums1 = [1, 10, 100, 1000, 10000],nums2 = [2, 11, 101, 1001, 10001]) == 5\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 405\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == 5\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 25\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 549990\n assert candidate(nums1 = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 999891\n assert candidate(nums1 = [100000, 200000, 300000, 400000, 500000],nums2 = [1, 2, 3, 4, 5]) == 1099985\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 20\n assert candidate(nums1 = [99999, 99998, 99997, 99996, 99995],nums2 = [1, 100, 200, 300, 400]) == 498980\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 9\n assert candidate(nums1 = [50000, 40000, 30000, 20000, 10000],nums2 = [1, 2, 3, 4, 5]) == 109985\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 171\n assert candidate(nums1 = [100000, 90000, 80000, 70000, 60000],nums2 = [50000, 40000, 30000, 20000, 10000]) == 210000\n assert candidate(nums1 = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 99943\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [101, 201, 301, 401, 501]) == 5\n assert candidate(nums1 = [5, 25, 45, 65, 85],nums2 = [10, 30, 50, 70, 90]) == 25\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 82\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 891\n assert candidate(nums1 = [100000, 100000, 100000, 100000, 100000],nums2 = [1, 1, 1, 1, 1]) == 499995\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 540\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [15, 25, 35, 45, 55]) == 25\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 20\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 999882\n assert candidate(nums1 = [100000, 50000, 25000, 12500, 6250],nums2 = [99999, 49999, 24999, 12499, 6249]) == 5\n assert candidate(nums1 = [1, 100000, 200000, 300000],nums2 = [50000, 250000, 150000, 350000]) == 199999\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 55\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().minAbsoluteSumDiff", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minAbsoluteSumDiff(vector& nums1, vector& nums2) {", "container": "Solution", "callable": "minAbsoluteSumDiff", "parameters": [{"name": "nums1", "type": "vector&"}, {"name": "nums2", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1819, "task_id": "number-of-different-subsequences-gcds", "difficulty": "Hard", "problem_description": "You are given an array nums that consists of positive integers.\nThe GCD of a sequence of numbers is defined as the greatest integer that divides all the numbers in the sequence evenly.\n\nFor example, the GCD of the sequence [4,6,16] is 2.\n\nA subsequence of an array is a sequence that can be formed by removing some elements (possibly none) of the array.\n\nFor example, [2,5,10] is a subsequence of [1,2,1,2,4,1,5,10].\n\nReturn the number of different GCDs among all non-empty subsequences of nums.\n \nExample 1:\n\n\nInput: nums = [6,10,3]\nOutput: 5\nExplanation: The figure shows all the non-empty subsequences and their GCDs.\nThe different GCDs are 6, 10, 3, 2, and 1.\n\nExample 2:\n\nInput: nums = [5,15,40,5,6]\nOutput: 7\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 2 * 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [6, 10, 3]) == 5\n assert candidate(nums = [2, 4, 6, 8, 10]) == 5\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [5, 15, 40, 5, 6]) == 7\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [7, 7, 7, 7, 7]) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000]) == 1\n assert candidate(nums = [100, 200, 300, 400, 500]) == 5\n assert candidate(nums = [7, 14, 21, 28, 35]) == 5\n assert candidate(nums = [100000]) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 11\n assert candidate(nums = [100000, 200000, 150000]) == 4\n assert candidate(nums = [7, 7, 7, 7]) == 1\n assert candidate(nums = [30, 15, 60, 90, 180]) == 5\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630, 672, 714, 756, 798, 840, 882, 924, 966, 1008, 1050]) == 25\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 50\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 20\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 15\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 10\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]) == 10\n assert candidate(nums = [37, 74, 111, 148, 185, 222, 259, 296, 333, 370, 407, 444, 481, 518, 555, 592, 629, 666, 703, 740, 777, 814, 851, 888, 925, 962, 999]) == 27\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630]) == 15\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515, 1616, 1717, 1818, 1919, 2020]) == 20\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175]) == 18\n assert candidate(nums = [12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]) == 30\n assert candidate(nums = [10, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205]) == 22\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072]) == 15\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 15\n assert candidate(nums = [6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120]) == 20\n assert candidate(nums = [5, 25, 45, 65, 85, 105, 125, 145, 165, 185, 205, 225, 245, 265, 285, 305, 325, 345, 365, 385]) == 23\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180, 189, 198, 207, 216, 225, 234, 243, 252, 261, 270]) == 30\n assert candidate(nums = [101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197]) == 21\n assert candidate(nums = [49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30]) == 34\n assert candidate(nums = [97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111]) == 25\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == 10\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]) == 10\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994, 8, 99993]) == 16\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 20\n assert candidate(nums = [12, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 26\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260, 273, 286, 299, 312, 325, 338, 351, 364, 377, 390]) == 30\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180, 189, 198, 207, 216, 225]) == 25\n assert candidate(nums = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]) == 16\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000, 130000, 140000, 150000]) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220]) == 20\n assert candidate(nums = [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96]) == 24\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515]) == 15\n assert candidate(nums = [37, 74, 111, 148, 185, 222, 259, 296, 333, 370, 407, 444, 481, 518, 555, 592, 629, 666, 703, 740]) == 20\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 21\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 25\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 25\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 220, 231, 242, 253, 264, 275, 286, 297, 308, 319, 330]) == 30\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 20\n assert candidate(nums = [104729, 104728, 104727, 104726, 104725, 104724, 104723, 104722, 104721, 104720, 104719, 104718, 104717, 104716, 104715]) == 25\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 20\n assert candidate(nums = [97, 194, 291, 388, 485, 582, 679, 776, 873, 970, 1067, 1164, 1261, 1358, 1455, 1552, 1649, 1746, 1843, 1940]) == 20\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 15\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == 16\n assert candidate(nums = [15, 21, 25, 33, 35, 39, 45, 51, 55, 57, 63, 65, 69, 75, 77, 81, 85, 87, 91, 93, 95, 99]) == 31\n assert candidate(nums = [37, 74, 111, 148, 185, 222, 259, 296, 333, 370, 407, 444, 481, 518, 555]) == 15\n assert candidate(nums = [12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54]) == 18\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105]) == 21\n assert candidate(nums = [60, 120, 180, 240, 300, 360, 420, 480, 540, 600]) == 10\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144, 156, 168, 180, 192, 204, 216, 228, 240, 252, 264, 276, 288, 300]) == 25\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 15\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 26\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225, 235, 245, 255, 265, 275, 285, 295]) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195]) == 14\n assert candidate(nums = [99995, 99996, 99997, 99998, 99999, 100000, 100001, 100002, 100003, 100004, 100005, 100006, 100007, 100008, 100009]) == 26\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 20\n assert candidate(nums = [71, 142, 213, 284, 355, 426, 497, 568, 639, 710, 781, 852, 923, 994, 1065, 1136, 1207, 1278, 1349]) == 19\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(nums = [30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360, 390, 420, 450, 480, 510, 540, 570, 600]) == 20\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == 15\n assert candidate(nums = [60, 120, 180, 240, 300, 360, 420, 480, 540, 600, 660, 720, 780, 840, 900, 960, 1020, 1080, 1140, 1200]) == 20\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]) == 30\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140]) == 20\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 10\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300, 315, 330, 345, 360, 375, 390, 405, 420, 435, 450]) == 30\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 1\n assert candidate(nums = [120, 240, 360, 480, 600, 720, 840, 960, 1080, 1200, 1320, 1440, 1560, 1680, 1800, 1920, 2040]) == 17\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 18\n assert candidate(nums = [21, 35, 49, 63, 77, 91, 105, 119, 133, 147]) == 11\n assert candidate(nums = [12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99]) == 33\n assert candidate(nums = [200000, 199999, 199998, 199997, 199996, 199995, 199994, 199993, 199992, 199991]) == 17\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240, 255, 270, 285, 300]) == 20\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 1\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255, 272, 289, 306, 323, 340]) == 20\n assert candidate(nums = [30, 42, 54, 60, 72, 84, 90, 102, 105, 108, 120, 126, 132, 144, 150, 156, 162, 168, 180, 192]) == 29\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015]) == 27\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countDifferentSubsequenceGCDs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countDifferentSubsequenceGCDs(vector& nums) {", "container": "Solution", "callable": "countDifferentSubsequenceGCDs", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1822, "task_id": "sign-of-the-product-of-an-array", "difficulty": "Easy", "problem_description": "Implement a function signFunc(x) that returns:\n\n1 if x is positive.\n-1 if x is negative.\n0 if x is equal to 0.\n\nYou are given an integer array nums. Let product be the product of all values in the array nums.\nReturn signFunc(product).\n \nExample 1:\n\nInput: nums = [-1,-2,-3,-4,3,2,1]\nOutput: 1\nExplanation: The product of all values in the array is 144, and signFunc(144) = 1\n\nExample 2:\n\nInput: nums = [1,5,0,2,-3]\nOutput: 0\nExplanation: The product of all values in the array is 0, and signFunc(0) = 0\n\nExample 3:\n\nInput: nums = [-1,1,-1,1,-1]\nOutput: -1\nExplanation: The product of all values in the array is -1, and signFunc(-1) = -1\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n-100 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1]) == -1\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [0, 0, 0]) == 0\n assert candidate(nums = [-99, -98, -97, -96, -95, -94, -93, -92, -91, -90]) == 1\n assert candidate(nums = [100, -100, 100]) == -1\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [100, -100, 1]) == -1\n assert candidate(nums = [-100, 0, 100]) == 0\n assert candidate(nums = [-1, -2, -3, -4, 3, 2, 1]) == 1\n assert candidate(nums = [100, -100, 100, -100]) == 1\n assert candidate(nums = [-1, -2, -3, -4]) == 1\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [-1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [1, 5, 0, 2, -3]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [-1, -2, -3]) == -1\n assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1, 0, 1]) == 0\n assert candidate(nums = [100, -50, 25, -10, 5]) == 1\n assert candidate(nums = [100, -50, 25, -12.5, 6.25]) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 0\n assert candidate(nums = [-1, 1, 0, -1, 1, 0, -1, 1, 0]) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 0, 60, 70, 80, 90]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, -1]) == -1\n assert candidate(nums = [1, -1, 0, 1, -1, 0, 1, -1, 0, 1, -1]) == 0\n assert candidate(nums = [-50, 50, -50, 50, -50, 50, -50, 50, -50, 50]) == -1\n assert candidate(nums = [50, 25, -10, 4, -2, 0.5, 0.2]) == 1\n assert candidate(nums = [-100, 0, 100, -100, 100, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, -6, -7, -8, -9, -10]) == -1\n assert candidate(nums = [-1, -1, -1, -1, -1]) == -1\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 1\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0]) == 0\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -1]) == -1\n assert candidate(nums = [99, -99, 100, -100, 101, -101]) == -1\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 0\n assert candidate(nums = [1, -10, 100, -1000, 10000, -100000, 1000000, -10000000, 100000000, -1000000000]) == -1\n assert candidate(nums = [0, 1, 2, 3]) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == -1\n assert candidate(nums = [10, -10, 100, -100, 1000, -1000, 10000, -10000]) == 1\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == -1\n assert candidate(nums = [100, -50, 25, -12.5, 0.5]) == 1\n assert candidate(nums = [-1, 0, 1, 0, -1, 0, 1, 0, -1, 0]) == 0\n assert candidate(nums = [100, -100, 50, -50, 25, -25]) == -1\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 12, -12, 6, -6]) == -1\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 1\n assert candidate(nums = [1, 0, -1, 2, 0, -2, 3, 0, -3, 4, 0, -4]) == 0\n assert candidate(nums = [100, -50, 0, 25, -10]) == 0\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [99, 98, 97, -96, -95, -94]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 0]) == 0\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [99, -99, 98, -98, 97, -97, 96, -96, 95, -95]) == -1\n assert candidate(nums = [-10, 10, -10, 10]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 0, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == 1\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500, -1]) == -1\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10]) == -1\n assert candidate(nums = [-10, -20, -30, -40, -50]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0]) == 0\n assert candidate(nums = [100, -50, 20, -10, 5]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -16]) == -1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 1\n assert candidate(nums = [100, 200, 300, -400, -500, 600, -700, 800, -900, 1000]) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == -1\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1\n assert candidate(nums = [-1, 0, 1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [100, -100, 100, -100, 100]) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == -1\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, 0]) == 0\n assert candidate(nums = [100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100, 100, -100]) == 1\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 1\n assert candidate(nums = [-100, 100, -10, 10, -1, 1]) == -1\n assert candidate(nums = [-100, -200, -300, -400, -500, 1]) == -1\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().arraySign", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int arraySign(vector& nums) {", "container": "Solution", "callable": "arraySign", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1823, "task_id": "find-the-winner-of-the-circular-game", "difficulty": "Medium", "problem_description": "There are n friends that are playing a game. The friends are sitting in a circle and are numbered from 1 to n in clockwise order. More formally, moving clockwise from the ith friend brings you to the (i+1)th friend for 1 <= i < n, and moving clockwise from the nth friend brings you to the 1st friend.\nThe rules of the game are as follows:\n\nStart at the 1st friend.\nCount the next k friends in the clockwise direction including the friend you started at. The counting wraps around the circle and may count some friends more than once.\nThe last friend you counted leaves the circle and loses the game.\nIf there is still more than one friend in the circle, go back to step 2 starting from the friend immediately clockwise of the friend who just lost and repeat.\nElse, the last friend in the circle wins the game.\n\nGiven the number of friends, n, and an integer k, return the winner of the game.\n \nExample 1:\n\n\nInput: n = 5, k = 2\nOutput: 3\nExplanation: Here are the steps of the game:\n1) Start at friend 1.\n2) Count 2 friends clockwise, which are friends 1 and 2.\n3) Friend 2 leaves the circle. Next start is friend 3.\n4) Count 2 friends clockwise, which are friends 3 and 4.\n5) Friend 4 leaves the circle. Next start is friend 5.\n6) Count 2 friends clockwise, which are friends 5 and 1.\n7) Friend 1 leaves the circle. Next start is friend 3.\n8) Count 2 friends clockwise, which are friends 3 and 5.\n9) Friend 5 leaves the circle. Only friend 3 is left, so they are the winner.\nExample 2:\n\nInput: n = 6, k = 5\nOutput: 1\nExplanation: The friends leave in this order: 5, 4, 6, 2, 3. The winner is friend 1.\n\n \nConstraints:\n\n1 <= k <= n <= 500\n\n \nFollow up:\nCould you solve this problem in linear time with constant space?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3,k = 1) == 3\n assert candidate(n = 3,k = 3) == 2\n assert candidate(n = 5,k = 2) == 3\n assert candidate(n = 7,k = 3) == 4\n assert candidate(n = 7,k = 1) == 7\n assert candidate(n = 6,k = 5) == 1\n assert candidate(n = 7,k = 7) == 5\n assert candidate(n = 1,k = 1) == 1\n assert candidate(n = 4,k = 4) == 2\n assert candidate(n = 10,k = 4) == 5\n assert candidate(n = 10,k = 3) == 4\n assert candidate(n = 250,k = 125) == 173\n assert candidate(n = 300,k = 150) == 152\n assert candidate(n = 250,k = 150) == 76\n assert candidate(n = 200,k = 100) == 189\n assert candidate(n = 150,k = 50) == 138\n assert candidate(n = 300,k = 300) == 265\n assert candidate(n = 450,k = 450) == 87\n assert candidate(n = 123,k = 123) == 94\n assert candidate(n = 499,k = 250) == 134\n assert candidate(n = 300,k = 200) == 139\n assert candidate(n = 100,k = 13) == 70\n assert candidate(n = 500,k = 1) == 500\n assert candidate(n = 37,k = 37) == 16\n assert candidate(n = 500,k = 250) == 384\n assert candidate(n = 20,k = 19) == 11\n assert candidate(n = 200,k = 199) == 163\n assert candidate(n = 100,k = 99) == 88\n assert candidate(n = 30,k = 15) == 4\n assert candidate(n = 50,k = 7) == 1\n assert candidate(n = 30,k = 29) == 25\n assert candidate(n = 50,k = 2) == 37\n assert candidate(n = 250,k = 89) == 225\n assert candidate(n = 250,k = 3) == 41\n assert candidate(n = 50,k = 10) == 36\n assert candidate(n = 100,k = 37) == 45\n assert candidate(n = 40,k = 7) == 24\n assert candidate(n = 45,k = 23) == 36\n assert candidate(n = 45,k = 19) == 14\n assert candidate(n = 100,k = 50) == 95\n assert candidate(n = 123,k = 45) == 116\n assert candidate(n = 45,k = 13) == 36\n assert candidate(n = 500,k = 2) == 489\n assert candidate(n = 499,k = 300) == 36\n assert candidate(n = 200,k = 1) == 200\n assert candidate(n = 300,k = 299) == 145\n assert candidate(n = 400,k = 399) == 30\n assert candidate(n = 125,k = 124) == 31\n assert candidate(n = 150,k = 75) == 125\n assert candidate(n = 20,k = 7) == 3\n assert candidate(n = 350,k = 7) == 211\n assert candidate(n = 150,k = 2) == 45\n assert candidate(n = 123,k = 57) == 77\n assert candidate(n = 150,k = 41) == 79\n assert candidate(n = 200,k = 67) == 163\n assert candidate(n = 499,k = 499) == 122\n assert candidate(n = 500,k = 499) == 121\n assert candidate(n = 500,k = 500) == 69\n assert candidate(n = 400,k = 100) == 313\n assert candidate(n = 499,k = 5) == 327\n assert candidate(n = 200,k = 50) == 23\n assert candidate(n = 20,k = 5) == 7\n assert candidate(n = 250,k = 249) == 204\n assert candidate(n = 40,k = 13) == 14\n assert candidate(n = 50,k = 11) == 10\n assert candidate(n = 450,k = 3) == 286\n assert candidate(n = 450,k = 449) == 143\n assert candidate(n = 50,k = 13) == 5\n assert candidate(n = 15,k = 11) == 12\n assert candidate(n = 37,k = 13) == 14\n assert candidate(n = 15,k = 7) == 5\n assert candidate(n = 30,k = 11) == 28\n assert candidate(n = 300,k = 100) == 59\n assert candidate(n = 40,k = 19) == 6\n assert candidate(n = 120,k = 1) == 120\n assert candidate(n = 299,k = 299) == 146\n assert candidate(n = 50,k = 17) == 8\n assert candidate(n = 150,k = 1) == 150\n assert candidate(n = 250,k = 100) == 23\n assert candidate(n = 45,k = 20) == 29\n assert candidate(n = 373,k = 186) == 14\n assert candidate(n = 499,k = 2) == 487\n assert candidate(n = 50,k = 25) == 5\n"}, "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().findTheWinner", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int findTheWinner(int n, int k) {", "container": "Solution", "callable": "findTheWinner", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1824, "task_id": "minimum-sideway-jumps", "difficulty": "Medium", "problem_description": "There is a 3 lane road of length n that consists of n + 1 points labeled from 0 to n. A frog starts at point 0 in the second lane and wants to jump to point n. However, there could be obstacles along the way.\nYou are given an array obstacles of length n + 1 where each obstacles[i] (ranging from 0 to 3) describes an obstacle on the lane obstacles[i] at point i. If obstacles[i] == 0, there are no obstacles at point i. There will be at most one obstacle in the 3 lanes at each point.\n\nFor example, if obstacles[2] == 1, then there is an obstacle on lane 1 at point 2.\n\nThe frog can only travel from point i to point i + 1 on the same lane if there is not an obstacle on the lane at point i + 1. To avoid obstacles, the frog can also perform a side jump to jump to another lane (even if they are not adjacent) at the same point if there is no obstacle on the new lane.\n\nFor example, the frog can jump from lane 3 at point 3 to lane 1 at point 3.\n\nReturn the minimum number of side jumps the frog needs to reach any lane at point n starting from lane 2 at point 0.\nNote: There will be no obstacles on points 0 and n.\n \nExample 1:\n\n\nInput: obstacles = [0,1,2,3,0]\nOutput: 2 \nExplanation: The optimal solution is shown by the arrows above. There are 2 side jumps (red arrows).\nNote that the frog can jump over obstacles only when making side jumps (as shown at point 2).\n\nExample 2:\n\n\nInput: obstacles = [0,1,1,3,3,0]\nOutput: 0\nExplanation: There are no obstacles on lane 2. No side jumps are required.\n\nExample 3:\n\n\nInput: obstacles = [0,2,1,0,3,0]\nOutput: 2\nExplanation: The optimal solution is shown by the arrows above. There are 2 side jumps.\n\n \nConstraints:\n\nobstacles.length == n + 1\n1 <= n <= 5 * 105\n0 <= obstacles[i] <= 3\nobstacles[0] == obstacles[n] == 0\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(obstacles = [0, 1, 0, 0, 2, 0, 0, 3, 0, 0]) == 1\n assert candidate(obstacles = [0, 0, 0, 0, 0, 0]) == 0\n assert candidate(obstacles = [0, 3, 2, 1, 0, 3, 2, 1, 0]) == 4\n assert candidate(obstacles = [0, 0, 1, 0, 0, 2, 0, 0, 3, 0]) == 1\n assert candidate(obstacles = [0, 1, 3, 2, 3, 1, 0, 0, 0, 0]) == 2\n assert candidate(obstacles = [0, 3, 0, 0, 2, 0, 0, 1, 0]) == 1\n assert candidate(obstacles = [0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(obstacles = [0, 2, 3, 1, 2, 3, 1, 0, 0]) == 5\n assert candidate(obstacles = [0, 2, 1, 0, 3, 0]) == 2\n assert candidate(obstacles = [0, 1, 2, 0, 2, 1, 0, 1, 2, 0]) == 1\n assert candidate(obstacles = [0, 2, 0, 0, 0, 3, 0, 0, 1, 0]) == 2\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 0]) == 1\n assert candidate(obstacles = [0, 1, 1, 3, 3, 0]) == 0\n assert candidate(obstacles = [0, 3, 2, 1, 3, 0]) == 3\n assert candidate(obstacles = [0, 0, 1, 2, 3, 0]) == 2\n assert candidate(obstacles = [0, 3, 0, 0, 0, 0]) == 0\n assert candidate(obstacles = [0, 2, 0, 2, 0, 2, 0]) == 1\n assert candidate(obstacles = [0, 3, 0, 3, 0, 3, 0]) == 0\n assert candidate(obstacles = [0, 1, 2, 3, 0]) == 2\n assert candidate(obstacles = [0, 1, 0, 0, 2, 0]) == 1\n assert candidate(obstacles = [0, 2, 3, 2, 1, 2, 3, 0]) == 3\n assert candidate(obstacles = [0, 3, 2, 1, 0, 0]) == 2\n assert candidate(obstacles = [0, 1, 2, 0, 3, 0]) == 2\n assert candidate(obstacles = [0, 2, 3, 1, 0, 0]) == 2\n assert candidate(obstacles = [0, 2, 2, 2, 2, 0]) == 1\n assert candidate(obstacles = [0, 3, 2, 1, 3, 2, 1, 0]) == 5\n assert candidate(obstacles = [0, 3, 0, 1, 2, 0, 0, 0, 0, 0]) == 1\n assert candidate(obstacles = [0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(obstacles = [0, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 16\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 0]) == 11\n assert candidate(obstacles = [0, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 0]) == 12\n assert candidate(obstacles = [0, 3, 3, 3, 3, 0, 0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0, 0]) == 0\n assert candidate(obstacles = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0]) == 1\n assert candidate(obstacles = [0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0]) == 2\n assert candidate(obstacles = [0, 2, 3, 1, 0, 2, 3, 1, 0, 2, 3, 1, 0, 2, 3, 1, 0, 2, 3, 1, 0]) == 10\n assert candidate(obstacles = [0, 2, 3, 1, 2, 3, 1, 2, 3, 1, 0]) == 8\n assert candidate(obstacles = [0, 1, 1, 1, 1, 0, 2, 2, 2, 2, 0, 3, 3, 3, 3, 0, 1, 1, 1, 1, 0]) == 2\n assert candidate(obstacles = [0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0]) == 2\n assert candidate(obstacles = [0, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 20\n assert candidate(obstacles = [0, 1, 2, 0, 3, 0, 1, 2, 0, 3, 0, 1, 2, 0, 3, 0, 1, 2, 0]) == 7\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0]) == 4\n assert candidate(obstacles = [0, 1, 1, 2, 2, 3, 3, 1, 1, 2, 2, 3, 3, 0]) == 5\n assert candidate(obstacles = [0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0]) == 10\n assert candidate(obstacles = [0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0]) == 2\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0]) == 3\n assert candidate(obstacles = [0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]) == 1\n assert candidate(obstacles = [0, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 10\n assert candidate(obstacles = [0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0]) == 0\n assert candidate(obstacles = [0, 3, 2, 0, 1, 0, 3, 2, 0, 1, 0, 3, 0]) == 4\n assert candidate(obstacles = [0, 1, 0, 0, 2, 0, 3, 0, 0, 1, 0, 0, 0, 3, 0, 2, 0]) == 3\n assert candidate(obstacles = [0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0]) == 2\n assert candidate(obstacles = [0, 3, 3, 2, 2, 1, 1, 3, 3, 2, 2, 1, 1, 0]) == 5\n assert candidate(obstacles = [0, 1, 3, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 10\n assert candidate(obstacles = [0, 3, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 0, 3, 2, 1, 0]) == 10\n assert candidate(obstacles = [0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0]) == 4\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 18\n assert candidate(obstacles = [0, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 13\n assert candidate(obstacles = [0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0]) == 1\n assert candidate(obstacles = [0, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 0]) == 0\n assert candidate(obstacles = [0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 0]) == 12\n assert candidate(obstacles = [0, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 1\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 2, 1, 0]) == 7\n assert candidate(obstacles = [0, 3, 0, 0, 0, 0, 1, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 0, 1]) == 2\n assert candidate(obstacles = [0, 3, 2, 1, 0, 2, 1, 0, 3, 2, 1, 0, 2, 1, 3, 0]) == 5\n assert candidate(obstacles = [0, 1, 3, 2, 3, 1, 2, 3, 0, 1, 2, 3, 0]) == 6\n assert candidate(obstacles = [0, 2, 0, 3, 0, 2, 0, 3, 0, 2, 0, 3, 0, 2, 0, 3, 0, 2, 0, 3, 0, 2, 0, 3, 0, 0]) == 1\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0]) == 3\n assert candidate(obstacles = [0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2, 0]) == 1\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 30\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 27\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 3, 2, 1, 0, 3, 2, 1]) == 8\n assert candidate(obstacles = [0, 2, 1, 3, 1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 26\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1]) == 5\n assert candidate(obstacles = [0, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 0]) == 11\n assert candidate(obstacles = [0, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0]) == 1\n assert candidate(obstacles = [0, 3, 1, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 25\n assert candidate(obstacles = [0, 2, 3, 1, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == 26\n assert candidate(obstacles = [0, 2, 2, 0, 3, 3, 1, 1, 2, 2, 3, 3, 1, 1, 0]) == 5\n assert candidate(obstacles = [0, 3, 0, 2, 3, 1, 0, 2, 3, 1, 0, 2, 3, 1, 0]) == 6\n assert candidate(obstacles = [0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 0]) == 7\n assert candidate(obstacles = [0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0]) == 8\n assert candidate(obstacles = [0, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 8\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0]) == 6\n assert candidate(obstacles = [0, 1, 3, 2, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 18\n assert candidate(obstacles = [0, 1, 1, 1, 1, 1, 0, 2, 2, 2, 2, 2, 0, 3, 3, 3, 3, 3, 0]) == 1\n assert candidate(obstacles = [0, 1, 2, 0, 3, 0, 1, 2, 0, 3, 0, 1, 0]) == 4\n assert candidate(obstacles = [0, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0]) == 2\n assert candidate(obstacles = [0, 3, 2, 1, 0, 2, 1, 0, 3, 1, 0, 2, 1, 0, 3, 1, 0, 2, 1, 0]) == 6\n assert candidate(obstacles = [0, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 19\n assert candidate(obstacles = [0, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 31\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 3, 2, 1, 0, 3, 2, 1, 0, 2, 1, 3, 2, 1, 0]) == 11\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 2, 3, 2, 1, 0]) == 5\n assert candidate(obstacles = [0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 23\n assert candidate(obstacles = [0, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 0]) == 1\n assert candidate(obstacles = [0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0]) == 3\n assert candidate(obstacles = [0, 3, 2, 1, 2, 3, 1, 2, 3, 1, 0]) == 7\n assert candidate(obstacles = [0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0]) == 1\n assert candidate(obstacles = [0, 2, 1, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1]) == 17\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0]) == 3\n assert candidate(obstacles = [0, 3, 3, 3, 3, 0, 0, 0, 0, 3, 3, 3, 3, 0, 0, 0, 0]) == 0\n assert candidate(obstacles = [0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]) == 1\n assert candidate(obstacles = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 0\n assert candidate(obstacles = [0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0]) == 3\n assert candidate(obstacles = [0, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 0]) == 12\n assert candidate(obstacles = [0, 1, 0, 3, 0, 2, 0, 1, 0, 3, 0, 2, 0, 1, 0]) == 3\n assert candidate(obstacles = [0, 1, 2, 3, 0, 2, 1, 3, 0, 1, 2, 3, 0]) == 6\n assert candidate(obstacles = [0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3]) == 0\n assert candidate(obstacles = [0, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 0]) == 11\n assert candidate(obstacles = [0, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 17\n assert candidate(obstacles = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(obstacles = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]) == 0\n assert candidate(obstacles = [0, 0, 0, 2, 3, 1, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 0, 1, 2, 3]) == 6\n assert candidate(obstacles = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0]) == 1\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0]) == 7\n assert candidate(obstacles = [0, 3, 0, 1, 0, 3, 0, 1, 0, 3, 0, 1, 0, 3, 0]) == 0\n assert candidate(obstacles = [0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 1, 0, 0, 2, 0, 0, 3, 0]) == 3\n assert candidate(obstacles = [0, 1, 0, 0, 0, 0, 0, 0, 0, 3, 2, 1, 0]) == 2\n assert candidate(obstacles = [0, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 17\n assert candidate(obstacles = [0, 1, 3, 1, 2, 3, 1, 2, 3, 1, 0]) == 6\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0]) == 2\n assert candidate(obstacles = [0, 2, 3, 2, 1, 3, 2, 1, 3, 2, 0]) == 7\n assert candidate(obstacles = [0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0, 3, 0, 1, 0, 2, 0]) == 4\n assert candidate(obstacles = [0, 3, 2, 3, 1, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 9\n assert candidate(obstacles = [0, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 0]) == 9\n assert candidate(obstacles = [0, 3, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]) == 2\n assert candidate(obstacles = [0, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 0]) == 1\n assert candidate(obstacles = [0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0]) == 1\n assert candidate(obstacles = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 0\n assert candidate(obstacles = [0, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0]) == 11\n assert candidate(obstacles = [0, 1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 0]) == 9\n assert candidate(obstacles = [0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0]) == 0\n assert candidate(obstacles = [0, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 11\n"}, "metadata": {"canonical_parameter_names": ["obstacles"], "leetcode_dataset_entry_point": "Solution().minSideJumps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minSideJumps(vector& obstacles) {", "container": "Solution", "callable": "minSideJumps", "parameters": [{"name": "obstacles", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1827, "task_id": "minimum-operations-to-make-the-array-increasing", "difficulty": "Easy", "problem_description": "You are given an integer array nums (0-indexed). In one operation, you can choose an element of the array and increment it by 1.\\r\n\\r\n\\r\n\tFor example, if nums = [1,2,3], you can choose to increment nums[1] to make nums = [1,3,3].\\r\n\\r\n\\r\nReturn the minimum number of operations needed to make nums strictly increasing.\\r\n\\r\nAn array nums is strictly increasing if nums[i] < nums[i+1] for all 0 <= i < nums.length - 1. An array of length 1 is trivially strictly increasing.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: nums = [1,1,1]\\r\nOutput: 3\\r\nExplanation: You can do the following operations:\\r\n1) Increment nums[2], so nums becomes [1,1,2].\\r\n2) Increment nums[1], so nums becomes [1,2,2].\\r\n3) Increment nums[2], so nums becomes [1,2,3].\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: nums = [1,5,2,4,1]\\r\nOutput: 14\\r\n\\r\n\\r\nExample 3:\\r\n\\r\n\\r\nInput: nums = [8]\\r\nOutput: 0\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= nums.length <= 5000\\r\n\t1 <= nums[i] <= 104\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [10000, 1, 1, 1, 1]) == 40006\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 25\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1]) == 109\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5]) == 7\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 25\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 16\n assert candidate(nums = [8]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [1, 1, 1]) == 3\n assert candidate(nums = [10000, 10000, 10000, 10000, 10000]) == 10\n assert candidate(nums = [10000, 10000, 10000, 10000]) == 6\n assert candidate(nums = [1, 5, 2, 4, 1]) == 14\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000]) == 100010\n assert candidate(nums = [1, 100, 1000, 10000, 100000]) == 0\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7]) == 35\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10]) == 2\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 400\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 66\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 10\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 380\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 4095\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 45045\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 380\n assert candidate(nums = [3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, -1, -1, -1, -1]) == 230\n assert candidate(nums = [1, 100, 50, 200, 100, 300, 150, 400, 200, 500]) == 504\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 190\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 0\n assert candidate(nums = [1, 5, 10, 15, 20, 25, 20, 25, 30, 35]) == 8\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 90\n assert candidate(nums = [5, 6, 6, 10, 8, 11, 11, 11]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [100, 200, 300, 200, 100, 200, 300, 400, 500]) == 410\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 90\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15]) == 273\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]) == 380\n assert candidate(nums = [10, 9, 10, 8, 10, 7, 10, 6, 10, 5, 10, 4, 10, 3, 10, 2, 10, 1, 10]) == 216\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 870\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 300\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 0\n assert candidate(nums = [5, 3, 2, 1, 0]) == 24\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 6215\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 225\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 0\n assert candidate(nums = [59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 1305\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 21, 20, 22, 21, 23, 22, 24, 23, 25]) == 35\n assert candidate(nums = [10000, 1000, 100, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 189064\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21]) == 18\n assert candidate(nums = [5000, 4999, 4998, 4997, 4996, 4995, 4994, 4993, 4992, 4991, 4990, 4989, 4988, 4987, 4986, 4985, 4984, 4983, 4982, 4981, 4980, 4979, 4978, 4977, 4976, 4975, 4974, 4973, 4972, 4971, 4970]) == 930\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 180\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15]) == 35\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 375\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 480\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 100\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 25\n assert candidate(nums = [5, 6, 6, 8, 8, 9, 9, 10, 10, 10, 11]) == 18\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 3, 2, 1]) == 930\n assert candidate(nums = [5, 3, 5, 3, 5, 3, 5, 3, 5, 3]) == 55\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 172\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 65\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4]) == 189\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5]) == 6\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 45\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 36\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 81\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 80\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9]) == 486\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990]) == 110\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6]) == 24\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 50, 150, 250, 350, 450, 550, 650, 750, 850, 950]) == 5055\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000]) == 45045\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 4000, 3000, 2000, 1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 1, 1, 1, 1, 1, 1, 1]) == 89209\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 280\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 260\n assert candidate(nums = [2, 3, 3, 5, 5, 5, 6, 7, 8, 8, 9, 9, 9]) == 25\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11]) == 2\n assert candidate(nums = [1, 2, 10, 11, 10, 12, 11, 13, 12, 14]) == 15\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 464\n assert candidate(nums = [10, 9, 10, 9, 10, 9, 10, 9, 10, 9]) == 50\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7]) == 133\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 212\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 189\n assert candidate(nums = [1, 3, 5, 2, 4, 6, 7, 8, 9, 10]) == 17\n assert candidate(nums = [100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50, 100, 50]) == 690\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 99\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1128\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 22935\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 4140\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 171\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 14\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 100, 100, 100]) == 7278\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 72\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [100, 100, 100, 100, 100, 101, 101, 101, 101, 101, 102, 102, 102, 102, 102, 103, 103, 103, 103, 103, 104, 104, 104, 104, 104, 105, 105, 105, 105, 105]) == 360\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 155\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 75\n assert candidate(nums = [1, 1, 10, 10, 100, 100, 1000, 1000, 10000, 10000]) == 5\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6]) == 36\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 280\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 45\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10]) == 40\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 496\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 100\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 1325\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 99\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 180\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 45\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 190\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 495\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 105\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 252\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minOperations(vector& nums) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1828, "task_id": "queries-on-number-of-points-inside-a-circle", "difficulty": "Medium", "problem_description": "You are given an array points where points[i] = [xi, yi] is the coordinates of the ith point on a 2D plane. Multiple points can have the same coordinates.\nYou are also given an array queries where queries[j] = [xj, yj, rj] describes a circle centered at (xj, yj) with a radius of rj.\nFor each query queries[j], compute the number of points inside the jth circle. Points on the border of the circle are considered inside.\nReturn an array answer, where answer[j] is the answer to the jth query.\n \nExample 1:\n\n\nInput: points = [[1,3],[3,3],[5,3],[2,2]], queries = [[2,3,1],[4,3,1],[1,1,2]]\nOutput: [3,2,2]\nExplanation: The points and circles are shown above.\nqueries[0] is the green circle, queries[1] is the red circle, and queries[2] is the blue circle.\n\nExample 2:\n\n\nInput: points = [[1,1],[2,2],[3,3],[4,4],[5,5]], queries = [[1,2,2],[2,2,2],[4,3,2],[4,3,3]]\nOutput: [2,3,2,4]\nExplanation: The points and circles are shown above.\nqueries[0] is green, queries[1] is red, queries[2] is blue, and queries[3] is purple.\n\n \nConstraints:\n\n1 <= points.length <= 500\npoints[i].length == 2\n0 <= x​​​​​​i, y​​​​​​i <= 500\n1 <= queries.length <= 500\nqueries[j].length == 3\n0 <= xj, yj <= 500\n1 <= rj <= 500\nAll coordinates are integers.\n\n \nFollow up: Could you find the answer for each query in better complexity than O(n)?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[1, 2, 2], [2, 2, 2], [4, 3, 2], [4, 3, 3]]) == [2, 3, 2, 4]\n assert candidate(points = [[1, 3], [3, 3], [5, 3], [2, 2]],queries = [[2, 3, 1], [4, 3, 1], [1, 1, 2]]) == [3, 2, 2]\n assert candidate(points = [[50, 50], [50, 150], [50, 250], [150, 50], [150, 150], [150, 250], [250, 50], [250, 150], [250, 250], [50, 100], [100, 100], [150, 100], [200, 100], [250, 100], [100, 150], [150, 150], [200, 150], [250, 150], [100, 200], [150, 200], [200, 200], [250, 200]],queries = [[100, 100, 50], [150, 150, 75], [200, 200, 100]]) == [4, 10, 12]\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],queries = [[5, 5, 5], [2, 2, 3], [7, 7, 2], [0, 0, 10]]) == [7, 5, 3, 8]\n assert candidate(points = [[250, 250], [260, 260], [270, 270], [280, 280], [290, 290]],queries = [[250, 250, 10], [250, 250, 20], [250, 250, 30], [250, 250, 40], [250, 250, 50]]) == [1, 2, 3, 3, 4]\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500]],queries = [[100, 100, 150], [200, 200, 150], [300, 300, 150], [400, 400, 150], [500, 500, 150]]) == [2, 3, 3, 3, 2]\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20], [21, 21], [22, 22], [23, 23], [24, 24], [25, 25]],queries = [[1, 1, 2], [10, 10, 5], [20, 20, 8], [15, 15, 10]]) == [2, 7, 11, 15]\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500]],queries = [[150, 150, 100], [350, 350, 150], [250, 250, 200], [450, 450, 250]]) == [2, 2, 2, 3]\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],queries = [[25, 25, 10], [15, 15, 5], [35, 35, 20]]) == [2, 0, 2]\n assert candidate(points = [[10, 10], [10, 20], [10, 30], [10, 40], [10, 50], [20, 10], [20, 20], [20, 30], [20, 40], [20, 50], [30, 10], [30, 20], [30, 30], [30, 40], [30, 50]],queries = [[15, 15, 5], [15, 25, 5], [15, 35, 5], [15, 45, 5], [15, 55, 5], [25, 15, 5], [25, 25, 5], [25, 35, 5], [25, 45, 5], [25, 55, 5], [35, 15, 5], [35, 25, 5], [35, 35, 5], [35, 45, 5], [35, 55, 5]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(points = [[50, 50], [150, 150], [250, 250], [350, 350], [450, 450], [50, 450], [450, 50]],queries = [[100, 100, 50], [200, 200, 50], [300, 300, 50], [400, 400, 50], [50, 50, 100], [450, 450, 100]]) == [0, 0, 0, 0, 1, 1]\n assert candidate(points = [[250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500], [550, 550], [600, 600], [650, 650], [700, 700], [750, 750], [800, 800], [850, 850], [900, 900], [950, 950]],queries = [[500, 500, 100], [600, 600, 150], [750, 750, 200], [850, 850, 250]]) == [3, 5, 5, 6]\n assert candidate(points = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [150, 250], [250, 350]],queries = [[200, 300, 50], [300, 400, 100], [400, 500, 150], [500, 600, 200]]) == [1, 2, 3, 2]\n assert candidate(points = [[0, 0], [500, 500], [250, 250], [100, 100], [400, 400]],queries = [[250, 250, 200], [100, 100, 100], [400, 400, 150]]) == [1, 1, 2]\n assert candidate(points = [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100], [110, 120]],queries = [[50, 50, 25], [70, 70, 30], [10, 10, 15], [90, 90, 20]]) == [2, 2, 1, 1]\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]],queries = [[3, 3, 5], [6, 6, 10], [9, 9, 15]]) == [6, 13, 15]\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]],queries = [[5, 5, 15], [15, 15, 25], [25, 25, 35], [35, 35, 45], [45, 45, 55]]) == [1, 3, 4, 5, 5]\n assert candidate(points = [[25, 25], [26, 26], [27, 27], [28, 28], [29, 29]],queries = [[10, 10, 20], [20, 20, 20], [30, 30, 20], [40, 40, 20], [50, 50, 20]]) == [0, 5, 5, 4, 0]\n assert candidate(points = [[50, 100], [100, 150], [150, 200], [200, 250], [250, 300]],queries = [[75, 125, 50], [125, 175, 50], [175, 225, 50], [225, 275, 50], [275, 325, 50]]) == [2, 2, 2, 2, 1]\n assert candidate(points = [[50, 50], [150, 150], [250, 250], [350, 350], [450, 450]],queries = [[100, 100, 50], [100, 100, 100], [100, 100, 150], [100, 100, 200], [100, 100, 250]]) == [0, 2, 2, 2, 3]\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],queries = [[15, 15, 10], [25, 25, 15], [35, 35, 20], [45, 45, 25], [55, 55, 30]]) == [2, 2, 2, 4, 4]\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],queries = [[5, 5, 5], [10, 10, 10], [15, 15, 15], [20, 20, 20], [25, 25, 25], [30, 30, 30], [35, 35, 35], [40, 40, 40], [45, 45, 45], [50, 50, 50]]) == [4, 7, 8, 7, 7, 6, 5, 4, 4, 3]\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],queries = [[15, 15, 10], [25, 25, 15], [35, 35, 20], [45, 45, 25], [55, 55, 30], [65, 65, 35], [75, 75, 40], [85, 85, 45], [95, 95, 50], [105, 105, 55]]) == [2, 2, 2, 4, 4, 4, 6, 5, 5, 4]\n assert candidate(points = [[400, 400], [450, 450], [500, 500], [550, 550], [600, 600]],queries = [[400, 400, 100], [450, 450, 150], [500, 500, 200], [550, 550, 250], [600, 600, 300]]) == [2, 4, 5, 5, 5]\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250]],queries = [[50, 50, 50], [100, 100, 50], [150, 150, 50], [200, 200, 50], [250, 250, 50]]) == [1, 1, 1, 1, 1]\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [50, 50], [150, 150], [250, 250], [350, 350], [450, 450]],queries = [[250, 250, 100], [150, 150, 50], [450, 450, 150], [50, 50, 200]]) == [3, 1, 4, 3]\n assert candidate(points = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65], [75, 75], [85, 85], [95, 95]],queries = [[10, 10, 10], [20, 20, 15], [30, 30, 20], [40, 40, 25], [50, 50, 30], [60, 60, 35], [70, 70, 40], [80, 80, 45], [90, 90, 50], [100, 100, 55]]) == [2, 2, 2, 4, 4, 4, 6, 5, 5, 4]\n assert candidate(points = [[50, 50], [150, 150], [250, 250], [350, 350], [450, 450], [100, 100], [200, 200], [300, 300], [400, 400], [500, 500]],queries = [[200, 200, 100], [100, 100, 50], [300, 300, 150], [400, 400, 200], [500, 500, 250]]) == [3, 1, 5, 5, 4]\n assert candidate(points = [[0, 0], [500, 0], [0, 500], [500, 500], [250, 250], [125, 125], [375, 125], [125, 375], [375, 375]],queries = [[250, 250, 200], [0, 0, 150], [500, 500, 150], [125, 125, 50], [375, 375, 50], [250, 0, 100], [250, 500, 100]]) == [5, 1, 1, 1, 1, 0, 0]\n assert candidate(points = [[10, 10], [10, 30], [10, 50], [10, 70], [10, 90], [30, 10], [30, 30], [30, 50], [30, 70], [30, 90], [50, 10], [50, 30], [50, 50], [50, 70], [50, 90]],queries = [[20, 20, 20], [40, 40, 20], [60, 60, 20], [20, 60, 20], [60, 20, 20]]) == [4, 4, 2, 4, 2]\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500]],queries = [[250, 250, 100], [300, 300, 150], [350, 350, 200], [400, 400, 250], [450, 450, 300]]) == [3, 5, 5, 6, 6]\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [110, 110], [120, 120], [130, 130], [140, 140], [150, 150]],queries = [[50, 50, 40], [100, 100, 50], [150, 150, 60], [20, 20, 30], [130, 130, 70]]) == [5, 7, 5, 4, 7]\n assert candidate(points = [[100, 100], [150, 100], [200, 100], [250, 100], [300, 100], [100, 150], [150, 150], [200, 150], [250, 150], [300, 150]],queries = [[150, 100, 50], [200, 150, 75], [100, 100, 100]]) == [4, 6, 5]\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [100, 200], [200, 300], [300, 400], [400, 500], [500, 100]],queries = [[150, 150, 50], [250, 250, 75], [350, 350, 100], [450, 450, 125], [550, 550, 150], [150, 250, 60], [250, 350, 85], [350, 450, 110], [450, 550, 135], [550, 150, 160]]) == [0, 3, 3, 3, 1, 0, 3, 3, 2, 1]\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [110, 110], [120, 120], [130, 130], [140, 140], [150, 150], [160, 160], [170, 170], [180, 180], [190, 190], [200, 200]],queries = [[100, 100, 50], [150, 150, 60], [200, 200, 70], [125, 125, 80]]) == [7, 9, 5, 12]\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500], [50, 100], [100, 150], [150, 200], [200, 250], [250, 300], [300, 350], [350, 400], [400, 450], [450, 500], [500, 550]],queries = [[75, 75, 25], [125, 125, 50], [175, 175, 75], [225, 225, 100], [275, 275, 125], [325, 325, 150], [375, 375, 175], [425, 425, 200], [475, 475, 225], [525, 525, 250]]) == [0, 3, 3, 5, 7, 9, 9, 10, 9, 8]\n assert candidate(points = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[5, 5, 5], [2, 2, 3], [8, 8, 4]]) == [7, 4, 5]\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [50, 50], [150, 150], [250, 250], [350, 350], [450, 450]],queries = [[100, 100, 50], [300, 300, 100], [400, 400, 150], [200, 200, 200], [50, 50, 25]]) == [1, 3, 5, 5, 1]\n assert candidate(points = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110]],queries = [[15, 25, 5], [25, 35, 10], [35, 45, 15], [45, 55, 20], [55, 65, 25], [65, 75, 30], [75, 85, 35], [85, 95, 40], [95, 105, 45], [105, 115, 50]]) == [0, 2, 2, 2, 4, 4, 4, 5, 4, 4]\n assert candidate(points = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100], [110, 110], [120, 120], [130, 130], [140, 140], [150, 150]],queries = [[75, 75, 25], [50, 50, 30], [125, 125, 40], [100, 100, 50]]) == [4, 5, 6, 7]\n assert candidate(points = [[250, 250], [260, 260], [270, 270], [280, 280], [290, 290], [300, 300], [310, 310], [320, 320], [330, 330], [340, 340]],queries = [[270, 270, 20], [300, 300, 40], [320, 320, 60]]) == [3, 5, 7]\n assert candidate(points = [[25, 25], [26, 26], [27, 27], [28, 28], [29, 29], [30, 30], [31, 31], [32, 32], [33, 33], [34, 34]],queries = [[25, 25, 10], [25, 25, 20], [25, 25, 30], [25, 25, 40], [25, 25, 50], [25, 25, 60], [25, 25, 70], [25, 25, 80], [25, 25, 90], [25, 25, 100]]) == [8, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500]],queries = [[25, 25, 30], [75, 75, 40], [125, 125, 50], [175, 175, 60], [225, 225, 70], [275, 275, 80], [325, 325, 90], [375, 375, 100], [425, 425, 110], [475, 475, 120]]) == [0, 2, 2, 2, 2, 2, 2, 2, 4, 3]\n assert candidate(points = [[10, 10], [10, 20], [20, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80]],queries = [[15, 15, 10], [50, 50, 30], [75, 75, 15], [45, 45, 25]]) == [4, 5, 2, 4]\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500]],queries = [[250, 250, 100], [50, 50, 50], [450, 450, 150], [300, 300, 200]]) == [3, 1, 4, 5]\n assert candidate(points = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500]],queries = [[250, 250, 100], [100, 100, 50], [300, 300, 150], [400, 400, 200]]) == [3, 1, 5, 5]\n assert candidate(points = [[0, 0], [500, 500], [250, 250], [100, 400], [400, 100], [200, 300], [300, 200], [150, 350], [350, 150], [50, 450]],queries = [[250, 250, 200], [100, 100, 50], [400, 400, 150], [200, 200, 100]]) == [5, 0, 1, 3]\n assert candidate(points = [[50, 50], [100, 50], [150, 50], [200, 50], [250, 50], [300, 50], [350, 50], [400, 50], [450, 50], [500, 50]],queries = [[75, 50, 25], [125, 50, 25], [175, 50, 25], [225, 50, 25], [275, 50, 25], [325, 50, 25], [375, 50, 25], [425, 50, 25], [475, 50, 25]]) == [2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(points = [[100, 100], [100, 200], [100, 300], [100, 400], [100, 500]],queries = [[100, 100, 50], [100, 200, 50], [100, 300, 50], [100, 400, 50], [100, 500, 50]]) == [1, 1, 1, 1, 1]\n assert candidate(points = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500]],queries = [[250, 250, 150], [150, 150, 50], [350, 350, 100]]) == [2, 0, 2]\n assert candidate(points = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19]],queries = [[5, 5, 5], [10, 10, 10], [15, 15, 15]]) == [7, 15, 15]\n"}, "metadata": {"canonical_parameter_names": ["points", "queries"], "leetcode_dataset_entry_point": "Solution().countPoints", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector countPoints(vector>& points, vector>& queries) {", "container": "Solution", "callable": "countPoints", "parameters": [{"name": "points", "type": "vector>&"}, {"name": "queries", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1829, "task_id": "maximum-xor-for-each-query", "difficulty": "Medium", "problem_description": "You are given a sorted array nums of n non-negative integers and an integer maximumBit. You want to perform the following query n times:\n\nFind a non-negative integer k < 2maximumBit such that nums[0] XOR nums[1] XOR ... XOR nums[nums.length-1] XOR k is maximized. k is the answer to the ith query.\nRemove the last element from the current array nums.\n\nReturn an array answer, where answer[i] is the answer to the ith query.\n \nExample 1:\n\nInput: nums = [0,1,1,3], maximumBit = 2\nOutput: [0,3,2,3]\nExplanation: The queries are answered as follows:\n1st query: nums = [0,1,1,3], k = 0 since 0 XOR 1 XOR 1 XOR 3 XOR 0 = 3.\n2nd query: nums = [0,1,1], k = 3 since 0 XOR 1 XOR 1 XOR 3 = 3.\n3rd query: nums = [0,1], k = 2 since 0 XOR 1 XOR 2 = 3.\n4th query: nums = [0], k = 3 since 0 XOR 3 = 3.\n\nExample 2:\n\nInput: nums = [2,3,4,7], maximumBit = 3\nOutput: [5,2,6,5]\nExplanation: The queries are answered as follows:\n1st query: nums = [2,3,4,7], k = 5 since 2 XOR 3 XOR 4 XOR 7 XOR 5 = 7.\n2nd query: nums = [2,3,4], k = 2 since 2 XOR 3 XOR 4 XOR 2 = 7.\n3rd query: nums = [2,3], k = 6 since 2 XOR 3 XOR 6 = 7.\n4th query: nums = [2], k = 5 since 2 XOR 5 = 7.\n\nExample 3:\n\nInput: nums = [0,1,2,2,5,7], maximumBit = 3\nOutput: [4,3,6,4,6,7]\n\n \nConstraints:\n\nnums.length == n\n1 <= n <= 105\n1 <= maximumBit <= 20\n0 <= nums[i] < 2maximumBit\nnums​​​ is sorted in ascending order.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 3, 4, 7],maximumBit = 3) == [5, 2, 6, 5]\n assert candidate(nums = [0, 1, 1, 3],maximumBit = 2) == [0, 3, 2, 3]\n assert candidate(nums = [1, 2, 4, 8, 16],maximumBit = 5) == [0, 16, 24, 28, 30]\n assert candidate(nums = [31, 31, 31, 31, 31],maximumBit = 5) == [0, 31, 0, 31, 0]\n assert candidate(nums = [0, 1, 2, 2, 5, 7],maximumBit = 3) == [4, 3, 6, 4, 6, 7]\n assert candidate(nums = [1, 1, 1, 1, 1],maximumBit = 1) == [0, 1, 0, 1, 0]\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],maximumBit = 20) == [434696, 813064, 624904, 73608, 941512, 1039208, 1047672, 1048464, 1048564, 1048574]\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101, 105, 109, 113, 117],maximumBit = 7) == [123, 14, 127, 18, 123, 30, 127, 34, 123, 46, 127, 50, 123, 62, 127, 66, 123, 78, 127, 82, 123, 94, 127, 98, 123, 110, 127, 114, 123, 126]\n assert candidate(nums = [1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575, 1048575],maximumBit = 20) == [1048575, 0, 1048575, 0, 1048575, 0, 1048575, 0, 1048575, 0, 1048575, 0, 1048575, 0, 1048575, 0, 1048575, 0, 1048575, 0]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],maximumBit = 4) == [14, 7, 15, 8, 14, 11, 15, 12, 14, 15]\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946],maximumBit = 14) == [5056, 14594, 9071, 13114, 14626, 16159, 15556, 16038, 16351, 16182, 16294, 16383, 16328, 16362, 16383, 16370, 16378, 16383, 16380, 16382]\n assert candidate(nums = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maximumBit = 1) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]\n assert candidate(nums = [0, 2, 6, 14, 30, 62, 126, 254, 510, 1022],maximumBit = 10) == [341, 683, 853, 939, 981, 1003, 1013, 1019, 1021, 1023]\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767],maximumBit = 15) == [10922, 21845, 27306, 30037, 31402, 32085, 32426, 32597, 32682, 32725, 32746, 32757, 32762, 32765, 32766]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],maximumBit = 5) == [31, 0, 29, 6, 31, 8, 29, 14, 31, 16, 29, 22, 31, 24, 29, 30]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],maximumBit = 4) == [15, 15, 14, 12, 15, 11, 14, 8, 15, 7, 14, 4, 15, 3, 14, 0]\n assert candidate(nums = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50],maximumBit = 6) == [29, 47, 0, 44, 5, 35, 0, 32, 61, 39, 48, 36, 53, 59, 48, 56, 61]\n assert candidate(nums = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 59049],maximumBit = 16) == [18165, 41052, 60607, 62750, 64917, 65356, 65471, 65518, 65525, 65532]\n assert candidate(nums = [1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023],maximumBit = 10) == [1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],maximumBit = 5) == [29, 14, 31, 16, 29, 22, 31, 24, 29, 30]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],maximumBit = 5) == [31, 0, 30, 3, 31, 4, 30, 7, 31, 8, 30, 11, 31, 12, 30, 15, 31, 16, 30, 19, 31, 20, 30, 23, 31, 24, 30, 27, 31, 28, 30]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],maximumBit = 6) == [61, 6, 63, 8, 61, 14, 63, 16, 61, 22, 63, 24, 61, 30, 63, 32, 61, 38, 63, 40, 61, 46, 63, 48, 61, 54, 63, 56, 61, 62]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],maximumBit = 20) == [0, 524288, 786432, 917504, 983040, 1015808, 1032192, 1040384, 1044480, 1046528, 1047552, 1048064, 1048320, 1048448, 1048512, 1048544, 1048560, 1048568, 1048572, 1048574]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],maximumBit = 5) == [11, 10, 8, 11, 15, 10, 12, 11, 3, 10, 0, 11, 7, 10, 4, 11, 27, 10, 24, 11]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],maximumBit = 3) == [7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2, 7, 2]\n assert candidate(nums = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38],maximumBit = 6) == [63, 25, 61, 31, 63, 33, 61, 39, 63, 41, 61, 47, 63, 49, 61, 55, 63, 57, 61, 63]\n assert candidate(nums = [3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575, 2097151],maximumBit = 21) == [699051, 1398100, 1747627, 1922388, 2009771, 2053460, 2075307, 2086228, 2091691, 2094420, 2095787, 2096468, 2096811, 2096980, 2097067, 2097108, 2097131, 2097140, 2097147, 2097148]\n assert candidate(nums = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58],maximumBit = 6) == [61, 7, 63, 9, 61, 15, 63, 17, 61, 23, 63, 25, 61, 31, 63, 33, 61, 39, 63, 41, 61, 47, 63, 49, 61, 55, 63, 57, 61, 63]\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400],maximumBit = 9) == [99, 499, 154, 478, 255, 511, 286, 474, 371, 483, 410, 510, 431, 495, 478, 506, 483, 499, 506, 510]\n assert candidate(nums = [3, 6, 12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288, 24576],maximumBit = 15) == [16382, 24574, 28670, 30718, 31742, 32254, 32510, 32638, 32702, 32734, 32750, 32758, 32762, 32764]\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765],maximumBit = 13) == [6403, 878, 4923, 6435, 7966, 7365, 7847, 8158, 7991, 8103, 8190, 8137, 8171, 8190, 8179, 8187, 8190, 8189, 8191, 8190]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],maximumBit = 11) == [0, 1024, 1536, 1792, 1920, 1984, 2016, 2032, 2040, 2044, 2046]\n assert candidate(nums = [1023, 1022, 1021, 1020, 1019, 1018, 1017, 1016, 1015],maximumBit = 10) == [8, 1023, 7, 1022, 4, 1023, 3, 1022, 0]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],maximumBit = 4) == [15, 0, 14, 3, 15, 4, 14, 7, 15, 8, 14, 11, 15, 12, 14, 15]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],maximumBit = 7) == [63, 116, 50, 115, 79, 120, 74, 103, 79, 108, 114, 107, 127, 112, 122]\n assert candidate(nums = [12, 24, 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288],maximumBit = 14) == [8187, 12283, 14331, 15355, 15867, 16123, 16251, 16315, 16347, 16363, 16371]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60],maximumBit = 6) == [1, 61, 7, 63, 9, 61, 15, 63, 17, 61, 23, 63, 25, 61, 31, 63, 33, 61, 39, 63, 41, 61, 47, 63, 49, 61, 55, 63, 57, 61]\n assert candidate(nums = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maximumBit = 1) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],maximumBit = 1) == [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35],maximumBit = 6) == [15, 44, 50, 43, 63, 48, 58]\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095],maximumBit = 13) == [5461, 6826, 7509, 7850, 8021, 8106, 8149, 8170, 8181, 8186, 8189, 8190]\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64],maximumBit = 7) == [63, 127, 71, 119, 95, 127, 103, 119]\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],maximumBit = 10) == [341, 682, 853, 938, 981, 1002, 1013, 1018, 1021, 1022]\n assert candidate(nums = [0, 2, 3, 5, 6, 8, 10, 12],maximumBit = 4) == [3, 15, 5, 13, 11, 14, 13, 15]\n assert candidate(nums = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18],maximumBit = 5) == [31, 13, 30, 14, 31, 17, 30, 18, 31, 21, 30, 22, 31, 25, 30, 26, 31, 29, 30, 30]\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127],maximumBit = 7) == [42, 85, 106, 117, 122, 125, 126]\n assert candidate(nums = [31, 62, 93, 124, 155, 186, 217, 248, 279, 310],maximumBit = 10) == [990, 744, 1023, 775, 990, 868, 1023, 899, 990, 992]\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],maximumBit = 1) == [0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1]\n assert candidate(nums = [7, 15, 23, 31, 39, 47, 55, 63, 71, 79, 87, 95],maximumBit = 7) == [127, 32, 119, 56, 127, 64, 119, 88, 127, 96, 119, 120]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],maximumBit = 8) == [183, 127, 193, 117, 223, 127, 233, 101, 231, 159, 241, 149, 207, 159, 217, 229, 215, 255, 225, 245]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],maximumBit = 1) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],maximumBit = 10) == [0, 512, 768, 896, 960, 992, 1008, 1016, 1020, 1022]\n assert candidate(nums = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287],maximumBit = 20) == [699050, 873813, 961194, 1004885, 1026730, 1037653, 1043114, 1045845, 1047210, 1047893, 1048234, 1048405, 1048490, 1048533, 1048554, 1048565, 1048570, 1048573, 1048574, 1048575]\n assert candidate(nums = [0, 1, 3, 7, 15, 31, 63],maximumBit = 6) == [21, 42, 53, 58, 61, 62, 63]\n assert candidate(nums = [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144],maximumBit = 18) == [0, 0, 131072, 196608, 229376, 245760, 253952, 258048, 260096, 261120, 261632, 261888, 262016, 262080, 262112, 262128, 262136, 262140, 262142, 262143]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],maximumBit = 4) == [15, 0, 14, 3, 15, 4, 14, 7, 15, 8, 14, 11, 15, 12, 14, 15]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],maximumBit = 20) == [0, 524288, 786432, 917504, 983040, 1015808, 1032192, 1040384, 1044480, 1046528, 1047552, 1048064, 1048320, 1048448, 1048512, 1048544, 1048560, 1048568, 1048572, 1048574]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],maximumBit = 6) == [14, 63, 16, 61, 22, 63, 24, 61, 30, 63, 32, 61, 38, 63, 40, 61, 46, 63, 48, 61, 54, 63, 56, 61, 62]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],maximumBit = 2) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023],maximumBit = 10) == [1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],maximumBit = 7) == [113, 21, 79, 31, 89, 101, 87, 127, 97, 117]\n assert candidate(nums = [1, 3, 4, 7, 10, 12, 15, 19, 22],maximumBit = 5) == [18, 4, 23, 24, 20, 30, 25, 29, 30]\n assert candidate(nums = [1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023, 1023],maximumBit = 10) == [1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0, 1023, 0]\n assert candidate(nums = [10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120],maximumBit = 13) == [2041, 5113, 6649, 7417, 7801, 7993, 8089, 8137, 8161, 8181]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],maximumBit = 1) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],maximumBit = 5) == [11, 31, 12, 30, 15, 31, 16, 30, 19, 31, 20, 30, 23, 31, 24, 30, 27, 31, 28, 30]\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],maximumBit = 7) == [26, 126, 47, 111, 94, 122, 99, 115, 122, 126]\n assert candidate(nums = [0, 1, 3, 7, 15, 31, 63, 127],maximumBit = 7) == [42, 85, 106, 117, 122, 125, 126, 127]\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3],maximumBit = 3) == [7, 4, 7, 4, 7, 4, 6, 4, 6, 4, 6, 7, 6, 7, 6, 7, 7, 7, 7, 7]\n assert candidate(nums = [127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117],maximumBit = 7) == [11, 126, 8, 127, 7, 126, 4, 127, 3, 126, 0]\n assert candidate(nums = [5, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383],maximumBit = 14) == [5458, 10925, 13650, 15021, 15698, 16045, 16210, 16301, 16338, 16365, 16370, 16381, 16378]\n assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],maximumBit = 20) == [349525, 349524, 349527, 349520, 349535, 349504, 349567, 349440, 349695, 349184, 350207, 348160, 352255, 344064, 360447, 327680, 393215, 262144, 524287, 0]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],maximumBit = 10) == [0, 512, 768, 896, 960, 992, 1008, 1016, 1020, 1022]\n assert candidate(nums = [8, 10, 12, 14, 16, 18, 20, 22],maximumBit = 5) == [31, 9, 29, 15, 31, 17, 29, 23]\n assert candidate(nums = [2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 524287, 1048575],maximumBit = 20) == [350207, 698368, 874495, 960512, 1005567, 1026048, 1038335, 1042432, 1046527, 1046528]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],maximumBit = 6) == [63, 3, 58, 12, 63, 15, 34, 8, 47, 11, 42, 52, 47, 55, 34, 48, 63, 51, 58, 60]\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255],maximumBit = 8) == [255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0]\n assert candidate(nums = [0, 2, 3, 5, 8, 13, 21, 34, 55, 89],maximumBit = 7) == [39, 126, 73, 107, 126, 115, 123, 126, 125, 127]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],maximumBit = 6) == [63, 24, 61, 30, 63, 32, 61, 38, 63, 40, 61, 46, 63, 48, 61, 54, 63, 56, 61, 62]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1023],maximumBit = 10) == [1023, 0, 512, 768, 896, 960, 992, 1008, 1016, 1020, 1022]\n assert candidate(nums = [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512],maximumBit = 10) == [0, 512, 768, 896, 960, 992, 1008, 1016, 1020, 1022, 1023]\n"}, "metadata": {"canonical_parameter_names": ["nums", "maximumBit"], "leetcode_dataset_entry_point": "Solution().getMaximumXor", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector getMaximumXor(vector& nums, int maximumBit) {", "container": "Solution", "callable": "getMaximumXor", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "maximumBit", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1832, "task_id": "check-if-the-sentence-is-pangram", "difficulty": "Easy", "problem_description": "A pangram is a sentence where every letter of the English alphabet appears at least once.\nGiven a string sentence containing only lowercase English letters, return true if sentence is a pangram, or false otherwise.\n \nExample 1:\n\nInput: sentence = \"thequickbrownfoxjumpsoverthelazydog\"\nOutput: true\nExplanation: sentence contains at least one of every letter of the English alphabet.\n\nExample 2:\n\nInput: sentence = \"leetcode\"\nOutput: false\n\n \nConstraints:\n\n1 <= sentence.length <= 1000\nsentence consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(sentence = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == True\n assert candidate(sentence = \"quickbrownfoxjumpsoverthelazydog\") == True\n assert candidate(sentence = \"aaaaabbbbbccccc\") == False\n assert candidate(sentence = \"a\") == False\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydogandmorelettersjusttoextendthelengthofthesentenceevenmorejustformeasurements\") == True\n assert candidate(sentence = \"hellothere\") == False\n assert candidate(sentence = \"hello\") == False\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazy\") == False\n assert candidate(sentence = \"abcdefghijjklmnopqrstuvwxyz\") == True\n assert candidate(sentence = \"hello world\") == False\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyzzzzz\") == True\n assert candidate(sentence = \"leetcode\") == False\n assert candidate(sentence = \"thisisaverylongsentencebutnotapangram\") == False\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydog\") == True\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyzabc\") == True\n assert candidate(sentence = \"mississippi\") == False\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelaz\") == False\n assert candidate(sentence = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(sentence = \"abcdefghijlkmnopqrstuvwxyz\") == True\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydogandthenomeofthezebra\") == True\n assert candidate(sentence = \"aquickmovementsoftheenemywilljeopardizethesecurityofthefort\") == False\n assert candidate(sentence = \"neverjumpoveraslydogquicklyasmyfastcat\") == False\n assert candidate(sentence = \"jumpedoverthelazybrownfoxquickly\") == False\n assert candidate(sentence = \"thisisaverylongsentencethatwantsyoumakesurethatispangram\") == False\n assert candidate(sentence = \"everygoodboydoesfine\") == False\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthefly\") == False\n assert candidate(sentence = \"thefoxjumpedoveralazydogandquicklymunchedberries\") == False\n assert candidate(sentence = \"aquickmovofjumpsbxngthevlackdwarf\") == False\n assert candidate(sentence = \"abcdefghijklnopqrstuvwxyz\") == False\n assert candidate(sentence = \"sphinxofblackquartzjudgemyvowels\") == True\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydozzzzzzzzzz\") == False\n assert candidate(sentence = \"aabbbcccdddeeefffggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == True\n assert candidate(sentence = \"thisisaverylongsentencethatshouldcontainalllettersquickly\") == False\n assert candidate(sentence = \"thebrownfoxjumpsovertheleazydog\") == False\n assert candidate(sentence = \"phinxofquizzingjudgesbringsmywonder\") == False\n assert candidate(sentence = \"packmyboxwithfivedozenliquorjugsquicklyandjudgeeachvowel\") == True\n assert candidate(sentence = \"vowelsaeiouyzqjfdxhcntrbplsmkgw\") == True\n assert candidate(sentence = \"jumpsquickonthisbrownfox\") == False\n assert candidate(sentence = \"fivexwiseguysjumpquicklyonthiszanyboat\") == False\n assert candidate(sentence = \"aquickmovewiththiszestyjuicebringsvexflation\") == False\n assert candidate(sentence = \"quickbrownfoxjumpsoverthelazydogquickbrownfoxjumpsoverthelazydog\") == True\n assert candidate(sentence = \"pythonprogramminglanguage\") == False\n assert candidate(sentence = \"xylophonesarefunbutquickbrownfoxjumpsoverthelazydog\") == True\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydogy\") == True\n assert candidate(sentence = \"qwertypoiuytrewqasdfghjklzxcvbnmasdfghjklzxcvbnmqwertyuiopcvbnm\") == True\n assert candidate(sentence = \"zyxwvutsrqponmlkjihgfedcbaabcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(sentence = \"thesixfatfingersjumpquicklyonthisverylazydog\") == False\n assert candidate(sentence = \"jumpsfoxoverthelazydogquickb\") == False\n assert candidate(sentence = \"sixjovialfellowshavequicklyzippedanddrunkmanybeers\") == False\n assert candidate(sentence = \"abacaxypromiseyouanelephantwhoxylophones\") == False\n assert candidate(sentence = \"jumpedoverthelazydogthequickbrownfox\") == False\n assert candidate(sentence = \"sphinxofblackquartzjudgemyvexzwift\") == True\n assert candidate(sentence = \"thequickbrownfoxjumpedoverthelazydogquickly\") == False\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxy\") == False\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzz\") == True\n assert candidate(sentence = \"foxjumpsoverthelazydogquickbrown\") == True\n assert candidate(sentence = \"thisquestionaboutpangramsissomewhatredundant\") == False\n assert candidate(sentence = \"aquickbrownfoxjumpsoverthelazydog\") == True\n assert candidate(sentence = \"jumpedoverthelazydogquickbrownfox\") == False\n assert candidate(sentence = \"aquickmovingtonafleetofsixgreyhounds\") == False\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydogg\") == True\n assert candidate(sentence = \"howvexinglyquickdaftzebrasjump\") == True\n assert candidate(sentence = \"quickbrownfoxjumpsoverthelazydogzzzzzzzzzz\") == True\n assert candidate(sentence = \"aquickmovementsofthejaguarzephyr\") == False\n assert candidate(sentence = \"quicklyjudginghowvexingzebraflowscanbeverytricky\") == False\n assert candidate(sentence = \"aquickbrownfoxjumpsoverthelazydogandbackagain\") == True\n assert candidate(sentence = \"abcdefghijklnopqrstuvwxyzabcdefghijklnopqrstuvwxyz\") == False\n assert candidate(sentence = \"jellyoftheplumlovesmeandthemonkeyrinsesupwithgrapejuicequickly\") == False\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(sentence = \"thebrownfoxjumpedoveralazylazydog\") == False\n assert candidate(sentence = \"packmyboxwithfivedozenliquorjugs\") == True\n assert candidate(sentence = \"foxjumpsoverthelazydogquickbrownzzzzzzzzzz\") == True\n assert candidate(sentence = \"althoughsomehumansareabsolutelyastonishing\") == False\n assert candidate(sentence = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(sentence = \"jovialwaltzsexemplifiesquickbymyflyfriend\") == False\n assert candidate(sentence = \"aquickbrownfoxjumpsoverthelazydogs\") == True\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydo\") == False\n assert candidate(sentence = \"abcdefghjklmnopqrstuvwxyz\") == False\n assert candidate(sentence = \"veryfewlazydogslikejumpingoverthebigbrownfox\") == False\n assert candidate(sentence = \"therearemanysmallpacksofdifferentbooksinthelibrary\") == False\n assert candidate(sentence = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(sentence = \"jimquicklyzippedvexedfowlsbymyplushog\") == False\n assert candidate(sentence = \"quickbrownfoxjumpsoverthelazydogs\") == True\n assert candidate(sentence = \"abcdefghijkllllmnopqrstuvwxyz\") == True\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydogandmore\") == True\n assert candidate(sentence = \"everygoodboydoesfinejustkickslovingmonkeysnearpianoquicksly\") == False\n assert candidate(sentence = \"pqrsghijklmnabcdefwxyzotuvcd\") == True\n assert candidate(sentence = \"pangramsarefunnywordsusedinyogamatclasses\") == False\n assert candidate(sentence = \"thequickbrownfoxjumpedoverthelazydogandthenranoff\") == False\n assert candidate(sentence = \"fourxsixtwoseveneleveneightfivenineninetwozero\") == False\n assert candidate(sentence = \"abracadabracabracadabra\") == False\n assert candidate(sentence = \"mjklqrswxzytfpuhncideaoxbgvlozmt\") == True\n assert candidate(sentence = \"thequickbrownfoxjumpsoverthelazydogandcat\") == True\n assert candidate(sentence = \"thisisaverylongstringsentencethatwillnotbepangram\") == False\n assert candidate(sentence = \"quovadis\") == False\n assert candidate(sentence = \"thisisaverylongsentencethatjustmightcontainallthelettersofthealphabet\") == False\n assert candidate(sentence = \"everygoodboydoesfineandzestfullyjumpoverlazysnails\") == False\n"}, "metadata": {"canonical_parameter_names": ["sentence"], "leetcode_dataset_entry_point": "Solution().checkIfPangram", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool checkIfPangram(string sentence) {", "container": "Solution", "callable": "checkIfPangram", "parameters": [{"name": "sentence", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1833, "task_id": "maximum-ice-cream-bars", "difficulty": "Medium", "problem_description": "It is a sweltering summer day, and a boy wants to buy some ice cream bars.\nAt the store, there are n ice cream bars. You are given an array costs of length n, where costs[i] is the price of the ith ice cream bar in coins. The boy initially has coins coins to spend, and he wants to buy as many ice cream bars as possible. \nNote: The boy can buy the ice cream bars in any order.\nReturn the maximum number of ice cream bars the boy can buy with coins coins.\nYou must solve the problem by counting sort.\n \nExample 1:\n\nInput: costs = [1,3,2,4,1], coins = 7\nOutput: 4\nExplanation: The boy can buy ice cream bars at indices 0,1,2,4 for a total price of 1 + 3 + 2 + 1 = 7.\n\nExample 2:\n\nInput: costs = [10,6,8,7,7,8], coins = 5\nOutput: 0\nExplanation: The boy cannot afford any of the ice cream bars.\n\nExample 3:\n\nInput: costs = [1,6,3,1,2,5], coins = 20\nOutput: 6\nExplanation: The boy can buy all the ice cream bars for a total price of 1 + 6 + 3 + 1 + 2 + 5 = 18.\n\n \nConstraints:\n\ncosts.length == n\n1 <= n <= 105\n1 <= costs[i] <= 105\n1 <= coins <= 108\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(costs = [1, 3, 2, 4, 1],coins = 7) == 4\n assert candidate(costs = [10, 6, 8, 7, 7, 8],coins = 5) == 0\n assert candidate(costs = [1],coins = 1) == 1\n assert candidate(costs = [1, 6, 3, 1, 2, 5],coins = 20) == 6\n assert candidate(costs = [100000],coins = 100000) == 1\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],coins = 10) == 4\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],coins = 55) == 10\n assert candidate(costs = [5, 5, 5, 5, 5],coins = 15) == 3\n assert candidate(costs = [10, 20, 30, 40, 50],coins = 100) == 4\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],coins = 15) == 5\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],coins = 50) == 9\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],coins = 19) == 19\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],coins = 5) == 5\n assert candidate(costs = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],coins = 15) == 6\n assert candidate(costs = [5, 4, 2, 3, 1, 6, 7, 8, 9, 10],coins = 15) == 5\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],coins = 250) == 6\n assert candidate(costs = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],coins = 25) == 12\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],coins = 210) == 20\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],coins = 55) == 2\n assert candidate(costs = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],coins = 40) == 8\n assert candidate(costs = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],coins = 100) == 13\n assert candidate(costs = [100000, 99999, 99998, 99997, 99996, 99995],coins = 599985) == 6\n assert candidate(costs = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],coins = 50) == 13\n assert candidate(costs = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5, 999996],coins = 1000000) == 5\n assert candidate(costs = [50, 25, 75, 100, 200, 300, 400, 500, 600, 700],coins = 2000) == 8\n assert candidate(costs = [1, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],coins = 10) == 10\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],coins = 800) == 12\n assert candidate(costs = [1, 1000000, 2, 999999, 3, 999998, 4, 999997, 5, 999996],coins = 5000000) == 9\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],coins = 10) == 10\n assert candidate(costs = [5, 1, 4, 2, 3],coins = 10) == 4\n assert candidate(costs = [1000, 500, 200, 100, 50, 20, 10, 5, 2, 1],coins = 1000) == 9\n assert candidate(costs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],coins = 8000) == 12\n assert candidate(costs = [5, 7, 8, 6, 3, 2, 1, 4, 9, 10],coins = 20) == 5\n assert candidate(costs = [50, 20, 30, 10, 40],coins = 100) == 4\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],coins = 1000) == 10\n assert candidate(costs = [100000, 100000, 100000, 100000, 100000],coins = 500000) == 5\n assert candidate(costs = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],coins = 50) == 5\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],coins = 300) == 24\n assert candidate(costs = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],coins = 25) == 6\n assert candidate(costs = [99999, 1, 99999, 1, 99999, 1, 99999, 1, 99999, 1],coins = 5) == 5\n assert candidate(costs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],coins = 20) == 4\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],coins = 10) == 10\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],coins = 50) == 9\n assert candidate(costs = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],coins = 50) == 10\n assert candidate(costs = [9, 8, 7, 6, 5, 4, 3, 2, 1],coins = 25) == 6\n assert candidate(costs = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],coins = 55) == 10\n assert candidate(costs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],coins = 1500) == 5\n assert candidate(costs = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],coins = 15) == 7\n assert candidate(costs = [5, 1, 3, 1, 2, 5, 3, 1, 2, 5],coins = 15) == 7\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],coins = 10) == 10\n assert candidate(costs = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],coins = 55) == 2\n assert candidate(costs = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],coins = 20) == 4\n assert candidate(costs = [1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4],coins = 10) == 7\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],coins = 550) == 10\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],coins = 10) == 10\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],coins = 190) == 19\n assert candidate(costs = [3, 1, 2, 1, 4, 2, 2, 3, 2, 1, 2, 3, 4, 1, 2],coins = 20) == 11\n assert candidate(costs = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],coins = 300) == 10\n assert candidate(costs = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31],coins = 100) == 8\n assert candidate(costs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],coins = 1000) == 13\n assert candidate(costs = [100000, 1, 100000, 1, 100000, 1, 100000],coins = 100003) == 4\n assert candidate(costs = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],coins = 100) == 10\n assert candidate(costs = [5, 1, 3, 2, 4, 1],coins = 10) == 4\n assert candidate(costs = [5, 3, 3, 2, 7, 8, 9],coins = 15) == 4\n assert candidate(costs = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],coins = 500000) == 9\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],coins = 100) == 13\n assert candidate(costs = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999],coins = 1000000) == 10\n assert candidate(costs = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],coins = 5) == 5\n assert candidate(costs = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195],coins = 150000) == 9\n assert candidate(costs = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],coins = 250) == 18\n assert candidate(costs = [5, 2, 3, 1, 4, 2, 3, 5, 1, 2],coins = 15) == 7\n assert candidate(costs = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],coins = 2500) == 6\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],coins = 30) == 7\n assert candidate(costs = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],coins = 60) == 10\n assert candidate(costs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],coins = 100) == 13\n"}, "metadata": {"canonical_parameter_names": ["costs", "coins"], "leetcode_dataset_entry_point": "Solution().maxIceCream", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxIceCream(vector& costs, int coins) {", "container": "Solution", "callable": "maxIceCream", "parameters": [{"name": "costs", "type": "vector&"}, {"name": "coins", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1834, "task_id": "single-threaded-cpu", "difficulty": "Medium", "problem_description": "You are given n​​​​​​ tasks labeled from 0 to n - 1 represented by a 2D integer array tasks, where tasks[i] = [enqueueTimei, processingTimei] means that the i​​​​​​th​​​​ task will be available to process at enqueueTimei and will take processingTimei to finish processing.\nYou have a single-threaded CPU that can process at most one task at a time and will act in the following way:\n\nIf the CPU is idle and there are no available tasks to process, the CPU remains idle.\nIf the CPU is idle and there are available tasks, the CPU will choose the one with the shortest processing time. If multiple tasks have the same shortest processing time, it will choose the task with the smallest index.\nOnce a task is started, the CPU will process the entire task without stopping.\nThe CPU can finish a task then start a new one instantly.\n\nReturn the order in which the CPU will process the tasks.\n \nExample 1:\n\nInput: tasks = [[1,2],[2,4],[3,2],[4,1]]\nOutput: [0,2,3,1]\nExplanation: The events go as follows: \n- At time = 1, task 0 is available to process. Available tasks = {0}.\n- Also at time = 1, the idle CPU starts processing task 0. Available tasks = {}.\n- At time = 2, task 1 is available to process. Available tasks = {1}.\n- At time = 3, task 2 is available to process. Available tasks = {1, 2}.\n- Also at time = 3, the CPU finishes task 0 and starts processing task 2 as it is the shortest. Available tasks = {1}.\n- At time = 4, task 3 is available to process. Available tasks = {1, 3}.\n- At time = 5, the CPU finishes task 2 and starts processing task 3 as it is the shortest. Available tasks = {1}.\n- At time = 6, the CPU finishes task 3 and starts processing task 1. Available tasks = {}.\n- At time = 10, the CPU finishes task 1 and becomes idle.\n\nExample 2:\n\nInput: tasks = [[7,10],[7,12],[7,5],[7,4],[7,2]]\nOutput: [4,3,2,0,1]\nExplanation: The events go as follows:\n- At time = 7, all the tasks become available. Available tasks = {0,1,2,3,4}.\n- Also at time = 7, the idle CPU starts processing task 4. Available tasks = {0,1,2,3}.\n- At time = 9, the CPU finishes task 4 and starts processing task 3. Available tasks = {0,1,2}.\n- At time = 13, the CPU finishes task 3 and starts processing task 2. Available tasks = {0,1}.\n- At time = 18, the CPU finishes task 2 and starts processing task 0. Available tasks = {1}.\n- At time = 28, the CPU finishes task 0 and starts processing task 1. Available tasks = {}.\n- At time = 40, the CPU finishes task 1 and becomes idle.\n\n \nConstraints:\n\ntasks.length == n\n1 <= n <= 105\n1 <= enqueueTimei, processingTimei <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(tasks = [[1, 3], [2, 2], [3, 1], [4, 4]]) == [0, 2, 1, 3]\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 3], [2, 5], [8, 2], [7, 4], [10, 2]]) == [0, 1, 2, 4, 3]\n assert candidate(tasks = [[1, 3], [2, 2], [3, 1], [4, 4], [5, 5]]) == [0, 2, 1, 3, 4]\n assert candidate(tasks = [[3, 1], [1, 2], [2, 4], [1, 4]]) == [1, 0, 2, 3]\n assert candidate(tasks = [[5, 2], [3, 1], [1, 4], [4, 3], [2, 5]]) == [2, 1, 0, 3, 4]\n assert candidate(tasks = [[5, 5], [8, 2], [1, 9], [3, 8]]) == [2, 1, 0, 3]\n assert candidate(tasks = [[9, 3], [3, 7], [8, 10], [4, 3], [5, 3]]) == [1, 0, 3, 4, 2]\n assert candidate(tasks = [[2, 1], [3, 1], [1, 2], [7, 3], [8, 4], [9, 5]]) == [2, 0, 1, 3, 4, 5]\n assert candidate(tasks = [[19, 13], [16, 9], [21, 10], [32, 25], [37, 4], [49, 24], [2, 15], [38, 41], [37, 34], [33, 6], [45, 4], [18, 18], [46, 39], [12, 24]]) == [6, 1, 2, 9, 4, 10, 0, 11, 5, 13, 3, 8, 12, 7]\n assert candidate(tasks = [[5, 2], [7, 2], [9, 4], [6, 3], [8, 2]]) == [0, 1, 4, 3, 2]\n assert candidate(tasks = [[7, 10], [7, 12], [7, 5], [7, 4], [7, 2]]) == [4, 3, 2, 0, 1]\n assert candidate(tasks = [[5, 2], [1, 2], [3, 1], [2, 1]]) == [1, 2, 3, 0]\n assert candidate(tasks = [[1, 2], [2, 4], [3, 2], [4, 1]]) == [0, 2, 3, 1]\n assert candidate(tasks = [[1, 3], [2, 5], [8, 2], [7, 4], [6, 1], [5, 6], [4, 3], [3, 2], [9, 5], [10, 4]]) == [0, 7, 4, 6, 2, 3, 9, 1, 8, 5]\n assert candidate(tasks = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 10]]) == [0, 8, 7, 6, 5, 4, 3, 2, 1, 9]\n assert candidate(tasks = [[100, 1], [100, 1], [100, 1], [100, 1], [100, 1], [100, 1], [100, 1], [100, 1], [100, 1], [100, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(tasks = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(tasks = [[1, 2], [2, 3], [4, 5], [8, 9], [16, 17], [32, 33], [64, 65], [128, 129], [256, 257], [512, 513], [1024, 1025], [2048, 2049], [4096, 4097], [8192, 8193], [16384, 16385]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(tasks = [[1, 100], [101, 1], [201, 10], [301, 100], [401, 10], [501, 1], [601, 100], [701, 10], [801, 1], [901, 100]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [2, 2], [1, 3], [2, 4], [1, 5], [2, 6], [1, 7], [2, 8], [1, 9], [2, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [0, 10, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19]\n assert candidate(tasks = [[1, 1000000000], [2, 1000000000], [3, 1000000000], [4, 1000000000], [5, 1000000000]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 100], [200, 1], [300, 1], [400, 1], [500, 1], [600, 1], [700, 1], [800, 1], [900, 1], [1000, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 1], [7, 2], [8, 3], [9, 4], [10, 5]]) == [0, 4, 5, 3, 6, 2, 7, 1, 8, 9]\n assert candidate(tasks = [[1, 10], [10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(tasks = [[2, 5], [1, 3], [2, 2], [4, 1], [5, 10], [7, 1], [8, 2], [9, 3], [10, 4]]) == [1, 3, 2, 5, 6, 7, 8, 0, 4]\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7]]) == [5, 6, 3, 4, 10, 2, 7, 11, 15, 1, 8, 12, 16, 0, 9, 13, 17, 14, 18, 19]\n assert candidate(tasks = [[1, 10], [10, 1], [100, 1], [1000, 1], [10000, 1], [100000, 1], [1000000, 1], [10000000, 1], [100000000, 1], [1000000000, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10], [5, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[10, 100], [100, 10], [200, 20], [300, 30], [400, 40], [500, 50], [600, 60], [700, 70], [800, 80], [900, 90]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 5], [1, 4], [1, 3], [1, 2], [1, 1], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5]]) == [4, 5, 3, 6, 2, 7, 1, 8, 0, 9]\n assert candidate(tasks = [[1, 3], [1, 2], [1, 1], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == [2, 1, 0, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 2], [1, 2], [1, 2], [2, 1], [2, 1], [2, 1], [3, 3], [3, 3], [3, 3], [4, 4], [4, 4], [4, 4], [5, 5], [5, 5], [5, 5]]) == [0, 3, 4, 5, 1, 2, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(tasks = [[1, 1], [1000000000, 1000000000], [2, 2], [999999999, 999999999], [3, 3], [999999998, 999999998], [4, 4], [999999997, 999999997], [5, 5], [999999996, 999999996]]) == [0, 2, 4, 6, 8, 9, 7, 5, 3, 1]\n assert candidate(tasks = [[10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 2], [2, 1], [3, 2], [4, 1], [5, 2], [6, 1], [7, 2], [8, 1], [9, 2], [10, 1], [1, 2], [2, 1], [3, 2], [4, 1], [5, 2], [6, 1], [7, 2], [8, 1], [9, 2], [10, 1]]) == [0, 1, 3, 11, 5, 13, 7, 15, 9, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18]\n assert candidate(tasks = [[1, 1], [10, 2], [20, 3], [30, 4], [40, 5], [50, 6], [60, 7], [70, 8], [80, 9], [90, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]]) == [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(tasks = [[1000000000, 1], [1000000000, 2], [1000000000, 3], [1000000000, 4], [1000000000, 5]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0]]) == [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(tasks = [[1, 1], [1, 2], [1, 4], [1, 8], [1, 16], [1, 32], [1, 64], [1, 128], [1, 256], [1, 512]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10]\n assert candidate(tasks = [[5, 10], [10, 5], [15, 1], [20, 2], [25, 8], [30, 3], [35, 4], [40, 9], [45, 6], [50, 7]]) == [0, 2, 1, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1000000000], [2, 1000000000], [3, 1000000000], [4, 1000000000], [5, 1000000000], [6, 1000000000], [7, 1000000000], [8, 1000000000], [9, 1000000000], [10, 1000000000]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [1000000000, 1], [999999999, 2], [2, 2], [999999998, 3], [3, 3], [999999997, 4], [4, 4], [999999996, 5], [5, 5]]) == [0, 3, 5, 7, 9, 8, 1, 2, 4, 6]\n assert candidate(tasks = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [10, 2]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(tasks = [[1, 2], [1, 3], [2, 1], [2, 2], [3, 3], [3, 4], [4, 1], [4, 2], [5, 3], [5, 4], [6, 1], [6, 2], [7, 3], [7, 4], [8, 1], [8, 2], [9, 3], [9, 4], [10, 1], [10, 2]]) == [0, 2, 6, 3, 10, 14, 7, 18, 11, 15, 19, 1, 4, 8, 12, 16, 5, 9, 13, 17]\n assert candidate(tasks = [[1, 100], [2, 50], [3, 25], [4, 12], [5, 6], [6, 3], [7, 2], [8, 1]]) == [0, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(tasks = [[1, 20], [5, 10], [10, 5], [15, 2], [20, 1], [25, 1], [30, 1], [35, 1], [40, 1], [45, 1]]) == [0, 4, 3, 2, 5, 6, 1, 7, 8, 9]\n assert candidate(tasks = [[100, 100], [150, 100], [200, 100], [250, 100], [300, 100], [350, 100], [400, 100], [450, 100], [500, 100]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(tasks = [[1, 1], [3, 1], [5, 1], [7, 1], [9, 1], [11, 1], [13, 1], [15, 1], [17, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(tasks = [[3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [4, 1]]) == [0, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[2, 1], [4, 1], [6, 1], [8, 1], [10, 1], [1, 2], [3, 2], [5, 2], [7, 2], [9, 2], [11, 2], [13, 2], [15, 2], [17, 2], [19, 2]]) == [5, 0, 1, 6, 2, 3, 7, 4, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(tasks = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10], [1, 10]]) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(tasks = [[10, 10], [15, 5], [20, 1], [25, 2], [30, 3], [35, 4], [40, 5], [45, 6], [50, 7]]) == [0, 2, 1, 3, 4, 5, 6, 7, 8]\n assert candidate(tasks = [[1, 100], [10, 100], [20, 100], [30, 100], [40, 100], [50, 100], [60, 100], [70, 100], [80, 100], [90, 100]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [1, 2]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(tasks = [[1, 5], [3, 3], [5, 1], [7, 2], [9, 4], [11, 6], [13, 5], [15, 3], [17, 2], [19, 1]]) == [0, 2, 3, 1, 4, 7, 9, 8, 6, 5]\n assert candidate(tasks = [[1000000000, 1], [1000000000, 1], [1000000000, 1], [1000000000, 1], [1000000000, 1]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 10], [11, 1], [21, 1], [31, 1], [41, 1], [51, 1], [61, 1], [71, 1], [81, 1], [91, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[10, 1], [11, 2], [12, 3], [13, 4], [14, 5], [15, 6], [16, 7], [17, 8], [18, 9], [19, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 2], [1, 2], [1, 2], [1, 2], [1, 2], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1]]) == [0, 5, 6, 7, 8, 9, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 2], [10, 3], [20, 4], [30, 5], [40, 6], [50, 7], [60, 8], [70, 9], [80, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(tasks = [[1, 1], [1, 10], [1, 100], [1, 1000], [1, 10000], [1, 100000], [1, 1000000], [1, 10000000], [1, 100000000], [1, 1000000000]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[2, 1], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1], [2, 1], [3, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(tasks = [[1, 2], [3, 1], [5, 3], [7, 4], [9, 2], [11, 1], [13, 5], [15, 3], [17, 2], [19, 1]]) == [0, 1, 2, 3, 5, 4, 7, 8, 9, 6]\n assert candidate(tasks = [[9, 5], [1, 5], [8, 5], [3, 5], [2, 5], [4, 5], [6, 5], [7, 5], [10, 5], [11, 5]]) == [1, 3, 0, 2, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 2], [2, 1], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [10, 2], [100, 3], [1000, 4], [10000, 5], [100000, 6], [1000000, 7], [10000000, 8], [100000000, 9], [1000000000, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[10, 3], [20, 2], [30, 1], [40, 4], [50, 5], [60, 6]]) == [0, 1, 2, 3, 4, 5]\n assert candidate(tasks = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [2, 2], [4, 4], [6, 6], [8, 8], [10, 10]]) == [0, 5, 1, 6, 2, 7, 3, 8, 4, 9]\n assert candidate(tasks = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == [0, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(tasks = [[1, 10], [1, 9], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2], [1, 1], [2, 10], [2, 9], [2, 8], [2, 7], [2, 6], [2, 5], [2, 4], [2, 3], [2, 2], [2, 1]]) == [9, 19, 8, 18, 7, 17, 6, 16, 5, 15, 4, 14, 3, 13, 2, 12, 1, 11, 0, 10]\n assert candidate(tasks = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13], [15, 15], [17, 17], [19, 19]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 2], [2, 4], [3, 8], [4, 16], [5, 32], [6, 64], [7, 128], [8, 256], [9, 512], [10, 1024]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1], [10, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(tasks = [[1, 10], [10, 10], [20, 10], [30, 10], [40, 10], [50, 10]]) == [0, 1, 2, 3, 4, 5]\n assert candidate(tasks = [[1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1]]) == [0, 1, 3, 5, 7, 9, 2, 4, 6, 8]\n assert candidate(tasks = [[10, 2], [10, 2], [10, 2], [10, 2], [10, 2], [10, 2], [10, 2], [10, 2], [10, 2], [10, 2]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2], [1, 1], [2, 2]]) == [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]\n assert candidate(tasks = [[1, 1], [1, 1], [1, 2], [1, 2], [1, 3], [1, 3], [1, 4], [1, 4], [1, 5], [1, 5]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 1], [10, 1], [20, 1], [30, 1], [40, 1], [50, 1], [60, 1], [70, 1], [80, 1], [90, 1], [100, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(tasks = [[1, 10], [2, 5], [3, 15], [4, 20], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == [0, 4, 5, 6, 7, 8, 9, 1, 2, 3]\n assert candidate(tasks = [[1000000000, 1000000000], [1000000001, 1000000000], [1000000002, 1000000000], [1000000003, 1000000000], [1000000004, 1000000000]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 2], [3, 3], [5, 2], [7, 1], [9, 2], [11, 3], [13, 1], [15, 2], [17, 3], [19, 1], [21, 2], [23, 3], [25, 1], [27, 2], [29, 3]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(tasks = [[10, 1], [20, 1], [30, 1], [40, 1], [50, 1], [60, 1], [70, 1], [80, 1], [90, 1], [100, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 10], [5, 1], [3, 2], [2, 3], [7, 4], [6, 5], [8, 6], [9, 7], [10, 8]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(tasks = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(tasks = [[1, 1000000000], [2, 900000000], [3, 800000000], [4, 700000000], [5, 600000000], [6, 500000000], [7, 400000000], [8, 300000000], [9, 200000000], [10, 100000000]]) == [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(tasks = [[10, 10], [20, 5], [30, 15], [40, 1], [50, 20]]) == [0, 1, 2, 3, 4]\n assert candidate(tasks = [[1, 1], [2, 1], [1, 2], [2, 2], [1, 3], [2, 3], [1, 4], [2, 4], [1, 5], [2, 5]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(tasks = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(tasks = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28], [29, 30]]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(tasks = [[1, 9], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2], [1, 1]]) == [8, 7, 6, 5, 4, 3, 2, 1, 0]\n assert candidate(tasks = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [11, 10], [12, 9], [13, 8], [14, 7], [15, 6], [16, 5], [17, 4], [18, 3], [19, 2], [20, 1]]) == [0, 9, 8, 7, 6, 19, 18, 17, 16, 5, 15, 4, 14, 3, 13, 2, 12, 1, 11, 10]\n"}, "metadata": {"canonical_parameter_names": ["tasks"], "leetcode_dataset_entry_point": "Solution().getOrder", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector getOrder(vector>& tasks) {", "container": "Solution", "callable": "getOrder", "parameters": [{"name": "tasks", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1835, "task_id": "find-xor-sum-of-all-pairs-bitwise-and", "difficulty": "Hard", "problem_description": "The XOR sum of a list is the bitwise XOR of all its elements. If the list only contains one element, then its XOR sum will be equal to this element.\n\nFor example, the XOR sum of [1,2,3,4] is equal to 1 XOR 2 XOR 3 XOR 4 = 4, and the XOR sum of [3] is equal to 3.\n\nYou are given two 0-indexed arrays arr1 and arr2 that consist only of non-negative integers.\nConsider the list containing the result of arr1[i] AND arr2[j] (bitwise AND) for every (i, j) pair where 0 <= i < arr1.length and 0 <= j < arr2.length.\nReturn the XOR sum of the aforementioned list.\n \nExample 1:\n\nInput: arr1 = [1,2,3], arr2 = [6,5]\nOutput: 0\nExplanation: The list = [1 AND 6, 1 AND 5, 2 AND 6, 2 AND 5, 3 AND 6, 3 AND 5] = [0,1,2,0,2,1].\nThe XOR sum = 0 XOR 1 XOR 2 XOR 0 XOR 2 XOR 1 = 0.\n\nExample 2:\n\nInput: arr1 = [12], arr2 = [4]\nOutput: 4\nExplanation: The list = [12 AND 4] = [4]. The XOR sum = 4.\n\n \nConstraints:\n\n1 <= arr1.length, arr2.length <= 105\n0 <= arr1[i], arr2[j] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr1 = [1, 2, 3],arr2 = [6, 5]) == 0\n assert candidate(arr1 = [1, 1, 1, 1, 1],arr2 = [1, 1, 1, 1, 1]) == 1\n assert candidate(arr1 = [1, 3, 5, 7, 9],arr2 = [2, 4, 6, 8, 10]) == 0\n assert candidate(arr1 = [1000000000],arr2 = [1000000000]) == 1000000000\n assert candidate(arr1 = [0, 0, 0],arr2 = [0, 0, 0]) == 0\n assert candidate(arr1 = [255, 128, 64],arr2 = [32, 16, 8]) == 56\n assert candidate(arr1 = [1000000000, 500000000],arr2 = [500000000, 1000000000]) == 643280640\n assert candidate(arr1 = [255, 128, 64, 32, 16],arr2 = [1, 3, 7, 15, 31]) == 5\n assert candidate(arr1 = [0, 1, 2, 3, 4],arr2 = [0, 1, 2, 3, 4]) == 4\n assert candidate(arr1 = [255, 128, 64, 32],arr2 = [1, 2, 4, 8]) == 15\n assert candidate(arr1 = [0, 1, 2, 3, 4],arr2 = [4, 3, 2, 1, 0]) == 4\n assert candidate(arr1 = [12],arr2 = [4]) == 4\n assert candidate(arr1 = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],arr2 = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 13\n assert candidate(arr1 = [8, 16, 32, 64, 128, 256, 512],arr2 = [1024, 2048, 4096, 8192]) == 0\n assert candidate(arr1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],arr2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15],arr2 = [2, 4, 6, 8, 10, 12, 14, 16]) == 0\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 484\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 11\n assert candidate(arr1 = [1023, 2047, 4095],arr2 = [8191, 16383, 32767]) == 3071\n assert candidate(arr1 = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127],arr2 = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 640\n assert candidate(arr1 = [123456789, 987654321, 1122334455, 5544332211],arr2 = [123, 456, 789, 987, 654, 321]) == 160\n assert candidate(arr1 = [5, 10, 15, 20, 25],arr2 = [30, 35, 40, 45, 50]) == 8\n assert candidate(arr1 = [7, 14, 21, 28, 35],arr2 = [42, 49, 56, 63, 70]) == 2\n assert candidate(arr1 = [11235813, 21345589, 34558914, 55891442],arr2 = [832040, 1346269, 2178309, 3524578]) == 279040\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(arr1 = [1023, 512, 256, 128, 64],arr2 = [32, 16, 8, 4, 2, 1]) == 63\n assert candidate(arr1 = [987654321, 234567890],arr2 = [135792468, 864201357]) == 855638081\n assert candidate(arr1 = [13, 29, 42, 57, 71],arr2 = [88, 99, 101, 113, 131]) == 4\n assert candidate(arr1 = [1],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],arr2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 0\n assert candidate(arr1 = [1000000000, 500000000, 250000000, 125000000, 62500000],arr2 = [1, 3, 5, 7, 9]) == 0\n assert candidate(arr1 = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 8\n assert candidate(arr1 = [23, 45, 67, 89, 101],arr2 = [113, 131, 149, 167]) == 64\n assert candidate(arr1 = [29, 18, 7, 2, 11],arr2 = [19, 23, 31, 37, 41]) == 1\n assert candidate(arr1 = [1000000, 2000000, 3000000],arr2 = [1000, 2000, 3000, 4000, 5000]) == 0\n assert candidate(arr1 = [1, 2, 4, 8, 16, 32],arr2 = [64, 128, 256, 512, 1024]) == 0\n assert candidate(arr1 = [1, 3, 7, 15, 31, 63, 127, 255],arr2 = [255, 127, 63, 31, 15, 7, 3, 1]) == 170\n assert candidate(arr1 = [15, 31, 63, 127, 255],arr2 = [255, 127, 63, 31, 15]) == 175\n assert candidate(arr1 = [7, 14, 21, 28, 35],arr2 = [8, 16, 24, 32, 40]) == 0\n assert candidate(arr1 = [1, 2, 4, 8, 16, 32, 64, 128],arr2 = [128, 64, 32, 16, 8, 4, 2, 1]) == 255\n assert candidate(arr1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048],arr2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(arr1 = [999999999, 999999998, 999999997, 999999996, 999999995],arr2 = [999999994, 999999993, 999999992, 999999991, 999999990]) == 999999994\n assert candidate(arr1 = [314159265, 271828182, 8675309],arr2 = [161803398, 141421356, 423606797]) == 403842\n assert candidate(arr1 = [17, 34, 51, 68, 85],arr2 = [1, 2, 4, 8, 16]) == 17\n assert candidate(arr1 = [1, 0, 1, 0, 1, 0],arr2 = [1024, 2048, 4096, 8192, 16384, 32768]) == 0\n assert candidate(arr1 = [123456789, 987654321, 1122334455, 5544332211, 9876543210],arr2 = [123, 456, 789, 101112, 131415]) == 198664\n assert candidate(arr1 = [2147483647, 2147483646, 2147483645],arr2 = [2147483644, 2147483643, 2147483642]) == 2147483644\n assert candidate(arr1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],arr2 = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 682\n assert candidate(arr1 = [123456789, 987654321],arr2 = [111111111, 222222222, 333333333]) == 403023108\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [1]) == 1\n assert candidate(arr1 = [255, 192, 128, 64, 32],arr2 = [16, 8, 4, 2, 1]) == 31\n assert candidate(arr1 = [134217728, 67108864, 33554432, 16777216, 8388608, 4194304, 2097152],arr2 = [512, 256, 128, 64, 32, 16]) == 0\n assert candidate(arr1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],arr2 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(arr1 = [1, 1, 1, 1],arr2 = [2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(arr1 = [1023, 511, 255, 127, 63],arr2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 703\n assert candidate(arr1 = [13, 14, 15],arr2 = [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 12\n assert candidate(arr1 = [1000000000, 2000000000, 3000000000],arr2 = [4000000000, 5000000000]) == 3295543296\n assert candidate(arr1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],arr2 = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 2047\n assert candidate(arr1 = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],arr2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 2097151\n assert candidate(arr1 = [1000000000, 500000000, 250000000, 125000000],arr2 = [2, 3, 5, 7]) == 0\n assert candidate(arr1 = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],arr2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 682\n assert candidate(arr1 = [2, 4, 6, 8, 10],arr2 = [3, 6, 9, 12, 15]) == 2\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(arr1 = [1023, 2047, 4095, 8191],arr2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 1024\n assert candidate(arr1 = [0, 0, 0, 0, 0],arr2 = [1, 3, 5, 7, 9]) == 0\n assert candidate(arr1 = [29, 31, 37, 41, 43],arr2 = [47, 53, 59, 61, 67, 71]) == 0\n assert candidate(arr1 = [31, 63, 127, 255],arr2 = [255, 127, 63, 31]) == 160\n assert candidate(arr1 = [2, 4, 6, 8, 10, 12, 14, 16],arr2 = [1, 3, 5, 7, 9, 11, 13, 15]) == 0\n assert candidate(arr1 = [2147483647, 2147483647],arr2 = [2147483647, 2147483647]) == 0\n assert candidate(arr1 = [234, 456, 789, 1024],arr2 = [123, 234, 345, 456]) == 0\n assert candidate(arr1 = [987654321, 123456789, 456789123],arr2 = [987654321, 123456789, 456789123]) == 650094887\n assert candidate(arr1 = [123456, 654321, 987654, 321654],arr2 = [789456, 123789, 456789]) == 196608\n assert candidate(arr1 = [0, 0, 0, 0, 0],arr2 = [0, 0, 0, 0, 0]) == 0\n assert candidate(arr1 = [23, 45, 67, 89, 123],arr2 = [56, 78, 90, 101, 112]) == 25\n assert candidate(arr1 = [100, 200, 300, 400, 500],arr2 = [600, 700, 800, 900, 1000]) == 416\n assert candidate(arr1 = [1000000007, 1000000008, 1000000009, 1000000010, 1000000011],arr2 = [1000000012, 1000000013, 1000000014, 1000000015, 1000000016]) == 1000000000\n assert candidate(arr1 = [7, 8, 9, 10, 11],arr2 = [12, 13, 14, 15, 16]) == 0\n assert candidate(arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(arr1 = [15, 30, 45, 60, 75, 90],arr2 = [10, 20, 30, 40, 50, 60]) == 0\n assert candidate(arr1 = [15, 27, 45, 63],arr2 = [31, 63, 95, 127]) == 0\n assert candidate(arr1 = [4294967295, 2147483647, 1073741823, 536870911],arr2 = [268435455, 134217727, 67108863, 33554431]) == 0\n assert candidate(arr1 = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31],arr2 = [31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17]) == 16\n assert candidate(arr1 = [2147483647, 1073741823, 536870911, 268435455, 134217727],arr2 = [858993459, 429496729, 214748364, 107374182, 53687091]) == 53687091\n assert candidate(arr1 = [1000000000, 999999999, 888888888],arr2 = [777777777, 666666666, 555555555]) == 553274368\n assert candidate(arr1 = [123456789, 987654321, 111111111],arr2 = [222222222, 333333333, 444444444]) == 1575491\n assert candidate(arr1 = [13, 21, 34, 55, 89, 144, 233, 377, 610, 987],arr2 = [1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393]) == 1\n assert candidate(arr1 = [1048576, 2097152, 4194304],arr2 = [1, 3, 5, 7]) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],arr2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 0\n assert candidate(arr1 = [0, 0, 0, 0],arr2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(arr1 = [255, 0, 127, 63, 31],arr2 = [255, 128, 64, 32, 16]) == 0\n assert candidate(arr1 = [314159265],arr2 = [271828182]) == 271679616\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15],arr2 = [1, 2, 4, 8, 16, 32, 64, 128]) == 0\n assert candidate(arr1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],arr2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 2\n assert candidate(arr1 = [1000000000, 500000000, 250000000],arr2 = [1000000000, 500000000, 250000000]) == 682696064\n assert candidate(arr1 = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],arr2 = [512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 682\n assert candidate(arr1 = [123456789, 987654321, 135792468],arr2 = [246813579, 864204864, 975318642]) == 85229744\n assert candidate(arr1 = [1048575, 524287, 262143, 131071, 65535],arr2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 720895\n assert candidate(arr1 = [1000000000, 999999999, 999999998],arr2 = [999999997, 999999996, 999999995]) == 999999488\n assert candidate(arr1 = [123456789, 987654321],arr2 = [234567891, 123456789]) == 142648708\n assert candidate(arr1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],arr2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(arr1 = [1000000000, 500000000, 250000000, 125000000],arr2 = [2, 4, 8, 16]) == 0\n assert candidate(arr1 = [256, 512, 768, 1024],arr2 = [1, 2, 4, 8, 16]) == 0\n assert candidate(arr1 = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1],arr2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 682\n"}, "metadata": {"canonical_parameter_names": ["arr1", "arr2"], "leetcode_dataset_entry_point": "Solution().getXORSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int getXORSum(vector& arr1, vector& arr2) {", "container": "Solution", "callable": "getXORSum", "parameters": [{"name": "arr1", "type": "vector&"}, {"name": "arr2", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1837, "task_id": "sum-of-digits-in-base-k", "difficulty": "Easy", "problem_description": "Given an integer n (in base 10) and a base k, return the sum of the digits of n after converting n from base 10 to base k.\nAfter converting, each digit should be interpreted as a base 10 number, and the sum should be returned in base 10.\n \nExample 1:\n\nInput: n = 34, k = 6\nOutput: 9\nExplanation: 34 (base 10) expressed in base 6 is 54. 5 + 4 = 9.\n\nExample 2:\n\nInput: n = 10, k = 10\nOutput: 1\nExplanation: n is already in base 10. 1 + 0 = 1.\n\n \nConstraints:\n\n1 <= n <= 100\n2 <= k <= 10\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 64,k = 2) == 1\n assert candidate(n = 7,k = 3) == 3\n assert candidate(n = 42,k = 5) == 6\n assert candidate(n = 50,k = 4) == 5\n assert candidate(n = 100,k = 3) == 4\n assert candidate(n = 10,k = 10) == 1\n assert candidate(n = 50,k = 7) == 2\n assert candidate(n = 99,k = 9) == 3\n assert candidate(n = 81,k = 9) == 1\n assert candidate(n = 34,k = 6) == 9\n assert candidate(n = 8,k = 2) == 1\n assert candidate(n = 45,k = 3) == 3\n assert candidate(n = 25,k = 2) == 3\n assert candidate(n = 81,k = 3) == 1\n assert candidate(n = 64,k = 10) == 10\n assert candidate(n = 27,k = 5) == 3\n assert candidate(n = 100,k = 2) == 3\n assert candidate(n = 1,k = 2) == 1\n assert candidate(n = 100,k = 4) == 4\n assert candidate(n = 72,k = 8) == 2\n assert candidate(n = 50,k = 5) == 2\n assert candidate(n = 17,k = 8) == 3\n assert candidate(n = 91,k = 8) == 7\n assert candidate(n = 73,k = 4) == 4\n assert candidate(n = 85,k = 7) == 7\n assert candidate(n = 63,k = 9) == 7\n assert candidate(n = 100,k = 7) == 4\n assert candidate(n = 63,k = 5) == 7\n assert candidate(n = 37,k = 5) == 5\n assert candidate(n = 95,k = 9) == 7\n assert candidate(n = 63,k = 7) == 3\n assert candidate(n = 55,k = 7) == 7\n assert candidate(n = 31,k = 5) == 3\n assert candidate(n = 32,k = 2) == 1\n assert candidate(n = 42,k = 4) == 6\n assert candidate(n = 19,k = 4) == 4\n assert candidate(n = 55,k = 6) == 5\n assert candidate(n = 100,k = 5) == 4\n assert candidate(n = 15,k = 6) == 5\n assert candidate(n = 45,k = 7) == 9\n assert candidate(n = 84,k = 4) == 3\n assert candidate(n = 31,k = 10) == 4\n assert candidate(n = 45,k = 6) == 5\n assert candidate(n = 97,k = 5) == 9\n assert candidate(n = 45,k = 10) == 9\n assert candidate(n = 50,k = 8) == 8\n assert candidate(n = 67,k = 5) == 7\n assert candidate(n = 37,k = 2) == 3\n assert candidate(n = 67,k = 7) == 7\n assert candidate(n = 29,k = 3) == 3\n assert candidate(n = 50,k = 6) == 5\n assert candidate(n = 72,k = 5) == 8\n assert candidate(n = 37,k = 6) == 2\n assert candidate(n = 85,k = 3) == 3\n assert candidate(n = 88,k = 3) == 4\n assert candidate(n = 64,k = 3) == 4\n assert candidate(n = 64,k = 4) == 1\n assert candidate(n = 95,k = 6) == 10\n assert candidate(n = 67,k = 3) == 5\n assert candidate(n = 100,k = 10) == 1\n assert candidate(n = 81,k = 5) == 5\n assert candidate(n = 55,k = 5) == 3\n assert candidate(n = 98,k = 2) == 3\n assert candidate(n = 58,k = 7) == 4\n assert candidate(n = 48,k = 4) == 3\n assert candidate(n = 31,k = 2) == 5\n assert candidate(n = 81,k = 8) == 4\n assert candidate(n = 42,k = 7) == 6\n assert candidate(n = 27,k = 9) == 3\n assert candidate(n = 77,k = 7) == 5\n assert candidate(n = 29,k = 8) == 8\n assert candidate(n = 97,k = 10) == 16\n assert candidate(n = 77,k = 4) == 5\n assert candidate(n = 13,k = 6) == 3\n assert candidate(n = 49,k = 9) == 9\n assert candidate(n = 55,k = 10) == 10\n assert candidate(n = 41,k = 4) == 5\n assert candidate(n = 98,k = 6) == 8\n assert candidate(n = 50,k = 3) == 6\n assert candidate(n = 85,k = 5) == 5\n assert candidate(n = 73,k = 8) == 3\n assert candidate(n = 100,k = 9) == 4\n assert candidate(n = 77,k = 8) == 7\n assert candidate(n = 85,k = 4) == 4\n assert candidate(n = 99,k = 3) == 3\n assert candidate(n = 29,k = 4) == 5\n assert candidate(n = 72,k = 6) == 2\n"}, "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().sumBase", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int sumBase(int n, int k) {", "container": "Solution", "callable": "sumBase", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1838, "task_id": "frequency-of-the-most-frequent-element", "difficulty": "Medium", "problem_description": "The frequency of an element is the number of times it occurs in an array.\nYou are given an integer array nums and an integer k. In one operation, you can choose an index of nums and increment the element at that index by 1.\nReturn the maximum possible frequency of an element after performing at most k operations.\n \nExample 1:\n\nInput: nums = [1,2,4], k = 5\nOutput: 3\nExplanation: Increment the first element three times and the second element two times to make nums = [4,4,4].\n4 has a frequency of 3.\nExample 2:\n\nInput: nums = [1,4,8,13], k = 5\nOutput: 2\nExplanation: There are multiple optimal solutions:\n- Increment the first element three times to make nums = [4,4,8,13]. 4 has a frequency of 2.\n- Increment the second element four times to make nums = [1,8,8,13]. 8 has a frequency of 2.\n- Increment the third element five times to make nums = [1,4,13,13]. 13 has a frequency of 2.\n\nExample 3:\n\nInput: nums = [3,9,6], k = 2\nOutput: 1\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 105\n1 <= k <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 4],k = 5) == 3\n assert candidate(nums = [100000, 100000, 100000],k = 300000) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 25) == 7\n assert candidate(nums = [1, 1, 1, 1],k = 0) == 4\n assert candidate(nums = [5, 5, 5, 5, 5],k = 10) == 5\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4],k = 7) == 6\n assert candidate(nums = [1, 1, 1, 1, 1],k = 10) == 5\n assert candidate(nums = [3, 9, 6],k = 2) == 1\n assert candidate(nums = [1, 1, 1, 1, 1],k = 5) == 5\n assert candidate(nums = [1, 1, 1],k = 0) == 3\n assert candidate(nums = [1, 100000],k = 100000) == 2\n assert candidate(nums = [1, 2, 2, 4],k = 6) == 3\n assert candidate(nums = [1, 4, 8, 13],k = 5) == 2\n assert candidate(nums = [1, 100000],k = 99999) == 2\n assert candidate(nums = [5, 5, 5, 5, 5],k = 0) == 5\n assert candidate(nums = [100000, 100000, 100000],k = 100000) == 3\n assert candidate(nums = [5, 9, 11, 13, 15],k = 10) == 3\n assert candidate(nums = [1, 2, 3, 4, 5],k = 10) == 5\n assert candidate(nums = [1, 2, 2, 3, 3, 3],k = 6) == 6\n assert candidate(nums = [1, 2, 2, 4],k = 3) == 3\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 10) == 10\n assert candidate(nums = [1, 1, 1, 1],k = 10) == 4\n assert candidate(nums = [1, 2, 3, 4, 5],k = 15) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 50) == 20\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 200) == 9\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 150) == 8\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 50) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 45) == 10\n assert candidate(nums = [2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5],k = 150) == 21\n assert candidate(nums = [5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 9],k = 50) == 15\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 15) == 10\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],k = 75) == 20\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6],k = 40) == 19\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 1000) == 14\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 55) == 7\n assert candidate(nums = [1, 3, 6, 10, 15],k = 25) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 6\n assert candidate(nums = [5, 7, 7, 8, 8, 10, 10, 10, 10],k = 30) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 50) == 10\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 100) == 20\n assert candidate(nums = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999],k = 500000) == 10\n assert candidate(nums = [5, 7, 7, 8, 8, 10, 10, 10, 12, 12, 12, 12],k = 30) == 11\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 10) == 7\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5],k = 100) == 20\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100000],k = 199999) == 19\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000],k = 500000) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 150) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 50) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5],k = 10) == 10\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 9],k = 30) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 60) == 25\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 20\n assert candidate(nums = [1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 1000) == 10\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],k = 60) == 20\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 100) == 10\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],k = 30) == 17\n assert candidate(nums = [10, 20, 30, 40, 50],k = 100) == 5\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000],k = 100000) == 5\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 0) == 10\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 100) == 10\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 50) == 10\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50],k = 100) == 7\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 200) == 14\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 50) == 18\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 100) == 20\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 1500) == 17\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4],k = 50) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 200) == 20\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 100) == 10\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101],k = 500) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 200) == 20\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0) == 15\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4],k = 20) == 10\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 3000) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1000) == 20\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 100) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 50) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 100) == 10\n assert candidate(nums = [1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 100) == 40\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 300) == 17\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 100) == 14\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 100) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 150) == 17\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50],k = 100) == 6\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7],k = 100) == 21\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],k = 200) == 30\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 20) == 14\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],k = 50000) == 10\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20],k = 200) == 29\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 15) == 13\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 250) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 100) == 14\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 500) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 100) == 14\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000],k = 500000) == 5\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5],k = 50) == 20\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 12\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maxFrequency", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxFrequency(vector& nums, int k) {", "container": "Solution", "callable": "maxFrequency", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1839, "task_id": "longest-substring-of-all-vowels-in-order", "difficulty": "Medium", "problem_description": "A string is considered beautiful if it satisfies the following conditions:\n\nEach of the 5 English vowels ('a', 'e', 'i', 'o', 'u') must appear at least once in it.\nThe letters must be sorted in alphabetical order (i.e. all 'a's before 'e's, all 'e's before 'i's, etc.).\n\nFor example, strings \"aeiou\" and \"aaaaaaeiiiioou\" are considered beautiful, but \"uaeio\", \"aeoiu\", and \"aaaeeeooo\" are not beautiful.\nGiven a string word consisting of English vowels, return the length of the longest beautiful substring of word. If no such substring exists, return 0.\nA substring is a contiguous sequence of characters in a string.\n \nExample 1:\n\nInput: word = \"aeiaaioaaaaeiiiiouuuooaauuaeiu\"\nOutput: 13\nExplanation: The longest beautiful substring in word is \"aaaaeiiiiouuu\" of length 13.\nExample 2:\n\nInput: word = \"aeeeiiiioooauuuaeiou\"\nOutput: 5\nExplanation: The longest beautiful substring in word is \"aeiou\" of length 5.\n\nExample 3:\n\nInput: word = \"a\"\nOutput: 0\nExplanation: There is no beautiful substring, so return 0.\n\n \nConstraints:\n\n1 <= word.length <= 5 * 105\nword consists of characters 'a', 'e', 'i', 'o', and 'u'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"aeiaaioaaaaeiiaaaiiiiiouuuooaauuaeiuuuuuuuuuuuuuuuuuuuuaaa\") == 0\n assert candidate(word = \"aeiaaioaaaaeiiaaaiiiiiouuuaauuaeiu\") == 0\n assert candidate(word = \"aeiaaioaaaaeiiaaaiiiiiouuuuuuuuuuuuuuuuuuuuaaaaaaeiou\") == 10\n assert candidate(word = \"aeiaaioaaaaeiioooaeiouuuaeiouuu\") == 7\n assert candidate(word = \"aeeeiiiioooauuuaeiou\") == 5\n assert candidate(word = \"aeiaaioaaaaeiiiiouuuuuaaaaaaaaaeeeeiiiioooouuuuuu\") == 27\n assert candidate(word = \"aeiaaioaaaaeiiaaaiiiiiouuuooaaeiouaaaaaaaaaaeiouuuuuuuuuuuuuuuuuuuu\") == 33\n assert candidate(word = \"aeiaaioaaaaeiioooaeiouuuaeiouuuaeiouuu\") == 7\n assert candidate(word = \"aeiaaioaaaaeiiaaaouuuooauuaeiu\") == 0\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiou\") == 5\n assert candidate(word = \"aaaaaaaaaeeeeeeeeeeiiiiiiioooooouuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu\") == 68\n assert candidate(word = \"aeiaaioaaaaeiioooaeiouuu\") == 7\n assert candidate(word = \"aeiaaioaaaaeiiooouuuaeiou\") == 13\n assert candidate(word = \"a\") == 0\n assert candidate(word = \"aeiou\") == 5\n assert candidate(word = \"aeiaaioaaaaeiiaaaiiiiiouuuuuuuuuuuuuuuuuuuu\") == 0\n assert candidate(word = \"aeiaaioaaaaeiiaaaouuuooaauuaeiaaioaaaaeiiiiouuuooaauuaeiu\") == 13\n assert candidate(word = \"aeiaaioaaaaeiiiiouuuooaauuaeiu\") == 13\n assert candidate(word = \"aeiaaioaaaaeiiooouuuooauuaeiu\") == 13\n assert candidate(word = \"uuuuuuuuuuuuuuuuuuuu\") == 0\n"}, "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().longestBeautifulSubstring", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int longestBeautifulSubstring(string word) {", "container": "Solution", "callable": "longestBeautifulSubstring", "parameters": [{"name": "word", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1840, "task_id": "maximum-building-height", "difficulty": "Hard", "problem_description": "You want to build n new buildings in a city. The new buildings will be built in a line and are labeled from 1 to n.\nHowever, there are city restrictions on the heights of the new buildings:\n\nThe height of each building must be a non-negative integer.\nThe height of the first building must be 0.\nThe height difference between any two adjacent buildings cannot exceed 1.\n\nAdditionally, there are city restrictions on the maximum height of specific buildings. These restrictions are given as a 2D integer array restrictions where restrictions[i] = [idi, maxHeighti] indicates that building idi must have a height less than or equal to maxHeighti.\nIt is guaranteed that each building will appear at most once in restrictions, and building 1 will not be in restrictions.\nReturn the maximum possible height of the tallest building.\n \nExample 1:\n\n\nInput: n = 5, restrictions = [[2,1],[4,1]]\nOutput: 2\nExplanation: The green area in the image indicates the maximum allowed height for each building.\nWe can build the buildings with heights [0,1,2,1,2], and the tallest building has a height of 2.\nExample 2:\n\n\nInput: n = 6, restrictions = []\nOutput: 5\nExplanation: The green area in the image indicates the maximum allowed height for each building.\nWe can build the buildings with heights [0,1,2,3,4,5], and the tallest building has a height of 5.\n\nExample 3:\n\n\nInput: n = 10, restrictions = [[5,3],[2,5],[7,4],[10,3]]\nOutput: 5\nExplanation: The green area in the image indicates the maximum allowed height for each building.\nWe can build the buildings with heights [0,1,2,3,3,4,4,5,4,3], and the tallest building has a height of 5.\n\n \nConstraints:\n\n2 <= n <= 109\n0 <= restrictions.length <= min(n - 1, 105)\n2 <= idi <= n\nidi is unique.\n0 <= maxHeighti <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 6,restrictions = []) == 5\n assert candidate(n = 5,restrictions = [[2, 1], [4, 1]]) == 2\n assert candidate(n = 100,restrictions = [[10, 5], [50, 25], [90, 10]]) == 37\n assert candidate(n = 1000000,restrictions = [[500000, 500000]]) == 999999\n assert candidate(n = 10,restrictions = [[5, 3], [2, 5], [7, 4], [10, 3]]) == 5\n assert candidate(n = 100000,restrictions = [[1000, 50], [2000, 100], [3000, 150], [4000, 200], [5000, 250], [6000, 300], [7000, 350], [8000, 400], [9000, 450]]) == 91450\n assert candidate(n = 20,restrictions = [[5, 3], [6, 2], [7, 1], [8, 0], [9, 1], [10, 2], [11, 3], [12, 4], [13, 5], [14, 6], [15, 7]]) == 12\n assert candidate(n = 1000,restrictions = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5], [600, 6], [700, 7], [800, 8], [900, 9]]) == 109\n assert candidate(n = 200,restrictions = [[20, 100], [40, 50], [60, 75], [80, 25], [100, 100], [120, 75], [140, 50], [160, 25], [180, 0], [200, 100]]) == 62\n assert candidate(n = 100,restrictions = [[10, 5], [30, 5], [50, 5], [70, 5], [90, 5]]) == 15\n assert candidate(n = 1000000,restrictions = [[500000, 1], [500001, 1], [500002, 1], [500003, 1], [500004, 1], [500005, 1], [500006, 1], [500007, 1], [500008, 1]]) == 499993\n assert candidate(n = 10000,restrictions = [[2000, 1000], [4000, 1500], [6000, 2000], [8000, 2500]]) == 4500\n assert candidate(n = 200,restrictions = [[5, 3], [10, 2], [15, 1], [20, 2], [25, 3], [30, 2], [35, 1], [40, 2], [45, 3], [50, 2], [55, 1], [60, 2], [65, 3], [70, 2], [75, 1], [80, 2], [85, 3], [90, 2], [95, 1], [100, 2], [105, 3], [110, 2], [115, 1], [120, 2], [125, 3], [130, 2], [135, 1], [140, 2], [145, 3], [150, 2], [155, 1], [160, 2], [165, 3], [170, 2], [175, 1], [180, 2], [185, 3], [190, 2], [195, 1]]) == 6\n assert candidate(n = 100,restrictions = [[10, 9], [20, 8], [30, 7], [40, 6], [50, 5], [60, 4], [70, 3], [80, 2], [90, 1]]) == 13\n assert candidate(n = 5000,restrictions = [[50, 1000], [100, 900], [150, 800], [200, 700], [250, 600], [300, 500], [350, 400], [400, 300], [450, 200], [500, 100]]) == 4600\n assert candidate(n = 20,restrictions = [[2, 3], [5, 4], [8, 1], [15, 5], [18, 2]]) == 6\n assert candidate(n = 100,restrictions = [[10, 5], [20, 10], [30, 3], [40, 15], [50, 5], [60, 20], [70, 7], [80, 12], [90, 10], [100, 2]]) == 16\n assert candidate(n = 20,restrictions = [[3, 2], [6, 3], [9, 2], [15, 5], [18, 4]]) == 6\n assert candidate(n = 10000,restrictions = [[1000, 5000], [2000, 10000], [3000, 15000], [4000, 20000], [5000, 25000], [6000, 30000], [7000, 35000], [8000, 40000], [9000, 45000], [10000, 50000]]) == 9999\n assert candidate(n = 999,restrictions = [[999, 1]]) == 499\n assert candidate(n = 1000000000,restrictions = [[100000000, 10000000], [200000000, 20000000], [300000000, 30000000], [400000000, 40000000]]) == 640000000\n assert candidate(n = 1000000,restrictions = [[999999, 999999]]) == 999999\n assert candidate(n = 50,restrictions = [[3, 2], [5, 3], [10, 5], [15, 7], [20, 9], [25, 11], [30, 13], [35, 15], [40, 17], [45, 19], [50, 21]]) == 22\n assert candidate(n = 20,restrictions = [[3, 3], [6, 2], [9, 5], [15, 4]]) == 9\n assert candidate(n = 1000,restrictions = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45], [100, 50]]) == 950\n assert candidate(n = 500000,restrictions = [[50000, 100000], [100000, 150000], [150000, 200000], [200000, 250000], [250000, 300000]]) == 499999\n assert candidate(n = 10000,restrictions = [[1000, 500], [2000, 1000], [3000, 1500], [4000, 2000], [5000, 2500], [6000, 3000], [7000, 3500], [8000, 4000], [9000, 4500], [10000, 5000]]) == 5250\n assert candidate(n = 1000000,restrictions = [[2, 1], [4, 1], [6, 1], [8, 1], [10, 1], [12, 1], [14, 1], [16, 1], [18, 1], [20, 1]]) == 999981\n assert candidate(n = 100000,restrictions = [[10000, 5000], [30000, 15000], [50000, 25000], [70000, 30000], [90000, 35000]]) == 45000\n assert candidate(n = 1000000,restrictions = [[2, 500000], [3, 500000], [4, 500000], [5, 500000], [6, 500000], [7, 500000], [8, 500000], [9, 500000], [10, 500000]]) == 999999\n assert candidate(n = 50000000,restrictions = [[10000000, 20000000], [20000000, 10000000], [30000000, 15000000], [40000000, 5000000], [50000000, 25000000]]) == 17500000\n assert candidate(n = 500000,restrictions = [[100000, 150000], [200000, 250000], [300000, 350000], [400000, 450000]]) == 499999\n assert candidate(n = 150,restrictions = [[15, 15], [30, 30], [45, 45], [60, 60], [75, 75], [90, 90], [105, 105], [120, 120], [135, 135], [150, 150]]) == 149\n assert candidate(n = 1000,restrictions = [[50, 50], [100, 100], [150, 150], [200, 200], [250, 250], [300, 300], [350, 350], [400, 400], [450, 450], [500, 500], [550, 550], [600, 600], [650, 650], [700, 700], [750, 750], [800, 800], [850, 850], [900, 900], [950, 950], [1000, 1000]]) == 999\n assert candidate(n = 5000,restrictions = [[1000, 500], [2000, 1000], [3000, 1500], [4000, 2000]]) == 3000\n assert candidate(n = 1000,restrictions = [[100, 900], [200, 800], [300, 700], [400, 600], [500, 500], [600, 400], [700, 300], [800, 200], [900, 100]]) == 499\n assert candidate(n = 100,restrictions = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25]]) == 75\n assert candidate(n = 50,restrictions = [[5, 4], [10, 3], [15, 2], [20, 1], [25, 0], [30, 1], [35, 2], [40, 3], [45, 4], [50, 5]]) == 7\n assert candidate(n = 1000,restrictions = [[50, 100], [150, 100], [250, 100], [350, 100], [450, 100], [550, 100], [650, 100], [750, 100], [850, 100], [950, 100]]) == 150\n assert candidate(n = 1000,restrictions = [[500, 500], [250, 250], [750, 750], [100, 100], [900, 900]]) == 999\n assert candidate(n = 100000,restrictions = [[1000, 500], [5000, 2500], [10000, 5000], [25000, 10000], [50000, 15000], [75000, 10000], [90000, 5000], [95000, 1000]]) == 25000\n assert candidate(n = 100,restrictions = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45]]) == 55\n assert candidate(n = 100,restrictions = [[10, 10], [20, 15], [30, 20], [40, 10], [50, 25], [60, 20], [70, 15], [80, 10], [90, 5]]) == 25\n assert candidate(n = 100,restrictions = [[3, 20], [50, 10], [90, 5]]) == 29\n assert candidate(n = 100,restrictions = [[10, 1], [20, 1], [30, 1], [40, 1], [50, 1], [60, 1], [70, 1], [80, 1], [90, 1]]) == 11\n assert candidate(n = 10000,restrictions = [[500, 1000], [2500, 2000], [5000, 3000], [7500, 2000], [9500, 1000]]) == 3750\n assert candidate(n = 100,restrictions = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45], [100, 50]]) == 52\n assert candidate(n = 1000000000,restrictions = [[100000000, 99999999], [200000000, 88888888], [300000000, 77777777], [400000000, 66666666], [500000000, 55555555]]) == 555555555\n assert candidate(n = 20,restrictions = [[2, 3], [4, 2], [6, 3], [8, 2], [10, 3], [12, 2], [14, 3], [16, 2], [18, 3]]) == 5\n assert candidate(n = 200,restrictions = [[20, 1], [40, 3], [60, 5], [80, 7], [100, 9], [120, 11], [140, 13], [160, 15], [180, 17]]) == 37\n assert candidate(n = 50,restrictions = [[5, 25], [10, 15], [20, 30], [35, 20], [45, 10]]) == 27\n assert candidate(n = 1000000,restrictions = [[100000, 50000], [200000, 100000], [300000, 75000], [400000, 25000], [500000, 100000]]) == 600000\n assert candidate(n = 1000000,restrictions = [[50000, 100000], [100000, 200000], [150000, 300000], [200000, 400000], [250000, 500000], [300000, 400000], [350000, 300000], [400000, 200000], [450000, 100000]]) == 650000\n assert candidate(n = 15,restrictions = [[3, 2], [6, 3], [9, 1], [12, 4]]) == 7\n assert candidate(n = 1000000,restrictions = [[10000, 1000], [20000, 2000], [30000, 3000], [40000, 4000], [50000, 5000], [60000, 6000], [70000, 7000], [80000, 8000], [90000, 9000]]) == 919000\n assert candidate(n = 100,restrictions = [[10, 10], [20, 5], [30, 15], [40, 20], [50, 10], [60, 25], [70, 30], [80, 5], [90, 40]]) == 25\n assert candidate(n = 50,restrictions = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45]]) == 49\n assert candidate(n = 100,restrictions = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]]) == 14\n assert candidate(n = 10000,restrictions = [[2, 9999], [4, 9998], [6, 9997], [8, 9996], [10, 9995], [12, 9994], [14, 9993], [16, 9992], [18, 9991], [20, 9990]]) == 9999\n assert candidate(n = 100,restrictions = [[2, 99], [4, 98], [6, 97], [8, 96], [10, 95], [12, 94], [14, 93], [16, 92], [18, 91], [20, 90], [22, 89], [24, 88], [26, 87], [28, 86], [30, 85], [32, 84], [34, 83], [36, 82], [38, 81], [40, 80], [42, 79], [44, 78], [46, 77], [48, 76], [50, 75], [52, 74], [54, 73], [56, 72], [58, 71], [60, 70], [62, 69], [64, 68], [66, 67], [68, 66], [70, 65], [72, 64], [74, 63], [76, 62], [78, 61], [80, 60], [82, 59], [84, 58], [86, 57], [88, 56], [90, 55], [92, 54], [94, 53], [96, 52], [98, 51], [100, 50]]) == 66\n assert candidate(n = 200,restrictions = [[2, 1], [50, 50], [150, 20], [100, 30], [180, 10]]) == 64\n assert candidate(n = 1000000,restrictions = [[200000, 300000], [400000, 100000], [600000, 200000], [800000, 400000], [1000000, 500000]]) == 550000\n assert candidate(n = 1000,restrictions = [[10, 900], [20, 800], [30, 700], [40, 600], [50, 500], [60, 400], [70, 300], [80, 200], [90, 100]]) == 999\n assert candidate(n = 10000,restrictions = [[100, 50], [200, 40], [300, 30], [400, 20], [500, 10], [600, 0], [700, 10], [800, 20], [900, 30]]) == 9130\n assert candidate(n = 200,restrictions = [[10, 100], [20, 90], [30, 80], [40, 70], [50, 60], [60, 50], [70, 40], [80, 30], [90, 20], [100, 10], [110, 20], [120, 30], [130, 40], [140, 50], [150, 60], [160, 70], [170, 80], [180, 90], [190, 100], [200, 110]]) == 110\n assert candidate(n = 500,restrictions = [[50, 10], [100, 20], [150, 10], [200, 20], [250, 10], [300, 20], [350, 10], [400, 20], [450, 10], [500, 20]]) == 40\n assert candidate(n = 50,restrictions = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5], [30, 6], [35, 7], [40, 8], [45, 9], [50, 10]]) == 12\n assert candidate(n = 5000,restrictions = [[500, 500], [1000, 400], [1500, 600], [2000, 500], [2500, 700], [3000, 400], [3500, 600], [4000, 500], [4500, 700], [5000, 400]]) == 850\n assert candidate(n = 500,restrictions = [[100, 10], [200, 200], [300, 150], [400, 100], [500, 50]]) == 180\n assert candidate(n = 300,restrictions = [[30, 2], [60, 4], [90, 6], [120, 8], [150, 10], [180, 12], [210, 14], [240, 16], [270, 18]]) == 48\n assert candidate(n = 100,restrictions = [[10, 5], [30, 10], [50, 5], [70, 10], [90, 5]]) == 17\n assert candidate(n = 100,restrictions = [[20, 15], [30, 25], [40, 35], [50, 45], [60, 55], [70, 65], [80, 75], [90, 85]]) == 95\n assert candidate(n = 1000,restrictions = [[10, 5], [20, 15], [30, 10], [40, 20], [50, 15], [60, 25], [70, 20], [80, 30], [90, 25], [100, 35]]) == 935\n assert candidate(n = 20,restrictions = [[3, 2], [6, 3], [15, 5], [18, 4]]) == 8\n assert candidate(n = 1000,restrictions = [[100, 100], [200, 900], [300, 300], [400, 700], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900]]) == 999\n assert candidate(n = 10000000,restrictions = [[1000000, 500000], [2000000, 1000000], [3000000, 1500000], [4000000, 2000000], [5000000, 2500000], [6000000, 3000000], [7000000, 3500000], [8000000, 4000000], [9000000, 4500000]]) == 5500000\n assert candidate(n = 500,restrictions = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5], [30, 6], [35, 7], [40, 8], [45, 9], [50, 10]]) == 460\n assert candidate(n = 2000,restrictions = [[500, 500], [1000, 500], [1500, 500]]) == 1000\n assert candidate(n = 2000,restrictions = [[500, 100], [1000, 500], [1500, 200], [2000, 1000]]) == 700\n assert candidate(n = 200,restrictions = [[2, 198], [4, 196], [6, 194], [8, 192], [10, 190], [12, 188], [14, 186], [16, 184], [18, 182], [20, 180]]) == 199\n assert candidate(n = 10000000,restrictions = [[1000000, 1000000], [3000000, 3000000], [5000000, 5000000], [7000000, 7000000], [9000000, 9000000]]) == 9999999\n assert candidate(n = 500000,restrictions = [[100000, 100000], [200000, 200000], [300000, 300000], [400000, 400000], [500000, 500000]]) == 499999\n assert candidate(n = 100000,restrictions = [[5000, 1000], [15000, 2000], [25000, 3000], [35000, 4000], [45000, 5000], [55000, 6000], [65000, 7000], [75000, 8000], [85000, 9000], [95000, 10000]]) == 15000\n assert candidate(n = 10000,restrictions = [[500, 5000], [1000, 10000], [1500, 15000], [2000, 20000], [2500, 25000], [3000, 30000]]) == 9999\n assert candidate(n = 1000000,restrictions = [[1000, 500], [2000, 1000], [3000, 750], [4000, 1500], [5000, 1250], [6000, 2000], [7000, 1750], [8000, 2500], [9000, 2250], [10000, 3000]]) == 993000\n assert candidate(n = 10000,restrictions = [[1000, 500], [2000, 750], [3000, 1000], [4000, 1250], [5000, 1500]]) == 6500\n assert candidate(n = 1000000,restrictions = [[100000, 100000], [200000, 200000], [300000, 300000], [400000, 400000], [500000, 500000], [600000, 600000], [700000, 700000], [800000, 800000], [900000, 900000]]) == 999999\n"}, "metadata": {"canonical_parameter_names": ["n", "restrictions"], "leetcode_dataset_entry_point": "Solution().maxBuilding", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxBuilding(int n, vector>& restrictions) {", "container": "Solution", "callable": "maxBuilding", "parameters": [{"name": "n", "type": "int"}, {"name": "restrictions", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1844, "task_id": "replace-all-digits-with-characters", "difficulty": "Easy", "problem_description": "You are given a 0-indexed string s that has lowercase English letters in its even indices and digits in its odd indices.\nYou must perform an operation shift(c, x), where c is a character and x is a digit, that returns the xth character after c.\n\nFor example, shift('a', 5) = 'f' and shift('x', 0) = 'x'.\n\nFor every odd index i, you want to replace the digit s[i] with the result of the shift(s[i-1], s[i]) operation.\nReturn s after replacing all digits. It is guaranteed that shift(s[i-1], s[i]) will never exceed 'z'.\nNote that shift(c, x) is not a preloaded function, but an operation to be implemented as part of the solution.\n \nExample 1:\n\nInput: s = \"a1c1e1\"\nOutput: \"abcdef\"\nExplanation: The digits are replaced as follows:\n- s[1] -> shift('a',1) = 'b'\n- s[3] -> shift('c',1) = 'd'\n- s[5] -> shift('e',1) = 'f'\nExample 2:\n\nInput: s = \"a1b2c3d4e\"\nOutput: \"abbdcfdhe\"\nExplanation: The digits are replaced as follows:\n- s[1] -> shift('a',1) = 'b'\n- s[3] -> shift('b',2) = 'd'\n- s[5] -> shift('c',3) = 'f'\n- s[7] -> shift('d',4) = 'h'\n \nConstraints:\n\n1 <= s.length <= 100\ns consists only of lowercase English letters and digits.\nshift(s[i-1], s[i]) <= 'z' for all odd indices i.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"x1y2z3a4b5c6d7e8f9g0\") == \"xyy{z}aebgcidkemfogg\"\n assert candidate(s = \"x5y5z5\") == \"x}y~z\"\n assert candidate(s = \"a9b8c7d6e5f4g3h2i1j0\") == \"ajbjcjdjejfjgjhjijjj\"\n assert candidate(s = \"a9b9c9d9\") == \"ajbkcldm\"\n assert candidate(s = \"z0y0x0w0\") == \"zzyyxxww\"\n assert candidate(s = \"a0b0c0d0\") == \"aabbccdd\"\n assert candidate(s = \"m9l8k7j6\") == \"mvltkrjp\"\n assert candidate(s = \"z0y1x2w3\") == \"zzyzxzwz\"\n assert candidate(s = \"z0y0x0w0v0\") == \"zzyyxxwwvv\"\n assert candidate(s = \"a0b0c0d0e0f0g0h0i0j0\") == \"aabbccddeeffgghhiijj\"\n assert candidate(s = \"a9b8c7d6e5f4g3h2i1\") == \"ajbjcjdjejfjgjhjij\"\n assert candidate(s = \"t1s2r3q4p5o6n7m8l9k0\") == \"tusuruqupuounumulukk\"\n assert candidate(s = \"s9r8q7p6o5n4m3l2k1j0\") == \"s|rzqxpvotnrmplnkljj\"\n assert candidate(s = \"p2r4t6v8\") == \"prrvtzv~\"\n assert candidate(s = \"m0n1o2p3\") == \"mmnooqps\"\n assert candidate(s = \"q2w3e4r5\") == \"qswzeirw\"\n assert candidate(s = \"t1t2t3t4\") == \"tutvtwtx\"\n assert candidate(s = \"a1b2c3d4e\") == \"abbdcfdhe\"\n assert candidate(s = \"p1q2r3s4t\") == \"pqqsruswt\"\n assert candidate(s = \"a1c1e1\") == \"abcdef\"\n assert candidate(s = \"z0y2x3w4v\") == \"zzy{x{w{v\"\n assert candidate(s = \"q9r8s7t6u5\") == \"qzrzsztzuz\"\n assert candidate(s = \"x2y3z4\") == \"xzy|z~\"\n assert candidate(s = \"q9r8s7t6\") == \"qzrzsztz\"\n assert candidate(s = \"s0t1u2v3w4x5y6z7\") == \"sstuuwvyw{x}yz\"\n assert candidate(s = \"m9l8k7j6i5h4g3f2e1d0\") == \"mvltkrjpinhlgjfhefdd\"\n assert candidate(s = \"s9s8s7s6\") == \"s|s{szsy\"\n assert candidate(s = \"p2o3n4m5l6\") == \"prornrmrlr\"\n assert candidate(s = \"t2r3e4w5q6p7o8i9u0y1t2r3e4w\") == \"tvrueiw|qwpwowiruuyztvrueiw\"\n assert candidate(s = \"m4n3o2p1q0r9s8t7u6v5w4x3y2z1\") == \"mqnqoqpqqqr{s{t{u{v{w{x{y{z{\"\n assert candidate(s = \"z1y2x3w4v5u6t7s8r9q0p1o2n3m4l5k6j7i8h9g0f1e2d3c4b5a6\") == \"z{y{x{w{v{u{t{s{r{qqpqoqnqmqlqkqjqiqhqggfgegdgcgbgag\"\n assert candidate(s = \"n9m8l7k6j5i4h3g2f1e0d9c8b7a6z5y4x3w2v1u0t9s8r7q6p5\") == \"nwmulskqjoimhkgifgeedmckbiagzy}x{wyvwuut}s{ryqwpu\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0p0o0n0m0l0k0j0i0h0g0f0e0d0c0b0a0\") == \"zƒyxw}v{uytwsursqqppoonnmmllkkjjiihhggffeeddccbbaa\"\n assert candidate(s = \"z8y6x4w2v0u8t6s4r2q0p8o6n4m2l0k8j6i4h2g0f8e6d4c2b0a8\") == \"z‚yx|wyvvu}tzswrtqqpxounrmollksjpimhjggfnekdhcebbai\"\n assert candidate(s = \"b1c2d3e4f5g6h7i8j9k0l1m2n3o4p5q6r7s8t9u0v1w2x3y4z5\") == \"bccedgeifkgmhoiqjskklmmonqospuqwrys{t}uuvwwyx{y}z\"\n assert candidate(s = \"m3n5o7p9q1r3s5t7u9v1w3x5y7z9a1b3c5d7e9f1g3h5i7j9\") == \"mpnsovpyqrrusxt{u~vwwzx}y€zƒabbechdkenfggjhmipjs\"\n assert candidate(s = \"c3d2e1f0g9h8i7j6k5l4m3n2o1p0q9r8\") == \"cfdfefffgphpipjpkplpmpnpopppqzrz\"\n assert candidate(s = \"d3c2b1a0z9y8x7w6v5u4t3s2r1q0p9o8n7m6l5k4j3i2h1g0f9\") == \"dgcebcaazƒyxw}v{uytwsursqqpyownumslqkojmikhiggfo\"\n assert candidate(s = \"a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4x5y6z7\") == \"acbecgdiekfmgohqiijkkmlomqnsoupwqyr{sstuuwvyw{x}yz\"\n assert candidate(s = \"d3f5h7j9l1n3p5r7t9v1x3z5b7d9f1h3j5l7n9p1r3t5v7x9\") == \"dgfkhojslmnqpuryt}vwx{zbidmfghkjolsnwpqrutyv}x\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0p9o8n7m6l5k4j3i2h1g0f9e8d7c6b5a4\") == \"zƒyxw}v{uytwsursqqpyownumslqkojmikhiggfoemdkcibgae\"\n assert candidate(s = \"z1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t1u2v3w4\") == \"z{acbecgdiekfmgohqiijkkmlomqnsoupwqyr{sstuuwvyw{\"\n assert candidate(s = \"v1u2t3s4r5q6p7o8n9m0l1k2j3i4h5g6f7e8d9c0b1a2z3y4x5\") == \"vwuwtwswrwqwpwownwmmlmkmjmimhmgmfmemdmccbcacz}y}x}\"\n assert candidate(s = \"b2c4d6e8f0g2h4i6j8k0l2m4n6o8p0q2r4s6t8u0v2w4x6y8z0a2\") == \"bdcgdjemffgihliojrkklnmqntowppqsrvsyt|uuvxw{x~yzzac\"\n assert candidate(s = \"a9z8y7x6w5v4u3t2s1r0\") == \"ajz‚y€x~w|vzuxtvstrr\"\n assert candidate(s = \"n7m6l5k4j3i2h1g0f5e4d3\") == \"numslqkojmikhiggfkeidg\"\n assert candidate(s = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == \"abbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{\"\n assert candidate(s = \"b5c6d7e8f9g0h1i2j3k4l5m6n7o8p9q0r1s2t3u4v5w6x7y8z9\") == \"bgcidkemfogghiikjmkolqmsnuowpyqqrssutwuyv{w}xyzƒ\"\n assert candidate(s = \"q0r2s4t6u8v0w2x4y6z8\") == \"qqrtswtzu}vvwyx|yz‚\"\n assert candidate(s = \"s5r4q3p2o1n0m9l8k7j6i5h4g3f2e1d0c9b8a7z6y5x4w3v2u1t0s9\") == \"sxrvqtpropnnmvltkrjpinhlgjfhefddclbjahz€y~x|wzvxuvtts|\"\n assert candidate(s = \"x2y3z2a3b4c5d6e7f8g9h0i1j2k3l4m5n6o7p8q9r0s1t2u3v4w5x6y7z8a9\") == \"xzy|z|adbfchdjelfngphhijjlknlpmrntovpxqzrrsttvuxvzw|x~y€z‚aj\"\n assert candidate(s = \"s1t2u3v4w5x6y7z8a9b0c1d2e3f4g5h6i7j8k9l0m1n2o3p4q5r6\") == \"sttvuxvzw|x~y€z‚ajbbcddfehfjglhnipjrktllmnnporptqvrx\"\n assert candidate(s = \"t4r2q0p8o6n4m2l0k8j6i4h2g0f8e6d4c2b0a8y6x4w2v0u8t6s4\") == \"txrtqqpxounrmollksjpimhjggfnekdhcebbaiyx|wyvvu}tzsw\"\n assert candidate(s = \"a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0\") == \"acbecgdiekfmgohqiijkkmlomqnsoupwqyr{ss\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9\") == \"abbdcfdhejflgnhpirjjkllnmpnrotpvqxrzs|ttuvvxwzx|y~z€ahbjcl\"\n assert candidate(s = \"x2y4z6a8b0c2d4e6f8g0h2i4j6k8l0m2n4o6p8q0r2s4t6u8v0\") == \"xzy}z€aibbcedhekfngghjimjpksllmonroupxqqrtswtzu}vv\"\n assert candidate(s = \"t4s3r2q1p0o9n8m7l6k5j4i3h2g1f0\") == \"txsvrtqrppoxnvmtlrkpjnilhjghff\"\n assert candidate(s = \"a2c4e6g8i0k2m4o6q8s0u2w4y6b8d0f2h4j6l8n0p2r4t6v8x0\") == \"accgekgoiikmmqouqyssuww{ybjddfhhljpltnnprrvtzv~xx\"\n assert candidate(s = \"m1n2o3p4q5r6s7t8u9v0w1x2y3z4\") == \"mnnporptqvrxszt|u~vvwxxzy|z~\"\n assert candidate(s = \"m7l6k5j4i3h2g1f0e9d8c7b6a5\") == \"mtlrkpjnilhjghffendlcjbhaf\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j8i7h6g5f4e3d2c1b0a9\") == \"abbdcfdhejflgnhpirjriphnglfjehdfcdbbaj\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0\") == \"zƒyxw}v{uytwsursqq\"\n assert candidate(s = \"y7x6w5v4u3t2s1r0q9p8o7n6m5l4k3j2i1h0g9f8e7d6c5b4a3z2y1x0w9v8u7t6s5r4q3p2o1n0\") == \"y€x~w|vzuxtvstrrqzpxovntmrlpknjlijhhgpfneldjchbfadz|yzxxw€v~u|tzsxrvqtpropnn\"\n assert candidate(s = \"z2y4x6w8v0u2t4s6r8q0p2o4n6m8l0k2j4i6h8g0f2e4d6c8b0\") == \"z|y}x~wvvuwtxsyrzqqprosntmullkmjniohpggfheidjckbb\"\n assert candidate(s = \"a2b4c6d8e0f1g3h5i7j9\") == \"acbfcidleefggjhmipjs\"\n assert candidate(s = \"b2d3f4h5j6l7n8p9r0t1v2x3z4\") == \"bddgfjhmjplsnvpyrrtuvxx{z~\"\n assert candidate(s = \"q2r3s4t5u6v7w8x9y0z1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7\") == \"qsruswtyu{v}wxyyz{acbecgdiekfmgohqiijkkmlomqnsoupw\"\n assert candidate(s = \"x9y8z7a6b5c4d3e2f1g0h9i8j7k6l5m4n3o2p1q0r9s8t7u6\") == \"xyzagbgcgdgegfggghqiqjqkqlqmqnqoqpqqqr{s{t{u{\"\n assert candidate(s = \"t2h4n6m8g0p2r4l6t8s0q2e4v6s8g0t2l4m6b8c0t2r4l6n8m0\") == \"tvhlntmuggprrvlrt|ssqseiv|s{ggtvlpmsbjcctvrvlrnvmm\"\n assert candidate(s = \"x2y3z4a5b6c7d8e9f0g1h2i3j4\") == \"xzy|z~afbhcjdlenffghhjiljn\"\n assert candidate(s = \"a9b8c7d6e5f4g3h2i1j0k9l8m7n6\") == \"ajbjcjdjejfjgjhjijjjktltmtnt\"\n assert candidate(s = \"n5n4n3n2n1n0n9n8n7n6\") == \"nsnrnqnpnonnnwnvnunt\"\n assert candidate(s = \"d7c6b5a4z3y2x1w0v9u8t7s6r5q4p3o2n1\") == \"dkcibgaez}y{xywwvu}t{syrwqupsoqno\"\n assert candidate(s = \"q7r5s3t1u9v7w5x3y1z9a7b5c3d1e9f7g5h3i1j9k7l5m3n1o9p7\") == \"qxrwsvtuu~v}w|x{yzzƒahbgcfdeenfmglhkijjskrlqmpnooxpw\"\n assert candidate(s = \"x2y4z6a8b0c2d4e6f8g0h2i4j6k8l0m2n4o6p8q0r2s4t6u8v0w2y4z6\") == \"xzy}z€aibbcedhekfngghjimjpksllmonroupxqqrtswtzu}vvwyy}z€\"\n assert candidate(s = \"n5m4l3k2j1i0h9g8f7e6d5c4b3a2z1y0x9w8v7u6t5s4r3q2p1o0\") == \"nsmqlokmjkiihqgofmekdicgbeacz{yyxwv}u{tyswruqspqoo\"\n assert candidate(s = \"a1b1c1d1e1f1g1h1i1j1\") == \"abbccddeeffgghhiijjk\"\n assert candidate(s = \"z9y8x7w6v5u4t3s2r1q0p\") == \"zƒyxw}v{uytwsursqqp\"\n assert candidate(s = \"a1z2y3x4w5v6u7t8s9r0q1p2o3n4m5l6k7j8i9h0g1f2e3d4c5b6a7\") == \"abz|y|x|w|v|u|t|s|rrqrprornrmrlrkrjrirhhghfhehdhchbhah\"\n assert candidate(s = \"n9m8l7k6j5i4h3g2f1e0d9c8b7a6n9m8l7k6j5i4h3g2f1e0\") == \"nwmulskqjoimhkgifgeedmckbiagnwmulskqjoimhkgifgee\"\n assert candidate(s = \"a1b2c3d4e5f6g7h8i9j0a1b2c3d4e5f6g7h8i9j0a1b2c3d4\") == \"abbdcfdhejflgnhpirjjabbdcfdhejflgnhpirjjabbdcfdh\"\n assert candidate(s = \"b5c3d7e2f4g6h1i5j3k7l2m4n6o1p5q3r7s2t4u6v1w5x3y7z2\") == \"bgcfdkegfjgmhiinjmkrlnmqntoppuqtrysutxu{vww|x{y€z|\"\n assert candidate(s = \"l8k7j6i5h4g3f2e1d0c9b8a7z6y5x4w3v2u1t0s9r8q7p6o5n4m3l2\") == \"ltkrjpinhlgjfhefddclbjahz€y~x|wzvxuvtts|rzqxpvotnrmpln\"\n assert candidate(s = \"z1y2x3w4v5u6t7s8r9q0p1o2n3m4\") == \"z{y{x{w{v{u{t{s{r{qqpqoqnqmq\"\n assert candidate(s = \"t2r3q4p5o6n7m8l9k0j1i2h3g4f5e6d7c8b9a0\") == \"tvruqupuounumulukkjkikhkgkfkekdkckbkaa\"\n assert candidate(s = \"t8r7e6w5q4u3i2o1p0l9k8j7h6g5f4d3c2b1a0\") == \"t|ryekw|quuxikopppluksjqhnglfjdgcebcaa\"\n assert candidate(s = \"a1c2e3g4i5k6m7o8q9s0u1w2y3\") == \"abceehgkinkqmtowqzssuvwyy|\"\n assert candidate(s = \"q9r8s7t6u5v4w3x2y1z0a9b8c7d6e5f4g3h2i1j0k9l8m7n6o5p4\") == \"qzrzsztzuzvzwzxzyzzzajbjcjdjejfjgjhjijjjktltmtntotpt\"\n assert candidate(s = \"t0u2v4w6x8y0z2a4b6c8d0e2f4g6h8i0j2k4l6m8n0o2p4q6r8s0t2u4v6w8x0y2z4\") == \"ttuwvzw}x€yyz|aebhckddegfjgmhpiijlkolrmunnoqptqwrzsstvuyv|wxxy{z~\"\n assert candidate(s = \"q2r3s4t5u6v7w8x9y0z1\") == \"qsruswtyu{v}wxyyz{\"\n assert candidate(s = \"s1t2u3v4w5x6y7z8a9b0c1d2e3f4g5h6i7j8k9l0m1n2o3p4q5\") == \"sttvuxvzw|x~y€z‚ajbbcddfehfjglhnipjrktllmnnporptqv\"\n assert candidate(s = \"b1c2d3e4f5g6h7i8j9k0l1m2n3o4p5q6\") == \"bccedgeifkgmhoiqjskklmmonqospuqw\"\n assert candidate(s = \"a9b8c7d6e5f4g3h2i1j0k9l8\") == \"ajbjcjdjejfjgjhjijjjktlt\"\n assert candidate(s = \"v9w8x7y6z5a4b3c2d1e0f9g8h7\") == \"vwxyzaebecedeeefogoho\"\n assert candidate(s = \"b5c7d9e2f0g1h3i5j7k9l1m3n5o7p9q1r3s5t7u9\") == \"bgcjdmegffghhkinjqktlmmpnsovpyqrrusxt{u~\"\n assert candidate(s = \"x9y8z7a6b5c4d3e2f1g0h9i8j7k6l5m4n3o2p1q0r9\") == \"xyzagbgcgdgegfggghqiqjqkqlqmqnqoqpqqqr{\"\n assert candidate(s = \"z0y0x0w0v0u0t0s0r0q0p0o0n0m0l0k0j0i0h0g0f0e0d0c0b0a0z0y0x0w0v0u0t0s0r0q0p0o0n0m0l0k0j0i0h0g0f0e0d0c0b0a0\") == \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaazzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\"\n assert candidate(s = \"a9z8y7x6w5v4u3t2s1r0q9p8o7n6m5l4k3j2i1h0g9f8e7d6c5b4a3\") == \"ajz‚y€x~w|vzuxtvstrrqzpxovntmrlpknjlijhhgpfneldjchbfad\"\n assert candidate(s = \"y0x1w2v3u4t5s6r7q8p9o0n1m2l3k4j5i6h7g8f9e0d1c2b3a4\") == \"yyxywyvyuytysyryqypyoonomolokojoiohogofoeedecebeae\"\n assert candidate(s = \"n5m4l3k2j1i0h9g8f7e6d5c4b3a2\") == \"nsmqlokmjkiihqgofmekdicgbeac\"\n assert candidate(s = \"a2b4c6d8e0f2g4h6i8j0k2l4m6n8o0p2q4r6s8t0u2v4w6x8y0z2\") == \"acbfcidleefhgkhniqjjkmlpmsnvooprqurxs{ttuwvzw}x€yyz|\"\n assert candidate(s = \"a2b2c2d2e2f2g2h2i2j2k2l2m2n2o2p2q2r2s2t2u2v2w2x2y2z2\") == \"acbdcedfegfhgihjikjlkmlnmonpoqprqsrtsutvuwvxwyxzy{z|\"\n assert candidate(s = \"a9b8c7d6e5f4g3h2i1j0k9l8m7n6o5p4q3r2s1t0u9v8w7x6y5z4\") == \"ajbjcjdjejfjgjhjijjjktltmtntotptqtrtstttu~v~w~x~y~z~\"\n assert candidate(s = \"t1s2r3q4p5o6n7m8l9k0j1i2h3g4f5e6d7c8b9a0z1y2x3w4v5u\") == \"tusuruqupuounumulukkjkikhkgkfkekdkckbkaaz{y{x{w{v{u\"\n assert candidate(s = \"z1y2x3w4v5u6t7s8r9q0p1o2n3\") == \"z{y{x{w{v{u{t{s{r{qqpqoqnq\"\n assert candidate(s = \"y2x3w4v5u6t7s8r9q0p1o2n3m4l5k6j7i8h9g0f1e2d3c4b5a6\") == \"y{x{w{v{u{t{s{r{qqpqoqnqmqlqkqjqiqhqggfgegdgcgbgag\"\n assert candidate(s = \"y3x5w7v9u1t3s5r7q9p1o3n5m7l9k1j3i5h7g9f1e3d5c7b9a1\") == \"y|x}w~vuvtwsxryqzpqornsmtlukljminhogpfgehdicjbkab\"\n assert candidate(s = \"s9r8q7p6o5n4m3l2k1j0i9h8g7f6e5d4c3b2a1z0y9x8w7v6u5t4s3r2q1p0\") == \"s|rzqxpvotnrmplnkljjirhpgnflejdhcfbdabzzy‚x€w~v|uztxsvrtqrpp\"\n assert candidate(s = \"m8n7o6p5q4r3s2t1u0v9w8x7y6z5a4b3c2d1e0f9g8h7i6j5k4l3m2\") == \"munuoupuqurusutuuuvwxyzaebecedeeefogohoiojokolomo\"\n assert candidate(s = \"q2w3e4r5t6y7u8i9o0p1a2s3d4f5g6h7j8k9l0\") == \"qswzeirwtzy€u}iroopqacsvdhfkgmhojrktll\"\n assert candidate(s = \"b5c6d7e8f9g0h1i2j3k4l5\") == \"bgcidkemfogghiikjmkolq\"\n assert candidate(s = \"m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2g3h4i5j6k7l8\") == \"mpnrotpvqxrzs|ttuvvxwzx|y~z€ahbjclddeffhgjhlinjpkrlt\"\n assert candidate(s = \"q1w2e3r4t5y6u7i8o9p0a1s2d3f4g5\") == \"qrwyehrvtyyu|iqoxppabsudgfjgl\"\n assert candidate(s = \"q2w3e4r5t6y7u8i9o0p1a2s3d4f5g6h7j8k9l0z1x2c3v4b5n6m7\") == \"qswzeirwtzy€u}iroopqacsvdhfkgmhojrktllz{xzcfvzbgntmt\"\n assert candidate(s = \"n4m3l2k1j0i9h8g7f6e5d4c3b2a1z0y9x8w7v6u5t4s3r2q1p0\") == \"nrmplnkljjirhpgnflejdhcfbdabzzy‚x€w~v|uztxsvrtqrpp\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().replaceDigits", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string replaceDigits(string s) {", "container": "Solution", "callable": "replaceDigits", "parameters": [{"name": "s", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1846, "task_id": "maximum-element-after-decreasing-and-rearranging", "difficulty": "Medium", "problem_description": "You are given an array of positive integers arr. Perform some operations (possibly none) on arr so that it satisfies these conditions:\n\nThe value of the first element in arr must be 1.\nThe absolute difference between any 2 adjacent elements must be less than or equal to 1. In other words, abs(arr[i] - arr[i - 1]) <= 1 for each i where 1 <= i < arr.length (0-indexed). abs(x) is the absolute value of x.\n\nThere are 2 types of operations that you can perform any number of times:\n\nDecrease the value of any element of arr to a smaller positive integer.\nRearrange the elements of arr to be in any order.\n\nReturn the maximum possible value of an element in arr after performing the operations to satisfy the conditions.\n \nExample 1:\n\nInput: arr = [2,2,1,2,1]\nOutput: 2\nExplanation: \nWe can satisfy the conditions by rearranging arr so it becomes [1,2,2,2,1].\nThe largest element in arr is 2.\n\nExample 2:\n\nInput: arr = [100,1,1000]\nOutput: 3\nExplanation: \nOne possible way to satisfy the conditions is by doing the following:\n1. Rearrange arr so it becomes [1,100,1000].\n2. Decrease the value of the second element to 2.\n3. Decrease the value of the third element to 3.\nNow arr = [1,2,3], which satisfies the conditions.\nThe largest element in arr is 3.\n\nExample 3:\n\nInput: arr = [1,2,3,4,5]\nOutput: 5\nExplanation: The array already satisfies the conditions, and the largest element is 5.\n\n \nConstraints:\n\n1 <= arr.length <= 105\n1 <= arr[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = [3, 2, 1]) == 3\n assert candidate(arr = [5, 4, 3, 2, 1]) == 5\n assert candidate(arr = [1, 1000000000, 2, 3, 4]) == 5\n assert candidate(arr = [9, 7, 5, 3, 1]) == 5\n assert candidate(arr = [5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [1000000000, 1, 1000000000, 1, 1000000000]) == 4\n assert candidate(arr = [1, 10, 20, 30, 40]) == 5\n assert candidate(arr = [1, 1000000000, 2, 1000000000, 3]) == 5\n assert candidate(arr = [1]) == 1\n assert candidate(arr = [100, 1, 1000]) == 3\n assert candidate(arr = [1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(arr = [1, 10, 100, 1000, 10000]) == 5\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 4\n assert candidate(arr = [1, 2, 3, 4, 5]) == 5\n assert candidate(arr = [2, 3, 4, 5, 6]) == 5\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(arr = [2, 2, 1, 2, 1]) == 2\n assert candidate(arr = [1, 3, 5, 7, 9]) == 5\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 4\n assert candidate(arr = [999999999, 1, 999999998, 2, 999999997, 3, 999999996, 4, 999999995, 5]) == 10\n assert candidate(arr = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 4\n assert candidate(arr = [1, 3, 6, 10, 15, 21]) == 6\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 10]) == 10\n assert candidate(arr = [100, 50, 25, 12, 6, 3, 1]) == 7\n assert candidate(arr = [1000000000, 1, 1000000000, 1, 1000000000]) == 4\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]) == 6\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(arr = [1, 100, 2, 101, 3, 102, 4, 103, 5, 104]) == 10\n assert candidate(arr = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [100, 100, 100, 100, 100, 100, 100]) == 7\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8, 9]) == 9\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [50, 25, 75, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 13\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(arr = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 5\n assert candidate(arr = [1000000000, 1000000000, 1000000000, 1000000000, 1]) == 5\n assert candidate(arr = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997]) == 8\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 16\n assert candidate(arr = [1, 1000000000, 2, 999999999, 3, 999999998]) == 6\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 20\n assert candidate(arr = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 10\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 20\n assert candidate(arr = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 10\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == 20\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 10\n assert candidate(arr = [5, 3, 1, 4, 2]) == 5\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 15\n assert candidate(arr = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == 5\n assert candidate(arr = [100, 50, 20, 10, 5, 2, 1, 2, 5, 10, 20, 50, 100, 150, 200, 250, 300]) == 16\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 12\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(arr = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == 20\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 13\n assert candidate(arr = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120]) == 15\n assert candidate(arr = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(arr = [10, 1, 2, 2, 3, 4, 5]) == 6\n assert candidate(arr = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9]) == 10\n assert candidate(arr = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210]) == 20\n assert candidate(arr = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 15\n assert candidate(arr = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 2\n assert candidate(arr = [10, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(arr = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(arr = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 20\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 5\n assert candidate(arr = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == 20\n assert candidate(arr = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(arr = [50, 40, 30, 20, 10, 5, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 2\n assert candidate(arr = [5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(arr = [2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, 7]) == 8\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1]) == 10\n assert candidate(arr = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3]) == 3\n assert candidate(arr = [50, 40, 30, 20, 10, 1, 2, 3, 4, 5]) == 10\n assert candidate(arr = [1, 999999999, 999999998, 999999997, 999999996, 999999995]) == 6\n assert candidate(arr = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 10\n assert candidate(arr = [1000, 1000, 1000, 1000, 1000]) == 5\n assert candidate(arr = [1000000000, 1000000000, 1000000000, 1, 1, 1]) == 4\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(arr = [1000000000, 999999999, 1000000001, 2, 3]) == 5\n assert candidate(arr = [999999999, 999999998, 999999997, 999999996, 999999995, 1]) == 6\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10]) == 10\n assert candidate(arr = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 30\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(arr = [5, 4, 3, 2, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(arr = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000, 1]) == 5\n assert candidate(arr = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10]) == 10\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 20\n assert candidate(arr = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(arr = [5, 4, 3, 2, 1, 1, 1]) == 5\n assert candidate(arr = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11]) == 11\n assert candidate(arr = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(arr = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(arr = [1, 2, 3, 4, 5, 10, 100, 1000]) == 8\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 30\n assert candidate(arr = [10, 5, 15, 20, 1, 3, 8]) == 7\n assert candidate(arr = [5, 4, 3, 2, 1]) == 5\n assert candidate(arr = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900]) == 10\n assert candidate(arr = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(arr = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5]) == 15\n assert candidate(arr = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190]) == 20\n assert candidate(arr = [1000000000, 1, 1000000000, 2, 1000000000, 3]) == 6\n assert candidate(arr = [1000000000, 999999999, 999999998, 999999997, 999999996]) == 5\n assert candidate(arr = [1, 2, 2, 3, 3, 4, 4, 5, 5]) == 5\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(arr = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(arr = [3, 3, 3, 3, 3, 2, 2, 2, 1, 1]) == 3\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(arr = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == 10\n assert candidate(arr = [5, 4, 3, 2, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(arr = [1, 1000000000, 2, 999999999, 3]) == 5\n assert candidate(arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(arr = [1, 1000000000, 2, 999999999, 3, 999999998]) == 6\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == 2\n assert candidate(arr = [5, 4, 3, 2, 1, 1, 1]) == 5\n assert candidate(arr = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140]) == 15\n assert candidate(arr = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(arr = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5]) == 5\n assert candidate(arr = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 15\n assert candidate(arr = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 21\n assert candidate(arr = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 2\n assert candidate(arr = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 15\n assert candidate(arr = [1, 2, 3, 100, 200, 300, 400, 500]) == 8\n"}, "metadata": {"canonical_parameter_names": ["arr"], "leetcode_dataset_entry_point": "Solution().maximumElementAfterDecrementingAndRearranging", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumElementAfterDecrementingAndRearranging(vector& arr) {", "container": "Solution", "callable": "maximumElementAfterDecrementingAndRearranging", "parameters": [{"name": "arr", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1847, "task_id": "closest-room", "difficulty": "Hard", "problem_description": "There is a hotel with n rooms. The rooms are represented by a 2D integer array rooms where rooms[i] = [roomIdi, sizei] denotes that there is a room with room number roomIdi and size equal to sizei. Each roomIdi is guaranteed to be unique.\nYou are also given k queries in a 2D array queries where queries[j] = [preferredj, minSizej]. The answer to the jth query is the room number id of a room such that:\n\nThe room has a size of at least minSizej, and\nabs(id - preferredj) is minimized, where abs(x) is the absolute value of x.\n\nIf there is a tie in the absolute difference, then use the room with the smallest such id. If there is no such room, the answer is -1.\nReturn an array answer of length k where answer[j] contains the answer to the jth query.\n \nExample 1:\n\nInput: rooms = [[2,2],[1,2],[3,2]], queries = [[3,1],[3,3],[5,2]]\nOutput: [3,-1,3]\nExplanation: The answers to the queries are as follows:\nQuery = [3,1]: Room number 3 is the closest as abs(3 - 3) = 0, and its size of 2 is at least 1. The answer is 3.\nQuery = [3,3]: There are no rooms with a size of at least 3, so the answer is -1.\nQuery = [5,2]: Room number 3 is the closest as abs(3 - 5) = 2, and its size of 2 is at least 2. The answer is 3.\nExample 2:\n\nInput: rooms = [[1,4],[2,3],[3,5],[4,1],[5,2]], queries = [[2,3],[2,4],[2,5]]\nOutput: [2,1,3]\nExplanation: The answers to the queries are as follows:\nQuery = [2,3]: Room number 2 is the closest as abs(2 - 2) = 0, and its size of 3 is at least 3. The answer is 2.\nQuery = [2,4]: Room numbers 1 and 3 both have sizes of at least 4. The answer is 1 since it is smaller.\nQuery = [2,5]: Room number 3 is the only room with a size of at least 5. The answer is 3.\n \nConstraints:\n\nn == rooms.length\n1 <= n <= 105\nk == queries.length\n1 <= k <= 104\n1 <= roomIdi, preferredj <= 107\n1 <= sizei, minSizej <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rooms = [[10, 5], [20, 3], [30, 8]],queries = [[15, 4], [25, 7], [35, 2]]) == [10, 30, 30]\n assert candidate(rooms = [[5, 5], [10, 5], [15, 5], [20, 5]],queries = [[7, 5], [12, 5], [17, 5], [22, 5]]) == [5, 10, 15, 20]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]) == [1, 2, 3, 4, 5, -1]\n assert candidate(rooms = [[10, 5], [20, 4], [30, 3]],queries = [[15, 3], [25, 4], [35, 5]]) == [10, 20, 10]\n assert candidate(rooms = [[2, 2], [1, 2], [3, 2]],queries = [[3, 1], [3, 3], [5, 2]]) == [3, -1, 3]\n assert candidate(rooms = [[10, 5], [20, 4], [30, 3]],queries = [[10, 5], [25, 3], [15, 4]]) == [10, 20, 10]\n assert candidate(rooms = [[5, 10], [10, 10], [15, 10]],queries = [[5, 10], [10, 10], [15, 10], [20, 10]]) == [5, 10, 15, 15]\n assert candidate(rooms = [[100, 100], [200, 200], [300, 300]],queries = [[150, 150], [250, 250], [350, 350]]) == [200, 300, -1]\n assert candidate(rooms = [[7, 10], [6, 9], [5, 8], [4, 7], [3, 6]],queries = [[7, 10], [6, 9], [5, 8], [4, 7], [3, 6]]) == [7, 6, 5, 4, 3]\n assert candidate(rooms = [[7, 10], [15, 7], [25, 12]],queries = [[10, 10], [15, 7], [30, 10]]) == [7, 15, 25]\n assert candidate(rooms = [[1, 4], [2, 3], [3, 5], [4, 1], [5, 2]],queries = [[2, 3], [2, 4], [2, 5]]) == [2, 1, 3]\n assert candidate(rooms = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]],queries = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [1, 2, 3, 4, 5]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 7]],queries = [[10, 5], [25, 4], [40, 8]]) == [10, 30, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[5, 5], [15, 10], [25, 15], [35, 20], [45, 25], [55, 30], [65, 35], [75, 40], [85, 45], [95, 50]]) == [5, 10, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(rooms = [[1, 10000000], [2, 9999999], [3, 9999998]],queries = [[10000000, 10000000], [9999999, 9999999], [9999998, 9999998]]) == [1, 2, 3]\n assert candidate(rooms = [[1, 1000], [2, 900], [3, 800], [4, 700], [5, 600], [6, 500], [7, 400], [8, 300], [9, 200], [10, 100]],queries = [[1, 1500], [2, 1400], [3, 1300], [4, 1200], [5, 1100], [6, 1000], [7, 900], [8, 800], [9, 700], [10, 600]]) == [-1, -1, -1, -1, -1, 1, 2, 3, 4, 5]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],queries = [[10, 5], [9, 15], [8, 25], [7, 35], [6, 45], [5, 55], [4, 65], [3, 75], [2, 85], [1, 95]]) == [10, 9, 8, 7, 6, 6, 7, 8, 9, 10]\n assert candidate(rooms = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996], [6, 9999995], [7, 9999994], [8, 9999993], [9, 9999992], [10, 9999991]],queries = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996], [6, 9999995], [7, 9999994], [8, 9999993], [9, 9999992], [10, 9999991], [11, 9999990]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10]\n assert candidate(rooms = [[1, 1000000], [2, 999999], [3, 999998], [4, 999997], [5, 999996], [6, 999995], [7, 999994], [8, 999993], [9, 999992], [10, 999991]],queries = [[1, 1000000], [2, 1000000], [3, 1000000], [4, 1000000], [5, 1000000], [6, 1000000], [7, 1000000], [8, 1000000], [9, 1000000], [10, 1000000]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rooms = [[10000, 5000], [20000, 4000], [30000, 3000], [40000, 2000], [50000, 1000]],queries = [[5000, 3000], [15000, 2000], [25000, 1000], [35000, 500], [45000, 1]]) == [10000, 10000, 20000, 30000, 40000]\n assert candidate(rooms = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10]],queries = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [11, 10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10]\n assert candidate(rooms = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65], [75, 75], [85, 85], [95, 95]],queries = [[1, 1], [10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, -1]\n assert candidate(rooms = [[1, 1], [10000000, 10000000]],queries = [[5000000, 1], [5000000, 10000000], [1, 1], [10000000, 10000000], [5000000, 5000000]]) == [1, 10000000, 1, 10000000, 10000000]\n assert candidate(rooms = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900], [1000, 1000]],queries = [[150, 100], [250, 200], [350, 300], [450, 400], [550, 500], [650, 600], [750, 700], [850, 800], [950, 900], [1050, 1000]]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(rooms = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5], [30, 6], [35, 7], [40, 8], [45, 9], [50, 10]],queries = [[3, 1], [6, 2], [9, 3], [12, 4], [15, 5], [18, 6], [21, 7], [24, 8], [27, 9], [30, 10], [33, 11]]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, -1]\n assert candidate(rooms = [[5, 10], [10, 9], [15, 8], [20, 7], [25, 6], [30, 5], [35, 4]],queries = [[8, 7], [13, 6], [18, 5], [23, 4], [28, 3], [33, 2], [38, 1]]) == [10, 15, 20, 25, 30, 35, 35]\n assert candidate(rooms = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60], [65, 70], [75, 80], [85, 90], [95, 100]],queries = [[10, 5], [20, 15], [30, 25], [40, 35], [50, 45], [60, 55], [70, 65], [80, 75], [90, 85], [100, 95], [110, 105]]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, -1]\n assert candidate(rooms = [[10000, 10000], [20000, 20000], [30000, 30000], [40000, 40000], [50000, 50000]],queries = [[5000, 9000], [15000, 19000], [25000, 29000], [35000, 39000], [45000, 49000]]) == [10000, 20000, 30000, 40000, 50000]\n assert candidate(rooms = [[1, 1], [10000000, 10000000], [5000000, 5000000], [1000000, 1000000], [100000, 100000], [10000, 10000], [1000, 1000], [100, 100], [10, 10], [100000000, 100000000]],queries = [[1, 1], [10000000, 10000000], [5000000, 5000000], [1000000, 1000000], [100000, 100000], [10000, 10000], [1000, 1000], [100, 100], [10, 10], [100000000, 100000000]]) == [1, 10000000, 5000000, 1000000, 100000, 10000, 1000, 100, 10, 100000000]\n assert candidate(rooms = [[1000, 5000], [2000, 4000], [3000, 3000], [4000, 2000], [5000, 1000]],queries = [[1500, 3000], [2500, 2000], [3500, 1000], [4500, 500], [5500, 1]]) == [1000, 2000, 3000, 4000, 5000]\n assert candidate(rooms = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500]],queries = [[50, 50], [150, 150], [250, 250], [350, 350], [450, 450], [550, 550]]) == [100, 200, 300, 400, 500, -1]\n assert candidate(rooms = [[100000, 1], [100001, 1], [100002, 1], [100003, 1], [100004, 1], [100005, 1], [100006, 1], [100007, 1], [100008, 1], [100009, 1]],queries = [[100000, 2], [100001, 2], [100002, 2], [100003, 2], [100004, 2], [100005, 2], [100006, 2], [100007, 2], [100008, 2], [100009, 2]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20], [21, 21]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1]\n assert candidate(rooms = [[1, 10], [10, 20], [100, 30], [1000, 40], [10000, 50]],queries = [[5, 5], [50, 15], [500, 25], [5000, 35], [50000, 45]]) == [1, 10, 100, 1000, 10000]\n assert candidate(rooms = [[1, 1], [10, 2], [100, 3], [1000, 4], [10000, 5], [100000, 6], [1000000, 7], [10000000, 8]],queries = [[5, 1], [50, 2], [500, 3], [5000, 4], [50000, 5], [500000, 6], [5000000, 7], [50000000, 8], [50000000, 9], [50000000, 10]]) == [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, -1, -1]\n assert candidate(rooms = [[10000000, 10000000], [1, 1], [5000000, 5000000], [2, 2], [9999999, 9999999]],queries = [[10000000, 10000000], [5000000, 5000000], [2, 1], [10000000, 1], [1, 10000000]]) == [10000000, 5000000, 2, 10000000, 10000000]\n assert candidate(rooms = [[500, 1000], [1000, 900], [1500, 800], [2000, 700], [2500, 600], [3000, 500], [3500, 400], [4000, 300], [4500, 200], [5000, 100]],queries = [[100, 500], [600, 400], [1100, 300], [1600, 200], [2100, 100], [2600, 50], [3100, 1], [3600, 1], [4100, 1], [4600, 1]]) == [500, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500]\n assert candidate(rooms = [[1, 10], [10, 9], [100, 8], [1000, 7], [10000, 6]],queries = [[1, 10], [10, 9], [100, 8], [1000, 7], [10000, 6], [5, 5], [50, 5], [500, 5], [5000, 5], [50000, 5]]) == [1, 10, 100, 1000, 10000, 1, 10, 100, 1000, 10000]\n assert candidate(rooms = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],queries = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65], [75, 75], [85, 85], [95, 95]]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(rooms = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996]],queries = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996], [6, 9999995]]) == [1, 2, 3, 4, 5, 5]\n assert candidate(rooms = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == [5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, -1]\n assert candidate(rooms = [[1, 5], [10, 15], [20, 25], [30, 35], [40, 45], [50, 55]],queries = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45], [55, 55], [65, 65]]) == [1, 10, 20, 30, 40, 50, -1]\n assert candidate(rooms = [[100, 100], [200, 90], [300, 80], [400, 70], [500, 60], [600, 50], [700, 40], [800, 30], [900, 20], [1000, 10]],queries = [[150, 80], [250, 70], [350, 60], [450, 50], [550, 40], [650, 30], [750, 20], [850, 10], [950, 5], [1050, 1]]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(rooms = [[1, 10], [20, 9], [30, 8], [40, 7], [50, 6], [60, 5], [70, 4], [80, 3], [90, 2], [100, 1]],queries = [[15, 3], [25, 4], [35, 5], [45, 6], [55, 7], [65, 8], [75, 9], [85, 10], [95, 11], [105, 12]]) == [20, 20, 30, 40, 40, 30, 20, 1, -1, -1]\n assert candidate(rooms = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10]],queries = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(rooms = [[10000000, 1], [9999999, 2], [9999998, 3], [9999997, 4], [9999996, 5], [9999995, 6], [9999994, 7], [9999993, 8], [9999992, 9], [9999991, 10]],queries = [[9999995, 3], [9999994, 4], [9999993, 5], [9999992, 6], [9999991, 7], [9999990, 8], [9999989, 9], [9999988, 10]]) == [9999995, 9999994, 9999993, 9999992, 9999991, 9999991, 9999991, 9999991]\n assert candidate(rooms = [[1, 10], [10, 10], [20, 10], [30, 10], [40, 10], [50, 10], [60, 10], [70, 10], [80, 10], [90, 10]],queries = [[5, 10], [15, 10], [25, 10], [35, 10], [45, 10], [55, 10], [65, 10], [75, 10], [85, 10], [95, 10]]) == [1, 10, 20, 30, 40, 50, 60, 70, 80, 90]\n assert candidate(rooms = [[10000, 100], [20000, 200], [30000, 300], [40000, 400], [50000, 500], [60000, 600], [70000, 700], [80000, 800], [90000, 900], [100000, 1000]],queries = [[5000, 50], [15000, 150], [25000, 250], [35000, 350], [45000, 450], [55000, 550], [65000, 650], [75000, 750], [85000, 850], [95000, 950]]) == [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]\n assert candidate(rooms = [[1, 10000000], [2, 9000000], [3, 8000000], [4, 7000000], [5, 6000000]],queries = [[1, 10000000], [2, 9000000], [3, 8000000], [4, 7000000], [5, 6000000], [10000000, 1]]) == [1, 2, 3, 4, 5, 5]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[5, 5], [5, 4], [5, 3], [5, 2], [5, 1], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]]) == [5, 5, 5, 5, 5, 6, 7, 8, 9, 10]\n assert candidate(rooms = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996]],queries = [[1, 9999999], [2, 9999998], [3, 9999997], [4, 9999996], [5, 9999995]]) == [1, 2, 3, 4, 5]\n assert candidate(rooms = [[100, 100], [200, 90], [300, 80], [400, 70], [500, 60]],queries = [[150, 85], [250, 75], [350, 65], [450, 55], [550, 45]]) == [100, 200, 300, 400, 500]\n assert candidate(rooms = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],queries = [[100, 1], [100, 2], [100, 3], [100, 4], [100, 5], [100, 6], [100, 7], [100, 8], [100, 9], [100, 10]]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(rooms = [[1, 1], [10000000, 10000000]],queries = [[5000000, 1], [5000000, 10000000], [1, 1], [10000000, 10000000], [5000000, 5000000]]) == [1, 10000000, 1, 10000000, 10000000]\n assert candidate(rooms = [[5, 1000], [15, 900], [25, 800], [35, 700], [45, 600], [55, 500], [65, 400], [75, 300], [85, 200], [95, 100]],queries = [[10, 900], [20, 800], [30, 700], [40, 600], [50, 500], [60, 400], [70, 300], [80, 200], [90, 100], [100, 90]]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]\n assert candidate(rooms = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],queries = [[5, 15], [15, 25], [25, 35], [35, 45], [45, 55], [55, 65], [65, 75], [75, 85], [85, 95], [95, 105]]) == [20, 30, 40, 50, 60, 70, 80, 90, 100, -1]\n assert candidate(rooms = [[1, 1000000], [2, 999999], [3, 999998], [4, 999997], [5, 999996], [6, 999995], [7, 999994], [8, 999993], [9, 999992], [10, 999991]],queries = [[500000, 999998], [1000000, 999997], [1500000, 999996], [2000000, 999995], [2500000, 999994], [3000000, 999993], [3500000, 999992], [4000000, 999991], [4500000, 999990], [5000000, 999989]]) == [3, 4, 5, 6, 7, 8, 9, 10, 10, 10]\n assert candidate(rooms = [[10, 100], [20, 90], [30, 80], [40, 70], [50, 60], [60, 50], [70, 40], [80, 30], [90, 20], [100, 10]],queries = [[15, 50], [25, 40], [35, 30], [45, 20], [55, 10], [65, 5], [75, 15], [85, 25], [95, 35], [105, 45]]) == [10, 20, 30, 40, 50, 60, 70, 80, 70, 60]\n assert candidate(rooms = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45], [50, 50]],queries = [[3, 3], [8, 8], [13, 13], [18, 18], [23, 23], [28, 28], [33, 33], [38, 38], [43, 43], [48, 48]]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(rooms = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]],queries = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5], [1, 6]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1]\n assert candidate(rooms = [[1, 1], [10000000, 10000000]],queries = [[5000000, 1], [5000000, 5000000], [5000000, 10000000], [15000000, 1]]) == [1, 10000000, 10000000, 10000000]\n assert candidate(rooms = [[100000, 10000], [200000, 9000], [300000, 8000], [400000, 7000], [500000, 6000]],queries = [[100000, 10000], [200000, 9000], [300000, 8000], [400000, 7000], [500000, 6000], [500000, 11000]]) == [100000, 200000, 300000, 400000, 500000, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1]\n assert candidate(rooms = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 9, -1]\n assert candidate(rooms = [[10000000, 10000000], [1, 1], [5000000, 5000000]],queries = [[9999999, 9999999], [1, 1], [5000000, 5000000]]) == [10000000, 1, 5000000]\n assert candidate(rooms = [[5, 10], [15, 12], [25, 9], [35, 8], [45, 11], [55, 7]],queries = [[10, 8], [20, 9], [30, 10], [40, 11], [50, 12]]) == [5, 15, 15, 45, 15]\n assert candidate(rooms = [[100000, 10], [200000, 20], [300000, 30], [400000, 40], [500000, 50], [600000, 60], [700000, 70], [800000, 80], [900000, 90], [1000000, 100]],queries = [[50000, 10], [150000, 20], [250000, 30], [350000, 40], [450000, 50], [550000, 60], [650000, 70], [750000, 80], [850000, 90], [950000, 100]]) == [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]\n assert candidate(rooms = [[1, 10000], [2, 10000], [3, 10000], [4, 10000], [5, 10000]],queries = [[1, 9000], [2, 9000], [3, 9000], [4, 9000], [5, 9000], [6, 9000], [7, 9000], [8, 9000], [9, 9000]]) == [1, 2, 3, 4, 5, 5, 5, 5, 5]\n assert candidate(rooms = [[1000000, 1000000], [999999, 999999], [999998, 999998], [999997, 999997], [999996, 999996], [999995, 999995]],queries = [[1000000, 1000000], [1000000, 999999], [1000000, 999998], [1000000, 999997], [1000000, 999996], [1000000, 999995], [1000000, 1], [1000000, 2], [1000000, 3], [1000000, 4]]) == [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]\n assert candidate(rooms = [[100, 50], [200, 60], [300, 70], [400, 80], [500, 90]],queries = [[150, 55], [250, 65], [350, 75], [450, 85], [550, 95]]) == [200, 300, 400, 500, -1]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],queries = [[5, 15], [6, 25], [7, 35], [8, 45], [9, 55], [10, 65], [11, 75], [12, 85], [13, 95], [14, 105], [15, 115]]) == [5, 6, 7, 8, 9, 10, 10, 10, 10, -1, -1]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],queries = [[1, 5], [2, 15], [3, 25], [4, 35], [5, 45], [6, 55], [7, 65], [8, 75], [9, 85], [10, 95]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(rooms = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500]],queries = [[150, 150], [250, 250], [350, 350], [450, 450], [550, 550]]) == [200, 300, 400, 500, -1]\n assert candidate(rooms = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1]\n assert candidate(rooms = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5], [600, 6], [700, 7], [800, 8], [900, 9], [1000, 10]],queries = [[50, 1], [150, 2], [250, 3], [350, 4], [450, 5], [550, 6], [650, 7], [750, 8], [850, 9], [950, 10], [1050, 11]]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 1]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10]\n assert candidate(rooms = [[100, 10], [200, 20], [300, 30], [400, 40], [500, 50], [600, 60], [700, 70], [800, 80], [900, 90], [1000, 100]],queries = [[50, 10], [150, 20], [250, 30], [350, 40], [450, 50], [550, 60], [650, 70], [750, 80], [850, 90], [950, 100], [1050, 10]]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1000]\n assert candidate(rooms = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10]\n assert candidate(rooms = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]],queries = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5], [11, 5], [12, 5], [13, 5], [14, 5], [15, 5]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10]\n assert candidate(rooms = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5], [30, 6], [35, 7], [40, 8], [45, 9], [50, 10]],queries = [[3, 1], [8, 2], [13, 3], [18, 4], [23, 5], [28, 6], [33, 7], [38, 8], [43, 9], [48, 10], [55, 11]]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[5, 5], [5, 6], [5, 4], [5, 7], [5, 3]]) == [5, 6, 5, 7, 5]\n assert candidate(rooms = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996]],queries = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996]]) == [1, 2, 3, 4, 5]\n assert candidate(rooms = [[10, 20], [20, 20], [30, 20], [40, 20], [50, 20], [60, 20], [70, 20], [80, 20], [90, 20], [100, 20]],queries = [[5, 10], [15, 10], [25, 10], [35, 10], [45, 10], [55, 10], [65, 10], [75, 10], [85, 10], [95, 10]]) == [10, 10, 20, 30, 40, 50, 60, 70, 80, 90]\n assert candidate(rooms = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5], [600, 6], [700, 7], [800, 8], [900, 9], [1000, 10]],queries = [[50, 5], [150, 15], [250, 25], [350, 35], [450, 45], [550, 55], [650, 65], [750, 75], [850, 85], [950, 95]]) == [500, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(rooms = [[9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]],queries = [[10, 1], [9, 1], [8, 1], [7, 1], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [1, 1]]) == [9, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(rooms = [[1, 1000000], [2, 999999], [3, 999998], [4, 999997], [5, 999996], [6, 999995], [7, 999994], [8, 999993], [9, 999992], [10, 999991]],queries = [[1, 999991], [2, 999992], [3, 999993], [4, 999994], [5, 999995], [6, 999996], [7, 999997], [8, 999998], [9, 999999], [10, 1000000]]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10]]) == [1, 2, 3, 4, 5, -1, -1, -1, -1, -1]\n assert candidate(rooms = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [1, 2, 3, 2, 1, -1, -1, -1, -1, -1]\n assert candidate(rooms = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996]],queries = [[1, 9999999], [2, 9999998], [3, 9999997], [4, 9999996], [5, 9999995], [6, 9999994], [7, 9999993]]) == [1, 2, 3, 4, 5, 5, 5]\n assert candidate(rooms = [[1000, 1], [2000, 2], [3000, 3], [4000, 4], [5000, 5], [6000, 6], [7000, 7], [8000, 8], [9000, 9], [10000, 10]],queries = [[500, 1], [1500, 2], [2500, 3], [3500, 4], [4500, 5], [5500, 6], [6500, 7], [7500, 8], [8500, 9], [9500, 10]]) == [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]\n assert candidate(rooms = [[10000000, 1], [9000000, 2], [8000000, 3], [7000000, 4], [6000000, 5], [5000000, 6], [4000000, 7], [3000000, 8], [2000000, 9], [1000000, 10]],queries = [[500000, 1], [1500000, 2], [2500000, 3], [3500000, 4], [4500000, 5], [5500000, 6], [6500000, 7], [7500000, 8], [8500000, 9], [9500000, 10], [10500000, 1]]) == [1000000, 1000000, 2000000, 3000000, 4000000, 5000000, 4000000, 3000000, 2000000, 1000000, 10000000]\n assert candidate(rooms = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 10]]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 1]\n assert candidate(rooms = [[1, 10000], [2, 9000], [3, 8000], [4, 7000], [5, 6000], [6, 5000], [7, 4000], [8, 3000], [9, 2000], [10, 1000]],queries = [[1, 10000], [2, 9000], [3, 8000], [4, 7000], [5, 6000], [6, 5000], [7, 4000], [8, 3000], [9, 2000], [10, 1000], [11, 500]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10]\n assert candidate(rooms = [[1000, 10], [2000, 20], [3000, 30], [4000, 40], [5000, 50]],queries = [[1500, 5], [2500, 15], [3500, 25], [4500, 35], [5500, 45]]) == [1000, 2000, 3000, 4000, 5000]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],queries = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]]) == [1, 2, 3, 4, 5]\n assert candidate(rooms = [[1, 1], [3, 3], [5, 5]],queries = [[2, 2], [4, 4]]) == [3, 5]\n assert candidate(rooms = [[10, 5], [20, 5], [30, 5], [40, 5], [50, 5]],queries = [[15, 5], [25, 5], [35, 5], [45, 5], [55, 5]]) == [10, 20, 30, 40, 50]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30]],queries = [[1, 10], [2, 20], [3, 30]]) == [1, 2, 3]\n assert candidate(rooms = [[5, 10], [10, 10], [15, 10]],queries = [[7, 5], [12, 5], [17, 5]]) == [5, 10, 15]\n assert candidate(rooms = [[7, 10], [15, 20], [25, 30]],queries = [[10, 10], [20, 20], [30, 30], [40, 40]]) == [7, 15, 25, -1]\n assert candidate(rooms = [[10, 10], [20, 20], [30, 30]],queries = [[15, 10], [25, 20], [35, 30]]) == [10, 20, 30]\n assert candidate(rooms = [[5, 5], [15, 15], [25, 25], [35, 35]],queries = [[10, 5], [20, 15], [30, 25], [40, 35]]) == [5, 15, 25, 35]\n assert candidate(rooms = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5]],queries = [[1, 1], [6, 2], [11, 3], [16, 4], [21, 5], [26, 6]]) == [5, 10, 15, 20, 25, -1]\n assert candidate(rooms = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5]],queries = [[3, 1], [3, 2], [3, 3], [3, 4], [3, 5]]) == [3, 3, 3, 2, 1]\n assert candidate(rooms = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]],queries = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]]) == [1, 2, 3, 4, 5]\n assert candidate(rooms = [[7, 7], [14, 14], [21, 21], [28, 28]],queries = [[7, 7], [14, 14], [21, 21], [28, 28], [35, 35]]) == [7, 14, 21, 28, -1]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],queries = [[3, 5], [3, 15], [3, 25], [3, 35], [3, 45]]) == [3, 3, 3, 4, 5]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 8]],queries = [[15, 3], [25, 7], [10, 5]]) == [10, 30, 10]\n assert candidate(rooms = [[1, 10000000]],queries = [[1, 10000000], [1, 9999999], [1, 10000001]]) == [1, 1, -1]\n assert candidate(rooms = [[10, 10], [20, 20], [30, 30]],queries = [[15, 10], [25, 15], [35, 25]]) == [10, 20, 30]\n assert candidate(rooms = [[1, 10000000], [10000000, 1]],queries = [[5000000, 5000000], [10000000, 1], [1, 10000000]]) == [1, 10000000, 1]\n assert candidate(rooms = [[7, 7], [17, 17], [27, 27], [37, 37]],queries = [[5, 7], [15, 17], [25, 27], [35, 37]]) == [7, 17, 27, 37]\n assert candidate(rooms = [[1, 10], [10, 1], [2, 9], [9, 2], [3, 8], [8, 3]],queries = [[5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == [3, 3, 8, 8, 9]\n assert candidate(rooms = [[7, 10], [5, 15], [12, 20], [3, 25]],queries = [[6, 15], [8, 10], [15, 20]]) == [5, 7, 12]\n assert candidate(rooms = [[5, 10], [6, 11], [7, 12]],queries = [[5, 10], [6, 11], [7, 12]]) == [5, 6, 7]\n assert candidate(rooms = [[100, 100], [200, 200], [300, 300]],queries = [[150, 150], [250, 250], [50, 50]]) == [200, 300, 100]\n assert candidate(rooms = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],queries = [[3, 5], [3, 10], [3, 15]]) == [3, 3, -1]\n assert candidate(rooms = [[100, 10], [200, 20], [300, 30], [400, 40], [500, 50]],queries = [[150, 15], [250, 25], [350, 35], [450, 45], [550, 55]]) == [200, 300, 400, 500, -1]\n assert candidate(rooms = [[5, 10], [15, 8], [25, 12], [35, 9]],queries = [[10, 10], [20, 8], [30, 12], [40, 9]]) == [5, 15, 25, 35]\n assert candidate(rooms = [[100, 100], [200, 100], [300, 100]],queries = [[150, 100], [250, 100], [50, 100]]) == [100, 200, 100]\n assert candidate(rooms = [[1, 10000000], [10000000, 1]],queries = [[5000000, 5000000], [10000000, 10000000], [1, 1]]) == [1, 1, 1]\n assert candidate(rooms = [[7, 7], [8, 8], [9, 9]],queries = [[10, 10], [11, 11], [12, 12]]) == [-1, -1, -1]\n assert candidate(rooms = [[100, 10], [200, 20], [300, 30]],queries = [[150, 15], [250, 25], [50, 5], [350, 35]]) == [200, 300, 100, -1]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],queries = [[1, 5], [2, 15], [3, 25], [4, 35], [5, 45]]) == [1, 2, 3, 4, 5]\n assert candidate(rooms = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]],queries = [[15, 1], [25, 2], [35, 3], [45, 4]]) == [10, 20, 30, 40]\n assert candidate(rooms = [[10, 5], [20, 5], [30, 5]],queries = [[25, 5], [15, 5], [5, 5], [35, 5]]) == [20, 10, 10, 30]\n assert candidate(rooms = [[1, 10000000], [10000000, 1]],queries = [[1, 1], [10000000, 10000000], [5000000, 5000000]]) == [1, 1, 1]\n assert candidate(rooms = [[1, 10000000], [2, 9999999], [3, 9999998]],queries = [[2, 9999999], [1, 10000000], [3, 9999998]]) == [2, 1, 3]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(rooms = [[5, 5], [4, 4], [3, 3], [2, 2], [1, 1]],queries = [[3, 3], [2, 2], [1, 1], [6, 6], [0, 0]]) == [3, 2, 1, -1, 1]\n assert candidate(rooms = [[1, 1]],queries = [[1, 1], [2, 1], [3, 1]]) == [1, 1, 1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6]]) == [3, 3, 3, 4, 5, -1]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 7]],queries = [[15, 3], [25, 6], [35, 8]]) == [10, 30, -1]\n assert candidate(rooms = [[100000, 100000], [1, 1], [50000, 50000]],queries = [[100000, 100000], [1, 1], [50000, 50000], [25000, 50000]]) == [100000, 1, 50000, 50000]\n assert candidate(rooms = [[1, 10000000], [2, 9999999], [3, 9999998]],queries = [[1, 10000000], [2, 9999999], [3, 9999998]]) == [1, 2, 3]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],queries = [[3, 15], [3, 25], [3, 35], [3, 45], [3, 55]]) == [3, 3, 4, 5, -1]\n assert candidate(rooms = [[5, 10], [15, 10], [25, 10]],queries = [[10, 10], [20, 10], [30, 10]]) == [5, 15, 25]\n assert candidate(rooms = [[5, 5], [5, 5], [5, 5]],queries = [[5, 5], [5, 5], [5, 5]]) == [5, 5, 5]\n assert candidate(rooms = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],queries = [[3, 10], [3, 11], [3, 9]]) == [3, -1, 3]\n assert candidate(rooms = [[10000000, 1], [9999999, 2], [9999998, 3]],queries = [[10000000, 1], [9999999, 2], [9999998, 3]]) == [10000000, 9999999, 9999998]\n assert candidate(rooms = [[10, 5], [20, 7], [30, 9]],queries = [[15, 6], [25, 8], [35, 10]]) == [20, 30, -1]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 7], [40, 2], [50, 6]],queries = [[15, 4], [25, 3], [35, 5], [45, 2]]) == [10, 20, 30, 40]\n assert candidate(rooms = [[5, 5], [6, 6], [7, 7]],queries = [[5, 6], [6, 7], [7, 8]]) == [6, 7, -1]\n assert candidate(rooms = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [1, 2, 3, 4, 5]\n assert candidate(rooms = [[1, 10000000], [2, 10000000], [3, 10000000]],queries = [[1, 10000000], [2, 10000000], [3, 10000000]]) == [1, 2, 3]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [5, 6, 7, 8, 9]\n assert candidate(rooms = [[7, 7], [8, 8], [9, 9]],queries = [[7, 7], [8, 8], [9, 9], [10, 10]]) == [7, 8, 9, -1]\n assert candidate(rooms = [[1, 10000000], [10000000, 1]],queries = [[5000000, 1], [5000000, 10000000], [1, 1], [10000000, 1]]) == [1, 1, 1, 10000000]\n assert candidate(rooms = [[1, 10000000], [10000000, 1]],queries = [[5000000, 5000000], [10000000, 10000000]]) == [1, 1]\n assert candidate(rooms = [[5, 5], [3, 3], [1, 1], [7, 7]],queries = [[4, 4], [6, 6], [2, 2], [8, 8]]) == [5, 7, 3, -1]\n assert candidate(rooms = [[100, 10], [200, 20], [300, 30]],queries = [[150, 15], [250, 25], [350, 35]]) == [200, 300, -1]\n assert candidate(rooms = [[10, 5], [20, 4], [30, 3], [40, 2], [50, 1]],queries = [[15, 4], [25, 3], [35, 2], [45, 1], [55, 1]]) == [10, 20, 30, 40, 50]\n assert candidate(rooms = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],queries = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10]]) == [1, 2, 3, 4, 5, 5]\n assert candidate(rooms = [[100, 100], [200, 90], [300, 80], [400, 70], [500, 60]],queries = [[150, 90], [250, 80], [350, 70]]) == [100, 200, 300]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[3, 3], [1, 1], [2, 2], [4, 4], [5, 5]]) == [3, 1, 2, 4, 5]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 4], [40, 2]],queries = [[25, 3], [15, 5], [35, 4]]) == [20, 10, 30]\n assert candidate(rooms = [[1, 1], [3, 3], [5, 5], [7, 7], [9, 9]],queries = [[2, 1], [4, 3], [6, 5], [8, 7], [10, 9]]) == [1, 3, 5, 7, 9]\n assert candidate(rooms = [[1, 100], [100, 1], [50, 50]],queries = [[50, 1], [50, 50], [50, 100]]) == [50, 50, 1]\n assert candidate(rooms = [[5, 10], [10, 10], [15, 10], [20, 10], [25, 10]],queries = [[7, 5], [12, 8], [17, 11], [22, 14], [27, 17]]) == [5, 10, -1, -1, -1]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 4], [40, 6]],queries = [[25, 3], [15, 5], [35, 4]]) == [20, 10, 30]\n assert candidate(rooms = [[100, 10], [200, 20], [300, 30], [400, 40]],queries = [[150, 5], [250, 15], [350, 25], [450, 35]]) == [100, 200, 300, 400]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 6], [40, 4]],queries = [[15, 4], [25, 5], [35, 6]]) == [10, 30, 30]\n assert candidate(rooms = [[10, 10], [20, 20], [30, 30]],queries = [[15, 5], [25, 25], [35, 15]]) == [10, 30, 30]\n assert candidate(rooms = [[1000, 1000], [2000, 1000], [3000, 1000]],queries = [[1500, 1000], [2500, 1000], [500, 1000]]) == [1000, 2000, 1000]\n assert candidate(rooms = [[1, 10], [2, 20], [3, 30]],queries = [[1, 5], [2, 15], [3, 25]]) == [1, 2, 3]\n assert candidate(rooms = [[1, 5], [2, 5], [3, 5]],queries = [[1, 6], [2, 6], [3, 6]]) == [-1, -1, -1]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 4], [40, 2]],queries = [[15, 3], [25, 4], [35, 5]]) == [10, 30, 10]\n assert candidate(rooms = [[10, 5], [20, 6], [30, 7]],queries = [[15, 5], [25, 6], [35, 7]]) == [10, 20, 30]\n assert candidate(rooms = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]],queries = [[5, 5], [15, 4], [25, 3], [35, 2], [45, 1], [55, 6]]) == [50, 40, 30, 30, 40, -1]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 8], [40, 7]],queries = [[15, 4], [25, 6], [35, 7]]) == [10, 30, 30]\n assert candidate(rooms = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]],queries = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9]]) == [1, 2, 3, 3, 2]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1]]) == [5, 4, 3, 4, 5]\n assert candidate(rooms = [[100, 1], [200, 2], [300, 3]],queries = [[99, 1], [199, 2], [299, 3]]) == [100, 200, 300]\n assert candidate(rooms = [[10, 10], [20, 20], [30, 30]],queries = [[15, 5], [25, 15], [35, 25]]) == [10, 20, 30]\n assert candidate(rooms = [[1, 10000000], [10000000, 1]],queries = [[5000000, 5000000], [1, 1], [10000000, 10000000]]) == [1, 1, 1]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 8]],queries = [[15, 4], [25, 3], [35, 9]]) == [10, 20, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[3, 1], [3, 2], [3, 3], [3, 4], [3, 5]]) == [3, 3, 3, 4, 5]\n assert candidate(rooms = [[5, 10], [15, 20], [25, 30]],queries = [[10, 15], [20, 25], [30, 35]]) == [15, 25, -1]\n assert candidate(rooms = [[1, 5], [3, 5], [5, 5], [7, 5], [9, 5]],queries = [[2, 5], [4, 5], [6, 5], [8, 5]]) == [1, 3, 5, 7]\n assert candidate(rooms = [[100, 10], [200, 20], [300, 30]],queries = [[50, 5], [150, 15], [250, 25]]) == [100, 200, 300]\n assert candidate(rooms = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50]],queries = [[10, 5], [20, 15], [30, 25], [40, 35], [50, 45]]) == [5, 15, 25, 35, 45]\n assert candidate(rooms = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5]],queries = [[5, 1], [15, 2], [25, 3], [35, 4], [45, 5]]) == [10, 20, 30, 40, 50]\n assert candidate(rooms = [[5, 10], [15, 15], [25, 20], [35, 25], [45, 30]],queries = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50]]) == [5, 25, 45, -1, -1]\n assert candidate(rooms = [[1, 1], [10, 10], [100, 100]],queries = [[5, 1], [50, 10], [500, 100], [5000, 50]]) == [1, 10, 100, 100]\n assert candidate(rooms = [[10, 5], [20, 3], [30, 8]],queries = [[15, 3], [25, 6], [35, 10]]) == [10, 30, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(rooms = [[10000000, 10000000]],queries = [[10000000, 10000000], [9999999, 10000000], [10000001, 10000000]]) == [10000000, 10000000, 10000000]\n assert candidate(rooms = [[10, 5], [20, 4], [30, 3], [40, 2], [50, 1]],queries = [[15, 2], [25, 3], [35, 4]]) == [10, 20, 20]\n assert candidate(rooms = [[100, 100], [200, 200], [300, 300], [400, 400]],queries = [[150, 100], [250, 200], [350, 300], [450, 400]]) == [100, 200, 300, 400]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[3, 1], [4, 2], [5, 3], [6, 4], [7, 5]]) == [3, 4, 5, 5, 5]\n assert candidate(rooms = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],queries = [[1, 1], [5, 5], [10, 10]]) == [1, 5, 1]\n assert candidate(rooms = [[1, 5], [2, 6], [3, 7]],queries = [[1, 6], [2, 7], [3, 8]]) == [2, 3, -1]\n assert candidate(rooms = [[5, 5], [15, 15], [25, 25], [35, 35]],queries = [[10, 10], [20, 20], [30, 30], [40, 40]]) == [15, 25, 35, -1]\n assert candidate(rooms = [[7, 7], [8, 8], [9, 9]],queries = [[7, 7], [8, 8], [9, 9], [6, 6], [10, 10]]) == [7, 8, 9, 7, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [1, 2, 3, 4, 5]\n assert candidate(rooms = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5]],queries = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == [1, 2, 3, 2, 1]\n assert candidate(rooms = [[1, 10000000], [2, 10000000], [3, 10000000]],queries = [[1, 10000000], [2, 10000000], [3, 10000000], [4, 10000000]]) == [1, 2, 3, 3]\n assert candidate(rooms = [[10000000, 10000000]],queries = [[10000000, 10000000], [9999999, 9999999], [10000001, 10000001]]) == [10000000, 10000000, -1]\n assert candidate(rooms = [[1, 10], [2, 10], [3, 10]],queries = [[1, 5], [2, 10], [3, 15]]) == [1, 2, -1]\n assert candidate(rooms = [[100, 100], [200, 200], [300, 300], [400, 400]],queries = [[50, 50], [150, 150], [250, 250], [350, 350], [450, 450]]) == [100, 200, 300, 400, -1]\n assert candidate(rooms = [[1000, 100], [2000, 200], [3000, 300], [4000, 400]],queries = [[1500, 50], [2500, 150], [3500, 250], [4500, 350]]) == [1000, 2000, 3000, 4000]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[3, 2], [4, 3], [5, 4]]) == [3, 4, 5]\n assert candidate(rooms = [[10, 5], [20, 4], [30, 3]],queries = [[15, 4], [25, 3], [5, 6]]) == [10, 20, -1]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[6, 1], [7, 2], [8, 3], [9, 4], [10, 5]]) == [5, 5, 5, 5, 5]\n assert candidate(rooms = [[10, 5], [20, 5], [30, 5]],queries = [[15, 5], [25, 5], [5, 5]]) == [10, 20, 10]\n assert candidate(rooms = [[1, 10000000], [2, 10000000], [3, 10000000], [4, 10000000], [5, 10000000]],queries = [[3, 10000000], [3, 10000001], [3, 9999999]]) == [3, -1, 3]\n assert candidate(rooms = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5]],queries = [[50, 1], [150, 2], [250, 3], [350, 4], [450, 5]]) == [100, 200, 300, 400, 500]\n assert candidate(rooms = [[10000000, 10000000]],queries = [[10000000, 10000000]]) == [10000000]\n assert candidate(rooms = [[10000000, 10000000], [1, 1]],queries = [[10000000, 10000000], [2, 1]]) == [10000000, 1]\n assert candidate(rooms = [[10, 10], [20, 20], [30, 30]],queries = [[25, 15], [15, 10], [35, 25]]) == [20, 10, 30]\n assert candidate(rooms = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [[3, 3], [3, 4], [3, 5], [3, 6], [3, 2], [3, 1]]) == [3, 4, 5, -1, 3, 3]\n assert candidate(rooms = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25]],queries = [[7, 6], [12, 11], [17, 16], [22, 21], [27, 26]]) == [10, 15, 20, 25, -1]\n"}, "metadata": {"canonical_parameter_names": ["rooms", "queries"], "leetcode_dataset_entry_point": "Solution().closestRoom", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector closestRoom(vector>& rooms, vector>& queries) {", "container": "Solution", "callable": "closestRoom", "parameters": [{"name": "rooms", "type": "vector>&"}, {"name": "queries", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1848, "task_id": "minimum-distance-to-the-target-element", "difficulty": "Easy", "problem_description": "Given an integer array nums (0-indexed) and two integers target and start, find an index i such that nums[i] == target and abs(i - start) is minimized. Note that abs(x) is the absolute value of x.\nReturn abs(i - start).\nIt is guaranteed that target exists in nums.\n \nExample 1:\n\nInput: nums = [1,2,3,4,5], target = 5, start = 3\nOutput: 1\nExplanation: nums[4] = 5 is the only value equal to target, so the answer is abs(4 - 3) = 1.\n\nExample 2:\n\nInput: nums = [1], target = 1, start = 0\nOutput: 0\nExplanation: nums[0] = 1 is the only value equal to target, so the answer is abs(0 - 0) = 0.\n\nExample 3:\n\nInput: nums = [1,1,1,1,1,1,1,1,1,1], target = 1, start = 0\nOutput: 0\nExplanation: Every value of nums is 1, but nums[0] minimizes abs(i - start), which is abs(0 - 0) = 0.\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n1 <= nums[i] <= 104\n0 <= start < nums.length\ntarget is in nums.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 1, 4, 1],target = 1,start = 2) == 1\n assert candidate(nums = [1, 5, 3, 4, 5],target = 5,start = 2) == 1\n assert candidate(nums = [4, 1, 3, 5, 2],target = 2,start = 1) == 3\n assert candidate(nums = [4, 1, 3, 5, 6],target = 3,start = 1) == 1\n assert candidate(nums = [4, 1, 3, 5, 2],target = 1,start = 2) == 1\n assert candidate(nums = [5, 1, 4, 1, 2],target = 1,start = 0) == 1\n assert candidate(nums = [1],target = 1,start = 0) == 0\n assert candidate(nums = [4, 1, 3, 5, 6],target = 1,start = 2) == 1\n assert candidate(nums = [5, 1, 4, 1, 2],target = 1,start = 1) == 0\n assert candidate(nums = [5, 1, 4, 1, 2],target = 1,start = 2) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 1,start = 0) == 0\n assert candidate(nums = [1, 2, 3, 4, 5],target = 5,start = 3) == 1\n assert candidate(nums = [7, 8, 9, 5, 6, 5, 4, 5, 3, 5],target = 5,start = 4) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15,start = 9) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 5,start = 9) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 500,start = 3) == 1\n assert candidate(nums = [7, 2, 5, 8, 3, 9, 1, 5],target = 5,start = 4) == 2\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],target = 18,start = 8) == 3\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],target = 3,start = 5) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 19,start = 4) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 30,start = 0) == 2\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],target = 2,start = 15) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],target = 6,start = 9) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 10,start = 19) == 10\n assert candidate(nums = [1, 3, 5, 2, 4, 3, 2, 1, 3],target = 3,start = 5) == 0\n assert candidate(nums = [10, 23, 56, 78, 90, 12, 34, 56, 78, 90],target = 56,start = 5) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 2,start = 10) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],target = 15,start = 20) == 6\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 700,start = 0) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 60,start = 5) == 0\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 20,start = 15) == 15\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],target = -3,start = 8) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 7,start = 9) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 10,start = 14) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 1,start = 9) == 9\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 15,start = 9) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 15,start = 4) == 3\n assert candidate(nums = [5, 3, 8, 6, 2, 10, 1, 4],target = 10,start = 3) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 12,start = 10) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 15,start = 0) == 14\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 1,start = 5) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 50,start = 2) == 2\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0, -1],target = 0,start = 4) == 4\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991],target = 997,start = 2) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],target = 35,start = 9) == 3\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 3,start = 15) == 0\n assert candidate(nums = [2, 5, 4, 7, 8, 6, 1, 3, 9, 0],target = 3,start = 8) == 1\n assert candidate(nums = [5, 2, 3, 4, 5, 1, 5],target = 5,start = 3) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = 16,start = 0) == 7\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 7],target = 7,start = 5) == 4\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5],target = 1,start = 4) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = 2,start = 9) == 9\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],target = 4,start = 10) == 0\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 10,start = 7) == 2\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],target = 93,start = 8) == 2\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = 12,start = 3) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 13,start = 19) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],target = 15,start = 0) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],target = 39,start = 0) == 19\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],target = 65,start = 5) == 1\n assert candidate(nums = [1000, 500, 250, 125, 63, 31, 16, 8, 4, 2, 1],target = 16,start = 5) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 500,start = 9) == 5\n assert candidate(nums = [45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59],target = 50,start = 14) == 9\n assert candidate(nums = [3, 2, 1, 3, 2, 1, 3, 2, 1, 3],target = 1,start = 4) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2],target = 10,start = 9) == 5\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 10,start = 0) == 10\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],target = 60,start = 4) == 0\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],target = 7,start = 7) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 40,start = 0) == 3\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 5,start = 10) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 19,start = 9) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10,start = 0) == 9\n assert candidate(nums = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1],target = 1,start = 19) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 7, 5, 3, 1],target = 9,start = 4) == 0\n assert candidate(nums = [5, 3, 2, 5, 3, 5, 2, 5, 3, 5],target = 3,start = 4) == 0\n assert candidate(nums = [1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],target = 2,start = 7) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],target = 19,start = 12) == 3\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981],target = 985,start = 15) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],target = 500,start = 9) == 5\n assert candidate(nums = [3, 4, 2, 5, 1, 5, 3, 2, 5],target = 5,start = 4) == 1\n assert candidate(nums = [7, 1, 3, 4, 2, 5, 7, 6, 7, 8],target = 7,start = 5) == 1\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, 9, 8],target = 0,start = 5) == 2\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10,start = 5) == 8\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 5,start = 10) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15,start = 10) == 4\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7],target = 2,start = 6) == 1\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],target = 4,start = 9) == 0\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009],target = 1009,start = 2) == 7\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],target = 0,start = 9) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],target = 18,start = 10) == 2\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5],target = 2,start = 4) == 1\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7],target = 5,start = 10) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 1,start = 19) == 19\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],target = 7,start = 15) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 13,start = 5) == 1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],target = 23,start = 0) == 8\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11],target = 15,start = 5) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 10,start = 7) == 2\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15],target = 12,start = 3) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 30,start = 5) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 7,start = 0) == 6\n assert candidate(nums = [8, 6, 4, 2, 0, 2, 4, 6, 8],target = 0,start = 4) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],target = 0,start = 10) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 3,start = 8) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],target = 25,start = 15) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 10,start = 0) == 9\n assert candidate(nums = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],target = 3,start = 6) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 5,start = 5) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 1,start = 19) == 19\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9],target = -4,start = 8) == 5\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = 18,start = 9) == 1\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],target = 18,start = 12) == 4\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 7,start = 3) == 1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],target = 5,start = 5) == 1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],target = 5,start = 9) == 5\n assert candidate(nums = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29],target = 20,start = 4) == 2\n assert candidate(nums = [10, 22, 33, 44, 55, 66, 77, 88, 99],target = 88,start = 0) == 7\n"}, "metadata": {"canonical_parameter_names": ["nums", "target", "start"], "leetcode_dataset_entry_point": "Solution().getMinDistance", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int getMinDistance(vector& nums, int target, int start) {", "container": "Solution", "callable": "getMinDistance", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "target", "type": "int"}, {"name": "start", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1849, "task_id": "splitting-a-string-into-descending-consecutive-values", "difficulty": "Medium", "problem_description": "You are given a string s that consists of only digits.\nCheck if we can split s into two or more non-empty substrings such that the numerical values of the substrings are in descending order and the difference between numerical values of every two adjacent substrings is equal to 1.\n\nFor example, the string s = \"0090089\" can be split into [\"0090\", \"089\"] with numerical values [90,89]. The values are in descending order and adjacent values differ by 1, so this way is valid.\nAnother example, the string s = \"001\" can be split into [\"0\", \"01\"], [\"00\", \"1\"], or [\"0\", \"0\", \"1\"]. However all the ways are invalid because they have numerical values [0,1], [0,1], and [0,0,1] respectively, all of which are not in descending order.\n\nReturn true if it is possible to split s​​​​​​ as described above, or false otherwise.\nA substring is a contiguous sequence of characters in a string.\n \nExample 1:\n\nInput: s = \"1234\"\nOutput: false\nExplanation: There is no valid way to split s.\n\nExample 2:\n\nInput: s = \"050043\"\nOutput: true\nExplanation: s can be split into [\"05\", \"004\", \"3\"] with numerical values [5,4,3].\nThe values are in descending order with adjacent values differing by 1.\n\nExample 3:\n\nInput: s = \"9080701\"\nOutput: false\nExplanation: There is no valid way to split s.\n\n \nConstraints:\n\n1 <= s.length <= 20\ns only consists of digits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"21\") == True\n assert candidate(s = \"9876543210\") == True\n assert candidate(s = \"050043\") == True\n assert candidate(s = \"989796959493929190\") == True\n assert candidate(s = \"1009998\") == True\n assert candidate(s = \"2120191817\") == True\n assert candidate(s = \"1201100009\") == False\n assert candidate(s = \"212120\") == False\n assert candidate(s = \"10010\") == False\n assert candidate(s = \"0000\") == False\n assert candidate(s = \"1234\") == False\n assert candidate(s = \"11110\") == False\n assert candidate(s = \"111121111\") == False\n assert candidate(s = \"1111111111\") == False\n assert candidate(s = \"989796\") == True\n assert candidate(s = \"1010\") == False\n assert candidate(s = \"9080701\") == False\n assert candidate(s = \"98765432109\") == False\n assert candidate(s = \"999988887777666655554444333322221111\") == False\n assert candidate(s = \"1001000\") == False\n assert candidate(s = \"543210\") == True\n assert candidate(s = \"1\") == False\n assert candidate(s = \"101010\") == False\n assert candidate(s = \"1000999898\") == False\n assert candidate(s = \"00000\") == False\n assert candidate(s = \"001\") == False\n assert candidate(s = \"2222222221222222211222221022221922218\") == False\n assert candidate(s = \"5432109876543210\") == False\n assert candidate(s = \"545454545454545454545454545454545454\") == False\n assert candidate(s = \"89888786858483828180797877767574737271706968676665646362616059585756555453525150494847464544434241403938373635343332313029282726252423222120191817161514131211109876543210\") == True\n assert candidate(s = \"100999989876543210\") == False\n assert candidate(s = \"10101010101010101010100999999999999999\") == False\n assert candidate(s = \"444444444344444443344444324444314444304443294442844417444064435442444134440244314420441944084397428641754064\") == False\n assert candidate(s = \"99888877776666555544443333222211110000\") == False\n assert candidate(s = \"22222222222222222221\") == True\n assert candidate(s = \"99887766554433221100\") == False\n assert candidate(s = \"1121112111110101001000\") == False\n assert candidate(s = \"10099988877766655544433322211100\") == False\n assert candidate(s = \"100009999888877776666555544443333222211110000\") == False\n assert candidate(s = \"11111111111111111112\") == False\n assert candidate(s = \"987876757473727170\") == False\n assert candidate(s = \"1232109876543210987654321\") == False\n assert candidate(s = \"191817161514131211109876543210987654321\") == False\n assert candidate(s = \"987654321987654320\") == True\n assert candidate(s = \"09080706050403020100\") == True\n assert candidate(s = \"000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\") == False\n assert candidate(s = \"111111111111111111101111111111111110\") == False\n assert candidate(s = \"100999888777666555444333222111000\") == False\n assert candidate(s = \"000011110000222200003333000044440000555500006666000077770000888800009999\") == False\n assert candidate(s = \"123432109876543210\") == False\n assert candidate(s = \"1234567898765432109876543210\") == False\n assert candidate(s = \"00009999888877776666555544443333\") == False\n assert candidate(s = \"00010020030040050060070080090100110012001300140015\") == False\n assert candidate(s = \"98765432100987654321\") == False\n assert candidate(s = \"999888777666555444333222111000123456789000987654321\") == False\n assert candidate(s = \"100000111110000011111000001111100000\") == False\n assert candidate(s = \"5432154320543195430853975296519509498487476465454443424140\") == False\n assert candidate(s = \"98979695949392919089888786858483828180797877767574737271706968676665646362616059585756555453525150\") == True\n assert candidate(s = \"20191817161514131211109876543210\") == True\n assert candidate(s = \"987654321009876543209\") == True\n assert candidate(s = \"999888777666555444333222111000\") == False\n assert candidate(s = \"21201918171615141312111009080706050403020100\") == True\n assert candidate(s = \"123321123321123321123321123321123321\") == False\n assert candidate(s = \"9897969594939291908988878685848382818079\") == True\n assert candidate(s = \"1098765432110987654\") == False\n assert candidate(s = \"9080706050403020100\") == True\n assert candidate(s = \"807978777675747372717069686766656463626160\") == True\n assert candidate(s = \"98798765432109876543210\") == False\n assert candidate(s = \"987654321010987654321010987654321010\") == False\n assert candidate(s = \"99999999999999999999\") == False\n assert candidate(s = \"11111111111111111111\") == False\n assert candidate(s = \"2120191817161514131211109876543210\") == True\n assert candidate(s = \"555555555555555555544444444444444443\") == False\n assert candidate(s = \"101009988776655443322110\") == False\n assert candidate(s = \"11111011110111101110110\") == False\n assert candidate(s = \"10000999988887777666655554444333322221111\") == False\n assert candidate(s = \"9999888877776666555544443333222211110000111122223333444455556666777788889999\") == False\n assert candidate(s = \"191817161514131211109876543210\") == True\n assert candidate(s = \"9876543210987654321098765432109876543210\") == False\n assert candidate(s = \"98765432109876543210\") == False\n assert candidate(s = \"100000000000000000010000000000000000\") == False\n assert candidate(s = \"56555453525150494847464544434241403938373635343332313029282726252423222120191817161514131211109876543210\") == True\n assert candidate(s = \"101010109101010810101071010106101010510101041010103101010210101011010100101009101008101007101006101005\") == False\n assert candidate(s = \"10010010010010010010\") == False\n assert candidate(s = \"76543210987654321098765432109876543210987654320\") == False\n assert candidate(s = \"8070605040302010\") == True\n assert candidate(s = \"987654321987654321\") == False\n assert candidate(s = \"222222222222222222222222222222222222\") == False\n assert candidate(s = \"9876543210109876543210\") == False\n assert candidate(s = \"2021222324252627282930\") == False\n assert candidate(s = \"65432165431654306542965418654076436642564146403639262816170\") == False\n assert candidate(s = \"123456789876543210987654321\") == False\n assert candidate(s = \"32313029282726252423222120191817161514131211109876543210\") == True\n assert candidate(s = \"111110000099999888887777766666555554444433333222221111100000\") == False\n assert candidate(s = \"987654321000000\") == True\n assert candidate(s = \"11211110110109108107106105104103102101100\") == False\n assert candidate(s = \"87654321098765432109876543210987\") == False\n assert candidate(s = \"1000100100200300400500600700800900\") == False\n assert candidate(s = \"9999888877776666555544443333222211110000\") == False\n assert candidate(s = \"9876543210987654321\") == False\n assert candidate(s = \"545352515049484746454443424140393837363534\") == True\n assert candidate(s = \"10010009999897969594939291908988878685848382818079787776757473727170696867666564636261605958575655545352515049484746454443424140393837363534333231302928272625242322212019181716151413121110987654321\") == False\n assert candidate(s = \"543211098765432109876543210\") == False\n assert candidate(s = \"0102030405060708091011121314151617181920\") == False\n assert candidate(s = \"111122223333444455556666777788889999000000001111\") == False\n assert candidate(s = \"54321543215432154321\") == False\n assert candidate(s = \"12345678909876543210\") == False\n assert candidate(s = \"999888777666555444333222111\") == False\n assert candidate(s = \"10010020030040050060070080090101011012013014015016017018019020\") == False\n assert candidate(s = \"987654321009876543210\") == False\n assert candidate(s = \"12321231230231231230231230231023\") == False\n assert candidate(s = \"2222222222222222222222222222222222222222222111111111111111111111111111111111111111111111111111111111\") == False\n assert candidate(s = \"1121111101091081071061051041031021011009998979695949392919089888786858483828180797877767574737271706968676665646362616059585756555453525150\") == True\n assert candidate(s = \"00000000000000000000\") == False\n assert candidate(s = \"123432100999888777666555444333222111000123\") == False\n assert candidate(s = \"9876556789\") == False\n assert candidate(s = \"987654321098765432109876543210\") == False\n assert candidate(s = \"123212321232123212321\") == False\n assert candidate(s = \"0000111122223333444455556666777788889999\") == False\n assert candidate(s = \"876543210987654321098765432109876543210987654321\") == False\n assert candidate(s = \"987654321011121314151617181920\") == False\n assert candidate(s = \"9876543210123456789\") == False\n assert candidate(s = \"151413121110090807060504030201000000000000000000000000000000000000000000000000000000000000000000000000000\") == True\n assert candidate(s = \"12321211110100998877665544332211\") == False\n assert candidate(s = \"1009999888777666555444333222111\") == False\n assert candidate(s = \"10987654321098765432109876543210\") == False\n assert candidate(s = \"00000000000000000001\") == False\n assert candidate(s = \"12341233123212311230\") == True\n assert candidate(s = \"11111111110111111110011111109999988888\") == False\n assert candidate(s = \"111122223333444455556666777788889999\") == False\n assert candidate(s = \"9879876543210\") == False\n assert candidate(s = \"1000000000000000000010000000000000000001\") == False\n assert candidate(s = \"10109080706050403020100\") == False\n assert candidate(s = \"999898979695949392919089888786858483828180\") == False\n assert candidate(s = \"000000001000000000\") == True\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().splitString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool splitString(string s) {", "container": "Solution", "callable": "splitString", "parameters": [{"name": "s", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1850, "task_id": "minimum-adjacent-swaps-to-reach-the-kth-smallest-number", "difficulty": "Medium", "problem_description": "You are given a string num, representing a large integer, and an integer k.\nWe call some integer wonderful if it is a permutation of the digits in num and is greater in value than num. There can be many wonderful integers. However, we only care about the smallest-valued ones.\n\nFor example, when num = \"5489355142\":\n\n\t\nThe 1st smallest wonderful integer is \"5489355214\".\nThe 2nd smallest wonderful integer is \"5489355241\".\nThe 3rd smallest wonderful integer is \"5489355412\".\nThe 4th smallest wonderful integer is \"5489355421\".\n\n\n\nReturn the minimum number of adjacent digit swaps that needs to be applied to num to reach the kth smallest wonderful integer.\nThe tests are generated in such a way that kth smallest wonderful integer exists.\n \nExample 1:\n\nInput: num = \"5489355142\", k = 4\nOutput: 2\nExplanation: The 4th smallest wonderful number is \"5489355421\". To get this number:\n- Swap index 7 with index 8: \"5489355142\" -> \"5489355412\"\n- Swap index 8 with index 9: \"5489355412\" -> \"5489355421\"\n\nExample 2:\n\nInput: num = \"11112\", k = 4\nOutput: 4\nExplanation: The 4th smallest wonderful number is \"21111\". To get this number:\n- Swap index 3 with index 4: \"11112\" -> \"11121\"\n- Swap index 2 with index 3: \"11121\" -> \"11211\"\n- Swap index 1 with index 2: \"11211\" -> \"12111\"\n- Swap index 0 with index 1: \"12111\" -> \"21111\"\n\nExample 3:\n\nInput: num = \"00123\", k = 1\nOutput: 1\nExplanation: The 1st smallest wonderful number is \"00132\". To get this number:\n- Swap index 3 with index 4: \"00123\" -> \"00132\"\n\n \nConstraints:\n\n2 <= num.length <= 1000\n1 <= k <= 1000\nnum only consists of digits.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = \"111222333\",k = 10) == 3\n assert candidate(num = \"1234567890\",k = 5) == 2\n assert candidate(num = \"1111111111\",k = 5) == 0\n assert candidate(num = \"9876543210\",k = 3) == 0\n assert candidate(num = \"5489355142\",k = 4) == 2\n assert candidate(num = \"321\",k = 2) == 0\n assert candidate(num = \"1000001\",k = 2) == 2\n assert candidate(num = \"343123\",k = 3) == 2\n assert candidate(num = \"00123\",k = 1) == 1\n assert candidate(num = \"12345678901234567890\",k = 10) == 5\n assert candidate(num = \"9999999999\",k = 1) == 0\n assert candidate(num = \"9876543210\",k = 5) == 0\n assert candidate(num = \"1234567890\",k = 3) == 3\n assert candidate(num = \"321\",k = 1) == 0\n assert candidate(num = \"11112\",k = 4) == 4\n assert candidate(num = \"000000000000000000000000000000000000000000000000\",k = 1) == 0\n assert candidate(num = \"12345678901234567890123456789012345678901234567890\",k = 500) == 11\n assert candidate(num = \"00000000001111111111\",k = 500) == 28\n assert candidate(num = \"12345678901234567890\",k = 1000) == 9\n assert candidate(num = \"111112222233333\",k = 500) == 9\n assert candidate(num = \"123456789012345678901234567890\",k = 50) == 3\n assert candidate(num = \"1234567890987654321012345678909876543210\",k = 100) == 39\n assert candidate(num = \"00000000000000000000000000000000000000000000000001\",k = 1) == 1\n assert candidate(num = \"01234567890123456789\",k = 500) == 8\n assert candidate(num = \"5555555555555555555555555555555555555555555555555\",k = 10) == 0\n assert candidate(num = \"3333333333\",k = 1) == 0\n assert candidate(num = \"1212121212121212121212121212\",k = 500) == 6\n assert candidate(num = \"9876543210\",k = 10) == 0\n assert candidate(num = \"5678987656789\",k = 250) == 10\n assert candidate(num = \"12345678909876543210\",k = 500) == 37\n assert candidate(num = \"55667788990011223344\",k = 500) == 11\n assert candidate(num = \"3456789012\",k = 10) == 2\n assert candidate(num = \"123123123123123123123123123123123123123123\",k = 200) == 6\n assert candidate(num = \"123321123321\",k = 50) == 3\n assert candidate(num = \"9876543210\",k = 15) == 0\n assert candidate(num = \"1000000000000000000000000000000000000000000000000001\",k = 10) == 10\n assert candidate(num = \"12345678901234567890\",k = 100) == 8\n assert candidate(num = \"3214567890\",k = 10) == 5\n assert candidate(num = \"123321123321\",k = 100) == 5\n assert candidate(num = \"987654321098765432109876543210\",k = 1000) == 37\n assert candidate(num = \"01234567890123456789\",k = 1000) == 8\n assert candidate(num = \"3333333333\",k = 500) == 0\n assert candidate(num = \"3333222211110000\",k = 100) == 0\n assert candidate(num = \"9876543210987654321098765432109876543210\",k = 50) == 42\n assert candidate(num = \"987654321987654321987654321\",k = 500) == 28\n assert candidate(num = \"33333333333333333333\",k = 1) == 0\n assert candidate(num = \"01010101010101010101\",k = 250) == 3\n assert candidate(num = \"987654321987654321\",k = 100) == 30\n assert candidate(num = \"22222222222222222223\",k = 500) == 19\n assert candidate(num = \"333333333333333333333333333333333333333333333333\",k = 10) == 0\n assert candidate(num = \"987654321098765432109876543210987654321098765432109876543210\",k = 500) == 37\n assert candidate(num = \"1010101010101010\",k = 50) == 5\n assert candidate(num = \"1221112222211122222211111222222211111111122222222222222\",k = 100) == 19\n assert candidate(num = \"99887766554433221100\",k = 500) == 0\n assert candidate(num = \"1234554321\",k = 10) == 13\n assert candidate(num = \"0000000001\",k = 1) == 1\n assert candidate(num = \"44444444444444444444\",k = 100) == 0\n assert candidate(num = \"111122223333444455556666777788889999\",k = 1000) == 15\n assert candidate(num = \"90876543210987654321\",k = 50) == 34\n assert candidate(num = \"1234321234321\",k = 50) == 6\n assert candidate(num = \"111111111111111111112\",k = 1000) == 20\n assert candidate(num = \"98765432109876543210\",k = 10) == 42\n assert candidate(num = \"1234567890\",k = 100) == 8\n assert candidate(num = \"55555555555555555555\",k = 100) == 0\n assert candidate(num = \"555444333222111000\",k = 300) == 0\n assert candidate(num = \"123123123123123123123\",k = 200) == 6\n assert candidate(num = \"0000000000000000000000000000000000000000000000000001\",k = 1) == 1\n assert candidate(num = \"33333333332222222222111111111111\",k = 500) == 0\n assert candidate(num = \"9876543210\",k = 50) == 0\n assert candidate(num = \"33333333333333333333333333333333333333333333333333\",k = 1) == 0\n assert candidate(num = \"102030405060708090\",k = 50) == 8\n assert candidate(num = \"989796959493929190898887868584838281807978777675747372717069686766656463626160595857565554535251504948474645444342414039383736353433323130292827262524232221201918171615141312111009080706050403020100\",k = 1000) == 15\n assert candidate(num = \"00000000000000000001\",k = 10) == 10\n assert candidate(num = \"23456789012345678901\",k = 500) == 10\n assert candidate(num = \"0000000000000000000000000000000000001\",k = 1) == 1\n assert candidate(num = \"13579135791357913579\",k = 500) == 7\n assert candidate(num = \"876543210123456789\",k = 500) == 8\n assert candidate(num = \"10000000001\",k = 5) == 5\n assert candidate(num = \"3333333333\",k = 100) == 0\n assert candidate(num = \"1111111111111111111111111111111111111111\",k = 100) == 0\n assert candidate(num = \"98765432101234567890\",k = 20) == 7\n assert candidate(num = \"98765432109876543210\",k = 1000) == 37\n assert candidate(num = \"1221122112211221\",k = 100) == 13\n assert candidate(num = \"222111333000444555666777888999\",k = 500) == 10\n assert candidate(num = \"123456789876543210\",k = 100) == 39\n assert candidate(num = \"11223344556677889900\",k = 50) == 12\n assert candidate(num = \"12345678900987654321\",k = 200) == 31\n assert candidate(num = \"432111111111111111111111111111\",k = 100) == 0\n assert candidate(num = \"9999999999999999999999999999999999999999999999999999\",k = 5) == 0\n assert candidate(num = \"12345678909876543210\",k = 5) == 43\n assert candidate(num = \"11223344556677889900\",k = 100) == 9\n assert candidate(num = \"11111111112222222222\",k = 100) == 11\n assert candidate(num = \"12345678901234567890\",k = 5) == 2\n assert candidate(num = \"133221100998877665544332211\",k = 1000) == 133\n assert candidate(num = \"12345678901234567890\",k = 20) == 7\n assert candidate(num = \"000000000011111111112222222222\",k = 100) == 11\n assert candidate(num = \"55555555555555555555555555555555555555555555555555555\",k = 5) == 0\n assert candidate(num = \"11223344556677889900\",k = 1000) == 11\n assert candidate(num = \"1111222233334444\",k = 1000) == 15\n assert candidate(num = \"9999999999888888888877777777776666666666\",k = 1000) == 0\n assert candidate(num = \"11223344556677889900\",k = 200) == 9\n assert candidate(num = \"99999999999999999999\",k = 1000) == 0\n assert candidate(num = \"2233445566\",k = 300) == 4\n assert candidate(num = \"99999999999999999999\",k = 100) == 0\n assert candidate(num = \"98765432109876543210987654321098765432109876543210\",k = 1000) == 37\n"}, "metadata": {"canonical_parameter_names": ["num", "k"], "leetcode_dataset_entry_point": "Solution().getMinSwaps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int getMinSwaps(string num, int k) {", "container": "Solution", "callable": "getMinSwaps", "parameters": [{"name": "num", "type": "string"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1851, "task_id": "minimum-interval-to-include-each-query", "difficulty": "Hard", "problem_description": "You are given a 2D integer array intervals, where intervals[i] = [lefti, righti] describes the ith interval starting at lefti and ending at righti (inclusive). The size of an interval is defined as the number of integers it contains, or more formally righti - lefti + 1.\nYou are also given an integer array queries. The answer to the jth query is the size of the smallest interval i such that lefti <= queries[j] <= righti. If no such interval exists, the answer is -1.\nReturn an array containing the answers to the queries.\n \nExample 1:\n\nInput: intervals = [[1,4],[2,4],[3,6],[4,4]], queries = [2,3,4,5]\nOutput: [3,3,1,4]\nExplanation: The queries are processed as follows:\n- Query = 2: The interval [2,4] is the smallest interval containing 2. The answer is 4 - 2 + 1 = 3.\n- Query = 3: The interval [2,4] is the smallest interval containing 3. The answer is 4 - 2 + 1 = 3.\n- Query = 4: The interval [4,4] is the smallest interval containing 4. The answer is 4 - 4 + 1 = 1.\n- Query = 5: The interval [3,6] is the smallest interval containing 5. The answer is 6 - 3 + 1 = 4.\n\nExample 2:\n\nInput: intervals = [[2,3],[2,5],[1,8],[20,25]], queries = [2,19,5,22]\nOutput: [2,-1,4,6]\nExplanation: The queries are processed as follows:\n- Query = 2: The interval [2,3] is the smallest interval containing 2. The answer is 3 - 2 + 1 = 2.\n- Query = 19: None of the intervals contain 19. The answer is -1.\n- Query = 5: The interval [2,5] is the smallest interval containing 5. The answer is 5 - 2 + 1 = 4.\n- Query = 22: The interval [20,25] is the smallest interval containing 22. The answer is 25 - 20 + 1 = 6.\n\n \nConstraints:\n\n1 <= intervals.length <= 105\n1 <= queries.length <= 105\nintervals[i].length == 2\n1 <= lefti <= righti <= 107\n1 <= queries[j] <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(intervals = [[1, 1], [2, 2]],queries = [1, 2, 3]) == [1, 1, -1]\n assert candidate(intervals = [[1, 10], [10, 20], [15, 25]],queries = [5, 10, 15, 20, 25]) == [10, 10, 11, 11, 11]\n assert candidate(intervals = [[1, 1]],queries = [1]) == [1]\n assert candidate(intervals = [[5, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [-1, -1, -1, -1, 6, 6, 6, 6, 6, 6, -1]\n assert candidate(intervals = [[2, 3], [2, 5], [1, 8], [20, 25]],queries = [2, 19, 5, 22]) == [2, -1, 4, 6]\n assert candidate(intervals = [[5, 5], [10, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [-1, -1, -1, -1, 1, -1, -1, -1, -1, 1, -1]\n assert candidate(intervals = [[1, 10000000]],queries = [1, 5000000, 10000000]) == [10000000, 10000000, 10000000]\n assert candidate(intervals = [[1, 4], [2, 4], [3, 6], [4, 4]],queries = [2, 3, 4, 5]) == [3, 3, 1, 4]\n assert candidate(intervals = [[1, 3], [4, 5]],queries = [2, 3, 4, 5]) == [3, 3, 2, 2]\n assert candidate(intervals = [[10000000, 10000000]],queries = [10000000]) == [1]\n assert candidate(intervals = [[5, 5], [1, 2], [3, 4]],queries = [1, 5, 2, 3]) == [2, 1, 2, 2]\n assert candidate(intervals = [[1, 10], [2, 9], [3, 8]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 8, 6, 6, 6, 6, 6, 6, 8, 10]\n assert candidate(intervals = [[1, 100], [50, 150], [100, 200], [150, 250], [200, 300]],queries = [1, 50, 100, 150, 200, 250, 300, 301]) == [100, 100, 100, 101, 101, 101, 101, -1]\n assert candidate(intervals = [[1000, 2000], [500, 1500], [100, 1000], [50, 500], [1, 50]],queries = [1, 50, 100, 500, 1000, 1500, 2000]) == [50, 50, 451, 451, 901, 1001, 1001]\n assert candidate(intervals = [[10, 20], [15, 25], [20, 30], [25, 35], [30, 40]],queries = [10, 15, 20, 25, 30, 35, 40, 45]) == [11, 11, 11, 11, 11, 11, 11, -1]\n assert candidate(intervals = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [1, 3, 5, 7, 9]) == [1, 1, 1, 1, 1]\n assert candidate(intervals = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, -1]\n assert candidate(intervals = [[1, 10000000], [5000000, 7500000], [2500000, 3750000], [6250000, 8750000]],queries = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == [10000000, 10000000, 1250001, 10000000, 2500001, 2500001, 2500001, 2500001, 10000000, 10000000]\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == [2, 2, 2, 2, 2, 2, -1, -1, -1, -1, -1]\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(intervals = [[1, 5], [6, 10], [11, 15], [16, 20]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(intervals = [[1, 10], [10, 20], [15, 25], [25, 35], [30, 40], [35, 45]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == [10, 10, 11, 11, 11, 11, 11, 11, 11]\n assert candidate(intervals = [[1000000, 10000000], [2000000, 10000000], [3000000, 10000000], [4000000, 10000000]],queries = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000]) == [9000001, 8000001, 7000001, 6000001, 6000001, 6000001, 6000001, 6000001, 6000001, 6000001]\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(intervals = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8]],queries = [1, 2, 3, 4, 5, 6, 7, 8]) == [3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(intervals = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],queries = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -1]\n assert candidate(intervals = [[1, 500000], [500000, 1000000], [1000000, 1500000], [1500000, 2000000], [2000000, 2500000]],queries = [250000, 750000, 1250000, 1750000, 2250000]) == [500000, 500001, 500001, 500001, 500001]\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -1]\n assert candidate(intervals = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(intervals = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [10, 11, 11, 11, 11, 11, 11, 11, 11, 11]\n assert candidate(intervals = [[1, 5000], [2, 4999], [3, 4998], [4, 4997], [5, 4996], [6, 4995], [7, 4994], [8, 4993], [9, 4992], [10, 4991]],queries = [2500, 3500, 4500, 5500]) == [4982, 4982, 4982, -1]\n assert candidate(intervals = [[1, 1000], [2, 1001], [3, 1002], [4, 1003], [5, 1004], [6, 1005], [7, 1006], [8, 1007], [9, 1008], [10, 1009]],queries = [1, 500, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010]) == [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, -1]\n assert candidate(intervals = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],queries = [1, 19, 10, 2, 9, 18, 7, 16, 5, 15, 3, 14, 11, 13, 6, 12, 8, 17, 4]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(intervals = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70]],queries = [15, 25, 35, 45, 55, 65, 75]) == [11, 11, 11, 11, 11, 11, -1]\n assert candidate(intervals = [[1, 50000], [2, 30000], [3, 20000], [4, 10000]],queries = [1, 2, 3, 4, 5, 10000, 20000, 30000, 50000]) == [50000, 29999, 19998, 9997, 9997, 9997, 19998, 29999, 50000]\n assert candidate(intervals = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -1, -1, -1, -1, -1]\n assert candidate(intervals = [[1, 10000000], [1000000, 2000000], [2000000, 3000000], [3000000, 4000000], [4000000, 5000000], [5000000, 6000000], [6000000, 7000000], [7000000, 8000000], [8000000, 9000000], [9000000, 10000000]],queries = [1, 5000000, 1000000, 1500000, 2000000, 2500000, 3000000, 3500000, 4000000, 4500000, 5500000, 6000000, 6500000, 7000000, 7500000, 8000000, 8500000, 9000000, 9500000, 10000000]) == [10000000, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001, 1000001]\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1]\n assert candidate(intervals = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 15], [14, 16], [15, 17]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]],queries = [1, 5, 9, 13, 17]) == [2, 2, 2, 2, -1]\n assert candidate(intervals = [[1, 10], [1, 9], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(intervals = [[1, 2000], [2, 1999], [3, 1998], [4, 1997], [5, 1996], [6, 1995], [7, 1994], [8, 1993], [9, 1992], [10, 1991]],queries = [1, 1000, 2000, 1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991]) == [2000, 1982, 2000, 1998, 1996, 1994, 1992, 1990, 1988, 1986, 1984, 1982]\n assert candidate(intervals = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25], [26, 30]],queries = [3, 7, 13, 19, 23, 27, 10, 21, 31]) == [5, 5, 5, 5, 5, 5, 5, 5, -1]\n assert candidate(intervals = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50], [55, 60], [65, 70], [75, 80], [85, 90], [95, 100]],queries = [1, 6, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56, 61, 66, 71, 76, 81, 86, 91, 96, 101]) == [-1, 6, -1, 6, -1, 6, -1, 6, -1, 6, -1, 6, -1, 6, -1, 6, -1, 6, -1, 6, -1]\n assert candidate(intervals = [[1, 3], [2, 5], [3, 7], [4, 9], [5, 11], [6, 13], [7, 15]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [3, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]\n assert candidate(intervals = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]],queries = [50, 60, 70, 80, 90, 100]) == [82, 82, 82, 82, 82, 100]\n assert candidate(intervals = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55]],queries = [1, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90]) == [-1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(intervals = [[1, 10000000]],queries = [1, 1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 11000000]) == [10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, -1]\n assert candidate(intervals = [[1, 1000000], [1, 999999], [1, 999998], [1, 999997], [1, 999996]],queries = [500000, 250000, 750000, 125000, 375000]) == [999996, 999996, 999996, 999996, 999996]\n assert candidate(intervals = [[1, 3], [1, 5], [1, 7], [1, 9], [1, 11], [1, 13], [1, 15], [1, 17], [1, 19], [1, 21]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]) == [3, 3, 3, 5, 5, 7, 7, 9, 9, 11, 11, 13, 13, 15, 15, 17, 17, 19, 19, 21, 21, -1]\n assert candidate(intervals = [[1, 100000], [2, 99999], [3, 99998], [4, 99997], [5, 99996]],queries = [1, 50000, 100000, 99999, 99998]) == [100000, 99992, 100000, 99998, 99996]\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(intervals = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996]],queries = [1, 2, 3, 4, 5]) == [10000000, 9999998, 9999996, 9999994, 9999992]\n assert candidate(intervals = [[5, 500], [6, 499], [7, 498], [8, 497], [9, 496]],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 500]) == [488, 488, 488, 488, 488, 488, 488, 488, 488, 488, 496]\n assert candidate(intervals = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997]],queries = [1, 2, 3, 4, 5, 9999999, 10000000]) == [10000000, 9999998, 9999996, 9999994, 9999994, 9999998, 10000000]\n assert candidate(intervals = [[1, 3], [5, 7], [9, 11], [13, 15], [17, 19], [21, 23]],queries = [1, 4, 5, 8, 9, 12, 13, 16, 17, 20, 21, 24]) == [3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1]\n assert candidate(intervals = [[1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5], [1, 5]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [5, 5, 5, 5, 5, -1, -1, -1, -1, -1]\n assert candidate(intervals = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50], [51, 60], [61, 70], [71, 80], [81, 90], [91, 100]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, -1]\n assert candidate(intervals = [[1, 3], [4, 6], [7, 9], [10, 12], [13, 15]],queries = [1, 5, 7, 11, 13, 16]) == [3, 3, 3, 3, 3, -1]\n assert candidate(intervals = [[1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3], [1, 3]],queries = [1, 2, 3]) == [3, 3, 3]\n assert candidate(intervals = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50]],queries = [5, 15, 25, 35, 45]) == [10, 10, 10, 10, 10]\n assert candidate(intervals = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]],queries = [3, 4, 5, 6, 7, 8, 9, 1, 2, 10]) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(intervals = [[1, 1000000], [2, 999999], [3, 999998], [4, 999997], [5, 999996]],queries = [500000, 250000, 750000, 125000, 375000]) == [999992, 999992, 999992, 999992, 999992]\n assert candidate(intervals = [[5, 10], [15, 20], [25, 30], [35, 40], [45, 50]],queries = [3, 7, 12, 18, 23, 28, 33, 38, 43, 48]) == [-1, 6, -1, 6, -1, 6, -1, 6, -1, 6]\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(intervals = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [11, 20], [12, 19], [13, 18], [14, 17], [15, 16]],queries = [5, 15, 25, 35, 45]) == [2, 2, -1, -1, -1]\n assert candidate(intervals = [[1, 1], [10000000, 10000000], [2, 9999999], [9999998, 9999998], [3, 9999997], [9999996, 9999996]],queries = [1, 5000000, 10000000, 9999999, 9999998, 9999997, 9999996, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 9999995, 1, 9999998, 1, 9999995, 1, 1, 9999998, 9999995, 9999995, 9999995, 9999995, 9999995, 9999995, 9999995, 9999995]\n assert candidate(intervals = [[1, 2], [4, 6], [8, 10], [12, 14], [16, 18], [20, 22], [24, 26], [28, 30], [32, 34], [36, 38], [40, 42], [44, 46], [48, 50], [52, 54], [56, 58], [60, 62], [64, 66], [68, 70], [72, 74], [76, 78]],queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79]) == [2, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1, 3, -1]\n assert candidate(intervals = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50], [51, 60], [61, 70], [71, 80], [81, 90], [91, 100]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, -1]\n assert candidate(intervals = [[1, 100000], [50000, 100000], [1, 50000], [100000, 100000]],queries = [1, 25000, 50000, 75000, 100000]) == [50000, 50000, 50000, 50001, 1]\n assert candidate(intervals = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(intervals = [[1, 10000], [2, 9999], [3, 9998], [4, 9997], [5, 9996], [6, 9995], [7, 9994]],queries = [1, 2, 3, 4, 5, 6, 7, 10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993]) == [10000, 9998, 9996, 9994, 9992, 9990, 9988, 10000, 9998, 9996, 9994, 9992, 9990, 9988, 9988]\n assert candidate(intervals = [[1, 5000], [1000, 5000], [2000, 5000], [3000, 5000], [4000, 5000]],queries = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000]) == [5000, 4001, 4001, 3001, 3001, 2001, 2001, 1001, 1001, 1001]\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],queries = [1, 11, 6, 3, 8, 5, 10, 2, 7, 4, 9]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(intervals = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],queries = [1, 5, 9, 13, 17, 21]) == [2, 2, 2, 2, 2, -1]\n assert candidate(intervals = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996], [6, 995], [7, 994], [8, 993], [9, 992], [10, 991]],queries = [500, 600, 700, 800, 900, 1000]) == [982, 982, 982, 982, 982, 1000]\n assert candidate(intervals = [[1, 1000000], [1000000, 2000000], [2000000, 3000000], [3000000, 4000000], [4000000, 5000000], [5000000, 6000000]],queries = [500000, 1500000, 2500000, 3500000, 4500000, 5500000]) == [1000000, 1000001, 1000001, 1000001, 1000001, 1000001]\n assert candidate(intervals = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 8, 6, 4, 2, 2, 4, 6, 8, 10]\n assert candidate(intervals = [[1, 100000], [2, 99999], [50, 100], [101, 200], [201, 300]],queries = [1, 50, 101, 201, 500, 1000, 100000]) == [100000, 51, 100, 100, 99998, 99998, 100000]\n assert candidate(intervals = [[1, 1000000], [500000, 1500000], [750000, 2000000]],queries = [1, 500000, 1000000, 1500000, 2000000]) == [1000000, 1000000, 1000000, 1000001, 1250001]\n assert candidate(intervals = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60]],queries = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == [11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11]\n assert candidate(intervals = [[1, 3], [4, 6], [7, 9], [10, 12], [13, 15]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, -1]\n assert candidate(intervals = [[1000000, 2000000], [1500000, 2500000], [2000000, 3000000]],queries = [1000000, 1500000, 2000000, 2500000, 3000000]) == [1000001, 1000001, 1000001, 1000001, 1000001]\n assert candidate(intervals = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996]],queries = [1, 5000000, 10000000, 9999999, 9999998]) == [10000000, 9999992, 10000000, 9999998, 9999996]\n assert candidate(intervals = [[10, 200], [20, 190], [30, 180], [40, 170], [50, 160]],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210]) == [191, 171, 151, 131, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 131, 151, 171, 191, -1]\n assert candidate(intervals = [[1, 100000], [50000, 150000], [75000, 250000]],queries = [10000, 50000, 75000, 150000, 250000]) == [100000, 100000, 100000, 100001, 175001]\n assert candidate(intervals = [[1, 100], [50, 150], [100, 200], [150, 250], [200, 300]],queries = [25, 75, 125, 175, 225]) == [100, 100, 101, 101, 101]\n assert candidate(intervals = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(intervals = [[100, 200], [150, 250], [200, 300], [250, 350], [300, 400], [350, 450], [400, 500], [450, 550], [500, 600]],queries = [150, 250, 350, 450, 550, 600, 100, 200, 300, 400, 500]) == [101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101]\n assert candidate(intervals = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]],queries = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59]) == [82, 82, 82, 82, 82, 82, 82, 82, 82, 82]\n assert candidate(intervals = [[1, 500], [501, 1000], [1001, 1500], [1501, 2000]],queries = [1, 500, 501, 1000, 1001, 1500, 1501, 2000]) == [500, 500, 500, 500, 500, 500, 500, 500]\n assert candidate(intervals = [[1, 10000000], [2, 9999999], [3, 9999998], [4, 9999997], [5, 9999996]],queries = [1, 9999998, 5000000, 9999997, 10000000]) == [10000000, 9999996, 9999992, 9999994, 10000000]\n assert candidate(intervals = [[1, 100000], [50000, 150000], [100000, 200000], [250000, 300000], [1, 1000000]],queries = [50000, 150000, 250000, 500000, 999999]) == [100000, 100001, 50001, 1000000, 1000000]\n assert candidate(intervals = [[1, 3], [4, 7], [8, 10], [11, 15], [16, 20], [21, 25], [26, 30]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == [3, 3, 3, 4, 4, 4, 4, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -1]\n assert candidate(intervals = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25]],queries = [3, 7, 12, 17, 22, 27]) == [5, 5, 5, 5, 5, -1]\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12]],queries = [1, 3, 5, 7, 9, 11]) == [1, 1, 1, 1, 1, 1]\n assert candidate(intervals = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [1, 3, 5, 7, 9, 11]) == [1, 1, 1, 1, 1, -1]\n assert candidate(intervals = [[1, 10000000], [5000001, 10000000], [5000001, 7500000], [5000001, 6250000], [5000001, 5625000]],queries = [1, 5000000, 5625000, 6250000, 7500000, 10000000]) == [10000000, 10000000, 625000, 1250000, 2500000, 5000000]\n assert candidate(intervals = [[1, 3], [2, 6], [5, 9], [8, 12], [11, 15]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(intervals = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(intervals = [[1, 100], [50, 150], [100, 200], [150, 250], [200, 300], [250, 350]],queries = [1, 50, 100, 150, 200, 250, 300, 350]) == [100, 100, 100, 101, 101, 101, 101, 101]\n"}, "metadata": {"canonical_parameter_names": ["intervals", "queries"], "leetcode_dataset_entry_point": "Solution().minInterval", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector minInterval(vector>& intervals, vector& queries) {", "container": "Solution", "callable": "minInterval", "parameters": [{"name": "intervals", "type": "vector>&"}, {"name": "queries", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1854, "task_id": "maximum-population-year", "difficulty": "Easy", "problem_description": "You are given a 2D integer array logs where each logs[i] = [birthi, deathi] indicates the birth and death years of the ith person.\nThe population of some year x is the number of people alive during that year. The ith person is counted in year x's population if x is in the inclusive range [birthi, deathi - 1]. Note that the person is not counted in the year that they die.\nReturn the earliest year with the maximum population.\n \nExample 1:\n\nInput: logs = [[1993,1999],[2000,2010]]\nOutput: 1993\nExplanation: The maximum population is 1, and 1993 is the earliest year with this population.\n\nExample 2:\n\nInput: logs = [[1950,1961],[1960,1971],[1970,1981]]\nOutput: 1960\nExplanation: \nThe maximum population is 2, and it had happened in years 1960 and 1970.\nThe earlier year between them is 1960.\n \nConstraints:\n\n1 <= logs.length <= 100\n1950 <= birthi < deathi <= 2050\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(logs = [[2000, 2005], [2005, 2010], [2010, 2015]]) == 2000\n assert candidate(logs = [[1980, 1985], [1985, 1990], [1990, 1995], [1995, 2000]]) == 1980\n assert candidate(logs = [[2000, 2010], [1990, 2000], [2000, 2020]]) == 2000\n assert candidate(logs = [[1993, 1999], [2000, 2010]]) == 1993\n assert candidate(logs = [[1950, 1960], [1960, 1970], [1970, 1980], [1980, 1990]]) == 1950\n assert candidate(logs = [[1991, 1992], [1992, 1993], [1993, 1994], [1994, 1995]]) == 1991\n assert candidate(logs = [[1950, 2050]]) == 1950\n assert candidate(logs = [[1950, 1961], [1960, 1971], [1970, 1981], [1960, 1980]]) == 1960\n assert candidate(logs = [[1975, 1985], [1985, 1995], [1995, 2005], [2005, 2015]]) == 1975\n assert candidate(logs = [[1990, 1995], [1991, 1996], [1992, 1997]]) == 1992\n assert candidate(logs = [[1950, 1961], [1960, 1971], [1970, 1981]]) == 1960\n assert candidate(logs = [[2000, 2010], [2010, 2020], [2020, 2030]]) == 2000\n assert candidate(logs = [[1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005]]) == 1985\n assert candidate(logs = [[1995, 2005], [2005, 2015], [2015, 2025]]) == 1995\n assert candidate(logs = [[2000, 2010], [1990, 2000], [1980, 1990]]) == 1980\n assert candidate(logs = [[1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015], [2010, 2020], [2015, 2025], [2020, 2030]]) == 1985\n assert candidate(logs = [[1993, 1995], [1994, 1996], [1995, 1997], [1996, 1998], [1997, 1999], [1998, 2000], [1999, 2001], [2000, 2002], [2001, 2003], [2002, 2004], [2003, 2005]]) == 1994\n assert candidate(logs = [[2000, 2005], [2001, 2006], [2002, 2007], [2003, 2008], [2004, 2009], [2005, 2010]]) == 2004\n assert candidate(logs = [[1965, 1980], [1970, 1985], [1975, 1990], [1980, 1995], [1985, 2000]]) == 1975\n assert candidate(logs = [[1950, 1960], [1960, 1970], [1970, 1980], [1980, 1990], [1990, 2000], [2000, 2010], [2010, 2020], [2020, 2030]]) == 1950\n assert candidate(logs = [[1985, 1995], [1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015], [2010, 2020], [2015, 2025]]) == 1990\n assert candidate(logs = [[1955, 1965], [1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990]]) == 1960\n assert candidate(logs = [[1950, 1960], [1955, 1965], [1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005]]) == 1955\n assert candidate(logs = [[1955, 1975], [1960, 1980], [1965, 1985], [1970, 1990], [1975, 1995], [1980, 2000], [1985, 2005], [1990, 2010], [1995, 2015], [2000, 2020]]) == 1970\n assert candidate(logs = [[1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015]]) == 1985\n assert candidate(logs = [[1980, 1990], [1981, 1991], [1982, 1992], [1983, 1993], [1984, 1994], [1985, 1995], [1986, 1996], [1987, 1997], [1988, 1998], [1989, 1999]]) == 1989\n assert candidate(logs = [[1950, 2000], [1960, 1990], [1970, 1995], [1980, 2005], [1990, 2010], [2000, 2020]]) == 1980\n assert candidate(logs = [[1975, 1978], [1977, 1980], [1979, 1982], [1981, 1984], [1983, 1986], [1985, 1988], [1987, 1990], [1989, 1992], [1991, 1994], [1993, 1996]]) == 1977\n assert candidate(logs = [[1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015], [2010, 2020], [2015, 2025], [2020, 2030], [2025, 2035]]) == 1995\n assert candidate(logs = [[1990, 1991], [1991, 1992], [1992, 1993], [1993, 1994], [1994, 1995], [1995, 1996], [1996, 1997], [1997, 1998], [1998, 1999], [1999, 2000]]) == 1990\n assert candidate(logs = [[1960, 1970], [1961, 1971], [1962, 1972], [1963, 1973], [1964, 1974], [1965, 1975], [1966, 1976], [1967, 1977], [1968, 1978], [1969, 1979], [1970, 1980]]) == 1969\n assert candidate(logs = [[1950, 2050], [1960, 2040], [1970, 2030], [1980, 2020], [1990, 2010], [2000, 2005]]) == 2000\n assert candidate(logs = [[1980, 1985], [1982, 1987], [1984, 1989], [1986, 1991], [1988, 1993]]) == 1984\n assert candidate(logs = [[1950, 2050], [1951, 2049], [1952, 2048], [1953, 2047], [1954, 2046], [1955, 2045], [1956, 2044], [1957, 2043], [1958, 2042], [1959, 2041], [1960, 2040]]) == 1960\n assert candidate(logs = [[1950, 2050], [1960, 1980], [1970, 1990], [1980, 2000], [1990, 2010], [2000, 2020]]) == 1970\n assert candidate(logs = [[1950, 2000], [1960, 1990], [1970, 1980], [1980, 1970], [1990, 1960], [2000, 1950]]) == 1950\n assert candidate(logs = [[1990, 1995], [1991, 1996], [1992, 1997], [1993, 1998], [1994, 1999]]) == 1994\n assert candidate(logs = [[1950, 1960], [1955, 1965], [1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985]]) == 1955\n assert candidate(logs = [[1950, 1961], [1955, 1966], [1960, 1971], [1965, 1976], [1970, 1981], [1975, 1986]]) == 1960\n assert candidate(logs = [[1980, 1990], [1982, 1992], [1984, 1994], [1986, 1996], [1988, 1998], [1990, 2000]]) == 1988\n assert candidate(logs = [[1955, 1966], [1961, 1971], [1966, 1976], [1971, 1981], [1976, 1986], [1981, 1991], [1986, 1996], [1991, 2001]]) == 1961\n assert candidate(logs = [[1965, 1985], [1970, 1990], [1975, 1995], [1980, 2000], [1985, 2005], [1990, 2010], [1995, 2015], [2000, 2020], [2005, 2025], [2010, 2030]]) == 1980\n assert candidate(logs = [[1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015], [2010, 2020], [2015, 2025], [2020, 2030], [2025, 2035], [2030, 2040], [2035, 2045], [2040, 2050]]) == 1975\n assert candidate(logs = [[1950, 1965], [1960, 1975], [1970, 1985], [1980, 1995], [1990, 2005], [2000, 2015], [2010, 2025], [2020, 2035]]) == 1960\n assert candidate(logs = [[1950, 1960], [1960, 1970], [1970, 1980], [1980, 1990], [1990, 2000], [2000, 2010], [2010, 2020], [2020, 2030], [2030, 2040], [2040, 2050]]) == 1950\n assert candidate(logs = [[1950, 2050], [1955, 2045], [1960, 2040], [1965, 2035], [1970, 2030], [1975, 2025], [1980, 2020], [1985, 2015], [1990, 2010]]) == 1990\n assert candidate(logs = [[1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005], [2000, 2015], [2005, 2020]]) == 1985\n assert candidate(logs = [[1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015]]) == 1965\n assert candidate(logs = [[1960, 1965], [1961, 1966], [1962, 1967], [1963, 1968], [1964, 1969], [1965, 1970], [1966, 1971], [1967, 1972], [1968, 1973], [1969, 1974]]) == 1964\n assert candidate(logs = [[1950, 1960], [1960, 1970], [1970, 1980], [1980, 1990], [1990, 2000], [2000, 2010]]) == 1950\n assert candidate(logs = [[1955, 1965], [1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005]]) == 1960\n assert candidate(logs = [[1993, 1999], [2000, 2010], [1995, 2000], [1985, 1995], [1990, 1998]]) == 1993\n assert candidate(logs = [[1955, 1965], [1950, 1960], [1960, 1970], [1970, 1980], [1965, 1975], [1975, 1985]]) == 1955\n assert candidate(logs = [[1955, 1965], [1965, 1975], [1975, 1985], [1985, 1995], [1995, 2005], [2005, 2015], [2015, 2025]]) == 1955\n assert candidate(logs = [[1970, 1975], [1971, 1976], [1972, 1977], [1973, 1978], [1974, 1979], [1975, 1980]]) == 1974\n assert candidate(logs = [[2000, 2010], [2005, 2015], [2010, 2020], [2015, 2025], [2020, 2030], [2025, 2035], [2030, 2040]]) == 2005\n assert candidate(logs = [[1955, 1961], [1960, 1965], [1965, 1970], [1970, 1975], [1975, 1980], [1980, 1985], [1985, 1990]]) == 1960\n assert candidate(logs = [[1970, 1980], [1971, 1981], [1972, 1982], [1973, 1983], [1974, 1984], [1975, 1985], [1976, 1986], [1977, 1987], [1978, 1988], [1979, 1989], [1980, 1990]]) == 1979\n assert candidate(logs = [[1950, 1960], [1955, 1965], [1960, 1970], [1965, 1975], [1970, 1980]]) == 1955\n assert candidate(logs = [[1975, 1985], [1985, 1995], [1995, 2005], [2005, 2015], [2015, 2025], [2025, 2035]]) == 1975\n assert candidate(logs = [[1990, 2000], [1992, 2002], [1994, 2004], [1996, 2006], [1998, 2008]]) == 1998\n assert candidate(logs = [[1960, 1961], [1961, 1962], [1962, 1963], [1963, 1964], [1964, 1965], [1965, 1966], [1966, 1967], [1967, 1968], [1968, 1969], [1969, 1970], [1970, 1971]]) == 1960\n assert candidate(logs = [[1950, 1955], [1951, 1956], [1952, 1957], [1953, 1958], [1954, 1959], [1955, 1960], [1956, 1961], [1957, 1962], [1958, 1963], [1959, 1964], [1960, 1965]]) == 1954\n assert candidate(logs = [[1993, 1998], [1994, 1999], [1995, 2000], [1996, 2001], [1997, 2002], [1998, 2003], [1999, 2004]]) == 1997\n assert candidate(logs = [[1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995]]) == 1965\n assert candidate(logs = [[1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000], [1995, 2000], [2000, 2010], [2005, 2015], [2010, 2020], [2015, 2025]]) == 1975\n assert candidate(logs = [[1970, 1975], [1971, 1976], [1972, 1977], [1973, 1978], [1974, 1979], [1975, 1980], [1976, 1981], [1977, 1982], [1978, 1983], [1979, 1984]]) == 1974\n assert candidate(logs = [[1950, 2000], [1960, 2010], [1970, 2020], [1980, 2030], [1990, 2040], [2000, 2050]]) == 1990\n assert candidate(logs = [[1950, 1955], [1955, 1960], [1960, 1965], [1965, 1970], [1970, 1975], [1975, 1980], [1980, 1985], [1985, 1990], [1990, 1995], [1995, 2000], [2000, 2005], [2005, 2010], [2010, 2015], [2015, 2020], [2020, 2025], [2025, 2030], [2030, 2035], [2035, 2040], [2040, 2045], [2045, 2050]]) == 1950\n assert candidate(logs = [[1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015], [2010, 2020], [2015, 2025]]) == 1995\n assert candidate(logs = [[1950, 1951], [1951, 1952], [1952, 1953], [1953, 1954], [1954, 1955], [1955, 1956], [1956, 1957], [1957, 1958], [1958, 1959], [1959, 1960], [1960, 1961], [1961, 1962], [1962, 1963], [1963, 1964], [1964, 1965]]) == 1950\n assert candidate(logs = [[1950, 1961], [1955, 1966], [1960, 1971], [1965, 1976], [1970, 1981], [1975, 1986], [1980, 1991], [1985, 1996]]) == 1960\n assert candidate(logs = [[1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015], [2010, 2020], [2015, 2025]]) == 1985\n assert candidate(logs = [[1955, 1975], [1960, 1980], [1965, 1985], [1970, 1990], [1975, 1995], [1980, 2000]]) == 1970\n assert candidate(logs = [[1990, 1995], [1992, 1997], [1994, 1999], [1996, 2001], [1998, 2003]]) == 1994\n assert candidate(logs = [[1955, 1965], [1965, 1975], [1975, 1985], [1985, 1995], [1995, 2005], [2005, 2015], [2015, 2025], [2025, 2035]]) == 1955\n assert candidate(logs = [[1975, 1980], [1978, 1985], [1980, 1985], [1982, 1990], [1985, 1995], [1988, 1995], [1990, 1998], [1992, 2000]]) == 1992\n assert candidate(logs = [[1950, 1980], [1960, 1990], [1970, 2000], [1980, 2010], [1990, 2020]]) == 1970\n assert candidate(logs = [[1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000], [1995, 2000], [2000, 2010]]) == 1975\n assert candidate(logs = [[1960, 1970], [1961, 1971], [1962, 1972], [1963, 1973], [1964, 1974], [1965, 1975], [1966, 1976], [1967, 1977]]) == 1967\n assert candidate(logs = [[1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000], [1995, 2005]]) == 1965\n assert candidate(logs = [[1980, 1985], [1981, 1986], [1982, 1987], [1983, 1988], [1984, 1989], [1985, 1990], [1986, 1991], [1987, 1992]]) == 1984\n assert candidate(logs = [[1990, 2000], [1995, 2005], [2000, 2010], [2005, 2015], [2010, 2020]]) == 1995\n assert candidate(logs = [[1993, 1995], [1994, 1996], [1995, 1997], [1996, 1998], [1997, 1999]]) == 1994\n assert candidate(logs = [[1955, 1965], [1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000]]) == 1960\n assert candidate(logs = [[1960, 1970], [1970, 1980], [1980, 1990], [1990, 2000], [2000, 2010], [2010, 2020], [2020, 2030]]) == 1960\n assert candidate(logs = [[1990, 1995], [1990, 1995], [1990, 1995], [1995, 2000], [1995, 2000], [1995, 2000]]) == 1990\n assert candidate(logs = [[1950, 1960], [1955, 1965], [1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990], [1985, 1995], [1990, 2000]]) == 1955\n assert candidate(logs = [[1980, 1990], [1982, 1992], [1984, 1994], [1986, 1996], [1988, 1998], [1990, 2000], [1992, 2002], [1994, 2004], [1996, 2006], [1998, 2008]]) == 1988\n assert candidate(logs = [[1960, 1970], [1970, 1980], [1980, 1990], [1990, 2000], [2000, 2010], [2010, 2020]]) == 1960\n assert candidate(logs = [[1950, 1960], [1955, 1965], [1960, 1970], [1965, 1975], [1970, 1980], [1975, 1985], [1980, 1990]]) == 1955\n"}, "metadata": {"canonical_parameter_names": ["logs"], "leetcode_dataset_entry_point": "Solution().maximumPopulation", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumPopulation(vector>& logs) {", "container": "Solution", "callable": "maximumPopulation", "parameters": [{"name": "logs", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1855, "task_id": "maximum-distance-between-a-pair-of-values", "difficulty": "Medium", "problem_description": "You are given two non-increasing 0-indexed integer arrays nums1​​​​​​ and nums2​​​​​​.\nA pair of indices (i, j), where 0 <= i < nums1.length and 0 <= j < nums2.length, is valid if both i <= j and nums1[i] <= nums2[j]. The distance of the pair is j - i​​​​.\nReturn the maximum distance of any valid pair (i, j). If there are no valid pairs, return 0.\nAn array arr is non-increasing if arr[i-1] >= arr[i] for every 1 <= i < arr.length.\n \nExample 1:\n\nInput: nums1 = [55,30,5,4,2], nums2 = [100,20,10,10,5]\nOutput: 2\nExplanation: The valid pairs are (0,0), (2,2), (2,3), (2,4), (3,3), (3,4), and (4,4).\nThe maximum distance is 2 with pair (2,4).\n\nExample 2:\n\nInput: nums1 = [2,2,2], nums2 = [10,10,1]\nOutput: 1\nExplanation: The valid pairs are (0,0), (0,1), and (1,1).\nThe maximum distance is 1 with pair (0,1).\n\nExample 3:\n\nInput: nums1 = [30,29,19,5], nums2 = [25,25,25,25,25]\nOutput: 2\nExplanation: The valid pairs are (2,2), (2,3), (2,4), (3,3), and (3,4).\nThe maximum distance is 2 with pair (2,4).\n\n \nConstraints:\n\n1 <= nums1.length, nums2.length <= 105\n1 <= nums1[i], nums2[j] <= 105\nBoth nums1 and nums2 are non-increasing.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [100],nums2 = [101]) == 0\n assert candidate(nums1 = [30, 29, 19, 5],nums2 = [25, 25, 25, 25, 25]) == 2\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [10, 9, 8, 7, 6],nums2 = [10, 9, 8, 7, 6]) == 0\n assert candidate(nums1 = [5],nums2 = [10]) == 0\n assert candidate(nums1 = [10, 9, 8, 7],nums2 = [7, 7, 7, 7]) == 0\n assert candidate(nums1 = [5],nums2 = [5]) == 0\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1]) == 3\n assert candidate(nums1 = [10],nums2 = [5]) == 0\n assert candidate(nums1 = [5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums1 = [10, 9, 8, 7, 6],nums2 = [6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums1 = [10, 9, 8, 7, 6],nums2 = [5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [100, 90],nums2 = [95, 85]) == 0\n assert candidate(nums1 = [100, 90, 80],nums2 = [100, 90, 80, 70, 60]) == 0\n assert candidate(nums1 = [99999, 99998, 99997],nums2 = [100000, 99999, 99998]) == 1\n assert candidate(nums1 = [1],nums2 = [2]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [5, 5, 5, 5, 5]) == 4\n assert candidate(nums1 = [2, 2, 2],nums2 = [10, 10, 1]) == 1\n assert candidate(nums1 = [100, 50, 25, 10],nums2 = [100, 100, 100, 100]) == 3\n assert candidate(nums1 = [55, 30, 5, 4, 2],nums2 = [100, 20, 10, 10, 5]) == 2\n assert candidate(nums1 = [1],nums2 = [1]) == 0\n assert candidate(nums1 = [10, 9, 8, 7, 6],nums2 = [15, 14, 13, 12, 11]) == 4\n assert candidate(nums1 = [100000],nums2 = [100000]) == 0\n assert candidate(nums1 = [50, 40, 30, 20, 10],nums2 = [100, 80, 60, 40, 20]) == 2\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums1 = [30, 29, 19, 5],nums2 = [25, 25, 25, 25, 25, 20, 15, 10, 5]) == 5\n assert candidate(nums1 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],nums2 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 9\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 9\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 9\n assert candidate(nums1 = [95, 85, 75, 65, 55],nums2 = [95, 85, 75, 65, 55, 45, 35, 25, 15, 5]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 9\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [100000, 100000, 100000, 100000, 100000],nums2 = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 9\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 9\n assert candidate(nums1 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],nums2 = [100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 9\n assert candidate(nums1 = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],nums2 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 5\n assert candidate(nums1 = [1],nums2 = [100000]) == 0\n assert candidate(nums1 = [50, 40, 30, 20, 10],nums2 = [55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 5\n assert candidate(nums1 = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums1 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],nums2 = [99, 89, 79, 69, 59, 49, 39, 29, 19, 9]) == 0\n assert candidate(nums1 = [999, 888, 777, 666, 555, 444, 333, 222, 111, 0],nums2 = [999, 888, 777, 666, 555, 444, 333, 222, 111, 0]) == 0\n assert candidate(nums1 = [50, 25, 10, 1],nums2 = [50, 40, 30, 25, 20, 15, 10, 5, 1]) == 5\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1]) == 10\n assert candidate(nums1 = [90, 80, 70, 60, 50],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 1\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(nums1 = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],nums2 = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 1\n assert candidate(nums1 = [10, 5, 3, 2],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 4\n assert candidate(nums1 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],nums2 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 4\n assert candidate(nums1 = [20, 10, 5, 2, 1],nums2 = [50, 40, 30, 20, 10, 5, 2, 1]) == 3\n assert candidate(nums1 = [50, 40, 30, 20, 10],nums2 = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 5\n assert candidate(nums1 = [100],nums2 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 9\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1]) == 10\n assert candidate(nums1 = [50, 30, 10],nums2 = [60, 50, 40, 30, 20, 10]) == 3\n assert candidate(nums1 = [10, 9, 8, 7, 6],nums2 = [10, 9, 8, 7, 6]) == 0\n assert candidate(nums1 = [90, 70, 50, 30, 10],nums2 = [100, 80, 60, 40, 20]) == 0\n assert candidate(nums1 = [100, 50, 25],nums2 = [150, 120, 90, 70, 50, 30, 10]) == 3\n assert candidate(nums1 = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],nums2 = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 9\n assert candidate(nums1 = [1000, 900, 800, 700, 600],nums2 = [1000, 950, 900, 850, 800, 750, 700, 650, 600, 550, 500]) == 4\n assert candidate(nums1 = [99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111, 1],nums2 = [100000, 99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111]) == 1\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [10, 10, 10, 10, 10, 10],nums2 = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == 14\n assert candidate(nums1 = [5, 4, 3, 2, 1],nums2 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums1 = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],nums2 = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 9\n assert candidate(nums1 = [100, 50, 25, 10, 1],nums2 = [200, 150, 100, 90, 80, 70, 60, 50, 40, 30, 25, 20, 15, 10, 5]) == 10\n assert candidate(nums1 = [10, 5, 5, 5, 5],nums2 = [20, 15, 15, 10, 10, 10, 5, 5, 5, 5]) == 8\n assert candidate(nums1 = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(nums1 = [5, 4, 4, 3, 3, 3, 2, 1],nums2 = [9, 8, 7, 6, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == 9\n assert candidate(nums1 = [100, 50, 30, 20, 10],nums2 = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 10\n assert candidate(nums1 = [100, 50, 25, 10, 5],nums2 = [100, 75, 50, 25, 10, 5, 2]) == 1\n assert candidate(nums1 = [10, 10, 10, 10, 10],nums2 = [20, 20, 20, 20, 20]) == 4\n assert candidate(nums1 = [100000],nums2 = [1]) == 0\n assert candidate(nums1 = [100, 90, 80, 70, 60],nums2 = [100, 95, 90, 85, 80, 75, 70, 65, 60, 55]) == 4\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().maxDistance", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxDistance(vector& nums1, vector& nums2) {", "container": "Solution", "callable": "maxDistance", "parameters": [{"name": "nums1", "type": "vector&"}, {"name": "nums2", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1856, "task_id": "maximum-subarray-min-product", "difficulty": "Medium", "problem_description": "The min-product of an array is equal to the minimum value in the array multiplied by the array's sum.\n\nFor example, the array [3,2,5] (minimum value is 2) has a min-product of 2 * (3+2+5) = 2 * 10 = 20.\n\nGiven an array of integers nums, return the maximum min-product of any non-empty subarray of nums. Since the answer may be large, return it modulo 109 + 7.\nNote that the min-product should be maximized before performing the modulo operation. Testcases are generated such that the maximum min-product without modulo will fit in a 64-bit signed integer.\nA subarray is a contiguous part of an array.\n \nExample 1:\n\nInput: nums = [1,2,3,2]\nOutput: 14\nExplanation: The maximum min-product is achieved with the subarray [2,3,2] (minimum value is 2).\n2 * (2+3+2) = 2 * 7 = 14.\n\nExample 2:\n\nInput: nums = [2,3,3,1,2]\nOutput: 18\nExplanation: The maximum min-product is achieved with the subarray [3,3] (minimum value is 3).\n3 * (3+3) = 3 * 6 = 18.\n\nExample 3:\n\nInput: nums = [3,1,5,6,4,2]\nOutput: 60\nExplanation: The maximum min-product is achieved with the subarray [5,6,4] (minimum value is 4).\n4 * (5+6+4) = 4 * 15 = 60.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 9, 6, 8, 7]) == 180\n assert candidate(nums = [2, 1]) == 4\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 240\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 180\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 240\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [10000000]) == 999300007\n assert candidate(nums = [5, 9, 6, 8, 7, 4, 3, 2, 10, 1]) == 180\n assert candidate(nums = [2, 3, 3, 1, 2]) == 18\n assert candidate(nums = [10000000, 9999999, 9999998, 9999997, 9999996]) == 696500047\n assert candidate(nums = [5, 5, 5, 5, 5]) == 125\n assert candidate(nums = [7, 1, 5, 6, 4, 2]) == 60\n assert candidate(nums = [1, 2, 3, 4, 5]) == 36\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 15\n assert candidate(nums = [1, 1, 1, 1, 1]) == 5\n assert candidate(nums = [3, 1, 5, 6, 4, 2]) == 60\n assert candidate(nums = [10000000, 9999999, 9999998, 9999997]) == 817200025\n assert candidate(nums = [5, 4, 3, 2, 1]) == 36\n assert candidate(nums = [1, 2]) == 4\n assert candidate(nums = [1, 2, 3, 2]) == 14\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1]) == 72\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 135\n assert candidate(nums = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991]) == 643000419\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 2400000\n assert candidate(nums = [5, 8, 6, 7, 8, 9, 9, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 642\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1728\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1728\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 360\n assert candidate(nums = [10, 20, 10, 30, 20, 10, 40, 30, 20, 10]) == 2100\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1728\n assert candidate(nums = [9999999, 1, 9999999, 1, 9999999, 1, 9999999, 1, 9999999, 1]) == 979300008\n assert candidate(nums = [1, 3, 2, 5, 6, 2, 8, 4, 9, 1, 3]) == 84\n assert candidate(nums = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991, 9999990]) == 342300564\n assert candidate(nums = [1, 10000000, 1, 10000000, 1, 10000000, 1, 10000000, 1, 10000000, 1, 10000000, 1, 10000000, 1, 10000000]) == 999300007\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 756\n assert candidate(nums = [1, 1, 1, 1, 10000000, 1, 1, 1, 1, 10000000, 1, 1, 1, 1]) == 999300007\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(nums = [10000000, 10000000, 10000000, 10000000, 10000000]) == 996500007\n assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5]) == 3600\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 420\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7]) == 90\n assert candidate(nums = [7, 8, 9, 10, 1, 2, 3, 4, 5, 6]) == 238\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 420\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100]) == 10000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 420\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 240\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 480\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 420\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 480\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == 999930007\n assert candidate(nums = [2, 3, 2, 4, 3, 2, 5, 4, 3, 2, 6, 5, 4, 3, 2, 7, 6, 5, 4, 3, 2, 8, 7, 6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2, 10]) == 332\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1728\n assert candidate(nums = [10000000, 9000000, 8000000, 7000000, 6000000, 5000000, 4000000, 3000000, 2000000, 1000000]) == 998320007\n assert candidate(nums = [3, 2, 1, 4, 3, 2, 5, 4, 3, 6, 5, 4, 7, 6, 5, 8, 7, 6, 9, 8, 7]) == 315\n assert candidate(nums = [10, 20, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1000\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 240\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 240\n assert candidate(nums = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994]) == 365100133\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1728\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 240\n assert candidate(nums = [8, 2, 6, 5, 4, 1, 3, 7, 9]) == 112\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 24000\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 41\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 82\n assert candidate(nums = [10000000, 1, 10000000, 1, 10000000, 1, 10000000, 1]) == 999300007\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 240\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 980\n assert candidate(nums = [2, 1, 3, 4, 1, 5, 1, 6, 1, 7]) == 49\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 420\n assert candidate(nums = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991]) == 643000419\n assert candidate(nums = [10000000, 1, 10000000, 1, 10000000, 1, 10000000, 1, 10000000]) == 999300007\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 3300\n assert candidate(nums = [3, 2, 5, 4, 7, 6, 8, 9, 1, 10, 2, 3, 4, 5, 6, 7, 8, 9, 1, 10, 2, 3, 4, 5, 6, 7, 8, 9, 1, 10, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == 210\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 756\n assert candidate(nums = [1, 5, 4, 3, 6, 2, 8, 7, 9]) == 168\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 81\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 100\n assert candidate(nums = [5, 6, 1, 2, 8, 9, 3, 4, 7, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 240\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1728\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 180\n assert candidate(nums = [10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000]) == 993000007\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10]) == 144\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6]) == 148\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [10000000, 1, 10000000, 1, 10000000, 1, 10000000]) == 999300007\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 240\n assert candidate(nums = [1, 10000000, 2, 9999999, 3, 9999998, 4, 9999997, 5, 9999996]) == 999300007\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1]) == 36\n assert candidate(nums = [9999996, 9999997, 9999998, 9999999, 10000000, 9999999, 9999998, 9999997, 9999996]) == 433700087\n assert candidate(nums = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == 30\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 240\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == 33\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 24000\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 999300007\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 375\n assert candidate(nums = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 25\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000]) == 999937007\n assert candidate(nums = [1, 10000000, 1, 10000000, 1, 10000000, 1, 10000000]) == 999300007\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxSumMinProduct", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxSumMinProduct(vector& nums) {", "container": "Solution", "callable": "maxSumMinProduct", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1857, "task_id": "largest-color-value-in-a-directed-graph", "difficulty": "Hard", "problem_description": "There is a directed graph of n colored nodes and m edges. The nodes are numbered from 0 to n - 1.\\r\n\\r\nYou are given a string colors where colors[i] is a lowercase English letter representing the color of the ith node in this graph (0-indexed). You are also given a 2D array edges where edges[j] = [aj, bj] indicates that there is a directed edge from node aj to node bj.\\r\n\\r\nA valid path in the graph is a sequence of nodes x1 -> x2 -> x3 -> ... -> xk such that there is a directed edge from xi to xi+1 for every 1 <= i < k. The color value of the path is the number of nodes that are colored the most frequently occurring color along that path.\\r\n\\r\nReturn the largest color value of any valid path in the given graph, or -1 if the graph contains a cycle.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\n\\r\n\\r\nInput: colors = \"abaca\", edges = [[0,1],[0,2],[2,3],[3,4]]\\r\nOutput: 3\\r\nExplanation: The path 0 -> 2 -> 3 -> 4 contains 3 nodes that are colored \"a\" (red in the above image).\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\n\\r\n\\r\nInput: colors = \"a\", edges = [[0,0]]\\r\nOutput: -1\\r\nExplanation: There is a cycle from 0 to 0.\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\tn == colors.length\\r\n\tm == edges.length\\r\n\t1 <= n <= 105\\r\n\t0 <= m <= 105\\r\n\tcolors consists of lowercase English letters.\\r\n\t0 <= aj, bj < n\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(colors = \"abcde\",edges = []) == 1\n assert candidate(colors = \"abcdefghijklmnopqrstuvwxyz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25]]) == 1\n assert candidate(colors = \"zzz\",edges = [[0, 1], [1, 2], [2, 0]]) == -1\n assert candidate(colors = \"abacabadabacaba\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 8\n assert candidate(colors = \"aaaaa\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]) == -1\n assert candidate(colors = \"abcdef\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 1\n assert candidate(colors = \"abcde\",edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 1\n assert candidate(colors = \"abcdef\",edges = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4], [4, 5]]) == 1\n assert candidate(colors = \"abcde\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]) == -1\n assert candidate(colors = \"aaaaa\",edges = [[0, 1], [1, 2], [2, 3], [3, 4]]) == 5\n assert candidate(colors = \"xyzz\",edges = [[0, 1], [1, 2], [2, 3]]) == 2\n assert candidate(colors = \"abcabc\",edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3]]) == -1\n assert candidate(colors = \"abcdabcdabcd\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 3\n assert candidate(colors = \"xyz\",edges = [[0, 1], [1, 2]]) == 1\n assert candidate(colors = \"aabbcc\",edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3]]) == -1\n assert candidate(colors = \"abcabcabc\",edges = [[0, 1], [1, 2], [2, 0], [3, 4], [4, 5], [5, 3]]) == -1\n assert candidate(colors = \"aabbcc\",edges = [[0, 1], [2, 3], [4, 5]]) == 2\n assert candidate(colors = \"aaabbb\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 3\n assert candidate(colors = \"zzzzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]]) == -1\n assert candidate(colors = \"aaaa\",edges = [[0, 1], [1, 2], [2, 3], [3, 0]]) == -1\n assert candidate(colors = \"aabbcc\",edges = [[0, 1], [1, 2], [2, 0]]) == -1\n assert candidate(colors = \"a\",edges = []) == 1\n assert candidate(colors = \"abcd\",edges = [[0, 1], [0, 2], [1, 3], [2, 3]]) == 1\n assert candidate(colors = \"aabbbbcccc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == 4\n assert candidate(colors = \"abcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 3\n assert candidate(colors = \"a\",edges = [[0, 0]]) == -1\n assert candidate(colors = \"abaca\",edges = [[0, 1], [0, 2], [2, 3], [3, 4]]) == 3\n assert candidate(colors = \"abcd\",edges = [[0, 1], [1, 2], [2, 3], [3, 0], [0, 2], [1, 3]]) == -1\n assert candidate(colors = \"ab\",edges = [[0, 1]]) == 1\n assert candidate(colors = \"aabbcc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]) == 2\n assert candidate(colors = \"zzzzzzzzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0]]) == -1\n assert candidate(colors = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35]]) == 2\n assert candidate(colors = \"abcabcabcabcabcabcabcabcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 10]]) == -1\n assert candidate(colors = \"zzzzzzzzzzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == -1\n assert candidate(colors = \"abcbcbc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 2]]) == -1\n assert candidate(colors = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39]]) == 2\n assert candidate(colors = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 0]]) == -1\n assert candidate(colors = \"abcdef\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]]) == -1\n assert candidate(colors = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39], [39, 40], [40, 41], [41, 42], [42, 43], [43, 44], [44, 45], [45, 46], [46, 47], [47, 48], [48, 49]]) == 2\n assert candidate(colors = \"abacabadabe\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == -1\n assert candidate(colors = \"abcde\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 2], [1, 3], [2, 4], [3, 0], [4, 1]]) == -1\n assert candidate(colors = \"aaaaaaaaaa\",edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 8], [6, 8], [7, 9], [8, 9]]) == 5\n assert candidate(colors = \"abcdef\",edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 4], [2, 5], [3, 5], [4, 5]]) == 1\n assert candidate(colors = \"bbaaabbbaaabbbaaabbbaaa\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 8\n assert candidate(colors = \"abcdefghijklmnopqrstuvwx\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23]]) == 1\n assert candidate(colors = \"ababababa\",edges = [[0, 1], [1, 2], [2, 0], [1, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 3]]) == -1\n assert candidate(colors = \"xyzxyzxyz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [0, 2], [1, 3], [4, 6], [5, 7]]) == -1\n assert candidate(colors = \"abcde\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [2, 0], [3, 1]]) == -1\n assert candidate(colors = \"abcdef\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 2]]) == -1\n assert candidate(colors = \"abacabadabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 5\n assert candidate(colors = \"abcdefghijk\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 0]]) == -1\n assert candidate(colors = \"abacabadabe\",edges = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 3]]) == -1\n assert candidate(colors = \"abcabcabcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 10]]) == -1\n assert candidate(colors = \"aaabbbccc\",edges = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 8], [8, 4], [1, 3], [3, 5], [5, 7]]) == -1\n assert candidate(colors = \"ababababc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0]]) == -1\n assert candidate(colors = \"abcdefghij\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 0], [9, 1]]) == -1\n assert candidate(colors = \"zzzzzzzzzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == -1\n assert candidate(colors = \"aaaabbbbccccdddd\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]]) == 4\n assert candidate(colors = \"zzzzzzzzzz\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 10\n assert candidate(colors = \"aabbccddeeff\",edges = [[0, 1], [0, 5], [1, 2], [1, 3], [2, 4], [3, 4], [5, 6], [5, 7], [6, 8], [7, 8], [8, 9]]) == 2\n assert candidate(colors = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 0]]) == -1\n assert candidate(colors = \"abacabadabe\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9]]) == 5\n assert candidate(colors = \"abcde\",edges = [[0, 1], [0, 2], [1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [4, 0]]) == -1\n assert candidate(colors = \"abcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [1, 3], [3, 5], [5, 7]]) == -1\n assert candidate(colors = \"abcabcabcabcabcabcabcabcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 28]]) == -1\n assert candidate(colors = \"abcabcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 0]]) == -1\n assert candidate(colors = \"abacbacba\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]]) == 4\n assert candidate(colors = \"abacabadabe\",edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 8], [6, 8], [7, 9], [8, 9]]) == 4\n assert candidate(colors = \"abacabadaba\",edges = [[0, 1], [0, 2], [1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 9]]) == 5\n assert candidate(colors = \"abacabadaba\",edges = [[0, 1], [1, 0], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == -1\n assert candidate(colors = \"ababababab\",edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 5], [3, 6], [4, 5], [4, 6], [5, 7], [5, 8], [6, 7], [6, 8], [7, 9], [8, 9]]) == 5\n assert candidate(colors = \"abacabadaba\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 5\n assert candidate(colors = \"abcabcabcabcabcabcabcabcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29]]) == 10\n assert candidate(colors = \"abcdefghij\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == -1\n assert candidate(colors = \"abacabadaba\",edges = [[0, 1], [0, 2], [1, 3], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 5\n assert candidate(colors = \"aabbaabb\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 1]]) == -1\n assert candidate(colors = \"abcdefgabcdefgabcdefgabcdefg\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 7]]) == -1\n assert candidate(colors = \"aaabbbcccdddeeefffggghhh\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23]]) == 3\n assert candidate(colors = \"abcdefghijk\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 1\n assert candidate(colors = \"aaaabbbbccccdddd\",edges = [[0, 1], [0, 4], [1, 2], [1, 5], [2, 3], [2, 6], [3, 7], [4, 5], [4, 8], [5, 6], [5, 9], [6, 7], [6, 10], [7, 11], [8, 9], [8, 12], [9, 10], [9, 13], [10, 11], [10, 14], [11, 15], [12, 13], [13, 14], [14, 15]]) == 4\n assert candidate(colors = \"abcabcabcabcabc\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 5\n assert candidate(colors = \"abcde\",edges = [[0, 1], [0, 2], [2, 1], [1, 3], [2, 3], [3, 4], [4, 0]]) == -1\n assert candidate(colors = \"zzzzzzyyyyy\",edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == 6\n assert candidate(colors = \"abacabadabacaba\",edges = [[0, 1], [0, 2], [2, 3], [3, 4], [1, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == 6\n"}, "metadata": {"canonical_parameter_names": ["colors", "edges"], "leetcode_dataset_entry_point": "Solution().largestPathValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int largestPathValue(string colors, vector>& edges) {", "container": "Solution", "callable": "largestPathValue", "parameters": [{"name": "colors", "type": "string"}, {"name": "edges", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1859, "task_id": "sorting-the-sentence", "difficulty": "Easy", "problem_description": "A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each word consists of lowercase and uppercase English letters.\nA sentence can be shuffled by appending the 1-indexed word position to each word then rearranging the words in the sentence.\n\nFor example, the sentence \"This is a sentence\" can be shuffled as \"sentence4 a3 is2 This1\" or \"is2 sentence4 This1 a3\".\n\nGiven a shuffled sentence s containing no more than 9 words, reconstruct and return the original sentence.\n \nExample 1:\n\nInput: s = \"is2 sentence4 This1 a3\"\nOutput: \"This is a sentence\"\nExplanation: Sort the words in s to their original positions \"This1 is2 a3 sentence4\", then remove the numbers.\n\nExample 2:\n\nInput: s = \"Myself2 Me1 I4 and3\"\nOutput: \"Me Myself and I\"\nExplanation: Sort the words in s to their original positions \"Me1 Myself2 and3 I4\", then remove the numbers.\n\n \nConstraints:\n\n2 <= s.length <= 200\ns consists of lowercase and uppercase English letters, spaces, and digits from 1 to 9.\nThe number of words in s is between 1 and 9.\nThe words in s are separated by a single space.\ns contains no leading or trailing spaces.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"eight8 seven7 six6 five5 four4 three3 two2 one1\") == \"one two three four five six seven eight\"\n assert candidate(s = \"seven7 six6 five5 four4 three3 two2 one1\") == \"one two three four five six seven\"\n assert candidate(s = \"nine9 eight8 seven7 six6 five5 four4 three3 two2 one1\") == \"one two three four five six seven eight nine\"\n assert candidate(s = \"three3 two2 one1\") == \"one two three\"\n assert candidate(s = \"is2 sentence4 This1 a3\") == \"This is a sentence\"\n assert candidate(s = \"five5 four4 three3 two2 one1\") == \"one two three four five\"\n assert candidate(s = \"A9 B8 C7 D6 E5 F4 G3 H2 I1\") == \"I H G F E D C B A\"\n assert candidate(s = \"Myself2 Me1 I4 and3\") == \"Me Myself and I\"\n assert candidate(s = \"nine9 eight8 seven7 six6 five5 four4 three3 two2 one1 zero0\") == \"one two three four five six seven eight nine zero\"\n assert candidate(s = \"six6 five5 four4 three3 two2 one1\") == \"one two three four five six\"\n assert candidate(s = \"one1\") == \"one\"\n assert candidate(s = \"two1 one2\") == \"two one\"\n assert candidate(s = \"four4 three3 two2 one1\") == \"one two three four\"\n assert candidate(s = \"quick5 brown3 fox2 jumps9 over8 lazy4 the7 dog6 a1\") == \"a fox brown lazy quick dog the over jumps\"\n assert candidate(s = \"Quick5 brown4 fox3 jumps2 over1\") == \"over jumps fox brown Quick\"\n assert candidate(s = \"big2 bigger3 biggest1\") == \"biggest big bigger\"\n assert candidate(s = \"order10 words9 in8 correct7 sequence6 is5 important4 for3 understanding2 this1\") == \"this understanding for important is sequence correct in words order1\"\n assert candidate(s = \"a1 bc2 def3 ghij4 klmno5 pqrstu6 vwxyz7 abcdefg8 hijklmno9\") == \"a bc def ghij klmno pqrstu vwxyz abcdefg hijklmno\"\n assert candidate(s = \"abc1 def2 ghi3 jkl4 mno5 pqr6 stu7 vwx8 yza9\") == \"abc def ghi jkl mno pqr stu vwx yza\"\n assert candidate(s = \"Data2 Science1\") == \"Science Data\"\n assert candidate(s = \"alpha10 beta9 gamma8 delta7 epsilon6 zeta5 eta4 theta3 iota2 kappa1\") == \"kappa iota theta eta zeta epsilon delta gamma beta alpha1\"\n assert candidate(s = \"Quick5 Brown4 Fox3 Jumps2 Over1\") == \"Over Jumps Fox Brown Quick\"\n assert candidate(s = \"Digital2 Transformation1\") == \"Transformation Digital\"\n assert candidate(s = \"zebra9 yellow8 xenon7 winter6 volcano5 umbrella4 tornado3 storm2 rainbow1\") == \"rainbow storm tornado umbrella volcano winter xenon yellow zebra\"\n assert candidate(s = \"short1 longerWord2 evenLongerWord3\") == \"short longerWord evenLongerWord\"\n assert candidate(s = \"one9 two8 three7 four6 five5 six4 seven3 eight2 nine1\") == \"nine eight seven six five four three two one\"\n assert candidate(s = \"apple8 banana7 cherry6 date5 elderberry4 fig3 grape2 huckleberry1\") == \"huckleberry grape fig elderberry date cherry banana apple\"\n assert candidate(s = \"apple9 banana8 cherry7 date6 elderberry5 fig4 grape3 honeydew2 ice1\") == \"ice honeydew grape fig elderberry date cherry banana apple\"\n assert candidate(s = \"MixedCASE1 Word2 with3 DIFFERENT4 cases5\") == \"MixedCASE Word with DIFFERENT cases\"\n assert candidate(s = \"Python1 is2 great3\") == \"Python is great\"\n assert candidate(s = \"a9 b8 c7 d6 e5 f4 g3 h2 i1\") == \"i h g f e d c b a\"\n assert candidate(s = \"single1\") == \"single\"\n assert candidate(s = \"one1 two2 three3 four4 five5 six6 seven7 eight8 nine9\") == \"one two three four five six seven eight nine\"\n assert candidate(s = \"reverse9 order8 words7 in6 a5 sentence4 for3 testing2 purposes1\") == \"purposes testing for sentence a in words order reverse\"\n assert candidate(s = \"sun8 moon7 stars6 galaxy5 universe4 planets3 asteroid2 comet1\") == \"comet asteroid planets universe galaxy stars moon sun\"\n assert candidate(s = \"two2 one1 three3 four4 five5 six6 seven7 eight8 nine9\") == \"one two three four five six seven eight nine\"\n assert candidate(s = \"complex1 testing2 cases3 with4 multiple5 digits6 and7 shuffled8 order9\") == \"complex testing cases with multiple digits and shuffled order\"\n assert candidate(s = \"Sustainability1\") == \"Sustainability\"\n assert candidate(s = \"Hard2 Work3 Makes1 Success4\") == \"Makes Hard Work Success\"\n assert candidate(s = \"A5 B4 C3 D2 E1 F6 G7 H8 I9\") == \"E D C B A F G H I\"\n assert candidate(s = \"Alphabetically9 Better8 Christmas7 Does6 Everyone5 Feel4 Good3 Happy2 Indeed1\") == \"Indeed Happy Good Feel Everyone Does Christmas Better Alphabetically\"\n assert candidate(s = \"sun9 moon8 star7 planet6 comet5 asteroid4 meteor3 satellite2 galaxy1\") == \"galaxy satellite meteor asteroid comet planet star moon sun\"\n assert candidate(s = \"The9 quick8 brown7 fox6 jumps5 over4 lazy3 dog2 one1\") == \"one dog lazy over jumps fox brown quick The\"\n assert candidate(s = \"short6 longer5 very4 much3 more2 words1\") == \"words more much very longer short\"\n assert candidate(s = \"first1 second2 third3 fourth4 fifth5 sixth6 seventh7 eighth8 ninth9\") == \"first second third fourth fifth sixth seventh eighth ninth\"\n assert candidate(s = \"Two2 Words1\") == \"Words Two\"\n assert candidate(s = \"Complicated1 Sorting2 becomes3 significantly4 more5 challenging6 when7 words8 overlap9\") == \"Complicated Sorting becomes significantly more challenging when words overlap\"\n assert candidate(s = \"Python10 Java9 C8 Cpp7 Rust6 Go5 Ruby4 Swift3 Kotlin2 TypeScript1\") == \"TypeScript Kotlin Swift Ruby Go Rust Cpp C Java Python1\"\n assert candidate(s = \"zZ9 yY8 xX7 wW6 vV5 uU4 tT3 sS2 rR1\") == \"rR sS tT uU vV wW xX yY zZ\"\n assert candidate(s = \"A9 lot8 of7 testing6 needs5 to4 be3 done2 always1\") == \"always done be to needs testing of lot A\"\n assert candidate(s = \"z9 y8 x7 w6 v5 u4 t3 s2 r1\") == \"r s t u v w x y z\"\n assert candidate(s = \"twoWords2 oneWord1\") == \"oneWord twoWords\"\n assert candidate(s = \"ab9 cd8 ef7 gh6 ij5 kl4 mn3 op2 qr1\") == \"qr op mn kl ij gh ef cd ab\"\n assert candidate(s = \"Open3 Source2 Software1\") == \"Software Source Open\"\n assert candidate(s = \"a9 quick8 brown7 fox6 jumps5 over4 lazy3 dogs2 one1\") == \"one dogs lazy over jumps fox brown quick a\"\n assert candidate(s = \"aA9 bB8 cC7 dD6 eE5 fF4 gG3 hH2 iI1\") == \"iI hH gG fF eE dD cC bB aA\"\n assert candidate(s = \"shuffle7 sentence6 original5 reconstruct4 and3 a2 is1\") == \"is a and reconstruct original sentence shuffle\"\n assert candidate(s = \"shuffle9 words8 correctly7 to6 get5 the4 right3 order2 one1\") == \"one order right the get to correctly words shuffle\"\n assert candidate(s = \"HELLO1 woRLD2\") == \"HELLO woRLD\"\n assert candidate(s = \"Short1 words2 can3 also4 be5 tricky6\") == \"Short words can also be tricky\"\n assert candidate(s = \"Python3 Java2 C1 Ruby4 Go5\") == \"C Java Python Ruby Go\"\n assert candidate(s = \"mixed8 case7 word6 CASE5 Mixed4 CASE3 mixed2 CASE1\") == \"CASE mixed CASE Mixed CASE word case mixed\"\n assert candidate(s = \"Python3 Java2 C1\") == \"C Java Python\"\n assert candidate(s = \"This8 is7 a6 sample5 sentence4 with3 various2 words1\") == \"words various with sentence sample a is This\"\n assert candidate(s = \"ninja9 samurai8 katana7 wakizashi6 tanto5 yoroi4 kusarigama3 tsurugi2 ninja1\") == \"ninja tsurugi kusarigama yoroi tanto wakizashi katana samurai ninja\"\n assert candidate(s = \"alpha9 beta8 gamma7 delta6 epsilon5 zeta4 eta3 theta2 iota1\") == \"iota theta eta zeta epsilon delta gamma beta alpha\"\n assert candidate(s = \"zebra9 yak8 xenon7 wolf6 vulture5 unicorn4 tiger3 snake2 rabbit1\") == \"rabbit snake tiger unicorn vulture wolf xenon yak zebra\"\n assert candidate(s = \"repeated1 same2 numbers3 in4 different5 words6 should7 not8 be9 valid10\") == \"repeated same numbers in different words should not be valid1\"\n assert candidate(s = \"reverse9 order8 words7 in6 this5 shuffled4 sentence3 into2 proper1\") == \"proper into sentence shuffled this in words order reverse\"\n assert candidate(s = \"Single1\") == \"Single\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().sortSentence", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string sortSentence(string s) {", "container": "Solution", "callable": "sortSentence", "parameters": [{"name": "s", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1860, "task_id": "incremental-memory-leak", "difficulty": "Medium", "problem_description": "You are given two integers memory1 and memory2 representing the available memory in bits on two memory sticks. There is currently a faulty program running that consumes an increasing amount of memory every second.\nAt the ith second (starting from 1), i bits of memory are allocated to the stick with more available memory (or from the first memory stick if both have the same available memory). If neither stick has at least i bits of available memory, the program crashes.\nReturn an array containing [crashTime, memory1crash, memory2crash], where crashTime is the time (in seconds) when the program crashed and memory1crash and memory2crash are the available bits of memory in the first and second sticks respectively.\n \nExample 1:\n\nInput: memory1 = 2, memory2 = 2\nOutput: [3,1,0]\nExplanation: The memory is allocated as follows:\n- At the 1st second, 1 bit of memory is allocated to stick 1. The first stick now has 1 bit of available memory.\n- At the 2nd second, 2 bits of memory are allocated to stick 2. The second stick now has 0 bits of available memory.\n- At the 3rd second, the program crashes. The sticks have 1 and 0 bits available respectively.\n\nExample 2:\n\nInput: memory1 = 8, memory2 = 11\nOutput: [6,0,4]\nExplanation: The memory is allocated as follows:\n- At the 1st second, 1 bit of memory is allocated to stick 2. The second stick now has 10 bit of available memory.\n- At the 2nd second, 2 bits of memory are allocated to stick 2. The second stick now has 8 bits of available memory.\n- At the 3rd second, 3 bits of memory are allocated to stick 1. The first stick now has 5 bits of available memory.\n- At the 4th second, 4 bits of memory are allocated to stick 2. The second stick now has 4 bits of available memory.\n- At the 5th second, 5 bits of memory are allocated to stick 1. The first stick now has 0 bits of available memory.\n- At the 6th second, the program crashes. The sticks have 0 and 4 bits available respectively.\n\n \nConstraints:\n\n0 <= memory1, memory2 <= 231 - 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(memory1 = 0,memory2 = 0) == [1, 0, 0]\n assert candidate(memory1 = 2147483647,memory2 = 2147483647) == [92681, 88047, 41707]\n assert candidate(memory1 = 1000000000,memory2 = 1000000000) == [63245, 49116, 17494]\n assert candidate(memory1 = 15,memory2 = 10) == [7, 4, 0]\n assert candidate(memory1 = 100,memory2 = 100) == [20, 0, 10]\n assert candidate(memory1 = 10,memory2 = 10) == [6, 1, 4]\n assert candidate(memory1 = 1073741823,memory2 = 1073741823) == [65535, 65534, 32767]\n assert candidate(memory1 = 1,memory2 = 1) == [2, 0, 1]\n assert candidate(memory1 = 8,memory2 = 11) == [6, 0, 4]\n assert candidate(memory1 = 1073741824,memory2 = 1073741824) == [65536, 0, 32768]\n assert candidate(memory1 = 15,memory2 = 15) == [7, 6, 3]\n assert candidate(memory1 = 1,memory2 = 2) == [2, 1, 1]\n assert candidate(memory1 = 15,memory2 = 5) == [6, 0, 5]\n assert candidate(memory1 = 100,memory2 = 50) == [17, 3, 11]\n assert candidate(memory1 = 2,memory2 = 2) == [3, 1, 0]\n assert candidate(memory1 = 1000000000,memory2 = 500000000) == [54772, 3472, 37922]\n assert candidate(memory1 = 0,memory2 = 1000000) == [1414, 0, 1009]\n assert candidate(memory1 = 1024,memory2 = 512) == [55, 12, 39]\n assert candidate(memory1 = 123456789,memory2 = 987654321) == [47140, 11258, 33622]\n assert candidate(memory1 = 256,memory2 = 255) == [32, 15, 0]\n assert candidate(memory1 = 1000000000,memory2 = 999999999) == [63245, 17493, 49116]\n assert candidate(memory1 = 2048,memory2 = 512) == [71, 67, 8]\n assert candidate(memory1 = 5,memory2 = 1) == [3, 2, 1]\n assert candidate(memory1 = 500000000,memory2 = 499999999) == [44721, 8039, 30400]\n assert candidate(memory1 = 100000,memory2 = 100001) == [632, 460, 145]\n assert candidate(memory1 = 1073741823,memory2 = 1073741824) == [65536, 32767, 0]\n assert candidate(memory1 = 2147483647,memory2 = 1073741824) == [80264, 34153, 76602]\n assert candidate(memory1 = 1000000,memory2 = 0) == [1414, 1009, 0]\n assert candidate(memory1 = 5,memory2 = 5) == [4, 1, 3]\n assert candidate(memory1 = 0,memory2 = 100) == [14, 0, 9]\n assert candidate(memory1 = 1000000000,memory2 = 2000000000) == [77459, 17790, 72599]\n assert candidate(memory1 = 500000000,memory2 = 500000001) == [44721, 8040, 30401]\n assert candidate(memory1 = 500000,memory2 = 500000) == [1414, 151, 858]\n assert candidate(memory1 = 2000000000,memory2 = 1000000000) == [77459, 72599, 17790]\n assert candidate(memory1 = 1,memory2 = 0) == [2, 0, 0]\n assert candidate(memory1 = 4000000000,memory2 = 3000000000) == [118321, 102440, 27200]\n assert candidate(memory1 = 1000000,memory2 = 1000000) == [2000, 0, 1000]\n assert candidate(memory1 = 3000000000,memory2 = 1000000000) == [89442, 62751, 46288]\n assert candidate(memory1 = 2147483647,memory2 = 0) == [65536, 32767, 0]\n assert candidate(memory1 = 500000000,memory2 = 500000000) == [44721, 30400, 8040]\n assert candidate(memory1 = 1234567890,memory2 = 1234567890) == [70272, 29394, 64530]\n assert candidate(memory1 = 1024,memory2 = 1023) == [64, 31, 0]\n assert candidate(memory1 = 1023,memory2 = 1024) == [64, 31, 0]\n assert candidate(memory1 = 1048576,memory2 = 1048576) == [2048, 0, 1024]\n assert candidate(memory1 = 512,memory2 = 1024) == [55, 39, 12]\n assert candidate(memory1 = 1000000000,memory2 = 1000000001) == [63245, 17494, 49117]\n assert candidate(memory1 = 4,memory2 = 5) == [4, 2, 1]\n assert candidate(memory1 = 0,memory2 = 2147483647) == [65536, 0, 32767]\n assert candidate(memory1 = 512,memory2 = 2048) == [71, 8, 67]\n assert candidate(memory1 = 1000000,memory2 = 999999) == [2000, 999, 0]\n assert candidate(memory1 = 2147483647,memory2 = 2147483646) == [92681, 41706, 88047]\n assert candidate(memory1 = 4,memory2 = 4) == [4, 0, 2]\n assert candidate(memory1 = 4096,memory2 = 2048) == [110, 102, 47]\n assert candidate(memory1 = 1024,memory2 = 1024) == [64, 0, 32]\n assert candidate(memory1 = 2147483646,memory2 = 1) == [65536, 32766, 1]\n assert candidate(memory1 = 234567890,memory2 = 234567890) == [30631, 18665, 3350]\n assert candidate(memory1 = 2147483646,memory2 = 2147483646) == [92681, 88046, 41706]\n assert candidate(memory1 = 1,memory2 = 1000000000) == [44721, 1, 38440]\n assert candidate(memory1 = 999999999,memory2 = 1) == [44721, 38439, 1]\n assert candidate(memory1 = 500,memory2 = 500) == [44, 16, 38]\n assert candidate(memory1 = 2,memory2 = 1) == [2, 1, 1]\n assert candidate(memory1 = 128,memory2 = 256) == [27, 23, 10]\n assert candidate(memory1 = 1,memory2 = 1073741823) == [46341, 1, 20853]\n assert candidate(memory1 = 100000,memory2 = 100000) == [632, 144, 460]\n assert candidate(memory1 = 4294967295,memory2 = 4294967295) == [131071, 131070, 65535]\n assert candidate(memory1 = 0,memory2 = 1000) == [45, 0, 10]\n assert candidate(memory1 = 2147483646,memory2 = 2147483645) == [92681, 41705, 88046]\n assert candidate(memory1 = 10,memory2 = 1) == [5, 0, 1]\n assert candidate(memory1 = 0,memory2 = 1) == [2, 0, 0]\n assert candidate(memory1 = 1000000001,memory2 = 1000000000) == [63245, 17494, 49117]\n assert candidate(memory1 = 1,memory2 = 2147483647) == [65536, 1, 32767]\n assert candidate(memory1 = 100,memory2 = 0) == [14, 9, 0]\n assert candidate(memory1 = 2147483646,memory2 = 2147483647) == [92681, 41706, 88047]\n assert candidate(memory1 = 1073741823,memory2 = 1073741825) == [65536, 0, 32768]\n assert candidate(memory1 = 10,memory2 = 15) == [7, 0, 4]\n assert candidate(memory1 = 9,memory2 = 9) == [6, 0, 3]\n assert candidate(memory1 = 1000,memory2 = 1000) == [63, 39, 8]\n assert candidate(memory1 = 2048,memory2 = 4096) == [110, 47, 102]\n assert candidate(memory1 = 1000,memory2 = 0) == [45, 10, 0]\n assert candidate(memory1 = 1,memory2 = 5) == [3, 1, 2]\n assert candidate(memory1 = 1000000000,memory2 = 1) == [44721, 38440, 1]\n"}, "metadata": {"canonical_parameter_names": ["memory1", "memory2"], "leetcode_dataset_entry_point": "Solution().memLeak", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector memLeak(int memory1, int memory2) {", "container": "Solution", "callable": "memLeak", "parameters": [{"name": "memory1", "type": "int"}, {"name": "memory2", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1861, "task_id": "rotating-the-box", "difficulty": "Medium", "problem_description": "You are given an m x n matrix of characters boxGrid representing a side-view of a box. Each cell of the box is one of the following:\n\nA stone '#'\nA stationary obstacle '*'\nEmpty '.'\n\nThe box is rotated 90 degrees clockwise, causing some of the stones to fall due to gravity. Each stone falls down until it lands on an obstacle, another stone, or the bottom of the box. Gravity does not affect the obstacles' positions, and the inertia from the box's rotation does not affect the stones' horizontal positions.\nIt is guaranteed that each stone in boxGrid rests on an obstacle, another stone, or the bottom of the box.\nReturn an n x m matrix representing the box after the rotation described above.\n \nExample 1:\n\n\nInput: boxGrid = [[\"#\",\".\",\"#\"]]\nOutput: [[\".\"],\n  [\"#\"],\n  [\"#\"]]\n\nExample 2:\n\n\nInput: boxGrid = [[\"#\",\".\",\"*\",\".\"],\n  [\"#\",\"#\",\"*\",\".\"]]\nOutput: [[\"#\",\".\"],\n  [\"#\",\"#\"],\n  [\"*\",\"*\"],\n  [\".\",\".\"]]\n\nExample 3:\n\n\nInput: boxGrid = [[\"#\",\"#\",\"*\",\".\",\"*\",\".\"],\n  [\"#\",\"#\",\"#\",\"*\",\".\",\".\"],\n  [\"#\",\"#\",\"#\",\".\",\"#\",\".\"]]\nOutput: [[\".\",\"#\",\"#\"],\n  [\".\",\"#\",\"#\"],\n  [\"#\",\"#\",\"*\"],\n  [\"#\",\"*\",\".\"],\n  [\"#\",\".\",\"*\"],\n  [\"#\",\".\",\".\"]]\n\n \nConstraints:\n\nm == boxGrid.length\nn == boxGrid[i].length\n1 <= m, n <= 500\nboxGrid[i][j] is either '#', '*', or '.'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(boxGrid = [['#', '.', '*', '.'], ['#', '#', '*', '.']]) == [['#', '.'], ['#', '#'], ['*', '*'], ['.', '.']]\n assert candidate(boxGrid = [['#', '.', '#']]) == [['.'], ['#'], ['#']]\n assert candidate(boxGrid = [['#', '#', '*', '.', '*', '.'], ['#', '#', '#', '*', '.', '.'], ['#', '#', '#', '.', '#', '.']]) == [['.', '#', '#'], ['.', '#', '#'], ['#', '#', '*'], ['#', '*', '.'], ['#', '.', '*'], ['#', '.', '.']]\n assert candidate(boxGrid = [['*', '.', '.', '.', '#', '.', '*', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '*'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#'], ['.', '.', '.', '.', '*'], ['#', '.', '.', '.', '.']]\n assert candidate(boxGrid = [['.', '.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '*', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '*', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '#', '#', '.']]\n assert candidate(boxGrid = [['#', '.', '.', '#', '*', '.'], ['.', '#', '.', '.', '#', '.'], ['.', '.', '#', '.', '.', '.']]) == [['.', '.', '.'], ['.', '.', '.'], ['.', '.', '#'], ['.', '.', '#'], ['.', '#', '*'], ['#', '#', '.']]\n assert candidate(boxGrid = [['#', '.', '.', '.', '#', '.'], ['*', '.', '#', '.', '.', '#'], ['#', '.', '*', '.', '#', '.'], ['.', '#', '#', '*', '.', '.']]) == [['.', '.', '*', '.'], ['#', '#', '.', '.'], ['#', '*', '.', '.'], ['*', '.', '.', '.'], ['.', '.', '#', '#'], ['.', '#', '#', '#']]\n assert candidate(boxGrid = [['.', '.', '#', '*'], ['*', '.', '.', '#'], ['.', '#', '.', '.'], ['#', '.', '.', '.']]) == [['.', '.', '*', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '#'], ['#', '#', '#', '*']]\n assert candidate(boxGrid = [['#', '.', '.', '*', '.', '.'], ['.', '#', '#', '.', '.', '#'], ['#', '.', '.', '.', '#', '.'], ['#', '.', '*', '.', '.', '*'], ['.', '.', '.', '#', '#', '.']]) == [['.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.'], ['.', '*', '.', '.', '#'], ['.', '.', '.', '#', '*'], ['#', '.', '#', '#', '.'], ['#', '*', '#', '#', '.']]\n assert candidate(boxGrid = [['*', '.', '.', '#'], ['.', '#', '#', '*'], ['.', '#', '.', '.'], ['.', '.', '.', '.']]) == [['.', '.', '.', '*'], ['.', '.', '#', '.'], ['.', '.', '#', '.'], ['.', '#', '*', '#']]\n assert candidate(boxGrid = [['#', '.', '*', '.', '#', '.', '*', '.'], ['.', '#', '.', '.', '.', '#', '.', '.'], ['.', '.', '#', '.', '.', '.', '#', '.']]) == [['.', '.', '.'], ['.', '.', '#'], ['.', '.', '*'], ['.', '.', '.'], ['.', '.', '.'], ['.', '.', '#'], ['#', '#', '*'], ['#', '#', '.']]\n assert candidate(boxGrid = [['#', '#', '.', '.', '*'], ['.', '#', '#', '.', '.'], ['.', '.', '*', '.', '#'], ['#', '.', '.', '#', '.']]) == [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '*', '.', '#'], ['#', '.', '#', '#'], ['#', '#', '#', '*']]\n assert candidate(boxGrid = [['.', '.', '.', '.', '*'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '*']]\n assert candidate(boxGrid = [['.', '.', '.', '.', '.', '.', '#'], ['.', '.', '.', '.', '#', '*', '.'], ['.', '.', '#', '*', '.', '.', '.'], ['#', '*', '.', '.', '.', '.', '.']]) == [['#', '.', '.', '.'], ['*', '.', '.', '.'], ['.', '#', '.', '.'], ['.', '*', '.', '.'], ['.', '.', '#', '.'], ['.', '.', '*', '.'], ['.', '.', '.', '#']]\n assert candidate(boxGrid = [['#', '#', '*', '#', '.', '.', '*', '.', '.'], ['.', '#', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '*', '.', '.'], ['.', '.', '.', '.', '#', '.', '.', '#', '.']]) == [['.', '.', '.', '.', '#'], ['.', '.', '.', '.', '#'], ['.', '.', '.', '.', '*'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#'], ['.', '*', '.', '.', '*'], ['#', '.', '#', '.', '.'], ['#', '.', '#', '#', '.']]\n assert candidate(boxGrid = [['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '*'], ['.', '.', '#', '.', '.', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '#', '*', '#', '.', '#', '#']]\n assert candidate(boxGrid = [['#', '#', '#', '.', '.', '.', '*'], ['.', '.', '#', '#', '.', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['.', '.', '.', '*', '.', '.', '.'], ['#', '.', '#', '.', '.', '.', '#'], ['.', '.', '.', '.', '#', '.', '.'], ['.', '*', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.', '.', '.'], ['*', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '*', '.', '.', '#'], ['.', '.', '#', '.', '.', '.', '#'], ['.', '.', '#', '.', '#', '#', '#'], ['.', '#', '#', '.', '#', '#', '*']]\n assert candidate(boxGrid = [['#', '.', '#', '*', '.', '*', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['*', '.', '.', '.', '*', '.', '.'], ['.', '#', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '#']]) == [['.', '.', '*', '.', '.'], ['.', '.', '.', '.', '#'], ['.', '.', '.', '.', '#'], ['.', '.', '.', '.', '*'], ['.', '.', '*', '.', '.'], ['.', '#', '.', '.', '*'], ['#', '#', '.', '.', '.']]\n assert candidate(boxGrid = [['.', '.', '.', '.'], ['#', '#', '#', '.'], ['.', '.', '#', '.'], ['.', '#', '.', '.']]) == [['.', '.', '.', '.'], ['.', '.', '#', '.'], ['.', '.', '#', '.'], ['#', '#', '#', '.']]\n assert candidate(boxGrid = [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '*'], ['#', '#', '#', '#', '#']]) == [['#', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.'], ['#', '*', '.', '.', '.', '.']]\n assert candidate(boxGrid = [['#', '#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.', '.'], ['*', '*', '*', '*', '*', '*']]) == [['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#']]\n assert candidate(boxGrid = [['.', '.', '#', '*', '#'], ['#', '.', '#', '.', '.'], ['.', '*', '.', '#', '.']]) == [['.', '.', '.'], ['*', '.', '.'], ['.', '.', '#'], ['.', '#', '*'], ['#', '#', '#']]\n assert candidate(boxGrid = [['#', '.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '#', '.', '.'], ['.', '.', '.', '.', '.', '#', '.'], ['.', '.', '.', '.', '.', '.', '*']]) == [['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['*', '#', '#', '#', '#', '#', '#']]\n assert candidate(boxGrid = [['#', '.', '#', '.', '#', '.', '*', '.'], ['.', '.', '#', '.', '.', '.', '#', '.'], ['#', '.', '.', '.', '*', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['*', '.', '.', '.', '.', '.', '.', '*'], ['.', '#', '.', '.', '.', '.', '.', '.']]) == [['.', '*', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.', '#'], ['.', '.', '.', '*', '.', '#'], ['.', '.', '.', '.', '.', '#'], ['.', '.', '.', '.', '#', '*'], ['#', '*', '.', '.', '#', '.']]\n assert candidate(boxGrid = [['#', '#', '#', '#', '*', '.'], ['.', '.', '*', '#', '.', '#'], ['*', '.', '#', '.', '.', '#'], ['#', '#', '#', '#', '.', '.']]) == [['.', '*', '.', '#'], ['.', '.', '.', '#'], ['#', '.', '*', '#'], ['#', '.', '.', '#'], ['#', '#', '#', '*'], ['#', '#', '#', '.']]\n assert candidate(boxGrid = [['*', '.', '.', '#', '.', '*'], ['.', '#', '.', '.', '.', '#'], ['.', '.', '#', '.', '*', '.'], ['#', '.', '.', '.', '.', '#'], ['.', '*', '.', '#', '.', '.']]) == [['.', '.', '.', '.', '*'], ['*', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '#', '.', '.'], ['.', '#', '*', '#', '#'], ['#', '#', '.', '#', '*']]\n assert candidate(boxGrid = [['.', '.', '#', '.', '*', '.', '#'], ['#', '.', '.', '.', '.', '.', '#'], ['.', '#', '#', '*', '.', '.', '.'], ['.', '.', '.', '.', '.', '*', '.']]) == [['.', '.', '.', '.'], ['.', '#', '.', '.'], ['.', '#', '.', '.'], ['.', '*', '.', '#'], ['.', '.', '.', '*'], ['*', '.', '#', '.'], ['.', '.', '#', '#']]\n assert candidate(boxGrid = [['#', '*', '#', '*', '.', '#'], ['.', '#', '.', '.', '.', '.'], ['#', '.', '.', '*', '#', '.'], ['*', '.', '.', '.', '#', '.'], ['.', '.', '#', '.', '.', '.']]) == [['.', '*', '.', '.', '#'], ['.', '.', '.', '.', '*'], ['.', '.', '#', '.', '#'], ['.', '.', '*', '.', '*'], ['.', '.', '.', '.', '.'], ['#', '#', '#', '#', '#']]\n assert candidate(boxGrid = [['#', '.', '#', '.', '.', '.', '#'], ['.', '.', '.', '#', '.', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['#', '.', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '#'], ['.', '#', '.', '#'], ['#', '#', '#', '#']]\n assert candidate(boxGrid = [['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['#', '#', '.', '#', '.', '.', '#'], ['.', '.', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.'], ['.', '#', '.', '.', '.', '.']]\n assert candidate(boxGrid = [['#', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '#']]) == [['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.', '.', '.', '#']]\n assert candidate(boxGrid = [['*', '*', '*', '*', '*'], ['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.'], ['*', '*', '#', '#', '.'], ['#', '#', '.', '.', '.']]) == [['.', '*', '.', '#', '*'], ['.', '*', '.', '#', '*'], ['.', '.', '.', '#', '*'], ['#', '#', '.', '#', '*'], ['#', '#', '.', '#', '*']]\n assert candidate(boxGrid = [['#', '#', '.', '.', '.', '.'], ['.', '#', '#', '.', '.', '.'], ['.', '.', '#', '#', '.', '.'], ['.', '.', '.', '#', '#', '.'], ['.', '.', '.', '.', '#', '#'], ['.', '.', '.', '.', '.', '#']]) == [['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '#', '#', '#', '#', '#'], ['#', '#', '#', '#', '#', '#']]\n assert candidate(boxGrid = [['*', '.', '.', '.', '.', '.', '#', '.', '*'], ['.', '.', '#', '.', '.', '.', '.', '#', '.'], ['.', '#', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#', '.', '.', '#', '.'], ['.', '.', '#', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '#', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.', '.', '.', '.', '*'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '#', '#', '#', '#'], ['.', '.', '.', '#', '#', '#', '#', '#', '*']]\n assert candidate(boxGrid = [['#', '.', '.', '.', '*'], ['.', '#', '.', '.', '.'], ['.', '.', '#', '.', '.'], ['.', '.', '.', '#', '.'], ['.', '.', '.', '.', '#']]) == [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#'], ['#', '#', '#', '#', '*']]\n assert candidate(boxGrid = [['#', '#', '.', '.', '*', '.'], ['#', '.', '.', '#', '.', '.'], ['*', '#', '.', '.', '.', '#'], ['.', '.', '.', '#', '*', '.'], ['#', '.', '.', '.', '.', '.']]) == [['.', '.', '*', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#'], ['.', '#', '.', '.', '#'], ['.', '*', '#', '#', '*'], ['#', '.', '#', '#', '.']]\n assert candidate(boxGrid = [['#', '.', '.', '.', '.', '.', '*'], ['#', '#', '.', '.', '.', '*', '.'], ['*', '.', '.', '#', '.', '.', '.'], ['.', '#', '#', '.', '.', '.', '#'], ['#', '.', '.', '.', '#', '.', '.'], ['.', '.', '#', '.', '.', '#', '.']]) == [['.', '.', '.', '*', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#', '.'], ['.', '.', '#', '.', '#', '.'], ['#', '#', '#', '.', '*', '#'], ['#', '#', '#', '#', '.', '*']]\n assert candidate(boxGrid = [['#', '#', '.', '.', '*', '.'], ['.', '#', '#', '*', '.', '#'], ['.', '.', '#', '#', '#', '.'], ['*', '.', '.', '#', '.', '.'], ['.', '#', '.', '.', '#', '*']]) == [['.', '*', '.', '.', '.'], ['.', '.', '.', '#', '.'], ['.', '.', '.', '#', '#'], ['#', '.', '#', '*', '#'], ['#', '.', '#', '.', '*'], ['*', '#', '#', '#', '.']]\n assert candidate(boxGrid = [['#', '#', '.', '.', '*', '.'], ['#', '.', '#', '.', '.', '*'], ['.', '#', '.', '#', '.', '.'], ['.', '.', '.', '.', '#', '.'], ['.', '*', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.'], ['*', '.', '.', '.', '.'], ['.', '.', '.', '.', '#'], ['.', '.', '.', '#', '#'], ['.', '.', '#', '#', '*'], ['.', '#', '#', '*', '.']]\n assert candidate(boxGrid = [['#', '.', '.', '#', '.', '.', '*', '.', '.', '#'], ['.', '#', '#', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#'], ['.', '.', '.', '.', '#'], ['.', '.', '.', '.', '*'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '#', '.'], ['.', '#', '.', '#', '#']]\n assert candidate(boxGrid = [['#', '.', '.', '.', '.', '.', '*', '.'], ['.', '.', '.', '.', '#', '.', '.', '.'], ['.', '.', '#', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '*', '.', '.', '.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.'], ['*', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '#'], ['.', '.', '.', '.', '*'], ['.', '.', '#', '#', '.']]\n assert candidate(boxGrid = [['#', '.', '#']]) == [['.'], ['#'], ['#']]\n assert candidate(boxGrid = [['.', '.', '.', '.'], ['*', '*', '*', '*']]) == [['*', '.'], ['*', '.'], ['*', '.'], ['*', '.']]\n assert candidate(boxGrid = [['#', '.', '#']]) == [['.'], ['#'], ['#']]\n assert candidate(boxGrid = [['*'], ['.'], ['#']]) == [['#', '.', '*']]\n assert candidate(boxGrid = [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['*', '*', '*', '*']]) == [['*', '.', '.'], ['*', '.', '.'], ['*', '.', '.'], ['*', '.', '.']]\n assert candidate(boxGrid = [['#', '.', '.', '#'], ['.', '#', '.', '.'], ['.', '.', '#', '.'], ['#', '.', '.', '*']]) == [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['#', '.', '.', '#'], ['*', '#', '#', '#']]\n assert candidate(boxGrid = [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.']]) == [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.']]\n assert candidate(boxGrid = [['#', '.', '.', '*'], ['.', '#', '.', '*'], ['#', '.', '#', '.']]) == [['.', '.', '.'], ['.', '.', '.'], ['#', '#', '#'], ['#', '*', '*']]\n assert candidate(boxGrid = [['#', '#', '#'], ['*', '*', '*'], ['#', '#', '#']]) == [['#', '*', '#'], ['#', '*', '#'], ['#', '*', '#']]\n assert candidate(boxGrid = [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['#', '#', '*', '.'], ['#', '#', '#', '*']]) == [['#', '#', '.', '.'], ['#', '#', '.', '.'], ['#', '*', '.', '.'], ['*', '.', '.', '.']]\n assert candidate(boxGrid = [['#', '#', '#'], ['.', '.', '.'], ['*', '*', '*']]) == [['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#']]\n assert candidate(boxGrid = [['.', '#', '#', '*']]) == [['.'], ['#'], ['#'], ['*']]\n assert candidate(boxGrid = [['#', '.', '#']]) == [['.'], ['#'], ['#']]\n assert candidate(boxGrid = [['*', '*', '*', '*']]) == [['*'], ['*'], ['*'], ['*']]\n assert candidate(boxGrid = [['#', '#', '#', '#', '#', '*', '.'], ['.', '.', '.', '.', '.', '.', '.'], ['*', '*', '*', '*', '*', '*', '*']]) == [['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#'], ['*', '.', '*'], ['*', '.', '.']]\n assert candidate(boxGrid = [['.', '#', '*', '#', '.', '*'], ['#', '.', '#', '.', '.', '#'], ['*', '.', '.', '#', '*', '.'], ['.', '#', '#', '*', '#', '.']]) == [['.', '*', '.', '.'], ['#', '.', '.', '#'], ['#', '.', '.', '*'], ['*', '#', '#', '.'], ['.', '*', '#', '#'], ['#', '.', '#', '*']]\n assert candidate(boxGrid = [['#', '.', '.', '*'], ['.', '#', '.', '.'], ['.', '.', '#', '*']]) == [['.', '.', '.'], ['.', '.', '.'], ['#', '.', '#'], ['*', '#', '*']]\n assert candidate(boxGrid = [['#', '#', '*', '.', '*', '.'], ['#', '#', '#', '*', '.', '.'], ['#', '#', '#', '.', '#', '.']]) == [['.', '#', '#'], ['.', '#', '#'], ['#', '#', '*'], ['#', '*', '.'], ['#', '.', '*'], ['#', '.', '.']]\n assert candidate(boxGrid = [['#', '#'], ['*', '.'], ['#', '.']]) == [['.', '*', '#'], ['#', '.', '#']]\n assert candidate(boxGrid = [['#', '*'], ['#', '*']]) == [['#', '#'], ['*', '*']]\n assert candidate(boxGrid = [['#', '.', '.', '*'], ['.', '#', '.', '.'], ['.', '.', '#', '.'], ['.', '.', '.', '*']]) == [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '#'], ['*', '#', '#', '*']]\n assert candidate(boxGrid = [['#', '#', '#'], ['.', '.', '.'], ['*', '*', '*']]) == [['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#']]\n assert candidate(boxGrid = [['#', '.', '*', '#', '.', '*'], ['#', '#', '.', '.', '#', '.'], ['.', '#', '#', '*', '.', '.'], ['*', '.', '.', '.', '.', '*']]) == [['*', '.', '.', '.'], ['.', '#', '.', '#'], ['.', '#', '.', '*'], ['.', '*', '#', '.'], ['.', '.', '#', '#'], ['*', '.', '#', '*']]\n assert candidate(boxGrid = [['#', '.', '*'], ['.', '#', '.'], ['*', '.', '#']]) == [['*', '.', '.'], ['.', '.', '#'], ['#', '#', '*']]\n assert candidate(boxGrid = [['#', '.', '.', '*'], ['.', '#', '.', '#'], ['.', '.', '#', '.']]) == [['.', '.', '.'], ['.', '.', '.'], ['.', '#', '#'], ['#', '#', '*']]\n assert candidate(boxGrid = [['.', '#', '.'], ['*', '.', '#'], ['#', '#', '*']]) == [['#', '*', '.'], ['#', '.', '.'], ['*', '#', '#']]\n assert candidate(boxGrid = [['.', '#', '.', '*', '.', '#'], ['.', '.', '.', '.', '.', '.'], ['*', '.', '#', '.', '.', '*']]) == [['*', '.', '.'], ['.', '.', '.'], ['.', '.', '#'], ['.', '.', '*'], ['#', '.', '.'], ['*', '.', '#']]\n assert candidate(boxGrid = [['#', '#', '#', '#', '#'], ['.', '.', '.', '.', '.'], ['*', '*', '*', '*', '*']]) == [['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#'], ['*', '.', '#']]\n assert candidate(boxGrid = [['.', '#', '*'], ['.', '.', '#'], ['#', '.', '.']]) == [['.', '.', '.'], ['.', '.', '#'], ['#', '#', '*']]\n assert candidate(boxGrid = [['#', '#', '.', '*'], ['.', '.', '.', '.'], ['.', '*', '.', '#'], ['#', '.', '#', '*']]) == [['.', '.', '.', '.'], ['#', '*', '.', '#'], ['#', '.', '.', '#'], ['*', '#', '.', '*']]\n assert candidate(boxGrid = [['*', '.', '.', '.'], ['#', '#', '#', '.'], ['*', '*', '#', '.']]) == [['*', '.', '*'], ['*', '#', '.'], ['.', '#', '.'], ['#', '#', '.']]\n assert candidate(boxGrid = [['#', '#', '#'], ['#', '#', '#'], ['#', '#', '#']]) == [['#', '#', '#'], ['#', '#', '#'], ['#', '#', '#']]\n assert candidate(boxGrid = [['#', '#', '#'], ['*', '*', '*'], ['.', '.', '.']]) == [['.', '*', '#'], ['.', '*', '#'], ['.', '*', '#']]\n assert candidate(boxGrid = [['*', '.', '.', '#'], ['*', '.', '.', '.'], ['#', '.', '.', '*']]) == [['.', '*', '*'], ['.', '.', '.'], ['#', '.', '.'], ['*', '.', '#']]\n assert candidate(boxGrid = [['*', '*', '*', '*'], ['#', '#', '#', '#'], ['*', '*', '*', '*'], ['#', '#', '#', '#']]) == [['#', '*', '#', '*'], ['#', '*', '#', '*'], ['#', '*', '#', '*'], ['#', '*', '#', '*']]\n assert candidate(boxGrid = [['#', '*'], ['#', '.'], ['#', '.'], ['#', '.']]) == [['.', '.', '.', '#'], ['#', '#', '#', '*']]\n assert candidate(boxGrid = [['#'], ['*'], ['.']]) == [['.', '*', '#']]\n assert candidate(boxGrid = [['.', '#', '*', '.', '#'], ['.', '.', '#', '.', '.'], ['#', '.', '.', '*', '.']]) == [['.', '.', '.'], ['.', '.', '#'], ['#', '.', '*'], ['*', '.', '.'], ['.', '#', '#']]\n assert candidate(boxGrid = [['#', '*', '.'], ['.', '#', '.'], ['.', '.', '#']]) == [['.', '.', '#'], ['.', '.', '*'], ['#', '#', '.']]\n assert candidate(boxGrid = [['.', '.', '.', '.'], ['#', '#', '#', '#'], ['.', '*', '.', '*'], ['#', '.', '#', '.']]) == [['.', '.', '#', '.'], ['.', '*', '#', '.'], ['#', '.', '#', '.'], ['#', '*', '#', '.']]\n assert candidate(boxGrid = [['*', '*', '.', '*'], ['*', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '#']]) == [['.', '.', '*', '*'], ['.', '.', '.', '*'], ['.', '.', '.', '.'], ['#', '.', '.', '*']]\n assert candidate(boxGrid = [['.', '.', '.', '.'], ['#', '#', '#', '#'], ['*', '.', '*', '.']]) == [['*', '#', '.'], ['.', '#', '.'], ['*', '#', '.'], ['.', '#', '.']]\n assert candidate(boxGrid = [['.', '#'], ['.', '*'], ['#', '.'], ['*', '.']]) == [['*', '.', '.', '.'], ['.', '#', '*', '#']]\n assert candidate(boxGrid = [['.', '.', '*', '.', '#'], ['#', '.', '#', '.', '.'], ['.', '#', '.', '*', '.']]) == [['.', '.', '.'], ['.', '.', '.'], ['#', '.', '*'], ['*', '#', '.'], ['.', '#', '#']]\n assert candidate(boxGrid = [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['#', '#', '#', '#'], ['*', '.', '.', '*']]) == [['*', '#', '.', '.'], ['.', '#', '.', '.'], ['.', '#', '.', '.'], ['*', '#', '.', '.']]\n assert candidate(boxGrid = [['#', '.', '*', '.'], ['#', '#', '*', '.']]) == [['#', '.'], ['#', '#'], ['*', '*'], ['.', '.']]\n assert candidate(boxGrid = [['#', '*', '#'], ['*', '#', '*'], ['#', '*', '#']]) == [['#', '*', '#'], ['*', '#', '*'], ['#', '*', '#']]\n assert candidate(boxGrid = [['.', '#', '*', '#', '.', '.', '#'], ['#', '.', '.', '.', '#', '.', '.'], ['.', '*', '.', '.', '.', '#', '#'], ['.', '.', '#', '.', '.', '.', '*']]) == [['.', '.', '.', '.'], ['.', '*', '.', '#'], ['.', '.', '.', '*'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['#', '#', '#', '#'], ['*', '#', '#', '#']]\n assert candidate(boxGrid = [['#', '.', '*', '.'], ['#', '#', '*', '.']]) == [['#', '.'], ['#', '#'], ['*', '*'], ['.', '.']]\n assert candidate(boxGrid = [['#'], ['.'], ['*']]) == [['*', '.', '#']]\n assert candidate(boxGrid = [['*', '.', '#'], ['.', '#', '.'], ['#', '.', '*']]) == [['.', '.', '*'], ['#', '.', '.'], ['*', '#', '#']]\n assert candidate(boxGrid = [['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.']]) == [['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.']]\n assert candidate(boxGrid = [['#', '.', '.', '.', '#'], ['.', '.', '#', '.', '.'], ['#', '#', '#', '*', '.']]) == [['#', '.', '.'], ['#', '.', '.'], ['#', '.', '.'], ['*', '.', '#'], ['.', '#', '#']]\n assert candidate(boxGrid = [['#', '.', '.', '.', '*'], ['#', '.', '.', '.', '.'], ['#', '.', '#', '.', '.'], ['#', '#', '.', '.', '.'], ['#', '.', '.', '#', '.'], ['#', '#', '#', '.', '.']]) == [['.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.'], ['#', '.', '.', '.', '.', '.'], ['#', '#', '#', '#', '.', '#'], ['#', '#', '#', '#', '#', '*']]\n assert candidate(boxGrid = [['#', '.', '#'], ['.', '*', '.'], ['#', '#', '#']]) == [['#', '.', '.'], ['#', '*', '#'], ['#', '.', '#']]\n assert candidate(boxGrid = [['#', '#', '*', '.', '*', '.'], ['#', '#', '#', '*', '.', '.'], ['#', '#', '#', '.', '#', '.']]) == [['.', '#', '#'], ['.', '#', '#'], ['#', '#', '*'], ['#', '*', '.'], ['#', '.', '*'], ['#', '.', '.']]\n assert candidate(boxGrid = [['#', '#', '*', '.', '*', '.'], ['#', '#', '#', '*', '.', '.'], ['#', '#', '#', '.', '#', '.']]) == [['.', '#', '#'], ['.', '#', '#'], ['#', '#', '*'], ['#', '*', '.'], ['#', '.', '*'], ['#', '.', '.']]\n assert candidate(boxGrid = [['*', '*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*', '*'], ['*', '*', '*', '*', '*', '*']]) == [['*', '*', '*'], ['*', '*', '*'], ['*', '*', '*'], ['*', '*', '*'], ['*', '*', '*'], ['*', '*', '*']]\n assert candidate(boxGrid = [['.', '.', '#'], ['.', '.', '.'], ['#', '.', '.']]) == [['.', '.', '.'], ['.', '.', '.'], ['#', '.', '#']]\n assert candidate(boxGrid = [['.', '.', '.', '*'], ['#', '.', '#', '.'], ['.', '#', '.', '.'], ['#', '.', '.', '.']]) == [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '#', '.'], ['#', '#', '#', '*']]\n assert candidate(boxGrid = [['.', '.', '.', '.', '.'], ['#', '#', '#', '#', '#'], ['*', '*', '*', '*', '*']]) == [['*', '#', '.'], ['*', '#', '.'], ['*', '#', '.'], ['*', '#', '.'], ['*', '#', '.']]\n assert candidate(boxGrid = [['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.']]) == [['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.']]\n assert candidate(boxGrid = [['#', '#', '#', '*'], ['.', '.', '.', '.'], ['*', '.', '.', '*']]) == [['*', '.', '#'], ['.', '.', '#'], ['.', '.', '#'], ['*', '.', '*']]\n assert candidate(boxGrid = [['*', '*', '*', '*'], ['#', '#', '#', '#'], ['#', '#', '#', '#'], ['*', '*', '*', '*']]) == [['*', '#', '#', '*'], ['*', '#', '#', '*'], ['*', '#', '#', '*'], ['*', '#', '#', '*']]\n assert candidate(boxGrid = [['.', '.', '#', '*', '.'], ['#', '#', '.', '.', '#'], ['.', '*', '#', '.', '.']]) == [['.', '.', '.'], ['*', '.', '.'], ['.', '#', '#'], ['.', '#', '*'], ['#', '#', '.']]\n assert candidate(boxGrid = [['#', '.', '*', '.'], ['#', '#', '*', '.']]) == [['#', '.'], ['#', '#'], ['*', '*'], ['.', '.']]\n assert candidate(boxGrid = [['*', '*', '*', '*'], ['.', '.', '.', '.'], ['#', '#', '#', '#']]) == [['#', '.', '*'], ['#', '.', '*'], ['#', '.', '*'], ['#', '.', '*']]\n assert candidate(boxGrid = [['#', '.', '.', '#'], ['.', '#', '#', '.'], ['.', '*', '.', '*']]) == [['.', '.', '.'], ['*', '.', '.'], ['.', '#', '#'], ['*', '#', '#']]\n assert candidate(boxGrid = [['#', '*', '*', '#'], ['#', '#', '#', '.'], ['*', '.', '.', '*']]) == [['*', '.', '#'], ['.', '#', '*'], ['.', '#', '*'], ['*', '#', '#']]\n assert candidate(boxGrid = [['*', '*', '*'], ['*', '*', '*'], ['*', '*', '*']]) == [['*', '*', '*'], ['*', '*', '*'], ['*', '*', '*']]\n assert candidate(boxGrid = [['#', '*', '.'], ['.', '.', '*'], ['*', '.', '.']]) == [['*', '.', '#'], ['.', '.', '*'], ['.', '*', '.']]\n assert candidate(boxGrid = [['*', '.', '.', '#'], ['#', '#', '#', '*'], ['#', '#', '.', '#']]) == [['.', '#', '*'], ['#', '#', '.'], ['#', '#', '.'], ['#', '*', '#']]\n assert candidate(boxGrid = [['.', '.', '.', '*'], ['.', '#', '.', '.'], ['.', '#', '#', '.'], ['*', '#', '.', '*']]) == [['*', '.', '.', '.'], ['.', '.', '.', '.'], ['#', '#', '.', '.'], ['*', '#', '#', '*']]\n"}, "metadata": {"canonical_parameter_names": ["boxGrid"], "leetcode_dataset_entry_point": "Solution().rotateTheBox", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector> rotateTheBox(vector>& boxGrid) {", "container": "Solution", "callable": "rotateTheBox", "parameters": [{"name": "boxGrid", "type": "vector>&"}], "return_type": "vector>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1862, "task_id": "sum-of-floored-pairs", "difficulty": "Hard", "problem_description": "Given an integer array nums, return the sum of floor(nums[i] / nums[j]) for all pairs of indices 0 <= i, j < nums.length in the array. Since the answer may be too large, return it modulo 109 + 7.\nThe floor() function returns the integer part of the division.\n \nExample 1:\n\nInput: nums = [2,5,9]\nOutput: 10\nExplanation:\nfloor(2 / 5) = floor(2 / 9) = floor(5 / 9) = 0\nfloor(2 / 2) = floor(5 / 5) = floor(9 / 9) = 1\nfloor(5 / 2) = 2\nfloor(9 / 2) = 4\nfloor(9 / 5) = 1\nWe calculate the floor of the division for every pair of indices in the array then sum them up.\n\nExample 2:\n\nInput: nums = [7,7,7,7,7,7,7]\nOutput: 49\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == 49\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 100\n assert candidate(nums = [2, 5, 9]) == 10\n assert candidate(nums = [100000, 1, 100000]) == 200005\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250]) == 57\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 400\n assert candidate(nums = [10, 20, 30, 40, 50]) == 27\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 178\n assert candidate(nums = [1, 2, 3, 4, 5]) == 27\n assert candidate(nums = [100000, 100000, 100000]) == 9\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 65519\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980]) == 210\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 600\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 127\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3249\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 4194281\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 1492\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 127\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 2400\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000]) == 127\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == 6268\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 834\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 2097130\n assert candidate(nums = [15, 15, 15, 30, 30, 45, 45, 60, 60, 75, 75, 90, 90, 105, 105]) == 287\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == 55\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 100\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930]) == 15615\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == 371\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 508\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000]) == 600\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == 314\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000, 21000, 22000, 23000, 24000, 25000]) == 991\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 508\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 1650\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 623578\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000]) == 123456\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == 127\n assert candidate(nums = [100000, 100000, 50000, 50000, 25000, 25000, 12500, 12500, 6250, 6250]) == 228\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 127\n assert candidate(nums = [50000, 40000, 30000, 20000, 10000, 5000, 2500, 1250, 625, 312, 156, 78, 39, 19, 9, 4, 2, 1]) == 314353\n assert candidate(nums = [5, 5, 10, 10, 15, 15, 20, 20, 25, 25, 30, 30, 35, 35, 40, 40, 45, 45, 50, 50]) == 508\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == 513\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 400\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 2036\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 127\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210]) == 2806\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 600\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 100000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 313945\n assert candidate(nums = [150000, 140000, 130000, 120000, 110000, 100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 314\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 949\n assert candidate(nums = [50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3, 1]) == 166591\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 6400\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225]) == 314\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 2841\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 65519\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 1024\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 600\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 314\n assert candidate(nums = [3, 3, 3, 5, 5, 5, 7, 7, 7, 11, 11, 11, 13, 13, 13, 17, 17, 17, 19, 19]) == 412\n assert candidate(nums = [99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111, 1]) == 500096\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sumOfFlooredPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int sumOfFlooredPairs(vector& nums) {", "container": "Solution", "callable": "sumOfFlooredPairs", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1863, "task_id": "sum-of-all-subset-xor-totals", "difficulty": "Easy", "problem_description": "The XOR total of an array is defined as the bitwise XOR of all its elements, or 0 if the array is empty.\n\nFor example, the XOR total of the array [2,5,6] is 2 XOR 5 XOR 6 = 1.\n\nGiven an array nums, return the sum of all XOR totals for every subset of nums. \nNote: Subsets with the same elements should be counted multiple times.\nAn array a is a subset of an array b if a can be obtained from b by deleting some (possibly zero) elements of b.\n \nExample 1:\n\nInput: nums = [1,3]\nOutput: 6\nExplanation: The 4 subsets of [1,3] are:\n- The empty subset has an XOR total of 0.\n- [1] has an XOR total of 1.\n- [3] has an XOR total of 3.\n- [1,3] has an XOR total of 1 XOR 3 = 2.\n0 + 1 + 3 + 2 = 6\n\nExample 2:\n\nInput: nums = [5,1,6]\nOutput: 28\nExplanation: The 8 subsets of [5,1,6] are:\n- The empty subset has an XOR total of 0.\n- [5] has an XOR total of 5.\n- [1] has an XOR total of 1.\n- [6] has an XOR total of 6.\n- [5,1] has an XOR total of 5 XOR 1 = 4.\n- [5,6] has an XOR total of 5 XOR 6 = 3.\n- [1,6] has an XOR total of 1 XOR 6 = 7.\n- [5,1,6] has an XOR total of 5 XOR 1 XOR 6 = 2.\n0 + 5 + 1 + 6 + 4 + 3 + 7 + 2 = 28\n\nExample 3:\n\nInput: nums = [3,4,5,6,7,8]\nOutput: 480\nExplanation: The sum of all XOR totals for every subset is 480.\n\n \nConstraints:\n\n1 <= nums.length <= 12\n1 <= nums[i] <= 20\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 1, 6]) == 28\n assert candidate(nums = [10, 20, 30]) == 120\n assert candidate(nums = [1, 1, 1, 1]) == 8\n assert candidate(nums = [1, 2, 4, 8, 16]) == 496\n assert candidate(nums = [10, 11, 12]) == 60\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14]) == 896\n assert candidate(nums = [2, 3, 5]) == 28\n assert candidate(nums = [11, 2, 3, 14, 7]) == 240\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [7, 8, 9, 10, 11]) == 240\n assert candidate(nums = [1, 2, 3, 4]) == 56\n assert candidate(nums = [3, 4, 5, 6, 7, 8]) == 480\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 30720\n assert candidate(nums = [12, 34, 56]) == 248\n assert candidate(nums = [10, 15, 20, 25]) == 248\n assert candidate(nums = [2, 3, 5, 7]) == 56\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9]) == 63488\n assert candidate(nums = [1, 3]) == 6\n assert candidate(nums = [2, 2, 2, 2]) == 16\n assert candidate(nums = [1, 2, 4, 8, 16, 32]) == 2016\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 15360\n assert candidate(nums = [15, 16, 17, 18, 19, 20]) == 992\n assert candidate(nums = [1, 2, 3]) == 12\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2048\n assert candidate(nums = [6, 3, 5, 2, 1, 9]) == 480\n assert candidate(nums = [31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2, 1]) == 63488\n assert candidate(nums = [1, 2, 4, 8, 16, 32]) == 2016\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144]) == 516096\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 67092480\n assert candidate(nums = [10, 20, 30, 40, 50, 60]) == 1984\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 16252928\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095]) == 8386560\n assert candidate(nums = [15, 20, 25, 30]) == 248\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 129024\n assert candidate(nums = [128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144]) == 1073479680\n assert candidate(nums = [3, 3, 3, 5, 5, 5, 7, 7, 7, 11, 11, 11]) == 30720\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == 130560\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64]) == 8128\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75]) == 8128\n assert candidate(nums = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8]) == 63488\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84]) == 260096\n assert candidate(nums = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70]) == 260096\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 245760\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 16773120\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125]) == 260096\n assert candidate(nums = [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 1015808\n assert candidate(nums = [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9]) == 63488\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120, 132, 144]) == 516096\n assert candidate(nums = [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) == 63488\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == 4186112\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096]) == 16773120\n assert candidate(nums = [13, 17, 19, 23, 29, 31, 37, 41]) == 8064\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]) == 129024\n assert candidate(nums = [13, 23, 33, 43, 53, 63, 73, 83, 93, 103, 113, 123]) == 260096\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 63488\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 30720\n assert candidate(nums = [14, 28, 42, 56, 70, 84, 98, 112, 126, 140, 154, 168]) == 520192\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == 14336\n assert candidate(nums = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8]) == 63488\n assert candidate(nums = [14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91]) == 260096\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200]) == 4186112\n assert candidate(nums = [2, 3, 4, 5, 6]) == 112\n assert candidate(nums = [12, 14, 18, 22, 26, 30]) == 960\n assert candidate(nums = [10, 15, 20, 25]) == 248\n assert candidate(nums = [17, 19, 21, 23, 25, 27, 29, 31]) == 3968\n assert candidate(nums = [3, 5, 7, 9, 11, 13]) == 480\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 8386560\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == 16128\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 8386560\n assert candidate(nums = [15, 25, 35, 45, 55]) == 1008\n assert candidate(nums = [10, 20, 30, 40, 50]) == 992\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 15360\n assert candidate(nums = [13, 17, 19, 23, 29, 31, 37, 41]) == 8064\n assert candidate(nums = [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42]) == 129024\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]) == 129024\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 258048\n assert candidate(nums = [3, 11, 19, 27, 35, 43, 51, 59, 67, 75, 83, 91]) == 251904\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104]) == 16256\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14]) == 896\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 258048\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9]) == 63488\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 14336\n assert candidate(nums = [31, 33, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73]) == 260096\n assert candidate(nums = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]) == 129024\n assert candidate(nums = [17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61]) == 129024\n assert candidate(nums = [8, 16, 32, 64, 128, 256, 512]) == 65024\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132]) == 522240\n assert candidate(nums = [19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67]) == 260096\n assert candidate(nums = [15, 20, 25, 30, 35, 40, 45]) == 4032\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 15360\n assert candidate(nums = [19, 17, 15, 13, 11, 9, 7]) == 1984\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96]) == 245760\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36]) == 129024\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4]) == 30720\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 63488\n assert candidate(nums = [12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 30720\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1]) == 30720\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63]) == 16128\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19]) == 3968\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().subsetXORSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int subsetXORSum(vector& nums) {", "container": "Solution", "callable": "subsetXORSum", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1864, "task_id": "minimum-number-of-swaps-to-make-the-binary-string-alternating", "difficulty": "Medium", "problem_description": "Given a binary string s, return the minimum number of character swaps to make it alternating, or -1 if it is impossible.\nThe string is called alternating if no two adjacent characters are equal. For example, the strings \"010\" and \"1010\" are alternating, while the string \"0100\" is not.\nAny two characters may be swapped, even if they are not adjacent.\n \nExample 1:\n\nInput: s = \"111000\"\nOutput: 1\nExplanation: Swap positions 1 and 4: \"111000\" -> \"101010\"\nThe string is now alternating.\n\nExample 2:\n\nInput: s = \"010\"\nOutput: 0\nExplanation: The string is already alternating, no swaps are needed.\n\nExample 3:\n\nInput: s = \"1110\"\nOutput: -1\n\n \nConstraints:\n\n1 <= s.length <= 1000\ns[i] is either '0' or '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1111\") == -1\n assert candidate(s = \"1100110\") == 2\n assert candidate(s = \"110011\") == -1\n assert candidate(s = \"00110011\") == 2\n assert candidate(s = \"0101010\") == 0\n assert candidate(s = \"111\") == -1\n assert candidate(s = \"11110000\") == 2\n assert candidate(s = \"1110\") == -1\n assert candidate(s = \"0000\") == -1\n assert candidate(s = \"01010\") == 0\n assert candidate(s = \"111000\") == 1\n assert candidate(s = \"10101\") == 0\n assert candidate(s = \"1100\") == 1\n assert candidate(s = \"010\") == 0\n assert candidate(s = \"1010101\") == 0\n assert candidate(s = \"1010\") == 0\n assert candidate(s = \"0101\") == 0\n assert candidate(s = \"000111\") == 1\n assert candidate(s = \"000\") == -1\n assert candidate(s = \"01010101\") == 0\n assert candidate(s = \"10101010\") == 0\n assert candidate(s = \"110\") == 1\n assert candidate(s = \"1010101010\") == 0\n assert candidate(s = \"010101\") == 0\n assert candidate(s = \"101010\") == 0\n assert candidate(s = \"1101001\") == 2\n assert candidate(s = \"11001100\") == 2\n assert candidate(s = \"0011\") == 1\n assert candidate(s = \"0101010101\") == 0\n assert candidate(s = \"0011001\") == 2\n assert candidate(s = \"1001\") == 1\n assert candidate(s = \"101010101010101010\") == 0\n assert candidate(s = \"1110010011100100111001\") == -1\n assert candidate(s = \"010101101010101010101010101\") == 3\n assert candidate(s = \"110010110010\") == 2\n assert candidate(s = \"000110110001101100011011\") == 6\n assert candidate(s = \"00111111001111110011111100111111001111110011111100\") == -1\n assert candidate(s = \"101010101110\") == -1\n assert candidate(s = \"000000111111000000111111\") == 6\n assert candidate(s = \"0000000111111\") == 3\n assert candidate(s = \"000000000000000000111111111111111\") == -1\n assert candidate(s = \"11110000111100001111000011110000111100001111000011\") == -1\n assert candidate(s = \"010101010101010101010101010101010101010101010101011\") == 25\n assert candidate(s = \"101010101010101001010101010\") == 8\n assert candidate(s = \"1010101010101010101\") == 0\n assert candidate(s = \"010101010101010110101010101\") == 8\n assert candidate(s = \"0000000000000001111111111111\") == -1\n assert candidate(s = \"11010101010101010101010101010101\") == -1\n assert candidate(s = \"010101010101010101010101\") == 0\n assert candidate(s = \"10101010101010101010101010\") == 0\n assert candidate(s = \"000000000000111111111111\") == 6\n assert candidate(s = \"0000111110101010\") == 2\n assert candidate(s = \"1001100110011\") == 3\n assert candidate(s = \"0000000000111111111000\") == -1\n assert candidate(s = \"101010101001010101010101010\") == 5\n assert candidate(s = \"00001111000011110000\") == -1\n assert candidate(s = \"111000111000111\") == -1\n assert candidate(s = \"1011010010110100\") == 4\n assert candidate(s = \"000111000111000111\") == 3\n assert candidate(s = \"101010101010101010101010\") == 0\n assert candidate(s = \"1010010101001010100101010\") == -1\n assert candidate(s = \"111010101010\") == -1\n assert candidate(s = \"101010101010101010101\") == 0\n assert candidate(s = \"111111000000111111000000111111000000111111\") == -1\n assert candidate(s = \"010101010101010101\") == 0\n assert candidate(s = \"101010101010101010101010101\") == 0\n assert candidate(s = \"1010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"1100110011\") == -1\n assert candidate(s = \"111000111000111000111000111000\") == 5\n assert candidate(s = \"11000011000011000011\") == -1\n assert candidate(s = \"0101010101001011\") == 2\n assert candidate(s = \"111001100110011001100110011\") == -1\n assert candidate(s = \"1111111111111111111000000000000000\") == -1\n assert candidate(s = \"1010101010101010\") == 0\n assert candidate(s = \"111100001111000011110000111100001111\") == -1\n assert candidate(s = \"0000000111111100000000111111110000000011111111\") == 11\n assert candidate(s = \"111111000000111111000000\") == 6\n assert candidate(s = \"011111000000\") == -1\n assert candidate(s = \"111100001111000011110000\") == 6\n assert candidate(s = \"10101110101000\") == 1\n assert candidate(s = \"110011001100\") == 3\n assert candidate(s = \"11100101101000\") == 3\n assert candidate(s = \"0011001100110011\") == 4\n assert candidate(s = \"001100110011001100\") == -1\n assert candidate(s = \"000000111111\") == 3\n assert candidate(s = \"11111000001111100000\") == 4\n assert candidate(s = \"110010101001\") == 2\n assert candidate(s = \"111100000011\") == 3\n assert candidate(s = \"01010101011\") == 5\n assert candidate(s = \"0101010101010101010101010101010101\") == 0\n assert candidate(s = \"0000111100001111000011110000\") == -1\n assert candidate(s = \"1110001000\") == -1\n assert candidate(s = \"010101010101010101010101010\") == 0\n assert candidate(s = \"10100101010\") == 2\n assert candidate(s = \"000000000000000011111111111111\") == -1\n assert candidate(s = \"01010101010101010101010\") == 0\n assert candidate(s = \"11110000111100001111\") == -1\n assert candidate(s = \"01010101010101010101010101\") == 0\n assert candidate(s = \"01101101101101\") == -1\n assert candidate(s = \"111111111111111111000000000000000\") == -1\n assert candidate(s = \"101010101010\") == 0\n assert candidate(s = \"111111000000111111\") == -1\n assert candidate(s = \"111111111111111100000000000000\") == -1\n assert candidate(s = \"1111111111110000000000\") == -1\n assert candidate(s = \"0011001100110\") == 3\n assert candidate(s = \"01101010100\") == 4\n assert candidate(s = \"000111111000\") == 3\n assert candidate(s = \"0101010010101010\") == -1\n assert candidate(s = \"11111111111111111111\") == -1\n assert candidate(s = \"000011110000\") == -1\n assert candidate(s = \"1111111111100000000011\") == -1\n assert candidate(s = \"001001110010011\") == 4\n assert candidate(s = \"00001111111100\") == -1\n assert candidate(s = \"000111000111000\") == -1\n assert candidate(s = \"11111111000000001111111100000000\") == 8\n assert candidate(s = \"001100110011\") == 3\n assert candidate(s = \"1111111000000\") == 3\n assert candidate(s = \"10010010010010\") == -1\n assert candidate(s = \"111111111000000001111111100000000\") == 8\n assert candidate(s = \"00000000001111111111\") == 5\n assert candidate(s = \"101010101010101010101010101010101\") == 0\n assert candidate(s = \"1111111111000000000011111111110000000000\") == 10\n assert candidate(s = \"01010101010101010101010101010101010101010101010100\") == -1\n assert candidate(s = \"11001100110011001100\") == 5\n assert candidate(s = \"11111111110000000000\") == 5\n assert candidate(s = \"1111111000000011111111100000001111111110000000\") == -1\n assert candidate(s = \"01010101010101010101010101010101\") == 0\n assert candidate(s = \"0101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"1010101010101010101010101010\") == 0\n assert candidate(s = \"11110000111100\") == -1\n assert candidate(s = \"00000000000000000000000000000000000000000000000000\") == -1\n assert candidate(s = \"111010101001\") == -1\n assert candidate(s = \"111000111000111000111000111\") == -1\n assert candidate(s = \"1110000011100000\") == -1\n assert candidate(s = \"111111101111111011111110\") == -1\n assert candidate(s = \"0000111111110000\") == 4\n assert candidate(s = \"111000111000\") == 2\n assert candidate(s = \"1111111100000000\") == 4\n assert candidate(s = \"1010101010110100\") == 2\n assert candidate(s = \"101110010110\") == -1\n assert candidate(s = \"0101101010101001\") == 3\n assert candidate(s = \"111100001111\") == -1\n assert candidate(s = \"000011111111\") == -1\n assert candidate(s = \"00000000000000000111111111111111\") == -1\n assert candidate(s = \"110110001101100\") == 4\n assert candidate(s = \"1100110011001100110011001100\") == 7\n assert candidate(s = \"11110000111100001111000011110000\") == 8\n assert candidate(s = \"110110110110110110110110\") == -1\n assert candidate(s = \"00110011001100\") == -1\n assert candidate(s = \"010101010101\") == 0\n assert candidate(s = \"111000100011\") == 2\n assert candidate(s = \"1111111111111111111111111111\") == -1\n assert candidate(s = \"0101010101010101\") == 0\n assert candidate(s = \"00001111\") == 2\n assert candidate(s = \"11111100000000\") == -1\n assert candidate(s = \"10100101001010010100101001010010100101001010\") == -1\n assert candidate(s = \"1111000010101010\") == 2\n assert candidate(s = \"11111111111111100000000000000000\") == -1\n assert candidate(s = \"11100111001110011100\") == -1\n assert candidate(s = \"1010101110001010\") == 1\n assert candidate(s = \"0101010101010101010101010101\") == 0\n assert candidate(s = \"11000000110000001100000011000000110000001100000011\") == -1\n assert candidate(s = \"0000000100000001000000010\") == -1\n assert candidate(s = \"111100001111000011\") == -1\n assert candidate(s = \"00000000000000000000000000000000000000000000000001\") == -1\n assert candidate(s = \"0101010101010101010\") == 0\n assert candidate(s = \"0000000000001111111111111111\") == -1\n assert candidate(s = \"000111000111000111000111000111\") == 5\n assert candidate(s = \"11111110000000\") == 3\n assert candidate(s = \"0000000000000001111111111111111\") == 8\n assert candidate(s = \"010100011101010\") == 1\n assert candidate(s = \"010101010001010101010101010\") == -1\n assert candidate(s = \"11111111111111111111111111111111111111111111111111\") == -1\n assert candidate(s = \"000000111111000000111111000000111111000000\") == -1\n assert candidate(s = \"110101010101010101\") == -1\n assert candidate(s = \"100010001000\") == -1\n assert candidate(s = \"00001111000011110000111100001111\") == 8\n assert candidate(s = \"1111111111111110000000000000\") == -1\n assert candidate(s = \"101010101000\") == -1\n assert candidate(s = \"10101010010\") == 4\n assert candidate(s = \"10010010010\") == -1\n assert candidate(s = \"00110011001100110011\") == 5\n assert candidate(s = \"010110001110\") == 3\n assert candidate(s = \"011011010101010101010101010\") == 12\n assert candidate(s = \"010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"10101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"00000000000000000000\") == -1\n assert candidate(s = \"1010101010101\") == 0\n assert candidate(s = \"1111000011110000\") == 4\n assert candidate(s = \"0000000011111111\") == 4\n assert candidate(s = \"010101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"1111000000001111\") == 4\n assert candidate(s = \"1111100000\") == 2\n assert candidate(s = \"11001100110011001100110011001100110011001100110011\") == -1\n assert candidate(s = \"00100100100100100100100100100100100100100100\") == -1\n assert candidate(s = \"000111000111000111000111000\") == -1\n assert candidate(s = \"01010101010101\") == 0\n assert candidate(s = \"111000010101\") == 2\n assert candidate(s = \"1001001001001\") == -1\n assert candidate(s = \"101011100010101\") == 1\n assert candidate(s = \"0100101101001011\") == 4\n assert candidate(s = \"0110110110110110110110110\") == -1\n assert candidate(s = \"11111111111111111000000000000000\") == -1\n assert candidate(s = \"1010101010101010101010\") == 0\n assert candidate(s = \"1010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"00111100111100111100\") == -1\n assert candidate(s = \"100110011001\") == 3\n assert candidate(s = \"111001001001\") == 3\n assert candidate(s = \"11101110111011101110\") == -1\n assert candidate(s = \"00011100011100011100\") == -1\n assert candidate(s = \"1001100110011001\") == 4\n assert candidate(s = \"01010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"100100100100\") == -1\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"0011001100110011001100110011\") == 7\n assert candidate(s = \"01010101010101010101\") == 0\n assert candidate(s = \"110011001100110011001100110011\") == -1\n assert candidate(s = \"1100110011001\") == 3\n assert candidate(s = \"11001100110011\") == -1\n assert candidate(s = \"101010101010101010101010101010101010101010101010100\") == 25\n assert candidate(s = \"1001001001001001001001001001\") == -1\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"1101011010100010\") == 3\n assert candidate(s = \"0110011001100110011001100110011\") == 8\n assert candidate(s = \"101010010101010101010101010\") == 3\n assert candidate(s = \"1111111111110000000000000000\") == -1\n assert candidate(s = \"101010101010101010101010101010101010\") == 0\n assert candidate(s = \"000100100100\") == -1\n assert candidate(s = \"1111000000\") == -1\n assert candidate(s = \"0101010101010\") == 0\n assert candidate(s = \"111111111110000000000111111111110000000000\") == -1\n assert candidate(s = \"1111111000000011111110000000\") == 6\n assert candidate(s = \"11000011110000111100\") == 5\n assert candidate(s = \"10101010101010101010\") == 0\n assert candidate(s = \"0000000000000000000111111111111111\") == -1\n assert candidate(s = \"100110011001100110011001\") == 6\n assert candidate(s = \"11001100110011001100110011\") == -1\n assert candidate(s = \"000000111111000000111111000000\") == -1\n assert candidate(s = \"011011011011\") == -1\n assert candidate(s = \"0000000000000000000000000000\") == -1\n assert candidate(s = \"11111111111111111111111111111111111111111111111110\") == -1\n assert candidate(s = \"00001111000011110000111100001111000011110000111100\") == -1\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minSwaps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minSwaps(string s) {", "container": "Solution", "callable": "minSwaps", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1866, "task_id": "number-of-ways-to-rearrange-sticks-with-k-sticks-visible", "difficulty": "Hard", "problem_description": "There are n uniquely-sized sticks whose lengths are integers from 1 to n. You want to arrange the sticks such that exactly k sticks are visible from the left. A stick is visible from the left if there are no longer sticks to the left of it.\n\nFor example, if the sticks are arranged [1,3,2,5,4], then the sticks with lengths 1, 3, and 5 are visible from the left.\n\nGiven n and k, return the number of such arrangements. Since the answer may be large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: n = 3, k = 2\nOutput: 3\nExplanation: [1,3,2], [2,3,1], and [2,1,3] are the only arrangements such that exactly 2 sticks are visible.\nThe visible sticks are underlined.\n\nExample 2:\n\nInput: n = 5, k = 5\nOutput: 1\nExplanation: [1,2,3,4,5] is the only arrangement such that all 5 sticks are visible.\nThe visible sticks are underlined.\n\nExample 3:\n\nInput: n = 20, k = 11\nOutput: 647427950\nExplanation: There are 647427950 (mod 109 + 7) ways to rearrange the sticks such that exactly 11 sticks are visible.\n\n \nConstraints:\n\n1 <= n <= 1000\n1 <= k <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,k = 1) == 362880\n assert candidate(n = 1000,k = 500) == 761367694\n assert candidate(n = 7,k = 4) == 735\n assert candidate(n = 1,k = 1) == 1\n assert candidate(n = 3,k = 2) == 3\n assert candidate(n = 100,k = 50) == 768969154\n assert candidate(n = 5,k = 5) == 1\n assert candidate(n = 20,k = 11) == 647427950\n assert candidate(n = 4,k = 3) == 6\n assert candidate(n = 10,k = 3) == 1172700\n assert candidate(n = 400,k = 200) == 321592380\n assert candidate(n = 300,k = 150) == 266738846\n assert candidate(n = 500,k = 20) == 997277428\n assert candidate(n = 200,k = 100) == 515897308\n assert candidate(n = 75,k = 40) == 957213722\n assert candidate(n = 600,k = 400) == 156741878\n assert candidate(n = 90,k = 45) == 884068127\n assert candidate(n = 1000,k = 999) == 499500\n assert candidate(n = 300,k = 200) == 692591146\n assert candidate(n = 70,k = 35) == 834330443\n assert candidate(n = 25,k = 10) == 513911237\n assert candidate(n = 30,k = 15) == 439815546\n assert candidate(n = 900,k = 40) == 539248312\n assert candidate(n = 75,k = 35) == 48172892\n assert candidate(n = 400,k = 10) == 650177568\n assert candidate(n = 800,k = 200) == 252157911\n assert candidate(n = 50,k = 20) == 506372014\n assert candidate(n = 999,k = 999) == 1\n assert candidate(n = 500,k = 2) == 540925953\n assert candidate(n = 700,k = 350) == 411412946\n assert candidate(n = 999,k = 1) == 22779421\n assert candidate(n = 999,k = 499) == 23728871\n assert candidate(n = 900,k = 450) == 911433285\n assert candidate(n = 900,k = 900) == 1\n assert candidate(n = 150,k = 75) == 309130836\n assert candidate(n = 8,k = 4) == 6769\n assert candidate(n = 100,k = 10) == 451985432\n assert candidate(n = 30,k = 10) == 283914142\n assert candidate(n = 750,k = 100) == 677105109\n assert candidate(n = 25,k = 15) == 729045180\n assert candidate(n = 250,k = 249) == 31125\n assert candidate(n = 250,k = 200) == 168555168\n assert candidate(n = 1000,k = 1000) == 1\n assert candidate(n = 1000,k = 1) == 756641425\n assert candidate(n = 15,k = 7) == 409322830\n assert candidate(n = 600,k = 599) == 179700\n assert candidate(n = 800,k = 300) == 156733966\n assert candidate(n = 600,k = 300) == 326283128\n assert candidate(n = 750,k = 375) == 43563744\n assert candidate(n = 700,k = 30) == 785311933\n assert candidate(n = 800,k = 400) == 551599071\n assert candidate(n = 500,k = 50) == 982286335\n assert candidate(n = 999,k = 500) == 975713359\n assert candidate(n = 350,k = 175) == 62253251\n assert candidate(n = 400,k = 250) == 585657508\n assert candidate(n = 500,k = 250) == 112330193\n assert candidate(n = 50,k = 25) == 253549512\n"}, "metadata": {"canonical_parameter_names": ["n", "k"], "leetcode_dataset_entry_point": "Solution().rearrangeSticks", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int rearrangeSticks(int n, int k) {", "container": "Solution", "callable": "rearrangeSticks", "parameters": [{"name": "n", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1869, "task_id": "longer-contiguous-segments-of-ones-than-zeros", "difficulty": "Easy", "problem_description": "Given a binary string s, return true if the longest contiguous segment of 1's is strictly longer than the longest contiguous segment of 0's in s, or return false otherwise.\n\nFor example, in s = \"110100010\" the longest continuous segment of 1s has length 2, and the longest continuous segment of 0s has length 3.\n\nNote that if there are no 0's, then the longest continuous segment of 0's is considered to have a length 0. The same applies if there is no 1's.\n \nExample 1:\n\nInput: s = \"1101\"\nOutput: true\nExplanation:\nThe longest contiguous segment of 1s has length 2: \"1101\"\nThe longest contiguous segment of 0s has length 1: \"1101\"\nThe segment of 1s is longer, so return true.\n\nExample 2:\n\nInput: s = \"111000\"\nOutput: false\nExplanation:\nThe longest contiguous segment of 1s has length 3: \"111000\"\nThe longest contiguous segment of 0s has length 3: \"111000\"\nThe segment of 1s is not longer, so return false.\n\nExample 3:\n\nInput: s = \"110100010\"\nOutput: false\nExplanation:\nThe longest contiguous segment of 1s has length 2: \"110100010\"\nThe longest contiguous segment of 0s has length 3: \"110100010\"\nThe segment of 1s is not longer, so return false.\n\n \nConstraints:\n\n1 <= s.length <= 100\ns[i] is either '0' or '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"1111\") == True\n assert candidate(s = \"111000\") == False\n assert candidate(s = \"101010\") == False\n assert candidate(s = \"11100111\") == True\n assert candidate(s = \"11001100\") == False\n assert candidate(s = \"111001001\") == True\n assert candidate(s = \"1101\") == True\n assert candidate(s = \"0\") == False\n assert candidate(s = \"110100010\") == False\n assert candidate(s = \"01010101\") == False\n assert candidate(s = \"10101010\") == False\n assert candidate(s = \"1110011100010001111100000\") == False\n assert candidate(s = \"000111000\") == False\n assert candidate(s = \"001100110011\") == False\n assert candidate(s = \"0000\") == False\n assert candidate(s = \"1\") == True\n assert candidate(s = \"101010101010101010\") == False\n assert candidate(s = \"1110111011101110111\") == True\n assert candidate(s = \"000111000111000111000\") == False\n assert candidate(s = \"111111111111111111111111\") == True\n assert candidate(s = \"101010101010101010101010101010101010101010101010101010101010101\") == False\n assert candidate(s = \"111000111000111000\") == False\n assert candidate(s = \"001111001100110011110000111100001111100000\") == False\n assert candidate(s = \"11111111111111111111111111111111111111111111111111111111\") == True\n assert candidate(s = \"1111110000000000000000000000000000000000000000000000\") == False\n assert candidate(s = \"111100000110011000000111\") == False\n assert candidate(s = \"00000000000000000000000000000000\") == False\n assert candidate(s = \"000111000111000111000111000111000111000111000\") == False\n assert candidate(s = \"000011110000111100001111000011110000111100001111\") == False\n assert candidate(s = \"1111111111111111111\") == True\n assert candidate(s = \"1100110011001100\") == False\n assert candidate(s = \"111010101010101010101\") == True\n assert candidate(s = \"1010101010101010101\") == False\n assert candidate(s = \"111110000011111000001111100000\") == False\n assert candidate(s = \"11010101010101010101010101010101\") == True\n assert candidate(s = \"11110011000001111100110000011111001100000\") == False\n assert candidate(s = \"010101010101010101010101\") == False\n assert candidate(s = \"00000000111111110000000011111111\") == False\n assert candidate(s = \"0000000000000000000000001111111111111111111111111\") == True\n assert candidate(s = \"10101010101010101010101010\") == False\n assert candidate(s = \"111000000011111111111\") == True\n assert candidate(s = \"1010101010101010101010101010101\") == False\n assert candidate(s = \"1110000110000111\") == False\n assert candidate(s = \"00000000001111111111111111111111111111111\") == True\n assert candidate(s = \"1111111111111111111111111111111111111111111111111\") == True\n assert candidate(s = \"111111110000000\") == True\n assert candidate(s = \"000000000000000000000001\") == False\n assert candidate(s = \"00000000000000000000000000000000000000000000000011111\") == False\n assert candidate(s = \"000111000111000111\") == False\n assert candidate(s = \"111111111111111111110000000000000000111111111111\") == True\n assert candidate(s = \"10101010101010101010101010101010101010101010101\") == False\n assert candidate(s = \"10000111110000001111111110000000011111111111\") == True\n assert candidate(s = \"111111111111100000000000000011111111111111111111111111111\") == True\n assert candidate(s = \"111110000011111000001111100000111110000011111\") == False\n assert candidate(s = \"0001001001001001001001001\") == False\n assert candidate(s = \"000110001100011000110001100011\") == False\n assert candidate(s = \"0000000000\") == False\n assert candidate(s = \"111111111111111111111\") == True\n assert candidate(s = \"111110000001110000111111\") == False\n assert candidate(s = \"1010101010101010101010101010101010101010101010101\") == False\n assert candidate(s = \"111111010101010101010101010101010101010101010101010101\") == True\n assert candidate(s = \"0000000000000000\") == False\n assert candidate(s = \"000100010001000\") == False\n assert candidate(s = \"000111000111000111000111\") == False\n assert candidate(s = \"101010101010101010101010101010\") == False\n assert candidate(s = \"1001001001001001001001001001001001001001001\") == False\n assert candidate(s = \"111100001111000011110000111100001111\") == False\n assert candidate(s = \"111111000000111111000000\") == False\n assert candidate(s = \"111100001111000011110000\") == False\n assert candidate(s = \"101010101010101010101010101010101010101010101\") == False\n assert candidate(s = \"000000000000000000000\") == False\n assert candidate(s = \"111111110000000000000000000\") == False\n assert candidate(s = \"11111000001111100000\") == False\n assert candidate(s = \"11111111111111111111110000000000000000\") == True\n assert candidate(s = \"0011001100110011001100110011001100110011\") == False\n assert candidate(s = \"000000000000000011111111111\") == False\n assert candidate(s = \"00110011001100110011001100110011\") == False\n assert candidate(s = \"000000000000000000000000000000000000000000000000000000000\") == False\n assert candidate(s = \"11110000111100001111\") == False\n assert candidate(s = \"11111000000000000000000000000000000000000000000000000\") == False\n assert candidate(s = \"110000000000000000000\") == False\n assert candidate(s = \"10101010101010101010101010101\") == False\n assert candidate(s = \"10101010101010101010101010101010101010\") == False\n assert candidate(s = \"010101010101010101010101010101010101010101010101\") == False\n assert candidate(s = \"000000011111111\") == True\n assert candidate(s = \"111111111100000000001111111111\") == False\n assert candidate(s = \"0011110000111100001111\") == False\n assert candidate(s = \"1111000001100100\") == False\n assert candidate(s = \"11111111111111111111\") == True\n assert candidate(s = \"1000000000000000000\") == False\n assert candidate(s = \"111001110011100\") == True\n assert candidate(s = \"1000111000111000111000111000111000111000\") == False\n assert candidate(s = \"1111111111111111\") == True\n assert candidate(s = \"111001110011100111001110011100\") == True\n assert candidate(s = \"101010101010101010101010101010101010101\") == False\n assert candidate(s = \"1100110011001100110011001100110011001100110011001100110011\") == False\n assert candidate(s = \"00000111111111000000\") == True\n assert candidate(s = \"000000000000000000000000000000000000001\") == False\n assert candidate(s = \"110000111100001111000011110000111100001111\") == False\n assert candidate(s = \"100000011111111111100\") == True\n assert candidate(s = \"00000000001111111111\") == False\n assert candidate(s = \"010101010101010101010101010101\") == False\n assert candidate(s = \"000000000000000000000000000000000000000000000000000000001\") == False\n assert candidate(s = \"111000111000111000111\") == False\n assert candidate(s = \"11111000011111000011\") == True\n assert candidate(s = \"0000111111110000000\") == True\n assert candidate(s = \"111111111000000001111000000111110000\") == True\n assert candidate(s = \"11111111110000000000\") == False\n assert candidate(s = \"11111111110000000000000000000000000000000\") == False\n assert candidate(s = \"01010101010101010101010101010101\") == False\n assert candidate(s = \"111111000000000000000000000000\") == False\n assert candidate(s = \"000000000000000011111111111111111111000000000000\") == True\n assert candidate(s = \"11000001110000011100000111\") == False\n assert candidate(s = \"1010101010101010101010101010\") == False\n assert candidate(s = \"111100000000011111\") == False\n assert candidate(s = \"111000111000111000111000111\") == False\n assert candidate(s = \"0000111111110000\") == True\n assert candidate(s = \"0000000000000000000000000000000000000000000000000\") == False\n assert candidate(s = \"1111111111111111111111111111111111111110\") == True\n assert candidate(s = \"11110000011110000\") == False\n assert candidate(s = \"1110000111000111\") == False\n assert candidate(s = \"11111111111111111111111111111111\") == True\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010101010\") == False\n assert candidate(s = \"0000000000011111111111111100000000011111111111\") == True\n assert candidate(s = \"000000001010101010101010101010101010101010101010101010\") == False\n assert candidate(s = \"0101010101010101010101010101\") == False\n assert candidate(s = \"11100100010001000100010001000100\") == False\n assert candidate(s = \"000001111110000011111100000111111\") == True\n assert candidate(s = \"11001100110011001100110011001100110011\") == False\n assert candidate(s = \"00011100010001000100010001110001\") == False\n assert candidate(s = \"11001100110011001100110011001100110011001100\") == False\n assert candidate(s = \"111000011100001110000111\") == False\n assert candidate(s = \"001111110000000011111100000000\") == False\n assert candidate(s = \"010101010101010101010101010101010101010\") == False\n assert candidate(s = \"00000000000000000000\") == False\n assert candidate(s = \"1111000011110000\") == False\n assert candidate(s = \"10101010101010101010101010101010\") == False\n assert candidate(s = \"1001001001001001001001001\") == False\n assert candidate(s = \"1010101011111010\") == True\n assert candidate(s = \"0000000111111111111111111111111111111111111111100000\") == True\n assert candidate(s = \"000111000111000111000111000\") == False\n assert candidate(s = \"1010101010101010101010101010101010101010101010\") == False\n assert candidate(s = \"0110110110110110110110110\") == True\n assert candidate(s = \"1111111111111111111111110000000000000000000000000\") == False\n assert candidate(s = \"1111111111\") == True\n assert candidate(s = \"111111111100000000\") == True\n assert candidate(s = \"1001100110011001\") == False\n assert candidate(s = \"000000000000111111000000000011111\") == False\n assert candidate(s = \"001001001001001001001\") == False\n assert candidate(s = \"1100110011001100110011\") == False\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010\") == False\n assert candidate(s = \"0101010101010101010101010101010101010101010101010101010101010101010101\") == False\n assert candidate(s = \"111110000000000000000000000000000000000\") == False\n assert candidate(s = \"110110110110110110110\") == True\n assert candidate(s = \"0000000000000000000000001111111111111111111111111111\") == True\n assert candidate(s = \"10101010101010101010\") == False\n assert candidate(s = \"100110011001100110011001\") == False\n assert candidate(s = \"11001100110011001100110011\") == False\n assert candidate(s = \"010101010101010101010101010101010101010101\") == False\n assert candidate(s = \"000000111111111111\") == True\n assert candidate(s = \"00011100010001000100010001000111\") == False\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().checkZeroOnes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool checkZeroOnes(string s) {", "container": "Solution", "callable": "checkZeroOnes", "parameters": [{"name": "s", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1870, "task_id": "minimum-speed-to-arrive-on-time", "difficulty": "Medium", "problem_description": "You are given a floating-point number hour, representing the amount of time you have to reach the office. To commute to the office, you must take n trains in sequential order. You are also given an integer array dist of length n, where dist[i] describes the distance (in kilometers) of the ith train ride.\nEach train can only depart at an integer hour, so you may need to wait in between each train ride.\n\nFor example, if the 1st train ride takes 1.5 hours, you must wait for an additional 0.5 hours before you can depart on the 2nd train ride at the 2 hour mark.\n\nReturn the minimum positive integer speed (in kilometers per hour) that all the trains must travel at for you to reach the office on time, or -1 if it is impossible to be on time.\nTests are generated such that the answer will not exceed 107 and hour will have at most two digits after the decimal point.\n \nExample 1:\n\nInput: dist = [1,3,2], hour = 6\nOutput: 1\nExplanation: At speed 1:\n- The first train ride takes 1/1 = 1 hour.\n- Since we are already at an integer hour, we depart immediately at the 1 hour mark. The second train takes 3/1 = 3 hours.\n- Since we are already at an integer hour, we depart immediately at the 4 hour mark. The third train takes 2/1 = 2 hours.\n- You will arrive at exactly the 6 hour mark.\n\nExample 2:\n\nInput: dist = [1,3,2], hour = 2.7\nOutput: 3\nExplanation: At speed 3:\n- The first train ride takes 1/3 = 0.33333 hours.\n- Since we are not at an integer hour, we wait until the 1 hour mark to depart. The second train ride takes 3/3 = 1 hour.\n- Since we are already at an integer hour, we depart immediately at the 2 hour mark. The third train takes 2/3 = 0.66667 hours.\n- You will arrive at the 2.66667 hour mark.\n\nExample 3:\n\nInput: dist = [1,3,2], hour = 1.9\nOutput: -1\nExplanation: It is impossible because the earliest the third train can depart is at the 2 hour mark.\n\n \nConstraints:\n\nn == dist.length\n1 <= n <= 105\n1 <= dist[i] <= 105\n1 <= hour <= 109\nThere will be at most two digits after the decimal point in hour.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(dist = [5, 4, 3, 2, 1],hour = 5.5) == 4\n assert candidate(dist = [5, 4, 1, 2],hour = 3.5) == 5\n assert candidate(dist = [1, 2, 3, 4, 5],hour = 9.0) == 2\n assert candidate(dist = [9],hour = 0.5) == 18\n assert candidate(dist = [1, 3, 2],hour = 1.9) == -1\n assert candidate(dist = [1, 1, 100000],hour = 2.01) == 10000000\n assert candidate(dist = [5, 5, 5, 5, 5],hour = 9.0) == 5\n assert candidate(dist = [100000],hour = 2.5) == 40000\n assert candidate(dist = [100000],hour = 1.0) == 100000\n assert candidate(dist = [10, 10, 10],hour = 3.5) == 10\n assert candidate(dist = [1, 3, 2],hour = 2.7) == 3\n assert candidate(dist = [1, 2, 3, 4, 5],hour = 10.0) == 2\n assert candidate(dist = [10, 10, 10],hour = 2.5) == 20\n assert candidate(dist = [1],hour = 1.0) == 1\n assert candidate(dist = [10, 10, 10],hour = 29.99) == 2\n assert candidate(dist = [1, 3, 2],hour = 6) == 1\n assert candidate(dist = [10, 10, 10],hour = 3.0) == 10\n assert candidate(dist = [5, 5, 5, 5],hour = 10.0) == 3\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],hour = 100000.0) == 1\n assert candidate(dist = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],hour = 19.99) == 11\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 4.5) == -1\n assert candidate(dist = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999],hour = 50.0) == 20000\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],hour = 30.0) == 50\n assert candidate(dist = [100, 200, 300, 400, 500],hour = 15.5) == 100\n assert candidate(dist = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],hour = 15.0) == 100\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 10.1) == 1\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],hour = 50.0) == 12\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 9.5) == 20\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],hour = 20.0) == 10\n assert candidate(dist = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],hour = 9.0) == -1\n assert candidate(dist = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],hour = 10.5) == 20\n assert candidate(dist = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],hour = 45.0) == 13334\n assert candidate(dist = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],hour = 15.0) == 25\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],hour = 30.5) == 20\n assert candidate(dist = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],hour = 14.0) == -1\n assert candidate(dist = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],hour = 10.0) == 100000\n assert candidate(dist = [100000, 100000, 100000, 100000, 100000],hour = 25.0) == 20000\n assert candidate(dist = [100000, 1, 1, 1, 1],hour = 10.1) == 14286\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 9.99) == 11\n assert candidate(dist = [100000, 200000, 300000, 400000, 500000],hour = 100.0) == 15385\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 2.5) == -1\n assert candidate(dist = [100000, 200000, 300000, 400000],hour = 25.0) == 42858\n assert candidate(dist = [1, 2, 3, 4, 5],hour = 2.0) == -1\n assert candidate(dist = [99999, 99999, 99999, 99999],hour = 20.0) == 20000\n assert candidate(dist = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],hour = 50.0) == 1200\n assert candidate(dist = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],hour = 15.0) == 5\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],hour = 49.99) == 12\n assert candidate(dist = [1000, 2000, 3000],hour = 7.0) == 1000\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 5.5) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],hour = 25.5) == 14\n assert candidate(dist = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],hour = 15.0) == 5\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 5.5) == -1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 25.0) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 20.0) == 4\n assert candidate(dist = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999],hour = 9.99) == 101010\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 15.0) == 5\n assert candidate(dist = [1, 10, 100, 1000, 10000],hour = 12.0) == 1250\n assert candidate(dist = [10000, 20000, 30000, 40000, 50000],hour = 12.5) == 14286\n assert candidate(dist = [10, 20, 30, 40, 50],hour = 12.5) == 15\n assert candidate(dist = [10, 20, 30, 40, 50],hour = 12.5) == 15\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 10.0) == 1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 19.0) == -1\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],hour = 18.0) == 40\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],hour = 18.0) == 40\n assert candidate(dist = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],hour = 9.0) == -1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 1.0) == -1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 20.0) == 1\n assert candidate(dist = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],hour = 15.25) == 5\n assert candidate(dist = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],hour = 4.0) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 5.0) == -1\n assert candidate(dist = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],hour = 15.5) == 5\n assert candidate(dist = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],hour = 9.5) == 10\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 9.0) == -1\n assert candidate(dist = [99999, 99999, 99999, 99999, 99999],hour = 25.0) == 20000\n assert candidate(dist = [100, 200, 300, 400, 500],hour = 10.0) == 200\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],hour = 19.99) == 21\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],hour = 50.5) == 118\n assert candidate(dist = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],hour = 11.0) == 9\n assert candidate(dist = [100, 200, 300, 400, 500],hour = 14.0) == 125\n assert candidate(dist = [100, 200, 300, 400, 500],hour = 20.0) == 84\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 50.0) == -1\n assert candidate(dist = [1, 10000, 1, 10000, 1, 10000, 1, 10000, 1, 10000],hour = 10.5) == 10000\n assert candidate(dist = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],hour = 10.0) == 19\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],hour = 25.0) == 70\n assert candidate(dist = [100000, 99999, 99998, 99997, 99996],hour = 5.0) == 100000\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],hour = 21.5) == 18\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 9.5) == 2\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 2.99) == -1\n assert candidate(dist = [5, 10, 15, 20, 25],hour = 9.0) == 10\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],hour = 9.99) == 102\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],hour = 5.0) == -1\n assert candidate(dist = [1, 100000, 1, 1, 1],hour = 10.1) == 14286\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],hour = 20.0) == 35\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],hour = 30.5) == 200\n assert candidate(dist = [99999, 99999, 99999],hour = 3.5) == 99999\n assert candidate(dist = [10000, 10000, 10000, 10000, 10000],hour = 25.0) == 2000\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],hour = 7.5) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],hour = 1.5) == -1\n"}, "metadata": {"canonical_parameter_names": ["dist", "hour"], "leetcode_dataset_entry_point": "Solution().minSpeedOnTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minSpeedOnTime(vector& dist, double hour) {", "container": "Solution", "callable": "minSpeedOnTime", "parameters": [{"name": "dist", "type": "vector&"}, {"name": "hour", "type": "double"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1871, "task_id": "jump-game-vii", "difficulty": "Medium", "problem_description": "You are given a 0-indexed binary string s and two integers minJump and maxJump. In the beginning, you are standing at index 0, which is equal to '0'. You can move from index i to index j if the following conditions are fulfilled:\n\ni + minJump <= j <= min(i + maxJump, s.length - 1), and\ns[j] == '0'.\n\nReturn true if you can reach index s.length - 1 in s, or false otherwise.\n \nExample 1:\n\nInput: s = \"011010\", minJump = 2, maxJump = 3\nOutput: true\nExplanation:\nIn the first step, move from index 0 to index 3. \nIn the second step, move from index 3 to index 5.\n\nExample 2:\n\nInput: s = \"01101110\", minJump = 2, maxJump = 3\nOutput: false\n\n \nConstraints:\n\n2 <= s.length <= 105\ns[i] is either '0' or '1'.\ns[0] == '0'\n1 <= minJump <= maxJump < s.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"0100100010001000\",minJump = 2,maxJump = 5) == True\n assert candidate(s = \"00001000\",minJump = 2,maxJump = 4) == True\n assert candidate(s = \"0010010010010010010010010010010010010010\",minJump = 2,maxJump = 4) == True\n assert candidate(s = \"011010\",minJump = 2,maxJump = 3) == True\n assert candidate(s = \"0100000\",minJump = 1,maxJump = 2) == True\n assert candidate(s = \"00001000\",minJump = 3,maxJump = 5) == True\n assert candidate(s = \"01010101\",minJump = 2,maxJump = 4) == False\n assert candidate(s = \"0101010101010101010101010101010101010101\",minJump = 5,maxJump = 10) == False\n assert candidate(s = \"0111111111111111111111111111111111111111\",minJump = 3,maxJump = 5) == False\n assert candidate(s = \"000000\",minJump = 1,maxJump = 2) == True\n assert candidate(s = \"001000\",minJump = 2,maxJump = 3) == True\n assert candidate(s = \"010101\",minJump = 1,maxJump = 2) == False\n assert candidate(s = \"00000000\",minJump = 1,maxJump = 2) == True\n assert candidate(s = \"00100\",minJump = 3,maxJump = 4) == True\n assert candidate(s = \"01101110\",minJump = 2,maxJump = 3) == False\n assert candidate(s = \"010000\",minJump = 1,maxJump = 3) == True\n assert candidate(s = \"00000000001000000000\",minJump = 4,maxJump = 7) == True\n assert candidate(s = \"0000011111000000000000000000\",minJump = 1,maxJump = 5) == False\n assert candidate(s = \"00000000000000000000000000000000000000000000000000000000000000000000000000000000\",minJump = 5,maxJump = 10) == True\n assert candidate(s = \"0000000000000000000000000000\",minJump = 2,maxJump = 2) == False\n assert candidate(s = \"0111111111111111111111111110\",minJump = 10,maxJump = 20) == False\n assert candidate(s = \"0100000000000000000000000000\",minJump = 2,maxJump = 3) == True\n assert candidate(s = \"00000000000000000000000000000000000000000000000000\",minJump = 10,maxJump = 20) == True\n assert candidate(s = \"01010101010101010101010101010101010101010101010101\",minJump = 5,maxJump = 15) == False\n assert candidate(s = \"0010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101\",minJump = 3,maxJump = 7) == False\n assert candidate(s = \"0000000000000000000000000001\",minJump = 5000,maxJump = 10000) == False\n assert candidate(s = \"0000000000000000000000000001\",minJump = 1,maxJump = 1) == False\n assert candidate(s = \"000001000001000001000001000001000001000001000001\",minJump = 6,maxJump = 12) == False\n assert candidate(s = \"000111000111000111000111000111000111000111000111\",minJump = 3,maxJump = 6) == False\n assert candidate(s = \"01001001001001001001001000\",minJump = 5,maxJump = 10) == True\n assert candidate(s = \"001001001000\",minJump = 2,maxJump = 4) == True\n assert candidate(s = \"0100000000000000000000000000\",minJump = 50000,maxJump = 50000) == False\n assert candidate(s = \"0000100100010001000100010001000100010001000100010000\",minJump = 5,maxJump = 15) == True\n assert candidate(s = \"0000000000000000000000000000000000000000000000000001000000000000000000000000\",minJump = 10,maxJump = 20) == True\n assert candidate(s = \"01001001001001001001001001001001001001001001001001\",minJump = 4,maxJump = 8) == False\n assert candidate(s = \"0000000000000000000000000000\",minJump = 5,maxJump = 5) == False\n assert candidate(s = \"010001000100010001000100010001000100010000\",minJump = 4,maxJump = 12) == True\n assert candidate(s = \"0000000000000000000000000000\",minJump = 1,maxJump = 10) == True\n assert candidate(s = \"0101010101010101010101010101\",minJump = 3,maxJump = 5) == False\n assert candidate(s = \"0100000000000000000000000000\",minJump = 10,maxJump = 10) == False\n assert candidate(s = \"0001010101010101010101010101010100\",minJump = 3,maxJump = 8) == True\n assert candidate(s = \"0000000000000000000000000000\",minJump = 50,maxJump = 100) == False\n assert candidate(s = \"0000000000\",minJump = 4,maxJump = 6) == True\n assert candidate(s = \"0000000000000000000000000000\",minJump = 1,maxJump = 99999) == True\n assert candidate(s = \"0100000000000000000000000000\",minJump = 10000,maxJump = 50000) == False\n assert candidate(s = \"0000000000000000000000000000\",minJump = 10000,maxJump = 10000) == False\n assert candidate(s = \"0000000000000000000000000000\",minJump = 100,maxJump = 100) == False\n assert candidate(s = \"0000000000000000000000000000\",minJump = 1,maxJump = 50000) == True\n assert candidate(s = \"0001000100010001000100010000\",minJump = 3,maxJump = 5) == True\n"}, "metadata": {"canonical_parameter_names": ["s", "minJump", "maxJump"], "leetcode_dataset_entry_point": "Solution().canReach", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool canReach(string s, int minJump, int maxJump) {", "container": "Solution", "callable": "canReach", "parameters": [{"name": "s", "type": "string"}, {"name": "minJump", "type": "int"}, {"name": "maxJump", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1872, "task_id": "stone-game-viii", "difficulty": "Hard", "problem_description": "Alice and Bob take turns playing a game, with Alice starting first.\\r\n\\r\nThere are n stones arranged in a row. On each player's turn, while the number of stones is more than one, they will do the following:\\r\n\\r\n\\r\n\tChoose an integer x > 1, and remove the leftmost x stones from the row.\\r\n\tAdd the sum of the removed stones' values to the player's score.\\r\n\tPlace a new stone, whose value is equal to that sum, on the left side of the row.\\r\n\\r\n\\r\nThe game stops when only one stone is left in the row.\\r\n\\r\nThe score difference between Alice and Bob is (Alice's score - Bob's score). Alice's goal is to maximize the score difference, and Bob's goal is the minimize the score difference.\\r\n\\r\nGiven an integer array stones of length n where stones[i] represents the value of the ith stone from the left, return the score difference between Alice and Bob if they both play optimally.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: stones = [-1,2,-3,4,-5]\\r\nOutput: 5\\r\nExplanation:\\r\n- Alice removes the first 4 stones, adds (-1) + 2 + (-3) + 4 = 2 to her score, and places a stone of\\r\n value 2 on the left. stones = [2,-5].\\r\n- Bob removes the first 2 stones, adds 2 + (-5) = -3 to his score, and places a stone of value -3 on\\r\n the left. stones = [-3].\\r\nThe difference between their scores is 2 - (-3) = 5.\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: stones = [7,-6,5,10,5,-2,-6]\\r\nOutput: 13\\r\nExplanation:\\r\n- Alice removes all stones, adds 7 + (-6) + 5 + 10 + 5 + (-2) + (-6) = 13 to her score, and places a\\r\n stone of value 13 on the left. stones = [13].\\r\nThe difference between their scores is 13 - 0 = 13.\\r\n\\r\n\\r\nExample 3:\\r\n\\r\n\\r\nInput: stones = [-10,-12]\\r\nOutput: -22\\r\nExplanation:\\r\n- Alice can only make one move, which is to remove both stones. She adds (-10) + (-12) = -22 to her\\r\n score and places a stone of value -22 on the left. stones = [-22].\\r\nThe difference between their scores is (-22) - 0 = -22.\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\tn == stones.length\\r\n\t2 <= n <= 105\\r\n\t-104 <= stones[i] <= 104\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(stones = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(stones = [10, -10, 20, -20, 30, -30]) == 30\n assert candidate(stones = [100, 200, -300, 400, -500, 600, -700, 800]) == 600\n assert candidate(stones = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 50\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(stones = [-1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000]) == 0\n assert candidate(stones = [1, 2, 3, 4, 5]) == 15\n assert candidate(stones = [100, -100, 100, -100, 100]) == 100\n assert candidate(stones = [10, -10, 20, -20, 30, -30, 40, -40]) == 40\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(stones = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 1\n assert candidate(stones = [-1, -2, -3, -4, -5]) == 5\n assert candidate(stones = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50]) == 50\n assert candidate(stones = [-10, -12]) == -22\n assert candidate(stones = [-5, -4, -3, -2, -1]) == 1\n assert candidate(stones = [7, -6, 5, 10, 5, -2, -6]) == 13\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(stones = [-1, 2, -3, 4, -5]) == 5\n assert candidate(stones = [100, -50, 25, -12, 6, -3, 1, -1, 3, -2, 5, -4, 7, -6, 9]) == 78\n assert candidate(stones = [-10000, 0, 10000, 0, -10000, 0, 10000, 0, -10000, 0, 10000, 0, -10000, 0, 10000, 0, -10000, 0, 10000, 0]) == 0\n assert candidate(stones = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(stones = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000, 1100, -1200, 1300, -1400, 1500]) == 800\n assert candidate(stones = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, -10000, -9000, -8000, -7000, -6000, -5000, -4000, -3000, -2000, -1000]) == 30000\n assert candidate(stones = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010]) == 11055\n assert candidate(stones = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900, 1000, -1000]) == 1000\n assert candidate(stones = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, -10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 250\n assert candidate(stones = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000]) == 1000\n assert candidate(stones = [5, 10, -5, 20, -10, 25, -15, 30, -20, 35, -25, 40, -30, 45, -35, 50, -40, 55, -45, 60]) == 150\n assert candidate(stones = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 1\n assert candidate(stones = [-5, 15, -25, 35, -45, 55, -65, 75, -85, 95, -105]) == 105\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 325\n assert candidate(stones = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10]) == 10\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(stones = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 210\n assert candidate(stones = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16]) == 16\n assert candidate(stones = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16, -17, 18, -19, 20]) == 10\n assert candidate(stones = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(stones = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10]) == 10\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0]) == 1000\n assert candidate(stones = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 0, -1, -3, -7, -15, -31]) == 1937\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 30\n assert candidate(stones = [10000, -10000, 9999, -9999, 9998, -9998, 9997, -9997, 9996, -9996]) == 9996\n assert candidate(stones = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11]) == 11\n assert candidate(stones = [-10000, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1]) == -1\n assert candidate(stones = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, -1000, -900, -800, -700, -600]) == 3100\n assert candidate(stones = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(stones = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == 20\n assert candidate(stones = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15]) == 15\n assert candidate(stones = [10000, -5000, 2000, -1000, 500, -200, 100, -50, 20, -10]) == 6360\n assert candidate(stones = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 28\n assert candidate(stones = [-1, -2, -4, -8, -16, -32, -64, -128, -256, -512, -1024, -2048, -4096, -8192, -16384, -32768, -65536, -131072, -262144, -524288]) == 524288\n assert candidate(stones = [1, 2, 3, 4, 5, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, -5, -4, -3, -2, -1]) == 9\n assert candidate(stones = [10000, -5000, 5000, -2500, 2500, -1250, 1250, -625, 625, -312, 312, -156, 156, -78, 78, -39, 39, -19, 19, -9, 9]) == 10000\n assert candidate(stones = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(stones = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, 5]) == 10\n assert candidate(stones = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == 550000\n assert candidate(stones = [10000, -9999, 9998, -9997, 9996, -9995, 9994, -9993, 9992, -9991, 9990]) == 9995\n assert candidate(stones = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15]) == 8\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 1200\n assert candidate(stones = [5, -5, 10, -10, 15, -15, 20, -20, 25, -25, 30, -30, 35, -35, 40, -40, 45, -45, 50, -50]) == 50\n assert candidate(stones = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800, 900, -900, 1000, -1000, 1100, -1100, 1200, -1200]) == 1200\n assert candidate(stones = [1, -10, 100, -1000, 10000, -100000, 1000000, -10000000, 100000000, -1000000000]) == 1000000000\n assert candidate(stones = [-150, -140, -130, -120, -110, -100, -90, -80, -70, -60, -50, -40, -30, -20, -10]) == 10\n assert candidate(stones = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10]) == 10\n assert candidate(stones = [10000, -9999, 9998, -9997, 9996, -9995, 9994, -9993, 9992, -9991]) == 9991\n assert candidate(stones = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 1\n assert candidate(stones = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10]) == 0\n assert candidate(stones = [100, 200, -300, 400, -500, 600, -700, 800, -900, 1000]) == 700\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -100, -90, -80, -70, -60, -50, -40, -30, -20, -10]) == 300\n assert candidate(stones = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == 1048575\n assert candidate(stones = [10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000]) == 10000\n assert candidate(stones = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 1\n assert candidate(stones = [1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1]) == 1\n assert candidate(stones = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10000]) == 10014\n assert candidate(stones = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20]) == 20\n assert candidate(stones = [-5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5]) == 5\n"}, "metadata": {"canonical_parameter_names": ["stones"], "leetcode_dataset_entry_point": "Solution().stoneGameVIII", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int stoneGameVIII(vector& stones) {", "container": "Solution", "callable": "stoneGameVIII", "parameters": [{"name": "stones", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1876, "task_id": "substrings-of-size-three-with-distinct-characters", "difficulty": "Easy", "problem_description": "A string is good if there are no repeated characters.\nGiven a string s​​​​​, return the number of good substrings of length three in s​​​​​​.\nNote that if there are multiple occurrences of the same substring, every occurrence should be counted.\nA substring is a contiguous sequence of characters in a string.\n \nExample 1:\n\nInput: s = \"xyzzaz\"\nOutput: 1\nExplanation: There are 4 substrings of size 3: \"xyz\", \"yzz\", \"zza\", and \"zaz\". \nThe only good substring of length 3 is \"xyz\".\n\nExample 2:\n\nInput: s = \"aababcabc\"\nOutput: 4\nExplanation: There are 7 substrings of size 3: \"aab\", \"aba\", \"bab\", \"abc\", \"bca\", \"cab\", and \"abc\".\nThe good substrings are \"abc\", \"bca\", \"cab\", and \"abc\".\n\n \nConstraints:\n\n1 <= s.length <= 100\ns​​​​​​ consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"xyzxyzxyz\") == 7\n assert candidate(s = \"abcabcabc\") == 7\n assert candidate(s = \"xyzzaz\") == 1\n assert candidate(s = \"aabbcc\") == 0\n assert candidate(s = \"abacab\") == 2\n assert candidate(s = \"qqqppprrr\") == 0\n assert candidate(s = \"abac\") == 1\n assert candidate(s = \"abc\") == 1\n assert candidate(s = \"xyzxyz\") == 4\n assert candidate(s = \"abcdcba\") == 4\n assert candidate(s = \"aababcabc\") == 4\n assert candidate(s = \"abacaba\") == 2\n assert candidate(s = \"abca\") == 2\n assert candidate(s = \"pqr\") == 1\n assert candidate(s = \"aaa\") == 0\n assert candidate(s = \"aaaaa\") == 0\n assert candidate(s = \"xyz\") == 1\n assert candidate(s = \"abcdefg\") == 5\n assert candidate(s = \"pqrspqrs\") == 6\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 49\n assert candidate(s = \"abcdefghijkabcdefghijkabcdefghijkabcdefghijk\") == 42\n assert candidate(s = \"abcdabcdeabcdefabcdefg\") == 20\n assert candidate(s = \"abcdefghtijklmnopqrstuvwxyz\") == 25\n assert candidate(s = \"abcdefghijklijkijklmnopqrstuvwxyz\") == 31\n assert candidate(s = \"abcdefabcdefabcdef\") == 16\n assert candidate(s = \"abcabcabcabc\") == 10\n assert candidate(s = \"uniquecharacters\") == 13\n assert candidate(s = \"thisisateststringforcountinggoodsubstrings\") == 32\n assert candidate(s = \"mnopqrspqrspqrspqr\") == 16\n assert candidate(s = \"aaaabbbbcccc\") == 0\n assert candidate(s = \"zzzzzzzzzz\") == 0\n assert candidate(s = \"abacabadabacabad\") == 7\n assert candidate(s = \"abababababababababababababababababab\") == 0\n assert candidate(s = \"mnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopqrstuvmnopq\") == 73\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabc\") == 34\n assert candidate(s = \"xyzzyxzyxzyxzyxzyxzyxzyxzyx\") == 23\n assert candidate(s = \"aaabbbcccddd\") == 0\n assert candidate(s = \"abcdbcefg\") == 7\n assert candidate(s = \"abacabadabcabcabcabc\") == 14\n assert candidate(s = \"pqrstuvwxyza\") == 10\n assert candidate(s = \"mnopqrstuvwxyzabcdefghijkl\") == 24\n assert candidate(s = \"abcdbca\") == 5\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 28\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzxyz\") == 2\n assert candidate(s = \"xyzabxyzabxyzabxyz\") == 16\n assert candidate(s = \"abcdefgabcdefgabcdefgabcdefgabcdefgabcdefg\") == 40\n assert candidate(s = \"abcababcbacbacbabc\") == 12\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\") == 24\n assert candidate(s = \"ababababababababab\") == 0\n assert candidate(s = \"abcabcabcabcabcabc\") == 16\n assert candidate(s = \"aabbccddeeffgghhii\") == 0\n assert candidate(s = \"abacabacabacabacabacabacabacabacabacabac\") == 19\n assert candidate(s = \"abcdeffedcbaabcdeffedcbaabcdeffedcbaabcdeffedcba\") == 32\n assert candidate(s = \"abcdefgheijklmnopqrstuvwxyz\") == 25\n assert candidate(s = \"xyzzyxzyxzyxzyxzyx\") == 14\n assert candidate(s = \"zzzzzzzzz\") == 0\n assert candidate(s = \"xyzzyzzxyzzxyzzxyzzx\") == 7\n assert candidate(s = \"abcdexyz\") == 6\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzaaa\") == 25\n assert candidate(s = \"abacabadabacaba\") == 6\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzzzz\") == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 76\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghijklmnopqrstuvwxyz\") == 25\n assert candidate(s = \"abcdefgabcdefgabcdefgabcdefg\") == 26\n assert candidate(s = \"aabbccddeeffgghhiii\") == 0\n assert candidate(s = \"abacabadabcaba\") == 7\n assert candidate(s = \"mnopqmnopqmnopq\") == 13\n assert candidate(s = \"aabbccddeeffgg\") == 0\n assert candidate(s = \"uniquecharactersinthisstringareunique\") == 32\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 0\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzzyyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggeeffddbbaa\") == 0\n assert candidate(s = \"aabcaabcdaabcaabcdaabc\") == 11\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 24\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnoooo\") == 0\n assert candidate(s = \"abcdeabcdeabcde\") == 13\n assert candidate(s = \"ababababab\") == 0\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaa\") == 0\n assert candidate(s = \"abcdefgabcdefgabcdefg\") == 19\n assert candidate(s = \"abacdefghijklmnopqrstuvwxyz\") == 24\n assert candidate(s = \"xyzzazxyzzazxyzzaz\") == 7\n assert candidate(s = \"abababababababababababababababababababab\") == 0\n assert candidate(s = \"abcabcabcabcabcabcabcabcabc\") == 25\n assert candidate(s = \"abcabcabcabcabcabcabcabc\") == 22\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 50\n assert candidate(s = \"abacabadabcabc\") == 8\n assert candidate(s = \"abacabadaba\") == 4\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabc\") == 31\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"thisisaverylongstringwithvariouscharacters\") == 37\n assert candidate(s = \"mississippi\") == 2\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"repeatedrepeatedrepeatedrepeatedrepeated\") == 33\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(s = \"allcharactersareuniquehere\") == 19\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().countGoodSubstrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countGoodSubstrings(string s) {", "container": "Solution", "callable": "countGoodSubstrings", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1877, "task_id": "minimize-maximum-pair-sum-in-array", "difficulty": "Medium", "problem_description": "The pair sum of a pair (a,b) is equal to a + b. The maximum pair sum is the largest pair sum in a list of pairs.\\r\n\\r\n\\r\n\tFor example, if we have pairs (1,5), (2,3), and (4,4), the maximum pair sum would be max(1+5, 2+3, 4+4) = max(6, 5, 8) = 8.\\r\n\\r\n\\r\nGiven an array nums of even length n, pair up the elements of nums into n / 2 pairs such that:\\r\n\\r\n\\r\n\tEach element of nums is in exactly one pair, and\\r\n\tThe maximum pair sum is minimized.\\r\n\\r\n\\r\nReturn the minimized maximum pair sum after optimally pairing up the elements.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: nums = [3,5,2,3]\\r\nOutput: 7\\r\nExplanation: The elements can be paired up into pairs (3,3) and (5,2).\\r\nThe maximum pair sum is max(3+3, 5+2) = max(6, 7) = 7.\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: nums = [3,5,4,2,4,6]\\r\nOutput: 8\\r\nExplanation: The elements can be paired up into pairs (3,5), (4,4), and (6,2).\\r\nThe maximum pair sum is max(3+5, 4+4, 6+2) = max(8, 8, 8) = 8.\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\tn == nums.length\\r\n\t2 <= n <= 105\\r\n\tn is even.\\r\n\t1 <= nums[i] <= 105\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 6, 2, 5, 3, 4]) == 7\n assert candidate(nums = [10, 10, 10, 10]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8]) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [100000, 1, 100000, 1, 100000, 1]) == 100001\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 7\n assert candidate(nums = [1, 1, 1, 1]) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(nums = [10, 10, 10, 10, 10, 10]) == 20\n assert candidate(nums = [3, 5, 4, 2, 4, 6]) == 8\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 5]) == 10\n assert candidate(nums = [3, 5, 2, 3]) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 32\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 105\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 32\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1100\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 5]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994]) == 100001\n assert candidate(nums = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 99999]) == 100001\n assert candidate(nums = [5, 8, 12, 19, 22, 28, 33, 45, 50, 55]) == 60\n assert candidate(nums = [8, 3, 5, 7, 1, 9, 2, 6, 4, 10]) == 11\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [7, 3, 1, 4, 9, 8, 2, 5, 6, 10]) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 17\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 16\n assert candidate(nums = [1, 99999, 2, 99998, 3, 99997, 4, 99996, 5, 99995]) == 100000\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 200000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 31\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [4, 1, 2, 3, 6, 5, 7, 8]) == 9\n assert candidate(nums = [1, 99999, 2, 99998, 3, 99997, 4, 99996, 5, 99995]) == 100000\n assert candidate(nums = [15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16]) == 17\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994, 8, 99993]) == 100001\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5, 5, 4, 6, 3, 7, 2, 8]) == 10\n assert candidate(nums = [34, 8, 64, 51, 32, 21]) == 72\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 55\n assert candidate(nums = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 100001\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 11\n assert candidate(nums = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100000]) == 100002\n assert candidate(nums = [100000, 1, 99999, 2, 99998, 3, 99997, 4, 99996, 5]) == 100001\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10]) == 11\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == 1991\n assert candidate(nums = [23, 34, 45, 56, 67, 78, 89, 90]) == 123\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [2, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 9\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 100000\n assert candidate(nums = [100, 1, 2, 99, 3, 98, 4, 97]) == 101\n assert candidate(nums = [9, 1, 4, 8, 5, 7, 6, 2]) == 11\n assert candidate(nums = [1, 99999, 2, 99998, 3, 99997, 4, 99996]) == 100000\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 2, 4, 6, 8, 10, 12, 14, 16]) == 17\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 3\n assert candidate(nums = [8, 3, 2, 1, 6, 5, 4, 7]) == 9\n assert candidate(nums = [100000, 1, 100000, 2, 100000, 3, 100000, 4]) == 100004\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 31\n assert candidate(nums = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25]) == 50\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11]) == 12\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12]) == 13\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 100000\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 9, 8, 11, 10]) == 12\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 100\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85]) == 100\n assert candidate(nums = [7, 10, 4, 17, 15, 9, 2, 12]) == 19\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 100\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140, 147, 154, 161, 168, 175, 182, 189, 196, 203, 210]) == 217\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 170\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11]) == 12\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == 30\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 130\n assert candidate(nums = [100000, 99999, 1, 2, 99998, 3, 99997, 4, 99996, 5, 99995, 6]) == 100001\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6]) == 3\n assert candidate(nums = [100000, 1, 100000, 2, 100000, 3, 100000, 4, 100000, 5]) == 100005\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 21\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000]) == 200000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 130\n assert candidate(nums = [100000, 1, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == 100001\n assert candidate(nums = [1, 3, 2, 4, 5, 7, 6, 8, 9, 11, 10, 12]) == 13\n assert candidate(nums = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 21\n assert candidate(nums = [99999, 1, 99998, 2, 99997, 3, 99996, 4, 99995, 5]) == 100000\n assert candidate(nums = [1, 99999, 2, 99998, 3, 99997, 4, 99996, 5, 99995, 6, 99994]) == 100000\n assert candidate(nums = [15, 21, 33, 44, 55, 60, 65, 70, 75, 80, 85, 90]) == 125\n assert candidate(nums = [9, 3, 2, 8, 6, 5, 7, 4, 1, 10]) == 11\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 18, 17, 16, 15, 14, 13, 12]) == 19\n assert candidate(nums = [100000, 1, 100000, 1, 100000, 1, 100000, 1]) == 100001\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 17\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 100000\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == 101\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 24\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1100\n assert candidate(nums = [9, 2, 8, 4, 5, 1, 6, 3, 7, 10]) == 11\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minPairSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minPairSum(vector& nums) {", "container": "Solution", "callable": "minPairSum", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1878, "task_id": "get-biggest-three-rhombus-sums-in-a-grid", "difficulty": "Medium", "problem_description": "You are given an m x n integer matrix grid​​​.\nA rhombus sum is the sum of the elements that form the border of a regular rhombus shape in grid​​​. The rhombus must have the shape of a square rotated 45 degrees with each of the corners centered in a grid cell. Below is an image of four valid rhombus shapes with the corresponding colored cells that should be included in each rhombus sum:\n\nNote that the rhombus can have an area of 0, which is depicted by the purple rhombus in the bottom right corner.\nReturn the biggest three distinct rhombus sums in the grid in descending order. If there are less than three distinct values, return all of them.\n \nExample 1:\n\n\nInput: grid = [[3,4,5,1,3],[3,3,4,2,3],[20,30,200,40,10],[1,5,5,4,1],[4,3,2,2,5]]\nOutput: [228,216,211]\nExplanation: The rhombus shapes for the three biggest distinct rhombus sums are depicted above.\n- Blue: 20 + 3 + 200 + 5 = 228\n- Red: 200 + 2 + 10 + 4 = 216\n- Green: 5 + 200 + 4 + 2 = 211\n\nExample 2:\n\n\nInput: grid = [[1,2,3],[4,5,6],[7,8,9]]\nOutput: [20,9,8]\nExplanation: The rhombus shapes for the three biggest distinct rhombus sums are depicted above.\n- Blue: 4 + 2 + 6 + 8 = 20\n- Red: 9 (area 0 rhombus in the bottom right corner)\n- Green: 8 (area 0 rhombus in the bottom middle)\n\nExample 3:\n\nInput: grid = [[7,7,7]]\nOutput: [7]\nExplanation: All three possible rhombus sums are the same, so return [7].\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 50\n1 <= grid[i][j] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == [104, 76, 72]\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == [56, 52, 48]\n assert candidate(grid = [[7, 7, 7]]) == [7]\n assert candidate(grid = [[3, 4, 5, 1, 3], [3, 3, 4, 2, 3], [20, 30, 200, 40, 10], [1, 5, 5, 4, 1], [4, 3, 2, 2, 5]]) == [228, 216, 211]\n assert candidate(grid = [[5, 3, 5, 8], [15, 25, 35, 45], [60, 70, 80, 90], [10, 20, 30, 40]]) == [225, 185, 155]\n assert candidate(grid = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == [40, 20, 5]\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == [4, 1]\n assert candidate(grid = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == [20, 5]\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]) == [20, 9, 8]\n assert candidate(grid = [[5, 3, 5, 5, 5], [3, 3, 3, 3, 3], [5, 5, 5, 5, 5], [3, 3, 3, 3, 3], [5, 5, 5, 5, 5]]) == [32, 16, 14]\n assert candidate(grid = [[10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10], [10, 10, 10, 10, 10]]) == [80, 40, 10]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 1], [1, 2, 3, 3, 2, 1], [1, 2, 3, 4, 3, 1], [1, 2, 3, 3, 2, 1], [1, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1]]) == [18, 17, 12]\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]]) == [40, 20, 5]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 7], [3, 4, 5, 6, 7, 8], [4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10], [6, 7, 8, 9, 10, 11]]) == [56, 48, 40]\n assert candidate(grid = [[9, 1, 3, 7, 5], [2, 6, 4, 8, 0], [5, 9, 1, 3, 7], [4, 8, 2, 6, 4], [3, 7, 5, 9, 1]]) == [48, 22, 20]\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 3, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 1, 1]]) == [12, 8, 6]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [20, 18, 16, 14, 12, 10, 8, 6, 4, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == [62, 61, 60]\n assert candidate(grid = [[10, 10, 10, 10, 10, 10, 10], [10, 9, 8, 7, 6, 5, 4], [10, 8, 6, 4, 2, 0, 2], [10, 7, 5, 3, 1, 3, 5], [10, 6, 4, 2, 0, 2, 4], [10, 5, 3, 1, 3, 5, 7], [10, 4, 2, 0, 2, 4, 6]]) == [61, 52, 42]\n assert candidate(grid = [[25, 16, 32, 8, 4], [12, 24, 18, 36, 27], [6, 12, 24, 18, 36], [3, 6, 12, 24, 18], [1, 3, 6, 12, 24]]) == [170, 120, 116]\n assert candidate(grid = [[20, 10, 20, 10, 20], [10, 20, 10, 20, 10], [20, 10, 20, 10, 20], [10, 20, 10, 20, 10], [20, 10, 20, 10, 20]]) == [160, 80, 40]\n assert candidate(grid = [[50, 40, 30, 20, 10], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65], [30, 40, 50, 60, 70]]) == [320, 220, 200]\n assert candidate(grid = [[10, 11, 12, 13, 14], [15, 16, 17, 18, 19], [20, 21, 22, 23, 24], [25, 26, 27, 28, 29], [30, 31, 32, 33, 34]]) == [176, 112, 108]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]]) == [176, 168, 128]\n assert candidate(grid = [[1, 10, 100, 1000, 10000], [10000, 1000, 100, 10, 1], [1, 10, 100, 1000, 10000], [10000, 1000, 100, 10, 1], [1, 10, 100, 1000, 10000]]) == [12221, 10120, 10000]\n assert candidate(grid = [[10, 20, 30, 40], [40, 30, 20, 10], [10, 20, 30, 40], [40, 30, 20, 10]]) == [100, 40, 30]\n assert candidate(grid = [[9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [5, 6, 7, 8, 9], [0, 1, 2, 3, 4], [9, 8, 7, 6, 5]]) == [36, 20, 18]\n assert candidate(grid = [[10, 15, 20, 25, 30], [5, 9, 12, 18, 22], [3, 6, 8, 10, 14], [1, 2, 3, 4, 5], [7, 11, 13, 17, 19]]) == [83, 69, 55]\n assert candidate(grid = [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [13, 15, 17, 19, 21, 23], [25, 27, 29, 31, 33, 35], [37, 39, 41, 43, 45, 47], [49, 51, 53, 55, 57, 59]]) == [249, 233, 180]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 3, 1], [2, 4, 6, 4, 2], [1, 5, 9, 5, 1]]) == [28, 22, 16]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]]) == [176, 160, 156]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1]]) == [20, 9, 8]\n assert candidate(grid = [[9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]) == [46, 36, 32]\n assert candidate(grid = [[1, 5, 9, 13, 17], [2, 6, 10, 14, 18], [3, 7, 11, 15, 19], [4, 8, 12, 16, 20], [5, 9, 13, 17, 21]]) == [88, 64, 60]\n assert candidate(grid = [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12]]) == [60, 44, 38]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == [88, 66, 44]\n assert candidate(grid = [[9, 8, 7, 6], [5, 4, 3, 2], [1, 0, 1, 2], [3, 4, 5, 6]]) == [16, 14, 10]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 2, 1], [1, 2, 3, 4, 3, 2, 1], [1, 2, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1]]) == [20, 18, 12]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 4, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == [32, 30, 28]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [20, 18, 16, 14, 12, 10, 8, 6, 4, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]) == [127, 118, 109]\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8], [6, 7, 8, 9]]) == [28, 24, 20]\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 2, 2, 2, 1], [1, 2, 3, 2, 1], [1, 2, 2, 2, 1], [1, 1, 1, 1, 1]]) == [12, 8, 6]\n assert candidate(grid = [[5, 5, 5, 5], [5, 1, 1, 5], [5, 1, 1, 5], [5, 5, 5, 5]]) == [12, 5, 1]\n assert candidate(grid = [[5, 5, 5, 5, 5, 5], [5, 10, 10, 10, 10, 5], [5, 10, 15, 15, 10, 5], [5, 10, 15, 15, 10, 5], [5, 10, 10, 10, 10, 5], [5, 5, 5, 5, 5, 5]]) == [75, 50, 40]\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7], [5, 6, 7, 8]]) == [24, 20, 16]\n assert candidate(grid = [[10, 20, 30, 40, 50], [20, 30, 40, 50, 60], [30, 40, 50, 60, 70], [40, 50, 60, 70, 80], [50, 60, 70, 80, 90]]) == [400, 280, 240]\n assert candidate(grid = [[1, 3, 5, 7, 9, 11], [2, 4, 6, 8, 10, 12], [3, 5, 7, 9, 11, 13], [4, 6, 8, 10, 12, 14], [5, 7, 9, 11, 13, 15], [6, 8, 10, 12, 14, 16]]) == [80, 72, 64]\n assert candidate(grid = [[1, 2, 1, 2, 1], [2, 1, 2, 1, 2], [1, 2, 1, 2, 1], [2, 1, 2, 1, 2], [1, 2, 1, 2, 1]]) == [8, 4, 2]\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5], [5, 6, 6, 6, 6, 6, 5], [5, 6, 7, 7, 7, 6, 5], [5, 6, 7, 8, 7, 6, 5], [5, 6, 7, 7, 7, 6, 5], [5, 6, 6, 6, 6, 6, 5], [5, 5, 5, 5, 5, 5, 5]]) == [68, 52, 50]\n assert candidate(grid = [[10, 20, 30, 40, 50], [60, 70, 80, 90, 100], [110, 120, 130, 140, 150], [160, 170, 180, 190, 200], [210, 220, 230, 240, 250]]) == [1040, 760, 720]\n assert candidate(grid = [[100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000]]) == [400000, 100000]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9]]) == [80, 60, 40]\n assert candidate(grid = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [60, 70, 80, 90, 100], [55, 65, 75, 85, 95], [110, 120, 130, 140, 150]]) == [520, 400, 360]\n assert candidate(grid = [[8, 1, 6, 3, 5, 7, 4], [3, 5, 7, 8, 1, 6, 4], [4, 6, 8, 3, 5, 7, 1], [9, 2, 5, 1, 8, 3, 6], [5, 7, 1, 6, 4, 9, 2], [6, 4, 9, 2, 7, 1, 5], [1, 8, 3, 7, 2, 5, 9]]) == [78, 55, 44]\n assert candidate(grid = [[8, 1, 2, 3, 4, 5], [6, 7, 8, 9, 1, 2], [3, 4, 5, 6, 7, 8], [9, 1, 2, 3, 4, 5], [5, 6, 7, 8, 9, 1], [2, 3, 4, 5, 6, 7]]) == [49, 48, 39]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 7, 5, 3, 1], [9, 7, 5, 3, 1, 3, 5, 7, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 7, 5, 3, 1], [9, 7, 5, 3, 1, 3, 5, 7, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9]]) == [80, 68, 67]\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3], [8, 7, 6, 5, 4, 3, 2], [7, 6, 5, 4, 3, 2, 1], [6, 5, 4, 3, 2, 1, 0], [5, 4, 3, 2, 1, 0, -1], [4, 3, 2, 1, 0, -1, -2], [3, 2, 1, 0, -1, -2, -3]]) == [40, 36, 32]\n assert candidate(grid = [[9, 9, 9, 9, 9, 9, 9], [9, 8, 8, 8, 8, 8, 9], [9, 8, 7, 7, 7, 8, 9], [9, 8, 7, 6, 7, 8, 9], [9, 8, 7, 7, 7, 8, 9], [9, 8, 8, 8, 8, 8, 9], [9, 9, 9, 9, 9, 9, 9]]) == [100, 62, 60]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 1], [1, 2, 3, 3, 2, 1], [1, 2, 3, 4, 3, 2], [1, 2, 3, 3, 2, 1], [1, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1]]) == [18, 17, 12]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [1, 2, 3, 4, 5]]) == [28, 15, 13]\n assert candidate(grid = [[5, 2, 1, 4, 3, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42]]) == [208, 200, 192]\n assert candidate(grid = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65], [30, 40, 50, 60, 70]]) == [320, 220, 200]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [2, 3, 4, 5, 6, 7, 8, 9], [3, 4, 5, 6, 7, 8, 9, 10], [4, 5, 6, 7, 8, 9, 10, 11], [5, 6, 7, 8, 9, 10, 11, 12], [6, 7, 8, 9, 10, 11, 12, 13], [7, 8, 9, 10, 11, 12, 13, 14], [8, 9, 10, 11, 12, 13, 14, 15]]) == [108, 96, 88]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7], [2, 3, 4, 5, 6, 7, 8], [3, 4, 5, 6, 7, 8, 9], [4, 5, 6, 7, 8, 9, 10], [5, 6, 7, 8, 9, 10, 11], [6, 7, 8, 9, 10, 11, 12], [7, 8, 9, 10, 11, 12, 13]]) == [84, 72, 64]\n assert candidate(grid = [[100000, 100000, 100000], [100000, 100000, 100000], [100000, 100000, 100000]]) == [400000, 100000]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 1], [3, 4, 5, 6, 7, 8, 9, 10, 1, 2], [4, 5, 6, 7, 8, 9, 10, 1, 2, 3], [5, 6, 7, 8, 9, 10, 1, 2, 3, 4], [6, 7, 8, 9, 10, 1, 2, 3, 4, 5], [7, 8, 9, 10, 1, 2, 3, 4, 5, 6], [8, 9, 10, 1, 2, 3, 4, 5, 6, 7], [9, 10, 1, 2, 3, 4, 5, 6, 7, 8], [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == [90, 86, 84]\n assert candidate(grid = [[1, 10, 100, 1000, 10000], [10, 100, 1000, 10000, 1], [100, 1000, 10000, 1, 10], [1000, 10000, 1, 10, 100], [10000, 1, 10, 100, 1000]]) == [20330, 20200, 20020]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48, 49]]) == [300, 264, 256]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 4, 3, 2, 1], [1, 2, 3, 4, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == [32, 30, 28]\n assert candidate(grid = [[10, 1, 10, 1, 10], [1, 10, 1, 10, 1], [10, 1, 10, 1, 10], [1, 10, 1, 10, 1], [10, 1, 10, 1, 10]]) == [80, 40, 10]\n assert candidate(grid = [[5, 2, 3, 1, 4], [1, 5, 6, 2, 3], [4, 1, 7, 3, 2], [3, 8, 4, 6, 5], [9, 7, 6, 5, 4]]) == [36, 27, 24]\n assert candidate(grid = [[10, 11, 12], [13, 14, 15], [16, 17, 18]]) == [56, 18, 17]\n assert candidate(grid = [[8, 4, 2], [6, 2, 4], [1, 3, 6]]) == [17, 8, 6]\n assert candidate(grid = [[1, 2], [3, 4]]) == [4, 3, 2]\n assert candidate(grid = [[5, 9, 1, 9], [8, 7, 4, 8], [6, 6, 3, 2]]) == [27, 19, 9]\n assert candidate(grid = [[5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5], [5, 5, 5, 5]]) == [20, 5]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 3, 1], [4, 2, 1, 2, 4], [1, 5, 9, 5, 1]]) == [24, 18, 14]\n assert candidate(grid = [[5, 1, 4, 3, 1], [2, 3, 5, 1, 4], [3, 4, 3, 4, 3], [4, 3, 5, 1, 3], [3, 4, 2, 4, 2]]) == [20, 18, 17]\n assert candidate(grid = [[1, 2, 3, 4], [2, 3, 4, 5], [3, 4, 5, 6], [4, 5, 6, 7]]) == [20, 16, 12]\n assert candidate(grid = [[10, 10, 10, 10, 10], [10, 20, 20, 20, 10], [10, 20, 30, 20, 10], [10, 20, 20, 20, 10], [10, 10, 10, 10, 10]]) == [120, 80, 60]\n assert candidate(grid = [[1, 2], [2, 3], [3, 4]]) == [4, 3, 2]\n assert candidate(grid = [[5, 3, 5, 3, 5], [3, 5, 3, 5, 3], [5, 3, 5, 3, 5], [3, 5, 3, 5, 3], [5, 3, 5, 3, 5]]) == [40, 20, 12]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24]]) == [68, 64, 60]\n assert candidate(grid = [[10, 10, 10, 10], [10, 10, 10, 10], [10, 10, 10, 10], [10, 10, 10, 10]]) == [40, 10]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 3, 1], [2, 4, 6, 4, 2], [3, 5, 7, 5, 3]]) == [26, 20, 16]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9]]) == [15, 14, 13]\n assert candidate(grid = [[5, 3, 2, 1], [4, 6, 7, 8], [1, 9, 10, 11], [12, 13, 14, 15]]) == [41, 30, 26]\n assert candidate(grid = [[100000, 100000], [100000, 100000]]) == [100000]\n assert candidate(grid = [[5, 3, 5, 5, 5], [3, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 3], [5, 5, 5, 3, 5]]) == [40, 20, 16]\n assert candidate(grid = [[5, 3, 5, 3], [5, 3, 5, 3], [5, 3, 5, 3], [5, 3, 5, 3]]) == [16, 5, 3]\n assert candidate(grid = [[5]]) == [5]\n assert candidate(grid = [[9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9]]) == [36, 9]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1], [1, 1, 1, 1, 1]]) == [30, 19, 18]\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 2, 3, 4, 5], [5, 4, 3, 2, 1]]) == [12, 5, 4]\n assert candidate(grid = [[10, 10, 10], [10, 10, 10], [10, 10, 10], [10, 10, 10]]) == [40, 10]\n assert candidate(grid = [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5]]) == [40, 20, 5]\n assert candidate(grid = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120], [130, 140, 150, 160]]) == [440, 400, 280]\n assert candidate(grid = [[1, 2], [3, 4], [5, 6]]) == [6, 5, 4]\n assert candidate(grid = [[10, 10, 10], [10, 10, 10], [10, 10, 10]]) == [40, 10]\n assert candidate(grid = [[9, 8, 7], [6, 5, 4], [3, 2, 1]]) == [20, 9, 8]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30]]) == [128, 120, 92]\n assert candidate(grid = [[5, 3, 2, 1], [9, 8, 7, 6], [5, 6, 7, 8], [1, 2, 3, 4]]) == [25, 24, 23]\n assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 20, 30, 40, 50]]) == [240, 120, 50]\n assert candidate(grid = [[9, 9, 9, 9, 9], [9, 8, 8, 8, 9], [9, 8, 7, 8, 9], [9, 8, 8, 8, 9], [9, 9, 9, 9, 9]]) == [68, 34, 32]\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == [8, 4, 1]\n assert candidate(grid = [[10, 20, 30, 40], [15, 25, 35, 45], [20, 30, 40, 50], [25, 35, 45, 55]]) == [160, 140, 120]\n assert candidate(grid = [[10, 20, 30], [40, 50, 60], [70, 80, 90]]) == [200, 90, 80]\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == [44, 40, 28]\n assert candidate(grid = [[5, 2, 10, 6], [8, 3, 9, 7], [1, 4, 8, 2], [7, 6, 5, 3]]) == [28, 23, 20]\n assert candidate(grid = [[5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5]]) == [40, 20, 5]\n assert candidate(grid = [[8, 1, 6], [3, 5, 7], [4, 9, 2]]) == [20, 9, 8]\n assert candidate(grid = [[9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9], [9, 9, 9, 9, 9]]) == [72, 36, 9]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == [10, 9, 8]\n assert candidate(grid = [[1, 2], [2, 1]]) == [2, 1]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == [8, 4, 1]\n assert candidate(grid = [[100000, 100000, 100000], [100000, 100000, 100000], [100000, 100000, 100000]]) == [400000, 100000]\n assert candidate(grid = [[9, 9, 9, 9], [9, 9, 9, 9], [9, 9, 9, 9], [9, 9, 9, 9]]) == [36, 9]\n assert candidate(grid = [[1]]) == [1]\n assert candidate(grid = [[5, 3, 8, 3, 7], [3, 2, 5, 7, 8], [1, 7, 3, 3, 2], [4, 8, 4, 2, 9], [6, 2, 3, 4, 8]]) == [33, 20, 19]\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().getBiggestThree", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector getBiggestThree(vector>& grid) {", "container": "Solution", "callable": "getBiggestThree", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1879, "task_id": "minimum-xor-sum-of-two-arrays", "difficulty": "Hard", "problem_description": "You are given two integer arrays nums1 and nums2 of length n.\nThe XOR sum of the two integer arrays is (nums1[0] XOR nums2[0]) + (nums1[1] XOR nums2[1]) + ... + (nums1[n - 1] XOR nums2[n - 1]) (0-indexed).\n\nFor example, the XOR sum of [1,2,3] and [3,2,1] is equal to (1 XOR 3) + (2 XOR 2) + (3 XOR 1) = 2 + 0 + 2 = 4.\n\nRearrange the elements of nums2 such that the resulting XOR sum is minimized.\nReturn the XOR sum after the rearrangement.\n \nExample 1:\n\nInput: nums1 = [1,2], nums2 = [2,3]\nOutput: 2\nExplanation: Rearrange nums2 so that it becomes [3,2].\nThe XOR sum is (1 XOR 3) + (2 XOR 2) = 2 + 0 = 2.\nExample 2:\n\nInput: nums1 = [1,0,3], nums2 = [5,3,4]\nOutput: 8\nExplanation: Rearrange nums2 so that it becomes [5,4,3]. \nThe XOR sum is (1 XOR 5) + (0 XOR 4) + (3 XOR 3) = 4 + 4 + 0 = 8.\n\n \nConstraints:\n\nn == nums1.length\nn == nums2.length\n1 <= n <= 14\n0 <= nums1[i], nums2[i] <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [3, 4, 2],nums2 = [4, 2, 2]) == 1\n assert candidate(nums1 = [1, 2],nums2 = [2, 3]) == 2\n assert candidate(nums1 = [2, 3, 4, 5],nums2 = [5, 4, 3, 2]) == 0\n assert candidate(nums1 = [4, 6, 2],nums2 = [9, 3, 5]) == 17\n assert candidate(nums1 = [5, 10, 15],nums2 = [15, 10, 5]) == 0\n assert candidate(nums1 = [10, 20, 30],nums2 = [30, 20, 10]) == 0\n assert candidate(nums1 = [1, 2, 3, 4],nums2 = [4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 1, 1],nums2 = [1, 1, 1]) == 0\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1]) == 0\n assert candidate(nums1 = [5, 3, 4],nums2 = [1, 0, 3]) == 8\n assert candidate(nums1 = [14, 15, 16],nums2 = [13, 14, 15]) == 29\n assert candidate(nums1 = [7, 8, 9],nums2 = [9, 8, 7]) == 0\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [2, 2, 2, 2]) == 12\n assert candidate(nums1 = [7, 8, 9],nums2 = [10, 11, 12]) == 15\n assert candidate(nums1 = [10000000, 10000000, 10000000],nums2 = [10000000, 10000000, 10000000]) == 0\n assert candidate(nums1 = [3, 5, 7, 9],nums2 = [9, 7, 5, 3]) == 0\n assert candidate(nums1 = [0, 1, 2],nums2 = [3, 4, 5]) == 9\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [14, 28, 19],nums2 = [28, 14, 19]) == 0\n assert candidate(nums1 = [1],nums2 = [1]) == 0\n assert candidate(nums1 = [1, 0, 3],nums2 = [5, 3, 4]) == 8\n assert candidate(nums1 = [0, 0, 0],nums2 = [0, 0, 0]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 14\n assert candidate(nums1 = [12, 14, 16, 18, 20, 22],nums2 = [21, 19, 17, 15, 13, 11]) == 34\n assert candidate(nums1 = [4, 1, 3, 2],nums2 = [7, 6, 5, 8]) == 18\n assert candidate(nums1 = [9999999, 8888888, 7777777, 6666666, 5555555],nums2 = [4444444, 3333333, 2222222, 1111111, 0]) == 28302135\n assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128],nums2 = [128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(nums1 = [7, 23, 15, 4, 8],nums2 = [17, 9, 3, 20, 12]) == 30\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8],nums2 = [8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27]) == 115\n assert candidate(nums1 = [10000000, 10000001, 10000002, 10000003, 10000004],nums2 = [10000005, 10000006, 10000007, 10000008, 10000009]) == 25\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == 36\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15],nums2 = [15, 13, 11, 9, 7, 5, 3, 1]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 119\n assert candidate(nums1 = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 9999999, 999999, 99999, 9999, 999, 99],nums2 = [99, 999, 9999, 99999, 999999, 9999999, 10000000, 1000000, 100000, 10000, 1000, 100, 10, 1]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 45\n assert candidate(nums1 = [7, 8, 9, 10, 11, 12],nums2 = [12, 11, 10, 9, 8, 7]) == 0\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 220\n assert candidate(nums1 = [7, 13, 21, 31],nums2 = [3, 8, 15, 28]) == 34\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],nums2 = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],nums2 = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 0\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70],nums2 = [70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],nums2 = [32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2]) == 32769\n assert candidate(nums1 = [13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41],nums2 = [43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71]) == 546\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [1, 2, 3, 4, 5]) == 15\n assert candidate(nums1 = [7, 8, 9, 10, 11],nums2 = [12, 13, 14, 15, 16]) == 39\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums1 = [10000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums2 = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10000000]) == 0\n assert candidate(nums1 = [13, 17, 19, 23, 29, 31],nums2 = [31, 29, 23, 19, 17, 13]) == 0\n assert candidate(nums1 = [101, 202, 303, 404, 505, 606, 707, 808, 909],nums2 = [909, 808, 707, 606, 505, 404, 303, 202, 101]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15],nums2 = [2, 4, 6, 8, 10, 12, 14, 16]) == 24\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 42\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],nums2 = [13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800],nums2 = [800, 700, 600, 500, 400, 300, 200, 100]) == 0\n assert candidate(nums1 = [5, 8, 12, 7, 3],nums2 = [10, 6, 4, 15, 9]) == 15\n assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],nums2 = [16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(nums1 = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000, 130000, 140000],nums2 = [140000, 130000, 120000, 110000, 100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 0\n assert candidate(nums1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 14\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140],nums2 = [140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 0\n assert candidate(nums1 = [1, 0, 0, 0],nums2 = [0, 1, 1, 1]) == 2\n assert candidate(nums1 = [21, 17, 34, 19, 28, 42],nums2 = [45, 39, 27, 51, 18, 32]) == 101\n assert candidate(nums1 = [8, 6, 4, 2, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18],nums2 = [18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 2, 4, 6, 8]) == 0\n assert candidate(nums1 = [5, 6, 7, 8, 9, 10, 11, 12, 13],nums2 = [13, 12, 11, 10, 9, 8, 7, 6, 5]) == 0\n assert candidate(nums1 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192],nums2 = [8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 0\n assert candidate(nums1 = [9, 11, 7, 13, 17, 19, 23],nums2 = [29, 25, 21, 15, 13, 11, 7]) == 30\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1]) == 0\n assert candidate(nums1 = [0, 1, 2, 3, 4, 5, 6, 7],nums2 = [7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums1 = [7, 23, 45, 6, 78],nums2 = [89, 12, 34, 56, 78]) == 146\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 0\n assert candidate(nums1 = [8, 16, 24, 32, 40, 48, 56, 64],nums2 = [64, 56, 48, 40, 32, 24, 16, 8]) == 0\n assert candidate(nums1 = [10000000, 0, 10000000, 0, 10000000, 0, 10000000, 0, 10000000, 0, 10000000, 0, 10000000, 0, 10000000],nums2 = [10000000, 0, 10000000, 0, 10000000, 0, 10000000, 0, 10000000, 0, 10000000, 0, 10000000, 0, 10000000]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10]) == 15\n assert candidate(nums1 = [9876543, 8765432, 7654321, 6543210, 5432109],nums2 = [4321098, 3210987, 2109876, 1098765, 987654]) == 28067535\n assert candidate(nums1 = [8, 16, 32, 64, 128, 256],nums2 = [256, 128, 64, 32, 16, 8]) == 0\n assert candidate(nums1 = [1234567, 7654321, 111222333, 444555666, 777888999],nums2 = [999888777, 666555444, 333222111, 210987654, 123456789]) == 1307758981\n assert candidate(nums1 = [10000, 20000, 30000, 40000, 50000],nums2 = [50000, 40000, 30000, 20000, 10000]) == 0\n assert candidate(nums1 = [123456, 789012, 345678, 901234, 567890, 678901, 789012, 890123, 901234, 123456, 234567, 345678, 456789, 567890],nums2 = [567890, 456789, 345678, 234567, 123456, 901234, 890123, 789012, 678901, 567890, 456789, 345678, 234567, 123456]) == 1656438\n assert candidate(nums1 = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53],nums2 = [53, 49, 45, 41, 37, 33, 29, 25, 21, 17, 13, 9, 5, 1]) == 0\n assert candidate(nums1 = [16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1],nums2 = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70],nums2 = [70, 60, 50, 40, 30, 20, 10]) == 0\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 40, 30, 20, 10]) == 0\n assert candidate(nums1 = [7, 8, 9, 10, 11],nums2 = [11, 10, 9, 8, 7]) == 0\n assert candidate(nums1 = [2, 3, 5, 7, 11, 13, 17, 19],nums2 = [19, 17, 13, 11, 7, 5, 3, 2]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [10, 8, 6, 4, 2]) == 15\n assert candidate(nums1 = [256, 512, 1024, 2048, 4096],nums2 = [8192, 4096, 2048, 1024, 512]) == 8448\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400],nums2 = [1400, 1300, 1200, 1100, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 0\n assert candidate(nums1 = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98],nums2 = [98, 91, 84, 77, 70, 63, 56, 49, 42, 35, 28, 21, 14, 7]) == 0\n assert candidate(nums1 = [1, 10000000, 2, 9999999, 3, 9999998, 4, 9999997, 5, 9999996, 6, 9999995, 7, 9999994, 8],nums2 = [8, 7, 9999994, 9, 6, 9999995, 10, 9999996, 5, 9999997, 4, 9999998, 3, 9999999, 2]) == 10000018\n assert candidate(nums1 = [23, 34, 45, 56, 67],nums2 = [67, 56, 45, 34, 23]) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13],nums2 = [13, 11, 9, 7, 5, 3, 1]) == 0\n assert candidate(nums1 = [100, 200, 300, 400, 500, 600, 700],nums2 = [700, 600, 500, 400, 300, 200, 100]) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2"], "leetcode_dataset_entry_point": "Solution().minimumXORSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumXORSum(vector& nums1, vector& nums2) {", "container": "Solution", "callable": "minimumXORSum", "parameters": [{"name": "nums1", "type": "vector&"}, {"name": "nums2", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1880, "task_id": "check-if-word-equals-summation-of-two-words", "difficulty": "Easy", "problem_description": "The letter value of a letter is its position in the alphabet starting from 0 (i.e. 'a' -> 0, 'b' -> 1, 'c' -> 2, etc.).\nThe numerical value of some string of lowercase English letters s is the concatenation of the letter values of each letter in s, which is then converted into an integer.\n\nFor example, if s = \"acb\", we concatenate each letter's letter value, resulting in \"021\". After converting it, we get 21.\n\nYou are given three strings firstWord, secondWord, and targetWord, each consisting of lowercase English letters 'a' through 'j' inclusive.\nReturn true if the summation of the numerical values of firstWord and secondWord equals the numerical value of targetWord, or false otherwise.\n \nExample 1:\n\nInput: firstWord = \"acb\", secondWord = \"cba\", targetWord = \"cdb\"\nOutput: true\nExplanation:\nThe numerical value of firstWord is \"acb\" -> \"021\" -> 21.\nThe numerical value of secondWord is \"cba\" -> \"210\" -> 210.\nThe numerical value of targetWord is \"cdb\" -> \"231\" -> 231.\nWe return true because 21 + 210 == 231.\n\nExample 2:\n\nInput: firstWord = \"aaa\", secondWord = \"a\", targetWord = \"aab\"\nOutput: false\nExplanation: \nThe numerical value of firstWord is \"aaa\" -> \"000\" -> 0.\nThe numerical value of secondWord is \"a\" -> \"0\" -> 0.\nThe numerical value of targetWord is \"aab\" -> \"001\" -> 1.\nWe return false because 0 + 0 != 1.\n\nExample 3:\n\nInput: firstWord = \"aaa\", secondWord = \"a\", targetWord = \"aaaa\"\nOutput: true\nExplanation: \nThe numerical value of firstWord is \"aaa\" -> \"000\" -> 0.\nThe numerical value of secondWord is \"a\" -> \"0\" -> 0.\nThe numerical value of targetWord is \"aaaa\" -> \"0000\" -> 0.\nWe return true because 0 + 0 == 0.\n\n \nConstraints:\n\n1 <= firstWord.length, secondWord.length, targetWord.length <= 8\nfirstWord, secondWord, and targetWord consist of lowercase English letters from 'a' to 'j' inclusive.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(firstWord = \"ij\",secondWord = \"ji\",targetWord = \"ii\") == False\n assert candidate(firstWord = \"fgh\",secondWord = \"ghf\",targetWord = \"ggg\") == False\n assert candidate(firstWord = \"ij\",secondWord = \"ji\",targetWord = \"jjj\") == False\n assert candidate(firstWord = \"b\",secondWord = \"c\",targetWord = \"d\") == True\n assert candidate(firstWord = \"abcdefghij\",secondWord = \"abcdefghij\",targetWord = \"aaaaaaaaaa\") == False\n assert candidate(firstWord = \"i\",secondWord = \"j\",targetWord = \"ji\") == False\n assert candidate(firstWord = \"ab\",secondWord = \"ba\",targetWord = \"bb\") == True\n assert candidate(firstWord = \"j\",secondWord = \"j\",targetWord = \"i\") == False\n assert candidate(firstWord = \"a\",secondWord = \"a\",targetWord = \"b\") == False\n assert candidate(firstWord = \"aaa\",secondWord = \"a\",targetWord = \"aab\") == False\n assert candidate(firstWord = \"aaa\",secondWord = \"a\",targetWord = \"aaaa\") == True\n assert candidate(firstWord = \"acb\",secondWord = \"cba\",targetWord = \"cdb\") == True\n assert candidate(firstWord = \"j\",secondWord = \"j\",targetWord = \"jj\") == False\n assert candidate(firstWord = \"acacacac\",secondWord = \"bdbdbdbd\",targetWord = \"cececece\") == False\n assert candidate(firstWord = \"aaaabbbb\",secondWord = \"ccccdddd\",targetWord = \"aaaabbbbccccdddd\") == False\n assert candidate(firstWord = \"ijijijij\",secondWord = \"jijijiji\",targetWord = \"jjjjjjjjjj\") == False\n assert candidate(firstWord = \"ijijij\",secondWord = \"jijiji\",targetWord = \"jjjjjjjj\") == False\n assert candidate(firstWord = \"j\",secondWord = \"jj\",targetWord = \"jjj\") == False\n assert candidate(firstWord = \"abcdefghij\",secondWord = \"abcdefghi\",targetWord = \"aaaaaaaaaa\") == False\n assert candidate(firstWord = \"babcbabcba\",secondWord = \"cbabcbabcb\",targetWord = \"bbbbbbaaaa\") == False\n assert candidate(firstWord = \"jihgfedcba\",secondWord = \"abcdefghij\",targetWord = \"aaaaaaaaaa\") == False\n assert candidate(firstWord = \"abcdefghij\",secondWord = \"abcdefghij\",targetWord = \"jjjjjjjjjj\") == False\n assert candidate(firstWord = \"ijkl\",secondWord = \"lkji\",targetWord = \"jjjjjj\") == False\n assert candidate(firstWord = \"ijijij\",secondWord = \"ijijij\",targetWord = \"jjjjjjjj\") == False\n assert candidate(firstWord = \"hjihj\",secondWord = \"ihjih\",targetWord = \"jjjjj\") == False\n assert candidate(firstWord = \"aabbcc\",secondWord = \"ddeeff\",targetWord = \"gggggh\") == False\n assert candidate(firstWord = \"abcdefgh\",secondWord = \"abcdefgh\",targetWord = \"hhhhhhhh\") == False\n assert candidate(firstWord = \"babababa\",secondWord = \"babababa\",targetWord = \"cacacaca\") == True\n assert candidate(firstWord = \"aaa\",secondWord = \"bbb\",targetWord = \"ccc\") == False\n assert candidate(firstWord = \"iiii\",secondWord = \"jjjj\",targetWord = \"jjjjjjjj\") == False\n assert candidate(firstWord = \"abcdefghi\",secondWord = \"j\",targetWord = \"abcdefghij\") == False\n assert candidate(firstWord = \"abcdefghij\",secondWord = \"abcdefghi\",targetWord = \"jjjjjjjjj\") == False\n assert candidate(firstWord = \"abcdefghijabcdefghij\",secondWord = \"abcdefghijabcdefghij\",targetWord = \"jjjjjjjjjjjjjjjjjjjj\") == False\n assert candidate(firstWord = \"abcdefgh\",secondWord = \"hgfedcba\",targetWord = \"aaaaaaaaaa\") == False\n assert candidate(firstWord = \"abcdefgh\",secondWord = \"hgfedcba\",targetWord = \"abcdefghhgfedcba\") == False\n assert candidate(firstWord = \"abcdefgh\",secondWord = \"abcdefgh\",targetWord = \"ggggggggg\") == False\n assert candidate(firstWord = \"abc\",secondWord = \"def\",targetWord = \"defabc\") == False\n assert candidate(firstWord = \"abcdefghij\",secondWord = \"abcdefghi\",targetWord = \"abcdefghijj\") == False\n assert candidate(firstWord = \"abcdefgh\",secondWord = \"abcdefgh\",targetWord = \"aaaaaaaaaaaaaaaa\") == False\n assert candidate(firstWord = \"aabbccddeeff\",secondWord = \"ffeeddccbbaa\",targetWord = \"feebbaaccdd\") == False\n assert candidate(firstWord = \"a\",secondWord = \"b\",targetWord = \"c\") == False\n assert candidate(firstWord = \"abcdefgh\",secondWord = \"hgfedcba\",targetWord = \"jjjjjjjj\") == False\n assert candidate(firstWord = \"abcd\",secondWord = \"efgh\",targetWord = \"ijkl\") == False\n assert candidate(firstWord = \"jjjjj\",secondWord = \"jjjjj\",targetWord = \"jjjjjjj\") == False\n assert candidate(firstWord = \"aaaaaaaa\",secondWord = \"bbbbbbbb\",targetWord = \"cccccccc\") == False\n assert candidate(firstWord = \"aabbccdd\",secondWord = \"dccbbaaa\",targetWord = \"dddddddd\") == False\n assert candidate(firstWord = \"abcdefghij\",secondWord = \"abcdefghij\",targetWord = \"iiiiiiiiii\") == False\n assert candidate(firstWord = \"abcabcabc\",secondWord = \"cbacbacba\",targetWord = \"bbbcccbbb\") == False\n assert candidate(firstWord = \"iiii\",secondWord = \"jjjj\",targetWord = \"jjjjjj\") == False\n assert candidate(firstWord = \"abcdefghi\",secondWord = \"abcdefghj\",targetWord = \"jjjjjjjjj\") == False\n assert candidate(firstWord = \"ijijijijij\",secondWord = \"jijijijiji\",targetWord = \"jjjjjjjjjjj\") == False\n assert candidate(firstWord = \"abcde\",secondWord = \"edcba\",targetWord = \"abcdeedcba\") == False\n assert candidate(firstWord = \"ijijijij\",secondWord = \"hghghghg\",targetWord = \"gggggggg\") == False\n assert candidate(firstWord = \"abcdefghij\",secondWord = \"abcdefghija\",targetWord = \"jjjjjjjjjjj\") == False\n assert candidate(firstWord = \"jijij\",secondWord = \"ijiji\",targetWord = \"jjjjjjj\") == False\n assert candidate(firstWord = \"abcdefghij\",secondWord = \"abcdefghij\",targetWord = \"abcdefghijabcdefghij\") == False\n assert candidate(firstWord = \"ijijij\",secondWord = \"jijiji\",targetWord = \"jjjjjjjjjjjj\") == False\n assert candidate(firstWord = \"abcdefghij\",secondWord = \"abcdefghij\",targetWord = \"aaaaaaaaaab\") == False\n assert candidate(firstWord = \"abcdefgh\",secondWord = \"hgfedcba\",targetWord = \"abcdefghij\") == False\n assert candidate(firstWord = \"abcdefghij\",secondWord = \"abcdefghij\",targetWord = \"aaaaaaaaaabbbbbbbbbb\") == False\n assert candidate(firstWord = \"abcdefghi\",secondWord = \"hgfedcba\",targetWord = \"jjjjjjjjj\") == False\n assert candidate(firstWord = \"jihgfedcba\",secondWord = \"abcdefghij\",targetWord = \"jjjjjjjjjj\") == True\n assert candidate(firstWord = \"abcdefghij\",secondWord = \"abcdefghij\",targetWord = \"ijijijijij\") == False\n assert candidate(firstWord = \"jijijijijij\",secondWord = \"jijijijijij\",targetWord = \"jjjjjjjjjjjjjjjjjjj\") == False\n assert candidate(firstWord = \"aabbccddeeffgg\",secondWord = \"hhiijjkkllmm\",targetWord = \"jjjjjjjjjjjj\") == False\n assert candidate(firstWord = \"abcdefghij\",secondWord = \"abcdefghij\",targetWord = \"aaaaaaaaaaab\") == False\n assert candidate(firstWord = \"abcdefgh\",secondWord = \"hgfedcba\",targetWord = \"jjjjjjj\") == False\n assert candidate(firstWord = \"abcde\",secondWord = \"edcba\",targetWord = \"jjjjj\") == False\n assert candidate(firstWord = \"hgfedcba\",secondWord = \"abcdefgh\",targetWord = \"iiiiiiii\") == False\n assert candidate(firstWord = \"jijij\",secondWord = \"ijiji\",targetWord = \"jjjjj\") == False\n assert candidate(firstWord = \"j\",secondWord = \"ij\",targetWord = \"ji\") == True\n assert candidate(firstWord = \"aabbccdd\",secondWord = \"ddeeffgg\",targetWord = \"hhiijjkk\") == False\n assert candidate(firstWord = \"jij\",secondWord = \"iji\",targetWord = \"jjjj\") == False\n"}, "metadata": {"canonical_parameter_names": ["firstWord", "secondWord", "targetWord"], "leetcode_dataset_entry_point": "Solution().isSumEqual", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool isSumEqual(string firstWord, string secondWord, string targetWord) {", "container": "Solution", "callable": "isSumEqual", "parameters": [{"name": "firstWord", "type": "string"}, {"name": "secondWord", "type": "string"}, {"name": "targetWord", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1881, "task_id": "maximum-value-after-insertion", "difficulty": "Medium", "problem_description": "You are given a very large integer n, represented as a string,​​​​​​ and an integer digit x. The digits in n and the digit x are in the inclusive range [1, 9], and n may represent a negative number.\nYou want to maximize n's numerical value by inserting x anywhere in the decimal representation of n​​​​​​. You cannot insert x to the left of the negative sign.\n\nFor example, if n = 73 and x = 6, it would be best to insert it between 7 and 3, making n = 763.\nIf n = -55 and x = 2, it would be best to insert it before the first 5, making n = -255.\n\nReturn a string representing the maximum value of n​​​​​​ after the insertion.\n \nExample 1:\n\nInput: n = \"99\", x = 9\nOutput: \"999\"\nExplanation: The result is the same regardless of where you insert 9.\n\nExample 2:\n\nInput: n = \"-13\", x = 2\nOutput: \"-123\"\nExplanation: You can make n one of {-213, -123, -132}, and the largest of those three is -123.\n\n \nConstraints:\n\n1 <= n.length <= 105\n1 <= x <= 9\nThe digits in n​​​ are in the range [1, 9].\nn is a valid representation of an integer.\nIn the case of a negative n,​​​​​​ it will begin with '-'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = \"5486\",x = 7) == \"75486\"\n assert candidate(n = \"-11111\",x = 1) == \"-111111\"\n assert candidate(n = \"-123456789\",x = 5) == \"-1234556789\"\n assert candidate(n = \"987654321\",x = 5) == \"9876554321\"\n assert candidate(n = \"-98765\",x = 3) == \"-398765\"\n assert candidate(n = \"-1000\",x = 1) == \"-10001\"\n assert candidate(n = \"-987654321\",x = 5) == \"-5987654321\"\n assert candidate(n = \"-54321\",x = 4) == \"-454321\"\n assert candidate(n = \"123456789\",x = 5) == \"5123456789\"\n assert candidate(n = \"5\",x = 9) == \"95\"\n assert candidate(n = \"-1000\",x = 5) == \"-10005\"\n assert candidate(n = \"1000\",x = 1) == \"11000\"\n assert candidate(n = \"54321\",x = 6) == \"654321\"\n assert candidate(n = \"12345\",x = 3) == \"312345\"\n assert candidate(n = \"1000\",x = 5) == \"51000\"\n assert candidate(n = \"-973\",x = 8) == \"-8973\"\n assert candidate(n = \"-13\",x = 2) == \"-123\"\n assert candidate(n = \"54823\",x = 7) == \"754823\"\n assert candidate(n = \"1\",x = 1) == \"11\"\n assert candidate(n = \"99\",x = 9) == \"999\"\n assert candidate(n = \"-64823\",x = 7) == \"-647823\"\n assert candidate(n = \"567\",x = 8) == \"8567\"\n assert candidate(n = \"-9\",x = 1) == \"-19\"\n assert candidate(n = \"-9\",x = 9) == \"-99\"\n assert candidate(n = \"54893\",x = 7) == \"754893\"\n assert candidate(n = \"-987\",x = 7) == \"-7987\"\n assert candidate(n = \"-222222222\",x = 2) == \"-2222222222\"\n assert candidate(n = \"1234567890\",x = 0) == \"12345678900\"\n assert candidate(n = \"-1\",x = 1) == \"-11\"\n assert candidate(n = \"1000000000\",x = 9) == \"91000000000\"\n assert candidate(n = \"123123123\",x = 3) == \"3123123123\"\n assert candidate(n = \"-101010101\",x = 5) == \"-1010101015\"\n assert candidate(n = \"999999999\",x = 1) == \"9999999991\"\n assert candidate(n = \"500000000\",x = 5) == \"5500000000\"\n assert candidate(n = \"555555555\",x = 5) == \"5555555555\"\n assert candidate(n = \"-595959595\",x = 5) == \"-5595959595\"\n assert candidate(n = \"-123456789\",x = 3) == \"-1233456789\"\n assert candidate(n = \"222222222\",x = 1) == \"2222222221\"\n assert candidate(n = \"876543210\",x = 0) == \"8765432100\"\n assert candidate(n = \"192837465\",x = 4) == \"4192837465\"\n assert candidate(n = \"-900000000\",x = 1) == \"-1900000000\"\n assert candidate(n = \"-999999999\",x = 9) == \"-9999999999\"\n assert candidate(n = \"-9876543210\",x = 1) == \"-19876543210\"\n assert candidate(n = \"-100000000\",x = 0) == \"-0100000000\"\n assert candidate(n = \"9876543210\",x = 9) == \"99876543210\"\n assert candidate(n = \"-5432109876\",x = 9) == \"-54321098769\"\n assert candidate(n = \"-123456789\",x = 4) == \"-1234456789\"\n assert candidate(n = \"-199999999\",x = 9) == \"-1999999999\"\n assert candidate(n = \"-101010101\",x = 0) == \"-0101010101\"\n assert candidate(n = \"-123123123\",x = 5) == \"-1231231235\"\n assert candidate(n = \"199999999\",x = 9) == \"9199999999\"\n assert candidate(n = \"123456789\",x = 9) == \"9123456789\"\n assert candidate(n = \"111111111\",x = 2) == \"2111111111\"\n assert candidate(n = \"53284769\",x = 5) == \"553284769\"\n assert candidate(n = \"9876543210\",x = 8) == \"98876543210\"\n assert candidate(n = \"1999999999\",x = 0) == \"19999999990\"\n assert candidate(n = \"9\",x = 1) == \"91\"\n assert candidate(n = \"987654321\",x = 9) == \"9987654321\"\n assert candidate(n = \"111000111\",x = 1) == \"1111000111\"\n assert candidate(n = \"-1000000000\",x = 9) == \"-10000000009\"\n assert candidate(n = \"-123456789\",x = 1) == \"-1123456789\"\n assert candidate(n = \"54321\",x = 3) == \"543321\"\n assert candidate(n = \"-9999999999\",x = 5) == \"-59999999999\"\n assert candidate(n = \"505050505\",x = 5) == \"5505050505\"\n assert candidate(n = \"121212121\",x = 3) == \"3121212121\"\n assert candidate(n = \"123454321\",x = 5) == \"5123454321\"\n assert candidate(n = \"333333333\",x = 3) == \"3333333333\"\n assert candidate(n = \"987654321\",x = 8) == \"9887654321\"\n assert candidate(n = \"11111111111111111111\",x = 2) == \"211111111111111111111\"\n assert candidate(n = \"-987654321\",x = 1) == \"-1987654321\"\n assert candidate(n = \"-500000000\",x = 5) == \"-5000000005\"\n assert candidate(n = \"-53284769\",x = 5) == \"-532584769\"\n assert candidate(n = \"101010101\",x = 5) == \"5101010101\"\n assert candidate(n = \"-9876543210\",x = 5) == \"-59876543210\"\n assert candidate(n = \"666666666\",x = 5) == \"6666666665\"\n assert candidate(n = \"111111111\",x = 1) == \"1111111111\"\n assert candidate(n = \"12345678901234567890\",x = 5) == \"512345678901234567890\"\n assert candidate(n = \"987654321\",x = 6) == \"9876654321\"\n assert candidate(n = \"-123456789\",x = 9) == \"-1234567899\"\n assert candidate(n = \"123456789\",x = 1) == \"1234567891\"\n assert candidate(n = \"-555555555\",x = 6) == \"-5555555556\"\n assert candidate(n = \"-333333333\",x = 2) == \"-2333333333\"\n assert candidate(n = \"595959595\",x = 9) == \"9595959595\"\n assert candidate(n = \"-54321\",x = 6) == \"-543216\"\n assert candidate(n = \"987654321\",x = 7) == \"9877654321\"\n assert candidate(n = \"9\",x = 9) == \"99\"\n assert candidate(n = \"-86420\",x = 1) == \"-186420\"\n assert candidate(n = \"-111111111\",x = 9) == \"-1111111119\"\n assert candidate(n = \"-54321\",x = 3) == \"-354321\"\n assert candidate(n = \"-505050505\",x = 5) == \"-5050505055\"\n assert candidate(n = \"-1000000001\",x = 0) == \"-01000000001\"\n assert candidate(n = \"100000000\",x = 9) == \"9100000000\"\n assert candidate(n = \"-9876543210987654321\",x = 9) == \"-98765432109876543219\"\n assert candidate(n = \"333333333\",x = 4) == \"4333333333\"\n assert candidate(n = \"-2222222222\",x = 1) == \"-12222222222\"\n assert candidate(n = \"122222222\",x = 2) == \"2122222222\"\n assert candidate(n = \"123456789\",x = 3) == \"3123456789\"\n assert candidate(n = \"-321321321\",x = 2) == \"-2321321321\"\n assert candidate(n = \"1122334455\",x = 6) == \"61122334455\"\n assert candidate(n = \"123456789\",x = 6) == \"6123456789\"\n assert candidate(n = \"1111111111\",x = 1) == \"11111111111\"\n assert candidate(n = \"-999999999\",x = 1) == \"-1999999999\"\n assert candidate(n = \"-333333333\",x = 3) == \"-3333333333\"\n assert candidate(n = \"-1122334455\",x = 3) == \"-11223334455\"\n assert candidate(n = \"-9876543210\",x = 8) == \"-89876543210\"\n assert candidate(n = \"98765432109876543210\",x = 5) == \"987655432109876543210\"\n assert candidate(n = \"123456789\",x = 0) == \"1234567890\"\n assert candidate(n = \"-12345678901234567890\",x = 5) == \"-123455678901234567890\"\n assert candidate(n = \"1\",x = 9) == \"91\"\n assert candidate(n = \"-2000000000\",x = 1) == \"-12000000000\"\n assert candidate(n = \"11111\",x = 1) == \"111111\"\n assert candidate(n = \"100000000\",x = 1) == \"1100000000\"\n assert candidate(n = \"1234567890\",x = 5) == \"51234567890\"\n assert candidate(n = \"-999000999\",x = 9) == \"-9990009999\"\n assert candidate(n = \"1111111111\",x = 2) == \"21111111111\"\n assert candidate(n = \"-876543210\",x = 0) == \"-0876543210\"\n assert candidate(n = \"-99999\",x = 1) == \"-199999\"\n assert candidate(n = \"-10000\",x = 0) == \"-010000\"\n assert candidate(n = \"555555555\",x = 6) == \"6555555555\"\n assert candidate(n = \"-98765432109876543210\",x = 5) == \"-598765432109876543210\"\n assert candidate(n = \"1999999999\",x = 2) == \"21999999999\"\n assert candidate(n = \"123123123\",x = 4) == \"4123123123\"\n assert candidate(n = \"86420\",x = 9) == \"986420\"\n assert candidate(n = \"-1\",x = 9) == \"-19\"\n assert candidate(n = \"-1000000000\",x = 1) == \"-10000000001\"\n assert candidate(n = \"989898989\",x = 7) == \"9898989897\"\n assert candidate(n = \"-222222222\",x = 3) == \"-2222222223\"\n assert candidate(n = \"192837465\",x = 8) == \"8192837465\"\n assert candidate(n = \"33333\",x = 3) == \"333333\"\n assert candidate(n = \"1000000000\",x = 1) == \"11000000000\"\n assert candidate(n = \"123456789\",x = 4) == \"4123456789\"\n assert candidate(n = \"-123456789\",x = 8) == \"-1234567889\"\n assert candidate(n = \"999999999\",x = 9) == \"9999999999\"\n"}, "metadata": {"canonical_parameter_names": ["n", "x"], "leetcode_dataset_entry_point": "Solution().maxValue", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string maxValue(string n, int x) {", "container": "Solution", "callable": "maxValue", "parameters": [{"name": "n", "type": "string"}, {"name": "x", "type": "int"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1882, "task_id": "process-tasks-using-servers", "difficulty": "Medium", "problem_description": "You are given two 0-indexed integer arrays servers and tasks of lengths n​​​​​​ and m​​​​​​ respectively. servers[i] is the weight of the i​​​​​​th​​​​ server, and tasks[j] is the time needed to process the j​​​​​​th​​​​ task in seconds.\nTasks are assigned to the servers using a task queue. Initially, all servers are free, and the queue is empty.\nAt second j, the jth task is inserted into the queue (starting with the 0th task being inserted at second 0). As long as there are free servers and the queue is not empty, the task in the front of the queue will be assigned to a free server with the smallest weight, and in case of a tie, it is assigned to a free server with the smallest index.\nIf there are no free servers and the queue is not empty, we wait until a server becomes free and immediately assign the next task. If multiple servers become free at the same time, then multiple tasks from the queue will be assigned in order of insertion following the weight and index priorities above.\nA server that is assigned task j at second t will be free again at second t + tasks[j].\nBuild an array ans​​​​ of length m, where ans[j] is the index of the server the j​​​​​​th task will be assigned to.\nReturn the array ans​​​​.\n \nExample 1:\n\nInput: servers = [3,3,2], tasks = [1,2,3,2,1,2]\nOutput: [2,2,0,2,1,2]\nExplanation: Events in chronological order go as follows:\n- At second 0, task 0 is added and processed using server 2 until second 1.\n- At second 1, server 2 becomes free. Task 1 is added and processed using server 2 until second 3.\n- At second 2, task 2 is added and processed using server 0 until second 5.\n- At second 3, server 2 becomes free. Task 3 is added and processed using server 2 until second 5.\n- At second 4, task 4 is added and processed using server 1 until second 5.\n- At second 5, all servers become free. Task 5 is added and processed using server 2 until second 7.\nExample 2:\n\nInput: servers = [5,1,4,3,2], tasks = [2,1,2,4,5,2,1]\nOutput: [1,4,1,4,1,3,2]\nExplanation: Events in chronological order go as follows: \n- At second 0, task 0 is added and processed using server 1 until second 2.\n- At second 1, task 1 is added and processed using server 4 until second 2.\n- At second 2, servers 1 and 4 become free. Task 2 is added and processed using server 1 until second 4. \n- At second 3, task 3 is added and processed using server 4 until second 7.\n- At second 4, server 1 becomes free. Task 4 is added and processed using server 1 until second 9. \n- At second 5, task 5 is added and processed using server 3 until second 7.\n- At second 6, task 6 is added and processed using server 2 until second 7.\n\n \nConstraints:\n\nservers.length == n\ntasks.length == m\n1 <= n, m <= 2 * 105\n1 <= servers[i], tasks[j] <= 2 * 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(servers = [3, 3, 2],tasks = [1, 2, 3, 2, 1, 2]) == [2, 2, 0, 2, 1, 2]\n assert candidate(servers = [1, 1, 1],tasks = [10, 20, 30, 40, 50]) == [0, 1, 2, 0, 1]\n assert candidate(servers = [5, 1, 4, 3, 2],tasks = [2, 1, 2, 4, 5, 2, 1]) == [1, 4, 1, 4, 1, 3, 2]\n assert candidate(servers = [2, 2, 2, 2],tasks = [1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [2, 2, 2, 2],tasks = [1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0]\n assert candidate(servers = [1],tasks = [10]) == [0]\n assert candidate(servers = [10, 20, 30],tasks = [3, 2, 1]) == [0, 1, 2]\n assert candidate(servers = [1, 2, 3],tasks = [3, 2, 1]) == [0, 1, 2]\n assert candidate(servers = [1, 2, 3, 4, 5],tasks = [5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4]\n assert candidate(servers = [10, 20, 30],tasks = [1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0]\n assert candidate(servers = [5, 4, 3, 2, 1],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [4, 4, 3, 4, 2, 3, 1, 4, 0, 2]\n assert candidate(servers = [10, 20, 30],tasks = [1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0]\n assert candidate(servers = [2, 2, 2, 2],tasks = [1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [1, 1, 1],tasks = [10, 10, 10, 10, 10]) == [0, 1, 2, 0, 1]\n assert candidate(servers = [1, 2, 3, 4, 5],tasks = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4]\n assert candidate(servers = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7]\n assert candidate(servers = [5, 4, 3, 2, 1],tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [4, 3, 2, 1, 0, 4, 3, 2, 1, 0, 4, 3, 2, 1, 0]\n assert candidate(servers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 5, 1, 3, 0, 5, 1, 4, 2, 3, 0, 3, 0, 5, 1, 3, 0, 4, 2]\n assert candidate(servers = [10, 15, 20, 25, 30],tasks = [5, 10, 15, 20, 25, 30, 35, 40]) == [0, 1, 2, 3, 4, 0, 1, 2]\n assert candidate(servers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0]\n assert candidate(servers = [10, 20, 30, 40, 50],tasks = [5, 15, 25, 35, 45, 55, 65]) == [0, 1, 2, 3, 4, 0, 1]\n assert candidate(servers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(servers = [1, 1, 1, 1, 1],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7, 0, 8, 4, 9, 2]\n assert candidate(servers = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],tasks = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 3, 6, 0, 9, 2, 4, 8, 10, 7, 5]\n assert candidate(servers = [3, 1, 2],tasks = [2, 3, 1, 2, 1, 3, 2, 1, 2, 3, 1, 2, 3]) == [1, 2, 1, 1, 2, 1, 2, 0, 1, 2, 1, 1, 2]\n assert candidate(servers = [3, 5, 2, 7, 6],tasks = [2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 0, 2, 1, 0, 4, 2, 3, 1]\n assert candidate(servers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(servers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],tasks = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9, 9, 8, 9, 8, 9, 7, 8]\n assert candidate(servers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],tasks = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(servers = [5, 4, 3, 2, 1],tasks = [2, 3, 4, 5, 1, 2, 3, 4, 5]) == [4, 3, 4, 2, 3, 3, 4, 3, 2]\n assert candidate(servers = [100, 200, 150, 50],tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [3, 0, 2, 1, 3, 0, 2, 1, 3, 0, 2, 1, 3, 0, 2]\n assert candidate(servers = [100, 100, 100, 100, 100],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [20, 10, 30, 40, 50],tasks = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [1, 0, 2, 3, 4, 1, 0, 2, 3, 4]\n assert candidate(servers = [2, 3, 1, 4, 5, 2, 3, 1, 4, 5],tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [2, 7, 0, 5, 1, 6, 3, 8, 4, 9, 2, 7, 0, 5, 1, 6, 3, 8, 4, 9]\n assert candidate(servers = [15, 25, 5, 20, 10],tasks = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [2, 4, 0, 3, 1, 2, 4, 0, 3, 1, 2, 4, 0, 3, 1, 2, 4, 0, 3, 1]\n assert candidate(servers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(servers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [2, 3, 5, 7, 11],tasks = [30, 10, 20, 40, 50, 15, 25, 35, 45, 55]) == [0, 1, 2, 3, 4, 1, 2, 1, 0, 3]\n assert candidate(servers = [7, 5, 3, 1],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [3, 3, 2, 3, 1, 2, 0, 3, 1, 2, 0, 3, 1, 2, 0]\n assert candidate(servers = [5, 3, 8, 6],tasks = [2, 6, 4, 1, 7, 3, 5]) == [1, 0, 1, 3, 3, 2, 1]\n assert candidate(servers = [3, 2, 1, 4, 5],tasks = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [2, 1, 0, 3, 4, 2, 1, 0, 3, 4, 2, 1, 0, 3, 4]\n assert candidate(servers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(servers = [10, 20, 30, 40, 50],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7, 0, 8, 4, 9, 2]\n assert candidate(servers = [10, 20, 30, 40, 50],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(servers = [5, 3, 8, 6, 2],tasks = [2, 4, 1, 5, 7, 3, 6, 8, 9, 10]) == [4, 1, 4, 4, 0, 1, 3, 2, 4, 1]\n assert candidate(servers = [5, 1, 4, 3, 2, 6],tasks = [2, 1, 2, 4, 5, 2, 1, 3, 5, 7, 9, 11, 13, 15]) == [1, 4, 1, 4, 1, 3, 2, 4, 3, 1, 4, 2, 0, 3]\n assert candidate(servers = [10, 20, 30, 40, 50],tasks = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10]) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4]\n assert candidate(servers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(servers = [7, 1, 1, 1, 1, 1],tasks = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]\n assert candidate(servers = [23, 45, 12, 67, 89, 34, 56, 78, 90, 10],tasks = [30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == [9, 2, 0, 5, 1, 6, 3, 7, 4, 8]\n assert candidate(servers = [100, 200, 300, 400, 500],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [10, 20, 30, 40, 50],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [3, 3, 3, 3, 3],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7, 0, 8, 4, 9, 2]\n assert candidate(servers = [100, 200, 300, 400, 500],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [3, 3, 3, 3, 3],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [10, 10, 10, 10],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 2, 1, 3, 0, 2, 1, 3, 0, 2, 1, 3, 0]\n assert candidate(servers = [100, 200, 300, 400, 500],tasks = [500, 400, 300, 200, 100, 500, 400, 300, 200, 100]) == [0, 1, 2, 3, 4, 4, 3, 2, 1, 0]\n assert candidate(servers = [2, 1, 3, 4],tasks = [4, 3, 2, 1, 5, 6, 7, 8, 9, 10]) == [1, 0, 2, 3, 1, 0, 2, 3, 1, 0]\n assert candidate(servers = [7, 8, 9, 10],tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 0, 1, 2, 3, 3, 2]\n assert candidate(servers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(servers = [5, 5, 5, 5, 5],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [3, 5, 1, 4, 2],tasks = [15, 10, 5, 20, 25, 30, 5, 10, 15, 20]) == [2, 4, 0, 3, 1, 0, 4, 2, 4, 3]\n assert candidate(servers = [7, 8, 9, 10, 11],tasks = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 4]\n assert candidate(servers = [1, 10, 1, 10, 1, 10],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [1, 1, 1, 1, 1],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [5, 10, 15, 20, 25],tasks = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4]\n assert candidate(servers = [10, 20, 30, 40, 50],tasks = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4]\n assert candidate(servers = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7]\n assert candidate(servers = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],tasks = [29, 23, 19, 17, 13, 11, 7, 5, 3, 2]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(servers = [3, 2, 1, 4, 5],tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [2, 1, 0, 3, 4, 2, 1, 0, 3, 4, 2, 1, 0, 3, 4]\n assert candidate(servers = [5, 3, 8, 6, 2],tasks = [2, 5, 7, 4, 9, 1, 3, 6, 8, 10]) == [4, 1, 4, 0, 3, 2, 1, 0, 2, 4]\n assert candidate(servers = [7, 11, 13, 17, 19, 23, 29],tasks = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == [0, 1, 0, 2, 1, 3, 4, 0, 5, 6, 2, 1, 3, 4, 0, 5, 6, 2, 1, 3]\n assert candidate(servers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [9, 9, 8, 9, 7, 8, 6, 9, 5, 7]\n assert candidate(servers = [1, 2, 3, 4, 5],tasks = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4]\n assert candidate(servers = [3, 2, 1],tasks = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == [2, 1, 0, 2, 1, 0, 2, 1, 0, 2]\n assert candidate(servers = [10, 20, 15, 25, 30],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 0, 2, 0, 1, 2, 3, 0, 4, 1, 2, 3, 0, 4, 1]\n assert candidate(servers = [5, 3, 8, 6, 2],tasks = [4, 3, 6, 2, 5, 4, 3, 7]) == [4, 1, 0, 3, 4, 1, 3, 2]\n assert candidate(servers = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7, 0, 8, 4, 9, 2]\n assert candidate(servers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7, 0, 8, 4, 9, 2]\n assert candidate(servers = [100, 200, 300, 400, 500],tasks = [500, 400, 300, 200, 100, 500, 400, 300, 200, 100]) == [0, 1, 2, 3, 4, 4, 3, 2, 1, 0]\n assert candidate(servers = [10, 5, 8, 3],tasks = [2, 8, 10, 3, 5, 7, 6, 4]) == [3, 1, 3, 2, 0, 2, 1, 0]\n assert candidate(servers = [5, 3, 7, 1, 4],tasks = [10, 5, 3, 8, 2, 1, 9, 6]) == [3, 1, 4, 0, 2, 4, 1, 4]\n assert candidate(servers = [1, 1, 1, 1, 1],tasks = [2, 3, 2, 4, 5, 2, 3, 1, 4, 5]) == [0, 1, 0, 2, 0, 1, 3, 1, 1, 0]\n assert candidate(servers = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [5, 5, 5, 5, 5],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [7, 7, 7, 7, 7],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [15, 10, 20, 5, 25],tasks = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42]) == [3, 1, 0, 3, 2, 4, 1, 0, 3, 2, 4, 1, 0, 3]\n assert candidate(servers = [1, 2, 3, 4, 5],tasks = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [0, 0, 1, 0, 2, 1, 1, 0, 1, 2]\n assert candidate(servers = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1],tasks = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [1, 3, 5, 7, 9, 1, 3, 5, 7, 9]\n assert candidate(servers = [2, 2, 2, 2],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(servers = [1, 3, 2],tasks = [3, 2, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1, 3, 2, 1, 2, 3, 1]) == [0, 2, 1, 0, 2, 0, 0, 2, 1, 0, 2, 0, 0, 2, 1, 0, 2, 0, 0, 2, 1, 0, 2, 0, 0, 2, 1, 0, 2, 0, 0, 2, 1, 0, 2, 0, 0, 2, 1, 0, 2, 0]\n assert candidate(servers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7, 0, 8, 4, 9, 2]\n assert candidate(servers = [10, 1, 10, 1, 10, 1],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 1, 3, 1, 5, 3, 0, 1, 2, 5, 4, 3, 0, 1, 2]\n assert candidate(servers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 5, 1, 6, 3, 7, 0, 8, 4, 9, 2]\n assert candidate(servers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(servers = [50, 25, 75, 100, 125],tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [1, 0, 2, 3, 4, 1, 0, 2, 3, 4, 1, 0, 2, 3, 4]\n assert candidate(servers = [2, 4, 6, 8, 10],tasks = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [0, 0, 1, 2, 0, 3, 4, 1, 2, 0]\n assert candidate(servers = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],tasks = [97, 89, 83, 79, 73, 71, 67, 61, 59, 53, 47, 43, 41, 37, 31, 29, 23, 19, 17, 13, 11, 7, 5, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 23]\n assert candidate(servers = [1, 1, 1, 1, 1],tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [0, 0, 1, 0, 2, 1, 3, 0, 4, 2, 1, 3, 0, 4, 2]\n assert candidate(servers = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],tasks = [8, 9, 7, 6, 5, 4, 3, 2, 1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 3, 6, 0, 9, 2, 4, 8, 1, 1, 1, 3, 6, 0, 9, 2, 4, 8, 10, 7]\n"}, "metadata": {"canonical_parameter_names": ["servers", "tasks"], "leetcode_dataset_entry_point": "Solution().assignTasks", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector assignTasks(vector& servers, vector& tasks) {", "container": "Solution", "callable": "assignTasks", "parameters": [{"name": "servers", "type": "vector&"}, {"name": "tasks", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1883, "task_id": "minimum-skips-to-arrive-at-meeting-on-time", "difficulty": "Hard", "problem_description": "You are given an integer hoursBefore, the number of hours you have to travel to your meeting. To arrive at your meeting, you have to travel through n roads. The road lengths are given as an integer array dist of length n, where dist[i] describes the length of the ith road in kilometers. In addition, you are given an integer speed, which is the speed (in km/h) you will travel at.\nAfter you travel road i, you must rest and wait for the next integer hour before you can begin traveling on the next road. Note that you do not have to rest after traveling the last road because you are already at the meeting.\n\nFor example, if traveling a road takes 1.4 hours, you must wait until the 2 hour mark before traveling the next road. If traveling a road takes exactly 2 hours, you do not need to wait.\n\nHowever, you are allowed to skip some rests to be able to arrive on time, meaning you do not need to wait for the next integer hour. Note that this means you may finish traveling future roads at different hour marks.\n\nFor example, suppose traveling the first road takes 1.4 hours and traveling the second road takes 0.6 hours. Skipping the rest after the first road will mean you finish traveling the second road right at the 2 hour mark, letting you start traveling the third road immediately.\n\nReturn the minimum number of skips required to arrive at the meeting on time, or -1 if it is impossible.\n \nExample 1:\n\nInput: dist = [1,3,2], speed = 4, hoursBefore = 2\nOutput: 1\nExplanation:\nWithout skipping any rests, you will arrive in (1/4 + 3/4) + (3/4 + 1/4) + (2/4) = 2.5 hours.\nYou can skip the first rest to arrive in ((1/4 + 0) + (3/4 + 0)) + (2/4) = 1.5 hours.\nNote that the second rest is shortened because you finish traveling the second road at an integer hour due to skipping the first rest.\n\nExample 2:\n\nInput: dist = [7,3,5,5], speed = 2, hoursBefore = 10\nOutput: 2\nExplanation:\nWithout skipping any rests, you will arrive in (7/2 + 1/2) + (3/2 + 1/2) + (5/2 + 1/2) + (5/2) = 11.5 hours.\nYou can skip the first and third rest to arrive in ((7/2 + 0) + (3/2 + 0)) + ((5/2 + 0) + (5/2)) = 10 hours.\n\nExample 3:\n\nInput: dist = [7,3,5,5], speed = 1, hoursBefore = 10\nOutput: -1\nExplanation: It is impossible to arrive at the meeting on time even if you skip all the rests.\n\n \nConstraints:\n\nn == dist.length\n1 <= n <= 1000\n1 <= dist[i] <= 105\n1 <= speed <= 106\n1 <= hoursBefore <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(dist = [10, 10, 10],speed = 5,hoursBefore = 6) == 0\n assert candidate(dist = [1, 1, 1, 1, 1],speed = 1,hoursBefore = 3) == -1\n assert candidate(dist = [5, 5, 5, 5, 5],speed = 10,hoursBefore = 2) == -1\n assert candidate(dist = [1, 1, 1, 1],speed = 1,hoursBefore = 4) == 0\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 10) == 0\n assert candidate(dist = [7, 3, 5, 5],speed = 1,hoursBefore = 10) == -1\n assert candidate(dist = [1, 2, 3, 4, 5],speed = 1,hoursBefore = 20) == 0\n assert candidate(dist = [1, 1, 1, 1, 1],speed = 1,hoursBefore = 4) == -1\n assert candidate(dist = [10, 10, 10],speed = 10,hoursBefore = 3) == 0\n assert candidate(dist = [5, 5, 5, 5, 5],speed = 5,hoursBefore = 5) == 0\n assert candidate(dist = [1, 1, 1, 1],speed = 1,hoursBefore = 3) == -1\n assert candidate(dist = [7, 3, 5, 5],speed = 2,hoursBefore = 10) == 2\n assert candidate(dist = [1, 3, 2],speed = 4,hoursBefore = 2) == 1\n assert candidate(dist = [100000, 100000, 100000],speed = 100000,hoursBefore = 3) == 0\n assert candidate(dist = [10, 10, 10],speed = 5,hoursBefore = 5) == -1\n assert candidate(dist = [5, 5, 5, 5, 5],speed = 10,hoursBefore = 3) == 2\n assert candidate(dist = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],speed = 2,hoursBefore = 15) == -1\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],speed = 15,hoursBefore = 15) == -1\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = 1000,hoursBefore = 5) == -1\n assert candidate(dist = [7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5, 7, 3, 5, 5],speed = 2,hoursBefore = 100) == -1\n assert candidate(dist = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],speed = 2,hoursBefore = 10) == -1\n assert candidate(dist = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],speed = 10000,hoursBefore = 99) == -1\n assert candidate(dist = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],speed = 5,hoursBefore = 20) == 8\n assert candidate(dist = [10, 20, 30, 40, 50],speed = 25,hoursBefore = 10) == 0\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],speed = 5,hoursBefore = 50) == -1\n assert candidate(dist = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],speed = 100000,hoursBefore = 9) == -1\n assert candidate(dist = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],speed = 10,hoursBefore = 40) == -1\n assert candidate(dist = [1, 2, 3, 4, 5],speed = 100,hoursBefore = 1) == 4\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = 3,hoursBefore = 100) == -1\n assert candidate(dist = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],speed = 100,hoursBefore = 20) == 7\n assert candidate(dist = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],speed = 2,hoursBefore = 100) == -1\n assert candidate(dist = [10, 20, 30, 40, 50],speed = 5,hoursBefore = 30) == 0\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],speed = 1,hoursBefore = 50) == -1\n assert candidate(dist = [10, 21, 30, 40, 50, 60, 70, 80, 90, 100],speed = 10,hoursBefore = 55) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],speed = 2,hoursBefore = 50) == -1\n assert candidate(dist = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999],speed = 100000,hoursBefore = 9) == -1\n assert candidate(dist = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],speed = 5,hoursBefore = 20) == -1\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = 5,hoursBefore = 35) == -1\n assert candidate(dist = [10, 20, 30, 40, 50],speed = 15,hoursBefore = 15) == 0\n assert candidate(dist = [100, 200, 300, 400, 500],speed = 100,hoursBefore = 10) == -1\n assert candidate(dist = [123, 456, 789, 101, 202, 303],speed = 100,hoursBefore = 15) == -1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 29) == -1\n assert candidate(dist = [1, 3, 2, 1, 3, 2, 1, 3, 2, 1],speed = 4,hoursBefore = 5) == 6\n assert candidate(dist = [3, 6, 9, 12, 15, 18, 21],speed = 5,hoursBefore = 15) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = 3,hoursBefore = 12) == -1\n assert candidate(dist = [5, 10, 15, 20, 25],speed = 5,hoursBefore = 10) == -1\n assert candidate(dist = [9, 8, 7, 6, 5, 4, 3, 2, 1],speed = 3,hoursBefore = 10) == -1\n assert candidate(dist = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],speed = 100,hoursBefore = 9) == -1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 15) == -1\n assert candidate(dist = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],speed = 2,hoursBefore = 30) == 10\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],speed = 1,hoursBefore = 105) == -1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 20) == 0\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 19) == -1\n assert candidate(dist = [7, 3, 5, 5, 3, 7, 5, 3, 5, 5, 3, 7, 5, 3, 5, 5, 3, 7, 5, 3, 5, 5, 3, 7, 5, 3, 5, 5, 3, 7, 5, 3, 5, 5],speed = 2,hoursBefore = 50) == -1\n assert candidate(dist = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],speed = 10,hoursBefore = 6) == 4\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 100) == -1\n assert candidate(dist = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],speed = 2,hoursBefore = 15) == -1\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],speed = 100,hoursBefore = 60) == -1\n assert candidate(dist = [7, 3, 5, 5, 7, 3, 5, 5],speed = 2,hoursBefore = 15) == -1\n assert candidate(dist = [100, 200, 300, 400],speed = 100,hoursBefore = 8) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = 5,hoursBefore = 12) == 4\n assert candidate(dist = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980],speed = 99999,hoursBefore = 10) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],speed = 3,hoursBefore = 20) == -1\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = 1,hoursBefore = 1000) == 0\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = 25,hoursBefore = 20) == -1\n assert candidate(dist = [9, 7, 5, 3, 1],speed = 4,hoursBefore = 5) == -1\n assert candidate(dist = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],speed = 7,hoursBefore = 25) == -1\n assert candidate(dist = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],speed = 10,hoursBefore = 13) == -1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 25) == -1\n assert candidate(dist = [5, 10, 15, 20, 25, 30, 35],speed = 7,hoursBefore = 20) == 5\n assert candidate(dist = [10000, 20000, 30000, 40000, 50000],speed = 10000,hoursBefore = 15) == 0\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = 15,hoursBefore = 30) == -1\n assert candidate(dist = [3, 8, 2, 7, 5],speed = 4,hoursBefore = 10) == 0\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = 100,hoursBefore = 50) == -1\n assert candidate(dist = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000],speed = 100000,hoursBefore = 5) == 5\n assert candidate(dist = [9, 8, 7, 6, 5, 4, 3, 2, 1],speed = 5,hoursBefore = 15) == 0\n assert candidate(dist = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],speed = 3,hoursBefore = 30) == 0\n assert candidate(dist = [1, 3, 2, 4, 5],speed = 3,hoursBefore = 5) == 3\n assert candidate(dist = [999, 1000, 1001, 1002, 1003],speed = 1,hoursBefore = 5000) == -1\n assert candidate(dist = [100000, 100000, 100000, 100000],speed = 100000,hoursBefore = 4) == 0\n assert candidate(dist = [100000, 100000, 100000, 100000, 100000],speed = 100000,hoursBefore = 4) == -1\n assert candidate(dist = [1000, 2000, 3000, 4000],speed = 1000,hoursBefore = 10) == 0\n assert candidate(dist = [100000, 100000, 100000, 100000, 100000],speed = 100000,hoursBefore = 5) == 0\n assert candidate(dist = [100000, 90000, 80000, 70000, 60000],speed = 50000,hoursBefore = 10) == 0\n assert candidate(dist = [10, 20, 30, 40, 50],speed = 15,hoursBefore = 12) == 0\n assert candidate(dist = [100000, 100000, 100000],speed = 100000,hoursBefore = 2) == -1\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = 15,hoursBefore = 25) == -1\n assert candidate(dist = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],speed = 1,hoursBefore = 100) == -1\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = 50,hoursBefore = 35) == -1\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = 100,hoursBefore = 30) == -1\n assert candidate(dist = [5, 10, 15, 20, 25],speed = 5,hoursBefore = 15) == 0\n assert candidate(dist = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],speed = 3,hoursBefore = 25) == 0\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = 100,hoursBefore = 45) == -1\n assert candidate(dist = [99999, 99998, 99997, 99996],speed = 100000,hoursBefore = 399990) == 0\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 10) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],speed = 5,hoursBefore = 25) == -1\n assert candidate(dist = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9],speed = 9,hoursBefore = 8) == -1\n assert candidate(dist = [50, 100, 150, 200, 250],speed = 50,hoursBefore = 10) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = 10,hoursBefore = 5) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],speed = 3,hoursBefore = 25) == -1\n assert candidate(dist = [5, 10, 15, 20, 25],speed = 5,hoursBefore = 14) == -1\n assert candidate(dist = [100, 200, 300, 400, 500],speed = 1,hoursBefore = 1500) == 0\n assert candidate(dist = [5, 4, 3, 2, 1],speed = 1,hoursBefore = 15) == 0\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = 1,hoursBefore = 20) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = 2,hoursBefore = 15) == -1\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = 5,hoursBefore = 10) == -1\n assert candidate(dist = [5, 15, 25, 35, 45],speed = 10,hoursBefore = 12) == -1\n assert candidate(dist = [100, 200, 300, 400, 500],speed = 50,hoursBefore = 25) == -1\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = 500,hoursBefore = 12) == 4\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],speed = 30,hoursBefore = 35) == -1\n assert candidate(dist = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200],speed = 50,hoursBefore = 20) == -1\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = 100,hoursBefore = 55) == 0\n assert candidate(dist = [1000, 2000, 3000, 4000, 5000],speed = 1000,hoursBefore = 20) == 0\n assert candidate(dist = [1000, 2000, 3000, 4000, 5000],speed = 1000,hoursBefore = 15) == 0\n"}, "metadata": {"canonical_parameter_names": ["dist", "speed", "hoursBefore"], "leetcode_dataset_entry_point": "Solution().minSkips", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minSkips(vector& dist, int speed, int hoursBefore) {", "container": "Solution", "callable": "minSkips", "parameters": [{"name": "dist", "type": "vector&"}, {"name": "speed", "type": "int"}, {"name": "hoursBefore", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1884, "task_id": "egg-drop-with-2-eggs-and-n-floors", "difficulty": "Medium", "problem_description": "You are given two identical eggs and you have access to a building with n floors labeled from 1 to n.\nYou know that there exists a floor f where 0 <= f <= n such that any egg dropped at a floor higher than f will break, and any egg dropped at or below floor f will not break.\nIn each move, you may take an unbroken egg and drop it from any floor x (where 1 <= x <= n). If the egg breaks, you can no longer use it. However, if the egg does not break, you may reuse it in future moves.\nReturn the minimum number of moves that you need to determine with certainty what the value of f is.\n \nExample 1:\n\nInput: n = 2\nOutput: 2\nExplanation: We can drop the first egg from floor 1 and the second egg from floor 2.\nIf the first egg breaks, we know that f = 0.\nIf the second egg breaks but the first egg didn't, we know that f = 1.\nOtherwise, if both eggs survive, we know that f = 2.\n\nExample 2:\n\nInput: n = 100\nOutput: 14\nExplanation: One optimal strategy is:\n- Drop the 1st egg at floor 9. If it breaks, we know f is between 0 and 8. Drop the 2nd egg starting from floor 1 and going up one at a time to find f within 8 more drops. Total drops is 1 + 8 = 9.\n- If the 1st egg does not break, drop the 1st egg again at floor 22. If it breaks, we know f is between 9 and 21. Drop the 2nd egg starting from floor 10 and going up one at a time to find f within 12 more drops. Total drops is 2 + 12 = 14.\n- If the 1st egg does not break again, follow a similar process dropping the 1st egg from floors 34, 45, 55, 64, 72, 79, 85, 90, 94, 97, 99, and 100.\nRegardless of the outcome, it takes at most 14 drops to determine f.\n\n \nConstraints:\n\n1 <= n <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 8) == 4\n assert candidate(n = 1000) == 45\n assert candidate(n = 5) == 3\n assert candidate(n = 81) == 13\n assert candidate(n = 999) == 45\n assert candidate(n = 15) == 5\n assert candidate(n = 64) == 11\n assert candidate(n = 450) == 30\n assert candidate(n = 600) == 35\n assert candidate(n = 6) == 3\n assert candidate(n = 2) == 2\n assert candidate(n = 100) == 14\n assert candidate(n = 500) == 32\n assert candidate(n = 50) == 10\n assert candidate(n = 1) == 1\n assert candidate(n = 10) == 4\n assert candidate(n = 300) == 24\n assert candidate(n = 990) == 44\n assert candidate(n = 850) == 41\n assert candidate(n = 125) == 16\n assert candidate(n = 900) == 42\n assert candidate(n = 995) == 45\n assert candidate(n = 505) == 32\n assert candidate(n = 650) == 36\n assert candidate(n = 550) == 33\n assert candidate(n = 460) == 30\n assert candidate(n = 99) == 14\n assert candidate(n = 501) == 32\n assert candidate(n = 250) == 22\n assert candidate(n = 75) == 12\n assert candidate(n = 997) == 45\n assert candidate(n = 925) == 43\n assert candidate(n = 504) == 32\n assert candidate(n = 350) == 26\n assert candidate(n = 503) == 32\n assert candidate(n = 150) == 17\n assert candidate(n = 800) == 40\n assert candidate(n = 200) == 20\n assert candidate(n = 400) == 28\n assert candidate(n = 750) == 39\n assert candidate(n = 502) == 32\n assert candidate(n = 950) == 44\n assert candidate(n = 700) == 37\n assert candidate(n = 366) == 27\n assert candidate(n = 998) == 45\n assert candidate(n = 25) == 7\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().twoEggDrop", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int twoEggDrop(int n) {", "container": "Solution", "callable": "twoEggDrop", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1886, "task_id": "determine-whether-matrix-can-be-obtained-by-rotation", "difficulty": "Easy", "problem_description": "Given two n x n binary matrices mat and target, return true if it is possible to make mat equal to target by rotating mat in 90-degree increments, or false otherwise.\n \nExample 1:\n\n\nInput: mat = [[0,1],[1,0]], target = [[1,0],[0,1]]\nOutput: true\nExplanation: We can rotate mat 90 degrees clockwise to make mat equal target.\n\nExample 2:\n\n\nInput: mat = [[0,1],[1,1]], target = [[1,0],[0,1]]\nOutput: false\nExplanation: It is impossible to make mat equal to target by rotating mat.\n\nExample 3:\n\n\nInput: mat = [[0,0,0],[0,1,0],[1,1,1]], target = [[1,1,1],[0,1,0],[0,0,0]]\nOutput: true\nExplanation: We can rotate mat 90 degrees clockwise two times to make mat equal target.\n\n \nConstraints:\n\nn == mat.length == target.length\nn == mat[i].length == target[i].length\n1 <= n <= 10\nmat[i][j] and target[i][j] are either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1, 0, 0], [0, 1, 0], [0, 0, 1]],target = [[0, 0, 1], [0, 1, 0], [1, 0, 0]]) == True\n assert candidate(mat = [[0, 1], [1, 0]],target = [[1, 0], [0, 1]]) == True\n assert candidate(mat = [[1, 1], [0, 0]],target = [[0, 1], [0, 1]]) == True\n assert candidate(mat = [[1, 0], [0, 1]],target = [[0, 1], [1, 0]]) == True\n assert candidate(mat = [[1, 1, 0], [0, 1, 0], [0, 1, 1]],target = [[0, 0, 1], [0, 1, 0], [1, 1, 0]]) == False\n assert candidate(mat = [[0, 1], [1, 1]],target = [[1, 0], [0, 1]]) == False\n assert candidate(mat = [[0, 0, 0], [0, 1, 0], [1, 1, 1]],target = [[1, 1, 1], [0, 1, 0], [0, 0, 0]]) == True\n assert candidate(mat = [[1, 1, 0], [0, 0, 0], [0, 1, 1]],target = [[0, 0, 0], [0, 1, 1], [1, 1, 0]]) == False\n assert candidate(mat = [[1, 1, 0, 0], [1, 0, 0, 1], [0, 1, 1, 0], [0, 0, 1, 1]],target = [[0, 0, 1, 1], [0, 1, 1, 0], [1, 0, 0, 1], [1, 1, 0, 0]]) == False\n assert candidate(mat = [[1, 1], [0, 0]],target = [[0, 0], [1, 1]]) == True\n assert candidate(mat = [[1, 1, 1, 1], [1, 0, 0, 0], [1, 0, 0, 0], [1, 1, 1, 1]],target = [[1, 1, 1, 1], [1, 0, 0, 0], [1, 0, 0, 0], [1, 1, 1, 1]]) == True\n assert candidate(mat = [[1, 1, 1, 0, 0], [1, 0, 0, 1, 1], [1, 0, 0, 1, 1], [0, 1, 1, 0, 0], [0, 0, 0, 0, 1]],target = [[0, 0, 0, 0, 1], [0, 1, 1, 0, 0], [0, 1, 1, 0, 0], [1, 0, 0, 1, 1], [1, 1, 1, 0, 0]]) == False\n assert candidate(mat = [[1, 1, 1, 0], [1, 0, 0, 1], [1, 0, 0, 1], [0, 1, 1, 1]],target = [[1, 1, 0, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 0, 1]]) == False\n assert candidate(mat = [[1, 1, 1, 0, 0], [1, 0, 0, 0, 1], [1, 0, 0, 1, 0], [1, 0, 1, 0, 0], [1, 1, 0, 0, 0]],target = [[0, 0, 0, 1, 1], [0, 0, 1, 0, 1], [0, 1, 0, 0, 1], [0, 0, 0, 0, 1], [0, 0, 0, 1, 1]]) == False\n assert candidate(mat = [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]],target = [[0, 0, 1, 1], [0, 0, 1, 1], [1, 1, 0, 0], [1, 1, 0, 0]]) == True\n assert candidate(mat = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]],target = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == True\n assert candidate(mat = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]],target = [[0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0], [1, 1, 1, 1]]) == False\n assert candidate(mat = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]],target = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == True\n assert candidate(mat = [[1, 1, 0, 0], [0, 0, 1, 1], [0, 1, 0, 1], [1, 0, 1, 0]],target = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]]) == False\n assert candidate(mat = [[0, 1, 1, 1, 1], [1, 0, 0, 0, 0], [1, 0, 1, 0, 1], [1, 0, 0, 1, 0], [0, 1, 1, 1, 0]],target = [[0, 1, 1, 1, 0], [1, 0, 0, 1, 0], [1, 0, 1, 0, 1], [0, 0, 0, 0, 1], [1, 1, 1, 1, 0]]) == False\n assert candidate(mat = [[0, 1, 1, 0], [1, 1, 0, 1], [1, 0, 1, 1], [0, 1, 1, 0]],target = [[0, 1, 1, 0], [1, 1, 0, 1], [1, 0, 1, 1], [0, 1, 1, 0]]) == True\n assert candidate(mat = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]],target = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == True\n assert candidate(mat = [[0, 1, 1, 0, 1], [1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [1, 0, 0, 1, 0], [0, 1, 1, 0, 1]],target = [[1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [1, 0, 0, 1, 0]]) == False\n assert candidate(mat = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]],target = [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == True\n assert candidate(mat = [[0, 1, 1, 0], [1, 1, 1, 1], [1, 0, 0, 1], [0, 1, 1, 0]],target = [[0, 1, 0, 1], [1, 1, 1, 1], [0, 0, 1, 0], [1, 1, 1, 1]]) == False\n assert candidate(mat = [[1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1]],target = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 1, 0], [0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0]]) == True\n assert candidate(mat = [[1, 0, 0, 1], [1, 0, 1, 0], [1, 0, 0, 1], [1, 0, 1, 0]],target = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]]) == False\n assert candidate(mat = [[1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [0, 1, 1, 0, 1], [0, 1, 1, 0, 1], [1, 0, 0, 1, 0]],target = [[0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0]]) == False\n assert candidate(mat = [[1, 1, 0, 1], [1, 0, 0, 1], [0, 0, 1, 1], [1, 0, 1, 0]],target = [[0, 1, 0, 1], [1, 1, 0, 0], [1, 0, 0, 1], [0, 1, 1, 0]]) == False\n assert candidate(mat = [[1, 1, 1], [1, 0, 1], [1, 1, 1]],target = [[1, 1, 1], [1, 0, 1], [1, 1, 1]]) == True\n assert candidate(mat = [[0, 0, 0, 1], [0, 1, 0, 0], [0, 0, 1, 0], [1, 0, 0, 0]],target = [[1, 0, 0, 0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 0, 1]]) == True\n assert candidate(mat = [[0, 0, 0, 1], [0, 0, 1, 1], [0, 1, 1, 1], [1, 1, 1, 1]],target = [[1, 1, 1, 1], [1, 1, 1, 0], [1, 1, 0, 0], [1, 0, 0, 0]]) == True\n assert candidate(mat = [[1, 0, 0, 0], [0, 1, 1, 1], [0, 1, 0, 1], [0, 1, 1, 0]],target = [[0, 1, 1, 0], [1, 0, 1, 0], [1, 1, 0, 1], [0, 0, 0, 1]]) == False\n assert candidate(mat = [[0, 1, 0, 0], [1, 1, 1, 0], [0, 1, 1, 1], [0, 0, 0, 1]],target = [[1, 0, 0, 0], [1, 1, 0, 1], [1, 1, 1, 0], [1, 0, 1, 0]]) == False\n assert candidate(mat = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]],target = [[1, 0, 1, 0, 1], [1, 0, 1, 0, 1], [1, 0, 1, 0, 1], [1, 0, 1, 0, 1], [1, 0, 1, 0, 1]]) == True\n assert candidate(mat = [[0, 0, 1, 1], [0, 1, 0, 0], [1, 0, 0, 1], [1, 1, 0, 0]],target = [[0, 1, 1, 0], [1, 0, 0, 1], [1, 0, 0, 1], [0, 1, 1, 0]]) == False\n assert candidate(mat = [[1, 1, 1, 1], [0, 0, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1]],target = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 0, 0, 0], [1, 1, 1, 1]]) == False\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]],target = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == True\n assert candidate(mat = [[1, 1, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 1, 1]],target = [[1, 0, 1, 0], [1, 0, 1, 0], [0, 1, 0, 1], [1, 1, 1, 0]]) == False\n assert candidate(mat = [[1, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1]],target = [[1, 0, 1, 0], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 1, 0]]) == False\n assert candidate(mat = [[1, 1, 1], [0, 0, 1], [0, 0, 1]],target = [[1, 1, 1], [1, 0, 0], [1, 0, 0]]) == True\n assert candidate(mat = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]],target = [[0, 0, 0, 0, 1], [0, 0, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 0, 0], [1, 0, 0, 0, 0]]) == True\n assert candidate(mat = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]],target = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]]) == False\n assert candidate(mat = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]],target = [[1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0]]) == False\n assert candidate(mat = [[1, 1, 0, 0, 0], [1, 0, 0, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [1, 1, 0, 0, 0]],target = [[0, 0, 0, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 1, 1]]) == False\n assert candidate(mat = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]],target = [[0, 0, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0]]) == False\n assert candidate(mat = [[0, 1, 0, 0], [1, 0, 0, 1], [0, 0, 1, 0], [1, 0, 0, 1]],target = [[1, 0, 0, 1], [0, 0, 1, 0], [1, 0, 0, 1], [0, 1, 0, 0]]) == False\n assert candidate(mat = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]],target = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == True\n assert candidate(mat = [[1, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 1]],target = [[0, 0, 0, 1], [0, 1, 1, 0], [0, 1, 1, 0], [1, 0, 0, 0]]) == True\n assert candidate(mat = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]],target = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]]) == False\n assert candidate(mat = [[1, 1, 1, 0, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 1], [0, 0, 0, 1, 1]],target = [[0, 0, 0, 1, 1], [0, 0, 0, 0, 1], [0, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 0, 0, 0]]) == False\n assert candidate(mat = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]],target = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == True\n assert candidate(mat = [[0, 0, 0, 1, 0], [0, 0, 1, 1, 0], [0, 1, 1, 0, 0], [1, 1, 0, 0, 0], [0, 1, 1, 0, 0]],target = [[0, 0, 1, 1, 0], [0, 0, 0, 1, 0], [0, 1, 1, 0, 0], [0, 0, 1, 1, 0], [0, 1, 1, 0, 0]]) == False\n assert candidate(mat = [[0, 1, 1, 0], [1, 1, 1, 1], [0, 0, 1, 0], [1, 1, 1, 1]],target = [[1, 0, 0, 0], [1, 1, 0, 1], [1, 1, 1, 1], [0, 0, 1, 1]]) == False\n assert candidate(mat = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]],target = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 1, 1]]) == True\n assert candidate(mat = [[0, 0, 1, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 1, 0]],target = [[0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0], [1, 1, 1, 1]]) == False\n assert candidate(mat = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]],target = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1]]) == False\n assert candidate(mat = [[0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [1, 0, 0, 0]],target = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) == True\n assert candidate(mat = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]],target = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == True\n assert candidate(mat = [[0, 1, 1, 1], [1, 1, 0, 0], [1, 0, 0, 1], [1, 1, 1, 0]],target = [[1, 1, 1, 0], [1, 0, 0, 1], [0, 0, 1, 1], [1, 1, 0, 0]]) == False\n assert candidate(mat = [[0, 0, 0, 0], [0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 1, 0]],target = [[0, 0, 1, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 0]]) == False\n assert candidate(mat = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]],target = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == False\n assert candidate(mat = [[1, 0, 1, 1], [0, 1, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0]],target = [[0, 0, 1, 1], [1, 1, 0, 0], [1, 0, 1, 1], [0, 1, 0, 0]]) == False\n assert candidate(mat = [[1, 1, 0, 1], [1, 0, 0, 1], [1, 0, 0, 1], [0, 1, 0, 1]],target = [[1, 0, 1, 0], [1, 0, 0, 1], [1, 0, 0, 1], [1, 1, 0, 1]]) == False\n assert candidate(mat = [[1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]],target = [[0, 0, 0, 0, 1], [0, 0, 0, 1, 0], [1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == False\n assert candidate(mat = [[1, 1, 1, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 1, 1], [1, 0, 0, 0, 0], [1, 0, 0, 0, 0]],target = [[0, 0, 0, 0, 1], [0, 0, 0, 0, 1], [1, 1, 1, 0, 0], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0]]) == False\n assert candidate(mat = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1]],target = [[0, 1, 0, 1], [1, 0, 1, 0], [0, 1, 0, 1], [1, 0, 1, 0]]) == True\n assert candidate(mat = [[1, 0, 0, 0, 1], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [1, 0, 0, 0, 1]],target = [[1, 0, 0, 0, 1], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [1, 0, 0, 0, 1]]) == False\n assert candidate(mat = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]],target = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == False\n assert candidate(mat = [[0, 1, 1, 0, 0], [1, 0, 1, 0, 1], [1, 1, 0, 1, 1], [0, 0, 1, 0, 0], [1, 0, 1, 0, 1]],target = [[0, 0, 1, 0, 0], [1, 1, 0, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0]]) == False\n assert candidate(mat = [[0, 0, 0, 1], [0, 0, 1, 1], [0, 1, 1, 0], [1, 1, 0, 0]],target = [[0, 0, 1, 0], [0, 1, 1, 0], [1, 1, 0, 0], [0, 0, 1, 0]]) == False\n assert candidate(mat = [[0, 0, 1, 1], [0, 0, 1, 1], [1, 1, 0, 0], [1, 1, 0, 0]],target = [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]]) == True\n assert candidate(mat = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 1, 1, 0], [0, 0, 1, 1, 0], [0, 0, 0, 0, 1]],target = [[0, 0, 0, 0, 1], [0, 0, 1, 1, 0], [0, 0, 1, 1, 0], [1, 1, 0, 0, 0], [1, 1, 0, 0, 0]]) == True\n assert candidate(mat = [[1, 0, 1], [0, 1, 0], [1, 0, 1]],target = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == True\n assert candidate(mat = [[0, 0, 1], [0, 1, 0], [1, 0, 0]],target = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]) == True\n assert candidate(mat = [[1, 0, 0, 1, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [1, 0, 0, 1, 0], [1, 1, 0, 0, 1]],target = [[1, 1, 0, 1, 1], [0, 0, 1, 0, 0], [1, 0, 0, 1, 0], [0, 1, 0, 1, 0], [1, 1, 0, 0, 1]]) == False\n assert candidate(mat = [[0, 1, 1, 1], [1, 0, 0, 0], [1, 0, 1, 0], [1, 0, 0, 1]],target = [[1, 0, 0, 1], [0, 1, 0, 1], [0, 0, 0, 1], [1, 1, 1, 0]]) == True\n assert candidate(mat = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]],target = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == True\n assert candidate(mat = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]],target = [[1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]) == True\n"}, "metadata": {"canonical_parameter_names": ["mat", "target"], "leetcode_dataset_entry_point": "Solution().findRotation", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool findRotation(vector>& mat, vector>& target) {", "container": "Solution", "callable": "findRotation", "parameters": [{"name": "mat", "type": "vector>&"}, {"name": "target", "type": "vector>&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1887, "task_id": "reduction-operations-to-make-the-array-elements-equal", "difficulty": "Medium", "problem_description": "Given an integer array nums, your goal is to make all elements in nums equal. To complete one operation, follow these steps:\n\nFind the largest value in nums. Let its index be i (0-indexed) and its value be largest. If there are multiple elements with the largest value, pick the smallest i.\nFind the next largest value in nums strictly smaller than largest. Let its value be nextLargest.\nReduce nums[i] to nextLargest.\n\nReturn the number of operations to make all elements in nums equal.\n \nExample 1:\n\nInput: nums = [5,1,3]\nOutput: 3\nExplanation: It takes 3 operations to make all elements in nums equal:\n1. largest = 5 at index 0. nextLargest = 3. Reduce nums[0] to 3. nums = [3,1,3].\n2. largest = 3 at index 0. nextLargest = 1. Reduce nums[0] to 1. nums = [1,1,3].\n3. largest = 3 at index 2. nextLargest = 1. Reduce nums[2] to 1. nums = [1,1,1].\n\nExample 2:\n\nInput: nums = [1,1,1]\nOutput: 0\nExplanation: All elements in nums are already equal.\n\nExample 3:\n\nInput: nums = [1,1,2,2,3]\nOutput: 4\nExplanation: It takes 4 operations to make all elements in nums equal:\n1. largest = 3 at index 4. nextLargest = 2. Reduce nums[4] to 2. nums = [1,1,2,2,2].\n2. largest = 2 at index 2. nextLargest = 1. Reduce nums[2] to 1. nums = [1,1,1,2,2].\n3. largest = 2 at index 3. nextLargest = 1. Reduce nums[3] to 1. nums = [1,1,1,1,2].\n4. largest = 2 at index 4. nextLargest = 1. Reduce nums[4] to 1. nums = [1,1,1,1,1].\n\n \nConstraints:\n\n1 <= nums.length <= 5 * 104\n1 <= nums[i] <= 5 * 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996]) == 10\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 20\n assert candidate(nums = [4, 3, 2, 1]) == 6\n assert candidate(nums = [1, 5, 2, 4, 3]) == 10\n assert candidate(nums = [1, 1, 1]) == 0\n assert candidate(nums = [1, 1, 2, 2, 3]) == 4\n assert candidate(nums = [3, 3, 2, 1, 2, 3, 3, 2, 1]) == 11\n assert candidate(nums = [4, 3, 2, 1, 4, 3, 2, 1]) == 12\n assert candidate(nums = [5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [5]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(nums = [5, 1, 3]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(nums = [4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2, 1]) == 18\n assert candidate(nums = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 60\n assert candidate(nums = [5, 3, 3, 3, 2, 2, 1, 1, 1, 1]) == 11\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 10\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, 7, 8, 9]) == 84\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 190\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 26\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 190\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5]) == 40\n assert candidate(nums = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 90\n assert candidate(nums = [5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 20\n assert candidate(nums = [4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == 21\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 105\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 40\n assert candidate(nums = [4, 3, 3, 2, 2, 1, 1, 1, 1]) == 9\n assert candidate(nums = [50000, 49999, 49998, 49997, 49996, 49995, 49994, 49993, 49992, 49991]) == 45\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1]) == 32\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 140\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 435\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 50\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6]) == 85\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 435\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7]) == 112\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 50\n assert candidate(nums = [50000, 49999, 49998, 49997, 49996, 49995, 49994, 49993, 49992, 49991, 49990, 49989, 49988, 49987, 49986, 49985, 49984, 49983, 49982, 49981]) == 190\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 126\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3]) == 24\n assert candidate(nums = [30000, 20000, 10000, 5000, 2500, 1250, 625, 312, 156, 78, 39, 19, 9, 4, 2, 1]) == 120\n assert candidate(nums = [5, 4, 4, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == 20\n assert candidate(nums = [1, 3, 2, 4, 5, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 43\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1]) == 19\n assert candidate(nums = [10, 10, 10, 10, 10, 9, 9, 9, 9, 9, 8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == 225\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == 32\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4]) == 24\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 5, 5, 5]) == 26\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 300\n assert candidate(nums = [1, 3, 2, 5, 4, 3, 2, 1, 4, 3, 2, 1, 3, 2, 1, 2, 1, 1]) == 23\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5]) == 30\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 90\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8]) == 174\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 190\n assert candidate(nums = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 20\n assert candidate(nums = [5, 4, 4, 4, 4, 3, 3, 3, 2, 2, 1]) == 24\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == 125\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 435\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 90\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 90\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 435\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 50\n assert candidate(nums = [1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 71\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 105\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 45\n assert candidate(nums = [25000, 25000, 24999, 24998, 24997, 24996, 24995, 24994, 24993, 24992]) == 44\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 190\n assert candidate(nums = [5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1]) == 40\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4]) == 26\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 28\n assert candidate(nums = [50000, 49999, 49998, 49997, 49996, 49995, 49994, 49993, 49992, 49991]) == 45\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 18\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 90\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 90\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 5, 5, 5]) == 41\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == 190\n assert candidate(nums = [1, 2, 1, 3, 2, 1, 4, 3, 2, 1, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]) == 56\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 50\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2]) == 24\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 50\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 25\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 135\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == 20\n assert candidate(nums = [1, 3, 2, 3, 1, 4, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 125\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2]) == 30\n assert candidate(nums = [5, 4, 4, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == 20\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 0\n assert candidate(nums = [5, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1]) == 36\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().reductionOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int reductionOperations(vector& nums) {", "container": "Solution", "callable": "reductionOperations", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1888, "task_id": "minimum-number-of-flips-to-make-the-binary-string-alternating", "difficulty": "Medium", "problem_description": "You are given a binary string s. You are allowed to perform two types of operations on the string in any sequence:\n\nType-1: Remove the character at the start of the string s and append it to the end of the string.\nType-2: Pick any character in s and flip its value, i.e., if its value is '0' it becomes '1' and vice-versa.\n\nReturn the minimum number of type-2 operations you need to perform such that s becomes alternating.\nThe string is called alternating if no two adjacent characters are equal.\n\nFor example, the strings \"010\" and \"1010\" are alternating, while the string \"0100\" is not.\n\n \nExample 1:\n\nInput: s = \"111000\"\nOutput: 2\nExplanation: Use the first operation two times to make s = \"100011\".\nThen, use the second operation on the third and sixth elements to make s = \"101010\".\n\nExample 2:\n\nInput: s = \"010\"\nOutput: 0\nExplanation: The string is already alternating.\n\nExample 3:\n\nInput: s = \"1110\"\nOutput: 1\nExplanation: Use the second operation on the second element to make s = \"1010\".\n\n \nConstraints:\n\n1 <= s.length <= 105\ns[i] is either '0' or '1'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"100100100\") == 3\n assert candidate(s = \"1111\") == 2\n assert candidate(s = \"110011\") == 3\n assert candidate(s = \"111000111000\") == 4\n assert candidate(s = \"11110000\") == 4\n assert candidate(s = \"1110\") == 1\n assert candidate(s = \"0000\") == 2\n assert candidate(s = \"010101010\") == 0\n assert candidate(s = \"01010\") == 0\n assert candidate(s = \"111000\") == 2\n assert candidate(s = \"111111\") == 3\n assert candidate(s = \"10101\") == 0\n assert candidate(s = \"010\") == 0\n assert candidate(s = \"00001111\") == 4\n assert candidate(s = \"000111\") == 2\n assert candidate(s = \"1001001001\") == 5\n assert candidate(s = \"11111\") == 2\n assert candidate(s = \"000000\") == 3\n assert candidate(s = \"010101\") == 0\n assert candidate(s = \"101010\") == 0\n assert candidate(s = \"00000\") == 2\n assert candidate(s = \"0001\") == 1\n assert candidate(s = \"111000111000111000\") == 6\n assert candidate(s = \"010101010101010101010101010101010101\") == 0\n assert candidate(s = \"0000000000111111111100000000001111111111\") == 20\n assert candidate(s = \"00011111000111110001111100011111\") == 12\n assert candidate(s = \"10101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"00000000000000000000000000000000\") == 16\n assert candidate(s = \"0110110110110110110110110110\") == 14\n assert candidate(s = \"1010101010101010101010101\") == 0\n assert candidate(s = \"110100110100\") == 4\n assert candidate(s = \"1100110011001100\") == 8\n assert candidate(s = \"1010101010101010101\") == 0\n assert candidate(s = \"0101001101010011010100110101001101010011010100110101001\") == 12\n assert candidate(s = \"010101010101010101010101\") == 0\n assert candidate(s = \"11101001111010011110100111101001\") == 12\n assert candidate(s = \"00001111000011110000\") == 10\n assert candidate(s = \"000111000111000111\") == 6\n assert candidate(s = \"101010101010101010101010\") == 0\n assert candidate(s = \"11110101010101011111\") == 4\n assert candidate(s = \"0000000011111111000000001111\") == 14\n assert candidate(s = \"1100101010\") == 2\n assert candidate(s = \"101010101010101010101\") == 0\n assert candidate(s = \"1010101010\") == 0\n assert candidate(s = \"1010101010101010101010101010101011\") == 1\n assert candidate(s = \"010101010101010101\") == 0\n assert candidate(s = \"0000000000\") == 5\n assert candidate(s = \"101010101010101010101010101\") == 0\n assert candidate(s = \"1110011100\") == 5\n assert candidate(s = \"1100110011\") == 5\n assert candidate(s = \"111000111000111000111000111000\") == 10\n assert candidate(s = \"0000000000000000\") == 8\n assert candidate(s = \"000111000111000111000111\") == 8\n assert candidate(s = \"11100000111000001110000011100000111000001110000011100000\") == 21\n assert candidate(s = \"0101001101010011010100110101001101010011\") == 10\n assert candidate(s = \"1100110011001100110011001100110011001100\") == 20\n assert candidate(s = \"1010101010101010\") == 0\n assert candidate(s = \"010100010101\") == 1\n assert candidate(s = \"0101010101010101010101\") == 0\n assert candidate(s = \"111000111000111000111000111000111000\") == 12\n assert candidate(s = \"111101111011110111101111011110111101111011110111\") == 23\n assert candidate(s = \"01101010101010101011\") == 3\n assert candidate(s = \"01010101011\") == 0\n assert candidate(s = \"11111000001111100000\") == 8\n assert candidate(s = \"0101010101010101010101010101010101\") == 0\n assert candidate(s = \"000011110000111100001111000011110000\") == 18\n assert candidate(s = \"11001100110011001100110011001100110011001100110011001\") == 25\n assert candidate(s = \"111000011100001110000\") == 9\n assert candidate(s = \"0000111100001111000011110000\") == 14\n assert candidate(s = \"1110001110001110001110\") == 7\n assert candidate(s = \"11110000111100001111\") == 10\n assert candidate(s = \"01010101010101010101010101\") == 0\n assert candidate(s = \"10010010010010010010010010010\") == 12\n assert candidate(s = \"0101001101010011\") == 4\n assert candidate(s = \"1111111100000000111111110000\") == 14\n assert candidate(s = \"1000000000\") == 4\n assert candidate(s = \"11111111111111111111\") == 10\n assert candidate(s = \"000011110000\") == 6\n assert candidate(s = \"0011001100\") == 5\n assert candidate(s = \"1111111111111111\") == 8\n assert candidate(s = \"10101010101010101010101010101010101\") == 0\n assert candidate(s = \"00000000001111111111\") == 10\n assert candidate(s = \"101010101010101010101010101010101\") == 0\n assert candidate(s = \"00000111110000011111\") == 8\n assert candidate(s = \"1111111111111111111111111111111111111111111111111111\") == 26\n assert candidate(s = \"1111100000111110000011111\") == 10\n assert candidate(s = \"111000111000111000111\") == 7\n assert candidate(s = \"11111111110000000000\") == 10\n assert candidate(s = \"11001100110011001100\") == 10\n assert candidate(s = \"11100011100011100011\") == 7\n assert candidate(s = \"01010101010101010101010101010101\") == 0\n assert candidate(s = \"10010010010010010010\") == 9\n assert candidate(s = \"1010101010101010101010101010\") == 0\n assert candidate(s = \"00000000000000000000000000000000000000000000000000\") == 25\n assert candidate(s = \"1001001001001001001001\") == 11\n assert candidate(s = \"0000011111000001111100000\") == 10\n assert candidate(s = \"1111000011110000111100001111000011110000\") == 20\n assert candidate(s = \"111100001111\") == 6\n assert candidate(s = \"11110000111100001111000011110000\") == 16\n assert candidate(s = \"0000000000000000000000000111111111111111111111111\") == 23\n assert candidate(s = \"11001100110011001100110011001100110011001100110011001100110\") == 28\n assert candidate(s = \"101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"000111100011110001111\") == 9\n assert candidate(s = \"11111111111111111111111111111111\") == 16\n assert candidate(s = \"00011111000111110001111100011111000111110001111100011111\") == 21\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"00010110000101100001011000010110\") == 12\n assert candidate(s = \"0101010101010101010101010101\") == 0\n assert candidate(s = \"000111000111000111000111000111\") == 10\n assert candidate(s = \"11010101010101010110\") == 3\n assert candidate(s = \"111111111111111111111111111111111\") == 16\n assert candidate(s = \"0101010101\") == 0\n assert candidate(s = \"11111111111111111111111111111111111111111111111111\") == 25\n assert candidate(s = \"00010001000100010001000\") == 6\n assert candidate(s = \"110011001100110011001100110011001\") == 15\n assert candidate(s = \"00110011001100110011\") == 10\n assert candidate(s = \"0111011101\") == 2\n assert candidate(s = \"010101010101010101010101010101010\") == 0\n assert candidate(s = \"00000000000000000000\") == 10\n assert candidate(s = \"1111000011110000\") == 8\n assert candidate(s = \"0101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"10101010101010101010101010101010\") == 0\n assert candidate(s = \"010101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"1111100000\") == 4\n assert candidate(s = \"111111111111111111111111111111111111111111111111111111111111111111\") == 33\n assert candidate(s = \"1010101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"0000000000000000000000000000000000000000000000000000\") == 26\n assert candidate(s = \"010101010101010101010\") == 0\n assert candidate(s = \"1111111111111111111111111000000000000000000000000\") == 23\n assert candidate(s = \"1010101010101010101010\") == 0\n assert candidate(s = \"1111111111\") == 5\n assert candidate(s = \"1111000011110000111100001111\") == 14\n assert candidate(s = \"00000000000000000000000000000\") == 14\n assert candidate(s = \"00011100011100011100\") == 7\n assert candidate(s = \"01010101010101010101\") == 0\n assert candidate(s = \"000000000000000000000000000000000\") == 16\n assert candidate(s = \"010101010101010101010101010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"01010101010101010101010101010101010101010101010101010\") == 0\n assert candidate(s = \"11100000111000001110000011100000\") == 12\n assert candidate(s = \"101010101010101010101010101010101010\") == 0\n assert candidate(s = \"10101010100\") == 0\n assert candidate(s = \"11111111000000001111\") == 10\n assert candidate(s = \"01101101101101101101\") == 9\n assert candidate(s = \"10101010101010101010\") == 0\n assert candidate(s = \"00000000111111110000\") == 10\n assert candidate(s = \"11000011110000111100\") == 10\n assert candidate(s = \"11111111111111111111111111\") == 13\n assert candidate(s = \"111000111000111000111000\") == 8\n assert candidate(s = \"010101010101010101010101010101010101010101\") == 0\n assert candidate(s = \"10111011101110111011\") == 5\n assert candidate(s = \"001100110011\") == 6\n assert candidate(s = \"0000111100001111\") == 8\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minFlips", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minFlips(string s) {", "container": "Solution", "callable": "minFlips", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1889, "task_id": "minimum-space-wasted-from-packaging", "difficulty": "Hard", "problem_description": "You have n packages that you are trying to place in boxes, one package in each box. There are m suppliers that each produce boxes of different sizes (with infinite supply). A package can be placed in a box if the size of the package is less than or equal to the size of the box.\nThe package sizes are given as an integer array packages, where packages[i] is the size of the ith package. The suppliers are given as a 2D integer array boxes, where boxes[j] is an array of box sizes that the jth supplier produces.\nYou want to choose a single supplier and use boxes from them such that the total wasted space is minimized. For each package in a box, we define the space wasted to be size of the box - size of the package. The total wasted space is the sum of the space wasted in all the boxes.\n\nFor example, if you have to fit packages with sizes [2,3,5] and the supplier offers boxes of sizes [4,8], you can fit the packages of size-2 and size-3 into two boxes of size-4 and the package with size-5 into a box of size-8. This would result in a waste of (4-2) + (4-3) + (8-5) = 6.\n\nReturn the minimum total wasted space by choosing the box supplier optimally, or -1 if it is impossible to fit all the packages inside boxes. Since the answer may be large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: packages = [2,3,5], boxes = [[4,8],[2,8]]\nOutput: 6\nExplanation: It is optimal to choose the first supplier, using two size-4 boxes and one size-8 box.\nThe total waste is (4-2) + (4-3) + (8-5) = 6.\n\nExample 2:\n\nInput: packages = [2,3,5], boxes = [[1,4],[2,3],[3,4]]\nOutput: -1\nExplanation: There is no box that the package of size 5 can fit in.\n\nExample 3:\n\nInput: packages = [3,5,8,10,11,12], boxes = [[12],[11,9],[10,5,14]]\nOutput: 9\nExplanation: It is optimal to choose the third supplier, using two size-5 boxes, two size-10 boxes, and two size-14 boxes.\nThe total waste is (5-3) + (5-5) + (10-8) + (10-10) + (14-11) + (14-12) = 9.\n\n \nConstraints:\n\nn == packages.length\nm == boxes.length\n1 <= n <= 105\n1 <= m <= 105\n1 <= packages[i] <= 105\n1 <= boxes[j].length <= 105\n1 <= boxes[j][k] <= 105\nsum(boxes[j].length) <= 105\nThe elements in boxes[j] are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(packages = [10, 20, 30],boxes = [[10], [20], [30], [40]]) == 30\n assert candidate(packages = [100000],boxes = [[100000]]) == 0\n assert candidate(packages = [10, 20, 30],boxes = [[10, 20, 30], [15, 25, 35]]) == 0\n assert candidate(packages = [1, 100000],boxes = [[1], [100000]]) == 99999\n assert candidate(packages = [2, 3, 5],boxes = [[4, 8], [2, 8]]) == 6\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 45\n assert candidate(packages = [3, 5, 8, 10, 11, 12],boxes = [[12], [11, 9], [10, 5, 14]]) == 9\n assert candidate(packages = [1, 2, 3, 4, 5],boxes = [[5, 5, 5, 5, 5]]) == 10\n assert candidate(packages = [1, 3, 5, 7, 9],boxes = [[2, 4, 6, 8, 10]]) == 5\n assert candidate(packages = [5, 5, 5, 5],boxes = [[5, 5, 5, 5]]) == 0\n assert candidate(packages = [2, 3, 5],boxes = [[1, 4], [2, 3], [3, 4]]) == -1\n assert candidate(packages = [10000, 20000, 30000, 40000, 50000],boxes = [[20000, 30000, 50000], [10000, 15000, 20000, 25000, 30000, 35000, 40000, 45000, 50000]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [5, 15, 25, 35, 45]]) == 0\n assert candidate(packages = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [1, 5, 9, 13, 17], [3, 7, 11, 15, 19]]) == 10\n assert candidate(packages = [50000, 50000, 50000, 50000, 50000],boxes = [[50000, 50000], [100000], [25000, 75000]]) == 0\n assert candidate(packages = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21], [5, 10, 15, 20, 25, 30]]) == 10\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[5, 15, 25, 35, 45, 55, 65, 75, 85, 95], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]]) == 0\n assert candidate(packages = [99999, 99998, 99997, 99996, 99995],boxes = [[100000], [99999], [99998], [99997], [99996], [99995]]) == 10\n assert candidate(packages = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],boxes = [[4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22], [3, 7, 11, 15, 19, 23, 27, 31]]) == 9\n assert candidate(packages = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900],boxes = [[500, 600, 700, 800, 900, 1000], [900, 1000, 1100, 1200, 1300, 1400, 1500], [100, 200, 300, 400, 500, 600, 700, 800, 900]]) == 99\n assert candidate(packages = [1, 10, 100, 1000, 10000, 100000],boxes = [[5, 10, 100, 1000, 10000, 100000, 500000], [1, 5, 10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],boxes = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]]) == 0\n assert candidate(packages = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],boxes = [[3, 6, 9, 12, 15, 18, 21], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]]) == 10\n assert candidate(packages = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30], [1, 5, 9, 13, 17, 21, 25, 29]]) == 14\n assert candidate(packages = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]]) == 0\n assert candidate(packages = [5, 10, 15, 20, 25],boxes = [[5, 10, 15, 20, 25], [1, 2, 3, 4, 5], [26, 27, 28, 29, 30]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [15, 25, 35, 45, 55, 65, 75, 85, 95, 105]]) == 0\n assert candidate(packages = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],boxes = [[5, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60]]) == 145\n assert candidate(packages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boxes = [[1], [2], [3, 4, 5]]) == 0\n assert candidate(packages = [100000, 90000, 80000, 70000, 60000],boxes = [[95000, 100000], [85000, 90000, 95000], [75000, 80000, 85000], [65000, 70000, 75000, 80000]]) == 80000\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 11, 12], [9, 8, 7, 6, 5, 4, 3, 2, 1], [15, 20, 25, 30, 35]]) == 45\n assert candidate(packages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boxes = [[1], [2], [1, 2, 3, 4, 5]]) == 0\n assert candidate(packages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boxes = [[1], [2], [3]]) == 0\n assert candidate(packages = [100000],boxes = [[99999, 99998, 99997, 99996, 99995]]) == -1\n assert candidate(packages = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[5, 10, 15], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]) == 0\n assert candidate(packages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boxes = [[1, 2, 3, 4, 5], [2, 4, 6, 8, 10], [3, 6, 9, 12, 15]]) == 0\n assert candidate(packages = [25000, 50000, 75000, 100000],boxes = [[12500, 37500, 62500, 87500], [10000, 40000, 70000, 100000], [50000, 50000, 50000, 50000]]) == 60000\n assert candidate(packages = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],boxes = [[100], [200], [300], [400], [500], [600], [700], [800], [900], [1000]]) == 4500\n assert candidate(packages = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],boxes = [[100000], [100001], [99999], [99998], [99997], [99996], [99995], [99994], [99993], [99992], [99991]]) == 45\n assert candidate(packages = [1, 10, 100, 1000, 10000, 100000],boxes = [[1, 10, 100, 1000, 10000, 100000], [2, 20, 200, 2000, 20000, 200000], [5, 50, 500, 5000, 50000, 500000]]) == 0\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]]) == 0\n assert candidate(packages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boxes = [[1], [2], [3]]) == 0\n assert candidate(packages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boxes = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [11, 12, 13, 14, 15], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],boxes = [[1, 3, 5, 7, 9, 11, 13, 15], [2, 4, 6, 8, 10, 12, 14], [16]]) == 7\n assert candidate(packages = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950],boxes = [[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], [50, 150, 250, 350, 450, 550, 650, 750, 850, 950, 1050]]) == 0\n assert candidate(packages = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10], [9, 10], [8, 9, 10], [7, 8, 9, 10], [6, 7, 8, 9, 10], [5, 6, 7, 8, 9, 10]]) == 10\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[1, 2, 3, 4, 5], [101, 102, 103, 104, 105], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]]) == 0\n assert candidate(packages = [20000, 10000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],boxes = [[50000, 70000, 90000, 110000], [30000, 60000, 90000, 120000], [25000, 50000, 75000, 100000, 125000]]) == 100000\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]) == 0\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[15, 25, 35, 45, 55, 65, 75, 85, 95, 105], [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105]]) == 0\n assert candidate(packages = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],boxes = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95], [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]]) == 0\n assert candidate(packages = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],boxes = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [3, 6, 9, 12, 15, 18], [4, 8, 12, 16, 20]]) == 0\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120], [50, 60, 70, 80, 90, 100, 110, 120, 130, 140]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(packages = [1, 100000],boxes = [[50000], [150000], [100000]]) == 99999\n assert candidate(packages = [1, 10, 100, 1000, 10000],boxes = [[5, 50, 500, 5000, 50000], [1, 2, 3, 4, 5], [9999, 99999]]) == 44444\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[5, 15, 25, 35, 45, 55, 65, 75, 85, 95], [10, 30, 50, 70, 90, 110], [20, 40, 60, 80, 100, 120]]) == 50\n assert candidate(packages = [1, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95], [1, 11, 21, 31, 41, 51, 61, 71, 81, 91]]) == 14\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],boxes = [[1, 3, 5, 7, 9, 11, 13, 15], [2, 4, 6, 8, 10, 12, 14], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 0\n assert candidate(packages = [50000, 50000, 50000, 50000, 50000],boxes = [[49999], [50000], [50001]]) == 0\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [50, 50, 50, 50, 50, 50, 50, 50, 50, 50], [100, 100, 100, 100, 100, 100, 100, 100, 100, 100], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 450\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],boxes = [[20, 40], [10, 30], [5, 15, 25, 35]]) == 90\n assert candidate(packages = [100000, 100000, 100000],boxes = [[100000], [100001], [99999, 100000, 100001]]) == 0\n assert candidate(packages = [50000, 40000, 30000, 20000, 10000],boxes = [[10000, 20000, 30000, 40000, 50000], [15000, 25000, 35000, 45000, 55000], [55000]]) == 0\n assert candidate(packages = [50, 60, 70, 80, 90, 100],boxes = [[40, 90], [50, 60, 100], [80, 95, 110]]) == 60\n assert candidate(packages = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],boxes = [[50000, 60000, 70000, 80000, 90000, 100000], [90000, 100000, 110000, 120000, 130000, 140000, 150000]]) == 100000\n assert candidate(packages = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],boxes = [[100], [256, 512, 1024], [2, 4, 8, 16, 32, 64, 128]]) == 1793\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 10, 10], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]]) == 5\n assert candidate(packages = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],boxes = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]]) == 0\n assert candidate(packages = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 10\n assert candidate(packages = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],boxes = [[110000, 120000, 130000], [90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000], [55000, 54000, 53000, 52000, 51000, 50000, 49000, 48000, 47000, 46000]]) == 550000\n assert candidate(packages = [10, 20, 30, 40, 50],boxes = [[5, 15, 25, 35, 45], [6, 16, 26, 36, 46], [7, 17, 27, 37, 47]]) == -1\n assert candidate(packages = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],boxes = [[1, 5, 9, 13, 17], [3, 7, 11, 15, 19], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]]) == 10\n assert candidate(packages = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],boxes = [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(packages = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],boxes = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]]) == 0\n assert candidate(packages = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],boxes = [[5, 15, 25, 35, 45, 55, 65, 75, 85, 95], [100, 100, 100, 100, 100, 100, 100, 100, 100, 100], [90, 80, 70, 60, 50, 40, 30, 20, 10, 0]]) == 450\n assert candidate(packages = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40], [1, 9, 17, 25, 33], [5, 10, 15, 20, 25, 30, 35]]) == 10\n assert candidate(packages = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97],boxes = [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100]]) == 25\n assert candidate(packages = [10000, 20000, 30000, 40000, 50000],boxes = [[5000, 15000, 25000, 35000, 45000, 55000], [10000, 20000, 30000, 40000, 50000]]) == 0\n assert candidate(packages = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],boxes = [[500, 600, 700, 800, 900, 1000], [900, 1000, 1100, 1200, 1300, 1400, 1500]]) == 1000\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[2, 3, 5, 7, 11], [1, 4, 9], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 9\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 20, 30], [5, 10, 15, 20, 25, 30], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]]) == 5\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]]) == -1\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [5, 10, 15, 20, 25], [3, 6, 9, 12, 15]]) == 0\n assert candidate(packages = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],boxes = [[1000, 2000], [500, 1500], [300, 700, 1100]]) == 1500\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],boxes = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == 0\n assert candidate(packages = [50000, 50000, 50000, 50000, 50000],boxes = [[50000], [50001], [50002], [50003], [50004]]) == 0\n assert candidate(packages = [1000, 2000, 3000, 4000, 5000],boxes = [[1000, 2000, 3000, 4000, 5000], [1500, 2500, 3500, 4500, 5500], [900, 1900, 2900, 3900, 4900]]) == 0\n assert candidate(packages = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],boxes = [[10, 20], [5, 15], [3, 7, 12]]) == 18\n"}, "metadata": {"canonical_parameter_names": ["packages", "boxes"], "leetcode_dataset_entry_point": "Solution().minWastedSpace", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minWastedSpace(vector& packages, vector>& boxes) {", "container": "Solution", "callable": "minWastedSpace", "parameters": [{"name": "packages", "type": "vector&"}, {"name": "boxes", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1893, "task_id": "check-if-all-the-integers-in-a-range-are-covered", "difficulty": "Easy", "problem_description": "You are given a 2D integer array ranges and two integers left and right. Each ranges[i] = [starti, endi] represents an inclusive interval between starti and endi.\nReturn true if each integer in the inclusive range [left, right] is covered by at least one interval in ranges. Return false otherwise.\nAn integer x is covered by an interval ranges[i] = [starti, endi] if starti <= x <= endi.\n \nExample 1:\n\nInput: ranges = [[1,2],[3,4],[5,6]], left = 2, right = 5\nOutput: true\nExplanation: Every integer between 2 and 5 is covered:\n- 2 is covered by the first range.\n- 3 and 4 are covered by the second range.\n- 5 is covered by the third range.\n\nExample 2:\n\nInput: ranges = [[1,10],[10,20]], left = 21, right = 21\nOutput: false\nExplanation: 21 is not covered by any range.\n\n \nConstraints:\n\n1 <= ranges.length <= 50\n1 <= starti <= endi <= 50\n1 <= left <= right <= 50\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(ranges = [[5, 7], [1, 3]],left = 1,right = 7) == False\n assert candidate(ranges = [[5, 10], [15, 20]],left = 10,right = 15) == False\n assert candidate(ranges = [[1, 1], [2, 2], [3, 3]],left = 1,right = 3) == True\n assert candidate(ranges = [[1, 3], [3, 5], [5, 7]],left = 3,right = 5) == True\n assert candidate(ranges = [[10, 20], [21, 30]],left = 15,right = 25) == True\n assert candidate(ranges = [[1, 3], [5, 7]],left = 2,right = 6) == False\n assert candidate(ranges = [[1, 3], [5, 7], [9, 11]],left = 4,right = 6) == False\n assert candidate(ranges = [[5, 10], [15, 20]],left = 8,right = 12) == False\n assert candidate(ranges = [[1, 2], [3, 4], [5, 6]],left = 2,right = 5) == True\n assert candidate(ranges = [[1, 2], [4, 5]],left = 3,right = 4) == False\n assert candidate(ranges = [[1, 10], [10, 20]],left = 21,right = 21) == False\n assert candidate(ranges = [[1, 5], [6, 10]],left = 1,right = 10) == True\n assert candidate(ranges = [[1, 50]],left = 1,right = 50) == True\n assert candidate(ranges = [[5, 10], [10, 15]],left = 10,right = 10) == True\n assert candidate(ranges = [[5, 10], [11, 16], [17, 22], [23, 28]],left = 8,right = 25) == True\n assert candidate(ranges = [[3, 6], [7, 10], [11, 14], [15, 18]],left = 5,right = 17) == True\n assert candidate(ranges = [[1, 10], [15, 25], [30, 40]],left = 11,right = 14) == False\n assert candidate(ranges = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25]],left = 5,right = 25) == True\n assert candidate(ranges = [[5, 15], [10, 20], [25, 35]],left = 7,right = 28) == False\n assert candidate(ranges = [[1, 2], [3, 5], [6, 8], [9, 11], [12, 14]],left = 1,right = 14) == True\n assert candidate(ranges = [[2, 5], [6, 9], [10, 15], [16, 20]],left = 3,right = 19) == True\n assert candidate(ranges = [[1, 3], [6, 8], [11, 13], [16, 18]],left = 5,right = 17) == False\n assert candidate(ranges = [[2, 6], [8, 12], [14, 18], [20, 24], [26, 30]],left = 3,right = 28) == False\n assert candidate(ranges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]],left = 1,right = 12) == True\n assert candidate(ranges = [[5, 5], [10, 10], [15, 15], [20, 20]],left = 5,right = 20) == False\n assert candidate(ranges = [[1, 50]],left = 1,right = 50) == True\n assert candidate(ranges = [[10, 20], [5, 15], [25, 35]],left = 12,right = 28) == False\n assert candidate(ranges = [[5, 7], [8, 10], [15, 20], [25, 30]],left = 7,right = 27) == False\n assert candidate(ranges = [[1, 4], [6, 9], [11, 14], [16, 19], [21, 24], [26, 29]],left = 1,right = 29) == False\n assert candidate(ranges = [[3, 6], [8, 11], [13, 16]],left = 4,right = 15) == False\n assert candidate(ranges = [[10, 15], [16, 20], [21, 25], [26, 30]],left = 12,right = 28) == True\n assert candidate(ranges = [[1, 5], [5, 10], [10, 15], [15, 20]],left = 6,right = 14) == True\n assert candidate(ranges = [[5, 8], [10, 13], [15, 18], [20, 23], [25, 28], [30, 33]],left = 3,right = 31) == False\n assert candidate(ranges = [[5, 10], [15, 25], [30, 35]],left = 25,right = 30) == False\n assert candidate(ranges = [[1, 20], [21, 40], [41, 50]],left = 1,right = 50) == True\n assert candidate(ranges = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],left = 1,right = 10) == True\n assert candidate(ranges = [[3, 7], [9, 13], [15, 19], [21, 25], [27, 31]],left = 6,right = 30) == False\n assert candidate(ranges = [[10, 15], [15, 20], [20, 25]],left = 12,right = 23) == True\n assert candidate(ranges = [[5, 5], [6, 6], [7, 7], [8, 8]],left = 5,right = 8) == True\n assert candidate(ranges = [[5, 8], [10, 15], [18, 23], [25, 30]],left = 8,right = 27) == False\n assert candidate(ranges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],left = 1,right = 8) == True\n assert candidate(ranges = [[1, 2], [4, 6], [8, 10], [12, 14]],left = 3,right = 13) == False\n assert candidate(ranges = [[1, 3], [4, 6], [7, 9], [10, 12]],left = 1,right = 12) == True\n assert candidate(ranges = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],left = 1,right = 5) == True\n assert candidate(ranges = [[3, 7], [10, 14], [17, 21]],left = 5,right = 19) == False\n assert candidate(ranges = [[1, 2], [4, 8], [10, 15], [16, 20], [22, 25]],left = 1,right = 25) == False\n assert candidate(ranges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],left = 2,right = 5) == True\n assert candidate(ranges = [[2, 5], [7, 10], [12, 15], [17, 20], [22, 25], [27, 30]],left = 4,right = 29) == False\n assert candidate(ranges = [[2, 4], [5, 7], [8, 10], [11, 13]],left = 2,right = 13) == True\n assert candidate(ranges = [[1, 2], [4, 5], [7, 8], [10, 11]],left = 3,right = 9) == False\n assert candidate(ranges = [[10, 20], [21, 30], [31, 40], [41, 50]],left = 15,right = 45) == True\n assert candidate(ranges = [[10, 12], [15, 17], [20, 22]],left = 10,right = 22) == False\n assert candidate(ranges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],left = 1,right = 10) == True\n assert candidate(ranges = [[1, 3], [4, 6], [7, 9], [10, 12], [13, 15]],left = 1,right = 15) == True\n assert candidate(ranges = [[5, 7], [7, 9], [9, 11], [11, 13]],left = 6,right = 12) == True\n assert candidate(ranges = [[5, 10], [15, 20], [25, 30]],left = 12,right = 17) == False\n assert candidate(ranges = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25], [26, 30]],left = 1,right = 30) == True\n assert candidate(ranges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],left = 1,right = 6) == True\n assert candidate(ranges = [[3, 6], [8, 12], [15, 20], [22, 25], [27, 30]],left = 5,right = 28) == False\n assert candidate(ranges = [[5, 8], [10, 12], [15, 18]],left = 6,right = 17) == False\n assert candidate(ranges = [[1, 10], [12, 20], [22, 30]],left = 5,right = 25) == False\n assert candidate(ranges = [[5, 10], [12, 15], [16, 20], [22, 25]],left = 11,right = 21) == False\n assert candidate(ranges = [[1, 10], [15, 25], [30, 40]],left = 5,right = 35) == False\n assert candidate(ranges = [[1, 5], [10, 15], [20, 25], [30, 35]],left = 5,right = 30) == False\n assert candidate(ranges = [[3, 3], [5, 5], [7, 7], [9, 9], [11, 11], [13, 13]],left = 3,right = 13) == False\n assert candidate(ranges = [[1, 10], [11, 20], [21, 30], [31, 40]],left = 5,right = 35) == True\n assert candidate(ranges = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50]],left = 25,right = 45) == True\n assert candidate(ranges = [[1, 5], [6, 10], [11, 15], [16, 20]],left = 3,right = 19) == True\n assert candidate(ranges = [[5, 10], [15, 20], [25, 30], [35, 40]],left = 2,right = 38) == False\n assert candidate(ranges = [[2, 4], [6, 8], [10, 12], [14, 16], [18, 20], [22, 24]],left = 1,right = 24) == False\n assert candidate(ranges = [[1, 3], [5, 7], [9, 11], [13, 15], [17, 19], [21, 23]],left = 1,right = 23) == False\n assert candidate(ranges = [[2, 4], [5, 7], [8, 10], [11, 13], [14, 16]],left = 3,right = 15) == True\n assert candidate(ranges = [[2, 4], [5, 8], [9, 11], [12, 15], [16, 18], [19, 22]],left = 2,right = 22) == True\n assert candidate(ranges = [[2, 4], [6, 8], [10, 12], [14, 16], [18, 20]],left = 3,right = 19) == False\n assert candidate(ranges = [[10, 20], [20, 30], [30, 40]],left = 5,right = 45) == False\n assert candidate(ranges = [[1, 2], [4, 5], [7, 8], [10, 11], [13, 14], [16, 17], [19, 20]],left = 1,right = 20) == False\n assert candidate(ranges = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50]],left = 25,right = 45) == True\n assert candidate(ranges = [[5, 10], [15, 20], [25, 30]],left = 3,right = 28) == False\n assert candidate(ranges = [[3, 7], [8, 12], [13, 17], [18, 22]],left = 5,right = 20) == True\n assert candidate(ranges = [[1, 10], [20, 30], [40, 50]],left = 15,right = 35) == False\n assert candidate(ranges = [[1, 2], [4, 5], [7, 8], [10, 11]],left = 1,right = 11) == False\n assert candidate(ranges = [[2, 4], [7, 9], [12, 14], [17, 19]],left = 4,right = 19) == False\n assert candidate(ranges = [[1, 2], [2, 3], [3, 4], [4, 5]],left = 1,right = 5) == True\n assert candidate(ranges = [[1, 5], [6, 10], [11, 15], [16, 20], [21, 25]],left = 1,right = 25) == True\n assert candidate(ranges = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50]],left = 5,right = 45) == True\n assert candidate(ranges = [[1, 3], [4, 7], [8, 10], [11, 15], [16, 20]],left = 5,right = 15) == True\n assert candidate(ranges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],left = 1,right = 10) == True\n assert candidate(ranges = [[5, 10], [15, 20], [25, 30], [35, 40]],left = 25,right = 35) == False\n assert candidate(ranges = [[5, 10], [11, 20], [21, 30]],left = 7,right = 29) == True\n assert candidate(ranges = [[1, 25], [26, 50]],left = 1,right = 50) == True\n assert candidate(ranges = [[3, 5], [8, 10], [13, 15], [18, 20]],left = 1,right = 20) == False\n assert candidate(ranges = [[5, 10], [15, 20], [25, 30]],left = 1,right = 30) == False\n assert candidate(ranges = [[1, 3], [4, 6], [7, 9], [10, 12], [13, 15]],left = 2,right = 14) == True\n assert candidate(ranges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]],left = 5,right = 10) == True\n assert candidate(ranges = [[2, 5], [6, 9], [10, 14]],left = 3,right = 13) == True\n assert candidate(ranges = [[1, 10], [15, 25], [30, 40]],left = 5,right = 20) == False\n assert candidate(ranges = [[1, 5], [6, 10], [11, 15], [16, 20]],left = 1,right = 20) == True\n assert candidate(ranges = [[1, 3], [4, 6], [7, 9]],left = 1,right = 9) == True\n assert candidate(ranges = [[2, 4], [6, 8], [10, 12], [14, 16], [18, 20]],left = 1,right = 20) == False\n assert candidate(ranges = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]],left = 2,right = 9) == True\n assert candidate(ranges = [[2, 5], [7, 10], [12, 15], [17, 20]],left = 3,right = 18) == False\n assert candidate(ranges = [[5, 9], [10, 14], [15, 19], [20, 24]],left = 8,right = 22) == True\n assert candidate(ranges = [[1, 4], [5, 8], [9, 12], [13, 16]],left = 3,right = 15) == True\n assert candidate(ranges = [[1, 10], [10, 20], [20, 30], [30, 40]],left = 1,right = 40) == True\n assert candidate(ranges = [[5, 10], [15, 20], [25, 30], [35, 40]],left = 10,right = 35) == False\n"}, "metadata": {"canonical_parameter_names": ["ranges", "left", "right"], "leetcode_dataset_entry_point": "Solution().isCovered", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool isCovered(vector>& ranges, int left, int right) {", "container": "Solution", "callable": "isCovered", "parameters": [{"name": "ranges", "type": "vector>&"}, {"name": "left", "type": "int"}, {"name": "right", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1894, "task_id": "find-the-student-that-will-replace-the-chalk", "difficulty": "Medium", "problem_description": "There are n students in a class numbered from 0 to n - 1. The teacher will give each student a problem starting with the student number 0, then the student number 1, and so on until the teacher reaches the student number n - 1. After that, the teacher will restart the process, starting with the student number 0 again.\nYou are given a 0-indexed integer array chalk and an integer k. There are initially k pieces of chalk. When the student number i is given a problem to solve, they will use chalk[i] pieces of chalk to solve that problem. However, if the current number of chalk pieces is strictly less than chalk[i], then the student number i will be asked to replace the chalk.\nReturn the index of the student that will replace the chalk pieces.\n \nExample 1:\n\nInput: chalk = [5,1,5], k = 22\nOutput: 0\nExplanation: The students go in turns as follows:\n- Student number 0 uses 5 chalk, so k = 17.\n- Student number 1 uses 1 chalk, so k = 16.\n- Student number 2 uses 5 chalk, so k = 11.\n- Student number 0 uses 5 chalk, so k = 6.\n- Student number 1 uses 1 chalk, so k = 5.\n- Student number 2 uses 5 chalk, so k = 0.\nStudent number 0 does not have enough chalk, so they will have to replace it.\nExample 2:\n\nInput: chalk = [3,4,1,2], k = 25\nOutput: 1\nExplanation: The students go in turns as follows:\n- Student number 0 uses 3 chalk so k = 22.\n- Student number 1 uses 4 chalk so k = 18.\n- Student number 2 uses 1 chalk so k = 17.\n- Student number 3 uses 2 chalk so k = 15.\n- Student number 0 uses 3 chalk so k = 12.\n- Student number 1 uses 4 chalk so k = 8.\n- Student number 2 uses 1 chalk so k = 7.\n- Student number 3 uses 2 chalk so k = 5.\n- Student number 0 uses 3 chalk so k = 2.\nStudent number 1 does not have enough chalk, so they will have to replace it.\n\n \nConstraints:\n\nchalk.length == n\n1 <= n <= 105\n1 <= chalk[i] <= 105\n1 <= k <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(chalk = [1, 2, 3, 4, 5],k = 15) == 0\n assert candidate(chalk = [1],k = 1000000000) == 0\n assert candidate(chalk = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 999999999) == 9\n assert candidate(chalk = [10, 10, 10],k = 100) == 1\n assert candidate(chalk = [100000],k = 1000000000) == 0\n assert candidate(chalk = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1000000000) == 0\n assert candidate(chalk = [3, 4, 1, 2],k = 25) == 1\n assert candidate(chalk = [5, 1, 5],k = 22) == 0\n assert candidate(chalk = [5, 1, 5],k = 1000000000) == 2\n assert candidate(chalk = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],k = 1000000000) == 6\n assert candidate(chalk = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 9999999999) == 19\n assert candidate(chalk = [100000, 200000, 300000],k = 1000000000) == 2\n assert candidate(chalk = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 123456789) == 1\n assert candidate(chalk = [5, 8, 12, 3, 7],k = 500000000) == 1\n assert candidate(chalk = [7, 3, 2, 8, 6, 4],k = 987654321) == 4\n assert candidate(chalk = [1, 10, 100, 1000, 10000, 100000],k = 123456789) == 5\n assert candidate(chalk = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000],k = 987654321) == 8\n assert candidate(chalk = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1200000000) == 4\n assert candidate(chalk = [100000, 200000, 300000, 400000, 500000],k = 1000000000) == 4\n assert candidate(chalk = [2, 3, 4, 5, 6, 7, 8, 9, 10],k = 100000000) == 8\n assert candidate(chalk = [10, 20, 30, 40, 50],k = 123456789) == 2\n assert candidate(chalk = [100, 200, 300, 400, 500],k = 999999999) == 3\n assert candidate(chalk = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 123456789) == 9\n assert candidate(chalk = [5, 1, 5, 2, 8],k = 1000000000) == 4\n assert candidate(chalk = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 1000000000) == 9\n assert candidate(chalk = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],k = 999999998) == 1\n assert candidate(chalk = [7, 14, 21, 28, 35],k = 123456789) == 4\n assert candidate(chalk = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 999999997) == 2\n assert candidate(chalk = [12345, 54321, 23456, 65432, 34567],k = 1234567890) == 3\n assert candidate(chalk = [5, 8, 3, 7, 2],k = 1000000001) == 0\n assert candidate(chalk = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31],k = 1000000000) == 0\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 543210) == 7\n assert candidate(chalk = [5, 1, 5, 2, 6],k = 1000000000) == 4\n assert candidate(chalk = [5, 8, 3, 7, 2],k = 500000000) == 0\n assert candidate(chalk = [5, 8, 15, 3],k = 1000000007) == 2\n assert candidate(chalk = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 8675309) == 6\n assert candidate(chalk = [5, 3, 7, 11],k = 50) == 3\n assert candidate(chalk = [987654321, 123456789, 987654321, 123456789],k = 2000000000) == 2\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 897654321) == 12\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 500000000) == 2\n assert candidate(chalk = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 900000000) == 5\n assert candidate(chalk = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 1000000000) == 5\n assert candidate(chalk = [10, 20, 30, 40, 50],k = 999999999) == 3\n assert candidate(chalk = [100000, 100000, 100000, 100000, 100000],k = 950000000) == 0\n assert candidate(chalk = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 999999999) == 9\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 1000000000) == 8\n assert candidate(chalk = [100, 200, 300, 400, 500],k = 1000000001) == 4\n assert candidate(chalk = [99999, 99998, 99997, 99996, 99995],k = 99999999999) == 0\n assert candidate(chalk = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 1700000000) == 26\n assert candidate(chalk = [2, 4, 6, 8, 10],k = 999999999) == 2\n assert candidate(chalk = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 987654321) == 1\n assert candidate(chalk = [100000, 200000, 300000, 400000],k = 1234567890) == 2\n assert candidate(chalk = [100000000, 200000000, 300000000],k = 1000000000) == 2\n assert candidate(chalk = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],k = 999999999) == 7\n assert candidate(chalk = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 9876543210) == 5\n assert candidate(chalk = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1],k = 1300000000) == 12\n assert candidate(chalk = [100, 200, 300, 400, 500],k = 9876543210) == 1\n assert candidate(chalk = [5, 8, 12, 3, 6],k = 1000000000) == 2\n assert candidate(chalk = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 800000000) == 8\n assert candidate(chalk = [99999, 99998, 99997, 99996, 99995],k = 1000000000) == 0\n assert candidate(chalk = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 987654321) == 2\n assert candidate(chalk = [1, 10, 100, 1000, 10000, 100000],k = 999999999) == 3\n assert candidate(chalk = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105],k = 123456789) == 8\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 987654321) == 18\n assert candidate(chalk = [100, 200, 300, 400, 500],k = 1000000000) == 4\n assert candidate(chalk = [100000000, 200000000, 300000000, 400000000, 500000000],k = 1000000000) == 4\n assert candidate(chalk = [12345, 67890, 13579, 24680, 97531],k = 987654321) == 4\n assert candidate(chalk = [50000, 50000, 50000, 50000, 50000],k = 1000000000) == 0\n assert candidate(chalk = [3, 6, 1, 8, 4, 7],k = 999999999) == 3\n assert candidate(chalk = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 100000000) == 9\n assert candidate(chalk = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 543210987) == 8\n assert candidate(chalk = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 1073741823) == 8\n assert candidate(chalk = [10, 15, 20, 25, 30],k = 123456789) == 4\n assert candidate(chalk = [3, 4, 1, 2, 5, 7, 8, 9, 10, 11],k = 987654321) == 5\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 1600000000) == 24\n assert candidate(chalk = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 500000000) == 0\n assert candidate(chalk = [100000, 200000, 300000, 400000],k = 1000000000000) == 0\n assert candidate(chalk = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 456789123) == 7\n assert candidate(chalk = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 999999999) == 8\n assert candidate(chalk = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 9876543210) == 7\n assert candidate(chalk = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 1000000000) == 2\n assert candidate(chalk = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 1000000000) == 0\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 876543210) == 12\n assert candidate(chalk = [100000, 100000, 100000, 100000, 100000],k = 999999999) == 4\n assert candidate(chalk = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 1800000000) == 13\n assert candidate(chalk = [5000, 10000, 15000, 20000, 25000],k = 500000000) == 4\n assert candidate(chalk = [10, 20, 30, 40, 50],k = 9999999999) == 3\n assert candidate(chalk = [100, 200, 300, 400, 500],k = 1500000000) == 0\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 500000000) == 2\n assert candidate(chalk = [100000000, 200000000, 300000000],k = 6000000000) == 0\n assert candidate(chalk = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 123456789) == 11\n assert candidate(chalk = [99999, 1, 99998, 2, 99997, 3, 99996, 4, 99995, 5],k = 1000000000) == 0\n"}, "metadata": {"canonical_parameter_names": ["chalk", "k"], "leetcode_dataset_entry_point": "Solution().chalkReplacer", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int chalkReplacer(vector& chalk, int k) {", "container": "Solution", "callable": "chalkReplacer", "parameters": [{"name": "chalk", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1895, "task_id": "largest-magic-square", "difficulty": "Medium", "problem_description": "A k x k magic square is a k x k grid filled with integers such that every row sum, every column sum, and both diagonal sums are all equal. The integers in the magic square do not have to be distinct. Every 1 x 1 grid is trivially a magic square.\nGiven an m x n integer grid, return the size (i.e., the side length k) of the largest magic square that can be found within this grid.\n \nExample 1:\n\n\nInput: grid = [[7,1,4,5,6],[2,5,1,6,4],[1,5,4,3,2],[1,2,7,3,4]]\nOutput: 3\nExplanation: The largest magic square has a size of 3.\nEvery row sum, column sum, and diagonal sum of this magic square is equal to 12.\n- Row sums: 5+1+6 = 5+4+3 = 2+7+3 = 12\n- Column sums: 5+5+2 = 1+4+7 = 6+3+3 = 12\n- Diagonal sums: 5+4+3 = 6+4+2 = 12\n\nExample 2:\n\n\nInput: grid = [[5,1,3,1],[9,3,3,1],[1,3,3,8]]\nOutput: 2\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 50\n1 <= grid[i][j] <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[10, 20], [15, 25]]) == 1\n assert candidate(grid = [[7, 1, 4, 5, 6], [2, 5, 1, 6, 4], [1, 5, 4, 3, 2], [1, 2, 7, 3, 4]]) == 3\n assert candidate(grid = [[6, 3, 2, 8, 1, 9, 3, 2], [4, 7, 5, 4, 5, 3, 4, 7], [8, 4, 6, 8, 7, 2, 8, 1], [2, 9, 1, 5, 8, 7, 7, 3], [5, 4, 3, 1, 9, 4, 6, 3], [2, 8, 4, 9, 7, 8, 4, 1], [7, 8, 4, 5, 3, 9, 6, 4], [6, 3, 5, 9, 8, 7, 1, 9]]) == 1\n assert candidate(grid = [[8]]) == 1\n assert candidate(grid = [[16, 23, 17], [78, 32, 21], [17, 26, 79]]) == 1\n assert candidate(grid = [[5, 1, 3, 1], [9, 3, 3, 1], [1, 3, 3, 8]]) == 2\n assert candidate(grid = [[4, 3, 8, 4], [9, 5, 1, 9], [2, 7, 6, 2]]) == 3\n assert candidate(grid = [[16, 23, 17], [78, 32, 21], [17, 26, 78]]) == 1\n assert candidate(grid = [[1, 2], [3, 4]]) == 1\n assert candidate(grid = [[4, 9, 2], [3, 5, 7], [8, 1, 6]]) == 3\n assert candidate(grid = [[8, 1, 6, 13, 10], [3, 5, 7, 14, 11], [4, 9, 2, 15, 12], [15, 17, 24, 4, 5], [16, 23, 19, 6, 18]]) == 3\n assert candidate(grid = [[47, 36, 19, 73], [60, 22, 43, 19], [71, 23, 44, 39], [82, 24, 45, 40]]) == 1\n assert candidate(grid = [[2, 15, 13, 9], [16, 4, 6, 12], [9, 14, 7, 8], [10, 5, 11, 3]]) == 1\n assert candidate(grid = [[1, 16, 15, 4, 12], [8, 9, 10, 11, 14], [17, 2, 13, 14, 3], [12, 7, 6, 5, 18], [13, 8, 1, 12, 17]]) == 1\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == 1\n assert candidate(grid = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == 5\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]]) == 1\n assert candidate(grid = [[8, 1, 6, 3, 5, 7, 4, 9, 2], [3, 5, 7, 8, 1, 6, 3, 5, 7], [4, 9, 2, 3, 5, 7, 4, 9, 2], [3, 5, 7, 4, 9, 2, 3, 5, 7], [8, 1, 6, 4, 9, 2, 3, 5, 7], [3, 5, 7, 8, 1, 6, 3, 5, 7], [4, 9, 2, 3, 5, 7, 8, 1, 6], [3, 5, 7, 4, 9, 2, 8, 1, 6], [4, 9, 2, 3, 5, 7, 3, 5, 7]]) == 3\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20]]) == 1\n assert candidate(grid = [[3, 8, 4, 6], [6, 5, 7, 10], [5, 7, 8, 9], [8, 4, 5, 10]]) == 1\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [4, 3, 8, 1, 6, 7, 2, 9, 5], [9, 5, 1, 8, 4, 2, 7, 6, 3], [7, 9, 4, 8, 5, 2, 6, 3, 1], [3, 6, 7, 2, 9, 5, 8, 1, 4], [5, 8, 1, 9, 3, 6, 4, 7, 2], [2, 4, 6, 3, 1, 8, 5, 9, 7], [8, 7, 5, 6, 4, 9, 1, 2, 3], [6, 1, 9, 7, 2, 3, 5, 8, 4]]) == 1\n assert candidate(grid = [[5, 15, 25, 35, 45], [10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65]]) == 1\n assert candidate(grid = [[3, 8, 1, 2, 7], [8, 1, 2, 7, 3], [1, 2, 7, 3, 8], [2, 7, 3, 8, 1], [7, 3, 8, 1, 2]]) == 1\n assert candidate(grid = [[17, 24, 1, 8, 15], [23, 5, 7, 14, 16], [4, 6, 13, 20, 22], [10, 12, 19, 21, 3], [11, 18, 25, 2, 9]]) == 5\n assert candidate(grid = [[37, 21, 15, 13, 31], [21, 37, 31, 15, 13], [15, 21, 37, 13, 31], [31, 13, 21, 37, 15], [13, 31, 15, 21, 37]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 5\n assert candidate(grid = [[16, 3, 2, 13], [5, 10, 11, 8], [9, 6, 7, 12], [4, 15, 14, 1]]) == 4\n assert candidate(grid = [[20, 30, 25, 15, 10], [35, 25, 30, 20, 15], [20, 25, 30, 15, 35], [15, 30, 20, 25, 20], [10, 15, 25, 30, 20]]) == 1\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [8, 7, 6, 5, 4, 3, 2, 1, 9], [7, 6, 5, 4, 3, 2, 1, 9, 8], [6, 5, 4, 3, 2, 1, 9, 8, 7], [5, 4, 3, 2, 1, 9, 8, 7, 6], [4, 3, 2, 1, 9, 8, 7, 6, 5], [3, 2, 1, 9, 8, 7, 6, 5, 4], [2, 1, 9, 8, 7, 6, 5, 4, 3], [1, 9, 8, 7, 6, 5, 4, 3, 2]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 5\n assert candidate(grid = [[16, 3, 2, 13], [5, 10, 11, 8], [9, 6, 7, 12], [4, 15, 14, 1]]) == 4\n assert candidate(grid = [[2, 7, 6, 9, 5], [9, 5, 1, 9, 7], [4, 3, 8, 4, 6], [1, 8, 3, 8, 2], [5, 4, 7, 5, 9]]) == 3\n assert candidate(grid = [[2, 7, 6], [9, 5, 1], [4, 3, 8], [15, 16, 17], [18, 19, 20]]) == 3\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 1\n assert candidate(grid = [[16, 23, 17], [78, 32, 21], [17, 23, 29]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 5\n assert candidate(grid = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == 5\n assert candidate(grid = [[2, 7, 6, 1, 8], [9, 5, 1, 3, 4], [8, 1, 6, 7, 2], [4, 9, 2, 8, 5], [3, 4, 5, 9, 6]]) == 1\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]]) == 1\n assert candidate(grid = [[3, 8, 4], [1, 6, 7], [6, 7, 2], [8, 1, 6], [7, 5, 3], [4, 9, 2]]) == 1\n assert candidate(grid = [[8, 1, 6, 3, 5, 7, 4], [1, 6, 7, 8, 5, 4, 3], [6, 7, 2, 1, 3, 4, 5], [3, 5, 7, 4, 6, 8, 1], [5, 7, 4, 6, 8, 1, 3], [7, 4, 6, 8, 1, 3, 5], [4, 6, 8, 1, 3, 5, 7]]) == 1\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 7, 6, 3, 5, 9, 4, 8, 1], [4, 9, 2, 3, 5, 7, 8, 1, 6], [3, 5, 7, 4, 9, 2, 1, 6, 8], [8, 1, 6, 7, 2, 9, 4, 3, 5], [5, 4, 3, 6, 9, 2, 7, 8, 1], [6, 8, 1, 5, 3, 7, 2, 9, 4], [7, 6, 3, 1, 8, 4, 5, 2, 9]]) == 3\n assert candidate(grid = [[20, 9, 17, 12, 15, 14], [13, 18, 8, 11, 7, 10], [16, 21, 2, 14, 18, 12], [4, 19, 15, 22, 10, 6], [1, 12, 20, 17, 9, 23], [5, 24, 11, 23, 16, 4]]) == 1\n assert candidate(grid = [[3, 7, 5, 9, 11, 12], [10, 6, 14, 3, 13, 15], [4, 16, 1, 8, 17, 18], [9, 20, 12, 15, 5, 2], [13, 11, 19, 2, 6, 16], [17, 4, 22, 18, 10, 7]]) == 1\n assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [20, 30, 40, 50, 60], [30, 40, 50, 60, 70], [40, 50, 60, 70, 80]]) == 1\n assert candidate(grid = [[17, 24, 1, 8, 15], [23, 5, 7, 14, 16], [4, 6, 13, 20, 22], [10, 12, 19, 21, 3], [11, 18, 25, 2, 9]]) == 5\n assert candidate(grid = [[3, 5, 7, 9, 11], [6, 12, 4, 8, 2], [15, 1, 13, 3, 17], [10, 14, 5, 19, 16], [21, 25, 23, 20, 22]]) == 1\n assert candidate(grid = [[8, 1, 6, 3, 5, 7, 4, 9, 2], [3, 5, 7, 8, 1, 6, 9, 2, 4], [4, 9, 2, 5, 8, 1, 6, 3, 7], [9, 2, 4, 7, 3, 5, 1, 6, 8], [1, 6, 8, 2, 4, 9, 3, 7, 5], [2, 4, 9, 6, 8, 3, 7, 5, 1], [7, 3, 5, 4, 9, 2, 8, 1, 6], [5, 8, 1, 9, 6, 4, 2, 7, 3], [6, 7, 3, 1, 2, 8, 5, 4, 9]]) == 3\n assert candidate(grid = [[2, 7, 6, 9, 5, 3], [9, 5, 1, 4, 1, 1], [4, 3, 8, 2, 4, 1], [8, 1, 6, 3, 5, 2], [3, 5, 7, 5, 3, 1], [6, 9, 2, 1, 7, 5]]) == 3\n assert candidate(grid = [[8, 1, 6, 7, 10, 12], [3, 5, 7, 8, 1, 11], [4, 9, 2, 13, 6, 7], [15, 14, 13, 12, 11, 10], [9, 8, 7, 6, 5, 4], [1, 2, 3, 4, 3, 2]]) == 3\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 6\n assert candidate(grid = [[30, 20, 10, 40, 50], [25, 15, 5, 35, 45], [20, 10, 0, 30, 40], [15, 5, 40, 25, 35], [10, 0, 35, 20, 25]]) == 1\n assert candidate(grid = [[4, 3, 8, 4], [9, 5, 1, 9], [2, 7, 6, 2], [6, 1, 8, 6], [7, 5, 3, 7]]) == 3\n assert candidate(grid = [[30, 5, 25], [5, 25, 30], [25, 30, 5], [5, 30, 25], [30, 25, 5], [25, 5, 30]]) == 1\n assert candidate(grid = [[35, 1, 6, 26, 19, 24], [3, 32, 7, 21, 23, 25], [31, 9, 2, 22, 27, 20], [8, 28, 33, 17, 10, 15], [30, 5, 34, 12, 14, 18], [4, 36, 29, 13, 16, 11]]) == 3\n assert candidate(grid = [[7, 12, 1, 14, 11, 2, 5], [13, 8, 10, 3, 4, 6, 15], [1, 14, 11, 2, 5, 7, 12], [13, 8, 10, 3, 4, 6, 15], [7, 12, 1, 14, 11, 2, 5], [13, 8, 10, 3, 4, 6, 15], [1, 14, 11, 2, 5, 7, 12]]) == 1\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90], [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 10\n assert candidate(grid = [[25, 7, 2, 17], [14, 20, 16, 15], [13, 9, 6, 19], [18, 8, 23, 12]]) == 1\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20]]) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == 6\n assert candidate(grid = [[3, 10, 6, 7, 9], [1, 5, 7, 12, 8], [8, 11, 2, 5, 10], [9, 4, 3, 11, 13], [6, 7, 8, 10, 4]]) == 1\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [3, 4, 5, 6, 7]]) == 1\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == 1\n assert candidate(grid = [[4, 9, 2, 16], [3, 5, 7, 12], [8, 1, 6, 10], [13, 14, 15, 11]]) == 3\n assert candidate(grid = [[3, 8, 4, 7, 2, 9], [2, 7, 3, 8, 4, 1], [1, 6, 2, 7, 3, 5], [5, 1, 6, 2, 7, 4], [4, 5, 1, 6, 2, 8], [8, 4, 5, 1, 6, 3]]) == 1\n assert candidate(grid = [[8, 1, 6, 3, 5, 7, 4], [1, 6, 7, 8, 5, 3, 4], [6, 7, 2, 1, 9, 4, 3], [1, 2, 3, 4, 5, 6, 7], [2, 3, 4, 5, 6, 7, 8], [3, 4, 5, 6, 7, 8, 9], [4, 5, 6, 7, 8, 9, 1]]) == 1\n assert candidate(grid = [[3, 10, 4, 2, 15], [6, 8, 12, 14, 1], [9, 11, 5, 13, 7], [14, 1, 10, 6, 12], [16, 15, 9, 11, 5]]) == 1\n assert candidate(grid = [[8, 1, 6, 3, 5, 7, 4, 9, 2], [3, 5, 7, 4, 9, 2, 8, 1, 6], [4, 9, 2, 8, 1, 6, 3, 5, 7], [3, 5, 7, 4, 9, 2, 8, 1, 6], [4, 9, 2, 8, 1, 6, 3, 5, 7], [3, 5, 7, 4, 9, 2, 8, 1, 6], [4, 9, 2, 8, 1, 6, 3, 5, 7], [3, 5, 7, 4, 9, 2, 8, 1, 6], [4, 9, 2, 8, 1, 6, 3, 5, 7]]) == 3\n assert candidate(grid = [[4, 3, 8, 4], [9, 5, 1, 9], [2, 7, 6, 2], [6, 1, 8, 6]]) == 3\n assert candidate(grid = [[2, 7, 6, 9, 5, 1], [9, 5, 1, 4, 3, 8], [4, 3, 8, 2, 4, 9], [3, 8, 4, 8, 4, 3], [8, 1, 6, 6, 7, 2], [6, 7, 2, 9, 5, 1]]) == 3\n assert candidate(grid = [[3, 8, 4, 8, 4], [1, 1, 6, 7, 2], [2, 9, 6, 2, 7], [8, 2, 9, 1, 8], [4, 8, 9, 2, 8]]) == 1\n assert candidate(grid = [[47, 38, 29, 20, 11, 2], [46, 37, 30, 21, 12, 3], [45, 36, 31, 22, 13, 4], [44, 35, 32, 23, 14, 5], [43, 34, 33, 24, 15, 6], [42, 39, 40, 25, 16, 7]]) == 1\n assert candidate(grid = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65], [30, 40, 50, 60, 70]]) == 1\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 1, 4, 3, 5], [3, 5, 1, 4, 2], [4, 3, 5, 2, 1]]) == 1\n assert candidate(grid = [[15, 15, 15, 15], [15, 15, 15, 15], [15, 15, 15, 15], [15, 15, 15, 15]]) == 4\n assert candidate(grid = [[2, 7, 6, 1, 8, 1], [8, 1, 6, 7, 2, 8], [6, 7, 2, 8, 1, 6], [1, 8, 1, 6, 7, 2], [8, 1, 6, 7, 2, 8], [6, 7, 2, 8, 1, 6]]) == 1\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48, 49]]) == 1\n assert candidate(grid = [[10, 20, 30, 40], [15, 25, 35, 45], [20, 30, 40, 50], [25, 35, 45, 55], [30, 40, 50, 60]]) == 1\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().largestMagicSquare", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int largestMagicSquare(vector>& grid) {", "container": "Solution", "callable": "largestMagicSquare", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1896, "task_id": "minimum-cost-to-change-the-final-value-of-expression", "difficulty": "Hard", "problem_description": "You are given a valid boolean expression as a string expression consisting of the characters '1','0','&' (bitwise AND operator),'|' (bitwise OR operator),'(', and ')'.\n\nFor example, \"()1|1\" and \"(1)&()\" are not valid while \"1\", \"(((1))|(0))\", and \"1|(0&(1))\" are valid expressions.\n\nReturn the minimum cost to change the final value of the expression.\n\nFor example, if expression = \"1|1|(0&0)&1\", its value is 1|1|(0&0)&1 = 1|1|0&1 = 1|0&1 = 1&1 = 1. We want to apply operations so that the new expression evaluates to 0.\n\nThe cost of changing the final value of an expression is the number of operations performed on the expression. The types of operations are described as follows:\n\nTurn a '1' into a '0'.\nTurn a '0' into a '1'.\nTurn a '&' into a '|'.\nTurn a '|' into a '&'.\n\nNote: '&' does not take precedence over '|' in the order of calculation. Evaluate parentheses first, then in left-to-right order.\n \nExample 1:\n\nInput: expression = \"1&(0|1)\"\nOutput: 1\nExplanation: We can turn \"1&(0|1)\" into \"1&(0&1)\" by changing the '|' to a '&' using 1 operation.\nThe new expression evaluates to 0. \n\nExample 2:\n\nInput: expression = \"(0&0)&(0&0&0)\"\nOutput: 3\nExplanation: We can turn \"(0&0)&(0&0&0)\" into \"(0|1)|(0&0&0)\" using 3 operations.\nThe new expression evaluates to 1.\n\nExample 3:\n\nInput: expression = \"(0|(1|0&1))\"\nOutput: 1\nExplanation: We can turn \"(0|(1|0&1))\" into \"(0|(0|0&1))\" using 1 operation.\nThe new expression evaluates to 0.\n \nConstraints:\n\n1 <= expression.length <= 105\nexpression only contains '1','0','&','|','(', and ')'\nAll parentheses are properly matched.\nThere will be no empty parentheses (i.e: \"()\" is not a substring of expression).\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(expression = \"(1&(0|1&(0|1)))\") == 1\n assert candidate(expression = \"(0&1&1)|(0|1)\") == 1\n assert candidate(expression = \"(1&1)|(0&0)\") == 1\n assert candidate(expression = \"(1&((0&0)|(1|1)))\") == 1\n assert candidate(expression = \"1&(1&(1&(1&1)))\") == 1\n assert candidate(expression = \"((1|1)&(0|0))\") == 1\n assert candidate(expression = \"1&(0|1)\") == 1\n assert candidate(expression = \"((1&1)|(0&0))\") == 1\n assert candidate(expression = \"(1&1&1)|(1|1|1)\") == 2\n assert candidate(expression = \"1|1|0&1\") == 1\n assert candidate(expression = \"(0&0)|((1&1)|(0&1))\") == 1\n assert candidate(expression = \"(1&((1&1)&(1&1)))\") == 1\n assert candidate(expression = \"((1&0)|(1&1))\") == 1\n assert candidate(expression = \"(0&0&0)|(0|0|0)\") == 1\n assert candidate(expression = \"0|1&(1|0)&1\") == 1\n assert candidate(expression = \"1|1|(0&0)&1\") == 1\n assert candidate(expression = \"(((0|1)&1)|(0&0))\") == 1\n assert candidate(expression = \"(1&((0&1)|0))\") == 1\n assert candidate(expression = \"(0|(1|0&1))\") == 1\n assert candidate(expression = \"(0|((0|0)|(0|0)))\") == 1\n assert candidate(expression = \"(1&0)|(1&1)\") == 1\n assert candidate(expression = \"(0&0)&(0&0&0)\") == 3\n assert candidate(expression = \"(0|(0|(0|(0|0))))\") == 1\n assert candidate(expression = \"((1|0)&(0|1))\") == 1\n assert candidate(expression = \"(1|0|0)&(1&1)\") == 1\n assert candidate(expression = \"((1&0)|(1|0))\") == 1\n assert candidate(expression = \"(1&(1&(1&(1&1))))\") == 1\n assert candidate(expression = \"(1&1&1)|(0|0|0)\") == 1\n assert candidate(expression = \"(1|(0&(1|0)))\") == 1\n assert candidate(expression = \"(0&1)|((1|0)&(0|1))\") == 1\n assert candidate(expression = \"0|(0|(0|(0|0)))\") == 1\n assert candidate(expression = \"(1&(0|(1&0)))\") == 1\n assert candidate(expression = \"((1&(1|0))&(0|1))\") == 1\n assert candidate(expression = \"(0&(((0|1)&(1|0))|((1&0)|(0|1))))\") == 1\n assert candidate(expression = \"((0&(((1|0)|(0&1))&(1&1)))|((1|0)|(0|1)))&(1|0)\") == 1\n assert candidate(expression = \"((0&(1|0))&(0&(1|0))&(0&(1|0)))\") == 2\n assert candidate(expression = \"(0|((1&0)|(0|1)&((1|0)&(1|0))))\") == 1\n assert candidate(expression = \"((1&((1|0)|(0|1)))&((0&0)|(1&(1&(1&1)))))\") == 1\n assert candidate(expression = \"((0|1)&(1|(0|1&0))&(1|(0&(1|0))))\") == 1\n assert candidate(expression = \"((1&((0|1)&(0|1)))|((0&(1|0))&(1|0)))\") == 1\n assert candidate(expression = \"(((0|0)|(1|1))&((0|0)|(1|1))&((0|0)|(1|1))&((0|0)|(1|1)))\") == 1\n assert candidate(expression = \"(((1|0)|(0&1))&((0|1)|(0&1))&((1|0)|(0&1))&((0|1)|(0&1)))\") == 1\n assert candidate(expression = \"((0&0)&(0&0)&(1|1)&((0|0)|(1|1)))\") == 1\n assert candidate(expression = \"((1&0)|(0|1)&((1|0)&(1|0)))\") == 1\n assert candidate(expression = \"((1|0)&(1&0)|(0|1)&(1|0))\") == 1\n assert candidate(expression = \"((1|0)|(0&1)&(0|1))\") == 1\n assert candidate(expression = \"(1|(((1|0)&(0|1)))&(((0&1)|(1&1))&(1|0)))|(0|1)\") == 2\n assert candidate(expression = \"((0&(1|0)&(1|0))|(0&(0|1)&(0|1)))\") == 1\n assert candidate(expression = \"(((0|1)&(0|1))&((1&0)|(1&0))&((0|1)&(0|1))&((1&0)|(1&0)))\") == 2\n assert candidate(expression = \"(((1|1)|(0|0))&(1&(1&(1&1))))\") == 1\n assert candidate(expression = \"((1&0)|((0&1)|(1|((1&0)|(0|1)))))\") == 1\n assert candidate(expression = \"(((0&(1|0))&(1&((0&1)|(1|0))))|((1&0)|(0&((1&0)|(0&1)))))\") == 1\n assert candidate(expression = \"(((1|0)&(0|1))&((1|0)&(0|1)))|(1&(0|((1&1)|(0&0))))\") == 2\n assert candidate(expression = \"(((0|1)&(1|0))|((1&(0|1))|(0&1)))\") == 2\n assert candidate(expression = \"(0|((1&0)|(0|1)&((1|0)|(0|1)&(1|0))))\") == 1\n assert candidate(expression = \"(((0|1)|(1&0))&((0&1)|(1|0)))\") == 1\n assert candidate(expression = \"((1&0)|(1&0)|(0|1)&(0|1))\") == 1\n assert candidate(expression = \"(1|(((1|0)&(1|0))|((0&1)|(0&1))))\") == 2\n assert candidate(expression = \"(1&(0|((1&1)|(0|0))))\") == 1\n assert candidate(expression = \"(1&(((0|1)&(0|1))&((1|0)|(0|1)&(1|0))))\") == 1\n assert candidate(expression = \"((0&((0&1)|(1|0)))|((1&((0&1)|(1|0)))&(1&(0&(1|0)))))\") == 1\n assert candidate(expression = \"((1&0)|(0|1)&((1|0)|(0|1)&(1|0)))\") == 1\n assert candidate(expression = \"(1|(0&(1|0))|(0&1))\") == 1\n assert candidate(expression = \"(0|((1&1)|(0&0)))&(1&(0|((1&1)|(0&0))))\") == 1\n assert candidate(expression = \"(1|(((0&(1|0))|(1&0))&((1|0)&(0|1))))\") == 1\n assert candidate(expression = \"(((1|0)&(0|1))|((0&1)|(1|0))|((1|0)&(0|1))|((0&1)|(1|0)))\") == 2\n assert candidate(expression = \"(((1&0)|(0&1))&((0&(1|0))|(1&((0&1)|(1|0)))))\") == 1\n assert candidate(expression = \"(((1&0)|(0|1))&((1|0)|(0&1)))\") == 1\n assert candidate(expression = \"((1&0)|(1&1))&(1|0)\") == 1\n assert candidate(expression = \"(((1|1)|(0&0))&((1&1)|(0|0))|(1|0))\") == 2\n assert candidate(expression = \"((1|((0&0)|(1&1)))&(1|0))|((0|1)&(1&1))\") == 2\n assert candidate(expression = \"(((1|0)&1)|(0&(1|0)))\") == 1\n assert candidate(expression = \"((0&1)|(1&(0|1)))&((1&0)|(1|1))\") == 1\n assert candidate(expression = \"(1&((0|1)&(0|1))&(0|1))\") == 1\n assert candidate(expression = \"((0|1)|(1|0)&(0|1)&(0|1))&((0|1)|(0|1))\") == 1\n assert candidate(expression = \"(1&((0&1)|(0&(1|0))&(1|0)))\") == 1\n assert candidate(expression = \"(1|((1|0)&(0|1)))|(((0&1)|(1&1))&(1|0))\") == 2\n assert candidate(expression = \"((0&((1|0)&(0|1)))|((0&(1|0))&(1|0)))\") == 1\n assert candidate(expression = \"(((0|1)&(0|1))&((1|0)|(0|1)&(1|0)))\") == 1\n assert candidate(expression = \"(1&(((0&0)|(1|1))&(1&((0&0)|(1|1)))))|((1&(0|((1&1)|(0&0))))&(1|0))\") == 2\n assert candidate(expression = \"(((1&1)&(0|0))|(1|0)&((1&0)|(0|1))&(1|0))\") == 1\n assert candidate(expression = \"((1|(0&(1&0)))&(0|(1|0)))\") == 1\n assert candidate(expression = \"((1&(0|1))|(0&(1|0)))\") == 1\n assert candidate(expression = \"(((0|1)|(0&1))&(1|(0&0)&(1|0)))\") == 1\n assert candidate(expression = \"(1|((0|1)&(0&1))|(1&0))\") == 1\n assert candidate(expression = \"((1&0)|(1&(0|1))|(0&(1|0)))\") == 1\n assert candidate(expression = \"((0|(1&0))&(((1|0)&(0|1))|((0&1)|(1|0))))\") == 1\n assert candidate(expression = \"(1&(((0|1)|(1&0))&(0|1)))\") == 1\n assert candidate(expression = \"(((1&(0|1))&((1&0)|(0&1)))|((0&(1|0))&(1&((0&1)|(1|0)))))\") == 1\n assert candidate(expression = \"((0|1)|((1&(0|1))&(0|1)))\") == 2\n assert candidate(expression = \"((0&1)|(0&1)|(0&1)|(0&1))\") == 1\n assert candidate(expression = \"(0|(1&0)|(0|1)&(1|0))\") == 1\n assert candidate(expression = \"((1&(0|((1|0)&(1|0))))&((1&(0|((1|0)&(1|0))))&((1&(0|((1|0)&(1|0))))))\") == 1\n assert candidate(expression = \"(1|((0&0)|(1&(0|1))))\") == 2\n assert candidate(expression = \"(0|((1&((0|1)|(1|0)))&(1|0)))\") == 1\n assert candidate(expression = \"((0|((1&0)|(0|1)))&(((1|0)&(0|1))|((0&1)|(1|0))))\") == 1\n assert candidate(expression = \"(1&((0|0)|(1&0))&(0&(1|0))&(0|1))\") == 1\n assert candidate(expression = \"(((1|1)|(0|0))&(1&0))|(0|1)\") == 1\n assert candidate(expression = \"(1&(0|((0|0)&(0|0))))|((1|0)&(1&1))\") == 1\n assert candidate(expression = \"((1&(0|1))&(1|0))\") == 1\n assert candidate(expression = \"(1|((1|0)|(0|1))&(0&1))\") == 1\n assert candidate(expression = \"((1&1)|(0&(1|0)))\") == 1\n assert candidate(expression = \"(0|((1&0)|(0|1)&(1|0)))\") == 1\n assert candidate(expression = \"(1|((0&(1|0))&(1&(0|1&0))))\") == 1\n assert candidate(expression = \"((0&(1|1))|((1&0)|(0&1)))\") == 1\n assert candidate(expression = \"(1&(((1|0)|(0&1))&(1&1)))|((0|1)&(1&1))\") == 2\n assert candidate(expression = \"(((0|1)&(0|1))&((1|0)&(1|0)))\") == 1\n assert candidate(expression = \"(((0|1)&(1|0))&((1&0)|(0|1)))\") == 1\n assert candidate(expression = \"((1&((0&1)|(1|0)))&((1|0)|(0&(1|0))))|((1&(0|((1&1)|(0&0))))&(1|0))\") == 2\n assert candidate(expression = \"(((0&0)|(1&(0|1)))&((1|0)|(0&((0&1)|(1|0)))))\") == 1\n assert candidate(expression = \"(((0|1)&(1|0))|((1&0)|(0&1)))\") == 1\n assert candidate(expression = \"(1&((1|0)|(0|1))&(0&(1|0))&(0|1)&((0|0)&(1|1)))\") == 2\n assert candidate(expression = \"((1&(1&(1&0)))|((0|1)|(0&1)))\") == 1\n assert candidate(expression = \"((1|0)&(0|1)|(0&(1|0)))\") == 1\n assert candidate(expression = \"(0|((1|0)&(0|1))&(1|0))\") == 1\n assert candidate(expression = \"((1&(0|((1&0)|(0&1))))&((0&(1|0))|(1&(0|1))))\") == 1\n assert candidate(expression = \"((1&(0|1))&(1&(0|1))&(1&(0|1))&(1&(0|1)))\") == 1\n assert candidate(expression = \"(1|((0&(1|0))|(1&(0|1))))\") == 2\n assert candidate(expression = \"((1|((0&(1&0))|(0|1)))&(0&((0&(1|0))|(1&(0|1)))))\") == 1\n assert candidate(expression = \"(0&((1&0)|(1|(0&1&0))))\") == 1\n assert candidate(expression = \"(1|((0&0)&(0|0))|(0|(1&1)))\") == 2\n assert candidate(expression = \"(((1|1)&(0&0))|(1&0))\") == 1\n assert candidate(expression = \"(((0|1)&(0|1))&(1|0)&(1|0))\") == 1\n assert candidate(expression = \"((0|0)&(0|0)&(1|1)|(0|0)&(0|0))\") == 2\n assert candidate(expression = \"(0&(((1|0)|(0&1))&(1&1)))|((1|0)|(0|1))\") == 1\n assert candidate(expression = \"((0&(0|1))|(0&(0|1))|(0&(0|1))|(0&(0|1)))\") == 1\n assert candidate(expression = \"((1&0)|(0|1)&(1|0))\") == 1\n assert candidate(expression = \"((0&1)|(1&(1|0)))\") == 1\n assert candidate(expression = \"((1&(1&1))|((0|0)|(0&0)))\") == 1\n assert candidate(expression = \"((1|(0&0)&(1|0))|(0&(0|1)&(0|1))&(0&(0|1)&(0|1)))\") == 1\n assert candidate(expression = \"(((1&0)|(0&1))&((1&(0|1))|(0&1)))\") == 1\n assert candidate(expression = \"((0|((1&(0|1))|(0&(1|0))))&(1&((0&1)|(1|0))))\") == 1\n assert candidate(expression = \"(((0|0)&(0|0))&((0|0)|(0|0)))\") == 2\n assert candidate(expression = \"(1&((1&((0&0)|(1|1)))|((1|(0|1))&(0&0))))\") == 1\n assert candidate(expression = \"((0&((1|0)|(0|1)))|((1&(0|1))&(0|1)))\") == 1\n assert candidate(expression = \"(((0&(1|0))|(1&0))&((1|0)&(0|1)))\") == 1\n assert candidate(expression = \"(((1&(0|1))|(0&(1|0)))|((1&(0|1))&(0|1)))\") == 2\n assert candidate(expression = \"((0&(0&0))|((1|1)&(1|1)))\") == 1\n assert candidate(expression = \"((1&(0|1))|(0&(0|1)&(0|1)))\") == 1\n assert candidate(expression = \"(1&((0|1)|(0|1))&(0&((1|0)|(1|0))))\") == 1\n assert candidate(expression = \"(((1&(0|1))|(0&1))&(1&((0|1)|(0&(1|0)))))\") == 1\n assert candidate(expression = \"(((1|0)&(0|1))|(0&(1|0))&(1&(0|1&0)))\") == 1\n assert candidate(expression = \"((1&(0|1))|(1&0))\") == 1\n assert candidate(expression = \"(1&(((0|1)&(0|1))&((1|0)&(1|0))))\") == 1\n assert candidate(expression = \"(1&(0|1&(0|1&(1|0))))\") == 1\n assert candidate(expression = \"(((1|0)|(0&1))&((1|0)|(0&1))&((1|0)|(0&1))&((1|0)|(0&1)))\") == 1\n assert candidate(expression = \"((((0|0)|(1&1))&((0|1)&(1|0)))|((0&1)|(1|0)))\") == 2\n assert candidate(expression = \"(1|((0&0)|(1&0))&(0&(1|0))&(0|1)&((1|0)|(0|1)))\") == 1\n assert candidate(expression = \"(((0|1)&(1|0))&(0|1))\") == 1\n assert candidate(expression = \"(((1|0)|(0&1))&((1&0)|(0|1)))\") == 1\n assert candidate(expression = \"(1|(((0|1)&(1|0))|(0&(1|0))))\") == 2\n assert candidate(expression = \"(1|(((1|0)&(0|1))|(1&(0&1))))\") == 2\n assert candidate(expression = \"(((1&0)|(1|0))&((1&1)|(0|0)))\") == 1\n assert candidate(expression = \"((0|1)|((0&1)&(1|0))&(1&(0|((1&1)|(0&0)))))\") == 1\n assert candidate(expression = \"(1|(((0&0)&(0|0))|((1|1)|(1&1))))\") == 2\n assert candidate(expression = \"(0&(((1|0)|(0|1))&(0|1))&(1|0))\") == 1\n assert candidate(expression = \"((0|0)|(1&1))&(((1|0)&(0|1))|(1&1))\") == 1\n assert candidate(expression = \"((1&(0|1))|((0&1)|((1|0)&(0|1))))\") == 2\n assert candidate(expression = \"(((1&1)&(0|0))|((0|0)|(1&1)))\") == 1\n assert candidate(expression = \"(((1|0)|(1|0))&((0&1)|(0&1))&((0&1)|(0&1))&((1|0)|(1|0)))\") == 1\n assert candidate(expression = \"((1&(0|1))&((0|1)|(1&0)))\") == 1\n assert candidate(expression = \"((1&(0|1))&((0|1)&(1|0)))\") == 1\n assert candidate(expression = \"(1&((0|1)&(0|1))|(1&0)&(0&1))\") == 1\n assert candidate(expression = \"(1|((0&(1|0))|((0|1)&(1&0))))\") == 1\n assert candidate(expression = \"((1&(0|1))|((0|1)|(1&(0|1&0))))\") == 2\n assert candidate(expression = \"(((1&(0&(1|0)))|((0&(1|0))|(0&1)))&((0&1)|(1&(0&1))))\") == 2\n assert candidate(expression = \"(1&(1|(0&0)&(1|0))|(0&(0|1)&(0|1)))\") == 1\n assert candidate(expression = \"(0|((((1|0)&(0|1))|((1&0)|(0|1)))|((1&(0&0))|(0|1))))\") == 1\n assert candidate(expression = \"(((0&0)|(1|1))&((0|1)|(1|0))&((1&0)|(0|1))&((0&0)|(1|1)))\") == 1\n assert candidate(expression = \"((0&(0|1))|((1|0)&1))\") == 1\n assert candidate(expression = \"(((0|1)&(1|0))|(0&(1|0)))\") == 1\n assert candidate(expression = \"(((0&1)|(1&0))|((1&1)&(0|0)))\") == 1\n assert candidate(expression = \"((0&(1|0))|((0&1)|(1&1)))&(1|0)\") == 1\n"}, "metadata": {"canonical_parameter_names": ["expression"], "leetcode_dataset_entry_point": "Solution().minOperationsToFlip", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minOperationsToFlip(string expression) {", "container": "Solution", "callable": "minOperationsToFlip", "parameters": [{"name": "expression", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1897, "task_id": "redistribute-characters-to-make-all-strings-equal", "difficulty": "Easy", "problem_description": "You are given an array of strings words (0-indexed).\nIn one operation, pick two distinct indices i and j, where words[i] is a non-empty string, and move any character from words[i] to any position in words[j].\nReturn true if you can make every string in words equal using any number of operations, and false otherwise.\n \nExample 1:\n\nInput: words = [\"abc\",\"aabc\",\"bc\"]\nOutput: true\nExplanation: Move the first 'a' in words[1] to the front of words[2],\nto make words[1] = \"abc\" and words[2] = \"abc\".\nAll the strings are now equal to \"abc\", so return true.\n\nExample 2:\n\nInput: words = [\"ab\",\"a\"]\nOutput: false\nExplanation: It is impossible to make all the strings equal using the operation.\n\n \nConstraints:\n\n1 <= words.length <= 100\n1 <= words[i].length <= 100\nwords[i] consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words = ['abc', 'def', 'ghi', 'jkl']) == False\n assert candidate(words = ['aabbcc', 'abc', 'abc', 'abc']) == False\n assert candidate(words = ['abcd', 'dcba', 'abcd', 'dcba']) == True\n assert candidate(words = ['abcd', 'bcad', 'acdb', 'bdac']) == True\n assert candidate(words = ['hello', 'olelh', 'loleh']) == True\n assert candidate(words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']) == False\n assert candidate(words = ['a', 'a', 'a', 'a']) == True\n assert candidate(words = ['test', 'sett', 'stte']) == True\n assert candidate(words = ['abc', 'def', 'ghi']) == False\n assert candidate(words = ['xyz', 'zyx', 'yzx']) == True\n assert candidate(words = ['abcde', 'fghij', 'klmno', 'pqrst', 'uvwxy']) == False\n assert candidate(words = ['ab', 'a']) == False\n assert candidate(words = ['same', 'same', 'same']) == True\n assert candidate(words = ['abcd', 'abcd', 'abcd', 'abcd']) == True\n assert candidate(words = ['one', 'two', 'three']) == False\n assert candidate(words = ['abc', 'aabc', 'bc']) == True\n assert candidate(words = ['aabbcc', 'abc', 'abc']) == False\n assert candidate(words = ['abcd', 'abcd', 'abcd']) == True\n assert candidate(words = ['same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same']) == True\n assert candidate(words = ['aabb', 'bbcc', 'ccdd', 'aabb', 'bbcc', 'ccdd', 'aabb', 'bbcc', 'ccdd']) == False\n assert candidate(words = ['abcdefghijklmnop', 'abcdefghijklmnop', 'abcdefghijklmnop', 'abcdefghijklmnop']) == True\n assert candidate(words = ['xyz', 'zyx', 'yzx', 'zxy', 'yxz', 'xzy']) == True\n assert candidate(words = ['zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz', 'zzzzzzzz']) == True\n assert candidate(words = ['repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat']) == True\n assert candidate(words = ['abcdabcd', 'bacdbacd', 'cdabdcab', 'dcbadacb']) == True\n assert candidate(words = ['xyz', 'yzx', 'zxy', 'zyx', 'yxz', 'xzy']) == True\n assert candidate(words = ['abcdefg', 'ghfedcb', 'fedcbaa', 'bcaefgd', 'abcdefg', 'ghfedcb', 'fedcbaa', 'bcaefgd', 'abcdefg', 'ghfedcb']) == False\n assert candidate(words = ['abcde', 'bcdea', 'cdeab', 'deabc', 'eabcd', 'fghij', 'ghijf', 'hijfg', 'ijfgh', 'jfgih']) == False\n assert candidate(words = ['hello', 'bello', 'hallo', 'hellb', 'hella', 'bellh', 'hblla']) == False\n assert candidate(words = ['abcde', 'edcba', 'bcdea', 'decab', 'acdeb']) == True\n assert candidate(words = ['hello', 'lohel', 'ohell', 'llohe', 'elloh']) == True\n assert candidate(words = ['python', 'typhon', 'typhno', 'hypton', 'hptyon', 'phyton', 'ptyhno', 'thpyon', 'ptyhon', 'phytom']) == False\n assert candidate(words = ['abacabadabacaba', 'bacabacabadabacab', 'acabacabadabacaba', 'cabacabadabacabaa']) == False\n assert candidate(words = ['aabbcc', 'abcabc', 'ccbaab', 'bcaacb']) == True\n assert candidate(words = ['aabbcc', 'abcabc', 'baccab', 'cbbaca', 'acabcb', 'bcacab']) == True\n assert candidate(words = ['hello', 'world', 'owrld', 'dlrow', 'llhow']) == False\n assert candidate(words = ['abcdef', 'fedcba', 'defabc', 'cabdef', 'bacdef', 'fabcde']) == True\n assert candidate(words = ['xyx', 'yxy', 'xyx', 'xyx', 'xyx', 'xyx', 'xyx', 'xyx', 'xyx', 'xyx']) == False\n assert candidate(words = ['mnopqr', 'nopqrm', 'opqrmn', 'pqrmno', 'qrmnop', 'rmnopq', 'mnopqr', 'nopqrm', 'opqrmn', 'pqrmno', 'qrmnop', 'rmnopq', 'mnopqr', 'nopqrm', 'opqrmn', 'pqrmno', 'qrmnop', 'rmnopq']) == True\n assert candidate(words = ['equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal', 'equal']) == True\n assert candidate(words = ['aabbcc', 'bbaacc', 'ccaabb', 'aabbbc', 'bbccaa']) == False\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']) == False\n assert candidate(words = ['unique', 'queuni', 'neuqui', 'uqinue', 'unei qu', 'nueiqu', 'einuq', 'uiqune', 'inuqeu', 'uqneui']) == False\n assert candidate(words = ['aaa', 'bbb', 'ccc', 'aaa', 'bbb', 'ccc', 'aaa', 'bbb', 'ccc']) == True\n assert candidate(words = ['qwertyuiop', 'poiuytrewq', 'oiuytrewqp', 'iuytrewqpo', 'uytrewqpoi', 'ytrewqpoiu']) == True\n assert candidate(words = ['abcdefg', 'bcdefga', 'cdefgab', 'defgabc', 'efgabcd', 'fgabcde', 'gabcdef']) == True\n assert candidate(words = ['aabb', 'bbaa', 'abab', 'abba', 'baab', 'baba', 'aaab', 'aaba', 'abaa', 'baaa', 'bbaa', 'abab', 'abba', 'baab', 'baba', 'aaab', 'aaba', 'abaa', 'baaa', 'bbaa']) == False\n assert candidate(words = ['aabbcc', 'abcabc', 'bcaabc', 'cababc']) == True\n assert candidate(words = ['apple', 'ppale', 'pleap', 'elppa', 'lappe']) == True\n assert candidate(words = ['aabbccddeeffgghhiijjooppllnnmmbbkkqqwwaass', 'aabbccddeeffgghhiijjooppllnnmmbbkkqqwwaass', 'aabbccddeeffgghhiijjooppllnnmmbbkkqqwwaass', 'aabbccddeeffgghhiijjooppllnnmmbbkkqqwwaass']) == True\n assert candidate(words = ['aabbcc', 'bbccaa', 'ccaabb']) == True\n assert candidate(words = ['abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba']) == True\n assert candidate(words = ['xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx', 'xy', 'yx']) == True\n assert candidate(words = ['aaaa', 'bbbb', 'cccc', 'dddd', 'eeee']) == False\n assert candidate(words = ['same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same']) == True\n assert candidate(words = ['same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same']) == True\n assert candidate(words = ['aabbcc', 'abcabc', 'ccbaab']) == True\n assert candidate(words = ['unique', 'uniqueness', 'uniquely', 'uniques']) == False\n assert candidate(words = ['aaaaab', 'aaabbb', 'aabbbb', 'abbbbb', 'bbbbbz']) == False\n assert candidate(words = ['python', 'typhon', 'nothpy', 'hnotyp', 'npytho']) == True\n assert candidate(words = ['aabbcc', 'abcabc', 'ccbaab', 'baccab']) == True\n assert candidate(words = ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']) == True\n assert candidate(words = ['abcdef', 'bcdefa', 'cdefab', 'defabc', 'efabcd', 'fabcde', 'abcdef', 'bcdefa', 'cdefab', 'defabc', 'efabcd', 'fabcde']) == True\n assert candidate(words = ['xyz', 'zyx', 'yzx', 'xzy']) == True\n assert candidate(words = ['unique', 'characters', 'only', 'in', 'each', 'string', 'here']) == False\n assert candidate(words = ['abcdefgh', 'hgfedcba', 'abcdefg', 'gfedcba', 'abcdef', 'fedcba', 'abcde', 'edcba', 'abcd', 'dcba', 'abc', 'cba', 'ab', 'ba', 'a', 'b']) == False\n assert candidate(words = ['qwertyuiop', 'asdfghjkl', 'zxcvbnm', 'qwertyuiop', 'asdfghjkl', 'zxcvbnm', 'qwertyuiop', 'asdfghjkl', 'zxcvbnm']) == False\n assert candidate(words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty']) == False\n assert candidate(words = ['abracadabra', 'cadabraab', 'rabracada', 'abracadab', 'acadabrabr']) == False\n assert candidate(words = ['abcdef', 'bcdefa', 'cdefab', 'defabc', 'efabcd', 'fabcde']) == True\n assert candidate(words = ['qqq', 'www', 'eee', 'rrr', 'ttt', 'yyy', 'uuu', 'iii', 'ooo', 'ppp', 'lll', 'mmm', 'nnn', 'sss', 'ddd', 'fff', 'ggg', 'hhh', 'jjj', 'kkk']) == False\n assert candidate(words = ['apple', 'ppale', 'pplea', 'pelap', 'pepla']) == True\n assert candidate(words = ['racecar', 'carrace', 'ecarrac', 'rraceca', 'acecarr']) == True\n assert candidate(words = ['abcdefgh', 'hgfedcba', 'bacdefgh', 'defghabc', 'efghabcd']) == True\n assert candidate(words = ['abc', 'abcabc', 'abcabcabc', 'abcabcabcabc', 'abcabcabcabcabc', 'abcabcabcabcabcabc', 'abcabcabcabcabcabcabc', 'abcabcabcabcabcabcabcabc', 'abcabcabcabcabcabcabcabcabc', 'abcabcabcabcabcabcabcabcabcabc']) == False\n assert candidate(words = ['mississippi', 'ppiimiss', 'pisimmpi', 'ssippiim', 'pmissipi', 'iimpsspi', 'sspiimp', 'misipip', 'sipimp', 'impispi']) == False\n assert candidate(words = ['unique', 'enquie', 'unieqe', 'inequeu', 'niuquee', 'uqneiee', 'qnueiee']) == False\n assert candidate(words = ['aabbcc', 'abcabc', 'bcaabc', 'cababc', 'bcacab']) == True\n assert candidate(words = ['xyz', 'zyx', 'yzx', 'xzy', 'yxz']) == True\n assert candidate(words = ['abcdabcd', 'dcbaabcd', 'abcdcdab', 'dcabcdab']) == True\n assert candidate(words = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd', 'eeeee', 'ffffff', 'gggggg', 'hhhhh', 'iiiii', 'jjjjj']) == False\n assert candidate(words = ['hello', 'world', 'world', 'hello']) == False\n assert candidate(words = ['aaa', 'bbb', 'ccc', 'aab', 'bbc', 'cca']) == True\n assert candidate(words = ['aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz', 'zzxyyxwwvvttsrrqpponmlkjihgfedcba', 'abcdefghijlkmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba', 'zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba', 'qrstuvwxyzzyxwvutsrqponmlkjihgfedcbaabcd']) == False\n assert candidate(words = ['zzzz', 'zzz', 'zz', 'z']) == False\n assert candidate(words = ['python', 'programming', 'challenge', 'easy']) == False\n assert candidate(words = ['qwerty', 'wertyq', 'ertyqw', 'rtyqwe', 'tyqwre', 'yqwret', 'qwertyui', 'wertyuiq', 'ertyuiqw', 'rtyuiqwe', 'tyuiqwre', 'yuiqwret']) == False\n assert candidate(words = ['hello', 'olleh', 'loleh', 'elloh', 'lhleo', 'heoll']) == True\n assert candidate(words = ['abacabadabacaba', 'bacabacabacaba', 'cabacabacabacaba', 'dacabacabacaba', 'eacabacabacaba', 'facabacabacaba', 'gacabacabacaba', 'hacabacabacaba', 'iacabacabacaba', 'jacobacabacaba', 'kacabacabacaba']) == False\n"}, "metadata": {"canonical_parameter_names": ["words"], "leetcode_dataset_entry_point": "Solution().makeEqual", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool makeEqual(vector& words) {", "container": "Solution", "callable": "makeEqual", "parameters": [{"name": "words", "type": "vector&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1898, "task_id": "maximum-number-of-removable-characters", "difficulty": "Medium", "problem_description": "You are given two strings s and p where p is a subsequence of s. You are also given a distinct 0-indexed integer array removable containing a subset of indices of s (s is also 0-indexed).\nYou want to choose an integer k (0 <= k <= removable.length) such that, after removing k characters from s using the first k indices in removable, p is still a subsequence of s. More formally, you will mark the character at s[removable[i]] for each 0 <= i < k, then remove all marked characters and check if p is still a subsequence.\nReturn the maximum k you can choose such that p is still a subsequence of s after the removals.\nA subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.\n \nExample 1:\n\nInput: s = \"abcacb\", p = \"ab\", removable = [3,1,0]\nOutput: 2\nExplanation: After removing the characters at indices 3 and 1, \"abcacb\" becomes \"accb\".\n\"ab\" is a subsequence of \"accb\".\nIf we remove the characters at indices 3, 1, and 0, \"abcacb\" becomes \"ccb\", and \"ab\" is no longer a subsequence.\nHence, the maximum k is 2.\n\nExample 2:\n\nInput: s = \"abcbddddd\", p = \"abcd\", removable = [3,2,1,4,5,6]\nOutput: 1\nExplanation: After removing the character at index 3, \"abcbddddd\" becomes \"abcddddd\".\n\"abcd\" is a subsequence of \"abcddddd\".\n\nExample 3:\n\nInput: s = \"abcab\", p = \"abc\", removable = [0,1,2,3,4]\nOutput: 0\nExplanation: If you remove the first index in the array removable, \"abc\" is no longer a subsequence.\n\n \nConstraints:\n\n1 <= p.length <= s.length <= 105\n0 <= removable.length < s.length\n0 <= removable[i] < s.length\np is a subsequence of s.\ns and p both consist of lowercase English letters.\nThe elements in removable are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"pqrstu\",p = \"psu\",removable = [5, 4, 3, 2, 1, 0]) == 0\n assert candidate(s = \"abcdefghij\",p = \"acegi\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(s = \"deeddeede\",p = \"dee\",removable = [5, 3, 4, 6]) == 4\n assert candidate(s = \"deeedbbcccbdaa\",p = \"ddccbb\",removable = [8, 2, 3, 0, 7]) == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",p = \"acegikmoqsuwy\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 13\n assert candidate(s = \"zzzzzzzzzz\",p = \"zz\",removable = [1, 3, 5, 7]) == 4\n assert candidate(s = \"aaaabbbb\",p = \"ab\",removable = [2, 3, 4, 5]) == 4\n assert candidate(s = \"abcdef\",p = \"abc\",removable = [5, 4, 3, 2, 1, 0]) == 3\n assert candidate(s = \"aabcbcb\",p = \"abc\",removable = [3, 1, 0, 4]) == 2\n assert candidate(s = \"abcdxyz\",p = \"ad\",removable = [0, 1, 2, 3, 4, 5, 6]) == 0\n assert candidate(s = \"abcacb\",p = \"ab\",removable = [3, 1, 0]) == 2\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",p = \"acegikmoqsuwy\",removable = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 0\n assert candidate(s = \"ababababab\",p = \"aaaa\",removable = [0, 2, 4, 6, 8]) == 1\n assert candidate(s = \"mississippi\",p = \"issi\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(s = \"zpqom\",p = \"z\",removable = [0, 1, 2, 3, 4]) == 0\n assert candidate(s = \"abcab\",p = \"abc\",removable = [0, 1, 2, 3, 4]) == 0\n assert candidate(s = \"xyz\",p = \"xyz\",removable = [0, 1, 2]) == 0\n assert candidate(s = \"abcdef\",p = \"af\",removable = [1, 2, 3, 4]) == 4\n assert candidate(s = \"abcbddddd\",p = \"abcd\",removable = [3, 2, 1, 4, 5, 6]) == 1\n assert candidate(s = \"zazbzczdzezfzgzhzi\",p = \"abcdefg\",removable = [0, 2, 4, 6, 8, 10, 12, 14, 16]) == 9\n assert candidate(s = \"pythonprogramming\",p = \"ppn\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == 0\n assert candidate(s = \"thisisaverylongstringthatweneedtoremovesomecharactersfrom\",p = \"thisisalong\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 0\n assert candidate(s = \"mississippi\",p = \"miss\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(s = \"onetwothreefourfivesixseveneightnine\",p = \"onefivesix\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]) == 0\n assert candidate(s = \"abcdefghijklnmopqrstuvwxyz\",p = \"zyxwvutsrqponmlkjihgfedcba\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n assert candidate(s = \"abracadabra\",p = \"aca\",removable = [1, 3, 5, 7, 9, 10]) == 5\n assert candidate(s = \"leetcodeleetcodeleetcode\",p = \"leetcode\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]) == 16\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",p = \"qwerty\",removable = [0, 1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15, 20, 21, 22, 23, 24, 25, 30, 31, 32, 33, 34, 35]) == 0\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",p = \"zzzz\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == 30\n assert candidate(s = \"abracadabra\",p = \"aa\",removable = [0, 2, 4, 6, 8, 10]) == 6\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",p = \"zzz\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]) == 29\n assert candidate(s = \"abacabadabacaba\",p = \"abc\",removable = [2, 5, 8, 11, 14]) == 5\n assert candidate(s = \"abcdefghijklm\",p = \"abc\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(s = \"zzzzzzzzzz\",p = \"zz\",removable = [1, 3, 5, 7, 9]) == 5\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\",p = \"quickbrownfox\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 3\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",p = \"abcdefghijklmnopqrstuvwxyz\",removable = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 2\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",p = \"zzzzz\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 15\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",p = \"az\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) == 0\n assert candidate(s = \"abcdeffedcba\",p = \"abcdef\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 0\n assert candidate(s = \"mississippi\",p = \"issi\",removable = [2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(s = \"abcdefghijklmno\",p = \"def\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == 3\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",p = \"zzzz\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 16\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",p = \"pus\",removable = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47]) == 7\n assert candidate(s = \"aaaaaaabbbbbbb\",p = \"aabbb\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 5\n assert candidate(s = \"abcdefghijklmnop\",p = \"mnop\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 12\n assert candidate(s = \"xyxzyzyzyxzyzyzyx\",p = \"xyz\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 9\n assert candidate(s = \"banana\",p = \"ban\",removable = [0, 2, 4]) == 0\n assert candidate(s = \"aaaabbbbccccdddd\",p = \"abcd\",removable = [3, 7, 11, 15]) == 4\n assert candidate(s = \"abracadabra\",p = \"aca\",removable = [1, 3, 5, 7, 9]) == 5\n assert candidate(s = \"banana\",p = \"ban\",removable = [0, 1, 2, 3, 4, 5]) == 0\n assert candidate(s = \"abcdefffffghijklmnopqrstuvwxyz\",p = \"acegikmoqsuwy\",removable = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]) == 10\n assert candidate(s = \"aabbccddeeffgghhii\",p = \"abcdefghi\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17]) == 9\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",p = \"abcdefghijklmnopqrstuvwxzy\",removable = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38]) == 0\n assert candidate(s = \"abcdabcdabcd\",p = \"abc\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 8\n assert candidate(s = \"thisisateststring\",p = \"tst\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 20, 21, 22, 23, 24]) == 5\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",p = \"qz\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n assert candidate(s = \"abcabcabcabcabc\",p = \"abcabcabc\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17]) == 4\n assert candidate(s = \"xyzzxyzzxyzz\",p = \"xyz\",removable = [0, 2, 4, 6, 8, 10]) == 4\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",p = \"abcdefghijklmnopqrstuvwxyz\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]) == 1\n assert candidate(s = \"aaaaaaaaaaa\",p = \"aaaaa\",removable = [1, 3, 5, 7, 9]) == 5\n assert candidate(s = \"abcdabcdabcdabcdabcdabcd\",p = \"abcd\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == 20\n assert candidate(s = \"abababababababababab\",p = \"aabbaabb\",removable = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]) == 4\n assert candidate(s = \"hellohellohellohello\",p = \"heo\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]) == 15\n assert candidate(s = \"xyzzxyzzxyzz\",p = \"xyz\",removable = [1, 3, 5, 7, 9, 11]) == 4\n assert candidate(s = \"mississippi\",p = \"issi\",removable = [3, 1, 0, 4, 5, 2, 6, 7, 8, 9, 10]) == 3\n assert candidate(s = \"abracadabra\",p = \"ac\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(s = \"bcaabcbabcabc\",p = \"abc\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 10\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",p = \"zzz\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 10\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",p = \"bdfhjlnprtvxz\",removable = [1, 5, 9, 13, 17, 21, 25]) == 0\n assert candidate(s = \"abcdeffedcba\",p = \"abcdef\",removable = [0, 2, 4, 6, 8, 10]) == 0\n assert candidate(s = \"findinganagrams\",p = \"anag\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17]) == 3\n assert candidate(s = \"mississippi\",p = \"miss\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",p = \"adgjmpsvy\",removable = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == 0\n assert candidate(s = \"hellotherehowareyou\",p = \"heoy\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17]) == 4\n assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",p = \"xyz\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 0\n assert candidate(s = \"aaaaabbbbbcccc\",p = \"abc\",removable = [5, 6, 7, 8, 9, 10]) == 4\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",p = \"pneumo\",removable = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54]) == 0\n assert candidate(s = \"thisisaverylongstring\",p = \"tils\",removable = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 3\n assert candidate(s = \"leetcodeleetcodeleetcodeleetcode\",p = \"leetcodelt\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 16\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",p = \"acegikmoqsuwy\",removable = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 12\n assert candidate(s = \"abcdefghijabcdefghij\",p = \"acegik\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 0\n assert candidate(s = \"nnnnoooooommmm\",p = \"nom\",removable = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 3\n"}, "metadata": {"canonical_parameter_names": ["s", "p", "removable"], "leetcode_dataset_entry_point": "Solution().maximumRemovals", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumRemovals(string s, string p, vector& removable) {", "container": "Solution", "callable": "maximumRemovals", "parameters": [{"name": "s", "type": "string"}, {"name": "p", "type": "string"}, {"name": "removable", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1899, "task_id": "merge-triplets-to-form-target-triplet", "difficulty": "Medium", "problem_description": "A triplet is an array of three integers. You are given a 2D integer array triplets, where triplets[i] = [ai, bi, ci] describes the ith triplet. You are also given an integer array target = [x, y, z] that describes the triplet you want to obtain.\nTo obtain target, you may apply the following operation on triplets any number of times (possibly zero):\n\nChoose two indices (0-indexed) i and j (i != j) and update triplets[j] to become [max(ai, aj), max(bi, bj), max(ci, cj)].\n\n\t\nFor example, if triplets[i] = [2, 5, 3] and triplets[j] = [1, 7, 5], triplets[j] will be updated to [max(2, 1), max(5, 7), max(3, 5)] = [2, 7, 5].\n\n\n\nReturn true if it is possible to obtain the target triplet [x, y, z] as an element of triplets, or false otherwise.\n \nExample 1:\n\nInput: triplets = [[2,5,3],[1,8,4],[1,7,5]], target = [2,7,5]\nOutput: true\nExplanation: Perform the following operations:\n- Choose the first and last triplets [[2,5,3],[1,8,4],[1,7,5]]. Update the last triplet to be [max(2,1), max(5,7), max(3,5)] = [2,7,5]. triplets = [[2,5,3],[1,8,4],[2,7,5]]\nThe target triplet [2,7,5] is now an element of triplets.\n\nExample 2:\n\nInput: triplets = [[3,4,5],[4,5,6]], target = [3,2,5]\nOutput: false\nExplanation: It is impossible to have [3,2,5] as an element because there is no 2 in any of the triplets.\n\nExample 3:\n\nInput: triplets = [[2,5,3],[2,3,4],[1,2,5],[5,2,3]], target = [5,5,5]\nOutput: true\nExplanation: Perform the following operations:\n- Choose the first and third triplets [[2,5,3],[2,3,4],[1,2,5],[5,2,3]]. Update the third triplet to be [max(2,1), max(5,2), max(3,5)] = [2,5,5]. triplets = [[2,5,3],[2,3,4],[2,5,5],[5,2,3]].\n- Choose the third and fourth triplets [[2,5,3],[2,3,4],[2,5,5],[5,2,3]]. Update the fourth triplet to be [max(2,5), max(5,2), max(5,3)] = [5,5,5]. triplets = [[2,5,3],[2,3,4],[2,5,5],[5,5,5]].\nThe target triplet [5,5,5] is now an element of triplets.\n\n \nConstraints:\n\n1 <= triplets.length <= 105\ntriplets[i].length == target.length == 3\n1 <= ai, bi, ci, x, y, z <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6]],target = [1, 2, 3]) == True\n assert candidate(triplets = [[3, 4, 5], [4, 5, 6]],target = [3, 2, 5]) == False\n assert candidate(triplets = [[2, 5, 3], [1, 8, 4], [1, 7, 5]],target = [2, 7, 5]) == True\n assert candidate(triplets = [[1000, 1000, 1000]],target = [1000, 1000, 1000]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3]],target = [1, 2, 3]) == False\n assert candidate(triplets = [[1, 2, 3], [3, 2, 1], [2, 3, 1]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],target = [1, 2, 3]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[5, 5, 5], [5, 5, 5], [5, 5, 5]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],target = [1, 1, 1]) == True\n assert candidate(triplets = [[2, 5, 3], [2, 3, 4], [1, 2, 5], [5, 2, 3]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 3, 3], [3, 1, 3], [3, 3, 1]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],target = [7, 8, 9]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 2, 4], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1000, 1, 1], [1, 1000, 1], [1, 1, 1000], [500, 500, 500]],target = [1000, 1000, 1000]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]],target = [6, 6, 6]) == True\n assert candidate(triplets = [[1, 1, 2], [1, 2, 1], [2, 1, 1], [1, 1, 3], [1, 3, 1], [3, 1, 1], [1, 2, 2], [2, 1, 2], [2, 2, 1]],target = [1, 2, 2]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]],target = [1, 2, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 1, 1], [10, 10, 10]],target = [7, 8, 9]) == True\n assert candidate(triplets = [[100, 1, 1], [1, 100, 1], [1, 1, 100], [50, 50, 50], [10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40]],target = [50, 50, 50]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],target = [13, 14, 15]) == True\n assert candidate(triplets = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9], [9, 10, 11]],target = [9, 10, 11]) == True\n assert candidate(triplets = [[999, 1, 1], [1, 999, 1], [1, 1, 999], [1000, 1000, 1000]],target = [999, 999, 999]) == True\n assert candidate(triplets = [[1, 2, 3], [3, 2, 1], [2, 3, 1], [3, 1, 2], [1, 3, 2], [2, 1, 3], [1, 1, 1]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 2, 2], [2, 1, 2], [2, 2, 1], [1, 2, 1], [2, 1, 1]],target = [2, 2, 2]) == True\n assert candidate(triplets = [[2, 5, 3], [1, 8, 4], [1, 7, 5], [3, 2, 1], [6, 6, 6], [9, 9, 9]],target = [3, 8, 9]) == False\n assert candidate(triplets = [[2, 5, 3], [1, 8, 4], [1, 7, 5], [3, 2, 1], [6, 6, 6], [9, 9, 9]],target = [2, 7, 5]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 2], [1, 2, 1], [2, 1, 1], [1, 2, 2], [2, 1, 2], [2, 2, 1], [2, 2, 2]],target = [2, 2, 2]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]],target = [10, 10, 10]) == True\n assert candidate(triplets = [[2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8]],target = [6, 7, 8]) == True\n assert candidate(triplets = [[1, 1000, 1], [2, 2, 999], [3, 3, 3], [4, 4, 4], [5, 5, 5]],target = [5, 1000, 999]) == True\n assert candidate(triplets = [[1000, 1, 1], [1, 1000, 1], [1, 1, 1000]],target = [1000, 1000, 1000]) == True\n assert candidate(triplets = [[999, 999, 999], [1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8]],target = [999, 999, 999]) == True\n assert candidate(triplets = [[1000, 1000, 1000], [999, 999, 999], [1, 1, 1]],target = [1000, 1000, 1000]) == True\n assert candidate(triplets = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 1], [10, 1, 2]],target = [10, 10, 10]) == True\n assert candidate(triplets = [[9, 8, 7], [6, 5, 4], [3, 2, 1], [10, 11, 12]],target = [10, 11, 12]) == True\n assert candidate(triplets = [[1000, 1000, 1000], [999, 999, 999], [998, 998, 998], [1, 2, 3]],target = [1000, 1000, 1000]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [2, 2, 2], [2, 2, 2], [2, 2, 2], [3, 3, 3], [3, 3, 3], [3, 3, 3]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [3, 2, 1], [2, 3, 1], [1, 3, 2]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],target = [4, 5, 6]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [3, 2, 1]],target = [4, 5, 6]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]],target = [7, 8, 9]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1], [1, 1, 1], [2, 2, 2], [3, 3, 3]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 3, 1], [2, 1, 2], [3, 2, 3], [4, 3, 4], [5, 4, 5]],target = [5, 5, 5]) == False\n assert candidate(triplets = [[1, 2, 3], [1, 2, 2], [2, 2, 3], [2, 2, 2], [3, 2, 3], [3, 2, 2], [3, 3, 3], [6, 6, 6], [9, 9, 9]],target = [9, 9, 9]) == True\n assert candidate(triplets = [[9, 5, 1], [5, 9, 1], [1, 9, 5], [5, 1, 9], [9, 1, 5]],target = [9, 9, 9]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1000, 1, 1], [1, 1000, 1], [1, 1, 1000], [1000, 1000, 1000]],target = [1000, 1000, 1000]) == True\n assert candidate(triplets = [[1, 3, 2], [3, 2, 1], [2, 1, 3], [4, 4, 4]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 9, 1], [1, 1, 9], [9, 1, 1], [9, 9, 9], [5, 5, 5], [4, 4, 4], [3, 3, 3], [2, 2, 2], [1, 1, 1]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[3, 3, 3], [3, 3, 3], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[5, 5, 5], [5, 5, 5], [5, 5, 5], [1, 2, 3], [4, 5, 6], [7, 8, 9]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[9, 9, 9], [8, 8, 8], [7, 7, 7], [6, 6, 6], [5, 5, 5], [4, 4, 4], [3, 3, 3], [2, 2, 2], [1, 1, 1]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 1, 2], [2, 2, 3], [3, 3, 4], [4, 4, 5]],target = [3, 3, 4]) == True\n assert candidate(triplets = [[1, 3, 1], [2, 1, 2], [3, 2, 1], [1, 2, 3], [2, 3, 1], [3, 1, 2]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9]],target = [7, 8, 9]) == True\n assert candidate(triplets = [[1, 9, 9], [9, 1, 9], [9, 9, 1], [3, 3, 3], [2, 2, 2], [4, 4, 4]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [2, 3, 4], [5, 6, 7], [8, 9, 10], [3, 4, 5], [6, 7, 8], [9, 10, 11]],target = [7, 8, 9]) == True\n assert candidate(triplets = [[1, 3, 5], [3, 5, 1], [5, 1, 3], [2, 4, 6], [4, 6, 2], [6, 2, 4]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 2, 3], [1, 2, 3], [2, 3, 4], [2, 3, 4]],target = [2, 3, 4]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 1, 1], [10, 10, 10], [2, 2, 2], [3, 3, 3], [5, 5, 5]],target = [4, 5, 6]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],target = [1, 1, 1]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7]],target = [7, 7, 7]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 2, 4], [2, 3, 4], [3, 4, 5], [4, 5, 6]],target = [4, 5, 6]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 2], [2, 1, 1], [2, 1, 2], [1, 2, 1], [1, 2, 2], [2, 2, 1], [2, 2, 2]],target = [2, 2, 2]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [1, 5, 1], [5, 1, 5], [1, 5, 5]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[10, 20, 30], [10, 25, 35], [15, 25, 30], [10, 20, 35], [10, 25, 30], [15, 20, 30]],target = [15, 25, 30]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [1, 5, 6], [4, 2, 6], [4, 5, 3]],target = [4, 5, 6]) == True\n assert candidate(triplets = [[1, 3, 5], [2, 2, 2], [3, 1, 4], [4, 4, 4], [5, 5, 5]],target = [5, 4, 5]) == False\n assert candidate(triplets = [[1, 1, 2], [1, 2, 1], [2, 1, 1], [1, 2, 2], [2, 2, 1], [2, 1, 2], [2, 2, 2]],target = [2, 2, 2]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],target = [15, 15, 15]) == False\n assert candidate(triplets = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [999, 999, 999]],target = [999, 999, 999]) == True\n assert candidate(triplets = [[2, 5, 3], [1, 8, 4], [1, 7, 5], [2, 7, 5], [5, 7, 5], [2, 7, 9]],target = [2, 7, 5]) == True\n assert candidate(triplets = [[1, 1, 2], [1, 2, 1], [2, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[5, 1, 1], [1, 5, 1], [1, 1, 5], [1, 1, 1], [1, 1, 1]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 2, 2], [2, 2, 2], [2, 3, 3], [3, 3, 3]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [1, 2, 3], [2, 1, 3], [3, 2, 1]],target = [3, 3, 3]) == False\n assert candidate(triplets = [[500, 1, 1], [1, 500, 1], [1, 1, 500], [1, 1, 1], [1, 1, 1], [1, 1, 1]],target = [500, 500, 500]) == True\n assert candidate(triplets = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10]],target = [6, 7, 8]) == True\n assert candidate(triplets = [[1, 100, 1], [100, 1, 1], [1, 1, 100], [100, 100, 1], [100, 1, 100], [1, 100, 100]],target = [100, 100, 100]) == True\n assert candidate(triplets = [[1, 5, 3], [1, 8, 4], [1, 7, 5], [1, 7, 9], [2, 5, 5], [1, 8, 8], [1, 7, 7]],target = [1, 8, 8]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 2, 1], [1, 1, 2], [2, 1, 1], [2, 2, 1], [2, 1, 2], [1, 2, 2], [2, 2, 2]],target = [2, 2, 2]) == True\n assert candidate(triplets = [[3, 2, 1], [2, 1, 3], [1, 3, 2], [3, 3, 3]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]],target = [10, 11, 12]) == True\n assert candidate(triplets = [[10, 10, 10], [20, 20, 20], [30, 30, 30], [40, 40, 40], [50, 50, 50]],target = [30, 30, 30]) == True\n assert candidate(triplets = [[2, 1, 1], [1, 2, 1], [1, 1, 2], [2, 2, 2]],target = [2, 2, 2]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]],target = [3, 3, 3]) == True\n assert candidate(triplets = [[100, 200, 300], [300, 400, 500], [500, 600, 700], [700, 800, 900], [900, 1000, 100], [100, 300, 500], [200, 400, 600]],target = [100, 400, 600]) == False\n assert candidate(triplets = [[1000, 1000, 1000], [1000, 1000, 1000], [1000, 1000, 1000], [1, 2, 3], [4, 5, 6], [7, 8, 9]],target = [1000, 1000, 1000]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 1], [1, 1, 2], [1, 2, 1], [2, 1, 1]],target = [1, 1, 2]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 2, 2], [2, 2, 3], [2, 2, 2], [3, 2, 3], [3, 2, 2], [3, 3, 3], [6, 6, 6], [9, 9, 9]],target = [6, 6, 6]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]],target = [1, 1, 1]) == True\n assert candidate(triplets = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8]],target = [5, 6, 7]) == True\n assert candidate(triplets = [[1, 2, 3], [3, 2, 1], [2, 3, 1], [2, 1, 3], [3, 1, 2], [1, 3, 2], [1, 1, 1], [999, 999, 999]],target = [2, 2, 2]) == False\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]],target = [9, 9, 9]) == True\n assert candidate(triplets = [[1, 999, 1], [999, 1, 1], [1, 1, 999], [999, 999, 1], [999, 1, 999], [1, 999, 999], [999, 999, 999]],target = [999, 999, 999]) == True\n assert candidate(triplets = [[5, 1, 1], [1, 5, 1], [1, 1, 5], [5, 5, 1], [5, 1, 5], [1, 5, 5], [5, 5, 5]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],target = [1, 1, 1]) == True\n assert candidate(triplets = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 1, 1], [10, 10, 10], [2, 2, 2], [3, 3, 3], [5, 5, 5]],target = [10, 10, 10]) == True\n assert candidate(triplets = [[1, 2, 3], [3, 2, 1], [2, 3, 1], [1, 3, 2], [3, 1, 2], [2, 1, 3], [5, 5, 5]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[1, 1, 999], [1, 999, 1], [999, 1, 1], [999, 999, 1], [999, 1, 999], [999, 999, 999]],target = [999, 999, 999]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 2, 2], [2, 2, 3], [2, 2, 2], [3, 2, 3], [3, 2, 2], [3, 3, 3], [6, 6, 6], [9, 9, 9]],target = [3, 2, 3]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 2], [1, 2, 1], [2, 1, 1], [1, 2, 2], [2, 1, 2], [2, 2, 1], [2, 2, 2], [2, 2, 3]],target = [2, 2, 2]) == True\n assert candidate(triplets = [[1, 2, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1], [2, 1, 3], [1, 3, 2]],target = [1, 2, 3]) == True\n assert candidate(triplets = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]],target = [4, 5, 6]) == True\n assert candidate(triplets = [[500, 500, 500], [1, 1, 1], [1000, 1000, 1000], [250, 250, 250], [750, 750, 750]],target = [500, 500, 500]) == True\n assert candidate(triplets = [[1, 1000, 1000], [1000, 1, 1000], [1000, 1000, 1], [250, 250, 250], [500, 500, 500], [750, 750, 750]],target = [1000, 1000, 1000]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]],target = [1, 1, 1]) == True\n assert candidate(triplets = [[3, 4, 5], [5, 6, 7], [8, 9, 10], [1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7]],target = [8, 9, 10]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]],target = [1, 1, 1]) == True\n assert candidate(triplets = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7]],target = [5, 6, 7]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]],target = [5, 5, 5]) == True\n assert candidate(triplets = [[2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 10, 11], [10, 11, 12]],target = [7, 8, 9]) == True\n assert candidate(triplets = [[1, 2, 3], [3, 4, 5], [5, 6, 7], [7, 8, 9]],target = [5, 6, 7]) == True\n assert candidate(triplets = [[1, 2, 3], [1, 2, 2], [2, 2, 3], [2, 2, 2], [3, 2, 3], [3, 2, 2], [3, 3, 3]],target = [3, 2, 3]) == True\n assert candidate(triplets = [[1, 1, 1], [2, 3, 4], [5, 6, 7], [1, 2, 3], [4, 5, 6], [7, 8, 9]],target = [7, 8, 9]) == True\n assert candidate(triplets = [[1, 1, 1], [1, 1, 2], [1, 2, 1], [2, 1, 1], [1, 2, 2], [2, 1, 2], [2, 2, 1], [2, 2, 2]],target = [2, 2, 2]) == True\n"}, "metadata": {"canonical_parameter_names": ["triplets", "target"], "leetcode_dataset_entry_point": "Solution().mergeTriplets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool mergeTriplets(vector>& triplets, vector& target) {", "container": "Solution", "callable": "mergeTriplets", "parameters": [{"name": "triplets", "type": "vector>&"}, {"name": "target", "type": "vector&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1900, "task_id": "the-earliest-and-latest-rounds-where-players-compete", "difficulty": "Hard", "problem_description": "There is a tournament where n players are participating. The players are standing in a single row and are numbered from 1 to n based on their initial standing position (player 1 is the first player in the row, player 2 is the second player in the row, etc.).\nThe tournament consists of multiple rounds (starting from round number 1). In each round, the ith player from the front of the row competes against the ith player from the end of the row, and the winner advances to the next round. When the number of players is odd for the current round, the player in the middle automatically advances to the next round.\n\nFor example, if the row consists of players 1, 2, 4, 6, 7\n\nPlayer 1 competes against player 7.\nPlayer 2 competes against player 6.\nPlayer 4 automatically advances to the next round.\n\n\n\nAfter each round is over, the winners are lined back up in the row based on the original ordering assigned to them initially (ascending order).\nThe players numbered firstPlayer and secondPlayer are the best in the tournament. They can win against any other player before they compete against each other. If any two other players compete against each other, either of them might win, and thus you may choose the outcome of this round.\nGiven the integers n, firstPlayer, and secondPlayer, return an integer array containing two values, the earliest possible round number and the latest possible round number in which these two players will compete against each other, respectively.\n \nExample 1:\n\nInput: n = 11, firstPlayer = 2, secondPlayer = 4\nOutput: [3,4]\nExplanation:\nOne possible scenario which leads to the earliest round number:\nFirst round: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11\nSecond round: 2, 3, 4, 5, 6, 11\nThird round: 2, 3, 4\nOne possible scenario which leads to the latest round number:\nFirst round: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11\nSecond round: 1, 2, 3, 4, 5, 6\nThird round: 1, 2, 4\nFourth round: 2, 4\n\nExample 2:\n\nInput: n = 5, firstPlayer = 1, secondPlayer = 5\nOutput: [1,1]\nExplanation: The players numbered 1 and 5 compete in the first round.\nThere is no way to make them compete in any other round.\n\n \nConstraints:\n\n2 <= n <= 28\n1 <= firstPlayer < secondPlayer <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 10,firstPlayer = 4,secondPlayer = 9) == [2, 4]\n assert candidate(n = 28,firstPlayer = 5,secondPlayer = 24) == [1, 1]\n assert candidate(n = 16,firstPlayer = 5,secondPlayer = 12) == [1, 1]\n assert candidate(n = 5,firstPlayer = 1,secondPlayer = 5) == [1, 1]\n assert candidate(n = 28,firstPlayer = 10,secondPlayer = 20) == [2, 5]\n assert candidate(n = 8,firstPlayer = 2,secondPlayer = 7) == [1, 1]\n assert candidate(n = 28,firstPlayer = 3,secondPlayer = 26) == [1, 1]\n assert candidate(n = 10,firstPlayer = 3,secondPlayer = 8) == [1, 1]\n assert candidate(n = 7,firstPlayer = 2,secondPlayer = 6) == [1, 1]\n assert candidate(n = 8,firstPlayer = 3,secondPlayer = 6) == [1, 1]\n assert candidate(n = 11,firstPlayer = 2,secondPlayer = 4) == [3, 4]\n assert candidate(n = 16,firstPlayer = 3,secondPlayer = 14) == [1, 1]\n assert candidate(n = 22,firstPlayer = 4,secondPlayer = 19) == [1, 1]\n assert candidate(n = 19,firstPlayer = 1,secondPlayer = 19) == [1, 1]\n assert candidate(n = 15,firstPlayer = 7,secondPlayer = 13) == [2, 4]\n assert candidate(n = 18,firstPlayer = 6,secondPlayer = 13) == [1, 1]\n assert candidate(n = 18,firstPlayer = 5,secondPlayer = 16) == [2, 5]\n assert candidate(n = 27,firstPlayer = 12,secondPlayer = 18) == [2, 5]\n assert candidate(n = 20,firstPlayer = 7,secondPlayer = 16) == [2, 5]\n assert candidate(n = 25,firstPlayer = 10,secondPlayer = 20) == [2, 5]\n assert candidate(n = 20,firstPlayer = 5,secondPlayer = 15) == [2, 5]\n assert candidate(n = 18,firstPlayer = 2,secondPlayer = 17) == [1, 1]\n assert candidate(n = 15,firstPlayer = 2,secondPlayer = 14) == [1, 1]\n assert candidate(n = 19,firstPlayer = 7,secondPlayer = 16) == [2, 5]\n assert candidate(n = 24,firstPlayer = 6,secondPlayer = 19) == [1, 1]\n assert candidate(n = 27,firstPlayer = 8,secondPlayer = 20) == [1, 1]\n assert candidate(n = 19,firstPlayer = 8,secondPlayer = 17) == [2, 5]\n assert candidate(n = 13,firstPlayer = 3,secondPlayer = 10) == [2, 4]\n assert candidate(n = 23,firstPlayer = 10,secondPlayer = 19) == [2, 5]\n assert candidate(n = 28,firstPlayer = 10,secondPlayer = 22) == [2, 5]\n assert candidate(n = 25,firstPlayer = 7,secondPlayer = 19) == [1, 1]\n assert candidate(n = 22,firstPlayer = 7,secondPlayer = 18) == [2, 5]\n assert candidate(n = 20,firstPlayer = 5,secondPlayer = 16) == [1, 1]\n assert candidate(n = 27,firstPlayer = 11,secondPlayer = 23) == [2, 5]\n assert candidate(n = 13,firstPlayer = 4,secondPlayer = 10) == [1, 1]\n assert candidate(n = 19,firstPlayer = 3,secondPlayer = 17) == [1, 1]\n assert candidate(n = 21,firstPlayer = 9,secondPlayer = 18) == [2, 5]\n assert candidate(n = 24,firstPlayer = 10,secondPlayer = 23) == [2, 5]\n assert candidate(n = 22,firstPlayer = 7,secondPlayer = 17) == [3, 5]\n assert candidate(n = 15,firstPlayer = 7,secondPlayer = 9) == [1, 1]\n assert candidate(n = 27,firstPlayer = 9,secondPlayer = 20) == [3, 5]\n assert candidate(n = 24,firstPlayer = 10,secondPlayer = 15) == [1, 1]\n assert candidate(n = 24,firstPlayer = 8,secondPlayer = 17) == [1, 1]\n assert candidate(n = 18,firstPlayer = 6,secondPlayer = 15) == [2, 5]\n assert candidate(n = 24,firstPlayer = 9,secondPlayer = 15) == [2, 5]\n assert candidate(n = 23,firstPlayer = 9,secondPlayer = 15) == [1, 1]\n assert candidate(n = 12,firstPlayer = 5,secondPlayer = 8) == [1, 1]\n assert candidate(n = 25,firstPlayer = 7,secondPlayer = 18) == [2, 5]\n assert candidate(n = 25,firstPlayer = 2,secondPlayer = 24) == [1, 1]\n assert candidate(n = 27,firstPlayer = 12,secondPlayer = 24) == [2, 5]\n assert candidate(n = 15,firstPlayer = 3,secondPlayer = 13) == [1, 1]\n assert candidate(n = 21,firstPlayer = 6,secondPlayer = 16) == [1, 1]\n assert candidate(n = 19,firstPlayer = 4,secondPlayer = 18) == [2, 4]\n assert candidate(n = 22,firstPlayer = 6,secondPlayer = 19) == [2, 5]\n assert candidate(n = 28,firstPlayer = 2,secondPlayer = 27) == [1, 1]\n assert candidate(n = 25,firstPlayer = 4,secondPlayer = 22) == [1, 1]\n assert candidate(n = 13,firstPlayer = 3,secondPlayer = 11) == [1, 1]\n assert candidate(n = 13,firstPlayer = 3,secondPlayer = 9) == [2, 4]\n assert candidate(n = 28,firstPlayer = 1,secondPlayer = 28) == [1, 1]\n assert candidate(n = 23,firstPlayer = 11,secondPlayer = 20) == [2, 5]\n assert candidate(n = 17,firstPlayer = 3,secondPlayer = 15) == [1, 1]\n assert candidate(n = 14,firstPlayer = 3,secondPlayer = 10) == [2, 4]\n assert candidate(n = 12,firstPlayer = 3,secondPlayer = 9) == [2, 4]\n assert candidate(n = 25,firstPlayer = 8,secondPlayer = 19) == [2, 5]\n assert candidate(n = 28,firstPlayer = 12,secondPlayer = 18) == [2, 5]\n assert candidate(n = 22,firstPlayer = 9,secondPlayer = 14) == [1, 1]\n assert candidate(n = 24,firstPlayer = 9,secondPlayer = 21) == [2, 5]\n assert candidate(n = 19,firstPlayer = 9,secondPlayer = 17) == [2, 5]\n assert candidate(n = 17,firstPlayer = 4,secondPlayer = 15) == [2, 4]\n assert candidate(n = 19,firstPlayer = 6,secondPlayer = 14) == [1, 1]\n assert candidate(n = 21,firstPlayer = 7,secondPlayer = 15) == [1, 1]\n assert candidate(n = 27,firstPlayer = 2,secondPlayer = 25) == [3, 3]\n assert candidate(n = 17,firstPlayer = 6,secondPlayer = 12) == [1, 1]\n assert candidate(n = 17,firstPlayer = 5,secondPlayer = 13) == [1, 1]\n assert candidate(n = 18,firstPlayer = 4,secondPlayer = 15) == [1, 1]\n assert candidate(n = 21,firstPlayer = 10,secondPlayer = 12) == [1, 1]\n assert candidate(n = 15,firstPlayer = 4,secondPlayer = 11) == [3, 4]\n assert candidate(n = 21,firstPlayer = 6,secondPlayer = 19) == [2, 5]\n assert candidate(n = 19,firstPlayer = 8,secondPlayer = 15) == [2, 5]\n assert candidate(n = 20,firstPlayer = 7,secondPlayer = 14) == [1, 1]\n assert candidate(n = 25,firstPlayer = 8,secondPlayer = 20) == [2, 5]\n assert candidate(n = 27,firstPlayer = 4,secondPlayer = 23) == [3, 5]\n assert candidate(n = 20,firstPlayer = 3,secondPlayer = 18) == [1, 1]\n assert candidate(n = 26,firstPlayer = 13,secondPlayer = 22) == [2, 5]\n assert candidate(n = 18,firstPlayer = 5,secondPlayer = 14) == [1, 1]\n assert candidate(n = 21,firstPlayer = 6,secondPlayer = 15) == [3, 5]\n assert candidate(n = 28,firstPlayer = 10,secondPlayer = 25) == [2, 5]\n"}, "metadata": {"canonical_parameter_names": ["n", "firstPlayer", "secondPlayer"], "leetcode_dataset_entry_point": "Solution().earliestAndLatest", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector earliestAndLatest(int n, int firstPlayer, int secondPlayer) {", "container": "Solution", "callable": "earliestAndLatest", "parameters": [{"name": "n", "type": "int"}, {"name": "firstPlayer", "type": "int"}, {"name": "secondPlayer", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1901, "task_id": "find-a-peak-element-ii", "difficulty": "Medium", "problem_description": "A peak element in a 2D grid is an element that is strictly greater than all of its adjacent neighbors to the left, right, top, and bottom.\nGiven a 0-indexed m x n matrix mat where no two adjacent cells are equal, find any peak element mat[i][j] and return the length 2 array [i,j].\nYou may assume that the entire matrix is surrounded by an outer perimeter with the value -1 in each cell.\nYou must write an algorithm that runs in O(m log(n)) or O(n log(m)) time.\n \nExample 1:\n\n\nInput: mat = [[1,4],[3,2]]\nOutput: [0,1]\nExplanation: Both 3 and 4 are peak elements so [1,0] and [0,1] are both acceptable answers.\n\nExample 2:\n\n\nInput: mat = [[10,20,15],[21,30,14],[7,16,32]]\nOutput: [1,1]\nExplanation: Both 30 and 32 are peak elements so [1,1] and [2,2] are both acceptable answers.\n\n \nConstraints:\n\nm == mat.length\nn == mat[i].length\n1 <= m, n <= 500\n1 <= mat[i][j] <= 105\nNo two adjacent cells are equal.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1]]) == [0, 0]\n assert candidate(mat = [[1, 2, 3, 4, 5], [16, 17, 18, 19, 6], [15, 24, 25, 20, 7], [14, 23, 22, 21, 8], [13, 12, 11, 10, 9]]) == [2, 2]\n assert candidate(mat = [[1, 2, 3, 4, 5], [16, 17, 24, 25, 6], [7, 8, 9, 10, 11], [12, 13, 14, 15, 18]]) == [1, 3]\n assert candidate(mat = [[10, 20, 15], [21, 30, 14], [7, 16, 32]]) == [1, 1]\n assert candidate(mat = [[1, 3, 5, 7], [10, 11, 16, 20], [23, 30, 34, 60]]) == [2, 3]\n assert candidate(mat = [[1, 4], [3, 2]]) == [0, 1]\n assert candidate(mat = [[5, 25, 15, 10], [100, 101, 102, 103], [99, 98, 97, 96], [50, 49, 48, 47]]) == [1, 3]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11]]) == [2, 9]\n assert candidate(mat = [[1, 10, 20, 10, 1], [10, 20, 30, 20, 10], [20, 30, 40, 30, 20], [10, 20, 30, 20, 10], [1, 10, 20, 10, 1]]) == [2, 2]\n assert candidate(mat = [[1, 5, 9, 12], [10, 20, 25, 16], [8, 18, 24, 13], [7, 17, 19, 21]]) == [1, 2]\n assert candidate(mat = [[10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [9, 21, 29, 39, 49, 59, 69, 79, 89, 101], [8, 22, 28, 38, 48, 58, 68, 78, 88, 102], [7, 23, 27, 37, 47, 57, 67, 77, 87, 103], [6, 24, 26, 36, 46, 56, 66, 76, 86, 104], [5, 25, 25, 35, 45, 55, 65, 75, 85, 105], [4, 26, 24, 34, 44, 54, 64, 74, 84, 106], [3, 27, 23, 33, 43, 53, 63, 73, 83, 107], [2, 28, 22, 32, 42, 52, 62, 72, 82, 108], [1, 29, 21, 31, 41, 51, 61, 71, 81, 109]]) == [9, 9]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [8, 7, 6, 5, 4, 3, 2, 1, 10], [9, 10, 11, 12, 13, 14, 15, 16, 17], [16, 15, 14, 13, 12, 11, 10, 9, 18], [19, 20, 21, 22, 23, 24, 25, 26, 27], [26, 25, 24, 23, 22, 21, 20, 19, 28], [29, 30, 31, 32, 33, 34, 35, 36, 37]]) == [6, 8]\n assert candidate(mat = [[999, 998, 997], [996, 995, 994], [993, 992, 991], [990, 989, 988], [987, 986, 985], [984, 983, 982], [981, 980, 979], [978, 977, 976], [975, 974, 973], [972, 971, 970]]) == [0, 0]\n assert candidate(mat = [[30, 27, 24, 21, 18, 15], [29, 26, 23, 20, 17, 14], [28, 25, 22, 19, 16, 13], [27, 24, 21, 18, 15, 12], [26, 23, 20, 17, 14, 11], [25, 22, 19, 16, 13, 10]]) == [0, 0]\n assert candidate(mat = [[100000, 99999, 99998], [99997, 99996, 99995], [99994, 99993, 99992], [99991, 99990, 99989], [99988, 99987, 99986]]) == [0, 0]\n assert candidate(mat = [[1, 2, 3, 4, 5], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]) == [2, 4]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [15, 16, 17, 18, 19, 7], [14, 23, 24, 25, 20, 8], [13, 22, 31, 32, 21, 9], [12, 21, 30, 33, 22, 10], [11, 20, 29, 28, 27, 16]]) == [4, 3]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [25, 26, 27, 28, 29, 30, 31, 32, 10], [24, 39, 40, 41, 42, 43, 44, 33, 11], [23, 38, 51, 52, 53, 54, 45, 34, 12], [22, 37, 50, 59, 60, 55, 46, 35, 13], [21, 36, 49, 58, 61, 56, 47, 36, 14], [20, 35, 48, 57, 62, 50, 40, 30, 15], [19, 34, 47, 56, 63, 49, 39, 29, 16], [18, 33, 46, 55, 64, 48, 38, 28, 17]]) == [8, 4]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]) == [2, 19]\n assert candidate(mat = [[50, 1, 100, 200, 300, 400, 500], [600, 501, 101, 201, 301, 401, 501], [601, 602, 102, 202, 302, 402, 502], [603, 604, 103, 203, 303, 403, 503], [604, 605, 104, 204, 304, 404, 504], [605, 606, 105, 205, 305, 405, 505]]) == [5, 1]\n assert candidate(mat = [[3, 8, 4, 5, 7], [2, 9, 6, 10, 3], [5, 7, 11, 12, 8], [1, 6, 9, 13, 4]]) == [3, 3]\n assert candidate(mat = [[100, 101, 102, 103, 104], [109, 108, 107, 106, 105], [110, 111, 112, 113, 114], [119, 118, 117, 116, 115]]) == [3, 0]\n assert candidate(mat = [[5, 25, 20], [15, 30, 21], [10, 19, 22], [14, 28, 27], [9, 23, 24]]) == [3, 1]\n assert candidate(mat = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]]) == [0, 24]\n assert candidate(mat = [[1, 3, 5, 7, 9], [10, 8, 6, 4, 2], [3, 5, 7, 9, 11], [12, 10, 8, 6, 4], [5, 7, 9, 11, 13]]) == [0, 4]\n assert candidate(mat = [[100, 200, 300, 400], [150, 250, 350, 450], [125, 225, 325, 425], [175, 275, 375, 475]]) == [1, 3]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [18, 17, 16, 15, 14, 13, 12, 11, 10], [19, 20, 21, 22, 23, 24, 25, 26, 27], [28, 29, 30, 31, 32, 33, 34, 35, 36], [37, 38, 39, 40, 41, 42, 43, 44, 45]]) == [4, 8]\n assert candidate(mat = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [10, 9, 8, 7, 6, 5, 4, 3, 2], [11, 10, 9, 8, 7, 6, 5, 4, 3], [12, 11, 10, 9, 8, 7, 6, 5, 4], [13, 12, 11, 10, 9, 8, 7, 6, 5]]) == [4, 0]\n assert candidate(mat = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [6, 7, 8, 9, 10], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15]]) == [2, 4]\n assert candidate(mat = [[1, 3, 5, 7, 9, 11], [12, 14, 16, 18, 20, 19], [13, 15, 17, 19, 21, 22], [25, 24, 23, 22, 21, 20], [26, 27, 28, 29, 30, 31]]) == [2, 5]\n assert candidate(mat = [[1, 3, 5, 7, 9, 11, 13], [2, 4, 6, 8, 10, 12, 14], [3, 5, 7, 9, 11, 13, 15], [4, 6, 8, 10, 12, 14, 16], [5, 7, 9, 11, 13, 15, 17]]) == [4, 6]\n assert candidate(mat = [[1, 2, 3, 4, 5], [16, 17, 18, 19, 6], [15, 24, 25, 20, 7], [14, 23, 22, 21, 8], [13, 12, 11, 10, 9], [26, 27, 28, 29, 30]]) == [2, 2]\n assert candidate(mat = [[5, 2, 1, 6, 7, 8, 10, 4, 9, 1], [15, 14, 13, 16, 17, 18, 20, 19, 21, 2], [22, 23, 24, 25, 26, 27, 28, 29, 30, 31]]) == [2, 9]\n assert candidate(mat = [[1, 2, 3], [6, 5, 4], [7, 8, 9]]) == [2, 2]\n assert candidate(mat = [[5, 25, 9, 20, 15], [30, 35, 28, 33, 26], [29, 40, 31, 36, 27], [24, 39, 32, 37, 34], [23, 38, 21, 22, 16]]) == [2, 1]\n assert candidate(mat = [[20, 30, 25, 10, 15], [100, 120, 115, 80, 85], [75, 82, 87, 55, 60], [65, 70, 67, 78, 77]]) == [1, 1]\n assert candidate(mat = [[10, 100, 1000], [9, 99, 999], [8, 88, 888], [7, 77, 777], [6, 66, 666], [5, 55, 555], [4, 44, 444], [3, 33, 333], [2, 22, 222], [1, 11, 111]]) == [0, 2]\n assert candidate(mat = [[2, 1, 3, 4, 5, 6, 7, 8, 9], [1, 1, 1, 1, 1, 1, 1, 1, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1]]) == [2, 0]\n assert candidate(mat = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) == [9, 0]\n assert candidate(mat = [[5, 2, 15, 10, 20], [6, 21, 16, 14, 19], [7, 17, 25, 23, 18], [8, 18, 24, 30, 22], [9, 29, 26, 27, 31]]) == [0, 4]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == [1, 0]\n assert candidate(mat = [[5, 10, 15, 20, 25], [9, 14, 19, 24, 29], [13, 18, 23, 28, 33], [17, 22, 27, 32, 37], [21, 26, 31, 36, 41]]) == [4, 4]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [11, 10, 9, 8, 7, 6, 5, 4, 3, 2], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]) == [0, 9]\n assert candidate(mat = [[50, 51, 52, 53, 54, 55, 56, 57, 58, 59], [100, 101, 102, 103, 104, 105, 106, 107, 108, 109], [99, 98, 97, 96, 95, 94, 93, 92, 91, 90], [80, 81, 82, 83, 84, 85, 86, 87, 88, 89], [79, 78, 77, 76, 75, 74, 73, 72, 71, 70], [60, 61, 62, 63, 64, 65, 66, 67, 68, 69], [59, 58, 57, 56, 55, 54, 53, 52, 51, 50], [40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [39, 38, 37, 36, 35, 34, 33, 32, 31, 30]]) == [1, 9]\n assert candidate(mat = [[1, 2, 3, 4], [8, 7, 6, 5], [9, 10, 11, 12], [16, 15, 14, 13], [17, 18, 19, 20]]) == [4, 3]\n assert candidate(mat = [[9, 8, 7, 6], [8, 7, 6, 5], [7, 6, 5, 4], [6, 5, 4, 3], [5, 4, 3, 2]]) == [0, 0]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6], [20, 19, 18, 17, 16, 15], [21, 22, 23, 24, 25, 26], [32, 31, 30, 29, 28, 27], [33, 34, 35, 36, 37, 38], [44, 43, 42, 41, 40, 39]]) == [5, 0]\n assert candidate(mat = [[10, 100, 30, 200, 40, 300], [9, 190, 25, 210, 35, 310], [18, 180, 27, 220, 45, 320], [17, 170, 26, 230, 44, 330], [16, 160, 24, 240, 43, 340], [15, 150, 23, 250, 42, 350]]) == [5, 5]\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11], [4, 6, 8, 10, 12], [5, 7, 9, 11, 13]]) == [4, 4]\n assert candidate(mat = [[50, 49, 48, 47, 46, 45, 44, 43, 42, 41], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90]]) == [4, 9]\n assert candidate(mat = [[1, 10, 8, 11, 9], [16, 17, 18, 19, 6], [15, 24, 25, 20, 7], [14, 23, 22, 21, 8], [13, 12, 11, 10, 15]]) == [2, 2]\n assert candidate(mat = [[1, 100, 200, 300, 400, 500], [600, 501, 502, 503, 504, 505], [700, 601, 701, 702, 703, 704], [800, 701, 801, 802, 803, 804], [900, 801, 901, 902, 903, 904]]) == [4, 5]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11], [30, 31, 32, 33, 34, 35, 36, 37, 38, 39], [49, 48, 47, 46, 45, 44, 43, 42, 41, 40]]) == [3, 0]\n assert candidate(mat = [[1000, 999, 998, 997, 996], [995, 994, 993, 992, 991], [990, 989, 988, 987, 986], [985, 984, 983, 982, 981], [980, 979, 978, 977, 976]]) == [0, 0]\n assert candidate(mat = [[30, 28, 19, 27, 22], [25, 31, 26, 23, 21], [24, 29, 32, 20, 18], [17, 22, 21, 16, 15], [13, 14, 12, 11, 10]]) == [0, 0]\n assert candidate(mat = [[100, 101, 102, 103, 104, 105], [99, 106, 107, 108, 109, 110], [98, 111, 112, 113, 114, 115], [97, 116, 117, 118, 119, 120], [96, 121, 122, 123, 124, 125], [95, 126, 127, 128, 129, 130]]) == [5, 5]\n assert candidate(mat = [[5, 3, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15], [19, 18, 17, 16, 23, 22], [27, 28, 29, 30, 25, 24], [34, 33, 32, 31, 38, 37], [43, 42, 41, 40, 47, 46]]) == [5, 4]\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 1]]) == [3, 0]\n assert candidate(mat = [[1, 3, 2], [4, 6, 5], [7, 9, 8], [10, 12, 11], [13, 15, 14]]) == [4, 1]\n assert candidate(mat = [[1, 5, 7, 4, 6], [9, 8, 2, 1, 3], [12, 15, 13, 11, 10], [17, 18, 16, 20, 21]]) == [3, 4]\n assert candidate(mat = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [20, 18, 16, 14, 12, 10, 8, 6, 4, 2], [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]]) == [0, 9]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == [0, 19]\n assert candidate(mat = [[10, 20, 30, 40, 50, 60, 70], [70, 60, 50, 40, 30, 20, 10], [10, 30, 50, 70, 90, 110, 130], [130, 110, 90, 70, 50, 30, 10]]) == [0, 6]\n assert candidate(mat = [[100, 200, 300, 400], [400, 300, 200, 100], [100, 200, 300, 400], [400, 300, 200, 100]]) == [0, 3]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50]]) == [4, 9]\n assert candidate(mat = [[1, 5, 9, 4], [6, 7, 3, 8], [2, 11, 13, 12], [10, 14, 15, 16]]) == [3, 3]\n assert candidate(mat = [[5, 20, 15, 25], [9, 10, 12, 8], [14, 6, 30, 7], [13, 16, 11, 18]]) == [2, 2]\n assert candidate(mat = [[10, 20, 30, 40, 50, 60], [61, 62, 63, 64, 65, 59], [70, 69, 68, 67, 66, 71], [72, 73, 74, 75, 76, 77], [78, 79, 80, 81, 82, 83]]) == [4, 5]\n assert candidate(mat = [[50, 49, 48, 47, 46], [45, 44, 43, 42, 41], [40, 39, 38, 37, 36], [35, 34, 33, 32, 31], [30, 29, 28, 27, 26]]) == [0, 0]\n assert candidate(mat = [[1, 2, 3], [6, 5, 4], [7, 8, 9], [12, 11, 10]]) == [3, 0]\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21]]) == [6, 2]\n assert candidate(mat = [[100, 200, 300, 400, 500, 600, 700, 800, 900], [901, 801, 701, 601, 501, 401, 301, 201, 101], [102, 202, 302, 402, 502, 602, 702, 802, 902], [903, 803, 703, 603, 503, 403, 303, 203, 103], [104, 204, 304, 404, 504, 604, 704, 804, 904], [905, 805, 705, 605, 505, 405, 305, 205, 105], [106, 206, 306, 406, 506, 606, 706, 806, 906], [907, 807, 707, 607, 507, 407, 307, 207, 107]]) == [0, 8]\n assert candidate(mat = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [2, 3, 4, 5, 6], [6, 5, 4, 3, 2], [3, 4, 5, 6, 7]]) == [0, 4]\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2]]) == [0, 8]\n assert candidate(mat = [[100, 200, 300, 400, 500], [501, 502, 503, 504, 505], [1000, 1001, 1002, 1003, 1004], [1501, 1502, 1503, 1504, 1505], [2000, 2001, 2002, 2003, 2004]]) == [4, 4]\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == [4, 4]\n assert candidate(mat = [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]) == [9, 0]\n assert candidate(mat = [[10, 11, 12, 13, 14, 15, 16], [9, 8, 7, 6, 5, 4, 3], [2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7]]) == [0, 6]\n assert candidate(mat = [[10, 20, 30, 40, 50], [15, 25, 35, 45, 55], [20, 30, 40, 50, 60], [25, 35, 45, 55, 65], [30, 40, 50, 60, 70], [35, 45, 55, 65, 75]]) == [5, 4]\n assert candidate(mat = [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16], [21, 22, 23, 24, 25]]) == [4, 4]\n assert candidate(mat = [[1, 1000, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == [0, 1]\n assert candidate(mat = [[10, 20, 30, 40, 50, 60], [5, 15, 25, 35, 45, 55], [40, 50, 60, 70, 80, 90], [35, 45, 55, 65, 75, 85], [25, 35, 45, 55, 65, 75], [15, 25, 35, 45, 55, 65]]) == [2, 5]\n assert candidate(mat = [[5, 4, 3, 2, 1], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]) == [4, 4]\n assert candidate(mat = [[5, 20, 3, 5, 6], [21, 22, 23, 24, 5], [1, 2, 3, 25, 26], [17, 18, 19, 28, 29], [30, 31, 32, 33, 34]]) == [4, 4]\n assert candidate(mat = [[20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]]) == [0, 0]\n"}, "metadata": {"canonical_parameter_names": ["mat"], "leetcode_dataset_entry_point": "Solution().findPeakGrid", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector findPeakGrid(vector>& mat) {", "container": "Solution", "callable": "findPeakGrid", "parameters": [{"name": "mat", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1903, "task_id": "largest-odd-number-in-string", "difficulty": "Easy", "problem_description": "You are given a string num, representing a large integer. Return the largest-valued odd integer (as a string) that is a non-empty substring of num, or an empty string \"\" if no odd integer exists.\nA substring is a contiguous sequence of characters within a string.\n \nExample 1:\n\nInput: num = \"52\"\nOutput: \"5\"\nExplanation: The only non-empty substrings are \"5\", \"2\", and \"52\". \"5\" is the only odd number.\n\nExample 2:\n\nInput: num = \"4206\"\nOutput: \"\"\nExplanation: There are no odd numbers in \"4206\".\n\nExample 3:\n\nInput: num = \"35427\"\nOutput: \"35427\"\nExplanation: \"35427\" is already an odd number.\n\n \nConstraints:\n\n1 <= num.length <= 105\nnum only consists of digits and does not contain any leading zeros.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = \"52\") == \"5\"\n assert candidate(num = \"9\") == \"9\"\n assert candidate(num = \"86420\") == \"\"\n assert candidate(num = \"1111111111\") == \"1111111111\"\n assert candidate(num = \"2468\") == \"\"\n assert candidate(num = \"1\") == \"1\"\n assert candidate(num = \"9876543210\") == \"987654321\"\n assert candidate(num = \"0\") == \"\"\n assert candidate(num = \"98765\") == \"98765\"\n assert candidate(num = \"2468013579\") == \"2468013579\"\n assert candidate(num = \"2222222222\") == \"\"\n assert candidate(num = \"8\") == \"\"\n assert candidate(num = \"987654321\") == \"987654321\"\n assert candidate(num = \"2\") == \"\"\n assert candidate(num = \"56789\") == \"56789\"\n assert candidate(num = \"321\") == \"321\"\n assert candidate(num = \"123\") == \"123\"\n assert candidate(num = \"1357924680\") == \"13579\"\n assert candidate(num = \"4206\") == \"\"\n assert candidate(num = \"123456789\") == \"123456789\"\n assert candidate(num = \"35427\") == \"35427\"\n assert candidate(num = \"24680\") == \"\"\n assert candidate(num = \"1234567890\") == \"123456789\"\n assert candidate(num = \"24681\") == \"24681\"\n assert candidate(num = \"11111\") == \"11111\"\n assert candidate(num = \"13579\") == \"13579\"\n assert candidate(num = \"13579135791357913577\") == \"13579135791357913577\"\n assert candidate(num = \"98765432109876543210\") == \"9876543210987654321\"\n assert candidate(num = \"10000000000000000000000000000000000000000000000002\") == \"1\"\n assert candidate(num = \"246802468024680246802468024680246802468024680\") == \"\"\n assert candidate(num = \"02468\") == \"\"\n assert candidate(num = \"9012345678\") == \"901234567\"\n assert candidate(num = \"0000000000\") == \"\"\n assert candidate(num = \"111222333444555\") == \"111222333444555\"\n assert candidate(num = \"135791357913579135791357913579135791357913579\") == \"135791357913579135791357913579135791357913579\"\n assert candidate(num = \"2468101214161820\") == \"2468101214161\"\n assert candidate(num = \"50505050505050505055\") == \"50505050505050505055\"\n assert candidate(num = \"902468013579\") == \"902468013579\"\n assert candidate(num = \"99999999999999999998\") == \"9999999999999999999\"\n assert candidate(num = \"987654321987654321987654321987654321987654321\") == \"987654321987654321987654321987654321987654321\"\n assert candidate(num = \"13579111315\") == \"13579111315\"\n assert candidate(num = \"0246802468024680246802468024680246802468024680\") == \"\"\n assert candidate(num = \"1234567890123456789012345678901234567890123456789\") == \"1234567890123456789012345678901234567890123456789\"\n assert candidate(num = \"1111111111111111111111111111111111111111111111111\") == \"1111111111111111111111111111111111111111111111111\"\n assert candidate(num = \"123456789012345678901\") == \"123456789012345678901\"\n assert candidate(num = \"246802468024680246805\") == \"246802468024680246805\"\n assert candidate(num = \"1000000000000000000000000000000000000000000000000\") == \"1\"\n assert candidate(num = \"5000000000000000000000000000000000000000000000003\") == \"5000000000000000000000000000000000000000000000003\"\n assert candidate(num = \"987654320\") == \"9876543\"\n assert candidate(num = \"111111111111111111111111111111111111111111111111\") == \"111111111111111111111111111111111111111111111111\"\n assert candidate(num = \"8642086420\") == \"\"\n assert candidate(num = \"10\") == \"1\"\n assert candidate(num = \"8080808080808080808080808080808080808080808080807\") == \"8080808080808080808080808080808080808080808080807\"\n assert candidate(num = \"1000000000000000000000000000000000000000000000001\") == \"1000000000000000000000000000000000000000000000001\"\n assert candidate(num = \"2468012345\") == \"2468012345\"\n assert candidate(num = \"0246802468\") == \"\"\n assert candidate(num = \"124\") == \"1\"\n assert candidate(num = \"246802468024680246802468024680\") == \"\"\n assert candidate(num = \"1000000000100000000010000000001000000000100000001\") == \"1000000000100000000010000000001000000000100000001\"\n assert candidate(num = \"1919191919191919191919191919191919191919191919\") == \"1919191919191919191919191919191919191919191919\"\n assert candidate(num = \"2000000002000000002\") == \"\"\n assert candidate(num = \"9999999998\") == \"999999999\"\n assert candidate(num = \"87654321\") == \"87654321\"\n assert candidate(num = \"10000000000000000001\") == \"10000000000000000001\"\n assert candidate(num = \"1357997531\") == \"1357997531\"\n assert candidate(num = \"987654321987654321987654321987654321987654321987654321\") == \"987654321987654321987654321987654321987654321987654321\"\n assert candidate(num = \"00000000000000000001\") == \"00000000000000000001\"\n assert candidate(num = \"987654321987654321987654321\") == \"987654321987654321987654321\"\n assert candidate(num = \"9999999999999999999999999999999999999999999999998\") == \"999999999999999999999999999999999999999999999999\"\n assert candidate(num = \"246801357924680\") == \"2468013579\"\n assert candidate(num = \"11111111111111111112\") == \"1111111111111111111\"\n assert candidate(num = \"20000000000000000000000000000000000000000000000002\") == \"\"\n assert candidate(num = \"13579111315171921\") == \"13579111315171921\"\n assert candidate(num = \"864200000\") == \"\"\n assert candidate(num = \"13579135791357913579\") == \"13579135791357913579\"\n assert candidate(num = \"2020202020202020202020202020202020202020202020\") == \"\"\n assert candidate(num = \"1001001001001001001001001001001001001001001001001\") == \"1001001001001001001001001001001001001001001001001\"\n assert candidate(num = \"24680246802468024689\") == \"24680246802468024689\"\n assert candidate(num = \"246810\") == \"24681\"\n assert candidate(num = \"999999999999999999\") == \"999999999999999999\"\n assert candidate(num = \"12345678909876543210\") == \"1234567890987654321\"\n assert candidate(num = \"99999999999999999999\") == \"99999999999999999999\"\n assert candidate(num = \"0123456789\") == \"0123456789\"\n assert candidate(num = \"1234567890123456789\") == \"1234567890123456789\"\n assert candidate(num = \"9876543210987654321098765432109876543210987654321\") == \"9876543210987654321098765432109876543210987654321\"\n assert candidate(num = \"101010101010101010101010101010101010101010101010101\") == \"101010101010101010101010101010101010101010101010101\"\n assert candidate(num = \"00000000000000000000000000000000000000000000000\") == \"\"\n assert candidate(num = \"2468024680246802468024680246802468024680246802468\") == \"\"\n assert candidate(num = \"9876543219\") == \"9876543219\"\n assert candidate(num = \"9876543210987654321098765432109876543210\") == \"987654321098765432109876543210987654321\"\n assert candidate(num = \"12345678901\") == \"12345678901\"\n assert candidate(num = \"2999999999999999999999999999999999999999999999998\") == \"299999999999999999999999999999999999999999999999\"\n assert candidate(num = \"999999999\") == \"999999999\"\n assert candidate(num = \"98765432101234567890\") == \"9876543210123456789\"\n assert candidate(num = \"11223344556677889900\") == \"112233445566778899\"\n assert candidate(num = \"543210987654321098765432109876543210987654321\") == \"543210987654321098765432109876543210987654321\"\n assert candidate(num = \"13579135791357913578\") == \"1357913579135791357\"\n assert candidate(num = \"100000000000000000001\") == \"100000000000000000001\"\n assert candidate(num = \"555555555555555555555555555555555555555555555555\") == \"555555555555555555555555555555555555555555555555\"\n assert candidate(num = \"123456789012345678902\") == \"1234567890123456789\"\n assert candidate(num = \"111222333444555666777888999\") == \"111222333444555666777888999\"\n assert candidate(num = \"864208642086420\") == \"\"\n assert candidate(num = \"024680246802468\") == \"\"\n assert candidate(num = \"9999999999\") == \"9999999999\"\n assert candidate(num = \"135791357913579135791357913579\") == \"135791357913579135791357913579\"\n assert candidate(num = \"9999999999999999999999999999999999999999999999999\") == \"9999999999999999999999999999999999999999999999999\"\n assert candidate(num = \"86420864208642086420\") == \"\"\n assert candidate(num = \"98765432109876543211\") == \"98765432109876543211\"\n assert candidate(num = \"01234567890123456789\") == \"01234567890123456789\"\n assert candidate(num = \"10000000000000000000\") == \"1\"\n assert candidate(num = \"1000000001\") == \"1000000001\"\n assert candidate(num = \"1999999999999999999999999999999999999999999999999\") == \"1999999999999999999999999999999999999999999999999\"\n assert candidate(num = \"24680246802468024680\") == \"\"\n assert candidate(num = \"222222222222222222222222222222222222222222222222\") == \"\"\n assert candidate(num = \"135790\") == \"13579\"\n assert candidate(num = \"8642097531\") == \"8642097531\"\n assert candidate(num = \"10000000000000000000000000000000000000000000000001\") == \"10000000000000000000000000000000000000000000000001\"\n assert candidate(num = \"123456789012345678901234567890\") == \"12345678901234567890123456789\"\n assert candidate(num = \"12345678901234567891\") == \"12345678901234567891\"\n assert candidate(num = \"1357913579135791357913579135791357913579135791357\") == \"1357913579135791357913579135791357913579135791357\"\n assert candidate(num = \"12345678901234567890123456789012345678901234567890\") == \"1234567890123456789012345678901234567890123456789\"\n assert candidate(num = \"246802468024680\") == \"\"\n assert candidate(num = \"987654321987654321\") == \"987654321987654321\"\n assert candidate(num = \"2222222222222222222222222222222222222222222222221\") == \"2222222222222222222222222222222222222222222222221\"\n assert candidate(num = \"9876543210987654321\") == \"9876543210987654321\"\n assert candidate(num = \"2222222222222222222222222222222222222222222222222\") == \"\"\n assert candidate(num = \"00000000000000000000\") == \"\"\n assert candidate(num = \"135791113151719\") == \"135791113151719\"\n assert candidate(num = \"987654321098765432\") == \"98765432109876543\"\n assert candidate(num = \"135791113151719111\") == \"135791113151719111\"\n assert candidate(num = \"11111111111111111111\") == \"11111111111111111111\"\n assert candidate(num = \"998877665544332211\") == \"998877665544332211\"\n assert candidate(num = \"12345678901234567890\") == \"1234567890123456789\"\n assert candidate(num = \"135791357913579\") == \"135791357913579\"\n assert candidate(num = \"09876543210987654321\") == \"09876543210987654321\"\n assert candidate(num = \"22222222221\") == \"22222222221\"\n assert candidate(num = \"10000000000000000000000000000000000000000001\") == \"10000000000000000000000000000000000000000001\"\n assert candidate(num = \"1357913579\") == \"1357913579\"\n assert candidate(num = \"22222222222222222222\") == \"\"\n assert candidate(num = \"9999999999999999999999999999999999999999998\") == \"999999999999999999999999999999999999999999\"\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().largestOddNumber", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string largestOddNumber(string num) {", "container": "Solution", "callable": "largestOddNumber", "parameters": [{"name": "num", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1904, "task_id": "the-number-of-full-rounds-you-have-played", "difficulty": "Medium", "problem_description": "You are participating in an online chess tournament. There is a chess round that starts every 15 minutes. The first round of the day starts at 00:00, and after every 15 minutes, a new round starts.\n\nFor example, the second round starts at 00:15, the fourth round starts at 00:45, and the seventh round starts at 01:30.\n\nYou are given two strings loginTime and logoutTime where:\n\nloginTime is the time you will login to the game, and\nlogoutTime is the time you will logout from the game.\n\nIf logoutTime is earlier than loginTime, this means you have played from loginTime to midnight and from midnight to logoutTime.\nReturn the number of full chess rounds you have played in the tournament.\nNote: All the given times follow the 24-hour clock. That means the first round of the day starts at 00:00 and the last round of the day starts at 23:45.\n \nExample 1:\n\nInput: loginTime = \"09:31\", logoutTime = \"10:14\"\nOutput: 1\nExplanation: You played one full round from 09:45 to 10:00.\nYou did not play the full round from 09:30 to 09:45 because you logged in at 09:31 after it began.\nYou did not play the full round from 10:00 to 10:15 because you logged out at 10:14 before it ended.\n\nExample 2:\n\nInput: loginTime = \"21:30\", logoutTime = \"03:00\"\nOutput: 22\nExplanation: You played 10 full rounds from 21:30 to 00:00 and 12 full rounds from 00:00 to 03:00.\n10 + 12 = 22.\n\n \nConstraints:\n\nloginTime and logoutTime are in the format hh:mm.\n00 <= hh <= 23\n00 <= mm <= 59\nloginTime and logoutTime are not equal.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(loginTime = \"11:59\",logoutTime = \"12:01\") == 0\n assert candidate(loginTime = \"14:30\",logoutTime = \"15:30\") == 4\n assert candidate(loginTime = \"00:01\",logoutTime = \"00:14\") == 0\n assert candidate(loginTime = \"14:20\",logoutTime = \"15:50\") == 5\n assert candidate(loginTime = \"00:00\",logoutTime = \"23:59\") == 95\n assert candidate(loginTime = \"18:14\",logoutTime = \"18:46\") == 2\n assert candidate(loginTime = \"14:30\",logoutTime = \"14:45\") == 1\n assert candidate(loginTime = \"23:45\",logoutTime = \"00:15\") == 2\n assert candidate(loginTime = \"22:15\",logoutTime = \"23:45\") == 6\n assert candidate(loginTime = \"15:30\",logoutTime = \"15:30\") == 0\n assert candidate(loginTime = \"14:20\",logoutTime = \"14:59\") == 1\n assert candidate(loginTime = \"05:45\",logoutTime = \"06:00\") == 1\n assert candidate(loginTime = \"09:31\",logoutTime = \"10:14\") == 1\n assert candidate(loginTime = \"00:01\",logoutTime = \"23:59\") == 94\n assert candidate(loginTime = \"07:45\",logoutTime = \"08:00\") == 1\n assert candidate(loginTime = \"11:59\",logoutTime = \"12:00\") == 0\n assert candidate(loginTime = \"23:45\",logoutTime = \"00:00\") == 1\n assert candidate(loginTime = \"05:00\",logoutTime = \"06:00\") == 4\n assert candidate(loginTime = \"01:10\",logoutTime = \"01:55\") == 2\n assert candidate(loginTime = \"01:15\",logoutTime = \"01:45\") == 2\n assert candidate(loginTime = \"07:15\",logoutTime = \"07:30\") == 1\n assert candidate(loginTime = \"01:05\",logoutTime = \"01:40\") == 1\n assert candidate(loginTime = \"21:30\",logoutTime = \"03:00\") == 22\n assert candidate(loginTime = \"13:00\",logoutTime = \"13:01\") == 0\n assert candidate(loginTime = \"12:00\",logoutTime = \"12:15\") == 1\n assert candidate(loginTime = \"05:30\",logoutTime = \"06:00\") == 2\n assert candidate(loginTime = \"08:45\",logoutTime = \"09:00\") == 1\n assert candidate(loginTime = \"01:00\",logoutTime = \"02:30\") == 6\n assert candidate(loginTime = \"18:15\",logoutTime = \"18:44\") == 1\n assert candidate(loginTime = \"10:15\",logoutTime = \"11:14\") == 3\n assert candidate(loginTime = \"19:10\",logoutTime = \"20:50\") == 6\n assert candidate(loginTime = \"07:00\",logoutTime = \"07:01\") == 0\n assert candidate(loginTime = \"12:16\",logoutTime = \"12:44\") == 0\n assert candidate(loginTime = \"20:44\",logoutTime = \"21:00\") == 1\n assert candidate(loginTime = \"12:30\",logoutTime = \"14:45\") == 9\n assert candidate(loginTime = \"11:15\",logoutTime = \"11:16\") == 0\n assert candidate(loginTime = \"14:30\",logoutTime = \"14:30\") == 0\n assert candidate(loginTime = \"18:45\",logoutTime = \"19:45\") == 4\n assert candidate(loginTime = \"18:00\",logoutTime = \"07:00\") == 52\n assert candidate(loginTime = \"07:15\",logoutTime = \"07:15\") == 0\n assert candidate(loginTime = \"08:15\",logoutTime = \"08:30\") == 1\n assert candidate(loginTime = \"02:10\",logoutTime = \"05:50\") == 14\n assert candidate(loginTime = \"08:25\",logoutTime = \"09:50\") == 5\n assert candidate(loginTime = \"01:00\",logoutTime = \"01:14\") == 0\n assert candidate(loginTime = \"12:30\",logoutTime = \"13:15\") == 3\n assert candidate(loginTime = \"03:45\",logoutTime = \"05:10\") == 5\n assert candidate(loginTime = \"06:30\",logoutTime = \"06:30\") == 0\n assert candidate(loginTime = \"17:45\",logoutTime = \"18:00\") == 1\n assert candidate(loginTime = \"20:00\",logoutTime = \"20:14\") == 0\n assert candidate(loginTime = \"23:59\",logoutTime = \"00:01\") == 0\n assert candidate(loginTime = \"07:07\",logoutTime = \"07:32\") == 1\n assert candidate(loginTime = \"06:59\",logoutTime = \"07:01\") == 0\n assert candidate(loginTime = \"14:23\",logoutTime = \"14:24\") == 0\n assert candidate(loginTime = \"12:10\",logoutTime = \"12:20\") == 0\n assert candidate(loginTime = \"05:00\",logoutTime = \"05:00\") == 0\n assert candidate(loginTime = \"02:30\",logoutTime = \"02:31\") == 0\n assert candidate(loginTime = \"20:00\",logoutTime = \"04:00\") == 32\n assert candidate(loginTime = \"21:15\",logoutTime = \"21:45\") == 2\n assert candidate(loginTime = \"00:45\",logoutTime = \"01:00\") == 1\n assert candidate(loginTime = \"21:10\",logoutTime = \"21:14\") == 0\n assert candidate(loginTime = \"12:45\",logoutTime = \"13:45\") == 4\n assert candidate(loginTime = \"00:10\",logoutTime = \"01:05\") == 3\n assert candidate(loginTime = \"14:00\",logoutTime = \"14:14\") == 0\n assert candidate(loginTime = \"17:10\",logoutTime = \"18:55\") == 6\n assert candidate(loginTime = \"06:30\",logoutTime = \"07:30\") == 4\n assert candidate(loginTime = \"00:44\",logoutTime = \"00:59\") == 0\n assert candidate(loginTime = \"16:00\",logoutTime = \"16:01\") == 0\n assert candidate(loginTime = \"09:00\",logoutTime = \"21:15\") == 49\n assert candidate(loginTime = \"15:10\",logoutTime = \"15:15\") == 0\n assert candidate(loginTime = \"14:00\",logoutTime = \"18:30\") == 18\n assert candidate(loginTime = \"20:00\",logoutTime = \"21:00\") == 4\n assert candidate(loginTime = \"11:10\",logoutTime = \"11:10\") == 0\n assert candidate(loginTime = \"11:45\",logoutTime = \"12:44\") == 3\n assert candidate(loginTime = \"07:45\",logoutTime = \"08:15\") == 2\n assert candidate(loginTime = \"10:00\",logoutTime = \"10:14\") == 0\n assert candidate(loginTime = \"07:05\",logoutTime = \"08:10\") == 3\n assert candidate(loginTime = \"08:45\",logoutTime = \"09:15\") == 2\n assert candidate(loginTime = \"16:45\",logoutTime = \"17:45\") == 4\n assert candidate(loginTime = \"07:01\",logoutTime = \"07:14\") == 0\n assert candidate(loginTime = \"11:46\",logoutTime = \"12:44\") == 2\n assert candidate(loginTime = \"09:00\",logoutTime = \"16:45\") == 31\n assert candidate(loginTime = \"13:30\",logoutTime = \"14:00\") == 2\n assert candidate(loginTime = \"20:00\",logoutTime = \"20:15\") == 1\n assert candidate(loginTime = \"00:00\",logoutTime = \"04:00\") == 16\n assert candidate(loginTime = \"00:00\",logoutTime = \"00:15\") == 1\n assert candidate(loginTime = \"07:07\",logoutTime = \"07:47\") == 2\n assert candidate(loginTime = \"13:46\",logoutTime = \"13:47\") == 0\n assert candidate(loginTime = \"13:15\",logoutTime = \"14:15\") == 4\n assert candidate(loginTime = \"14:16\",logoutTime = \"15:14\") == 2\n assert candidate(loginTime = \"21:00\",logoutTime = \"21:59\") == 3\n assert candidate(loginTime = \"07:00\",logoutTime = \"07:14\") == 0\n assert candidate(loginTime = \"01:01\",logoutTime = \"24:00\") == 91\n assert candidate(loginTime = \"17:15\",logoutTime = \"17:45\") == 2\n assert candidate(loginTime = \"12:00\",logoutTime = \"12:00\") == 0\n assert candidate(loginTime = \"03:45\",logoutTime = \"04:15\") == 2\n assert candidate(loginTime = \"04:45\",logoutTime = \"05:00\") == 1\n assert candidate(loginTime = \"00:00\",logoutTime = \"23:45\") == 95\n assert candidate(loginTime = \"02:20\",logoutTime = \"02:25\") == 0\n assert candidate(loginTime = \"09:45\",logoutTime = \"10:45\") == 4\n assert candidate(loginTime = \"22:00\",logoutTime = \"01:30\") == 14\n assert candidate(loginTime = \"07:07\",logoutTime = \"07:45\") == 2\n assert candidate(loginTime = \"22:45\",logoutTime = \"23:59\") == 4\n assert candidate(loginTime = \"05:00\",logoutTime = \"24:00\") == 76\n assert candidate(loginTime = \"02:30\",logoutTime = \"03:30\") == 4\n assert candidate(loginTime = \"13:23\",logoutTime = \"14:22\") == 3\n assert candidate(loginTime = \"16:20\",logoutTime = \"18:55\") == 9\n assert candidate(loginTime = \"00:00\",logoutTime = \"00:14\") == 0\n assert candidate(loginTime = \"08:20\",logoutTime = \"09:20\") == 3\n assert candidate(loginTime = \"12:05\",logoutTime = \"12:20\") == 0\n assert candidate(loginTime = \"03:33\",logoutTime = \"04:48\") == 4\n assert candidate(loginTime = \"23:00\",logoutTime = \"23:15\") == 1\n assert candidate(loginTime = \"13:46\",logoutTime = \"14:14\") == 0\n assert candidate(loginTime = \"15:00\",logoutTime = \"15:15\") == 1\n assert candidate(loginTime = \"13:15\",logoutTime = \"13:30\") == 1\n assert candidate(loginTime = \"15:00\",logoutTime = \"16:00\") == 4\n assert candidate(loginTime = \"03:00\",logoutTime = \"03:01\") == 0\n assert candidate(loginTime = \"09:00\",logoutTime = \"09:00\") == 0\n assert candidate(loginTime = \"00:00\",logoutTime = \"24:00\") == 96\n assert candidate(loginTime = \"19:40\",logoutTime = \"20:05\") == 1\n assert candidate(loginTime = \"16:00\",logoutTime = \"17:00\") == 4\n assert candidate(loginTime = \"12:46\",logoutTime = \"13:14\") == 0\n assert candidate(loginTime = \"03:45\",logoutTime = \"03:45\") == 0\n assert candidate(loginTime = \"00:15\",logoutTime = \"00:30\") == 1\n assert candidate(loginTime = \"08:30\",logoutTime = \"09:00\") == 2\n assert candidate(loginTime = \"23:15\",logoutTime = \"00:14\") == 3\n assert candidate(loginTime = \"05:55\",logoutTime = \"06:05\") == 0\n assert candidate(loginTime = \"00:15\",logoutTime = \"23:59\") == 94\n assert candidate(loginTime = \"10:00\",logoutTime = \"10:00\") == 0\n assert candidate(loginTime = \"01:59\",logoutTime = \"02:01\") == 0\n assert candidate(loginTime = \"06:59\",logoutTime = \"07:00\") == 0\n assert candidate(loginTime = \"23:40\",logoutTime = \"00:10\") == 1\n assert candidate(loginTime = \"09:00\",logoutTime = \"09:59\") == 3\n assert candidate(loginTime = \"06:30\",logoutTime = \"07:00\") == 2\n assert candidate(loginTime = \"01:45\",logoutTime = \"02:44\") == 3\n assert candidate(loginTime = \"18:00\",logoutTime = \"18:00\") == 0\n assert candidate(loginTime = \"01:14\",logoutTime = \"01:46\") == 2\n assert candidate(loginTime = \"23:55\",logoutTime = \"00:05\") == 0\n assert candidate(loginTime = \"09:00\",logoutTime = \"18:45\") == 39\n assert candidate(loginTime = \"01:46\",logoutTime = \"02:14\") == 0\n assert candidate(loginTime = \"09:10\",logoutTime = \"09:20\") == 0\n assert candidate(loginTime = \"09:00\",logoutTime = \"09:14\") == 0\n assert candidate(loginTime = \"18:25\",logoutTime = \"19:50\") == 5\n assert candidate(loginTime = \"23:00\",logoutTime = \"23:45\") == 3\n assert candidate(loginTime = \"07:05\",logoutTime = \"08:05\") == 3\n assert candidate(loginTime = \"23:30\",logoutTime = \"00:30\") == 4\n assert candidate(loginTime = \"10:00\",logoutTime = \"24:00\") == 56\n assert candidate(loginTime = \"06:30\",logoutTime = \"09:15\") == 11\n assert candidate(loginTime = \"06:45\",logoutTime = \"07:00\") == 1\n assert candidate(loginTime = \"00:30\",logoutTime = \"00:45\") == 1\n assert candidate(loginTime = \"21:00\",logoutTime = \"22:15\") == 5\n assert candidate(loginTime = \"14:45\",logoutTime = \"15:00\") == 1\n assert candidate(loginTime = \"00:05\",logoutTime = \"00:30\") == 1\n assert candidate(loginTime = \"11:59\",logoutTime = \"12:14\") == 0\n assert candidate(loginTime = \"18:45\",logoutTime = \"19:10\") == 1\n assert candidate(loginTime = \"13:30\",logoutTime = \"16:45\") == 13\n assert candidate(loginTime = \"09:44\",logoutTime = \"09:45\") == 0\n assert candidate(loginTime = \"08:29\",logoutTime = \"08:40\") == 0\n assert candidate(loginTime = \"14:30\",logoutTime = \"16:30\") == 8\n assert candidate(loginTime = \"01:05\",logoutTime = \"02:30\") == 5\n assert candidate(loginTime = \"00:00\",logoutTime = \"01:00\") == 4\n assert candidate(loginTime = \"05:15\",logoutTime = \"05:15\") == 0\n assert candidate(loginTime = \"13:20\",logoutTime = \"13:59\") == 1\n assert candidate(loginTime = \"09:59\",logoutTime = \"10:00\") == 0\n assert candidate(loginTime = \"10:10\",logoutTime = \"11:09\") == 3\n assert candidate(loginTime = \"01:10\",logoutTime = \"01:40\") == 1\n assert candidate(loginTime = \"13:00\",logoutTime = \"13:14\") == 0\n assert candidate(loginTime = \"23:01\",logoutTime = \"23:14\") == 0\n assert candidate(loginTime = \"19:15\",logoutTime = \"20:00\") == 3\n"}, "metadata": {"canonical_parameter_names": ["loginTime", "logoutTime"], "leetcode_dataset_entry_point": "Solution().numberOfRounds", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numberOfRounds(string loginTime, string logoutTime) {", "container": "Solution", "callable": "numberOfRounds", "parameters": [{"name": "loginTime", "type": "string"}, {"name": "logoutTime", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1905, "task_id": "count-sub-islands", "difficulty": "Medium", "problem_description": "You are given two m x n binary matrices grid1 and grid2 containing only 0's (representing water) and 1's (representing land). An island is a group of 1's connected 4-directionally (horizontal or vertical). Any cells outside of the grid are considered water cells.\nAn island in grid2 is considered a sub-island if there is an island in grid1 that contains all the cells that make up this island in grid2.\nReturn the number of islands in grid2 that are considered sub-islands.\n \nExample 1:\n\n\nInput: grid1 = [[1,1,1,0,0],[0,1,1,1,1],[0,0,0,0,0],[1,0,0,0,0],[1,1,0,1,1]], grid2 = [[1,1,1,0,0],[0,0,1,1,1],[0,1,0,0,0],[1,0,1,1,0],[0,1,0,1,0]]\nOutput: 3\nExplanation: In the picture above, the grid on the left is grid1 and the grid on the right is grid2.\nThe 1s colored red in grid2 are those considered to be part of a sub-island. There are three sub-islands.\n\nExample 2:\n\n\nInput: grid1 = [[1,0,1,0,1],[1,1,1,1,1],[0,0,0,0,0],[1,1,1,1,1],[1,0,1,0,1]], grid2 = [[0,0,0,0,0],[1,1,1,1,1],[0,1,0,1,0],[0,1,0,1,0],[1,0,0,0,1]]\nOutput: 2 \nExplanation: In the picture above, the grid on the left is grid1 and the grid on the right is grid2.\nThe 1s colored red in grid2 are those considered to be part of a sub-island. There are two sub-islands.\n\n \nConstraints:\n\nm == grid1.length == grid2.length\nn == grid1[i].length == grid2[i].length\n1 <= m, n <= 500\ngrid1[i][j] and grid2[i][j] are either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid1 = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 1, 1], [0, 0, 0, 0, 0]],grid2 = [[1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 1, 0], [0, 0, 0, 0, 1]]) == 2\n assert candidate(grid1 = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],grid2 = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 0\n assert candidate(grid1 = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 1, 1]],grid2 = [[1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 0, 1, 1], [0, 0, 0, 0, 0]]) == 2\n assert candidate(grid1 = [[1, 1, 1], [0, 0, 0], [0, 0, 0]],grid2 = [[1, 1, 1], [0, 0, 0], [0, 0, 0]]) == 1\n assert candidate(grid1 = [[1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1]],grid2 = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1]]) == 2\n assert candidate(grid1 = [[0, 0, 0], [0, 0, 0]],grid2 = [[0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid1 = [[1, 1, 0, 1, 1], [1, 0, 0, 0, 0], [0, 0, 0, 0, 1], [1, 1, 0, 1, 1]],grid2 = [[1, 1, 0, 0, 0], [1, 0, 1, 1, 1], [0, 0, 0, 0, 1], [1, 1, 0, 1, 1]]) == 2\n assert candidate(grid1 = [[1, 1, 1, 0, 0], [0, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 0, 0, 0, 0], [1, 1, 0, 1, 1]],grid2 = [[1, 1, 1, 0, 0], [0, 0, 1, 1, 1], [0, 1, 0, 0, 0], [1, 0, 1, 1, 0], [0, 1, 0, 1, 0]]) == 3\n assert candidate(grid1 = [[1, 0, 1], [0, 1, 0], [1, 0, 1]],grid2 = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == 1\n assert candidate(grid1 = [[1, 1, 0, 0, 0], [1, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 0, 1]],grid2 = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [0, 0, 1, 0, 1]]) == 0\n assert candidate(grid1 = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],grid2 = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 1\n assert candidate(grid1 = [[1, 1, 1], [1, 0, 1], [1, 1, 1]],grid2 = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid1 = [[1, 0, 0, 1, 1], [0, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 1, 1], [1, 0, 1, 0, 1]],grid2 = [[1, 0, 0, 1, 1], [0, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 0, 1], [1, 0, 1, 0, 1]]) == 4\n assert candidate(grid1 = [[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 1, 1]],grid2 = [[1, 1, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 0, 1]]) == 2\n assert candidate(grid1 = [[1, 1, 1, 0, 0, 0, 0, 0], [1, 0, 0, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0]],grid2 = [[1, 1, 1, 0, 0, 0, 0, 0], [1, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0]]) == 3\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]],grid2 = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 0, 0], [1, 0, 0, 0, 1, 0, 0], [1, 0, 1, 0, 1, 1, 0], [0, 0, 1, 0, 1, 0, 0], [1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0]],grid2 = [[1, 1, 1, 1, 1, 0, 0], [1, 0, 0, 0, 1, 0, 0], [1, 0, 1, 0, 1, 1, 0], [0, 0, 1, 0, 1, 0, 0], [1, 1, 1, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0]]) == 3\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]],grid2 = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0]]) == 5\n assert candidate(grid1 = [[1, 1, 0, 0, 1, 1, 1, 1], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 0], [0, 0, 0, 1, 0, 0, 0, 1], [1, 1, 1, 1, 0, 0, 0, 1], [0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]],grid2 = [[1, 1, 0, 0, 1, 1, 1, 1], [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1], [1, 1, 1, 1, 0, 0, 0, 1], [0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]) == 5\n assert candidate(grid1 = [[0, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0]],grid2 = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]],grid2 = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 50\n assert candidate(grid1 = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]],grid2 = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 13\n assert candidate(grid1 = [[1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0]],grid2 = [[1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1, 0], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1, 1, 0, 0]]) == 23\n assert candidate(grid1 = [[1, 1, 1, 0, 0, 0, 1], [0, 0, 1, 1, 1, 1, 0], [0, 1, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, 1, 1], [1, 1, 0, 1, 1, 0, 1]],grid2 = [[1, 1, 1, 0, 0, 0, 1], [0, 0, 1, 1, 0, 1, 0], [0, 1, 1, 0, 0, 0, 0], [1, 0, 0, 0, 1, 1, 1], [1, 1, 0, 1, 0, 0, 1]]) == 5\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]],grid2 = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 0, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 0, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 19\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0, 0, 1, 0, 0], [0, 0, 1, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0, 0, 0], [0, 1, 0, 0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 14\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]],grid2 = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 3\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]],grid2 = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid1 = [[1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1]],grid2 = [[1, 0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0, 0], [1, 0, 0, 0, 1, 0, 0, 0, 1]]) == 5\n assert candidate(grid1 = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid1 = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]],grid2 = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]) == 1\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 1, 0], [1, 1, 1, 0, 0, 1, 0], [0, 0, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0, 1]],grid2 = [[1, 0, 1, 0, 1, 1, 0], [1, 1, 0, 0, 0, 1, 0], [0, 0, 1, 1, 1, 1, 1], [0, 0, 1, 1, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1]]) == 6\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]],grid2 = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 0, 0, 1], [1, 0, 0, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == 3\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0, 1, 1], [1, 1, 1, 0, 0, 0, 0, 1]],grid2 = [[0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0, 1, 1], [1, 1, 1, 0, 0, 0, 0, 1]]) == 2\n assert candidate(grid1 = [[1, 1, 0, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 0, 0], [1, 0, 0, 1, 0], [0, 0, 1, 0, 0]],grid2 = [[1, 1, 0, 1, 1], [0, 0, 1, 0, 0], [0, 0, 1, 1, 0], [1, 1, 0, 1, 0], [0, 0, 0, 0, 0]]) == 2\n assert candidate(grid1 = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]],grid2 = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]],grid2 = [[1, 0, 0, 0, 0, 0, 1, 0, 1], [0, 1, 0, 0, 0, 1, 0, 1, 0], [1, 0, 1, 0, 0, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 27\n assert candidate(grid1 = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]],grid2 = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 19\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]],grid2 = [[1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 7\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]],grid2 = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0, 1], [1, 0, 0, 1, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 1\n assert candidate(grid1 = [[1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 1, 0, 1, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1]],grid2 = [[0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 1, 0, 1, 0, 0, 0], [0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1]]) == 3\n assert candidate(grid1 = [[1, 1, 0, 0, 0, 0, 1], [1, 1, 0, 1, 0, 0, 1], [0, 0, 0, 1, 1, 0, 0], [0, 1, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 0, 0, 1, 1], [1, 1, 1, 0, 0, 1, 1]],grid2 = [[1, 1, 0, 0, 0, 0, 1], [1, 0, 0, 1, 0, 0, 1], [0, 0, 0, 1, 1, 0, 0], [0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 0, 0, 1, 1], [1, 1, 1, 0, 0, 0, 1]]) == 6\n assert candidate(grid1 = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]],grid2 = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 4\n assert candidate(grid1 = [[1, 1, 0, 0, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 1, 0, 0], [1, 0, 0, 0, 0, 1, 0, 0, 1], [1, 1, 1, 1, 1, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 0, 0, 1, 0, 1, 0, 1]],grid2 = [[0, 1, 0, 0, 0, 0, 1, 0, 0], [0, 0, 1, 1, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0, 0, 0], [1, 0, 0, 0, 0, 1, 0, 0, 1], [1, 1, 1, 1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 0, 0, 1, 0, 1, 0, 1]]) == 8\n assert candidate(grid1 = [[1, 1, 1, 0, 0, 0, 1], [1, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 0, 1, 1]],grid2 = [[1, 1, 1, 0, 0, 0, 1], [1, 0, 0, 0, 1, 1, 1], [0, 0, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 1, 1]]) == 6\n assert candidate(grid1 = [[1, 1, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 1, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 1, 0, 0, 0, 1], [0, 1, 1, 1, 0, 1, 0, 0, 0, 1], [0, 0, 0, 0, 1, 1, 0, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 1], [0, 0, 0, 1, 1, 1, 0, 0, 0, 1], [0, 0, 0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 0, 0, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]],grid2 = [[0, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0], [0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0]]) == 11\n assert candidate(grid1 = [[1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1]],grid2 = [[1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 0], [1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1]]) == 7\n assert candidate(grid1 = [[1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],grid2 = [[1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 5\n assert candidate(grid1 = [[1, 0, 0, 1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0, 1, 1, 0], [0, 0, 1, 0, 0, 1, 0, 0, 1, 0], [1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [0, 1, 0, 0, 1, 0, 0, 1, 0, 0], [1, 0, 1, 1, 0, 1, 1, 0, 1, 1], [0, 0, 0, 1, 0, 0, 0, 1, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1, 0]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 1, 1, 0, 1, 1, 0], [0, 0, 1, 0, 0, 1, 0, 0, 1, 0], [1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 1, 0, 1, 1, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 17\n assert candidate(grid1 = [[1, 1, 1, 0, 0, 0, 1], [0, 0, 1, 1, 1, 0, 1], [0, 0, 1, 0, 0, 0, 1], [1, 0, 1, 0, 0, 1, 1], [1, 0, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1]],grid2 = [[1, 1, 1, 0, 0, 0, 1], [0, 0, 1, 1, 1, 0, 1], [0, 0, 1, 0, 0, 0, 1], [1, 0, 1, 0, 0, 1, 1], [1, 0, 1, 1, 1, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 3\n assert candidate(grid1 = [[1, 1, 0, 0, 1, 1], [1, 0, 0, 1, 0, 0], [0, 0, 1, 1, 1, 0], [0, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 1], [1, 1, 0, 1, 1, 0]],grid2 = [[1, 1, 0, 0, 1, 1], [1, 0, 0, 1, 0, 0], [0, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 1], [1, 1, 0, 1, 1, 0]]) == 6\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 0, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 0, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 0, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1]],grid2 = [[0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0]]) == 9\n assert candidate(grid1 = [[1, 1, 0, 0, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 0, 1], [1, 1, 0, 0, 0, 1, 1]],grid2 = [[1, 1, 0, 0, 0, 1, 1], [1, 0, 1, 1, 1, 0, 1], [0, 1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 0], [1, 0, 1, 1, 1, 0, 1], [1, 1, 0, 0, 0, 1, 1]]) == 4\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]],grid2 = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == 14\n assert candidate(grid1 = [[1, 0, 0, 1, 0, 1, 1, 0, 0, 1], [0, 1, 0, 1, 0, 1, 1, 0, 0, 1], [0, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 0, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]],grid2 = [[0, 0, 0, 1, 0, 1, 1, 0, 0, 1], [0, 1, 0, 1, 0, 1, 1, 0, 0, 1], [0, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 0, 0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 0, 0, 1, 0, 1, 0], [0, 0, 0, 1, 0, 0, 0, 1, 0, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 33\n assert candidate(grid1 = [[1, 1, 0, 0, 1], [1, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 1, 0, 1], [1, 1, 0, 0, 1]],grid2 = [[1, 1, 0, 0, 1], [1, 0, 0, 0, 0], [0, 0, 1, 1, 1], [0, 0, 0, 0, 1], [1, 1, 0, 0, 1]]) == 4\n assert candidate(grid1 = [[1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]],grid2 = [[1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 46\n assert candidate(grid1 = [[1, 1, 0, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 0, 1, 0, 1]],grid2 = [[1, 1, 0, 0, 0, 0, 1], [0, 0, 0, 1, 0, 1, 0], [0, 0, 1, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 0, 0, 0, 1]]) == 10\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],grid2 = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 1\n assert candidate(grid1 = [[1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 0, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 1], [0, 0, 0, 1, 0, 0, 1, 1], [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]) == 5\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid1 = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 1\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]],grid2 = [[0, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 0, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 0, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 0]]) == 26\n assert candidate(grid1 = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]],grid2 = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 1, 0, 0, 1, 0, 0, 1, 0], [0, 0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 13\n assert candidate(grid1 = [[1, 0, 0, 1, 1, 0, 1], [0, 0, 1, 1, 1, 0, 0], [1, 0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0, 1]],grid2 = [[1, 0, 0, 1, 0, 0, 1], [0, 0, 1, 1, 0, 0, 0], [1, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 1], [1, 0, 0, 0, 0, 0, 1]]) == 5\n"}, "metadata": {"canonical_parameter_names": ["grid1", "grid2"], "leetcode_dataset_entry_point": "Solution().countSubIslands", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countSubIslands(vector>& grid1, vector>& grid2) {", "container": "Solution", "callable": "countSubIslands", "parameters": [{"name": "grid1", "type": "vector>&"}, {"name": "grid2", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1906, "task_id": "minimum-absolute-difference-queries", "difficulty": "Medium", "problem_description": "The minimum absolute difference of an array a is defined as the minimum value of |a[i] - a[j]|, where 0 <= i < j < a.length and a[i] != a[j]. If all elements of a are the same, the minimum absolute difference is -1.\n\nFor example, the minimum absolute difference of the array [5,2,3,7,2] is |2 - 3| = 1. Note that it is not 0 because a[i] and a[j] must be different.\n\nYou are given an integer array nums and the array queries where queries[i] = [li, ri]. For each query i, compute the minimum absolute difference of the subarray nums[li...ri] containing the elements of nums between the 0-based indices li and ri (inclusive).\nReturn an array ans where ans[i] is the answer to the ith query.\nA subarray is a contiguous sequence of elements in an array.\nThe value of |x| is defined as:\n\nx if x >= 0.\n-x if x < 0.\n\n \nExample 1:\n\nInput: nums = [1,3,4,8], queries = [[0,1],[1,2],[2,3],[0,3]]\nOutput: [2,1,4,1]\nExplanation: The queries are processed as follows:\n- queries[0] = [0,1]: The subarray is [1,3] and the minimum absolute difference is |1-3| = 2.\n- queries[1] = [1,2]: The subarray is [3,4] and the minimum absolute difference is |3-4| = 1.\n- queries[2] = [2,3]: The subarray is [4,8] and the minimum absolute difference is |4-8| = 4.\n- queries[3] = [0,3]: The subarray is [1,3,4,8] and the minimum absolute difference is |3-4| = 1.\n\nExample 2:\n\nInput: nums = [4,5,2,2,7,10], queries = [[2,3],[0,2],[0,5],[3,5]]\nOutput: [-1,1,1,3]\nExplanation: The queries are processed as follows:\n- queries[0] = [2,3]: The subarray is [2,2] and the minimum absolute difference is -1 because all the\n elements are the same.\n- queries[1] = [0,2]: The subarray is [4,5,2] and the minimum absolute difference is |4-5| = 1.\n- queries[2] = [0,5]: The subarray is [4,5,2,2,7,10] and the minimum absolute difference is |4-5| = 1.\n- queries[3] = [3,5]: The subarray is [2,7,10] and the minimum absolute difference is |7-10| = 3.\n\n \nConstraints:\n\n2 <= nums.length <= 105\n1 <= nums[i] <= 100\n1 <= queries.length <= 2 * 104\n0 <= li < ri < nums.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30, 40, 50],queries = [[0, 0], [1, 1], [2, 2], [0, 4]]) == [-1, -1, -1, 10]\n assert candidate(nums = [1, 1, 1, 1, 1],queries = [[0, 4], [1, 3]]) == [-1, -1]\n assert candidate(nums = [5, 5, 5, 5],queries = [[0, 3], [1, 2], [2, 3], [0, 1]]) == [-1, -1, -1, -1]\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [5, 5, 5, 5],queries = [[0, 3], [1, 2]]) == [-1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5],queries = [[0, 4], [1, 3], [2, 2]]) == [1, 1, -1]\n assert candidate(nums = [4, 5, 2, 2, 7, 10],queries = [[2, 3], [0, 2], [0, 5], [3, 5]]) == [-1, 1, 1, 3]\n assert candidate(nums = [1, 3, 4, 8],queries = [[0, 1], [1, 2], [2, 3], [0, 3]]) == [2, 1, 4, 1]\n assert candidate(nums = [100, 1, 100, 1, 100],queries = [[0, 4], [1, 3], [2, 2]]) == [99, 99, -1]\n assert candidate(nums = [100, 1, 2, 3, 4, 100],queries = [[0, 5], [1, 4], [2, 3], [0, 1]]) == [1, 1, 1, 99]\n assert candidate(nums = [3, 1, 2, 3, 1, 2, 3],queries = [[0, 6], [1, 5], [2, 4]]) == [1, 1, 1]\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 5]\n assert candidate(nums = [9, 10, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 10], [2, 9], [5, 8], [1, 4], [3, 6]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [99, 99, 99, 99, 99]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 19], [1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19], [0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [8, 8, 8, 1, 2, 3, 4, 5, 6, 7, 8, 8, 8, 8],queries = [[0, 13], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8]]) == [1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 19], [0, 9], [10, 19], [5, 15], [1, 18]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7]]) == [-1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [5, 9]]) == [1, 1, 1, 1, 3, 1, 1]\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [0, 19], [9, 10]]) == [99, 99, 99, 99, 99, 99]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],queries = [[0, 29], [1, 28], [2, 27], [3, 26], [4, 25]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [5, 1, 4, 8, 2, 3, 7, 6],queries = [[0, 2], [1, 6], [3, 7], [0, 7], [2, 5]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],queries = [[0, 9], [0, 4], [5, 9], [2, 8], [1, 7]]) == [2, 2, 2, 2, 2]\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 3], [5, 8], [0, 4]]) == [-1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 2, 4, 5, 7, 6, 8, 9, 10, 12, 11, 14, 13, 15],queries = [[0, 14], [0, 4], [5, 14], [2, 12], [1, 10]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [3, 6, 5, 4, 7, 8, 1, 2, 9],queries = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 4]]) == [1, 1, 1, 1, -1]\n assert candidate(nums = [50, 20, 30, 10, 40],queries = [[0, 4], [1, 3], [2, 4], [0, 3], [1, 4], [0, 2], [3, 4], [0, 1]]) == [10, 10, 10, 10, 10, 10, 30, 30]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 9], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [10, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15]]) == [-1, -1, -1, -1, -1]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5],queries = [[0, 14], [1, 3], [5, 7], [9, 11], [0, 4], [6, 8]]) == [1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [2, 5], [5, 8], [1, 1], [8, 9]]) == [1, 1, 1, -1, 1]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [0, 19], [9, 10]]) == [1, 1, 1, 1, 1, 2]\n assert candidate(nums = [3, 1, 2, 1, 3, 1, 2, 1],queries = [[0, 7], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2]]) == [1, 1, 1, 2, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8]]) == [1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [42, 21, 17, 36, 21, 21, 17, 42, 36, 21],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4]]) == [4, 4, 4, 4, -1, 4]\n assert candidate(nums = [1, 2, 1, 3, 4, 5, 4, 3, 2, 1],queries = [[0, 9], [0, 0], [9, 9], [1, 8], [3, 6]]) == [1, -1, -1, 1, 1]\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]]) == [9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(nums = [10, 1, 2, 10, 1, 2, 10, 1, 2, 10],queries = [[0, 9], [0, 2], [3, 5], [6, 8], [1, 7]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 3, 2, 4, 3, 2, 1, 3, 2, 4],queries = [[0, 3], [1, 5], [2, 8], [3, 9], [0, 9]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],queries = [[0, 5], [5, 9], [0, 9], [2, 7], [1, 8]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 95]\n assert candidate(nums = [5, 2, 5, 2, 7, 5, 2, 2, 5, 7, 5, 2],queries = [[0, 10], [2, 8], [4, 7], [0, 11], [5, 5], [6, 6]]) == [2, 2, 2, 2, -1, -1]\n assert candidate(nums = [50, 40, 30, 20, 10, 20, 30, 40, 50, 60],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [10, 10, 10, 10, 10]\n assert candidate(nums = [3, 1, 5, 1, 3, 2, 5, 3, 2, 1],queries = [[0, 4], [4, 8], [0, 9], [1, 5], [5, 9]]) == [2, 1, 1, 1, 1]\n assert candidate(nums = [2, 5, 1, 4, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],queries = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50],queries = [[0, 9], [0, 4], [5, 9], [2, 8], [1, 7]]) == [10, 10, 10, 10, 10]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [1, 1, 1, 1, 1, 1, 1, 1, 2, 2]\n assert candidate(nums = [5, 5, 1, 1, 9, 9, 5, 5, 1, 1, 9, 9],queries = [[0, 11], [0, 3], [2, 5], [4, 7], [6, 9], [8, 11]]) == [4, 4, 8, 4, 4, 8]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14]]) == [1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [0, 19], [9, 10]]) == [-1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [-1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [5, 9]]) == [10, 10, 10, 10, 10, 10, 10]\n assert candidate(nums = [20, 30, 10, 40, 50, 10, 20, 30, 40, 50],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [10, 10, 10, 10, 40]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 7]]) == [1, 1, 1, 1, 1, 1, 1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 2], [2, 4], [4, 6], [6, 8], [1, 3], [3, 5], [5, 7], [7, 9]]) == [1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [3, 1, 2, 3, 1, 2, 3, 1, 2],queries = [[0, 8], [1, 5], [2, 6], [3, 7], [4, 8], [0, 3], [5, 8], [0, 4]]) == [1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],queries = [[0, 9], [0, 4], [5, 9], [2, 8], [1, 7]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [10, 19], [0, 19], [5, 14], [1, 18]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [5, 2, 5, 2, 5, 2, 5, 2, 5, 2],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [3, 3, 3, 3, 3]\n assert candidate(nums = [50, 40, 30, 20, 10, 20, 30, 40, 50],queries = [[0, 4], [4, 8], [0, 8], [1, 7], [2, 6]]) == [10, 10, 10, 10, 10]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 9], [1, 4], [5, 8], [2, 7], [0, 0], [9, 9]]) == [10, 10, 10, 10, -1, -1]\n assert candidate(nums = [1, 5, 3, 9, 7, 11, 13, 15, 17, 19],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 3], [5, 8], [0, 4], [1, 3], [2, 4], [1, 5], [3, 7], [0, 6]]) == [2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],queries = [[0, 10], [0, 5], [5, 10], [2, 8], [1, 9]]) == [5, 5, 5, 5, 5]\n assert candidate(nums = [7, 10, 4, 3, 20, 15],queries = [[0, 5], [1, 2], [2, 4], [3, 5], [0, 4], [1, 3], [2, 5], [0, 3]]) == [1, 6, 1, 5, 1, 1, 1, 1]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [4, 1, 3, 2, 5, 6, 7, 8, 9, 10],queries = [[0, 9], [1, 4], [2, 6], [0, 5], [3, 8], [4, 9], [0, 2], [7, 9]]) == [1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],queries = [[0, 19], [1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [10, 10, 10, 10, 10]\n assert candidate(nums = [50, 1, 51, 2, 52, 3, 53, 4, 54, 5, 55, 6, 56, 7, 57, 8, 58, 9, 59, 10],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 50]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [2, 4, 2, 4, 2, 4, 2, 4, 2, 4],queries = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [0, 9], [1, 8], [2, 7], [3, 6]]) == [2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(nums = [5, 6, 6, 5, 5, 6, 5, 6, 6, 5],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 3], [5, 8], [0, 4], [1, 3], [2, 4]]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1],queries = [[0, 10], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == [1, 1, 1, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],queries = [[0, 19], [1, 18], [2, 17], [3, 16], [4, 15]]) == [2, 2, 2, 2, 2]\n assert candidate(nums = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 3], [5, 8], [0, 4], [1, 3], [2, 4], [1, 5], [3, 7], [0, 6], [4, 8], [0, 7], [2, 9]]) == [1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [5, 9]]) == [-1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [1, 1, 1, 1, 95]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9]]) == [1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],queries = [[0, 14], [0, 4], [5, 14], [2, 12], [1, 10]]) == [1, 1, 1, 1, 1]\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],queries = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [0, 4], [5, 9]]) == [10, 10, 10, 10, 10, 10, 10]\n"}, "metadata": {"canonical_parameter_names": ["nums", "queries"], "leetcode_dataset_entry_point": "Solution().minDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector minDifference(vector& nums, vector>& queries) {", "container": "Solution", "callable": "minDifference", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "queries", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1909, "task_id": "remove-one-element-to-make-the-array-strictly-increasing", "difficulty": "Easy", "problem_description": "Given a 0-indexed integer array nums, return true if it can be made strictly increasing after removing exactly one element, or false otherwise. If the array is already strictly increasing, return true.\nThe array nums is strictly increasing if nums[i - 1] < nums[i] for each index (1 <= i < nums.length).\n \nExample 1:\n\nInput: nums = [1,2,10,5,7]\nOutput: true\nExplanation: By removing 10 at index 2 from nums, it becomes [1,2,5,7].\n[1,2,5,7] is strictly increasing, so return true.\n\nExample 2:\n\nInput: nums = [2,3,1,2]\nOutput: false\nExplanation:\n[3,1,2] is the result of removing the element at index 0.\n[2,1,2] is the result of removing the element at index 1.\n[2,3,2] is the result of removing the element at index 2.\n[2,3,1] is the result of removing the element at index 3.\nNo resulting array is strictly increasing, so return false.\nExample 3:\n\nInput: nums = [1,1,1]\nOutput: false\nExplanation: The result of removing any element is [1,1].\n[1,1] is not strictly increasing, so return false.\n\n \nConstraints:\n\n2 <= nums.length <= 1000\n1 <= nums[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 3, 2, 4, 5]) == True\n assert candidate(nums = [1, 2, 2, 3, 4, 5]) == True\n assert candidate(nums = [1, 2, 2, 3]) == True\n assert candidate(nums = [1, 1, 1]) == False\n assert candidate(nums = [10, 9, 2, 5, 3, 7, 101, 18]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 3]) == True\n assert candidate(nums = [3, 5, 4, 6, 7]) == True\n assert candidate(nums = [1, 2, 10, 5, 7]) == True\n assert candidate(nums = [1, 2, 3, 4, 5]) == True\n assert candidate(nums = [10, 1, 2, 3, 4, 5]) == True\n assert candidate(nums = [5, 2, 3, 4]) == True\n assert candidate(nums = [100, 20, 30]) == True\n assert candidate(nums = [3, 2, 1]) == False\n assert candidate(nums = [5, 7, 1, 8]) == True\n assert candidate(nums = [1, 2, 3, 3, 4]) == True\n assert candidate(nums = [5, 4, 3, 2, 1]) == False\n assert candidate(nums = [1, 2, 2, 3, 4]) == True\n assert candidate(nums = [1, 2, 3]) == True\n assert candidate(nums = [2, 3, 1, 2]) == False\n assert candidate(nums = [100, 200, 150, 300]) == True\n assert candidate(nums = [100, 200, 150, 300, 400]) == True\n assert candidate(nums = [1, 3, 2, 4]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 19]) == True\n assert candidate(nums = [1, 2, 3, 5, 4, 3, 2, 6, 7, 8]) == False\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 8, 9]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 15]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 3]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 2]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 5, 15, 16, 17]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 7, 8, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 21]) == True\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 12]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 22]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 5]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 5, 18, 19]) == True\n assert candidate(nums = [1, 3, 5, 2, 4, 6, 8, 7, 9]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 10, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 7, 8, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 5, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 1000, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 11, 12, 13]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 0]) == True\n assert candidate(nums = [1, 5, 2, 3, 4, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 10, 9, 11]) == True\n assert candidate(nums = [1, 3, 2, 5, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 5, 4, 3, 6, 7, 8]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 10, 8, 9, 11, 12]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 14]) == True\n assert candidate(nums = [1, 2, 3, 5, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == False\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 20, 27]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 12, 13]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 5]) == True\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 20, 23]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 11]) == True\n assert candidate(nums = [1, 2, 3, 5, 4, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 10, 9, 11, 12]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5]) == False\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 55]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 2]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 15]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 12, 13]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5]) == True\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]) == True\n assert candidate(nums = [1, 3, 5, 4, 7, 9, 8, 10, 12, 14, 15]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 13, 12]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 18]) == True\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7]) == True\n assert candidate(nums = [1, 2, 2, 2, 3, 4, 5]) == False\n assert candidate(nums = [3, 4, 5, 6, 7, 8, 9, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 25]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 18, 21, 23, 25, 27, 29]) == True\n assert candidate(nums = [1, 2, 3, 4, 3, 5, 6, 7, 8]) == True\n assert candidate(nums = [6, 7, 8, 9, 10, 5, 11, 12]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 6, 7]) == True\n assert candidate(nums = [8, 9, 10, 2, 11, 12]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == True\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 8, 10]) == False\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 2, 17, 19, 21]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 5, 19, 20]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 5, 16, 17, 18]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 5, 21, 22]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 24]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 3]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 21]) == True\n assert candidate(nums = [1, 3, 2, 4, 5, 6]) == True\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [10, 9, 8, 7, 6, 11, 12]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 12, 14]) == True\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [1, 2, 3, 10, 4, 5, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 12]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 13, 15, 16, 17, 18, 19]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 7, 9, 10, 11]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 23]) == True\n assert candidate(nums = [100, 200, 150, 250, 300]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 11]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 100, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 100, 4, 5, 6]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 25]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 4, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 15]) == True\n assert candidate(nums = [1, 3, 5, 7, 9, 8, 10, 12, 14]) == True\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7]) == True\n assert candidate(nums = [1, 3, 5, 7, 6, 8, 9]) == True\n assert candidate(nums = [1, 5, 2, 6, 3, 7, 4, 8]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 9, 8, 10, 11]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 10, 5, 6]) == True\n assert candidate(nums = [1, 2, 3, 4, 3, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 3, 5, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [1, 2, 2, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 10, 9, 11, 12]) == True\n assert candidate(nums = [1, 3, 2, 3, 4, 5]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 5, 7, 8, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 10, 11]) == False\n assert candidate(nums = [1, 2, 3, 5, 4, 6, 7, 8, 9]) == True\n assert candidate(nums = [1, 9, 2, 3, 4, 5]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 8]) == True\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5]) == False\n assert candidate(nums = [3, 5, 6, 7, 8, 9, 10, 5, 11, 12]) == True\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 3, 12, 13, 14, 15]) == True\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 8, 9]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 3]) == True\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 4]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 3, 14]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 11, 12, 13, 14, 15]) == True\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 4, 5, 6]) == False\n assert candidate(nums = [1, 2, 3, 4, 3, 5, 6, 7]) == True\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 10, 13]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 13]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5, 4, 11]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 5]) == True\n assert candidate(nums = [1, 2, 3, 5, 4, 6, 7, 8, 9, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 17]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 11]) == True\n assert candidate(nums = [10, 20, 30, 25, 40, 50]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 5, 20, 21]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 16]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 20, 22]) == True\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 10]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 8, 9, 11, 12, 13]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 10, 13, 14]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 10, 7, 8, 9]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 6, 7, 8]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 3, 7, 8, 9, 10]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 11, 12, 13, 14, 15]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 10]) == True\n assert candidate(nums = [1, 2, 2, 2, 3, 4, 5, 6, 7, 8]) == False\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 2]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 10, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 4, 7]) == True\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 20]) == True\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().canBeIncreasing", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool canBeIncreasing(vector& nums) {", "container": "Solution", "callable": "canBeIncreasing", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1910, "task_id": "remove-all-occurrences-of-a-substring", "difficulty": "Medium", "problem_description": "Given two strings s and part, perform the following operation on s until all occurrences of the substring part are removed:\n\nFind the leftmost occurrence of the substring part and remove it from s.\n\nReturn s after removing all occurrences of part.\nA substring is a contiguous sequence of characters in a string.\n \nExample 1:\n\nInput: s = \"daabcbaabcbc\", part = \"abc\"\nOutput: \"dab\"\nExplanation: The following operations are done:\n- s = \"daabcbaabcbc\", remove \"abc\" starting at index 2, so s = \"dabaabcbc\".\n- s = \"dabaabcbc\", remove \"abc\" starting at index 4, so s = \"dababc\".\n- s = \"dababc\", remove \"abc\" starting at index 3, so s = \"dab\".\nNow s has no occurrences of \"abc\".\n\nExample 2:\n\nInput: s = \"axxxxyyyyb\", part = \"xy\"\nOutput: \"ab\"\nExplanation: The following operations are done:\n- s = \"axxxxyyyyb\", remove \"xy\" starting at index 4 so s = \"axxxyyyb\".\n- s = \"axxxyyyb\", remove \"xy\" starting at index 3 so s = \"axxyyb\".\n- s = \"axxyyb\", remove \"xy\" starting at index 2 so s = \"axyb\".\n- s = \"axyb\", remove \"xy\" starting at index 1 so s = \"ab\".\nNow s has no occurrences of \"xy\".\n\n \nConstraints:\n\n1 <= s.length <= 1000\n1 <= part.length <= 1000\ns​​​​​​ and part consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcd\",part = \"efg\") == \"abcd\"\n assert candidate(s = \"zzzz\",part = \"zz\") == \"\"\n assert candidate(s = \"abcdabcdabcd\",part = \"abcd\") == \"\"\n assert candidate(s = \"abcdefg\",part = \"xyz\") == \"abcdefg\"\n assert candidate(s = \"abcde\",part = \"f\") == \"abcde\"\n assert candidate(s = \"daabcbaabcbc\",part = \"abc\") == \"dab\"\n assert candidate(s = \"abcabcabc\",part = \"bca\") == \"abc\"\n assert candidate(s = \"axxxxyyyyb\",part = \"xy\") == \"ab\"\n assert candidate(s = \"hello\",part = \"ll\") == \"heo\"\n assert candidate(s = \"abcabcabc\",part = \"abc\") == \"\"\n assert candidate(s = \"aaaa\",part = \"aa\") == \"\"\n assert candidate(s = \"mississippi\",part = \"issi\") == \"mssippi\"\n assert candidate(s = \"abababab\",part = \"aba\") == \"bb\"\n assert candidate(s = \"aaaaaaa\",part = \"aa\") == \"a\"\n assert candidate(s = \"zzzzzzz\",part = \"zzz\") == \"z\"\n assert candidate(s = \"banana\",part = \"na\") == \"ba\"\n assert candidate(s = \"abcabcabc\",part = \"cab\") == \"abc\"\n assert candidate(s = \"aabababa\",part = \"aba\") == \"ba\"\n assert candidate(s = \"abababababababababab\",part = \"abab\") == \"\"\n assert candidate(s = \"qwertyuiopqwertyuiopqwertyuiop\",part = \"erty\") == \"qwuiopqwuiopqwuiop\"\n assert candidate(s = \"hellohellohellohellohello\",part = \"hello\") == \"\"\n assert candidate(s = \"abcdefghij\",part = \"xyz\") == \"abcdefghij\"\n assert candidate(s = \"abcdabcdabcdabcd\",part = \"dabc\") == \"abcd\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",part = \"xyz\") == \"abcdefghijklmnopqrstuvw\"\n assert candidate(s = \"aabbccddeeff\",part = \"bbcc\") == \"aaddeeff\"\n assert candidate(s = \"exampleexampleexampleexample\",part = \"exampleexample\") == \"\"\n assert candidate(s = \"aaaaaaabbbbbbbcccccc\",part = \"abc\") == \"aaaaaaabbbbbbbcccccc\"\n assert candidate(s = \"aaaaabbbbbcccc\",part = \"ab\") == \"cccc\"\n assert candidate(s = \"thisisaverylongstringthatwillbeusedtocheckthefunctionality\",part = \"is\") == \"thaverylongstringthatwillbeusedtocheckthefunctionality\"\n assert candidate(s = \"yyyyyyyyyyyyyyyyyyyy\",part = \"yyyy\") == \"\"\n assert candidate(s = \"lkjhgfedcba\",part = \"fe\") == \"lkjhgdcba\"\n assert candidate(s = \"hellohellohello\",part = \"lohe\") == \"hellllo\"\n assert candidate(s = \"abcdeabcdeabcdeabcde\",part = \"abc\") == \"dededede\"\n assert candidate(s = \"hellohellohellohello\",part = \"elloh\") == \"hello\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",part = \"abc\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"aaaaaaaaaabcdeeeeee\",part = \"aaa\") == \"abcdeeeeee\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiop\",part = \"qwerty\") == \"uiopasdfghjklzxcvbnmuiop\"\n assert candidate(s = \"zzzzzzzzzz\",part = \"zz\") == \"\"\n assert candidate(s = \"stackoverflow\",part = \"flow\") == \"stackover\"\n assert candidate(s = \"aaaaaaabaaaaa\",part = \"aaaa\") == \"aaaba\"\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",part = \"ghij\") == \"abcdefabcdefabcdef\"\n assert candidate(s = \"acabacabacabacabacab\",part = \"acab\") == \"\"\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",part = \"abcdefghij\") == \"\"\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbcccccc\",part = \"abccba\") == \"aaaaaaaaaabbbbbbbbbbcccccc\"\n assert candidate(s = \"abcdefghij\",part = \"jihgfedcba\") == \"abcdefghij\"\n assert candidate(s = \"qwertyuiopqwertyuiop\",part = \"rty\") == \"qweuiopqweuiop\"\n assert candidate(s = \"ababababab\",part = \"aba\") == \"bbab\"\n assert candidate(s = \"aabbccddeeffgg\",part = \"bbcc\") == \"aaddeeffgg\"\n assert candidate(s = \"racecaracecaracecar\",part = \"aceca\") == \"rrrr\"\n assert candidate(s = \"xylophoneisfunxylophoneisfunxylophoneisfun\",part = \"xylophoneis\") == \"funfunfun\"\n assert candidate(s = \"abacabadabacaba\",part = \"abaca\") == \"badba\"\n assert candidate(s = \"supercalifragilisticexpialidocious\",part = \"cious\") == \"supercalifragilisticexpialido\"\n assert candidate(s = \"abababababababababab\",part = \"bab\") == \"aaaaa\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",part = \"abcabc\") == \"\"\n assert candidate(s = \"abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef\",part = \"defabc\") == \"abcdef\"\n assert candidate(s = \"abracadabra\",part = \"abra\") == \"cad\"\n assert candidate(s = \"aaabaaaabaaa\",part = \"aab\") == \"aaaaaa\"\n assert candidate(s = \"longstringwithsomerepeatedpatternpattern\",part = \"pattern\") == \"longstringwithsomerepeated\"\n assert candidate(s = \"programmingprogrammingprogramming\",part = \"gram\") == \"promingpromingproming\"\n assert candidate(s = \"abcabcabcabcabcabcabcabc\",part = \"abcabc\") == \"\"\n assert candidate(s = \"aaaaabaaaaabaaaaab\",part = \"ba\") == \"aaaaaaaaaaaaab\"\n assert candidate(s = \"hellohellohellohellohellohello\",part = \"ll\") == \"heoheoheoheoheoheo\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\",part = \"qwerty\") == \"uiopasdfghjklzxcvbnmuiopasdfghjklzxcvbnm\"\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyz\",part = \"xyzxyz\") == \"\"\n assert candidate(s = \"bananaapplebanana\",part = \"an\") == \"baappleba\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",part = \"mnop\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"xyxyxyxyxy\",part = \"xyx\") == \"yyxy\"\n assert candidate(s = \"hellohellohellohello\",part = \"llohe\") == \"hello\"\n assert candidate(s = \"aaaaabbbbbcccccd\",part = \"abc\") == \"aaaaabbbbbcccccd\"\n assert candidate(s = \"abcdabcdabcd\",part = \"cdab\") == \"abcd\"\n assert candidate(s = \"xyzxyzxyzxyz\",part = \"xyz\") == \"\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",part = \"nopqr\") == \"abcdefghijklmstuvwxyz\"\n assert candidate(s = \"xyzyxzyxzyxzyxzyxzyx\",part = \"zyx\") == \"xy\"\n assert candidate(s = \"zzzzzzzzzz\",part = \"zzz\") == \"z\"\n assert candidate(s = \"abcdefgabcdefgabcdefg\",part = \"efgabc\") == \"abcdddefg\"\n assert candidate(s = \"ababababab\",part = \"abab\") == \"ab\"\n assert candidate(s = \"xxxxxxxxxxxxxxxxxxxx\",part = \"xxx\") == \"xx\"\n assert candidate(s = \"pneumonoultramicroscopicsilicovolcanoconiosis\",part = \"micro\") == \"pneumonoultrascopicsilicovolcanoconiosis\"\n assert candidate(s = \"abcdefgabcdefg\",part = \"def\") == \"abcgabcg\"\n assert candidate(s = \"aabbccddeeaabbccddeeaabbccddeeaabbccdd\",part = \"abcd\") == \"aabbccddeeaabbccddeeaabbccddeeaabbccdd\"\n assert candidate(s = \"abacabadabacabadabacaba\",part = \"abad\") == \"abacabacabacaba\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwertyuiop\",part = \"erty\") == \"qwuiopasdfghjklzxcvbnmqwuiop\"\n assert candidate(s = \"abcdabcdeabcdabcdeabcd\",part = \"bcde\") == \"abcdaabcdaabcd\"\n assert candidate(s = \"abcdabcdabcdabcd\",part = \"abcd\") == \"\"\n assert candidate(s = \"ababababababababababababababababababababababababababababababababab\",part = \"abab\") == \"ab\"\n assert candidate(s = \"abcdabcdabcdabcd\",part = \"abcdabcd\") == \"\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",part = \"zyx\") == \"wvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwerty\",part = \"erty\") == \"qwuiopasdfghjklzxcvbnmqw\"\n assert candidate(s = \"noonnoonnoonnoon\",part = \"noon\") == \"\"\n assert candidate(s = \"oneonetwoonethreeonefouronefiveonesixone\",part = \"oneone\") == \"twoonethreeonefouronefiveonesixone\"\n assert candidate(s = \"12345678901234567890\",part = \"345\") == \"12678901267890\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",part = \"def\") == \"abcghijklmnopqrstuvwxyz\"\n assert candidate(s = \"thisisaverylongstringwithrepeatedpatterns\",part = \"pattern\") == \"thisisaverylongstringwithrepeateds\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnm\",part = \"mnop\") == \"qwertyuiopasdfghjklzxcvbnm\"\n assert candidate(s = \"abcdefghijabcdefghij\",part = \"cdefg\") == \"abhijabhij\"\n assert candidate(s = \"aaaaaaaaaaaabbbbbaaaaaaaaaaabbbbbaaaaaaaaaaabbbbbaaaaaaaaaaabbbbb\",part = \"aaaabbbb\") == \"aaaaaaaabaaaaaaabaaaaaaabaaaaaaab\"\n assert candidate(s = \"abcdefghabcdefghabcdefgh\",part = \"efgh\") == \"abcdabcdabcd\"\n assert candidate(s = \"thisisaverylongstringwithrepeatedpattern\",part = \"pattern\") == \"thisisaverylongstringwithrepeated\"\n assert candidate(s = \"abababababababab\",part = \"abab\") == \"\"\n assert candidate(s = \"abcdeabcdeabcdeabcde\",part = \"abcde\") == \"\"\n assert candidate(s = \"abababababababababab\",part = \"ababa\") == \"bbbab\"\n assert candidate(s = \"abcdeabcdeabcde\",part = \"bcde\") == \"aaa\"\n assert candidate(s = \"abcdefghij\",part = \"gh\") == \"abcdefij\"\n assert candidate(s = \"aabbccddeeff\",part = \"abc\") == \"aabbccddeeff\"\n assert candidate(s = \"xyxxyxyxyx\",part = \"xyx\") == \"y\"\n assert candidate(s = \"aaaaaa\",part = \"aa\") == \"\"\n assert candidate(s = \"abcdefabcdef\",part = \"defabc\") == \"abcdef\"\n assert candidate(s = \"zzzzzzzz\",part = \"zz\") == \"\"\n assert candidate(s = \"bananaanananasanananananana\",part = \"ana\") == \"bnnasnnna\"\n assert candidate(s = \"abcabcabcabcabcabc\",part = \"abcabc\") == \"\"\n assert candidate(s = \"aaaaaa\",part = \"a\") == \"\"\n assert candidate(s = \"abcdefghij\",part = \"efg\") == \"abcdhij\"\n assert candidate(s = \"onetwothreefourfivesixseveneightnineseven\",part = \"seven\") == \"onetwothreefourfivesixeightnine\"\n assert candidate(s = \"abcabcabcabcabcabc\",part = \"ab\") == \"cccccc\"\n assert candidate(s = \"mississippi\",part = \"iss\") == \"mippi\"\n assert candidate(s = \"aaaabbbbcccc\",part = \"bbcc\") == \"aaaa\"\n assert candidate(s = \"abracadabraabracadabra\",part = \"bracad\") == \"aabraaabra\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",part = \"abcdabcd\") == \"\"\n assert candidate(s = \"abababababababab\",part = \"aba\") == \"bbbb\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",part = \"zzzz\") == \"zz\"\n assert candidate(s = \"xyzxyzxyzxyzxyzxyz\",part = \"xyzxyz\") == \"\"\n assert candidate(s = \"aaaaaaaaaa\",part = \"aaa\") == \"a\"\n assert candidate(s = \"repeatedrepeatedrepeatedrepeated\",part = \"repeated\") == \"\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzz\",part = \"zzzz\") == \"zz\"\n assert candidate(s = \"repeatedsubstringrepeatedsubstring\",part = \"ted\") == \"repeasubstringrepeasubstring\"\n assert candidate(s = \"abcdefghijkabcdefghijkabcdefghijk\",part = \"efg\") == \"abcdhijkabcdhijkabcdhijk\"\n assert candidate(s = \"mnopqrsmnopqrsmnopqrs\",part = \"mnopqrs\") == \"\"\n assert candidate(s = \"ananasanananas\",part = \"ana\") == \"nasns\"\n assert candidate(s = \"zzzzz\",part = \"zz\") == \"z\"\n assert candidate(s = \"thisisaverylongstringwithrepeatedparts\",part = \"thisis\") == \"averylongstringwithrepeatedparts\"\n"}, "metadata": {"canonical_parameter_names": ["s", "part"], "leetcode_dataset_entry_point": "Solution().removeOccurrences", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string removeOccurrences(string s, string part) {", "container": "Solution", "callable": "removeOccurrences", "parameters": [{"name": "s", "type": "string"}, {"name": "part", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1911, "task_id": "maximum-alternating-subsequence-sum", "difficulty": "Medium", "problem_description": "The alternating sum of a 0-indexed array is defined as the sum of the elements at even indices minus the sum of the elements at odd indices.\\r\n\\r\n\\r\n\tFor example, the alternating sum of [4,2,5,3] is (4 + 5) - (2 + 3) = 4.\\r\n\\r\n\\r\nGiven an array nums, return the maximum alternating sum of any subsequence of nums (after reindexing the elements of the subsequence).\\r\n\\r\n\\r\n\\r\n\\r\nA subsequence of an array is a new array generated from the original array by deleting some elements (possibly none) without changing the remaining elements' relative order. For example, [2,7,4] is a subsequence of [4,2,3,7,2,1,4] (the underlined elements), while [2,4,2] is not.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: nums = [4,2,5,3]\\r\nOutput: 7\\r\nExplanation: It is optimal to choose the subsequence [4,2,5] with alternating sum (4 + 5) - 2 = 7.\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: nums = [5,6,7,8]\\r\nOutput: 8\\r\nExplanation: It is optimal to choose the subsequence [8] with alternating sum 8.\\r\n\\r\n\\r\nExample 3:\\r\n\\r\n\\r\nInput: nums = [6,2,1,2,4,5]\\r\nOutput: 10\\r\nExplanation: It is optimal to choose the subsequence [6,1,5] with alternating sum (6 + 5) - 1 = 10.\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= nums.length <= 105\\r\n\t1 <= nums[i] <= 105\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996]) == 100000\n assert candidate(nums = [4, 2, 5, 3]) == 7\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [6, 2, 1, 2, 4, 5]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [100]) == 100\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50]) == 50\n assert candidate(nums = [1, 100000, 1, 100000, 1]) == 199999\n assert candidate(nums = [5, 6, 7, 8]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5]) == 5\n assert candidate(nums = [100000, 1, 100000, 1, 100000]) == 299998\n assert candidate(nums = [10, 20, 30, 40, 50, 1, 2, 3, 4, 5]) == 54\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 17\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 100000\n assert candidate(nums = [100, 0, 100, 0, 100]) == 300\n assert candidate(nums = [100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1]) == 499996\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100]) == 991\n assert candidate(nums = [100, 50, 100, 50, 100, 50, 100]) == 250\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 24\n assert candidate(nums = [100, 10, 200, 20, 300, 30, 400, 40, 500, 50]) == 1400\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == 499976\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1, 11, 1, 12, 1, 13, 1, 14, 1, 15]) == 106\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1]) == 10\n assert candidate(nums = [100000, 50000, 100000, 50000, 100000, 50000, 100000, 50000, 100000, 50000]) == 300000\n assert candidate(nums = [5, 3, 8, 1, 4, 7, 2, 6, 9]) == 23\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 1000\n assert candidate(nums = [10, 20, 30, 40, 50, 40, 30, 20, 10, 20, 30, 40, 50, 60, 70]) == 110\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 6\n assert candidate(nums = [9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9]) == 65\n assert candidate(nums = [120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 120\n assert candidate(nums = [100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000]) == 499996\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == 9\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [10, 5, 10, 5, 10, 5, 10, 5, 10, 5]) == 30\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 100000\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 19\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2]) == 11\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]) == 15\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 7\n assert candidate(nums = [5, 3, 8, 12, 4, 9, 2, 7, 6, 10]) == 28\n assert candidate(nums = [10, 15, 10, 5, 20, 25, 30, 35, 40, 45]) == 55\n assert candidate(nums = [100000, 99999, 100000, 99998, 100000, 99997, 100000, 99996, 100000, 99995]) == 100010\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9]) == 15\n assert candidate(nums = [5, 3, 8, 6, 7, 2, 9, 4, 1, 10]) == 27\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 15\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5]) == 140\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 11\n assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 50, 40, 60, 50]) == 100\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 29\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 28\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 17\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 17\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5, 0, 9, 1, 8, 2, 7, 3, 6, 4, 5, 0]) == 50\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [9, 7, 8, 5, 6, 3, 4, 1, 2, 10]) == 21\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11]) == 20\n assert candidate(nums = [5, 3, 8, 6, 11, 9, 14, 12, 17, 15, 20, 18, 23, 21, 25]) == 39\n assert candidate(nums = [5, 3, 6, 7, 2, 9, 4, 10, 1, 11]) == 32\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 11\n assert candidate(nums = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == 13\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 20\n assert candidate(nums = [75, 70, 65, 60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5]) == 75\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 21\n assert candidate(nums = [5, 1, 4, 2, 7, 3, 6, 8]) == 18\n assert candidate(nums = [1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10]) == 46\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == 13\n assert candidate(nums = [99999, 1, 99998, 2, 99997, 3, 99996, 4]) == 399984\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 7\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 120\n assert candidate(nums = [10, 5, 15, 10, 20, 15, 25, 20, 30, 25]) == 50\n assert candidate(nums = [5, 1, 4, 2, 3]) == 9\n assert candidate(nums = [8, 6, 7, 5, 3, 0, 9, 1, 4, 2, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 38\n assert candidate(nums = [5, 1, 4, 2, 3, 1, 2, 1, 3, 2, 1]) == 12\n assert candidate(nums = [5, 3, 8, 12, 7, 10, 1, 15, 9, 20]) == 42\n assert candidate(nums = [100000, 1, 100000, 2, 100000, 3, 100000, 4, 100000, 5]) == 499990\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 110\n assert candidate(nums = [100, 200, 150, 300, 250, 350, 400, 300, 450, 500]) == 700\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5, 5, 4, 6, 3, 7, 2, 8, 1, 9]) == 45\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 150\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96]) == 476\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 10000, 1000, 100, 10]) == 100000\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 75\n assert candidate(nums = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 150\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxAlternatingSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long maxAlternatingSum(vector& nums) {", "container": "Solution", "callable": "maxAlternatingSum", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1913, "task_id": "maximum-product-difference-between-two-pairs", "difficulty": "Easy", "problem_description": "The product difference between two pairs (a, b) and (c, d) is defined as (a * b) - (c * d).\\r\n\\r\n\\r\n\tFor example, the product difference between (5, 6) and (2, 7) is (5 * 6) - (2 * 7) = 16.\\r\n\\r\n\\r\nGiven an integer array nums, choose four distinct indices w, x, y, and z such that the product difference between pairs (nums[w], nums[x]) and (nums[y], nums[z]) is maximized.\\r\n\\r\nReturn the maximum such product difference.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: nums = [5,6,2,7,4]\\r\nOutput: 34\\r\nExplanation: We can choose indices 1 and 3 for the first pair (6, 7) and indices 2 and 4 for the second pair (2, 4).\\r\nThe product difference is (6 * 7) - (2 * 4) = 34.\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: nums = [4,2,5,9,7,4,8]\\r\nOutput: 64\\r\nExplanation: We can choose indices 3 and 6 for the first pair (9, 8) and indices 1 and 5 for the second pair (2, 4).\\r\nThe product difference is (9 * 8) - (2 * 4) = 64.\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t4 <= nums.length <= 104\\r\n\t1 <= nums[i] <= 104\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 6, 2, 7, 4]) == 34\n assert candidate(nums = [9, 5, 8, 6, 7, 3, 2, 1, 4]) == 70\n assert candidate(nums = [1, 2, 3, 4]) == 10\n assert candidate(nums = [4, 2, 5, 9, 7, 4, 8]) == 64\n assert candidate(nums = [10000, 1, 10000, 1]) == 99999999\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 72\n assert candidate(nums = [9, 5, 8, 6, 7, 3, 4, 2, 1]) == 70\n assert candidate(nums = [9, 5, 8, 3, 7]) == 57\n assert candidate(nums = [10000, 1, 10000, 1, 10000, 1]) == 99999999\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 88000000\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 2080000\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 896\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 880000\n assert candidate(nums = [2345, 1234, 5678, 6789, 3456, 4567, 7890, 8901]) == 67335160\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 11766\n assert candidate(nums = [5000, 5000, 5000, 5000, 1, 1, 1, 1]) == 24999999\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10000, 10000, 10000, 10000, 10000]) == 99999999\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 832\n assert candidate(nums = [10000, 10000, 10000, 10000, 9999, 9999, 9999, 9999]) == 19999\n assert candidate(nums = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 1, 9999]) == 49990000\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 780\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == 80\n assert candidate(nums = [10000, 1, 9999, 2, 9998, 3, 9997, 4, 9996, 5]) == 99989998\n assert candidate(nums = [1, 10000, 2, 9999, 3, 9998, 4, 9997, 5, 9996]) == 99989998\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81]) == 3258\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10000, 10000, 10000, 10000, 10000]) == 99999975\n assert candidate(nums = [10000, 9999, 1, 2]) == 99989998\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 159928\n assert candidate(nums = [8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 100, 200, 300, 400, 500, 600, 700, 800]) == 55980000\n assert candidate(nums = [2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19]) == 357\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 10, 20, 30, 40, 50]) == 899800\n assert candidate(nums = [5000, 5000, 5000, 5000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 24999999\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009]) == 16072\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 99\n assert candidate(nums = [10000, 10000, 10000, 10000, 1, 1, 1, 1]) == 99999999\n assert candidate(nums = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == 2015\n assert candidate(nums = [3333, 6666, 4444, 7777, 2222, 8888, 1111, 9999]) == 86402470\n assert candidate(nums = [5000, 5000, 4999, 4999, 4998, 4998, 4997, 4997, 4996, 4996]) == 39984\n assert candidate(nums = [8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 500, 100, 50, 10, 5, 1, 2, 3, 4, 6, 7, 8]) == 55999998\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86]) == 2418\n assert candidate(nums = [1, 10000, 2, 9999, 3, 9998, 4, 9997, 5, 9996, 6, 9995, 7, 9994, 8, 9993, 9, 9992, 10, 9991]) == 99989998\n assert candidate(nums = [2, 3, 6, 7, 8, 10, 5, 4, 1, 9]) == 88\n assert candidate(nums = [10000, 10000, 10000, 1, 1, 1, 9999, 9999, 9999, 2]) == 99999999\n assert candidate(nums = [9999, 9998, 9997, 9996, 2, 3, 4, 5]) == 99969996\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109]) == 1672\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 378\n assert candidate(nums = [3, 9, 10, 2, 18, 15, 11, 1, 17, 7]) == 304\n assert candidate(nums = [1, 10000, 2, 9999, 3, 9998, 4, 9997, 5, 9996, 6, 9995, 7, 9994, 8]) == 99989998\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4]) == 899998\n assert candidate(nums = [1, 1, 1, 1, 10000, 10000, 10000, 10000, 9999, 9999, 9999, 9999]) == 99999999\n assert candidate(nums = [10000, 9999, 9998, 9997, 1, 2, 3, 4, 5, 6]) == 99989998\n assert candidate(nums = [1, 10000, 2, 9999, 3, 9998, 4, 9997]) == 99989998\n assert candidate(nums = [5000, 5001, 4999, 4998, 5002, 5003]) == 40004\n assert candidate(nums = [1, 10, 100, 1000, 10000, 1, 10, 100, 1000, 10000]) == 99999999\n assert candidate(nums = [5000, 5001, 5002, 5003, 5004, 1, 2, 3, 4, 5]) == 25035010\n assert candidate(nums = [10000, 9999, 9998, 9997, 1, 2, 3, 4]) == 99989998\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 10000, 10000]) == 99999991\n assert candidate(nums = [1, 10000, 1, 10000, 1, 10000, 1, 10000]) == 99999999\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 8800\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 2080000\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 8627\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 208\n assert candidate(nums = [1500, 1400, 1300, 1200, 1100, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 2080000\n assert candidate(nums = [1, 10000, 2, 9999, 3, 9998, 4, 9997, 5, 9996]) == 99989998\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 880000\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97]) == 9898\n assert candidate(nums = [1, 2, 3, 4, 5, 10000, 9999, 9998, 9997, 9996]) == 99989998\n assert candidate(nums = [1, 1, 1, 1, 10000, 10000, 10000, 10000, 10000, 10000]) == 99999999\n assert candidate(nums = [2500, 2501, 2502, 2503, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 6262504\n assert candidate(nums = [5000, 4000, 3000, 2000, 1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == 19999997\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 378\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 360\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10000, 9999]) == 99989999\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5]) == 899998\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986, 9985]) == 279790\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 8\n assert candidate(nums = [9999, 1, 9998, 2, 9997, 3, 9996, 4, 9995, 5, 9994, 6, 9993, 7, 9992, 8, 9991, 9, 9990, 10]) == 99970000\n assert candidate(nums = [5000, 5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008, 5009, 5010, 5011, 5012, 5013, 5014, 5015]) == 140210\n assert candidate(nums = [10000, 1, 9999, 2, 9998, 3, 9997, 4, 9996, 5]) == 99989998\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 99989998\n assert candidate(nums = [10000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 189998\n assert candidate(nums = [5000, 5000, 5000, 5000, 5000, 1, 2, 3, 4, 5]) == 24999998\n assert candidate(nums = [3000, 6000, 9000, 12000, 15000, 18000, 21000, 24000, 27000, 30000, 33000, 36000, 39000, 42000, 45000, 48000, 51000, 54000, 57000, 60000, 1, 2, 3, 4, 5]) == 3419999998\n assert candidate(nums = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 1, 2, 3, 4, 5]) == 99970000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 8800\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10000]) == 49975\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 1810\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53]) == 2485\n assert candidate(nums = [9999, 9998, 9997, 9996, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 99970000\n assert candidate(nums = [2500, 5000, 7500, 10000, 12500, 15000, 17500, 20000, 22500, 25000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 562499998\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 89\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 661\n assert candidate(nums = [5000, 5001, 5002, 5003, 1, 2, 3, 4]) == 25025004\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 20800\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 5200\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10000]) == 89998\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maxProductDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxProductDifference(vector& nums) {", "container": "Solution", "callable": "maxProductDifference", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1914, "task_id": "cyclically-rotating-a-grid", "difficulty": "Medium", "problem_description": "You are given an m x n integer matrix grid​​​, where m and n are both even integers, and an integer k.\\r\n\\r\nThe matrix is composed of several layers, which is shown in the below image, where each color is its own layer:\\r\n\\r\n\\r\n\\r\nA cyclic rotation of the matrix is done by cyclically rotating each layer in the matrix. To cyclically rotate a layer once, each element in the layer will take the place of the adjacent element in the counter-clockwise direction. An example rotation is shown below:\\r\n\\r\nReturn the matrix after applying k cyclic rotations to it.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: grid = [[40,10],[30,20]], k = 1\\r\nOutput: [[10,20],[40,30]]\\r\nExplanation: The figures above represent the grid at every state.\\r\n\\r\n\\r\nExample 2:\\r\n \\r\n\\r\n\\r\nInput: grid = [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]], k = 2\\r\nOutput: [[3,4,8,12],[2,11,10,16],[1,7,6,15],[5,9,13,14]]\\r\nExplanation: The figures above represent the grid at every state.\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\tm == grid.length\\r\n\tn == grid[i].length\\r\n\t2 <= m, n <= 50\\r\n\tBoth m and n are even integers.\\r\n\t1 <= grid[i][j] <= 5000\\r\n\t1 <= k <= 109\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 2], [3, 4], [5, 6], [7, 8]],k = 1) == [[2, 4], [1, 6], [3, 8], [5, 7]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 4) == [[5, 6, 7, 8, 16, 24, 32, 40], [4, 14, 15, 23, 31, 39, 47, 48], [3, 13, 30, 38, 46, 45, 55, 56], [2, 12, 22, 28, 29, 44, 54, 64], [1, 11, 21, 36, 37, 43, 53, 63], [9, 10, 20, 19, 27, 35, 52, 62], [17, 18, 26, 34, 42, 50, 51, 61], [25, 33, 41, 49, 57, 58, 59, 60]]\n assert candidate(grid = [[100, 200, 300, 400], [500, 600, 700, 800], [900, 1000, 1100, 1200], [1300, 1400, 1500, 1600]],k = 10) == [[900, 500, 100, 200], [1300, 1100, 1000, 300], [1400, 700, 600, 400], [1500, 1600, 1200, 800]]\n assert candidate(grid = [[100, 101, 102], [99, 103, 104], [98, 105, 106]],k = 4) == [[106, 105, 98], [104, 103, 99], [102, 101, 100]]\n assert candidate(grid = [[1, 2], [3, 4], [5, 6], [7, 8]],k = 5) == [[7, 5], [8, 3], [6, 1], [4, 2]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]],k = 3) == [[4, 5, 6, 12, 18, 24], [3, 11, 17, 23, 29, 30], [2, 10, 21, 15, 28, 36], [1, 9, 22, 16, 27, 35], [7, 8, 14, 20, 26, 34], [13, 19, 25, 31, 32, 33]]\n assert candidate(grid = [[5000, 5000, 5000, 5000], [5000, 1, 2, 5000], [5000, 4, 3, 5000], [5000, 5000, 5000, 5000]],k = 1000000000) == [[5000, 5000, 5000, 5000], [5000, 1, 2, 5000], [5000, 4, 3, 5000], [5000, 5000, 5000, 5000]]\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],k = 1000000000) == [[8, 12, 16, 15], [4, 6, 7, 14], [3, 10, 11, 13], [2, 1, 5, 9]]\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],k = 2) == [[3, 4, 8, 12], [2, 11, 10, 16], [1, 7, 6, 15], [5, 9, 13, 14]]\n assert candidate(grid = [[40, 10], [30, 20]],k = 1) == [[10, 20], [40, 30]]\n assert candidate(grid = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120], [130, 140, 150, 160]],k = 7) == [[150, 140, 130, 90], [160, 100, 60, 50], [120, 110, 70, 10], [80, 40, 30, 20]]\n assert candidate(grid = [[100, 101, 102, 103, 104, 105, 106, 107], [108, 11, 12, 13, 14, 15, 16, 109], [110, 17, 18, 19, 20, 21, 22, 111], [112, 23, 24, 25, 26, 27, 28, 113], [114, 29, 30, 31, 32, 33, 34, 115], [116, 35, 36, 37, 38, 39, 40, 117], [118, 41, 42, 43, 44, 45, 46, 119], [120, 121, 122, 123, 124, 125, 126, 127]],k = 10) == [[113, 115, 117, 119, 127, 126, 125, 124], [111, 46, 45, 44, 43, 42, 41, 123], [109, 40, 30, 24, 18, 19, 35, 122], [107, 34, 36, 32, 31, 20, 29, 121], [106, 28, 37, 26, 25, 21, 23, 120], [105, 22, 38, 39, 33, 27, 17, 118], [104, 16, 15, 14, 13, 12, 11, 116], [103, 102, 101, 100, 108, 110, 112, 114]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2]],k = 50) == [[1, 1, 1, 1, 1, 1, 1, 2], [1, 7, 6, 5, 4, 3, 2, 3], [2, 7, 5, 6, 6, 6, 2, 4], [3, 7, 4, 5, 4, 6, 2, 5], [4, 7, 3, 5, 4, 5, 2, 6], [5, 7, 3, 3, 3, 4, 2, 7], [6, 7, 6, 5, 4, 3, 2, 8], [7, 2, 2, 2, 2, 2, 2, 2]]\n assert candidate(grid = [[6, 7, 8, 9], [5, 2, 3, 10], [4, 1, 12, 11], [13, 14, 15, 16]],k = 3) == [[9, 10, 11, 16], [8, 1, 2, 15], [7, 12, 3, 14], [6, 5, 4, 13]]\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20], [21, 22, 23, 24], [25, 26, 27, 28], [29, 30, 31, 32]],k = 500000000) == [[1, 2, 3, 4], [5, 22, 18, 8], [9, 26, 14, 12], [13, 27, 10, 16], [17, 23, 6, 20], [21, 19, 7, 24], [25, 15, 11, 28], [29, 30, 31, 32]]\n assert candidate(grid = [[5000, 5000, 5000, 5000, 5000, 5000], [5000, 1, 2, 3, 4, 5000], [5000, 6, 7, 8, 9, 5000], [5000, 10, 11, 12, 13, 5000], [5000, 14, 15, 16, 17, 5000], [5000, 5000, 5000, 5000, 5000, 5000]],k = 1000000000) == [[5000, 5000, 5000, 5000, 5000, 5000], [5000, 9, 13, 17, 16, 5000], [5000, 4, 7, 8, 15, 5000], [5000, 3, 11, 12, 14, 5000], [5000, 2, 1, 6, 10, 5000], [5000, 5000, 5000, 5000, 5000, 5000]]\n assert candidate(grid = [[100, 101, 102, 103, 104], [99, 49, 50, 51, 105], [98, 48, 1, 2, 106], [97, 47, 46, 3, 107], [96, 95, 94, 93, 108]],k = 7) == [[107, 108, 93, 94, 95], [106, 48, 49, 50, 96], [105, 47, 1, 51, 97], [104, 46, 3, 2, 98], [103, 102, 101, 100, 99]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 25) == [[25, 17, 9, 1, 2, 3, 4, 5], [33, 15, 23, 31, 39, 47, 55, 6], [41, 14, 20, 21, 22, 30, 54, 7], [49, 13, 19, 29, 37, 38, 53, 8], [57, 12, 27, 28, 36, 46, 52, 16], [58, 11, 35, 43, 44, 45, 51, 24], [59, 10, 18, 26, 34, 42, 50, 32], [60, 61, 62, 63, 64, 56, 48, 40]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]],k = 1000000001) == [[2, 3, 4, 5, 6, 12], [1, 23, 29, 28, 27, 18], [7, 17, 16, 22, 26, 24], [13, 11, 15, 21, 20, 30], [19, 10, 9, 8, 14, 36], [25, 31, 32, 33, 34, 35]]\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]],k = 13) == [[16, 11, 6, 1, 2], [21, 18, 17, 12, 3], [22, 19, 13, 7, 4], [23, 14, 9, 8, 5], [24, 25, 20, 15, 10]]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 2, 2, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 2, 3, 4, 4, 3, 2, 1], [1, 2, 3, 4, 5, 4, 3, 1], [1, 2, 3, 4, 4, 3, 2, 1], [1, 2, 3, 3, 3, 3, 2, 1], [1, 2, 2, 2, 2, 2, 2, 1]],k = 5) == [[1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 2, 2, 3, 2, 2, 1], [1, 2, 4, 3, 4, 4, 3, 1], [1, 2, 3, 4, 5, 3, 3, 2], [1, 2, 3, 4, 4, 3, 3, 2], [1, 2, 3, 3, 3, 3, 3, 2], [1, 2, 2, 2, 2, 2, 2, 2], [1, 1, 1, 1, 1, 1, 2, 2]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 10) == [[32, 40, 48, 56, 64, 63, 62, 61], [24, 55, 54, 53, 52, 51, 50, 60], [16, 47, 35, 27, 19, 20, 42, 59], [8, 39, 43, 37, 36, 21, 34, 58], [7, 31, 44, 29, 28, 22, 26, 57], [6, 23, 45, 46, 38, 30, 18, 49], [5, 15, 14, 13, 12, 11, 10, 41], [4, 3, 2, 1, 9, 17, 25, 33]]\n assert candidate(grid = [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]],k = 100) == [[2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 1, 1, 1, 1, 1, 1, 1, 1, 2], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]\n assert candidate(grid = [[2, 3, 4, 5, 6, 7, 8], [1, 14, 13, 12, 11, 10, 9], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48, 49]],k = 25) == [[3, 4, 5, 6, 7, 8, 9], [2, 40, 39, 38, 37, 30, 21], [1, 41, 18, 19, 26, 23, 28], [15, 34, 17, 25, 33, 16, 35], [22, 27, 24, 31, 32, 14, 42], [29, 20, 10, 11, 12, 13, 49], [36, 43, 44, 45, 46, 47, 48]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36], [37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48]],k = 100) == [[5, 6, 12, 18, 24, 30], [4, 17, 23, 29, 35, 36], [3, 11, 34, 33, 41, 42], [2, 10, 28, 27, 40, 48], [1, 9, 22, 21, 39, 47], [7, 8, 16, 15, 38, 46], [13, 14, 20, 26, 32, 45], [19, 25, 31, 37, 43, 44]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [21, 22, 23, 24, 25, 7], [20, 35, 36, 37, 26, 8], [19, 34, 39, 38, 27, 9], [18, 33, 32, 31, 28, 10], [17, 16, 15, 14, 13, 11]],k = 2000000000) == [[1, 2, 3, 4, 5, 6], [21, 32, 33, 34, 35, 7], [20, 31, 36, 37, 22, 8], [19, 28, 39, 38, 23, 9], [18, 27, 26, 25, 24, 10], [17, 16, 15, 14, 13, 11]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]],k = 5) == [[6, 12, 18, 24, 30, 36], [5, 23, 29, 28, 27, 35], [4, 17, 16, 22, 26, 34], [3, 11, 15, 21, 20, 33], [2, 10, 9, 8, 14, 32], [1, 7, 13, 19, 25, 31]]\n assert candidate(grid = [[9, 2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2], [1, 2, 3, 4, 5, 6, 7, 2]],k = 100) == [[6, 5, 4, 3, 2, 1, 1, 1], [7, 2, 3, 4, 5, 6, 7, 1], [2, 2, 6, 6, 6, 5, 7, 1], [2, 2, 6, 4, 5, 4, 7, 1], [2, 2, 5, 4, 5, 3, 7, 1], [2, 2, 4, 3, 3, 3, 7, 9], [2, 2, 3, 4, 5, 6, 7, 2], [2, 2, 8, 7, 6, 5, 4, 3]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80]],k = 1000000000) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 65, 64, 63, 62, 52, 42, 32, 22, 20], [21, 66, 23, 24, 25, 26, 27, 28, 12, 30], [31, 67, 33, 34, 35, 36, 37, 38, 13, 40], [41, 68, 43, 44, 45, 46, 47, 48, 14, 50], [51, 69, 53, 54, 55, 56, 57, 58, 15, 60], [61, 59, 49, 39, 29, 19, 18, 17, 16, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 20) == [[58, 57, 49, 41, 33, 25, 17, 9], [59, 10, 11, 12, 13, 14, 15, 1], [60, 18, 44, 43, 35, 27, 23, 2], [61, 26, 45, 28, 29, 19, 31, 3], [62, 34, 46, 36, 37, 20, 39, 4], [63, 42, 38, 30, 22, 21, 47, 5], [64, 50, 51, 52, 53, 54, 55, 6], [56, 48, 40, 32, 24, 16, 8, 7]]\n assert candidate(grid = [[9, 10, 11, 12, 13, 14], [8, 17, 18, 19, 20, 15], [7, 16, 25, 26, 21, 16], [6, 15, 24, 23, 22, 17], [5, 14, 13, 12, 11, 18], [4, 3, 2, 1, 0, 19]],k = 23) == [[12, 13, 14, 15, 16, 17], [11, 16, 17, 18, 19, 18], [10, 15, 24, 25, 20, 19], [9, 14, 23, 26, 21, 0], [8, 13, 12, 11, 22, 1], [7, 6, 5, 4, 3, 2]]\n assert candidate(grid = [[5000, 1, 2, 3, 4, 5, 6, 5000], [5000, 5000, 1, 2, 3, 4, 5000, 5000], [5000, 5000, 5000, 1, 2, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 1, 2, 5000, 5000, 5000], [5000, 5000, 1, 2, 3, 4, 5000, 5000], [5000, 1, 2, 3, 4, 5, 6, 5000], [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000]],k = 1000000000) == [[5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 1, 2, 3, 4, 5000, 5000], [5000, 5000, 5000, 5000, 4, 3, 5000, 1], [5000, 5000, 5000, 5000, 5000, 2, 5000, 2], [5000, 5000, 2, 1, 2, 1, 5000, 3], [5000, 5000, 1, 5000, 5000, 5000, 5000, 4], [5000, 1, 2, 3, 4, 5, 6, 5], [5000, 5000, 5000, 5000, 5000, 5000, 5000, 6]]\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6]],k = 4) == [[1, 1, 2, 3, 4, 5], [1, 3, 4, 5, 5, 6], [1, 2, 3, 3, 5, 6], [1, 2, 4, 4, 5, 6], [1, 2, 2, 3, 4, 6], [2, 3, 4, 5, 6, 6]]\n assert candidate(grid = [[5, 5, 5, 5, 5, 5], [5, 1, 2, 3, 4, 5], [5, 6, 7, 8, 9, 5], [5, 10, 11, 12, 13, 5], [5, 14, 15, 16, 17, 5], [5, 5, 5, 5, 5, 5]],k = 15) == [[5, 5, 5, 5, 5, 5], [5, 4, 9, 13, 17, 5], [5, 3, 11, 7, 16, 5], [5, 2, 12, 8, 15, 5], [5, 1, 6, 10, 14, 5], [5, 5, 5, 5, 5, 5]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 50) == [[49, 41, 33, 25, 17, 9, 1, 2], [57, 55, 54, 53, 52, 51, 50, 3], [58, 47, 21, 22, 30, 38, 42, 4], [59, 39, 20, 37, 36, 46, 34, 5], [60, 31, 19, 29, 28, 45, 26, 6], [61, 23, 27, 35, 43, 44, 18, 7], [62, 15, 14, 13, 12, 11, 10, 8], [63, 64, 56, 48, 40, 32, 24, 16]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 15) == [[63, 62, 61, 60, 59, 58, 57, 49], [64, 50, 42, 34, 26, 18, 10, 41], [56, 51, 22, 30, 38, 46, 11, 33], [48, 52, 21, 36, 28, 45, 12, 25], [40, 53, 20, 37, 29, 44, 13, 17], [32, 54, 19, 27, 35, 43, 14, 9], [24, 55, 47, 39, 31, 23, 15, 1], [16, 8, 7, 6, 5, 4, 3, 2]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 5) == [[6, 7, 8, 16, 24, 32, 40, 48], [5, 15, 23, 31, 39, 47, 55, 56], [4, 14, 38, 46, 45, 44, 54, 64], [3, 13, 30, 29, 37, 43, 53, 63], [2, 12, 22, 28, 36, 35, 52, 62], [1, 11, 21, 20, 19, 27, 51, 61], [9, 10, 18, 26, 34, 42, 50, 60], [17, 25, 33, 41, 49, 57, 58, 59]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]],k = 15) == [[31, 25, 19, 13, 7, 1], [32, 11, 17, 23, 29, 2], [33, 10, 21, 15, 28, 3], [34, 9, 22, 16, 27, 4], [35, 8, 14, 20, 26, 5], [36, 30, 24, 18, 12, 6]]\n assert candidate(grid = [[1, 2, 3, 4], [12, 13, 14, 5], [11, 16, 15, 6], [10, 9, 8, 7]],k = 3) == [[4, 5, 6, 7], [3, 16, 13, 8], [2, 15, 14, 9], [1, 12, 11, 10]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36], [37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48]],k = 1000000000) == [[44, 43, 37, 31, 25, 19], [45, 8, 9, 10, 11, 13], [46, 14, 15, 16, 17, 7], [47, 20, 21, 22, 23, 1], [48, 26, 27, 28, 29, 2], [42, 32, 33, 34, 35, 3], [36, 38, 39, 40, 41, 4], [30, 24, 18, 12, 6, 5]]\n assert candidate(grid = [[6, 7, 8, 9, 10], [5, 4, 3, 2, 11], [14, 13, 12, 1, 15], [19, 18, 17, 16, 20], [24, 23, 22, 21, 25]],k = 3) == [[9, 10, 11, 15, 20], [8, 1, 16, 17, 25], [7, 2, 12, 18, 21], [6, 3, 4, 13, 22], [5, 14, 19, 24, 23]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42], [43, 44, 45, 46, 47, 48, 49]],k = 15) == [[46, 45, 44, 43, 36, 29, 22], [47, 16, 9, 10, 11, 12, 15], [48, 23, 24, 17, 18, 13, 8], [49, 30, 31, 25, 19, 20, 1], [42, 37, 32, 33, 26, 27, 2], [35, 38, 39, 40, 41, 34, 3], [28, 21, 14, 7, 6, 5, 4]]\n assert candidate(grid = [[4, 3, 2, 1, 0], [9, 8, 7, 6, 5], [14, 13, 12, 11, 10], [19, 18, 17, 16, 15], [24, 23, 22, 21, 20]],k = 3) == [[1, 0, 5, 10, 15], [2, 11, 16, 17, 20], [3, 6, 12, 18, 21], [4, 7, 8, 13, 22], [9, 14, 19, 24, 23]]\n assert candidate(grid = [[10, 20, 30, 40, 50, 60], [70, 80, 90, 100, 110, 120], [130, 140, 150, 160, 170, 180], [190, 200, 210, 220, 230, 240], [250, 260, 270, 280, 290, 300], [310, 320, 330, 340, 350, 360]],k = 7) == [[180, 240, 300, 360, 350, 340], [120, 280, 270, 260, 200, 330], [60, 290, 210, 150, 140, 320], [50, 230, 220, 160, 80, 310], [40, 170, 110, 100, 90, 250], [30, 20, 10, 70, 130, 190]]\n assert candidate(grid = [[100, 101, 102, 103, 104, 105, 106, 107, 108, 109], [110, 1, 2, 3, 4, 5, 6, 7, 8, 111], [112, 9, 12, 13, 14, 15, 16, 17, 9, 113], [114, 8, 11, 18, 19, 20, 21, 10, 12, 115], [116, 7, 10, 19, 22, 23, 18, 11, 13, 117], [118, 6, 9, 20, 25, 24, 17, 12, 14, 119], [120, 5, 8, 21, 26, 27, 22, 13, 15, 121], [122, 4, 7, 28, 29, 30, 25, 14, 16, 123], [124, 3, 6, 31, 32, 33, 34, 26, 17, 125], [126, 2, 5, 35, 36, 37, 38, 39, 40, 127]],k = 15) == [[121, 123, 125, 127, 40, 39, 38, 37, 36, 35], [119, 26, 34, 33, 32, 31, 6, 3, 4, 5], [117, 17, 7, 8, 9, 10, 11, 12, 5, 2], [115, 16, 28, 21, 18, 17, 22, 13, 6, 126], [113, 15, 29, 20, 25, 22, 27, 14, 7, 124], [111, 14, 30, 19, 24, 23, 26, 15, 8, 122], [109, 13, 25, 18, 19, 20, 21, 16, 9, 120], [108, 12, 14, 13, 12, 11, 10, 17, 1, 118], [107, 9, 8, 7, 6, 5, 4, 3, 2, 116], [106, 105, 104, 103, 102, 101, 100, 110, 112, 114]]\n assert candidate(grid = [[100, 200, 300, 400], [201, 5, 6, 501], [202, 7, 8, 502], [303, 403, 503, 600]],k = 3) == [[400, 501, 502, 600], [300, 7, 5, 503], [200, 8, 6, 403], [100, 201, 202, 303]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36]],k = 15) == [[31, 25, 19, 13, 7, 1], [32, 11, 17, 23, 29, 2], [33, 10, 21, 15, 28, 3], [34, 9, 22, 16, 27, 4], [35, 8, 14, 20, 26, 5], [36, 30, 24, 18, 12, 6]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [21, 22, 23, 24, 25, 7], [20, 35, 36, 37, 26, 8], [19, 34, 39, 38, 27, 9], [18, 33, 32, 31, 28, 10], [17, 16, 15, 14, 13, 11]],k = 3) == [[4, 5, 6, 7, 8, 9], [3, 25, 26, 27, 28, 10], [2, 24, 39, 36, 31, 11], [1, 23, 38, 37, 32, 13], [21, 22, 35, 34, 33, 14], [20, 19, 18, 17, 16, 15]]\n assert candidate(grid = [[5000, 1, 2, 5000, 3, 5000], [5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000]],k = 1000000000) == [[5000, 1, 2, 5000, 3, 5000], [5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000], [5000, 5000, 5000, 5000, 5000, 5000]]\n assert candidate(grid = [[100, 101, 102, 103], [104, 105, 106, 107], [108, 109, 110, 111], [112, 113, 114, 115]],k = 7) == [[114, 113, 112, 108], [115, 109, 105, 104], [111, 110, 106, 100], [107, 103, 102, 101]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 20) == [[58, 57, 49, 41, 33, 25, 17, 9], [59, 10, 11, 12, 13, 14, 15, 1], [60, 18, 44, 43, 35, 27, 23, 2], [61, 26, 45, 28, 29, 19, 31, 3], [62, 34, 46, 36, 37, 20, 39, 4], [63, 42, 38, 30, 22, 21, 47, 5], [64, 50, 51, 52, 53, 54, 55, 6], [56, 48, 40, 32, 24, 16, 8, 7]]\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5], [5, 1, 2, 3, 4, 5, 6, 5], [5, 8, 9, 10, 11, 12, 7, 5], [5, 15, 14, 13, 16, 17, 8, 5], [5, 22, 21, 20, 19, 18, 9, 5], [5, 29, 28, 27, 26, 25, 10, 5], [5, 36, 35, 34, 33, 32, 31, 5], [5, 5, 5, 5, 5, 5, 5, 5]],k = 2000000000) == [[5, 5, 5, 5, 5, 5, 5, 5], [5, 1, 2, 3, 4, 5, 6, 5], [5, 8, 27, 28, 21, 14, 7, 5], [5, 15, 26, 13, 16, 9, 8, 5], [5, 22, 25, 20, 19, 10, 9, 5], [5, 29, 18, 17, 12, 11, 10, 5], [5, 36, 35, 34, 33, 32, 31, 5], [5, 5, 5, 5, 5, 5, 5, 5]]\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]],k = 50) == [[3, 4, 5, 10, 15], [2, 9, 14, 19, 20], [1, 8, 13, 18, 25], [6, 7, 12, 17, 24], [11, 16, 21, 22, 23]]\n assert candidate(grid = [[500, 501, 502, 503, 504], [505, 1, 2, 3, 506], [507, 4, 508, 509, 510], [511, 512, 513, 6, 514], [515, 516, 517, 518, 519]],k = 2000000000) == [[500, 501, 502, 503, 504], [505, 1, 2, 3, 506], [507, 4, 508, 509, 510], [511, 512, 513, 6, 514], [515, 516, 517, 518, 519]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48], [49, 50, 51, 52, 53, 54, 55, 56], [57, 58, 59, 60, 61, 62, 63, 64]],k = 7) == [[8, 16, 24, 32, 40, 48, 56, 64], [7, 31, 39, 47, 55, 54, 53, 63], [6, 23, 45, 44, 43, 35, 52, 62], [5, 15, 46, 36, 28, 27, 51, 61], [4, 14, 38, 37, 29, 19, 50, 60], [3, 13, 30, 22, 21, 20, 42, 59], [2, 12, 11, 10, 18, 26, 34, 58], [1, 9, 17, 25, 33, 41, 49, 57]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90], [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]],k = 1000000000) == [[81, 71, 61, 51, 41, 31, 21, 11, 1, 2], [91, 83, 82, 72, 62, 52, 42, 32, 22, 3], [92, 84, 23, 24, 25, 26, 27, 28, 12, 4], [93, 85, 33, 47, 57, 67, 66, 38, 13, 5], [94, 86, 43, 37, 45, 46, 65, 48, 14, 6], [95, 87, 53, 36, 55, 56, 64, 58, 15, 7], [96, 88, 63, 35, 34, 44, 54, 68, 16, 8], [97, 89, 73, 74, 75, 76, 77, 78, 17, 9], [98, 79, 69, 59, 49, 39, 29, 19, 18, 10], [99, 100, 90, 80, 70, 60, 50, 40, 30, 20]]\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90], [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]],k = 50) == [[60, 70, 80, 90, 100, 99, 98, 97, 96, 95], [50, 72, 62, 52, 42, 32, 22, 12, 13, 94], [40, 82, 78, 77, 76, 75, 74, 73, 14, 93], [30, 83, 68, 36, 37, 47, 57, 63, 15, 92], [20, 84, 58, 35, 56, 55, 67, 53, 16, 91], [10, 85, 48, 34, 46, 45, 66, 43, 17, 81], [9, 86, 38, 44, 54, 64, 65, 33, 18, 71], [8, 87, 28, 27, 26, 25, 24, 23, 19, 61], [7, 88, 89, 79, 69, 59, 49, 39, 29, 51], [6, 5, 4, 3, 2, 1, 11, 21, 31, 41]]\n"}, "metadata": {"canonical_parameter_names": ["grid", "k"], "leetcode_dataset_entry_point": "Solution().rotateGrid", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector> rotateGrid(vector>& grid, int k) {", "container": "Solution", "callable": "rotateGrid", "parameters": [{"name": "grid", "type": "vector>&"}, {"name": "k", "type": "int"}], "return_type": "vector>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1915, "task_id": "number-of-wonderful-substrings", "difficulty": "Medium", "problem_description": "A wonderful string is a string where at most one letter appears an odd number of times.\\r\n\\r\n\\r\n\tFor example, \"ccjjc\" and \"abab\" are wonderful, but \"ab\" is not.\\r\n\\r\n\\r\nGiven a string word that consists of the first ten lowercase English letters ('a' through 'j'), return the number of wonderful non-empty substrings in word. If the same substring appears multiple times in word, then count each occurrence separately.\\r\n\\r\nA substring is a contiguous sequence of characters in a string.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: word = \"aba\"\\r\nOutput: 4\\r\nExplanation: The four wonderful substrings are underlined below:\\r\n- \"aba\" -> \"a\"\\r\n- \"aba\" -> \"b\"\\r\n- \"aba\" -> \"a\"\\r\n- \"aba\" -> \"aba\"\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\nInput: word = \"aabb\"\\r\nOutput: 9\\r\nExplanation: The nine wonderful substrings are underlined below:\\r\n- \"aabb\" -> \"a\"\\r\n- \"aabb\" -> \"aa\"\\r\n- \"aabb\" -> \"aab\"\\r\n- \"aabb\" -> \"aabb\"\\r\n- \"aabb\" -> \"a\"\\r\n- \"aabb\" -> \"abb\"\\r\n- \"aabb\" -> \"b\"\\r\n- \"aabb\" -> \"bb\"\\r\n- \"aabb\" -> \"b\"\\r\n\\r\n\\r\nExample 3:\\r\n\\r\n\\r\nInput: word = \"he\"\\r\nOutput: 2\\r\nExplanation: The two wonderful substrings are underlined below:\\r\n- \"he\" -> \"h\"\\r\n- \"he\" -> \"e\"\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\t1 <= word.length <= 105\\r\n\tword consists of lowercase English letters from 'a' to 'j'.\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"aaaaaaaaaa\") == 55\n assert candidate(word = \"aabbccddeeffgghhiijj\") == 165\n assert candidate(word = \"aba\") == 4\n assert candidate(word = \"aaaabbbbcccc\") == 66\n assert candidate(word = \"babcbabcbab\") == 32\n assert candidate(word = \"abcdefghija\") == 11\n assert candidate(word = \"abcdcba\") == 10\n assert candidate(word = \"aaa\") == 6\n assert candidate(word = \"aabb\") == 9\n assert candidate(word = \"aabbccddeeffgg\") == 84\n assert candidate(word = \"abcdefghij\") == 10\n assert candidate(word = \"jihgfedcba\") == 10\n assert candidate(word = \"aabbccddeeff\") == 63\n assert candidate(word = \"abcabc\") == 9\n assert candidate(word = \"abacaba\") == 12\n assert candidate(word = \"jij\") == 4\n assert candidate(word = \"xyz\") == 0\n assert candidate(word = \"abcdefghijabcdefghij\") == 23\n assert candidate(word = \"abcde\") == 5\n assert candidate(word = \"ijji\") == 8\n assert candidate(word = \"jjjjj\") == 15\n assert candidate(word = \"jijijijiji\") == 40\n assert candidate(word = \"aabbaa\") == 19\n assert candidate(word = \"abcabcabc\") == 21\n assert candidate(word = \"he\") == 2\n assert candidate(word = \"a\") == 1\n assert candidate(word = \"abcdefghijabcdefghijabcdefghij\") == 63\n assert candidate(word = \"jijjjijijj\") == 41\n assert candidate(word = \"aaaaaaa\") == 28\n assert candidate(word = \"aaaaa\") == 15\n assert candidate(word = \"abacabadabacaba\") == 32\n assert candidate(word = \"aaaaaaaabbbbbbbbaaaaaaaabbbbbbbb\") == 464\n assert candidate(word = \"jihgfedcbajihgfedcbajihgfedcbajihgfedcbajihgfedcba\") == 176\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 1038\n assert candidate(word = \"jijijiijijijiijijijiijijijiijijijiijijijiijijiij\") == 879\n assert candidate(word = \"abcdefghijabcde\") == 15\n assert candidate(word = \"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj\") == 903\n assert candidate(word = \"acacacacacacacacacac\") == 155\n assert candidate(word = \"jijijiijjjjijiijijijiijjjjijiijijijiijjjjijiijijijiijjjjijiijijijiijjjjijiijijijiijjjjijiijijijiijjjjijiijijijiijjjjj\") == 5171\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghij\") == 106\n assert candidate(word = \"aabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccddeeaabbccdd\") == 4720\n assert candidate(word = \"aabbaaabbbaaabbaaa\") == 126\n assert candidate(word = \"jjiijjiijjjiiijjiiijjjijjjiiijjiiijjjijjjjj\") == 721\n assert candidate(word = \"aabbaabbaabbaabb\") == 120\n assert candidate(word = \"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj\") == 990\n assert candidate(word = \"aabbaabbaabbaabbccddeeffgghhiijj\") == 420\n assert candidate(word = \"abcabcabcabcabcabcabcabcabcabc\") == 225\n assert candidate(word = \"abcdeedcba\") == 23\n assert candidate(word = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjj\") == 640\n assert candidate(word = \"abcdabcdaabbccddeeffgghhiijj\") == 222\n assert candidate(word = \"ababababababababababababababababababababab\") == 672\n assert candidate(word = \"jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj\") == 2485\n assert candidate(word = \"jijijiijjjijiiiiij\") == 132\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 176\n assert candidate(word = \"ababababababababababababab\") == 260\n assert candidate(word = \"aabbaaabbbaaabbaaabbba\") == 187\n assert candidate(word = \"acccabbbdcbaaaccbbaaccbbcdac\") == 161\n assert candidate(word = \"aabbaaabbbaaaabbbaaa\") == 159\n assert candidate(word = \"abcabcabcabcabc\") == 57\n assert candidate(word = \"jjjjjjjjjj\") == 55\n assert candidate(word = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == 670\n assert candidate(word = \"abcdefghijkabcdefghijkabcdefghijk\") == 63\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 452\n assert candidate(word = \"aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeee\") == 1025\n assert candidate(word = \"abcdefghijabcdeijfgh\") == 23\n assert candidate(word = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 820\n assert candidate(word = \"aaaaaaaaaabbbbbbbbbbbbccccccccccdddddddddd\") == 738\n assert candidate(word = \"aabbccddeeaabbccddeeaabbccddeedcba\") == 403\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == 715\n assert candidate(word = \"babababababababababa\") == 155\n assert candidate(word = \"aabbccddeeffgghhiijjijjiihhggeeffddccbbaa\") == 501\n assert candidate(word = \"aabbccddeeffgghhiijjabcdefghijabcdefghijabcdefghijabcdefghij\") == 363\n assert candidate(word = \"abcabccbaabccbaabcabccbaabccba\") == 225\n assert candidate(word = \"abcdefghijjihgfedcba\") == 48\n assert candidate(word = \"abacabadabacabadabacabad\") == 90\n assert candidate(word = \"abababababababababababababababab\") == 392\n assert candidate(word = \"abacabadabacabadabacabadabacabad\") == 154\n"}, "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().wonderfulSubstrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long wonderfulSubstrings(string word) {", "container": "Solution", "callable": "wonderfulSubstrings", "parameters": [{"name": "word", "type": "string"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1916, "task_id": "count-ways-to-build-rooms-in-an-ant-colony", "difficulty": "Hard", "problem_description": "You are an ant tasked with adding n new rooms numbered 0 to n-1 to your colony. You are given the expansion plan as a 0-indexed integer array of length n, prevRoom, where prevRoom[i] indicates that you must build room prevRoom[i] before building room i, and these two rooms must be connected directly. Room 0 is already built, so prevRoom[0] = -1. The expansion plan is given such that once all the rooms are built, every room will be reachable from room 0.\\r\n\\r\nYou can only build one room at a time, and you can travel freely between rooms you have already built only if they are connected. You can choose to build any room as long as its previous room is already built.\\r\n\\r\nReturn the number of different orders you can build all the rooms in. Since the answer may be large, return it modulo 109 + 7.\\r\n\\r\n \\r\nExample 1:\\r\n\\r\n\\r\nInput: prevRoom = [-1,0,1]\\r\nOutput: 1\\r\nExplanation: There is only one way to build the additional rooms: 0 → 1 → 2\\r\n\\r\n\\r\nExample 2:\\r\n\\r\n\\r\n\\r\nInput: prevRoom = [-1,0,0,1,2]\\r\nOutput: 6\\r\nExplanation:\\r\nThe 6 ways are:\\r\n0 → 1 → 3 → 2 → 4\\r\n0 → 2 → 4 → 1 → 3\\r\n0 → 1 → 2 → 3 → 4\\r\n0 → 1 → 2 → 4 → 3\\r\n0 → 2 → 1 → 3 → 4\\r\n0 → 2 → 1 → 4 → 3\\r\n\\r\n\\r\n \\r\nConstraints:\\r\n\\r\n\\r\n\tn == prevRoom.length\\r\n\t2 <= n <= 105\\r\n\tprevRoom[0] == -1\\r\n\t0 <= prevRoom[i] < n for all 1 <= i < n\\r\n\tEvery room is reachable from room 0 once all the rooms are built.\\r\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9]) == 258365767\n assert candidate(prevRoom = [-1, 0, 1, 1, 2, 2]) == 8\n assert candidate(prevRoom = [-1, 0, 0, 1, 2]) == 6\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2]) == 80\n assert candidate(prevRoom = [-1, 0, 1]) == 1\n assert candidate(prevRoom = [-1, 0, 0, 0]) == 6\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 2, 2]) == 120\n assert candidate(prevRoom = [-1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 896\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 4]) == 1\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4]) == 3360\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8]) == 1\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 2, 2]) == 560\n assert candidate(prevRoom = [-1, 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12]) == 645120\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 203434154\n assert candidate(prevRoom = [-1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]) == 37717233\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8]) == 118354482\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 14]) == 2\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4]) == 977384288\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 1\n assert candidate(prevRoom = [-1, 0, 1, 2, 1, 4, 2, 6, 5, 7, 5, 9, 8, 10, 9, 11, 12, 13, 14, 10]) == 245044800\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14]) == 645247453\n assert candidate(prevRoom = [-1, 0, 0, 2, 2, 1, 1, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 466985999\n assert candidate(prevRoom = [-1, 0, 1, 2, 0, 2, 3, 4, 3, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 11, 12]) == 777509735\n assert candidate(prevRoom = [-1, 0, 0, 1, 2, 3, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 960269310\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 10, 11, 11, 12, 12]) == 270200339\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3]) == 815328371\n assert candidate(prevRoom = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39]) == 558903913\n assert candidate(prevRoom = [-1, 0, 0, 1, 2, 1, 3, 4, 3, 5, 6, 7, 5, 8, 9, 10, 11, 12, 11, 13, 14, 15, 16, 17, 18]) == 574577861\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]) == 1\n assert candidate(prevRoom = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12]) == 594293086\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 65279563\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 258365767\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6]) == 916824814\n assert candidate(prevRoom = [-1, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5]) == 499858301\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == 144195955\n assert candidate(prevRoom = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17]) == 977718734\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 927211300\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == 214454105\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 881663664\n assert candidate(prevRoom = [-1, 0, 0, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7]) == 182996126\n assert candidate(prevRoom = [-1, 0, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6]) == 904828424\n assert candidate(prevRoom = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 19170323\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 232266423\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10]) == 281601700\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == 134837072\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35]) == 151296514\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19]) == 580542770\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]) == 374254273\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 506880\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7]) == 4036032\n assert candidate(prevRoom = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24]) == 457389881\n assert candidate(prevRoom = [-1, 0, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == 862785756\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20]) == 259495482\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39]) == 104533170\n assert candidate(prevRoom = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29]) == 944857254\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4]) == 185834123\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 0, 5, 6, 7, 8, 4, 11, 12, 13, 14, 10, 16, 17, 18, 19]) == 462\n assert candidate(prevRoom = [-1, 0, 0, 1, 2, 3, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 686400\n assert candidate(prevRoom = [-1, 0, 1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12]) == 846964197\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12]) == 839553459\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9]) == 864359005\n assert candidate(prevRoom = [-1, 0, 1, 0, 2, 3, 2, 4, 5, 6, 5, 7, 8, 9, 10, 11, 10, 11, 12, 13, 14, 15, 14, 15, 16, 17, 18, 19, 20]) == 696057029\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5]) == 495153778\n assert candidate(prevRoom = [-1, 0, 1, 2, 1, 4, 5, 6, 4, 8, 9, 5, 10, 11, 6, 12, 13, 7, 14, 15, 8, 16, 17, 9, 18, 19]) == 298444100\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == 980653881\n assert candidate(prevRoom = [-1, 0, 1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 185998261\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7]) == 820019200\n assert candidate(prevRoom = [-1, 0, 0, 1, 2, 2, 3, 4, 4, 5, 6, 7, 7, 8, 8, 9, 9, 10, 11, 11, 12, 12, 13, 14, 15, 15, 16, 17, 18, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24]) == 316920121\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5]) == 645414306\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8]) == 989258543\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 414301485\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7]) == 452706138\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == 37717233\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 185998261\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34]) == 764478009\n assert candidate(prevRoom = [-1, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9]) == 874133999\n assert candidate(prevRoom = [-1, 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 838387635\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 544962428\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 268444119\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]) == 1\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24]) == 435629637\n assert candidate(prevRoom = [-1, 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11]) == 59583424\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29]) == 468972288\n assert candidate(prevRoom = [-1, 0, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]) == 930392109\n assert candidate(prevRoom = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 466985999\n assert candidate(prevRoom = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17]) == 715654985\n assert candidate(prevRoom = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4]) == 199114634\n assert candidate(prevRoom = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == 1\n"}, "metadata": {"canonical_parameter_names": ["prevRoom"], "leetcode_dataset_entry_point": "Solution().waysToBuildRooms", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int waysToBuildRooms(vector& prevRoom) {", "container": "Solution", "callable": "waysToBuildRooms", "parameters": [{"name": "prevRoom", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1920, "task_id": "build-array-from-permutation", "difficulty": "Easy", "problem_description": "Given a zero-based permutation nums (0-indexed), build an array ans of the same length where ans[i] = nums[nums[i]] for each 0 <= i < nums.length and return it.\nA zero-based permutation nums is an array of distinct integers from 0 to nums.length - 1 (inclusive).\n \nExample 1:\n\nInput: nums = [0,2,1,5,3,4]\nOutput: [0,1,2,4,5,3]\nExplanation: The array ans is built as follows: \nans = [nums[nums[0]], nums[nums[1]], nums[nums[2]], nums[nums[3]], nums[nums[4]], nums[nums[5]]]\n = [nums[0], nums[2], nums[1], nums[5], nums[3], nums[4]]\n = [0,1,2,4,5,3]\nExample 2:\n\nInput: nums = [5,0,1,2,3,4]\nOutput: [4,5,0,1,2,3]\nExplanation: The array ans is built as follows:\nans = [nums[nums[0]], nums[nums[1]], nums[nums[2]], nums[nums[3]], nums[nums[4]], nums[nums[5]]]\n = [nums[5], nums[0], nums[1], nums[2], nums[3], nums[4]]\n = [4,5,0,1,2,3]\n \nConstraints:\n\n1 <= nums.length <= 1000\n0 <= nums[i] < nums.length\nThe elements in nums are distinct.\n\n \nFollow-up: Can you solve it without using an extra space (i.e., O(1) memory)?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [4, 0, 2, 1, 3]) == [3, 4, 2, 0, 1]\n assert candidate(nums = [3, 2, 1, 0]) == [0, 1, 2, 3]\n assert candidate(nums = [5, 0, 1, 2, 3, 4]) == [4, 5, 0, 1, 2, 3]\n assert candidate(nums = [1, 0, 3, 2]) == [0, 1, 2, 3]\n assert candidate(nums = [0, 1, 2, 3]) == [0, 1, 2, 3]\n assert candidate(nums = [0, 2, 1, 5, 3, 4]) == [0, 1, 2, 4, 5, 3]\n assert candidate(nums = [1, 0, 2, 3]) == [0, 1, 2, 3]\n assert candidate(nums = [4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4]\n assert candidate(nums = [1, 0]) == [0, 1]\n assert candidate(nums = [1, 5, 4, 3, 2, 0, 8, 7, 6, 9]) == [5, 0, 2, 3, 4, 1, 6, 7, 8, 9]\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [15, 2, 12, 11, 9, 4, 8, 13, 10, 7, 5, 6, 3, 14, 1, 0]) == [0, 12, 3, 6, 7, 9, 10, 14, 5, 13, 4, 8, 11, 1, 2, 15]\n assert candidate(nums = [15, 10, 5, 0, 14, 9, 4, 13, 8, 3, 12, 7, 2, 11, 6, 1]) == [1, 12, 9, 15, 6, 3, 14, 11, 8, 0, 2, 13, 5, 7, 4, 10]\n assert candidate(nums = [1, 3, 0, 2, 6, 5, 4, 7, 9, 8]) == [3, 2, 1, 0, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [8, 0, 4, 1, 3, 7, 6, 2, 5, 9]) == [5, 8, 3, 0, 1, 2, 6, 4, 7, 9]\n assert candidate(nums = [21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]\n assert candidate(nums = [1, 2, 3, 0, 4, 5, 6]) == [2, 3, 0, 1, 4, 5, 6]\n assert candidate(nums = [6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(nums = [6, 2, 0, 4, 5, 1, 3]) == [3, 0, 6, 5, 1, 2, 4]\n assert candidate(nums = [9, 3, 2, 8, 4, 5, 7, 0, 6, 1]) == [1, 8, 2, 6, 4, 5, 0, 9, 7, 3]\n assert candidate(nums = [7, 5, 9, 8, 6, 0, 1, 2, 4, 3]) == [2, 0, 3, 4, 1, 7, 5, 9, 6, 8]\n assert candidate(nums = [13, 9, 1, 15, 0, 14, 6, 10, 5, 2, 12, 4, 11, 7, 3, 8]) == [7, 2, 9, 8, 13, 3, 6, 12, 14, 1, 11, 0, 4, 10, 15, 5]\n assert candidate(nums = [7, 5, 2, 4, 6, 0, 3, 1]) == [1, 0, 2, 6, 3, 7, 4, 5]\n assert candidate(nums = [1, 3, 0, 2]) == [3, 2, 1, 0]\n assert candidate(nums = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(nums = [6, 2, 0, 5, 1, 4, 3]) == [3, 0, 6, 4, 2, 1, 5]\n assert candidate(nums = [2, 0, 1, 4, 3, 6, 5, 8, 7, 9, 10, 11]) == [1, 2, 0, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(nums = [24, 25, 28, 0, 7, 12, 17, 29, 15, 9, 23, 21, 20, 22, 5, 27, 10, 13, 16, 3, 18, 8, 19, 11, 1, 6, 26, 4, 14, 2]) == [1, 6, 14, 24, 29, 20, 13, 2, 27, 9, 11, 8, 18, 19, 12, 4, 23, 22, 10, 0, 16, 15, 3, 21, 25, 17, 26, 7, 5, 28]\n assert candidate(nums = [2, 1, 0, 4, 3, 5, 9, 8, 6, 7]) == [0, 1, 2, 3, 4, 5, 7, 6, 9, 8]\n assert candidate(nums = [4, 5, 6, 7, 0, 1, 2, 3, 8, 9]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 0, 3, 2, 5, 4]) == [0, 1, 2, 3, 4, 5]\n assert candidate(nums = [0, 3, 1, 4, 2, 5, 7, 6]) == [0, 4, 3, 2, 1, 5, 6, 7]\n assert candidate(nums = [10, 7, 8, 9, 1, 5, 6, 0, 3, 4, 2]) == [2, 0, 3, 4, 7, 5, 6, 10, 9, 1, 8]\n assert candidate(nums = [5, 8, 6, 3, 1, 0, 9, 2, 4, 7]) == [0, 4, 9, 3, 8, 5, 7, 6, 1, 2]\n assert candidate(nums = [33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]\n assert candidate(nums = [75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75]\n assert candidate(nums = [0, 5, 2, 1, 6, 4, 3]) == [0, 4, 2, 5, 3, 6, 1]\n assert candidate(nums = [3, 0, 1, 4, 2]) == [4, 3, 0, 2, 1]\n assert candidate(nums = [6, 1, 0, 2, 3, 5, 4]) == [4, 1, 6, 0, 2, 5, 3]\n assert candidate(nums = [6, 0, 3, 1, 8, 9, 7, 4, 2, 5]) == [7, 6, 1, 0, 2, 5, 4, 8, 3, 9]\n assert candidate(nums = [2, 0, 1]) == [1, 2, 0]\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(nums = [2, 4, 3, 0, 1, 5, 6, 7, 8, 9]) == [3, 1, 0, 2, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [8, 2, 3, 0, 4, 1, 7, 5, 9, 6]) == [9, 3, 0, 8, 4, 2, 5, 1, 6, 7]\n assert candidate(nums = [4, 8, 3, 1, 7, 10, 5, 6, 9, 0, 2, 11]) == [7, 9, 1, 8, 6, 2, 10, 5, 0, 4, 3, 11]\n assert candidate(nums = [9, 4, 3, 7, 8, 0, 2, 1, 5, 6]) == [6, 8, 7, 1, 5, 9, 3, 4, 0, 2]\n assert candidate(nums = [4, 3, 0, 1, 2]) == [2, 1, 4, 3, 0]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(nums = [0, 5, 1, 4, 6, 2, 3, 7, 8, 9]) == [0, 2, 5, 6, 3, 1, 4, 7, 8, 9]\n assert candidate(nums = [7, 5, 6, 3, 2, 1, 4, 0]) == [0, 1, 4, 3, 6, 5, 2, 7]\n assert candidate(nums = [1, 3, 0, 2, 7, 5, 8, 4, 9, 6]) == [3, 2, 1, 0, 4, 5, 9, 7, 6, 8]\n assert candidate(nums = [6, 1, 3, 5, 7, 0, 2, 4, 9, 8]) == [2, 1, 5, 0, 4, 6, 3, 7, 8, 9]\n assert candidate(nums = [34, 5, 11, 14, 2, 8, 1, 25, 16, 18, 20, 4, 0, 13, 31, 33, 10, 17, 3, 32, 23, 26, 15, 19, 6, 29, 7, 28, 24, 30, 9, 22, 12, 27, 5, 21]) == [5, 8, 4, 31, 11, 16, 5, 29, 10, 3, 23, 2, 34, 13, 22, 27, 20, 17, 14, 12, 19, 7, 33, 32, 1, 30, 25, 24, 6, 9, 18, 15, 0, 28, 8, 26]\n assert candidate(nums = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [6, 0, 1, 2, 3, 4, 5, 7, 8, 9]) == [5, 6, 0, 1, 2, 3, 4, 7, 8, 9]\n assert candidate(nums = [0, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(nums = [59, 48, 54, 28, 74, 33, 85, 64, 80, 68, 47, 22, 25, 63, 98, 70, 19, 34, 6, 5, 82, 44, 73, 14, 72, 31, 32, 86, 3, 18, 92, 56, 53, 50, 49, 97, 90, 9, 93, 69, 37, 10, 84, 95, 35, 38, 52, 11, 62, 16, 88, 60, 42, 51, 15, 41, 77, 45, 67, 78, 46, 13, 20, 65, 87, 21, 7, 58, 36, 83, 17, 23, 29, 39, 91, 75, 61, 12, 99, 27, 94, 26, 40, 55, 1, 89, 79, 24, 57, 8, 30, 0, 43, 81, 96, 71, 66, 4, 76, 2, 59]) == [78, 62, 15, 3, 91, 50, 89, 87, 94, 36, 11, 73, 31, 65, 76, 17, 5, 49, 85, 33, 40, 35, 39, 98, 29, 56, 53, 79, 28, 6, 43, 77, 51, 88, 16, 4, 30, 68, 81, 83, 9, 47, 1, 71, 97, 93, 42, 22, 20, 19, 57, 46, 84, 60, 70, 10, 12, 38, 58, 99, 52, 63, 82, 21, 24, 44, 64, 67, 90, 55, 34, 14, 18, 69, 0, 75, 13, 25, 2, 86, 96, 32, 37, 41, 48, 8, 27, 72, 45, 80, 92, 59, 95, 26, 66, 23, 7, 74, 61, 54, 78]\n assert candidate(nums = [4, 0, 3, 1, 2]) == [2, 4, 1, 0, 3]\n assert candidate(nums = [5, 8, 4, 2, 0, 6, 7, 9, 1, 3]) == [6, 1, 0, 4, 5, 7, 9, 3, 8, 2]\n assert candidate(nums = [9, 7, 2, 3, 8, 6, 5, 0, 1, 4]) == [4, 0, 2, 3, 1, 5, 6, 9, 7, 8]\n assert candidate(nums = [10, 0, 2, 4, 1, 5, 6, 8, 3, 9, 7]) == [7, 10, 2, 1, 0, 5, 6, 3, 4, 9, 8]\n assert candidate(nums = [5, 1, 4, 8, 2, 9, 6, 0, 3, 7]) == [9, 1, 2, 3, 4, 7, 6, 5, 8, 0]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5]) == [0, 5, 9, 4, 1, 6, 8, 3, 2, 7]\n assert candidate(nums = [8, 11, 1, 0, 14, 9, 4, 13, 8, 3, 12, 7, 6, 10, 2, 5]) == [8, 7, 11, 8, 2, 3, 14, 10, 8, 0, 6, 13, 4, 12, 1, 9]\n assert candidate(nums = [8, 5, 2, 1, 6, 9, 7, 3, 0, 4]) == [0, 9, 2, 5, 7, 4, 3, 1, 8, 6]\n assert candidate(nums = [64, 5, 37, 49, 46, 17, 27, 47, 53, 39, 19, 35, 50, 1, 28, 58, 44, 0, 13, 20, 4, 30, 59, 10, 56, 63, 3, 31, 18, 48, 36, 24, 55, 26, 57, 34, 14, 6, 2, 40, 33, 16, 60, 25, 54, 52, 21, 62, 43, 61, 29, 38, 45, 41, 32, 51, 23, 11, 12, 42, 8, 7, 22, 15, 9, 5, 65, 37, 49, 46, 17, 27, 47, 53, 39, 19, 35, 50, 1, 28, 58, 44, 0, 13, 20, 4, 30, 59, 10, 56, 63, 3, 31, 18, 48, 36, 24, 55, 26, 57, 34, 14, 6, 2, 40, 33, 16, 60, 25, 54, 52, 21, 62, 43, 61, 29, 38, 45, 41, 32, 51, 23, 11, 12, 42, 8, 7, 22, 15, 9, 5]) == [9, 17, 6, 61, 21, 0, 31, 62, 41, 40, 20, 34, 29, 5, 18, 12, 54, 64, 1, 4, 46, 36, 42, 19, 23, 15, 49, 24, 13, 43, 14, 56, 51, 3, 11, 57, 28, 27, 37, 33, 26, 44, 8, 63, 32, 45, 30, 22, 25, 7, 48, 2, 52, 16, 55, 38, 10, 35, 50, 60, 53, 47, 59, 58, 39, 17, 5, 6, 61, 21, 0, 31, 62, 41, 40, 20, 34, 29, 5, 18, 12, 54, 64, 1, 4, 46, 36, 42, 19, 23, 15, 49, 24, 13, 43, 14, 56, 51, 3, 11, 57, 28, 27, 37, 33, 26, 44, 8, 63, 32, 45, 30, 22, 25, 7, 48, 2, 52, 16, 55, 38, 10, 35, 50, 60, 53, 47, 59, 58, 39, 17]\n assert candidate(nums = [1, 3, 5, 7, 9, 0, 2, 4, 6, 8]) == [3, 7, 0, 4, 8, 1, 5, 9, 2, 6]\n assert candidate(nums = [0, 5, 9, 1, 7, 2, 8, 4, 6, 3]) == [0, 2, 3, 5, 4, 9, 6, 7, 8, 1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 10, 9, 8, 7, 6]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [29, 22, 15, 8, 1, 28, 21, 14, 7, 0, 27, 20, 13, 6, 2, 26, 19, 12, 5, 3, 25, 18, 11, 4, 24, 17, 10, 16, 9, 23]) == [23, 11, 26, 7, 22, 9, 18, 2, 14, 29, 16, 25, 6, 21, 15, 10, 3, 13, 28, 8, 17, 5, 20, 1, 24, 12, 27, 19, 0, 4]\n assert candidate(nums = [0, 1, 3, 2, 4, 5, 7, 6, 8, 9, 11, 10]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(nums = [7, 0, 5, 3, 6, 2, 4, 1]) == [1, 7, 2, 3, 4, 5, 6, 0]\n assert candidate(nums = [0, 10, 6, 7, 4, 3, 9, 1, 8, 2, 5]) == [0, 5, 9, 1, 4, 7, 2, 10, 8, 6, 3]\n assert candidate(nums = [4, 5, 0, 1, 2, 3]) == [2, 3, 4, 5, 0, 1]\n assert candidate(nums = [7, 9, 6, 3, 5, 8, 4, 0, 2, 1]) == [0, 1, 4, 3, 8, 2, 5, 7, 6, 9]\n assert candidate(nums = [7, 8, 9, 0, 3, 2, 5, 4, 6, 1]) == [4, 6, 1, 7, 0, 9, 2, 3, 5, 8]\n assert candidate(nums = [2, 7, 4, 5, 1, 9, 3, 6, 8, 0]) == [4, 6, 1, 9, 7, 0, 5, 3, 8, 2]\n assert candidate(nums = [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(nums = [2, 5, 8, 3, 9, 6, 1, 7, 4, 0]) == [8, 6, 4, 3, 0, 1, 5, 7, 9, 2]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().buildArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector buildArray(vector& nums) {", "container": "Solution", "callable": "buildArray", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1921, "task_id": "eliminate-maximum-number-of-monsters", "difficulty": "Medium", "problem_description": "You are playing a video game where you are defending your city from a group of n monsters. You are given a 0-indexed integer array dist of size n, where dist[i] is the initial distance in kilometers of the ith monster from the city.\nThe monsters walk toward the city at a constant speed. The speed of each monster is given to you in an integer array speed of size n, where speed[i] is the speed of the ith monster in kilometers per minute.\nYou have a weapon that, once fully charged, can eliminate a single monster. However, the weapon takes one minute to charge. The weapon is fully charged at the very start.\nYou lose when any monster reaches your city. If a monster reaches the city at the exact moment the weapon is fully charged, it counts as a loss, and the game ends before you can use your weapon.\nReturn the maximum number of monsters that you can eliminate before you lose, or n if you can eliminate all the monsters before they reach the city.\n \nExample 1:\n\nInput: dist = [1,3,4], speed = [1,1,1]\nOutput: 3\nExplanation:\nIn the beginning, the distances of the monsters are [1,3,4]. You eliminate the first monster.\nAfter a minute, the distances of the monsters are [X,2,3]. You eliminate the second monster.\nAfter a minute, the distances of the monsters are [X,X,2]. You eliminate the third monster.\nAll 3 monsters can be eliminated.\nExample 2:\n\nInput: dist = [1,1,2,3], speed = [1,1,1,1]\nOutput: 1\nExplanation:\nIn the beginning, the distances of the monsters are [1,1,2,3]. You eliminate the first monster.\nAfter a minute, the distances of the monsters are [X,0,1,2], so you lose.\nYou can only eliminate 1 monster.\n\nExample 3:\n\nInput: dist = [3,2,4], speed = [5,3,2]\nOutput: 1\nExplanation:\nIn the beginning, the distances of the monsters are [3,2,4]. You eliminate the first monster.\nAfter a minute, the distances of the monsters are [X,0,2], so you lose.\nYou can only eliminate 1 monster.\n\n \nConstraints:\n\nn == dist.length == speed.length\n1 <= n <= 105\n1 <= dist[i], speed[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(dist = [6, 7, 8],speed = [2, 2, 2]) == 3\n assert candidate(dist = [1, 2, 3],speed = [3, 2, 1]) == 1\n assert candidate(dist = [100, 200, 300],speed = [1, 1, 1]) == 3\n assert candidate(dist = [7, 14, 21],speed = [1, 2, 3]) == 3\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [3, 5, 7, 9],speed = [1, 2, 3, 4]) == 3\n assert candidate(dist = [1, 1, 2, 3],speed = [1, 1, 1, 1]) == 1\n assert candidate(dist = [100, 200, 300, 400, 500],speed = [50, 40, 30, 20, 10]) == 5\n assert candidate(dist = [6, 4, 5],speed = [1, 2, 1]) == 3\n assert candidate(dist = [1, 2, 3, 4, 5],speed = [1, 2, 3, 4, 5]) == 1\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(dist = [1, 3, 4],speed = [1, 1, 1]) == 3\n assert candidate(dist = [10, 20, 30],speed = [1, 2, 3]) == 3\n assert candidate(dist = [5, 10, 15, 20],speed = [5, 4, 3, 2]) == 4\n assert candidate(dist = [3, 2, 4],speed = [5, 3, 2]) == 1\n assert candidate(dist = [1, 2, 3, 4, 5],speed = [1, 1, 1, 1, 1]) == 5\n assert candidate(dist = [10, 5, 6, 12, 3],speed = [2, 1, 1, 1, 1]) == 5\n assert candidate(dist = [5, 5, 5],speed = [1, 1, 1]) == 3\n assert candidate(dist = [2, 4, 6],speed = [2, 2, 2]) == 3\n assert candidate(dist = [1],speed = [1]) == 1\n assert candidate(dist = [100, 200, 300, 400, 500],speed = [10, 20, 30, 40, 50]) == 5\n assert candidate(dist = [5, 5, 5, 5],speed = [1, 1, 1, 1]) == 4\n assert candidate(dist = [6, 7, 12, 13, 14],speed = [3, 3, 4, 4, 5]) == 3\n assert candidate(dist = [6, 3, 4, 1],speed = [2, 1, 2, 1]) == 3\n assert candidate(dist = [10, 20, 30],speed = [5, 10, 15]) == 2\n assert candidate(dist = [10, 15, 20],speed = [2, 3, 4]) == 3\n assert candidate(dist = [10, 20, 30],speed = [5, 5, 5]) == 3\n assert candidate(dist = [100, 200, 300],speed = [10, 20, 30]) == 3\n assert candidate(dist = [10, 20, 30, 40],speed = [10, 10, 10, 10]) == 4\n assert candidate(dist = [1, 2, 3, 4, 5],speed = [5, 4, 3, 2, 1]) == 1\n assert candidate(dist = [10, 10, 10, 10, 10],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(dist = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [500, 1000, 1500, 2000, 2500],speed = [50, 100, 150, 200, 250]) == 5\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],speed = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(dist = [100, 200, 300, 400, 500],speed = [1, 1, 1, 1, 1]) == 5\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(dist = [1000, 900, 800, 700, 600],speed = [100, 200, 300, 400, 500]) == 5\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(dist = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(dist = [9, 8, 7, 6, 5, 4, 3, 2, 1],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(dist = [2, 3, 4, 5, 6],speed = [2, 2, 2, 2, 2]) == 2\n assert candidate(dist = [10, 20, 30, 40, 50],speed = [2, 3, 4, 5, 6]) == 5\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(dist = [10, 25, 40, 55, 70, 85],speed = [5, 5, 5, 5, 5, 5]) == 6\n assert candidate(dist = [10, 15, 20, 25],speed = [5, 4, 3, 2]) == 4\n assert candidate(dist = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(dist = [99, 98, 97, 96, 95],speed = [1, 1, 1, 1, 1]) == 5\n assert candidate(dist = [1000, 1500, 2000, 2500, 3000],speed = [100, 200, 300, 400, 500]) == 5\n assert candidate(dist = [100, 200, 300, 400, 500],speed = [50, 40, 30, 20, 10]) == 5\n assert candidate(dist = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(dist = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [100, 200, 300, 400, 500],speed = [10, 20, 30, 40, 50]) == 5\n assert candidate(dist = [15, 15, 20, 25, 30],speed = [1, 2, 1, 2, 1]) == 5\n assert candidate(dist = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],speed = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],speed = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(dist = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(dist = [5, 15, 25, 35, 45],speed = [1, 1, 1, 1, 1]) == 5\n assert candidate(dist = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 15\n assert candidate(dist = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(dist = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(dist = [10, 20, 30, 40, 50],speed = [5, 5, 5, 5, 5]) == 5\n assert candidate(dist = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(dist = [2, 4, 6, 8, 10],speed = [1, 2, 3, 4, 5]) == 2\n assert candidate(dist = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],speed = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(dist = [5, 10, 15, 20, 25, 30],speed = [1, 1, 1, 1, 1, 1]) == 6\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1\n assert candidate(dist = [25, 25, 25, 25, 25],speed = [5, 5, 5, 5, 5]) == 5\n assert candidate(dist = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 5\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(dist = [2, 4, 6, 8, 10],speed = [1, 2, 3, 4, 5]) == 2\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10\n assert candidate(dist = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [5, 15, 25, 35, 45],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(dist = [5, 10, 15, 20, 25, 30],speed = [1, 2, 3, 4, 5, 6]) == 5\n assert candidate(dist = [99, 198, 297, 396, 495, 594, 693, 792, 891, 990],speed = [99, 99, 99, 99, 99, 99, 99, 99, 99, 99]) == 10\n assert candidate(dist = [3, 5, 7, 9, 11],speed = [1, 2, 3, 4, 5]) == 3\n assert candidate(dist = [10000, 20000, 30000, 40000, 50000],speed = [100, 200, 300, 400, 500]) == 5\n assert candidate(dist = [3, 6, 9, 12, 15],speed = [1, 1, 1, 1, 1]) == 5\n assert candidate(dist = [1, 2, 3, 4, 5],speed = [5, 4, 3, 2, 1]) == 1\n assert candidate(dist = [10, 20, 30, 40, 50],speed = [2, 4, 5, 6, 8]) == 5\n assert candidate(dist = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [1000, 2000, 3000],speed = [10, 20, 30]) == 3\n assert candidate(dist = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3\n assert candidate(dist = [10, 25, 30, 45, 50, 65, 70, 85, 90, 105],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [2, 3, 4, 5, 6],speed = [1, 1, 1, 1, 1]) == 5\n assert candidate(dist = [30, 60, 90, 120, 150, 180, 210, 240, 270, 300],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(dist = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 15\n assert candidate(dist = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],speed = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 10\n assert candidate(dist = [10, 20, 30, 40, 50],speed = [10, 20, 30, 40, 50]) == 1\n assert candidate(dist = [10, 20, 30, 40, 50],speed = [2, 2, 2, 2, 1]) == 5\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 1\n assert candidate(dist = [9, 9, 9, 9, 9],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(dist = [100, 150, 200, 250, 300],speed = [25, 50, 75, 100, 125]) == 3\n assert candidate(dist = [10, 20, 30, 40, 50],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(dist = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(dist = [10, 11, 12, 13, 14],speed = [1, 1, 1, 1, 1]) == 5\n assert candidate(dist = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 3\n assert candidate(dist = [15, 10, 20, 30, 40],speed = [2, 5, 3, 4, 1]) == 5\n assert candidate(dist = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(dist = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(dist = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 10\n assert candidate(dist = [100, 200, 300, 400, 500],speed = [50, 100, 150, 200, 250]) == 2\n assert candidate(dist = [3, 6, 9, 12, 15, 18],speed = [1, 2, 3, 4, 5, 6]) == 3\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(dist = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(dist = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],speed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(dist = [10, 20, 30, 40, 50],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(dist = [9, 18, 27, 36, 45],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(dist = [15, 25, 35, 45, 55],speed = [5, 5, 5, 5, 5]) == 5\n assert candidate(dist = [100, 200, 300, 400, 500],speed = [50, 50, 50, 50, 50]) == 5\n assert candidate(dist = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],speed = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(dist = [2, 4, 6, 8, 10],speed = [2, 2, 2, 2, 2]) == 5\n assert candidate(dist = [7, 14, 21, 28, 35],speed = [1, 2, 3, 4, 5]) == 5\n assert candidate(dist = [100, 150, 200, 250, 300],speed = [5, 10, 15, 20, 25]) == 5\n assert candidate(dist = [100, 150, 200, 250, 300, 350, 400, 450, 500],speed = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 9\n"}, "metadata": {"canonical_parameter_names": ["dist", "speed"], "leetcode_dataset_entry_point": "Solution().eliminateMaximum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int eliminateMaximum(vector& dist, vector& speed) {", "container": "Solution", "callable": "eliminateMaximum", "parameters": [{"name": "dist", "type": "vector&"}, {"name": "speed", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1922, "task_id": "count-good-numbers", "difficulty": "Medium", "problem_description": "A digit string is good if the digits (0-indexed) at even indices are even and the digits at odd indices are prime (2, 3, 5, or 7).\n\nFor example, \"2582\" is good because the digits (2 and 8) at even positions are even and the digits (5 and 2) at odd positions are prime. However, \"3245\" is not good because 3 is at an even index but is not even.\n\nGiven an integer n, return the total number of good digit strings of length n. Since the answer may be large, return it modulo 109 + 7.\nA digit string is a string consisting of digits 0 through 9 that may contain leading zeros.\n \nExample 1:\n\nInput: n = 1\nOutput: 5\nExplanation: The good numbers of length 1 are \"0\", \"2\", \"4\", \"6\", \"8\".\n\nExample 2:\n\nInput: n = 4\nOutput: 400\n\nExample 3:\n\nInput: n = 50\nOutput: 564908303\n\n \nConstraints:\n\n1 <= n <= 1015\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1) == 5\n assert candidate(n = 4) == 400\n assert candidate(n = 50) == 564908303\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().countGoodNumbers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countGoodNumbers(long long n) {", "container": "Solution", "callable": "countGoodNumbers", "parameters": [{"name": "n", "type": "long long"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1923, "task_id": "longest-common-subpath", "difficulty": "Hard", "problem_description": "There is a country of n cities numbered from 0 to n - 1. In this country, there is a road connecting every pair of cities.\nThere are m friends numbered from 0 to m - 1 who are traveling through the country. Each one of them will take a path consisting of some cities. Each path is represented by an integer array that contains the visited cities in order. The path may contain a city more than once, but the same city will not be listed consecutively.\nGiven an integer n and a 2D integer array paths where paths[i] is an integer array representing the path of the ith friend, return the length of the longest common subpath that is shared by every friend's path, or 0 if there is no common subpath at all.\nA subpath of a path is a contiguous sequence of cities within that path.\n \nExample 1:\n\nInput: n = 5, paths = [[0,1,2,3,4],\n [2,3,4],\n [4,0,1,2,3]]\nOutput: 2\nExplanation: The longest common subpath is [2,3].\n\nExample 2:\n\nInput: n = 3, paths = [[0],[1],[2]]\nOutput: 0\nExplanation: There is no common subpath shared by the three paths.\n\nExample 3:\n\nInput: n = 5, paths = [[0,1,2,3,4],\n [4,3,2,1,0]]\nOutput: 1\nExplanation: The possible longest common subpaths are [0], [1], [2], [3], and [4]. All have a length of 1.\n \nConstraints:\n\n1 <= n <= 105\nm == paths.length\n2 <= m <= 105\nsum(paths[i].length) <= 105\n0 <= paths[i][j] < n\nThe same city is not listed multiple times consecutively in paths[i].\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1,paths = [[0], [0], [0]]) == 1\n assert candidate(n = 5,paths = [[0, 1, 2, 3, 4], [4, 3, 2, 1, 0]]) == 1\n assert candidate(n = 3,paths = [[0], [1], [2]]) == 0\n assert candidate(n = 10,paths = [[0, 1, 2], [1, 2, 3], [2, 3, 4]]) == 1\n assert candidate(n = 10,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 0, 1, 2, 3, 4], [3, 4, 5, 6, 7, 8, 9, 0, 1, 2]]) == 5\n assert candidate(n = 7,paths = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]]) == 0\n assert candidate(n = 6,paths = [[0, 1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 0], [2, 3, 4, 5, 0, 1]]) == 4\n assert candidate(n = 10,paths = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5]]) == 0\n assert candidate(n = 5,paths = [[0, 1, 2, 3, 4], [2, 3, 4], [4, 0, 1, 2, 3]]) == 2\n assert candidate(n = 15,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3], [6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3, 4, 5]]) == 9\n assert candidate(n = 9,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7, 8, 0], [2, 3, 4, 5, 6, 7, 8, 0, 1], [3, 4, 5, 6, 7, 8, 0, 1, 2]]) == 6\n assert candidate(n = 100,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], [90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79], [45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44]]) == 45\n assert candidate(n = 20,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3]]) == 16\n assert candidate(n = 20,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 10\n assert candidate(n = 7,paths = [[0, 1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6, 0], [2, 3, 4, 5, 6, 0, 1], [3, 4, 5, 6, 0, 1, 2], [4, 5, 6, 0, 1, 2, 3], [5, 6, 0, 1, 2, 3, 4], [6, 0, 1, 2, 3, 4, 5], [0, 6, 5, 4, 3, 2, 1]]) == 1\n assert candidate(n = 8,paths = [[0, 1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1, 0], [2, 1, 0, 7, 6, 5, 4, 3], [3, 2, 1, 0, 7, 6, 5, 4]]) == 1\n assert candidate(n = 100,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39], [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]]) == 50\n assert candidate(n = 8,paths = [[0, 1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7, 0], [2, 3, 4, 5, 6, 7, 0, 1], [3, 4, 5, 6, 7, 0, 1, 2], [4, 5, 6, 7, 0, 1, 2, 3], [5, 6, 7, 0, 1, 2, 3, 4], [6, 7, 0, 1, 2, 3, 4, 5], [7, 0, 1, 2, 3, 4, 5, 6]]) == 1\n assert candidate(n = 25,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 10\n assert candidate(n = 100,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]]) == 70\n assert candidate(n = 7,paths = [[0, 1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6, 0], [2, 3, 4, 5, 6, 0, 1], [3, 4, 5, 6, 0, 1, 2], [4, 5, 6, 0, 1, 2, 3], [5, 6, 0, 1, 2, 3, 4], [6, 0, 1, 2, 3, 4, 5]]) == 1\n assert candidate(n = 15,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1]]) == 13\n assert candidate(n = 15,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3, 4], [10, 11, 12, 13, 14, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 5\n assert candidate(n = 10,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 10\n assert candidate(n = 50,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], [49, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48]]) == 25\n assert candidate(n = 25,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 15\n assert candidate(n = 20,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]) == 10\n assert candidate(n = 15,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [10, 11, 12, 13, 14, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3, 4]]) == 5\n assert candidate(n = 20,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4]]) == 10\n assert candidate(n = 10,paths = [[0, 1, 2, 3, 4], [1, 2, 3, 4, 0], [2, 3, 4, 0, 1], [3, 4, 0, 1, 2], [4, 0, 1, 2, 3], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 0, 1, 2, 3, 4], [6, 7, 8, 9, 0, 1, 2, 3, 4, 5], [7, 8, 9, 0, 1, 2, 3, 4, 5, 6], [8, 9, 0, 1, 2, 3, 4, 5, 6, 7], [9, 0, 1, 2, 3, 4, 5, 6, 7, 8]]) == 1\n assert candidate(n = 20,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1]]) == 18\n assert candidate(n = 25,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], [20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 10\n assert candidate(n = 10,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [2, 3, 4, 5, 6, 7, 8, 9, 0, 1], [3, 4, 5, 6, 7, 8, 9, 0, 1, 2], [4, 5, 6, 7, 8, 9, 0, 1, 2, 3], [5, 6, 7, 8, 9, 0, 1, 2, 3, 4], [6, 7, 8, 9, 0, 1, 2, 3, 4, 5], [7, 8, 9, 0, 1, 2, 3, 4, 5, 6], [8, 9, 0, 1, 2, 3, 4, 5, 6, 7], [9, 0, 1, 2, 3, 4, 5, 6, 7, 8]]) == 1\n assert candidate(n = 25,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [20, 21, 22, 23, 24, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]]) == 10\n assert candidate(n = 5,paths = [[0, 1, 2, 3, 4], [1, 2, 3, 0, 4], [2, 3, 0, 1, 4], [3, 0, 1, 2, 4], [0, 1, 2, 3, 4]]) == 1\n assert candidate(n = 50,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39]]) == 20\n assert candidate(n = 15,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3, 4]]) == 10\n assert candidate(n = 5,paths = [[0, 1, 2, 3, 4], [1, 2, 3, 4, 0], [2, 3, 4, 0, 1], [3, 4, 0, 1, 2], [4, 0, 1, 2, 3]]) == 1\n assert candidate(n = 10,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 2, 4, 6, 8, 0, 2, 4, 6, 8], [0, 3, 6, 9, 0, 3, 6, 9, 0, 3]]) == 1\n assert candidate(n = 10,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [2, 3, 4, 5, 6, 7, 8, 9, 0, 1], [8, 9, 0, 1, 2, 3, 4, 5, 6, 7]]) == 1\n assert candidate(n = 30,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]]) == 10\n assert candidate(n = 15,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3]]) == 11\n assert candidate(n = 15,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [10, 11, 12, 13, 14, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2, 3, 4], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 1, 2]]) == 5\n assert candidate(n = 50,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]]) == 30\n assert candidate(n = 20,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2]]) == 17\n assert candidate(n = 7,paths = [[0, 1, 2, 3, 4, 5, 6], [3, 4, 5, 6, 0, 1, 2], [6, 0, 1, 2, 3, 4, 5], [4, 5, 6, 0, 1, 2, 3], [2, 3, 4, 5, 6, 0, 1]]) == 2\n assert candidate(n = 12,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1], [3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2]]) == 9\n assert candidate(n = 7,paths = [[0, 1, 2, 3, 4, 5, 6], [2, 3, 4, 5, 6, 0, 1], [4, 5, 6, 0, 1, 2, 3], [6, 0, 1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 6, 0]]) == 2\n assert candidate(n = 12,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1], [4, 5, 6, 7, 8, 9, 10, 11, 0, 1, 2, 3], [6, 7, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5], [8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7]]) == 4\n assert candidate(n = 20,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8], [15, 16, 17, 18, 19, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]]) == 9\n assert candidate(n = 10,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [2, 3, 4, 5, 6, 7, 8, 9, 0, 1], [3, 4, 5, 6, 7, 8, 9, 0, 1, 2]]) == 7\n assert candidate(n = 100,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 90\n assert candidate(n = 15,paths = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [5, 4, 3, 2, 1, 0, 14, 13, 12, 11, 10, 9, 8, 7, 6]]) == 1\n assert candidate(n = 7,paths = [[0, 1, 2, 3, 4, 5, 6], [6, 0, 1, 2, 3, 4, 5], [5, 6, 0, 1, 2, 3, 4], [4, 5, 6, 0, 1, 2, 3]]) == 4\n assert candidate(n = 5,paths = [[0, 1, 2, 3, 4], [1, 2, 3, 4], [2, 3, 4], [3, 4], [4]]) == 1\n"}, "metadata": {"canonical_parameter_names": ["n", "paths"], "leetcode_dataset_entry_point": "Solution().longestCommonSubpath", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int longestCommonSubpath(int n, vector>& paths) {", "container": "Solution", "callable": "longestCommonSubpath", "parameters": [{"name": "n", "type": "int"}, {"name": "paths", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1925, "task_id": "count-square-sum-triples", "difficulty": "Easy", "problem_description": "A square triple (a,b,c) is a triple where a, b, and c are integers and a2 + b2 = c2.\nGiven an integer n, return the number of square triples such that 1 <= a, b, c <= n.\n \nExample 1:\n\nInput: n = 5\nOutput: 2\nExplanation: The square triples are (3,4,5) and (4,3,5).\n\nExample 2:\n\nInput: n = 10\nOutput: 4\nExplanation: The square triples are (3,4,5), (4,3,5), (6,8,10), and (8,6,10).\n\n \nConstraints:\n\n1 <= n <= 250\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 250) == 330\n assert candidate(n = 5) == 2\n assert candidate(n = 15) == 8\n assert candidate(n = 200) == 254\n assert candidate(n = 20) == 12\n assert candidate(n = 100) == 104\n assert candidate(n = 50) == 40\n assert candidate(n = 1) == 0\n assert candidate(n = 10) == 4\n assert candidate(n = 25) == 16\n assert candidate(n = 150) == 178\n assert candidate(n = 80) == 78\n assert candidate(n = 230) == 302\n assert candidate(n = 125) == 142\n assert candidate(n = 75) == 74\n assert candidate(n = 240) == 314\n assert candidate(n = 199) == 250\n assert candidate(n = 120) == 132\n assert candidate(n = 225) == 296\n assert candidate(n = 249) == 324\n assert candidate(n = 190) == 236\n assert candidate(n = 175) == 214\n assert candidate(n = 180) == 218\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().countTriples", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countTriples(int n) {", "container": "Solution", "callable": "countTriples", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1926, "task_id": "nearest-exit-from-entrance-in-maze", "difficulty": "Medium", "problem_description": "You are given an m x n matrix maze (0-indexed) with empty cells (represented as '.') and walls (represented as '+'). You are also given the entrance of the maze, where entrance = [entrancerow, entrancecol] denotes the row and column of the cell you are initially standing at.\nIn one step, you can move one cell up, down, left, or right. You cannot step into a cell with a wall, and you cannot step outside the maze. Your goal is to find the nearest exit from the entrance. An exit is defined as an empty cell that is at the border of the maze. The entrance does not count as an exit.\nReturn the number of steps in the shortest path from the entrance to the nearest exit, or -1 if no such path exists.\n \nExample 1:\n\n\nInput: maze = [[\"+\",\"+\",\".\",\"+\"],[\".\",\".\",\".\",\"+\"],[\"+\",\"+\",\"+\",\".\"]], entrance = [1,2]\nOutput: 1\nExplanation: There are 3 exits in this maze at [1,0], [0,2], and [2,3].\nInitially, you are at the entrance cell [1,2].\n- You can reach [1,0] by moving 2 steps left.\n- You can reach [0,2] by moving 1 step up.\nIt is impossible to reach [2,3] from the entrance.\nThus, the nearest exit is [0,2], which is 1 step away.\n\nExample 2:\n\n\nInput: maze = [[\"+\",\"+\",\"+\"],[\".\",\".\",\".\"],[\"+\",\"+\",\"+\"]], entrance = [1,0]\nOutput: 2\nExplanation: There is 1 exit in this maze at [1,2].\n[1,0] does not count as an exit since it is the entrance cell.\nInitially, you are at the entrance cell [1,0].\n- You can reach [1,2] by moving 2 steps right.\nThus, the nearest exit is [1,2], which is 2 steps away.\n\nExample 3:\n\n\nInput: maze = [[\".\",\"+\"]], entrance = [0,0]\nOutput: -1\nExplanation: There are no exits in this maze.\n\n \nConstraints:\n\nmaze.length == m\nmaze[i].length == n\n1 <= m, n <= 100\nmaze[i][j] is either '.' or '+'.\nentrance.length == 2\n0 <= entrancerow < m\n0 <= entrancecol < n\nentrance will always be an empty cell.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(maze = [['.', '+']],entrance = [0, 0]) == -1\n assert candidate(maze = [['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.']],entrance = [0, 1]) == 1\n assert candidate(maze = [['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.']],entrance = [0, 0]) == 1\n assert candidate(maze = [['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.']],entrance = [2, 2]) == 1\n assert candidate(maze = [['+)', '+)', '+'], ['.', '.', '.'], ['+)', '+)', '+']],entrance = [1, 0]) == 2\n assert candidate(maze = [['+)', '+)', '.'], ['.', '.', '.', '+'], ['+)', '+)', '+)', '.']],entrance = [1, 2]) == 1\n assert candidate(maze = [['+', '.', '+'], ['.', '.', '.'], ['+', '.', '+']],entrance = [1, 1]) == 1\n assert candidate(maze = [['.', '.', '+', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.']],entrance = [0, 3]) == 1\n assert candidate(maze = [['.', '.', '.', '.'], ['.', '+', '.', '.'], ['.', '.', '.', '.'], ['.', '.', '.', '.']],entrance = [1, 1]) == 1\n assert candidate(maze = [['.', '.', '.'], ['.', '.', '.'], ['.', '.', '.']],entrance = [1, 1]) == 1\n"}, "metadata": {"canonical_parameter_names": ["maze", "entrance"], "leetcode_dataset_entry_point": "Solution().nearestExit", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int nearestExit(vector>& maze, vector& entrance) {", "container": "Solution", "callable": "nearestExit", "parameters": [{"name": "maze", "type": "vector>&"}, {"name": "entrance", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1927, "task_id": "sum-game", "difficulty": "Medium", "problem_description": "Alice and Bob take turns playing a game, with Alice starting first.\nYou are given a string num of even length consisting of digits and '?' characters. On each turn, a player will do the following if there is still at least one '?' in num:\n\nChoose an index i where num[i] == '?'.\nReplace num[i] with any digit between '0' and '9'.\n\nThe game ends when there are no more '?' characters in num.\nFor Bob to win, the sum of the digits in the first half of num must be equal to the sum of the digits in the second half. For Alice to win, the sums must not be equal.\n\nFor example, if the game ended with num = \"243801\", then Bob wins because 2+4+3 = 8+0+1. If the game ended with num = \"243803\", then Alice wins because 2+4+3 != 8+0+3.\n\nAssuming Alice and Bob play optimally, return true if Alice will win and false if Bob will win.\n \nExample 1:\n\nInput: num = \"5023\"\nOutput: false\nExplanation: There are no moves to be made.\nThe sum of the first half is equal to the sum of the second half: 5 + 0 = 2 + 3.\n\nExample 2:\n\nInput: num = \"25??\"\nOutput: true\nExplanation: Alice can replace one of the '?'s with '9' and it will be impossible for Bob to make the sums equal.\n\nExample 3:\n\nInput: num = \"?3295???\"\nOutput: false\nExplanation: It can be proven that Bob will always win. One possible outcome is:\n- Alice replaces the first '?' with '9'. num = \"93295???\".\n- Bob replaces one of the '?' in the right half with '9'. num = \"932959??\".\n- Alice replaces one of the '?' in the right half with '2'. num = \"9329592?\".\n- Bob replaces the last '?' in the right half with '7'. num = \"93295927\".\nBob wins because 9 + 3 + 2 + 9 = 5 + 9 + 2 + 7.\n\n \nConstraints:\n\n2 <= num.length <= 105\nnum.length is even.\nnum consists of only digits and '?'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = \"1???2???\") == True\n assert candidate(num = \"9?8?7?6?\") == True\n assert candidate(num = \"????2222\") == True\n assert candidate(num = \"98765432\") == True\n assert candidate(num = \"???45678\") == True\n assert candidate(num = \"9999????\") == True\n assert candidate(num = \"0000???\") == True\n assert candidate(num = \"12??34??\") == True\n assert candidate(num = \"?3295???\") == False\n assert candidate(num = \"0000????\") == True\n assert candidate(num = \"12345678\") == True\n assert candidate(num = \"12345678??\") == True\n assert candidate(num = \"00112233\") == True\n assert candidate(num = \"????567890\") == True\n assert candidate(num = \"5023\") == False\n assert candidate(num = \"????1234\") == True\n assert candidate(num = \"9999???\") == True\n assert candidate(num = \"????????\") == False\n assert candidate(num = \"00?0?0?0\") == True\n assert candidate(num = \"00000000\") == False\n assert candidate(num = \"1234?678?\") == True\n assert candidate(num = \"1234567890\") == True\n assert candidate(num = \"99?9?9?9\") == True\n assert candidate(num = \"25??\") == True\n assert candidate(num = \"1234????\") == True\n assert candidate(num = \"11112222\") == True\n assert candidate(num = \"????5000500050005000\") == True\n assert candidate(num = \"8888888888????????????????\") == True\n assert candidate(num = \"1234567890????\") == True\n assert candidate(num = \"00000000001234567890\") == True\n assert candidate(num = \"1234????5678\") == True\n assert candidate(num = \"1111111111111111????\") == True\n assert candidate(num = \"12345678901234567890????????????????????\") == False\n assert candidate(num = \"98765432109876543210\") == False\n assert candidate(num = \"1010101010??????????????????????\") == True\n assert candidate(num = \"9999999999999999999999999999????????????????????????????????????????????????????????????????????????????????????????????????????????\") == True\n assert candidate(num = \"12345678????????????????12345678\") == False\n assert candidate(num = \"1111111111111111????????????????\") == True\n assert candidate(num = \"2468013579????????????????\") == False\n assert candidate(num = \"99999999998765432100\") == True\n assert candidate(num = \"5555555555555555????\") == True\n assert candidate(num = \"50005000500050005000????\") == True\n assert candidate(num = \"1111111111????????????????\") == True\n assert candidate(num = \"1111????2222\") == True\n assert candidate(num = \"????????5432109876\") == True\n assert candidate(num = \"2222222222????????????????\") == True\n assert candidate(num = \"1234567890123456789012345678901234567890????\") == True\n assert candidate(num = \"1234567890????????\") == True\n assert candidate(num = \"555555555555555555550000000000000000????????\") == True\n assert candidate(num = \"00009999????\") == True\n assert candidate(num = \"2468024680??????????????????????\") == True\n assert candidate(num = \"98765432109876543210????????????\") == True\n assert candidate(num = \"1111222233334444????\") == True\n assert candidate(num = \"243801????????????????243801\") == False\n assert candidate(num = \"12345678901234567890????????????????????????????????????????????????????\") == False\n assert candidate(num = \"12345678901234561234567890???????\") == True\n assert candidate(num = \"222222222222222222222222222222222222222222222222????????????????????????????????????????????\") == True\n assert candidate(num = \"1234567890123456????\") == True\n assert candidate(num = \"12345678901234567890????????????????????????????????????????????????????????????????????????????????????????????????????????\") == False\n assert candidate(num = \"????????????\") == False\n assert candidate(num = \"502350235023????\") == True\n assert candidate(num = \"1234567890????????1234567890????????\") == False\n assert candidate(num = \"11111111????1111\") == True\n assert candidate(num = \"1111111111111111\") == False\n assert candidate(num = \"????????????????\") == False\n assert candidate(num = \"25??1234????????????????\") == True\n assert candidate(num = \"1234123412341234????\") == True\n assert candidate(num = \"0000000000000000000011111111111111111111\") == True\n assert candidate(num = \"55555555555555555555555555555555555555555555555555555555555555555????????????????????????????????????????????????????????????????????????????????????????????????\") == True\n assert candidate(num = \"5432109876????????\") == True\n assert candidate(num = \"????567890????567890\") == False\n assert candidate(num = \"1111111122222222????\") == True\n assert candidate(num = \"4444444444????????????????\") == True\n assert candidate(num = \"1234567890123456789012345678901234????\") == True\n assert candidate(num = \"999999999999????????????\") == True\n assert candidate(num = \"9876543210??????????????????????\") == False\n assert candidate(num = \"6666666666????????????????\") == True\n assert candidate(num = \"55555555555555555555555555555555\") == False\n assert candidate(num = \"9876543210????????????????\") == False\n assert candidate(num = \"0987654321????\") == True\n assert candidate(num = \"00000000000000001111111111111111????????????????\") == True\n assert candidate(num = \"0123456789????????\") == True\n assert candidate(num = \"0987654321098765\") == True\n assert candidate(num = \"1234567890????????????????\") == False\n assert candidate(num = \"????????1234567890\") == True\n assert candidate(num = \"9999999999999999999999999999????\") == True\n assert candidate(num = \"????0000????0000\") == False\n assert candidate(num = \"0000000000000000????????????????\") == True\n assert candidate(num = \"55555555555555555555555555555555????????????????\") == True\n assert candidate(num = \"0?????????????????????????????????\") == True\n assert candidate(num = \"9876987698769876????\") == True\n assert candidate(num = \"0000000000????????\") == True\n assert candidate(num = \"11111111111111111111????????????????\") == True\n assert candidate(num = \"1234567890????1234\") == True\n assert candidate(num = \"9999999999999999????\") == True\n assert candidate(num = \"1234567890??????????????????????\") == False\n assert candidate(num = \"9999????????\") == True\n assert candidate(num = \"1234567890????????1234567890????\") == False\n assert candidate(num = \"1010101010????????????????\") == True\n assert candidate(num = \"1234567890123456\") == True\n assert candidate(num = \"1234567890????????????????0123456789\") == False\n assert candidate(num = \"5555555555??????????????????????\") == True\n assert candidate(num = \"55555555????\") == True\n assert candidate(num = \"000000000000000000000000????????????????\") == True\n assert candidate(num = \"000099990000????????\") == False\n assert candidate(num = \"????????11111111\") == True\n assert candidate(num = \"1111111111????????????????????1111111111\") == False\n assert candidate(num = \"1234567890123456????????????????\") == True\n assert candidate(num = \"5023????5023????\") == False\n assert candidate(num = \"1234567890????????????????1234567890\") == False\n assert candidate(num = \"13579135791357913579????????????????????\") == True\n assert candidate(num = \"99999999999999991234\") == True\n assert candidate(num = \"????9876543210????\") == True\n assert candidate(num = \"99999999999999999999999999999999\") == False\n assert candidate(num = \"9999999999999999????????????????\") == True\n assert candidate(num = \"99999999999999999999\") == False\n assert candidate(num = \"9????9????\") == False\n assert candidate(num = \"99999999990000000000\") == True\n assert candidate(num = \"1122334455????????????????\") == True\n assert candidate(num = \"1111111122222222\") == True\n assert candidate(num = \"?????????????????????????????????1\") == True\n assert candidate(num = \"5555555544444444????\") == True\n assert candidate(num = \"1234567890123456789012345678901234567890????????????????????????????\") == True\n assert candidate(num = \"????1234567890??\") == True\n assert candidate(num = \"0000000000000000????\") == True\n assert candidate(num = \"00000000000000000000000000000000000000000000????????????????\") == True\n assert candidate(num = \"99999999????\") == True\n assert candidate(num = \"1020304050????????????????\") == True\n assert candidate(num = \"24680246802468024680????????????????????\") == True\n assert candidate(num = \"5000500050005000????\") == True\n assert candidate(num = \"0000000000000000000000000000????????????????????????????????\") == True\n assert candidate(num = \"9012345678????????????????8765432109\") == False\n assert candidate(num = \"????????9999999999\") == True\n assert candidate(num = \"98765432109876543210????????????????????\") == False\n assert candidate(num = \"9876543210????????????\") == False\n assert candidate(num = \"7777777777????????????????\") == True\n assert candidate(num = \"9753186420????????????????\") == False\n assert candidate(num = \"2222111144443333????\") == True\n assert candidate(num = \"5023????????????????????\") == True\n assert candidate(num = \"0000000000????????????????\") == True\n assert candidate(num = \"3333333333????????????????\") == True\n assert candidate(num = \"9876543210????????\") == True\n assert candidate(num = \"0000000000000000000000000000????\") == True\n assert candidate(num = \"12345678901234567890????????????\") == True\n assert candidate(num = \"123456789012345678901234567890\") == True\n assert candidate(num = \"5555555555????????????????\") == True\n assert candidate(num = \"9999????9999\") == False\n assert candidate(num = \"????2345????????????????5432????\") == False\n assert candidate(num = \"11223344556677889900????????????\") == False\n assert candidate(num = \"0000000099999999\") == True\n assert candidate(num = \"55555555555555555555555555555555????????????????????????????????????\") == True\n assert candidate(num = \"22222222222222222222222222222222????????????????????????????????????2222222222\") == True\n assert candidate(num = \"99999999????9999\") == True\n assert candidate(num = \"11111111111111111111\") == False\n assert candidate(num = \"20202020202020202020202020????????\") == True\n assert candidate(num = \"0101010101????????????????\") == True\n assert candidate(num = \"?9?8?7?6?5?4?3?2?1?\") == True\n assert candidate(num = \"12345678901234567890\") == False\n assert candidate(num = \"9876543210????\") == True\n assert candidate(num = \"5555555555????????\") == True\n assert candidate(num = \"33333333333333333333333333333333333333333333333333????????????????????????????????????????????????????????????????????????????????333333333333\") == True\n assert candidate(num = \"11111111111111112222222222222222\") == True\n assert candidate(num = \"1?????????????????????????????????\") == True\n assert candidate(num = \"88888888888888888888888888888888888888888888888888888888888888888????????????????????????????????????????????????????????????????????????????????????????????????888888888888\") == True\n assert candidate(num = \"1234567890????????????????0987654321\") == False\n assert candidate(num = \"0000000000000000\") == False\n assert candidate(num = \"9999999999????????????????\") == True\n assert candidate(num = \"50505050????\") == True\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().sumGame", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool sumGame(string num) {", "container": "Solution", "callable": "sumGame", "parameters": [{"name": "num", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1928, "task_id": "minimum-cost-to-reach-destination-in-time", "difficulty": "Hard", "problem_description": "There is a country of n cities numbered from 0 to n - 1 where all the cities are connected by bi-directional roads. The roads are represented as a 2D integer array edges where edges[i] = [xi, yi, timei] denotes a road between cities xi and yi that takes timei minutes to travel. There may be multiple roads of differing travel times connecting the same two cities, but no road connects a city to itself.\nEach time you pass through a city, you must pay a passing fee. This is represented as a 0-indexed integer array passingFees of length n where passingFees[j] is the amount of dollars you must pay when you pass through city j.\nIn the beginning, you are at city 0 and want to reach city n - 1 in maxTime minutes or less. The cost of your journey is the summation of passing fees for each city that you passed through at some moment of your journey (including the source and destination cities).\nGiven maxTime, edges, and passingFees, return the minimum cost to complete your journey, or -1 if you cannot complete it within maxTime minutes.\n \nExample 1:\n\n\nInput: maxTime = 30, edges = [[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]], passingFees = [5,1,2,20,20,3]\nOutput: 11\nExplanation: The path to take is 0 -> 1 -> 2 -> 5, which takes 30 minutes and has $11 worth of passing fees.\n\nExample 2:\n\n\nInput: maxTime = 29, edges = [[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]], passingFees = [5,1,2,20,20,3]\nOutput: 48\nExplanation: The path to take is 0 -> 3 -> 4 -> 5, which takes 26 minutes and has $48 worth of passing fees.\nYou cannot take path 0 -> 1 -> 2 -> 5 since it would take too long.\n\nExample 3:\n\nInput: maxTime = 25, edges = [[0,1,10],[1,2,10],[2,5,10],[0,3,1],[3,4,10],[4,5,15]], passingFees = [5,1,2,20,20,3]\nOutput: -1\nExplanation: There is no way to reach city 5 from city 0 within 25 minutes.\n\n \nConstraints:\n\n1 <= maxTime <= 1000\nn == passingFees.length\n2 <= n <= 1000\nn - 1 <= edges.length <= 1000\n0 <= xi, yi <= n - 1\n1 <= timei <= 1000\n1 <= passingFees[j] <= 1000 \nThe graph may contain multiple edges between two nodes.\nThe graph does not contain self loops.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(maxTime = 50,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1]],passingFees = [1, 2, 3, 4, 5, 6]) == 21\n assert candidate(maxTime = 5,edges = [[0, 1, 5], [0, 2, 5], [1, 3, 5], [2, 3, 5], [3, 4, 5]],passingFees = [10, 10, 10, 10, 10]) == -1\n assert candidate(maxTime = 10,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [0, 3, 15]],passingFees = [10, 1, 1, 10]) == -1\n assert candidate(maxTime = 20,edges = [[0, 1, 10], [1, 0, 10], [0, 2, 5], [2, 0, 5], [1, 3, 10], [3, 1, 10], [2, 3, 10], [3, 2, 10]],passingFees = [1, 2, 3, 4]) == 7\n assert candidate(maxTime = 15,edges = [[0, 1, 10], [1, 2, 10], [0, 2, 1]],passingFees = [3, 1, 2]) == 5\n assert candidate(maxTime = 10,edges = [[0, 1, 5], [1, 2, 5], [0, 2, 10]],passingFees = [3, 2, 1]) == 4\n assert candidate(maxTime = 5,edges = [[0, 1, 5], [1, 2, 5], [0, 2, 10]],passingFees = [1, 2, 3]) == -1\n assert candidate(maxTime = 29,edges = [[0, 1, 10], [1, 2, 10], [2, 5, 10], [0, 3, 1], [3, 4, 10], [4, 5, 15]],passingFees = [5, 1, 2, 20, 20, 3]) == 48\n assert candidate(maxTime = 50,edges = [[0, 1, 1], [0, 2, 1], [1, 2, 1], [1, 3, 1], [2, 3, 1]],passingFees = [1, 1, 1, 1]) == 3\n assert candidate(maxTime = 50,edges = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1]],passingFees = [1, 1, 1, 1, 1, 1]) == 6\n assert candidate(maxTime = 5,edges = [[0, 1, 5], [1, 2, 5], [0, 2, 10]],passingFees = [3, 2, 1]) == -1\n assert candidate(maxTime = 30,edges = [[0, 1, 10], [1, 2, 10], [2, 5, 10], [0, 3, 1], [3, 4, 10], [4, 5, 15]],passingFees = [5, 1, 2, 20, 20, 3]) == 11\n assert candidate(maxTime = 25,edges = [[0, 1, 10], [1, 2, 10], [2, 5, 10], [0, 3, 1], [3, 4, 10], [4, 5, 15]],passingFees = [5, 1, 2, 20, 20, 3]) == -1\n assert candidate(maxTime = 5,edges = [[0, 1, 6], [1, 2, 5], [0, 2, 10]],passingFees = [1, 2, 3]) == -1\n assert candidate(maxTime = 10,edges = [[0, 1, 3], [1, 2, 3], [0, 2, 5]],passingFees = [1, 2, 3]) == 4\n assert candidate(maxTime = 50,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [0, 3, 15]],passingFees = [10, 20, 30, 40]) == 50\n assert candidate(maxTime = 20,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [0, 2, 5], [1, 3, 6]],passingFees = [1, 2, 3, 4]) == 7\n assert candidate(maxTime = 10,edges = [[0, 1, 5], [1, 2, 5], [0, 2, 10]],passingFees = [1, 2, 3]) == 4\n assert candidate(maxTime = 1,edges = [[0, 1, 1]],passingFees = [1, 1]) == 2\n assert candidate(maxTime = 45,edges = [[0, 1, 10], [1, 2, 15], [2, 3, 20], [0, 2, 25], [1, 3, 30], [2, 4, 10], [3, 5, 15], [0, 3, 35], [1, 4, 40], [2, 5, 20], [0, 4, 50], [1, 5, 55]],passingFees = [5, 4, 3, 2, 1, 6]) == 14\n assert candidate(maxTime = 150,edges = [[0, 1, 20], [1, 2, 30], [0, 2, 40], [2, 3, 10], [3, 4, 50], [0, 3, 10], [1, 4, 30], [4, 5, 20], [5, 6, 40], [6, 7, 30], [7, 5, 15], [6, 8, 10], [8, 9, 50], [9, 0, 20], [9, 1, 10], [1, 3, 25]],passingFees = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 55\n assert candidate(maxTime = 500,edges = [[0, 1, 5], [0, 2, 10], [1, 2, 15], [1, 3, 20], [2, 3, 25], [2, 4, 30], [3, 4, 35], [3, 5, 40], [4, 5, 45], [4, 6, 50], [5, 6, 55], [5, 7, 60], [6, 7, 65], [6, 8, 70], [7, 8, 75], [7, 9, 80], [8, 9, 85], [0, 3, 30], [0, 4, 40], [0, 5, 50], [1, 4, 45], [1, 5, 55], [1, 6, 65], [2, 5, 50], [2, 6, 60], [2, 7, 70], [3, 6, 65], [3, 7, 75], [3, 8, 80], [4, 7, 70], [4, 8, 80], [4, 9, 85], [5, 8, 80], [5, 9, 85], [6, 9, 85]],passingFees = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 160\n assert candidate(maxTime = 50,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [9, 10, 5], [0, 10, 10], [1, 9, 15], [2, 8, 20], [3, 7, 25], [4, 6, 30]],passingFees = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == 60\n assert candidate(maxTime = 100,edges = [[0, 1, 20], [1, 2, 30], [2, 3, 10], [3, 4, 50], [0, 2, 40], [1, 3, 10], [2, 4, 20]],passingFees = [10, 5, 15, 20, 25]) == 50\n assert candidate(maxTime = 300,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10], [0, 9, 9], [1, 0, 1], [2, 1, 2], [3, 2, 3], [4, 3, 4], [5, 4, 5], [6, 5, 6], [7, 6, 7], [8, 7, 8], [9, 8, 9]],passingFees = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(maxTime = 15,edges = [[0, 1, 4], [1, 2, 3], [0, 2, 6], [2, 3, 5], [3, 4, 7], [0, 3, 8], [1, 3, 2]],passingFees = [2, 3, 4, 1, 5]) == 8\n assert candidate(maxTime = 100,edges = [[0, 1, 50], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 10], [0, 5, 90], [1, 3, 25], [2, 4, 15]],passingFees = [10, 20, 30, 40, 50, 60]) == 70\n assert candidate(maxTime = 25,edges = [[0, 1, 2], [1, 2, 2], [2, 3, 2], [3, 4, 2], [4, 5, 2], [0, 5, 10], [1, 3, 5], [2, 4, 5], [0, 3, 7], [0, 4, 8], [1, 4, 4], [2, 5, 3]],passingFees = [1, 2, 3, 4, 5, 6]) == 7\n assert candidate(maxTime = 600,edges = [[0, 1, 15], [0, 5, 15], [1, 2, 25], [1, 6, 25], [2, 3, 35], [2, 7, 35], [3, 4, 45], [3, 8, 45], [4, 9, 55], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [0, 6, 25], [1, 7, 35], [2, 8, 45], [3, 9, 55], [0, 7, 35], [1, 8, 45], [2, 9, 55], [0, 8, 45], [1, 9, 55], [0, 9, 55], [5, 10, 5], [10, 6, 5], [6, 10, 5], [7, 10, 5], [10, 8, 5], [8, 10, 5], [9, 10, 5]],passingFees = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 180\n assert candidate(maxTime = 60,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [0, 3, 15], [0, 2, 10], [1, 3, 10], [3, 4, 10], [2, 4, 10], [0, 4, 20]],passingFees = [3, 2, 1, 2, 3]) == 6\n assert candidate(maxTime = 10,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [0, 3, 5], [0, 2, 1], [1, 3, 1]],passingFees = [1, 2, 3, 4]) == 5\n assert candidate(maxTime = 5,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5]],passingFees = [1, 1, 1, 1, 1]) == -1\n assert candidate(maxTime = 220,edges = [[0, 1, 50], [1, 2, 40], [2, 3, 30], [3, 4, 20], [4, 0, 10], [0, 2, 60], [1, 3, 50], [2, 4, 40], [0, 4, 50], [3, 2, 40]],passingFees = [1, 1, 1, 1, 1]) == 2\n assert candidate(maxTime = 300,edges = [[0, 1, 50], [1, 2, 50], [2, 3, 50], [3, 4, 50], [0, 2, 60], [1, 3, 60], [2, 4, 60], [0, 3, 70], [1, 4, 70], [0, 4, 80]],passingFees = [10, 20, 30, 40, 50]) == 60\n assert candidate(maxTime = 100,edges = [[0, 1, 10], [0, 2, 30], [1, 3, 20], [2, 3, 10], [3, 4, 40], [1, 2, 5]],passingFees = [10, 15, 20, 25, 30]) == 80\n assert candidate(maxTime = 100,edges = [[0, 1, 20], [1, 2, 20], [2, 3, 20], [3, 4, 20], [4, 5, 20], [0, 3, 50], [3, 5, 50]],passingFees = [5, 10, 15, 20, 25, 30]) == 55\n assert candidate(maxTime = 200,edges = [[0, 1, 50], [1, 2, 40], [2, 3, 30], [3, 4, 20], [4, 0, 10], [0, 2, 60], [1, 3, 50], [2, 4, 40]],passingFees = [100, 200, 150, 50, 300]) == 400\n assert candidate(maxTime = 250,edges = [[0, 1, 5], [1, 2, 15], [2, 3, 25], [3, 4, 35], [4, 5, 45], [0, 5, 55], [1, 3, 25], [2, 4, 35], [0, 4, 45], [1, 4, 15]],passingFees = [5, 5, 5, 5, 5, 5]) == 10\n assert candidate(maxTime = 600,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [0, 4, 40], [4, 5, 50], [1, 5, 60], [2, 6, 70], [3, 6, 80], [4, 7, 90], [5, 8, 100], [6, 8, 110], [0, 7, 120], [0, 3, 130], [1, 6, 140], [2, 7, 150], [3, 8, 160], [4, 6, 170], [5, 7, 180], [6, 7, 190]],passingFees = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 140\n assert candidate(maxTime = 150,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [9, 10, 5]],passingFees = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(maxTime = 100,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 0, 10], [0, 5, 5], [1, 6, 5], [2, 7, 5], [3, 8, 5], [4, 9, 5]],passingFees = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 55\n assert candidate(maxTime = 100,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [2, 3, 25], [1, 4, 40], [3, 4, 15], [4, 5, 5], [5, 6, 30], [6, 1, 25], [2, 6, 10]],passingFees = [10, 15, 20, 25, 30, 35, 40]) == 65\n assert candidate(maxTime = 30,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10]],passingFees = [5, 1, 2, 20, 20, 3, 5, 1, 2, 3]) == -1\n assert candidate(maxTime = 120,edges = [[0, 1, 20], [0, 2, 30], [0, 3, 10], [1, 2, 15], [1, 3, 20], [1, 4, 10], [2, 3, 25], [2, 4, 5], [3, 4, 15], [2, 5, 10], [3, 5, 20], [4, 5, 5], [0, 5, 20]],passingFees = [15, 25, 35, 45, 55, 65]) == 80\n assert candidate(maxTime = 200,edges = [[0, 1, 30], [0, 2, 20], [1, 2, 10], [1, 3, 40], [2, 4, 20], [3, 4, 10], [3, 5, 50], [4, 5, 30], [2, 5, 25], [5, 6, 10], [6, 7, 20], [6, 8, 15], [7, 8, 5], [8, 9, 10], [9, 0, 10]],passingFees = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(maxTime = 20,edges = [[0, 1, 5], [1, 2, 10], [0, 3, 15], [3, 4, 20], [2, 4, 25], [4, 5, 30]],passingFees = [5, 10, 15, 20, 25, 30]) == -1\n assert candidate(maxTime = 50,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 15], [3, 4, 10], [4, 5, 10], [0, 3, 25], [1, 4, 20]],passingFees = [10, 20, 30, 40, 50, 60]) == 140\n assert candidate(maxTime = 60,edges = [[0, 1, 10], [0, 2, 15], [0, 3, 20], [1, 2, 5], [1, 3, 10], [2, 3, 25], [1, 4, 10], [2, 4, 5], [3, 4, 15], [2, 5, 10], [3, 5, 20], [4, 5, 5]],passingFees = [10, 20, 30, 40, 50, 60]) == 100\n assert candidate(maxTime = 50,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 0, 5], [0, 2, 10], [1, 3, 10], [2, 4, 10]],passingFees = [1, 2, 3, 4, 5]) == 6\n assert candidate(maxTime = 80,edges = [[0, 1, 10], [1, 2, 20], [0, 2, 30], [2, 3, 40], [0, 3, 50], [3, 4, 60], [0, 4, 70]],passingFees = [5, 5, 5, 5, 5]) == 10\n assert candidate(maxTime = 50,edges = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [0, 2, 4], [1, 3, 3], [2, 4, 2], [3, 5, 1]],passingFees = [1, 2, 3, 4, 5, 6]) == 13\n assert candidate(maxTime = 120,edges = [[0, 1, 15], [1, 2, 25], [2, 3, 35], [3, 4, 45], [0, 3, 65], [1, 4, 75], [2, 4, 85], [0, 4, 95], [3, 1, 105], [4, 2, 115]],passingFees = [50, 20, 30, 40, 60]) == 110\n assert candidate(maxTime = 20,edges = [[0, 1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [0, 5, 10]],passingFees = [5, 10, 15, 20, 25, 30]) == 35\n assert candidate(maxTime = 500,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [0, 4, 40], [4, 5, 50], [1, 5, 60], [2, 6, 70], [3, 6, 80], [4, 7, 90], [5, 8, 100], [6, 8, 110], [0, 7, 120]],passingFees = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 18\n assert candidate(maxTime = 200,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [0, 3, 30], [1, 3, 30], [2, 4, 30], [3, 4, 30], [0, 4, 50]],passingFees = [1, 2, 3, 4, 5]) == 6\n assert candidate(maxTime = 550,edges = [[0, 1, 20], [0, 5, 20], [1, 2, 30], [1, 6, 30], [2, 3, 40], [2, 7, 40], [3, 4, 50], [3, 8, 50], [4, 9, 60], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [0, 6, 40], [1, 7, 50], [2, 8, 60], [3, 9, 70], [0, 7, 50], [1, 8, 60], [2, 9, 70], [0, 8, 60], [1, 9, 70], [0, 9, 70]],passingFees = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 110\n assert candidate(maxTime = 400,edges = [[0, 1, 30], [1, 2, 30], [2, 3, 30], [3, 4, 30], [0, 2, 50], [1, 3, 50], [2, 4, 50], [0, 3, 70], [1, 4, 70], [0, 4, 90], [0, 5, 40], [5, 4, 10], [4, 6, 60], [6, 5, 10], [5, 3, 20]],passingFees = [5, 15, 25, 35, 45, 55, 65]) == 115\n assert candidate(maxTime = 350,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [2, 3, 20], [3, 4, 40], [0, 3, 30], [1, 2, 20], [0, 4, 50], [1, 4, 30], [2, 4, 40]],passingFees = [10, 20, 30, 40, 50]) == 60\n assert candidate(maxTime = 350,edges = [[0, 1, 50], [1, 2, 100], [2, 3, 150], [3, 4, 200], [4, 5, 250], [5, 6, 300], [6, 7, 350], [7, 8, 400], [8, 9, 450], [0, 9, 500]],passingFees = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == -1\n assert candidate(maxTime = 30,edges = [[0, 1, 5], [0, 2, 10], [1, 2, 3], [1, 3, 15], [2, 3, 20], [3, 4, 25]],passingFees = [1, 2, 3, 4, 5]) == -1\n assert candidate(maxTime = 180,edges = [[0, 1, 20], [0, 2, 30], [1, 3, 40], [2, 3, 20], [3, 4, 50], [0, 3, 30], [1, 2, 30], [0, 4, 60], [1, 4, 40]],passingFees = [10, 10, 10, 10, 10]) == 20\n assert candidate(maxTime = 150,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [9, 0, 5], [0, 3, 10], [1, 4, 10], [2, 5, 10], [3, 6, 10], [4, 7, 10], [5, 8, 10], [6, 9, 10], [7, 0, 10], [8, 1, 10], [9, 2, 10]],passingFees = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 110\n assert candidate(maxTime = 100,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [0, 5, 50], [0, 2, 40], [1, 3, 30], [2, 4, 20], [3, 5, 10], [0, 4, 60], [1, 5, 50]],passingFees = [5, 1, 2, 3, 4, 5]) == 10\n assert candidate(maxTime = 100,edges = [[0, 1, 10], [0, 2, 15], [1, 2, 10], [1, 3, 20], [2, 4, 15], [3, 4, 20], [4, 5, 30], [3, 5, 40]],passingFees = [5, 1, 2, 3, 4, 5]) == 14\n assert candidate(maxTime = 35,edges = [[0, 1, 5], [1, 2, 3], [0, 2, 9], [1, 3, 7], [2, 4, 4], [0, 3, 6], [1, 4, 8], [3, 4, 2], [0, 4, 12]],passingFees = [1, 2, 3, 4, 5]) == 6\n assert candidate(maxTime = 25,edges = [[0, 1, 10], [1, 2, 15], [0, 2, 20], [2, 3, 5], [3, 4, 10], [4, 5, 15], [5, 6, 20], [6, 7, 25], [7, 8, 30], [8, 9, 10], [0, 9, 35]],passingFees = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(maxTime = 300,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [0, 3, 60], [1, 4, 70], [2, 5, 80], [0, 2, 90], [3, 5, 100]],passingFees = [10, 20, 30, 40, 50, 60]) == 100\n assert candidate(maxTime = 30,edges = [[0, 1, 5], [1, 2, 7], [2, 3, 6], [0, 3, 10], [1, 3, 2], [2, 4, 5], [3, 4, 3], [0, 4, 8]],passingFees = [10, 20, 15, 25, 30]) == 40\n assert candidate(maxTime = 400,edges = [[0, 1, 100], [1, 2, 100], [2, 3, 100], [3, 4, 100], [4, 5, 100], [0, 5, 100], [0, 2, 100], [1, 3, 100], [2, 4, 100], [3, 5, 100]],passingFees = [5, 5, 5, 5, 5, 5]) == 10\n assert candidate(maxTime = 200,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 0, 10], [0, 2, 20], [1, 3, 20], [2, 4, 20], [3, 5, 20], [4, 6, 20], [5, 7, 20], [6, 8, 20], [7, 9, 20], [8, 1, 20], [9, 2, 20], [0, 3, 30], [1, 4, 30], [2, 5, 30], [3, 6, 30], [4, 7, 30], [5, 8, 30], [6, 9, 30], [7, 0, 30], [8, 1, 30], [9, 2, 30], [0, 4, 40], [1, 5, 40], [2, 6, 40], [3, 7, 40], [4, 8, 40], [5, 9, 40], [6, 0, 40], [7, 1, 40], [8, 2, 40], [9, 3, 40]],passingFees = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 55\n assert candidate(maxTime = 100,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [0, 2, 5], [1, 3, 5], [0, 3, 2], [2, 4, 20], [3, 4, 10]],passingFees = [10, 5, 3, 20, 1]) == 14\n assert candidate(maxTime = 30,edges = [[0, 1, 10], [1, 2, 10], [2, 5, 10], [0, 3, 1], [3, 4, 10], [4, 5, 15], [1, 3, 1], [2, 4, 5]],passingFees = [5, 1, 2, 20, 20, 3]) == 11\n assert candidate(maxTime = 50,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [0, 9, 40]],passingFees = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 19\n assert candidate(maxTime = 700,edges = [[0, 1, 50], [1, 2, 100], [2, 3, 150], [0, 4, 200], [4, 5, 250], [1, 5, 300], [2, 6, 350], [3, 6, 400], [4, 7, 450], [5, 8, 500], [6, 8, 550], [0, 7, 600], [0, 3, 650], [1, 6, 700], [2, 7, 750], [3, 8, 800], [4, 6, 850], [5, 7, 900], [6, 7, 950], [0, 8, 1000], [2, 5, 1050]],passingFees = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == -1\n assert candidate(maxTime = 200,edges = [[0, 1, 15], [0, 2, 20], [1, 3, 25], [2, 3, 15], [3, 4, 30], [0, 3, 15], [1, 2, 10]],passingFees = [10, 20, 30, 40, 50]) == 100\n assert candidate(maxTime = 180,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [0, 4, 50], [0, 2, 60], [1, 3, 70], [2, 4, 80], [3, 1, 90], [4, 0, 100]],passingFees = [50, 40, 30, 20, 10]) == 60\n assert candidate(maxTime = 300,edges = [[0, 1, 10], [1, 2, 20], [0, 3, 30], [3, 4, 40], [4, 5, 50], [0, 2, 60], [2, 3, 70], [1, 4, 80], [2, 5, 90]],passingFees = [5, 10, 15, 20, 25, 30]) == 50\n assert candidate(maxTime = 150,edges = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [0, 5, 50], [1, 3, 20], [2, 4, 25]],passingFees = [1, 1, 1, 1, 1, 1]) == 2\n assert candidate(maxTime = 220,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 20], [2, 3, 15], [3, 4, 25], [0, 3, 25], [1, 2, 15], [0, 4, 40], [1, 4, 25], [2, 4, 35]],passingFees = [5, 15, 25, 35, 45]) == 50\n assert candidate(maxTime = 15,edges = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 4], [2, 3, 5], [0, 3, 1]],passingFees = [10, 20, 30, 40]) == 50\n assert candidate(maxTime = 40,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 15], [3, 4, 5], [4, 5, 5], [5, 6, 5], [0, 2, 25], [1, 3, 15], [2, 4, 25], [3, 5, 15], [0, 4, 40], [1, 5, 25]],passingFees = [3, 2, 1, 4, 2, 5, 3]) == 13\n assert candidate(maxTime = 200,edges = [[0, 1, 100], [1, 2, 100], [2, 3, 100], [3, 4, 100], [4, 5, 100], [0, 3, 1], [3, 4, 1], [4, 5, 1], [0, 2, 1], [2, 4, 1]],passingFees = [5, 1, 2, 20, 20, 3]) == 30\n assert candidate(maxTime = 40,edges = [[0, 1, 3], [0, 2, 4], [1, 2, 2], [1, 3, 5], [2, 3, 6], [2, 4, 1], [3, 4, 7], [0, 4, 8], [1, 4, 3]],passingFees = [1, 2, 3, 4, 5]) == 6\n assert candidate(maxTime = 60,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10]],passingFees = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(maxTime = 150,edges = [[0, 1, 10], [1, 2, 20], [0, 2, 30], [2, 3, 10], [3, 0, 20], [1, 3, 10], [0, 3, 50], [1, 0, 20], [2, 1, 30], [3, 2, 40]],passingFees = [5, 15, 25, 35]) == 40\n assert candidate(maxTime = 60,edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10], [0, 14, 60]],passingFees = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 18\n assert candidate(maxTime = 250,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 8, 80], [8, 9, 90], [0, 9, 100]],passingFees = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 110\n assert candidate(maxTime = 500,edges = [[0, 1, 25], [1, 2, 25], [2, 3, 25], [3, 4, 25], [4, 5, 25], [5, 6, 25], [6, 7, 25], [7, 8, 25], [8, 9, 25], [9, 10, 25], [0, 9, 200], [9, 1, 200], [1, 10, 200], [10, 0, 200], [0, 10, 100], [1, 9, 100], [9, 2, 100], [2, 0, 100], [0, 8, 150], [8, 3, 150], [3, 1, 150], [1, 6, 150], [6, 4, 150], [4, 2, 150], [2, 7, 150], [7, 5, 150], [5, 8, 150]],passingFees = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == 120\n assert candidate(maxTime = 400,edges = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [2, 4, 40], [3, 5, 50], [4, 6, 60], [1, 2, 70], [3, 4, 80], [2, 5, 90], [4, 5, 100]],passingFees = [5, 10, 15, 20, 25, 30, 35]) == 80\n assert candidate(maxTime = 100,edges = [[0, 1, 20], [1, 2, 20], [2, 3, 20], [3, 4, 20], [4, 5, 20], [5, 6, 20], [6, 7, 20], [7, 8, 20], [8, 9, 20], [9, 10, 20], [10, 11, 20], [11, 12, 20], [12, 13, 20], [13, 14, 20], [14, 15, 20], [15, 16, 20], [16, 17, 20], [17, 18, 20], [18, 19, 20], [0, 19, 90]],passingFees = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 21\n assert candidate(maxTime = 80,edges = [[0, 1, 20], [0, 2, 30], [1, 3, 10], [2, 3, 10], [3, 4, 20], [0, 3, 10]],passingFees = [5, 5, 5, 5, 5]) == 15\n assert candidate(maxTime = 70,edges = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [9, 0, 5]],passingFees = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 20\n assert candidate(maxTime = 60,edges = [[0, 1, 20], [1, 2, 20], [2, 3, 20], [3, 4, 20], [0, 2, 10], [1, 3, 10], [2, 4, 10], [0, 3, 30], [1, 4, 30]],passingFees = [5, 15, 25, 35, 45]) == 65\n assert candidate(maxTime = 120,edges = [[0, 1, 10], [0, 2, 20], [1, 2, 30], [1, 3, 20], [2, 3, 10], [3, 4, 10], [0, 3, 20], [1, 2, 30]],passingFees = [5, 5, 5, 5, 5]) == 15\n assert candidate(maxTime = 800,edges = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [0, 4, 40], [4, 5, 50], [1, 5, 60], [2, 6, 70], [3, 6, 80], [4, 7, 90], [5, 8, 100], [6, 8, 110], [0, 7, 120], [0, 3, 130], [1, 6, 140], [2, 7, 150], [3, 8, 160], [4, 6, 170], [5, 7, 180], [6, 7, 190], [1, 3, 200], [2, 4, 210], [3, 5, 220], [4, 8, 230], [5, 6, 240], [0, 8, 250], [1, 7, 260], [2, 8, 270], [3, 7, 280], [4, 7, 290], [0, 6, 300], [1, 8, 310], [2, 5, 320], [3, 4, 330]],passingFees = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == 100\n assert candidate(maxTime = 20,edges = [[0, 1, 5], [1, 2, 3], [2, 3, 7], [0, 3, 12], [3, 4, 10], [2, 4, 2], [0, 4, 8]],passingFees = [4, 1, 2, 3, 5]) == 9\n assert candidate(maxTime = 200,edges = [[0, 1, 50], [1, 2, 50], [2, 3, 50], [3, 4, 50], [4, 5, 50], [0, 3, 60], [2, 4, 70]],passingFees = [10, 20, 30, 40, 50, 60]) == 160\n assert candidate(maxTime = 300,edges = [[0, 1, 50], [0, 2, 100], [1, 3, 200], [2, 3, 150], [3, 4, 250], [0, 3, 200], [1, 2, 100], [0, 4, 300], [1, 4, 150]],passingFees = [10, 20, 30, 40, 50]) == 60\n"}, "metadata": {"canonical_parameter_names": ["maxTime", "edges", "passingFees"], "leetcode_dataset_entry_point": "Solution().minCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minCost(int maxTime, vector>& edges, vector& passingFees) {", "container": "Solution", "callable": "minCost", "parameters": [{"name": "maxTime", "type": "int"}, {"name": "edges", "type": "vector>&"}, {"name": "passingFees", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1929, "task_id": "concatenation-of-array", "difficulty": "Easy", "problem_description": "Given an integer array nums of length n, you want to create an array ans of length 2n where ans[i] == nums[i] and ans[i + n] == nums[i] for 0 <= i < n (0-indexed).\nSpecifically, ans is the concatenation of two nums arrays.\nReturn the array ans.\n \nExample 1:\n\nInput: nums = [1,2,1]\nOutput: [1,2,1,1,2,1]\nExplanation: The array ans is formed as follows:\n- ans = [nums[0],nums[1],nums[2],nums[0],nums[1],nums[2]]\n- ans = [1,2,1,1,2,1]\nExample 2:\n\nInput: nums = [1,3,2,1]\nOutput: [1,3,2,1,1,3,2,1]\nExplanation: The array ans is formed as follows:\n- ans = [nums[0],nums[1],nums[2],nums[3],nums[0],nums[1],nums[2],nums[3]]\n- ans = [1,3,2,1,1,3,2,1]\n\n \nConstraints:\n\nn == nums.length\n1 <= n <= 1000\n1 <= nums[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7]) == [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [5, 6, 7]) == [5, 6, 7, 5, 6, 7]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [7, 7, 7, 7, 7, 7]) == [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [1, 2, 1]) == [1, 2, 1, 1, 2, 1]\n assert candidate(nums = [1000, 999, 998, 997, 996]) == [1000, 999, 998, 997, 996, 1000, 999, 998, 997, 996]\n assert candidate(nums = [1, 1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [999, 1000]) == [999, 1000, 999, 1000]\n assert candidate(nums = [1, 3, 2, 1]) == [1, 3, 2, 1, 1, 3, 2, 1]\n assert candidate(nums = [10, 20, 30, 40, 50]) == [10, 20, 30, 40, 50, 10, 20, 30, 40, 50]\n assert candidate(nums = [999, 1000, 999, 1000]) == [999, 1000, 999, 1000, 999, 1000, 999, 1000]\n assert candidate(nums = [5, 6, 7, 8, 9]) == [5, 6, 7, 8, 9, 5, 6, 7, 8, 9]\n assert candidate(nums = [5]) == [5, 5]\n assert candidate(nums = [1, 1, 1, 1]) == [1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [10]) == [10, 10]\n assert candidate(nums = [999, 1, 998, 2, 997, 3, 996, 4, 995, 5, 994, 6, 993, 7, 992, 8, 991, 9, 990, 10]) == [999, 1, 998, 2, 997, 3, 996, 4, 995, 5, 994, 6, 993, 7, 992, 8, 991, 9, 990, 10, 999, 1, 998, 2, 997, 3, 996, 4, 995, 5, 994, 6, 993, 7, 992, 8, 991, 9, 990, 10]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(nums = [1, 2, 3, 2, 1, 2, 3, 2, 1]) == [1, 2, 3, 2, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1, 2, 3, 2, 1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(nums = [500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510]) == [500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510]\n assert candidate(nums = [1000, 1, 999, 2, 998, 3, 997, 4, 996, 5]) == [1000, 1, 999, 2, 998, 3, 997, 4, 996, 5, 1000, 1, 999, 2, 998, 3, 997, 4, 996, 5]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(nums = [500, 250, 125, 62, 31, 15, 7, 3, 1]) == [500, 250, 125, 62, 31, 15, 7, 3, 1, 500, 250, 125, 62, 31, 15, 7, 3, 1]\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630]) == [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630, 42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630]\n assert candidate(nums = [10, 200, 3000, 40000, 500000, 6, 7, 8, 9, 10]) == [10, 200, 3000, 40000, 500000, 6, 7, 8, 9, 10, 10, 200, 3000, 40000, 500000, 6, 7, 8, 9, 10]\n assert candidate(nums = [1000, 1, 200, 2, 300, 3, 400, 4]) == [1000, 1, 200, 2, 300, 3, 400, 4, 1000, 1, 200, 2, 300, 3, 400, 4]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145]\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]) == [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [9, 8, 7, 6, 5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209]) == [10, 21, 32, 43, 54, 65, 76, 87, 98, 109, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209, 10, 21, 32, 43, 54, 65, 76, 87, 98, 109, 110, 121, 132, 143, 154, 165, 176, 187, 198, 209]\n assert candidate(nums = [999, 1000, 998, 999, 1000, 998, 999]) == [999, 1000, 998, 999, 1000, 998, 999, 999, 1000, 998, 999, 1000, 998, 999]\n assert candidate(nums = [500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1]) == [500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1, 500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666]) == [333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666, 333, 666]\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970]) == [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971, 970]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]\n assert candidate(nums = [999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 998, 997, 996, 995, 994, 993, 992, 991, 990]) == [999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 998, 997, 996, 995, 994, 993, 992, 991, 990, 999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 998, 997, 996, 995, 994, 993, 992, 991, 990]\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]) == [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]\n assert candidate(nums = [500, 250, 125, 62, 31, 15, 7, 3, 1, 0]) == [500, 250, 125, 62, 31, 15, 7, 3, 1, 0, 500, 250, 125, 62, 31, 15, 7, 3, 1, 0]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 1]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]\n assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991]) == [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991, 1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]\n assert candidate(nums = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]\n assert candidate(nums = [999, 1000, 999, 1000, 999, 1000, 999, 1000]) == [999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000, 999, 1000]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70]) == [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115]) == [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115]\n assert candidate(nums = [1000, 1, 1000, 1, 1000, 1, 1000]) == [1000, 1, 1000, 1, 1000, 1, 1000, 1000, 1, 1000, 1, 1000, 1, 1000]\n assert candidate(nums = [123, 456, 789, 101, 202, 303, 404, 505]) == [123, 456, 789, 101, 202, 303, 404, 505, 123, 456, 789, 101, 202, 303, 404, 505]\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990]) == [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990]) == [999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]) == [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 1000, 999, 998, 997, 996, 995, 994, 993, 992, 991]\n assert candidate(nums = [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630, 672, 714, 756, 798, 840]) == [42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630, 672, 714, 756, 798, 840, 42, 84, 126, 168, 210, 252, 294, 336, 378, 420, 462, 504, 546, 588, 630, 672, 714, 756, 798, 840]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().getConcatenation", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector getConcatenation(vector& nums) {", "container": "Solution", "callable": "getConcatenation", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1930, "task_id": "unique-length-3-palindromic-subsequences", "difficulty": "Medium", "problem_description": "Given a string s, return the number of unique palindromes of length three that are a subsequence of s.\nNote that even if there are multiple ways to obtain the same subsequence, it is still only counted once.\nA palindrome is a string that reads the same forwards and backwards.\nA subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remaining characters.\n\nFor example, \"ace\" is a subsequence of \"abcde\".\n\n \nExample 1:\n\nInput: s = \"aabca\"\nOutput: 3\nExplanation: The 3 palindromic subsequences of length 3 are:\n- \"aba\" (subsequence of \"aabca\")\n- \"aaa\" (subsequence of \"aabca\")\n- \"aca\" (subsequence of \"aabca\")\n\nExample 2:\n\nInput: s = \"adc\"\nOutput: 0\nExplanation: There are no palindromic subsequences of length 3 in \"adc\".\n\nExample 3:\n\nInput: s = \"bbcbaba\"\nOutput: 4\nExplanation: The 4 palindromic subsequences of length 3 are:\n- \"bbb\" (subsequence of \"bbcbaba\")\n- \"bcb\" (subsequence of \"bbcbaba\")\n- \"bab\" (subsequence of \"bbcbaba\")\n- \"aba\" (subsequence of \"bbcbaba\")\n\n \nConstraints:\n\n3 <= s.length <= 105\ns consists of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"abcba\") == 3\n assert candidate(s = \"madam\") == 3\n assert candidate(s = \"abcdedcba\") == 10\n assert candidate(s = \"aaaaa\") == 1\n assert candidate(s = \"adc\") == 0\n assert candidate(s = \"abcabcabc\") == 9\n assert candidate(s = \"abracadabra\") == 13\n assert candidate(s = \"aaa\") == 1\n assert candidate(s = \"racecar\") == 6\n assert candidate(s = \"abba\") == 1\n assert candidate(s = \"noon\") == 1\n assert candidate(s = \"abccba\") == 3\n assert candidate(s = \"aaaa\") == 1\n assert candidate(s = \"aabbcc\") == 0\n assert candidate(s = \"mississippi\") == 5\n assert candidate(s = \"aabca\") == 3\n assert candidate(s = \"bbcbaba\") == 4\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 0\n assert candidate(s = \"xyzzyx\") == 3\n assert candidate(s = \"level\") == 3\n assert candidate(s = \"abcdefg\") == 0\n assert candidate(s = \"aabacbaabacba\") == 8\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(s = \"noonmoonnoonmoonnoonmoonnoonmoonnoonmoonnoonmoonnoon\") == 9\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzyyxwwvvuuttssrrqqppoonnmmllkkjjiihhggeeffddccbbaa\") == 352\n assert candidate(s = \"zzzzzzzyyyyxxxwwvvuttsrrqqppoonnmmllkkjjiihhggffeeddccba\") == 3\n assert candidate(s = \"zzzazzaaz\") == 4\n assert candidate(s = \"abacabadabacaba\") == 11\n assert candidate(s = \"ababababababababababababababababababababab\") == 4\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\") == 9\n assert candidate(s = \"ababcab\") == 6\n assert candidate(s = \"abacabadabacabadabacabadabacabad\") == 16\n assert candidate(s = \"racecarcarcarecarracecarcarcarecarracecarcarcarecarracecar\") == 16\n assert candidate(s = \"abacdfgdcaba\") == 16\n assert candidate(s = \"aabbbaaabbbaaa\") == 4\n assert candidate(s = \"aaabaaaabaaaaabaaaabaaaaaabaaaa\") == 4\n assert candidate(s = \"aaaabaaaabaaaab\") == 4\n assert candidate(s = \"abcbabcbabcbabcbabcbabcbabcba\") == 9\n assert candidate(s = \"bababababababababababababababababababababa\") == 4\n assert candidate(s = \"abcbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbacbac\") == 9\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == 4\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 325\n assert candidate(s = \"xyzyxyzyxyzyx\") == 9\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 650\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbaedcba\") == 20\n assert candidate(s = \"abbaabbbaabbaabbbaabbaabbbaabbaabbbaabbaabbba\") == 4\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 9\n assert candidate(s = \"abcdefghihgfedcbaabcdefghihgfedcba\") == 80\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == 26\n assert candidate(s = \"aaabaaaabaaaabaaaabaaaabaaaabaaaabaaaabaaaab\") == 4\n assert candidate(s = \"abcbacbacbacbacbacbacbacbacbacbacbacbacb\") == 9\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(s = \"babababababababababababababababababababababababababababababa\") == 4\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabba\") == 4\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzzzz\") == 26\n assert candidate(s = \"mamamadadadmmadammaddada\") == 9\n assert candidate(s = \"aabbccddeeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 1\n assert candidate(s = \"ababababababababababababababababababababababababababab\") == 4\n assert candidate(s = \"aaaaaaaaaaaabbbbbbbbbbbbccccccccccdddddddddd\") == 4\n assert candidate(s = \"racecarcarcarecarracecarcarcarecarracecar\") == 16\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 9\n assert candidate(s = \"abacbacbacbacba\") == 9\n assert candidate(s = \"ababababababababababababababababababababababababababababababab\") == 4\n assert candidate(s = \"mississippississippiississippiississippiississippiississippi\") == 9\n assert candidate(s = \"abcabcabcabcabc\") == 9\n assert candidate(s = \"noonmoonnoonmoon\") == 8\n assert candidate(s = \"noonmoonnoonmoonnoonmoonnoonmoonnoonmoonnoonmoonnoonnoonmoon\") == 9\n assert candidate(s = \"aaaaabbbbbccccc\") == 3\n assert candidate(s = \"mississippississippiississippiississippiississippi\") == 9\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabad\") == 16\n assert candidate(s = \"zzzzzyyyxxwwvvuttsrrqqppoonnmmllkkjjiihhggffeeddccba\") == 2\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 9\n assert candidate(s = \"aabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabbaabba\") == 4\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().countPalindromicSubsequence", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countPalindromicSubsequence(string s) {", "container": "Solution", "callable": "countPalindromicSubsequence", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1931, "task_id": "painting-a-grid-with-three-different-colors", "difficulty": "Hard", "problem_description": "You are given two integers m and n. Consider an m x n grid where each cell is initially white. You can paint each cell red, green, or blue. All cells must be painted.\nReturn the number of ways to color the grid with no two adjacent cells having the same color. Since the answer can be very large, return it modulo 109 + 7.\n \nExample 1:\n\n\nInput: m = 1, n = 1\nOutput: 3\nExplanation: The three possible colorings are shown in the image above.\n\nExample 2:\n\n\nInput: m = 1, n = 2\nOutput: 6\nExplanation: The six possible colorings are shown in the image above.\n\nExample 3:\n\nInput: m = 5, n = 5\nOutput: 580986\n\n \nConstraints:\n\n1 <= m <= 5\n1 <= n <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(m = 2,n = 4) == 162\n assert candidate(m = 4,n = 3) == 1122\n assert candidate(m = 5,n = 1) == 48\n assert candidate(m = 1,n = 2) == 6\n assert candidate(m = 5,n = 5) == 580986\n assert candidate(m = 3,n = 4) == 1122\n assert candidate(m = 1,n = 1) == 3\n assert candidate(m = 4,n = 2) == 162\n assert candidate(m = 3,n = 3) == 246\n assert candidate(m = 2,n = 3) == 54\n assert candidate(m = 5,n = 800) == 253729951\n assert candidate(m = 4,n = 4) == 7812\n assert candidate(m = 2,n = 800) == 351341125\n assert candidate(m = 5,n = 500) == 859596253\n assert candidate(m = 5,n = 250) == 385854418\n assert candidate(m = 1,n = 1000) == 32634808\n assert candidate(m = 4,n = 350) == 47085356\n assert candidate(m = 3,n = 10) == 10107954\n assert candidate(m = 4,n = 500) == 614795573\n assert candidate(m = 1,n = 5) == 48\n assert candidate(m = 1,n = 500) == 85724507\n assert candidate(m = 3,n = 50) == 151149117\n assert candidate(m = 4,n = 600) == 643128638\n assert candidate(m = 4,n = 750) == 346928514\n assert candidate(m = 3,n = 500) == 350959293\n assert candidate(m = 2,n = 100) == 772083415\n assert candidate(m = 5,n = 2) == 486\n assert candidate(m = 2,n = 900) == 360544652\n assert candidate(m = 2,n = 2) == 18\n assert candidate(m = 4,n = 1000) == 281273229\n assert candidate(m = 4,n = 998) == 16509421\n assert candidate(m = 3,n = 7) == 106494\n assert candidate(m = 3,n = 1000) == 650420578\n assert candidate(m = 5,n = 50) == 597561939\n assert candidate(m = 4,n = 100) == 80216004\n assert candidate(m = 4,n = 10) == 896895828\n assert candidate(m = 4,n = 999) == 772309689\n assert candidate(m = 4,n = 6) == 379602\n assert candidate(m = 2,n = 999) == 37925462\n assert candidate(m = 5,n = 100) == 714933866\n assert candidate(m = 2,n = 600) == 138487123\n assert candidate(m = 3,n = 1) == 12\n assert candidate(m = 5,n = 10) == 796884854\n assert candidate(m = 3,n = 800) == 314710698\n assert candidate(m = 4,n = 5) == 54450\n assert candidate(m = 5,n = 200) == 55054779\n assert candidate(m = 3,n = 750) == 493513580\n assert candidate(m = 5,n = 997) == 582030758\n assert candidate(m = 3,n = 900) == 999754739\n assert candidate(m = 3,n = 700) == 360760626\n assert candidate(m = 5,n = 300) == 194398079\n assert candidate(m = 4,n = 9) == 128643282\n assert candidate(m = 2,n = 1000) == 113776386\n assert candidate(m = 4,n = 700) == 795691966\n assert candidate(m = 4,n = 250) == 727847864\n assert candidate(m = 5,n = 3) == 5118\n assert candidate(m = 4,n = 800) == 197304781\n assert candidate(m = 3,n = 300) == 748221310\n assert candidate(m = 5,n = 1000) == 408208448\n assert candidate(m = 3,n = 20) == 690883140\n assert candidate(m = 2,n = 5) == 486\n"}, "metadata": {"canonical_parameter_names": ["m", "n"], "leetcode_dataset_entry_point": "Solution().colorTheGrid", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int colorTheGrid(int m, int n) {", "container": "Solution", "callable": "colorTheGrid", "parameters": [{"name": "m", "type": "int"}, {"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1935, "task_id": "maximum-number-of-words-you-can-type", "difficulty": "Easy", "problem_description": "There is a malfunctioning keyboard where some letter keys do not work. All other keys on the keyboard work properly.\nGiven a string text of words separated by a single space (no leading or trailing spaces) and a string brokenLetters of all distinct letter keys that are broken, return the number of words in text you can fully type using this keyboard.\n \nExample 1:\n\nInput: text = \"hello world\", brokenLetters = \"ad\"\nOutput: 1\nExplanation: We cannot type \"world\" because the 'd' key is broken.\n\nExample 2:\n\nInput: text = \"leet code\", brokenLetters = \"lt\"\nOutput: 1\nExplanation: We cannot type \"leet\" because the 'l' and 't' keys are broken.\n\nExample 3:\n\nInput: text = \"leet code\", brokenLetters = \"e\"\nOutput: 0\nExplanation: We cannot type either word because the 'e' key is broken.\n\n \nConstraints:\n\n1 <= text.length <= 104\n0 <= brokenLetters.length <= 26\ntext consists of words separated by a single space without any leading or trailing spaces.\nEach word only consists of lowercase English letters.\nbrokenLetters consists of distinct lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(text = \"jumped over the lazy dog\",brokenLetters = \"zg\") == 3\n assert candidate(text = \"nopqrstuvwxyz\",brokenLetters = \"xyz\") == 0\n assert candidate(text = \"xyzzzz\",brokenLetters = \"x\") == 0\n assert candidate(text = \"leet code\",brokenLetters = \"lt\") == 1\n assert candidate(text = \"programming is fun\",brokenLetters = \"fn\") == 1\n assert candidate(text = \"this is a test\",brokenLetters = \"xyz\") == 4\n assert candidate(text = \"mississippi\",brokenLetters = \"sip\") == 0\n assert candidate(text = \"python java cplusplus\",brokenLetters = \"ypx\") == 1\n assert candidate(text = \"same same same\",brokenLetters = \"aem\") == 0\n assert candidate(text = \"a b c d e\",brokenLetters = \"\") == 5\n assert candidate(text = \"aa bb cc dd ee ff gg hh ii jj kk ll mm nn oo pp qq rr ss tt uu vv ww xx yy zz\",brokenLetters = \"xyz\") == 23\n assert candidate(text = \"abcdefghijk\",brokenLetters = \"abcde\") == 0\n assert candidate(text = \"leet code\",brokenLetters = \"e\") == 0\n assert candidate(text = \"single\",brokenLetters = \"s\") == 0\n assert candidate(text = \"unique words\",brokenLetters = \"\") == 2\n assert candidate(text = \"single\",brokenLetters = \"\") == 1\n assert candidate(text = \"abc def ghi\",brokenLetters = \"xyz\") == 3\n assert candidate(text = \"python programming\",brokenLetters = \"p\") == 0\n assert candidate(text = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",brokenLetters = \"\") == 26\n assert candidate(text = \"a quick brown fox\",brokenLetters = \"\") == 4\n assert candidate(text = \"abcd efgh ijkl mnop qrst uvwx yz\",brokenLetters = \"aeiou\") == 2\n assert candidate(text = \"python programming\",brokenLetters = \"th\") == 1\n assert candidate(text = \"abcdefghij\",brokenLetters = \"\") == 1\n assert candidate(text = \"hello hello hello\",brokenLetters = \"lo\") == 0\n assert candidate(text = \"hello world\",brokenLetters = \"ad\") == 1\n assert candidate(text = \"every good boy does fine\",brokenLetters = \"f\") == 4\n assert candidate(text = \"hello world abcdefghijklmnopqrstuvwxyz\",brokenLetters = \"\") == 3\n assert candidate(text = \"a b c d e f g\",brokenLetters = \"xyz\") == 7\n assert candidate(text = \"extreme example with all letters\",brokenLetters = \"abcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(text = \"this is a simple test\",brokenLetters = \"sti\") == 1\n assert candidate(text = \"singleword\",brokenLetters = \"w\") == 0\n assert candidate(text = \"abcdefghij klmnopqrstuvwxyz\",brokenLetters = \"xyz\") == 1\n assert candidate(text = \"university of california berkeley\",brokenLetters = \"bcdfg\") == 1\n assert candidate(text = \"congratulations on your success\",brokenLetters = \"cns\") == 1\n assert candidate(text = \"every good boy does fine\",brokenLetters = \"bd\") == 2\n assert candidate(text = \"hello world from the other side\",brokenLetters = \"dfr\") == 2\n assert candidate(text = \"complexity arises from multiple factors\",brokenLetters = \"ae\") == 1\n assert candidate(text = \"all the letters of the alphabet\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"keyboard malfunctioning example\",brokenLetters = \"kmb\") == 0\n assert candidate(text = \"short long longer longestword\",brokenLetters = \"nlg\") == 1\n assert candidate(text = \"repeated letters letters letters\",brokenLetters = \"r\") == 0\n assert candidate(text = \"quick brown fox jumps over the lazy dog\",brokenLetters = \"xyz\") == 6\n assert candidate(text = \"data structures and algorithms\",brokenLetters = \"dts\") == 0\n assert candidate(text = \"abcdef ghijklm nopqrst uvwxyz\",brokenLetters = \"mnop\") == 2\n assert candidate(text = \"multiple broken letters test\",brokenLetters = \"mlpt\") == 1\n assert candidate(text = \"abcdefghij klmnopqrstuvwxyz\",brokenLetters = \"jkl\") == 0\n assert candidate(text = \"mississippi river\",brokenLetters = \"is\") == 0\n assert candidate(text = \"no broken letters here\",brokenLetters = \"qwxz\") == 4\n assert candidate(text = \"programming is fun\",brokenLetters = \"funs\") == 0\n assert candidate(text = \"all unique characters\",brokenLetters = \"\") == 3\n assert candidate(text = \"quick brown fox jumps over the lazy dog\",brokenLetters = \"\") == 8\n assert candidate(text = \"hello world hello universe\",brokenLetters = \"d\") == 3\n assert candidate(text = \"supercalifragilisticexpialidocious\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"special symbols are not included !@#$%^&*()\",brokenLetters = \"\") == 6\n assert candidate(text = \"brokenkeyboard faultydevice\",brokenLetters = \"bdf\") == 0\n assert candidate(text = \"sequential typing test\",brokenLetters = \"qseq\") == 1\n assert candidate(text = \"unique letters in words\",brokenLetters = \"aeiouy\") == 0\n assert candidate(text = \"python code implementation\",brokenLetters = \"py\") == 1\n assert candidate(text = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",brokenLetters = \"qz\") == 24\n assert candidate(text = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",brokenLetters = \"abcdefghijkl\") == 14\n assert candidate(text = \"complex words like supercalifragilisticexpialidocious\",brokenLetters = \"xyz\") == 2\n assert candidate(text = \"this is a simple test case\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"one two three four five six seven eight nine ten\",brokenLetters = \"on\") == 4\n assert candidate(text = \"lets write some code\",brokenLetters = \"wrs\") == 1\n assert candidate(text = \"multiple broken letters scenario\",brokenLetters = \"aeiouy\") == 0\n assert candidate(text = \"complex problem solving required\",brokenLetters = \"abc\") == 2\n assert candidate(text = \"this is a simple test\",brokenLetters = \"s\") == 1\n assert candidate(text = \"all characters must be checked\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"quick brown fox jumps over lazy dog\",brokenLetters = \"qz\") == 5\n assert candidate(text = \"various broken keys test\",brokenLetters = \"var\") == 2\n assert candidate(text = \"quick brown fox jumps over the lazy dog\",brokenLetters = \"qz\") == 6\n assert candidate(text = \"a quick brown fox jumps over the lazy dog\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"beautiful scenery on the mountain top\",brokenLetters = \"mnt\") == 0\n assert candidate(text = \"vowels are often omitted\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"mississippi river flows smoothly\",brokenLetters = \"m\") == 2\n assert candidate(text = \"hello world from another dimension\",brokenLetters = \"ad\") == 2\n assert candidate(text = \"singlewordwithoutspaces\",brokenLetters = \"s\") == 0\n assert candidate(text = \"abcdefghijklmnopqrstuvwxyz\",brokenLetters = \"xyz\") == 0\n assert candidate(text = \"fuzzy wuzzy was a bear\",brokenLetters = \"f\") == 4\n assert candidate(text = \"algorithms and data structures\",brokenLetters = \"da\") == 1\n assert candidate(text = \"make america great again\",brokenLetters = \"mag\") == 0\n assert candidate(text = \"hello hello hello world\",brokenLetters = \"d\") == 3\n assert candidate(text = \"a aa aaa aaaa aaaaa\",brokenLetters = \"a\") == 0\n assert candidate(text = \"mississippi river\",brokenLetters = \"m\") == 1\n assert candidate(text = \"many many words with many repeated letters\",brokenLetters = \"mny\") == 4\n assert candidate(text = \"abcdefghijklmnopqrstuvwxyz abcdefghijklmnopqrstuvwxyz\",brokenLetters = \"\") == 2\n assert candidate(text = \"special characters are not considered\",brokenLetters = \"!@#$%^&*()\") == 5\n assert candidate(text = \"alibaba cloud is amazing\",brokenLetters = \"aim\") == 1\n assert candidate(text = \"boundary conditions and edge cases\",brokenLetters = \"bace\") == 0\n assert candidate(text = \"the quick brown fox jumps over the lazy dog\",brokenLetters = \"\") == 9\n assert candidate(text = \"algorithm data structures\",brokenLetters = \"abcde\") == 0\n assert candidate(text = \"xylophone xylophone xylophone\",brokenLetters = \"xy\") == 0\n assert candidate(text = \"complex problem solving\",brokenLetters = \"cps\") == 0\n assert candidate(text = \"longer words with various letters\",brokenLetters = \"wv\") == 2\n assert candidate(text = \"every good boy does fine\",brokenLetters = \"boyd\") == 1\n assert candidate(text = \"the quick brown fox jumps over the lazy dog\",brokenLetters = \"qxyz\") == 6\n assert candidate(text = \"programming in python is fun\",brokenLetters = \"pqf\") == 2\n assert candidate(text = \"this is a test case with many words\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"repeated letters in words\",brokenLetters = \"r\") == 1\n assert candidate(text = \"mississippi river\",brokenLetters = \"r\") == 1\n assert candidate(text = \"edge cases require attention\",brokenLetters = \"ecr\") == 0\n assert candidate(text = \"short words\",brokenLetters = \"aef\") == 2\n assert candidate(text = \"all characters are broken here\",brokenLetters = \"abcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(text = \"this is a simple test\",brokenLetters = \"st\") == 1\n assert candidate(text = \"multiple words with repeated letters\",brokenLetters = \"w\") == 3\n assert candidate(text = \"python is a versatile programming language\",brokenLetters = \"p\") == 4\n assert candidate(text = \"this is a simple test case\",brokenLetters = \"\") == 6\n assert candidate(text = \"short words\",brokenLetters = \"ow\") == 0\n assert candidate(text = \"distinct distinct letters letters\",brokenLetters = \"distnl\") == 0\n assert candidate(text = \"the quick brown fox jumps over the lazy dog\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"let us escape from this困境\",brokenLetters = \"et\") == 2\n assert candidate(text = \"broken keyboards are annoying sometimes\",brokenLetters = \"bks\") == 2\n assert candidate(text = \"various combinations\",brokenLetters = \"vbc\") == 0\n assert candidate(text = \"every good boy does fine and gets chocolate\",brokenLetters = \"xyz\") == 6\n assert candidate(text = \"hello world from mars\",brokenLetters = \"mr\") == 1\n assert candidate(text = \"various punctuations are missing\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"quick brown fox jumps over the lazy dog\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"unique words in this sentence\",brokenLetters = \"uie\") == 1\n assert candidate(text = \"multiple words with repeated letters\",brokenLetters = \"r\") == 2\n assert candidate(text = \"one two three four five\",brokenLetters = \"one\") == 0\n assert candidate(text = \"computer science\",brokenLetters = \"xyz\") == 2\n assert candidate(text = \"this is a simple test case\",brokenLetters = \"s\") == 1\n assert candidate(text = \"multiple spaces between words are not allowed\",brokenLetters = \"\") == 7\n assert candidate(text = \"special characters !@#$%^&*()\",brokenLetters = \"s\") == 1\n assert candidate(text = \"banana apple orange\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"abcdefghijklmnopqrstuvwxyz\",brokenLetters = \"nopqrstuvwxyz\") == 0\n assert candidate(text = \"abcdef ghijklm nopqrstuvwxyz\",brokenLetters = \"aeiou\") == 0\n assert candidate(text = \"spaceship traveling fast\",brokenLetters = \"spfc\") == 1\n assert candidate(text = \"unique characters only\",brokenLetters = \"uqnc\") == 0\n assert candidate(text = \"every good boy does fine\",brokenLetters = \"egbf\") == 0\n assert candidate(text = \"repeated repeated words words\",brokenLetters = \"dpw\") == 0\n assert candidate(text = \"abcdefghijklmnopqrstuvwxy z\",brokenLetters = \"z\") == 1\n assert candidate(text = \"complex problems require careful thought\",brokenLetters = \"th\") == 4\n assert candidate(text = \"all words can be typed\",brokenLetters = \"\") == 5\n assert candidate(text = \"abcdefg hijklm nopqrstuvwxyz\",brokenLetters = \"xyz\") == 2\n"}, "metadata": {"canonical_parameter_names": ["text", "brokenLetters"], "leetcode_dataset_entry_point": "Solution().canBeTypedWords", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int canBeTypedWords(string text, string brokenLetters) {", "container": "Solution", "callable": "canBeTypedWords", "parameters": [{"name": "text", "type": "string"}, {"name": "brokenLetters", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1936, "task_id": "add-minimum-number-of-rungs", "difficulty": "Medium", "problem_description": "You are given a strictly increasing integer array rungs that represents the height of rungs on a ladder. You are currently on the floor at height 0, and you want to reach the last rung.\nYou are also given an integer dist. You can only climb to the next highest rung if the distance between where you are currently at (the floor or on a rung) and the next rung is at most dist. You are able to insert rungs at any positive integer height if a rung is not already there.\nReturn the minimum number of rungs that must be added to the ladder in order for you to climb to the last rung.\n \nExample 1:\n\nInput: rungs = [1,3,5,10], dist = 2\nOutput: 2\nExplanation:\nYou currently cannot reach the last rung.\nAdd rungs at heights 7 and 8 to climb this ladder. \nThe ladder will now have rungs at [1,3,5,7,8,10].\n\nExample 2:\n\nInput: rungs = [3,6,8,10], dist = 3\nOutput: 0\nExplanation:\nThis ladder can be climbed without adding additional rungs.\n\nExample 3:\n\nInput: rungs = [3,4,6,7], dist = 2\nOutput: 1\nExplanation:\nYou currently cannot reach the first rung from the ground.\nAdd a rung at height 1 to climb this ladder.\nThe ladder will now have rungs at [1,3,4,6,7].\n\n \nConstraints:\n\n1 <= rungs.length <= 105\n1 <= rungs[i] <= 109\n1 <= dist <= 109\nrungs is strictly increasing.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rungs = [1, 3, 5, 10],dist = 2) == 2\n assert candidate(rungs = [1, 2, 3, 4, 5],dist = 1) == 0\n assert candidate(rungs = [3, 6, 8, 10],dist = 3) == 0\n assert candidate(rungs = [10],dist = 10) == 0\n assert candidate(rungs = [1000000000],dist = 1) == 999999999\n assert candidate(rungs = [1, 1000000000],dist = 1) == 999999998\n assert candidate(rungs = [1, 5, 11, 20],dist = 4) == 3\n assert candidate(rungs = [3, 4, 6, 7],dist = 2) == 1\n assert candidate(rungs = [5],dist = 10) == 0\n assert candidate(rungs = [1, 5, 10, 16, 23, 31, 40, 50, 61, 73, 86, 100],dist = 14) == 0\n assert candidate(rungs = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],dist = 1) == 89\n assert candidate(rungs = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],dist = 10) == 0\n assert candidate(rungs = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],dist = 2) == 502\n assert candidate(rungs = [2, 8, 16, 32, 64, 128],dist = 15) == 7\n assert candidate(rungs = [100, 200, 300, 400, 500],dist = 150) == 0\n assert candidate(rungs = [2, 5, 10, 20, 35, 55, 80, 110, 145, 185, 230],dist = 5) == 36\n assert candidate(rungs = [1, 8, 15, 22, 29],dist = 5) == 4\n assert candidate(rungs = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],dist = 10) == 0\n assert candidate(rungs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],dist = 15) == 0\n assert candidate(rungs = [5, 10, 20, 40, 80, 160],dist = 10) == 11\n assert candidate(rungs = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89],dist = 3) == 24\n assert candidate(rungs = [1, 7, 15, 30, 60],dist = 10) == 3\n assert candidate(rungs = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],dist = 1) == 502\n assert candidate(rungs = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023],dist = 20) == 47\n assert candidate(rungs = [10, 25, 45, 70, 100, 130, 160, 190, 220, 250],dist = 30) == 0\n assert candidate(rungs = [1, 6, 15, 30, 50],dist = 10) == 2\n assert candidate(rungs = [1, 1000000000],dist = 100000000) == 9\n assert candidate(rungs = [100, 200, 300, 400, 500],dist = 99) == 5\n assert candidate(rungs = [1, 8, 15, 22, 30],dist = 5) == 4\n assert candidate(rungs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],dist = 9) == 10\n assert candidate(rungs = [10, 15, 25, 40, 50],dist = 10) == 1\n assert candidate(rungs = [2, 5, 11, 21, 35, 50],dist = 5) == 6\n assert candidate(rungs = [5, 11, 17, 23, 29, 35, 41, 47, 53, 59],dist = 6) == 0\n assert candidate(rungs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],dist = 1) == 90\n assert candidate(rungs = [1, 1000000000],dist = 100000000) == 9\n assert candidate(rungs = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105],dist = 14) == 0\n assert candidate(rungs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],dist = 1) == 0\n assert candidate(rungs = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],dist = 50) == 0\n assert candidate(rungs = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 100],dist = 10) == 0\n assert candidate(rungs = [10, 30, 50, 70, 90, 110, 130, 150, 170, 190],dist = 20) == 0\n assert candidate(rungs = [10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105],dist = 10) == 4\n assert candidate(rungs = [5, 10, 20, 40, 80, 160],dist = 25) == 4\n assert candidate(rungs = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],dist = 1) == 10\n assert candidate(rungs = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120],dist = 4) == 21\n assert candidate(rungs = [1, 4, 10, 20, 30],dist = 5) == 3\n assert candidate(rungs = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],dist = 10) == 98\n assert candidate(rungs = [5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000],dist = 100000) == 6\n assert candidate(rungs = [3, 15, 25, 30, 45, 60, 85, 100],dist = 12) == 5\n assert candidate(rungs = [1, 3, 6, 10, 15, 21, 28],dist = 3) == 5\n assert candidate(rungs = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],dist = 100) == 8\n assert candidate(rungs = [2, 6, 10, 14, 18, 22, 26],dist = 4) == 0\n assert candidate(rungs = [100, 200, 300, 400, 500],dist = 90) == 5\n assert candidate(rungs = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],dist = 100000) == 9995\n assert candidate(rungs = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576],dist = 1024) == 1013\n assert candidate(rungs = [5, 11, 19, 29, 41, 55, 71, 89, 109, 131],dist = 6) == 15\n assert candidate(rungs = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],dist = 9) == 9\n assert candidate(rungs = [2, 8, 14, 20, 26, 32, 38, 44, 50],dist = 6) == 0\n assert candidate(rungs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],dist = 3) == 0\n assert candidate(rungs = [1, 2, 4, 7, 13, 21],dist = 3) == 3\n assert candidate(rungs = [1000000000],dist = 500000000) == 1\n assert candidate(rungs = [1, 5, 15, 30, 50, 70, 100, 150, 200, 300],dist = 25) == 6\n assert candidate(rungs = [2, 8, 14, 22, 30, 40, 50],dist = 6) == 4\n assert candidate(rungs = [1, 1000000000],dist = 1) == 999999998\n assert candidate(rungs = [1, 100, 200, 300],dist = 50) == 3\n assert candidate(rungs = [3, 15, 35, 65, 100, 145, 195, 250, 310, 375],dist = 10) == 31\n assert candidate(rungs = [10, 25, 45, 60, 75, 90],dist = 15) == 1\n assert candidate(rungs = [10, 25, 45, 70, 100],dist = 15) == 3\n assert candidate(rungs = [1, 1000000000],dist = 500000000) == 1\n assert candidate(rungs = [5, 12, 24, 40, 60, 85, 100],dist = 10) == 6\n assert candidate(rungs = [1, 1000000000],dist = 1000000) == 999\n assert candidate(rungs = [2, 5, 9, 14, 20, 27, 35, 44, 54, 65],dist = 4) == 10\n assert candidate(rungs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],dist = 2) == 0\n assert candidate(rungs = [1, 9, 15, 25, 30],dist = 5) == 3\n assert candidate(rungs = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],dist = 9) == 0\n assert candidate(rungs = [2, 8, 18, 32, 50, 72, 98],dist = 15) == 3\n assert candidate(rungs = [10, 20, 40, 80, 160, 320, 640, 1280, 2560, 5120],dist = 500) == 8\n assert candidate(rungs = [5, 10, 20, 40, 80, 160],dist = 10) == 11\n assert candidate(rungs = [1, 6, 11, 16, 21, 26],dist = 5) == 0\n assert candidate(rungs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],dist = 10) == 0\n assert candidate(rungs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],dist = 2) == 0\n assert candidate(rungs = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],dist = 5) == 5\n assert candidate(rungs = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],dist = 1000000) == 996\n assert candidate(rungs = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],dist = 3) == 0\n assert candidate(rungs = [1000000000],dist = 100000000) == 9\n assert candidate(rungs = [1, 1000000000],dist = 500000000) == 1\n assert candidate(rungs = [10, 1000000000],dist = 500000000) == 1\n assert candidate(rungs = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],dist = 9) == 9\n assert candidate(rungs = [1, 2, 4, 7, 11, 16, 22, 29, 37, 46, 56, 67, 79, 92, 106],dist = 5) == 13\n assert candidate(rungs = [2, 3, 6, 8, 15, 22, 30, 35, 40, 50],dist = 5) == 4\n assert candidate(rungs = [3, 9, 12, 21, 23, 29, 30],dist = 6) == 1\n assert candidate(rungs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],dist = 2) == 0\n assert candidate(rungs = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55],dist = 3) == 12\n assert candidate(rungs = [1, 10, 15, 20, 25, 30],dist = 5) == 1\n assert candidate(rungs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],dist = 15) == 0\n assert candidate(rungs = [5, 12, 22, 35, 50, 68, 89, 113, 141, 173, 209],dist = 7) == 23\n assert candidate(rungs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],dist = 1) == 0\n assert candidate(rungs = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],dist = 1) == 10\n assert candidate(rungs = [1, 2, 4, 8, 16, 32, 64],dist = 15) == 3\n assert candidate(rungs = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89],dist = 2) == 38\n assert candidate(rungs = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],dist = 9) == 10\n assert candidate(rungs = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],dist = 1000000) == 996\n assert candidate(rungs = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],dist = 100) == 8\n"}, "metadata": {"canonical_parameter_names": ["rungs", "dist"], "leetcode_dataset_entry_point": "Solution().addRungs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int addRungs(vector& rungs, int dist) {", "container": "Solution", "callable": "addRungs", "parameters": [{"name": "rungs", "type": "vector&"}, {"name": "dist", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1937, "task_id": "maximum-number-of-points-with-cost", "difficulty": "Medium", "problem_description": "You are given an m x n integer matrix points (0-indexed). Starting with 0 points, you want to maximize the number of points you can get from the matrix.\nTo gain points, you must pick one cell in each row. Picking the cell at coordinates (r, c) will add points[r][c] to your score.\nHowever, you will lose points if you pick a cell too far from the cell that you picked in the previous row. For every two adjacent rows r and r + 1 (where 0 <= r < m - 1), picking cells at coordinates (r, c1) and (r + 1, c2) will subtract abs(c1 - c2) from your score.\nReturn the maximum number of points you can achieve.\nabs(x) is defined as:\n\nx for x >= 0.\n-x for x < 0.\n\n \nExample 1: \n\n\nInput: points = [[1,2,3],[1,5,1],[3,1,1]]\nOutput: 9\nExplanation:\nThe blue cells denote the optimal cells to pick, which have coordinates (0, 2), (1, 1), and (2, 0).\nYou add 3 + 5 + 3 = 11 to your score.\nHowever, you must subtract abs(2 - 1) + abs(1 - 0) = 2 from your score.\nYour final score is 11 - 2 = 9.\n\nExample 2:\n\n\nInput: points = [[1,5],[2,3],[4,2]]\nOutput: 11\nExplanation:\nThe blue cells denote the optimal cells to pick, which have coordinates (0, 1), (1, 1), and (2, 0).\nYou add 5 + 3 + 4 = 12 to your score.\nHowever, you must subtract abs(1 - 1) + abs(1 - 0) = 1 from your score.\nYour final score is 12 - 1 = 11.\n\n \nConstraints:\n\nm == points.length\nn == points[r].length\n1 <= m, n <= 105\n1 <= m * n <= 105\n0 <= points[r][c] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(points = [[5, 10], [10, 5]]) == 19\n assert candidate(points = [[5, 2], [1, 2]]) == 6\n assert candidate(points = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1], [1, 3, 5, 7, 9]]) == 15\n assert candidate(points = [[1, 2, 3], [1, 5, 1], [3, 1, 1]]) == 9\n assert candidate(points = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1]]) == 6\n assert candidate(points = [[1, 5], [2, 3], [4, 2]]) == 11\n assert candidate(points = [[1]]) == 1\n assert candidate(points = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 15\n assert candidate(points = [[5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]]) == 25\n assert candidate(points = [[5, 3, 8, 6, 7, 2], [9, 4, 1, 5, 3, 8], [2, 6, 4, 9, 1, 5], [7, 3, 5, 2, 8, 6]]) == 28\n assert candidate(points = [[1, 3, 2], [4, 6, 5], [7, 9, 8], [10, 12, 11], [13, 15, 14]]) == 45\n assert candidate(points = [[1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1]]) == 15\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 2, 4, 6, 8, 10], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]) == 121\n assert candidate(points = [[9, 5, 3, 1, 7], [2, 8, 6, 4, 0], [5, 1, 9, 3, 6], [4, 7, 2, 8, 5], [3, 6, 4, 1, 9]]) == 39\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]]) == 21\n assert candidate(points = [[9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]]) == 28\n assert candidate(points = [[5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 20\n assert candidate(points = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 0\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]]) == 40\n assert candidate(points = [[5, 10, 15, 20, 25], [25, 20, 15, 10, 5], [5, 5, 5, 5, 5], [10, 15, 20, 25, 30], [30, 25, 20, 15, 10]]) == 103\n assert candidate(points = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 12\n assert candidate(points = [[10, 20, 30, 40, 50, 60, 70], [70, 60, 50, 40, 30, 20, 10], [10, 70, 20, 60, 30, 50, 40]]) == 203\n assert candidate(points = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 40\n assert candidate(points = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(points = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [1, 3, 5, 7, 9], [9, 7, 5, 3, 1]]) == 106\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 4, 6, 8, 10, 9, 7, 5, 3, 1]]) == 21\n assert candidate(points = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]]) == 51\n assert candidate(points = [[5, 3, 1, 4], [3, 1, 4, 5], [1, 4, 5, 3], [4, 5, 3, 1]]) == 17\n assert candidate(points = [[5, 3, 8, 6], [2, 4, 7, 1], [3, 6, 9, 2], [8, 5, 2, 4]]) == 30\n assert candidate(points = [[9, 1, 5, 3, 7], [3, 9, 1, 5, 3], [7, 3, 9, 1, 5], [5, 7, 3, 9, 1], [1, 5, 7, 3, 9]]) == 41\n assert candidate(points = [[5, 2, 3, 1, 4], [1, 3, 2, 5, 4], [3, 4, 5, 2, 1], [4, 1, 2, 3, 5], [2, 5, 4, 1, 3]]) == 18\n assert candidate(points = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4], [5, 5, 5, 5]]) == 15\n assert candidate(points = [[10, 20, 30], [40, 50, 60], [70, 80, 90]]) == 180\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]]) == 45\n assert candidate(points = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 0\n assert candidate(points = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 5\n assert candidate(points = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]]) == 50\n assert candidate(points = [[1, 2, 3, 4, 5, 6], [6, 5, 4, 3, 2, 1], [1, 6, 2, 5, 3, 4]]) == 13\n assert candidate(points = [[9, 8, 7, 6, 5], [4, 3, 2, 1, 0], [0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [9, 8, 7, 6, 5]]) == 27\n assert candidate(points = [[50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50]]) == 250\n assert candidate(points = [[100000, 100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000, 100000]]) == 300000\n assert candidate(points = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [9, 1, 9, 1, 9, 1, 9, 1, 9], [1, 9, 1, 9, 1, 9, 1, 9, 1]]) == 27\n assert candidate(points = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 100], [100, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 100, 0], [0, 0, 0, 0, 0, 0, 0, 100, 0, 0], [0, 0, 0, 0, 0, 0, 100, 0, 0, 0]]) == 481\n assert candidate(points = [[100, 200, 300, 400, 500], [90, 80, 70, 60, 50], [10, 20, 30, 40, 50], [5, 15, 25, 35, 45]]) == 677\n assert candidate(points = [[1, 10, 2, 9, 3, 8, 4, 7, 5, 6], [10, 1, 9, 2, 8, 3, 7, 4, 6, 5], [5, 6, 4, 7, 3, 8, 2, 9, 1, 10]]) == 24\n assert candidate(points = [[10, 10, 10, 10, 10], [1, 1, 1, 1, 1], [9, 9, 9, 9, 9], [2, 2, 2, 2, 2]]) == 22\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]]) == 30\n assert candidate(points = [[1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1], [1, 2], [2, 1]]) == 12\n assert candidate(points = [[10, 6, 3, 9, 7], [1, 4, 5, 8, 2], [9, 7, 4, 3, 6], [2, 8, 1, 5, 9]]) == 31\n assert candidate(points = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]]) == 110\n assert candidate(points = [[100, 100, 100], [100, 100, 100], [100, 100, 100], [100, 100, 100], [100, 100, 100]]) == 500\n assert candidate(points = [[5, 3, 8, 6, 2, 9], [1, 7, 4, 8, 5, 3], [6, 2, 9, 4, 8, 1], [3, 6, 5, 7, 2, 8]]) == 29\n assert candidate(points = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 50, 10, 50, 10], [50, 10, 50, 10, 50], [10, 20, 30, 40, 50]]) == 242\n assert candidate(points = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 4\n assert candidate(points = [[1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7], [7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13]]) == 22\n assert candidate(points = [[1, 1, 1, 1, 1], [1, 2, 3, 4, 5], [5, 4, 3, 2, 1]]) == 7\n assert candidate(points = [[100000, 90000, 80000, 70000, 60000], [50000, 40000, 30000, 20000, 10000], [90000, 80000, 70000, 60000, 50000], [40000, 30000, 20000, 10000, 9000]]) == 280000\n assert candidate(points = [[90, 91, 92, 93, 94, 95, 96, 97, 98, 99], [99, 98, 97, 96, 95, 94, 93, 92, 91, 90], [90, 92, 94, 96, 98, 100, 98, 96, 94, 92]]) == 289\n assert candidate(points = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 20, 30, 40, 50, 60, 70, 80, 90], [90, 80, 70, 60, 50, 40, 30, 20, 10]]) == 182\n assert candidate(points = [[1000, 500, 250, 125], [125, 250, 500, 1000], [1000, 500, 250, 125], [125, 250, 500, 1000]]) == 3991\n assert candidate(points = [[5, 3, 1, 4, 2], [8, 6, 7, 5, 3], [0, 9, 8, 7, 6], [2, 3, 4, 5, 1]]) == 24\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [20, 18, 16, 14, 12, 10, 8, 6, 4, 2], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 42\n assert candidate(points = [[50, 50, 50, 50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]]) == 150\n assert candidate(points = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == 45\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]]) == 112\n assert candidate(points = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(points = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [20, 18, 16, 14, 12, 10, 8, 6, 4, 2]]) == 41\n assert candidate(points = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [10, 30, 50, 70, 90], [90, 70, 50, 30, 10]]) == 268\n assert candidate(points = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]]) == 10\n assert candidate(points = [[1, 0, 0, 0, 0], [0, 1, 0, 0, 0], [0, 0, 1, 0, 0], [0, 0, 0, 1, 0], [0, 0, 0, 0, 1]]) == 1\n assert candidate(points = [[5, 3, 8, 2, 1], [1, 4, 2, 3, 8], [8, 1, 4, 2, 3], [3, 8, 1, 4, 2]]) == 25\n assert candidate(points = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10], [1, 2, 3, 4, 5], [9, 8, 7, 6, 5]]) == 106\n assert candidate(points = [[100000, 100000, 100000], [100000, 100000, 100000], [100000, 100000, 100000]]) == 300000\n assert candidate(points = [[100, 200], [150, 250], [200, 150], [250, 100], [300, 50]]) == 1199\n assert candidate(points = [[100, 90, 80, 70, 60, 50, 40, 30, 20, 10], [10, 20, 30, 40, 50, 60, 70, 80, 90, 100], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 201\n assert candidate(points = [[5, 3, 1], [1, 5, 3], [3, 1, 5], [5, 3, 1], [1, 5, 3]]) == 20\n assert candidate(points = [[10, 3, 5, 1, 2], [4, 6, 7, 3, 8], [2, 9, 1, 4, 6], [5, 3, 7, 9, 1], [8, 2, 6, 4, 5]]) == 36\n assert candidate(points = [[10, 1, 3, 5, 20], [5, 10, 15, 20, 25], [25, 20, 15, 10, 5]]) == 66\n assert candidate(points = [[1, 3, 1, 5, 1, 3, 1], [3, 1, 3, 1, 3, 1, 3], [1, 5, 1, 5, 1, 5, 1], [5, 1, 5, 1, 5, 1, 5]]) == 15\n assert candidate(points = [[100, 200, 300], [300, 200, 100], [200, 300, 200], [100, 100, 100]]) == 997\n assert candidate(points = [[100, 90, 80, 70, 60], [60, 70, 80, 90, 100], [100, 100, 100, 100, 100], [1, 2, 3, 4, 5]]) == 301\n assert candidate(points = [[7, 6, 8, 5, 9, 10], [10, 9, 8, 7, 6, 5], [5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6]]) == 31\n assert candidate(points = [[10, 15, 20, 25, 30], [5, 10, 15, 20, 25], [30, 25, 20, 15, 10], [1, 2, 3, 4, 5]]) == 82\n assert candidate(points = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]]) == 32\n assert candidate(points = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 11\n assert candidate(points = [[10, 20, 30], [30, 20, 10], [20, 30, 10], [10, 20, 30], [30, 10, 20]]) == 144\n assert candidate(points = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]]) == 45\n assert candidate(points = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]) == 0\n assert candidate(points = [[10, 15, 20, 25], [25, 20, 15, 10], [10, 20, 30, 40], [40, 30, 20, 10]]) == 121\n assert candidate(points = [[7, 8, 9, 10, 11], [11, 10, 9, 8, 7], [7, 9, 11, 10, 8], [8, 10, 7, 9, 11]]) == 38\n assert candidate(points = [[5, 1, 3, 2, 4], [2, 6, 1, 4, 5], [3, 3, 5, 1, 2], [1, 2, 4, 6, 3]]) == 19\n"}, "metadata": {"canonical_parameter_names": ["points"], "leetcode_dataset_entry_point": "Solution().maxPoints", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long maxPoints(vector>& points) {", "container": "Solution", "callable": "maxPoints", "parameters": [{"name": "points", "type": "vector>&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1938, "task_id": "maximum-genetic-difference-query", "difficulty": "Hard", "problem_description": "There is a rooted tree consisting of n nodes numbered 0 to n - 1. Each node's number denotes its unique genetic value (i.e. the genetic value of node x is x). The genetic difference between two genetic values is defined as the bitwise-XOR of their values. You are given the integer array parents, where parents[i] is the parent for node i. If node x is the root of the tree, then parents[x] == -1.\nYou are also given the array queries where queries[i] = [nodei, vali]. For each query i, find the maximum genetic difference between vali and pi, where pi is the genetic value of any node that is on the path between nodei and the root (including nodei and the root). More formally, you want to maximize vali XOR pi.\nReturn an array ans where ans[i] is the answer to the ith query.\n \nExample 1:\n\n\nInput: parents = [-1,0,1,1], queries = [[0,2],[3,2],[2,5]]\nOutput: [2,3,7]\nExplanation: The queries are processed as follows:\n- [0,2]: The node with the maximum genetic difference is 0, with a difference of 2 XOR 0 = 2.\n- [3,2]: The node with the maximum genetic difference is 1, with a difference of 2 XOR 1 = 3.\n- [2,5]: The node with the maximum genetic difference is 2, with a difference of 5 XOR 2 = 7.\n\nExample 2:\n\n\nInput: parents = [3,7,-1,2,0,7,0,2], queries = [[4,6],[1,15],[0,5]]\nOutput: [6,14,7]\nExplanation: The queries are processed as follows:\n- [4,6]: The node with the maximum genetic difference is 0, with a difference of 6 XOR 0 = 6.\n- [1,15]: The node with the maximum genetic difference is 1, with a difference of 15 XOR 1 = 14.\n- [0,5]: The node with the maximum genetic difference is 2, with a difference of 5 XOR 2 = 7.\n\n \nConstraints:\n\n2 <= parents.length <= 105\n0 <= parents[i] <= parents.length - 1 for every node i that is not the root.\nparents[root] == -1\n1 <= queries.length <= 3 * 104\n0 <= nodei <= parents.length - 1\n0 <= vali <= 2 * 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(parents = [-1, 0, 0, 1, 1],queries = [[0, 3], [2, 1], [3, 4], [4, 5]]) == [3, 3, 7, 5]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3],queries = [[4, 5], [7, 10], [2, 15]]) == [5, 13, 15]\n assert candidate(parents = [3, 7, -1, 2, 0, 7, 0, 2],queries = [[4, 6], [1, 15], [0, 5]]) == [6, 14, 7]\n assert candidate(parents = [0, 0, 0, 1, 1, 2, 2, 3, 3],queries = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90]]) == [0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2],queries = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70]]) == [10, 21, 30, 43, 54, 62, 70]\n assert candidate(parents = [-1, 0, 0, 1, 1],queries = [[2, 3], [4, 4], [3, 5]]) == [3, 5, 6]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7],queries = [[8, 1], [7, 2], [6, 3], [5, 4], [4, 5], [3, 6], [2, 7], [1, 8], [0, 9]]) == [9, 7, 7, 7, 7, 7, 7, 9, 9]\n assert candidate(parents = [-1, 0, 1, 1, 3, 3],queries = [[0, 10], [5, 15], [3, 20]]) == [10, 15, 23]\n assert candidate(parents = [-1, 0, 0, 1, 1],queries = [[0, 3], [1, 2], [2, 1], [3, 4], [4, 5]]) == [3, 3, 3, 7, 5]\n assert candidate(parents = [-1, 0, 1, 1],queries = [[0, 2], [3, 2], [2, 5]]) == [2, 3, 7]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7]]) == [1, 3, 3, 7, 7, 7, 7]\n assert candidate(parents = [-1, 0, 0, 1],queries = [[0, 3], [2, 5], [3, 4]]) == [3, 7, 7]\n assert candidate(parents = [-1, 0, 1, 2, 3],queries = [[4, 1], [1, 2], [2, 3], [3, 4]]) == [5, 3, 3, 7]\n assert candidate(parents = [3, 3, -1, 0, 0],queries = [[4, 100000], [3, 100001], [2, 100002], [1, 100003], [0, 100004]]) == [0, 0, 100000, 0, 0]\n assert candidate(parents = [-1, 0, 0, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9],queries = [[0, 25], [1, 50], [2, 75], [3, 100], [4, 125], [5, 150], [6, 175], [7, 200], [8, 225], [9, 250], [10, 275], [11, 300], [12, 325], [13, 350], [14, 375], [15, 400], [16, 425], [17, 450], [18, 475], [19, 500], [20, 525], [21, 550], [22, 575], [23, 600], [24, 625], [25, 650], [26, 675], [27, 700]]) == [25, 51, 75, 103, 125, 151, 175, 207, 233, 251, 281, 301, 329, 351, 377, 415, 441, 467, 477, 502, 537, 563, 575, 603, 633, 659, 697, 703]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39]]) == [1, 3, 3, 7, 5, 6, 7, 15, 10, 14, 15, 14, 15, 14, 15, 31, 22, 26, 27, 29, 28, 28, 29, 29, 28, 31, 30, 30, 31, 30, 31, 63, 46, 50, 51, 53, 52, 52, 53]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9],queries = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90], [9, 100], [10, 110], [11, 120], [12, 130], [13, 140], [14, 150], [15, 160], [16, 170], [17, 180], [18, 190], [19, 200], [20, 210], [21, 220], [22, 230], [23, 240], [24, 250], [25, 260], [26, 270], [27, 280], [28, 290], [29, 300]]) == [10, 21, 30, 43, 54, 61, 71, 87, 90, 109, 110, 123, 142, 141, 152, 175, 186, 181, 191, 219, 212, 221, 240, 247, 253, 285, 276, 282, 318, 305]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19],queries = [[0, 100000], [1, 50000], [2, 25000], [3, 12500], [4, 6250], [5, 3125], [6, 1562], [7, 781], [8, 390], [9, 195], [10, 97], [11, 48], [12, 24], [13, 12], [14, 6], [15, 3], [16, 1], [17, 0], [18, 0], [19, 0], [0, 100000]]) == [100000, 50001, 25002, 12503, 6254, 3127, 1564, 782, 398, 202, 107, 59, 29, 14, 8, 12, 17, 17, 18, 19, 100000]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49],queries = [[0, 10000], [1, 20000], [2, 30000], [3, 40000], [4, 50000], [5, 60000], [6, 70000], [7, 80000], [8, 90000], [9, 100000], [10, 110000], [11, 120000], [12, 130000], [13, 140000], [14, 150000], [15, 160000], [16, 170000], [17, 180000], [18, 190000], [19, 200000], [20, 210000], [21, 220000], [22, 230000], [23, 240000], [24, 250000], [25, 260000], [26, 270000], [27, 280000], [28, 290000], [29, 300000], [30, 310000], [31, 320000], [32, 330000], [33, 340000], [34, 350000], [35, 360000], [36, 370000], [37, 380000], [38, 390000], [39, 400000], [40, 410000], [41, 420000], [42, 430000], [43, 440000], [44, 450000], [45, 460000], [46, 470000], [47, 480000], [48, 490000], [49, 500000]]) == [10000, 20001, 30002, 40003, 50004, 60005, 70006, 80007, 90008, 100009, 110010, 120011, 130012, 140013, 150014, 160015, 170015, 180017, 190015, 200019, 210015, 220021, 230015, 240023, 250015, 260025, 7871, 17883, 27871, 37885, 47871, 57887, 67888, 77887, 87871, 97891, 107892, 117887, 127871, 137895, 147896, 157887, 167871, 177899, 187900, 197887, 207871, 217903, 227903, 237887]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24],queries = [[0, 10101], [1, 10102], [2, 10103], [3, 10104], [4, 10105], [5, 10106], [6, 10107], [7, 10108], [8, 10109], [9, 10110], [10, 10111], [11, 10112], [12, 10113], [13, 10114], [14, 10115], [15, 10116], [16, 10117], [17, 10118], [18, 10119], [19, 10120], [20, 10121], [21, 10122], [22, 10123], [23, 10124], [24, 10125], [25, 10126], [26, 10127], [27, 10128], [28, 10129], [29, 10130], [30, 10131], [31, 10132], [32, 10133], [33, 10134], [34, 10135], [35, 10136], [36, 10137], [37, 10138], [38, 10139], [39, 10140]]) == [10101, 10103, 10103, 10107, 10109, 10111, 10109, 10111, 10110, 10111, 10111, 10123, 10125, 10127, 10125, 10123, 10133, 10135, 10133, 10139, 10141, 10143, 10141, 10139, 10133, 10135, 10133, 10141, 10140, 10140, 10141, 10139, 10165, 10167, 10165, 10171, 10173, 10175, 10173, 10171]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39],queries = [[39, 1], [38, 2], [37, 3], [36, 4], [35, 5], [34, 6], [33, 7], [32, 8], [31, 9], [30, 10], [29, 11], [28, 12], [27, 13], [26, 14], [25, 15], [24, 16], [23, 17], [22, 18], [21, 19], [20, 20], [19, 21], [18, 22], [17, 23], [16, 24], [15, 25], [14, 26], [13, 27], [12, 28], [11, 29], [10, 30], [9, 31], [8, 32], [7, 33], [6, 34], [5, 35], [4, 36], [3, 37], [2, 38], [1, 39], [0, 40]]) == [38, 36, 38, 32, 38, 36, 38, 40, 22, 20, 22, 16, 22, 20, 22, 27, 26, 24, 25, 29, 28, 30, 31, 31, 30, 28, 29, 30, 31, 31, 31, 40, 38, 36, 38, 37, 38, 38, 39, 40]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],queries = [[0, 1], [1, 3], [2, 7], [3, 15], [4, 31], [5, 63], [6, 127], [7, 255], [8, 511], [9, 1023], [10, 2047], [11, 4095], [12, 8191], [13, 16383], [14, 32767], [15, 65535]]) == [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535]\n assert candidate(parents = [-1, 0, 0, 1, 1, 3, 3, 4, 4, 5, 5],queries = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [10, 1100]]) == [100, 201, 302, 403, 501, 605, 703, 807, 908, 1005, 1103]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29],queries = [[0, 5000], [1, 5001], [2, 5002], [3, 5003], [4, 5004], [5, 5005], [6, 5006], [7, 5007], [8, 5008], [9, 5009], [10, 5010], [11, 5011], [12, 5012], [13, 5013], [14, 5014], [15, 5015], [16, 5016], [17, 5017], [18, 5018], [19, 5019], [20, 5020], [21, 5021], [22, 5022], [23, 5023], [24, 5024], [25, 5025], [26, 5026], [27, 5027], [28, 5028], [29, 5029], [30, 5030], [31, 5031], [32, 5032], [33, 5033], [34, 5034], [35, 5035], [36, 5036], [37, 5037], [38, 5038], [39, 5039]]) == [5000, 5001, 5002, 5003, 5005, 5007, 5006, 5007, 5016, 5016, 5016, 5016, 5016, 5016, 5016, 5016, 5023, 5018, 5019, 5023, 5021, 5021, 5023, 5023, 5048, 5048, 5048, 5048, 5048, 5048, 5048, 5048, 5039, 5049, 5050, 5050, 5053, 5055, 5052, 5052]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20],queries = [[0, 1000], [1, 2000], [2, 3000], [3, 4000], [4, 5000], [5, 6000], [6, 7000], [7, 8000], [8, 9000], [9, 10000], [10, 11000], [11, 12000], [12, 13000], [13, 14000], [14, 15000], [15, 16000], [16, 17000], [17, 18000], [18, 19000], [19, 20000], [20, 21000], [21, 22000], [22, 23000], [23, 24000], [24, 25000], [25, 26000], [26, 27000], [27, 28000], [28, 29000], [29, 30000], [30, 31000], [31, 32000]]) == [1000, 2001, 3002, 4003, 5004, 6005, 7006, 8007, 9003, 10009, 11004, 12011, 13005, 14013, 15006, 16015, 17016, 18008, 19003, 20019, 21020, 22010, 23004, 24023, 25008, 26012, 27005, 28027, 29012, 30014, 31006, 32031]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4],queries = [[0, 123], [1, 456], [2, 789], [3, 101], [4, 202], [5, 303], [6, 404], [7, 505], [8, 606], [9, 707], [10, 808], [11, 909]]) == [123, 457, 791, 102, 206, 303, 406, 510, 606, 714, 812, 909]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],queries = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [10, 1100], [11, 1200], [12, 1300], [13, 1400], [14, 1500], [15, 1600], [16, 1700], [17, 1800]]) == [100, 201, 302, 403, 501, 605, 702, 807, 908, 1003, 1101, 1211, 1304, 1405, 1502, 1615, 1716, 1817]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14],queries = [[0, 500], [1, 1000], [2, 1500], [3, 2000], [4, 2500], [5, 3000], [6, 3500], [7, 4000], [8, 4500], [9, 5000], [10, 5500], [11, 6000], [12, 6500], [13, 7000], [14, 7500], [15, 8000], [16, 8500], [17, 9000], [18, 9500], [19, 10000], [20, 10500], [21, 11000], [22, 11500], [23, 12000], [24, 12500], [25, 13000], [26, 13500], [27, 14000], [28, 14500], [29, 15000]]) == [500, 1001, 1502, 2003, 2501, 3005, 3502, 4007, 4508, 5004, 5501, 6011, 6504, 7006, 7502, 8015, 8503, 9017, 9503, 10009, 10512, 11004, 11514, 12023, 12511, 13009, 13502, 14013, 14520, 15006]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15],queries = [[0, 30], [1, 60], [2, 90], [3, 120], [4, 150], [5, 180], [6, 210], [7, 240], [8, 270], [9, 300], [10, 330], [11, 360], [12, 390], [13, 420], [14, 450], [15, 480], [16, 510], [17, 540], [18, 570], [19, 600], [20, 630], [21, 660], [22, 690], [23, 720], [24, 750], [25, 780], [26, 810], [27, 840], [28, 870], [29, 900], [30, 930], [31, 960], [32, 990], [33, 1020], [34, 1050], [35, 1080], [36, 1110], [37, 1140], [38, 1170], [39, 1200], [40, 1230], [41, 1260], [42, 1290], [43, 1320], [44, 1350], [45, 1380], [46, 1410], [47, 1440], [48, 1470], [49, 1500]]) == [30, 61, 90, 123, 151, 181, 212, 247, 270, 302, 330, 363, 394, 425, 460, 495, 511, 541, 575, 606, 631, 661, 693, 727, 758, 789, 816, 851, 890, 921, 956, 991, 1022, 1023, 1080, 1083, 1138, 1144, 1204, 1212, 1254, 1261, 1312, 1324, 1386, 1386, 1452, 1455, 1471, 0]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],queries = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [10, 1100], [11, 1200], [12, 1300], [13, 1400], [14, 1500], [15, 1600], [16, 1700], [17, 1800], [18, 1900]]) == [100, 201, 302, 403, 503, 605, 703, 807, 908, 1007, 1103, 1211, 1311, 1407, 1503, 1615, 1716, 1817, 1918]\n assert candidate(parents = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]]) == [1, 3, 3, 7, 5, 7, 7, 15, 11, 11, 11, 15, 13, 15, 15, 31, 20, 23, 21, 22]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59],queries = [[0, 100000], [1, 200000], [2, 300000], [3, 400000], [4, 500000], [5, 600000], [6, 700000], [7, 800000], [8, 900000], [9, 1000000], [10, 1100000], [11, 1200000], [12, 1300000], [13, 1400000], [14, 1500000], [15, 1600000], [16, 1700000], [17, 1800000], [18, 1900000], [19, 2000000], [20, 2100000], [21, 2200000], [22, 2300000], [23, 2400000], [24, 2500000], [25, 2600000], [26, 2700000], [27, 2800000], [28, 2900000], [29, 3000000], [30, 3100000], [31, 3200000], [32, 3300000], [33, 3400000], [34, 3500000], [35, 3600000], [36, 3700000], [37, 3800000], [38, 3900000], [39, 4000000], [40, 4100000], [41, 4200000], [42, 4300000], [43, 4400000], [44, 4500000], [45, 4600000], [46, 4700000], [47, 4800000], [48, 4900000], [49, 5000000], [50, 5100000], [51, 5200000], [52, 5300000], [53, 5400000], [54, 5500000], [55, 5600000], [56, 5700000], [57, 5800000], [58, 5900000], [59, 6000000]]) == [100000, 200001, 37858, 137859, 237860, 75717, 175718, 13575, 113576, 213577, 51434, 151435, 251436, 89293, 189294, 27151, 127152, 227153, 65010, 165011, 2868, 102869, 202870, 40727, 140728, 240729, 78586, 178587, 16444, 116445, 216446, 54303, 154303, 254305, 92159, 192163, 30015, 130021, 230015, 67879, 167871, 5737, 105727, 205739, 43583, 143597, 243583, 81455, 181439, 19313, 119295, 219315, 57151, 157173, 257151, 95031, 195007, 32889, 132863, 232891]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],queries = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [10, 1100], [11, 1200], [12, 1300], [13, 1400], [14, 1500], [15, 1600], [16, 1700], [17, 1800], [18, 1900], [19, 2000], [20, 2100], [21, 2200]]) == [100, 201, 302, 403, 501, 605, 702, 807, 908, 1003, 1101, 1211, 1304, 1405, 1502, 1615, 1716, 1817, 1918, 2008, 2109, 2203]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14],queries = [[0, 10], [1, 20], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90], [9, 100], [10, 110], [11, 120], [12, 130], [13, 140], [14, 150], [15, 160], [16, 170], [17, 180], [18, 190], [19, 200], [20, 210], [21, 220], [22, 230], [23, 240], [24, 250], [25, 260], [26, 270], [27, 280], [28, 290], [29, 300]]) == [10, 21, 30, 43, 54, 62, 70, 87, 91, 109, 111, 125, 142, 142, 152, 175, 186, 188, 191, 219, 219, 221, 240, 251, 255, 285, 276, 286, 318, 305]\n assert candidate(parents = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11],queries = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [10, 1100], [11, 1200], [12, 1300], [13, 1400], [14, 1500], [15, 1600], [16, 1700], [17, 1800], [18, 1900], [19, 2000], [20, 2100], [21, 2200], [22, 2300], [23, 2400], [24, 2500], [25, 2600], [26, 2700], [27, 2800], [28, 2900], [29, 3000], [30, 3100], [31, 3200], [32, 3300], [33, 3400], [34, 3500], [35, 3600], [36, 3700], [37, 3800], [38, 3900], [39, 4000]]) == [100, 201, 302, 403, 500, 605, 701, 807, 908, 1002, 1102, 1211, 1304, 1403, 1503, 1615, 1716, 1817, 1918, 2004, 2100, 2205, 2301, 2423, 2524, 2609, 2710, 2806, 2901, 3007, 3101, 3231, 3301, 3433, 3501, 3635, 3708, 3837, 3902, 4009]\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],queries = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [10, 1100], [11, 1200], [12, 1300], [13, 1400], [14, 1500], [15, 1600]]) == [100, 201, 302, 403, 502, 605, 703, 807, 908, 1004, 1102, 1211, 1304, 1406, 1503, 1615]\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],queries = [[0, 101], [1, 102], [2, 103], [3, 104], [4, 105], [5, 106], [6, 107], [7, 108], [8, 109], [9, 110], [10, 111], [11, 112], [12, 113], [13, 114], [14, 115], [15, 116], [16, 117], [17, 118], [18, 119], [19, 120]]) == [101, 103, 103, 107, 109, 111, 109, 111, 111, 111, 111, 123, 125, 127, 125, 123, 125, 126, 126, 124]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24, 25, 25, 25, 26, 26, 26, 27, 27, 27, 28, 28, 28, 29, 29, 29],queries = [[0, 1000], [1, 2000], [2, 3000], [3, 4000], [4, 5000], [5, 6000], [6, 7000], [7, 8000], [8, 9000], [9, 10000], [10, 11000], [11, 12000], [12, 13000], [13, 14000], [14, 15000], [15, 16000], [16, 17000], [17, 18000], [18, 19000], [19, 20000], [20, 21000], [21, 22000], [22, 23000], [23, 24000], [24, 25000], [25, 26000], [26, 27000], [27, 28000], [28, 29000], [29, 30000], [30, 31000], [31, 32000], [32, 33000], [33, 34000], [34, 35000], [35, 36000], [36, 37000], [37, 38000], [38, 39000], [39, 40000], [40, 41000], [41, 42000], [42, 43000], [43, 44000], [44, 45000], [45, 46000], [46, 47000], [47, 48000], [48, 49000], [49, 50000], [50, 51000], [51, 52000], [52, 53000], [53, 54000], [54, 55000], [55, 56000], [56, 57000], [57, 58000], [58, 59000], [59, 60000]]) == [1000, 2001, 3002, 4003, 5004, 6005, 7006, 8007, 9002, 10009, 11003, 12011, 13003, 14013, 15004, 16015, 17016, 18005, 19005, 20019, 21020, 22006, 23007, 24023, 25008, 26008, 27002, 28027, 29012, 30009, 31002, 32031, 33003, 34033, 35003, 36011, 37036, 38012, 39038, 40039, 41004, 42041, 43004, 44014, 45028, 46014, 47030, 48047, 49004, 50017, 51005, 52016, 53052, 54005, 55022, 56055, 57018, 58025, 59006, 60019]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],queries = [[0, 1024], [1, 512], [2, 256], [3, 128], [4, 64], [5, 32], [6, 16], [7, 8], [8, 4], [9, 2], [10, 1], [11, 513], [12, 257], [13, 129], [14, 65], [15, 33]]) == [1024, 513, 258, 131, 68, 37, 22, 15, 12, 11, 11, 523, 269, 141, 79, 47]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49],queries = [[0, 3000], [1, 4000], [2, 5000], [3, 6000], [4, 7000], [5, 8000], [6, 9000], [7, 10000], [8, 11000], [9, 12000], [10, 13000], [11, 14000], [12, 15000], [13, 16000], [14, 17000], [15, 18000], [16, 19000], [17, 20000], [18, 21000], [19, 22000], [20, 23000], [21, 24000], [22, 25000], [23, 26000], [24, 27000], [25, 28000], [26, 29000], [27, 30000], [28, 31000], [29, 32000], [30, 33000], [31, 34000], [32, 35000], [33, 36000], [34, 37000], [35, 38000], [36, 39000], [37, 40000], [38, 41000], [39, 42000], [40, 43000], [41, 44000], [42, 45000], [43, 46000], [44, 47000], [45, 48000], [46, 49000], [47, 50000], [48, 51000], [49, 52000], [50, 53000], [51, 54000], [52, 55000], [53, 56000], [54, 57000], [55, 58000], [56, 59000], [57, 60000], [58, 61000], [59, 62000], [60, 63000], [61, 64000], [62, 65000], [63, 66000], [64, 67000], [65, 68000], [66, 69000], [67, 70000], [68, 71000], [69, 72000], [70, 73000], [71, 74000], [72, 75000], [73, 76000], [74, 77000], [75, 78000], [76, 79000], [77, 80000], [78, 81000], [79, 82000], [80, 83000], [81, 84000], [82, 85000], [83, 86000], [84, 87000], [85, 88000], [86, 89000], [87, 90000], [88, 91000], [89, 92000], [90, 93000], [91, 94000], [92, 95000], [93, 96000], [94, 97000], [95, 98000], [96, 99000], [97, 100000], [98, 101000], [99, 102000]]) == [3000, 4001, 5002, 6003, 7004, 8005, 9006, 10007, 11003, 12009, 13004, 14011, 15005, 16013, 17006, 18015, 19007, 20017, 21018, 22009, 23004, 24021, 25022, 26011, 27005, 28025, 29010, 30013, 31006, 32029, 33014, 34015, 35007, 36016, 37034, 38008, 39036, 40037, 41018, 42039, 43004, 44020, 45026, 46010, 47028, 48045, 49022, 50047, 51005, 52024, 53050, 54012, 55020, 56053, 57010, 58023, 59006, 60028, 61042, 62014, 63012, 64061, 65014, 66031, 67064, 68065, 69066, 70007, 71033, 72034, 73070, 74071, 75003, 76017, 77036, 78075, 79060, 80077, 81018, 82039, 83048, 84081, 85082, 86009, 87025, 88042, 89086, 90055, 91004, 92021, 93028, 94059, 95044, 96093, 97022, 98047, 99032, 100033, 101098, 102011]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14],queries = [[0, 255], [1, 511], [2, 1023], [3, 2047], [4, 4095], [5, 8191], [6, 16383], [7, 32767], [8, 65535], [9, 131071], [10, 262143], [11, 524287], [12, 1048575], [13, 2097151], [14, 4194303], [15, 8388607], [16, 16777215], [17, 33554431], [18, 67108863], [19, 134217727], [20, 268435455], [21, 536870911], [22, 1073741823], [23, 2147483647], [24, 4294967295], [25, 8589934591], [26, 17179869183], [27, 34359738367], [28, 68719476735], [29, 137438953471]]) == [255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535, 131071, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143, 262143]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9],queries = [[0, 100], [1, 200], [2, 300], [3, 400], [4, 500], [5, 600], [6, 700], [7, 800], [8, 900], [9, 1000], [10, 1100], [11, 1200], [12, 1300], [13, 1400], [14, 1500], [15, 1600], [16, 1700], [17, 1800], [18, 1900], [19, 2000]]) == [100, 201, 302, 403, 501, 605, 702, 807, 908, 1004, 1101, 1211, 1304, 1406, 1502, 1615, 1716, 1817, 1918, 2009]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49],queries = [[0, 2000], [1, 3000], [2, 4000], [3, 5000], [4, 6000], [5, 7000], [6, 8000], [7, 9000], [8, 10000], [9, 11000], [10, 12000], [11, 13000], [12, 14000], [13, 15000], [14, 16000], [15, 17000], [16, 18000], [17, 19000], [18, 20000], [19, 21000], [20, 22000], [21, 23000], [22, 24000], [23, 25000], [24, 26000], [25, 27000], [26, 28000], [27, 29000], [28, 30000], [29, 31000], [30, 32000], [31, 33000], [32, 34000], [33, 35000], [34, 36000], [35, 37000], [36, 38000], [37, 39000], [38, 40000], [39, 41000], [40, 42000], [41, 43000], [42, 44000], [43, 45000], [44, 46000], [45, 47000], [46, 48000], [47, 49000], [48, 50000], [49, 51000]]) == [2000, 3001, 4002, 5003, 6004, 7005, 8006, 9007, 10008, 11007, 12010, 13007, 14012, 15007, 16014, 17007, 18015, 19007, 20018, 21019, 22015, 23007, 24022, 25023, 26015, 27007, 28026, 29023, 30015, 31007, 32030, 33023, 34032, 35007, 36031, 37035, 38015, 39037, 40038, 41023, 42040, 43007, 44031, 45039, 46015, 47039, 48046, 49023, 50047, 51007]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],queries = [[0, 255], [1, 512], [2, 1024], [3, 2048], [4, 4096], [5, 8192], [6, 16384], [7, 32768], [8, 65536], [9, 131072], [10, 262144], [11, 524288], [12, 1048576], [13, 2097152], [14, 4194304], [15, 8388608], [16, 16777216], [17, 33554432], [18, 67108864], [19, 134217728]]) == [255, 513, 1026, 2051, 4100, 8197, 16390, 32775, 65544, 131081, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30],queries = [[0, 50], [1, 100], [2, 150], [3, 200], [4, 250], [5, 300], [6, 350], [7, 400], [8, 450], [9, 500], [10, 550], [11, 600], [12, 650], [13, 700], [14, 750], [15, 800], [16, 850], [17, 900], [18, 950], [19, 1000], [20, 1050], [21, 1100], [22, 1150], [23, 1200], [24, 1250], [25, 1300], [26, 1350], [27, 1400], [28, 1450], [29, 1500], [30, 1550], [31, 1600], [32, 1650], [33, 1700], [34, 1750], [35, 1800], [36, 1850], [37, 1900], [38, 1950], [39, 2000], [40, 2050], [41, 2100], [42, 2150], [43, 2200], [44, 2250], [45, 2300], [46, 2350], [47, 2400], [48, 2450], [49, 2500]]) == [50, 101, 150, 203, 254, 302, 350, 407, 458, 509, 556, 605, 655, 702, 750, 815, 853, 917, 958, 1019, 1054, 1113, 1151, 1211, 1274, 1304, 1372, 1406, 1462, 1502, 1552, 1631, 1661, 1716, 1780, 1835, 1851, 1918, 1976, 2039, 2090, 2109, 2162, 2227, 2278, 2301, 2360, 2423, 2466, 2549]\n assert candidate(parents = [-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39], [39, 40], [40, 41], [41, 42], [42, 43], [43, 44], [44, 45], [45, 46], [46, 47], [47, 48], [48, 49], [49, 50], [50, 51]]) == [1, 3, 3, 7, 5, 6, 7, 15, 9, 11, 11, 14, 15, 14, 15, 31, 18, 18, 19, 23, 22, 22, 23, 28, 29, 30, 30, 28, 29, 30, 31, 63, 39, 36, 37, 37, 37, 39, 39, 47, 46, 43, 43, 45, 45, 47, 47, 57, 56, 59, 58]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],queries = [[0, 1000], [1, 2000], [2, 3000], [3, 4000], [4, 5000], [5, 6000], [6, 7000], [7, 8000], [8, 9000], [9, 10000], [10, 11000], [11, 12000], [12, 13000], [13, 14000], [14, 15000]]) == [1000, 2001, 3002, 4003, 5004, 6005, 7006, 8007, 9007, 10009, 11007, 12011, 13007, 14013, 15007]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99],queries = [[0, 3000], [1, 4000], [2, 5000], [3, 6000], [4, 7000], [5, 8000], [6, 9000], [7, 10000], [8, 11000], [9, 12000], [10, 13000], [11, 14000], [12, 15000], [13, 16000], [14, 17000], [15, 18000], [16, 19000], [17, 20000], [18, 21000], [19, 22000], [20, 23000], [21, 24000], [22, 25000], [23, 26000], [24, 27000], [25, 28000], [26, 29000], [27, 30000], [28, 31000], [29, 32000], [30, 33000], [31, 34000], [32, 35000], [33, 36000], [34, 37000], [35, 38000], [36, 39000], [37, 40000], [38, 41000], [39, 42000], [40, 43000], [41, 44000], [42, 45000], [43, 46000], [44, 47000], [45, 48000], [46, 49000], [47, 50000], [48, 51000], [49, 52000], [50, 53000], [51, 54000], [52, 55000], [53, 56000], [54, 57000], [55, 58000], [56, 59000], [57, 60000], [58, 61000], [59, 62000], [60, 63000], [61, 64000], [62, 65000], [63, 66000], [64, 67000], [65, 68000], [66, 69000], [67, 70000], [68, 71000], [69, 72000], [70, 73000], [71, 74000], [72, 75000], [73, 76000], [74, 77000], [75, 78000], [76, 79000], [77, 80000], [78, 81000], [79, 82000], [80, 83000], [81, 84000], [82, 85000], [83, 86000], [84, 87000], [85, 88000], [86, 89000], [87, 90000], [88, 91000], [89, 92000], [90, 93000], [91, 94000], [92, 95000], [93, 96000], [94, 97000], [95, 98000], [96, 99000], [97, 100000], [98, 101000], [99, 102000]]) == [3000, 4001, 5002, 6003, 7004, 8005, 9006, 10007, 11007, 12009, 13007, 14011, 15007, 16013, 17007, 18015, 19007, 20017, 21018, 22015, 23007, 24021, 25022, 26015, 27007, 28025, 29023, 30015, 31007, 32029, 33023, 34015, 35007, 36031, 37034, 38015, 39036, 40037, 41023, 42039, 43007, 44031, 45039, 46015, 47039, 48045, 49023, 50047, 51007, 52031, 53050, 54015, 55039, 56053, 57023, 58047, 59007, 60031, 61055, 62015, 63039, 64061, 65023, 66047, 67064, 68065, 69066, 70015, 71039, 72063, 73070, 74071, 75007, 76031, 77055, 78075, 79071, 80077, 81023, 82047, 83071, 84081, 85082, 86015, 87039, 88063, 89086, 90079, 91007, 92031, 93055, 94079, 95071, 96093, 97023, 98047, 99071, 100095, 101098, 102015]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99],queries = [[0, 100000], [1, 100001], [2, 100002], [3, 100003], [4, 100004], [5, 100005], [6, 100006], [7, 100007], [8, 100008], [9, 100009], [10, 100010], [11, 100011], [12, 100012], [13, 100013], [14, 100014], [15, 100015], [16, 100016], [17, 100017], [18, 100018], [19, 100019], [20, 100020], [21, 100021], [22, 100022], [23, 100023], [24, 100024], [25, 100025], [26, 100026], [27, 100027], [28, 100028], [29, 100029], [30, 100030], [31, 100031], [32, 100032], [33, 100033], [34, 100034], [35, 100035], [36, 100036], [37, 100037], [38, 100038], [39, 100039], [40, 100040], [41, 100041], [42, 100042], [43, 100043], [44, 100044], [45, 100045], [46, 100046], [47, 100047], [48, 100048], [49, 100049], [50, 100050], [51, 100051], [52, 100052], [53, 100053], [54, 100054], [55, 100055], [56, 100056], [57, 100057], [58, 100058], [59, 100059], [60, 100060], [61, 100061], [62, 100062], [63, 100063], [64, 100064], [65, 100065], [66, 100066], [67, 100067], [68, 100068], [69, 100069], [70, 100070], [71, 100071], [72, 100072], [73, 100073], [74, 100074], [75, 100075], [76, 100076], [77, 100077], [78, 100078], [79, 100079], [80, 100080], [81, 100081], [82, 100082], [83, 100083], [84, 100084], [85, 100085], [86, 100086], [87, 100087], [88, 100088], [89, 100089], [90, 100090], [91, 100091], [92, 100092], [93, 100093], [94, 100094], [95, 100095], [96, 100096], [97, 100097], [98, 100098], [99, 100099]]) == [100000, 100001, 100003, 100003, 100007, 100007, 100007, 100007, 100015, 100015, 100015, 100015, 100015, 100015, 100015, 100015, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100031, 100064, 100065, 100067, 100067, 100071, 100071, 100071, 100071, 100079, 100079, 100079, 100079, 100079, 100079, 100079, 100079, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100095, 100192, 100193, 100195, 100195]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],queries = [[0, 100000], [1, 50000], [2, 25000], [3, 12500], [4, 6250], [5, 3125], [6, 1562], [7, 781], [8, 390], [9, 195], [10, 97], [11, 48], [12, 24], [13, 12], [14, 6], [15, 3], [16, 1], [17, 513], [18, 257], [19, 129], [20, 65], [21, 32], [22, 16], [23, 8], [24, 4], [25, 2], [26, 1], [27, 513], [28, 257], [29, 129], [30, 65]]) == [100000, 50001, 25002, 12503, 6254, 3127, 1567, 783, 398, 203, 107, 59, 31, 15, 15, 15, 17, 529, 275, 147, 85, 53, 31, 31, 28, 27, 27, 539, 285, 157, 95]\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14],queries = [[0, 2000], [1, 2001], [2, 2002], [3, 2003], [4, 2004], [5, 2005], [6, 2006], [7, 2007], [8, 2008], [9, 2009], [10, 2010], [11, 2011], [12, 2012], [13, 2013], [14, 2014], [15, 2015], [16, 2016], [17, 2017], [18, 2018], [19, 2019], [20, 2020], [21, 2021], [22, 2022], [23, 2023], [24, 2024], [25, 2025], [26, 2026], [27, 2027], [28, 2028], [29, 2029]]) == [2000, 2001, 2002, 2003, 2006, 2007, 2007, 2007, 2012, 2013, 2015, 2014, 2015, 2014, 2015, 2015, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032, 2032]\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],queries = [[0, 101], [1, 202], [2, 303], [3, 404], [4, 505], [5, 606], [6, 707], [7, 808], [8, 909], [9, 1010], [10, 1111], [11, 1212], [12, 1313], [13, 1414], [14, 1515], [15, 1616], [16, 1717], [17, 1818]]) == [101, 203, 303, 407, 509, 606, 709, 815, 911, 1019, 1117, 1214, 1325, 1419, 1516, 1631, 1725, 1822]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19],queries = [[19, 2], [18, 5], [17, 10], [16, 20], [15, 40], [14, 80], [13, 160], [12, 320], [11, 640], [10, 1280], [9, 2560], [8, 5120], [7, 10240], [6, 20480], [5, 40960], [4, 81920], [3, 163840], [2, 327680], [1, 655360], [0, 1310720]]) == [17, 23, 27, 23, 47, 94, 173, 332, 651, 1290, 2569, 5128, 10247, 20486, 40965, 81924, 163843, 65538, 131073, 0]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],queries = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30]]) == [1, 3, 3, 7, 5, 7, 7, 15, 11, 10, 11, 15, 14, 15, 15, 31, 20, 23, 22, 21, 21, 23, 23, 31, 30, 26, 27, 30, 31, 30]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4],queries = [[0, 15], [1, 30], [2, 45], [3, 60], [4, 75], [5, 90], [6, 105], [7, 120], [8, 135], [9, 150]]) == [15, 31, 47, 63, 79, 95, 111, 127, 143, 159]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14],queries = [[0, 10000], [1, 20000], [2, 30000], [3, 40000], [4, 50000], [5, 60000], [6, 70000], [7, 80000], [8, 90000], [9, 100000], [10, 110000], [11, 120000], [12, 130000], [13, 140000], [14, 150000], [15, 160000], [16, 170000], [17, 180000], [18, 190000], [19, 200000], [20, 210000], [21, 220000], [22, 230000], [23, 240000], [24, 250000], [25, 260000], [26, 270000], [27, 280000], [28, 290000], [29, 300000]]) == [10000, 20001, 30002, 40003, 50004, 60005, 70006, 80007, 90008, 100009, 110010, 120011, 130012, 140013, 150014, 160015, 170007, 180017, 190008, 200019, 210009, 220021, 230010, 240023, 250011, 260025, 7868, 17883, 27869, 37885]\n assert candidate(parents = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14],queries = [[0, 65535], [1, 65534], [2, 65533], [3, 65532], [4, 65531], [5, 65530], [6, 65529], [7, 65528], [8, 65527], [9, 65526], [10, 65525], [11, 65524], [12, 65523], [13, 65522], [14, 65521], [15, 65520], [16, 65519], [17, 65518], [18, 65517], [19, 65516], [20, 65515], [21, 65514], [22, 65513], [23, 65512], [24, 65511], [25, 65510], [26, 65509], [27, 65508], [28, 65507], [29, 65506], [30, 65505], [31, 65504], [32, 65503], [33, 65502], [34, 65501], [35, 65500], [36, 65499], [37, 65498], [38, 65497], [39, 65496], [40, 65495], [41, 65494], [42, 65493], [43, 65492], [44, 65491], [45, 65490], [46, 65489], [47, 65488], [48, 65487], [49, 65486]]) == [65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535, 65535]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],queries = [[0, 65536], [1, 32768], [2, 16384], [3, 8192], [4, 4096], [5, 2048], [6, 1024], [7, 512], [8, 256], [9, 128], [10, 64], [11, 32], [12, 16], [13, 8], [14, 4], [15, 2], [14, 1], [13, 3], [12, 7], [11, 15], [10, 31], [9, 63], [8, 127], [7, 255], [6, 511], [5, 1023], [4, 2047], [3, 4095], [2, 8191], [1, 16383], [0, 32767]]) == [65536, 32769, 16386, 8195, 4100, 2053, 1030, 519, 264, 137, 74, 43, 28, 14, 10, 13, 15, 14, 11, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15],queries = [[15, 65535], [14, 32767], [13, 16383], [12, 8191], [11, 4095], [10, 2047], [9, 1023], [8, 511], [7, 255], [6, 127], [5, 63], [4, 31], [3, 15], [2, 7], [1, 3], [0, 1]]) == [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]\n"}, "metadata": {"canonical_parameter_names": ["parents", "queries"], "leetcode_dataset_entry_point": "Solution().maxGeneticDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector maxGeneticDifference(vector& parents, vector>& queries) {", "container": "Solution", "callable": "maxGeneticDifference", "parameters": [{"name": "parents", "type": "vector&"}, {"name": "queries", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1941, "task_id": "check-if-all-characters-have-equal-number-of-occurrences", "difficulty": "Easy", "problem_description": "Given a string s, return true if s is a good string, or false otherwise.\nA string s is good if all the characters that appear in s have the same number of occurrences (i.e., the same frequency).\n \nExample 1:\n\nInput: s = \"abacbc\"\nOutput: true\nExplanation: The characters that appear in s are 'a', 'b', and 'c'. All characters occur 2 times in s.\n\nExample 2:\n\nInput: s = \"aaabb\"\nOutput: false\nExplanation: The characters that appear in s are 'a' and 'b'.\n'a' occurs 3 times while 'b' occurs 2 times, which is not the same number of times.\n\n \nConstraints:\n\n1 <= s.length <= 1000\ns consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aabbccc\") == False\n assert candidate(s = \"abacbc\") == True\n assert candidate(s = \"abcabcabc\") == True\n assert candidate(s = \"qqqq\") == True\n assert candidate(s = \"aabbcc\") == True\n assert candidate(s = \"zzzzzzzzzz\") == True\n assert candidate(s = \"aabbc\") == False\n assert candidate(s = \"a\") == True\n assert candidate(s = \"abc\") == True\n assert candidate(s = \"\") == False\n assert candidate(s = \"aabb\") == True\n assert candidate(s = \"aabbccddeeff\") == True\n assert candidate(s = \"abcdabcd\") == True\n assert candidate(s = \"zzz\") == True\n assert candidate(s = \"xyz\") == True\n assert candidate(s = \"aaabb\") == False\n assert candidate(s = \"hello\") == False\n assert candidate(s = \"thisisnotagoodstring\") == False\n assert candidate(s = \"aaaabbbbccccdddd\") == True\n assert candidate(s = \"almostgoodbutoneextrab\") == False\n assert candidate(s = \"mnopqrstuvwxyzz\") == False\n assert candidate(s = \"uniquecharactersabcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(s = \"qwertyuioplkjhgfdsazxcvbnm\") == True\n assert candidate(s = \"kjhgfdsazxcvbnmlpoiuytrewq\") == True\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == True\n assert candidate(s = \"llllkkkkjjjjiiiihhhhggggffffeeeeeeee\") == False\n assert candidate(s = \"repeatedcharsrepeatedcharsrepeatedchars\") == False\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz\") == False\n assert candidate(s = \"samefrequencyforallcharacters\") == False\n assert candidate(s = \"lmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmnolmno\") == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == False\n assert candidate(s = \"mnopqrsmnopqrsmnopqrsmnopqrsmnopqrs\") == True\n assert candidate(s = \"abcdefabcdefabcdef\") == True\n assert candidate(s = \"abacadaeafagahaibiciidieifigihiiijijikikililimimioinioipoipiqiririsititiuiujujukukululumiumiujujukvkvkwlwlxmxmylynzozp\") == False\n assert candidate(s = \"mnopqrstuvwxyzabcdefghijklmnopqrstuvwxyza\") == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzqqqq\") == False\n assert candidate(s = \"abracadabra\") == False\n assert candidate(s = \"mnopqrstuvwxymnopqrstuvwxymnopqrstuvwxymnopqrstuvwxyn\") == False\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghijabcdefghij\") == True\n assert candidate(s = \"qwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiopqwertyuiop\") == True\n assert candidate(s = \"abcdefabcdef\") == True\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(s = \"aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\") == True\n assert candidate(s = \"almostgoodbutoneextraa\") == False\n assert candidate(s = \"abcdefghijklmnopabcdefghijklmnopabcdefghijklmnopabcdefghijklmnopabcdefghijklmnopabcdefghijklmnop\") == True\n assert candidate(s = \"jjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzzaaaaaa\") == False\n assert candidate(s = \"zzzzzyyyyxxxwwvvuuttssrrqqlloommnnppekkaaiioouuyy\") == False\n assert candidate(s = \"racecar\") == False\n assert candidate(s = \"almostgoodbutoneextrac\") == False\n assert candidate(s = \"xyzxyzxyz\") == True\n assert candidate(s = \"qwerqwerqwer\") == True\n assert candidate(s = \"abababababababab\") == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\") == True\n assert candidate(s = \"ppppppqqqqqrrrrrssssstttttuuuuuvvvvvwwwwwooooo\") == False\n assert candidate(s = \"ababababc\") == False\n assert candidate(s = \"mmnnnmmmnnnmmmnnnmmmnnnmmmnnnmmmnnnmmmnnnmm\") == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzzz\") == False\n assert candidate(s = \"pqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrspqrs\") == True\n assert candidate(s = \"mmnnooppqqrrssttuuvvwwxxyyzzqqwweerrttyyuuiihhggffeeddccba\") == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxy\") == True\n assert candidate(s = \"ppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == True\n assert candidate(s = \"mnopmnopmnopmnopmnopmnopmnopmnop\") == True\n assert candidate(s = \"xyzzzzzyzx\") == False\n assert candidate(s = \"abacabadabacabad\") == False\n assert candidate(s = \"abcdefghijklmnopqrstuvwxzyabcdefghijklmnopqrstuvwxzy\") == True\n assert candidate(s = \"abcdefghijklmnop\") == True\n assert candidate(s = \"xyzzxyzzxyzzxyzzxyzzxyzz\") == False\n assert candidate(s = \"zzzyyyxxxwwwwvvvvuuuuuuuuutttttttsssssssrrrrrrqqqqpppooooonnnnmmmmllllkkkkjjjjiiiihhhhhgggggfffffeeeeeeeee\") == False\n assert candidate(s = \"mnopqrmpqrno\") == True\n assert candidate(s = \"qqwweerrttyyuuuiooppppllkkiijjhgffeeddccba\") == False\n assert candidate(s = \"qrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(s = \"mississippi\") == False\n assert candidate(s = \"xyzzxyzzxyzzxyzz\") == False\n assert candidate(s = \"oneonetwoonetwothree\") == False\n assert candidate(s = \"zxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnmzxcvbnm\") == True\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == True\n assert candidate(s = \"xyzxyzxyzxyz\") == True\n assert candidate(s = \"zzzzyyyyxxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == False\n assert candidate(s = \"qqqqwweerrrrtttyyyy\") == False\n assert candidate(s = \"abcdabcdabcdabcd\") == True\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == False\n assert candidate(s = \"almostgoodbutoneextrad\") == False\n assert candidate(s = \"almostgoodbutoneextrae\") == False\n assert candidate(s = \"programming\") == False\n assert candidate(s = \"equalfrequenciesequalfrequencies\") == False\n assert candidate(s = \"xyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabc\") == False\n assert candidate(s = \"almostgoodbutoneextraf\") == False\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzzabcdefghij\") == False\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().areOccurrencesEqual", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool areOccurrencesEqual(string s) {", "container": "Solution", "callable": "areOccurrencesEqual", "parameters": [{"name": "s", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1942, "task_id": "the-number-of-the-smallest-unoccupied-chair", "difficulty": "Medium", "problem_description": "There is a party where n friends numbered from 0 to n - 1 are attending. There is an infinite number of chairs in this party that are numbered from 0 to infinity. When a friend arrives at the party, they sit on the unoccupied chair with the smallest number.\n\nFor example, if chairs 0, 1, and 5 are occupied when a friend comes, they will sit on chair number 2.\n\nWhen a friend leaves the party, their chair becomes unoccupied at the moment they leave. If another friend arrives at that same moment, they can sit in that chair.\nYou are given a 0-indexed 2D integer array times where times[i] = [arrivali, leavingi], indicating the arrival and leaving times of the ith friend respectively, and an integer targetFriend. All arrival times are distinct.\nReturn the chair number that the friend numbered targetFriend will sit on.\n \nExample 1:\n\nInput: times = [[1,4],[2,3],[4,6]], targetFriend = 1\nOutput: 1\nExplanation: \n- Friend 0 arrives at time 1 and sits on chair 0.\n- Friend 1 arrives at time 2 and sits on chair 1.\n- Friend 1 leaves at time 3 and chair 1 becomes empty.\n- Friend 0 leaves at time 4 and chair 0 becomes empty.\n- Friend 2 arrives at time 4 and sits on chair 0.\nSince friend 1 sat on chair 1, we return 1.\n\nExample 2:\n\nInput: times = [[3,10],[1,5],[2,6]], targetFriend = 0\nOutput: 2\nExplanation: \n- Friend 1 arrives at time 1 and sits on chair 0.\n- Friend 2 arrives at time 2 and sits on chair 1.\n- Friend 0 arrives at time 3 and sits on chair 2.\n- Friend 1 leaves at time 5 and chair 0 becomes empty.\n- Friend 2 leaves at time 6 and chair 1 becomes empty.\n- Friend 0 leaves at time 10 and chair 2 becomes empty.\nSince friend 0 sat on chair 2, we return 2.\n\n \nConstraints:\n\nn == times.length\n2 <= n <= 104\ntimes[i].length == 2\n1 <= arrivali < leavingi <= 105\n0 <= targetFriend <= n - 1\nEach arrivali time is distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(times = [[5, 10], [1, 3], [2, 6], [7, 8]],targetFriend = 1) == 0\n assert candidate(times = [[5, 10], [1, 2], [3, 8]],targetFriend = 2) == 0\n assert candidate(times = [[2, 7], [7, 9], [1, 5]],targetFriend = 2) == 0\n assert candidate(times = [[1, 2], [2, 3], [3, 4], [4, 5]],targetFriend = 3) == 0\n assert candidate(times = [[8, 12], [1, 6], [3, 5], [9, 10]],targetFriend = 2) == 1\n assert candidate(times = [[2, 5], [3, 7], [4, 9], [5, 10]],targetFriend = 2) == 2\n assert candidate(times = [[5, 15], [1, 20], [10, 25]],targetFriend = 2) == 2\n assert candidate(times = [[10, 20], [20, 30], [15, 25], [5, 15]],targetFriend = 2) == 0\n assert candidate(times = [[2, 5], [3, 9], [4, 7], [5, 8]],targetFriend = 2) == 2\n assert candidate(times = [[5, 10], [1, 3], [4, 8], [6, 9]],targetFriend = 3) == 2\n assert candidate(times = [[10, 20], [5, 10], [15, 25]],targetFriend = 1) == 0\n assert candidate(times = [[1, 4], [2, 3], [4, 6]],targetFriend = 1) == 1\n assert candidate(times = [[5, 10], [1, 3], [4, 6], [6, 7]],targetFriend = 1) == 0\n assert candidate(times = [[1, 3], [2, 5], [3, 6], [4, 7]],targetFriend = 2) == 0\n assert candidate(times = [[2, 5], [1, 3], [6, 7], [4, 8]],targetFriend = 1) == 0\n assert candidate(times = [[3, 10], [1, 5], [2, 6]],targetFriend = 0) == 2\n assert candidate(times = [[1, 2], [2, 5], [4, 7], [7, 9]],targetFriend = 0) == 0\n assert candidate(times = [[3, 4], [1, 5], [2, 6], [5, 7], [4, 8], [6, 9]],targetFriend = 3) == 0\n assert candidate(times = [[5, 8], [12, 15], [10, 14], [20, 25], [1, 4], [16, 18], [6, 9], [19, 22], [3, 7], [11, 13]],targetFriend = 8) == 1\n assert candidate(times = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26]],targetFriend = 6) == 0\n assert candidate(times = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100], [11, 110], [12, 120]],targetFriend = 11) == 10\n assert candidate(times = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92]],targetFriend = 8) == 8\n assert candidate(times = [[1, 10], [2, 5], [3, 7], [8, 12], [6, 9], [11, 13]],targetFriend = 5) == 0\n assert candidate(times = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [11, 90], [12, 89], [13, 88], [14, 87], [15, 86]],targetFriend = 7) == 7\n assert candidate(times = [[10, 20], [5, 15], [1, 10], [16, 30], [21, 40]],targetFriend = 3) == 1\n assert candidate(times = [[1, 10], [2, 11], [3, 12], [4, 13], [5, 14]],targetFriend = 2) == 2\n assert candidate(times = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11]],targetFriend = 6) == 2\n assert candidate(times = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],targetFriend = 8) == 0\n assert candidate(times = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],targetFriend = 5) == 0\n assert candidate(times = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28]],targetFriend = 7) == 0\n assert candidate(times = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]],targetFriend = 0) == 0\n assert candidate(times = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10]],targetFriend = 9) == 0\n assert candidate(times = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],targetFriend = 9) == 0\n assert candidate(times = [[5, 10], [1, 6], [7, 12], [15, 20], [2, 8]],targetFriend = 4) == 1\n assert candidate(times = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]],targetFriend = 3) == 3\n assert candidate(times = [[3, 20], [1, 5], [7, 15], [10, 18], [2, 8], [13, 17]],targetFriend = 3) == 1\n assert candidate(times = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],targetFriend = 4) == 0\n assert candidate(times = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28], [29, 30], [31, 32], [33, 34], [35, 36], [37, 38], [39, 40], [41, 42], [43, 44], [45, 46], [47, 48], [49, 50]],targetFriend = 22) == 0\n assert candidate(times = [[1, 5], [2, 3], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11]],targetFriend = 5) == 1\n assert candidate(times = [[10, 20], [1, 6], [3, 11], [7, 14], [15, 25]],targetFriend = 4) == 0\n assert candidate(times = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [11, 90], [12, 89], [13, 88], [14, 87], [15, 86], [16, 85], [17, 84], [18, 83], [19, 82], [20, 81]],targetFriend = 15) == 15\n assert candidate(times = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [11, 90], [12, 89], [13, 88], [14, 87], [15, 86]],targetFriend = 10) == 10\n assert candidate(times = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],targetFriend = 6) == 0\n assert candidate(times = [[1, 50], [2, 49], [3, 48], [4, 47], [5, 46], [6, 45], [7, 44], [8, 43], [9, 42], [10, 41]],targetFriend = 9) == 9\n assert candidate(times = [[1, 10], [2, 5], [3, 4], [6, 9], [7, 11]],targetFriend = 4) == 2\n assert candidate(times = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50], [51, 60], [61, 70], [71, 80], [81, 90], [91, 100]],targetFriend = 9) == 0\n assert candidate(times = [[1, 10], [2, 12], [3, 14], [4, 16], [5, 18], [6, 20]],targetFriend = 2) == 2\n assert candidate(times = [[1, 1000], [2, 999], [3, 998], [4, 997], [5, 996], [6, 995], [7, 994], [8, 993], [9, 992], [10, 991]],targetFriend = 9) == 9\n assert candidate(times = [[3, 8], [1, 5], [2, 6], [7, 10], [4, 9], [6, 12], [8, 15]],targetFriend = 2) == 1\n assert candidate(times = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [25, 26], [27, 28], [29, 30], [31, 32], [33, 34], [35, 36], [37, 38], [39, 40]],targetFriend = 19) == 0\n assert candidate(times = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90]],targetFriend = 4) == 0\n assert candidate(times = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14]],targetFriend = 10) == 0\n assert candidate(times = [[10, 20], [5, 15], [1, 8], [21, 25], [11, 18]],targetFriend = 2) == 0\n assert candidate(times = [[2, 4], [6, 8], [10, 12], [1, 3], [5, 7], [9, 11]],targetFriend = 0) == 1\n assert candidate(times = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]],targetFriend = 5) == 0\n assert candidate(times = [[1, 10], [2, 5], [6, 12], [3, 9], [7, 15]],targetFriend = 2) == 1\n assert candidate(times = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95]],targetFriend = 5) == 5\n assert candidate(times = [[1, 5], [2, 3], [4, 7], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 13], [11, 14], [12, 15]],targetFriend = 7) == 2\n assert candidate(times = [[1, 4], [2, 5], [3, 6], [4, 7], [5, 8], [6, 9]],targetFriend = 5) == 2\n assert candidate(times = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40]],targetFriend = 5) == 0\n assert candidate(times = [[1, 30], [2, 25], [3, 20], [4, 15], [5, 10], [6, 28], [7, 24], [8, 22], [9, 29], [10, 18], [11, 21], [12, 27], [13, 23], [14, 26], [15, 19], [16, 17]],targetFriend = 4) == 4\n assert candidate(times = [[1, 10000], [2, 9999], [3, 9998], [4, 9997], [5, 9996], [6, 9995], [7, 9994], [8, 9993], [9, 9992], [10, 9991]],targetFriend = 9) == 9\n assert candidate(times = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],targetFriend = 0) == 0\n assert candidate(times = [[10, 20], [30, 40], [20, 30], [5, 15], [45, 55], [50, 60]],targetFriend = 4) == 0\n assert candidate(times = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91]],targetFriend = 9) == 9\n assert candidate(times = [[1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12]],targetFriend = 9) == 1\n assert candidate(times = [[1, 500], [2, 499], [3, 498], [4, 497], [5, 496], [6, 495], [7, 494], [8, 493], [9, 492], [10, 491], [11, 490], [12, 489], [13, 488], [14, 487], [15, 486]],targetFriend = 13) == 13\n assert candidate(times = [[10, 20], [15, 25], [5, 15], [20, 30], [25, 35], [0, 10]],targetFriend = 2) == 1\n assert candidate(times = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80]],targetFriend = 3) == 0\n assert candidate(times = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 110]],targetFriend = 4) == 0\n assert candidate(times = [[10, 30], [20, 40], [30, 50], [40, 60], [50, 70], [60, 80], [70, 90], [80, 100], [90, 110], [100, 120], [110, 130], [120, 140], [130, 150], [140, 160], [150, 170], [160, 180], [170, 190], [180, 200], [190, 210], [200, 220]],targetFriend = 9) == 1\n assert candidate(times = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50]],targetFriend = 0) == 0\n assert candidate(times = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40]],targetFriend = 3) == 0\n assert candidate(times = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55]],targetFriend = 8) == 0\n assert candidate(times = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [11, 10]],targetFriend = 10) == 0\n assert candidate(times = [[1, 100], [2, 30], [3, 40], [4, 50], [5, 60], [6, 70], [7, 80], [8, 90], [9, 100]],targetFriend = 5) == 5\n assert candidate(times = [[1, 30], [2, 29], [3, 28], [4, 27], [5, 26], [6, 25], [7, 24], [8, 23], [9, 22], [10, 21]],targetFriend = 5) == 5\n assert candidate(times = [[1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11]],targetFriend = 6) == 6\n assert candidate(times = [[1, 10000], [2, 9999], [3, 9998], [4, 9997], [5, 9996], [6, 9995], [7, 9994]],targetFriend = 6) == 6\n assert candidate(times = [[1, 10], [2, 11], [3, 12], [4, 13], [5, 14], [6, 15], [7, 16], [8, 17], [9, 18], [10, 19]],targetFriend = 9) == 0\n assert candidate(times = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 13], [13, 15], [15, 17], [17, 19], [19, 21]],targetFriend = 5) == 0\n assert candidate(times = [[1, 10], [11, 20], [2, 19], [12, 18], [3, 17]],targetFriend = 3) == 3\n assert candidate(times = [[1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12]],targetFriend = 4) == 4\n assert candidate(times = [[3, 8], [5, 10], [1, 4], [7, 12], [9, 15]],targetFriend = 3) == 2\n assert candidate(times = [[1, 10], [2, 12], [3, 14], [4, 16], [5, 18], [6, 20], [7, 22], [8, 24], [9, 26], [10, 28]],targetFriend = 9) == 0\n assert candidate(times = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90]],targetFriend = 5) == 0\n assert candidate(times = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],targetFriend = 5) == 0\n assert candidate(times = [[2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19], [20, 21]],targetFriend = 9) == 0\n assert candidate(times = [[1, 5], [1, 4], [1, 3], [1, 2], [2, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7]],targetFriend = 8) == 0\n assert candidate(times = [[10, 25], [20, 30], [5, 15], [15, 20], [1, 10], [25, 35], [30, 40], [5, 10], [15, 20]],targetFriend = 5) == 0\n assert candidate(times = [[1, 10], [2, 5], [3, 6], [7, 12], [8, 9], [4, 11]],targetFriend = 2) == 2\n assert candidate(times = [[1, 100], [2, 50], [3, 30], [4, 20], [5, 10], [6, 5], [7, 3]],targetFriend = 0) == 0\n assert candidate(times = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],targetFriend = 8) == 0\n assert candidate(times = [[1, 10], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]],targetFriend = 4) == 4\n assert candidate(times = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]],targetFriend = 7) == 3\n assert candidate(times = [[5, 10], [1, 6], [11, 16], [21, 26], [10, 15], [6, 11], [16, 21], [26, 31], [2, 7], [7, 12]],targetFriend = 8) == 1\n assert candidate(times = [[1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11], [21, 40], [22, 39], [23, 38], [24, 37], [25, 36], [26, 35], [27, 34], [28, 33], [29, 32], [30, 31]],targetFriend = 15) == 5\n assert candidate(times = [[1, 10], [11, 20], [21, 30], [31, 40], [41, 50], [51, 60]],targetFriend = 5) == 0\n assert candidate(times = [[5, 10], [10, 20], [15, 25], [20, 30], [25, 35], [30, 40]],targetFriend = 3) == 0\n assert candidate(times = [[5, 10], [1, 2], [3, 4], [6, 7], [8, 9], [10, 11]],targetFriend = 1) == 0\n assert candidate(times = [[10, 20], [5, 15], [1, 11], [25, 35], [30, 40]],targetFriend = 4) == 1\n"}, "metadata": {"canonical_parameter_names": ["times", "targetFriend"], "leetcode_dataset_entry_point": "Solution().smallestChair", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int smallestChair(vector>& times, int targetFriend) {", "container": "Solution", "callable": "smallestChair", "parameters": [{"name": "times", "type": "vector>&"}, {"name": "targetFriend", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1943, "task_id": "describe-the-painting", "difficulty": "Medium", "problem_description": "There is a long and thin painting that can be represented by a number line. The painting was painted with multiple overlapping segments where each segment was painted with a unique color. You are given a 2D integer array segments, where segments[i] = [starti, endi, colori] represents the half-closed segment [starti, endi) with colori as the color.\nThe colors in the overlapping segments of the painting were mixed when it was painted. When two or more colors mix, they form a new color that can be represented as a set of mixed colors.\n\nFor example, if colors 2, 4, and 6 are mixed, then the resulting mixed color is {2,4,6}.\n\nFor the sake of simplicity, you should only output the sum of the elements in the set rather than the full set.\nYou want to describe the painting with the minimum number of non-overlapping half-closed segments of these mixed colors. These segments can be represented by the 2D array painting where painting[j] = [leftj, rightj, mixj] describes a half-closed segment [leftj, rightj) with the mixed color sum of mixj.\n\nFor example, the painting created with segments = [[1,4,5],[1,7,7]] can be described by painting = [[1,4,12],[4,7,7]] because:\n\n\t\n[1,4) is colored {5,7} (with a sum of 12) from both the first and second segments.\n[4,7) is colored {7} from only the second segment.\n\n\n\nReturn the 2D array painting describing the finished painting (excluding any parts that are not painted). You may return the segments in any order.\nA half-closed segment [a, b) is the section of the number line between points a and b including point a and not including point b.\n \nExample 1:\n\n\nInput: segments = [[1,4,5],[4,7,7],[1,7,9]]\nOutput: [[1,4,14],[4,7,16]]\nExplanation: The painting can be described as follows:\n- [1,4) is colored {5,9} (with a sum of 14) from the first and third segments.\n- [4,7) is colored {7,9} (with a sum of 16) from the second and third segments.\n\nExample 2:\n\n\nInput: segments = [[1,7,9],[6,8,15],[8,10,7]]\nOutput: [[1,6,9],[6,7,24],[7,8,15],[8,10,7]]\nExplanation: The painting can be described as follows:\n- [1,6) is colored 9 from the first segment.\n- [6,7) is colored {9,15} (with a sum of 24) from the first and second segments.\n- [7,8) is colored 15 from the second segment.\n- [8,10) is colored 7 from the third segment.\n\nExample 3:\n\n\nInput: segments = [[1,4,5],[1,4,7],[4,7,1],[4,7,11]]\nOutput: [[1,4,12],[4,7,12]]\nExplanation: The painting can be described as follows:\n- [1,4) is colored {5,7} (with a sum of 12) from the first and second segments.\n- [4,7) is colored {1,11} (with a sum of 12) from the third and fourth segments.\nNote that returning a single segment [1,7) is incorrect because the mixed color sets are different.\n\n \nConstraints:\n\n1 <= segments.length <= 2 * 104\nsegments[i].length == 3\n1 <= starti < endi <= 105\n1 <= colori <= 109\nEach colori is distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(segments = [[10, 20, 5], [15, 25, 3], [12, 18, 8]]) == [[10, 12, 5], [12, 15, 13], [15, 18, 16], [18, 20, 8], [20, 25, 3]]\n assert candidate(segments = [[1, 10, 100], [5, 15, 200], [12, 20, 300]]) == [[1, 5, 100], [5, 10, 300], [10, 12, 200], [12, 15, 500], [15, 20, 300]]\n assert candidate(segments = [[0, 1, 3], [2, 3, 4], [1, 2, 5]]) == [[0, 1, 3], [1, 2, 5], [2, 3, 4]]\n assert candidate(segments = [[2, 5, 10], [3, 8, 20], [5, 6, 30]]) == [[2, 3, 10], [3, 5, 30], [5, 6, 50], [6, 8, 20]]\n assert candidate(segments = [[2, 5, 10], [3, 8, 20], [6, 10, 30]]) == [[2, 3, 10], [3, 5, 30], [5, 6, 20], [6, 8, 50], [8, 10, 30]]\n assert candidate(segments = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9]]) == [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9]]\n assert candidate(segments = [[0, 2, 3], [2, 5, 4], [1, 3, 2]]) == [[0, 1, 3], [1, 2, 5], [2, 3, 6], [3, 5, 4]]\n assert candidate(segments = [[1, 4, 5], [1, 4, 7], [4, 7, 1], [4, 7, 11]]) == [[1, 4, 12], [4, 7, 12]]\n assert candidate(segments = [[5, 10, 1], [10, 15, 2], [15, 20, 3], [20, 25, 4]]) == [[5, 10, 1], [10, 15, 2], [15, 20, 3], [20, 25, 4]]\n assert candidate(segments = [[10, 20, 100], [15, 25, 200], [20, 30, 300]]) == [[10, 15, 100], [15, 20, 300], [20, 25, 500], [25, 30, 300]]\n assert candidate(segments = [[10, 20, 100], [20, 30, 200], [15, 25, 150]]) == [[10, 15, 100], [15, 20, 250], [20, 25, 350], [25, 30, 200]]\n assert candidate(segments = [[1, 3, 1], [3, 5, 2], [5, 7, 3], [7, 9, 4]]) == [[1, 3, 1], [3, 5, 2], [5, 7, 3], [7, 9, 4]]\n assert candidate(segments = [[1, 4, 5], [4, 7, 7], [1, 7, 9]]) == [[1, 4, 14], [4, 7, 16]]\n assert candidate(segments = [[1, 100000, 1000000000]]) == [[1, 100000, 1000000000]]\n assert candidate(segments = [[1, 7, 9], [6, 8, 15], [8, 10, 7]]) == [[1, 6, 9], [6, 7, 24], [7, 8, 15], [8, 10, 7]]\n assert candidate(segments = [[10, 15, 5], [12, 20, 15], [18, 25, 25]]) == [[10, 12, 5], [12, 15, 20], [15, 18, 15], [18, 20, 40], [20, 25, 25]]\n assert candidate(segments = [[1, 10, 5], [2, 9, 10], [3, 8, 15], [4, 7, 20]]) == [[1, 2, 5], [2, 3, 15], [3, 4, 30], [4, 7, 50], [7, 8, 30], [8, 9, 15], [9, 10, 5]]\n assert candidate(segments = [[1, 3, 1], [2, 5, 2], [3, 7, 3], [4, 8, 4], [5, 9, 5], [6, 10, 6]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 5], [4, 5, 9], [5, 6, 12], [6, 7, 18], [7, 8, 15], [8, 9, 11], [9, 10, 6]]\n assert candidate(segments = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5]]) == [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5]]\n assert candidate(segments = [[10, 20, 500], [15, 25, 700], [20, 30, 900], [5, 25, 300], [25, 35, 800]]) == [[5, 10, 300], [10, 15, 800], [15, 20, 1500], [20, 25, 1900], [25, 30, 1700], [30, 35, 800]]\n assert candidate(segments = [[10, 20, 1], [11, 19, 2], [12, 18, 3], [13, 17, 4], [14, 16, 5], [15, 15, 6]]) == [[10, 11, 1], [11, 12, 3], [12, 13, 6], [13, 14, 10], [14, 15, 15], [15, 16, 15], [16, 17, 10], [17, 18, 6], [18, 19, 3], [19, 20, 1]]\n assert candidate(segments = [[1000, 2000, 5000000], [1500, 2500, 10000000], [2000, 3000, 15000000], [1750, 2250, 12000000], [2250, 2750, 22000000], [2750, 3250, 25000000]]) == [[1000, 1500, 5000000], [1500, 1750, 15000000], [1750, 2000, 27000000], [2000, 2250, 37000000], [2250, 2500, 47000000], [2500, 2750, 37000000], [2750, 3000, 40000000], [3000, 3250, 25000000]]\n assert candidate(segments = [[1, 100, 1000000000], [50, 150, 1000000000], [100, 200, 1000000000], [150, 250, 1000000000], [200, 300, 1000000000]]) == [[1, 50, 1000000000], [50, 100, 2000000000], [100, 150, 2000000000], [150, 200, 2000000000], [200, 250, 2000000000], [250, 300, 1000000000]]\n assert candidate(segments = [[1, 4, 5], [2, 6, 7], [3, 7, 9], [4, 8, 11], [5, 9, 13], [6, 10, 15]]) == [[1, 2, 5], [2, 3, 12], [3, 4, 21], [4, 5, 27], [5, 6, 40], [6, 7, 48], [7, 8, 39], [8, 9, 28], [9, 10, 15]]\n assert candidate(segments = [[10000, 10005, 1], [10001, 10006, 2], [10002, 10007, 3], [10003, 10008, 4], [10004, 10009, 5]]) == [[10000, 10001, 1], [10001, 10002, 3], [10002, 10003, 6], [10003, 10004, 10], [10004, 10005, 15], [10005, 10006, 14], [10006, 10007, 12], [10007, 10008, 9], [10008, 10009, 5]]\n assert candidate(segments = [[5, 10, 10], [10, 15, 20], [15, 20, 30], [20, 25, 40], [25, 30, 50], [30, 35, 60], [35, 40, 70], [40, 45, 80], [45, 50, 90], [50, 55, 100]]) == [[5, 10, 10], [10, 15, 20], [15, 20, 30], [20, 25, 40], [25, 30, 50], [30, 35, 60], [35, 40, 70], [40, 45, 80], [45, 50, 90], [50, 55, 100]]\n assert candidate(segments = [[1, 2, 1000000000], [2, 3, 1000000000], [3, 4, 1000000000], [4, 5, 1000000000], [5, 6, 1000000000]]) == [[1, 2, 1000000000], [2, 3, 1000000000], [3, 4, 1000000000], [4, 5, 1000000000], [5, 6, 1000000000]]\n assert candidate(segments = [[1, 100000, 1], [50000, 100000, 2], [1, 50000, 3], [25000, 75000, 4]]) == [[1, 25000, 4], [25000, 50000, 8], [50000, 75000, 7], [75000, 100000, 3]]\n assert candidate(segments = [[1, 5, 10], [2, 4, 20], [3, 6, 30], [4, 8, 40], [5, 9, 50], [6, 10, 60], [7, 11, 70], [8, 12, 80], [9, 13, 90]]) == [[1, 2, 10], [2, 3, 30], [3, 4, 60], [4, 5, 80], [5, 6, 120], [6, 7, 150], [7, 8, 220], [8, 9, 260], [9, 10, 300], [10, 11, 240], [11, 12, 170], [12, 13, 90]]\n assert candidate(segments = [[1, 3, 1000000000], [3, 5, 1000000000], [5, 7, 1000000000], [7, 9, 1000000000], [9, 11, 1000000000], [11, 13, 1000000000], [13, 15, 1000000000], [15, 17, 1000000000], [17, 19, 1000000000], [19, 21, 1000000000]]) == [[1, 3, 1000000000], [3, 5, 1000000000], [5, 7, 1000000000], [7, 9, 1000000000], [9, 11, 1000000000], [11, 13, 1000000000], [13, 15, 1000000000], [15, 17, 1000000000], [17, 19, 1000000000], [19, 21, 1000000000]]\n assert candidate(segments = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1]]) == [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1]]\n assert candidate(segments = [[1, 2, 1], [1, 2, 2], [1, 2, 3], [1, 2, 4], [1, 2, 5], [1, 2, 6], [1, 2, 7], [1, 2, 8], [1, 2, 9], [1, 2, 10]]) == [[1, 2, 55]]\n assert candidate(segments = [[5, 15, 100], [10, 20, 200], [15, 25, 300], [20, 30, 400], [25, 35, 500]]) == [[5, 10, 100], [10, 15, 300], [15, 20, 500], [20, 25, 700], [25, 30, 900], [30, 35, 500]]\n assert candidate(segments = [[1, 100000, 1000000], [50000, 100000, 900000], [1, 50000, 800000]]) == [[1, 50000, 1800000], [50000, 100000, 1900000]]\n assert candidate(segments = [[10, 20, 100], [15, 25, 50], [5, 30, 25], [20, 35, 75], [0, 40, 20]]) == [[0, 5, 20], [5, 10, 45], [10, 15, 145], [15, 20, 195], [20, 25, 170], [25, 30, 120], [30, 35, 95], [35, 40, 20]]\n assert candidate(segments = [[1, 2, 1000000000], [2, 3, 1000000000], [3, 4, 1000000000], [4, 5, 1000000000], [5, 6, 1000000000], [6, 7, 1000000000], [7, 8, 1000000000], [8, 9, 1000000000], [9, 10, 1000000000], [10, 11, 1000000000]]) == [[1, 2, 1000000000], [2, 3, 1000000000], [3, 4, 1000000000], [4, 5, 1000000000], [5, 6, 1000000000], [6, 7, 1000000000], [7, 8, 1000000000], [8, 9, 1000000000], [9, 10, 1000000000], [10, 11, 1000000000]]\n assert candidate(segments = [[1, 5, 1], [2, 4, 2], [3, 5, 3], [4, 6, 4], [5, 7, 5], [6, 8, 6]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 8], [5, 6, 9], [6, 7, 11], [7, 8, 6]]\n assert candidate(segments = [[100, 200, 500], [150, 250, 1000], [200, 300, 1500], [175, 225, 1200], [225, 275, 2200], [275, 325, 2500]]) == [[100, 150, 500], [150, 175, 1500], [175, 200, 2700], [200, 225, 3700], [225, 250, 4700], [250, 275, 3700], [275, 300, 4000], [300, 325, 2500]]\n assert candidate(segments = [[1, 20, 1], [2, 19, 2], [3, 18, 3], [4, 17, 4], [5, 16, 5], [6, 15, 6], [7, 14, 7], [8, 13, 8], [9, 12, 9], [10, 11, 10]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 10], [5, 6, 15], [6, 7, 21], [7, 8, 28], [8, 9, 36], [9, 10, 45], [10, 11, 55], [11, 12, 45], [12, 13, 36], [13, 14, 28], [14, 15, 21], [15, 16, 15], [16, 17, 10], [17, 18, 6], [18, 19, 3], [19, 20, 1]]\n assert candidate(segments = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15], [16, 17, 16], [17, 18, 17], [18, 19, 18], [19, 20, 19], [20, 21, 20]]) == [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15], [16, 17, 16], [17, 18, 17], [18, 19, 18], [19, 20, 19], [20, 21, 20]]\n assert candidate(segments = [[100000, 100001, 1000000000], [1, 100000, 1], [2, 99999, 2], [3, 99998, 3], [4, 99997, 4]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 99997, 10], [99997, 99998, 6], [99998, 99999, 3], [99999, 100000, 1], [100000, 100001, 1000000000]]\n assert candidate(segments = [[1, 5, 1], [2, 6, 2], [3, 7, 3], [4, 8, 4], [5, 9, 5], [6, 10, 6], [7, 11, 7], [8, 12, 8], [9, 13, 9], [10, 14, 10]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 10], [5, 6, 14], [6, 7, 18], [7, 8, 22], [8, 9, 26], [9, 10, 30], [10, 11, 34], [11, 12, 27], [12, 13, 19], [13, 14, 10]]\n assert candidate(segments = [[1, 5, 1], [1, 5, 2], [1, 5, 3], [1, 5, 4], [1, 5, 5], [1, 5, 6], [1, 5, 7], [1, 5, 8], [1, 5, 9], [1, 5, 10]]) == [[1, 5, 55]]\n assert candidate(segments = [[1, 5, 100], [2, 6, 200], [3, 7, 300], [4, 8, 400], [5, 9, 500], [6, 10, 600], [7, 11, 700], [8, 12, 800], [9, 13, 900], [10, 14, 1000]]) == [[1, 2, 100], [2, 3, 300], [3, 4, 600], [4, 5, 1000], [5, 6, 1400], [6, 7, 1800], [7, 8, 2200], [8, 9, 2600], [9, 10, 3000], [10, 11, 3400], [11, 12, 2700], [12, 13, 1900], [13, 14, 1000]]\n assert candidate(segments = [[1, 5, 1], [2, 4, 2], [3, 6, 3], [4, 8, 4], [5, 9, 5], [6, 10, 6]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 8], [5, 6, 12], [6, 8, 15], [8, 9, 11], [9, 10, 6]]\n assert candidate(segments = [[1, 5, 5], [2, 6, 6], [3, 7, 7], [4, 8, 8], [5, 9, 9], [6, 10, 10], [7, 11, 11], [8, 12, 12], [9, 13, 13], [10, 14, 14]]) == [[1, 2, 5], [2, 3, 11], [3, 4, 18], [4, 5, 26], [5, 6, 30], [6, 7, 34], [7, 8, 38], [8, 9, 42], [9, 10, 46], [10, 11, 50], [11, 12, 39], [12, 13, 27], [13, 14, 14]]\n assert candidate(segments = [[1, 10, 5], [5, 15, 7], [10, 20, 9], [1, 20, 3]]) == [[1, 5, 8], [5, 10, 15], [10, 15, 19], [15, 20, 12]]\n assert candidate(segments = [[1, 100000, 1], [2, 100001, 2], [3, 100002, 3], [4, 100003, 4], [5, 100004, 5], [6, 100005, 6], [7, 100006, 7], [8, 100007, 8], [9, 100008, 9], [10, 100009, 10]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 10], [5, 6, 15], [6, 7, 21], [7, 8, 28], [8, 9, 36], [9, 10, 45], [10, 100000, 55], [100000, 100001, 54], [100001, 100002, 52], [100002, 100003, 49], [100003, 100004, 45], [100004, 100005, 40], [100005, 100006, 34], [100006, 100007, 27], [100007, 100008, 19], [100008, 100009, 10]]\n assert candidate(segments = [[1, 10, 10], [2, 8, 20], [5, 15, 30], [10, 20, 40], [15, 25, 50]]) == [[1, 2, 10], [2, 5, 30], [5, 8, 60], [8, 10, 40], [10, 15, 70], [15, 20, 90], [20, 25, 50]]\n assert candidate(segments = [[1, 3, 10], [2, 4, 20], [3, 5, 30], [4, 6, 40], [5, 7, 50], [6, 8, 60], [7, 9, 70], [8, 10, 80], [9, 11, 90], [10, 12, 100]]) == [[1, 2, 10], [2, 3, 30], [3, 4, 50], [4, 5, 70], [5, 6, 90], [6, 7, 110], [7, 8, 130], [8, 9, 150], [9, 10, 170], [10, 11, 190], [11, 12, 100]]\n assert candidate(segments = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10]]) == [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10]]\n assert candidate(segments = [[1, 10, 1000000000], [2, 9, 900000000], [3, 8, 800000000], [4, 7, 700000000], [5, 6, 600000000]]) == [[1, 2, 1000000000], [2, 3, 1900000000], [3, 4, 2700000000], [4, 5, 3400000000], [5, 6, 4000000000], [6, 7, 3400000000], [7, 8, 2700000000], [8, 9, 1900000000], [9, 10, 1000000000]]\n assert candidate(segments = [[1, 10, 5], [2, 8, 10], [3, 7, 15], [4, 6, 20]]) == [[1, 2, 5], [2, 3, 15], [3, 4, 30], [4, 6, 50], [6, 7, 30], [7, 8, 15], [8, 10, 5]]\n assert candidate(segments = [[2, 6, 7], [3, 8, 3], [5, 9, 5], [1, 4, 10], [6, 11, 2]]) == [[1, 2, 10], [2, 3, 17], [3, 4, 20], [4, 5, 10], [5, 6, 15], [6, 8, 10], [8, 9, 7], [9, 11, 2]]\n assert candidate(segments = [[5, 10, 1], [10, 15, 2], [15, 20, 3], [20, 25, 4], [25, 30, 5], [30, 35, 6], [35, 40, 7], [40, 45, 8], [45, 50, 9], [50, 55, 10]]) == [[5, 10, 1], [10, 15, 2], [15, 20, 3], [20, 25, 4], [25, 30, 5], [30, 35, 6], [35, 40, 7], [40, 45, 8], [45, 50, 9], [50, 55, 10]]\n assert candidate(segments = [[100, 200, 1], [150, 250, 2], [200, 300, 3], [250, 350, 4], [300, 400, 5], [350, 450, 6], [400, 500, 7], [450, 550, 8], [500, 600, 9], [550, 650, 10]]) == [[100, 150, 1], [150, 200, 3], [200, 250, 5], [250, 300, 7], [300, 350, 9], [350, 400, 11], [400, 450, 13], [450, 500, 15], [500, 550, 17], [550, 600, 19], [600, 650, 10]]\n assert candidate(segments = [[1, 100, 1], [50, 150, 2], [100, 200, 3], [150, 250, 4], [200, 300, 5]]) == [[1, 50, 1], [50, 100, 3], [100, 150, 5], [150, 200, 7], [200, 250, 9], [250, 300, 5]]\n assert candidate(segments = [[10, 20, 100], [15, 25, 200], [20, 30, 300], [12, 18, 150], [17, 23, 250]]) == [[10, 12, 100], [12, 15, 250], [15, 17, 450], [17, 18, 700], [18, 20, 550], [20, 23, 750], [23, 25, 500], [25, 30, 300]]\n assert candidate(segments = [[1, 3, 1000000000], [2, 4, 500000000], [3, 5, 300000000], [4, 6, 200000000], [5, 7, 100000000]]) == [[1, 2, 1000000000], [2, 3, 1500000000], [3, 4, 800000000], [4, 5, 500000000], [5, 6, 300000000], [6, 7, 100000000]]\n assert candidate(segments = [[10, 20, 5], [15, 25, 6], [20, 30, 7], [10, 30, 3], [25, 35, 8]]) == [[10, 15, 8], [15, 20, 14], [20, 25, 16], [25, 30, 18], [30, 35, 8]]\n assert candidate(segments = [[1, 50000, 1], [2, 50001, 2], [3, 50002, 3], [4, 50003, 4], [5, 50004, 5]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 10], [5, 50000, 15], [50000, 50001, 14], [50001, 50002, 12], [50002, 50003, 9], [50003, 50004, 5]]\n assert candidate(segments = [[1, 10, 5], [2, 9, 15], [3, 8, 25], [4, 7, 35], [5, 6, 45]]) == [[1, 2, 5], [2, 3, 20], [3, 4, 45], [4, 5, 80], [5, 6, 125], [6, 7, 80], [7, 8, 45], [8, 9, 20], [9, 10, 5]]\n assert candidate(segments = [[1, 10, 5], [5, 15, 10], [10, 20, 15]]) == [[1, 5, 5], [5, 10, 15], [10, 15, 25], [15, 20, 15]]\n assert candidate(segments = [[1, 100, 1], [50, 150, 2], [100, 200, 3], [150, 250, 4], [200, 300, 5], [250, 350, 6], [300, 400, 7], [350, 450, 8], [400, 500, 9], [450, 550, 10]]) == [[1, 50, 1], [50, 100, 3], [100, 150, 5], [150, 200, 7], [200, 250, 9], [250, 300, 11], [300, 350, 13], [350, 400, 15], [400, 450, 17], [450, 500, 19], [500, 550, 10]]\n assert candidate(segments = [[10, 20, 100], [15, 25, 50], [5, 15, 200]]) == [[5, 10, 200], [10, 15, 300], [15, 20, 150], [20, 25, 50]]\n assert candidate(segments = [[1, 10, 100], [5, 15, 200], [10, 20, 300], [15, 25, 400]]) == [[1, 5, 100], [5, 10, 300], [10, 15, 500], [15, 20, 700], [20, 25, 400]]\n assert candidate(segments = [[1, 2, 1000000000], [1, 2, 1000000000], [1, 2, 1000000000], [1, 2, 1000000000], [1, 2, 1000000000], [1, 2, 1000000000], [1, 2, 1000000000], [1, 2, 1000000000], [1, 2, 1000000000], [1, 2, 1000000000]]) == [[1, 2, 10000000000]]\n assert candidate(segments = [[1, 10, 1], [2, 8, 2], [3, 7, 3], [4, 6, 4], [5, 5, 5]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 10], [5, 6, 10], [6, 7, 6], [7, 8, 3], [8, 10, 1]]\n assert candidate(segments = [[1, 2, 1000000000], [2, 3, 1000000000], [3, 4, 1000000000], [4, 5, 1000000000], [5, 6, 1000000000], [6, 7, 1000000000], [7, 8, 1000000000], [8, 9, 1000000000], [9, 10, 1000000000]]) == [[1, 2, 1000000000], [2, 3, 1000000000], [3, 4, 1000000000], [4, 5, 1000000000], [5, 6, 1000000000], [6, 7, 1000000000], [7, 8, 1000000000], [8, 9, 1000000000], [9, 10, 1000000000]]\n assert candidate(segments = [[1, 100, 1], [1, 100, 2], [1, 100, 3], [1, 100, 4], [1, 100, 5], [1, 100, 6], [1, 100, 7], [1, 100, 8], [1, 100, 9], [1, 100, 10]]) == [[1, 100, 55]]\n assert candidate(segments = [[1, 10, 1], [2, 9, 2], [3, 8, 3], [4, 7, 4], [5, 6, 5]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 10], [5, 6, 15], [6, 7, 10], [7, 8, 6], [8, 9, 3], [9, 10, 1]]\n assert candidate(segments = [[10, 20, 5], [5, 15, 10], [20, 30, 15], [15, 25, 20], [25, 35, 25], [30, 40, 30]]) == [[5, 10, 10], [10, 15, 15], [15, 20, 25], [20, 25, 35], [25, 30, 40], [30, 35, 55], [35, 40, 30]]\n assert candidate(segments = [[1, 3, 10], [3, 5, 20], [5, 7, 30], [7, 9, 40], [9, 11, 50], [11, 13, 60], [13, 15, 70]]) == [[1, 3, 10], [3, 5, 20], [5, 7, 30], [7, 9, 40], [9, 11, 50], [11, 13, 60], [13, 15, 70]]\n assert candidate(segments = [[1, 10, 1], [1, 10, 2], [1, 10, 3], [1, 10, 4], [1, 10, 5], [1, 10, 6], [1, 10, 7], [1, 10, 8], [1, 10, 9], [1, 10, 10]]) == [[1, 10, 55]]\n assert candidate(segments = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15]]) == [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15]]\n assert candidate(segments = [[1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [1, 7, 6], [1, 8, 7], [1, 9, 8], [1, 10, 9]]) == [[1, 2, 45], [2, 3, 44], [3, 4, 42], [4, 5, 39], [5, 6, 35], [6, 7, 30], [7, 8, 24], [8, 9, 17], [9, 10, 9]]\n assert candidate(segments = [[1, 10, 10], [2, 9, 9], [3, 8, 8], [4, 7, 7], [5, 6, 6], [6, 5, 5], [7, 4, 4], [8, 3, 3], [9, 2, 2], [10, 1, 1]]) == [[1, 2, 9], [2, 3, 16], [3, 4, 21], [4, 5, 24], [5, 6, 25], [6, 7, 24], [7, 8, 21], [8, 9, 16], [9, 10, 9]]\n assert candidate(segments = [[5, 10, 10], [10, 15, 10], [15, 20, 10], [20, 25, 10], [25, 30, 10], [30, 35, 10], [35, 40, 10], [40, 45, 10], [45, 50, 10], [50, 55, 10]]) == [[5, 10, 10], [10, 15, 10], [15, 20, 10], [20, 25, 10], [25, 30, 10], [30, 35, 10], [35, 40, 10], [40, 45, 10], [45, 50, 10], [50, 55, 10]]\n assert candidate(segments = [[1, 1000, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1], [19, 20, 1], [20, 1000, 1]]) == [[1, 2, 2], [2, 3, 2], [3, 4, 2], [4, 5, 2], [5, 6, 2], [6, 7, 2], [7, 8, 2], [8, 9, 2], [9, 10, 2], [10, 11, 2], [11, 12, 2], [12, 13, 2], [13, 14, 2], [14, 15, 2], [15, 16, 2], [16, 17, 2], [17, 18, 2], [18, 19, 2], [19, 20, 2], [20, 1000, 2]]\n assert candidate(segments = [[1, 100, 1], [2, 99, 2], [3, 98, 3], [4, 97, 4], [5, 96, 5], [6, 95, 6], [7, 94, 7], [8, 93, 8], [9, 92, 9], [10, 91, 10]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 10], [5, 6, 15], [6, 7, 21], [7, 8, 28], [8, 9, 36], [9, 10, 45], [10, 91, 55], [91, 92, 45], [92, 93, 36], [93, 94, 28], [94, 95, 21], [95, 96, 15], [96, 97, 10], [97, 98, 6], [98, 99, 3], [99, 100, 1]]\n assert candidate(segments = [[1, 10, 10], [2, 8, 20], [5, 15, 30], [10, 20, 40]]) == [[1, 2, 10], [2, 5, 30], [5, 8, 60], [8, 10, 40], [10, 15, 70], [15, 20, 40]]\n assert candidate(segments = [[10, 20, 100], [20, 30, 200], [30, 40, 300], [40, 50, 400], [50, 60, 500], [60, 70, 600], [70, 80, 700], [80, 90, 800], [90, 100, 900], [100, 110, 1000]]) == [[10, 20, 100], [20, 30, 200], [30, 40, 300], [40, 50, 400], [50, 60, 500], [60, 70, 600], [70, 80, 700], [80, 90, 800], [90, 100, 900], [100, 110, 1000]]\n assert candidate(segments = [[1, 3, 1000000000], [2, 4, 1000000000], [3, 5, 1000000000], [4, 6, 1000000000], [5, 7, 1000000000]]) == [[1, 2, 1000000000], [2, 3, 2000000000], [3, 4, 2000000000], [4, 5, 2000000000], [5, 6, 2000000000], [6, 7, 1000000000]]\n assert candidate(segments = [[10, 20, 5], [15, 25, 7], [20, 30, 9], [25, 35, 11], [30, 40, 13], [35, 45, 15], [40, 50, 17], [45, 55, 19], [50, 60, 21], [55, 65, 23]]) == [[10, 15, 5], [15, 20, 12], [20, 25, 16], [25, 30, 20], [30, 35, 24], [35, 40, 28], [40, 45, 32], [45, 50, 36], [50, 55, 40], [55, 60, 44], [60, 65, 23]]\n assert candidate(segments = [[1, 10000, 1], [2, 9999, 2], [3, 9998, 3], [4, 9997, 4], [5, 9996, 5]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 6], [4, 5, 10], [5, 9996, 15], [9996, 9997, 10], [9997, 9998, 6], [9998, 9999, 3], [9999, 10000, 1]]\n assert candidate(segments = [[1, 5, 10], [2, 6, 20], [3, 7, 30], [4, 8, 40], [5, 9, 50]]) == [[1, 2, 10], [2, 3, 30], [3, 4, 60], [4, 5, 100], [5, 6, 140], [6, 7, 120], [7, 8, 90], [8, 9, 50]]\n assert candidate(segments = [[10, 20, 1], [15, 25, 2], [20, 30, 3], [25, 35, 4], [30, 40, 5], [35, 45, 6], [40, 50, 7], [45, 55, 8], [50, 60, 9], [55, 65, 10]]) == [[10, 15, 1], [15, 20, 3], [20, 25, 5], [25, 30, 7], [30, 35, 9], [35, 40, 11], [40, 45, 13], [45, 50, 15], [50, 55, 17], [55, 60, 19], [60, 65, 10]]\n assert candidate(segments = [[1, 2, 9], [2, 3, 8], [3, 4, 7], [4, 5, 6], [5, 6, 5], [6, 7, 4], [7, 8, 3], [8, 9, 2], [9, 10, 1]]) == [[1, 2, 9], [2, 3, 8], [3, 4, 7], [4, 5, 6], [5, 6, 5], [6, 7, 4], [7, 8, 3], [8, 9, 2], [9, 10, 1]]\n assert candidate(segments = [[1, 5, 1], [2, 4, 2], [3, 6, 3], [1, 3, 4], [2, 5, 5], [3, 4, 6], [4, 5, 7], [5, 6, 8]]) == [[1, 2, 5], [2, 3, 12], [3, 4, 17], [4, 5, 16], [5, 6, 11]]\n assert candidate(segments = [[1, 10, 1], [10, 20, 2], [20, 30, 3], [30, 40, 4], [40, 50, 5], [50, 60, 6], [60, 70, 7], [70, 80, 8], [80, 90, 9], [90, 100, 10]]) == [[1, 10, 1], [10, 20, 2], [20, 30, 3], [30, 40, 4], [40, 50, 5], [50, 60, 6], [60, 70, 7], [70, 80, 8], [80, 90, 9], [90, 100, 10]]\n assert candidate(segments = [[1, 10, 10], [2, 9, 20], [3, 8, 30], [4, 7, 40], [5, 6, 50], [1, 10, 1], [2, 9, 2], [3, 8, 3], [4, 7, 4], [5, 6, 5]]) == [[1, 2, 11], [2, 3, 33], [3, 4, 66], [4, 5, 110], [5, 6, 165], [6, 7, 110], [7, 8, 66], [8, 9, 33], [9, 10, 11]]\n assert candidate(segments = [[1, 5, 1], [1, 5, 2], [1, 5, 3], [1, 5, 4], [1, 5, 5], [1, 5, 6], [1, 5, 7], [1, 5, 8], [1, 5, 9], [1, 5, 10]]) == [[1, 5, 55]]\n assert candidate(segments = [[1, 100000, 1], [1, 100000, 2], [1, 100000, 3], [1, 100000, 4], [1, 100000, 5]]) == [[1, 100000, 15]]\n assert candidate(segments = [[1, 100000, 1], [50000, 150000, 2], [25000, 75000, 3], [1, 50000, 4], [100000, 150000, 5]]) == [[1, 25000, 5], [25000, 50000, 8], [50000, 75000, 6], [75000, 100000, 3], [100000, 150000, 7]]\n assert candidate(segments = [[10, 20, 1], [20, 30, 2], [30, 40, 3], [40, 50, 4], [50, 60, 5], [60, 70, 6], [70, 80, 7], [80, 90, 8], [90, 100, 9], [100, 110, 10]]) == [[10, 20, 1], [20, 30, 2], [30, 40, 3], [40, 50, 4], [50, 60, 5], [60, 70, 6], [70, 80, 7], [80, 90, 8], [90, 100, 9], [100, 110, 10]]\n assert candidate(segments = [[1, 100, 100], [20, 50, 200], [30, 40, 300], [40, 60, 400], [50, 70, 500], [60, 80, 600], [70, 90, 700], [80, 100, 800]]) == [[1, 20, 100], [20, 30, 300], [30, 40, 600], [40, 50, 700], [50, 60, 1000], [60, 70, 1200], [70, 80, 1400], [80, 90, 1600], [90, 100, 900]]\n assert candidate(segments = [[1, 2, 1], [1, 3, 2], [1, 4, 3], [1, 5, 4], [1, 6, 5], [1, 7, 6], [1, 8, 7], [1, 9, 8], [1, 10, 9], [1, 11, 10]]) == [[1, 2, 55], [2, 3, 54], [3, 4, 52], [4, 5, 49], [5, 6, 45], [6, 7, 40], [7, 8, 34], [8, 9, 27], [9, 10, 19], [10, 11, 10]]\n assert candidate(segments = [[1, 5, 1], [2, 4, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9]]) == [[1, 2, 1], [2, 3, 3], [3, 4, 3], [4, 5, 1], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9]]\n"}, "metadata": {"canonical_parameter_names": ["segments"], "leetcode_dataset_entry_point": "Solution().splitPainting", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector> splitPainting(vector>& segments) {", "container": "Solution", "callable": "splitPainting", "parameters": [{"name": "segments", "type": "vector>&"}], "return_type": "vector>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1944, "task_id": "number-of-visible-people-in-a-queue", "difficulty": "Hard", "problem_description": "There are n people standing in a queue, and they numbered from 0 to n - 1 in left to right order. You are given an array heights of distinct integers where heights[i] represents the height of the ith person.\nA person can see another person to their right in the queue if everybody in between is shorter than both of them. More formally, the ith person can see the jth person if i < j and min(heights[i], heights[j]) > max(heights[i+1], heights[i+2], ..., heights[j-1]).\nReturn an array answer of length n where answer[i] is the number of people the ith person can see to their right in the queue.\n \nExample 1:\n\n\nInput: heights = [10,6,8,5,11,9]\nOutput: [3,1,2,1,1,0]\nExplanation:\nPerson 0 can see person 1, 2, and 4.\nPerson 1 can see person 2.\nPerson 2 can see person 3 and 4.\nPerson 3 can see person 4.\nPerson 4 can see person 5.\nPerson 5 can see no one since nobody is to the right of them.\n\nExample 2:\n\nInput: heights = [5,1,2,3,10]\nOutput: [4,1,1,1,0]\n\n \nConstraints:\n\nn == heights.length\n1 <= n <= 105\n1 <= heights[i] <= 105\nAll the values of heights are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(heights = [1]) == [0]\n assert candidate(heights = [1, 2, 3, 6, 5, 4, 10, 9, 8, 7]) == [1, 1, 1, 2, 2, 1, 1, 1, 1, 0]\n assert candidate(heights = [5, 1, 2, 3, 10]) == [4, 1, 1, 1, 0]\n assert candidate(heights = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [5, 4, 3, 2, 1]) == [1, 1, 1, 1, 0]\n assert candidate(heights = [10, 6, 8, 5, 11, 9]) == [3, 1, 2, 1, 1, 0]\n assert candidate(heights = [3, 1, 2]) == [2, 1, 0]\n assert candidate(heights = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0]\n assert candidate(heights = [100, 80, 60, 70, 60, 75, 85]) == [2, 4, 1, 2, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5]) == [1, 1, 1, 1, 0]\n assert candidate(heights = [3, 1, 4, 2, 5]) == [2, 1, 2, 1, 0]\n assert candidate(heights = [100000]) == [0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == [2, 1, 2, 1, 1, 2, 1, 2, 2, 1, 0]\n assert candidate(heights = [1, 9, 2, 8, 3, 7, 4, 6, 5, 14, 13, 12, 11, 10]) == [1, 3, 1, 3, 1, 3, 1, 2, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5, 60, 6, 70, 7, 80, 8, 90, 9, 100, 10]) == [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [5, 9, 2, 8, 7, 6, 3, 4, 1, 10]) == [1, 3, 1, 2, 2, 3, 1, 2, 1, 0]\n assert candidate(heights = [10, 20, 15, 25, 30, 5, 35, 40, 45, 50]) == [1, 2, 1, 1, 2, 1, 1, 1, 1, 0]\n assert candidate(heights = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [5, 1, 7, 2, 6, 3, 5, 4, 8, 9, 10, 11, 12, 13, 14]) == [2, 1, 3, 1, 3, 1, 2, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980, 99979, 99978, 99977, 99976, 99975, 99974, 99973, 99972, 99971, 99970]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 12, 14, 16, 18, 20, 11, 13, 15, 17, 19]) == [1, 1, 1, 1, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [1, 5, 2, 6, 3, 7, 4, 8, 9, 10]) == [1, 2, 1, 2, 1, 2, 1, 1, 1, 0]\n assert candidate(heights = [5, 1, 3, 2, 4, 6, 7, 8, 9, 10]) == [4, 1, 2, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [100000, 1, 99999, 2, 99998, 3, 99997, 4, 99996, 5]) == [2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [3, 6, 5, 4, 3, 2, 1, 7, 8, 9]) == [1, 2, 2, 2, 2, 2, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1]) == [1, 1, 3, 2, 1, 1, 3, 2, 1, 1, 3, 2, 1, 1, 3, 2, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994, 8, 99993, 9, 99992, 10, 99991]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [5, 1, 3, 2, 6, 4, 8, 7, 10, 9]) == [3, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [50, 10, 51, 11, 52, 12, 53, 13, 54, 14]) == [2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [2, 1, 5, 4, 3, 8, 7, 6, 10, 9, 14, 13, 12, 18, 17, 16, 20, 19, 22, 21]) == [2, 1, 2, 2, 1, 2, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [100000, 1, 100000, 2, 100000, 3, 100000, 4, 100000, 5]) == [2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [5, 3, 8, 6, 11, 9, 14, 12, 17, 15, 20, 18, 23, 21, 26, 24, 29, 27, 32, 30, 35, 33, 38, 36, 39]) == [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 2, 4, 6, 8, 10]) == [1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 0]\n assert candidate(heights = [15, 10, 5, 14, 9, 4, 13, 8, 3, 12, 7, 2, 11, 6, 1]) == [2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 5, 2, 6, 3, 7, 4, 8, 9, 10]) == [1, 2, 1, 2, 1, 2, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == [1, 1, 1, 3, 3, 2, 1, 1, 1, 0]\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5, 11, 12, 13, 14, 15]) == [3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0]\n assert candidate(heights = [5, 4, 3, 2, 1, 10]) == [2, 2, 2, 2, 1, 0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15, 14, 16, 15, 17]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 99999]) == [30, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [50000, 40000, 30000, 20000, 10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [2, 4, 6, 8, 10, 1, 3, 5, 7, 9]) == [1, 1, 1, 1, 5, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 10, 3, 9, 5, 8, 7, 2, 6, 4]) == [1, 2, 1, 2, 1, 1, 2, 1, 1, 0]\n assert candidate(heights = [10, 5, 6, 7, 1, 2, 3, 4, 8, 9]) == [5, 1, 1, 5, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == [1, 1, 3, 2, 1, 1, 3, 2, 1, 1, 3, 2, 1, 1, 0]\n assert candidate(heights = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [1, 2, 3, 5, 4, 6, 7, 8, 9, 10]) == [1, 1, 1, 2, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19, 22, 21, 24, 23]) == [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15, 14, 12, 10, 8, 6, 4, 2]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [5, 8, 4, 9, 7, 6, 10, 3, 2, 1, 11, 14, 12, 13, 16, 15, 18, 17, 20, 19]) == [1, 2, 1, 2, 2, 1, 2, 2, 2, 1, 1, 3, 1, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [1, 20, 2, 19, 3, 18, 4, 17, 5, 16, 6, 15, 7, 14, 8, 13, 9, 12, 10, 11]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5, 15, 11, 14, 12, 13, 20, 16, 19, 17, 18]) == [3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 3, 1, 3, 1, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [5, 3, 8, 6, 7, 2, 4, 1, 10, 9]) == [2, 1, 3, 1, 3, 1, 2, 1, 1, 0]\n assert candidate(heights = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == [2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 20, 15, 30, 25, 40, 35, 50, 45, 60, 55, 70, 65, 80, 75, 90, 85, 100, 95, 110]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 20, 12, 19, 13, 18, 14, 17, 15, 16]) == [1, 3, 1, 3, 1, 3, 1, 3, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [10, 1, 20, 3, 40, 5, 60, 7, 80, 9, 100]) == [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [3, 3, 3, 3, 3, 3, 3, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [5, 1, 3, 2, 4, 6, 8, 7, 10, 9]) == [4, 1, 2, 1, 1, 1, 2, 1, 1, 0]\n assert candidate(heights = [100, 50, 75, 25, 60, 35, 80, 10, 90, 40]) == [4, 1, 3, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [10, 20, 15, 25, 30, 5, 10, 15, 20, 25]) == [1, 2, 1, 1, 5, 1, 1, 1, 1, 0]\n assert candidate(heights = [50, 20, 40, 10, 30, 60, 70, 80, 90, 100]) == [3, 1, 3, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 15, 4, 3, 2, 1, 16, 17, 18, 19]) == [2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [5, 9, 1, 4, 6, 8, 2, 3, 7, 10]) == [1, 5, 1, 1, 1, 4, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 105, 95, 85, 75, 65, 55, 45, 35, 25, 15]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [77, 73, 69, 65, 61, 57, 53, 49, 45, 41, 37, 33, 29, 25, 21, 17, 13, 9, 5, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [5, 1, 3, 2, 4, 6, 2, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]) == [4, 1, 2, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 11, 12, 13, 14, 15, 20, 19, 18, 17, 16]) == [1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == [2, 2, 2, 2, 2, 2, 2, 2, 1, 0]\n assert candidate(heights = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15]) == [1, 3, 1, 3, 1, 3, 1, 3, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 1, 10, 2, 10, 3, 10, 4, 10, 5]) == [2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [100000, 99999, 99998, 99997, 99996, 99995]) == [1, 1, 1, 1, 1, 0]\n assert candidate(heights = [50, 40, 30, 20, 10, 5, 15, 25, 35, 45]) == [2, 3, 3, 3, 2, 1, 1, 1, 1, 0]\n assert candidate(heights = [10, 20, 15, 25, 30, 5, 10, 35, 40, 45]) == [1, 2, 1, 1, 3, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 3, 2, 6, 5, 4, 10, 9, 8, 7, 14, 13, 12, 11, 20, 19, 18, 17, 16, 15]) == [1, 2, 1, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [5, 3, 8, 6, 7, 2, 4, 9, 1, 10]) == [2, 1, 3, 1, 3, 1, 1, 2, 1, 0]\n assert candidate(heights = [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 18]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 1, 0]\n assert candidate(heights = [1, 5, 3, 7, 2, 8, 4, 9, 6, 10]) == [1, 2, 1, 2, 1, 2, 1, 2, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 11, 12, 13, 14, 15]) == [1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 0]\n assert candidate(heights = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == [2, 2, 2, 2, 1, 1, 1, 1, 1, 0]\n"}, "metadata": {"canonical_parameter_names": ["heights"], "leetcode_dataset_entry_point": "Solution().canSeePersonsCount", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector canSeePersonsCount(vector& heights) {", "container": "Solution", "callable": "canSeePersonsCount", "parameters": [{"name": "heights", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1945, "task_id": "sum-of-digits-of-string-after-convert", "difficulty": "Easy", "problem_description": "You are given a string s consisting of lowercase English letters, and an integer k. Your task is to convert the string into an integer by a special process, and then transform it by summing its digits repeatedly k times. More specifically, perform the following steps:\n\nConvert s into an integer by replacing each letter with its position in the alphabet (i.e. replace 'a' with 1, 'b' with 2, ..., 'z' with 26).\nTransform the integer by replacing it with the sum of its digits.\nRepeat the transform operation (step 2) k times in total.\n\nFor example, if s = \"zbax\" and k = 2, then the resulting integer would be 8 by the following operations:\n\nConvert: \"zbax\" ➝ \"(26)(2)(1)(24)\" ➝ \"262124\" ➝ 262124\nTransform #1: 262124 ➝ 2 + 6 + 2 + 1 + 2 + 4 ➝ 17\nTransform #2: 17 ➝ 1 + 7 ➝ 8\n\nReturn the resulting integer after performing the operations described above.\n \nExample 1:\n\nInput: s = \"iiii\", k = 1\nOutput: 36\nExplanation:\nThe operations are as follows:\n- Convert: \"iiii\" ➝ \"(9)(9)(9)(9)\" ➝ \"9999\" ➝ 9999\n- Transform #1: 9999 ➝ 9 + 9 + 9 + 9 ➝ 36\nThus the resulting integer is 36.\n\nExample 2:\n\nInput: s = \"leetcode\", k = 2\nOutput: 6\nExplanation:\nThe operations are as follows:\n- Convert: \"leetcode\" ➝ \"(12)(5)(5)(20)(3)(15)(4)(5)\" ➝ \"12552031545\" ➝ 12552031545\n- Transform #1: 12552031545 ➝ 1 + 2 + 5 + 5 + 2 + 0 + 3 + 1 + 5 + 4 + 5 ➝ 33\n- Transform #2: 33 ➝ 3 + 3 ➝ 6\nThus the resulting integer is 6.\n\nExample 3:\n\nInput: s = \"zbax\", k = 2\nOutput: 8\n\n \nConstraints:\n\n1 <= s.length <= 100\n1 <= k <= 10\ns consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"zzzz\",k = 1) == 32\n assert candidate(s = \"zzz\",k = 10) == 6\n assert candidate(s = \"programming\",k = 1) == 68\n assert candidate(s = \"abz\",k = 5) == 2\n assert candidate(s = \"a\",k = 1) == 1\n assert candidate(s = \"aaa\",k = 3) == 3\n assert candidate(s = \"challenge\",k = 2) == 4\n assert candidate(s = \"iiii\",k = 1) == 36\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 1) == 135\n assert candidate(s = \"hello\",k = 1) == 25\n assert candidate(s = \"python\",k = 2) == 8\n assert candidate(s = \"abc\",k = 3) == 6\n assert candidate(s = \"zbax\",k = 2) == 8\n assert candidate(s = \"abcxyz\",k = 3) == 9\n assert candidate(s = \"leetcode\",k = 2) == 6\n assert candidate(s = \"a\",k = 10) == 1\n assert candidate(s = \"zzzz\",k = 3) == 5\n assert candidate(s = \"zzzzzzzzzz\",k = 1) == 80\n assert candidate(s = \"algorithms\",k = 4) == 5\n assert candidate(s = \"repeatthisoverandover\",k = 7) == 8\n assert candidate(s = \"zzzzzzzzzz\",k = 6) == 8\n assert candidate(s = \"interview\",k = 5) == 8\n assert candidate(s = \"artificialintelligence\",k = 7) == 5\n assert candidate(s = \"zzyxwvutsrqponmlkjihgfedcba\",k = 4) == 8\n assert candidate(s = \"singleletterx\",k = 10) == 8\n assert candidate(s = \"thisisaverylongstringwhichshouldbeconverted\",k = 4) == 2\n assert candidate(s = \"zzzzzzzzzz\",k = 3) == 8\n assert candidate(s = \"hippopotamus\",k = 10) == 7\n assert candidate(s = \"qwen\",k = 5) == 5\n assert candidate(s = \"datastructure\",k = 4) == 9\n assert candidate(s = \"quickbrownfoxjumpsoverthelazydog\",k = 3) == 8\n assert candidate(s = \"repeatedlettersqqqq\",k = 6) == 7\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 2) == 9\n assert candidate(s = \"programming\",k = 3) == 5\n assert candidate(s = \"unbelievable\",k = 9) == 2\n assert candidate(s = \"mississippi\",k = 7) == 4\n assert candidate(s = \"zebra\",k = 6) == 7\n assert candidate(s = \"zzzzzzzzzz\",k = 10) == 8\n assert candidate(s = \"xyzxyz\",k = 3) == 6\n assert candidate(s = \"supercalifragilisticexpialidocious\",k = 5) == 1\n assert candidate(s = \"onetwothreefourfivesixseveneightnine\",k = 5) == 8\n assert candidate(s = \"generateadditionalinputs\",k = 8) == 2\n assert candidate(s = \"quickbrownfoxjumpsoverthelazydog\",k = 4) == 8\n assert candidate(s = \"multifarious\",k = 7) == 2\n assert candidate(s = \"consecutivesimilar\",k = 8) == 1\n assert candidate(s = \"neuralnetwork\",k = 8) == 6\n assert candidate(s = \"developerslovepython\",k = 9) == 3\n assert candidate(s = \"algorithm\",k = 1) == 49\n assert candidate(s = \"wearethebestprogrammers\",k = 7) == 4\n assert candidate(s = \"xylophone\",k = 3) == 8\n assert candidate(s = \"alibabacloud\",k = 7) == 2\n assert candidate(s = \"aaaaaaaaaa\",k = 10) == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 5) == 9\n assert candidate(s = \"elephant\",k = 8) == 9\n assert candidate(s = \"supercalifragilisticexpialidocious\",k = 4) == 1\n assert candidate(s = \"abcdefghij\",k = 5) == 1\n assert candidate(s = \"repeatedletters\",k = 4) == 2\n assert candidate(s = \"datastructures\",k = 5) == 1\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 3) == 9\n assert candidate(s = \"facetious\",k = 8) == 9\n assert candidate(s = \"numericalsum\",k = 7) == 5\n assert candidate(s = \"expertise\",k = 2) == 13\n assert candidate(s = \"codingcontest\",k = 6) == 4\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcba\",k = 4) == 9\n assert candidate(s = \"alibabacloud\",k = 2) == 11\n assert candidate(s = \"manytimesk\",k = 10) == 4\n assert candidate(s = \"quickbrownfoxjumpsoverthelazydog\",k = 6) == 8\n assert candidate(s = \"giraffe\",k = 9) == 7\n assert candidate(s = \"qwen\",k = 10) == 5\n assert candidate(s = \"mississippi\",k = 8) == 4\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 10) == 9\n assert candidate(s = \"quickbrownfoxjumpsoverthelazydog\",k = 10) == 8\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 10) == 4\n assert candidate(s = \"solution\",k = 7) == 8\n assert candidate(s = \"abacaxabacax\",k = 5) == 1\n assert candidate(s = \"algorithms\",k = 5) == 5\n assert candidate(s = \"zzzzzzzzzz\",k = 5) == 8\n assert candidate(s = \"transform\",k = 8) == 7\n assert candidate(s = \"congratulations\",k = 5) == 9\n assert candidate(s = \"xylophone\",k = 4) == 8\n assert candidate(s = \"quickbrownfoxjumpsoverthelazydog\",k = 2) == 8\n assert candidate(s = \"qwen\",k = 4) == 5\n assert candidate(s = \"leetcodeisfun\",k = 9) == 3\n assert candidate(s = \"programmingisfun\",k = 3) == 2\n assert candidate(s = \"machinelearning\",k = 6) == 7\n assert candidate(s = \"abcdefg\",k = 10) == 1\n assert candidate(s = \"thequickbrownfoxjumpsoverthelazydog\",k = 6) == 5\n assert candidate(s = \"thisisaverylongandcomplexstring\",k = 6) == 1\n assert candidate(s = \"xylophone\",k = 5) == 8\n assert candidate(s = \"thisisanexampletocheckthecomplexity\",k = 4) == 1\n assert candidate(s = \"datastructure\",k = 5) == 9\n assert candidate(s = \"abacaxi\",k = 3) == 5\n assert candidate(s = \"abcdabcdabcd\",k = 4) == 3\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().getLucky", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int getLucky(string s, int k) {", "container": "Solution", "callable": "getLucky", "parameters": [{"name": "s", "type": "string"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1946, "task_id": "largest-number-after-mutating-substring", "difficulty": "Medium", "problem_description": "You are given a string num, which represents a large integer. You are also given a 0-indexed integer array change of length 10 that maps each digit 0-9 to another digit. More formally, digit d maps to digit change[d].\nYou may choose to mutate a single substring of num. To mutate a substring, replace each digit num[i] with the digit it maps to in change (i.e. replace num[i] with change[num[i]]).\nReturn a string representing the largest possible integer after mutating (or choosing not to) a single substring of num.\nA substring is a contiguous sequence of characters within the string.\n \nExample 1:\n\nInput: num = \"132\", change = [9,8,5,0,3,6,4,2,6,8]\nOutput: \"832\"\nExplanation: Replace the substring \"1\":\n- 1 maps to change[1] = 8.\nThus, \"132\" becomes \"832\".\n\"832\" is the largest number that can be created, so return it.\n\nExample 2:\n\nInput: num = \"021\", change = [9,4,3,5,7,2,1,9,0,6]\nOutput: \"934\"\nExplanation: Replace the substring \"021\":\n- 0 maps to change[0] = 9.\n- 2 maps to change[2] = 3.\n- 1 maps to change[1] = 4.\nThus, \"021\" becomes \"934\".\n\"934\" is the largest number that can be created, so return it.\n\nExample 3:\n\nInput: num = \"5\", change = [1,4,7,5,3,2,5,6,9,4]\nOutput: \"5\"\nExplanation: \"5\" is already the largest number that can be created, so return it.\n\n \nConstraints:\n\n1 <= num.length <= 105\nnum consists of only digits 0-9.\nchange.length == 10\n0 <= change[d] <= 9\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = \"132\",change = [9, 8, 5, 0, 3, 6, 4, 2, 6, 8]) == \"832\"\n assert candidate(num = \"1111\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999\"\n assert candidate(num = \"5\",change = [1, 4, 7, 5, 3, 2, 5, 6, 9, 4]) == \"5\"\n assert candidate(num = \"9876543210\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"9876543210\"\n assert candidate(num = \"3333\",change = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"3333\"\n assert candidate(num = \"021\",change = [9, 4, 3, 5, 7, 2, 1, 9, 0, 6]) == \"934\"\n assert candidate(num = \"1234567890\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"8765567890\"\n assert candidate(num = \"1001001001\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"8642086420\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"9753197531\"\n assert candidate(num = \"1999999999\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"9999999999\"\n assert candidate(num = \"9999999999\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"9999999999\"\n assert candidate(num = \"1231231231\",change = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"1231231231\"\n assert candidate(num = \"1001\",change = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == \"1111\"\n assert candidate(num = \"9000000009\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"9111111119\"\n assert candidate(num = \"9876543210\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"9876543210\"\n assert candidate(num = \"0001112223\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"13579\",change = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]) == \"26579\"\n assert candidate(num = \"1357924680\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"1122334455\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"1122334455\"\n assert candidate(num = \"5432109876\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"5567899876\"\n assert candidate(num = \"999888777666555444333222111000\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 9]) == \"999888777666555444333222111000\"\n assert candidate(num = \"11111111111111111111\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"99999999999999999999\"\n assert candidate(num = \"100100100\",change = [9, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"199100100\"\n assert candidate(num = \"100100\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"899899\"\n assert candidate(num = \"1234567890\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == \"2345678990\"\n assert candidate(num = \"99999\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 9]) == \"99999\"\n assert candidate(num = \"2468013579\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"7568013579\"\n assert candidate(num = \"1000000001\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"9000000009\"\n assert candidate(num = \"9876543210\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"9876556789\"\n assert candidate(num = \"9009\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"9999\"\n assert candidate(num = \"0123456789\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"0123456789\"\n assert candidate(num = \"13579246801357924680\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"13579246801357924680\"\n assert candidate(num = \"10987654321\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"99999999999\"\n assert candidate(num = \"1234567890\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"1234567890\"\n assert candidate(num = \"9087654321\",change = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"9187654321\"\n assert candidate(num = \"1919191919\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"8919191919\"\n assert candidate(num = \"5555555555\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"6666666666\"\n assert candidate(num = \"4444444444\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"4444444444\"\n assert candidate(num = \"1111\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"1111\"\n assert candidate(num = \"9876543210\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"9090909090\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 9]) == \"9090909090\"\n assert candidate(num = \"12345678901234567890\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"12345678901234567890\"\n assert candidate(num = \"1234567890\",change = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"1234567891\"\n assert candidate(num = \"98765432109876543210\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"98765567899876543210\"\n assert candidate(num = \"9898989898\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"9898989898\"\n assert candidate(num = \"5432109876\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"5432109876\"\n assert candidate(num = \"9999999999\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"9999999999\"\n assert candidate(num = \"0000000000\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"9999999999\"\n assert candidate(num = \"2222\",change = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == \"3333\"\n assert candidate(num = \"1123344556677889900\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"1123344556677889900\"\n assert candidate(num = \"8765432109\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"8765567899\"\n assert candidate(num = \"2468013579\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"2468013579\"\n assert candidate(num = \"1000100010\",change = [9, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"1999100010\"\n assert candidate(num = \"9999999999\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"123456789012345678901234567890\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"987656789012345678901234567890\"\n assert candidate(num = \"3214567890\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"6785567890\"\n assert candidate(num = \"11223344556677889900\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"99887766556677889900\"\n assert candidate(num = \"543210\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"543210\"\n assert candidate(num = \"1234554321\",change = [0, 1, 2, 3, 4, 6, 5, 6, 7, 8]) == \"1234664321\"\n assert candidate(num = \"9080706050\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"9191817161\"\n assert candidate(num = \"99999999999999999999\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"99999999999999999999\"\n assert candidate(num = \"5678943210\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"5678943210\"\n assert candidate(num = \"11223344556677889900\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"11223344556677889900\"\n assert candidate(num = \"9090909090\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"9190909090\"\n assert candidate(num = \"2222222222\",change = [0, 1, 9, 3, 4, 5, 6, 7, 8, 9]) == \"9999999999\"\n assert candidate(num = \"0000000000\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"1111111111\"\n assert candidate(num = \"239847362876\",change = [8, 9, 5, 7, 6, 5, 4, 3, 2, 1]) == \"579847362876\"\n assert candidate(num = \"00000000000000000000\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"99999999999999999999\"\n assert candidate(num = \"123123123\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"987987987\"\n assert candidate(num = \"2468024680\",change = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]) == \"4868024680\"\n assert candidate(num = \"0000000000\",change = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"1111111111\"\n assert candidate(num = \"2345678901\",change = [0, 1, 2, 9, 4, 5, 6, 7, 8, 3]) == \"2945678901\"\n assert candidate(num = \"999999\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 9]) == \"999999\"\n assert candidate(num = \"3333\",change = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == \"3333\"\n assert candidate(num = \"00112233445566778899\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"99999999999999999999\"\n assert candidate(num = \"8888888888\",change = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"8888888888\"\n assert candidate(num = \"1234567890\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"2345678990\"\n assert candidate(num = \"1212121212\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"1212121212\"\n assert candidate(num = \"2727272727\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"2727272727\"\n assert candidate(num = \"111222333\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"222333444\"\n assert candidate(num = \"111000111\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"111000111\"\n assert candidate(num = \"1919191919\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"9919191919\"\n assert candidate(num = \"86420\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"86579\"\n assert candidate(num = \"4444444444\",change = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == \"4444444444\"\n assert candidate(num = \"0000000000\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"0000000000\"\n assert candidate(num = \"1357924680\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"1357924680\"\n assert candidate(num = \"109876543210987654321\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"219876543210987654321\"\n assert candidate(num = \"09876543210\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"09876543210\"\n assert candidate(num = \"0000000000\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"01234567890123456789\",change = [9, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"91234567890123456789\"\n assert candidate(num = \"3456789\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"6556789\"\n assert candidate(num = \"2222222222\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"2222222222\"\n assert candidate(num = \"12345678901234567890\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"98765678901234567890\"\n assert candidate(num = \"0123456789\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"9876556789\"\n assert candidate(num = \"1234567890\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"9876567890\"\n assert candidate(num = \"888888\",change = [1, 2, 3, 4, 5, 6, 7, 8, 8, 9]) == \"888888\"\n assert candidate(num = \"56789\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"56789\"\n assert candidate(num = \"99999\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"99999\"\n assert candidate(num = \"5643210987\",change = [0, 1, 2, 3, 4, 9, 6, 7, 8, 9]) == \"9643210987\"\n assert candidate(num = \"54321098765432109876\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"55678998765432109876\"\n assert candidate(num = \"9234567890\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"9345678990\"\n assert candidate(num = \"98765432109876543210\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"98765432109876543210\"\n assert candidate(num = \"1234567890\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"12345678901234567890\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"87655678901234567890\"\n assert candidate(num = \"1111111111\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == \"1111111111\"\n assert candidate(num = \"1999\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"2999\"\n assert candidate(num = \"2736419850\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"7736419850\"\n assert candidate(num = \"505050\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"505050\"\n assert candidate(num = \"1010101010\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"000000\",change = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == \"000000\"\n assert candidate(num = \"1212121212\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"8787878787\"\n assert candidate(num = \"1122334455\",change = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4]) == \"6677889955\"\n assert candidate(num = \"5555555555\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"9876543210\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"9987654321\"\n assert candidate(num = \"1122334455\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"8877665555\"\n assert candidate(num = \"1111111111\",change = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == \"9999999999\"\n assert candidate(num = \"532532532\",change = [8, 9, 0, 7, 6, 5, 4, 3, 2, 1]) == \"572532532\"\n assert candidate(num = \"9321876543\",change = [8, 7, 6, 5, 4, 3, 2, 1, 0, 9]) == \"9567876543\"\n assert candidate(num = \"0000\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"9999\"\n assert candidate(num = \"5678912345\",change = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == \"5678998765\"\n assert candidate(num = \"543210\",change = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == \"654321\"\n assert candidate(num = \"1234567890\",change = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == \"1234567890\"\n assert candidate(num = \"5555555555\",change = [5, 4, 3, 2, 1, 0, 9, 8, 7, 6]) == \"5555555555\"\n assert candidate(num = \"5555\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"5555\"\n assert candidate(num = \"8888888888\",change = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == \"8888888888\"\n"}, "metadata": {"canonical_parameter_names": ["num", "change"], "leetcode_dataset_entry_point": "Solution().maximumNumber", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string maximumNumber(string num, vector& change) {", "container": "Solution", "callable": "maximumNumber", "parameters": [{"name": "num", "type": "string"}, {"name": "change", "type": "vector&"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1947, "task_id": "maximum-compatibility-score-sum", "difficulty": "Medium", "problem_description": "There is a survey that consists of n questions where each question's answer is either 0 (no) or 1 (yes).\nThe survey was given to m students numbered from 0 to m - 1 and m mentors numbered from 0 to m - 1. The answers of the students are represented by a 2D integer array students where students[i] is an integer array that contains the answers of the ith student (0-indexed). The answers of the mentors are represented by a 2D integer array mentors where mentors[j] is an integer array that contains the answers of the jth mentor (0-indexed).\nEach student will be assigned to one mentor, and each mentor will have one student assigned to them. The compatibility score of a student-mentor pair is the number of answers that are the same for both the student and the mentor.\n\nFor example, if the student's answers were [1, 0, 1] and the mentor's answers were [0, 0, 1], then their compatibility score is 2 because only the second and the third answers are the same.\n\nYou are tasked with finding the optimal student-mentor pairings to maximize the sum of the compatibility scores.\nGiven students and mentors, return the maximum compatibility score sum that can be achieved.\n \nExample 1:\n\nInput: students = [[1,1,0],[1,0,1],[0,0,1]], mentors = [[1,0,0],[0,0,1],[1,1,0]]\nOutput: 8\nExplanation: We assign students to mentors in the following way:\n- student 0 to mentor 2 with a compatibility score of 3.\n- student 1 to mentor 0 with a compatibility score of 2.\n- student 2 to mentor 1 with a compatibility score of 3.\nThe compatibility score sum is 3 + 2 + 3 = 8.\n\nExample 2:\n\nInput: students = [[0,0],[0,0],[0,0]], mentors = [[1,1],[1,1],[1,1]]\nOutput: 0\nExplanation: The compatibility score of any student-mentor pair is 0.\n\n \nConstraints:\n\nm == students.length == mentors.length\nn == students[i].length == mentors[j].length\n1 <= m, n <= 8\nstudents[i][k] is either 0 or 1.\nmentors[j][k] is either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(students = [[1, 1, 0, 0], [0, 0, 1, 1]],mentors = [[1, 0, 1, 0], [0, 1, 0, 1]]) == 4\n assert candidate(students = [[1, 1], [0, 0]],mentors = [[0, 0], [1, 1]]) == 4\n assert candidate(students = [[1, 0], [0, 1]],mentors = [[1, 0], [0, 1]]) == 4\n assert candidate(students = [[1, 1, 1, 1], [0, 0, 0, 0], [1, 0, 1, 0]],mentors = [[1, 1, 1, 1], [0, 0, 0, 0], [0, 1, 0, 1]]) == 8\n assert candidate(students = [[1, 0, 1, 0], [0, 1, 0, 1]],mentors = [[0, 0, 1, 1], [1, 1, 0, 0]]) == 4\n assert candidate(students = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 1, 1, 1]],mentors = [[0, 0, 0, 0], [1, 1, 1, 1], [0, 1, 0, 1]]) == 10\n assert candidate(students = [[1, 1, 0, 0], [0, 0, 1, 1]],mentors = [[0, 0, 1, 1], [1, 1, 0, 0]]) == 8\n assert candidate(students = [[1, 1, 1], [0, 0, 0]],mentors = [[1, 1, 1], [0, 0, 0]]) == 6\n assert candidate(students = [[0, 0], [0, 0], [0, 0]],mentors = [[1, 1], [1, 1], [1, 1]]) == 0\n assert candidate(students = [[1, 1, 1, 1], [0, 0, 0, 0]],mentors = [[1, 1, 1, 1], [0, 0, 0, 0]]) == 8\n assert candidate(students = [[0, 0, 0], [1, 1, 1], [0, 1, 0]],mentors = [[1, 1, 1], [0, 0, 0], [1, 0, 1]]) == 6\n assert candidate(students = [[1, 0, 1], [0, 1, 0]],mentors = [[0, 1, 0], [1, 0, 1]]) == 6\n assert candidate(students = [[1, 1, 0], [1, 0, 1], [0, 0, 1]],mentors = [[1, 0, 0], [0, 0, 1], [1, 1, 0]]) == 8\n assert candidate(students = [[1, 0], [0, 1]],mentors = [[0, 1], [1, 0]]) == 4\n assert candidate(students = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]],mentors = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1]]) == 32\n assert candidate(students = [[1, 1, 0, 1, 0, 1, 0], [0, 0, 1, 0, 1, 0, 1], [1, 0, 0, 1, 1, 0, 0], [0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1]],mentors = [[0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, 0], [1, 0, 1, 0, 0, 1, 1]]) == 40\n assert candidate(students = [[1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [1, 1, 0, 1, 0], [0, 0, 1, 0, 0]],mentors = [[0, 1, 1, 0, 1], [1, 0, 0, 1, 0], [0, 0, 1, 0, 0], [1, 1, 0, 1, 0]]) == 20\n assert candidate(students = [[1, 0, 1, 1, 0], [0, 1, 0, 0, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]],mentors = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]) == 16\n assert candidate(students = [[1, 0, 0, 1, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0, 1, 0], [1, 1, 0, 1, 0, 0, 1, 1], [0, 0, 1, 0, 1, 1, 0, 0], [1, 0, 1, 0, 0, 1, 1, 0], [0, 1, 0, 1, 1, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]],mentors = [[0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 0, 1, 1, 0], [0, 1, 0, 1, 1, 0, 0, 1], [0, 1, 1, 0, 1, 0, 1, 0], [1, 0, 0, 1, 0, 1, 0, 1], [1, 1, 0, 1, 0, 0, 1, 1], [0, 0, 1, 0, 1, 1, 0, 0]]) == 64\n assert candidate(students = [[1, 1, 1], [0, 0, 0], [1, 0, 1], [0, 1, 0]],mentors = [[1, 0, 1], [0, 1, 0], [0, 0, 0], [1, 1, 1]]) == 12\n assert candidate(students = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]],mentors = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]) == 20\n assert candidate(students = [[1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]],mentors = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 0]]) == 28\n assert candidate(students = [[0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1, 1]],mentors = [[1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 0, 1, 1]]) == 49\n assert candidate(students = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0]],mentors = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 20\n assert candidate(students = [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1]],mentors = [[1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0]]) == 20\n assert candidate(students = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1]],mentors = [[1, 0, 0, 1, 1, 0, 0], [0, 1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 0]]) == 22\n assert candidate(students = [[1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]],mentors = [[1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == 24\n assert candidate(students = [[0, 0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0]],mentors = [[1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1]]) == 32\n assert candidate(students = [[0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]],mentors = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 20\n assert candidate(students = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]],mentors = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == 8\n assert candidate(students = [[1, 0, 1, 1, 0], [0, 1, 0, 0, 1], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0]],mentors = [[0, 1, 0, 0, 1], [1, 0, 1, 1, 0], [0, 0, 1, 1, 0], [1, 1, 0, 0, 1]]) == 20\n assert candidate(students = [[0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]],mentors = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == 64\n assert candidate(students = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]],mentors = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 20\n assert candidate(students = [[1, 0, 0, 1, 0], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [0, 1, 1, 0, 0]],mentors = [[0, 1, 1, 0, 0], [1, 0, 0, 1, 0], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0]]) == 20\n assert candidate(students = [[1, 0, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0], [1, 1, 0, 1, 0, 0], [0, 0, 1, 0, 1, 1]],mentors = [[0, 1, 1, 0, 1, 0], [1, 0, 0, 1, 0, 1], [1, 1, 0, 1, 0, 0], [0, 0, 1, 0, 1, 1]]) == 24\n assert candidate(students = [[1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]],mentors = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1]]) == 28\n assert candidate(students = [[1, 0, 1, 1, 0], [0, 1, 0, 0, 1], [1, 1, 1, 0, 0], [0, 0, 0, 1, 1]],mentors = [[0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]) == 12\n assert candidate(students = [[0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 0, 1, 1, 0, 0, 1], [0, 1, 1, 0, 0, 1, 1, 0]],mentors = [[0, 1, 1, 0, 0, 1, 1, 0], [1, 0, 0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]) == 64\n assert candidate(students = [[1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]],mentors = [[0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1]]) == 24\n assert candidate(students = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]],mentors = [[0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 64\n assert candidate(students = [[1, 0, 0, 1, 0, 0, 1, 0], [0, 1, 1, 0, 1, 1, 0, 1]],mentors = [[0, 1, 1, 0, 1, 1, 0, 1], [1, 0, 0, 1, 0, 0, 1, 0]]) == 16\n assert candidate(students = [[0, 1, 1, 0, 1, 1], [1, 0, 0, 1, 0, 0], [0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1]],mentors = [[1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [1, 0, 0, 1, 0, 0], [0, 1, 1, 0, 1, 1]]) == 24\n assert candidate(students = [[1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]],mentors = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 64\n assert candidate(students = [[1, 0, 1, 0], [0, 1, 0, 1], [1, 1, 0, 0], [0, 0, 1, 1]],mentors = [[1, 1, 1, 1], [0, 0, 0, 0], [1, 0, 1, 0], [0, 1, 0, 1]]) == 12\n assert candidate(students = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]],mentors = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == 64\n assert candidate(students = [[1, 0, 0, 1, 0, 1], [0, 1, 1, 0, 1, 0], [1, 1, 0, 0, 0, 1], [0, 0, 1, 1, 1, 0], [1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1]],mentors = [[0, 0, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1]]) == 28\n assert candidate(students = [[1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]],mentors = [[0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == 24\n assert candidate(students = [[1, 0, 1, 1, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 0, 1], [1, 1, 1, 0, 0, 1, 1, 0], [0, 0, 0, 0, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, 0, 0]],mentors = [[0, 0, 1, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 0, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1, 1]]) == 28\n assert candidate(students = [[1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]],mentors = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0]]) == 32\n assert candidate(students = [[1, 0, 1, 1, 0], [0, 1, 0, 1, 0], [1, 1, 1, 0, 1]],mentors = [[0, 1, 0, 0, 1], [1, 0, 1, 1, 0], [0, 1, 1, 0, 0]]) == 11\n assert candidate(students = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]],mentors = [[0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 1, 0, 0, 1, 0, 1], [1, 0, 0, 1, 1, 0, 1, 0], [0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0]]) == 60\n assert candidate(students = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]],mentors = [[0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 28\n assert candidate(students = [[1, 1, 0, 1, 0, 1, 0, 1], [0, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]],mentors = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 30\n assert candidate(students = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0]],mentors = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == 20\n assert candidate(students = [[1, 1, 0, 0, 1, 0, 1], [0, 0, 1, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0]],mentors = [[0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [0, 0, 1, 1, 0, 1, 0], [1, 1, 0, 0, 1, 0, 1]]) == 42\n assert candidate(students = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1]],mentors = [[0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]) == 48\n assert candidate(students = [[0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0]],mentors = [[1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1]]) == 36\n assert candidate(students = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0, 1, 1]],mentors = [[0, 0, 1, 1, 0, 0, 1, 1], [1, 1, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 48\n assert candidate(students = [[0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1]],mentors = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]) == 32\n assert candidate(students = [[0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1]],mentors = [[1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0]]) == 30\n assert candidate(students = [[1, 0, 1, 1, 0, 1], [0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0]],mentors = [[1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1]]) == 21\n assert candidate(students = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 1, 0, 0, 1]],mentors = [[1, 1, 0, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 15\n assert candidate(students = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]],mentors = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == 25\n assert candidate(students = [[1, 1, 0, 1], [1, 0, 1, 0], [0, 1, 1, 0], [1, 0, 0, 1]],mentors = [[0, 1, 1, 0], [1, 0, 0, 1], [1, 1, 0, 1], [0, 0, 1, 0]]) == 15\n assert candidate(students = [[0, 1, 1, 1, 1, 0], [1, 0, 0, 0, 1, 1], [1, 1, 0, 1, 0, 0], [0, 1, 0, 1, 1, 0], [0, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0]],mentors = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 1, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0], [0, 1, 1, 0, 0, 1], [1, 0, 0, 1, 1, 0]]) == 28\n assert candidate(students = [[1, 0, 0, 1, 1, 0, 1], [0, 1, 1, 0, 0, 1, 0], [1, 1, 0, 0, 1, 1, 0], [0, 0, 1, 1, 0, 0, 1]],mentors = [[0, 1, 1, 0, 0, 1, 0], [1, 0, 0, 1, 1, 0, 1], [0, 0, 1, 1, 0, 0, 1], [1, 1, 0, 0, 1, 1, 0]]) == 28\n assert candidate(students = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 0, 1, 0, 0, 1, 0], [0, 1, 1, 0, 1, 1, 0, 1]],mentors = [[0, 1, 1, 0, 1, 1, 0, 1], [1, 0, 0, 1, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 48\n assert candidate(students = [[1, 1, 1, 0, 0], [0, 0, 1, 1, 1], [1, 0, 1, 0, 1]],mentors = [[0, 1, 0, 1, 1], [1, 0, 0, 1, 0], [1, 1, 1, 0, 0]]) == 10\n"}, "metadata": {"canonical_parameter_names": ["students", "mentors"], "leetcode_dataset_entry_point": "Solution().maxCompatibilitySum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxCompatibilitySum(vector>& students, vector>& mentors) {", "container": "Solution", "callable": "maxCompatibilitySum", "parameters": [{"name": "students", "type": "vector>&"}, {"name": "mentors", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1948, "task_id": "delete-duplicate-folders-in-system", "difficulty": "Hard", "problem_description": "Due to a bug, there are many duplicate folders in a file system. You are given a 2D array paths, where paths[i] is an array representing an absolute path to the ith folder in the file system.\n\nFor example, [\"one\", \"two\", \"three\"] represents the path \"/one/two/three\".\n\nTwo folders (not necessarily on the same level) are identical if they contain the same non-empty set of identical subfolders and underlying subfolder structure. The folders do not need to be at the root level to be identical. If two or more folders are identical, then mark the folders as well as all their subfolders.\n\nFor example, folders \"/a\" and \"/b\" in the file structure below are identical. They (as well as their subfolders) should all be marked:\n\n\t\n/a\n/a/x\n/a/x/y\n/a/z\n/b\n/b/x\n/b/x/y\n/b/z\n\n\nHowever, if the file structure also included the path \"/b/w\", then the folders \"/a\" and \"/b\" would not be identical. Note that \"/a/x\" and \"/b/x\" would still be considered identical even with the added folder.\n\nOnce all the identical folders and their subfolders have been marked, the file system will delete all of them. The file system only runs the deletion once, so any folders that become identical after the initial deletion are not deleted.\nReturn the 2D array ans containing the paths of the remaining folders after deleting all the marked folders. The paths may be returned in any order.\n \nExample 1:\n\n\nInput: paths = [[\"a\"],[\"c\"],[\"d\"],[\"a\",\"b\"],[\"c\",\"b\"],[\"d\",\"a\"]]\nOutput: [[\"d\"],[\"d\",\"a\"]]\nExplanation: The file structure is as shown.\nFolders \"/a\" and \"/c\" (and their subfolders) are marked for deletion because they both contain an empty\nfolder named \"b\".\n\nExample 2:\n\n\nInput: paths = [[\"a\"],[\"c\"],[\"a\",\"b\"],[\"c\",\"b\"],[\"a\",\"b\",\"x\"],[\"a\",\"b\",\"x\",\"y\"],[\"w\"],[\"w\",\"y\"]]\nOutput: [[\"c\"],[\"c\",\"b\"],[\"a\"],[\"a\",\"b\"]]\nExplanation: The file structure is as shown. \nFolders \"/a/b/x\" and \"/w\" (and their subfolders) are marked for deletion because they both contain an empty folder named \"y\".\nNote that folders \"/a\" and \"/c\" are identical after the deletion, but they are not deleted because they were not marked beforehand.\n\nExample 3:\n\n\nInput: paths = [[\"a\",\"b\"],[\"c\",\"d\"],[\"c\"],[\"a\"]]\nOutput: [[\"c\"],[\"c\",\"d\"],[\"a\"],[\"a\",\"b\"]]\nExplanation: All folders are unique in the file system.\nNote that the returned array can be in a different order as the order does not matter.\n\n \nConstraints:\n\n1 <= paths.length <= 2 * 104\n1 <= paths[i].length <= 500\n1 <= paths[i][j].length <= 10\n1 <= sum(paths[i][j].length) <= 2 * 105\npath[i][j] consists of lowercase English letters.\nNo two paths lead to the same folder.\nFor any folder not at the root level, its parent folder will also be in the input.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(paths = [['project'], ['project', 'src'], ['project', 'src', 'main'], ['project', 'src', 'test'], ['project', 'docs'], ['project', 'docs', 'api'], ['project', 'docs', 'user']]) == [['project', 'docs', 'api'], ['project', 'docs', 'user'], ['project', 'docs'], ['project', 'src', 'main'], ['project', 'src', 'test'], ['project', 'src'], ['project']]\n assert candidate(paths = [['x'], ['x', 'y'], ['x', 'z'], ['y'], ['y', 'x'], ['z'], ['z', 'x']]) == [['x', 'y'], ['x', 'z'], ['x']]\n assert candidate(paths = [['a', 'b'], ['c', 'd'], ['c'], ['a']]) == [['a', 'b'], ['a'], ['c', 'd'], ['c']]\n assert candidate(paths = [['home'], ['home', 'user'], ['home', 'user', 'documents'], ['home', 'guest'], ['home', 'guest', 'documents']]) == [['home']]\n assert candidate(paths = [['a'], ['a', 'b'], ['a', 'b', 'c'], ['a', 'b', 'c', 'd'], ['a', 'b', 'c', 'd', 'e'], ['f'], ['f', 'g'], ['f', 'g', 'h'], ['f', 'g', 'h', 'i'], ['f', 'g', 'h', 'i', 'j']]) == [['a', 'b', 'c', 'd', 'e'], ['a', 'b', 'c', 'd'], ['a', 'b', 'c'], ['a', 'b'], ['a'], ['f', 'g', 'h', 'i', 'j'], ['f', 'g', 'h', 'i'], ['f', 'g', 'h'], ['f', 'g'], ['f']]\n assert candidate(paths = [['root'], ['root', 'a'], ['root', 'b'], ['root', 'a', 'x'], ['root', 'b', 'x'], ['root', 'a', 'x', 'y'], ['root', 'b', 'x', 'y']]) == [['root']]\n assert candidate(paths = [['folder1'], ['folder1', 'sub1'], ['folder1', 'sub2'], ['folder2'], ['folder2', 'sub1'], ['folder2', 'sub2']]) == []\n assert candidate(paths = [['a'], ['c'], ['a', 'b'], ['c', 'b'], ['a', 'b', 'x'], ['a', 'b', 'x', 'y'], ['w'], ['w', 'y']]) == [['a', 'b'], ['a'], ['c', 'b'], ['c']]\n assert candidate(paths = [['x'], ['x', 'y'], ['x', 'y', 'z'], ['x', 'y', 'z', 'w'], ['u'], ['u', 'v'], ['u', 'v', 'w']]) == [['u'], ['x', 'y'], ['x']]\n assert candidate(paths = [['m'], ['m', 'n'], ['n'], ['n', 'm'], ['m', 'n', 'o'], ['n', 'm', 'o']]) == [['m'], ['n']]\n assert candidate(paths = [['root'], ['root', 'folder1'], ['root', 'folder2'], ['root', 'folder1', 'subfolder1'], ['root', 'folder2', 'subfolder1']]) == [['root']]\n assert candidate(paths = [['m'], ['m', 'n'], ['p'], ['p', 'n']]) == []\n assert candidate(paths = [['a'], ['c'], ['d'], ['a', 'b'], ['c', 'b'], ['d', 'a']]) == [['d', 'a'], ['d']]\n assert candidate(paths = [['x'], ['x', 'y'], ['x', 'y', 'z'], ['y'], ['y', 'z']]) == [['x']]\n assert candidate(paths = [['one'], ['one', 'two'], ['one', 'two', 'three'], ['two'], ['two', 'three']]) == [['one']]\n assert candidate(paths = [['p'], ['p', 'q'], ['p', 'q', 'r'], ['p', 'q', 'r', 's'], ['p', 'q', 'r', 't'], ['q'], ['q', 'r'], ['q', 'r', 's'], ['q', 'r', 't'], ['r'], ['r', 's'], ['r', 't'], ['s'], ['t'], ['u'], ['u', 'v'], ['u', 'v', 'w'], ['u', 'v', 'w', 'x'], ['u', 'v', 'w', 'y'], ['v'], ['v', 'w'], ['v', 'w', 'x'], ['v', 'w', 'y'], ['w'], ['w', 'x'], ['w', 'y'], ['x'], ['y']]) == [['p'], ['s'], ['t'], ['u'], ['x'], ['y']]\n assert candidate(paths = [['level1', 'level2', 'level3', 'level4'], ['level1', 'level2', 'level5', 'level4'], ['level1', 'level6', 'level3', 'level4'], ['level1', 'level6', 'level5', 'level4'], ['level1', 'level7', 'level8'], ['level1', 'level9', 'level10', 'level11'], ['level1', 'level9', 'level10', 'level12']]) == [['level1', 'level7', 'level8'], ['level1', 'level7'], ['level1', 'level9', 'level10', 'level11'], ['level1', 'level9', 'level10', 'level12'], ['level1', 'level9', 'level10'], ['level1', 'level9'], ['level1']]\n assert candidate(paths = [['system', 'folderA'], ['system', 'folderB'], ['system', 'folderA', 'subfolderA1'], ['system', 'folderB', 'subfolderA1'], ['system', 'folderA', 'subfolderA2'], ['system', 'folderB', 'subfolderA2'], ['system', 'folderA', 'subfolderA1', 'subsubfolderA1'], ['system', 'folderB', 'subfolderA1', 'subsubfolderA1'], ['system', 'folderA', 'subfolderA1', 'subsubfolderA2'], ['system', 'folderB', 'subfolderA1', 'subsubfolderA2'], ['system', 'folderA', 'subfolderA2', 'subsubfolderA1'], ['system', 'folderB', 'subfolderA2', 'subsubfolderA1'], ['system', 'folderA', 'subfolderA2', 'subsubfolderA2'], ['system', 'folderB', 'subfolderA2', 'subsubfolderA2']]) == [['system']]\n assert candidate(paths = [['home', 'user', 'docs'], ['home', 'user', 'photos'], ['home', 'guest', 'docs'], ['home', 'guest', 'photos'], ['home', 'user', 'docs', 'file1'], ['home', 'guest', 'docs', 'file1'], ['home', 'user', 'photos', 'image1'], ['home', 'guest', 'photos', 'image1'], ['home', 'user', 'docs', 'file2'], ['home', 'guest', 'docs', 'file2']]) == [['home']]\n assert candidate(paths = [['projects', 'proj1'], ['projects', 'proj2'], ['projects', 'proj1', 'src'], ['projects', 'proj2', 'src'], ['projects', 'proj1', 'src', 'main'], ['projects', 'proj2', 'src', 'main'], ['projects', 'proj1', 'src', 'test'], ['projects', 'proj2', 'src', 'test'], ['projects', 'proj1', 'src', 'main', 'file1'], ['projects', 'proj2', 'src', 'main', 'file1'], ['projects', 'proj1', 'src', 'test', 'test1'], ['projects', 'proj2', 'src', 'test', 'test1']]) == [['projects']]\n assert candidate(paths = [['alpha'], ['alpha', 'beta'], ['alpha', 'beta', 'gamma'], ['alpha', 'beta', 'delta'], ['alpha', 'epsilon'], ['alpha', 'epsilon', 'gamma'], ['alpha', 'epsilon', 'delta'], ['beta'], ['beta', 'gamma'], ['beta', 'delta'], ['epsilon'], ['epsilon', 'gamma'], ['epsilon', 'delta'], ['gamma'], ['delta'], ['charlie'], ['charlie', 'foxtrot'], ['charlie', 'foxtrot', 'gamma'], ['charlie', 'foxtrot', 'delta'], ['charlie', 'tango'], ['charlie', 'tango', 'gamma'], ['charlie', 'tango', 'delta']]) == [['alpha'], ['charlie'], ['delta'], ['gamma']]\n assert candidate(paths = [['project'], ['project', 'src'], ['project', 'docs'], ['project', 'src', 'main'], ['project', 'src', 'test'], ['project', 'docs', 'api'], ['project', 'docs', 'userguide'], ['project', 'src', 'main', 'java'], ['project', 'src', 'test', 'java'], ['project', 'docs', 'api', 'java'], ['project', 'docs', 'userguide', 'java'], ['project', 'src', 'main', 'java', 'utils'], ['project', 'src', 'test', 'java', 'utils'], ['project', 'docs', 'api', 'java', 'utils'], ['project', 'docs', 'userguide', 'java', 'utils']]) == [['project', 'docs'], ['project', 'src'], ['project']]\n assert candidate(paths = [['data', 'archive'], ['data', 'archive', '2021'], ['data', 'archive', '2022'], ['data', 'archive', '2023'], ['data', 'backup'], ['data', 'backup', '2021'], ['data', 'backup', '2022'], ['data', 'backup', '2023'], ['data', 'logs'], ['data', 'logs', 'server1'], ['data', 'logs', 'server2'], ['data', 'logs', 'server3'], ['data', 'temp'], ['data', 'temp', 'server1'], ['data', 'temp', 'server2'], ['data', 'temp', 'server3']]) == [['data']]\n assert candidate(paths = [['app'], ['app', 'module1'], ['app', 'module2'], ['app', 'module1', 'component1'], ['app', 'module2', 'component1'], ['app', 'module1', 'component2'], ['app', 'module2', 'component2'], ['app', 'module1', 'component1', 'subcomponent1'], ['app', 'module2', 'component1', 'subcomponent1'], ['app', 'module1', 'component2', 'subcomponent1'], ['app', 'module2', 'component2', 'subcomponent1'], ['app', 'module1', 'component1', 'subcomponent2'], ['app', 'module2', 'component1', 'subcomponent2'], ['app', 'module1', 'component2', 'subcomponent2'], ['app', 'module2', 'component2', 'subcomponent2'], ['app', 'module1', 'component1', 'subcomponent2', 'deep1'], ['app', 'module2', 'component1', 'subcomponent2', 'deep1']]) == [['app']]\n assert candidate(paths = [['root', 'a'], ['root', 'b'], ['root', 'a', 'c'], ['root', 'b', 'c'], ['root', 'a', 'd'], ['root', 'b', 'd'], ['root', 'a', 'c', 'e'], ['root', 'b', 'c', 'e']]) == [['root']]\n assert candidate(paths = [['root', 'folder1'], ['root', 'folder2'], ['root', 'folder1', 'subfolder1'], ['root', 'folder2', 'subfolder1'], ['root', 'folder1', 'subfolder1', 'subsubfolder1'], ['root', 'folder2', 'subfolder1', 'subsubfolder1'], ['root', 'unique', 'folder1'], ['root', 'unique', 'folder1', 'subfolder1'], ['root', 'unique', 'folder1', 'subfolder1', 'subsubfolder1']]) == [['root', 'unique'], ['root']]\n assert candidate(paths = [['home'], ['home', 'user1'], ['home', 'user2'], ['home', 'user1', 'files'], ['home', 'user2', 'files'], ['home', 'user1', 'files', 'docs'], ['home', 'user2', 'files', 'docs'], ['home', 'user1', 'files', 'docs', 'report1'], ['home', 'user2', 'files', 'docs', 'report1'], ['home', 'user1', 'files', 'docs', 'report2'], ['home', 'user2', 'files', 'docs', 'report2']]) == [['home']]\n assert candidate(paths = [['x'], ['y'], ['z'], ['x', 'a'], ['y', 'a'], ['z', 'a'], ['x', 'a', 'b'], ['y', 'a', 'b'], ['z', 'a', 'b'], ['x', 'a', 'b', 'c'], ['y', 'a', 'b', 'c'], ['z', 'a', 'b', 'c'], ['x', 'd'], ['y', 'e'], ['z', 'f']]) == [['x', 'd'], ['x'], ['y', 'e'], ['y'], ['z', 'f'], ['z']]\n assert candidate(paths = [['root', 'a', 'b', 'c', 'd'], ['root', 'x', 'y', 'z', 'w'], ['root', 'a', 'b', 'c', 'd', 'e'], ['root', 'x', 'y', 'z', 'w', 'v'], ['root', 'a', 'b', 'f'], ['root', 'x', 'y', 'f'], ['root', 'a', 'g'], ['root', 'x', 'g'], ['root', 'a', 'h'], ['root', 'x', 'h'], ['root', 'a', 'i', 'j'], ['root', 'x', 'i', 'j'], ['root', 'a', 'i', 'k'], ['root', 'x', 'i', 'k']]) == [['root', 'a', 'b', 'c', 'd', 'e'], ['root', 'a', 'b', 'c', 'd'], ['root', 'a', 'b', 'c'], ['root', 'a', 'b', 'f'], ['root', 'a', 'b'], ['root', 'a', 'g'], ['root', 'a', 'h'], ['root', 'a'], ['root', 'x', 'g'], ['root', 'x', 'h'], ['root', 'x', 'y', 'f'], ['root', 'x', 'y', 'z', 'w', 'v'], ['root', 'x', 'y', 'z', 'w'], ['root', 'x', 'y', 'z'], ['root', 'x', 'y'], ['root', 'x'], ['root']]\n assert candidate(paths = [['root'], ['root', 'folder1'], ['root', 'folder2'], ['root', 'folder1', 'sub1'], ['root', 'folder2', 'sub1'], ['root', 'folder1', 'sub1', 'subsub1'], ['root', 'folder2', 'sub1', 'subsub1']]) == [['root']]\n assert candidate(paths = [['base'], ['base', 'folder1'], ['base', 'folder1', 'subfolder1'], ['base', 'folder1', 'subfolder2'], ['base', 'folder2'], ['base', 'folder2', 'subfolder1'], ['base', 'folder2', 'subfolder2'], ['base', 'folder3'], ['base', 'folder3', 'subfolder1'], ['base', 'folder3', 'subfolder2'], ['base', 'folder1', 'subfolder1', 'deep1'], ['base', 'folder2', 'subfolder1', 'deep1'], ['base', 'folder3', 'subfolder1', 'deep1']]) == [['base']]\n assert candidate(paths = [['system'], ['system', 'app1'], ['system', 'app1', 'data'], ['system', 'app2'], ['system', 'app2', 'data'], ['system', 'app3'], ['system', 'app3', 'data'], ['system', 'app3', 'logs'], ['system', 'app4'], ['system', 'app4', 'data'], ['system', 'app4', 'logs'], ['system', 'app4', 'temp'], ['system', 'app5'], ['system', 'app5', 'data'], ['system', 'app5', 'logs'], ['system', 'app5', 'temp'], ['system', 'app6'], ['system', 'app6', 'data'], ['system', 'app6', 'logs'], ['system', 'app6', 'temp'], ['system', 'app6', 'config'], ['system', 'app7'], ['system', 'app7', 'data'], ['system', 'app7', 'logs'], ['system', 'app7', 'temp'], ['system', 'app7', 'config'], ['system', 'app8'], ['system', 'app8', 'data'], ['system', 'app8', 'logs'], ['system', 'app8', 'temp'], ['system', 'app8', 'config'], ['system', 'app8', 'bin']]) == [['system', 'app3', 'data'], ['system', 'app3', 'logs'], ['system', 'app3'], ['system', 'app8', 'bin'], ['system', 'app8', 'config'], ['system', 'app8', 'data'], ['system', 'app8', 'logs'], ['system', 'app8', 'temp'], ['system', 'app8'], ['system']]\n assert candidate(paths = [['root', 'x'], ['root', 'y'], ['root', 'x', 'z'], ['root', 'y', 'z'], ['root', 'x', 'a'], ['root', 'y', 'a'], ['root', 'x', 'a', 'b'], ['root', 'y', 'a', 'b']]) == [['root']]\n assert candidate(paths = [['root', 'level1', 'level2', 'level3'], ['root', 'level1', 'level2', 'level4'], ['root', 'level5', 'level6'], ['root', 'level1', 'level2', 'level3', 'level7'], ['root', 'level5', 'level6', 'level7'], ['root', 'level1', 'level2', 'level3', 'level7', 'level8'], ['root', 'level5', 'level6', 'level7', 'level8']]) == [['root', 'level1', 'level2', 'level4'], ['root', 'level1', 'level2'], ['root', 'level1'], ['root', 'level5'], ['root']]\n assert candidate(paths = [['data'], ['data', 'backup'], ['data', 'backup', '2021'], ['data', 'backup', '2022'], ['data', 'backup', '2021', 'month1'], ['data', 'backup', '2022', 'month1'], ['data', 'backup', '2021', 'month2'], ['data', 'backup', '2022', 'month2'], ['data', 'backup', '2021', 'month1', 'day1'], ['data', 'backup', '2022', 'month1', 'day1'], ['data', 'backup', '2021', 'month1', 'day2'], ['data', 'backup', '2022', 'month1', 'day2'], ['data', 'backup', '2021', 'month2', 'day1'], ['data', 'backup', '2022', 'month2', 'day1'], ['data', 'backup', '2021', 'month2', 'day2'], ['data', 'backup', '2022', 'month2', 'day2'], ['data', 'backup', '2021', 'month1', 'day1', 'file1'], ['data', 'backup', '2022', 'month1', 'day1', 'file1'], ['data', 'backup', '2021', 'month1', 'day2', 'file1'], ['data', 'backup', '2022', 'month1', 'day2', 'file1'], ['data', 'backup', '2021', 'month2', 'day1', 'file1'], ['data', 'backup', '2022', 'month2', 'day1', 'file1'], ['data', 'backup', '2021', 'month2', 'day2', 'file1'], ['data', 'backup', '2022', 'month2', 'day2', 'file1']]) == [['data', 'backup'], ['data']]\n assert candidate(paths = [['root', 'dir1', 'subdir1'], ['root', 'dir1', 'subdir2'], ['root', 'dir2', 'subdir1'], ['root', 'dir2', 'subdir3'], ['root', 'dir3', 'subdir2'], ['root', 'dir3', 'subdir4']]) == [['root', 'dir1', 'subdir1'], ['root', 'dir1', 'subdir2'], ['root', 'dir1'], ['root', 'dir2', 'subdir1'], ['root', 'dir2', 'subdir3'], ['root', 'dir2'], ['root', 'dir3', 'subdir2'], ['root', 'dir3', 'subdir4'], ['root', 'dir3'], ['root']]\n assert candidate(paths = [['x'], ['x', 'y'], ['x', 'y', 'z'], ['x', 'y', 'w'], ['y'], ['y', 'z'], ['y', 'w'], ['a'], ['a', 'b'], ['a', 'b', 'c'], ['b'], ['b', 'c'], ['b', 'd'], ['c'], ['c', 'd'], ['d']]) == [['a', 'b', 'c'], ['a', 'b'], ['a'], ['b', 'c'], ['b', 'd'], ['b'], ['c', 'd'], ['c'], ['d'], ['x']]\n assert candidate(paths = [['base', 'level1', 'level2', 'level3'], ['other', 'level1', 'level2', 'level3'], ['base', 'level1', 'level2', 'level3', 'level4'], ['other', 'level1', 'level2', 'level3', 'level4'], ['base', 'level1', 'level2', 'level3', 'level4', 'level5'], ['other', 'level1', 'level2', 'level3', 'level4', 'level5'], ['base', 'level1', 'level2', 'other'], ['other', 'level1', 'level2', 'other']]) == []\n assert candidate(paths = [['home', 'user1', 'documents'], ['home', 'user2', 'documents'], ['home', 'user1', 'documents', 'file1'], ['home', 'user2', 'documents', 'file1'], ['home', 'user1', 'pictures'], ['home', 'user2', 'pictures'], ['home', 'user1', 'pictures', 'photo1'], ['home', 'user2', 'pictures', 'photo1']]) == [['home']]\n assert candidate(paths = [['nested', 'folder1'], ['nested', 'folder2'], ['nested', 'folder1', 'subfolder1'], ['nested', 'folder2', 'subfolder1'], ['nested', 'folder1', 'subfolder1', 'subsubfolder1'], ['nested', 'folder2', 'subfolder1', 'subsubfolder1'], ['nested', 'folder1', 'subfolder2'], ['nested', 'folder2', 'subfolder2'], ['nested', 'folder1', 'subfolder2', 'subsubfolder2'], ['nested', 'folder2', 'subfolder2', 'subsubfolder2'], ['nested', 'folder1', 'subfolder2', 'subsubfolder2', 'file1'], ['nested', 'folder2', 'subfolder2', 'subsubfolder2', 'file1']]) == [['nested']]\n assert candidate(paths = [['a', 'b', 'c', 'd', 'e'], ['f', 'g', 'h'], ['a', 'b', 'c', 'd', 'f'], ['f', 'g', 'h', 'i'], ['a', 'b', 'c', 'd', 'j'], ['j', 'k'], ['f', 'g', 'h', 'i', 'k']]) == [['a', 'b', 'c', 'd', 'e'], ['a', 'b', 'c', 'd', 'f'], ['a', 'b', 'c', 'd', 'j'], ['a', 'b', 'c', 'd'], ['a', 'b', 'c'], ['a', 'b'], ['a'], ['f', 'g', 'h'], ['f', 'g'], ['f']]\n assert candidate(paths = [['root', 'a', 'b', 'c'], ['root', 'x', 'y', 'z'], ['root', 'a', 'b', 'd'], ['root', 'x', 'y', 'd'], ['root', 'a', 'b', 'c', 'e'], ['root', 'x', 'y', 'z', 'e'], ['root', 'a', 'b', 'c', 'f'], ['root', 'x', 'y', 'z', 'f'], ['root', 'a', 'g'], ['root', 'x', 'g'], ['root', 'a', 'h'], ['root', 'x', 'h']]) == [['root', 'a', 'b', 'd'], ['root', 'a', 'b'], ['root', 'a', 'g'], ['root', 'a', 'h'], ['root', 'a'], ['root', 'x', 'g'], ['root', 'x', 'h'], ['root', 'x', 'y', 'd'], ['root', 'x', 'y'], ['root', 'x'], ['root']]\n assert candidate(paths = [['library', 'books', 'genre1'], ['library', 'books', 'genre2'], ['library', 'books', 'genre3'], ['library', 'books', 'genre1', 'author1'], ['library', 'books', 'genre3', 'author1'], ['library', 'books', 'genre2', 'author2'], ['library', 'books', 'genre3', 'author2'], ['library', 'books', 'genre1', 'author1', 'book1'], ['library', 'books', 'genre3', 'author1', 'book1']]) == [['library', 'books', 'genre1'], ['library', 'books', 'genre2', 'author2'], ['library', 'books', 'genre2'], ['library', 'books', 'genre3', 'author2'], ['library', 'books', 'genre3'], ['library', 'books'], ['library']]\n assert candidate(paths = [['a'], ['a', 'b'], ['a', 'b', 'c'], ['a', 'b', 'c', 'd'], ['a', 'b', 'c', 'd', 'e'], ['b'], ['b', 'c'], ['b', 'c', 'd'], ['b', 'c', 'd', 'e'], ['c'], ['c', 'd'], ['c', 'd', 'e'], ['d'], ['d', 'e'], ['e']]) == [['a'], ['e']]\n assert candidate(paths = [['folder1'], ['folder1', 'folder2'], ['folder1', 'folder2', 'folder3'], ['folder1', 'folder2', 'folder3', 'folder4'], ['folder1', 'folder2', 'folder3', 'folder5'], ['folder1', 'folder2', 'folder6'], ['folder1', 'folder2', 'folder6', 'folder7'], ['folder1', 'folder2', 'folder6', 'folder8'], ['folder1', 'folder9'], ['folder1', 'folder9', 'folder10'], ['folder1', 'folder9', 'folder10', 'folder11'], ['folder1', 'folder9', 'folder10', 'folder12'], ['folder1', 'folder9', 'folder13'], ['folder1', 'folder9', 'folder13', 'folder14'], ['folder1', 'folder9', 'folder13', 'folder15']]) == [['folder1', 'folder2', 'folder3', 'folder4'], ['folder1', 'folder2', 'folder3', 'folder5'], ['folder1', 'folder2', 'folder3'], ['folder1', 'folder2', 'folder6', 'folder7'], ['folder1', 'folder2', 'folder6', 'folder8'], ['folder1', 'folder2', 'folder6'], ['folder1', 'folder2'], ['folder1', 'folder9', 'folder10', 'folder11'], ['folder1', 'folder9', 'folder10', 'folder12'], ['folder1', 'folder9', 'folder10'], ['folder1', 'folder9', 'folder13', 'folder14'], ['folder1', 'folder9', 'folder13', 'folder15'], ['folder1', 'folder9', 'folder13'], ['folder1', 'folder9'], ['folder1']]\n assert candidate(paths = [['projects', 'projectA'], ['projects', 'projectB'], ['projects', 'projectA', 'src'], ['projects', 'projectB', 'src'], ['projects', 'projectA', 'src', 'module1'], ['projects', 'projectB', 'src', 'module1'], ['projects', 'projectA', 'src', 'module2'], ['projects', 'projectB', 'src', 'module2'], ['projects', 'projectA', 'src', 'module1', 'file1'], ['projects', 'projectB', 'src', 'module1', 'file1'], ['projects', 'projectA', 'src', 'module2', 'file2'], ['projects', 'projectB', 'src', 'module2', 'file3'], ['projects', 'projectA', 'src', 'module1', 'file4'], ['projects', 'projectB', 'src', 'module1', 'file5']]) == [['projects', 'projectA', 'src', 'module1', 'file1'], ['projects', 'projectA', 'src', 'module1', 'file4'], ['projects', 'projectA', 'src', 'module1'], ['projects', 'projectA', 'src', 'module2', 'file2'], ['projects', 'projectA', 'src', 'module2'], ['projects', 'projectA', 'src'], ['projects', 'projectA'], ['projects', 'projectB', 'src', 'module1', 'file1'], ['projects', 'projectB', 'src', 'module1', 'file5'], ['projects', 'projectB', 'src', 'module1'], ['projects', 'projectB', 'src', 'module2', 'file3'], ['projects', 'projectB', 'src', 'module2'], ['projects', 'projectB', 'src'], ['projects', 'projectB'], ['projects']]\n assert candidate(paths = [['dir1'], ['dir2'], ['dir3'], ['dir1', 'sub1'], ['dir2', 'sub2'], ['dir3', 'sub1'], ['dir1', 'sub1', 'subsub1'], ['dir2', 'sub2', 'subsub2'], ['dir3', 'sub1', 'subsub1'], ['dir1', 'sub1', 'subsub1', 'deeper1'], ['dir3', 'sub1', 'subsub1', 'deeper1']]) == [['dir2', 'sub2', 'subsub2'], ['dir2', 'sub2'], ['dir2']]\n assert candidate(paths = [['a'], ['a', 'b'], ['a', 'b', 'c'], ['a', 'b', 'd'], ['b'], ['b', 'c'], ['b', 'd'], ['c'], ['c', 'a'], ['c', 'a', 'b'], ['d'], ['d', 'a'], ['d', 'a', 'b']]) == [['a']]\n assert candidate(paths = [['root', 'folder1', 'subfolder1', 'subsubfolder1'], ['root', 'folder2', 'subfolder2', 'subsubfolder1'], ['root', 'folder3', 'subfolder3'], ['root', 'folder1', 'subfolder1'], ['root', 'folder2', 'subfolder2']]) == [['root', 'folder1'], ['root', 'folder2'], ['root', 'folder3', 'subfolder3'], ['root', 'folder3'], ['root']]\n assert candidate(paths = [['folderA'], ['folderB'], ['folderA', 'subA'], ['folderB', 'subA'], ['folderA', 'subA', 'subsubA'], ['folderB', 'subA', 'subsubA'], ['folderC'], ['folderC', 'subB'], ['folderD'], ['folderD', 'subB', 'subsubB'], ['folderE'], ['folderE', 'subB', 'subsubB', 'deepB']]) == [['folderC', 'subB'], ['folderC'], ['folderD', 'subB', 'subsubB'], ['folderD', 'subB'], ['folderD'], ['folderE', 'subB', 'subsubB', 'deepB'], ['folderE', 'subB', 'subsubB'], ['folderE', 'subB'], ['folderE']]\n assert candidate(paths = [['main'], ['main', 'projects'], ['main', 'projects', 'project1'], ['main', 'projects', 'project2'], ['main', 'projects', 'project1', 'code'], ['main', 'projects', 'project2', 'code'], ['main', 'docs'], ['main', 'docs', 'project1'], ['main', 'docs', 'project2'], ['main', 'docs', 'project1', 'notes'], ['main', 'docs', 'project2', 'notes']]) == [['main', 'docs'], ['main', 'projects'], ['main']]\n assert candidate(paths = [['folder1', 'subfolder1', 'deepsub1'], ['folder2', 'subfolder2', 'deepsub2'], ['folder1', 'subfolder1', 'deepsub3'], ['folder2', 'subfolder2', 'deepsub3'], ['folder1', 'subfolder2'], ['folder2', 'subfolder2'], ['folder3', 'subfolder3']]) == [['folder1', 'subfolder1', 'deepsub1'], ['folder1', 'subfolder1', 'deepsub3'], ['folder1', 'subfolder1'], ['folder1', 'subfolder2'], ['folder1'], ['folder2', 'subfolder2', 'deepsub2'], ['folder2', 'subfolder2', 'deepsub3'], ['folder2', 'subfolder2'], ['folder2'], ['folder3', 'subfolder3'], ['folder3']]\n assert candidate(paths = [['parent', 'child1', 'grandchild1'], ['parent', 'child2', 'grandchild1'], ['parent', 'child1', 'grandchild2'], ['parent', 'child2', 'grandchild2'], ['parent', 'child1', 'grandchild3'], ['parent', 'child2', 'grandchild3'], ['parent', 'child1', 'subchild1', 'subsubchild1'], ['parent', 'child2', 'subchild1', 'subsubchild1'], ['parent', 'child1', 'subchild2', 'subsubchild2'], ['parent', 'child2', 'subchild2', 'subsubchild2']]) == [['parent']]\n assert candidate(paths = [['root', 'a', 'x'], ['root', 'b', 'x'], ['root', 'a', 'y'], ['root', 'b', 'y'], ['root', 'a', 'x', 'z'], ['root', 'b', 'x', 'z'], ['root', 'a', 'w'], ['root', 'b', 'w']]) == [['root']]\n assert candidate(paths = [['a', 'b', 'c'], ['a', 'd', 'e'], ['a', 'd', 'e', 'f'], ['g', 'h', 'i'], ['g', 'j', 'k'], ['g', 'j', 'l'], ['a', 'b', 'c', 'm'], ['g', 'h', 'i', 'm'], ['n', 'o', 'p'], ['n', 'o', 'q'], ['n', 'r', 's'], ['n', 'r', 's', 't']]) == [['a', 'b'], ['a', 'd', 'e', 'f'], ['a', 'd', 'e'], ['a', 'd'], ['a'], ['g', 'h'], ['g', 'j', 'k'], ['g', 'j', 'l'], ['g', 'j'], ['g'], ['n', 'o', 'p'], ['n', 'o', 'q'], ['n', 'o'], ['n', 'r', 's', 't'], ['n', 'r', 's'], ['n', 'r'], ['n']]\n assert candidate(paths = [['x'], ['x', 'y'], ['x', 'y', 'z'], ['x', 'y', 'z', 'w'], ['y'], ['y', 'z'], ['y', 'z', 'w'], ['z'], ['z', 'w'], ['w']]) == [['w'], ['x']]\n assert candidate(paths = [['main', 'branch1'], ['main', 'branch2'], ['main', 'branch1', 'sub1'], ['main', 'branch2', 'sub1'], ['main', 'branch1', 'sub2'], ['main', 'branch2', 'sub2'], ['main', 'branch1', 'sub1', 'subsub1'], ['main', 'branch2', 'sub1', 'subsub1'], ['main', 'branch1', 'sub1', 'subsub2'], ['main', 'branch2', 'sub1', 'subsub2']]) == [['main']]\n assert candidate(paths = [['x'], ['y'], ['z'], ['x', 'a'], ['y', 'a'], ['z', 'a'], ['x', 'a', 'b'], ['y', 'a', 'b'], ['x', 'a', 'b', 'c'], ['y', 'a', 'b', 'c'], ['w'], ['w', 'd'], ['w', 'd', 'e'], ['w', 'd', 'e', 'f'], ['v'], ['v', 'd'], ['v', 'd', 'e'], ['v', 'd', 'e', 'f']]) == [['z', 'a'], ['z']]\n assert candidate(paths = [['level1'], ['level1', 'level2'], ['level1', 'level2', 'level3'], ['level1', 'level2', 'level3', 'level4'], ['level1', 'level2', 'level3', 'level4', 'level5'], ['levelA'], ['levelA', 'level2'], ['levelA', 'level2', 'level3'], ['levelA', 'level2', 'level3', 'level4'], ['levelA', 'level2', 'level3', 'level4', 'level5']]) == []\n assert candidate(paths = [['root'], ['root', 'dir1'], ['root', 'dir1', 'subdir1'], ['root', 'dir2'], ['root', 'dir2', 'subdir1'], ['root', 'dir2', 'subdir2'], ['root', 'dir3'], ['root', 'dir3', 'subdir2'], ['root', 'dir4'], ['root', 'dir4', 'subdir1'], ['root', 'dir4', 'subdir2']]) == [['root', 'dir1', 'subdir1'], ['root', 'dir1'], ['root', 'dir3', 'subdir2'], ['root', 'dir3'], ['root']]\n assert candidate(paths = [['root', 'folder1', 'subfolder1'], ['root', 'folder2', 'subfolder1'], ['root', 'folder3', 'subfolder2'], ['root', 'folder3', 'subfolder2', 'deepsubfolder1'], ['root', 'folder4', 'subfolder2', 'deepsubfolder1'], ['root', 'folder5', 'subfolder2', 'deepsubfolder1', 'deeper1']]) == [['root', 'folder5', 'subfolder2', 'deepsubfolder1', 'deeper1'], ['root', 'folder5', 'subfolder2', 'deepsubfolder1'], ['root', 'folder5', 'subfolder2'], ['root', 'folder5'], ['root']]\n assert candidate(paths = [['home', 'user1', 'docs'], ['home', 'user2', 'docs'], ['home', 'user1', 'music'], ['home', 'user2', 'music'], ['home', 'user1', 'docs', 'report'], ['home', 'user2', 'docs', 'report'], ['home', 'user1', 'music', 'song1'], ['home', 'user2', 'music', 'song2'], ['home', 'user1', 'docs', 'report', 'summary'], ['home', 'user2', 'docs', 'report', 'summary'], ['home', 'user1', 'docs', 'report', 'summary', 'details'], ['home', 'user2', 'docs', 'report', 'summary', 'details']]) == [['home', 'user1', 'music', 'song1'], ['home', 'user1', 'music'], ['home', 'user1'], ['home', 'user2', 'music', 'song2'], ['home', 'user2', 'music'], ['home', 'user2'], ['home']]\n assert candidate(paths = [['main', 'project', 'src', 'module1'], ['main', 'project', 'src', 'module2'], ['main', 'project', 'src', 'module1', 'submodule1'], ['main', 'project', 'src', 'module2', 'submodule1'], ['main', 'project', 'src', 'module1', 'submodule2'], ['main', 'project', 'src', 'module2', 'submodule2'], ['main', 'project', 'src', 'module1', 'submodule1', 'subsubmodule1'], ['main', 'project', 'src', 'module2', 'submodule1', 'subsubmodule1'], ['main', 'unique', 'project', 'src', 'module1'], ['main', 'unique', 'project', 'src', 'module1', 'submodule1'], ['main', 'unique', 'project', 'src', 'module1', 'submodule1', 'subsubmodule1']]) == [['main', 'project', 'src'], ['main', 'project'], ['main', 'unique', 'project', 'src', 'module1'], ['main', 'unique', 'project', 'src'], ['main', 'unique', 'project'], ['main', 'unique'], ['main']]\n assert candidate(paths = [['projects', 'proj1', 'src'], ['projects', 'proj2', 'src'], ['projects', 'proj3'], ['projects', 'proj1', 'src', 'main'], ['projects', 'proj2', 'src', 'main'], ['projects', 'proj1', 'docs'], ['projects', 'proj2', 'docs'], ['projects', 'proj3', 'docs']]) == [['projects', 'proj3', 'docs'], ['projects', 'proj3'], ['projects']]\n assert candidate(paths = [['alpha'], ['beta'], ['gamma'], ['alpha', 'delta'], ['beta', 'delta'], ['gamma', 'epsilon'], ['alpha', 'delta', 'zeta'], ['beta', 'delta', 'zeta'], ['alpha', 'delta', 'zeta', 'eta'], ['beta', 'delta', 'zeta', 'eta'], ['alpha', 'theta'], ['beta', 'theta'], ['gamma', 'theta']]) == [['gamma', 'epsilon'], ['gamma', 'theta'], ['gamma']]\n assert candidate(paths = [['project'], ['project', 'module1'], ['project', 'module1', 'file1'], ['project', 'module2'], ['project', 'module2', 'file1'], ['project', 'module3'], ['project', 'module3', 'file2'], ['project', 'module4'], ['project', 'module4', 'file3'], ['project', 'module5'], ['project', 'module5', 'file3'], ['project', 'module6'], ['project', 'module6', 'file4'], ['project', 'module7'], ['project', 'module7', 'file4'], ['project', 'module8'], ['project', 'module8', 'file5'], ['project', 'module8', 'file6']]) == [['project', 'module3', 'file2'], ['project', 'module3'], ['project', 'module8', 'file5'], ['project', 'module8', 'file6'], ['project', 'module8'], ['project']]\n assert candidate(paths = [['app', 'module1', 'service1'], ['app', 'module2', 'service2'], ['app', 'module3', 'service1'], ['app', 'module4', 'service4'], ['app', 'module1', 'service1', 'endpoint1'], ['app', 'module3', 'service1', 'endpoint1'], ['app', 'module5'], ['app', 'module5', 'endpoint2']]) == [['app', 'module2', 'service2'], ['app', 'module2'], ['app', 'module4', 'service4'], ['app', 'module4'], ['app', 'module5', 'endpoint2'], ['app', 'module5'], ['app']]\n assert candidate(paths = [['root', 'dir1', 'subdir1'], ['root', 'dir2', 'subdir1'], ['root', 'dir1', 'subdir2'], ['root', 'dir2', 'subdir2'], ['root', 'dir1', 'subdir1', 'subsubdir1'], ['root', 'dir2', 'subdir1', 'subsubdir1'], ['root', 'dir1', 'subdir3'], ['root', 'dir2', 'subdir3']]) == [['root']]\n assert candidate(paths = [['root'], ['root', 'child1'], ['root', 'child2'], ['root', 'child1', 'sub1'], ['root', 'child2', 'sub1'], ['root', 'child1', 'sub1', 'subsub1'], ['root', 'child2', 'sub1', 'subsub1'], ['root', 'child1', 'sub2'], ['root', 'child2', 'sub2'], ['root', 'child1', 'sub2', 'subsub2'], ['root', 'child2', 'sub2', 'subsub2'], ['root', 'child3'], ['root', 'child3', 'sub1'], ['root', 'child3', 'sub1', 'subsub1'], ['root', 'child3', 'sub2'], ['root', 'child3', 'sub2', 'subsub2']]) == [['root']]\n assert candidate(paths = [['home'], ['home', 'user1'], ['home', 'user1', 'documents'], ['home', 'user1', 'pictures'], ['home', 'user2'], ['home', 'user2', 'documents'], ['home', 'user2', 'pictures'], ['home', 'user3'], ['home', 'user3', 'documents'], ['home', 'user3', 'pictures'], ['home', 'user3', 'videos'], ['home', 'user4'], ['home', 'user4', 'documents'], ['home', 'user4', 'pictures'], ['home', 'user4', 'videos'], ['home', 'user5'], ['home', 'user5', 'documents'], ['home', 'user5', 'pictures'], ['home', 'user5', 'videos'], ['home', 'user6'], ['home', 'user6', 'documents'], ['home', 'user6', 'pictures'], ['home', 'user6', 'videos'], ['home', 'user6', 'music']]) == [['home', 'user6', 'documents'], ['home', 'user6', 'music'], ['home', 'user6', 'pictures'], ['home', 'user6', 'videos'], ['home', 'user6'], ['home']]\n assert candidate(paths = [['documents', 'work', 'reports'], ['documents', 'work', 'reports', 'monthly'], ['documents', 'work', 'reports', 'monthly', 'jan'], ['documents', 'work', 'reports', 'monthly', 'feb'], ['documents', 'work', 'reports', 'monthly', 'mar'], ['documents', 'home', 'reports'], ['documents', 'home', 'reports', 'monthly'], ['documents', 'home', 'reports', 'monthly', 'jan'], ['documents', 'home', 'reports', 'monthly', 'feb'], ['documents', 'home', 'reports', 'monthly', 'mar'], ['documents', 'finance', 'reports'], ['documents', 'finance', 'reports', 'monthly'], ['documents', 'finance', 'reports', 'monthly', 'jan'], ['documents', 'finance', 'reports', 'monthly', 'feb'], ['documents', 'finance', 'reports', 'monthly', 'mar']]) == [['documents']]\n assert candidate(paths = [['root', 'folder1', 'sub1'], ['root', 'folder2', 'sub1'], ['root', 'folder1', 'sub2'], ['root', 'folder2', 'sub2'], ['root', 'folder3', 'sub1'], ['root', 'folder4', 'sub1'], ['root', 'folder3', 'sub3'], ['root', 'folder4', 'sub3']]) == [['root']]\n assert candidate(paths = [['home', 'user1', 'docs', 'work'], ['home', 'user2', 'docs', 'work'], ['home', 'user1', 'docs', 'projects'], ['home', 'user2', 'docs', 'projects'], ['home', 'user1', 'downloads', 'movies'], ['home', 'user2', 'downloads', 'movies'], ['home', 'user1', 'downloads', 'music'], ['home', 'user2', 'downloads', 'music'], ['home', 'user1', 'pictures', 'vacation'], ['home', 'user2', 'pictures', 'vacation'], ['home', 'user1', 'pictures', 'wedding'], ['home', 'user2', 'pictures', 'wedding']]) == [['home']]\n assert candidate(paths = [['library'], ['library', 'section1'], ['library', 'section1', 'shelf1'], ['library', 'section1', 'shelf2'], ['library', 'section1', 'shelf3'], ['library', 'section2'], ['library', 'section2', 'shelf1'], ['library', 'section2', 'shelf2'], ['library', 'section2', 'shelf4'], ['library', 'section3'], ['library', 'section3', 'shelf3'], ['library', 'section3', 'shelf4'], ['library', 'section4'], ['library', 'section4', 'shelf5'], ['library', 'section4', 'shelf6'], ['library', 'section5'], ['library', 'section5', 'shelf5'], ['library', 'section5', 'shelf6'], ['library', 'section6'], ['library', 'section6', 'shelf7'], ['library', 'section6', 'shelf8'], ['library', 'section7'], ['library', 'section7', 'shelf9'], ['library', 'section7', 'shelf10']]) == [['library', 'section1', 'shelf1'], ['library', 'section1', 'shelf2'], ['library', 'section1', 'shelf3'], ['library', 'section1'], ['library', 'section2', 'shelf1'], ['library', 'section2', 'shelf2'], ['library', 'section2', 'shelf4'], ['library', 'section2'], ['library', 'section3', 'shelf3'], ['library', 'section3', 'shelf4'], ['library', 'section3'], ['library', 'section6', 'shelf7'], ['library', 'section6', 'shelf8'], ['library', 'section6'], ['library', 'section7', 'shelf10'], ['library', 'section7', 'shelf9'], ['library', 'section7'], ['library']]\n assert candidate(paths = [['home'], ['home', 'user1'], ['home', 'user2'], ['home', 'user1', 'documents'], ['home', 'user2', 'documents'], ['home', 'user1', 'pictures'], ['home', 'user2', 'pictures'], ['home', 'user1', 'documents', 'work'], ['home', 'user2', 'documents', 'work'], ['home', 'user1', 'documents', 'personal'], ['home', 'user2', 'documents', 'personal'], ['home', 'user1', 'pictures', 'vacation'], ['home', 'user2', 'pictures', 'vacation'], ['home', 'user1', 'pictures', 'travel'], ['home', 'user2', 'pictures', 'travel'], ['home', 'user1', 'pictures', 'travel', '2022'], ['home', 'user2', 'pictures', 'travel', '2022']]) == [['home']]\n assert candidate(paths = [['root'], ['root', 'dir1'], ['root', 'dir2'], ['root', 'dir1', 'dir3'], ['root', 'dir2', 'dir4'], ['root', 'dir2', 'dir3'], ['root', 'dir1', 'dir3', 'dir5'], ['root', 'dir2', 'dir3', 'dir5']]) == [['root', 'dir1'], ['root', 'dir2', 'dir4'], ['root', 'dir2'], ['root']]\n"}, "metadata": {"canonical_parameter_names": ["paths"], "leetcode_dataset_entry_point": "Solution().deleteDuplicateFolder", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector> deleteDuplicateFolder(vector>& paths) {", "container": "Solution", "callable": "deleteDuplicateFolder", "parameters": [{"name": "paths", "type": "vector>&"}], "return_type": "vector>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1952, "task_id": "three-divisors", "difficulty": "Easy", "problem_description": "Given an integer n, return true if n has exactly three positive divisors. Otherwise, return false.\nAn integer m is a divisor of n if there exists an integer k such that n = k * m.\n \nExample 1:\n\nInput: n = 2\nOutput: false\nExplantion: 2 has only two divisors: 1 and 2.\n\nExample 2:\n\nInput: n = 4\nOutput: true\nExplantion: 4 has three divisors: 1, 2, and 4.\n\n \nConstraints:\n\n1 <= n <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 625) == False\n assert candidate(n = 3) == False\n assert candidate(n = 576) == False\n assert candidate(n = 729) == False\n assert candidate(n = 144) == False\n assert candidate(n = 49) == True\n assert candidate(n = 900) == False\n assert candidate(n = 324) == False\n assert candidate(n = 100) == False\n assert candidate(n = 841) == True\n assert candidate(n = 5) == False\n assert candidate(n = 289) == True\n assert candidate(n = 4) == True\n assert candidate(n = 64) == False\n assert candidate(n = 16) == False\n assert candidate(n = 10000) == False\n assert candidate(n = 484) == False\n assert candidate(n = 2) == False\n assert candidate(n = 225) == False\n assert candidate(n = 784) == False\n assert candidate(n = 1024) == False\n assert candidate(n = 101) == False\n assert candidate(n = 169) == True\n assert candidate(n = 256) == False\n assert candidate(n = 36) == False\n assert candidate(n = 529) == True\n assert candidate(n = 20) == False\n assert candidate(n = 676) == False\n assert candidate(n = 81) == False\n assert candidate(n = 15) == False\n assert candidate(n = 961) == True\n assert candidate(n = 400) == False\n assert candidate(n = 9) == True\n assert candidate(n = 196) == False\n assert candidate(n = 121) == True\n assert candidate(n = 361) == True\n assert candidate(n = 441) == False\n assert candidate(n = 7) == False\n assert candidate(n = 10) == False\n assert candidate(n = 25) == True\n assert candidate(n = 1089) == False\n assert candidate(n = 7225) == False\n assert candidate(n = 13689) == False\n assert candidate(n = 63841) == False\n assert candidate(n = 73081) == False\n assert candidate(n = 48601) == False\n assert candidate(n = 12544) == False\n assert candidate(n = 14400) == False\n assert candidate(n = 5929) == False\n assert candidate(n = 15625) == False\n assert candidate(n = 4761) == False\n assert candidate(n = 27) == False\n assert candidate(n = 90409) == False\n assert candidate(n = 34081) == False\n assert candidate(n = 66109) == False\n assert candidate(n = 6241) == True\n assert candidate(n = 8821) == False\n assert candidate(n = 16807) == False\n assert candidate(n = 2809) == True\n assert candidate(n = 10201) == True\n assert candidate(n = 11881) == True\n assert candidate(n = 823543) == False\n assert candidate(n = 57201) == False\n assert candidate(n = 1) == False\n assert candidate(n = 9604) == False\n assert candidate(n = 30025) == False\n assert candidate(n = 2601) == False\n assert candidate(n = 68401) == False\n assert candidate(n = 5329) == True\n assert candidate(n = 14641) == False\n assert candidate(n = 3025) == False\n assert candidate(n = 12321) == False\n assert candidate(n = 32041) == True\n assert candidate(n = 1009) == False\n assert candidate(n = 1681) == True\n assert candidate(n = 13456) == False\n assert candidate(n = 1225) == False\n assert candidate(n = 24025) == False\n assert candidate(n = 38161) == False\n assert candidate(n = 7921) == True\n assert candidate(n = 18769) == True\n assert candidate(n = 2401) == False\n assert candidate(n = 10609) == True\n assert candidate(n = 95657) == False\n assert candidate(n = 2025) == False\n assert candidate(n = 5625) == False\n assert candidate(n = 10404) == False\n assert candidate(n = 61609) == False\n assert candidate(n = 4489) == True\n assert candidate(n = 2209) == True\n assert candidate(n = 75469) == False\n assert candidate(n = 8388608) == False\n assert candidate(n = 12769) == True\n assert candidate(n = 52849) == False\n assert candidate(n = 55025) == False\n assert candidate(n = 4225) == False\n assert candidate(n = 3969) == False\n assert candidate(n = 16777216) == False\n assert candidate(n = 11236) == False\n assert candidate(n = 93019) == False\n assert candidate(n = 11449) == True\n assert candidate(n = 343) == False\n assert candidate(n = 42301) == False\n assert candidate(n = 6561) == False\n assert candidate(n = 98329) == False\n assert candidate(n = 36121) == False\n assert candidate(n = 101025) == False\n assert candidate(n = 12996) == False\n assert candidate(n = 12100) == False\n assert candidate(n = 77881) == False\n assert candidate(n = 44389) == False\n assert candidate(n = 14161) == False\n assert candidate(n = 5041) == True\n assert candidate(n = 8361) == False\n assert candidate(n = 85309) == False\n assert candidate(n = 80329) == False\n assert candidate(n = 82801) == False\n assert candidate(n = 2097152) == False\n assert candidate(n = 1849) == True\n assert candidate(n = 3481) == True\n assert candidate(n = 6889) == True\n assert candidate(n = 28099) == False\n assert candidate(n = 46489) == False\n assert candidate(n = 70729) == False\n assert candidate(n = 10816) == False\n assert candidate(n = 22201) == True\n assert candidate(n = 13924) == False\n assert candidate(n = 11025) == False\n assert candidate(n = 4194304) == False\n assert candidate(n = 87841) == False\n assert candidate(n = 1369) == True\n assert candidate(n = 59401) == False\n assert candidate(n = 13225) == False\n assert candidate(n = 40225) == False\n assert candidate(n = 11664) == False\n assert candidate(n = 50721) == False\n assert candidate(n = 7569) == False\n assert candidate(n = 3721) == True\n assert candidate(n = 3249) == False\n assert candidate(n = 20449) == False\n assert candidate(n = 9409) == True\n assert candidate(n = 9216) == False\n assert candidate(n = 26041) == False\n assert candidate(n = 1521) == False\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().isThree", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool isThree(int n) {", "container": "Solution", "callable": "isThree", "parameters": [{"name": "n", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1953, "task_id": "maximum-number-of-weeks-for-which-you-can-work", "difficulty": "Medium", "problem_description": "There are n projects numbered from 0 to n - 1. You are given an integer array milestones where each milestones[i] denotes the number of milestones the ith project has.\nYou can work on the projects following these two rules:\n\nEvery week, you will finish exactly one milestone of one project. You must work every week.\nYou cannot work on two milestones from the same project for two consecutive weeks.\n\nOnce all the milestones of all the projects are finished, or if the only milestones that you can work on will cause you to violate the above rules, you will stop working. Note that you may not be able to finish every project's milestones due to these constraints.\nReturn the maximum number of weeks you would be able to work on the projects without violating the rules mentioned above.\n \nExample 1:\n\nInput: milestones = [1,2,3]\nOutput: 6\nExplanation: One possible scenario is:\n​​​​- During the 1st week, you will work on a milestone of project 0.\n- During the 2nd week, you will work on a milestone of project 2.\n- During the 3rd week, you will work on a milestone of project 1.\n- During the 4th week, you will work on a milestone of project 2.\n- During the 5th week, you will work on a milestone of project 1.\n- During the 6th week, you will work on a milestone of project 2.\nThe total number of weeks is 6.\n\nExample 2:\n\nInput: milestones = [5,2,1]\nOutput: 7\nExplanation: One possible scenario is:\n- During the 1st week, you will work on a milestone of project 0.\n- During the 2nd week, you will work on a milestone of project 1.\n- During the 3rd week, you will work on a milestone of project 0.\n- During the 4th week, you will work on a milestone of project 1.\n- During the 5th week, you will work on a milestone of project 0.\n- During the 6th week, you will work on a milestone of project 2.\n- During the 7th week, you will work on a milestone of project 0.\nThe total number of weeks is 7.\nNote that you cannot work on the last milestone of project 0 on 8th week because it would violate the rules.\nThus, one milestone in project 0 will remain unfinished.\n\n \nConstraints:\n\nn == milestones.length\n1 <= n <= 105\n1 <= milestones[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(milestones = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(milestones = [3, 3, 3]) == 9\n assert candidate(milestones = [1, 1, 1, 1, 1]) == 5\n assert candidate(milestones = [10, 5, 1]) == 13\n assert candidate(milestones = [1000000000, 1, 1]) == 5\n assert candidate(milestones = [1, 2, 3]) == 6\n assert candidate(milestones = [5, 2, 1]) == 7\n assert candidate(milestones = [1000000000, 1000000000, 1000000000]) == 3000000000\n assert candidate(milestones = [1, 1, 1000000000]) == 5\n assert candidate(milestones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(milestones = [1]) == 1\n assert candidate(milestones = [1, 1000000000]) == 3\n assert candidate(milestones = [5, 5, 5, 5, 5, 5]) == 30\n assert candidate(milestones = [10, 1, 1]) == 5\n assert candidate(milestones = [1, 1000000000, 1]) == 5\n assert candidate(milestones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 1200\n assert candidate(milestones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 20\n assert candidate(milestones = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 200\n assert candidate(milestones = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1023\n assert candidate(milestones = [1000000000, 1000000000, 1000000000]) == 3000000000\n assert candidate(milestones = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 150\n assert candidate(milestones = [1000000000, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 19\n assert candidate(milestones = [1000000000, 500000000, 100000000, 50000000, 10000000, 5000000, 1000000, 500000, 100000, 50000, 10000, 5000, 1000, 500, 100, 50, 10, 5, 1]) == 1333333333\n assert candidate(milestones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(milestones = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]) == 10000\n assert candidate(milestones = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 50\n assert candidate(milestones = [1000000000, 999999999, 1, 2, 3, 4, 5]) == 2000000014\n assert candidate(milestones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 120\n assert candidate(milestones = [100, 200, 300, 400]) == 1000\n assert candidate(milestones = [1000000000, 999999999, 888888888]) == 2888888887\n assert candidate(milestones = [1, 2, 3, 4, 5]) == 15\n assert candidate(milestones = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610]) == 1596\n assert candidate(milestones = [500000000, 500000000, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1000000009\n assert candidate(milestones = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 1000\n assert candidate(milestones = [10, 10, 10, 10, 10, 10, 10, 10, 10, 100]) == 181\n assert candidate(milestones = [10, 10, 10, 10, 10]) == 50\n assert candidate(milestones = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 550\n assert candidate(milestones = [999999999, 1, 1, 1]) == 7\n assert candidate(milestones = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000]) == 550000\n assert candidate(milestones = [1000000000, 1000000000, 1000000000, 1]) == 3000000001\n assert candidate(milestones = [10, 20, 30, 40, 50]) == 150\n assert candidate(milestones = [5, 5, 5, 5, 5, 5]) == 30\n assert candidate(milestones = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1]) == 5000000001\n assert candidate(milestones = [10, 20, 30, 40, 50]) == 150\n assert candidate(milestones = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 55\n assert candidate(milestones = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 45\n assert candidate(milestones = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1]) == 10000000001\n assert candidate(milestones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 64\n assert candidate(milestones = [100, 99, 98, 97, 96, 95]) == 585\n assert candidate(milestones = [999999999, 999999999, 1]) == 1999999999\n assert candidate(milestones = [1000000000, 500000000, 250000000, 125000000]) == 1750000001\n assert candidate(milestones = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 32767\n assert candidate(milestones = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 90\n assert candidate(milestones = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 5500\n assert candidate(milestones = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]) == 5500\n assert candidate(milestones = [999999999, 999999998, 999999997, 999999996, 999999995, 999999994, 999999993, 999999992, 999999991, 999999990]) == 9999999945\n assert candidate(milestones = [100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 39\n assert candidate(milestones = [1000000000, 1000000000, 1000000000, 1000000000, 1]) == 4000000001\n assert candidate(milestones = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1]) == 101\n assert candidate(milestones = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 40\n assert candidate(milestones = [2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1, 2, 1, 3, 1]) == 35\n assert candidate(milestones = [500000000, 500000000, 1]) == 1000000001\n assert candidate(milestones = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 80\n assert candidate(milestones = [999999999, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 39\n assert candidate(milestones = [100, 150, 200, 250]) == 700\n assert candidate(milestones = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 50\n assert candidate(milestones = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 77\n assert candidate(milestones = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 110\n assert candidate(milestones = [500, 400, 300, 200, 100, 50, 25, 12, 6, 3, 1]) == 1597\n assert candidate(milestones = [1000000000, 1, 1000000000, 1, 1000000000, 1, 1000000000]) == 4000000003\n assert candidate(milestones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(milestones = [500000000, 500000000, 500000000, 500000000]) == 2000000000\n assert candidate(milestones = [1000000000, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 19\n assert candidate(milestones = [1, 2, 4, 8, 16, 32, 64]) == 127\n assert candidate(milestones = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711]) == 46365\n assert candidate(milestones = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120]) == 680\n assert candidate(milestones = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]) == 376\n assert candidate(milestones = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 30\n assert candidate(milestones = [333333333, 333333333, 333333333, 333333333, 333333333, 333333333, 333333333, 333333333, 333333333, 333333333]) == 3333333330\n assert candidate(milestones = [100, 1, 100, 1, 100, 1]) == 303\n"}, "metadata": {"canonical_parameter_names": ["milestones"], "leetcode_dataset_entry_point": "Solution().numberOfWeeks", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long numberOfWeeks(vector& milestones) {", "container": "Solution", "callable": "numberOfWeeks", "parameters": [{"name": "milestones", "type": "vector&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1954, "task_id": "minimum-garden-perimeter-to-collect-enough-apples", "difficulty": "Medium", "problem_description": "In a garden represented as an infinite 2D grid, there is an apple tree planted at every integer coordinate. The apple tree planted at an integer coordinate (i, j) has |i| + |j| apples growing on it.\nYou will buy an axis-aligned square plot of land that is centered at (0, 0).\nGiven an integer neededApples, return the minimum perimeter of a plot such that at least neededApples apples are inside or on the perimeter of that plot.\nThe value of |x| is defined as:\n\nx if x >= 0\n-x if x < 0\n\n \nExample 1:\n\n\nInput: neededApples = 1\nOutput: 8\nExplanation: A square plot of side length 1 does not contain any apples.\nHowever, a square plot of side length 2 has 12 apples inside (as depicted in the image above).\nThe perimeter is 2 * 4 = 8.\n\nExample 2:\n\nInput: neededApples = 13\nOutput: 16\n\nExample 3:\n\nInput: neededApples = 1000000000\nOutput: 5040\n\n \nConstraints:\n\n1 <= neededApples <= 1015\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(neededApples = 10000000000) == 10856\n assert candidate(neededApples = 10) == 8\n assert candidate(neededApples = 50) == 16\n assert candidate(neededApples = 1000000) == 504\n assert candidate(neededApples = 13) == 16\n assert candidate(neededApples = 1000000000) == 5040\n assert candidate(neededApples = 1000000000000000) == 503968\n assert candidate(neededApples = 1000) == 48\n assert candidate(neededApples = 987654321) == 5016\n assert candidate(neededApples = 1000000000000) == 50400\n assert candidate(neededApples = 999999999999999) == 503968\n assert candidate(neededApples = 100) == 24\n assert candidate(neededApples = 100000000) == 2336\n assert candidate(neededApples = 123456789) == 2512\n assert candidate(neededApples = 1) == 8\n assert candidate(neededApples = 2000000000) == 6352\n assert candidate(neededApples = 50000000000) == 18568\n assert candidate(neededApples = 123456789012345) == 250944\n assert candidate(neededApples = 1000000001) == 5040\n assert candidate(neededApples = 18014398509481984) == 1321120\n assert candidate(neededApples = 10000) == 112\n assert candidate(neededApples = 5000000000) == 8616\n assert candidate(neededApples = 50000) == 184\n assert candidate(neededApples = 120) == 24\n assert candidate(neededApples = 5) == 8\n assert candidate(neededApples = 6) == 8\n assert candidate(neededApples = 20) == 16\n assert candidate(neededApples = 2000000000000) == 63496\n assert candidate(neededApples = 100000000000) == 23392\n assert candidate(neededApples = 2147483647) == 6504\n assert candidate(neededApples = 100000) == 232\n assert candidate(neededApples = 123456789123) == 25096\n assert candidate(neededApples = 987654321987) == 50192\n assert candidate(neededApples = 2500000000) == 6840\n assert candidate(neededApples = 468) == 40\n assert candidate(neededApples = 500000000000) == 40000\n assert candidate(neededApples = 20736) == 136\n assert candidate(neededApples = 256) == 32\n assert candidate(neededApples = 500000000000000) == 400000\n assert candidate(neededApples = 111111111111111) == 242280\n assert candidate(neededApples = 99999999999999999) == 2339216\n assert candidate(neededApples = 8000000000) == 10080\n assert candidate(neededApples = 12) == 8\n assert candidate(neededApples = 122500) == 248\n assert candidate(neededApples = 25200) == 144\n assert candidate(neededApples = 598593750000) == 42472\n assert candidate(neededApples = 9261000) == 1056\n assert candidate(neededApples = 754321098) == 4584\n assert candidate(neededApples = 999999999999999999) == 5039688\n assert candidate(neededApples = 876543210987654) == 482312\n assert candidate(neededApples = 100000000000000000000) == 23392144\n assert candidate(neededApples = 100000000000000) == 233920\n assert candidate(neededApples = 400000000000000) == 371328\n assert candidate(neededApples = 1000000000000000000) == 5039688\n assert candidate(neededApples = 987654321098765) == 501888\n assert candidate(neededApples = 9999999999999999) == 1085768\n assert candidate(neededApples = 5000) == 88\n assert candidate(neededApples = 10000000000000) == 108576\n assert candidate(neededApples = 3500) == 80\n assert candidate(neededApples = 1024) == 48\n assert candidate(neededApples = 18) == 16\n assert candidate(neededApples = 30000000000000) == 156592\n assert candidate(neededApples = 2) == 8\n assert candidate(neededApples = 500) == 40\n assert candidate(neededApples = 4) == 8\n assert candidate(neededApples = 3) == 8\n assert candidate(neededApples = 10000000000000000000) == 10857672\n assert candidate(neededApples = 4608) == 80\n"}, "metadata": {"canonical_parameter_names": ["neededApples"], "leetcode_dataset_entry_point": "Solution().minimumPerimeter", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long minimumPerimeter(long long neededApples) {", "container": "Solution", "callable": "minimumPerimeter", "parameters": [{"name": "neededApples", "type": "long long"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1955, "task_id": "count-number-of-special-subsequences", "difficulty": "Hard", "problem_description": "A sequence is special if it consists of a positive number of 0s, followed by a positive number of 1s, then a positive number of 2s.\n\nFor example, [0,1,2] and [0,0,1,1,1,2] are special.\nIn contrast, [2,1,0], [1], and [0,1,2,0] are not special.\n\nGiven an array nums (consisting of only integers 0, 1, and 2), return the number of different subsequences that are special. Since the answer may be very large, return it modulo 109 + 7.\nA subsequence of an array is a sequence that can be derived from the array by deleting some or no elements without changing the order of the remaining elements. Two subsequences are different if the set of indices chosen are different.\n \nExample 1:\n\nInput: nums = [0,1,2,2]\nOutput: 3\nExplanation: The special subsequences are bolded [0,1,2,2], [0,1,2,2], and [0,1,2,2].\n\nExample 2:\n\nInput: nums = [2,2,0,0]\nOutput: 0\nExplanation: There are no special subsequences in [2,2,0,0].\n\nExample 3:\n\nInput: nums = [0,1,2,0,1,2]\nOutput: 7\nExplanation: The special subsequences are bolded:\n- [0,1,2,0,1,2]\n- [0,1,2,0,1,2]\n- [0,1,2,0,1,2]\n- [0,1,2,0,1,2]\n- [0,1,2,0,1,2]\n- [0,1,2,0,1,2]\n- [0,1,2,0,1,2]\n\n \nConstraints:\n\n1 <= nums.length <= 105\n0 <= nums[i] <= 2\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 0, 1, 1, 2]) == 9\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2]) == 0\n assert candidate(nums = [0, 0, 0, 1, 1, 2]) == 21\n assert candidate(nums = [2, 2, 0, 0]) == 0\n assert candidate(nums = [0, 1, 2, 2]) == 3\n assert candidate(nums = [0, 1, 2, 2, 2]) == 7\n assert candidate(nums = [1, 2, 2, 0, 0, 1]) == 0\n assert candidate(nums = [0, 1, 2, 1, 2, 0, 1, 2]) == 19\n assert candidate(nums = [0, 1, 0, 1, 2]) == 5\n assert candidate(nums = [0, 1, 1, 1, 2, 2, 2]) == 49\n assert candidate(nums = [2, 1, 0, 1, 0, 2, 0]) == 1\n assert candidate(nums = [0, 1, 2, 0, 1, 0, 1, 2]) == 19\n assert candidate(nums = [2, 0, 1, 2, 0, 1, 2]) == 7\n assert candidate(nums = [2, 0, 1, 0, 1, 2]) == 5\n assert candidate(nums = [2, 0, 1, 0, 1, 2, 0, 1, 2]) == 27\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 2]) == 63\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 0, 1, 2, 0, 1, 2, 0]) == 7\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 2, 2]) == 51\n assert candidate(nums = [0, 1, 2, 0, 1, 2]) == 7\n assert candidate(nums = [0, 1, 2]) == 1\n assert candidate(nums = [0, 0, 1, 2, 1, 2]) == 15\n assert candidate(nums = [0, 0, 1, 1, 2, 2]) == 27\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 2, 2, 2]) == 119\n assert candidate(nums = [0, 0, 0, 1, 2, 2]) == 21\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2]) == 343\n assert candidate(nums = [0, 1, 0, 1, 2, 0, 1, 2]) == 27\n assert candidate(nums = [0, 1, 1, 2, 2, 2]) == 21\n assert candidate(nums = [1, 2, 0]) == 0\n assert candidate(nums = [2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2]) == 735\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 375309442\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2]) == 21567\n assert candidate(nums = [0, 0, 0, 0, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2]) == 9975\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 554508028\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 25039\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 133432831\n assert candidate(nums = [0, 1, 0, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 207\n assert candidate(nums = [2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0]) == 351\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == 14415\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2]) == 2048383\n assert candidate(nums = [0, 1, 0, 2, 0, 1, 0, 2, 1, 2]) == 55\n assert candidate(nums = [0, 1, 1, 0, 2, 2, 1, 1, 0, 2, 0, 1, 2]) == 135\n assert candidate(nums = [0, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2]) == 6399\n assert candidate(nums = [2, 1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2]) == 735\n assert candidate(nums = [0, 1, 2, 2, 0, 1, 2, 2, 0, 1, 2, 2, 0, 1, 2, 2, 0, 1, 2, 2]) == 3519\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]) == 14175\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 2, 2, 2, 2, 2, 0, 1, 2, 0, 1, 2]) == 2335\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 2, 2, 2, 2, 2]) == 3999\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 0, 1, 2, 2]) == 3279\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2]) == 1575\n assert candidate(nums = [2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 0, 0]) == 0\n assert candidate(nums = [0, 1, 0, 2, 0, 1, 0, 2, 0, 1, 0, 2]) == 71\n assert candidate(nums = [2, 2, 2, 1, 1, 1, 0, 0, 0, 2, 2, 2, 1, 1, 1, 0, 0, 0]) == 0\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 2, 2, 0, 0, 1, 1, 2, 2, 2]) == 1647\n assert candidate(nums = [0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 1, 1, 2]) == 423\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2]) == 26775\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]) == 29295\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 2, 2]) == 135\n assert candidate(nums = [2, 2, 2, 2, 0, 0, 0, 0, 1, 1, 1, 1]) == 0\n assert candidate(nums = [0, 0, 0, 1, 1, 2, 2, 2, 1, 1, 2, 2, 2, 0, 1, 2]) == 4047\n assert candidate(nums = [0, 1, 2, 0, 1, 2, 0, 1, 2]) == 31\n assert candidate(nums = [2, 2, 2, 1, 1, 0, 0, 0, 0]) == 0\n assert candidate(nums = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 1023\n assert candidate(nums = [2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 70599160\n assert candidate(nums = [0, 0, 1, 1, 1, 1, 2, 2, 0, 0, 1, 1, 2]) == 495\n assert candidate(nums = [0, 1, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2]) == 63\n assert candidate(nums = [0, 1, 1, 2, 0, 1, 2, 2, 1, 2, 0, 1, 2, 2, 1, 0, 1, 2, 2]) == 2847\n assert candidate(nums = [0, 0, 1, 1, 1, 1, 2, 2, 2, 2]) == 675\n assert candidate(nums = [0, 1, 2, 2, 1, 0, 1, 2, 2, 1, 0, 1, 2]) == 127\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2]) == 1575\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 2, 2, 2, 2]) == 255\n assert candidate(nums = [2, 0, 0, 0, 1, 1, 1, 2, 2, 2]) == 343\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]) == 250047\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 0, 1, 1, 1, 2, 2, 2]) == 8575\n assert candidate(nums = [0, 0, 1, 1, 1, 2, 2, 2, 2, 2]) == 651\n assert candidate(nums = [2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 18943\n assert candidate(nums = [0, 1, 2, 2, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2, 2, 1, 1, 2, 2]) == 4609\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 534776319\n assert candidate(nums = [0, 1, 2, 0, 1, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 303\n assert candidate(nums = [0, 1, 1, 2, 2, 2, 2, 2, 0, 1, 2, 0, 1, 2, 2]) == 855\n assert candidate(nums = [2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 2815\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2]) == 3375\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 4287\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2]) == 20223\n assert candidate(nums = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 2815\n assert candidate(nums = [2, 2, 0, 0, 0, 1, 1, 1, 2, 2]) == 147\n assert candidate(nums = [2, 0, 0, 1, 1, 1, 2, 2, 2, 2, 0, 0, 1, 1, 2, 2]) == 1647\n assert candidate(nums = [0, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 831\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == 29791\n assert candidate(nums = [2, 2, 2, 2, 2, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 451143\n assert candidate(nums = [2, 2, 2, 0, 1, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 335\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 1, 2, 0, 1, 2]) == 1855\n assert candidate(nums = [0, 1, 1, 1, 2, 2, 2, 2, 0, 1, 2]) == 227\n assert candidate(nums = [0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 0, 1, 2]) == 1447\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 0, 0, 1, 1, 2, 2, 2, 2]) == 16095\n assert candidate(nums = [0, 1, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2]) == 7039\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2]) == 351\n assert candidate(nums = [0, 1, 2, 0, 0, 1, 1, 1, 2, 2, 0, 1, 2]) == 479\n assert candidate(nums = [2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2]) == 2943\n assert candidate(nums = [2, 2, 2, 2, 2, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2]) == 735\n assert candidate(nums = [0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 1, 1, 2, 2]) == 975\n assert candidate(nums = [2, 0, 0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 1, 1, 2, 2]) == 2239\n assert candidate(nums = [0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2]) == 6727\n assert candidate(nums = [0, 0, 0, 1, 2, 2, 2, 1, 1, 1, 0, 0, 0]) == 49\n assert candidate(nums = [0, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2]) == 783\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2]) == 704511\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 2, 2, 2, 2, 2]) == 527\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 0, 0, 1, 1, 2, 2, 2, 2]) == 28639\n assert candidate(nums = [0, 0, 0, 0, 1, 1, 1, 2, 2, 2]) == 735\n assert candidate(nums = [0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2, 0, 0, 1, 1, 2, 2]) == 2943\n assert candidate(nums = [0, 0, 1, 1, 1, 2, 2, 2, 2]) == 315\n assert candidate(nums = [0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2]) == 1323\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2]) == 3375\n assert candidate(nums = [0, 0, 1, 1, 1, 2, 2, 2, 0, 0, 1, 1, 1, 2, 2, 2]) == 3087\n assert candidate(nums = [0, 1, 2, 1, 2, 0, 1, 2, 1, 2, 0, 1, 2]) == 167\n assert candidate(nums = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 351\n assert candidate(nums = [2, 1, 0, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 2]) == 7423\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2]) == 4335\n assert candidate(nums = [0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 0, 1, 2]) == 3151\n assert candidate(nums = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 18943\n assert candidate(nums = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 274431\n assert candidate(nums = [0, 0, 1, 1, 2, 0, 1, 2, 0, 1, 2]) == 151\n assert candidate(nums = [0, 0, 0, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2]) == 3591\n assert candidate(nums = [2, 2, 2, 0, 0, 0, 1, 1, 1]) == 0\n assert candidate(nums = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 111\n assert candidate(nums = [0, 0, 0, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 2, 2]) == 3367\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countSpecialSubsequences", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countSpecialSubsequences(vector& nums) {", "container": "Solution", "callable": "countSpecialSubsequences", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1957, "task_id": "delete-characters-to-make-fancy-string", "difficulty": "Easy", "problem_description": "A fancy string is a string where no three consecutive characters are equal.\nGiven a string s, delete the minimum possible number of characters from s to make it fancy.\nReturn the final string after the deletion. It can be shown that the answer will always be unique.\n \nExample 1:\n\nInput: s = \"leeetcode\"\nOutput: \"leetcode\"\nExplanation:\nRemove an 'e' from the first group of 'e's to create \"leetcode\".\nNo three consecutive characters are equal, so return \"leetcode\".\n\nExample 2:\n\nInput: s = \"aaabaaaa\"\nOutput: \"aabaa\"\nExplanation:\nRemove an 'a' from the first group of 'a's to create \"aabaaaa\".\nRemove two 'a's from the second group of 'a's to create \"aabaa\".\nNo three consecutive characters are equal, so return \"aabaa\".\n\nExample 3:\n\nInput: s = \"aab\"\nOutput: \"aab\"\nExplanation: No three consecutive characters are equal, so return \"aab\".\n\n \nConstraints:\n\n1 <= s.length <= 105\ns consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"zzzzzzzzz\") == \"zz\"\n assert candidate(s = \"aaabbbccc\") == \"aabbcc\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(s = \"aabbaa\") == \"aabbaa\"\n assert candidate(s = \"leeetcode\") == \"leetcode\"\n assert candidate(s = \"aaaaa\") == \"aa\"\n assert candidate(s = \"ccccccaaa\") == \"ccaa\"\n assert candidate(s = \"aabbccddd\") == \"aabbccdd\"\n assert candidate(s = \"cccaaa\") == \"ccaa\"\n assert candidate(s = \"aaa\") == \"aa\"\n assert candidate(s = \"aababab\") == \"aababab\"\n assert candidate(s = \"aaaabbbcccaa\") == \"aabbccaa\"\n assert candidate(s = \"aaaabbbbcccc\") == \"aabbcc\"\n assert candidate(s = \"zzzzzzzzzz\") == \"zz\"\n assert candidate(s = \"ababababc\") == \"ababababc\"\n assert candidate(s = \"abacadaeafag\") == \"abacadaeafag\"\n assert candidate(s = \"abc\") == \"abc\"\n assert candidate(s = \"aabbaaabbbaaa\") == \"aabbaabbaa\"\n assert candidate(s = \"aab\") == \"aab\"\n assert candidate(s = \"aabbcc\") == \"aabbcc\"\n assert candidate(s = \"mississippi\") == \"mississippi\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"xyzzzxxzzzz\") == \"xyzzxxzz\"\n assert candidate(s = \"aaabaaaa\") == \"aabaa\"\n assert candidate(s = \"abcdefg\") == \"abcdefg\"\n assert candidate(s = \"aabbccddeeefffggghhhiiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwwwxxxxyyyzzz\") == \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"abcabcabcabc\") == \"abcabcabcabc\"\n assert candidate(s = \"pppaaabbbcccddddeeeffffggghhhhiiiijjjjjkkkkklllllmmmmmnnnnnooooooopppppqqqqqrrrrrssssstttttuuuuuuvvvvvvvvvvwwwwwwxxxxxyyyyzzzzz\") == \"ppaabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\"\n assert candidate(s = \"xyzzzzzzzzzyx\") == \"xyzzyx\"\n assert candidate(s = \"mnonononojmnonononojmnonononoj\") == \"mnonononojmnonononojmnonononoj\"\n assert candidate(s = \"pppqqqrssstttuuuvvvwwwxxyyyzzz\") == \"ppqqrssttuuvvwwxxyyzz\"\n assert candidate(s = \"aabbccddeeefff\") == \"aabbccddeeff\"\n assert candidate(s = \"abcdefghijjjjjklmnopqrstuvwxyz\") == \"abcdefghijjklmnopqrstuvwxyz\"\n assert candidate(s = \"nnneennneennneennn\") == \"nneenneenneenn\"\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().makeFancyString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string makeFancyString(string s) {", "container": "Solution", "callable": "makeFancyString", "parameters": [{"name": "s", "type": "string"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1958, "task_id": "check-if-move-is-legal", "difficulty": "Medium", "problem_description": "You are given a 0-indexed 8 x 8 grid board, where board[r][c] represents the cell (r, c) on a game board. On the board, free cells are represented by '.', white cells are represented by 'W', and black cells are represented by 'B'.\nEach move in this game consists of choosing a free cell and changing it to the color you are playing as (either white or black). However, a move is only legal if, after changing it, the cell becomes the endpoint of a good line (horizontal, vertical, or diagonal).\nA good line is a line of three or more cells (including the endpoints) where the endpoints of the line are one color, and the remaining cells in the middle are the opposite color (no cells in the line are free). You can find examples for good lines in the figure below:\n\nGiven two integers rMove and cMove and a character color representing the color you are playing as (white or black), return true if changing cell (rMove, cMove) to color color is a legal move, or false if it is not legal.\n \nExample 1:\n\n\nInput: board = [[\".\",\".\",\".\",\"B\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"W\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"W\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"W\",\".\",\".\",\".\",\".\"],[\"W\",\"B\",\"B\",\".\",\"W\",\"W\",\"W\",\"B\"],[\".\",\".\",\".\",\"B\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"B\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"W\",\".\",\".\",\".\",\".\"]], rMove = 4, cMove = 3, color = \"B\"\nOutput: true\nExplanation: '.', 'W', and 'B' are represented by the colors blue, white, and black respectively, and cell (rMove, cMove) is marked with an 'X'.\nThe two good lines with the chosen cell as an endpoint are annotated above with the red rectangles.\n\nExample 2:\n\n\nInput: board = [[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\"B\",\".\",\".\",\"W\",\".\",\".\",\".\"],[\".\",\".\",\"W\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\"W\",\"B\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\".\"],[\".\",\".\",\".\",\".\",\"B\",\"W\",\".\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\"W\",\".\"],[\".\",\".\",\".\",\".\",\".\",\".\",\".\",\"B\"]], rMove = 4, cMove = 4, color = \"W\"\nOutput: false\nExplanation: While there are good lines with the chosen cell as a middle cell, there are no good lines with the chosen cell as an endpoint.\n\n \nConstraints:\n\nboard.length == board[r].length == 8\n0 <= rMove, cMove < 8\nboard[rMove][cMove] == '.'\ncolor is either 'B' or 'W'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(board = [['.', 'W', '.', '.', '.', '.', '.', '.'], ['.', '.', 'W', '.', '.', '.', '.', '.'], ['W', '.', '.', 'W', '.', '.', '.', '.'], ['.', '.', 'W', '.', '.', '.', '.', '.'], ['.', 'W', 'W', 'W', '.', '.', '.', '.'], ['.', '.', 'W', '.', '.', '.', '.', '.'], ['.', '.', 'W', '.', '.', '.', '.', '.'], ['.', 'W', '.', '.', '.', '.', '.', '.']],rMove = 3,cMove = 3,color = \"W\") == False\n assert candidate(board = [['.', 'W', '.', '.', '.', '.', '.', '.'], ['.', 'W', '.', '.', '.', '.', '.', '.'], ['W', '.', '.', 'W', '.', '.', '.', '.'], ['.', 'W', 'W', 'W', '.', '.', '.', '.'], ['.', 'W', 'W', 'W', '.', '.', '.', '.'], ['.', 'W', 'W', 'W', '.', '.', '.', '.'], ['.', 'W', '.', '.', '.', '.', '.', '.'], ['W', '.', '.', '.', '.', '.', '.', '.']],rMove = 4,cMove = 3,color = \"B\") == False\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', 'B', '.', '.', 'W', '.', '.', '.'], ['.', '.', 'W', '.', '.', '.', '.', '.'], ['.', '.', '.', 'W', 'B', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', 'B', 'W', '.', '.'], ['.', '.', '.', '.', '.', '.', 'W', '.'], ['.', '.', '.', '.', '.', '.', '.', 'B']],rMove = 4,cMove = 4,color = \"W\") == False\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'W', '.', '.', '.', '.'], ['.', 'W', '.', 'W', '.', '.', '.', '.'], ['W', '.', 'W', '.', 'W', '.', '.', '.'], ['.', 'W', '.', 'W', '.', '.', '.', '.'], ['.', '.', 'W', '.', 'W', '.', '.', '.'], ['.', '.', '.', 'W', '.', '.', '.', '.'], ['.', '.', '.', 'W', '.', '.', '.', '.']],rMove = 2,cMove = 2,color = \"B\") == False\n assert candidate(board = [['.', '.', '.', 'B', '.', '.', '.', '.'], ['.', '.', '.', 'W', '.', '.', '.', '.'], ['.', '.', '.', 'W', '.', '.', '.', '.'], ['.', '.', '.', 'W', '.', '.', '.', '.'], ['W', 'B', 'B', '.', 'W', 'W', 'W', 'B'], ['.', '.', '.', 'B', '.', '.', '.', '.'], ['.', '.', '.', 'B', '.', '.', '.', '.'], ['.', '.', '.', 'W', '.', '.', '.', '.']],rMove = 4,cMove = 3,color = \"B\") == True\n assert candidate(board = [['.', 'B', '.', '.', '.', '.', '.', '.'], ['B', 'B', '.', '.', '.', '.', '.', '.'], ['.', 'B', '.', '.', '.', '.', '.', '.'], ['.', 'B', '.', '.', '.', '.', '.', '.'], ['.', 'B', '.', '.', '.', '.', '.', '.'], ['.', 'B', '.', '.', '.', '.', '.', '.'], ['.', 'B', '.', '.', '.', '.', '.', '.'], ['.', 'B', '.', '.', '.', '.', '.', '.']],rMove = 4,cMove = 1,color = \"W\") == False\n assert candidate(board = [['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', 'W', 'B', '.', '.', '.'], ['.', '.', '.', 'B', 'W', '.', '.', '.'], ['.', '.', '.', 'B', 'B', '.', '.', '.'], ['.', '.', '.', 'B', 'W', '.', '.', '.'], ['.', '.', '.', 'W', 'B', '.', '.', '.']],rMove = 3,cMove = 3,color = \"W\") == True\n assert candidate(board = [['.', 'W', '.', '.', '.', '.', '.', '.'], ['.', 'W', '.', '.', '.', '.', '.', '.'], ['W', '.', '.', 'W', '.', '.', '.', '.'], ['.', 'W', 'W', 'W', '.', '.', '.', '.'], ['.', 'W', 'W', 'B', '.', '.', '.', '.'], ['.', 'W', 'W', 'W', '.', '.', '.', '.'], ['.', 'W', '.', '.', '.', '.', '.', '.'], ['W', '.', '.', '.', '.', '.', '.', '.']],rMove = 4,cMove = 3,color = \"W\") == False\n"}, "metadata": {"canonical_parameter_names": ["board", "rMove", "cMove", "color"], "leetcode_dataset_entry_point": "Solution().checkMove", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool checkMove(vector>& board, int rMove, int cMove, char color) {", "container": "Solution", "callable": "checkMove", "parameters": [{"name": "board", "type": "vector>&"}, {"name": "rMove", "type": "int"}, {"name": "cMove", "type": "int"}, {"name": "color", "type": "char"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1959, "task_id": "minimum-total-space-wasted-with-k-resizing-operations", "difficulty": "Medium", "problem_description": "You are currently designing a dynamic array. You are given a 0-indexed integer array nums, where nums[i] is the number of elements that will be in the array at time i. In addition, you are given an integer k, the maximum number of times you can resize the array (to any size).\nThe size of the array at time t, sizet, must be at least nums[t] because there needs to be enough space in the array to hold all the elements. The space wasted at time t is defined as sizet - nums[t], and the total space wasted is the sum of the space wasted across every time t where 0 <= t < nums.length.\nReturn the minimum total space wasted if you can resize the array at most k times.\nNote: The array can have any size at the start and does not count towards the number of resizing operations.\n \nExample 1:\n\nInput: nums = [10,20], k = 0\nOutput: 10\nExplanation: size = [20,20].\nWe can set the initial size to be 20.\nThe total wasted space is (20 - 10) + (20 - 20) = 10.\n\nExample 2:\n\nInput: nums = [10,20,30], k = 1\nOutput: 10\nExplanation: size = [20,20,30].\nWe can set the initial size to be 20 and resize to 30 at time 2. \nThe total wasted space is (20 - 10) + (20 - 20) + (30 - 30) = 10.\n\nExample 3:\n\nInput: nums = [10,20,15,30,20], k = 2\nOutput: 15\nExplanation: size = [10,20,20,30,30].\nWe can set the initial size to 10, resize to 20 at time 1, and resize to 30 at time 3.\nThe total wasted space is (10 - 10) + (20 - 20) + (20 - 15) + (30 - 30) + (30 - 20) = 15.\n\n \nConstraints:\n\n1 <= nums.length <= 200\n1 <= nums[i] <= 106\n0 <= k <= nums.length - 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 10, 10, 10, 10],k = 2) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30],k = 3) == 10\n assert candidate(nums = [10, 20, 30],k = 1) == 10\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],k = 0) == 45\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7],k = 3) == 3\n assert candidate(nums = [100, 200, 150, 300, 200, 350],k = 2) == 250\n assert candidate(nums = [10, 20, 15, 30, 20],k = 2) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 0) == 90\n assert candidate(nums = [1, 2, 3, 4, 5],k = 4) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 0\n assert candidate(nums = [100, 200, 300, 400, 500],k = 0) == 1000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 3) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 0) == 450\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500],k = 4) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 4) == 10\n assert candidate(nums = [5, 8, 6, 10],k = 1) == 5\n assert candidate(nums = [1, 3, 5, 7, 9],k = 4) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 9) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 9) == 0\n assert candidate(nums = [5, 5, 5, 5, 5],k = 0) == 0\n assert candidate(nums = [1000000, 1000000, 1000000],k = 2) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 40\n assert candidate(nums = [10, 20],k = 0) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 5\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == 0\n assert candidate(nums = [20, 10, 30, 25, 40],k = 2) == 15\n assert candidate(nums = [5, 5, 5, 5, 5, 5],k = 0) == 0\n assert candidate(nums = [20, 10, 30, 25, 15],k = 2) == 15\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 2) == 4\n assert candidate(nums = [300, 200, 100, 400, 300, 200, 500, 400, 300, 600, 500, 400, 700, 600, 500, 800, 700, 600, 900, 800, 700, 1000, 900, 800, 1100, 1000, 900, 1200, 1100, 1000, 1300, 1200, 1100, 1400, 1300, 1200, 1500, 1400, 1300, 1600, 1500, 1400, 1700, 1600, 1500, 1800, 1700, 1600, 1900, 1800, 1700, 2000, 1900, 1800, 2100, 2000, 1900, 2200, 2100, 2000, 2300, 2200, 2100, 2400, 2300, 2200],k = 30) == 4800\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 100) == inf\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 14) == 15\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384],k = 10) == 33\n assert candidate(nums = [3, 5, 4, 7, 8, 6, 9],k = 2) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 10) == 18\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 5) == 120\n assert candidate(nums = [20, 15, 10, 5, 15, 20, 25, 30, 35, 40, 45, 50],k = 2) == 65\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 4) == 50\n assert candidate(nums = [300, 200, 100, 50, 25, 125, 62, 31, 15, 7, 3, 1],k = 5) == 186\n assert candidate(nums = [100, 200, 150, 300, 250, 350, 400],k = 2) == 250\n assert candidate(nums = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 5) == 50\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 9) == 0\n assert candidate(nums = [10, 20, 30, 25, 40, 35, 50, 45, 60, 55],k = 4) == 30\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 0) == 190\n assert candidate(nums = [500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000],k = 9) == 5000\n assert candidate(nums = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500],k = 0) == 0\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],k = 3) == 30\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 4) == 90\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 5) == 24\n assert candidate(nums = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100, 1, 100],k = 9) == 495\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996, 999995, 999994],k = 3) == 3\n assert candidate(nums = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],k = 0) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],k = 9) == 29\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 4) == 50\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 200) == inf\n assert candidate(nums = [20, 10, 30, 25, 40, 35, 50, 45, 60, 55, 70, 65, 80, 75, 90, 85, 100, 95, 110, 105],k = 3) == 215\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 0\n assert candidate(nums = [100, 200, 150, 100, 300, 250, 200, 350, 400, 300],k = 3) == 450\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],k = 10) == 1985\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 0) == 1900\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 9) == 90\n assert candidate(nums = [1000000, 500000, 750000, 250000, 100000],k = 2) == 400000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 9) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 19) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 4) == 150\n assert candidate(nums = [10, 5, 15, 10, 20, 15, 25, 20, 30, 25, 35, 30, 40, 35, 45],k = 6) == 45\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 0\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61, 30, 15, 7, 3, 1],k = 5) == 140629\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25],k = 6) == 12\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288],k = 5) == 73729\n assert candidate(nums = [100, 200, 150, 300, 250, 400, 350],k = 2) == 250\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 0) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 5) == 120\n assert candidate(nums = [100, 200, 150, 300, 250, 400, 350, 500],k = 2) == 450\n assert candidate(nums = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 70, 70, 80, 80, 90, 90, 100, 100],k = 5) == 80\n assert candidate(nums = [10, 20, 30, 20, 10, 40, 30, 20, 50, 40, 30, 20, 60, 50, 40, 30],k = 5) == 130\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 9) == 977778\n assert candidate(nums = [200, 150, 100, 50, 150, 200, 250, 300, 350, 400],k = 3) == 350\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],k = 0) == 0\n assert candidate(nums = [500000, 400000, 300000, 200000, 100000, 100000, 200000, 300000, 400000, 500000, 100000, 200000, 300000, 400000, 500000, 100000, 200000, 300000, 400000, 500000],k = 7) == 1400000\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 5) == 81\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205],k = 7) == 160\n assert candidate(nums = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61, 30, 15, 7, 3, 1],k = 10) == 3788\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],k = 5) == 0\n assert candidate(nums = [20, 10, 30, 5, 40, 25, 60, 35, 70, 45, 80, 55, 90, 65, 100, 75, 110, 85, 120, 95, 130, 105, 140, 115, 150, 125, 160, 135, 170, 145, 180, 155],k = 8) == 515\n assert candidate(nums = [10, 20, 10, 30, 10, 20, 30, 40, 50],k = 3) == 50\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100],k = 25) == 48\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 4) == 10\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 4) == 488889\n assert candidate(nums = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],k = 0) == 0\n assert candidate(nums = [100, 200, 150, 300, 250, 400],k = 2) == 200\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],k = 9) == 45\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9],k = 25) == 119\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],k = 15) == 140\n assert candidate(nums = [100, 200, 150, 100, 250, 200, 150, 300],k = 2) == 400\n assert candidate(nums = [200, 100, 200, 100, 200, 100, 200, 100, 200, 100],k = 4) == 300\n assert candidate(nums = [1000000, 999999, 999998, 999997, 999996],k = 0) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],k = 10) == 90\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 2) == 1200\n assert candidate(nums = [500, 400, 300, 200, 100, 50, 25, 10, 5, 2, 1, 1, 2, 5, 10, 25, 50, 100, 200, 300, 400, 500],k = 10) == 264\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 9\n assert candidate(nums = [10, 20, 30, 25, 40, 35, 50, 45, 60, 55, 70, 65, 80, 75, 90, 85, 100, 95, 110, 105, 120, 115, 130, 125, 140, 135, 150, 145, 160, 155, 170, 165, 180, 175, 190, 185, 200, 195, 210, 205, 220, 215, 230, 225, 240, 235, 250, 245, 260, 255, 270, 265, 280, 275, 290, 285, 300, 295, 310, 305, 320, 315, 330, 325, 340, 335, 350, 345, 360, 355, 370, 365, 380, 375, 390, 385, 400, 395, 410, 405],k = 100) == inf\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 90\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == 8\n assert candidate(nums = [100, 90, 110, 80, 120, 70, 130, 60, 140, 50, 150, 40, 160, 30, 170, 20, 180, 10, 190, 0],k = 5) == 820\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],k = 7) == 16\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20],k = 10) == 100\n assert candidate(nums = [10, 20, 15, 30, 20, 25, 35, 40, 45, 50],k = 4) == 30\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000],k = 5) == 9\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 0) == 450\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 3) == 6\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == 0\n assert candidate(nums = [20, 15, 10, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85],k = 5) == 100\n assert candidate(nums = [1000, 2000, 1500, 3000, 2500, 4000, 3500, 5000, 4500, 6000],k = 5) == 2000\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 0) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 2) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minSpaceWastedKResizing", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minSpaceWastedKResizing(vector& nums, int k) {", "container": "Solution", "callable": "minSpaceWastedKResizing", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1960, "task_id": "maximum-product-of-the-length-of-two-palindromic-substrings", "difficulty": "Hard", "problem_description": "You are given a 0-indexed string s and are tasked with finding two non-intersecting palindromic substrings of odd length such that the product of their lengths is maximized.\nMore formally, you want to choose four integers i, j, k, l such that 0 <= i <= j < k <= l < s.length and both the substrings s[i...j] and s[k...l] are palindromes and have odd lengths. s[i...j] denotes a substring from index i to index j inclusive.\nReturn the maximum possible product of the lengths of the two non-intersecting palindromic substrings.\nA palindrome is a string that is the same forward and backward. A substring is a contiguous sequence of characters in a string.\n \nExample 1:\n\nInput: s = \"ababbb\"\nOutput: 9\nExplanation: Substrings \"aba\" and \"bbb\" are palindromes with odd length. product = 3 * 3 = 9.\n\nExample 2:\n\nInput: s = \"zaaaxbbby\"\nOutput: 9\nExplanation: Substrings \"aaa\" and \"bbb\" are palindromes with odd length. product = 3 * 3 = 9.\n\n \nConstraints:\n\n2 <= s.length <= 105\ns consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"mnoonmmon\") == 1\n assert candidate(s = \"mamadmim\") == 9\n assert candidate(s = \"abcdcba\") == 5\n assert candidate(s = \"abcdedcba\") == 7\n assert candidate(s = \"mamad\") == 3\n assert candidate(s = \"aaaaa\") == 3\n assert candidate(s = \"abcdefghi\") == 1\n assert candidate(s = \"abacdfgdcaba\") == 9\n assert candidate(s = \"zaaaxbbby\") == 9\n assert candidate(s = \"noonnoon\") == 1\n assert candidate(s = \"abcde\") == 1\n assert candidate(s = \"racecar\") == 5\n assert candidate(s = \"abcdeedcba\") == 1\n assert candidate(s = \"banana\") == 5\n assert candidate(s = \"ababbb\") == 9\n assert candidate(s = \"abc\") == 1\n assert candidate(s = \"abcbabcbabcba\") == 35\n assert candidate(s = \"abcdefgh\") == 1\n assert candidate(s = \"abcd\") == 1\n assert candidate(s = \"mississippi\") == 7\n assert candidate(s = \"aabbccddeeffgghhiijj\") == 1\n assert candidate(s = \"mnoonmnonoomnm\") == 15\n assert candidate(s = \"abcdefg\") == 1\n assert candidate(s = \"aabbccddeeeffgg\") == 3\n assert candidate(s = \"abccbaabccbaabccbaabccba\") == 1\n assert candidate(s = \"aaaaaabbaaaaa\") == 25\n assert candidate(s = \"nunrunrunrun\") == 3\n assert candidate(s = \"abaaacbaaaaba\") == 9\n assert candidate(s = \"racecarlevelnoonracecar\") == 49\n assert candidate(s = \"deeeeefedeeeed\") == 15\n assert candidate(s = \"rotorrotor\") == 25\n assert candidate(s = \"abracadabra\") == 3\n assert candidate(s = \"abcabcabcabc\") == 1\n assert candidate(s = \"abcbaacbabcba\") == 25\n assert candidate(s = \"abcbacbacbacb\") == 5\n assert candidate(s = \"tattarrattat\") == 9\n assert candidate(s = \"repaperrelevelrepeepr\") == 35\n assert candidate(s = \"babadabababa\") == 25\n assert candidate(s = \"madaminnadammadam\") == 25\n assert candidate(s = \"abccbaabcdcba\") == 7\n assert candidate(s = \"aabaaaabaaaabaa\") == 25\n assert candidate(s = \"abcdeffedcbaffedcba\") == 1\n assert candidate(s = \"abccbaabccba\") == 1\n assert candidate(s = \"xyzabcbaedcbaxyz\") == 5\n assert candidate(s = \"levellevellevellevel\") == 75\n assert candidate(s = \"noonnoonnoonnoon\") == 1\n assert candidate(s = \"mississippimississippi\") == 49\n assert candidate(s = \"xyzxyzxyzxyz\") == 1\n assert candidate(s = \"abacdfgdcabaxyzzyzyzyzyzx\") == 27\n assert candidate(s = \"aabbbaabbbaabbbaaa\") == 49\n assert candidate(s = \"abacadaeafagahagaha\") == 21\n assert candidate(s = \"noonracecarnoon\") == 13\n assert candidate(s = \"aabbbaaabbbaaabbbaaabbbaaabbba\") == 221\n assert candidate(s = \"ababababababababa\") == 63\n assert candidate(s = \"abacabaabacabaabacaba\") == 49\n assert candidate(s = \"repel\") == 3\n assert candidate(s = \"levelnoonlevel\") == 25\n assert candidate(s = \"rotorlevelmadamracecar\") == 35\n assert candidate(s = \"noonnoonnoonnoonnoonnoon\") == 1\n assert candidate(s = \"kayak\") == 3\n assert candidate(s = \"mnopqrstuvuvwxyzyx\") == 15\n assert candidate(s = \"madamlevelmadam\") == 25\n assert candidate(s = \"babcbabcbabcba\") == 35\n assert candidate(s = \"abacadaeafagaha\") == 9\n assert candidate(s = \"leveloneleveleleveldoneleveldot\") == 55\n assert candidate(s = \"xyzzzzyzyzyzx\") == 21\n assert candidate(s = \"madaminnadam\") == 15\n assert candidate(s = \"abababababababab\") == 63\n assert candidate(s = \"racecarabcdeedcbacar\") == 21\n assert candidate(s = \"noon\") == 1\n assert candidate(s = \"abcbacbacb\") == 5\n assert candidate(s = \"ababababababababab\") == 81\n assert candidate(s = \"deeee\") == 3\n assert candidate(s = \"leveloneleveltwo\") == 25\n assert candidate(s = \"abcabcabcabcabcabc\") == 1\n assert candidate(s = \"xyzbcbzxyxzyzyzyz\") == 35\n assert candidate(s = \"abcdefggfedcba\") == 1\n assert candidate(s = \"aaaaabbbbbbaaaa\") == 25\n assert candidate(s = \"abcdeffedcba\") == 1\n assert candidate(s = \"ababcbaababcbaababcba\") == 25\n assert candidate(s = \"babcbabcbabcbabcbabcbabcbabcbabcbabcbabcba\") == 399\n assert candidate(s = \"ababaababaababa\") == 27\n assert candidate(s = \"abcbabcbaabcbabcba\") == 81\n assert candidate(s = \"mmabccbaakak\") == 3\n assert candidate(s = \"abcdefedcba\") == 9\n assert candidate(s = \"palindromeemordnilap\") == 1\n assert candidate(s = \"level\") == 3\n assert candidate(s = \"racecarlevelracecar\") == 49\n assert candidate(s = \"levellevellevel\") == 25\n assert candidate(s = \"aaaaabaaaaabaaaaabaaaaab\") == 143\n assert candidate(s = \"xyxzyxzyxzyx\") == 3\n assert candidate(s = \"nunabannun\") == 15\n assert candidate(s = \"deeeeefeeeed\") == 15\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzz\") == 143\n assert candidate(s = \"abababababababababab\") == 99\n assert candidate(s = \"madamimadamracecar\") == 77\n assert candidate(s = \"abbbbabbbaaaaaaaabbba\") == 49\n assert candidate(s = \"radar\") == 3\n assert candidate(s = \"abababa\") == 9\n assert candidate(s = \"abacabadabacaba\") == 49\n assert candidate(s = \"abacabadabacabada\") == 63\n assert candidate(s = \"bananaananab\") == 25\n assert candidate(s = \"aabbccddeeefffggg\") == 9\n assert candidate(s = \"redivider\") == 7\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\") == 99\n assert candidate(s = \"abcabccbaabcabccba\") == 1\n assert candidate(s = \"mnbvcxzlkjhgfdsapoiuytrewq\") == 1\n assert candidate(s = \"deedlevel\") == 5\n assert candidate(s = \"abcbabcba\") == 15\n assert candidate(s = \"deifiedrotatordeified\") == 49\n assert candidate(s = \"noonnoonnoonnoonnoon\") == 1\n assert candidate(s = \"abcbadefgfe\") == 25\n assert candidate(s = \"anana\") == 3\n assert candidate(s = \"ababaabababababa\") == 55\n assert candidate(s = \"abracadabraabracadabra\") == 9\n assert candidate(s = \"detartrated\") == 9\n assert candidate(s = \"manamzzamanaplanacanalpanamazzamanaplanacanalpanamazzzzzz\") == 529\n assert candidate(s = \"xyxyxyxyxyxyxyxyx\") == 63\n assert candidate(s = \"madamimadam\") == 25\n assert candidate(s = \"levelonelevelonelevel\") == 25\n assert candidate(s = \"madamracecaramadam\") == 35\n assert candidate(s = \"aaabbaaabbaaa\") == 21\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 1\n assert candidate(s = \"xylophonepiponolyx\") == 9\n assert candidate(s = \"racecarandracecar\") == 49\n assert candidate(s = \"aabaaaabaaba\") == 25\n assert candidate(s = \"racecarannakayak\") == 35\n assert candidate(s = \"kayakkayakkayakkayak\") == 75\n assert candidate(s = \"aaaaabbbbbaaaaa\") == 27\n assert candidate(s = \"mammadmooommom\") == 15\n assert candidate(s = \"aaaaabbbbbaaaaaabbbbaaaaa\") == 75\n assert candidate(s = \"racecarracecar\") == 49\n assert candidate(s = \"noonnoonnoon\") == 1\n assert candidate(s = \"repaper\") == 5\n assert candidate(s = \"racecarlevelrotorkayak\") == 35\n assert candidate(s = \"rotorrotorrotor\") == 25\n assert candidate(s = \"aaaaabaaabaaaabaaaaabaaaa\") == 99\n assert candidate(s = \"ababaababab\") == 25\n assert candidate(s = \"noonhighnoon\") == 1\n assert candidate(s = \"tacocattacocattaco\") == 49\n assert candidate(s = \"rotorrotorrotorrotor\") == 75\n assert candidate(s = \"bananaananananab\") == 45\n assert candidate(s = \"zzzyzyzyzyzyzyzyzyzyzyzyz\") == 121\n assert candidate(s = \"deeddeeddeed\") == 1\n assert candidate(s = \"aaaaaabbbbbaaaa\") == 35\n assert candidate(s = \"rotorresistor\") == 15\n assert candidate(s = \"xylophonelevel\") == 5\n assert candidate(s = \"aaabaaaabaaaaabaaaaaaab\") == 77\n assert candidate(s = \"aabbccddeeefffgggzzzzzzzzzzzzzzzzzzzz\") == 99\n assert candidate(s = \"abcdedcbaabcdedcbaabcdedcba\") == 81\n assert candidate(s = \"civic\") == 3\n assert candidate(s = \"rotor\") == 3\n assert candidate(s = \"qwertyuioplkjhgfdsazxcvbnmnbvcxzasdfghjklpoiuytrewq\") == 49\n assert candidate(s = \"abbaabbbaabba\") == 11\n assert candidate(s = \"abcdefghihgfedcba\") == 15\n assert candidate(s = \"tacocattaco\") == 7\n assert candidate(s = \"repaperrepaperrepaper\") == 49\n assert candidate(s = \"aabaaaabaa\") == 25\n assert candidate(s = \"reviled\") == 1\n assert candidate(s = \"amoreroma\") == 7\n assert candidate(s = \"aabbccddeeefffggghhhiiiijjjjkkkkllllmmmnnnooopppqqqqrrrrssssttttuuuuvvvvwwwwwxxxxxyyyyyzzzzzzyyyyyxxxwwvvuuttrrqqppoonnmlkkjjiihhggffeeddccbbaa\") == 25\n assert candidate(s = \"xyzyzyzyzyzyzyzyz\") == 63\n assert candidate(s = \"xyxzyzyzyzyzyzyx\") == 35\n assert candidate(s = \"zzzzzzyyyyyxxxwwvvuuttrrqqppoonnmlkkjjiihhggffeeddccbbaa\") == 25\n assert candidate(s = \"rotorabcdrotor\") == 25\n assert candidate(s = \"aabbccddeeeffgghhiii\") == 9\n assert candidate(s = \"abcdedcbabcdedcbabcdedcb\") == 135\n assert candidate(s = \"aabbccddeeefffggghhhiiiijjjjkkkkllllmmmnnnooopppqqqqrrrrssssttttuuuuvvvvwwwwwxxxxxyyyyyzzzzz\") == 25\n assert candidate(s = \"abcabcabcabcabc\") == 1\n assert candidate(s = \"deed\") == 1\n assert candidate(s = \"aaaaabbbbbbaaaaa\") == 25\n assert candidate(s = \"levelwasracecar\") == 35\n assert candidate(s = \"racecarabcdeedcba\") == 9\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxProduct", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long maxProduct(string s) {", "container": "Solution", "callable": "maxProduct", "parameters": [{"name": "s", "type": "string"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1961, "task_id": "check-if-string-is-a-prefix-of-array", "difficulty": "Easy", "problem_description": "Given a string s and an array of strings words, determine whether s is a prefix string of words.\nA string s is a prefix string of words if s can be made by concatenating the first k strings in words for some positive k no larger than words.length.\nReturn true if s is a prefix string of words, or false otherwise.\n \nExample 1:\n\nInput: s = \"iloveleetcode\", words = [\"i\",\"love\",\"leetcode\",\"apples\"]\nOutput: true\nExplanation:\ns can be made by concatenating \"i\", \"love\", and \"leetcode\" together.\n\nExample 2:\n\nInput: s = \"iloveleetcode\", words = [\"apples\",\"i\",\"love\",\"leetcode\"]\nOutput: false\nExplanation:\nIt is impossible to make s using a prefix of arr.\n \nConstraints:\n\n1 <= words.length <= 100\n1 <= words[i].length <= 20\n1 <= s.length <= 1000\nwords[i] and s consist of only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aaaa\",words = ['aa', 'aa']) == True\n assert candidate(s = \"hello\",words = ['he', 'll', 'o']) == True\n assert candidate(s = \"abc\",words = ['a']) == False\n assert candidate(s = \"abc\",words = ['a', 'bc']) == True\n assert candidate(s = \"a\",words = ['a', 'b', 'c']) == True\n assert candidate(s = \"abcd\",words = ['a', 'bcd']) == True\n assert candidate(s = \"cat\",words = ['ca', 't']) == True\n assert candidate(s = \"abcd\",words = ['abc', 'd']) == True\n assert candidate(s = \"hello\",words = ['he', 'l', 'lo']) == True\n assert candidate(s = \"abc\",words = ['ab', 'c']) == True\n assert candidate(s = \"\",words = ['a', 'b', 'c']) == False\n assert candidate(s = \"iloveleetcode\",words = ['apples', 'i', 'love', 'leetcode']) == False\n assert candidate(s = \"hello\",words = ['he', 'llo']) == True\n assert candidate(s = \"abcd\",words = ['a', 'b', 'c', 'd']) == True\n assert candidate(s = \"abcd\",words = ['ab', 'cd']) == True\n assert candidate(s = \"abcd\",words = ['abcd']) == True\n assert candidate(s = \"iloveleetcode\",words = ['i', 'love', 'leetcode', 'apples']) == True\n assert candidate(s = \"xyz\",words = ['x', 'y', 'z']) == True\n assert candidate(s = \"abc\",words = ['a', 'b', 'c']) == True\n assert candidate(s = \"abcd\",words = ['abc']) == False\n assert candidate(s = \"complexprefixstring\",words = ['complex', 'prefix', 'string', 'extra']) == True\n assert candidate(s = \"aquickbrownfox\",words = ['a', 'quick', 'brown', 'fox', 'jumps']) == True\n assert candidate(s = \"onetwothree\",words = ['one', 'two', 'three', 'four', 'five']) == True\n assert candidate(s = \"algorithm\",words = ['algo', 'r', 'ith', 'm']) == True\n assert candidate(s = \"python\",words = ['py', 'th', 'on', 'n']) == True\n assert candidate(s = \"complexprefix\",words = ['com', 'ple', 'xpre', 'fix']) == True\n assert candidate(s = \"concatenate\",words = ['con', 'cat', 'en', 'ate']) == True\n assert candidate(s = \"algorithms\",words = ['algo', 'rithm', 's', 'data']) == True\n assert candidate(s = \"abracadabra\",words = ['abra', 'ca', 'da', 'bra', 'bra']) == True\n assert candidate(s = \"substring\",words = ['sub', 'str', 'ing', 'example']) == True\n assert candidate(s = \"onetwothreefour\",words = ['one', 'two', 'three', 'four', 'five']) == True\n assert candidate(s = \"xyz\",words = ['x', 'y', 'z', 'w']) == True\n assert candidate(s = \"prefixstring\",words = ['pre', 'fix', 'string']) == True\n assert candidate(s = \"programming\",words = ['pro', 'gram', 'ming']) == True\n assert candidate(s = \"concatenate\",words = ['con', 'cat', 'e', 'nate']) == True\n assert candidate(s = \"thisisatest\",words = ['this', 'is', 'a', 'test', 'case']) == True\n assert candidate(s = \"substring\",words = ['sub', 'string', 'abc']) == True\n assert candidate(s = \"mississippi\",words = ['mis', 'si', 'ssippi', 'p']) == True\n assert candidate(s = \"prefixprefix\",words = ['pre', 'fix', 'pre', 'fix', 'pre', 'fix']) == True\n assert candidate(s = \"abcdef\",words = ['a', 'b', 'c', 'def', 'ghi']) == True\n assert candidate(s = \"thisisatest\",words = ['this', 'is', 'a', 'test', 'case']) == True\n assert candidate(s = \"abcdefg\",words = ['a', 'b', 'c', 'd', 'e', 'f', 'g']) == True\n assert candidate(s = \"aaabbbccc\",words = ['aaa', 'bbb', 'ccc', 'ddd']) == True\n assert candidate(s = \"hello\",words = ['h', 'he', 'hel', 'hell', 'hello']) == False\n assert candidate(s = \"abcdabc\",words = ['ab', 'c', 'd', 'abc', 'def']) == True\n assert candidate(s = \"complexstring\",words = ['com', 'plex', 'string', 'other']) == True\n assert candidate(s = \"abcdefghijk\",words = ['abcd', 'ef', 'gh', 'ijk']) == True\n assert candidate(s = \"uniqueprefix\",words = ['unique', 'prefix', 'not']) == True\n assert candidate(s = \"prefix\",words = ['pre', 'fix', 'e', 'f', 'g']) == True\n assert candidate(s = \"oneonetwo\",words = ['one', 'one', 'two', 'three']) == True\n assert candidate(s = \"xyzzy\",words = ['xy', 'zz', 'y', 'z']) == True\n assert candidate(s = \"partialmatch\",words = ['partial', 'non', 'matching', 'words']) == False\n assert candidate(s = \"prefixmatching\",words = ['pre', 'fix', 'mat', 'ching']) == True\n assert candidate(s = \"overlapexample\",words = ['over', 'lap', 'ex', 'ample']) == True\n assert candidate(s = \"boundary\",words = ['bound', 'ary', 'extra']) == True\n assert candidate(s = \"partialmatch\",words = ['par', 'tial', 'match', 'nomatch']) == True\n assert candidate(s = \"abcdabcd\",words = ['abcd', 'abcd', 'abcd']) == True\n assert candidate(s = \"oneonetwo\",words = ['one', 'one', 'two', 'three']) == True\n assert candidate(s = \"abcdefghij\",words = ['abc', 'def', 'ghi', 'j']) == True\n assert candidate(s = \"mississippi\",words = ['mis', 'si', 'ss', 'ippi']) == True\n assert candidate(s = \"matchmaking\",words = ['mat', 'ch', 'mak', 'ing']) == True\n assert candidate(s = \"abcdefg\",words = ['a', 'bc', 'de', 'fg', 'xyz']) == True\n assert candidate(s = \"prefix\",words = ['pre', 'fix', 'ed', 'abc']) == True\n assert candidate(s = \"prefix\",words = ['pre', 'fix', 'post']) == True\n assert candidate(s = \"mnopqr\",words = ['mn', 'op', 'qr', 'st']) == True\n assert candidate(s = \"programminglanguage\",words = ['pro', 'gram', 'ming', 'lan', 'guage']) == True\n assert candidate(s = \"hellohello\",words = ['hello', 'hello', 'world']) == True\n assert candidate(s = \"prefixstring\",words = ['pre', 'fix', 'str', 'ing']) == True\n assert candidate(s = \"hellothere\",words = ['he', 'll', 'o', 'there']) == True\n assert candidate(s = \"concatenation\",words = ['con', 'cat', 'en', 'ation']) == True\n assert candidate(s = \"hellohello\",words = ['hello', 'hello', 'hello']) == True\n assert candidate(s = \"hello\",words = ['h', 'e', 'l', 'l', 'o', 'world']) == True\n assert candidate(s = \"quickbrownfox\",words = ['quick', 'brown', 'fox', 'jump']) == True\n assert candidate(s = \"abcdefghi\",words = ['abc', 'def', 'ghi', 'jkl']) == True\n assert candidate(s = \"one\",words = ['on', 'e', 'extra']) == True\n assert candidate(s = \"notprefix\",words = ['prefix', 'not']) == False\n assert candidate(s = \"abcdefgh\",words = ['a', 'bc', 'def', 'gh']) == True\n assert candidate(s = \"prefixstring\",words = ['prefix', 'string', 'extra']) == True\n assert candidate(s = \"prefix\",words = ['pre', 'fi', 'x']) == True\n assert candidate(s = \"longword\",words = ['lo', 'ng', 'wor', 'd']) == True\n assert candidate(s = \"xxyyyzzz\",words = ['xx', 'yyy', 'zzz', 'a']) == True\n assert candidate(s = \"concatenation\",words = ['con', 'cat', 'en', 'ation']) == True\n assert candidate(s = \"unique\",words = ['un', 'iq', 'ue']) == True\n assert candidate(s = \"abcdefghij\",words = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']) == True\n assert candidate(s = \"algorithm\",words = ['algo', 'r', 'ith', 'm']) == True\n assert candidate(s = \"variouslengths\",words = ['vari', 'ous', 'length', 's']) == True\n assert candidate(s = \"two\",words = ['tw', 'o', 'tw', 'o']) == True\n assert candidate(s = \"abcdabcd\",words = ['abc', 'd', 'abcd']) == True\n assert candidate(s = \"wordplay\",words = ['word', 'play', 'game', 'time']) == True\n assert candidate(s = \"programming\",words = ['pro', 'gram', 'ming', 'lang']) == True\n assert candidate(s = \"concatenation\",words = ['con', 'cat', 'enation', 'ation']) == True\n assert candidate(s = \"supercalifragilisticexpialidocious\",words = ['super', 'cali', 'fragilistic', 'expiali', 'docious']) == True\n assert candidate(s = \"abcdefghij\",words = ['a', 'bc', 'de', 'fghi', 'j']) == True\n assert candidate(s = \"algorithm\",words = ['algo', 'rith', 'm']) == True\n assert candidate(s = \"testcase\",words = ['tes', 't', 'ca', 'se']) == True\n assert candidate(s = \"concatenation\",words = ['con', 'cat', 'e', 'na', 'tion']) == True\n assert candidate(s = \"abcdefghij\",words = ['abc', 'def', 'ghi', 'j']) == True\n assert candidate(s = \"xyz\",words = ['x', 'y', 'z', 'a', 'b', 'c']) == True\n assert candidate(s = \"prefixtest\",words = ['pre', 'fix', 'test', 'suffix']) == True\n assert candidate(s = \"repeated\",words = ['rep', 'e', 'ated']) == True\n assert candidate(s = \"matchingprefix\",words = ['matching', 'prefix', 'matching', 'prefix']) == True\n assert candidate(s = \"abcdexyz\",words = ['abc', 'de', 'xyz', 'mnop']) == True\n assert candidate(s = \"aabbccdd\",words = ['aa', 'bb', 'cc', 'd', 'd']) == True\n assert candidate(s = \"abcdef\",words = ['a', 'b', 'c', 'def']) == True\n assert candidate(s = \"programmingisfun\",words = ['pro', 'gram', 'ming', 'is', 'fun']) == True\n assert candidate(s = \"short\",words = ['shor', 't']) == True\n assert candidate(s = \"mississippi\",words = ['mis', 'si', 's', 'ip', 'pi']) == False\n assert candidate(s = \"repeatedword\",words = ['repeated', 'word', 'repeated']) == True\n assert candidate(s = \"rapiddevelopment\",words = ['rap', 'id', 'devel', 'op', 'ment']) == True\n assert candidate(s = \"onetwothree\",words = ['one', 'two', 'three', 'four']) == True\n assert candidate(s = \"interviewquestion\",words = ['inter', 'view', 'quest', 'ion']) == True\n assert candidate(s = \"abcdabcd\",words = ['abcd', 'abcd']) == True\n assert candidate(s = \"longstring\",words = ['long', 'string', 'extrastuff']) == True\n assert candidate(s = \"xyz\",words = ['xy', 'z', 'a', 'b']) == True\n assert candidate(s = \"thisisatest\",words = ['this', 'is', 'a', 'test']) == True\n assert candidate(s = \"abcdefg\",words = ['abc', 'def', 'g', 'h']) == True\n assert candidate(s = \"hellothere\",words = ['he', 'll', 'ot', 'her', 'e']) == True\n assert candidate(s = \"buildingblocks\",words = ['building', 'block', 's']) == True\n assert candidate(s = \"abcdefghij\",words = ['abc', 'de', 'f', 'gh', 'ij']) == True\n assert candidate(s = \"prefixmatch\",words = ['prefix', 'ma', 'tch']) == True\n assert candidate(s = \"python\",words = ['py', 'th', 'on', 'o']) == True\n assert candidate(s = \"python\",words = ['py', 't', 'h', 'o', 'n', 'extra']) == True\n assert candidate(s = \"aabbcc\",words = ['aa', 'bb', 'cc', 'dd']) == True\n assert candidate(s = \"abacax\",words = ['aba', 'c', 'ax', 'a']) == True\n assert candidate(s = \"aabbcc\",words = ['aa', 'bb', 'cc', 'dd']) == True\n"}, "metadata": {"canonical_parameter_names": ["s", "words"], "leetcode_dataset_entry_point": "Solution().isPrefixString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool isPrefixString(string s, vector& words) {", "container": "Solution", "callable": "isPrefixString", "parameters": [{"name": "s", "type": "string"}, {"name": "words", "type": "vector&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1962, "task_id": "remove-stones-to-minimize-the-total", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array piles, where piles[i] represents the number of stones in the ith pile, and an integer k. You should apply the following operation exactly k times:\n\nChoose any piles[i] and remove floor(piles[i] / 2) stones from it.\n\nNotice that you can apply the operation on the same pile more than once.\nReturn the minimum possible total number of stones remaining after applying the k operations.\nfloor(x) is the greatest integer that is smaller than or equal to x (i.e., rounds x down).\n \nExample 1:\n\nInput: piles = [5,4,9], k = 2\nOutput: 12\nExplanation: Steps of a possible scenario are:\n- Apply the operation on pile 2. The resulting piles are [5,4,5].\n- Apply the operation on pile 0. The resulting piles are [3,4,5].\nThe total number of stones in [3,4,5] is 12.\n\nExample 2:\n\nInput: piles = [4,3,6,7], k = 3\nOutput: 12\nExplanation: Steps of a possible scenario are:\n- Apply the operation on pile 2. The resulting piles are [4,3,3,7].\n- Apply the operation on pile 3. The resulting piles are [4,3,3,4].\n- Apply the operation on pile 0. The resulting piles are [2,3,3,4].\nThe total number of stones in [2,3,3,4] is 12.\n\n \nConstraints:\n\n1 <= piles.length <= 105\n1 <= piles[i] <= 104\n1 <= k <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(piles = [1, 2, 3, 4, 5],k = 10) == 5\n assert candidate(piles = [10, 10, 10, 10],k = 4) == 20\n assert candidate(piles = [5, 4, 9],k = 2) == 12\n assert candidate(piles = [10, 10, 10],k = 1) == 25\n assert candidate(piles = [100, 200, 300],k = 10) == 57\n assert candidate(piles = [4, 3, 6, 7],k = 3) == 12\n assert candidate(piles = [100, 200, 300],k = 1) == 450\n assert candidate(piles = [10000, 10000, 10000],k = 10000) == 3\n assert candidate(piles = [100, 200, 300],k = 2) == 350\n assert candidate(piles = [100, 100, 100],k = 10) == 33\n assert candidate(piles = [1],k = 1) == 1\n assert candidate(piles = [10000, 10000, 10000],k = 10000) == 3\n assert candidate(piles = [10, 10, 10],k = 5) == 11\n assert candidate(piles = [1, 2, 3, 4, 5],k = 5) == 8\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 20) == 15\n assert candidate(piles = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930],k = 5000) == 10\n assert candidate(piles = [9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111, 1],k = 100) == 25\n assert candidate(piles = [5000, 5000, 5000, 5000, 5000],k = 25000) == 5\n assert candidate(piles = [1000, 500, 250, 125],k = 10) == 252\n assert candidate(piles = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 100) == 20\n assert candidate(piles = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991],k = 100) == 10\n assert candidate(piles = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],k = 50) == 1441\n assert candidate(piles = [9999, 9998, 9997, 9996, 9995],k = 100) == 5\n assert candidate(piles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 10\n assert candidate(piles = [1000, 999, 998, 997, 996, 995],k = 15) == 1123\n assert candidate(piles = [10000, 5000, 2500, 1250, 625, 312, 156, 78, 39, 19],k = 50) == 149\n assert candidate(piles = [9999],k = 10000) == 1\n assert candidate(piles = [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000],k = 1000) == 10\n assert candidate(piles = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 100) == 10\n assert candidate(piles = [1, 10, 100, 1000, 10000],k = 100) == 5\n assert candidate(piles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 50) == 10\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 20) == 117\n assert candidate(piles = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991],k = 1000) == 10\n assert candidate(piles = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 1000) == 20\n assert candidate(piles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 32\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 10\n assert candidate(piles = [1, 100, 1000, 10000, 10000, 1000, 100, 1],k = 50000) == 8\n assert candidate(piles = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 100) == 50\n assert candidate(piles = [50, 25, 75, 200, 150],k = 5) == 201\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 20\n assert candidate(piles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 15) == 20\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 50) == 20\n assert candidate(piles = [10000, 1000, 100, 10, 1],k = 15000) == 5\n assert candidate(piles = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 1000) == 20\n assert candidate(piles = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 200) == 10\n assert candidate(piles = [5000, 5000, 5000, 5000, 5000],k = 1000) == 5\n assert candidate(piles = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000],k = 1000) == 10\n assert candidate(piles = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512],k = 100) == 20\n assert candidate(piles = [9999, 10000, 10001],k = 10000) == 3\n assert candidate(piles = [1000, 500, 250, 125, 63, 32, 16, 8, 4, 2, 1],k = 30) == 63\n assert candidate(piles = [999, 1000, 1001, 1002, 1003],k = 10) == 1253\n assert candidate(piles = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500],k = 2500) == 20\n assert candidate(piles = [10000, 5000, 2500, 1250, 625],k = 20) == 785\n assert candidate(piles = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 30) == 63\n assert candidate(piles = [5000, 5000, 5000, 5000, 5000],k = 100000) == 5\n assert candidate(piles = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],k = 1000) == 20\n assert candidate(piles = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 50) == 20\n assert candidate(piles = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],k = 50) == 1441\n assert candidate(piles = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 100) == 15\n assert candidate(piles = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],k = 500) == 20\n assert candidate(piles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 20\n assert candidate(piles = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71],k = 20) == 253\n assert candidate(piles = [9999, 9999, 9999, 9999],k = 100000) == 4\n assert candidate(piles = [1, 10, 100, 1000, 10000],k = 10) == 315\n assert candidate(piles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 100) == 20\n assert candidate(piles = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 1000) == 10\n assert candidate(piles = [500, 300, 200, 100],k = 5) == 400\n assert candidate(piles = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],k = 30) == 31\n assert candidate(piles = [9999, 8888, 7777, 6666, 5555, 4444, 3333, 2222, 1111],k = 10000) == 9\n assert candidate(piles = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],k = 100) == 11\n assert candidate(piles = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 5000) == 31\n assert candidate(piles = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990],k = 50) == 3130\n assert candidate(piles = [5000, 4000, 3000, 2000, 1000, 500, 250, 125, 62, 31, 15, 7, 3, 1],k = 100) == 16\n assert candidate(piles = [1048576, 1048576, 1048576, 1048576, 1048576, 1048576, 1048576, 1048576, 1048576, 1048576],k = 100000) == 10\n assert candidate(piles = [10, 15, 20, 25, 30, 35, 40, 45, 50],k = 100) == 9\n assert candidate(piles = [9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999],k = 10000) == 20\n assert candidate(piles = [9999, 1, 2, 3, 4, 5],k = 10) == 25\n assert candidate(piles = [1000, 1000, 1000, 1000, 1000],k = 50) == 5\n assert candidate(piles = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500],k = 100) == 10\n assert candidate(piles = [9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990],k = 5000) == 10\n assert candidate(piles = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000],k = 50000) == 10\n assert candidate(piles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 50) == 30\n assert candidate(piles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 100) == 20\n"}, "metadata": {"canonical_parameter_names": ["piles", "k"], "leetcode_dataset_entry_point": "Solution().minStoneSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minStoneSum(vector& piles, int k) {", "container": "Solution", "callable": "minStoneSum", "parameters": [{"name": "piles", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1963, "task_id": "minimum-number-of-swaps-to-make-the-string-balanced", "difficulty": "Medium", "problem_description": "You are given a 0-indexed string s of even length n. The string consists of exactly n / 2 opening brackets '[' and n / 2 closing brackets ']'.\nA string is called balanced if and only if:\n\nIt is the empty string, or\nIt can be written as AB, where both A and B are balanced strings, or\nIt can be written as [C], where C is a balanced string.\n\nYou may swap the brackets at any two indices any number of times.\nReturn the minimum number of swaps to make s balanced.\n \nExample 1:\n\nInput: s = \"][][\"\nOutput: 1\nExplanation: You can make the string balanced by swapping index 0 with index 3.\nThe resulting string is \"[[]]\".\n\nExample 2:\n\nInput: s = \"]]][[[\"\nOutput: 2\nExplanation: You can do the following to make the string balanced:\n- Swap index 0 with index 4. s = \"[]][][\".\n- Swap index 1 with index 5. s = \"[[][]]\".\nThe resulting string is \"[[][]]\".\n\nExample 3:\n\nInput: s = \"[]\"\nOutput: 0\nExplanation: The string is already balanced.\n\n \nConstraints:\n\nn == s.length\n2 <= n <= 106\nn is even.\ns[i] is either '[' or ']'.\nThe number of opening brackets '[' equals n / 2, and the number of closing brackets ']' equals n / 2.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"[]][[]\") == 1\n assert candidate(s = \"[[[[]]]]\") == 0\n assert candidate(s = \"]][[[]]]\") == 0\n assert candidate(s = \"][][\") == 1\n assert candidate(s = \"]]][[][[\") == 2\n assert candidate(s = \"]]]][[[[\") == 2\n assert candidate(s = \"][[]][\") == 1\n assert candidate(s = \"[][][][]\") == 0\n assert candidate(s = \"[[[]]]\") == 0\n assert candidate(s = \"[[[]]][[]]\") == 0\n assert candidate(s = \"]][[][][\") == 1\n assert candidate(s = \"]]][[[\") == 2\n assert candidate(s = \"[][]\") == 0\n assert candidate(s = \"[]\") == 0\n assert candidate(s = \"]][[\") == 1\n assert candidate(s = \"]]][[[[[[]]]]]\") == 1\n assert candidate(s = \"]][[[]\") == 1\n assert candidate(s = \"[[]][]\") == 0\n assert candidate(s = \"][[][]\") == 1\n assert candidate(s = \"[[[][]]]\") == 0\n assert candidate(s = \"]]]]][[[[[[[]]]]]]\") == 1\n assert candidate(s = \"]]]]][[[[[][][]]]]]][[[[[][][]]]]]\") == 0\n assert candidate(s = \"[[[[[[]]]]]]][[[[[[[]]]]]]][[[[[[[]]]]]]][[[[[[[]]]]]]\") == 1\n assert candidate(s = \"][]]]][[[[[]][[]]]\") == 1\n assert candidate(s = \"]][[[[[[[[[[]]]]]]]]][[[[[[[]]]]]]][[[[[[[]]]]]]][[[[[[[]]]]]]][[[[[[[]]]]]]][[[[[[[]]]]]]][[[[[[[]]]]]]\") == 1\n assert candidate(s = \"]][[[]]]]][[[[[]]]\") == 1\n assert candidate(s = \"]]][[][[[[[]]]]]]]\") == 0\n assert candidate(s = \"]]][[[[[[[[[[[][][][]]]]]]][[[[[[[[[][][][]]]]]]][[[[[[[[[][][][]]]]]]]\") == 4\n assert candidate(s = \"]]][[[[]]]][[[[[]]]]][[[[]]]]\") == 0\n assert candidate(s = \"]]][[[][]]][[[[[[[]]]]]][][][[]][[\") == 2\n assert candidate(s = \"]][[[]]][][[[[[[[[]]]]]][][[\") == 2\n assert candidate(s = \"]]][[[[[[[]]]]]]][[[[[]]]]]][[[[]]]]]]]]\") == 0\n assert candidate(s = \"]]]]][[[[[[]]][]]]\") == 1\n assert candidate(s = \"]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[\") == 1\n assert candidate(s = \"[[[[]]]]][[[[[]]]]][[[[[]]]]][[[[[]]]]]\") == 0\n assert candidate(s = \"]][[[]]][][[[]]]\") == 0\n assert candidate(s = \"]]]]]]]]][[[[[[[[[[\") == 5\n assert candidate(s = \"[[][]]]][[[][][[]][][[]][[]]\") == 1\n assert candidate(s = \"[[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]][[]]\") == 0\n assert candidate(s = \"]][[[][]]][[[[]]]\") == 1\n assert candidate(s = \"]][[[][]]][[[[[[[]]]]]]\") == 1\n assert candidate(s = \"]]][[[][]][[[\") == 2\n assert candidate(s = \"]]][[[[[[[[[[[][]]]]]]]]][[[[[[[[[][]]]]]]]]][[[[[[[[[][]]]]]]]]]\") == 1\n assert candidate(s = \"[[[[]]]]][[[[]]]]\") == 0\n assert candidate(s = \"[[[[[[]]]]]]][[[[[]]]]][[[[[]]]]][[[[[]]]]][[[[[]]]]][[[[[]]]]]\") == 0\n assert candidate(s = \"]]][[[[[[[]]]]]]][[[[[]]]]]][[[[[]]]]]]][[[[[]]]]][[[[[]]]]][[[[[]]]]]]]]]]\") == 0\n assert candidate(s = \"]]][[[[[[[]]]]]]][[[[[]]]]]][[[[[]]]]]\") == 0\n assert candidate(s = \"]]][[[[[[[][]]]]]]][[[[[][]]]]][[[[[][]]]]]\") == 0\n assert candidate(s = \"]]][[]]][[[[][[\") == 3\n assert candidate(s = \"]][[][][][[][]][[]][[\") == 2\n assert candidate(s = \"]]][[[[]][]][][[][]][][[[]][]][][[[]]]\") == 1\n assert candidate(s = \"[][][][][][][][][][][][][][][][][][][][][][][][]\") == 0\n assert candidate(s = \"]][[[]][[]][[[]]]\") == 1\n assert candidate(s = \"[[[[[[[[]]]]]]]][[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]\") == 0\n assert candidate(s = \"]]]]]][[[[[[\") == 3\n assert candidate(s = \"]]]][[[[[][]]][]][[[[[]]]]]\") == 1\n assert candidate(s = \"]]]]][[[[[]]]]\") == 1\n assert candidate(s = \"]]][[[[[[[]]]]][[[[[[]]]]]]][[[[\") == 3\n assert candidate(s = \"]]]]][[[[[]]]][[\") == 2\n assert candidate(s = \"]]][[[[[[[[[[[][][]][[]][]]]]]]][[[[[[[[[][][]][[]][]]]]]]][[[[[[[[[][][]][[]][]]]]]]][[[[[[[[[][]]]]]]]]]\") == 3\n assert candidate(s = \"]]][[[[[[[[[[[][][]]]]]]][[[[[[[[[][][]]]]]]][[[[[[[[[][][]]]]]]][[[[[[[[[][]]]]]]]]]\") == 4\n assert candidate(s = \"]][[[[[[[]]]]]]][[[[[]]]]]\") == 0\n assert candidate(s = \"]]][[[]][[[[]]]][]]]]][][[[[]]]]\") == 0\n assert candidate(s = \"]]][[[[]]][][[[]]]\") == 1\n assert candidate(s = \"]]][[[[[[[]]]]][[[[\") == 3\n assert candidate(s = \"]][[[[[][]]]]]][[[[[][]]]]]][[[[[][]]]]][[\") == 1\n assert candidate(s = \"]]][[[[[[[]]]]]]\") == 1\n assert candidate(s = \"]]][[[]][][[[]]]]\") == 0\n assert candidate(s = \"]][[[][]]][[\") == 1\n assert candidate(s = \"]][[[[[[[[[[]]]]]]]]][[[[[[[[[[[]]]]]]]]]][[[[[[[[[[[]]]]]]]]]]]\") == 1\n assert candidate(s = \"]][[[]]][][[\") == 1\n assert candidate(s = \"]]][[[[[]][[]]]]][[[[[]][[]]]]]\") == 0\n assert candidate(s = \"]]][[[[[[[]]]]]]][[[]]]\") == 0\n assert candidate(s = \"]]][[[]]][[[]]]]][[[[[]]]]\") == 1\n assert candidate(s = \"]]][[[][]][[[[[[[]]]]]][]\") == 1\n assert candidate(s = \"]]]]][[[[[[]]]]][[[[]]]]\") == 1\n assert candidate(s = \"]][[[[[][]]]]]][[[[[[[]]]]]][[[[[]]]]]]\") == 0\n assert candidate(s = \"]]][[[[[[]]]][]][[[[]]]]]\") == 0\n assert candidate(s = \"]]][[[[[[[[[[[][][]][[]][]]]][][[[[[[[[][][]][[]][]]]][][[[[[[[[][][]][[]][]]]][][[[[[[[[][]]]]]]]]]\") == 6\n assert candidate(s = \"]]][[[[[[[]]]]]]][[[[[]]]]]][[[[[]]]]]]][[[[[]]]]]]]]]]\") == 0\n assert candidate(s = \"]]][[[]]]][[[[\") == 2\n assert candidate(s = \"]]]][][][[[[\") == 2\n assert candidate(s = \"]][[[[[[]]]]]][[[]]\") == 1\n assert candidate(s = \"]][[[[[][]]]]]][[\") == 1\n assert candidate(s = \"]]][[[[[]]]]][[[[[]]]]][[[[[]]]]][[[[[]]]]][[[[[]]]]]\") == 0\n assert candidate(s = \"]]][[[[[[[][]]]]]]\") == 1\n assert candidate(s = \"]][[[]][[[]][]]]\") == 0\n assert candidate(s = \"]]][[[[[[[][][]]]]]]][[[[[][][]]]]][[[[[][][]]]]]\") == 0\n assert candidate(s = \"]]][[[[[[[]]]]][[[[[[]]]]]]\") == 1\n assert candidate(s = \"]]][[[[]][]]\") == 1\n assert candidate(s = \"]]][[[[[[[]]]]]]]]][[[[[[[[[]]]]]]]]]\") == 0\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minSwaps", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minSwaps(string s) {", "container": "Solution", "callable": "minSwaps", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1964, "task_id": "find-the-longest-valid-obstacle-course-at-each-position", "difficulty": "Hard", "problem_description": "You want to build some obstacle courses. You are given a 0-indexed integer array obstacles of length n, where obstacles[i] describes the height of the ith obstacle.\nFor every index i between 0 and n - 1 (inclusive), find the length of the longest obstacle course in obstacles such that:\n\nYou choose any number of obstacles between 0 and i inclusive.\nYou must include the ith obstacle in the course.\nYou must put the chosen obstacles in the same order as they appear in obstacles.\nEvery obstacle (except the first) is taller than or the same height as the obstacle immediately before it.\n\nReturn an array ans of length n, where ans[i] is the length of the longest obstacle course for index i as described above.\n \nExample 1:\n\nInput: obstacles = [1,2,3,2]\nOutput: [1,2,3,3]\nExplanation: The longest valid obstacle course at each position is:\n- i = 0: [1], [1] has length 1.\n- i = 1: [1,2], [1,2] has length 2.\n- i = 2: [1,2,3], [1,2,3] has length 3.\n- i = 3: [1,2,3,2], [1,2,2] has length 3.\n\nExample 2:\n\nInput: obstacles = [2,2,1]\nOutput: [1,2,1]\nExplanation: The longest valid obstacle course at each position is:\n- i = 0: [2], [2] has length 1.\n- i = 1: [2,2], [2,2] has length 2.\n- i = 2: [2,2,1], [1] has length 1.\n\nExample 3:\n\nInput: obstacles = [3,1,5,6,4,2]\nOutput: [1,1,2,3,2,2]\nExplanation: The longest valid obstacle course at each position is:\n- i = 0: [3], [3] has length 1.\n- i = 1: [3,1], [1] has length 1.\n- i = 2: [3,1,5], [3,5] has length 2. [1,5] is also valid.\n- i = 3: [3,1,5,6], [3,5,6] has length 3. [1,5,6] is also valid.\n- i = 4: [3,1,5,6,4], [3,4] has length 2. [1,4] is also valid.\n- i = 5: [3,1,5,6,4,2], [1,2] has length 2.\n\n \nConstraints:\n\nn == obstacles.length\n1 <= n <= 105\n1 <= obstacles[i] <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(obstacles = [1]) == [1]\n assert candidate(obstacles = [3, 1, 5, 6, 4, 2]) == [1, 1, 2, 3, 2, 2]\n assert candidate(obstacles = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1]\n assert candidate(obstacles = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [5, 5, 5, 5, 5]) == [1, 2, 3, 4, 5]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [1, 1, 1, 1, 1]) == [1, 2, 3, 4, 5]\n assert candidate(obstacles = [10, 9, 2, 5, 3, 7, 101, 18]) == [1, 1, 1, 2, 2, 3, 4, 4]\n assert candidate(obstacles = [10, 9, 8, 7, 6]) == [1, 1, 1, 1, 1]\n assert candidate(obstacles = [2, 2, 1]) == [1, 2, 1]\n assert candidate(obstacles = [1, 3, 5, 6, 8, 7, 9, 4, 10, 2]) == [1, 2, 3, 4, 5, 5, 6, 3, 7, 2]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 13]) == [1, 2, 3, 4, 5, 6, 7]\n assert candidate(obstacles = [1, 3, 5, 7, 9]) == [1, 2, 3, 4, 5]\n assert candidate(obstacles = [1, 2, 3, 2]) == [1, 2, 3, 3]\n assert candidate(obstacles = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(obstacles = [10000000, 9000000, 8000000, 7000000, 6000000, 5000000, 4000000, 3000000, 2000000, 1000000]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(obstacles = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11, 12, 11, 12, 11, 12, 11, 12]\n assert candidate(obstacles = [5, 1, 5, 2, 5, 3, 5, 4, 5]) == [1, 1, 2, 2, 3, 3, 4, 4, 5]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2, 3, 4, 5, 6]\n assert candidate(obstacles = [1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 8]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]\n assert candidate(obstacles = [10, 10, 10, 1, 1, 1, 10, 10, 10, 1, 1, 1, 10, 10, 10]) == [1, 2, 3, 1, 2, 3, 4, 5, 6, 4, 5, 6, 7, 8, 9]\n assert candidate(obstacles = [5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 2, 3, 4, 5, 6, 7, 8, 9, 10, 3, 4, 5, 6, 7, 8, 9, 10, 11, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(obstacles = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 2, 7, 3, 7, 4, 7, 5, 7, 6, 7]\n assert candidate(obstacles = [5, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 5]) == [1, 1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 4]\n assert candidate(obstacles = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 2, 4, 5, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19, 20]\n assert candidate(obstacles = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3]) == [1, 2, 3, 3, 2, 4, 5, 5, 3, 6, 7, 7, 4, 8, 9]\n assert candidate(obstacles = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]\n assert candidate(obstacles = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14]\n assert candidate(obstacles = [7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1]) == [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]\n assert candidate(obstacles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [3, 2, 1, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12, 14, 13, 15, 14, 16, 15, 17, 16, 18, 17, 19, 18, 20, 19, 21, 20, 22, 21, 23, 22, 24, 23, 25, 24, 26, 25, 27, 26, 28, 27, 29, 28, 30, 29, 31, 30, 32, 31, 33, 32, 34, 33, 35, 34, 36, 35, 37, 36, 38, 37, 39, 38, 40, 39]) == [1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38]\n assert candidate(obstacles = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 2, 4, 6, 8, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2, 3, 4, 5, 6]\n assert candidate(obstacles = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == [1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7]\n assert candidate(obstacles = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(obstacles = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(obstacles = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 10, 7, 8, 5, 6, 3, 4, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(obstacles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 4, 5, 6, 7]\n assert candidate(obstacles = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(obstacles = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]\n assert candidate(obstacles = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11, 13, 12]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]\n assert candidate(obstacles = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 20, 19, 18, 17, 16, 15, 14, 13, 12]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8]\n assert candidate(obstacles = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50, 10, 20, 30, 40, 50]) == [1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7]\n assert candidate(obstacles = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11]\n assert candidate(obstacles = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16]\n assert candidate(obstacles = [1, 2, 3, 2, 1, 4, 5, 4, 3, 2, 1, 5, 6, 5, 4, 3, 2, 1]) == [1, 2, 3, 3, 2, 4, 5, 5, 4, 4, 3, 6, 7, 7, 6, 5, 5, 4]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7, 4, 5, 6, 7, 8]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 4, 5, 6, 7, 7, 6, 5, 3]\n assert candidate(obstacles = [100000, 99999, 99998, 100000, 100000, 99999, 99998, 99997, 99996, 99995]) == [1, 1, 1, 2, 3, 2, 2, 1, 1, 1]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5, 6, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(obstacles = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6]\n assert candidate(obstacles = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11]\n assert candidate(obstacles = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 11, 10, 9, 8, 7, 6, 5, 4, 3]\n assert candidate(obstacles = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(obstacles = [3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1]) == [1, 2, 3, 4, 5, 1, 2, 3, 4, 1, 2, 3, 4, 5]\n assert candidate(obstacles = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67]\n assert candidate(obstacles = [1, 2, 2, 3, 3, 2, 1, 4, 4, 3, 3, 5, 5, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 7]) == [1, 2, 3, 4, 5, 4, 2, 6, 7, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]\n assert candidate(obstacles = [2, 3, 3, 3, 2, 2, 2, 2, 3, 3, 3, 3, 2, 2, 2, 2]) == [1, 2, 3, 4, 2, 3, 4, 5, 6, 7, 8, 9, 6, 7, 8, 9]\n assert candidate(obstacles = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]\n assert candidate(obstacles = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 10, 7, 8, 5, 6, 3, 4, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(obstacles = [1, 2, 2, 3, 4, 5, 5, 6, 6, 7, 8, 9, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 13, 12, 11, 10, 8, 6, 5, 4, 2]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [10000000, 5000000, 7500000, 6000000, 8000000, 9000000, 4000000, 3000000, 2000000, 1000000]) == [1, 1, 2, 2, 3, 4, 1, 1, 1, 1]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(obstacles = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]\n assert candidate(obstacles = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5, 10, 1, 9, 2, 8, 3, 7, 4, 6, 5]) == [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 2, 6, 3, 6, 4, 6, 5, 6, 6]\n assert candidate(obstacles = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11]\n assert candidate(obstacles = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 11, 11, 10, 9, 8, 7, 6, 5, 4, 3]\n assert candidate(obstacles = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == [1, 2, 3, 4, 5, 2, 3, 4, 5, 6]\n assert candidate(obstacles = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1]) == [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]\n assert candidate(obstacles = [1, 3, 5, 2, 4, 6, 3, 5, 7, 8, 4, 6, 9]) == [1, 2, 3, 2, 3, 4, 3, 4, 5, 6, 4, 5, 7]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10, 1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == [1, 2, 3, 4, 5, 2, 3, 4, 5, 6, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7]\n assert candidate(obstacles = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 12, 11, 10, 9, 8, 7, 6, 5, 3]\n assert candidate(obstacles = [20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(obstacles = [1, 2, 3, 2, 1, 3, 4, 5, 4, 3, 2, 4, 5, 6, 5, 4, 3, 4, 5]) == [1, 2, 3, 3, 2, 4, 5, 6, 6, 5, 4, 7, 8, 9, 9, 8, 6, 9, 10]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11]\n assert candidate(obstacles = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(obstacles = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5, 5, 4, 3, 2, 4, 5, 6, 7, 7, 6, 5, 3, 6, 7, 8, 9]\n assert candidate(obstacles = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]\n assert candidate(obstacles = [1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(obstacles = [3, 1, 2, 3, 4, 2, 1, 4, 3, 2, 5, 6, 4, 5, 7, 8, 9]) == [1, 1, 2, 3, 4, 3, 2, 5, 4, 4, 6, 7, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 10, 1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 10, 1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 10]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, 2, 8, 3, 7, 4, 7, 5, 7, 6, 7, 9, 3, 10, 4, 8, 5, 8, 6, 8, 7, 8, 11]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(obstacles = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 11, 12, 13, 14, 15, 5, 6, 7, 8, 9, 16, 17, 18, 19, 20, 1, 2, 3, 4]) == [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 7, 8, 9, 10, 11, 5, 6, 7, 8, 9, 12, 13, 14, 15, 16, 2, 3, 4, 5]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(obstacles = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2, 3, 4, 5, 6, 7, 8, 9, 10, 21]\n assert candidate(obstacles = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 5, 6, 7, 8, 9]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [5, 1, 4, 2, 3, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 2, 2, 3, 4, 5, 6, 7, 8, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(obstacles = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]\n assert candidate(obstacles = [5, 3, 4, 1, 2, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == [1, 1, 2, 1, 2, 3, 4, 5, 6, 7, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 4, 5, 6, 7]\n assert candidate(obstacles = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11]\n assert candidate(obstacles = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(obstacles = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 3, 3, 3, 2, 2, 2, 1, 1, 1]) == [1, 2, 3, 4, 2, 3, 4, 5, 6, 7, 5, 6, 7, 8, 9, 10, 8, 9, 10, 8, 9, 10]\n assert candidate(obstacles = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20]) == [1, 2, 2, 3, 3, 4, 4, 5, 5, 6]\n assert candidate(obstacles = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(obstacles = [10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == [1, 1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, 7, 8, 9]\n assert candidate(obstacles = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(obstacles = [1, 2, 3, 4, 5, 4, 5, 3, 4, 5, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1]) == [1, 2, 3, 4, 5, 5, 6, 4, 6, 7, 3, 5, 7, 8, 2, 4, 6, 8, 9, 3]\n assert candidate(obstacles = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(obstacles = [10000000, 9999999, 9999998, 9999997, 9999996, 9999995, 9999994, 9999993, 9999992, 9999991, 9999990, 9999989, 9999988, 9999987, 9999986, 9999985, 9999984, 9999983, 9999982, 9999981, 9999980, 9999979, 9999978, 9999977, 9999976, 9999975, 9999974, 9999973, 9999972, 9999971]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(obstacles = [3, 2, 1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5]) == [1, 1, 1, 2, 3, 3, 2, 4, 5, 6, 6, 5, 3, 6, 7, 8, 9]\n"}, "metadata": {"canonical_parameter_names": ["obstacles"], "leetcode_dataset_entry_point": "Solution().longestObstacleCourseAtEachPosition", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector longestObstacleCourseAtEachPosition(vector& obstacles) {", "container": "Solution", "callable": "longestObstacleCourseAtEachPosition", "parameters": [{"name": "obstacles", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1967, "task_id": "number-of-strings-that-appear-as-substrings-in-word", "difficulty": "Easy", "problem_description": "Given an array of strings patterns and a string word, return the number of strings in patterns that exist as a substring in word.\nA substring is a contiguous sequence of characters within a string.\n \nExample 1:\n\nInput: patterns = [\"a\",\"abc\",\"bc\",\"d\"], word = \"abc\"\nOutput: 3\nExplanation:\n- \"a\" appears as a substring in \"abc\".\n- \"abc\" appears as a substring in \"abc\".\n- \"bc\" appears as a substring in \"abc\".\n- \"d\" does not appear as a substring in \"abc\".\n3 of the strings in patterns appear as a substring in word.\n\nExample 2:\n\nInput: patterns = [\"a\",\"b\",\"c\"], word = \"aaaaabbbbb\"\nOutput: 2\nExplanation:\n- \"a\" appears as a substring in \"aaaaabbbbb\".\n- \"b\" appears as a substring in \"aaaaabbbbb\".\n- \"c\" does not appear as a substring in \"aaaaabbbbb\".\n2 of the strings in patterns appear as a substring in word.\n\nExample 3:\n\nInput: patterns = [\"a\",\"a\",\"a\"], word = \"ab\"\nOutput: 3\nExplanation: Each of the patterns appears as a substring in word \"ab\".\n\n \nConstraints:\n\n1 <= patterns.length <= 100\n1 <= patterns[i].length <= 100\n1 <= word.length <= 100\npatterns[i] and word consist of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(patterns = ['a', 'b', 'c'],word = \"aaaaabbbbb\") == 2\n assert candidate(patterns = ['aa', 'bb', 'cc'],word = \"abcabc\") == 0\n assert candidate(patterns = ['a', 'abc', 'bc', 'd'],word = \"abc\") == 3\n assert candidate(patterns = ['aaa'],word = \"aaaaa\") == 1\n assert candidate(patterns = ['abc'],word = \"abc\") == 1\n assert candidate(patterns = ['xyz', 'xy', 'yz'],word = \"xyz\") == 3\n assert candidate(patterns = ['hello', 'world'],word = \"helloworld\") == 2\n assert candidate(patterns = ['a', 'a', 'a'],word = \"ab\") == 3\n assert candidate(patterns = ['z'],word = \"abcz\") == 1\n assert candidate(patterns = ['a', 'b', 'c', 'd', 'e'],word = \"edcba\") == 5\n assert candidate(patterns = ['hello', 'world', 'foo', 'bar'],word = \"helloworldfoo\") == 3\n assert candidate(patterns = ['repeated', 'repeat', 'eat'],word = \"repeatedrepeat\") == 3\n assert candidate(patterns = ['this', 'is', 'a', 'test'],word = \"thisisatest\") == 4\n assert candidate(patterns = ['abc', 'cab', 'bac'],word = \"abacabcabc\") == 3\n assert candidate(patterns = ['aabb', 'bbcc', 'ccdd', 'ddaa'],word = \"aabbccdd\") == 3\n assert candidate(patterns = ['a', 'ab', 'abc', 'abcd'],word = \"abcd\") == 4\n assert candidate(patterns = ['a', 'aa', 'aaa', 'aaaa'],word = \"aaaaaaaa\") == 4\n assert candidate(patterns = ['overlapping', 'lapping', 'lappingo', 'verlapping'],word = \"overlappinglappingoverlappingoverlapping\") == 4\n assert candidate(patterns = ['hello', 'world', 'python', 'programming'],word = \"helloworldpythonprogramming\") == 4\n assert candidate(patterns = ['xyz', 'zyx', 'zxy'],word = \"xyzzyxzyxzxyzyx\") == 3\n assert candidate(patterns = ['xy', 'yx', 'xyz', 'zyx'],word = \"xyzzyx\") == 4\n assert candidate(patterns = ['lorem', 'ipsum', 'dolor', 'sit', 'amet'],word = \"loremipsumdolorsitamet\") == 5\n assert candidate(patterns = ['abcd', 'bcde', 'cdef', 'defg', 'efgh', 'fghi', 'ghij', 'hijk', 'ijkl', 'jklm', 'klmn', 'lmno', 'mnop', 'nopq', 'opqr', 'pqrs', 'qrst', 'rstu', 'stuv', 'tuvw', 'uvwx', 'vwxy', 'wxyz'],word = \"abcdefghijklmnopqrstuvwxyz\") == 23\n assert candidate(patterns = ['mnop', 'nopq', 'opqr', 'pqrs', 'qrst'],word = \"mnopqrstu\") == 5\n assert candidate(patterns = ['quick', 'brown', 'fox'],word = \"thequickbrownfox\") == 3\n assert candidate(patterns = ['abcd', 'abcde', 'abcdef'],word = \"abcdefgabcdefg\") == 3\n assert candidate(patterns = ['xyz', 'zyx', 'yxz', 'xzy', 'zyx'],word = \"zyxzyxzyxzyx\") == 4\n assert candidate(patterns = ['ab', 'ba', 'aba', 'bab'],word = \"abababab\") == 4\n assert candidate(patterns = ['aaaa', 'bbbb', 'cccc'],word = \"aaaabbbbccccaaaabbbbcccc\") == 3\n assert candidate(patterns = ['aba', 'bba', 'aaa', 'bbb'],word = \"abababababa\") == 1\n assert candidate(patterns = ['repeated', 'pattern', 'substring', 'string'],word = \"repeatedpatternsubstringstring\") == 4\n assert candidate(patterns = ['ab', 'bc', 'cd', 'de', 'ef', 'fg'],word = \"abcdefg\") == 6\n assert candidate(patterns = ['repeated', 'substring', 'example'],word = \"repeatedsubstringexample\") == 3\n assert candidate(patterns = ['overlap', 'lap', 'ap', 'p'],word = \"overlaplapap\") == 4\n assert candidate(patterns = ['hello', 'world', 'python', 'programming'],word = \"programmingworldpython\") == 3\n assert candidate(patterns = ['longer', 'substrings', 'to', 'check'],word = \"thisisalongersubstringtocheck\") == 3\n assert candidate(patterns = ['unique', 'un', 'iq'],word = \"uniqueiq\") == 3\n assert candidate(patterns = ['substring', 'string', 'sub'],word = \"thisisjustasubstringexample\") == 3\n assert candidate(patterns = ['hello', 'world', 'hello', 'world'],word = \"helloworldhello\") == 4\n assert candidate(patterns = ['aaa', 'aa', 'a'],word = \"aaaaaaaaaaaa\") == 3\n assert candidate(patterns = ['z', 'zz', 'zzz'],word = \"zzzzzzzzz\") == 3\n assert candidate(patterns = ['ab', 'bc', 'cd', 'de', 'ef'],word = \"abcdef\") == 5\n assert candidate(patterns = ['123', '234', '345'],word = \"1234567890\") == 3\n assert candidate(patterns = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],word = \"abcdefghij\") == 10\n assert candidate(patterns = ['a', 'b', 'c', 'd', 'e', 'f'],word = \"abcdef\") == 6\n assert candidate(patterns = ['a', 'ab', 'abc', 'abcd', 'abcde'],word = \"abcde\") == 5\n assert candidate(patterns = ['one', 'two', 'three'],word = \"onetwothreeonetwothree\") == 3\n assert candidate(patterns = ['aaa', 'aab', 'aba', 'baa', 'aabaa', 'aaaba', 'aaba', 'baaa'],word = \"aaaabaaaa\") == 8\n assert candidate(patterns = ['hello', 'world', 'helloworld'],word = \"helloworld\") == 3\n assert candidate(patterns = ['quick', 'brown', 'fox'],word = \"thequickbrownfoxjumps\") == 3\n assert candidate(patterns = ['xyz', 'zyx', 'yzz', 'zzz'],word = \"xyzzyzyzzz\") == 3\n assert candidate(patterns = ['aaa', 'bbb', 'ccc', 'abc', 'bca', 'cab'],word = \"abcabcabc\") == 3\n assert candidate(patterns = ['abcd', 'dcba', 'abcdabcd'],word = \"abcdabcdabcdabcd\") == 2\n assert candidate(patterns = ['a', 'ab', 'abc', 'abcd', 'abcde'],word = \"abcdefghijklmnopqrstuvwxyz\") == 5\n assert candidate(patterns = ['abc', 'def', 'ghi', 'jkl'],word = \"abcdefghijkl\") == 4\n assert candidate(patterns = ['aaaaa', 'bbbbb', 'ccccc', 'ddddd'],word = \"abcdeabcdeabcdeabcde\") == 0\n assert candidate(patterns = ['ab', 'bc', 'cd', 'de'],word = \"abcdefg\") == 4\n assert candidate(patterns = ['pattern', 'matching', 'substrings'],word = \"matchingpatternsubstring\") == 2\n assert candidate(patterns = ['ab', 'ba', 'abab', 'baba'],word = \"abababababababab\") == 4\n assert candidate(patterns = ['same', 'sub', 'string', 'test', 'case'],word = \"substringtestcase\") == 4\n assert candidate(patterns = ['aaaa', 'bbbb', 'cccc', 'ddd'],word = \"aaaabbbbccccddd\") == 4\n assert candidate(patterns = ['apple', 'banana', 'cherry'],word = \"cherrybananaapple\") == 3\n assert candidate(patterns = ['cat', 'dog', 'bird', 'fish'],word = \"fishdogcatbird\") == 4\n assert candidate(patterns = ['python', 'java', 'cpp'],word = \"pythonjavacpp\") == 3\n assert candidate(patterns = ['aaa', 'bbb', 'ccc', 'ddd'],word = \"aaabbbcccddd\") == 4\n assert candidate(patterns = ['test', 'sett', 'best'],word = \"bestsett\") == 2\n assert candidate(patterns = ['abc', 'bca', 'cab', 'abcabc'],word = \"abcabcabcabc\") == 4\n assert candidate(patterns = ['aaa', 'aa', 'a'],word = \"aaaaaaaaaa\") == 3\n assert candidate(patterns = ['quick', 'brown', 'fox', 'jump', 'over', 'lazy', 'dog'],word = \"thequickbrownfoxjumpsoverthelazydog\") == 7\n assert candidate(patterns = ['abc', 'cab', 'bca'],word = \"abcabcabcabc\") == 3\n assert candidate(patterns = ['xyz', 'zyx', 'xy', 'yx', 'xzy', 'yzx'],word = \"zyxwvutsrqponmlkjihgfedcba\") == 2\n assert candidate(patterns = ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff'],word = \"abcdefabcdefabcdef\") == 0\n assert candidate(patterns = ['abc', 'def', 'ghi'],word = \"defabc\") == 2\n assert candidate(patterns = ['quick', 'brown', 'fox'],word = \"thequickbrownfoxjumpsoverthelazydog\") == 3\n assert candidate(patterns = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],word = \"abcdef ghijklmnopqrstuvwxyz\") == 9\n assert candidate(patterns = ['aaa', 'aa', 'a'],word = \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\") == 3\n assert candidate(patterns = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],word = \"abcdefghijabcdefghij\") == 10\n assert candidate(patterns = ['test', 'string', 'finding', 'substring'],word = \"teststringfindingsubstring\") == 4\n assert candidate(patterns = ['aa', 'aaa', 'aaaa'],word = \"aaaa\") == 3\n assert candidate(patterns = ['short', 'shot', 'dot'],word = \"shortshot\") == 2\n assert candidate(patterns = ['foo', 'bar', 'foobar', 'barfoo'],word = \"foobarbarfoobarfoo\") == 4\n assert candidate(patterns = ['aba', 'bab', 'aba'],word = \"ababababa\") == 3\n assert candidate(patterns = ['hello', 'world', 'python'],word = \"pythonworldhello\") == 3\n assert candidate(patterns = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba'],word = \"abcacbcbacbacbcbac\") == 5\n assert candidate(patterns = ['banana', 'ana', 'nan', 'ban'],word = \"banananana\") == 4\n assert candidate(patterns = ['abc', 'abcd', 'abcde'],word = \"abcdefgh\") == 3\n assert candidate(patterns = ['abcd', 'dcba', 'abcd'],word = \"abcdcbaabcd\") == 3\n assert candidate(patterns = ['aaaa', 'bbbb', 'cccc', 'dddd'],word = \"abcdeabcdeabcde\") == 0\n assert candidate(patterns = ['longpattern', 'long', 'pattern'],word = \"longpatternlongpattern\") == 3\n assert candidate(patterns = ['ab', 'bc', 'cd', 'de', 'ef', 'fg', 'gh', 'hi', 'ij'],word = \"abcdefghij\") == 9\n assert candidate(patterns = ['abc', 'bcd', 'cde', 'def', 'efg', 'fgh', 'ghi', 'hij', 'ijk', 'jkl', 'klm', 'lmn', 'mno', 'nop', 'opq', 'pqr', 'qrs', 'rst', 'stu', 'tuv', 'uvw', 'vwx', 'wxy', 'xyz'],word = \"abcdefghijklmnopqrstuvwxyz\") == 24\n assert candidate(patterns = ['zzz', 'zzzz', 'zzzzz'],word = \"zzzzzzzzzz\") == 3\n assert candidate(patterns = ['ab', 'bc', 'cd', 'de'],word = \"abcde\") == 4\n assert candidate(patterns = ['abc', 'bcd', 'cde', 'def'],word = \"abcdefg\") == 4\n assert candidate(patterns = ['abc', 'abcd', 'abcde', 'abcdef'],word = \"abcdefg\") == 4\n assert candidate(patterns = ['test', 'tset', 'sett', 'settset'],word = \"testsettsettset\") == 4\n assert candidate(patterns = ['small', 'medium', 'large', 'extra', 'huge'],word = \"smallmediumlargeextrahuge\") == 5\n assert candidate(patterns = ['pattern', 'tern', 'ternary', 'ternarysearch'],word = \"binarysearchternarysearch\") == 3\n assert candidate(patterns = ['xyz', 'zyx', 'yzx'],word = \"xyzzyxzyxzyx\") == 2\n assert candidate(patterns = ['abcd', 'efgh', 'ijkl'],word = \"efghijklabcd\") == 3\n assert candidate(patterns = ['abc', 'cab', 'bac', 'bca', 'acb', 'cba'],word = \"abcabcabc\") == 3\n assert candidate(patterns = ['abc', 'abcabc', 'abcabcabc'],word = \"abcabcabcabc\") == 3\n assert candidate(patterns = ['aaa', 'bbb', 'ccc'],word = \"abacabadabc\") == 0\n assert candidate(patterns = ['one', 'two', 'three', 'onetwothree'],word = \"onetwothreeonetwothree\") == 4\n assert candidate(patterns = ['search', 'sear', 'arch'],word = \"searchingthesearchinthesearch\") == 3\n assert candidate(patterns = ['overlap', 'lap', 'lapping'],word = \"lapping\") == 2\n assert candidate(patterns = ['abc', 'def', 'ghi', 'jkl'],word = \"abcdefghijklmnopqrstuvwxyz\") == 4\n assert candidate(patterns = ['abc', 'def', 'ghi', 'jkl'],word = \"abcdefghijk\") == 3\n assert candidate(patterns = ['xyz', 'zyx', 'wxy', 'uvw'],word = \"xyzzyxwxyuvw\") == 4\n assert candidate(patterns = ['abc', 'def', 'ghi', 'jkl'],word = \"abcdefghij\") == 3\n assert candidate(patterns = ['abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yz'],word = \"abcdefghijklmnopqrstuvwxyz\") == 7\n assert candidate(patterns = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],word = \"abcdefghijklmnopqrstuvwxyz\") == 9\n assert candidate(patterns = ['zz', 'zzz', 'zzzz'],word = \"zzzzzzzzzz\") == 3\n assert candidate(patterns = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],word = \"zyxwvutsrqponmlkjihgfedcba\") == 26\n assert candidate(patterns = ['example', 'ample', 'mple', 'ple', 'le', 'e'],word = \"exampleexampleexample\") == 6\n assert candidate(patterns = ['ab', 'ba', 'ac', 'ca', 'bc', 'cb'],word = \"abcbaacbba\") == 5\n assert candidate(patterns = ['abc', 'def', 'ghi'],word = \"abcdefghi\") == 3\n assert candidate(patterns = ['xyz', 'zyx', 'yzx'],word = \"xyzzyxzyx\") == 2\n assert candidate(patterns = ['zzz', 'zz', 'z'],word = \"zzzzzzzzzz\") == 3\n assert candidate(patterns = ['pattern', 'tern', 'ternary', 'ary'],word = \"patternarypatternary\") == 4\n assert candidate(patterns = ['xyz', 'abc', 'def', 'ghi', 'jkl'],word = \"zyxwvutsrqponmlkjihgfedcba\") == 0\n assert candidate(patterns = ['a', 'ab', 'abc', 'abcd'],word = \"abcdabcdabcd\") == 4\n"}, "metadata": {"canonical_parameter_names": ["patterns", "word"], "leetcode_dataset_entry_point": "Solution().numOfStrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numOfStrings(vector& patterns, string word) {", "container": "Solution", "callable": "numOfStrings", "parameters": [{"name": "patterns", "type": "vector&"}, {"name": "word", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1968, "task_id": "array-with-elements-not-equal-to-average-of-neighbors", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums of distinct integers. You want to rearrange the elements in the array such that every element in the rearranged array is not equal to the average of its neighbors.\nMore formally, the rearranged array should have the property such that for every i in the range 1 <= i < nums.length - 1, (nums[i-1] + nums[i+1]) / 2 is not equal to nums[i].\nReturn any rearrangement of nums that meets the requirements.\n \nExample 1:\n\nInput: nums = [1,2,3,4,5]\nOutput: [1,2,4,5,3]\nExplanation:\nWhen i=1, nums[i] = 2, and the average of its neighbors is (1+4) / 2 = 2.5.\nWhen i=2, nums[i] = 4, and the average of its neighbors is (2+5) / 2 = 3.5.\nWhen i=3, nums[i] = 5, and the average of its neighbors is (4+3) / 2 = 3.5.\n\nExample 2:\n\nInput: nums = [6,2,0,9,7]\nOutput: [9,7,6,2,0]\nExplanation:\nWhen i=1, nums[i] = 7, and the average of its neighbors is (9+6) / 2 = 7.5.\nWhen i=2, nums[i] = 6, and the average of its neighbors is (7+2) / 2 = 4.5.\nWhen i=3, nums[i] = 2, and the average of its neighbors is (6+0) / 2 = 3.\nNote that the original array [6,2,0,9,7] also satisfies the conditions.\n \nConstraints:\n\n3 <= nums.length <= 105\n0 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 100000, 50000, 25000, 75000]) == [0, 75000, 25000, 100000, 50000]\n assert candidate(nums = [10, 20, 30, 40, 50, 60]) == [10, 40, 20, 50, 30, 60]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13]) == [1, 9, 3, 11, 5, 13, 7]\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7]) == [1, 5, 2, 6, 3, 7, 4]\n assert candidate(nums = [3, 1, 2, 5, 4]) == [1, 4, 2, 5, 3]\n assert candidate(nums = [10, 5, 1, 6, 2]) == [1, 6, 2, 10, 5]\n assert candidate(nums = [5, 1, 3, 2, 4]) == [1, 4, 2, 5, 3]\n assert candidate(nums = [5, 10, 15, 20, 25, 30]) == [5, 20, 10, 25, 15, 30]\n assert candidate(nums = [6, 2, 0, 9, 7]) == [0, 7, 2, 9, 6]\n assert candidate(nums = [0, 100, 50, 25, 75]) == [0, 75, 25, 100, 50]\n assert candidate(nums = [10, 20, 30, 40, 50]) == [10, 40, 20, 50, 30]\n assert candidate(nums = [5, 3, 1, 2, 4]) == [1, 4, 2, 5, 3]\n assert candidate(nums = [1, 2, 3, 4, 5]) == [1, 4, 2, 5, 3]\n assert candidate(nums = [1, 3, 5, 7, 9, 11]) == [1, 7, 3, 9, 5, 11]\n assert candidate(nums = [10, 0, 5, 3, 8]) == [0, 8, 3, 10, 5]\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == [100, 106, 101, 107, 102, 108, 103, 109, 104, 110, 105]\n assert candidate(nums = [31, 41, 59, 26, 53, 58, 97, 93, 23, 84, 62, 64, 33, 83, 27, 95, 0, 88, 49, 51]) == [0, 58, 23, 59, 26, 62, 27, 64, 31, 83, 33, 84, 41, 88, 49, 93, 51, 95, 53, 97]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140]) == [7, 77, 14, 84, 21, 91, 28, 98, 35, 105, 42, 112, 49, 119, 56, 126, 63, 133, 70, 140]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [100, 600, 200, 700, 300, 800, 400, 900, 500, 1000]\n assert candidate(nums = [85, 90, 80, 95, 75, 100, 70, 105, 65, 110]) == [65, 90, 70, 95, 75, 100, 80, 105, 85, 110]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == [1, 32, 2, 64, 4, 128, 8, 256, 16, 512]\n assert candidate(nums = [100000, 50000, 25000, 12500, 62500, 31250, 93750, 46875, 15625, 78125]) == [12500, 50000, 15625, 62500, 25000, 78125, 31250, 93750, 46875, 100000]\n assert candidate(nums = [123, 456, 789, 234, 567, 890, 345, 678, 901, 12, 34, 56]) == [12, 456, 34, 567, 56, 678, 123, 789, 234, 890, 345, 901]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 10, 20]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 10, 20]\n assert candidate(nums = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991, 9990, 9989, 9988, 9987, 9986]) == [9986, 9994, 9987, 9995, 9988, 9996, 9989, 9997, 9990, 9998, 9991, 9999, 9992, 10000, 9993]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 6, 2, 7, 3, 8, 4, 9, 5]\n assert candidate(nums = [5, 3, 8, 6, 11, 9, 14, 12, 17, 15, 20, 18, 23, 21, 26, 24, 29, 27, 32, 30]) == [3, 18, 5, 20, 6, 21, 8, 23, 9, 24, 11, 26, 12, 27, 14, 29, 15, 30, 17, 32]\n assert candidate(nums = [100000, 0, 50000, 25000, 75000, 12500, 87500, 31250, 68750]) == [0, 68750, 12500, 75000, 25000, 87500, 31250, 100000, 50000]\n assert candidate(nums = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9]) == [-9, 1, -8, 3, -7, 7, -6, 15, -5, 31, -4, 62, -3, 125, -2, 250, -1, 500, 0, 1000]\n assert candidate(nums = [50, 25, 75, 37, 62, 88, 43, 91, 56, 12]) == [12, 56, 25, 62, 37, 75, 43, 88, 50, 91]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == [1, 5, 1, 5, 2, 5, 2, 6, 3, 6, 3, 7, 3, 8, 3, 9, 4, 9, 4, 9]\n assert candidate(nums = [5, 15, 10, 20, 25, 30, 35, 40, 45, 50]) == [5, 30, 10, 35, 15, 40, 20, 45, 25, 50]\n assert candidate(nums = [5, 15, 10, 20, 25, 12, 30, 18, 28]) == [5, 20, 10, 25, 12, 28, 15, 30, 18]\n assert candidate(nums = [8, 6, 4, 2, 0, 1, 3, 5, 7, 9]) == [0, 5, 1, 6, 2, 7, 3, 8, 4, 9]\n assert candidate(nums = [100000, 1, 99999, 2, 99998, 3, 99997, 4, 99996, 5, 99995, 6, 99994, 7, 99993]) == [1, 99994, 2, 99995, 3, 99996, 4, 99997, 5, 99998, 6, 99999, 7, 100000, 99993]\n assert candidate(nums = [8, 1, 6, 3, 9, 4, 5, 2, 7]) == [1, 6, 2, 7, 3, 8, 4, 9, 5]\n assert candidate(nums = [42, 84, 21, 168, 105, 252, 175, 336, 245, 420, 315, 462, 368]) == [21, 252, 42, 315, 84, 336, 105, 368, 168, 420, 175, 462, 245]\n assert candidate(nums = [8192, 16384, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == [1, 256, 2, 512, 4, 1024, 8, 2048, 16, 4096, 32, 8192, 64, 16384, 128]\n assert candidate(nums = [1, 4, 2, 5, 3, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 10, 20]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15, 8]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]\n assert candidate(nums = [99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111, 0]) == [0, 55555, 11111, 66666, 22222, 77777, 33333, 88888, 44444, 99999]\n assert candidate(nums = [34, 7, 23, 32, 5, 62, 32, 2, 78, 1, 45, 67, 89, 12, 34, 56, 78, 90]) == [1, 34, 2, 45, 5, 56, 7, 62, 12, 67, 23, 78, 32, 78, 32, 89, 34, 90]\n assert candidate(nums = [101, 203, 305, 407, 509, 611, 713, 815, 917, 1019]) == [101, 611, 203, 713, 305, 815, 407, 917, 509, 1019]\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == [15, 90, 30, 105, 45, 120, 60, 135, 75, 150]\n assert candidate(nums = [10, 5, 8, 2, 6, 4, 9, 1, 7, 3]) == [1, 6, 2, 7, 3, 8, 4, 9, 5, 10]\n assert candidate(nums = [1, 5, 3, 9, 7, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == [1, 17, 3, 19, 5, 21, 7, 23, 9, 25, 11, 27, 13, 29, 15]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]) == [1, 5, 1, 5, 2, 5, 3, 6, 3, 9, 4, 9]\n assert candidate(nums = [314159, 271828, 161803, 377987, 141421, 271828, 161803, 377987, 141421, 271828]) == [141421, 271828, 141421, 271828, 161803, 314159, 161803, 377987, 271828, 377987]\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125]) == [15, 75, 25, 85, 35, 95, 45, 105, 55, 115, 65, 125]\n assert candidate(nums = [99999, 0, 50000, 25000, 75000, 1, 99998]) == [0, 75000, 1, 99998, 25000, 99999, 50000]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [5, 30, 10, 35, 15, 40, 20, 45, 25, 50]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13]) == [1, 8, 2, 9, 3, 10, 4, 11, 5, 12, 6, 13, 7]\n assert candidate(nums = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930]) == [123, 161718, 456, 192021, 789, 222324, 101112, 252627, 131415, 282930]\n assert candidate(nums = [85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == [85, 93, 86, 94, 87, 95, 88, 96, 89, 97, 90, 98, 91, 99, 92, 100]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40]) == [5, 25, 10, 30, 15, 35, 20, 40]\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990]) == [99990, 99995, 99991, 99996, 99992, 99997, 99993, 99998, 99994, 99999]\n assert candidate(nums = [42, 84, 21, 105, 52, 7, 14, 35, 28, 70]) == [7, 42, 14, 52, 21, 70, 28, 84, 35, 105]\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89]) == [1, 13, 2, 21, 3, 34, 5, 55, 8, 89]\n assert candidate(nums = [1000, 2000, 500, 3000, 1500, 4000, 2500, 5000, 3500]) == [500, 3000, 1000, 3500, 1500, 4000, 2000, 5000, 2500]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [5, 55, 15, 65, 25, 75, 35, 85, 45, 95]\n assert candidate(nums = [100000, 0, 50000, 25000, 75000, 125000, 37500, 62500, 187500, 93750]) == [0, 75000, 25000, 93750, 37500, 100000, 50000, 125000, 62500, 187500]\n assert candidate(nums = [100, 200, 150, 300, 250, 400, 350, 500, 450, 600]) == [100, 350, 150, 400, 200, 450, 250, 500, 300, 600]\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [7, 17, 8, 18, 9, 19, 10, 20, 11, 21, 12, 22, 13, 23, 14, 24, 15, 25, 16]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 10, 20]\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384]) == [1, 256, 2, 512, 4, 1024, 8, 2048, 16, 4096, 32, 8192, 64, 16384, 128]\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 9, 1, 10]) == [1, 6, 2, 7, 3, 8, 4, 9, 5, 10]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == [90, 95, 91, 96, 92, 97, 93, 98, 94, 99]\n assert candidate(nums = [10000, 10001, 10002, 10003, 10004, 10005, 10006, 10007, 10008, 10009]) == [10000, 10005, 10001, 10006, 10002, 10007, 10003, 10008, 10004, 10009]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == [2, 14, 4, 16, 6, 18, 8, 20, 10, 22, 12]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == [2, 18, 4, 20, 6, 22, 8, 24, 10, 26, 12, 28, 14, 30, 16]\n assert candidate(nums = [50000, 25000, 75000, 12500, 87500, 31250, 68750, 15625, 93750]) == [12500, 68750, 15625, 75000, 25000, 87500, 31250, 93750, 50000]\n assert candidate(nums = [200, 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180]) == [180, 191, 181, 192, 182, 193, 183, 194, 184, 195, 185, 196, 186, 197, 187, 198, 188, 199, 189, 200, 190]\n assert candidate(nums = [8, 6, 4, 2, 0, 1, 3, 5, 7, 9, 11, 13]) == [0, 6, 1, 7, 2, 8, 3, 9, 4, 11, 5, 13]\n assert candidate(nums = [50, 40, 30, 20, 10, 60, 70, 80, 90, 100, 110, 120]) == [10, 70, 20, 80, 30, 90, 40, 100, 50, 110, 60, 120]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15, 8]\n assert candidate(nums = [9, 1, 8, 2, 7, 3, 6, 4, 5]) == [1, 6, 2, 7, 3, 8, 4, 9, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 6, 2, 7, 3, 8, 4, 9, 5, 10]\n assert candidate(nums = [30, 20, 10, 40, 50, 60, 70, 80, 90, 100]) == [10, 60, 20, 70, 30, 80, 40, 90, 50, 100]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 5, 1, 6, 2, 7, 3, 8, 4, 9]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40]) == [-40, 40, -30, 50, -20, 60, -10, 70, 0, 80, 10, 90, 20, 100, 30]\n assert candidate(nums = [23, 45, 12, 67, 89, 34, 56, 78, 90, 11, 32, 54]) == [11, 54, 12, 56, 23, 67, 32, 78, 34, 89, 45, 90]\n assert candidate(nums = [2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19]) == [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 10, 20]\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == [1, 5, 1, 5, 2, 5, 3, 6, 3, 9, 4]\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120]) == [100, 111, 101, 112, 102, 113, 103, 114, 104, 115, 105, 116, 106, 117, 107, 118, 108, 119, 109, 120, 110]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == [10, 70, 20, 80, 30, 90, 40, 100, 50, 110, 60, 120]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [10, 90, 20, 100, 30, 110, 40, 120, 50, 130, 60, 140, 70, 150, 80]\n assert candidate(nums = [123456, 654321, 13579, 24680, 98765, 43210]) == [13579, 98765, 24680, 123456, 43210, 654321]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4]) == [-4, 6, -3, 7, -2, 8, -1, 9, 0, 10, 1, 11, 2, 12, 3, 13, 4, 14, 5, 15]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 11, 2, 12, 3, 13, 4, 14, 5, 15, 6, 16, 7, 17, 8, 18, 9, 19, 10, 20]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105]) == [7, 63, 14, 70, 21, 77, 28, 84, 35, 91, 42, 98, 49, 105, 56]\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == [85, 93, 86, 94, 87, 95, 88, 96, 89, 97, 90, 98, 91, 99, 92, 100]\n assert candidate(nums = [1, 2, 3, 6, 5, 4, 7, 8, 9]) == [1, 6, 2, 7, 3, 8, 4, 9, 5]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300]) == [100, 800, 200, 900, 300, 1000, 400, 1100, 500, 1200, 600, 1300, 700]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == [85, 93, 86, 94, 87, 95, 88, 96, 89, 97, 90, 98, 91, 99, 92]\n assert candidate(nums = [8, 1, 6, 3, 5, 7, 2, 4, 9]) == [1, 6, 2, 7, 3, 8, 4, 9, 5]\n assert candidate(nums = [100, 1, 200, 2, 300, 3, 400, 4, 500, 5]) == [1, 100, 2, 200, 3, 300, 4, 400, 5, 500]\n assert candidate(nums = [99999, 1, 99998, 2, 99997, 3, 99996, 4, 99995]) == [1, 99996, 2, 99997, 3, 99998, 4, 99999, 99995]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15]) == [1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15, 8]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119]) == [7, 70, 14, 77, 21, 84, 28, 91, 35, 98, 42, 105, 49, 112, 56, 119, 63]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [10, 60, 20, 70, 30, 80, 40, 90, 50, 100]\n assert candidate(nums = [8, 1, 4, 9, 3, 7, 6, 2, 5, 10]) == [1, 6, 2, 7, 3, 8, 4, 9, 5, 10]\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6]) == [1, 6, 2, 7, 3, 8, 4, 9, 5]\n assert candidate(nums = [123, 456, 789, 101, 202, 303, 404, 505, 606, 707]) == [101, 456, 123, 505, 202, 606, 303, 707, 404, 789]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [0, 5, 1, 6, 2, 7, 3, 8, 4, 9]\n assert candidate(nums = [15, 10, 5, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == [5, 45, 10, 50, 15, 55, 20, 60, 25, 65, 30, 70, 35, 75, 40]\n assert candidate(nums = [0, 100000, 50000, 25000, 75000, 125000, 37500, 62500, 87500, 162500]) == [0, 75000, 25000, 87500, 37500, 100000, 50000, 125000, 62500, 162500]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == [5, 35, 10, 40, 15, 45, 20, 50, 25, 55, 30]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == [100, 600, 200, 700, 300, 800, 400, 900, 500, 1000]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == [1000, 6000, 2000, 7000, 3000, 8000, 4000, 9000, 5000, 10000]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == [10, 90, 20, 100, 30, 110, 40, 120, 50, 130, 60, 140, 70, 150, 80]\n assert candidate(nums = [100, 200, 150, 300, 250, 400, 350]) == [100, 300, 150, 350, 200, 400, 250]\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7]) == [7, 17, 8, 18, 9, 19, 10, 20, 11, 21, 12, 22, 13, 23, 14, 24, 15, 25, 16]\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108, 120]) == [12, 72, 24, 84, 36, 96, 48, 108, 60, 120]\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().rearrangeArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector rearrangeArray(vector& nums) {", "container": "Solution", "callable": "rearrangeArray", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1970, "task_id": "last-day-where-you-can-still-cross", "difficulty": "Hard", "problem_description": "There is a 1-based binary matrix where 0 represents land and 1 represents water. You are given integers row and col representing the number of rows and columns in the matrix, respectively.\nInitially on day 0, the entire matrix is land. However, each day a new cell becomes flooded with water. You are given a 1-based 2D array cells, where cells[i] = [ri, ci] represents that on the ith day, the cell on the rith row and cith column (1-based coordinates) will be covered with water (i.e., changed to 1).\nYou want to find the last day that it is possible to walk from the top to the bottom by only walking on land cells. You can start from any cell in the top row and end at any cell in the bottom row. You can only travel in the four cardinal directions (left, right, up, and down).\nReturn the last day where it is possible to walk from the top to the bottom by only walking on land cells.\n \nExample 1:\n\n\nInput: row = 2, col = 2, cells = [[1,1],[2,1],[1,2],[2,2]]\nOutput: 2\nExplanation: The above image depicts how the matrix changes each day starting from day 0.\nThe last day where it is possible to cross from top to bottom is on day 2.\n\nExample 2:\n\n\nInput: row = 2, col = 2, cells = [[1,1],[1,2],[2,1],[2,2]]\nOutput: 1\nExplanation: The above image depicts how the matrix changes each day starting from day 0.\nThe last day where it is possible to cross from top to bottom is on day 1.\n\nExample 3:\n\n\nInput: row = 3, col = 3, cells = [[1,2],[2,1],[3,3],[2,2],[1,1],[1,3],[2,3],[3,2],[3,1]]\nOutput: 3\nExplanation: The above image depicts how the matrix changes each day starting from day 0.\nThe last day where it is possible to cross from top to bottom is on day 3.\n\n \nConstraints:\n\n2 <= row, col <= 2 * 104\n4 <= row * col <= 2 * 104\ncells.length == row * col\n1 <= ri <= row\n1 <= ci <= col\nAll the values of cells are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(row = 3,col = 3,cells = [[1, 2], [2, 1], [3, 3], [2, 2], [1, 1], [1, 3], [2, 3], [3, 2], [3, 1]]) == 3\n assert candidate(row = 3,col = 4,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4]]) == 3\n assert candidate(row = 4,col = 4,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [4, 1], [4, 2], [4, 3], [4, 4]]) == 3\n assert candidate(row = 2,col = 2,cells = [[1, 1], [2, 1], [1, 2], [2, 2]]) == 2\n assert candidate(row = 2,col = 2,cells = [[1, 1], [1, 2], [2, 1], [2, 2]]) == 1\n assert candidate(row = 6,col = 6,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 1], [2, 6], [3, 1], [3, 6], [4, 1], [4, 6], [5, 1], [5, 6], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [2, 2], [2, 3], [2, 4], [2, 5], [3, 2], [3, 3], [3, 4], [3, 5], [4, 2], [4, 3], [4, 4], [4, 5], [5, 2], [5, 3], [5, 4], [5, 5], [3, 3], [4, 4]]) == 5\n assert candidate(row = 5,col = 5,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [5, 4], [5, 3], [5, 2], [5, 1], [4, 1], [3, 1], [2, 1], [2, 2], [2, 3], [2, 4], [3, 2], [3, 3], [3, 4], [4, 2], [4, 3], [4, 4]]) == 4\n assert candidate(row = 7,col = 7,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7]]) == 6\n assert candidate(row = 10,col = 10,cells = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10], [9, 10], [8, 10], [7, 10], [6, 10], [5, 10], [4, 10], [3, 10], [2, 10], [1, 10], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [8, 2], [9, 2], [2, 9], [3, 9], [4, 9], [5, 9], [6, 9], [7, 9], [8, 9]]) == 18\n assert candidate(row = 5,col = 4,cells = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [1, 4], [2, 4], [3, 4], [4, 4], [5, 4]]) == 15\n assert candidate(row = 6,col = 6,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6], [6, 5], [6, 4], [6, 3], [6, 2], [6, 1], [5, 1], [4, 1], [3, 1], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 2], [3, 3], [3, 4], [3, 5], [4, 2], [4, 3], [4, 4], [4, 5], [5, 2], [5, 3], [5, 4], [5, 5]]) == 5\n assert candidate(row = 7,col = 7,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 1], [3, 7], [4, 1], [4, 7], [5, 1], [5, 7], [6, 1], [6, 7], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [4, 2], [4, 6], [5, 2], [5, 6], [6, 2], [6, 6], [4, 3], [4, 4], [4, 5], [5, 3], [5, 4], [5, 5]]) == 6\n assert candidate(row = 5,col = 5,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 5], [3, 1], [3, 5], [4, 1], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [2, 2], [2, 3], [2, 4], [3, 2], [3, 4], [4, 2], [4, 3], [4, 4]]) == 4\n assert candidate(row = 5,col = 5,cells = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 4], [3, 5], [4, 1], [4, 2], [4, 3], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4]]) == 4\n assert candidate(row = 6,col = 6,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [1, 3], [2, 4], [3, 5], [4, 6], [5, 5], [6, 4], [5, 4], [5, 3], [6, 3], [6, 2], [5, 2], [4, 2], [3, 2], [2, 3], [3, 3], [4, 3], [3, 4], [4, 4], [5, 4], [4, 5], [3, 5], [2, 5], [2, 6], [3, 6], [4, 6], [5, 6], [4, 5], [3, 4], [2, 3], [1, 2], [1, 4], [1, 6], [3, 1], [5, 1], [6, 1]]) == 5\n assert candidate(row = 5,col = 5,cells = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 2], [2, 3], [3, 4], [4, 5], [5, 4], [5, 3], [5, 2], [5, 1], [4, 1], [3, 1], [2, 1], [1, 3], [1, 4], [1, 5], [2, 5], [3, 5], [4, 3], [4, 2], [3, 2], [2, 3], [2, 4], [3, 4], [4, 4], [4, 3], [3, 3], [2, 2], [1, 2]]) == 4\n assert candidate(row = 8,col = 8,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [2, 1], [2, 8], [3, 1], [3, 8], [4, 1], [4, 8], [5, 1], [5, 8], [6, 1], [6, 8], [7, 1], [7, 8], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 2], [3, 7], [4, 2], [4, 7], [5, 2], [5, 7], [6, 2], [6, 7], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [3, 3], [3, 5], [4, 3], [4, 5], [5, 3], [5, 5], [6, 3], [6, 5], [4, 4], [5, 4]]) == 7\n assert candidate(row = 4,col = 6,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 6], [3, 6], [4, 6], [4, 5], [4, 4], [4, 3], [4, 2], [4, 1], [3, 1], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 2], [3, 3], [3, 4], [3, 5]]) == 5\n assert candidate(row = 4,col = 6,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [4, 1], [4, 6], [4, 2], [4, 3], [4, 4], [4, 5]]) == 5\n assert candidate(row = 10,col = 5,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [9, 1], [9, 2], [9, 3], [9, 4], [9, 5], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5]]) == 4\n assert candidate(row = 9,col = 9,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [9, 1], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [9, 9], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [4, 5], [6, 5], [3, 5], [7, 5], [2, 5], [8, 5]]) == 8\n assert candidate(row = 8,col = 8,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [2, 1], [2, 8], [3, 1], [3, 8], [4, 1], [4, 8], [5, 1], [5, 8], [6, 1], [6, 8], [7, 1], [7, 8], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 2], [3, 7], [3, 3], [3, 6], [3, 4], [3, 5], [4, 2], [4, 7], [4, 3], [4, 6], [4, 4], [4, 5], [5, 2], [5, 7], [5, 3], [5, 6], [5, 4], [5, 5], [6, 2], [6, 7], [6, 3], [6, 6], [6, 4], [6, 5], [7, 2], [7, 7], [7, 3], [7, 6], [7, 4], [7, 5]]) == 7\n assert candidate(row = 4,col = 4,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 4], [3, 4], [4, 4], [4, 3], [4, 2], [4, 1], [3, 1], [2, 1], [2, 2], [2, 3], [3, 3], [3, 2], [3, 1]]) == 3\n assert candidate(row = 7,col = 7,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 1], [2, 7], [3, 1], [3, 7], [4, 1], [4, 7], [5, 1], [5, 7], [6, 1], [6, 7], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [3, 2], [3, 6], [3, 3], [3, 5], [3, 4], [4, 2], [4, 6], [4, 3], [4, 5], [4, 4], [5, 2], [5, 6], [5, 3], [5, 5], [5, 4], [6, 2], [6, 6], [6, 3], [6, 5], [6, 4]]) == 6\n assert candidate(row = 5,col = 5,cells = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [1, 4], [2, 4], [3, 4], [4, 4], [5, 4], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5]]) == 20\n assert candidate(row = 6,col = 6,cells = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [1, 4], [2, 4], [3, 4], [4, 4], [5, 4], [6, 4], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5]]) == 36\n assert candidate(row = 10,col = 10,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [2, 10], [3, 1], [3, 10], [4, 1], [4, 10], [5, 1], [5, 10], [6, 1], [6, 10], [7, 1], [7, 10], [8, 1], [8, 10], [9, 1], [9, 10], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [3, 8], [3, 9], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [4, 8], [4, 9], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [6, 8], [6, 9], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [7, 8], [7, 9], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [8, 9], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [9, 9]]) == 9\n assert candidate(row = 6,col = 5,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [6, 4], [6, 3], [6, 2], [6, 1], [5, 1], [5, 2], [5, 3], [5, 4], [4, 4], [4, 3], [4, 2], [4, 1], [3, 1], [3, 2], [3, 3], [3, 4], [2, 4], [2, 3], [2, 2], [2, 1]]) == 4\n assert candidate(row = 6,col = 5,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5]]) == 4\n assert candidate(row = 6,col = 6,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 1], [2, 6], [3, 1], [3, 6], [4, 1], [4, 6], [5, 1], [5, 6], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [2, 2], [2, 3], [2, 4], [2, 5], [3, 2], [3, 5], [4, 2], [4, 5], [5, 2], [5, 3], [5, 4], [3, 3], [3, 4], [4, 3], [4, 4]]) == 5\n assert candidate(row = 5,col = 4,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 1], [2, 2], [2, 3], [2, 4], [3, 1], [3, 2], [3, 3], [3, 4], [4, 1], [4, 2], [4, 3], [4, 4], [5, 1], [5, 2], [5, 3], [5, 4]]) == 3\n assert candidate(row = 5,col = 6,cells = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [2, 4], [3, 4], [4, 4], [5, 4], [1, 4], [1, 2], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [5, 2], [4, 2], [3, 2], [2, 2], [1, 5], [1, 6], [2, 6], [3, 6], [4, 6], [5, 5], [5, 6], [5, 6]]) == 21\n assert candidate(row = 8,col = 8,cells = [[1, 4], [1, 5], [2, 4], [2, 5], [3, 4], [3, 5], [4, 4], [4, 5], [5, 4], [5, 5], [6, 4], [6, 5], [7, 4], [7, 5], [8, 4], [8, 5], [1, 1], [1, 2], [1, 3], [1, 6], [1, 7], [1, 8], [2, 1], [2, 2], [2, 3], [2, 6], [2, 7], [2, 8], [3, 1], [3, 2], [3, 3], [3, 6], [3, 7], [3, 8], [4, 1], [4, 2], [4, 3], [4, 6], [4, 7], [4, 8], [5, 1], [5, 2], [5, 3], [5, 6], [5, 7], [5, 8], [6, 1], [6, 2], [6, 3], [6, 6], [6, 7], [6, 8], [7, 1], [7, 2], [7, 3], [7, 6], [7, 7], [7, 8], [8, 1], [8, 2], [8, 3], [8, 6], [8, 7], [8, 8]]) == 21\n assert candidate(row = 5,col = 10,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [2, 10], [3, 1], [3, 10], [4, 1], [4, 10], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 2], [3, 9], [3, 3], [3, 8], [3, 4], [3, 7], [3, 5], [3, 6], [4, 2], [4, 9], [4, 3], [4, 8], [4, 4], [4, 7], [4, 5], [4, 6]]) == 9\n assert candidate(row = 6,col = 6,cells = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 5], [6, 4], [5, 3], [4, 2], [3, 1], [2, 1], [1, 3], [1, 4], [1, 5], [1, 6], [2, 6], [3, 6], [4, 6], [5, 4], [5, 1], [6, 1], [6, 2], [6, 3]]) == 5\n assert candidate(row = 7,col = 7,cells = [[1, 1], [1, 7], [7, 1], [7, 7], [3, 3], [4, 4], [5, 5], [2, 2], [6, 6], [3, 2], [3, 4], [4, 3], [4, 5], [5, 4], [5, 6], [2, 3], [2, 4], [2, 5], [2, 6], [6, 2], [6, 3], [6, 4], [6, 5], [1, 3], [1, 4], [1, 5], [1, 6], [7, 3], [7, 4], [7, 5], [7, 6], [3, 1], [3, 5], [3, 6], [3, 7], [5, 1], [5, 2], [5, 3], [5, 7], [2, 1], [2, 7], [6, 1], [6, 7], [4, 1], [4, 2], [4, 6], [4, 7]]) == 8\n assert candidate(row = 7,col = 7,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 1], [2, 7], [3, 1], [3, 7], [4, 1], [4, 7], [5, 1], [5, 7], [6, 1], [6, 7], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [3, 2], [3, 6], [4, 2], [4, 6], [5, 2], [5, 6], [6, 2], [6, 3], [6, 4], [6, 5], [3, 3], [3, 5], [4, 3], [4, 5], [5, 3], [5, 5], [4, 4]]) == 6\n assert candidate(row = 5,col = 5,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 5], [3, 1], [3, 5], [4, 1], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [2, 2], [2, 3], [2, 4], [3, 2], [3, 4], [4, 2], [4, 3], [4, 4], [3, 3]]) == 4\n assert candidate(row = 7,col = 7,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 1], [2, 7], [3, 1], [3, 7], [4, 1], [4, 7], [5, 1], [5, 7], [6, 1], [6, 7], [7, 1], [7, 7], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6]]) == 6\n assert candidate(row = 6,col = 6,cells = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [1, 6], [2, 5], [3, 4], [4, 3], [5, 2], [6, 1], [1, 2], [2, 1], [1, 5], [2, 4], [1, 4], [2, 3], [1, 3], [2, 2], [1, 2], [1, 1]]) == 5\n assert candidate(row = 5,col = 5,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 5], [3, 1], [3, 5], [4, 1], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [2, 2], [2, 3], [2, 4], [3, 2], [3, 3], [3, 4], [4, 2], [4, 3], [4, 4]]) == 4\n assert candidate(row = 10,col = 10,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [2, 10], [3, 1], [3, 10], [4, 1], [4, 10], [5, 1], [5, 10], [6, 1], [6, 10], [7, 1], [7, 10], [8, 1], [8, 10], [9, 1], [9, 10], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [3, 2], [3, 9], [4, 2], [4, 9], [5, 2], [5, 9], [6, 2], [6, 9], [7, 2], [7, 9], [8, 2], [8, 9], [9, 2], [9, 3], [9, 4], [9, 5], [9, 6], [9, 7], [9, 8], [3, 3], [3, 5], [3, 7], [4, 3], [4, 5], [4, 7], [5, 3], [5, 5], [5, 7], [6, 3], [6, 5], [6, 7], [7, 3], [7, 5], [7, 7], [5, 4]]) == 9\n assert candidate(row = 7,col = 7,cells = [[1, 4], [2, 4], [3, 4], [4, 4], [5, 4], [6, 4], [7, 4], [1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [7, 3], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [6, 2], [7, 2], [1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 6], [7, 6], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [1, 7], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [7, 7]]) == 42\n assert candidate(row = 8,col = 8,cells = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [7, 8], [6, 8], [5, 8], [4, 8], [3, 8], [2, 8], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2], [7, 2], [6, 2], [5, 2], [4, 2], [3, 2], [2, 2], [2, 3], [3, 3], [4, 3], [5, 3], [6, 3], [7, 3], [7, 4], [6, 4], [5, 4], [4, 4], [3, 4], [2, 4], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [7, 6], [6, 6], [5, 6], [4, 6], [3, 6], [2, 6], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [7, 7]]) == 14\n assert candidate(row = 5,col = 5,cells = [[1, 3], [2, 3], [3, 3], [4, 3], [5, 3], [1, 2], [2, 2], [3, 2], [4, 2], [5, 2], [1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [1, 4], [2, 4], [3, 4], [4, 4], [5, 4], [1, 5], [2, 5], [3, 5], [4, 5], [5, 5]]) == 20\n assert candidate(row = 7,col = 7,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 1], [2, 7], [3, 1], [3, 7], [4, 1], [4, 7], [5, 1], [5, 7], [6, 1], [6, 7], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6]]) == 6\n assert candidate(row = 8,col = 8,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [2, 1], [2, 8], [3, 1], [3, 8], [4, 1], [4, 8], [5, 1], [5, 8], [6, 1], [6, 8], [7, 1], [7, 8], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 6], [8, 7], [8, 8], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7]]) == 7\n assert candidate(row = 6,col = 6,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [2, 1], [2, 6], [3, 1], [3, 6], [4, 1], [4, 6], [5, 1], [5, 6], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [2, 2], [2, 3], [2, 4], [2, 5], [3, 2], [3, 3], [3, 4], [3, 5], [4, 2], [4, 3], [4, 4], [4, 5], [5, 2], [5, 3], [5, 4], [5, 5]]) == 5\n assert candidate(row = 8,col = 8,cells = [[1, 1], [1, 8], [8, 1], [8, 8], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [3, 3], [4, 4], [5, 5], [6, 6], [3, 2], [3, 4], [4, 3], [4, 5], [5, 4], [5, 6], [6, 5], [6, 3], [3, 1], [3, 5], [3, 6], [3, 7], [5, 1], [5, 2], [5, 3], [5, 7], [2, 1], [2, 7], [6, 1], [6, 7], [4, 1], [4, 2], [4, 6], [4, 7]]) == 9\n assert candidate(row = 8,col = 8,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [2, 1], [2, 8], [3, 1], [3, 8], [4, 1], [4, 8], [5, 1], [5, 8], [6, 1], [6, 8], [7, 1], [7, 8], [8, 1], [8, 8], [8, 7], [8, 6], [8, 5], [8, 4], [8, 3], [8, 2], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7]]) == 7\n assert candidate(row = 10,col = 10,cells = [[1, 5], [1, 6], [2, 5], [2, 6], [3, 5], [3, 6], [4, 5], [4, 6], [5, 5], [5, 6], [6, 5], [6, 6], [7, 5], [7, 6], [8, 5], [8, 6], [9, 5], [9, 6], [10, 5], [10, 6], [1, 1], [1, 2], [1, 3], [1, 4], [1, 7], [1, 8], [1, 9], [1, 10], [2, 1], [2, 2], [2, 3], [2, 4], [2, 7], [2, 8], [2, 9], [2, 10], [3, 1], [3, 2], [3, 3], [3, 4], [3, 7], [3, 8], [3, 9], [3, 10], [4, 1], [4, 2], [4, 3], [4, 4], [4, 7], [4, 8], [4, 9], [4, 10], [5, 1], [5, 2], [5, 3], [5, 4], [5, 7], [5, 8], [5, 9], [5, 10], [6, 1], [6, 2], [6, 3], [6, 4], [6, 7], [6, 8], [6, 9], [6, 10], [7, 1], [7, 2], [7, 3], [7, 4], [7, 7], [7, 8], [7, 9], [7, 10], [8, 1], [8, 2], [8, 3], [8, 4], [8, 7], [8, 8], [8, 9], [8, 10], [9, 1], [9, 2], [9, 3], [9, 4], [9, 7], [9, 8], [9, 9], [9, 10], [10, 1], [10, 2], [10, 3], [10, 4], [10, 7], [10, 8], [10, 9], [10, 10]]) == 27\n assert candidate(row = 5,col = 4,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [2, 4], [3, 4], [4, 4], [5, 4], [5, 3], [5, 2], [5, 1], [4, 1], [3, 1], [2, 1], [2, 2], [2, 3], [3, 2], [3, 3], [4, 2], [4, 3]]) == 3\n assert candidate(row = 7,col = 7,cells = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [3, 6], [3, 7], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [4, 6], [4, 7], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [6, 1], [6, 2], [6, 3], [6, 4], [6, 5], [6, 6], [6, 7], [7, 1], [7, 2], [7, 3], [7, 4], [7, 5], [7, 6], [7, 7], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 6], [6, 5], [5, 5], [5, 4], [6, 4], [6, 3], [5, 3], [4, 3], [3, 3], [2, 3], [2, 4], [3, 4], [4, 4], [4, 3], [3, 3], [2, 2], [1, 2], [1, 4], [1, 6], [1, 7], [3, 1], [3, 2], [5, 1], [5, 2], [7, 1], [7, 2], [7, 3], [6, 3], [5, 3], [4, 2], [3, 2], [2, 2], [2, 6], [3, 6], [4, 6], [5, 6], [4, 5], [3, 4], [2, 4], [2, 5], [2, 7], [3, 7], [4, 7], [5, 7], [6, 7], [4, 6], [3, 5], [2, 5], [1, 5]]) == 6\n assert candidate(row = 4,col = 5,cells = [[1, 2], [1, 3], [1, 4], [2, 2], [2, 3], [2, 4], [3, 2], [3, 3], [3, 4], [4, 2], [4, 3], [4, 4], [1, 1], [2, 1], [3, 1], [4, 1], [1, 5], [2, 5], [3, 5], [4, 5]]) == 16\n"}, "metadata": {"canonical_parameter_names": ["row", "col", "cells"], "leetcode_dataset_entry_point": "Solution().latestDayToCross", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int latestDayToCross(int row, int col, vector>& cells) {", "container": "Solution", "callable": "latestDayToCross", "parameters": [{"name": "row", "type": "int"}, {"name": "col", "type": "int"}, {"name": "cells", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1971, "task_id": "find-if-path-exists-in-graph", "difficulty": "Easy", "problem_description": "There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [ui, vi] denotes a bi-directional edge between vertex ui and vertex vi. Every vertex pair is connected by at most one edge, and no vertex has an edge to itself.\nYou want to determine if there is a valid path that exists from vertex source to vertex destination.\nGiven edges and the integers n, source, and destination, return true if there is a valid path from source to destination, or false otherwise.\n \nExample 1:\n\n\nInput: n = 3, edges = [[0,1],[1,2],[2,0]], source = 0, destination = 2\nOutput: true\nExplanation: There are two paths from vertex 0 to vertex 2:\n- 0 → 1 → 2\n- 0 → 2\n\nExample 2:\n\n\nInput: n = 6, edges = [[0,1],[0,2],[3,5],[5,4],[4,3]], source = 0, destination = 5\nOutput: false\nExplanation: There is no path from vertex 0 to vertex 5.\n\n \nConstraints:\n\n1 <= n <= 2 * 105\n0 <= edges.length <= 2 * 105\nedges[i].length == 2\n0 <= ui, vi <= n - 1\nui != vi\n0 <= source, destination <= n - 1\nThere are no duplicate edges.\nThere are no self edges.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 1,edges = [],source = 0,destination = 0) == True\n assert candidate(n = 100,edges = [],source = 0,destination = 99) == False\n assert candidate(n = 25,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 0]],source = 15,destination = 10) == True\n assert candidate(n = 15,edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],source = 14,destination = 0) == True\n"}, "metadata": {"canonical_parameter_names": ["n", "edges", "source", "destination"], "leetcode_dataset_entry_point": "Solution().validPath", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool validPath(int n, vector>& edges, int source, int destination) {", "container": "Solution", "callable": "validPath", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "vector>&"}, {"name": "source", "type": "int"}, {"name": "destination", "type": "int"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1974, "task_id": "minimum-time-to-type-word-using-special-typewriter", "difficulty": "Easy", "problem_description": "There is a special typewriter with lowercase English letters 'a' to 'z' arranged in a circle with a pointer. A character can only be typed if the pointer is pointing to that character. The pointer is initially pointing to the character 'a'.\n\nEach second, you may perform one of the following operations:\n\nMove the pointer one character counterclockwise or clockwise.\nType the character the pointer is currently on.\n\nGiven a string word, return the minimum number of seconds to type out the characters in word.\n \nExample 1:\n\nInput: word = \"abc\"\nOutput: 5\nExplanation: \nThe characters are printed as follows:\n- Type the character 'a' in 1 second since the pointer is initially on 'a'.\n- Move the pointer clockwise to 'b' in 1 second.\n- Type the character 'b' in 1 second.\n- Move the pointer clockwise to 'c' in 1 second.\n- Type the character 'c' in 1 second.\n\nExample 2:\n\nInput: word = \"bza\"\nOutput: 7\nExplanation:\nThe characters are printed as follows:\n- Move the pointer clockwise to 'b' in 1 second.\n- Type the character 'b' in 1 second.\n- Move the pointer counterclockwise to 'z' in 2 seconds.\n- Type the character 'z' in 1 second.\n- Move the pointer clockwise to 'a' in 1 second.\n- Type the character 'a' in 1 second.\n\nExample 3:\n\nInput: word = \"zjpc\"\nOutput: 34\nExplanation:\nThe characters are printed as follows:\n- Move the pointer counterclockwise to 'z' in 1 second.\n- Type the character 'z' in 1 second.\n- Move the pointer clockwise to 'j' in 10 seconds.\n- Type the character 'j' in 1 second.\n- Move the pointer clockwise to 'p' in 6 seconds.\n- Type the character 'p' in 1 second.\n- Move the pointer counterclockwise to 'c' in 13 seconds.\n- Type the character 'c' in 1 second.\n\n \nConstraints:\n\n1 <= word.length <= 100\nword consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"aaabbbccc\") == 11\n assert candidate(word = \"zyxwvut\") == 14\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 29\n assert candidate(word = \"mnbvcxzlkjhgfdsapoiuytrewq\") == 178\n assert candidate(word = \"qpwoeirutyalskdjfhgzmxncbv\") == 191\n assert candidate(word = \"zjpc\") == 34\n assert candidate(word = \"abcdz\") == 12\n assert candidate(word = \"pqrstuvwxyzabcdefghijklmno\") == 62\n assert candidate(word = \"aaa\") == 3\n assert candidate(word = \"mnopqrstuvwxyzabcdefghijkl\") == 63\n assert candidate(word = \"z\") == 2\n assert candidate(word = \"aaaaaaaaaaaaaaaaaaaaaaaaaa\") == 26\n assert candidate(word = \"qpwoeirutyalskdjfhgzmxncbva\") == 197\n assert candidate(word = \"za\") == 4\n assert candidate(word = \"zzz\") == 4\n assert candidate(word = \"qpwoeirutyalskdjfhgzmxcvbn\") == 193\n assert candidate(word = \"mnonmonmomnonmon\") == 47\n assert candidate(word = \"a\") == 1\n assert candidate(word = \"bza\") == 7\n assert candidate(word = \"abc\") == 5\n assert candidate(word = \"az\") == 3\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcba\") == 52\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\") == 51\n assert candidate(word = \"abacabadabacaba\") == 37\n assert candidate(word = \"mnbvcxzlkjhgfdsapoiuytrewqmnbvcxzlkjhgfdsapoiuytrewq\") == 348\n assert candidate(word = \"adgjmpsvxzbehiklnortuwfyqc\") == 110\n assert candidate(word = \"bbaaccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 79\n assert candidate(word = \"aazzbbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 81\n assert candidate(word = \"mamamamamamamamamamamamamam\") == 351\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 47\n assert candidate(word = \"abcdezyxwvut\") == 27\n assert candidate(word = \"zaqwsxcderfvgytujnhytgfrdxcvbnmzaqwsxcderfv\") == 328\n assert candidate(word = \"mnopqrstuvmnopqrstuvmnopqrstuv\") == 87\n assert candidate(word = \"qwertyuioplkjhgfdsazxcvbnmnbvcxzlkjhgfdsapoiuytrewq\") == 323\n assert candidate(word = \"mamamamamamamamamamamamamamamamamamamamamamamamamamama\") == 702\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzzzzzzzzzzzzzzzzzzzz\") == 70\n assert candidate(word = \"qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm\") == 346\n assert candidate(word = \"lkjhgfdsapoiuytrewqzxcvbnm\") == 174\n assert candidate(word = \"mjmlkdjfhakjdhfkahdfkldshfklsjdhfkjd\") == 217\n assert candidate(word = \"aaaabbbbccccddddeeeeffffgggghhhhiiiiijjjjkkkkllllmmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxyyyyzzzz\") == 130\n assert candidate(word = \"aaaabbbbccccddddeeeeffffgggghhhhiiii\") == 44\n assert candidate(word = \"lkjhgfdsapoiuytrewqmasdfghjkl\") == 178\n assert candidate(word = \"qponmlkjihgfedcba\") == 43\n assert candidate(word = \"jklmnopqrstuvwxyzaaaazzzzz\") == 53\n assert candidate(word = \"wvutsrqponmlkjihgfedcba\") == 49\n assert candidate(word = \"wertyuioplkjhgfdsamnbvcxzabcd\") == 164\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 33\n assert candidate(word = \"abcdpqrsuvxyzefghijkmnotwxyz\") == 79\n assert candidate(word = \"qwertypasdfghjklzxcvbnmqwertypasdfghjklzxcvbnm\") == 312\n assert candidate(word = \"bdfhjlnprtvxz\") == 38\n assert candidate(word = \"qzcvmlkjhgfdsapoiuytrwer\") == 157\n assert candidate(word = \"mnopqrstuvwxynmlkjihgfedcbazyxw\") == 83\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyza\") == 53\n assert candidate(word = \"zyzzzzzzzzzzzzzzzzzzzzzzzzz\") == 30\n assert candidate(word = \"qwerasdfzxcv\") == 99\n assert candidate(word = \"abcdefghijklnmopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 104\n assert candidate(word = \"abcdpqrsuvxyzefghijkmnotw\") == 73\n assert candidate(word = \"dcbazyxwvutsrqponmlkjihgfedcba\") == 62\n assert candidate(word = \"fedcbaZYXWVUTSRQPONMLKJIHGFEDCBA\") == 74\n assert candidate(word = \"acdfghjklmnpqrstvwxyz\") == 46\n assert candidate(word = \"mnopqrstuzyxwvutsrqponmlkjihgfedcba\") == 85\n assert candidate(word = \"zxcvbnmlkjhgfdsapoiuytrewqzxcvbnmlkjhgfdsapoiuytrewq\") == 320\n assert candidate(word = \"lkjhgfdsapoiuytrewqzxcvbnmzxcvbnmlkjhgfdsapoiuytrewq\") == 342\n assert candidate(word = \"fedcbazyxwvutsrqponmlkjihg\") == 56\n assert candidate(word = \"aaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbb\") == 40\n assert candidate(word = \"mnopqrlkjihgfedcbazyxwvut\") == 66\n assert candidate(word = \"qpwoeirutyalskdjfhgzxcvbnm\") == 172\n assert candidate(word = \"mlkjihgfedcba\") == 37\n assert candidate(word = \"yzab\") == 9\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 102\n assert candidate(word = \"qzmlkihgfedcba\") == 58\n assert candidate(word = \"bcadefghijklmnopqrstuvwxyz\") == 55\n assert candidate(word = \"aaaaaaaaaaaabbbbbbbbccccccccdddddd\") == 37\n assert candidate(word = \"llllllllllllllllllllllllllllllllllllllllllllllllllllllll\") == 67\n assert candidate(word = \"nlbnlkbnlkbnlkbnlkbnlkbnlkbnlkbnlkbnlkbnlkbnlkbnlkbnlkb\") == 392\n assert candidate(word = \"lkjhgfdsazxcvbnmmnbvcxzlkjhgfdsa\") == 176\n assert candidate(word = \"mnopqrsvxyz\") == 36\n assert candidate(word = \"poiuytrewqlkjhgfdsamnbvcxzpoiuytrewqlkjhgfdsamnbvcxz\") == 341\n assert candidate(word = \"qwertypoiuytrewertyuiop\") == 178\n assert candidate(word = \"aaaaabbbbbcccccdddddeeeee\") == 29\n assert candidate(word = \"uqwertyuioplkjhgfdsamnbvcxz\") == 170\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == 104\n assert candidate(word = \"qrstuvzxcvbnmlkjhgfedcba\") == 88\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 35\n assert candidate(word = \"qwerasdfzxcvqwerasdfzxcvqwerasdfzxcv\") == 287\n assert candidate(word = \"lkmlkmlkmlkmlkmlkmlkmlkmlkmlkmlkmlkmlkmlkmlkmlkmlkmlkm\") == 136\n assert candidate(word = \"zazazazazazazazazazazazazazazaz\") == 62\n assert candidate(word = \"aazzzzyyyyxxxwwvvuuttrrssqqppoonnmmlkkjjiihhggffeeddaa\") == 82\n assert candidate(word = \"jqpnfjwmsvkmrekjijgqpxvukz\") == 175\n assert candidate(word = \"lkjhgfdsapoiuytrewqasdfghjklmnbvcxz\") == 212\n assert candidate(word = \"ejpmytlrzwhgodicuvnkxfsab\") == 190\n assert candidate(word = \"qwertyuioplkjhgfdsazxcvbnmqwertyuioplkjhgfdsazxcvbnm\") == 310\n assert candidate(word = \"qrstuvwxyzaeiou\") == 55\n assert candidate(word = \"aeiouyaeiouyaeiouyaeiouy\") == 126\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcbaa\") == 53\n assert candidate(word = \"poiuytrewqasdfghjklzxcvbnmpoiuytrewqasdfghjklzxcvbnmpoiuytrewq\") == 414\n assert candidate(word = \"abcdefghjklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 101\n assert candidate(word = \"qazwsxedcrfvtgbyhnujmikolpqwazxsedcrfvtgbyhnujmikolpqwaz\") == 361\n assert candidate(word = \"mzaixmsdcvnbmqwerty\") == 169\n assert candidate(word = \"zabcdefghijklmnopqrstuvwxyz\") == 54\n assert candidate(word = \"poiuytrewqlkjhgfdsamnbvcxz\") == 171\n assert candidate(word = \"zyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyx\") == 111\n assert candidate(word = \"aaaaaaaaaaaaaaaaaaaaaaaaaaab\") == 29\n assert candidate(word = \"pppppppppppppppppppppppppppp\") == 39\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 103\n assert candidate(word = \"abcdefghijkmnopqrstuvwxyz\") == 50\n assert candidate(word = \"azzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 58\n assert candidate(word = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\") == 97\n assert candidate(word = \"zaazaaazzaa\") == 17\n assert candidate(word = \"zzzaaazzzaaazzzaaazzzaaazzzaaazzz\") == 44\n assert candidate(word = \"zyxcbaqwertyuiopasdfghjklmnbvcxz\") == 181\n assert candidate(word = \"asdfghjklqwertyuiopzxcvbnm\") == 158\n assert candidate(word = \"pqrstuvwxyzyxwvutsrqponmlkjihgfedcba\") == 82\n assert candidate(word = \"zabcdefghijklmnopqrstuvwxyza\") == 56\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzza\") == 54\n assert candidate(word = \"tgbnhyujmkiolpvcxz\") == 125\n assert candidate(word = \"qwertyuiopasdfghjklzxcvbnm\") == 176\n assert candidate(word = \"qazwsxedcrfvtgbyhnujmikolp\") == 177\n assert candidate(word = \"zyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzyx\") == 118\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 77\n assert candidate(word = \"mnbvcxzlkjhgfdsapoiuytrewqasdfghjklpoiuytrewq\") == 295\n assert candidate(word = \"lkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkjlkj\") == 135\n assert candidate(word = \"abcabcabcabcabcabcabcabcabcabcabcabcabcabcabc\") == 103\n assert candidate(word = \"bcbcbcbcbcbcbcbcbcbcbcbcbcbcbcbc\") == 64\n assert candidate(word = \"mnopqrstuvwx\") == 35\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcbaqwertyuiop\") == 129\n assert candidate(word = \"abacabadabacabadabacaba\") == 59\n assert candidate(word = \"fedcbazyxwvutsrqponmlkjihgfedcba\") == 68\n assert candidate(word = \"zaqwsxcderfvgytuhjnmkiolp\") == 156\n"}, "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().minTimeToType", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minTimeToType(string word) {", "container": "Solution", "callable": "minTimeToType", "parameters": [{"name": "word", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1975, "task_id": "maximum-matrix-sum", "difficulty": "Medium", "problem_description": "You are given an n x n integer matrix. You can do the following operation any number of times:\n\nChoose any two adjacent elements of matrix and multiply each of them by -1.\n\nTwo elements are considered adjacent if and only if they share a border.\nYour goal is to maximize the summation of the matrix's elements. Return the maximum sum of the matrix's elements using the operation mentioned above.\n \nExample 1:\n\n\nInput: matrix = [[1,-1],[-1,1]]\nOutput: 4\nExplanation: We can follow the following steps to reach sum equals 4:\n- Multiply the 2 elements in the first row by -1.\n- Multiply the 2 elements in the first column by -1.\n\nExample 2:\n\n\nInput: matrix = [[1,2,3],[-1,-2,-3],[1,2,3]]\nOutput: 16\nExplanation: We can follow the following step to reach sum equals 16:\n- Multiply the 2 last elements in the second row by -1.\n\n \nConstraints:\n\nn == matrix.length == matrix[i].length\n2 <= n <= 250\n-105 <= matrix[i][j] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(matrix = [[-1, -2], [3, 4]]) == 10\n assert candidate(matrix = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]]) == 43\n assert candidate(matrix = [[1, 2], [3, -4]]) == 8\n assert candidate(matrix = [[1, 2, 3], [-1, -2, -3], [1, 2, 3]]) == 16\n assert candidate(matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(matrix = [[1, 2], [3, 4]]) == 10\n assert candidate(matrix = [[100000, -100000], [-100000, 100000]]) == 400000\n assert candidate(matrix = [[1, 0, -1], [0, 1, 0], [-1, 0, 1]]) == 5\n assert candidate(matrix = [[1, -2], [-3, 4]]) == 10\n assert candidate(matrix = [[1, -1], [-1, 1]]) == 4\n assert candidate(matrix = [[-10, -9, -8, -7, -6], [-5, -4, -3, -2, -1], [0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14]]) == 160\n assert candidate(matrix = [[-1, 2, -3, 4], [5, -6, 7, -8], [-9, 10, -11, 12], [13, -14, 15, -16]]) == 136\n assert candidate(matrix = [[-20, 15, 30], [5, -25, 40], [-10, 25, -35]]) == 205\n assert candidate(matrix = [[0, -100000, 100000, 0], [100000, 0, 0, -100000], [0, 100000, 0, -100000], [-100000, 0, 100000, 0]]) == 800000\n assert candidate(matrix = [[-1, -2, -3, -4], [5, 6, 7, 8], [-9, -10, -11, -12], [13, 14, 15, 16]]) == 136\n assert candidate(matrix = [[100000, 0, 0], [0, 0, 0], [0, 0, -100000]]) == 200000\n assert candidate(matrix = [[1, -1, 1, -1, 1], [-1, 1, -1, 1, -1], [1, -1, 1, -1, 1], [-1, 1, -1, 1, -1], [1, -1, 1, -1, 1]]) == 25\n assert candidate(matrix = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(matrix = [[-1, 0, 1], [0, -2, 0], [1, 0, -1]]) == 6\n assert candidate(matrix = [[-1, -1, -1], [-1, -1, -1], [-1, -1, -1]]) == 7\n assert candidate(matrix = [[1, -1], [-1, 1], [1, -1], [-1, 1]]) == 8\n assert candidate(matrix = [[10, 20, 30], [-40, -50, -60], [70, 80, 90]]) == 430\n assert candidate(matrix = [[-1, 2, -3, 4], [-5, 6, -7, 8], [9, -10, 11, -12], [13, -14, 15, -16]]) == 136\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, -25]]) == 47\n assert candidate(matrix = [[0, 0, 0], [0, -1, 0], [0, 0, 0]]) == 1\n assert candidate(matrix = [[-1, -1, -1], [-1, -1, -1], [-1, -1, -1]]) == 7\n assert candidate(matrix = [[1, -1, 1, -1, 1], [-1, 1, -1, 1, -1], [1, -1, 1, -1, 1], [-1, 1, -1, 1, -1], [1, -1, 1, -1, 1]]) == 25\n assert candidate(matrix = [[1000, -1000, 1000, -1000], [1000, -1000, 1000, -1000], [-1000, 1000, -1000, 1000], [-1000, 1000, -1000, 1000]]) == 16000\n assert candidate(matrix = [[1, -2, 3, -4, 5], [-6, 7, -8, 9, -10], [11, -12, 13, -14, 15], [-16, 17, -18, 19, -20], [21, -22, 23, -24, 25]]) == 325\n assert candidate(matrix = [[-1, -1, 1, 1], [1, 1, -1, -1], [-1, -1, 1, 1], [1, 1, -1, -1]]) == 16\n assert candidate(matrix = [[-1, 1, -1, 1], [-1, 1, -1, 1], [-1, 1, -1, 1], [-1, 1, -1, 1]]) == 16\n assert candidate(matrix = [[-1, 2, -3, 4, -5], [5, -4, 3, -2, 1], [-1, 2, -3, 4, -5], [5, -4, 3, -2, 1], [-1, 2, -3, 4, -5]]) == 73\n assert candidate(matrix = [[-1, -2, -3, -4], [-5, -6, -7, -8], [-9, -10, -11, -12], [-13, -14, -15, -16]]) == 136\n assert candidate(matrix = [[-10000, 20000, -30000], [40000, -50000, 60000], [-70000, 80000, -90000]]) == 430000\n assert candidate(matrix = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90], [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]]) == 5050\n assert candidate(matrix = [[100000, 0, -100000, 0], [0, 100000, 0, -100000], [-100000, 0, 100000, 0], [0, -100000, 0, 100000]]) == 800000\n assert candidate(matrix = [[-1, 2, 3], [4, -5, 6], [-7, 8, -9]]) == 45\n assert candidate(matrix = [[-100000, 100000, -100000], [100000, -100000, 100000], [-100000, 100000, -100000]]) == 700000\n assert candidate(matrix = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]) == 136\n assert candidate(matrix = [[-1, 2, -3], [4, -5, 6], [-7, 8, -9], [10, -11, 12], [-13, 14, -15]]) == 120\n assert candidate(matrix = [[-99999, 99999], [100000, -100000]]) == 399998\n assert candidate(matrix = [[-1, 2, -3, 4], [-5, 6, -7, 8], [-9, 10, -11, 12], [-13, 14, -15, 16]]) == 136\n assert candidate(matrix = [[-10, -20, -30, -40], [-50, -60, -70, -80], [-90, -100, -110, -120], [-130, -140, -150, -160]]) == 1360\n assert candidate(matrix = [[-100000, -100000], [-100000, -100000]]) == 400000\n assert candidate(matrix = [[-100000, 100000], [-100000, 100000], [100000, -100000], [100000, -100000]]) == 800000\n assert candidate(matrix = [[-5, 3, -2], [-1, 4, -6], [7, -8, 9]]) == 43\n assert candidate(matrix = [[-1, -2, -3], [-4, -5, -6], [-7, -8, -9]]) == 43\n assert candidate(matrix = [[1, 2, 3, 4, 5], [-6, -7, -8, -9, -10], [11, 12, 13, 14, 15], [-16, -17, -18, -19, -20], [21, 22, 23, 24, 25]]) == 325\n assert candidate(matrix = [[-50000, 50000, -60000], [60000, -70000, 70000], [-80000, 80000, -90000]]) == 510000\n assert candidate(matrix = [[-1, -2, -3, -4], [-5, -6, -7, -8], [-9, -10, -11, -12], [-13, -14, -15, -16]]) == 136\n assert candidate(matrix = [[1, -1, 2, -2, 3, -3], [4, -4, 5, -5, 6, -6], [7, -7, 8, -8, 9, -9]]) == 88\n assert candidate(matrix = [[-1, 2, -3, 4, -5], [6, -7, 8, -9, 10], [-11, 12, -13, 14, -15], [16, -17, 18, -19, 20], [-21, 22, -23, 24, -25]]) == 323\n assert candidate(matrix = [[-5, -4, -3, -2, -1], [0, 1, 2, 3, 4], [5, 6, 7, 8, 9], [10, 11, 12, 13, 14], [15, 16, 17, 18, 19]]) == 205\n assert candidate(matrix = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [-11, -12, -13, -14, -15], [-16, -17, -18, -19, -20], [21, 22, 23, 24, 25]]) == 325\n assert candidate(matrix = [[1, -2, 3, -4, 5], [-6, 7, -8, 9, -10], [11, -12, 13, -14, 15], [-16, 17, -18, 19, -20], [21, -22, 23, -24, 25]]) == 325\n assert candidate(matrix = [[-99999, 99998, -99997, 99996], [99995, -99994, 99993, -99992], [-99991, 99990, -99989, 99988], [99987, -99986, 99985, -99984]]) == 1599864\n assert candidate(matrix = [[-10, -20, -30], [-40, -50, -60], [-70, -80, -90]]) == 430\n assert candidate(matrix = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(matrix = [[-10, -20, -30], [-40, -50, -60], [-70, -80, -90]]) == 430\n assert candidate(matrix = [[-1, 0, 1, 0, -1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [-1, 0, 1, 0, -1]]) == 13\n assert candidate(matrix = [[-99999, 100000, 99999], [-100000, -99999, 100000], [99999, -100000, -99999]]) == 699997\n assert candidate(matrix = [[1, -1, 1, -1], [1, -1, 1, -1], [-1, 1, -1, 1], [-1, 1, -1, 1]]) == 16\n assert candidate(matrix = [[10, 20, 30], [40, 50, 60], [70, 80, 90]]) == 450\n assert candidate(matrix = [[-5, -4, -3, -2, -1], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]) == 223\n assert candidate(matrix = [[-1, -1, -1], [1, 1, 1], [-1, -1, -1]]) == 9\n assert candidate(matrix = [[-1, 0, 1], [-2, 0, 2], [-3, 0, 3]]) == 12\n assert candidate(matrix = [[-1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1], [-1, 1, -1, 1, -1, 1]]) == 36\n assert candidate(matrix = [[-10000, 10000, -10000, 10000, -10000], [10000, -10000, 10000, -10000, 10000], [-10000, 10000, -10000, 10000, -10000], [10000, -10000, 10000, -10000, 10000], [-10000, 10000, -10000, 10000, -10000]]) == 230000\n assert candidate(matrix = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 25\n assert candidate(matrix = [[1, -1, 1, -1], [-1, 1, -1, 1], [1, -1, 1, -1], [-1, 1, -1, 1]]) == 16\n assert candidate(matrix = [[-100000, 100000, -100000, 100000], [100000, -100000, 100000, -100000], [-100000, 100000, -100000, 100000], [100000, -100000, 100000, -100000]]) == 1600000\n assert candidate(matrix = [[100, -100, 200], [-300, 400, -500], [600, -700, 800]]) == 3700\n assert candidate(matrix = [[1, -2, 3, -4, 5], [6, -7, 8, -9, 10], [11, -12, 13, -14, 15], [16, -17, 18, -19, 20], [21, -22, 23, -24, 25]]) == 325\n assert candidate(matrix = [[-2, 3, -4], [-1, -2, -3], [4, 5, -6]]) == 30\n assert candidate(matrix = [[0, 1, -1], [1, 0, -1], [-1, 1, 0]]) == 6\n assert candidate(matrix = [[100000, -100000, 100000], [-100000, 100000, -100000], [100000, -100000, 100000]]) == 900000\n assert candidate(matrix = [[-5, -4, 3], [2, 1, 0], [-1, 6, -7]]) == 29\n assert candidate(matrix = [[100000, 0, -100000], [-100000, 0, 100000], [0, 100000, 0]]) == 500000\n assert candidate(matrix = [[1, -1, 2, -2], [3, -3, 4, -4], [5, -5, 6, -6], [7, -7, 8, -8]]) == 72\n assert candidate(matrix = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == 1\n assert candidate(matrix = [[-1, 2, -3, 4], [-5, 6, -7, 8], [-9, 10, -11, 12], [13, -14, 15, -16]]) == 136\n assert candidate(matrix = [[100, -200, 300, -400], [500, -600, 700, -800], [900, -1000, 1100, -1200], [-1300, 1400, -1500, 1600]]) == 13600\n assert candidate(matrix = [[-1, 2, -3, 4, -5], [6, -7, 8, -9, 10], [-11, 12, -13, 14, -15], [16, -17, 18, -19, 20], [-21, 22, -23, 24, -25]]) == 323\n assert candidate(matrix = [[100000, 100000], [100000, 100000]]) == 400000\n assert candidate(matrix = [[-1, 2, -3, 4], [-5, 6, -7, 8], [9, -10, 11, -12], [-13, 14, -15, 16]]) == 136\n"}, "metadata": {"canonical_parameter_names": ["matrix"], "leetcode_dataset_entry_point": "Solution().maxMatrixSum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long maxMatrixSum(vector>& matrix) {", "container": "Solution", "callable": "maxMatrixSum", "parameters": [{"name": "matrix", "type": "vector>&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1976, "task_id": "number-of-ways-to-arrive-at-destination", "difficulty": "Medium", "problem_description": "You are in a city that consists of n intersections numbered from 0 to n - 1 with bi-directional roads between some intersections. The inputs are generated such that you can reach any intersection from any other intersection and that there is at most one road between any two intersections.\nYou are given an integer n and a 2D integer array roads where roads[i] = [ui, vi, timei] means that there is a road between intersections ui and vi that takes timei minutes to travel. You want to know in how many ways you can travel from intersection 0 to intersection n - 1 in the shortest amount of time.\nReturn the number of ways you can arrive at your destination in the shortest amount of time. Since the answer may be large, return it modulo 109 + 7.\n \nExample 1:\n\n\nInput: n = 7, roads = [[0,6,7],[0,1,2],[1,2,3],[1,3,3],[6,3,3],[3,5,1],[6,5,1],[2,5,1],[0,4,5],[4,6,2]]\nOutput: 4\nExplanation: The shortest amount of time it takes to go from intersection 0 to intersection 6 is 7 minutes.\nThe four ways to get there in 7 minutes are:\n- 0 ➝ 6\n- 0 ➝ 4 ➝ 6\n- 0 ➝ 1 ➝ 2 ➝ 5 ➝ 6\n- 0 ➝ 1 ➝ 3 ➝ 5 ➝ 6\n\nExample 2:\n\nInput: n = 2, roads = [[1,0,10]]\nOutput: 1\nExplanation: There is only one way to go from intersection 0 to intersection 1, and it takes 10 minutes.\n\n \nConstraints:\n\n1 <= n <= 200\nn - 1 <= roads.length <= n * (n - 1) / 2\nroads[i].length == 3\n0 <= ui, vi <= n - 1\n1 <= timei <= 109\nui != vi\nThere is at most one road connecting any two intersections.\nYou can reach any intersection from any other intersection.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,roads = [[0, 1, 1], [0, 2, 4], [0, 3, 3], [0, 4, 10], [1, 2, 2], [1, 3, 4], [1, 4, 6], [2, 3, 3], [2, 4, 5], [3, 4, 1]]) == 1\n assert candidate(n = 4,roads = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5]]) == 1\n assert candidate(n = 3,roads = [[0, 1, 1], [1, 2, 1], [0, 2, 2]]) == 2\n assert candidate(n = 5,roads = [[0, 1, 2], [0, 4, 8], [1, 2, 6], [1, 4, 2], [2, 3, 3], [3, 4, 2]]) == 1\n assert candidate(n = 5,roads = [[0, 1, 1], [0, 2, 2], [1, 3, 1], [1, 4, 3], [2, 3, 3], [2, 4, 1], [3, 4, 1]]) == 2\n assert candidate(n = 6,roads = [[0, 1, 5], [1, 2, 3], [0, 2, 4], [2, 3, 1], [2, 4, 2], [3, 5, 1], [4, 5, 2]]) == 1\n assert candidate(n = 4,roads = [[0, 1, 1], [0, 2, 1], [1, 2, 1], [1, 3, 1], [2, 3, 1]]) == 2\n assert candidate(n = 7,roads = [[0, 6, 7], [0, 1, 2], [1, 2, 3], [1, 3, 3], [6, 3, 3], [3, 5, 1], [6, 5, 1], [2, 5, 1], [0, 4, 5], [4, 6, 2]]) == 4\n assert candidate(n = 5,roads = [[0, 1, 2], [0, 2, 4], [1, 2, 1], [1, 3, 2], [2, 3, 3], [3, 4, 1]]) == 1\n assert candidate(n = 5,roads = [[0, 1, 1], [0, 2, 1], [1, 2, 1], [1, 3, 1], [2, 4, 1], [3, 4, 1]]) == 1\n assert candidate(n = 4,roads = [[0, 1, 2], [0, 2, 4], [1, 2, 1], [1, 3, 1], [2, 3, 2]]) == 1\n assert candidate(n = 3,roads = [[0, 1, 2], [1, 2, 2], [0, 2, 3]]) == 1\n assert candidate(n = 6,roads = [[0, 1, 4], [1, 2, 4], [2, 3, 3], [3, 4, 2], [4, 5, 2]]) == 1\n assert candidate(n = 2,roads = [[1, 0, 10]]) == 1\n assert candidate(n = 4,roads = [[0, 1, 1], [0, 2, 5], [1, 2, 1], [2, 3, 1]]) == 1\n assert candidate(n = 8,roads = [[0, 1, 5], [0, 2, 3], [1, 3, 2], [1, 4, 4], [2, 3, 1], [2, 4, 2], [3, 5, 3], [3, 6, 2], [4, 5, 4], [4, 6, 1], [5, 7, 2], [6, 7, 1]]) == 2\n assert candidate(n = 8,roads = [[0, 1, 4], [1, 2, 5], [2, 3, 1], [3, 4, 2], [4, 5, 3], [5, 6, 4], [6, 7, 5], [0, 7, 20], [0, 2, 10], [1, 6, 15], [2, 5, 8], [3, 4, 7]]) == 1\n assert candidate(n = 15,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [0, 14, 70], [1, 13, 69], [2, 12, 68], [3, 11, 67], [4, 10, 66], [5, 9, 65], [6, 8, 64]]) == 1\n assert candidate(n = 15,roads = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 2], [2, 3, 3], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 1], [7, 8, 2], [8, 9, 1], [9, 10, 2], [10, 11, 3], [11, 12, 1], [12, 13, 2], [13, 14, 1]]) == 1\n assert candidate(n = 8,roads = [[0, 1, 3], [0, 2, 5], [1, 2, 2], [1, 3, 4], [1, 4, 1], [2, 5, 3], [3, 4, 2], [4, 5, 6], [4, 6, 4], [4, 7, 2], [5, 7, 5], [6, 7, 1]]) == 1\n assert candidate(n = 8,roads = [[0, 1, 1], [0, 2, 1], [1, 3, 2], [1, 4, 2], [2, 5, 3], [2, 6, 3], [3, 7, 4], [4, 7, 4], [5, 6, 1], [5, 7, 2], [6, 7, 2]]) == 2\n assert candidate(n = 20,roads = [[0, 1, 2], [0, 2, 10], [0, 3, 5], [1, 4, 1], [1, 5, 3], [1, 6, 4], [2, 5, 2], [2, 7, 6], [3, 6, 5], [3, 8, 7], [4, 9, 1], [4, 10, 2], [5, 9, 4], [5, 10, 3], [5, 11, 1], [6, 11, 3], [7, 11, 2], [7, 12, 10], [8, 12, 5], [8, 13, 3], [9, 13, 4], [9, 14, 6], [10, 14, 5], [11, 14, 3], [11, 15, 2], [11, 16, 1], [12, 16, 2], [12, 17, 10], [13, 17, 5], [14, 17, 3], [14, 18, 2], [14, 19, 1], [15, 18, 2], [16, 19, 3], [17, 19, 1]]) == 2\n assert candidate(n = 6,roads = [[0, 1, 10], [0, 2, 10], [1, 3, 5], [1, 4, 2], [2, 3, 3], [2, 4, 4], [3, 5, 8], [4, 5, 1]]) == 1\n assert candidate(n = 10,roads = [[0, 1, 5], [0, 2, 3], [1, 3, 2], [1, 4, 6], [2, 4, 4], [2, 5, 1], [3, 6, 3], [3, 7, 2], [4, 7, 5], [4, 8, 3], [5, 8, 2], [5, 9, 4], [6, 9, 1], [7, 9, 3]]) == 1\n assert candidate(n = 12,roads = [[0, 1, 6], [0, 2, 3], [1, 3, 4], [1, 4, 5], [2, 4, 2], [2, 5, 1], [3, 6, 3], [3, 7, 2], [4, 7, 1], [4, 8, 4], [5, 8, 3], [5, 9, 2], [6, 10, 1], [7, 10, 2], [7, 11, 3], [8, 11, 1], [9, 11, 2]]) == 2\n assert candidate(n = 20,roads = [[0, 1, 1], [0, 2, 2], [1, 2, 1], [1, 3, 2], [1, 4, 3], [2, 3, 1], [2, 4, 2], [2, 5, 3], [3, 4, 1], [3, 5, 2], [3, 6, 3], [4, 5, 1], [4, 6, 2], [4, 7, 3], [5, 6, 1], [5, 7, 2], [5, 8, 3], [6, 7, 1], [6, 8, 2], [6, 9, 3], [7, 8, 1], [7, 9, 2], [7, 10, 3], [8, 9, 1], [8, 10, 2], [8, 11, 3], [9, 10, 1], [9, 11, 2], [9, 12, 3], [10, 11, 1], [10, 12, 2], [10, 13, 3], [11, 12, 1], [11, 13, 2], [11, 14, 3], [12, 13, 1], [12, 14, 2], [12, 15, 3], [13, 14, 1], [13, 15, 2], [13, 16, 3], [14, 15, 1], [14, 16, 2], [14, 17, 3], [15, 16, 1], [15, 17, 2], [15, 18, 3], [16, 17, 1], [16, 18, 2], [16, 19, 3], [17, 18, 1], [17, 19, 2], [18, 19, 1]]) == 55403\n assert candidate(n = 15,roads = [[0, 1, 5], [0, 2, 5], [1, 3, 4], [1, 4, 4], [2, 5, 5], [2, 6, 5], [3, 7, 3], [3, 8, 3], [4, 9, 4], [4, 10, 4], [5, 11, 5], [5, 12, 5], [6, 13, 6], [6, 14, 6], [7, 11, 2], [8, 12, 2], [9, 13, 3], [10, 14, 3], [11, 14, 1], [12, 13, 1]]) == 1\n assert candidate(n = 10,roads = [[0, 1, 2], [0, 2, 4], [1, 2, 1], [1, 3, 2], [2, 3, 3], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 4], [7, 8, 5], [8, 9, 6], [0, 3, 5], [1, 4, 3], [2, 5, 6], [3, 6, 7], [4, 7, 8], [5, 8, 9], [6, 9, 10]]) == 2\n assert candidate(n = 15,roads = [[0, 1, 5], [0, 2, 10], [1, 2, 3], [1, 3, 8], [2, 3, 6], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 4], [7, 8, 5], [8, 9, 6], [9, 10, 7], [10, 11, 8], [11, 12, 9], [12, 13, 10], [13, 14, 11], [0, 5, 7], [1, 6, 4], [2, 7, 5], [3, 8, 6], [4, 9, 7], [5, 10, 8], [6, 11, 9], [7, 12, 10], [8, 13, 11], [9, 14, 12]]) == 1\n assert candidate(n = 10,roads = [[0, 1, 1], [0, 2, 2], [1, 2, 2], [1, 3, 3], [2, 4, 4], [3, 4, 3], [3, 5, 5], [4, 6, 6], [5, 7, 7], [6, 8, 8], [7, 8, 9], [8, 9, 10], [0, 3, 4], [1, 4, 5], [2, 5, 6], [3, 6, 7], [4, 7, 8], [5, 8, 9], [6, 9, 10]]) == 2\n assert candidate(n = 9,roads = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 4, 1], [1, 5, 2], [2, 5, 3], [2, 6, 2], [3, 6, 1], [3, 7, 2], [4, 8, 1], [5, 8, 2], [6, 8, 3], [7, 8, 4]]) == 1\n assert candidate(n = 10,roads = [[0, 1, 5], [0, 2, 3], [1, 2, 2], [1, 3, 10], [2, 3, 6], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 4], [7, 8, 5], [8, 9, 6], [0, 9, 15], [1, 8, 8], [2, 7, 7], [3, 6, 5]]) == 1\n assert candidate(n = 8,roads = [[0, 1, 1], [0, 2, 1], [1, 3, 2], [2, 3, 2], [1, 4, 1], [2, 5, 1], [3, 6, 3], [4, 6, 3], [5, 7, 4], [6, 7, 4], [1, 5, 2], [2, 4, 2], [0, 3, 3], [0, 4, 3], [1, 2, 3], [3, 5, 4], [4, 5, 4]]) == 1\n assert candidate(n = 20,roads = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5], [9, 10, 5], [10, 11, 5], [11, 12, 5], [12, 13, 5], [13, 14, 5], [14, 15, 5], [15, 16, 5], [16, 17, 5], [17, 18, 5], [18, 19, 5], [0, 19, 100], [1, 18, 99], [2, 17, 98], [3, 16, 97], [4, 15, 96], [5, 14, 95], [6, 13, 94], [7, 12, 93], [8, 11, 92], [9, 10, 91]]) == 1\n assert candidate(n = 12,roads = [[0, 1, 5], [0, 2, 3], [1, 2, 1], [1, 3, 2], [2, 3, 3], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 1], [7, 8, 2], [8, 9, 1], [9, 10, 2], [10, 11, 3], [11, 4, 1]]) == 2\n assert candidate(n = 10,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [0, 9, 45], [1, 8, 35], [2, 7, 25], [3, 6, 15], [4, 5, 5]]) == 5\n assert candidate(n = 10,roads = [[0, 1, 4], [0, 2, 3], [1, 3, 2], [1, 4, 1], [2, 3, 5], [2, 4, 2], [3, 5, 1], [4, 5, 3], [5, 6, 2], [5, 7, 1], [6, 8, 2], [7, 8, 1], [8, 9, 3]]) == 1\n assert candidate(n = 10,roads = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [0, 9, 18]]) == 1\n assert candidate(n = 15,roads = [[0, 1, 5], [0, 2, 4], [1, 2, 3], [1, 3, 2], [2, 3, 1], [2, 4, 6], [3, 4, 5], [3, 5, 7], [3, 6, 2], [4, 5, 4], [4, 6, 3], [4, 7, 10], [5, 6, 6], [5, 7, 8], [5, 8, 4], [6, 7, 7], [6, 8, 9], [7, 8, 11], [7, 9, 6], [8, 9, 3], [9, 10, 2], [9, 11, 5], [9, 12, 7], [10, 11, 3], [10, 12, 6], [11, 12, 4], [11, 13, 8], [11, 14, 2], [12, 13, 5], [12, 14, 9], [13, 14, 1]]) == 4\n assert candidate(n = 8,roads = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [0, 7, 70], [1, 6, 60], [2, 5, 50], [3, 4, 40]]) == 1\n assert candidate(n = 15,roads = [[0, 1, 2], [0, 2, 3], [1, 2, 4], [1, 3, 5], [2, 3, 6], [2, 4, 7], [3, 4, 8], [3, 5, 9], [4, 5, 10], [5, 6, 11], [6, 7, 12], [7, 8, 13], [8, 9, 14], [9, 10, 15], [10, 11, 16], [11, 12, 17], [12, 13, 18], [13, 14, 19], [0, 14, 20], [1, 13, 21], [2, 12, 22], [3, 11, 23], [4, 10, 24], [5, 9, 25], [6, 8, 26], [7, 9, 27], [8, 11, 28], [9, 12, 29], [10, 13, 30], [11, 14, 31]]) == 1\n assert candidate(n = 12,roads = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 4], [1, 4, 5], [2, 5, 2], [2, 6, 3], [3, 6, 1], [3, 7, 2], [4, 7, 3], [4, 8, 4], [5, 8, 5], [5, 9, 6], [6, 9, 7], [6, 10, 8], [7, 10, 9], [7, 11, 10], [8, 11, 11], [9, 11, 12]]) == 1\n assert candidate(n = 10,roads = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 2], [2, 3, 3], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 1], [7, 8, 2], [8, 9, 1]]) == 1\n assert candidate(n = 9,roads = [[0, 1, 2], [0, 2, 3], [1, 3, 4], [1, 4, 5], [2, 5, 6], [2, 6, 7], [3, 7, 8], [3, 8, 9], [4, 5, 10], [4, 6, 11], [5, 7, 12], [5, 8, 13], [6, 7, 14], [6, 8, 15], [7, 8, 16]]) == 1\n assert candidate(n = 15,roads = [[0, 1, 2], [0, 2, 3], [0, 3, 4], [1, 4, 1], [1, 5, 2], [2, 5, 3], [2, 6, 1], [3, 6, 2], [3, 7, 3], [4, 8, 1], [5, 8, 2], [5, 9, 3], [6, 9, 1], [6, 10, 2], [7, 10, 3], [8, 11, 1], [9, 11, 2], [9, 12, 3], [10, 12, 1], [10, 13, 2], [11, 14, 1], [12, 14, 2], [13, 14, 3]]) == 1\n assert candidate(n = 15,roads = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [6, 7, 70], [7, 8, 80], [8, 9, 90], [9, 10, 100], [10, 11, 110], [11, 12, 120], [12, 13, 130], [13, 14, 140], [0, 14, 900], [1, 13, 800], [2, 12, 700], [3, 11, 600], [4, 10, 500], [5, 9, 400], [6, 8, 300], [7, 9, 200], [8, 10, 100]]) == 1\n assert candidate(n = 12,roads = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5], [2, 4, 6], [3, 4, 7], [3, 5, 8], [4, 5, 9], [4, 6, 10], [5, 6, 11], [5, 7, 12], [6, 7, 13], [6, 8, 14], [7, 8, 15], [7, 9, 16], [8, 9, 17], [8, 10, 18], [9, 10, 19], [9, 11, 20], [10, 11, 21], [0, 7, 22], [1, 8, 23], [2, 9, 24], [3, 10, 25], [4, 11, 26], [5, 0, 27], [6, 1, 28], [7, 2, 29], [8, 3, 30], [9, 4, 31], [10, 5, 32], [11, 6, 33]]) == 1\n assert candidate(n = 20,roads = [[0, 1, 5], [1, 2, 4], [2, 3, 3], [3, 4, 2], [4, 5, 1], [5, 6, 1], [6, 7, 2], [7, 8, 3], [8, 9, 4], [9, 10, 5], [10, 11, 6], [11, 12, 7], [12, 13, 8], [13, 14, 9], [14, 15, 10], [15, 16, 11], [16, 17, 12], [17, 18, 13], [18, 19, 14], [0, 19, 95], [1, 18, 90], [2, 17, 85], [3, 16, 80], [4, 15, 75], [5, 14, 70], [6, 13, 65], [7, 12, 60], [8, 11, 55], [9, 10, 50]]) == 1\n assert candidate(n = 20,roads = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5], [2, 4, 6], [3, 4, 7], [3, 5, 8], [4, 5, 9], [4, 6, 10], [5, 6, 11], [5, 7, 12], [6, 7, 13], [6, 8, 14], [7, 8, 15], [7, 9, 16], [8, 9, 17], [8, 10, 18], [9, 10, 19], [9, 11, 20], [10, 11, 21], [10, 12, 22], [11, 12, 23], [11, 13, 24], [12, 13, 25], [12, 14, 26], [13, 14, 27], [13, 15, 28], [14, 15, 29], [14, 16, 30], [15, 16, 31], [15, 17, 32], [16, 17, 33], [16, 18, 34], [17, 18, 35], [17, 19, 36], [18, 19, 37]]) == 1\n assert candidate(n = 10,roads = [[0, 1, 2], [0, 2, 5], [1, 2, 1], [1, 3, 3], [2, 4, 2], [3, 4, 2], [3, 5, 1], [4, 5, 1], [4, 6, 4], [5, 6, 3], [5, 7, 5], [6, 7, 2], [6, 8, 6], [7, 8, 1], [7, 9, 3], [8, 9, 2]]) == 10\n assert candidate(n = 8,roads = [[0, 1, 3], [0, 2, 5], [1, 2, 2], [1, 3, 4], [2, 3, 1], [2, 4, 6], [3, 4, 3], [3, 5, 7], [4, 5, 2], [4, 6, 8], [5, 6, 1], [5, 7, 5], [6, 7, 4]]) == 4\n assert candidate(n = 12,roads = [[0, 1, 2], [0, 3, 1], [1, 2, 3], [1, 3, 2], [2, 4, 1], [2, 5, 2], [3, 4, 4], [3, 5, 3], [4, 6, 1], [4, 7, 2], [5, 6, 2], [5, 7, 3], [6, 8, 1], [6, 9, 2], [7, 8, 3], [7, 9, 4], [8, 10, 1], [8, 11, 2], [9, 10, 3], [9, 11, 4]]) == 2\n assert candidate(n = 18,roads = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5], [2, 4, 6], [3, 4, 7], [3, 5, 8], [4, 5, 9], [4, 6, 10], [5, 6, 11], [5, 7, 12], [6, 7, 13], [6, 8, 14], [7, 8, 15], [7, 9, 16], [8, 9, 17], [8, 10, 18], [9, 10, 19], [9, 11, 20], [10, 11, 21], [10, 12, 22], [11, 12, 23], [11, 13, 24], [12, 13, 25], [12, 14, 26], [13, 14, 27], [13, 15, 28], [14, 15, 29], [14, 16, 30], [15, 16, 31], [15, 17, 32], [16, 17, 33], [0, 13, 34], [1, 14, 35], [2, 15, 36], [3, 16, 37], [4, 17, 38], [5, 0, 39], [6, 1, 40], [7, 2, 41], [8, 3, 42], [9, 4, 43], [10, 5, 44], [11, 6, 45], [12, 7, 46], [13, 8, 47], [14, 9, 48], [15, 10, 49], [16, 11, 50], [17, 12, 51]]) == 1\n assert candidate(n = 10,roads = [[0, 1, 1], [0, 2, 4], [1, 3, 2], [1, 4, 5], [2, 3, 1], [2, 5, 6], [3, 4, 3], [3, 6, 7], [4, 5, 2], [4, 7, 8], [5, 6, 3], [5, 8, 4], [6, 7, 1], [6, 9, 5], [7, 8, 2], [8, 9, 3]]) == 3\n assert candidate(n = 12,roads = [[0, 1, 2], [0, 2, 5], [0, 3, 10], [1, 4, 1], [1, 5, 3], [1, 6, 4], [2, 5, 2], [2, 7, 6], [3, 6, 5], [3, 8, 7], [4, 9, 1], [4, 10, 2], [5, 9, 4], [5, 10, 3], [5, 11, 1], [6, 11, 3], [7, 11, 2], [8, 11, 5], [9, 11, 2], [10, 11, 4]]) == 2\n assert candidate(n = 10,roads = [[0, 1, 1], [0, 3, 5], [1, 2, 2], [1, 3, 4], [2, 3, 1], [3, 4, 1], [4, 5, 2], [5, 6, 1], [6, 7, 2], [7, 8, 1], [8, 9, 2], [0, 2, 3], [2, 4, 2], [4, 6, 1], [6, 8, 2], [1, 5, 3], [5, 7, 1], [7, 9, 2]]) == 1\n assert candidate(n = 15,roads = [[0, 1, 10], [0, 2, 15], [1, 2, 5], [1, 3, 6], [1, 4, 8], [2, 3, 3], [2, 4, 7], [3, 4, 1], [3, 5, 2], [3, 6, 4], [4, 5, 9], [4, 6, 6], [5, 7, 5], [5, 8, 1], [6, 8, 3], [6, 9, 7], [7, 10, 4], [8, 10, 2], [8, 11, 6], [9, 11, 5], [10, 12, 3], [10, 13, 8], [11, 13, 1], [11, 14, 9], [12, 14, 2], [13, 14, 7]]) == 1\n assert candidate(n = 18,roads = [[0, 1, 10], [0, 2, 5], [1, 2, 1], [1, 3, 2], [2, 3, 3], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 1], [7, 8, 2], [8, 9, 1], [9, 10, 2], [10, 11, 3], [11, 12, 1], [12, 13, 2], [13, 14, 1], [14, 15, 2], [15, 16, 3], [16, 17, 1]]) == 2\n assert candidate(n = 15,roads = [[0, 1, 10], [0, 2, 15], [0, 3, 5], [1, 2, 7], [1, 4, 4], [1, 5, 3], [2, 5, 2], [2, 6, 10], [3, 5, 6], [3, 7, 2], [4, 6, 5], [4, 8, 3], [5, 9, 1], [5, 10, 2], [6, 10, 4], [6, 11, 8], [7, 11, 2], [7, 12, 10], [8, 12, 5], [8, 13, 3], [9, 13, 4], [9, 14, 6], [10, 14, 5], [11, 14, 3]]) == 1\n assert candidate(n = 12,roads = [[0, 1, 5], [0, 2, 3], [0, 3, 4], [1, 2, 2], [1, 3, 10], [2, 3, 6], [3, 4, 1], [4, 5, 2], [5, 6, 3], [6, 7, 4], [7, 8, 5], [8, 9, 6], [9, 10, 7], [10, 11, 8], [0, 11, 60], [1, 10, 59], [2, 9, 58], [3, 8, 57], [4, 7, 56], [5, 6, 55]]) == 1\n assert candidate(n = 8,roads = [[0, 1, 1], [0, 2, 2], [1, 2, 3], [1, 3, 4], [2, 3, 5], [2, 4, 6], [3, 4, 7], [3, 5, 8], [4, 5, 9], [4, 6, 10], [5, 6, 11], [5, 7, 12], [6, 7, 13], [0, 5, 14], [1, 6, 15], [2, 7, 16], [0, 3, 17], [1, 4, 18], [2, 5, 19], [3, 6, 20], [4, 7, 21]]) == 1\n assert candidate(n = 18,roads = [[0, 1, 2], [0, 2, 10], [0, 3, 5], [1, 4, 1], [1, 5, 3], [1, 6, 4], [2, 5, 2], [2, 7, 6], [3, 6, 5], [3, 8, 7], [4, 9, 1], [4, 10, 2], [5, 9, 4], [5, 10, 3], [5, 11, 1], [6, 11, 3], [7, 11, 2], [7, 12, 10], [8, 12, 5], [8, 13, 3], [9, 13, 4], [9, 14, 6], [10, 14, 5], [11, 14, 3], [11, 15, 2], [11, 16, 1], [12, 16, 2], [12, 17, 10], [13, 17, 5], [14, 17, 3]]) == 1\n assert candidate(n = 7,roads = [[0, 1, 2], [0, 2, 3], [1, 2, 1], [1, 3, 5], [2, 4, 4], [3, 4, 2], [3, 5, 6], [4, 5, 3], [4, 6, 7], [5, 6, 1]]) == 2\n assert candidate(n = 8,roads = [[0, 1, 4], [0, 2, 1], [1, 2, 2], [1, 3, 5], [2, 3, 1], [2, 4, 2], [3, 4, 3], [3, 5, 1], [4, 5, 2], [4, 6, 1], [5, 6, 2], [5, 7, 3], [6, 7, 1]]) == 1\n"}, "metadata": {"canonical_parameter_names": ["n", "roads"], "leetcode_dataset_entry_point": "Solution().countPaths", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countPaths(int n, vector>& roads) {", "container": "Solution", "callable": "countPaths", "parameters": [{"name": "n", "type": "int"}, {"name": "roads", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1977, "task_id": "number-of-ways-to-separate-numbers", "difficulty": "Hard", "problem_description": "You wrote down many positive integers in a string called num. However, you realized that you forgot to add commas to seperate the different numbers. You remember that the list of integers was non-decreasing and that no integer had leading zeros.\nReturn the number of possible lists of integers that you could have written down to get the string num. Since the answer may be large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: num = \"327\"\nOutput: 2\nExplanation: You could have written down the numbers:\n3, 27\n327\n\nExample 2:\n\nInput: num = \"094\"\nOutput: 0\nExplanation: No numbers can have leading zeros and all numbers must be positive.\n\nExample 3:\n\nInput: num = \"0\"\nOutput: 0\nExplanation: No numbers can have leading zeros and all numbers must be positive.\n\n \nConstraints:\n\n1 <= num.length <= 3500\nnum consists of digits '0' through '9'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(num = \"327\") == 2\n assert candidate(num = \"11110000111100001111\") == 30\n assert candidate(num = \"3333333333\") == 42\n assert candidate(num = \"123456789012345678901234567890\") == 1451\n assert candidate(num = \"0\") == 0\n assert candidate(num = \"10101\") == 2\n assert candidate(num = \"987654321\") == 8\n assert candidate(num = \"123\") == 3\n assert candidate(num = \"094\") == 0\n assert candidate(num = \"1111111111111111111111111111111\") == 6842\n assert candidate(num = \"9876543210987654321098765432109876543210\") == 1307\n assert candidate(num = \"101010\") == 3\n assert candidate(num = \"5555555\") == 15\n assert candidate(num = \"9999999999999999999999999999999\") == 6842\n assert candidate(num = \"100100100100100100100\") == 15\n assert candidate(num = \"24680\") == 6\n assert candidate(num = \"12345678901234567890\") == 287\n assert candidate(num = \"1234567890\") == 41\n assert candidate(num = \"11111\") == 7\n assert candidate(num = \"13579\") == 7\n assert candidate(num = \"12345\") == 7\n assert candidate(num = \"1001\") == 1\n assert candidate(num = \"999\") == 3\n assert candidate(num = \"111\") == 3\n assert candidate(num = \"1000000000000000000000000000000\") == 1\n assert candidate(num = \"112113114115116117118119120121\") == 1464\n assert candidate(num = \"11223344556677889900112233445566\") == 4050\n assert candidate(num = \"112233445566778899001122334455\") == 2836\n assert candidate(num = \"3330333033303330333033303330333\") == 481\n assert candidate(num = \"98765432109876543210\") == 67\n assert candidate(num = \"9999999999999999999999999999998\") == 5604\n assert candidate(num = \"123456789101112131415161718192021\") == 3405\n assert candidate(num = \"012345678901234567890123456789\") == 0\n assert candidate(num = \"987654321109876543211098765432110987654321\") == 1638\n assert candidate(num = \"1234567890123456789012345678901\") == 1716\n assert candidate(num = \"1000000000000000000000000000001\") == 1\n assert candidate(num = \"111222333444555666777888999000111222333444555\") == 41226\n assert candidate(num = \"1234567890123456789012345678901234567890\") == 6307\n assert candidate(num = \"1010101010101010101010101010101\") == 176\n assert candidate(num = \"212121212121212121212121212121\") == 1186\n assert candidate(num = \"11110001111000111100011110001111000111100011110001111000\") == 2300\n assert candidate(num = \"123456789876543211234567898765\") == 2137\n assert candidate(num = \"5555555555555555555555555555555555555555555555555\") == 173525\n assert candidate(num = \"123123123123123123123123123123\") == 1474\n assert candidate(num = \"111111111111111111111111111111111111111111111111\") == 147273\n assert candidate(num = \"321321321321321321321321321321\") == 809\n assert candidate(num = \"12312312312312312312312312312312\") == 2069\n assert candidate(num = \"1231231231231231231231231231230\") == 1641\n assert candidate(num = \"123456789876543211234567898765432112345678987654321\") == 41516\n assert candidate(num = \"123123123123123123123123123123123\") == 2438\n assert candidate(num = \"987654321109876543210987654321\") == 310\n assert candidate(num = \"121212121212121212121212121212\") == 1888\n assert candidate(num = \"1234567898765432109876543210987654321098765432109876543210\") == 81400\n assert candidate(num = \"00000000000000000000000000000000000000000000000000000000\") == 0\n assert candidate(num = \"1122334455667788990011223344556677889900\") == 14863\n assert candidate(num = \"1001001001001001001001001001001\") == 42\n assert candidate(num = \"202020202020202020202020202020\") == 176\n assert candidate(num = \"987654321987654321987654321987\") == 423\n assert candidate(num = \"123123123123123123123123123123123123123123123123123123123\") == 78648\n assert candidate(num = \"11112222333344445555666677778888\") == 8349\n assert candidate(num = \"98979695949392919089888786858483\") == 454\n assert candidate(num = \"999000999000999000999000999000999000999000999000999000\") == 1027\n assert candidate(num = \"10203040506070809010\") == 41\n assert candidate(num = \"111222333444555666777888999000\") == 5513\n assert candidate(num = \"2222222222222222222222222222222\") == 6842\n assert candidate(num = \"1234123412341234123412341234123412341234\") == 7113\n assert candidate(num = \"999111999111999111999111999111\") == 987\n assert candidate(num = \"2333233323332333233323332333233323332333233323332333\") == 43205\n assert candidate(num = \"100100100100100100100100100100100100100100100100100\") == 297\n assert candidate(num = \"999999999999999999999999999999999999999999999999\") == 147273\n assert candidate(num = \"1234567891011121314151617181920\") == 2406\n assert candidate(num = \"987654321098765432109876543210\") == 326\n assert candidate(num = \"1231231231231231231231231231231\") == 1751\n assert candidate(num = \"101010101010101010101010101010101010101010101010101\") == 1958\n assert candidate(num = \"999990000099999000009999900000\") == 107\n assert candidate(num = \"999000999000999000999000999000\") == 98\n assert candidate(num = \"99999999988888888877777777666666665555555544444444333333332222222211111111\") == 299850\n assert candidate(num = \"11223344556677889900\") == 616\n assert candidate(num = \"1234567898765432109876543210987654321\") == 5367\n assert candidate(num = \"0123456789012345678901234567890\") == 0\n assert candidate(num = \"10101010101010101010101010101010\") == 231\n assert candidate(num = \"1111111111111111111122222222222222222\") == 21637\n assert candidate(num = \"1010101010101010101010101010102\") == 176\n assert candidate(num = \"22222222222222222222222222222222222222222222222\") == 124754\n assert candidate(num = \"1231231231231231231231231231231231231231231231231231231230\") == 85398\n assert candidate(num = \"12343211234567898765432109876543210\") == 2572\n assert candidate(num = \"123412341234123412341234123412\") == 1471\n assert candidate(num = \"12345432101234543210\") == 199\n assert candidate(num = \"0000000000000000000000000000001\") == 0\n assert candidate(num = \"123456789876543212345678987654321\") == 3452\n assert candidate(num = \"100100100100100100100100100100\") == 42\n assert candidate(num = \"00000000000000000000\") == 0\n assert candidate(num = \"10000000000000000000000000000000000000000000000\") == 1\n assert candidate(num = \"555555555555555555555555555555\") == 5604\n assert candidate(num = \"9999999999999999999999999999999999999999999999\") == 105558\n assert candidate(num = \"303030303030303030303030303030\") == 176\n assert candidate(num = \"1112131415161718192021222324252627282930\") == 12048\n assert candidate(num = \"1212121212121212121212121212121\") == 2059\n assert candidate(num = \"123412341234123412341234123412341234123412341234123412341\") == 69419\n assert candidate(num = \"1213141516171819202122232425262728293031323334353637383940\") == 97025\n assert candidate(num = \"0000000000000000000000000000000\") == 0\n assert candidate(num = \"1010101010101010101010101010101010101010101010\") == 1255\n assert candidate(num = \"1221221221221221221221221221221221221221221221221221\") == 46460\n assert candidate(num = \"123456789101112131415\") == 387\n assert candidate(num = \"1001001001001001001001001001000\") == 42\n"}, "metadata": {"canonical_parameter_names": ["num"], "leetcode_dataset_entry_point": "Solution().numberOfCombinations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numberOfCombinations(string num) {", "container": "Solution", "callable": "numberOfCombinations", "parameters": [{"name": "num", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1979, "task_id": "find-greatest-common-divisor-of-array", "difficulty": "Easy", "problem_description": "Given an integer array nums, return the greatest common divisor of the smallest number and largest number in nums.\nThe greatest common divisor of two numbers is the largest positive integer that evenly divides both numbers.\n \nExample 1:\n\nInput: nums = [2,5,6,9,10]\nOutput: 2\nExplanation:\nThe smallest number in nums is 2.\nThe largest number in nums is 10.\nThe greatest common divisor of 2 and 10 is 2.\n\nExample 2:\n\nInput: nums = [7,5,6,8,3]\nOutput: 1\nExplanation:\nThe smallest number in nums is 3.\nThe largest number in nums is 8.\nThe greatest common divisor of 3 and 8 is 1.\n\nExample 3:\n\nInput: nums = [3,3]\nOutput: 3\nExplanation:\nThe smallest number in nums is 3.\nThe largest number in nums is 3.\nThe greatest common divisor of 3 and 3 is 3.\n\n \nConstraints:\n\n2 <= nums.length <= 1000\n1 <= nums[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [42, 56, 14]) == 14\n assert candidate(nums = [1, 1000]) == 1\n assert candidate(nums = [17, 23, 37, 41]) == 1\n assert candidate(nums = [3, 3]) == 3\n assert candidate(nums = [7, 5, 6, 8, 3]) == 1\n assert candidate(nums = [1000, 1000]) == 1000\n assert candidate(nums = [48, 18, 30]) == 6\n assert candidate(nums = [10, 20, 30, 40, 50]) == 10\n assert candidate(nums = [100, 200, 300, 400, 500]) == 100\n assert candidate(nums = [17, 23, 19, 29, 31]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [1000, 1]) == 1\n assert candidate(nums = [48, 18]) == 6\n assert candidate(nums = [2, 5, 6, 9, 10]) == 2\n assert candidate(nums = [48, 180, 120, 240]) == 48\n assert candidate(nums = [54, 24, 36]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [56, 98, 140, 224, 336]) == 56\n assert candidate(nums = [81, 27, 9, 3, 1]) == 1\n assert candidate(nums = [22, 44, 66, 88, 110, 132, 154]) == 22\n assert candidate(nums = [27, 54, 81, 108, 135, 162, 189]) == 27\n assert candidate(nums = [1024, 512, 256, 128, 64]) == 64\n assert candidate(nums = [999, 1000]) == 1\n assert candidate(nums = [4096, 2048, 1024, 512, 256, 128]) == 128\n assert candidate(nums = [84, 60, 48, 36, 24]) == 12\n assert candidate(nums = [81, 27, 54, 162, 81]) == 27\n assert candidate(nums = [29, 29, 29, 29, 29, 29]) == 29\n assert candidate(nums = [83, 166, 332, 664, 996]) == 83\n assert candidate(nums = [123456, 234567, 345678, 456789, 567891, 678912, 789123, 891234, 912345]) == 3\n assert candidate(nums = [999, 333, 666, 111, 222]) == 111\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136]) == 17\n assert candidate(nums = [1000, 1, 500, 250, 750, 200]) == 1\n assert candidate(nums = [60, 48, 36, 24, 12, 6, 3, 1]) == 1\n assert candidate(nums = [441, 49, 147, 343, 735]) == 49\n assert candidate(nums = [1, 1000, 2, 999, 3, 998]) == 1\n assert candidate(nums = [1000, 10, 50, 250, 500]) == 10\n assert candidate(nums = [44, 55, 66, 77, 88, 99]) == 11\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == 15\n assert candidate(nums = [999, 998, 997, 996, 995]) == 1\n assert candidate(nums = [100, 200, 300, 400, 500]) == 100\n assert candidate(nums = [31, 62, 93, 124, 155]) == 31\n assert candidate(nums = [77, 143, 209, 286, 187]) == 11\n assert candidate(nums = [42, 42, 42, 42, 42]) == 42\n assert candidate(nums = [98, 49, 147, 245, 343, 441, 539]) == 49\n assert candidate(nums = [17, 23, 29, 31, 37]) == 1\n assert candidate(nums = [13, 13, 13, 13, 13, 13, 13]) == 13\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130]) == 13\n assert candidate(nums = [999, 888, 777, 666, 555]) == 111\n assert candidate(nums = [1000, 750, 500, 250]) == 250\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 143, 156, 169, 182, 195, 208, 221, 234, 247, 260]) == 13\n assert candidate(nums = [999999, 888888, 777777, 666666, 555555, 444444, 333333, 222222, 111111]) == 111111\n assert candidate(nums = [987654, 876543, 765432, 654321, 543210, 432109, 321098, 210987, 109876]) == 2\n assert candidate(nums = [123, 246, 369, 492, 615, 738, 861, 984, 1107, 1230, 1353, 1476, 1599, 1722, 1845, 1968, 2091, 2214, 2337, 2460]) == 123\n assert candidate(nums = [54, 24, 36, 48, 60]) == 12\n assert candidate(nums = [1000, 1000, 1000, 1000]) == 1000\n assert candidate(nums = [1024, 512, 256, 128, 64, 32, 16, 8, 4, 2]) == 2\n assert candidate(nums = [999, 333, 111, 37, 1]) == 1\n assert candidate(nums = [231, 105, 77, 49, 33, 11, 7]) == 7\n assert candidate(nums = [77, 49, 14, 21, 28]) == 7\n assert candidate(nums = [997, 991, 983, 977, 971, 967, 953, 941, 929, 919, 907, 887, 883]) == 1\n assert candidate(nums = [50, 75, 100, 125, 150, 175, 200]) == 50\n assert candidate(nums = [123456, 234567, 345678, 456789, 567890]) == 2\n assert candidate(nums = [210, 231, 273, 308, 357, 399]) == 21\n assert candidate(nums = [17, 34, 51, 68, 85]) == 17\n assert candidate(nums = [1, 1000]) == 1\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170]) == 17\n assert candidate(nums = [100, 150, 200, 250, 300]) == 100\n assert candidate(nums = [650, 520, 390, 780, 260]) == 260\n assert candidate(nums = [100, 200, 300, 400, 500, 600]) == 100\n assert candidate(nums = [17, 19, 23, 29, 31]) == 1\n assert candidate(nums = [123456, 987654, 111111, 222222, 333333]) == 3\n assert candidate(nums = [123, 456, 789, 987, 654]) == 3\n assert candidate(nums = [33, 66, 99, 132, 165, 198, 231, 264]) == 33\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [101010, 202020, 303030, 404040, 505050, 606060, 707070, 808080, 909090]) == 101010\n assert candidate(nums = [13, 26, 39, 52, 65]) == 13\n assert candidate(nums = [12, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 12\n assert candidate(nums = [17, 34, 51, 68, 85, 102]) == 17\n assert candidate(nums = [1, 1000, 2, 500, 4]) == 1\n assert candidate(nums = [29, 58, 87, 116, 145, 174, 203, 232, 261, 290, 319, 348, 377, 406, 435, 464, 493, 522, 551, 580]) == 29\n assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996]) == 1\n assert candidate(nums = [256, 512, 1024, 2048, 4096]) == 256\n assert candidate(nums = [77, 49, 14, 28, 35, 56]) == 7\n assert candidate(nums = [123, 456, 789, 1011, 1213]) == 1\n assert candidate(nums = [500, 500, 500, 500, 500, 500]) == 500\n assert candidate(nums = [24, 36, 48, 60, 72, 84, 96]) == 24\n assert candidate(nums = [1000, 750, 500, 250, 125, 62, 31]) == 1\n assert candidate(nums = [999, 888, 777, 666, 555, 444, 333, 222, 111]) == 111\n assert candidate(nums = [41, 82, 123, 164, 205, 246, 287, 328]) == 41\n assert candidate(nums = [1001, 2002, 3003, 4004, 5005, 6006]) == 1001\n assert candidate(nums = [1, 1000, 500, 250, 125, 62, 31, 15]) == 1\n assert candidate(nums = [84, 112, 168, 224, 280]) == 28\n assert candidate(nums = [56, 98, 140, 182, 224]) == 56\n assert candidate(nums = [840, 1764, 4620, 10920]) == 840\n assert candidate(nums = [77, 154, 231, 308, 385, 462, 539, 616]) == 77\n assert candidate(nums = [60, 120, 180, 240, 300, 360]) == 60\n assert candidate(nums = [840, 756, 630, 504, 420]) == 420\n assert candidate(nums = [12, 24, 36, 48, 60, 72, 84, 96, 108]) == 12\n assert candidate(nums = [49, 63, 28, 91, 35]) == 7\n assert candidate(nums = [1000, 500, 250, 125, 62]) == 2\n assert candidate(nums = [1000, 500, 250, 125, 62, 31, 15, 7, 3, 1]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 10\n assert candidate(nums = [27, 81, 54, 162, 243]) == 27\n assert candidate(nums = [101, 202, 303, 404, 505]) == 101\n assert candidate(nums = [27, 81, 243, 729, 2187, 6561, 19683, 59049, 177147, 531441]) == 27\n assert candidate(nums = [29, 58, 87, 116, 145, 174, 203]) == 29\n assert candidate(nums = [1024, 2048, 3072, 4096, 5120]) == 1024\n assert candidate(nums = [24, 36, 48, 60, 72, 84]) == 12\n assert candidate(nums = [840, 756, 672, 588, 504, 420, 336, 252, 168, 84]) == 84\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909]) == 101\n assert candidate(nums = [997, 991, 983, 977, 971]) == 1\n assert candidate(nums = [8317, 16634, 24951, 33268, 41585, 49902, 58219]) == 8317\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010]) == 101\n assert candidate(nums = [101, 103, 107, 109, 113, 127, 131, 137]) == 1\n assert candidate(nums = [987, 654, 321, 123, 456, 789]) == 3\n assert candidate(nums = [101, 103, 107, 109, 113]) == 1\n assert candidate(nums = [23, 47, 17, 53, 31, 19, 89, 73]) == 1\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findGCD", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int findGCD(vector& nums) {", "container": "Solution", "callable": "findGCD", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1980, "task_id": "find-unique-binary-string", "difficulty": "Medium", "problem_description": "Given an array of strings nums containing n unique binary strings each of length n, return a binary string of length n that does not appear in nums. If there are multiple answers, you may return any of them.\n \nExample 1:\n\nInput: nums = [\"01\",\"10\"]\nOutput: \"11\"\nExplanation: \"11\" does not appear in nums. \"00\" would also be correct.\n\nExample 2:\n\nInput: nums = [\"00\",\"01\"]\nOutput: \"11\"\nExplanation: \"11\" does not appear in nums. \"10\" would also be correct.\n\nExample 3:\n\nInput: nums = [\"111\",\"011\",\"001\"]\nOutput: \"101\"\nExplanation: \"101\" does not appear in nums. \"000\", \"010\", \"100\", and \"110\" would also be correct.\n\n \nConstraints:\n\nn == nums.length\n1 <= n <= 16\nnums[i].length == n\nnums[i] is either '0' or '1'.\nAll the strings of nums are unique.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = ['01', '10']) == \"00\"\n assert candidate(nums = ['1111', '1011', '0111', '0011', '1101', '1001', '0101', '0001']) == \"00000000\"\n assert candidate(nums = ['00', '01']) == \"11\"\n assert candidate(nums = ['111', '011', '001']) == \"000\"\n assert candidate(nums = ['1101', '1011', '0111', '0011']) == \"0000\"\n assert candidate(nums = ['11110000', '00001111', '10101010', '01010101', '11001100', '00110011', '10000000', '01111111', '11011011', '00100100', '10100101', '01011010', '11100011', '00011100', '10011001', '01100110']) == \"0000000000000000\"\n assert candidate(nums = ['11110000', '00001111', '10101010', '01010101', '11001100', '00110011', '10011001', '01100110', '11010100', '00101011', '10111000', '01000111', '10001011', '01110100', '11000110', '00111001']) == \"0000000000000000\"\n assert candidate(nums = ['000000', '111111', '010101', '101010', '110011', '001100', '011001', '100110', '000111', '111000', '110100', '001011']) == \"100000000000\"\n assert candidate(nums = ['1100', '0011', '1010', '0101']) == \"0000\"\n assert candidate(nums = ['1111100000', '0000011111', '1010101010', '0101010101', '1100110011', '0011001100', '1001100110', '0110011001', '1101010010', '0010101101', '1011100011', '0100011100', '1000101100', '0111010011', '1100011011', '0011100100']) == \"0000000000000000\"\n assert candidate(nums = ['111110', '000001', '100011', '010110', '110101', '101000', '001100', '011010', '110011', '000110', '011101', '101111', '111000', '001011', '110110', '010000']) == \"0000000000000000\"\n assert candidate(nums = ['11111111', '00000000', '11111110', '00000001', '11111101', '00000010', '11111011', '00000100', '11110111', '00001000', '11101111', '00010000', '11011111', '00100000', '10111111']) == \"110000000000000\"\n assert candidate(nums = ['1111', '1110', '1101', '1100', '1011', '1010', '1001', '1000', '0111', '0110', '0101', '0100', '0011', '0010', '0001']) == \"000000000000000\"\n assert candidate(nums = ['111010', '000101', '101011', '010100', '110001', '100110', '011000', '001110', '011100', '110111', '101110', '000011', '111100', '010001', '000111', '110010']) == \"0000000000000000\"\n assert candidate(nums = ['101010', '010101', '001100', '110011', '111100', '000011']) == \"000000\"\n assert candidate(nums = ['1100', '1011', '0011', '1110']) == \"0000\"\n assert candidate(nums = ['11111111', '00000000', '10101010', '01010101', '11001100', '00110011', '11110000', '00001111', '10001000', '01110111', '11000110', '00111001', '11100010', '00011101', '10010110', '01101001']) == \"1000000000000000\"\n assert candidate(nums = ['1111111111', '0000000000', '1111111000', '0000000111', '1111110111', '0000001000', '1111101111', '0000010000', '1111011111', '0000100000', '1110111111', '0001000000', '1101111111', '0010000000', '1011111111']) == \"110000000000000\"\n assert candidate(nums = ['110110', '001011', '100100', '011001', '101110', '010010', '111000', '000111', '011101', '101010', '111100', '000011', '100001', '010110', '110010']) == \"000000000000000\"\n assert candidate(nums = ['10101010', '01010101', '11001100', '00110011', '11110000', '00001111', '10011001', '01100110', '11010101', '00101010', '10111100', '01000011', '11100011', '00011100', '10001100']) == \"000000000000000\"\n assert candidate(nums = ['000000000', '000000001', '000000010', '000000011', '000000100', '000000101', '000000110', '000000111', '000001000', '000001001', '000001010', '000001011', '000001100', '000001101', '000001110', '000001111']) == \"1111100000000000\"\n assert candidate(nums = ['1101', '0010', '1001', '0110']) == \"0000\"\n assert candidate(nums = ['00000', '00001', '00010', '00011', '00100', '00101', '00110', '00111', '01000', '01001', '01010', '01011', '01100', '01101', '01110', '01111']) == \"1111100000000000\"\n assert candidate(nums = ['1100', '1010', '0011', '1001', '0110', '0000', '1110', '1000']) == \"11110000\"\n assert candidate(nums = ['1111', '1000', '0100', '0001', '0010', '0110', '1001', '1101']) == \"00000000\"\n assert candidate(nums = ['110110', '001001', '101010', '010101', '111111', '000000', '100011', '011100', '110001', '001110', '111001', '000110']) == \"100000000000\"\n assert candidate(nums = ['00000', '00001', '00010', '00011', '00100', '00101', '00110', '00111', '01000', '01001', '01010', '01011', '01100', '01101', '01110', '01111']) == \"1111100000000000\"\n assert candidate(nums = ['1110', '1101', '1011', '0111', '0000', '0001', '0010', '0100']) == \"11000000\"\n assert candidate(nums = ['1100', '0101', '1010', '0011']) == \"0000\"\n assert candidate(nums = ['1111', '1110', '1101', '1100', '1011', '1010', '1001', '1000', '0111', '0110', '0101', '0100', '0011', '0010', '0001']) == \"000000000000000\"\n assert candidate(nums = ['00000000', '00000001', '00000010', '00000011', '00000100', '00000101', '00000110', '00000111', '00001000', '00001001', '00001010', '00001011', '00001100', '00001101', '00001110', '00001111']) == \"1111100000000000\"\n assert candidate(nums = ['00000', '00001', '00010', '00011', '00100', '00101', '00110', '00111']) == \"11110000\"\n assert candidate(nums = ['1111', '1011', '0111', '0011', '1101', '1001', '0101', '0001', '1110', '1010', '0110', '0010', '1100', '1000', '0100', '0000']) == \"1111100000000000\"\n assert candidate(nums = ['0000000000', '0000000001', '0000000010', '0000000011', '0000000100', '0000000101', '0000000110', '0000000111', '0000001000', '0000001001', '0000001010', '0000001011', '0000001100', '0000001101', '0000001110']) == \"111100000000000\"\n assert candidate(nums = ['100000', '110000', '111000', '111100', '111110', '111111', '000001', '000011', '000111', '001111', '011111']) == \"00000000000\"\n assert candidate(nums = ['111110', '000001', '101010', '010101', '110011', '001100', '011001', '100110', '000111', '111000', '110100', '001011', '110110', '001001', '100100', '011011']) == \"0000000000000000\"\n assert candidate(nums = ['101010', '010101', '110011', '001100', '111100', '000011', '100101', '011010', '110110', '001001', '101101', '010010', '111000', '000111', '110001', '001110']) == \"0000000000000000\"\n assert candidate(nums = ['111000', '000111', '110110', '001001', '101010', '010101', '110011', '001100', '100011', '011100', '000111', '111000', '010101', '101010', '001100', '110011']) == \"0000000000000000\"\n assert candidate(nums = ['10101010', '01010101', '11110000', '00001111', '11001100', '00110011', '11111111', '00000000', '10010010', '01101101', '11011011', '00100100', '10000001', '01111110', '11101100', '00010011']) == \"1000000000000000\"\n assert candidate(nums = ['11111111', '00000000', '10101010', '01010101', '11001100', '00110011', '10011001', '01100110']) == \"10000000\"\n assert candidate(nums = ['1110', '1101', '1011', '0111', '1000', '0100', '0010', '0001']) == \"00000000\"\n assert candidate(nums = ['1100', '1010', '0110', '0001']) == \"0000\"\n assert candidate(nums = ['1010', '0101', '1111', '0000']) == \"1000\"\n assert candidate(nums = ['0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111', '1000', '1001', '1010', '1011', '1100', '1101', '1110']) == \"111100000000000\"\n assert candidate(nums = ['0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111']) == \"11110000\"\n assert candidate(nums = ['110011', '001100', '101010', '010101', '111100', '000011', '100100', '011011']) == \"00000000\"\n assert candidate(nums = ['10101', '01010', '11100', '00011', '11011', '01100', '10000', '01001', '11111', '00000', '10010', '01110', '10110', '00111', '11001', '01011']) == \"1111110000000000\"\n assert candidate(nums = ['1111', '1110', '1101', '1100', '1011', '1010', '1001', '1000', '0111', '0110', '0101', '0100', '0011', '0010', '0001', '0000']) == \"1111100000000000\"\n assert candidate(nums = ['1010', '0101', '1100', '0011']) == \"0000\"\n assert candidate(nums = ['11101', '10010', '01100', '11011', '00001', '01011', '10101', '11001', '01111', '00100', '10000', '11111', '00011', '00110', '10110']) == \"000000000000000\"\n assert candidate(nums = ['111111', '111110', '111101', '111100', '111011', '111010', '111001', '111000', '110111', '110110', '110101', '110100', '110011', '110010', '110001', '110000']) == \"0000000000000000\"\n assert candidate(nums = ['111000', '000111', '101010', '010101', '110011', '001100', '100100', '011011', '111100', '000011', '101110', '010001', '100001', '011110', '110110', '001001']) == \"0000000000000000\"\n assert candidate(nums = ['1111', '0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111', '1000', '1001', '1010', '1011', '1100', '1101']) == \"111110000000000\"\n assert candidate(nums = ['00000', '00001', '00010', '00011', '00100', '00101', '00110', '00111', '01000', '01001', '01010', '01011', '01100', '01101', '01110', '01111', '10000', '10001', '10010', '10011', '10100', '10101', '10110', '10111']) == \"111110000000000000000000\"\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findDifferentBinaryString", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string findDifferentBinaryString(vector& nums) {", "container": "Solution", "callable": "findDifferentBinaryString", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1981, "task_id": "minimize-the-difference-between-target-and-chosen-elements", "difficulty": "Medium", "problem_description": "You are given an m x n integer matrix mat and an integer target.\nChoose one integer from each row in the matrix such that the absolute difference between target and the sum of the chosen elements is minimized.\nReturn the minimum absolute difference.\nThe absolute difference between two numbers a and b is the absolute value of a - b.\n \nExample 1:\n\n\nInput: mat = [[1,2,3],[4,5,6],[7,8,9]], target = 13\nOutput: 0\nExplanation: One possible choice is to:\n- Choose 1 from the first row.\n- Choose 5 from the second row.\n- Choose 7 from the third row.\nThe sum of the chosen elements is 13, which equals the target, so the absolute difference is 0.\n\nExample 2:\n\n\nInput: mat = [[1],[2],[3]], target = 100\nOutput: 94\nExplanation: The best possible choice is to:\n- Choose 1 from the first row.\n- Choose 2 from the second row.\n- Choose 3 from the third row.\nThe sum of the chosen elements is 6, and the absolute difference is 94.\n\nExample 3:\n\n\nInput: mat = [[1,2,9,8,7]], target = 6\nOutput: 1\nExplanation: The best choice is to choose 7 from the first row.\nThe absolute difference is 1.\n\n \nConstraints:\n\nm == mat.length\nn == mat[i].length\n1 <= m, n <= 70\n1 <= mat[i][j] <= 70\n1 <= target <= 800\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(mat = [[1], [2], [3]],target = 100) == 94\n assert candidate(mat = [[5, 5, 5], [5, 5, 5], [5, 5, 5]],target = 15) == 0\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],target = 13) == 0\n assert candidate(mat = [[7, 8, 9], [1, 2, 3], [4, 5, 6]],target = 20) == 2\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19]],target = 25) == 1\n assert candidate(mat = [[10, 20, 30], [5, 15, 25], [1, 10, 20]],target = 50) == 4\n assert candidate(mat = [[7, 8, 9], [10, 11, 12], [13, 14, 15]],target = 36) == 0\n assert candidate(mat = [[70, 70, 70], [70, 70, 70], [70, 70, 70]],target = 150) == 60\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 6, 9, 12, 15]],target = 20) == 0\n assert candidate(mat = [[70, 70, 70], [70, 70, 70], [70, 70, 70]],target = 100) == 110\n assert candidate(mat = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],target = 150) == 0\n assert candidate(mat = [[1, 2, 9, 8, 7]],target = 6) == 1\n assert candidate(mat = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],target = 5) == 2\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5, 6, 7]],target = 21) == 0\n assert candidate(mat = [[70, 60, 50, 40, 30], [20, 10, 0, -10, -20], [-30, -40, -50, -60, -70], [80, 90, 100, 110, 120]],target = 200) == 20\n assert candidate(mat = [[70, 70, 70, 70, 70], [70, 70, 70, 70, 70], [70, 70, 70, 70, 70]],target = 800) == 590\n assert candidate(mat = [[2, 4, 6, 8, 10], [3, 6, 9, 12, 15], [5, 10, 15, 20, 25], [7, 14, 21, 28, 35]],target = 100) == 15\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [1, 1, 1, 1, 1]],target = 25) == 5\n assert candidate(mat = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41], [7, 17, 27, 37, 47]],target = 150) == 3\n assert candidate(mat = [[5, 15, 25], [5, 15, 25], [5, 15, 25], [5, 15, 25], [5, 15, 25]],target = 50) == 5\n assert candidate(mat = [[70, 1], [70, 1], [70, 1], [70, 1], [70, 1], [70, 1], [70, 1]],target = 200) == 14\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]],target = 75) == 12\n assert candidate(mat = [[50, 60, 70], [10, 20, 30], [40, 50, 60], [70, 80, 90]],target = 200) == 0\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21]],target = 105) == 21\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21]],target = 50) == 8\n assert candidate(mat = [[1, 10, 100], [1, 10, 100], [1, 10, 100], [1, 10, 100], [1, 10, 100], [1, 10, 100], [1, 10, 100]],target = 700) == 0\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28]],target = 100) == 30\n assert candidate(mat = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 2, 3, 4, 5]],target = 85) == 1\n assert candidate(mat = [[60, 59, 58, 57, 56, 55, 54], [53, 52, 51, 50, 49, 48, 47], [46, 45, 44, 43, 42, 41, 40], [39, 38, 37, 36, 35, 34, 33], [32, 31, 30, 29, 28, 27, 26], [25, 24, 23, 22, 21, 20, 19]],target = 420) == 165\n assert candidate(mat = [[10, 20, 30, 40, 50, 60, 70], [70, 60, 50, 40, 30, 20, 10], [1, 2, 3, 4, 5, 6, 7]],target = 200) == 53\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5]],target = 50) == 35\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19], [20, 22, 24, 26, 28]],target = 50) == 0\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18]],target = 50) == 1\n assert candidate(mat = [[5, 10, 15], [20, 25, 30], [35, 40, 45], [50, 55, 60]],target = 120) == 0\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [2, 3, 4, 5, 6, 7, 8], [3, 4, 5, 6, 7, 8, 9], [4, 5, 6, 7, 8, 9, 10]],target = 50) == 16\n assert candidate(mat = [[50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50], [50, 50, 50, 50, 50, 50, 50]],target = 400) == 50\n assert candidate(mat = [[1, 70], [2, 69], [3, 68], [4, 67], [5, 66], [6, 65], [7, 64], [8, 63], [9, 62], [10, 61]],target = 400) == 1\n assert candidate(mat = [[5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [1, 6, 11, 16, 21, 26, 31, 36, 41, 46], [2, 7, 12, 17, 22, 27, 32, 37, 42, 47], [3, 8, 13, 18, 23, 28, 33, 38, 43, 48]],target = 150) == 1\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5], [6, 6, 6, 6, 6, 6, 6], [7, 7, 7, 7, 7, 7, 7]],target = 28) == 0\n assert candidate(mat = [[1, 50, 100], [2, 51, 101], [3, 52, 102], [4, 53, 103], [5, 54, 104]],target = 260) == 0\n assert candidate(mat = [[70, 69, 68, 67, 66, 65, 64], [63, 62, 61, 60, 59, 58, 57], [56, 55, 54, 53, 52, 51, 50], [49, 48, 47, 46, 45, 44, 43]],target = 260) == 22\n assert candidate(mat = [[10, 20, 30, 40, 50, 60, 70], [11, 21, 31, 41, 51, 61, 71], [12, 22, 32, 42, 52, 62, 72], [13, 23, 33, 43, 53, 63, 73], [14, 24, 34, 44, 54, 64, 74], [15, 25, 35, 45, 55, 65, 75]],target = 300) == 5\n assert candidate(mat = [[1, 10, 100], [10, 100, 1000], [100, 1000, 10000]],target = 1234) == 34\n assert candidate(mat = [[10, 20, 30], [40, 50, 60], [70, 80, 90], [100, 110, 120], [130, 140, 150], [160, 170, 180], [190, 200, 210]],target = 700) == 0\n assert candidate(mat = [[70, 69, 68], [67, 66, 65], [64, 63, 62], [61, 60, 59], [58, 57, 56]],target = 250) == 60\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28]],target = 100) == 30\n assert candidate(mat = [[50, 49, 48, 47, 46, 45, 44], [43, 42, 41, 40, 39, 38, 37], [36, 35, 34, 33, 32, 31, 30]],target = 130) == 1\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],target = 10) == 6\n assert candidate(mat = [[3, 10, 7], [8, 6, 4], [15, 12, 9], [18, 16, 13]],target = 50) == 1\n assert candidate(mat = [[60, 70, 80, 90, 100], [1, 2, 3, 4, 5], [10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [100, 90, 80, 70, 60]],target = 300) == 0\n assert candidate(mat = [[7, 8, 9], [1, 2, 3], [4, 5, 6], [10, 11, 12]],target = 25) == 0\n assert candidate(mat = [[7, 21, 42, 58], [9, 23, 46, 62], [11, 25, 49, 65], [13, 27, 51, 67], [15, 29, 53, 69]],target = 200) == 0\n assert candidate(mat = [[70, 60, 50, 40], [30, 20, 10, 0], [1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]],target = 150) == 26\n assert candidate(mat = [[70, 60, 50, 40, 30], [20, 30, 40, 50, 60], [10, 20, 30, 40, 50]],target = 200) == 20\n assert candidate(mat = [[7, 17, 27, 37, 47], [8, 18, 28, 38, 48], [9, 19, 29, 39, 49], [10, 20, 30, 40, 50], [11, 21, 31, 41, 51]],target = 150) == 5\n assert candidate(mat = [[70, 69, 68, 67], [66, 65, 64, 63], [62, 61, 60, 59], [58, 57, 56, 55]],target = 260) == 4\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],target = 80) == 30\n assert candidate(mat = [[7, 8, 9], [4, 5, 6], [1, 2, 3], [7, 8, 9], [4, 5, 6], [1, 2, 3]],target = 30) == 0\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]],target = 50) == 5\n assert candidate(mat = [[70, 60, 50, 40, 30], [10, 20, 30, 40, 50], [60, 50, 40, 30, 20], [1, 2, 3, 4, 5]],target = 180) == 1\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]],target = 60) == 0\n assert candidate(mat = [[1, 3, 5, 7, 9, 11, 13], [2, 4, 6, 8, 10, 12, 14], [15, 17, 19, 21, 23, 25, 27]],target = 50) == 0\n assert candidate(mat = [[10, 20, 30], [11, 21, 31], [12, 22, 32], [13, 23, 33], [14, 24, 34]],target = 120) == 0\n assert candidate(mat = [[5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5]],target = 10) == 10\n assert candidate(mat = [[1, 3, 5, 7], [2, 4, 6, 8], [9, 11, 13, 15], [17, 19, 21, 23]],target = 30) == 1\n assert candidate(mat = [[1, 70], [1, 70], [1, 70], [1, 70], [1, 70], [1, 70], [1, 70]],target = 300) == 17\n assert candidate(mat = [[10, 20, 30], [15, 25, 35], [20, 30, 40], [25, 35, 45]],target = 120) == 0\n assert candidate(mat = [[10, 20, 30], [40, 50, 60], [70, 80, 90], [100, 110, 120], [130, 140, 150], [160, 170, 180]],target = 600) == 0\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 6, 9, 12, 15]],target = 100) == 66\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4]],target = 20) == 10\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35]],target = 150) == 45\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]],target = 1) == 5\n assert candidate(mat = [[5, 10, 15], [10, 20, 30], [15, 25, 35], [20, 30, 40], [25, 35, 45]],target = 100) == 0\n assert candidate(mat = [[10, 20, 30, 40, 50], [5, 15, 25, 35, 45], [1, 11, 21, 31, 41]],target = 120) == 4\n assert candidate(mat = [[70, 70, 70], [70, 70, 70], [70, 70, 70], [70, 70, 70], [70, 70, 70], [70, 70, 70], [70, 70, 70]],target = 800) == 310\n assert candidate(mat = [[5, 15, 25], [10, 20, 30], [15, 25, 35], [20, 30, 40]],target = 100) == 0\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14]],target = 50) == 0\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2], [3, 3, 3, 3, 3, 3, 3], [4, 4, 4, 4, 4, 4, 4], [5, 5, 5, 5, 5, 5, 5]],target = 100) == 85\n assert candidate(mat = [[1, 100, 200], [2, 150, 250], [3, 200, 300], [4, 250, 350]],target = 800) == 0\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19]],target = 50) == 12\n assert candidate(mat = [[5, 15, 25, 35], [10, 20, 30, 40], [15, 25, 35, 45], [20, 30, 40, 50], [25, 35, 45, 55]],target = 200) == 5\n assert candidate(mat = [[5, 10, 15, 20, 25], [30, 35, 40, 45, 50], [55, 60, 65, 70, 75]],target = 120) == 0\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [11, 13, 15, 17, 19]],target = 30) == 0\n assert candidate(mat = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],target = 10) == 3\n assert candidate(mat = [[1, 50, 100, 150, 200], [2, 51, 101, 151, 201], [3, 52, 102, 152, 202], [4, 53, 103, 153, 203], [5, 54, 104, 154, 204]],target = 500) == 10\n assert candidate(mat = [[70, 60, 50, 40, 30, 20, 10], [65, 55, 45, 35, 25, 15, 5], [1, 2, 3, 4, 5, 6, 7]],target = 200) == 58\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 6, 9, 12, 15], [4, 8, 12, 16, 20]],target = 40) == 0\n assert candidate(mat = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],target = 30) == 4\n assert candidate(mat = [[1, 5, 9, 14], [3, 7, 10, 17], [4, 8, 12, 19], [6, 11, 15, 20]],target = 45) == 0\n assert candidate(mat = [[7, 14, 21, 28], [35, 42, 49, 56], [63, 70, 77, 84]],target = 210) == 42\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21]],target = 50) == 8\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12]],target = 55) == 22\n assert candidate(mat = [[1, 100, 200], [1, 100, 200], [1, 100, 200], [1, 100, 200], [1, 100, 200]],target = 500) == 0\n assert candidate(mat = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [4, 4, 4, 4, 4], [5, 5, 5, 5, 5]],target = 15) == 0\n assert candidate(mat = [[7, 14, 21, 28, 35], [42, 49, 56, 63, 70], [77, 84, 91, 98, 105]],target = 250) == 40\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21], [22, 23, 24], [25, 26, 27], [28, 29, 30]],target = 150) == 0\n assert candidate(mat = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11], [4, 6, 8, 10, 12], [5, 7, 9, 11, 13]],target = 30) == 1\n assert candidate(mat = [[1, 2, 3, 4, 5, 6, 7], [8, 9, 10, 11, 12, 13, 14], [15, 16, 17, 18, 19, 20, 21], [22, 23, 24, 25, 26, 27, 28], [29, 30, 31, 32, 33, 34, 35], [36, 37, 38, 39, 40, 41, 42]],target = 200) == 53\n assert candidate(mat = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14]],target = 49) == 0\n assert candidate(mat = [[7, 8, 9], [1, 2, 3], [4, 5, 6], [7, 8, 9], [1, 2, 3], [4, 5, 6], [7, 8, 9]],target = 50) == 5\n assert candidate(mat = [[7, 8, 9], [1, 2, 3], [4, 5, 6], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21]],target = 80) == 0\n assert candidate(mat = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2], [3, 3, 3, 3, 3], [4, 4, 4, 4, 4]],target = 25) == 15\n assert candidate(mat = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21]],target = 100) == 16\n assert candidate(mat = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]],target = 7) == 0\n"}, "metadata": {"canonical_parameter_names": ["mat", "target"], "leetcode_dataset_entry_point": "Solution().minimizeTheDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimizeTheDifference(vector>& mat, int target) {", "container": "Solution", "callable": "minimizeTheDifference", "parameters": [{"name": "mat", "type": "vector>&"}, {"name": "target", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1982, "task_id": "find-array-given-subset-sums", "difficulty": "Hard", "problem_description": "You are given an integer n representing the length of an unknown array that you are trying to recover. You are also given an array sums containing the values of all 2n subset sums of the unknown array (in no particular order).\nReturn the array ans of length n representing the unknown array. If multiple answers exist, return any of them.\nAn array sub is a subset of an array arr if sub can be obtained from arr by deleting some (possibly zero or all) elements of arr. The sum of the elements in sub is one possible subset sum of arr. The sum of an empty array is considered to be 0.\nNote: Test cases are generated such that there will always be at least one correct answer.\n \nExample 1:\n\nInput: n = 3, sums = [-3,-2,-1,0,0,1,2,3]\nOutput: [1,2,-3]\nExplanation: [1,2,-3] is able to achieve the given subset sums:\n- []: sum is 0\n- [1]: sum is 1\n- [2]: sum is 2\n- [1,2]: sum is 3\n- [-3]: sum is -3\n- [1,-3]: sum is -2\n- [2,-3]: sum is -1\n- [1,2,-3]: sum is 0\nNote that any permutation of [1,2,-3] and also any permutation of [-1,-2,3] will also be accepted.\n\nExample 2:\n\nInput: n = 2, sums = [0,0,0,0]\nOutput: [0,0]\nExplanation: The only correct answer is [0,0].\n\nExample 3:\n\nInput: n = 4, sums = [0,0,5,5,4,-1,4,9,9,-1,4,3,4,8,3,8]\nOutput: [0,-1,4,5]\nExplanation: [0,-1,4,5] is able to achieve the given subset sums.\n\n \nConstraints:\n\n1 <= n <= 15\nsums.length == 2n\n-104 <= sums[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,sums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0]\n assert candidate(n = 3,sums = [-3, -2, -1, 0, 0, 1, 2, 3]) == [-1, -2, 3]\n assert candidate(n = 2,sums = [0, 0, 0, 0]) == [0, 0]\n assert candidate(n = 1,sums = [0, 5]) == [5]\n assert candidate(n = 3,sums = [3, 1, 2, 0, 4, 5, 6, 8]) == [1, 2, 4]\n assert candidate(n = 4,sums = [0, 0, 5, 5, 4, -1, 4, 9, 9, -1, 4, 3, 4, 8, 3, 8]) == [0, -1, 4, 5]\n assert candidate(n = 1,sums = [0, -1]) == [-1]\n assert candidate(n = 5,sums = [-20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, -4, 8, -16]\n assert candidate(n = 3,sums = [-1, 0, 1, 2, 3, 4, -2, -3, -4]) == [1, 2, -4]\n assert candidate(n = 6,sums = [-21, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [-2, -3, 4, 8, -16, 21]\n assert candidate(n = 5,sums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, 2, 4, 8, 16]\n assert candidate(n = 5,sums = [-25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == [-1, 2, 4, -8, -16]\n assert candidate(n = 4,sums = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7]) == [0, 1, 2, 4]\n assert candidate(n = 4,sums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 2, 4, 8]\n assert candidate(n = 3,sums = [0, 2, 2, 4, 6, 6, 8, 10]) == [2, 2, 6]\n assert candidate(n = 5,sums = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27]) == [1, 2, 4, 8, 16]\n assert candidate(n = 5,sums = [-15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [-1, -2, -4, -8, 16]\n assert candidate(n = 5,sums = [-7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11]) == [-1, -2, -4, 8, 17]\n assert candidate(n = 3,sums = [-5, -4, -3, -2, -1, 0, 1, 2, 3]) == [-1, 2, -4]\n assert candidate(n = 3,sums = [1, 2, 3, 4, 5, 6, 7, 8]) == [1, 2, 4]\n assert candidate(n = 3,sums = [-6, -5, -5, -4, -2, -1, -1, 0, 1, 1, 2, 4, 5, 5, 6, 7]) == [-1, -1, -4]\n assert candidate(n = 4,sums = [-7, -6, -5, -4, -4, -3, -2, -1, 0, 0, 1, 2, 3, 4, 5, 6, 7]) == [1, 2, 3, -7]\n assert candidate(n = 5,sums = [-30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, -2, -4, -8, -16]\n assert candidate(n = 5,sums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, -2, 4, -8, 16]\n assert candidate(n = 5,sums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == [1, 2, 4, 8, 16]\n assert candidate(n = 5,sums = [-10, -8, -7, -6, -5, -4, -4, -3, -3, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 7, 8, 10]) == [2, 3, -4, -6, 7]\n assert candidate(n = 5,sums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0]) == [1, -2, 4, -8, 10]\n assert candidate(n = 4,sums = [10, -10, 5, -5, 15, -15, 0, 20, -20]) == [5, 10, -20, 40]\n assert candidate(n = 3,sums = [-2, -1, 0, 1, 2, 3]) == [1, -2, 4]\n assert candidate(n = 4,sums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == [1, -2, 4, -8]\n assert candidate(n = 5,sums = [-5, -4, -4, -3, -3, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5]) == [-1, 1, 2, -4, 8]\n assert candidate(n = 5,sums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, -2, 4, -8, 16]\n assert candidate(n = 5,sums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 4, 8, 16]\n assert candidate(n = 4,sums = [0, -1, -2, -3, -4, 1, 2, 3, 4, -5, 5, -6, 6, -7, 7, 8]) == [-1, -2, -4, 8]\n assert candidate(n = 3,sums = [10, 20, 30, 40, 50, 60, 70, 80]) == [10, 20, 40]\n assert candidate(n = 4,sums = [1, -1, 2, -2, 3, -3, 4, -4, 0]) == [1, 2, -4, 8]\n assert candidate(n = 5,sums = [0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == [1, 2, 2, 4, 8]\n assert candidate(n = 4,sums = [-1, -2, -3, -4, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [1, 2, -4, 8]\n assert candidate(n = 4,sums = [-9, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7]) == [-2, -3, -4, 8]\n assert candidate(n = 6,sums = [-20, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [2, 3, -4, 8, -16, 32]\n assert candidate(n = 5,sums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]) == [1, 2, 4, 8, 16]\n assert candidate(n = 6,sums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0, 0]\n assert candidate(n = 6,sums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]) == [1, 2, 4, 8, 16, 32]\n assert candidate(n = 5,sums = [0, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11]) == [1, 2, 3, 4, 8]\n assert candidate(n = 5,sums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15]) == [1, -2, 4, -8, 16]\n assert candidate(n = 4,sums = [-3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == [-1, -2, 4, 8]\n assert candidate(n = 5,sums = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == [-1, 2, 4, 8, 16]\n assert candidate(n = 4,sums = [-10, -7, -9, -8, -5, -6, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == [1, -2, 4, -8]\n assert candidate(n = 5,sums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 4, 8, 16]\n assert candidate(n = 5,sums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, -2, 4, -8, 16]\n assert candidate(n = 6,sums = [-63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]) == [-1, -2, -4, -8, -16, -32]\n assert candidate(n = 3,sums = [-4, -2, -1, 0, 0, 1, 2, 4]) == [2, 3, -4]\n assert candidate(n = 5,sums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == [1, 2, 4, 8, 16]\n assert candidate(n = 3,sums = [-1, -2, -3, 0, 1, 2, 3, 4, 5]) == [-1, -2, 4]\n assert candidate(n = 5,sums = [-15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [-1, -2, -4, -8, 16]\n assert candidate(n = 3,sums = [-6, -3, -5, -2, -4, -1, 0, 1, 3, 2, 4, 5]) == [1, -2, -4]\n assert candidate(n = 4,sums = [-5, -4, -3, -2, -1, -1, 0, 0, 1, 1, 2, 3, 4, 5]) == [-1, 2, -4, 4]\n assert candidate(n = 4,sums = [-5, -4, -4, -3, -3, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [-1, 1, 2, -4]\n assert candidate(n = 4,sums = [-6, -4, -3, -2, -2, -1, 0, 0, 1, 2, 2, 3, 4, 6]) == [-2, 3, -4, 4]\n assert candidate(n = 5,sums = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == [0, 1, 2, 4, 8]\n assert candidate(n = 4,sums = [-6, -5, -5, -4, -4, -3, -3, -2, -2, -1, -1, 0, 0, 1, 1, 2]) == [-1, -1, 2, -4]\n assert candidate(n = 5,sums = [-15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [-1, -2, -4, -8, 15]\n assert candidate(n = 1,sums = [0, 2]) == [2]\n assert candidate(n = 5,sums = [-10, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 10]) == [-2, 3, 4, -8, 10]\n assert candidate(n = 5,sums = [-10, -9, -8, -8, -7, -7, -6, -6, -5, -5, -4, -4, -3, -3, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 10]) == [1, -2, 2, 4, -8]\n assert candidate(n = 6,sums = [-31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == [-1, -2, -4, -8, -16, 31]\n assert candidate(n = 5,sums = [31, 17, 21, 18, 12, 13, 19, 14, 20, 24, 8, 11, 9, 5, 4, 10, 0, 15, 7, 3, 16, 6, 2, 1, 23, 22, 16, 25, 26, 30, 27, 29, 31]) == [1, 2, 4, 8, 16]\n assert candidate(n = 3,sums = [-5, -3, -2, -1, 0, 0, 1, 2]) == [-2, -3, 4]\n assert candidate(n = 3,sums = [-1, -1, -1, -1, -1, 0, 0, 0]) == [0, 0, 0]\n assert candidate(n = 5,sums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, -1, -1, -1, -1, -2, -2, -2, -2, -3, -3, -3, -3, -4, -4, -4, -4, -5, -5, -5, -5]) == [0, 0, -1, 2, -4]\n assert candidate(n = 1,sums = [0, 1]) == [1]\n assert candidate(n = 4,sums = [0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == [0, 0, 1, 2]\n assert candidate(n = 1,sums = [0, 3]) == [3]\n assert candidate(n = 2,sums = [-1, 0, 1, 2]) == [-1, 2]\n assert candidate(n = 3,sums = [-1, 0, 1, 2, 3, 4]) == [-1, 2, 4]\n assert candidate(n = 6,sums = [0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10, -11, 11, -12, 12, -13, 13, -14, 14, -15, 15, -16, 16, -17, 17, -18, 18, -19, 19, -20, 20, -21, 21, -22, 22, -23, 23, -24, 24, -25, 25, -26, 26, -27, 27, -28, 28, -29, 29, -30, 30, -31, 31, -32, 32]) == [1, 2, 4, 8, 16, -32]\n assert candidate(n = 4,sums = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == [1, -2, 4, -8]\n assert candidate(n = 3,sums = [-6, -5, -4, -3, -2, -1, 0, 1, 2, 3]) == [1, -2, -4]\n assert candidate(n = 1,sums = [0, -5]) == [-5]\n assert candidate(n = 5,sums = [0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [-1, -2, -4, -8, 16]\n assert candidate(n = 4,sums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0]\n assert candidate(n = 2,sums = [-2, -1, 0, 1]) == [1, -2]\n assert candidate(n = 3,sums = [-3, -1, 0, 1, 2, 3, 4, 6]) == [2, -3, 4]\n assert candidate(n = 3,sums = [-1, -2, -3, 0, 1, 2, 3, 4]) == [-1, -2, 4]\n assert candidate(n = 1,sums = [0, 0]) == [0]\n assert candidate(n = 3,sums = [-6, -5, -5, -4, -3, -3, -2, -1, 0, 0, 1, 2, 3, 4, 5, 6]) == [1, 1, 3]\n assert candidate(n = 3,sums = [-3, -2, -1, -1, 0, 0, 1, 2]) == [-1, -2, 2]\n assert candidate(n = 5,sums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == [0, 0, 0, 0, 0]\n assert candidate(n = 3,sums = [1, 2, 3, 4, 5, 6, 7, 8]) == [1, 2, 4]\n"}, "metadata": {"canonical_parameter_names": ["n", "sums"], "leetcode_dataset_entry_point": "Solution().recoverArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector recoverArray(int n, vector& sums) {", "container": "Solution", "callable": "recoverArray", "parameters": [{"name": "n", "type": "int"}, {"name": "sums", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1984, "task_id": "minimum-difference-between-highest-and-lowest-of-k-scores", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums, where nums[i] represents the score of the ith student. You are also given an integer k.\nPick the scores of any k students from the array so that the difference between the highest and the lowest of the k scores is minimized.\nReturn the minimum possible difference.\n \nExample 1:\n\nInput: nums = [90], k = 1\nOutput: 0\nExplanation: There is one way to pick score(s) of one student:\n- [90]. The difference between the highest and lowest score is 90 - 90 = 0.\nThe minimum possible difference is 0.\n\nExample 2:\n\nInput: nums = [9,4,1,7], k = 2\nOutput: 2\nExplanation: There are six ways to pick score(s) of two students:\n- [9,4,1,7]. The difference between the highest and lowest score is 9 - 4 = 5.\n- [9,4,1,7]. The difference between the highest and lowest score is 9 - 1 = 8.\n- [9,4,1,7]. The difference between the highest and lowest score is 9 - 7 = 2.\n- [9,4,1,7]. The difference between the highest and lowest score is 4 - 1 = 3.\n- [9,4,1,7]. The difference between the highest and lowest score is 7 - 4 = 3.\n- [9,4,1,7]. The difference between the highest and lowest score is 7 - 1 = 6.\nThe minimum possible difference is 2.\n \nConstraints:\n\n1 <= k <= nums.length <= 1000\n0 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [4, 9, 1, 32, 13],k = 3) == 8\n assert candidate(nums = [1, 5, 6, 14, 15],k = 3) == 5\n assert candidate(nums = [9, 4, 1, 7],k = 2) == 2\n assert candidate(nums = [8, 10, 2],k = 2) == 2\n assert candidate(nums = [1, 5, 9, 14, 18],k = 3) == 8\n assert candidate(nums = [4, 9, 1, 17, 6, 11, 22],k = 5) == 10\n assert candidate(nums = [10, 20, 30, 40, 50],k = 1) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 0\n assert candidate(nums = [8, 10, 5, 7, 9, 3],k = 4) == 3\n assert candidate(nums = [4, 9, 1, 32, 13],k = 2) == 3\n assert candidate(nums = [90],k = 1) == 0\n assert candidate(nums = [8, 10, 12, 14, 16],k = 3) == 4\n assert candidate(nums = [4, 2, 1, 3],k = 2) == 1\n assert candidate(nums = [8, 8, 8, 8, 8],k = 5) == 0\n assert candidate(nums = [1, 5, 6, 14, 15],k = 2) == 1\n assert candidate(nums = [100000, 0, 1, 2, 99999],k = 2) == 1\n assert candidate(nums = [8, 10, 15, 17, 20, 23],k = 4) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 3\n assert candidate(nums = [1, 3, 6, 19, 20],k = 3) == 5\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 10) == 900\n assert candidate(nums = [5, 8, 12, 19, 23, 27, 31, 35, 39, 41, 45, 49, 51, 55, 59, 63, 67, 71, 75, 79, 83, 87, 91, 95, 99],k = 5) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == 40\n assert candidate(nums = [28, 90, 3, 23, 90, 18, 39, 72, 45, 67],k = 5) == 27\n assert candidate(nums = [88, 22, 55, 77, 33, 44, 66, 11, 99, 0, 6, 3, 5, 7, 9, 1, 2, 4, 8, 10, 12, 14, 16, 18, 20, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 90, 92, 94, 96, 98],k = 10) == 9\n assert candidate(nums = [50, 40, 30, 20, 10, 90, 80, 70, 60, 100],k = 5) == 40\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 8) == 700\n assert candidate(nums = [1, 3, 6, 19, 20, 25, 28, 30, 31, 32, 33],k = 6) == 8\n assert candidate(nums = [500, 400, 300, 200, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, 10, 20, 30, 40, 50],k = 7) == 30\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4],k = 3) == 0\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 5) == 4\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020],k = 11) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400],k = 13) == 120\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980],k = 15) == 14\n assert candidate(nums = [10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000],k = 3) == 2000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300],k = 15) == 140\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 8) == 7\n assert candidate(nums = [99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111, 0, 99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111, 0],k = 15) == 77777\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 10000, 20000, 30000, 40000, 50000],k = 10) == 40000\n assert candidate(nums = [99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120],k = 6) == 5\n assert candidate(nums = [123, 456, 789, 101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515, 1616, 1717],k = 8) == 505\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],k = 30) == 29\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 0\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 90000, 9000, 900, 90],k = 3) == 89\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 4) == 3\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],k = 5) == 12\n assert candidate(nums = [2, 22, 222, 2222, 22222, 222222, 2222222, 22222222, 222222222],k = 5) == 22220\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 9\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120],k = 10) == 72\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 4) == 3\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 3, 9, 3, 2, 8, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0],k = 20) == 1\n assert candidate(nums = [5, 15, 30, 10, 20, 25, 40, 50],k = 5) == 20\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],k = 11) == 1000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 5) == 40\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 6) == 50\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 1) == 0\n assert candidate(nums = [1, 3, 6, 19, 20, 25, 30, 35, 40, 45, 50],k = 6) == 21\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 3) == 20000\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, -60, -70, -80, -90],k = 4) == 30\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97, 101, 105, 109],k = 10) == 36\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 2) == 0\n assert candidate(nums = [80, 60, 40, 20, 0, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400, 420, 440, 460, 480],k = 7) == 120\n assert candidate(nums = [23, 45, 12, 67, 89, 34, 56, 78, 90, 12, 34, 56, 78, 90, 12, 34, 56, 78, 90],k = 8) == 23\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 2) == 100\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7) == 60\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 3) == 200\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 7) == 60\n assert candidate(nums = [1, 100, 1000, 10000, 100000, 1000000],k = 3) == 999\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110],k = 3) == 2\n assert candidate(nums = [45, 33, 21, 10, 1, 0, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],k = 25) == 41\n assert candidate(nums = [300, 200, 100, 50, 25, 10, 5, 3, 2, 1, 0, 1, 3, 5, 10, 25, 50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 15) == 99\n assert candidate(nums = [99999, 100000, 0, 1, 2, 99998, 3, 4, 5, 6],k = 4) == 3\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 3) == 0\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109, 210, 311, 412, 513, 614, 715, 816, 917, 1018],k = 8) == 77\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 90\n assert candidate(nums = [8, 18, 28, 38, 48, 58, 68, 78, 88, 98, 108, 118, 128, 138, 148, 158],k = 3) == 20\n assert candidate(nums = [34, 7, 23, 32, 5, 62],k = 4) == 27\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 7) == 60\n assert candidate(nums = [5, 8, 12, 18, 23, 30, 37, 45, 53, 62],k = 6) == 25\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],k = 26) == 50\n assert candidate(nums = [55, 45, 35, 25, 15, 5, 0, -5, -10, -15, -20, -25, -30],k = 6) == 25\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 15) == 14\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 4) == 999\n assert candidate(nums = [89, 75, 91, 85, 92, 88, 76, 90, 86, 84],k = 4) == 3\n assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991],k = 10) == 9\n assert candidate(nums = [5, 8, 12, 18, 22, 27, 30, 35, 40, 45, 50],k = 5) == 17\n assert candidate(nums = [987, 654, 321, 654, 321, 987, 654, 321, 987, 654, 321, 987, 654, 321, 987],k = 6) == 333\n assert candidate(nums = [345, 678, 901, 234, 567, 890, 123, 456, 789],k = 4) == 223\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 9) == 16\n assert candidate(nums = [5, 23, 9, 56, 12, 89, 76, 45, 34, 67, 88, 90],k = 5) == 23\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],k = 6) == 99999\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 10) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().minimumDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumDifference(vector& nums, int k) {", "container": "Solution", "callable": "minimumDifference", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1985, "task_id": "find-the-kth-largest-integer-in-the-array", "difficulty": "Medium", "problem_description": "You are given an array of strings nums and an integer k. Each string in nums represents an integer without leading zeros.\nReturn the string that represents the kth largest integer in nums.\nNote: Duplicate numbers should be counted distinctly. For example, if nums is [\"1\",\"2\",\"2\"], \"2\" is the first largest integer, \"2\" is the second-largest integer, and \"1\" is the third-largest integer.\n \nExample 1:\n\nInput: nums = [\"3\",\"6\",\"7\",\"10\"], k = 4\nOutput: \"3\"\nExplanation:\nThe numbers in nums sorted in non-decreasing order are [\"3\",\"6\",\"7\",\"10\"].\nThe 4th largest integer in nums is \"3\".\n\nExample 2:\n\nInput: nums = [\"2\",\"21\",\"12\",\"1\"], k = 3\nOutput: \"2\"\nExplanation:\nThe numbers in nums sorted in non-decreasing order are [\"1\",\"2\",\"12\",\"21\"].\nThe 3rd largest integer in nums is \"2\".\n\nExample 3:\n\nInput: nums = [\"0\",\"0\"], k = 2\nOutput: \"0\"\nExplanation:\nThe numbers in nums sorted in non-decreasing order are [\"0\",\"0\"].\nThe 2nd largest integer in nums is \"0\".\n\n \nConstraints:\n\n1 <= k <= nums.length <= 104\n1 <= nums[i].length <= 100\nnums[i] consists of only digits.\nnums[i] will not have any leading zeros.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = ['100', '200', '300', '400', '500'],k = 2) == \"400\"\n assert candidate(nums = ['2', '21', '12', '1'],k = 3) == \"2\"\n assert candidate(nums = ['9', '8', '7', '6', '5', '4', '3', '2', '1'],k = 5) == \"5\"\n assert candidate(nums = ['100', '200', '300', '400'],k = 2) == \"300\"\n assert candidate(nums = ['9', '11', '8', '9', '10'],k = 5) == \"8\"\n assert candidate(nums = ['9', '11', '2', '22'],k = 2) == \"11\"\n assert candidate(nums = ['10', '20', '30', '40', '50'],k = 5) == \"10\"\n assert candidate(nums = ['10', '10', '10', '10'],k = 3) == \"10\"\n assert candidate(nums = ['0', '0'],k = 2) == \"0\"\n assert candidate(nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'],k = 10) == \"1\"\n assert candidate(nums = ['100', '200', '300', '400'],k = 1) == \"400\"\n assert candidate(nums = ['10', '2', '11', '3', '7'],k = 1) == \"11\"\n assert candidate(nums = ['5', '3', '8', '6', '7'],k = 1) == \"8\"\n assert candidate(nums = ['1', '2', '2', '3', '3', '3'],k = 4) == \"2\"\n assert candidate(nums = ['10', '100', '1000', '10000'],k = 3) == \"100\"\n assert candidate(nums = ['3', '6', '7', '10'],k = 4) == \"3\"\n assert candidate(nums = ['100', '200', '300', '400', '500', '600', '700', '800', '900'],k = 9) == \"100\"\n assert candidate(nums = ['500', '50', '5000', '50000', '5'],k = 4) == \"50\"\n assert candidate(nums = ['987654321', '987654320', '987654319', '987654318', '987654317'],k = 5) == \"987654317\"\n assert candidate(nums = ['123456789', '987654321', '135792468', '246813579', '864209753'],k = 3) == \"246813579\"\n assert candidate(nums = ['1', '11', '111', '1111', '11111'],k = 3) == \"111\"\n assert candidate(nums = ['111', '222', '333', '444', '555', '666', '777', '888', '999', '000'],k = 7) == \"333\"\n assert candidate(nums = ['500', '50', '5', '5000'],k = 3) == \"50\"\n assert candidate(nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15'],k = 10) == \"6\"\n assert candidate(nums = ['1', '10', '100', '1000', '10000', '100000', '1000000'],k = 5) == \"100\"\n assert candidate(nums = ['1', '3', '5', '7', '9', '11', '13', '15', '17', '19'],k = 7) == \"7\"\n assert candidate(nums = ['123', '456', '789', '101112', '131415', '161718', '192021', '222324', '252627', '282930'],k = 5) == \"161718\"\n assert candidate(nums = ['1000000', '999999', '100000', '99999', '10000', '9999', '1000', '999', '100', '99', '10', '9'],k = 8) == \"999\"\n assert candidate(nums = ['999', '1000', '1001', '1002', '1003'],k = 2) == \"1002\"\n assert candidate(nums = ['987654321', '987654320', '987654319', '987654318', '987654317'],k = 4) == \"987654318\"\n assert candidate(nums = ['9876543210', '9876543211', '9876543212', '9876543213', '9876543214'],k = 5) == \"9876543210\"\n assert candidate(nums = ['123', '456', '789', '123', '456', '789', '123', '456', '789'],k = 5) == \"456\"\n assert candidate(nums = ['10', '100', '1000', '10000', '100000', '1000000', '10000000', '100000000', '1000000000'],k = 3) == \"10000000\"\n assert candidate(nums = ['1000000000', '1000000001', '1000000002', '1000000003', '1000000004'],k = 2) == \"1000000003\"\n assert candidate(nums = ['100000000000000000000000000000000000000000000000000000000000000', '99999999999999999999999999999999999999999999999999999999999999'],k = 1) == \"100000000000000000000000000000000000000000000000000000000000000\"\n assert candidate(nums = ['0', '00', '000', '0000', '00000'],k = 3) == \"000\"\n assert candidate(nums = ['5000', '4000', '3000', '2000', '1000', '500', '400', '300', '200', '100'],k = 5) == \"1000\"\n assert candidate(nums = ['987654321', '87654321', '7654321', '654321', '54321', '4321', '321', '21', '1'],k = 3) == \"7654321\"\n assert candidate(nums = ['1', '1', '2', '2', '3', '3', '4', '4', '5', '5'],k = 8) == \"2\"\n assert candidate(nums = ['111111111', '222222222', '333333333', '444444444', '555555555', '666666666', '777777777', '888888888', '999999999'],k = 9) == \"111111111\"\n assert candidate(nums = ['1', '11', '111', '1111', '11111', '111111'],k = 6) == \"1\"\n assert candidate(nums = ['12345', '12345', '12345', '12345', '12345', '12345', '12345', '12345', '12345', '12345'],k = 8) == \"12345\"\n assert candidate(nums = ['99', '98', '97', '96', '95', '94', '93', '92', '91', '90'],k = 5) == \"95\"\n assert candidate(nums = ['10', '2', '3', '4', '5', '6', '7', '8', '9'],k = 1) == \"10\"\n assert candidate(nums = ['9876543210', '987654321', '98765432', '9876543', '987654', '98765', '9876', '987', '98', '9'],k = 5) == \"987654\"\n assert candidate(nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20'],k = 10) == \"11\"\n assert candidate(nums = ['1', '3', '5', '7', '9', '11', '13', '15', '17', '19'],k = 1) == \"19\"\n assert candidate(nums = ['11111111111111111111', '22222222222222222222', '33333333333333333333', '44444444444444444444', '55555555555555555555'],k = 2) == \"44444444444444444444\"\n assert candidate(nums = ['100', '1000', '10000', '100000', '1000000'],k = 4) == \"1000\"\n assert candidate(nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20'],k = 19) == \"2\"\n assert candidate(nums = ['1', '10', '100', '1000', '10000', '100000', '1000000', '10000000', '100000000', '1000000000'],k = 7) == \"1000\"\n assert candidate(nums = ['1000', '999', '100', '99', '10', '9', '1'],k = 7) == \"1\"\n assert candidate(nums = ['9', '8', '7', '6', '5', '4', '3', '2', '1'],k = 9) == \"1\"\n assert candidate(nums = ['1', '10', '100', '1000', '10000', '100000', '1000000', '10000000', '100000000', '1000000000'],k = 3) == \"10000000\"\n assert candidate(nums = ['999999999999999999', '888888888888888888', '777777777777777777', '666666666666666666', '555555555555555555'],k = 3) == \"777777777777777777\"\n assert candidate(nums = ['123', '123', '123', '123', '123', '123', '123', '123', '123', '123'],k = 10) == \"123\"\n assert candidate(nums = ['123456789', '987654321', '123456789', '987654321', '123456789', '987654321', '123456789', '987654321', '123456789', '987654321'],k = 5) == \"987654321\"\n assert candidate(nums = ['1000', '999', '888', '777', '666', '555', '444', '333', '222', '111'],k = 10) == \"111\"\n assert candidate(nums = ['123456789', '987654321', '111111111', '999999999', '222222222'],k = 3) == \"222222222\"\n assert candidate(nums = ['111', '222', '333', '444', '555', '666', '777', '888', '999', '1111'],k = 6) == \"555\"\n assert candidate(nums = ['10000', '9999', '9998', '9997', '9996', '9995', '9994', '9993', '9992', '9991'],k = 6) == \"9995\"\n assert candidate(nums = ['1000', '1000', '1000', '1000', '1000', '1000', '1000', '1000', '1000', '1000'],k = 1) == \"1000\"\n assert candidate(nums = ['9', '99', '999', '9999', '99999', '999999', '9999999', '99999999', '999999999'],k = 8) == \"99\"\n assert candidate(nums = ['1000000000', '999999999', '100000000', '99999999', '10000000', '9999999', '1000000', '999999', '100000', '99999'],k = 10) == \"99999\"\n assert candidate(nums = ['123456789', '987654321', '135792468', '246813579'],k = 4) == \"123456789\"\n assert candidate(nums = ['1000000000', '1000000001', '1000000002', '1000000003', '1000000004', '1000000005'],k = 2) == \"1000000004\"\n assert candidate(nums = ['100', '200', '300', '400', '500', '600', '700', '800', '900', '1000'],k = 10) == \"100\"\n assert candidate(nums = ['123456789012345678901234567890', '987654321098765432109876543210', '111111111111111111111111111111', '999999999999999999999999999999', '222222222222222222222222222222'],k = 3) == \"222222222222222222222222222222\"\n assert candidate(nums = ['11111', '22222', '33333', '44444', '55555', '66666', '77777', '88888', '99999', '100000'],k = 9) == \"22222\"\n assert candidate(nums = ['500', '500', '500', '500', '500', '500', '500', '500', '500', '500'],k = 5) == \"500\"\n assert candidate(nums = ['9', '19', '29', '39', '49', '59', '69', '79', '89', '99'],k = 1) == \"99\"\n assert candidate(nums = ['9', '8', '7', '6', '5', '4', '3', '2', '1'],k = 1) == \"9\"\n assert candidate(nums = ['9', '99', '999', '9999', '99999'],k = 3) == \"999\"\n assert candidate(nums = ['1111111111', '2222222222', '3333333333', '4444444444', '5555555555'],k = 1) == \"5555555555\"\n assert candidate(nums = ['9999999999', '8888888888', '7777777777', '6666666666', '5555555555', '4444444444', '3333333333', '2222222222', '1111111111', '0'],k = 10) == \"0\"\n assert candidate(nums = ['111', '222', '333', '444', '555', '666', '777', '888', '999', '1111', '2222', '3333', '4444', '5555', '6666', '7777', '8888', '9999'],k = 15) == \"444\"\n assert candidate(nums = ['9999999999', '8888888888', '7777777777', '6666666666', '5555555555'],k = 3) == \"7777777777\"\n assert candidate(nums = ['1000', '1000', '1000', '1000', '1000', '1000'],k = 3) == \"1000\"\n assert candidate(nums = ['1111111111', '2222222222', '3333333333', '4444444444', '5555555555', '6666666666', '7777777777', '8888888888', '9999999999', '10000000000'],k = 2) == \"9999999999\"\n assert candidate(nums = ['1', '10', '100', '1000', '10000', '100000'],k = 5) == \"10\"\n assert candidate(nums = ['9', '29', '39', '49', '59', '69', '79', '89', '99', '109'],k = 8) == \"39\"\n assert candidate(nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15'],k = 15) == \"1\"\n assert candidate(nums = ['123456789', '987654321', '111111111', '222222222', '333333333'],k = 4) == \"123456789\"\n assert candidate(nums = ['123', '456', '789', '101112', '131415'],k = 1) == \"131415\"\n assert candidate(nums = ['123', '456', '789', '101112', '131415', '161718', '192021', '222324', '252627', '282930'],k = 4) == \"192021\"\n assert candidate(nums = ['5', '10', '15', '20', '25', '30', '35', '40'],k = 7) == \"10\"\n assert candidate(nums = ['1000000000', '999999999', '1000000000', '999999999', '1000000000', '999999999', '1000000000', '999999999', '1000000000', '999999999'],k = 8) == \"999999999\"\n assert candidate(nums = ['999999999999999999', '1000000000000000000', '999999999999999998'],k = 1) == \"1000000000000000000\"\n assert candidate(nums = ['100', '1000', '10', '1'],k = 2) == \"100\"\n assert candidate(nums = ['100', '200', '300', '400', '500', '600', '700', '800', '900'],k = 7) == \"300\"\n assert candidate(nums = ['1234567890', '1234567891', '1234567892', '1234567893', '1234567894', '1234567895', '1234567896', '1234567897', '1234567898', '1234567899'],k = 9) == \"1234567891\"\n assert candidate(nums = ['987654321', '98765432', '9876543', '987654', '98765', '9876', '987', '98', '9'],k = 8) == \"98\"\n assert candidate(nums = ['99999', '88888', '77777', '66666', '55555', '44444', '33333', '22222', '11111'],k = 9) == \"11111\"\n assert candidate(nums = ['1', '10', '100', '1000', '10000'],k = 3) == \"100\"\n assert candidate(nums = ['10000', '10001', '10002', '10003', '10004', '10005', '10006', '10007', '10008', '10009'],k = 8) == \"10002\"\n assert candidate(nums = ['123456789', '987654321', '111111111', '222222222', '333333333'],k = 2) == \"333333333\"\n assert candidate(nums = ['999999999999999999', '999999999999999998', '1000000000000000000'],k = 2) == \"999999999999999999\"\n assert candidate(nums = ['111', '222', '333', '444', '555', '666', '777', '888', '999', '111', '222', '333', '444', '555', '666', '777', '888', '999', '111', '222'],k = 15) == \"222\"\n assert candidate(nums = ['999999999999999999', '1000000000000000000', '999999999999999998'],k = 2) == \"999999999999999999\"\n assert candidate(nums = ['1', '10', '100', '1000', '10000', '100000', '1000000', '10000000', '100000000', '1000000000'],k = 10) == \"1\"\n assert candidate(nums = ['100', '200', '300', '400', '500', '600', '700', '800', '900', '1000'],k = 7) == \"400\"\n assert candidate(nums = ['999', '998', '997', '996', '995', '994', '993', '992', '991', '990'],k = 10) == \"990\"\n assert candidate(nums = ['1', '11', '111', '1111', '11111', '111111', '1111111', '11111111', '111111111', '1111111111'],k = 3) == \"11111111\"\n assert candidate(nums = ['9876543210', '102030405060708090', '123456789', '987654321', '1000000000', '999999999', '1111111111', '2222222222', '3333333333', '4444444444'],k = 3) == \"4444444444\"\n assert candidate(nums = ['9', '99', '999', '9999', '99999', '999999', '9999999', '99999999', '999999999', '9999999999'],k = 5) == \"999999\"\n assert candidate(nums = ['123', '456', '789', '101112', '131415', '161718', '192021', '222324', '252627', '282930'],k = 6) == \"131415\"\n assert candidate(nums = ['123', '456', '789', '101112', '131415', '161718'],k = 3) == \"101112\"\n assert candidate(nums = ['1000', '1000', '1000', '1000', '1000', '1000', '1000', '1000', '1000', '1000'],k = 5) == \"1000\"\n assert candidate(nums = ['1000000', '999999', '888888', '777777', '666666'],k = 2) == \"999999\"\n assert candidate(nums = ['999', '998', '997', '996', '995', '994', '993', '992', '991', '990'],k = 5) == \"995\"\n assert candidate(nums = ['1', '10', '100', '1000', '10000', '100000', '1000000', '10000000', '100000000', '1000000000'],k = 5) == \"100000\"\n assert candidate(nums = ['12345678901234567890', '12345678901234567891', '12345678901234567892'],k = 2) == \"12345678901234567891\"\n assert candidate(nums = ['999', '888', '777', '666', '555', '444', '333', '222', '111', '0'],k = 1) == \"999\"\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().kthLargestNumber", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string kthLargestNumber(vector& nums, int k) {", "container": "Solution", "callable": "kthLargestNumber", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1986, "task_id": "minimum-number-of-work-sessions-to-finish-the-tasks", "difficulty": "Medium", "problem_description": "There are n tasks assigned to you. The task times are represented as an integer array tasks of length n, where the ith task takes tasks[i] hours to finish. A work session is when you work for at most sessionTime consecutive hours and then take a break.\nYou should finish the given tasks in a way that satisfies the following conditions:\n\nIf you start a task in a work session, you must complete it in the same work session.\nYou can start a new task immediately after finishing the previous one.\nYou may complete the tasks in any order.\n\nGiven tasks and sessionTime, return the minimum number of work sessions needed to finish all the tasks following the conditions above.\nThe tests are generated such that sessionTime is greater than or equal to the maximum element in tasks[i].\n \nExample 1:\n\nInput: tasks = [1,2,3], sessionTime = 3\nOutput: 2\nExplanation: You can finish the tasks in two work sessions.\n- First work session: finish the first and the second tasks in 1 + 2 = 3 hours.\n- Second work session: finish the third task in 3 hours.\n\nExample 2:\n\nInput: tasks = [3,1,3,1,1], sessionTime = 8\nOutput: 2\nExplanation: You can finish the tasks in two work sessions.\n- First work session: finish all the tasks except the last one in 3 + 1 + 3 + 1 = 8 hours.\n- Second work session: finish the last task in 1 hour.\n\nExample 3:\n\nInput: tasks = [1,2,3,4,5], sessionTime = 15\nOutput: 1\nExplanation: You can finish all the tasks in one work session.\n\n \nConstraints:\n\nn == tasks.length\n1 <= n <= 14\n1 <= tasks[i] <= 10\nmax(tasks[i]) <= sessionTime <= 15\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(tasks = [1, 3, 2, 4],sessionTime = 5) == 2\n assert candidate(tasks = [5, 7, 4, 2, 6],sessionTime = 10) == 3\n assert candidate(tasks = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],sessionTime = 12) == 5\n assert candidate(tasks = [1, 2, 3],sessionTime = 3) == 2\n assert candidate(tasks = [5, 5, 5, 5],sessionTime = 5) == 4\n assert candidate(tasks = [9, 9, 9, 9],sessionTime = 9) == 4\n assert candidate(tasks = [2, 3, 3, 4, 6],sessionTime = 6) == 3\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 2) == 7\n assert candidate(tasks = [14],sessionTime = 14) == 1\n assert candidate(tasks = [7, 7, 7, 7],sessionTime = 14) == 2\n assert candidate(tasks = [10, 10, 10, 10],sessionTime = 10) == 4\n assert candidate(tasks = [10, 10, 10],sessionTime = 10) == 3\n assert candidate(tasks = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 1],sessionTime = 14) == 8\n assert candidate(tasks = [14, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 14) == 2\n assert candidate(tasks = [2, 3, 4, 5, 1],sessionTime = 6) == 3\n assert candidate(tasks = [1, 2, 3, 4, 5],sessionTime = 15) == 1\n assert candidate(tasks = [7, 2, 7, 2, 7],sessionTime = 12) == 3\n assert candidate(tasks = [8, 8, 8, 8, 8, 8, 8, 8],sessionTime = 15) == 8\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],sessionTime = 15) == 7\n assert candidate(tasks = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],sessionTime = 10) == 14\n assert candidate(tasks = [1, 2, 3, 4],sessionTime = 10) == 1\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],sessionTime = 15) == 5\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],sessionTime = 14) == 8\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 14) == 1\n assert candidate(tasks = [3, 1, 3, 1, 1],sessionTime = 8) == 2\n assert candidate(tasks = [7, 2, 4, 3, 5],sessionTime = 12) == 2\n assert candidate(tasks = [1, 2, 3, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7],sessionTime = 10) == 6\n assert candidate(tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1],sessionTime = 10) == 6\n assert candidate(tasks = [1, 3, 5, 7, 9, 11, 13, 1, 3, 5, 7, 9, 11, 13],sessionTime = 15) == 7\n assert candidate(tasks = [7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7],sessionTime = 13) == 5\n assert candidate(tasks = [2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5],sessionTime = 12) == 5\n assert candidate(tasks = [1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6],sessionTime = 12) == 5\n assert candidate(tasks = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1],sessionTime = 11) == 7\n assert candidate(tasks = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],sessionTime = 15) == 14\n assert candidate(tasks = [10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 15) == 4\n assert candidate(tasks = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],sessionTime = 14) == 7\n assert candidate(tasks = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2],sessionTime = 8) == 5\n assert candidate(tasks = [1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 14],sessionTime = 14) == 5\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],sessionTime = 28) == 4\n assert candidate(tasks = [3, 6, 7, 9, 10, 1, 2, 4, 5, 8, 2, 3, 4, 6],sessionTime = 10) == 7\n assert candidate(tasks = [7, 8, 7, 8, 7, 8, 7, 8],sessionTime = 15) == 4\n assert candidate(tasks = [7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7],sessionTime = 12) == 5\n assert candidate(tasks = [2, 3, 5, 7, 11, 13],sessionTime = 15) == 3\n assert candidate(tasks = [2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9],sessionTime = 14) == 6\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],sessionTime = 20) == 6\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6],sessionTime = 10) == 6\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],sessionTime = 20) == 6\n assert candidate(tasks = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5],sessionTime = 10) == 4\n assert candidate(tasks = [8, 8, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 15) == 4\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],sessionTime = 15) == 5\n assert candidate(tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7],sessionTime = 15) == 6\n assert candidate(tasks = [3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1],sessionTime = 7) == 5\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 14],sessionTime = 14) == 2\n assert candidate(tasks = [10, 10, 10, 10, 1, 2, 3, 4],sessionTime = 15) == 4\n assert candidate(tasks = [9, 1, 4, 8, 3, 2, 5, 6, 7, 10, 1, 2, 3, 4],sessionTime = 10) == 7\n assert candidate(tasks = [7, 7, 7, 7, 7, 7, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 14) == 4\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],sessionTime = 5) == 14\n assert candidate(tasks = [10, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 10, 1, 2],sessionTime = 10) == 8\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5],sessionTime = 10) == 4\n assert candidate(tasks = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],sessionTime = 30) == 5\n assert candidate(tasks = [7, 3, 4, 5, 6, 2, 8, 9, 10, 1, 2, 3, 4, 5],sessionTime = 10) == 7\n assert candidate(tasks = [10, 10, 10, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4],sessionTime = 14) == 4\n assert candidate(tasks = [2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5],sessionTime = 10) == 5\n assert candidate(tasks = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],sessionTime = 14) == 4\n assert candidate(tasks = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],sessionTime = 9) == 5\n assert candidate(tasks = [2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],sessionTime = 12) == 6\n assert candidate(tasks = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],sessionTime = 9) == 5\n assert candidate(tasks = [2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7],sessionTime = 12) == 6\n assert candidate(tasks = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5],sessionTime = 10) == 5\n assert candidate(tasks = [1, 2, 3, 4, 3, 2, 1, 4, 3, 2, 1, 4, 3, 2],sessionTime = 8) == 5\n assert candidate(tasks = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],sessionTime = 10) == 14\n assert candidate(tasks = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5],sessionTime = 9) == 5\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],sessionTime = 10) == 7\n assert candidate(tasks = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4],sessionTime = 20) == 4\n assert candidate(tasks = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4],sessionTime = 10) == 4\n assert candidate(tasks = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],sessionTime = 16) == 7\n assert candidate(tasks = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1],sessionTime = 10) == 14\n assert candidate(tasks = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],sessionTime = 13) == 5\n assert candidate(tasks = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],sessionTime = 10) == 7\n assert candidate(tasks = [2, 4, 6, 8, 10, 12, 14, 1, 3, 5, 7, 9, 11, 13],sessionTime = 14) == 8\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2],sessionTime = 6) == 4\n assert candidate(tasks = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43],sessionTime = 15) == inf\n assert candidate(tasks = [10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 10) == 5\n assert candidate(tasks = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],sessionTime = 4) == 7\n assert candidate(tasks = [9, 6, 7, 8, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14],sessionTime = 14) == 8\n assert candidate(tasks = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3],sessionTime = 6) == 6\n assert candidate(tasks = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5],sessionTime = 10) == 6\n assert candidate(tasks = [9, 6, 3, 2, 1, 9, 6, 3, 2, 1, 9, 6, 3, 2],sessionTime = 10) == 7\n assert candidate(tasks = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],sessionTime = 13) == 3\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],sessionTime = 10) == inf\n assert candidate(tasks = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2],sessionTime = 10) == 5\n assert candidate(tasks = [10, 10, 10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],sessionTime = 15) == 6\n assert candidate(tasks = [10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 10) == 5\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 14],sessionTime = 10) == inf\n assert candidate(tasks = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4],sessionTime = 8) == 4\n assert candidate(tasks = [1, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7],sessionTime = 12) == 6\n assert candidate(tasks = [1, 3, 2, 4, 6, 5, 7, 8, 9, 10, 11, 12, 13, 14],sessionTime = 14) == 8\n assert candidate(tasks = [14, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 14) == 2\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],sessionTime = 13) == inf\n assert candidate(tasks = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],sessionTime = 4) == 6\n assert candidate(tasks = [3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 1, 1],sessionTime = 9) == 4\n assert candidate(tasks = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8],sessionTime = 15) == 5\n assert candidate(tasks = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],sessionTime = 12) == 7\n assert candidate(tasks = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5],sessionTime = 6) == 7\n assert candidate(tasks = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],sessionTime = 8) == 4\n assert candidate(tasks = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1],sessionTime = 8) == 14\n assert candidate(tasks = [3, 2, 3, 2, 3, 2, 3, 2],sessionTime = 5) == 4\n assert candidate(tasks = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],sessionTime = 10) == 6\n assert candidate(tasks = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43],sessionTime = 20) == inf\n assert candidate(tasks = [1, 3, 5, 7, 9, 11, 13, 11, 9, 7, 5, 3, 1],sessionTime = 15) == 6\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 2) == 8\n assert candidate(tasks = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8],sessionTime = 14) == 5\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],sessionTime = 10) == inf\n assert candidate(tasks = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2],sessionTime = 5) == 6\n assert candidate(tasks = [2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5],sessionTime = 10) == 5\n assert candidate(tasks = [1, 3, 5, 7, 9, 11, 13, 15, 1, 3, 5, 7, 9, 11],sessionTime = 15) == 7\n assert candidate(tasks = [7, 7, 7, 7, 6, 6, 6, 5, 5, 4, 4, 3, 3, 2],sessionTime = 15) == 5\n assert candidate(tasks = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],sessionTime = 8) == 7\n assert candidate(tasks = [1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7],sessionTime = 14) == 5\n assert candidate(tasks = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8],sessionTime = 12) == 6\n assert candidate(tasks = [10, 10, 10, 10, 10, 10, 1, 1, 1, 1, 1, 1, 1, 1],sessionTime = 20) == 4\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],sessionTime = 7) == inf\n assert candidate(tasks = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],sessionTime = 20) == 7\n"}, "metadata": {"canonical_parameter_names": ["tasks", "sessionTime"], "leetcode_dataset_entry_point": "Solution().minSessions", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minSessions(vector& tasks, int sessionTime) {", "container": "Solution", "callable": "minSessions", "parameters": [{"name": "tasks", "type": "vector&"}, {"name": "sessionTime", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1987, "task_id": "number-of-unique-good-subsequences", "difficulty": "Hard", "problem_description": "You are given a binary string binary. A subsequence of binary is considered good if it is not empty and has no leading zeros (with the exception of \"0\").\nFind the number of unique good subsequences of binary.\n\nFor example, if binary = \"001\", then all the good subsequences are [\"0\", \"0\", \"1\"], so the unique good subsequences are \"0\" and \"1\". Note that subsequences \"00\", \"01\", and \"001\" are not good because they have leading zeros.\n\nReturn the number of unique good subsequences of binary. Since the answer may be very large, return it modulo 109 + 7.\nA subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.\n \nExample 1:\n\nInput: binary = \"001\"\nOutput: 2\nExplanation: The good subsequences of binary are [\"0\", \"0\", \"1\"].\nThe unique good subsequences are \"0\" and \"1\".\n\nExample 2:\n\nInput: binary = \"11\"\nOutput: 2\nExplanation: The good subsequences of binary are [\"1\", \"1\", \"11\"].\nThe unique good subsequences are \"1\" and \"11\".\nExample 3:\n\nInput: binary = \"101\"\nOutput: 5\nExplanation: The good subsequences of binary are [\"1\", \"0\", \"1\", \"10\", \"11\", \"101\"]. \nThe unique good subsequences are \"0\", \"1\", \"10\", \"11\", and \"101\".\n\n \nConstraints:\n\n1 <= binary.length <= 105\nbinary consists of only '0's and '1's.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(binary = \"101\") == 5\n assert candidate(binary = \"1111\") == 4\n assert candidate(binary = \"1\") == 1\n assert candidate(binary = \"010101\") == 13\n assert candidate(binary = \"111000111\") == 43\n assert candidate(binary = \"10000100001\") == 64\n assert candidate(binary = \"1001001\") == 26\n assert candidate(binary = \"1010101010\") == 144\n assert candidate(binary = \"00000\") == 1\n assert candidate(binary = \"000000\") == 1\n assert candidate(binary = \"0000000000\") == 1\n assert candidate(binary = \"000\") == 1\n assert candidate(binary = \"001\") == 2\n assert candidate(binary = \"11\") == 2\n assert candidate(binary = \"0101010101\") == 89\n assert candidate(binary = \"1100110011\") == 99\n assert candidate(binary = \"0101010\") == 21\n assert candidate(binary = \"0\") == 1\n assert candidate(binary = \"111111\") == 6\n assert candidate(binary = \"100101010\") == 76\n assert candidate(binary = \"1000000000000000000000000000000000000000000000000000000000000001\") == 127\n assert candidate(binary = \"1101\") == 8\n assert candidate(binary = \"1001010\") == 29\n assert candidate(binary = \"01010101\") == 34\n assert candidate(binary = \"11010\") == 13\n assert candidate(binary = \"11111\") == 5\n assert candidate(binary = \"1111111111\") == 10\n assert candidate(binary = \"00000000000000000000000000000000000000000001\") == 2\n assert candidate(binary = \"11011011011011011011\") == 7953\n assert candidate(binary = \"10000000000000000001\") == 39\n assert candidate(binary = \"010101010101010101010101\") == 75025\n assert candidate(binary = \"11111111111111111111111111111111111111111110\") == 87\n assert candidate(binary = \"100000000000000000000000\") == 25\n assert candidate(binary = \"101010101010101010101010101010101010101010101010101\") == 316290802\n assert candidate(binary = \"10101010101010101010\") == 17711\n assert candidate(binary = \"010101010101010101010101010101010101010101010101010\") == 951279875\n assert candidate(binary = \"0000000011111111\") == 9\n assert candidate(binary = \"11110000111100001111000011110000\") == 121393\n assert candidate(binary = \"110110110110\") == 265\n assert candidate(binary = \"11111000001111100000\") == 836\n assert candidate(binary = \"1010101010101\") == 610\n assert candidate(binary = \"111000111000\") == 142\n assert candidate(binary = \"1001001001001001001001001001001001\") == 3650401\n assert candidate(binary = \"0101010101010101010101010101\") == 514229\n assert candidate(binary = \"010101010101\") == 233\n assert candidate(binary = \"1010101010101010101010101010101010101010\") == 267914296\n assert candidate(binary = \"0101010101010101\") == 1597\n assert candidate(binary = \"1111111111111111111111111111111111111111\") == 40\n assert candidate(binary = \"11001100110011001100\") == 8119\n assert candidate(binary = \"000000000001\") == 2\n assert candidate(binary = \"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110\") == 199\n assert candidate(binary = \"01010101010101010101010101010101010101010101010\") == 807526948\n assert candidate(binary = \"10101010101010101010101\") == 75025\n assert candidate(binary = \"1001001001\") == 97\n assert candidate(binary = \"11001010010111\") == 545\n assert candidate(binary = \"000111111111111111111111111111111111111111111111111\") == 49\n assert candidate(binary = \"111111111111111111111111\") == 24\n assert candidate(binary = \"11111111111111111111111111111111111111111111\") == 44\n assert candidate(binary = \"1001001001001001001001001001001001001001001001001001001001\") == 379190178\n assert candidate(binary = \"000000000000000000000000000000000000000000000000001\") == 2\n assert candidate(binary = \"0101010101010101010101010101010101010101\") == 165580141\n assert candidate(binary = \"110110110110110110\") == 3691\n assert candidate(binary = \"1111000011110000\") == 377\n assert candidate(binary = \"000000000000\") == 1\n assert candidate(binary = \"1111100000011111\") == 191\n assert candidate(binary = \"1111111111111111111111111111\") == 28\n assert candidate(binary = \"111000111000111000111000111000111000111000111000111000111\") == 619446900\n assert candidate(binary = \"110101010101\") == 377\n assert candidate(binary = \"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001\") == 2\n assert candidate(binary = \"1001001001001001\") == 1351\n assert candidate(binary = \"1100110011001100\") == 1393\n assert candidate(binary = \"00000000000000000000000000000000\") == 1\n assert candidate(binary = \"01010101010101010101010101010101010101010101\") == 134903163\n assert candidate(binary = \"1010101010101010101010101010101010101010101010101011\") == 681301736\n assert candidate(binary = \"10111001001010011001\") == 8492\n assert candidate(binary = \"11111111111111111110\") == 39\n assert candidate(binary = \"111000111000111000111000111000111000111000111000\") == 239244622\n assert candidate(binary = \"101010101010\") == 377\n assert candidate(binary = \"000000000011111111110000000000\") == 111\n assert candidate(binary = \"00000000000000000000\") == 1\n assert candidate(binary = \"1111100000111110000011111\") == 4341\n assert candidate(binary = \"100100100100100100100100100100100100100100100100100\") == 694626305\n assert candidate(binary = \"000111000111000\") == 142\n assert candidate(binary = \"001100110011\") == 99\n assert candidate(binary = \"11000110001100011000\") == 4401\n assert candidate(binary = \"1000000000000000001\") == 37\n assert candidate(binary = \"111100001111000011110000111100001111000011110000111\") == 133957148\n assert candidate(binary = \"10010101010101010101\") == 15127\n assert candidate(binary = \"01010101010101010101\") == 10946\n assert candidate(binary = \"0001111111000\") == 29\n"}, "metadata": {"canonical_parameter_names": ["binary"], "leetcode_dataset_entry_point": "Solution().numberOfUniqueGoodSubsequences", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numberOfUniqueGoodSubsequences(string binary) {", "container": "Solution", "callable": "numberOfUniqueGoodSubsequences", "parameters": [{"name": "binary", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1991, "task_id": "find-the-middle-index-in-array", "difficulty": "Easy", "problem_description": "Given a 0-indexed integer array nums, find the leftmost middleIndex (i.e., the smallest amongst all the possible ones).\nA middleIndex is an index where nums[0] + nums[1] + ... + nums[middleIndex-1] == nums[middleIndex+1] + nums[middleIndex+2] + ... + nums[nums.length-1].\nIf middleIndex == 0, the left side sum is considered to be 0. Similarly, if middleIndex == nums.length - 1, the right side sum is considered to be 0.\nReturn the leftmost middleIndex that satisfies the condition, or -1 if there is no such index.\n \nExample 1:\n\nInput: nums = [2,3,-1,8,4]\nOutput: 3\nExplanation: The sum of the numbers before index 3 is: 2 + 3 + -1 = 4\nThe sum of the numbers after index 3 is: 4 = 4\n\nExample 2:\n\nInput: nums = [1,-1,4]\nOutput: 2\nExplanation: The sum of the numbers before index 2 is: 1 + -1 = 0\nThe sum of the numbers after index 2 is: 0\n\nExample 3:\n\nInput: nums = [2,5]\nOutput: -1\nExplanation: There is no valid middleIndex.\n\n \nConstraints:\n\n1 <= nums.length <= 100\n-1000 <= nums[i] <= 1000\n\n \nNote: This question is the same as 724: https://leetcode.com/problems/find-pivot-index/\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, -1, 4]) == 2\n assert candidate(nums = [1]) == 0\n assert candidate(nums = [1, 100]) == -1\n assert candidate(nums = [0, 1]) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5]) == -1\n assert candidate(nums = [2, 5]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == -1\n assert candidate(nums = [1, 0]) == 0\n assert candidate(nums = [2, 3, -1, 8, 4]) == 3\n assert candidate(nums = [0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == -1\n assert candidate(nums = [-1, -1, -1, -1]) == -1\n assert candidate(nums = [1, 7, 3, 6, 5, 6]) == 3\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [1000, -1000, 1000, -1000]) == -1\n assert candidate(nums = [1, 1]) == -1\n assert candidate(nums = [1, 2, 3]) == -1\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000]) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(nums = [1000, -500, 250, 250, -1000, 500, 500, 0, 0, 0]) == 0\n assert candidate(nums = [100, 0, -100, 0, 100, 0, -100]) == 3\n assert candidate(nums = [100, -50, 25, 25, -100, 50, 50]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41]) == -1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [0, 1, 0, -1, 0, 1, 0, -1, 0]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == -1\n assert candidate(nums = [7, 1, 5, 2, -4, 3, 0, 1, -2, 3]) == -1\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == -1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1]) == 0\n assert candidate(nums = [5, -10, 10, 5, 0]) == -1\n assert candidate(nums = [-5, 5, -5, 5, -5, 5]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == -1\n assert candidate(nums = [3, -2, 1, 6, -4, 2, 5]) == -1\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20]) == -1\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40]) == 6\n assert candidate(nums = [100, 200, -300, 400, -500, 600, -700, 800]) == -1\n assert candidate(nums = [7, 1, 5, 2, -4, 3, 0]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == -1\n assert candidate(nums = [10, -10, 10, -10, 10, -10, 10, -10, 10, -10]) == -1\n assert candidate(nums = [10, -10, 20, -20, 30, -30]) == -1\n assert candidate(nums = [100, 200, 300, 400, 500, -1500, 600, 700]) == -1\n assert candidate(nums = [1000, -1000, 0, 1000, -1000]) == 2\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == -1\n assert candidate(nums = [-1000, 500, -250, 125, -62, 31, -15, 7, -3, 1]) == -1\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5]) == 0\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == -1\n assert candidate(nums = [-1, -2, -3, -4, -5, 15]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0]) == 9\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == -1\n assert candidate(nums = [1, -2, 3, 4, -3, 2]) == -1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, -210]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [10, -10, 0, 5, -5, 5, -5]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == -1\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == -1\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000, 1000, -1000]) == -1\n assert candidate(nums = [-10, 10, -20, 20, -30, 30, -40, 40]) == -1\n assert candidate(nums = [0, 1, 0, -1, 0, 1, 0, -1]) == 0\n assert candidate(nums = [999, 1, 999, 1, 999, 1, 999, 1, 999, 1]) == -1\n assert candidate(nums = [1000, -1000, 500, -500, 250, -250, 125, -125]) == -1\n assert candidate(nums = [0, 1, 2, 3, 4, 3, 2, 1, 0]) == 4\n assert candidate(nums = [1, -1, 0, 1, -1]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 7\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == -1\n assert candidate(nums = [10, 20, 30, 10, 10, 30]) == -1\n assert candidate(nums = [1000, -500, 250, -125, 62, -31, 15, -7, 3, -1, 0]) == -1\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 1\n assert candidate(nums = [1000, -1000, 1000, -1000, 1000, -1000]) == -1\n assert candidate(nums = [100, -100, 50, -50, 25, -25, 12, -12, 6, -6, 3, -3, 1, -1]) == -1\n assert candidate(nums = [-100, -99, -98, -97, -96, -95, -94, -93, -92, -91, -90, -89, -88, -87, -86, -85, -84, -83, -82, -81, -80, -79, -78, -77, -76, -75, -74, -73, -72, -71, -70, -69, -68, -67, -66, -65, -64, -63, -62, -61, -60, -59, -58, -57, -56, -55, -54, -53, -52, -51, -50, -49, -48, -47, -46, -45, -44, -43, -42, -41, -40, -39, -38, -37, -36, -35, -34, -33, -32, -31, -30, -29, -28, -27, -26, -25, -24, -23, -22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1]) == -1\n assert candidate(nums = [1, -1, 2, -2, 3, -3]) == -1\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == -1\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 9\n assert candidate(nums = [1000, -1000, 500, -500, 250, -250]) == -1\n assert candidate(nums = [1000, -1000, 500, -500, 0, 0]) == 4\n assert candidate(nums = [7, 1, 5, 2, -4, 3, 0, 0, 0, 0]) == -1\n assert candidate(nums = [1000, -500, 250, -125, 62, -31, 15, -7, 3, -1, 1]) == -1\n assert candidate(nums = [-10, 10, -20, 20, -30, 30]) == -1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 0]) == 20\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().findMiddleIndex", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int findMiddleIndex(vector& nums) {", "container": "Solution", "callable": "findMiddleIndex", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1992, "task_id": "find-all-groups-of-farmland", "difficulty": "Medium", "problem_description": "You are given a 0-indexed m x n binary matrix land where a 0 represents a hectare of forested land and a 1 represents a hectare of farmland.\nTo keep the land organized, there are designated rectangular areas of hectares that consist entirely of farmland. These rectangular areas are called groups. No two groups are adjacent, meaning farmland in one group is not four-directionally adjacent to another farmland in a different group.\nland can be represented by a coordinate system where the top left corner of land is (0, 0) and the bottom right corner of land is (m-1, n-1). Find the coordinates of the top left and bottom right corner of each group of farmland. A group of farmland with a top left corner at (r1, c1) and a bottom right corner at (r2, c2) is represented by the 4-length array [r1, c1, r2, c2].\nReturn a 2D array containing the 4-length arrays described above for each group of farmland in land. If there are no groups of farmland, return an empty array. You may return the answer in any order.\n \nExample 1:\n\n\nInput: land = [[1,0,0],[0,1,1],[0,1,1]]\nOutput: [[0,0,0,0],[1,1,2,2]]\nExplanation:\nThe first group has a top left corner at land[0][0] and a bottom right corner at land[0][0].\nThe second group has a top left corner at land[1][1] and a bottom right corner at land[2][2].\n\nExample 2:\n\n\nInput: land = [[1,1],[1,1]]\nOutput: [[0,0,1,1]]\nExplanation:\nThe first group has a top left corner at land[0][0] and a bottom right corner at land[1][1].\n\nExample 3:\n\n\nInput: land = [[0]]\nOutput: []\nExplanation:\nThere are no groups of farmland.\n\n \nConstraints:\n\nm == land.length\nn == land[i].length\n1 <= m, n <= 300\nland consists of only 0's and 1's.\nGroups of farmland are rectangular in shape.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(land = [[0]]) == []\n assert candidate(land = [[1, 1, 0, 0], [0, 0, 1, 1], [1, 1, 0, 0], [0, 0, 1, 1]]) == [[0, 0, 0, 1], [1, 2, 1, 3], [2, 0, 2, 1], [3, 2, 3, 3]]\n assert candidate(land = [[1, 0, 1], [0, 0, 0], [1, 1, 1]]) == [[0, 0, 0, 0], [0, 2, 0, 2], [2, 0, 2, 2]]\n assert candidate(land = [[1, 0, 1], [0, 0, 0], [1, 1, 0]]) == [[0, 0, 0, 0], [0, 2, 0, 2], [2, 0, 2, 1]]\n assert candidate(land = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == []\n assert candidate(land = [[1, 1, 1], [1, 0, 1], [1, 1, 1]]) == [[0, 0, 2, 2]]\n assert candidate(land = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == [[0, 0, 0, 0], [0, 2, 0, 2], [1, 1, 1, 1], [2, 0, 2, 0], [2, 2, 2, 2]]\n assert candidate(land = [[1, 1], [1, 1]]) == [[0, 0, 1, 1]]\n assert candidate(land = [[1, 1, 0, 0], [1, 1, 0, 0], [0, 0, 1, 1], [0, 0, 1, 1]]) == [[0, 0, 1, 1], [2, 2, 3, 3]]\n assert candidate(land = [[1, 0, 0, 0], [0, 1, 1, 1], [0, 1, 1, 1], [0, 0, 0, 0]]) == [[0, 0, 0, 0], [1, 1, 2, 3]]\n assert candidate(land = [[1, 0, 0], [0, 1, 1], [0, 1, 1]]) == [[0, 0, 0, 0], [1, 1, 2, 2]]\n assert candidate(land = [[0, 1, 1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 1, 1, 1, 0], [1, 1, 1, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0, 1, 1]]) == [[0, 1, 1, 2], [0, 5, 1, 6], [3, 0, 4, 2], [3, 4, 4, 6], [6, 0, 7, 1], [6, 6, 7, 7]]\n assert candidate(land = [[1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 1]]) == [[0, 0, 1, 1], [2, 2, 3, 4], [4, 5, 5, 5]]\n assert candidate(land = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == [[0, 0, 0, 0], [0, 2, 0, 2], [0, 4, 0, 4], [0, 6, 0, 6], [1, 1, 1, 1], [1, 3, 1, 3], [1, 5, 1, 5], [1, 7, 1, 7], [2, 0, 2, 0], [2, 2, 2, 2], [2, 4, 2, 4], [2, 6, 2, 6], [3, 1, 3, 1], [3, 3, 3, 3], [3, 5, 3, 5], [3, 7, 3, 7], [4, 0, 4, 0], [4, 2, 4, 2], [4, 4, 4, 4], [4, 6, 4, 6]]\n assert candidate(land = [[1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1]]) == [[0, 0, 1, 3]]\n assert candidate(land = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]]) == [[0, 0, 1, 5], [3, 0, 4, 5]]\n assert candidate(land = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1]]) == [[0, 0, 0, 0], [0, 2, 0, 2], [0, 4, 0, 4], [1, 1, 1, 1], [1, 3, 1, 3], [2, 0, 2, 0], [2, 2, 2, 2], [2, 4, 2, 4], [3, 1, 3, 1], [3, 3, 3, 3], [4, 0, 4, 0], [4, 2, 4, 2], [4, 4, 4, 4]]\n assert candidate(land = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 0, 0], [0, 1, 0, 1, 0, 0], [0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[1, 1, 3, 3]]\n assert candidate(land = [[1, 1, 1, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 0, 0, 1, 1]]) == [[0, 0, 0, 2], [0, 6, 0, 8], [2, 0, 2, 2], [2, 4, 2, 6], [3, 7, 4, 8], [4, 0, 4, 4]]\n assert candidate(land = [[1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 1, 1, 0, 1], [1, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1]]) == [[0, 0, 5, 5], [2, 2, 3, 3]]\n assert candidate(land = [[1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 0, 1, 1, 0, 1, 1, 0, 1], [1, 1, 0, 1, 1, 0, 1, 1, 0, 1]]) == [[0, 0, 1, 1], [0, 3, 1, 4], [0, 6, 1, 7], [0, 9, 1, 9], [3, 0, 4, 1], [3, 3, 4, 4], [3, 6, 4, 7], [3, 9, 4, 9], [6, 0, 7, 1], [6, 3, 7, 4], [6, 6, 7, 7], [6, 9, 7, 9]]\n assert candidate(land = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0]]) == [[0, 0, 0, 0], [0, 2, 0, 2], [0, 4, 0, 4], [0, 6, 0, 6], [2, 0, 2, 0], [2, 2, 2, 2], [2, 4, 2, 4], [2, 6, 2, 6], [4, 0, 4, 0], [4, 2, 4, 2], [4, 4, 4, 4], [4, 6, 4, 6]]\n assert candidate(land = [[1, 1, 1, 1], [1, 0, 0, 1], [1, 0, 1, 1], [1, 0, 0, 0]]) == [[0, 0, 3, 0], [2, 2, 2, 3]]\n assert candidate(land = [[1, 0, 0, 0, 0, 1], [1, 1, 0, 0, 1, 1], [0, 1, 0, 0, 1, 0], [1, 1, 0, 0, 1, 1], [0, 1, 0, 0, 1, 0]]) == [[0, 0, 1, 1], [0, 5, 1, 5], [1, 4, 4, 4], [3, 0, 3, 1]]\n assert candidate(land = [[1, 0, 0, 0, 1, 0, 1, 1, 0, 0], [0, 1, 1, 0, 1, 0, 1, 1, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [0, 1, 0, 0, 1, 1, 1, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 0, 1, 1]]) == [[0, 0, 0, 0], [0, 4, 3, 7], [0, 6, 1, 7], [1, 1, 1, 2], [2, 9, 3, 9], [3, 1, 3, 1], [5, 2, 5, 4], [5, 8, 5, 9]]\n assert candidate(land = [[1, 1, 1, 0, 0, 0, 1, 1, 1], [1, 0, 1, 0, 0, 0, 1, 0, 1], [1, 1, 1, 0, 0, 0, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 1, 1, 1], [1, 0, 1, 0, 0, 0, 1, 0, 1], [1, 1, 1, 0, 0, 0, 1, 1, 1]]) == [[0, 0, 2, 2], [0, 6, 2, 8], [4, 0, 6, 2], [4, 6, 6, 8]]\n assert candidate(land = [[1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 0], [0, 1, 0, 1, 1, 0], [0, 0, 1, 0, 0, 1]]) == [[0, 0, 0, 2], [1, 3, 2, 4], [2, 1, 2, 1], [3, 2, 3, 2], [3, 5, 3, 5]]\n assert candidate(land = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0]]) == [[0, 0, 2, 7], [4, 0, 6, 7]]\n assert candidate(land = [[1, 0, 0, 0, 1, 0], [0, 1, 1, 0, 0, 1], [0, 1, 1, 0, 0, 1], [0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1]]) == [[0, 0, 0, 0], [0, 4, 0, 4], [1, 1, 2, 2], [1, 5, 4, 5], [3, 3, 4, 5]]\n assert candidate(land = [[1, 0, 0, 1, 0], [1, 1, 0, 1, 0], [0, 0, 0, 0, 0], [1, 1, 1, 0, 1], [0, 1, 1, 0, 1]]) == [[0, 0, 1, 1], [0, 3, 1, 3], [3, 0, 3, 2], [3, 4, 4, 4]]\n assert candidate(land = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1]]) == [[0, 0, 0, 0], [0, 2, 0, 2], [0, 4, 0, 4], [0, 6, 0, 6], [1, 1, 1, 1], [1, 3, 1, 3], [1, 5, 1, 5], [1, 7, 1, 7], [2, 0, 2, 0], [2, 2, 2, 2], [2, 4, 2, 4], [2, 6, 2, 6], [3, 1, 3, 1], [3, 3, 3, 3], [3, 5, 3, 5], [3, 7, 3, 7], [4, 0, 4, 0], [4, 2, 4, 2], [4, 4, 4, 4], [4, 6, 4, 6], [5, 1, 5, 1], [5, 3, 5, 3], [5, 5, 5, 5], [5, 7, 5, 7]]\n assert candidate(land = [[1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1]]) == [[0, 0, 1, 3], [2, 4, 3, 5]]\n assert candidate(land = [[0, 1, 1, 0, 0, 0], [1, 1, 0, 0, 1, 1], [1, 0, 0, 1, 1, 0], [0, 1, 1, 0, 0, 1], [0, 0, 1, 1, 0, 0]]) == [[0, 1, 1, 1], [1, 0, 2, 0], [1, 4, 2, 4], [2, 3, 2, 4], [3, 1, 3, 2], [3, 5, 3, 5]]\n assert candidate(land = [[0, 0, 0, 0, 0], [0, 1, 1, 1, 0], [0, 1, 0, 1, 0], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0]]) == [[1, 1, 3, 3]]\n assert candidate(land = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0], [1, 1, 1, 1], [0, 0, 0, 0], [1, 0, 0, 1], [1, 0, 0, 1]]) == [[1, 1, 2, 2], [4, 0, 4, 3], [6, 0, 7, 0], [6, 3, 7, 3]]\n assert candidate(land = [[1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0]]) == [[0, 0, 1, 1], [1, 4, 2, 5], [3, 2, 3, 3]]\n assert candidate(land = [[1, 1, 1, 1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 0, 0, 1, 1, 0, 1], [0, 0, 0, 0, 1, 1, 1, 1, 0, 1], [0, 0, 0, 0, 1, 1, 1, 1, 0, 1], [0, 0, 1, 1, 0, 0, 0, 0, 0, 0]]) == [[0, 0, 1, 3], [0, 9, 3, 9], [1, 6, 3, 7], [2, 4, 3, 7], [4, 2, 4, 3]]\n assert candidate(land = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 1, 0, 1, 1], [0, 0, 1, 0, 0]]) == [[0, 0, 0, 0], [0, 2, 1, 3], [0, 4, 0, 4], [1, 1, 2, 1], [2, 0, 2, 1], [3, 2, 3, 2]]\n assert candidate(land = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0], [0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == [[1, 1, 3, 4], [1, 8, 4, 9], [3, 6, 4, 9], [3, 11, 4, 12]]\n assert candidate(land = [[1, 1, 1, 1, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0], [0, 0, 0, 0, 1, 1, 0], [0, 0, 1, 1, 1, 1, 1]]) == [[0, 0, 1, 3], [2, 4, 4, 6], [4, 2, 4, 6]]\n assert candidate(land = [[1, 1, 1, 0, 0, 0, 0, 0], [1, 0, 1, 0, 0, 0, 0, 0], [1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1]]) == [[0, 0, 2, 2], [3, 3, 5, 5], [6, 6, 7, 7]]\n assert candidate(land = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 0, 0], [0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 1], [0, 0, 0, 1, 0, 0, 0, 1], [0, 0, 0, 1, 1, 1, 1, 1]]) == [[1, 1, 3, 5], [5, 3, 7, 7]]\n assert candidate(land = [[1, 1, 0, 1, 1], [1, 1, 0, 1, 1], [0, 0, 0, 0, 0], [1, 1, 0, 1, 1], [1, 1, 0, 1, 1]]) == [[0, 0, 1, 1], [0, 3, 1, 4], [3, 0, 4, 1], [3, 3, 4, 4]]\n assert candidate(land = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 0, 1, 1, 0, 0], [0, 1, 1, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1], [0, 0, 0, 1, 1, 0, 0, 0]]) == [[1, 1, 2, 2], [1, 4, 2, 5], [3, 6, 4, 7], [5, 3, 5, 4]]\n assert candidate(land = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == [[1, 1, 4, 4]]\n assert candidate(land = [[1, 1, 0, 0, 1], [1, 1, 0, 0, 1], [0, 0, 1, 1, 0], [0, 0, 1, 1, 0], [1, 0, 0, 0, 1]]) == [[0, 0, 1, 1], [0, 4, 1, 4], [2, 2, 3, 3], [4, 0, 4, 0], [4, 4, 4, 4]]\n assert candidate(land = [[1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1], [1, 1, 1, 0, 1, 1, 0], [0, 0, 0, 1, 0, 0, 1], [1, 1, 1, 0, 0, 1, 0]]) == [[0, 0, 0, 3], [1, 4, 2, 5], [2, 0, 2, 2], [3, 3, 3, 3], [3, 6, 3, 6], [4, 0, 4, 2], [4, 5, 4, 5]]\n assert candidate(land = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == [[0, 0, 0, 0], [0, 2, 0, 2], [0, 4, 0, 4], [0, 6, 0, 6], [1, 1, 1, 1], [1, 3, 1, 3], [1, 5, 1, 5], [2, 0, 2, 0], [2, 2, 2, 2], [2, 4, 2, 4], [2, 6, 2, 6], [3, 1, 3, 1], [3, 3, 3, 3], [3, 5, 3, 5], [4, 0, 4, 0], [4, 2, 4, 2], [4, 4, 4, 4], [4, 6, 4, 6]]\n assert candidate(land = [[0, 0, 0, 0, 0], [0, 1, 1, 0, 0], [0, 1, 1, 0, 0], [0, 0, 0, 0, 0], [1, 1, 1, 1, 0], [0, 0, 0, 1, 1]]) == [[1, 1, 2, 2], [4, 0, 4, 3]]\n assert candidate(land = [[1, 1, 1, 0, 0, 0, 1, 1], [1, 1, 1, 0, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 0, 0, 1, 1]]) == [[0, 0, 1, 2], [0, 6, 1, 7], [2, 4, 3, 5], [4, 0, 4, 1], [4, 6, 4, 7]]\n assert candidate(land = [[1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1], [1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0]]) == [[0, 0, 1, 2], [2, 3, 3, 5], [4, 0, 5, 0], [4, 2, 5, 2]]\n assert candidate(land = [[1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [1, 1, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 1, 1]]) == [[0, 0, 1, 1], [0, 5, 1, 6], [2, 2, 3, 4], [4, 0, 5, 1], [4, 5, 5, 6]]\n assert candidate(land = [[1, 0, 0, 0, 1], [0, 1, 1, 1, 0], [0, 0, 0, 0, 0], [1, 0, 0, 1, 1], [0, 0, 0, 1, 1]]) == [[0, 0, 0, 0], [0, 4, 0, 4], [1, 1, 1, 3], [3, 0, 3, 0], [3, 3, 4, 4]]\n assert candidate(land = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1]]) == [[0, 0, 4, 0]]\n assert candidate(land = [[1, 0, 0, 1, 0], [0, 1, 1, 0, 1], [0, 1, 1, 0, 1], [1, 0, 0, 1, 0], [0, 1, 1, 0, 1]]) == [[0, 0, 0, 0], [0, 3, 0, 3], [1, 1, 2, 2], [1, 4, 2, 4], [3, 0, 3, 0], [3, 3, 3, 3], [4, 1, 4, 2], [4, 4, 4, 4]]\n assert candidate(land = [[1, 1, 1, 1, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 0, 0, 0, 0]]) == [[0, 0, 1, 3], [2, 4, 3, 7], [5, 0, 5, 3]]\n assert candidate(land = [[1, 1, 1, 0, 0, 0], [1, 1, 1, 0, 1, 1], [0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0]]) == [[0, 0, 1, 2], [1, 4, 2, 5], [3, 0, 4, 1]]\n assert candidate(land = [[1, 1, 0, 0, 0], [1, 1, 0, 1, 1], [0, 0, 0, 1, 1], [1, 1, 0, 0, 0], [1, 1, 0, 0, 0]]) == [[0, 0, 1, 1], [1, 3, 2, 4], [3, 0, 4, 1]]\n assert candidate(land = [[1, 1, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 1, 1], [1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[0, 0, 1, 1], [1, 4, 2, 5], [3, 0, 3, 3]]\n assert candidate(land = [[1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0]]) == [[0, 0, 0, 0], [0, 2, 0, 2], [0, 4, 0, 4], [1, 1, 1, 1], [1, 3, 1, 3], [1, 5, 1, 5], [2, 0, 2, 0], [2, 2, 2, 2], [2, 4, 2, 4], [3, 1, 3, 1], [3, 3, 3, 3], [3, 5, 3, 5], [4, 0, 4, 0], [4, 2, 4, 2], [4, 4, 4, 4]]\n assert candidate(land = [[1, 0, 0, 0, 1, 1], [0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 0, 0], [1, 0, 0, 0, 1, 1], [0, 1, 1, 1, 0, 0]]) == [[0, 0, 0, 0], [0, 4, 0, 5], [1, 1, 2, 3], [3, 0, 3, 0], [3, 4, 3, 5], [4, 1, 4, 3]]\n assert candidate(land = [[1, 1, 1, 0, 0, 0, 1, 1, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1], [1, 1, 1, 0, 0, 0, 1, 1, 1], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0]]) == [[0, 0, 2, 2], [0, 6, 0, 8], [1, 4, 1, 4], [2, 6, 2, 8], [3, 3, 5, 5], [4, 1, 4, 7]]\n assert candidate(land = [[0, 1, 1, 0, 0, 1], [0, 0, 1, 0, 1, 0], [1, 1, 1, 0, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 0, 1, 1, 1]]) == [[0, 1, 0, 2], [0, 5, 0, 5], [1, 4, 2, 5], [2, 0, 2, 2], [4, 0, 4, 1], [4, 3, 4, 5]]\n assert candidate(land = [[0, 0, 0, 0], [0, 1, 1, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == [[1, 1, 2, 2]]\n assert candidate(land = [[1, 1, 1, 1, 0, 0], [1, 0, 0, 1, 1, 0], [1, 0, 0, 1, 1, 0], [0, 0, 0, 1, 1, 1]]) == [[0, 0, 2, 0]]\n assert candidate(land = [[0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1]]) == [[0, 1, 4, 1], [0, 3, 4, 3], [0, 5, 4, 5], [1, 0, 1, 5], [3, 0, 3, 5]]\n assert candidate(land = [[1, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1]]) == [[0, 0, 0, 0], [0, 4, 0, 5], [2, 0, 2, 1], [2, 4, 2, 5], [4, 0, 4, 1], [4, 4, 4, 5]]\n assert candidate(land = [[1, 0, 0, 0, 0, 1], [0, 1, 1, 0, 1, 0], [0, 1, 1, 0, 1, 0], [0, 0, 0, 1, 0, 1]]) == [[0, 0, 0, 0], [0, 5, 0, 5], [1, 1, 2, 2], [1, 4, 2, 4], [3, 3, 3, 3], [3, 5, 3, 5]]\n assert candidate(land = [[1, 1, 0, 0, 0, 0, 1, 1], [1, 1, 0, 0, 0, 0, 1, 1], [0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 0, 0, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0]]) == [[0, 0, 1, 1], [0, 6, 1, 7], [2, 2, 3, 3], [4, 0, 4, 1], [4, 4, 4, 5]]\n assert candidate(land = [[1, 0, 1, 0, 1], [0, 1, 0, 1, 0], [1, 0, 1, 0, 1], [0, 1, 0, 1, 0]]) == [[0, 0, 0, 0], [0, 2, 0, 2], [0, 4, 0, 4], [1, 1, 1, 1], [1, 3, 1, 3], [2, 0, 2, 0], [2, 2, 2, 2], [2, 4, 2, 4], [3, 1, 3, 1], [3, 3, 3, 3]]\n assert candidate(land = [[1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0, 1, 1, 0, 0], [1, 1, 0, 0, 1, 1, 0, 0, 1, 1]]) == [[0, 0, 0, 1], [0, 4, 0, 5], [0, 8, 0, 9], [1, 6, 1, 7], [2, 0, 2, 1], [2, 4, 2, 5], [2, 8, 2, 9], [3, 6, 3, 7], [4, 0, 4, 1], [4, 4, 4, 5], [4, 8, 4, 9]]\n assert candidate(land = [[1, 0, 0, 0, 0, 1], [0, 0, 1, 1, 0, 0], [0, 0, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0], [1, 0, 0, 0, 0, 1]]) == [[0, 0, 0, 0], [0, 5, 0, 5], [1, 2, 2, 3], [4, 0, 4, 0], [4, 5, 4, 5]]\n assert candidate(land = [[0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == [[0, 1, 0, 1], [0, 3, 0, 3], [0, 5, 0, 5], [0, 7, 0, 7], [0, 9, 0, 9], [1, 0, 1, 0], [1, 2, 1, 2], [1, 4, 1, 4], [1, 6, 1, 6], [1, 8, 1, 8], [2, 1, 2, 1], [2, 3, 2, 3], [2, 5, 2, 5], [2, 7, 2, 7], [2, 9, 2, 9], [3, 0, 3, 0], [3, 2, 3, 2], [3, 4, 3, 4], [3, 6, 3, 6], [3, 8, 3, 8]]\n assert candidate(land = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) == [[0, 0, 2, 5]]\n"}, "metadata": {"canonical_parameter_names": ["land"], "leetcode_dataset_entry_point": "Solution().findFarmland", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector> findFarmland(vector>& land) {", "container": "Solution", "callable": "findFarmland", "parameters": [{"name": "land", "type": "vector>&"}], "return_type": "vector>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1994, "task_id": "the-number-of-good-subsets", "difficulty": "Hard", "problem_description": "You are given an integer array nums. We call a subset of nums good if its product can be represented as a product of one or more distinct prime numbers.\n\nFor example, if nums = [1, 2, 3, 4]:\n\n\t\n[2, 3], [1, 2, 3], and [1, 3] are good subsets with products 6 = 2*3, 6 = 2*3, and 3 = 3 respectively.\n[1, 4] and [4] are not good subsets with products 4 = 2*2 and 4 = 2*2 respectively.\n\n\n\nReturn the number of different good subsets in nums modulo 109 + 7.\nA subset of nums is any array that can be obtained by deleting some (possibly none or all) elements from nums. Two subsets are different if and only if the chosen indices to delete are different.\n \nExample 1:\n\nInput: nums = [1,2,3,4]\nOutput: 6\nExplanation: The good subsets are:\n- [1,2]: product is 2, which is the product of distinct prime 2.\n- [1,2,3]: product is 6, which is the product of distinct primes 2 and 3.\n- [1,3]: product is 3, which is the product of distinct prime 3.\n- [2]: product is 2, which is the product of distinct prime 2.\n- [2,3]: product is 6, which is the product of distinct primes 2 and 3.\n- [3]: product is 3, which is the product of distinct prime 3.\n\nExample 2:\n\nInput: nums = [4,2,3,15]\nOutput: 5\nExplanation: The good subsets are:\n- [2]: product is 2, which is the product of distinct prime 2.\n- [2,3]: product is 6, which is the product of distinct primes 2 and 3.\n- [2,15]: product is 30, which is the product of distinct primes 2, 3, and 5.\n- [3]: product is 3, which is the product of distinct prime 3.\n- [15]: product is 15, which is the product of distinct primes 3 and 5.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 30\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 3, 2, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29]) == 59048.0\n assert candidate(nums = [1, 1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 8184.0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10.0\n assert candidate(nums = [1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == 142.0\n assert candidate(nums = [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 703.0\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 20.0\n assert candidate(nums = [30, 26, 28, 12, 14, 22, 2, 4, 18, 20, 16, 8, 10, 24, 6, 5, 15, 3, 25, 7, 9, 11, 13, 17, 19, 21, 23, 27, 29]) == 3327.0\n assert candidate(nums = [1, 2, 3, 4]) == 6.0\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 6654.0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 20.0\n assert candidate(nums = [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 20.0\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29]) == 127.0\n assert candidate(nums = [4, 2, 3, 15]) == 5.0\n assert candidate(nums = [2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29]) == 59048.0\n assert candidate(nums = [30, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 3326.0\n assert candidate(nums = [30, 28, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2]) == 6.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 1023.0\n assert candidate(nums = [1, 1, 1, 2, 2, 3, 3, 30]) == 72.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 59048.0\n assert candidate(nums = [10, 20, 30, 1, 2, 3, 5, 7]) == 42.0\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == 1.0\n assert candidate(nums = [6, 10, 14, 15, 21, 22, 26, 30]) == 14.0\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 1]) == 4092.0\n assert candidate(nums = [2, 2, 2, 3, 3, 3, 5, 5, 5, 7, 7, 7, 11, 11, 11, 13, 13, 13, 17, 17, 17, 19, 19, 19, 23, 23, 23, 29, 29, 29]) == 1048575.0\n assert candidate(nums = [1, 2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30, 33]) == 6654.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 6, 10, 14, 15, 21, 22, 26, 30, 4, 9, 16, 25, 28, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3406848.0\n assert candidate(nums = [4, 6, 8, 9, 10, 12, 14, 15, 18, 20, 21, 22, 25, 26, 27, 30]) == 14.0\n assert candidate(nums = [6, 10, 14, 15, 21, 22, 26, 30, 33, 34, 35, 38, 39, 42, 46, 51, 55, 57, 58, 62]) == 14.0\n assert candidate(nums = [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 20.0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [6, 10, 14, 15, 21, 22, 26, 30, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 1, 1]) == 13308.0\n assert candidate(nums = [2, 3, 2, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29, 30, 30, 30]) == 65609.0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 43.0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 6654.0\n assert candidate(nums = [4, 6, 10, 14, 15, 21, 22, 26, 27, 30]) == 14.0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 72693241.0\n assert candidate(nums = [29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29]) == 27.0\n assert candidate(nums = [2, 2, 2, 2, 3, 3, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 11, 11, 11, 11]) == 3124.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 1023.0\n assert candidate(nums = [4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30]) == 14.0\n assert candidate(nums = [1, 1, 1, 1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 32736.0\n assert candidate(nums = [2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3]) == 255.0\n assert candidate(nums = [1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 30]) == 4604.0\n assert candidate(nums = [1, 2, 2, 2, 3, 3, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7, 11, 11, 11, 11]) == 4998.0\n assert candidate(nums = [6, 15, 10, 14, 21, 22, 26, 22, 21, 14, 10, 15, 6, 30, 30, 30, 30, 30, 30, 30]) == 40.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 6, 10, 14, 15, 21, 22, 26, 30, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3406848.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 2303.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18]) == 2111.0\n assert candidate(nums = [4, 9, 16, 25, 28, 10, 14, 21, 22, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 16.0\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67]) == 2046.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == 1023.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 9765624.0\n assert candidate(nums = [2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29, 30, 30, 30, 30, 30]) == 69983.0\n assert candidate(nums = [4, 8, 9, 12, 18, 20, 24, 25, 27, 28, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 5, 5, 5, 5, 7, 7, 7, 7]) == 9984.0\n assert candidate(nums = [4, 6, 8, 9, 10, 12, 14, 15, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 30, 30]) == 16.0\n assert candidate(nums = [1, 6, 10, 15, 21, 22, 26, 30]) == 24.0\n assert candidate(nums = [1, 6, 8, 9, 10, 12, 14, 15, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30]) == 28.0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 6654.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30]) == 3327.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30]) == 1548287.0\n assert candidate(nums = [8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 32, 33, 35]) == 13.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 32, 34, 35, 38, 39, 41, 43, 46, 47]) == 1023.0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 1047552.0\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 30, 15, 6, 10, 21, 22]) == 5246.0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 72693241.0\n assert candidate(nums = [1, 1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 8184.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 1023.0\n assert candidate(nums = [1, 2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29, 30, 30]) == 126844.0\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 6, 10, 14, 15, 21, 22, 26, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 8958.0\n assert candidate(nums = [1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30]) == 28.0\n assert candidate(nums = [30, 28, 15, 10, 6, 3, 2, 1]) == 18.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 59048.0\n assert candidate(nums = [15, 10, 21, 30, 22, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 32.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113]) == 1023.0\n assert candidate(nums = [30, 28, 26, 22, 21, 14, 10, 15, 6, 4, 8, 9, 12, 18, 20, 24, 25, 27, 1, 1]) == 56.0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1054.0\n assert candidate(nums = [10, 15, 21, 22, 26, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 25.0\n assert candidate(nums = [8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30]) == 13.0\n assert candidate(nums = [6, 10, 14, 15, 21, 22, 26, 30, 30, 30, 30, 30]) == 18.0\n assert candidate(nums = [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]) == 30.0\n assert candidate(nums = [4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 30, 30, 1, 1, 1, 1, 1, 1]) == 1024.0\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30]) == 691088.0\n assert candidate(nums = [4, 6, 8, 9, 10, 12, 14, 15, 18, 20, 21, 22, 24, 25, 26, 27, 28, 30, 32, 33, 34, 35, 36, 38, 39, 40, 42, 44, 45, 46, 48, 49, 50, 51, 52, 54, 55, 56, 57, 58, 60, 62, 63, 64, 65, 66, 68, 69, 70, 72, 74, 75, 76, 77, 78, 80, 81, 82, 84, 85, 86, 87, 88, 90, 91, 92, 93, 94, 95, 96, 98, 99, 100]) == 14.0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 14.0\n assert candidate(nums = [6, 10, 14, 15, 21, 22, 26, 30, 33, 34, 35, 38, 39, 46, 51, 55, 57, 58, 62, 65, 69, 74, 77, 82, 85, 86, 87, 91, 93, 94, 95]) == 14.0\n assert candidate(nums = [30, 15, 6, 10, 21, 22, 26, 27, 28, 3, 5, 7, 11, 13, 17, 19, 23, 29, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2292736.0\n assert candidate(nums = [2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30, 33, 34]) == 3327.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 30, 2, 3, 5, 7, 11, 13, 17, 19, 23]) == 40823.0\n assert candidate(nums = [1, 2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29]) == 118096.0\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 30]) == 2302.0\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 3406848.0\n assert candidate(nums = [30, 15, 21, 10, 6, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 4, 8, 9, 12, 14, 16, 18, 20, 22, 24, 25, 26, 27, 28, 32, 34, 35, 36, 38, 39, 40, 42, 44, 45, 46, 48, 49, 50, 51, 52, 54, 55, 56, 57, 58, 60, 62, 63, 64, 65, 66, 68, 69, 70, 72, 74, 75, 76, 77, 78, 80, 81, 82, 84, 85, 86, 87, 88, 90, 91, 92, 93, 94, 95, 96, 98, 99, 100]) == 3327.0\n assert candidate(nums = [6, 15, 10, 14, 21, 22, 26, 22, 21, 14, 10, 15, 6, 30, 2, 3, 5, 7, 11, 13]) == 359.0\n assert candidate(nums = [1, 6, 10, 14, 15, 21, 22, 26, 30, 33, 34, 35, 38, 39, 46, 51, 55, 57, 58, 62, 65, 69, 74, 77, 82, 85, 86, 87, 91, 93, 94, 95]) == 28.0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1047552.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 30, 30, 30]) == 1407.0\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 20.0\n assert candidate(nums = [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 6, 10, 14, 15, 21, 22, 26, 30, 1]) == 13308.0\n assert candidate(nums = [6, 10, 14, 15, 21, 22, 26, 30, 30, 30]) == 16.0\n assert candidate(nums = [1, 1, 1, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == 16368.0\n assert candidate(nums = [4, 8, 9, 12, 16, 18, 20, 24, 25, 27, 28, 1, 2, 3, 5, 7, 11, 13, 17, 19]) == 510.0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23, 29, 29]) == 1048575.0\n assert candidate(nums = [8, 9, 12, 18, 20, 24, 25, 27, 28, 30]) == 1.0\n assert candidate(nums = [1, 1, 2, 3, 5, 6, 7, 10, 11, 13, 14, 15, 17, 19, 21, 22, 23, 26, 29, 30]) == 13308.0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 24166.0\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().numberOfGoodSubsets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numberOfGoodSubsets(vector& nums) {", "container": "Solution", "callable": "numberOfGoodSubsets", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1995, "task_id": "count-special-quadruplets", "difficulty": "Easy", "problem_description": "Given a 0-indexed integer array nums, return the number of distinct quadruplets (a, b, c, d) such that:\n\nnums[a] + nums[b] + nums[c] == nums[d], and\na < b < c < d\n\n \nExample 1:\n\nInput: nums = [1,2,3,6]\nOutput: 1\nExplanation: The only quadruplet that satisfies the requirement is (0, 1, 2, 3) because 1 + 2 + 3 == 6.\n\nExample 2:\n\nInput: nums = [3,3,6,4,5]\nOutput: 0\nExplanation: There are no such quadruplets in [3,3,6,4,5].\n\nExample 3:\n\nInput: nums = [1,1,1,3,5]\nOutput: 4\nExplanation: The 4 quadruplets that satisfy the requirement are:\n- (0, 1, 2, 3): 1 + 1 + 1 == 3\n- (0, 1, 3, 4): 1 + 1 + 3 == 5\n- (0, 2, 3, 4): 1 + 1 + 3 == 5\n- (1, 2, 3, 4): 1 + 1 + 3 == 5\n\n \nConstraints:\n\n4 <= nums.length <= 50\n1 <= nums[i] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 6]) == 1\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100, 1]) == 0\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28]) == 3\n assert candidate(nums = [1, 3, 5, 0, 0, 1, 3, 5]) == 5\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 10]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70]) == 2\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 4\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 12\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 11\n assert candidate(nums = [3, 3, 6, 4, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [1, 1, 1, 3, 5]) == 4\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36]) == 3\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 135]) == 21\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66]) == 7\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 147\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70]) == 11\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 6, 7, 7, 8, 9, 10]) == 40\n assert candidate(nums = [30, 20, 10, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 147\n assert candidate(nums = [4, 3, 2, 1, 8, 7, 6, 5, 12, 11, 10, 9, 16, 15, 14, 13, 20, 19, 18, 17]) == 143\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 19]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 12, 12]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15]) == 21\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99]) == 817\n assert candidate(nums = [50, 25, 25, 75, 50, 50, 100, 50, 75, 100]) == 7\n assert candidate(nums = [5, 5, 5, 5, 15, 15, 15, 15, 25, 25, 25, 25, 35, 35, 35, 35]) == 304\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 174\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 60]) == 123\n assert candidate(nums = [1, 2, 3, 6, 3, 6, 9, 12, 15, 18, 21, 24]) == 34\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == 927\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 15, 5, 5, 5, 5, 5, 5, 5]) == 35\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 358\n assert candidate(nums = [5, 5, 5, 5, 5, 15, 5, 5, 5, 5]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [5, 1, 4, 3, 6, 2, 7, 8, 9, 10]) == 10\n assert candidate(nums = [50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 53\n assert candidate(nums = [2, 2, 2, 6, 6, 6, 18, 18, 18]) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]) == 31\n assert candidate(nums = [1, 1, 1, 1, 4, 1, 1, 1, 1, 5]) == 0\n assert candidate(nums = [3, 3, 6, 4, 5, 5, 5, 15, 15, 15, 15, 30, 30, 30, 30]) == 16\n assert candidate(nums = [1, 2, 3, 4, 10, 11, 12, 13, 20, 21, 22, 23, 30, 31, 32, 33]) == 19\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 30]) == 21\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20]) == 11\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 244\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [5, 5, 5, 15, 15, 15, 30]) == 3\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 244\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11]) == 39\n assert candidate(nums = [7, 1, 2, 4, 5, 3, 8, 6, 9, 10]) == 10\n assert candidate(nums = [3, 3, 3, 9, 3, 3, 3, 3, 3, 3, 9, 3]) == 85\n assert candidate(nums = [5, 5, 5, 15, 15, 25, 25]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 147\n assert candidate(nums = [2, 2, 2, 6, 2, 2, 2, 6, 2, 2, 2, 6, 2, 2, 2]) == 105\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 15, 15]) == 420\n assert candidate(nums = [50, 25, 100, 75, 50, 125, 100, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400, 425, 450]) == 212\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == 147\n assert candidate(nums = [5, 5, 5, 15, 10, 15, 20]) == 5\n assert candidate(nums = [8, 2, 2, 4, 6, 10, 2, 6, 2, 12, 8, 4]) == 22\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325]) == 55\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 20]) == 0\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 53\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36]) == 0\n assert candidate(nums = [1, 2, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54]) == 119\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 83\n assert candidate(nums = [8, 8, 8, 8, 32, 8, 8, 8, 8, 8, 8, 8]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [2, 5, 1, 8, 3, 9, 4, 6]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 586\n assert candidate(nums = [5, 5, 5, 5, 5, 15, 5, 5, 5, 5]) == 10\n assert candidate(nums = [1, 1, 2, 3, 3, 5, 5, 6, 7, 7, 8, 9, 9, 10, 11, 11, 13, 13, 14, 15]) == 218\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]) == 23\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 53\n assert candidate(nums = [5, 1, 4, 2, 8, 10, 7]) == 3\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 2972\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15]) == 21\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 147\n assert candidate(nums = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765]) == 17\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250]) == 314\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 110]) == 104\n assert candidate(nums = [5, 1, 5, 5, 5, 5, 5, 10]) == 0\n assert candidate(nums = [30, 20, 10, 60, 50, 40, 100, 90, 80, 70]) == 10\n assert candidate(nums = [1, 2, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39]) == 43\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 21]) == 76\n assert candidate(nums = [2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 166\n assert candidate(nums = [5, 15, 10, 10, 10, 10, 25, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 120\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300]) == 575\n assert candidate(nums = [1, 2, 3, 6, 7, 8, 11, 12, 15, 16, 19, 20, 23, 24, 27, 28]) == 61\n assert candidate(nums = [9, 5, 3, 7, 2, 8, 10, 6, 4, 12, 1, 11]) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 150, 200, 250, 300]) == 48\n assert candidate(nums = [7, 3, 6, 2, 4, 8, 10, 15, 1, 9]) == 5\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]) == 0\n assert candidate(nums = [90, 80, 70, 60, 50, 40, 30, 20, 10, 100, 9, 8, 7, 6, 5, 4, 3, 2, 1, 101]) == 12\n assert candidate(nums = [3, 3, 3, 6, 9, 12, 15, 18, 21, 24, 27]) == 38\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countQuadruplets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countQuadruplets(vector& nums) {", "container": "Solution", "callable": "countQuadruplets", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1996, "task_id": "the-number-of-weak-characters-in-the-game", "difficulty": "Medium", "problem_description": "You are playing a game that contains multiple characters, and each of the characters has two main properties: attack and defense. You are given a 2D integer array properties where properties[i] = [attacki, defensei] represents the properties of the ith character in the game.\nA character is said to be weak if any other character has both attack and defense levels strictly greater than this character's attack and defense levels. More formally, a character i is said to be weak if there exists another character j where attackj > attacki and defensej > defensei.\nReturn the number of weak characters.\n \nExample 1:\n\nInput: properties = [[5,5],[6,3],[3,6]]\nOutput: 0\nExplanation: No character has strictly greater attack and defense than the other.\n\nExample 2:\n\nInput: properties = [[2,2],[3,3]]\nOutput: 1\nExplanation: The first character is weak because the second character has a strictly greater attack and defense.\n\nExample 3:\n\nInput: properties = [[1,5],[10,4],[4,3]]\nOutput: 1\nExplanation: The third character is weak because the second character has a strictly greater attack and defense.\n\n \nConstraints:\n\n2 <= properties.length <= 105\nproperties[i].length == 2\n1 <= attacki, defensei <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(properties = [[5, 5], [6, 3], [3, 6], [2, 2], [1, 1]]) == 2\n assert candidate(properties = [[2, 2], [3, 3]]) == 1\n assert candidate(properties = [[5, 1], [5, 10], [4, 10], [4, 4], [3, 14], [3, 6], [2, 10], [1, 14], [1, 4]]) == 4\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 4\n assert candidate(properties = [[5, 5], [6, 3], [3, 6]]) == 0\n assert candidate(properties = [[10, 1], [5, 1], [7, 10], [4, 1], [5, 9], [6, 9], [7, 2], [1, 10]]) == 4\n assert candidate(properties = [[1, 5], [10, 4], [4, 3], [5, 6], [7, 8], [8, 7], [9, 9], [2, 2]]) == 6\n assert candidate(properties = [[1, 10], [10, 1], [4, 4], [4, 5]]) == 0\n assert candidate(properties = [[1, 5], [10, 4], [4, 3], [3, 15], [1, 20]]) == 2\n assert candidate(properties = [[1, 5], [10, 4], [4, 3]]) == 1\n assert candidate(properties = [[5, 5], [6, 3], [3, 6], [2, 2], [1, 1], [6, 7]]) == 4\n assert candidate(properties = [[1, 5], [1, 5], [1, 5], [10, 4], [4, 3]]) == 1\n assert candidate(properties = [[10, 1], [5, 1], [7, 10], [4, 11], [12, 1], [8, 4], [9, 7]]) == 2\n assert candidate(properties = [[6, 9], [7, 5], [7, 9], [7, 10], [10, 4], [10, 7], [8, 4]]) == 3\n assert candidate(properties = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 4\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4]]) == 3\n assert candidate(properties = [[100000, 100000], [1, 1], [2, 2], [3, 3], [4, 4]]) == 4\n assert candidate(properties = [[1, 100000], [2, 99999], [3, 99998], [4, 99997], [5, 99996], [6, 99995], [7, 99994], [8, 99993], [9, 99992], [10, 99991], [11, 99990], [12, 99989], [13, 99988], [14, 99987], [15, 99986], [16, 99985], [17, 99984], [18, 99983], [19, 99982], [20, 99981]]) == 0\n assert candidate(properties = [[1, 1], [1, 2], [2, 1], [2, 2], [1, 3], [2, 3], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3], [1, 4], [2, 4], [3, 4], [4, 4], [1, 5], [2, 5], [3, 5], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5]]) == 16\n assert candidate(properties = [[1, 100000], [2, 99999], [3, 99998], [4, 99997], [5, 99996], [6, 99995], [7, 99994], [8, 99993], [9, 99992], [10, 99991]]) == 0\n assert candidate(properties = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [9, 5], [8, 5], [7, 5], [6, 5], [5, 5]]) == 0\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 2]]) == 8\n assert candidate(properties = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [1, 11]]) == 9\n assert candidate(properties = [[100000, 100000], [1, 1], [2, 2], [99999, 99999], [50000, 50000], [10000, 10000]]) == 5\n assert candidate(properties = [[100000, 100000], [99999, 99999], [99998, 99998], [99997, 99997], [99996, 99996], [99995, 99995], [99994, 99994], [99993, 99993], [99992, 99992], [99991, 99991]]) == 9\n assert candidate(properties = [[100000, 1], [1, 100000], [50000, 50000], [25000, 75000], [75000, 25000]]) == 0\n assert candidate(properties = [[1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [1, 1], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [2, 2], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3], [3, 3]]) == 20\n assert candidate(properties = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [10, 9], [9, 8], [8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 10]]) == 17\n assert candidate(properties = [[5, 9], [5, 7], [5, 5], [5, 3], [5, 1], [10, 10], [10, 9], [10, 8], [10, 7], [10, 6], [10, 5], [10, 4], [10, 3], [10, 2], [10, 1]]) == 5\n assert candidate(properties = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 17\n assert candidate(properties = [[1, 10], [10, 1], [2, 9], [9, 2], [3, 8], [8, 3], [4, 7], [7, 4], [5, 6], [6, 5]]) == 0\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [2, 10], [3, 9], [4, 8], [5, 7], [6, 6], [7, 5], [8, 4], [9, 3], [10, 2], [1, 10]]) == 16\n assert candidate(properties = [[1, 1], [1, 10], [1, 100], [1, 1000], [1, 10000], [1, 100000], [10, 1], [10, 10], [10, 100], [10, 1000], [10, 10000], [10, 100000]]) == 5\n assert candidate(properties = [[10, 9], [9, 8], [8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 10]]) == 8\n assert candidate(properties = [[100000, 100000], [99999, 99999], [99998, 99998], [99997, 99997], [99996, 99996]]) == 4\n assert candidate(properties = [[10, 10], [10, 9], [10, 8], [10, 7], [10, 6], [10, 5], [10, 4], [10, 3], [10, 2], [10, 1], [9, 10], [8, 10], [7, 10], [6, 10], [5, 10], [4, 10], [3, 10], [2, 10], [1, 10]]) == 0\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [10, 10]]) == 9\n assert candidate(properties = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [1, 90], [2, 89], [3, 88], [4, 87], [5, 86], [6, 85], [7, 84], [8, 83], [9, 82], [10, 81], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 18\n assert candidate(properties = [[50, 50], [51, 49], [52, 48], [53, 47], [54, 46], [55, 45], [56, 44], [57, 43], [58, 42], [59, 41], [60, 40]]) == 0\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10]]) == 9\n assert candidate(properties = [[100000, 1], [99999, 2], [99998, 3], [99997, 4], [99996, 5], [99995, 6], [99994, 7], [99993, 8], [99992, 9], [99991, 10]]) == 0\n assert candidate(properties = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == 8\n assert candidate(properties = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == 13\n assert candidate(properties = [[10, 5], [9, 6], [8, 7], [7, 8], [6, 9], [5, 10], [4, 11], [3, 12], [2, 13], [1, 14], [10, 15], [9, 16], [8, 17], [7, 18], [6, 19], [5, 20], [4, 21], [3, 22], [2, 23], [1, 24]]) == 9\n assert candidate(properties = [[100000, 1], [1, 100000], [50000, 50000], [90000, 20000], [20000, 90000]]) == 0\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5]]) == 8\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [2, 4], [2, 5], [2, 6], [3, 7], [3, 8], [3, 9], [4, 10], [4, 11], [4, 12], [5, 13], [5, 14], [5, 15]]) == 12\n assert candidate(properties = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [10, 2], [10, 3], [10, 4], [10, 5], [10, 6], [10, 7], [10, 8], [10, 9], [10, 10]]) == 9\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 9\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 5], [2, 4], [2, 3], [2, 2], [2, 1], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5]]) == 8\n assert candidate(properties = [[10, 10], [9, 9], [8, 8], [7, 7], [6, 6], [5, 5], [4, 4], [3, 3], [2, 2], [1, 1]]) == 9\n assert candidate(properties = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]]) == 14\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3], [4, 1], [4, 2], [4, 3], [5, 1], [5, 2], [5, 3]]) == 8\n assert candidate(properties = [[1, 5], [2, 10], [3, 15], [4, 20], [5, 25], [6, 30], [7, 35], [8, 40], [9, 45], [10, 50], [5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45]]) == 17\n assert candidate(properties = [[1, 10], [1, 20], [1, 30], [1, 40], [1, 50], [1, 60], [1, 70], [1, 80], [1, 90], [1, 100]]) == 0\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 0\n assert candidate(properties = [[5, 9], [7, 7], [4, 3], [1, 10], [6, 6], [8, 2], [3, 5]]) == 3\n assert candidate(properties = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [15, 6], [25, 11], [35, 16], [45, 21], [55, 26], [10, 7], [20, 12], [30, 17], [40, 22], [50, 27]]) == 13\n assert candidate(properties = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 1], [8, 2], [9, 3], [10, 4]]) == 8\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == 14\n assert candidate(properties = [[1, 100000], [2, 99999], [3, 99998], [4, 99997], [5, 99996], [6, 99995]]) == 0\n assert candidate(properties = [[20, 39], [19, 37], [18, 35], [17, 33], [16, 31], [15, 29], [14, 27], [13, 25], [12, 23], [11, 21], [10, 19], [9, 17], [8, 15], [7, 13], [6, 11], [5, 9], [4, 7], [3, 5], [2, 3], [1, 1]]) == 19\n assert candidate(properties = [[1, 100000], [100000, 1], [50000, 50000], [75000, 25000], [25000, 75000], [1, 1], [100000, 100000]]) == 4\n assert candidate(properties = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]]) == 0\n assert candidate(properties = [[1, 10], [1, 9], [1, 8], [1, 7], [1, 6], [1, 5], [1, 4], [1, 3], [1, 2], [1, 1]]) == 0\n assert candidate(properties = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]]) == 9\n assert candidate(properties = [[100, 1], [100, 2], [100, 3], [100, 4], [100, 5], [100, 6], [100, 7], [100, 8], [100, 9], [100, 10], [99, 11], [98, 12], [97, 13], [96, 14], [95, 15], [94, 16], [93, 17], [92, 18], [91, 19], [90, 20]]) == 0\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == 17\n assert candidate(properties = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]]) == 0\n assert candidate(properties = [[5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14]]) == 9\n assert candidate(properties = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10], [1, 11]]) == 0\n assert candidate(properties = [[1, 100], [2, 99], [3, 98], [4, 97], [5, 96], [6, 95], [7, 94], [8, 93], [9, 92], [10, 91], [1, 90], [2, 89], [3, 88], [4, 87], [5, 86], [6, 85], [7, 84], [8, 83], [9, 82], [10, 81]]) == 9\n assert candidate(properties = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 4\n assert candidate(properties = [[5, 5], [5, 6], [6, 5], [6, 6], [1, 1], [1, 2], [2, 1], [2, 2], [7, 7], [8, 8]]) == 9\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [10, 9], [9, 8], [8, 7], [7, 6], [6, 5], [5, 4], [4, 3], [3, 2], [2, 1], [1, 1]]) == 18\n assert candidate(properties = [[10, 10], [10, 9], [10, 8], [10, 7], [10, 6], [9, 10], [8, 10], [7, 10], [6, 10], [5, 10]]) == 0\n assert candidate(properties = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]]) == 0\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10]]) == 8\n assert candidate(properties = [[1, 5], [1, 5], [1, 5], [10, 4], [4, 3], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]]) == 8\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [1, 10]]) == 8\n assert candidate(properties = [[1, 50000], [50000, 1], [2, 49999], [49999, 2], [3, 49998], [49998, 3], [4, 49997], [49997, 4], [5, 49996], [49996, 5], [6, 49995], [49995, 6], [7, 49994], [49994, 7], [8, 49993], [49993, 8], [9, 49992], [49992, 9], [10, 49991], [49991, 10]]) == 0\n assert candidate(properties = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1]]) == 0\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12]]) == 11\n assert candidate(properties = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 9], [11, 8], [12, 7], [13, 6], [14, 5], [15, 4]]) == 8\n assert candidate(properties = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19], [11, 21], [12, 23], [13, 25], [14, 27], [15, 29], [16, 31], [17, 33], [18, 35], [19, 37], [20, 39]]) == 19\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [4, 5], [3, 5], [2, 5], [1, 5], [5, 4], [5, 3], [5, 2], [5, 1]]) == 4\n assert candidate(properties = [[50, 50], [40, 40], [30, 30], [20, 20], [10, 10], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]]) == 9\n assert candidate(properties = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]]) == 8\n assert candidate(properties = [[5, 5], [5, 5], [5, 5], [5, 5], [5, 5], [10, 10], [10, 10], [10, 10], [10, 10], [10, 10]]) == 5\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15]]) == 0\n assert candidate(properties = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]]) == 0\n assert candidate(properties = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1], [1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 10]]) == 17\n assert candidate(properties = [[9, 8], [8, 9], [7, 10], [6, 11], [5, 12], [4, 13], [3, 14], [2, 15], [1, 16], [10, 7], [11, 6], [12, 5], [13, 4], [14, 3], [15, 2], [16, 1]]) == 0\n assert candidate(properties = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5]]) == 16\n assert candidate(properties = [[1, 50], [50, 1], [2, 49], [49, 2], [3, 48], [48, 3], [4, 47], [47, 4], [5, 46], [46, 5], [6, 45], [45, 6], [7, 44], [44, 7], [8, 43], [43, 8], [9, 42], [42, 9], [10, 41], [41, 10]]) == 0\n assert candidate(properties = [[9, 7], [9, 8], [9, 9], [10, 7], [10, 8], [10, 9], [11, 7], [11, 8], [11, 9]]) == 4\n assert candidate(properties = [[1, 100000], [100000, 1], [50000, 50000], [75000, 25000], [25000, 75000]]) == 0\n assert candidate(properties = [[5, 10], [10, 5], [15, 15], [20, 10], [25, 15], [30, 20], [35, 25], [40, 30], [45, 35], [50, 40]]) == 9\n assert candidate(properties = [[5, 5], [4, 4], [3, 3], [2, 2], [1, 1], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 9\n"}, "metadata": {"canonical_parameter_names": ["properties"], "leetcode_dataset_entry_point": "Solution().numberOfWeakCharacters", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numberOfWeakCharacters(vector>& properties) {", "container": "Solution", "callable": "numberOfWeakCharacters", "parameters": [{"name": "properties", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1997, "task_id": "first-day-where-you-have-been-in-all-the-rooms", "difficulty": "Medium", "problem_description": "There are n rooms you need to visit, labeled from 0 to n - 1. Each day is labeled, starting from 0. You will go in and visit one room a day.\nInitially on day 0, you visit room 0. The order you visit the rooms for the coming days is determined by the following rules and a given 0-indexed array nextVisit of length n:\n\nAssuming that on a day, you visit room i,\nif you have been in room i an odd number of times (including the current visit), on the next day you will visit a room with a lower or equal room number specified by nextVisit[i] where 0 <= nextVisit[i] <= i;\nif you have been in room i an even number of times (including the current visit), on the next day you will visit room (i + 1) mod n.\n\nReturn the label of the first day where you have been in all the rooms. It can be shown that such a day exists. Since the answer may be very large, return it modulo 109 + 7.\n \nExample 1:\n\nInput: nextVisit = [0,0]\nOutput: 2\nExplanation:\n- On day 0, you visit room 0. The total times you have been in room 0 is 1, which is odd.\n  On the next day you will visit room nextVisit[0] = 0\n- On day 1, you visit room 0, The total times you have been in room 0 is 2, which is even.\n  On the next day you will visit room (0 + 1) mod 2 = 1\n- On day 2, you visit room 1. This is the first day where you have been in all the rooms.\n\nExample 2:\n\nInput: nextVisit = [0,0,2]\nOutput: 6\nExplanation:\nYour room visiting order for each day is: [0,0,1,0,0,1,2,...].\nDay 6 is the first day where you have been in all the rooms.\n\nExample 3:\n\nInput: nextVisit = [0,1,2,0]\nOutput: 6\nExplanation:\nYour room visiting order for each day is: [0,0,1,1,2,2,3,...].\nDay 6 is the first day where you have been in all the rooms.\n\n \nConstraints:\n\nn == nextVisit.length\n2 <= n <= 105\n0 <= nextVisit[i] <= i\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nextVisit = [0, 0, 2]) == 6\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5]) == 10\n assert candidate(nextVisit = [0, 2, 1, 0, 1, 2]) == 52\n assert candidate(nextVisit = [0, 1, 1, 1, 1]) == 16\n assert candidate(nextVisit = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1022\n assert candidate(nextVisit = [0, 1, 0, 1, 0, 1]) == 42\n assert candidate(nextVisit = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 712\n assert candidate(nextVisit = [0, 1, 2, 3, 2, 1, 0, 1, 2, 3]) == 230\n assert candidate(nextVisit = [0, 1, 0, 2]) == 10\n assert candidate(nextVisit = [0, 1, 2, 0]) == 6\n assert candidate(nextVisit = [0, 1, 1, 1, 1, 1]) == 32\n assert candidate(nextVisit = [0, 1, 1, 0, 1, 1, 0]) == 72\n assert candidate(nextVisit = [0, 1, 0, 2, 1]) == 18\n assert candidate(nextVisit = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 682\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 0]) == 10\n assert candidate(nextVisit = [0, 2, 2, 2, 2, 2]) == 20\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 18\n assert candidate(nextVisit = [0, 2, 1, 0]) == 12\n assert candidate(nextVisit = [0, 1, 1, 0, 1, 2]) == 36\n assert candidate(nextVisit = [0, 1, 1, 0]) == 8\n assert candidate(nextVisit = [0, 2, 1, 0, 1]) == 26\n assert candidate(nextVisit = [0, 0]) == 2\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4]) == 328\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 0, 0, 0, 0]) == 670\n assert candidate(nextVisit = [0, 2, 1, 3, 2, 4, 3, 5, 4, 6]) == 192\n assert candidate(nextVisit = [0, 2, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 579139391\n assert candidate(nextVisit = [0, 1, 0, 3, 2, 5, 4, 7, 6, 9]) == 58\n assert candidate(nextVisit = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1022\n assert candidate(nextVisit = [0, 0, 2, 1, 4, 3, 5, 6, 7, 8, 9]) == 98\n assert candidate(nextVisit = [0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0]) == 599186\n assert candidate(nextVisit = [0, 1, 1, 2, 2, 2, 3, 3, 3, 3]) == 358\n assert candidate(nextVisit = [0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18]) == 56\n assert candidate(nextVisit = [0, 1, 0, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 633246732\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 38\n assert candidate(nextVisit = [0, 2, 1, 2, 3, 4, 5, 4, 3, 2]) == 178\n assert candidate(nextVisit = [0, 2, 1, 3, 1, 2, 4, 2, 1, 3, 1, 2, 4, 2, 1, 3, 1, 2, 4, 2, 1, 3, 1, 2, 4, 2, 1, 3, 1, 2, 4, 2, 1, 3, 1, 2, 4]) == 449162187\n assert candidate(nextVisit = [0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 110\n assert candidate(nextVisit = [0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2]) == 786434\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 2044\n assert candidate(nextVisit = [0, 1, 0, 3, 2, 1, 4, 5, 2, 3, 6, 7, 8, 9]) == 3802\n assert candidate(nextVisit = [0, 2, 1, 0, 4, 3, 2, 1, 0]) == 176\n assert candidate(nextVisit = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 524288\n assert candidate(nextVisit = [9, 0, 1, 2, 3, 4, 5, 6, 7, 8]) == 90\n assert candidate(nextVisit = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 562740\n assert candidate(nextVisit = [0, 2, 1, 0, 3, 2, 1, 0, 4, 3, 2, 1, 0]) == 4912\n assert candidate(nextVisit = [0, 3, 5, 3, 4, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0]) == 11288\n assert candidate(nextVisit = [0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 19]) == 262148\n assert candidate(nextVisit = [0, 2, 1, 0, 3, 2, 1, 0, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 6, 5, 4, 3, 2, 1, 0]) == 40131408\n assert candidate(nextVisit = [0, 1, 0, 2, 1, 0, 3, 2, 1, 0, 4, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0]) == 13851577\n assert candidate(nextVisit = [0, 2, 1, 3, 1, 2, 5, 4, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4]) == 269566\n assert candidate(nextVisit = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 461127067\n assert candidate(nextVisit = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1048574\n assert candidate(nextVisit = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 44739242\n assert candidate(nextVisit = [0, 1, 0, 2, 1, 0, 3, 2, 1, 0]) == 556\n assert candidate(nextVisit = [0, 3, 2, 1, 0, 5, 4, 3, 2, 1, 0, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 594736\n assert candidate(nextVisit = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 701096\n assert candidate(nextVisit = [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) == 786430\n assert candidate(nextVisit = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1048574\n assert candidate(nextVisit = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 699050\n assert candidate(nextVisit = [0, 1, 2, 3, 2, 1, 2, 3, 4, 3, 4, 5, 6, 5, 6, 7, 8, 7, 8, 9]) == 198234\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 10258\n assert candidate(nextVisit = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 712\n assert candidate(nextVisit = [0, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 260\n assert candidate(nextVisit = [0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 28010\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 41964584\n assert candidate(nextVisit = [0, 1, 1, 2, 2, 3, 3, 4, 4, 5]) == 308\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1]) == 63550\n assert candidate(nextVisit = [0, 1, 1, 3, 2, 2, 5]) == 34\n assert candidate(nextVisit = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 311766262\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 38954\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 0]) == 18\n assert candidate(nextVisit = [0, 1, 0, 2, 3, 2, 5, 4]) == 82\n assert candidate(nextVisit = [0, 2, 1, 0, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9]) == 438546\n assert candidate(nextVisit = [0, 1, 2, 3, 2, 3, 4, 3, 4, 5]) == 154\n assert candidate(nextVisit = [5, 4, 3, 2, 1, 0]) == 48\n assert candidate(nextVisit = [0, 1, 0, 3, 0, 1, 0, 5, 0, 1, 0, 3, 0, 1, 0, 7, 0, 1, 0, 3, 0, 1]) == 1543578\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 3, 2, 3, 4, 5]) == 106\n assert candidate(nextVisit = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 717916156\n assert candidate(nextVisit = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]) == 57521884\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 10258\n assert candidate(nextVisit = [0, 1, 2, 0, 4, 0, 6, 0, 8, 0, 10, 0, 12, 0, 14, 0, 16, 0, 18, 0, 20]) == 5114\n assert candidate(nextVisit = [0, 1, 2, 0, 1, 2, 0, 1, 2, 0]) == 438\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3]) == 123366\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 20126903\n assert candidate(nextVisit = [5, 0, 4, 1, 3, 2, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5]) == 514496163\n assert candidate(nextVisit = [0, 0, 0, 1, 0, 0, 2, 0, 0, 3, 0, 0, 4, 0, 0, 5, 0, 0, 6, 0, 0, 7, 0, 0, 8, 0, 0, 9, 0, 0, 10]) == 943314207\n assert candidate(nextVisit = [0, 1, 2, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3]) == 229862\n assert candidate(nextVisit = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 317428\n assert candidate(nextVisit = [0, 2, 1, 0, 3, 4, 5]) == 60\n assert candidate(nextVisit = [10, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 66670\n assert candidate(nextVisit = [0, 2, 1, 2, 0, 0, 0, 3, 4, 2, 5]) == 1312\n assert candidate(nextVisit = [0, 2, 4, 6, 8, 0, 2, 4, 6, 8]) == 812\n assert candidate(nextVisit = [0, 1, 0, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 89816588\n assert candidate(nextVisit = [0, 2, 1, 0, 3, 2, 1]) == 80\n assert candidate(nextVisit = [0, 2, 1, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 16, 15, 18, 17, 20, 19, 22, 21, 24, 23, 25]) == 2657202\n assert candidate(nextVisit = [0, 3, 1, 0, 2, 0, 3, 1, 0, 2, 0, 3, 1, 0, 2, 0, 3, 1, 0, 2, 0, 3, 1, 0, 2, 0, 3, 1, 0, 2, 0]) == 558657481\n assert candidate(nextVisit = [0, 5, 2, 4, 3, 1, 6, 8, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 212\n assert candidate(nextVisit = [0, 2, 1, 2, 3, 2, 1, 2, 3, 4]) == 430\n assert candidate(nextVisit = [0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, 0]) == 855298880\n assert candidate(nextVisit = [0, 2, 4, 6, 8, 0, 2, 4, 6, 8]) == 812\n assert candidate(nextVisit = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 40\n assert candidate(nextVisit = [0, 2, 1, 0, 3, 2, 5, 4, 7, 6, 9, 8]) == 788\n assert candidate(nextVisit = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 512\n assert candidate(nextVisit = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 640520038\n assert candidate(nextVisit = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 147483632\n assert candidate(nextVisit = [0, 1, 2, 0, 3, 2, 5, 6, 7, 8, 9, 10, 0]) == 220\n assert candidate(nextVisit = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == 590\n assert candidate(nextVisit = [0, 3, 2, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 38\n assert candidate(nextVisit = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 512\n assert candidate(nextVisit = [0, 1, 0, 1, 2, 3, 4, 5, 6, 7]) == 334\n"}, "metadata": {"canonical_parameter_names": ["nextVisit"], "leetcode_dataset_entry_point": "Solution().firstDayBeenInAllRooms", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int firstDayBeenInAllRooms(vector& nextVisit) {", "container": "Solution", "callable": "firstDayBeenInAllRooms", "parameters": [{"name": "nextVisit", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 1998, "task_id": "gcd-sort-of-an-array", "difficulty": "Hard", "problem_description": "You are given an integer array nums, and you can perform the following operation any number of times on nums:\n\nSwap the positions of two elements nums[i] and nums[j] if gcd(nums[i], nums[j]) > 1 where gcd(nums[i], nums[j]) is the greatest common divisor of nums[i] and nums[j].\n\nReturn true if it is possible to sort nums in non-decreasing order using the above swap method, or false otherwise.\n \nExample 1:\n\nInput: nums = [7,21,3]\nOutput: true\nExplanation: We can sort [7,21,3] by performing the following operations:\n- Swap 7 and 21 because gcd(7,21) = 7. nums = [21,7,3]\n- Swap 21 and 3 because gcd(21,3) = 3. nums = [3,7,21]\n\nExample 2:\n\nInput: nums = [5,2,6,2]\nOutput: false\nExplanation: It is impossible to sort the array because 5 cannot be swapped with any other element.\n\nExample 3:\n\nInput: nums = [10,5,9,3,15]\nOutput: true\nWe can sort [10,5,9,3,15] by performing the following operations:\n- Swap 10 and 15 because gcd(10,15) = 5. nums = [15,5,9,3,10]\n- Swap 15 and 3 because gcd(15,3) = 3. nums = [3,5,9,15,10]\n- Swap 10 and 15 because gcd(10,15) = 5. nums = [3,5,9,10,15]\n\n \nConstraints:\n\n1 <= nums.length <= 3 * 104\n2 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [12, 15, 18, 20, 25]) == True\n assert candidate(nums = [7, 21, 3]) == True\n assert candidate(nums = [8, 4, 12, 6]) == True\n assert candidate(nums = [2, 3, 5, 7, 11]) == True\n assert candidate(nums = [2, 4, 6, 8, 10]) == True\n assert candidate(nums = [1, 2, 3, 4]) == True\n assert candidate(nums = [18, 9, 27, 3, 6]) == True\n assert candidate(nums = [3, 9, 6, 18, 27]) == True\n assert candidate(nums = [1, 2, 3, 4, 5]) == True\n assert candidate(nums = [37, 49, 111, 143, 169]) == True\n assert candidate(nums = [100, 200, 400, 800, 1600]) == True\n assert candidate(nums = [22, 44, 11, 66, 33]) == True\n assert candidate(nums = [100, 200, 300, 400, 500]) == True\n assert candidate(nums = [83, 97, 101, 103, 107]) == True\n assert candidate(nums = [100000, 99998, 99999, 99997, 99996]) == False\n assert candidate(nums = [10, 5, 9, 3, 15]) == True\n assert candidate(nums = [105, 70, 30, 210, 42]) == True\n assert candidate(nums = [30, 42, 70, 105, 35]) == True\n assert candidate(nums = [5, 2, 6, 2]) == False\n assert candidate(nums = [56, 72, 88, 104, 120, 136, 152]) == True\n assert candidate(nums = [121, 132, 143, 154, 165, 176, 187, 198, 209]) == True\n assert candidate(nums = [48, 64, 80, 96, 112]) == True\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119]) == True\n assert candidate(nums = [210, 315, 420, 525, 630, 735]) == True\n assert candidate(nums = [105, 45, 63, 21, 315]) == True\n assert candidate(nums = [100, 50, 25, 125, 200, 150]) == True\n assert candidate(nums = [91, 182, 273, 364, 455]) == True\n assert candidate(nums = [121, 132, 143, 154, 165, 176]) == True\n assert candidate(nums = [16, 32, 48, 64, 80, 96, 112, 128, 144]) == True\n assert candidate(nums = [70, 35, 28, 56, 14, 18]) == True\n assert candidate(nums = [14, 21, 28, 35, 42, 49, 56, 63, 70]) == True\n assert candidate(nums = [32, 48, 64, 80, 96, 112]) == True\n assert candidate(nums = [31, 62, 93, 124, 155, 186, 217, 248, 279, 310]) == True\n assert candidate(nums = [30, 25, 20, 15, 10, 5]) == True\n assert candidate(nums = [30, 45, 60, 75, 90, 105]) == True\n assert candidate(nums = [44, 55, 66, 77, 88, 99, 110, 121]) == True\n assert candidate(nums = [15, 20, 25, 30, 35]) == True\n assert candidate(nums = [33, 66, 99, 132, 165]) == True\n assert candidate(nums = [49, 14, 7, 98, 28]) == True\n assert candidate(nums = [6, 8, 10, 12, 14, 16, 18, 20]) == True\n assert candidate(nums = [21, 42, 63, 84, 105, 126, 147, 168, 189]) == True\n assert candidate(nums = [49, 42, 28, 35, 70]) == True\n assert candidate(nums = [123, 246, 369, 492, 615, 738, 861, 984]) == True\n assert candidate(nums = [84, 126, 168, 210, 252, 294, 336, 378, 420]) == True\n assert candidate(nums = [84, 28, 42, 70, 56]) == True\n assert candidate(nums = [101, 202, 303, 404, 505, 606]) == True\n assert candidate(nums = [56, 14, 28, 7, 98, 49]) == True\n assert candidate(nums = [45, 30, 60, 90, 120, 150]) == True\n assert candidate(nums = [100, 50, 75, 25, 150]) == True\n assert candidate(nums = [15, 25, 35, 45, 55, 65]) == True\n assert candidate(nums = [23, 46, 69, 92, 115, 138, 161, 184]) == True\n assert candidate(nums = [121, 221, 143, 169, 13]) == True\n assert candidate(nums = [100, 200, 300, 400, 500]) == True\n assert candidate(nums = [462, 882, 924, 1092, 1260]) == True\n assert candidate(nums = [360, 720, 1080, 1440, 1800, 2160]) == True\n assert candidate(nums = [1000, 500, 250, 125, 625]) == True\n assert candidate(nums = [48, 120, 180, 240, 300]) == True\n assert candidate(nums = [16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240]) == True\n assert candidate(nums = [210, 70, 35, 14, 105]) == True\n assert candidate(nums = [1024, 2048, 512, 256, 128]) == True\n assert candidate(nums = [56, 112, 168, 224, 280]) == True\n assert candidate(nums = [100, 25, 50, 20, 40]) == True\n assert candidate(nums = [24, 36, 48, 12, 60]) == True\n assert candidate(nums = [99, 33, 66, 22, 11, 132]) == True\n assert candidate(nums = [21, 42, 63, 84, 105]) == True\n assert candidate(nums = [13, 26, 39, 52, 65, 78]) == True\n assert candidate(nums = [30, 45, 60, 75, 90]) == True\n assert candidate(nums = [77, 154, 231, 308, 385]) == True\n assert candidate(nums = [91, 130, 169, 182, 273, 338]) == True\n assert candidate(nums = [22, 15, 45, 33, 10, 55]) == True\n assert candidate(nums = [18, 27, 36, 45, 54, 63, 72, 81, 90]) == True\n assert candidate(nums = [111, 222, 333, 444, 555, 666, 777, 888, 999]) == True\n assert candidate(nums = [171, 342, 513, 684, 855]) == True\n assert candidate(nums = [33, 55, 66, 88, 110, 121, 132, 143]) == True\n assert candidate(nums = [4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28]) == True\n assert candidate(nums = [45, 90, 135, 180, 225]) == True\n assert candidate(nums = [20, 40, 60, 80, 100, 120, 140, 160, 180]) == True\n assert candidate(nums = [100, 50, 25, 20, 125]) == True\n assert candidate(nums = [18, 24, 30, 36, 42]) == True\n assert candidate(nums = [1000, 250, 500, 200, 750, 125, 375, 625, 875, 1250]) == True\n assert candidate(nums = [102, 136, 170, 204, 238, 272, 306, 340, 374]) == True\n assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190]) == True\n assert candidate(nums = [27, 54, 81, 108, 135, 162, 189, 216]) == True\n assert candidate(nums = [119, 238, 357, 476, 595]) == True\n assert candidate(nums = [81, 27, 54, 162, 324, 486]) == True\n assert candidate(nums = [84, 12, 14, 21, 63]) == True\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105]) == True\n assert candidate(nums = [18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108]) == True\n assert candidate(nums = [49, 63, 77, 91, 105, 119, 133, 147, 161, 175, 189, 203, 217]) == True\n assert candidate(nums = [72, 108, 144, 180, 216, 252, 288, 324, 360, 396]) == True\n assert candidate(nums = [225, 150, 100, 50, 25, 75]) == True\n assert candidate(nums = [121, 110, 99, 88, 77, 66, 55, 44, 33, 22, 11]) == True\n assert candidate(nums = [22, 44, 66, 88, 110, 132, 154, 176, 198]) == True\n assert candidate(nums = [1000, 500, 250, 125, 2000]) == True\n assert candidate(nums = [135, 90, 45, 60, 30]) == True\n assert candidate(nums = [9, 18, 27, 36, 45, 54]) == True\n assert candidate(nums = [17, 34, 51, 68, 85]) == True\n assert candidate(nums = [105, 15, 35, 21, 63]) == True\n assert candidate(nums = [81, 135, 207, 279, 351, 423]) == True\n assert candidate(nums = [36, 48, 60, 72, 84, 96]) == True\n assert candidate(nums = [180, 120, 90, 60, 45, 30, 20, 15, 10, 5]) == True\n assert candidate(nums = [28, 14, 42, 70, 98]) == True\n assert candidate(nums = [17, 19, 23, 29, 31, 37]) == True\n assert candidate(nums = [81, 27, 54, 108, 162]) == True\n assert candidate(nums = [121, 11, 22, 33, 44, 55]) == True\n assert candidate(nums = [165, 330, 495, 660, 825]) == True\n assert candidate(nums = [49, 98, 147, 196, 245]) == True\n assert candidate(nums = [121, 44, 88, 22, 176]) == True\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85]) == True\n assert candidate(nums = [100, 101, 102, 103, 104, 105]) == True\n assert candidate(nums = [17, 19, 23, 29, 31]) == True\n assert candidate(nums = [315, 105, 35, 7, 14, 21, 42, 63, 84]) == True\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]) == True\n assert candidate(nums = [13, 26, 39, 52, 65]) == True\n assert candidate(nums = [15, 25, 35, 45, 55]) == True\n assert candidate(nums = [7, 49, 343, 2401, 16807]) == True\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == True\n assert candidate(nums = [19, 38, 57, 76, 95, 114, 133, 152]) == True\n assert candidate(nums = [14, 21, 35, 49, 70]) == True\n assert candidate(nums = [33, 66, 99, 132, 165, 198]) == True\n assert candidate(nums = [18, 24, 30, 36, 42, 48]) == True\n assert candidate(nums = [22, 44, 66, 88, 110]) == True\n assert candidate(nums = [84, 56, 28, 14, 7, 49, 35]) == True\n assert candidate(nums = [48, 64, 80, 96, 112, 128]) == True\n assert candidate(nums = [1024, 2048, 4096, 8192, 16384, 32768]) == True\n assert candidate(nums = [56, 63, 70, 77, 84, 91]) == True\n assert candidate(nums = [99, 33, 66, 132, 264]) == True\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250]) == True\n assert candidate(nums = [77, 91, 143, 1001, 1001, 143]) == True\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700]) == True\n assert candidate(nums = [77, 55, 99, 110, 132]) == True\n assert candidate(nums = [30, 45, 60, 15, 90]) == True\n assert candidate(nums = [72, 24, 16, 8, 40]) == True\n assert candidate(nums = [42, 21, 7, 14, 28]) == True\n assert candidate(nums = [77, 143, 169, 187, 209, 221, 247, 299, 323, 341]) == True\n assert candidate(nums = [15, 20, 25, 30, 35, 40, 45, 50]) == True\n assert candidate(nums = [121, 143, 169, 187, 209]) == True\n assert candidate(nums = [14, 21, 28, 35, 42, 49, 56, 63]) == True\n assert candidate(nums = [14, 21, 28, 35, 42, 49]) == True\n assert candidate(nums = [49, 147, 245, 343, 441, 539]) == True\n assert candidate(nums = [22, 15, 10, 18, 30]) == True\n assert candidate(nums = [64, 32, 16, 8, 4, 2, 1]) == False\n assert candidate(nums = [101, 103, 107, 109, 113, 127, 131, 137, 139, 149]) == True\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81]) == True\n assert candidate(nums = [16, 32, 64, 128, 256, 512, 1024]) == True\n assert candidate(nums = [102, 204, 306, 408, 510]) == True\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000]) == True\n assert candidate(nums = [60, 120, 180, 240, 300, 360]) == True\n assert candidate(nums = [42, 28, 70, 14, 35]) == True\n assert candidate(nums = [22, 33, 44, 55, 66]) == True\n assert candidate(nums = [77, 49, 35, 21, 14, 7]) == True\n assert candidate(nums = [23, 46, 69, 92, 115]) == True\n assert candidate(nums = [16, 8, 4, 2, 1]) == False\n assert candidate(nums = [101, 202, 303, 404, 505]) == True\n assert candidate(nums = [102, 68, 34, 17, 51, 85]) == True\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117]) == True\n assert candidate(nums = [100, 105, 140, 210, 70]) == True\n assert candidate(nums = [11, 22, 33, 44, 55, 66]) == True\n assert candidate(nums = [17, 34, 51, 68, 85, 102, 119, 136, 153]) == True\n assert candidate(nums = [256, 512, 1024, 2048, 4096, 8192, 16384]) == True\n assert candidate(nums = [1000, 500, 250, 125, 2000, 10000, 2500]) == True\n assert candidate(nums = [30, 45, 60, 75, 90, 105, 120]) == True\n assert candidate(nums = [12, 18, 24, 30, 36, 42]) == True\n assert candidate(nums = [25, 45, 65, 85, 105]) == True\n assert candidate(nums = [100, 200, 150, 300, 250]) == True\n assert candidate(nums = [14, 28, 42, 56, 70]) == True\n assert candidate(nums = [81, 135, 225, 315, 405, 525, 675]) == True\n assert candidate(nums = [121, 132, 220, 110, 55]) == True\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().gcdSort", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool gcdSort(vector& nums) {", "container": "Solution", "callable": "gcdSort", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2000, "task_id": "reverse-prefix-of-word", "difficulty": "Easy", "problem_description": "Given a 0-indexed string word and a character ch, reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ch (inclusive). If the character ch does not exist in word, do nothing.\n\nFor example, if word = \"abcdefd\" and ch = \"d\", then you should reverse the segment that starts at 0 and ends at 3 (inclusive). The resulting string will be \"dcbaefd\".\n\nReturn the resulting string.\n \nExample 1:\n\nInput: word = \"abcdefd\", ch = \"d\"\nOutput: \"dcbaefd\"\nExplanation: The first occurrence of \"d\" is at index 3. \nReverse the part of word from 0 to 3 (inclusive), the resulting string is \"dcbaefd\".\n\nExample 2:\n\nInput: word = \"xyxzxe\", ch = \"z\"\nOutput: \"zxyxxe\"\nExplanation: The first and only occurrence of \"z\" is at index 3.\nReverse the part of word from 0 to 3 (inclusive), the resulting string is \"zxyxxe\".\n\nExample 3:\n\nInput: word = \"abcd\", ch = \"z\"\nOutput: \"abcd\"\nExplanation: \"z\" does not exist in word.\nYou should not do any reverse operation, the resulting string is \"abcd\".\n\n \nConstraints:\n\n1 <= word.length <= 250\nword consists of lowercase English letters.\nch is a lowercase English letter.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"abcdef\",ch = \"f\") == \"fedcba\"\n assert candidate(word = \"madam\",ch = \"d\") == \"damam\"\n assert candidate(word = \"abcdefd\",ch = \"d\") == \"dcbaefd\"\n assert candidate(word = \"abcd\",ch = \"z\") == \"abcd\"\n assert candidate(word = \"a\",ch = \"a\") == \"a\"\n assert candidate(word = \"python\",ch = \"y\") == \"ypthon\"\n assert candidate(word = \"operation\",ch = \"p\") == \"poeration\"\n assert candidate(word = \"xyxzxe\",ch = \"z\") == \"zxyxxe\"\n assert candidate(word = \"segment\",ch = \"t\") == \"tnemges\"\n assert candidate(word = \"hello\",ch = \"l\") == \"lehlo\"\n assert candidate(word = \"racecar\",ch = \"e\") == \"ecarcar\"\n assert candidate(word = \"abcdef\",ch = \"g\") == \"abcdef\"\n assert candidate(word = \"example\",ch = \"m\") == \"maxeple\"\n assert candidate(word = \"reverse\",ch = \"r\") == \"reverse\"\n assert candidate(word = \"abcdef\",ch = \"a\") == \"abcdef\"\n assert candidate(word = \"supercalifragilisticexpialidocious\",ch = \"x\") == \"xecitsiligarfilacrepuspialidocious\"\n assert candidate(word = \"abracadabra\",ch = \"r\") == \"rbaacadabra\"\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcba\",ch = \"a\") == \"abcdefghijklmnopqrstuvwxyz\"\n assert candidate(word = \"\",ch = \"a\") == \"\"\n assert candidate(word = \"unbelievable\",ch = \"e\") == \"ebnulievable\"\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\",ch = \"m\") == \"mlkjihgfedcbanopqrstuvwxyz\"\n assert candidate(word = \"supercalifragilisticexpialidocious\",ch = \"c\") == \"crepusalifragilisticexpialidocious\"\n assert candidate(word = \"interview\",ch = \"w\") == \"weivretni\"\n assert candidate(word = \"unpredictable\",ch = \"d\") == \"derpnuictable\"\n assert candidate(word = \"beautifulization\",ch = \"z\") == \"zilufituaebation\"\n assert candidate(word = \"characterization\",ch = \"c\") == \"characterization\"\n assert candidate(word = \"communication\",ch = \"m\") == \"mocmunication\"\n assert candidate(word = \"reversethispart\",ch = \"e\") == \"erversethispart\"\n assert candidate(word = \"reinforce\",ch = \"e\") == \"erinforce\"\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcba\",ch = \"q\") == \"qrstuvwxyzponmlkjihgfedcba\"\n assert candidate(word = \"unbelievable\",ch = \"l\") == \"lebnuievable\"\n assert candidate(word = \"nothingtoreverse\",ch = \"x\") == \"nothingtoreverse\"\n assert candidate(word = \"characterization\",ch = \"a\") == \"ahcracterization\"\n assert candidate(word = \"quickbrownfox\",ch = \"o\") == \"orbkciuqwnfox\"\n assert candidate(word = \"banana\",ch = \"n\") == \"nabana\"\n assert candidate(word = \"qwertyuiop\",ch = \"p\") == \"poiuytrewq\"\n assert candidate(word = \"qwertyuiop\",ch = \"q\") == \"qwertyuiop\"\n assert candidate(word = \"boundary\",ch = \"d\") == \"dnuobary\"\n assert candidate(word = \"continuous\",ch = \"s\") == \"suounitnoc\"\n assert candidate(word = \"interoperability\",ch = \"i\") == \"interoperability\"\n assert candidate(word = \"aaaaaa\",ch = \"a\") == \"aaaaaa\"\n assert candidate(word = \"quizzically\",ch = \"q\") == \"quizzically\"\n assert candidate(word = \"congratulations\",ch = \"g\") == \"gnocratulations\"\n assert candidate(word = \"aabbccddeeff\",ch = \"f\") == \"feeddccbbaaf\"\n assert candidate(word = \"zyxwvutsrqponmlkjihgfedcba\",ch = \"m\") == \"mnopqrstuvwxyzlkjihgfedcba\"\n assert candidate(word = \"concatenation\",ch = \"c\") == \"concatenation\"\n assert candidate(word = \"implementation\",ch = \"i\") == \"implementation\"\n assert candidate(word = \"establishment\",ch = \"b\") == \"batselishment\"\n assert candidate(word = \"abcdefghijkllllllllllllllllllllllllllllllllllllllllllllllll\",ch = \"l\") == \"lkjihgfedcballlllllllllllllllllllllllllllllllllllllllllllll\"\n assert candidate(word = \"abcdefg\",ch = \"g\") == \"gfedcba\"\n assert candidate(word = \"development\",ch = \"p\") == \"polevedment\"\n assert candidate(word = \"unfortunately\",ch = \"r\") == \"rofnutunately\"\n assert candidate(word = \"challenges\",ch = \"e\") == \"ellahcnges\"\n assert candidate(word = \"thisisaverylongwordthatneedstoreversed\",ch = \"n\") == \"nolyrevasisihtgwordthatneedstoreversed\"\n assert candidate(word = \"interview\",ch = \"e\") == \"etnirview\"\n assert candidate(word = \"abcdeffedcba\",ch = \"f\") == \"fedcbafedcba\"\n assert candidate(word = \"classification\",ch = \"l\") == \"lcassification\"\n assert candidate(word = \"thisisateststring\",ch = \"t\") == \"thisisateststring\"\n assert candidate(word = \"mississippi\",ch = \"i\") == \"imssissippi\"\n assert candidate(word = \"unbelievable\",ch = \"b\") == \"bnuelievable\"\n assert candidate(word = \"mississippi\",ch = \"s\") == \"simsissippi\"\n assert candidate(word = \"congratulations\",ch = \"l\") == \"lutargnocations\"\n assert candidate(word = \"synchronous\",ch = \"c\") == \"cnyshronous\"\n assert candidate(word = \"algorithm\",ch = \"l\") == \"lagorithm\"\n assert candidate(word = \"abracadabra\",ch = \"c\") == \"carbaadabra\"\n assert candidate(word = \"zzzzzzzzzzzzzzzz\",ch = \"z\") == \"zzzzzzzzzzzzzzzz\"\n assert candidate(word = \"development\",ch = \"l\") == \"levedopment\"\n assert candidate(word = \"identification\",ch = \"i\") == \"identification\"\n assert candidate(word = \"beautiful\",ch = \"t\") == \"tuaebiful\"\n assert candidate(word = \"asdfghjklzxcvbnm\",ch = \"m\") == \"mnbvcxzlkjhgfdsa\"\n assert candidate(word = \"representation\",ch = \"r\") == \"representation\"\n assert candidate(word = \"congratulations\",ch = \"t\") == \"targnoculations\"\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",ch = \"q\") == \"qppoonnmmllkkjjiihhggffeeddccbbaaqrrssttuuvvwwxxyyzz\"\n assert candidate(word = \"sequence\",ch = \"q\") == \"qesuence\"\n assert candidate(word = \"environment\",ch = \"v\") == \"vneironment\"\n assert candidate(word = \"algorithm\",ch = \"g\") == \"glaorithm\"\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",ch = \"z\") == \"zyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaaz\"\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\",ch = \"z\") == \"zyxwvutsrqponmlkjihgfedcba\"\n assert candidate(word = \"abcdefghij\",ch = \"e\") == \"edcbafghij\"\n assert candidate(word = \"solution\",ch = \"u\") == \"ulostion\"\n assert candidate(word = \"environment\",ch = \"n\") == \"nevironment\"\n assert candidate(word = \"environmentally\",ch = \"v\") == \"vneironmentally\"\n assert candidate(word = \"algorithm\",ch = \"o\") == \"oglarithm\"\n assert candidate(word = \"single\",ch = \"l\") == \"lgnise\"\n assert candidate(word = \"supercalifragilisticexpialidocious\",ch = \"f\") == \"filacrepusragilisticexpialidocious\"\n assert candidate(word = \"abcdefg\",ch = \"z\") == \"abcdefg\"\n assert candidate(word = \"double\",ch = \"x\") == \"double\"\n assert candidate(word = \"algorithms\",ch = \"a\") == \"algorithms\"\n assert candidate(word = \"algorithm\",ch = \"r\") == \"roglaithm\"\n assert candidate(word = \"characterization\",ch = \"h\") == \"hcaracterization\"\n assert candidate(word = \"xyzzyx\",ch = \"z\") == \"zyxzyx\"\n assert candidate(word = \"subsequence\",ch = \"q\") == \"qesbusuence\"\n assert candidate(word = \"reversal\",ch = \"a\") == \"asreverl\"\n assert candidate(word = \"a\",ch = \"b\") == \"a\"\n assert candidate(word = \"visualization\",ch = \"i\") == \"ivsualization\"\n assert candidate(word = \"incomprehensible\",ch = \"h\") == \"herpmocniensible\"\n assert candidate(word = \"hellothere\",ch = \"e\") == \"ehllothere\"\n assert candidate(word = \"reverseprefix\",ch = \"r\") == \"reverseprefix\"\n assert candidate(word = \"pneumonoultramicroscopicsilicovolcanoconiosis\",ch = \"o\") == \"omuenpnoultramicroscopicsilicovolcanoconiosis\"\n assert candidate(word = \"uniquecharacters\",ch = \"u\") == \"uniquecharacters\"\n assert candidate(word = \"alphabetization\",ch = \"b\") == \"bahplaetization\"\n assert candidate(word = \"standardization\",ch = \"i\") == \"idradnatszation\"\n assert candidate(word = \"automation\",ch = \"o\") == \"otuamation\"\n assert candidate(word = \"mnopqr\",ch = \"r\") == \"rqponm\"\n assert candidate(word = \"pronunciation\",ch = \"u\") == \"unorpnciation\"\n assert candidate(word = \"abacaxa\",ch = \"a\") == \"abacaxa\"\n assert candidate(word = \"reversal\",ch = \"r\") == \"reversal\"\n assert candidate(word = \"congratulations\",ch = \"u\") == \"utargnoclations\"\n assert candidate(word = \"performance\",ch = \"f\") == \"frepormance\"\n assert candidate(word = \"nevertheless\",ch = \"n\") == \"nevertheless\"\n assert candidate(word = \"multifaceted\",ch = \"f\") == \"fitlumaceted\"\n assert candidate(word = \"reversal\",ch = \"v\") == \"verersal\"\n assert candidate(word = \"thisisaverylongwordthatshouldtestthelimitsofthefunction\",ch = \"t\") == \"thisisaverylongwordthatshouldtestthelimitsofthefunction\"\n assert candidate(word = \"sophistication\",ch = \"s\") == \"sophistication\"\n assert candidate(word = \"xylophone\",ch = \"o\") == \"olyxphone\"\n assert candidate(word = \"visualization\",ch = \"z\") == \"zilausivation\"\n assert candidate(word = \"pneumonoultramicroscopicsilicovolcanoconiosis\",ch = \"u\") == \"uenpmonoultramicroscopicsilicovolcanoconiosis\"\n assert candidate(word = \"xyzxyzxyz\",ch = \"x\") == \"xyzxyzxyz\"\n assert candidate(word = \"challenge\",ch = \"e\") == \"ellahcnge\"\n assert candidate(word = \"perseverance\",ch = \"v\") == \"vesreperance\"\n assert candidate(word = \"abcdefghijk\",ch = \"i\") == \"ihgfedcbajk\"\n assert candidate(word = \"mississippi\",ch = \"p\") == \"pississimpi\"\n assert candidate(word = \"programming\",ch = \"g\") == \"gorpramming\"\n assert candidate(word = \"responsibilities\",ch = \"s\") == \"serponsibilities\"\n assert candidate(word = \"synchronization\",ch = \"n\") == \"nyschronization\"\n assert candidate(word = \"floccinaucinihilipilification\",ch = \"f\") == \"floccinaucinihilipilification\"\n assert candidate(word = \"operationalization\",ch = \"o\") == \"operationalization\"\n assert candidate(word = \"specializations\",ch = \"a\") == \"aicepslizations\"\n assert candidate(word = \"optimization\",ch = \"t\") == \"tpoimization\"\n assert candidate(word = \"abcdefghijk\",ch = \"h\") == \"hgfedcbaijk\"\n assert candidate(word = \"xylophone\",ch = \"p\") == \"polyxhone\"\n assert candidate(word = \"hellohellohello\",ch = \"l\") == \"lehlohellohello\"\n assert candidate(word = \"concatenation\",ch = \"n\") == \"noccatenation\"\n"}, "metadata": {"canonical_parameter_names": ["word", "ch"], "leetcode_dataset_entry_point": "Solution().reversePrefix", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string reversePrefix(string word, char ch) {", "container": "Solution", "callable": "reversePrefix", "parameters": [{"name": "word", "type": "string"}, {"name": "ch", "type": "char"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2001, "task_id": "number-of-pairs-of-interchangeable-rectangles", "difficulty": "Medium", "problem_description": "You are given n rectangles represented by a 0-indexed 2D integer array rectangles, where rectangles[i] = [widthi, heighti] denotes the width and height of the ith rectangle.\nTwo rectangles i and j (i < j) are considered interchangeable if they have the same width-to-height ratio. More formally, two rectangles are interchangeable if widthi/heighti == widthj/heightj (using decimal division, not integer division).\nReturn the number of pairs of interchangeable rectangles in rectangles.\n \nExample 1:\n\nInput: rectangles = [[4,8],[3,6],[10,20],[15,30]]\nOutput: 6\nExplanation: The following are the interchangeable pairs of rectangles by index (0-indexed):\n- Rectangle 0 with rectangle 1: 4/8 == 3/6.\n- Rectangle 0 with rectangle 2: 4/8 == 10/20.\n- Rectangle 0 with rectangle 3: 4/8 == 15/30.\n- Rectangle 1 with rectangle 2: 3/6 == 10/20.\n- Rectangle 1 with rectangle 3: 3/6 == 15/30.\n- Rectangle 2 with rectangle 3: 10/20 == 15/30.\n\nExample 2:\n\nInput: rectangles = [[4,5],[7,8]]\nOutput: 0\nExplanation: There are no interchangeable pairs of rectangles.\n\n \nConstraints:\n\nn == rectangles.length\n1 <= n <= 105\nrectangles[i].length == 2\n1 <= widthi, heighti <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]]) == 10\n assert candidate(rectangles = [[5, 10], [10, 20], [20, 40], [40, 80]]) == 6\n assert candidate(rectangles = [[2, 3], [3, 4], [4, 5], [5, 6]]) == 0\n assert candidate(rectangles = [[4, 5], [7, 8]]) == 0\n assert candidate(rectangles = [[5, 10], [10, 20], [15, 30], [20, 40], [25, 50]]) == 10\n assert candidate(rectangles = [[5, 10], [10, 20], [15, 30], [20, 40]]) == 6\n assert candidate(rectangles = [[4, 8], [3, 6], [10, 20], [15, 30]]) == 6\n assert candidate(rectangles = [[1, 2], [2, 4], [3, 6], [4, 8]]) == 6\n assert candidate(rectangles = [[2, 3], [3, 4], [4, 6], [6, 9]]) == 3\n assert candidate(rectangles = [[2, 3], [3, 2], [6, 9], [9, 6]]) == 2\n assert candidate(rectangles = [[10, 5], [5, 10], [20, 10], [10, 20], [30, 15]]) == 4\n assert candidate(rectangles = [[1, 2], [2, 4], [4, 8], [8, 16]]) == 6\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]]) == 45\n assert candidate(rectangles = [[2, 4], [4, 8], [8, 16], [16, 32], [32, 64], [64, 128]]) == 15\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12]]) == 66\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11]]) == 55\n assert candidate(rectangles = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]]) == 45\n assert candidate(rectangles = [[1, 3], [2, 6], [3, 9], [4, 12], [5, 15]]) == 10\n assert candidate(rectangles = [[5, 10], [10, 20], [15, 30], [20, 40], [25, 50], [30, 60], [35, 70], [40, 80], [45, 90], [50, 100]]) == 45\n assert candidate(rectangles = [[7, 10], [14, 20], [21, 30], [28, 40], [35, 50], [42, 60], [49, 70], [56, 80], [63, 90], [70, 100], [77, 110], [84, 120]]) == 66\n assert candidate(rectangles = [[10, 20], [15, 30], [20, 40], [25, 50], [30, 60], [35, 70], [40, 80], [45, 90]]) == 28\n assert candidate(rectangles = [[100, 200], [150, 300], [200, 400], [250, 500], [300, 600], [350, 700], [400, 800], [450, 900], [500, 1000]]) == 36\n assert candidate(rectangles = [[2, 5], [4, 10], [6, 15], [8, 20], [10, 25], [12, 30], [14, 35], [16, 40], [18, 45], [20, 50]]) == 45\n assert candidate(rectangles = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20], [11, 22], [12, 24]]) == 66\n assert candidate(rectangles = [[100, 200], [200, 400], [300, 600], [400, 800], [500, 1000], [600, 1200], [700, 1400], [800, 1600], [900, 1800], [1000, 2000]]) == 45\n assert candidate(rectangles = [[3, 9], [6, 18], [9, 27], [12, 36], [15, 45], [18, 54], [21, 63], [24, 72], [27, 81], [30, 90]]) == 45\n assert candidate(rectangles = [[1000, 2000], [1500, 3000], [2000, 4000], [2500, 5000], [3000, 6000], [3500, 7000], [4000, 8000], [4500, 9000], [5000, 10000]]) == 36\n assert candidate(rectangles = [[1, 1], [1, 2], [2, 1], [1, 3], [3, 1], [2, 3], [3, 2], [1, 4], [4, 1], [2, 4], [4, 2], [3, 4], [4, 3]]) == 2\n assert candidate(rectangles = [[10, 20], [15, 30], [20, 40], [25, 50], [30, 60], [35, 70], [40, 80], [45, 90], [50, 100]]) == 36\n assert candidate(rectangles = [[10, 5], [5, 10], [2, 1], [1, 2], [4, 2], [2, 4], [8, 4], [4, 8], [16, 8], [8, 16]]) == 20\n assert candidate(rectangles = [[1, 3], [2, 6], [3, 9], [4, 12], [5, 15], [6, 18], [7, 21], [8, 24], [9, 27], [10, 30], [11, 33], [12, 36], [13, 39]]) == 78\n assert candidate(rectangles = [[3, 4], [6, 8], [9, 12], [12, 16], [15, 20], [18, 24], [21, 28], [24, 32]]) == 28\n assert candidate(rectangles = [[5, 15], [10, 30], [15, 45], [20, 60], [25, 75]]) == 10\n assert candidate(rectangles = [[3, 9], [9, 27], [27, 81], [81, 243], [243, 729]]) == 10\n assert candidate(rectangles = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20], [11, 22], [12, 24], [13, 26], [14, 28], [15, 30]]) == 105\n assert candidate(rectangles = [[10, 20], [15, 30], [20, 40], [25, 50], [30, 60], [35, 70], [40, 80], [45, 90], [50, 100], [55, 110]]) == 45\n assert candidate(rectangles = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]]) == 0\n assert candidate(rectangles = [[1, 2], [2, 1], [1, 3], [3, 1], [2, 3], [3, 2], [1, 4], [4, 1], [2, 4], [4, 2]]) == 2\n assert candidate(rectangles = [[5, 15], [10, 30], [15, 45], [20, 60], [25, 75], [30, 90], [35, 105], [40, 120]]) == 28\n assert candidate(rectangles = [[1, 100000], [2, 50000], [3, 33333], [4, 25000], [5, 20000], [6, 16667], [7, 14286], [8, 12500], [9, 11111], [10, 10000]]) == 0\n assert candidate(rectangles = [[2, 3], [4, 6], [6, 9], [8, 12], [10, 15], [12, 18], [14, 21], [16, 24], [18, 27], [20, 30]]) == 45\n assert candidate(rectangles = [[1, 3], [2, 6], [3, 9], [4, 12], [5, 15], [6, 18], [7, 21], [8, 24], [9, 27], [10, 30]]) == 45\n assert candidate(rectangles = [[2, 4], [4, 8], [8, 16], [16, 32], [32, 64], [64, 128], [128, 256], [256, 512], [512, 1024], [1024, 2048]]) == 45\n assert candidate(rectangles = [[5, 4], [10, 8], [15, 12], [20, 16], [25, 20], [30, 24], [35, 28], [40, 32], [45, 36], [50, 40]]) == 45\n assert candidate(rectangles = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100], [11, 110], [12, 120], [13, 130], [14, 140], [15, 150]]) == 105\n assert candidate(rectangles = [[11, 22], [22, 44], [33, 66], [44, 88], [55, 110], [66, 132], [77, 154], [88, 176]]) == 28\n assert candidate(rectangles = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45], [100, 50]]) == 45\n assert candidate(rectangles = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5], [30, 6], [35, 7], [40, 8], [45, 9], [50, 10]]) == 45\n assert candidate(rectangles = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]]) == 105\n assert candidate(rectangles = [[1, 4], [2, 8], [3, 12], [4, 16], [5, 20], [6, 24], [7, 28], [8, 32], [9, 36], [10, 40]]) == 45\n assert candidate(rectangles = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 0\n assert candidate(rectangles = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000]]) == 45\n assert candidate(rectangles = [[1, 100000], [2, 200000], [3, 300000], [4, 400000], [5, 500000], [6, 600000], [7, 700000], [8, 800000], [9, 900000], [10, 1000000]]) == 45\n assert candidate(rectangles = [[3, 4], [6, 8], [9, 12], [12, 16], [15, 20], [18, 24], [21, 28], [24, 32], [27, 36], [30, 40]]) == 45\n assert candidate(rectangles = [[3, 5], [6, 10], [9, 15], [12, 20], [15, 25], [18, 30]]) == 15\n assert candidate(rectangles = [[8, 12], [16, 24], [24, 36], [32, 48], [40, 60], [48, 72], [56, 84], [64, 96]]) == 28\n assert candidate(rectangles = [[100, 200], [200, 400], [300, 600], [400, 800], [500, 1000], [600, 1200]]) == 15\n assert candidate(rectangles = [[2, 1], [4, 2], [6, 3], [8, 4], [10, 5], [12, 6], [14, 7], [16, 8], [18, 9], [20, 10]]) == 45\n assert candidate(rectangles = [[100, 200], [200, 400], [300, 600], [400, 800], [500, 1000]]) == 10\n assert candidate(rectangles = [[3, 7], [6, 14], [9, 21], [12, 28], [15, 35], [18, 42], [21, 49], [24, 56], [27, 63], [30, 70]]) == 45\n assert candidate(rectangles = [[100000, 1], [200000, 2], [300000, 3], [400000, 4], [500000, 5], [600000, 6], [700000, 7], [800000, 8], [900000, 9], [1000000, 10]]) == 45\n assert candidate(rectangles = [[3, 9], [1, 3], [2, 6], [4, 12], [5, 15], [6, 18], [7, 21], [8, 24]]) == 28\n assert candidate(rectangles = [[7, 14], [14, 28], [28, 56], [56, 112], [112, 224], [224, 448]]) == 15\n assert candidate(rectangles = [[3, 5], [6, 10], [9, 15], [12, 20], [15, 25], [18, 30], [21, 35], [24, 40], [27, 45], [30, 50]]) == 45\n assert candidate(rectangles = [[1, 3], [2, 6], [3, 9], [4, 12], [5, 15], [6, 18], [7, 21]]) == 21\n assert candidate(rectangles = [[7, 14], [14, 28], [21, 42], [28, 56], [35, 70], [42, 84]]) == 15\n assert candidate(rectangles = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]]) == 0\n assert candidate(rectangles = [[1, 1], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]]) == 0\n assert candidate(rectangles = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11]]) == 0\n assert candidate(rectangles = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]]) == 45\n assert candidate(rectangles = [[100, 1], [200, 2], [300, 3], [400, 4], [500, 5], [600, 6], [700, 7], [800, 8], [900, 9], [1000, 10]]) == 45\n assert candidate(rectangles = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20]]) == 45\n assert candidate(rectangles = [[100000, 1], [1, 100000], [50000, 2], [2, 50000], [1, 1], [1, 2], [2, 1]]) == 0\n assert candidate(rectangles = [[1, 5], [2, 10], [3, 15], [4, 20], [5, 25], [6, 30], [7, 35], [8, 40], [9, 45], [10, 50], [11, 55], [12, 60]]) == 66\n assert candidate(rectangles = [[7, 14], [14, 28], [21, 42], [28, 56], [35, 70], [42, 84], [49, 98]]) == 21\n assert candidate(rectangles = [[3, 1], [6, 2], [9, 3], [12, 4], [15, 5], [18, 6], [21, 7], [24, 8], [27, 9], [30, 10]]) == 45\n assert candidate(rectangles = [[3, 4], [6, 8], [9, 12], [12, 16], [15, 20], [18, 24], [21, 28]]) == 21\n assert candidate(rectangles = [[1, 2], [2, 4], [4, 8], [8, 16], [16, 32], [32, 64], [64, 128], [128, 256], [256, 512], [512, 1024]]) == 45\n assert candidate(rectangles = [[1, 3], [2, 6], [3, 9], [4, 12], [5, 15], [6, 18], [7, 21], [8, 24], [9, 27], [10, 30], [11, 33], [12, 36]]) == 66\n assert candidate(rectangles = [[5, 10], [10, 20], [15, 30], [20, 40], [25, 50], [30, 60], [35, 70], [40, 80], [45, 90], [50, 100], [55, 110], [60, 120]]) == 66\n assert candidate(rectangles = [[7, 14], [14, 28], [21, 42], [28, 56], [35, 70], [42, 84], [49, 98], [56, 112]]) == 28\n assert candidate(rectangles = [[1, 2], [1, 3], [2, 4], [2, 6], [3, 6], [3, 9], [4, 8], [4, 12], [5, 10], [5, 15]]) == 20\n assert candidate(rectangles = [[5, 10], [15, 30], [25, 50], [35, 70], [45, 90], [55, 110], [65, 130], [75, 150], [85, 170], [95, 190]]) == 45\n assert candidate(rectangles = [[5, 7], [10, 14], [15, 21], [20, 28], [25, 35], [30, 42], [35, 49], [40, 56]]) == 28\n"}, "metadata": {"canonical_parameter_names": ["rectangles"], "leetcode_dataset_entry_point": "Solution().interchangeableRectangles", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long interchangeableRectangles(vector>& rectangles) {", "container": "Solution", "callable": "interchangeableRectangles", "parameters": [{"name": "rectangles", "type": "vector>&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2002, "task_id": "maximum-product-of-the-length-of-two-palindromic-subsequences", "difficulty": "Medium", "problem_description": "Given a string s, find two disjoint palindromic subsequences of s such that the product of their lengths is maximized. The two subsequences are disjoint if they do not both pick a character at the same index.\nReturn the maximum possible product of the lengths of the two palindromic subsequences.\nA subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters. A string is palindromic if it reads the same forward and backward.\n \nExample 1:\n\n\nInput: s = \"leetcodecom\"\nOutput: 9\nExplanation: An optimal solution is to choose \"ete\" for the 1st subsequence and \"cdc\" for the 2nd subsequence.\nThe product of their lengths is: 3 * 3 = 9.\n\nExample 2:\n\nInput: s = \"bb\"\nOutput: 1\nExplanation: An optimal solution is to choose \"b\" (the first character) for the 1st subsequence and \"b\" (the second character) for the 2nd subsequence.\nThe product of their lengths is: 1 * 1 = 1.\n\nExample 3:\n\nInput: s = \"accbcaxxcxx\"\nOutput: 25\nExplanation: An optimal solution is to choose \"accca\" for the 1st subsequence and \"xxcxx\" for the 2nd subsequence.\nThe product of their lengths is: 5 * 5 = 25.\n\n \nConstraints:\n\n2 <= s.length <= 12\ns consists of lowercase English letters only.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"xyzyx\") == 6\n assert candidate(s = \"aabbcc\") == 4\n assert candidate(s = \"aaaa\") == 4\n assert candidate(s = \"accbcaxxcxx\") == 25\n assert candidate(s = \"madam\") == 6\n assert candidate(s = \"noon\") == 4\n assert candidate(s = \"racecar\") == 12\n assert candidate(s = \"deified\") == 12\n assert candidate(s = \"noonhighnoon\") == 35\n assert candidate(s = \"abcdcba\") == 12\n assert candidate(s = \"abacaba\") == 12\n assert candidate(s = \"level\") == 6\n assert candidate(s = \"abcdedcba\") == 20\n assert candidate(s = \"abcde\") == 1\n assert candidate(s = \"rotor\") == 6\n assert candidate(s = \"leetcodecom\") == 9\n assert candidate(s = \"bb\") == 1\n assert candidate(s = \"refer\") == 6\n assert candidate(s = \"palindromeabcdcba\") == 20\n assert candidate(s = \"aaabbbccc\") == 9\n assert candidate(s = \"xxyyzzxxyyzz\") == 36\n assert candidate(s = \"noonnoonnoon\") == 36\n assert candidate(s = \"repaper\") == 12\n assert candidate(s = \"abbaabbaabba\") == 36\n assert candidate(s = \"xyzzyxzyxz\") == 25\n assert candidate(s = \"aababababab\") == 30\n assert candidate(s = \"xyzyzyzyzyzy\") == 30\n assert candidate(s = \"racecarlevelmadam\") == 45\n assert candidate(s = \"aabbbbaa\") == 16\n assert candidate(s = \"abababa\") == 12\n assert candidate(s = \"babadab\") == 9\n assert candidate(s = \"referrefer\") == 25\n assert candidate(s = \"rotorrotor\") == 25\n assert candidate(s = \"abracadabra\") == 25\n assert candidate(s = \"abacdfgdcaba\") == 35\n assert candidate(s = \"mammam\") == 9\n assert candidate(s = \"noonbedalabamoon\") == 35\n assert candidate(s = \"levelonelevel\") == 35\n assert candidate(s = \"abccbaabcba\") == 30\n assert candidate(s = \"redderredder\") == 36\n assert candidate(s = \"redivider\") == 20\n assert candidate(s = \"zzzyzzyyzzyzz\") == 42\n assert candidate(s = \"racecarabc\") == 15\n assert candidate(s = \"noonabbadammadam\") == 32\n assert candidate(s = \"noonnoon\") == 16\n assert candidate(s = \"abcdzdcba\") == 20\n assert candidate(s = \"abcdefghihgfedcba\") == 72\n assert candidate(s = \"levelup\") == 6\n assert candidate(s = \"rotorositor\") == 25\n assert candidate(s = \"madamracecarmadam\") == 72\n assert candidate(s = \"abcddcbaabcddcba\") == 64\n assert candidate(s = \"abcdefgfedcba\") == 42\n assert candidate(s = \"zyxzyxzyxzyxzyx\") == 49\n assert candidate(s = \"zzzzzzzzzzzz\") == 36\n assert candidate(s = \"xyzyxzyzyx\") == 25\n assert candidate(s = \"deeee\") == 4\n assert candidate(s = \"noonappaloopnoon\") == 56\n assert candidate(s = \"abcabcabcabcabcabc\") == 81\n assert candidate(s = \"abcbaabcba\") == 25\n assert candidate(s = \"aabbbaaaabbbb\") == 42\n assert candidate(s = \"aabbccddeeffgg\") == 4\n assert candidate(s = \"aabbccddeeefff\") == 9\n assert candidate(s = \"deeeevee\") == 12\n assert candidate(s = \"aaabaaa\") == 12\n assert candidate(s = \"aabbccddeeff\") == 4\n assert candidate(s = \"levellevel\") == 25\n assert candidate(s = \"madamimadam\") == 30\n assert candidate(s = \"mississippi\") == 24\n assert candidate(s = \"madamatadammadamada\") == 81\n assert candidate(s = \"xyzzazxy\") == 15\n assert candidate(s = \"xyxxyxyxyxyx\") == 35\n assert candidate(s = \"levelracecarlevel\") == 72\n assert candidate(s = \"programming\") == 12\n assert candidate(s = \"zyxzyxzyxzyx\") == 36\n assert candidate(s = \"levelracecara\") == 35\n assert candidate(s = \"zzzzzyzzzz\") == 25\n assert candidate(s = \"racecarannakayak\") == 40\n assert candidate(s = \"aabbaabbaa\") == 25\n assert candidate(s = \"xyzabcdcba\") == 12\n assert candidate(s = \"optimization\") == 15\n assert candidate(s = \"abccbaabc\") == 15\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().maxProduct", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxProduct(string s) {", "container": "Solution", "callable": "maxProduct", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2003, "task_id": "smallest-missing-genetic-value-in-each-subtree", "difficulty": "Hard", "problem_description": "There is a family tree rooted at 0 consisting of n nodes numbered 0 to n - 1. You are given a 0-indexed integer array parents, where parents[i] is the parent for node i. Since node 0 is the root, parents[0] == -1.\nThere are 105 genetic values, each represented by an integer in the inclusive range [1, 105]. You are given a 0-indexed integer array nums, where nums[i] is a distinct genetic value for node i.\nReturn an array ans of length n where ans[i] is the smallest genetic value that is missing from the subtree rooted at node i.\nThe subtree rooted at a node x contains node x and all of its descendant nodes.\n \nExample 1:\n\n\nInput: parents = [-1,0,0,2], nums = [1,2,3,4]\nOutput: [5,1,1,1]\nExplanation: The answer for each subtree is calculated as follows:\n- 0: The subtree contains nodes [0,1,2,3] with values [1,2,3,4]. 5 is the smallest missing value.\n- 1: The subtree contains only node 1 with value 2. 1 is the smallest missing value.\n- 2: The subtree contains nodes [2,3] with values [3,4]. 1 is the smallest missing value.\n- 3: The subtree contains only node 3 with value 4. 1 is the smallest missing value.\n\nExample 2:\n\n\nInput: parents = [-1,0,1,0,3,3], nums = [5,4,6,2,1,3]\nOutput: [7,1,1,4,2,1]\nExplanation: The answer for each subtree is calculated as follows:\n- 0: The subtree contains nodes [0,1,2,3,4,5] with values [5,4,6,2,1,3]. 7 is the smallest missing value.\n- 1: The subtree contains nodes [1,2] with values [4,6]. 1 is the smallest missing value.\n- 2: The subtree contains only node 2 with value 6. 1 is the smallest missing value.\n- 3: The subtree contains nodes [3,4,5] with values [2,1,3]. 4 is the smallest missing value.\n- 4: The subtree contains only node 4 with value 1. 2 is the smallest missing value.\n- 5: The subtree contains only node 5 with value 3. 1 is the smallest missing value.\n\nExample 3:\n\nInput: parents = [-1,2,3,0,2,4,1], nums = [2,3,4,5,6,7,8]\nOutput: [1,1,1,1,1,1,1]\nExplanation: The value 1 is missing from all the subtrees.\n\n \nConstraints:\n\nn == parents.length == nums.length\n2 <= n <= 105\n0 <= parents[i] <= n - 1 for i != 0\nparents[0] == -1\nparents represents a valid tree.\n1 <= nums[i] <= 105\nEach nums[i] is distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(parents = [-1, 0, 0, 2],nums = [1, 2, 3, 4]) == [5, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 0, 3, 3],nums = [5, 4, 6, 2, 1, 3]) == [7, 1, 1, 4, 2, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2],nums = [1, 2, 3, 4, 5, 6, 7]) == [8, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 2, 3, 0, 2, 4, 1],nums = [2, 3, 4, 5, 6, 7, 8]) == [1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 2, 2, 3, 3],nums = [7, 1, 3, 2, 6, 5, 4]) == [8, 2, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],nums = [5, 1, 12, 13, 1, 2, 6, 7, 8, 9, 3, 4, 10, 11, 14, 15]) == [16, 5, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7],nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3],nums = [10, 1, 2, 9, 8, 7, 6, 5, 4]) == [3, 2, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == [19, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 0, 6, 7, 8],nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [10, 6, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [11, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4],nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11]) == [12, 4, 1, 1, 2, 1, 1, 1, 1, 2, 1]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [11, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums = [5, 1, 3, 7, 9, 2, 6, 4, 8, 10, 11]) == [12, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7],nums = [2, 1, 14, 13, 8, 15, 6, 9, 4, 10, 5, 11, 3, 12, 7, 16]) == [17, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3],nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 3, 1, 3, 1, 1, 1, 1, 2]\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == [23, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 0, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],nums = [20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [21, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4],nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 100, 101]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],nums = [10, 20, 30, 40, 1, 11, 21, 31, 41, 2, 12, 22, 32, 42, 3, 13, 23, 33, 4, 14, 24, 29]) == [5, 5, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]) == [23, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],nums = [40, 30, 20, 10, 35, 31, 25, 21, 34, 32, 24, 22, 33, 26, 23, 27, 36, 28, 29, 37, 38, 39]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 0, 3, 3, 4, 4],nums = [1, 2, 3, 4, 5, 6, 7, 8]) == [9, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18],nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums = [10, 9, 1, 2, 3, 4, 5, 6, 7, 8, 15, 16, 17, 18, 19, 20]) == [11, 10, 9, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == [13, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6],nums = [3, 1, 2, 5, 7, 8, 10, 12, 13, 9, 4, 6, 11, 14, 15, 16, 17, 18, 19, 20, 21]) == [22, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13]) == [14, 4, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30],nums = [31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [21, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11]) == [12, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == [44, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3],nums = [13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == [14, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == [36, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 22]) == [23, 2, 2, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3],nums = [8, 9, 10, 1, 2, 3, 4, 5, 6]) == [7, 3, 1, 2, 1, 1, 1, 1, 1]\n"}, "metadata": {"canonical_parameter_names": ["parents", "nums"], "leetcode_dataset_entry_point": "Solution().smallestMissingValueSubtree", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector smallestMissingValueSubtree(vector& parents, vector& nums) {", "container": "Solution", "callable": "smallestMissingValueSubtree", "parameters": [{"name": "parents", "type": "vector&"}, {"name": "nums", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2006, "task_id": "count-number-of-pairs-with-absolute-difference-k", "difficulty": "Easy", "problem_description": "Given an integer array nums and an integer k, return the number of pairs (i, j) where i < j such that |nums[i] - nums[j]| == k.\nThe value of |x| is defined as:\n\nx if x >= 0.\n-x if x < 0.\n\n \nExample 1:\n\nInput: nums = [1,2,2,1], k = 1\nOutput: 4\nExplanation: The pairs with an absolute difference of 1 are:\n- [1,2,2,1]\n- [1,2,2,1]\n- [1,2,2,1]\n- [1,2,2,1]\n\nExample 2:\n\nInput: nums = [1,3], k = 3\nOutput: 0\nExplanation: There are no pairs with an absolute difference of 3.\n\nExample 3:\n\nInput: nums = [3,2,1,5,4], k = 2\nOutput: 3\nExplanation: The pairs with an absolute difference of 2 are:\n- [3,2,1,5,4]\n- [3,2,1,5,4]\n- [3,2,1,5,4]\n\n \nConstraints:\n\n1 <= nums.length <= 200\n1 <= nums[i] <= 100\n1 <= k <= 99\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [100, 1, 100, 1, 100],k = 99) == 6\n assert candidate(nums = [5, 4, 3, 2, 1],k = 4) == 1\n assert candidate(nums = [1, 1, 1, 1],k = 0) == 6\n assert candidate(nums = [5, 5, 5, 5],k = 0) == 6\n assert candidate(nums = [3, 2, 1, 5, 4],k = 2) == 3\n assert candidate(nums = [5, 1, 4, 1],k = 2) == 0\n assert candidate(nums = [1, 3],k = 3) == 0\n assert candidate(nums = [10, 20, 30, 40, 50],k = 20) == 3\n assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == 4\n assert candidate(nums = [1, 2, 2, 1],k = 1) == 4\n assert candidate(nums = [100, 1, 100, 1],k = 99) == 4\n assert candidate(nums = [20, 30, 40, 50, 60, 70, 80, 90, 100, 110],k = 10) == 9\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 4) == 32\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82],k = 9) == 9\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93],k = 99) == 1\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86],k = 1) == 14\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24],k = 4) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 20\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 3, 6, 9, 12, 15],k = 3) == 22\n assert candidate(nums = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5],k = 1) == 40\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57],k = 4) == 14\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50],k = 30) == 16\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 1) == 36\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 43],k = 1) == 10\n assert candidate(nums = [10, 20, 30, 40, 50],k = 10) == 4\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 8) == 6\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30, 40, 50],k = 10) == 16\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 5, 15, 25, 35, 45],k = 10) == 22\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5],k = 4) == 13\n assert candidate(nums = [55, 45, 35, 25, 15, 5, 5, 15, 25, 35, 45],k = 10) == 18\n assert candidate(nums = [99, 100, 1, 98, 2, 97, 3, 96, 4, 95, 5, 94],k = 1) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 2) == 19\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 0) == 45\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15],k = 2) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 1) == 9\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 0) == 105\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 10) == 9\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],k = 9) == 1\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],k = 1) == 9\n assert candidate(nums = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25],k = 0) == 1225\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90],k = 1) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 3) == 17\n assert candidate(nums = [99, 2, 98, 3, 97, 4, 96, 5, 95, 6, 94, 7, 93, 8, 92, 9],k = 97) == 1\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0) == 45\n assert candidate(nums = [55, 45, 35, 25, 15, 5, 105, 115, 125],k = 10) == 7\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 10) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 1) == 14\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80],k = 9) == 26\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],k = 0) == 45\n assert candidate(nums = [10, 20, 30, 40, 50, 10, 20, 30],k = 10) == 11\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],k = 1) == 9\n assert candidate(nums = [50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 52, 52, 52, 52, 52, 53, 53, 53, 53, 53, 54, 54, 54, 54, 54, 55, 55, 55, 55, 55],k = 1) == 125\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000],k = 99) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 2) == 14\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 20) == 32\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85],k = 2) == 13\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 15\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 2) == 12\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 2) == 19\n assert candidate(nums = [10, 10, 10, 10, 11, 11, 12, 12, 13],k = 1) == 14\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33],k = 3) == 10\n assert candidate(nums = [10, 20, 30, 20, 10, 30, 20, 10, 30],k = 10) == 18\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 2) == 32\n assert candidate(nums = [90, 85, 80, 75, 70, 65, 60, 55, 50, 45, 40],k = 5) == 10\n assert candidate(nums = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50],k = 10) == 10\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],k = 2) == 14\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85],k = 3) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 1) == 19\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 10) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],k = 2) == 24\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 1) == 16\n assert candidate(nums = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 9],k = 10) == 10\n assert candidate(nums = [10, 12, 15, 7, 5, 3, 10, 15],k = 5) == 7\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],k = 10) == 10\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81],k = 9) == 11\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 2) == 9\n assert candidate(nums = [10, 10, 20, 20, 30, 30],k = 10) == 8\n assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79],k = 4) == 19\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 10) == 9\n assert candidate(nums = [100, 1, 100, 2, 100, 3, 100, 4, 100, 5],k = 99) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 5\n assert candidate(nums = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97],k = 4) == 24\n assert candidate(nums = [8, 18, 28, 38, 48, 58, 68, 78, 88, 98],k = 10) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == 36\n assert candidate(nums = [50, 60, 70, 80, 90, 50, 60, 70, 80, 90, 50, 60],k = 20) == 16\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50],k = 1) == 50\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 1) == 29\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 1) == 32\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 2) == 10\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42],k = 0) == 45\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 2) == 13\n assert candidate(nums = [50, 50, 50, 51, 51, 52, 52, 52, 53, 53],k = 1) == 18\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 4) == 13\n assert candidate(nums = [5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 15, 15, 15, 15, 15],k = 5) == 50\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 3) == 8\n assert candidate(nums = [42, 42, 42, 42, 42, 42, 42],k = 0) == 21\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 0) == 2850\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == 6\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91],k = 9) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 10) == 19\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 1) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 1\n assert candidate(nums = [1, 10, 100, 1000, 10000, 10, 100, 1000],k = 999) == 2\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98],k = 7) == 13\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91, 100],k = 9) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == 60\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().countKDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countKDifference(vector& nums, int k) {", "container": "Solution", "callable": "countKDifference", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2007, "task_id": "find-original-array-from-doubled-array", "difficulty": "Medium", "problem_description": "An integer array original is transformed into a doubled array changed by appending twice the value of every element in original, and then randomly shuffling the resulting array.\nGiven an array changed, return original if changed is a doubled array. If changed is not a doubled array, return an empty array. The elements in original may be returned in any order.\n \nExample 1:\n\nInput: changed = [1,3,4,2,6,8]\nOutput: [1,3,4]\nExplanation: One possible original array could be [1,3,4]:\n- Twice the value of 1 is 1 * 2 = 2.\n- Twice the value of 3 is 3 * 2 = 6.\n- Twice the value of 4 is 4 * 2 = 8.\nOther original arrays could be [4,3,1] or [3,1,4].\n\nExample 2:\n\nInput: changed = [6,3,0,1]\nOutput: []\nExplanation: changed is not a doubled array.\n\nExample 3:\n\nInput: changed = [1]\nOutput: []\nExplanation: changed is not a doubled array.\n\n \nConstraints:\n\n1 <= changed.length <= 105\n0 <= changed[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(changed = [2, 1, 4, 2, 8, 4]) == [1, 2, 4]\n assert candidate(changed = [2, 4, 2, 4]) == [2, 2]\n assert candidate(changed = [1, 2, 3, 6, 9, 18]) == [1, 3, 9]\n assert candidate(changed = [8, 4, 2, 1, 16, 8, 4, 2]) == [1, 2, 4, 8]\n assert candidate(changed = [5, 3, 10, 0, 6, 9, 18, 15]) == []\n assert candidate(changed = [0, 0, 0, 0]) == [0, 0]\n assert candidate(changed = [100, 200, 300, 400, 500, 1000]) == []\n assert candidate(changed = [1, 2, 3, 4, 6, 8, 12, 16]) == []\n assert candidate(changed = [1, 2, 3, 6, 12, 24, 48, 96]) == [1, 3, 12, 48]\n assert candidate(changed = [5, 3, 10, 15, 2, 6]) == []\n assert candidate(changed = [1, 3, 4, 2, 6, 8]) == [1, 3, 4]\n assert candidate(changed = [1, 2]) == [1]\n assert candidate(changed = [1]) == []\n assert candidate(changed = [2, 1, 2, 4, 4, 8]) == [1, 2, 4]\n assert candidate(changed = [6, 3, 0, 1]) == []\n assert candidate(changed = [5, 10, 15, 20, 25, 50]) == []\n assert candidate(changed = [1, 2, 3, 6, 4, 8]) == [1, 3, 4]\n assert candidate(changed = [2, 4, 2, 4, 8, 8]) == []\n assert candidate(changed = [2, 1]) == [1]\n assert candidate(changed = [5, 3, 10, 15, 20, 6]) == []\n assert candidate(changed = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 60, 120, 180, 240, 300]) == []\n assert candidate(changed = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == []\n assert candidate(changed = [3, 6, 6, 12, 12, 12, 24, 24, 24, 24, 24, 24, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48]) == []\n assert candidate(changed = [2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512, 1024, 1024]) == [2, 2, 8, 8, 32, 32, 128, 128, 512, 512]\n assert candidate(changed = [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683, 18, 54, 162, 486, 1458, 4374, 13122, 39366, 118098, 354294]) == []\n assert candidate(changed = [1, 2, 3, 4, 6, 8, 9, 12, 12, 16, 18, 24, 24, 32, 36, 48, 48, 64, 72, 96, 96, 128, 144, 192, 192]) == []\n assert candidate(changed = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == []\n assert candidate(changed = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154, 165, 176, 187, 198, 220, 242, 264, 286, 308, 330, 352, 374, 396, 440, 484, 528, 572, 616, 660, 704, 748, 792, 880, 968, 1056, 1144, 1232, 1320, 1408, 1496, 1584, 1760, 1936, 2112, 2288, 2464, 2640, 2816, 2992, 3168, 3520, 3872, 4224, 4576, 4928, 5280, 5632, 5984, 6336, 7040, 7744, 8448, 9152, 9856, 10560, 11264, 11968, 12672, 14080, 15488, 16896, 18304, 19712, 21120, 22528, 23936, 25344, 28160, 31936, 35712, 39488, 43264, 47136, 50944, 54752, 58560, 62368, 66176, 69984, 73792, 77600, 81408, 85216, 89024, 92832, 96640, 100448]) == []\n assert candidate(changed = [9, 18, 36, 72, 144, 288, 576, 1152, 2304, 4608, 9216, 18432, 36864, 73728, 147456, 294912, 589824, 1179648, 2359296]) == []\n assert candidate(changed = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98, 105, 112, 119, 126, 133, 140]) == []\n assert candidate(changed = [19, 38, 57, 76, 95, 114, 133, 152, 171, 190, 380, 570, 760, 950, 1140, 1330, 1520, 1710, 1900]) == []\n assert candidate(changed = [1, 1, 2, 2, 3, 3, 6, 6, 9, 9, 12, 12, 18, 18, 24, 24, 36, 36, 48, 48, 54, 54, 72, 72, 96, 96, 108, 108, 144, 144, 192, 192]) == []\n assert candidate(changed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 24, 28, 32, 36, 40]) == []\n assert candidate(changed = [1, 1, 2, 2, 3, 3, 6, 6, 9, 9, 18, 18]) == [1, 1, 3, 3, 9, 9]\n assert candidate(changed = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == []\n assert candidate(changed = [0, 0, 0, 0, 0, 0]) == [0, 0, 0]\n assert candidate(changed = [7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584, 7168, 14336, 28672, 57344, 114688]) == []\n assert candidate(changed = [23, 46, 92, 184, 368, 736, 1472, 2944, 5888, 11776, 23552, 47104, 94208, 188416, 376832, 753664, 1507328, 3014656, 6029312]) == []\n assert candidate(changed = [2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256]) == []\n assert candidate(changed = [1, 2, 3, 4, 6, 8, 9, 12, 12, 16, 18, 24, 24, 32, 36, 48, 48, 64, 72, 96, 96, 128, 144, 192, 192, 256, 288, 384, 384]) == []\n assert candidate(changed = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 6, 10, 14, 18, 22, 26, 30, 34, 38]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(changed = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]) == []\n assert candidate(changed = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 222, 333, 444, 555, 666, 777, 888, 999, 1100, 2200, 3300, 4400, 5500, 6600, 7700, 8800, 9900]) == []\n assert candidate(changed = [7, 14, 7, 14, 28, 28, 56, 56, 112, 112, 224, 224]) == [7, 7, 28, 28, 112, 112]\n assert candidate(changed = [1, 2, 3, 6, 9, 18, 27, 54, 81, 162, 243, 486, 729, 1458, 2187, 4374, 6561, 13122, 19683, 39366]) == [1, 3, 9, 27, 81, 243, 729, 2187, 6561, 19683]\n assert candidate(changed = [3, 6, 12, 15, 30, 60, 75, 150, 225, 450, 900]) == []\n assert candidate(changed = [1, 2, 2, 4, 4, 4, 8, 8, 8, 8, 16, 16, 16, 16, 16, 32, 32, 32, 32, 32, 64, 64, 64, 64, 64, 128, 128, 128, 128, 128, 256, 256, 256, 256, 256, 512, 512, 512, 512, 512, 1024, 1024, 1024, 1024, 1024, 2048, 2048, 2048, 2048, 2048]) == []\n assert candidate(changed = [5, 10, 15, 20, 25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350, 375, 400]) == []\n assert candidate(changed = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 300, 450, 600, 750, 900]) == []\n assert candidate(changed = [1023, 2046, 3069, 4092, 5115, 6138, 7161, 8184, 9207, 10230, 2046, 4092, 6138, 8184, 10230, 12276, 14322, 16368, 18414, 20460, 3069, 6138, 9207, 12276, 15345, 18414, 21483, 24540, 27597, 30654]) == []\n assert candidate(changed = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == []\n assert candidate(changed = [1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 48, 72, 144, 288, 576, 1152, 2304, 4608, 9216, 18432, 36864, 73728, 147456, 294912, 589824, 1179648, 2359296, 4718592, 9437184, 18874368, 37748736, 75497472, 150994944, 301989888, 603979776, 1207959552, 2415919104, 4831838208, 9663676416, 19327352832, 38654705664, 77309411328, 154618822656, 309237645312, 618475290624, 1236950581248, 2473901162496, 4947802324992, 9895604649984, 19791209299968, 39582418599936, 79164837199872, 158329674399744, 316659348799488, 633318697598976, 1266637395197952, 2533274790395904, 5066549580791808, 10133099161583616, 20266198323167232, 40532396646334464, 81064793292668928, 162129586585337856, 324259173170675712, 648518346341351424, 1297036692682702848, 2594073385365405696, 5188146770730811392, 10376293541461622784, 20752587082923245568, 41505174165846491136, 83010348331692982272, 166020696663385964544]) == []\n assert candidate(changed = [7, 14, 14, 21, 28, 28, 35, 42, 42, 56, 56, 70, 70, 84, 84, 105, 105, 140, 140, 168, 168, 210, 210, 280, 280]) == []\n assert candidate(changed = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 40, 80, 120, 160, 200, 240, 280, 320, 360, 400]) == [5, 10, 15, 20, 20, 25, 30, 35, 40, 40, 45, 50, 60, 80, 100, 120, 140, 160, 180, 200]\n assert candidate(changed = [23, 46, 69, 92, 115, 138, 161, 184, 207, 230, 460, 690, 920, 1150, 1380, 1610, 1840, 2070, 2300]) == []\n assert candidate(changed = [0, 0, 0, 0, 0, 0, 0]) == []\n assert candidate(changed = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60]) == []\n assert candidate(changed = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == []\n assert candidate(changed = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40]) == []\n assert candidate(changed = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130, 260, 520, 780, 1040, 1300]) == []\n assert candidate(changed = [1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128]) == []\n assert candidate(changed = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == []\n assert candidate(changed = [1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32]) == []\n assert candidate(changed = [1, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256]) == []\n assert candidate(changed = [5, 10, 10, 20, 20, 40, 40, 80, 80, 160, 160, 320, 320]) == []\n assert candidate(changed = [3, 6, 9, 18, 27, 54, 81, 162, 243, 486]) == [3, 9, 27, 81, 243]\n assert candidate(changed = [1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512, 1024, 1024]) == []\n assert candidate(changed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40]) == []\n assert candidate(changed = [101, 202, 404, 808, 1616, 3232, 6464, 12928, 25856, 51712, 103424, 206848, 413696, 827392, 1654784, 3309568, 6619136, 13238272, 26476544]) == []\n assert candidate(changed = [17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 340, 510, 680, 850, 1020, 1190, 1360, 1530, 1700]) == []\n assert candidate(changed = [1, 2, 2, 4, 4, 4, 8, 8, 8, 8, 8, 8, 8, 8, 8, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16]) == []\n assert candidate(changed = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000]) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(changed = [5, 10, 10, 15, 20, 20, 25, 30, 30, 40, 40, 50, 50, 60, 60, 75, 75, 100, 100, 120, 120, 150, 150, 200, 200]) == []\n assert candidate(changed = [3, 6, 9, 12, 18, 24, 36, 48, 54, 72, 96, 108, 144, 192, 216, 288, 384, 432, 576, 768, 864, 1152, 1536, 1728, 2304, 3072, 3456, 4608, 6144, 6912, 9216, 12288, 13824, 18432, 24576, 27648, 36864, 49152, 55296, 73728, 98304]) == []\n assert candidate(changed = [1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1024]) == []\n assert candidate(changed = [1, 1, 2, 2, 3, 3, 4, 4, 6, 6, 8, 8, 12, 12, 16, 16, 24, 24, 32, 32, 48, 48, 64, 64, 96, 96, 128, 128]) == [1, 1, 3, 3, 4, 4, 12, 12, 16, 16, 48, 48, 64, 64]\n assert candidate(changed = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == []\n assert candidate(changed = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180, 189, 198, 207, 216, 225, 234, 243, 252, 261, 270]) == []\n assert candidate(changed = [1, 1, 1, 2, 2, 2, 4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64, 64, 128, 128, 128, 256, 256, 256, 512, 512, 512]) == [1, 1, 1, 4, 4, 4, 16, 16, 16, 64, 64, 64, 256, 256, 256]\n assert candidate(changed = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == [2, 8, 32, 128, 512]\n assert candidate(changed = [2, 4, 4, 8, 8, 16, 16, 32, 32, 64]) == [2, 4, 8, 16, 32]\n assert candidate(changed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200]) == []\n assert candidate(changed = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 140, 280, 420, 560, 700]) == []\n assert candidate(changed = [1, 2, 2, 3, 6, 6, 12, 12, 24, 24, 48, 48]) == []\n assert candidate(changed = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == [1, 4, 16, 64, 256]\n assert candidate(changed = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512, 1024, 1024, 2048, 2048, 4096, 4096, 8192, 8192, 16384, 16384]) == []\n assert candidate(changed = [2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64]) == []\n assert candidate(changed = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24]) == []\n assert candidate(changed = [10, 20, 30, 40, 50, 60, 20, 40, 60, 80, 100, 120, 40, 80, 120, 160, 200, 240, 80, 160, 240, 320, 400, 480, 160, 320, 480, 640, 800, 960]) == []\n assert candidate(changed = [3, 3, 6, 6, 9, 9, 18, 18, 27, 27]) == []\n assert candidate(changed = [1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512, 1024]) == [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]\n assert candidate(changed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40]) == []\n assert candidate(changed = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(changed = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64]) == []\n assert candidate(changed = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == [2, 8, 32, 128, 512, 2048, 8192, 32768]\n assert candidate(changed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 60, 120, 180, 240, 300]) == []\n assert candidate(changed = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 180, 360, 540, 720, 900]) == []\n assert candidate(changed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == []\n assert candidate(changed = [7, 14, 28, 56, 112, 224, 448, 896, 1792, 3584, 7168, 14336, 28672, 57344, 114688, 229376, 458752, 917504, 1835008]) == []\n assert candidate(changed = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 18, 36, 54, 72, 90, 108, 126, 144, 162, 180]) == []\n assert candidate(changed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == []\n assert candidate(changed = [10, 20, 30, 40, 50, 60, 20, 40, 60, 80, 100, 120]) == [10, 20, 30, 40, 50, 60]\n assert candidate(changed = [1, 2, 2, 4, 4, 8, 8, 16, 16, 32]) == [1, 2, 4, 8, 16]\n assert candidate(changed = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 22, 44, 66, 88, 110, 132, 154, 176, 198, 220, 33, 66, 99, 132, 165, 198, 231, 264, 297, 330]) == []\n assert candidate(changed = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150]) == []\n assert candidate(changed = [1, 1, 2, 3, 3, 6, 6, 12, 12, 24, 24, 48, 48, 96, 96, 192, 192, 384, 384, 768, 768, 1536, 1536, 3072, 3072, 6144, 6144, 12288, 12288, 24576, 24576]) == []\n assert candidate(changed = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288]) == [1, 4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144]\n assert candidate(changed = [29, 58, 87, 116, 145, 174, 203, 232, 261, 290, 580, 870, 1160, 1450, 1740, 2030, 2320, 2610, 2900]) == []\n assert candidate(changed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240, 256, 272, 288, 304, 320, 336, 352, 368, 384, 400, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 480, 512, 544, 576, 608, 640, 672, 704, 736, 768, 800, 64, 128, 192, 256, 320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024, 1088, 1152, 1216, 1280, 1344, 1408, 1472, 1536, 1600, 128, 256, 384, 512, 640, 768, 896, 1024, 1152, 1280, 1408, 1536, 1664, 1792, 1920, 2048, 2176, 2304, 2432, 2560, 2688, 2816, 2944, 3072, 3200, 256, 512, 768, 1024, 1280, 1536, 1792, 2048, 2304, 2560, 2816, 3072, 3328, 3584, 3840, 4096, 4352, 4608, 4864, 5120, 5376, 5632, 5888, 6144, 6400]) == []\n assert candidate(changed = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576]) == [2, 8, 32, 128, 512, 2048, 8192, 32768, 131072, 524288]\n assert candidate(changed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == []\n assert candidate(changed = [5, 10, 10, 20, 20, 40, 40, 80, 80, 160, 160, 320, 320, 640, 640, 1280, 1280, 2560, 2560, 5120]) == [5, 10, 20, 40, 80, 160, 320, 640, 1280, 2560]\n assert candidate(changed = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 120, 140, 160, 180, 200, 240, 280, 320, 360, 400]) == []\n assert candidate(changed = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(changed = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512]) == [1, 1, 4, 4, 16, 16, 64, 64, 256, 256]\n assert candidate(changed = [1, 2, 3, 6, 9, 12, 18, 27, 36, 54, 81, 108, 162, 243, 324, 486, 729, 972, 1458, 2187]) == []\n assert candidate(changed = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3, 1]) == []\n assert candidate(changed = [5, 10, 15, 20, 25, 50, 75, 100, 125, 250, 375, 500, 625, 1250]) == []\n assert candidate(changed = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40]) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]\n assert candidate(changed = [100, 200, 400, 800, 1600, 3200, 6400, 12800, 25600, 51200]) == [100, 400, 1600, 6400, 25600]\n assert candidate(changed = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128, 256, 256, 512, 512, 1024, 1024]) == []\n assert candidate(changed = [1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 24, 30, 40, 60, 120]) == []\n assert candidate(changed = [1, 2, 3, 4, 6, 8, 9, 12, 16, 18, 24, 27, 36, 48, 54, 72, 96, 108, 144, 192, 216, 288, 384, 432, 576, 768, 864, 1152, 1536, 1728, 2304, 3072, 3456, 4608, 6144, 6912, 9216, 12288, 13824, 18432, 24576, 27648, 36864, 49152, 55296, 73728, 98304, 110592, 147456, 196608, 221184, 294912, 393216, 442368, 589824, 786432, 884736, 1179648, 1572864, 1769472, 2359296, 3145728, 3538944, 4718592, 6291456, 7077888, 9437184, 12582912, 14155776, 18874368, 25165824, 28311552, 37748736, 50331648, 56623104, 75497472, 100663296, 113246208, 150994944, 201326592, 226492416, 301989888, 402653184, 452984832, 603979776, 805306368, 893558688, 1207959552, 1610612736, 1787117376, 2415919104, 3221225472, 3574234752, 4831838208, 6442450944, 7148469504, 9663676416, 12884901888, 14296939008, 19327352832, 25769803776, 28593878016, 38654705664, 51539607552, 57187756032, 77309411328, 103079215104, 114375512064, 154618822656, 206158430208, 228751024128, 309237645312, 412316860416, 457502048256, 618475290624, 824633720832, 915004096512, 1236950581248, 1649267441664, 1830008193024, 2473901162496, 3298534883328, 3660016386048, 4947802324992, 6597069766656, 7320032772096, 9895604649984, 13194139533312, 14640065544192, 19791209299968, 26388279066624, 29280131088384, 39582418599936, 52776558133248, 58560262176768, 79164837199872, 105553116266496, 117120524353536, 158329674399744, 211106232532992, 234241048707072, 316659348799488, 422212465065984, 468482097414144, 633318697598976, 844424930131968, 936964194828288, 1266637395197952, 1688849860263936, 1873928389656576, 2533274790395904, 3377699720527872, 3747856779313152, 5066549580791808, 6755399441055744, 7495713558626304, 10133099161583616, 13510798882111488, 14991427117252608, 18958426576449824, 24349218045901216, 25722183890390144, 33392794892405760, 43998436091802432, 46474474833634208, 59525809886226240, 76796872183603840, 81348611215888544, 104281498830908160, 133593744367207680, 139342930911092288, 166399283014597440, 204791659156811520, 215343397595105920, 253068831957584768, 306386488715214080, 323015096392658880, 386797763385011520, 459579311430428160, 484522644589988224, 583887458675897600, 719158822845642240, 726783966884982336, 875809045506491520, 1078318430193856320, 1090175950327473344, 1313710568259737280, 1617491260261184480, 1635263925491209984, 1970565852389605840, 2434982520522368960, 2452895888236814976, 2956131704779211680, 3669965041044737920, 3679343832355222464, 4434197557168817440, 5539930082089475840, 5519015748532833696, 6651296335753226160, 8303893443132713760, 8278523622799250544, 10666592671504839200, 13338186886263570720, 13317785434198875816, 16000189007257258880, 20450915848351427640, 20423678151298313728, 24000378014514517760, 30676373772527141460, 30635517226947470592, 36000567021771776000, 46014560658790712180, 46002688140418453888, 54000850532657664000]) == []\n assert candidate(changed = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [0, 0, 0, 0, 0]\n"}, "metadata": {"canonical_parameter_names": ["changed"], "leetcode_dataset_entry_point": "Solution().findOriginalArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector findOriginalArray(vector& changed) {", "container": "Solution", "callable": "findOriginalArray", "parameters": [{"name": "changed", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2008, "task_id": "maximum-earnings-from-taxi", "difficulty": "Medium", "problem_description": "There are n points on a road you are driving your taxi on. The n points on the road are labeled from 1 to n in the direction you are going, and you want to drive from point 1 to point n to make money by picking up passengers. You cannot change the direction of the taxi.\nThe passengers are represented by a 0-indexed 2D integer array rides, where rides[i] = [starti, endi, tipi] denotes the ith passenger requesting a ride from point starti to point endi who is willing to give a tipi dollar tip.\nFor each passenger i you pick up, you earn endi - starti + tipi dollars. You may only drive at most one passenger at a time.\nGiven n and rides, return the maximum number of dollars you can earn by picking up the passengers optimally.\nNote: You may drop off a passenger and pick up a different passenger at the same point.\n \nExample 1:\n\nInput: n = 5, rides = [[2,5,4],[1,5,1]]\nOutput: 7\nExplanation: We can pick up passenger 0 to earn 5 - 2 + 4 = 7 dollars.\n\nExample 2:\n\nInput: n = 20, rides = [[1,6,1],[3,10,2],[10,12,3],[11,12,2],[12,15,2],[13,18,1]]\nOutput: 20\nExplanation: We will pick up the following passengers:\n- Drive passenger 1 from point 3 to point 10 for a profit of 10 - 3 + 2 = 9 dollars.\n- Drive passenger 2 from point 10 to point 12 for a profit of 12 - 10 + 3 = 5 dollars.\n- Drive passenger 5 from point 13 to point 18 for a profit of 18 - 13 + 1 = 6 dollars.\nWe earn 9 + 5 + 6 = 20 dollars in total.\n \nConstraints:\n\n1 <= n <= 105\n1 <= rides.length <= 3 * 104\nrides[i].length == 3\n1 <= starti < endi <= n\n1 <= tipi <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 100,rides = [[1, 10, 50], [20, 30, 25], [50, 60, 100], [70, 80, 75], [90, 100, 200]]) == 499\n assert candidate(n = 10,rides = [[1, 3, 2], [2, 5, 3], [4, 6, 1]]) == 7\n assert candidate(n = 30,rides = [[1, 10, 10], [10, 20, 10], [20, 30, 10]]) == 59\n assert candidate(n = 15,rides = [[1, 2, 5], [2, 3, 10], [3, 4, 20], [4, 5, 30]]) == 69\n assert candidate(n = 5,rides = [[2, 5, 4], [1, 5, 1]]) == 7\n assert candidate(n = 15,rides = [[1, 4, 1], [2, 6, 2], [3, 7, 3], [4, 8, 4], [5, 9, 5]]) == 13\n assert candidate(n = 10,rides = [[1, 3, 2], [2, 5, 3], [4, 8, 2], [6, 10, 3]]) == 13\n assert candidate(n = 100,rides = [[1, 10, 50], [2, 20, 60], [3, 30, 70], [4, 40, 80], [5, 50, 90]]) == 135\n assert candidate(n = 30,rides = [[1, 15, 10], [16, 30, 5]]) == 43\n assert candidate(n = 15,rides = [[1, 4, 3], [3, 7, 4], [7, 10, 5]]) == 16\n assert candidate(n = 15,rides = [[1, 4, 5], [2, 6, 3], [3, 8, 7], [5, 9, 4]]) == 16\n assert candidate(n = 20,rides = [[1, 6, 1], [3, 10, 2], [10, 12, 3], [11, 12, 2], [12, 15, 2], [13, 18, 1]]) == 20\n assert candidate(n = 10,rides = [[1, 3, 5], [2, 5, 2], [5, 8, 3]]) == 13\n assert candidate(n = 10,rides = [[1, 3, 2], [2, 5, 3], [5, 7, 2], [6, 9, 1]]) == 10\n assert candidate(n = 100000,rides = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1]]) == 20\n assert candidate(n = 1000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 1000, 999]]) == 2043\n assert candidate(n = 30000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [29998, 29999, 1], [29999, 30000, 100]]) == 112\n assert candidate(n = 100000,rides = [[1, 100000, 1], [100000, 100000, 100000], [1, 2, 1], [2, 3, 2], [3, 4, 3], [99999, 100000, 100000]]) == 200010\n assert candidate(n = 10000,rides = [[1, 500, 100], [501, 1000, 200], [1001, 1500, 300], [1501, 2000, 400], [2001, 2500, 500], [2501, 3000, 600], [3001, 3500, 700], [3501, 4000, 800], [4001, 4500, 900], [4501, 5000, 1000], [5001, 10000, 4500]]) == 19989\n assert candidate(n = 75000,rides = [[1, 25000, 10000], [25000, 50000, 10000], [50000, 75000, 10000]]) == 104999\n assert candidate(n = 5000,rides = [[1, 2500, 2500], [2501, 5000, 2500], [1, 5000, 5000]]) == 9999\n assert candidate(n = 100,rides = [[1, 5, 10], [5, 10, 10], [10, 15, 10], [15, 20, 10], [20, 25, 10], [25, 30, 10], [30, 35, 10], [35, 40, 10], [40, 45, 10], [45, 50, 10], [50, 55, 10], [55, 60, 10], [60, 65, 10], [65, 70, 10], [70, 75, 10], [75, 80, 10], [80, 85, 10], [85, 90, 10], [90, 95, 10], [95, 100, 10]]) == 299\n assert candidate(n = 1000,rides = [[1, 500, 1000], [501, 1000, 500], [1, 250, 200], [251, 500, 150], [501, 750, 125], [751, 1000, 100]]) == 2498\n assert candidate(n = 50000,rides = [[1, 5, 5], [2, 6, 7], [3, 7, 8], [4, 8, 9], [5, 9, 10], [6, 10, 12], [7, 11, 14], [8, 12, 16], [9, 13, 18], [10, 14, 20]]) == 51\n assert candidate(n = 30000,rides = [[1, 10000, 5000], [10001, 20000, 5000], [20001, 30000, 5000], [1, 20000, 10000], [10001, 30000, 10000], [1, 30000, 15000]]) == 44999\n assert candidate(n = 30000,rides = [[1, 10000, 5000], [10001, 20000, 10000], [20001, 30000, 15000], [1, 5000, 2500], [5001, 10000, 5000], [10001, 15000, 7500], [15001, 20000, 10000], [20001, 25000, 12500], [25001, 30000, 15000], [1, 2000, 1000], [2001, 4000, 2000], [4001, 6000, 3000], [6001, 8000, 4000], [8001, 10000, 5000], [10001, 12000, 6000], [12001, 14000, 7000], [14001, 16000, 8000], [16001, 18000, 9000], [18001, 20000, 10000], [20001, 22000, 11000], [22001, 24000, 12000], [24001, 26000, 13000], [26001, 28000, 14000], [28001, 30000, 15000]]) == 149985\n assert candidate(n = 30000,rides = [[1, 30000, 15000], [2, 29999, 14999], [3, 29998, 14998], [4, 29997, 14997], [5, 29996, 14996], [6, 29995, 14995], [7, 29994, 14994], [8, 29993, 14993], [9, 29992, 14992], [10, 29991, 14991]]) == 44999\n assert candidate(n = 50000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5]]) == 20\n assert candidate(n = 200,rides = [[1, 100, 50], [50, 150, 100], [100, 200, 150], [25, 75, 75], [75, 125, 125], [125, 175, 175], [175, 225, 225]]) == 800\n assert candidate(n = 80000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 80000, 79999]]) == 160043\n assert candidate(n = 100000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15]]) == 135\n assert candidate(n = 50000,rides = [[1, 1000, 500], [1001, 2000, 1000], [2001, 3000, 1500], [3001, 4000, 2000], [4001, 5000, 2500], [5001, 10000, 3000], [10001, 15000, 3500], [15001, 20000, 4000], [20001, 25000, 4500], [25001, 30000, 5000], [30001, 35000, 5500], [35001, 40000, 6000], [40001, 45000, 6500], [45001, 50000, 7000]]) == 102486\n assert candidate(n = 10000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15], [16, 17, 16], [17, 18, 17], [18, 19, 18], [19, 20, 19], [20, 21, 20], [21, 22, 21], [22, 23, 22], [23, 24, 23], [24, 25, 24], [25, 26, 25], [26, 27, 26], [27, 28, 27], [28, 29, 28], [29, 30, 29], [30, 31, 30], [31, 32, 31], [32, 33, 32], [33, 34, 33], [34, 35, 34], [35, 36, 35], [36, 37, 36], [37, 38, 37], [38, 39, 38], [39, 40, 39], [40, 41, 40]]) == 860\n assert candidate(n = 200,rides = [[1, 100, 50], [2, 199, 49], [3, 198, 48], [4, 197, 47], [5, 196, 46], [6, 195, 45], [7, 194, 44], [8, 193, 43], [9, 192, 42], [10, 191, 41]]) == 246\n assert candidate(n = 100,rides = [[10, 20, 10], [20, 30, 20], [30, 40, 30], [40, 50, 40], [50, 60, 50], [60, 70, 60], [70, 80, 70], [80, 90, 80], [90, 100, 90], [1, 10, 5], [2, 20, 15], [3, 30, 25], [4, 40, 35], [5, 50, 45], [6, 60, 55], [7, 70, 65], [8, 80, 75], [9, 90, 85], [10, 100, 95]]) == 554\n assert candidate(n = 10000,rides = [[1, 10000, 10000], [2, 9999, 9999], [3, 9998, 9998], [4, 9997, 9997], [5, 9996, 9996]]) == 19999\n assert candidate(n = 10000,rides = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1], [19, 20, 1]]) == 38\n assert candidate(n = 50,rides = [[1, 3, 2], [3, 5, 3], [5, 7, 2], [7, 9, 1], [9, 11, 5], [11, 13, 4], [13, 15, 6], [15, 17, 2], [17, 19, 3], [19, 21, 7], [21, 23, 4], [23, 25, 5], [25, 27, 2], [27, 29, 3], [29, 31, 1], [31, 33, 5], [33, 35, 4], [35, 37, 6], [37, 39, 2], [39, 41, 3], [41, 43, 7], [43, 45, 4], [45, 47, 5], [47, 49, 2], [49, 50, 3]]) == 140\n assert candidate(n = 100,rides = [[1, 10, 50], [11, 20, 50], [21, 30, 50], [31, 40, 50], [41, 50, 50], [51, 60, 50], [61, 70, 50], [71, 80, 50], [81, 90, 50], [91, 100, 50]]) == 590\n assert candidate(n = 30000,rides = [[1, 10, 50], [11, 20, 100], [21, 30, 150], [31, 40, 200], [41, 50, 250], [51, 60, 300], [61, 70, 350], [71, 80, 400], [81, 90, 450], [91, 100, 500], [101, 30000, 29900]]) == 62639\n assert candidate(n = 150,rides = [[1, 50, 10], [50, 100, 20], [100, 150, 30], [20, 70, 15], [70, 120, 25], [120, 170, 35], [30, 80, 20], [80, 130, 30], [130, 180, 40]]) == 240\n assert candidate(n = 20000,rides = [[1, 5, 10], [2, 6, 15], [3, 7, 20], [4, 8, 25], [5, 9, 30], [6, 10, 35], [7, 11, 40], [8, 12, 45], [9, 13, 50], [10, 20000, 19950]]) == 39998\n assert candidate(n = 1000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9]]) == 54\n assert candidate(n = 100000,rides = [[1, 100000, 100000]]) == 199999\n assert candidate(n = 30000,rides = [[1, 30000, 10000], [10000, 20000, 15000], [20000, 30000, 20000], [5000, 15000, 10000]]) == 55000\n assert candidate(n = 50000,rides = [[1, 25000, 25000], [25000, 50000, 25000], [5000, 10000, 5000], [15000, 20000, 5000], [30000, 35000, 5000]]) == 99999\n assert candidate(n = 50,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15], [16, 17, 16], [17, 18, 17], [18, 19, 18], [19, 20, 19], [20, 21, 20], [21, 22, 21], [22, 23, 22], [23, 24, 23], [24, 25, 24], [25, 26, 25], [26, 27, 26], [27, 28, 27], [28, 29, 28], [29, 30, 29], [30, 31, 30], [31, 32, 31], [32, 33, 32], [33, 34, 33], [34, 35, 34], [35, 36, 35], [36, 37, 36], [37, 38, 37], [38, 39, 38], [39, 40, 39], [40, 41, 40], [41, 42, 41], [42, 43, 42], [43, 44, 43], [44, 45, 44], [45, 46, 45], [46, 47, 46], [47, 48, 47], [48, 49, 48], [49, 50, 49]]) == 1274\n assert candidate(n = 50,rides = [[1, 10, 5], [1, 10, 3], [1, 10, 1], [10, 20, 5], [10, 20, 3], [10, 20, 1], [20, 30, 5], [20, 30, 3], [20, 30, 1]]) == 44\n assert candidate(n = 70000,rides = [[1, 10000, 10000], [10001, 20000, 10000], [20001, 30000, 10000], [30001, 40000, 10000], [40001, 50000, 10000], [50001, 60000, 10000], [60001, 70000, 10000]]) == 139993\n assert candidate(n = 100000,rides = [[1, 50000, 50000], [50000, 100000, 50000], [25000, 75000, 30000]]) == 199999\n assert candidate(n = 50000,rides = [[1, 10, 100], [10, 20, 100], [20, 30, 100], [30, 40, 100], [40, 50, 100], [50, 60, 100], [60, 70, 100], [70, 80, 100], [80, 90, 100], [90, 100, 100]]) == 1099\n assert candidate(n = 10000,rides = [[1, 5000, 1000], [5001, 10000, 2000], [2001, 4000, 1500], [4001, 6000, 1200], [6001, 8000, 1800], [8001, 10000, 1600], [3001, 4500, 800], [4501, 6500, 1300], [6501, 8500, 1700], [8501, 9500, 1400]]) == 14096\n assert candidate(n = 50000,rides = [[1, 10, 10], [10, 20, 20], [20, 30, 30], [30, 40, 40], [40, 50, 50], [50, 60, 60], [60, 70, 70], [70, 80, 80], [80, 90, 90], [90, 100, 100], [100, 50000, 49900]]) == 100449\n assert candidate(n = 90000,rides = [[1, 10, 1], [11, 20, 2], [21, 30, 3], [31, 40, 4], [41, 50, 5], [51, 60, 6], [61, 70, 7], [71, 80, 8], [81, 90, 9], [91, 100, 10], [101, 110, 11], [111, 120, 12], [121, 130, 13], [131, 140, 14], [141, 150, 15], [151, 160, 16], [161, 170, 17], [171, 180, 18], [181, 190, 19], [191, 200, 20]]) == 390\n assert candidate(n = 90000,rides = [[1, 30000, 30000], [30001, 60000, 30000], [60001, 90000, 30000], [1, 60000, 60000], [30001, 90000, 60000], [1, 90000, 90000]]) == 179999\n assert candidate(n = 5000,rides = [[1, 3, 1], [2, 4, 1], [3, 5, 1], [4, 6, 1], [5, 7, 1], [6, 8, 1], [7, 9, 1], [8, 10, 1], [9, 11, 1], [10, 12, 1], [11, 13, 1], [12, 14, 1], [13, 15, 1], [14, 16, 1], [15, 17, 1], [16, 18, 1], [17, 19, 1], [18, 20, 1], [19, 21, 1], [20, 22, 1], [21, 23, 1], [22, 24, 1], [23, 25, 1], [24, 26, 1], [25, 27, 1], [26, 28, 1], [27, 29, 1], [28, 30, 1], [29, 31, 1], [30, 32, 1], [31, 33, 1], [32, 34, 1], [33, 35, 1], [34, 36, 1], [35, 37, 1], [36, 38, 1], [37, 39, 1], [38, 40, 1]]) == 57\n assert candidate(n = 10000,rides = [[1, 5, 50], [2, 6, 40], [3, 7, 30], [4, 8, 20], [5, 9, 10], [6, 10, 5]]) == 68\n assert candidate(n = 1000,rides = [[1, 10, 5], [2, 15, 10], [5, 100, 50], [10, 50, 25], [15, 90, 45], [20, 80, 35], [25, 70, 30], [30, 60, 25], [35, 55, 20], [40, 45, 15]]) == 145\n assert candidate(n = 50000,rides = [[1, 10000, 10000], [10001, 20000, 20000], [20001, 30000, 30000], [30001, 40000, 40000], [40001, 50000, 50000]]) == 199995\n assert candidate(n = 100,rides = [[1, 10, 5], [11, 20, 10], [21, 30, 15], [31, 40, 20], [41, 50, 25], [51, 60, 30], [61, 70, 35], [71, 80, 40], [81, 90, 45], [91, 100, 50]]) == 365\n assert candidate(n = 100000,rides = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1], [19, 20, 1], [20, 21, 1], [21, 22, 1], [22, 23, 1], [23, 24, 1], [24, 25, 1], [25, 26, 1], [26, 27, 1], [27, 28, 1], [28, 29, 1], [29, 30, 1], [30, 31, 1], [31, 32, 1], [32, 33, 1], [33, 34, 1], [34, 35, 1], [35, 36, 1], [36, 37, 1], [37, 38, 1], [38, 39, 1], [39, 40, 1], [40, 41, 1], [41, 42, 1], [42, 43, 1], [43, 44, 1], [44, 45, 1], [45, 46, 1], [46, 47, 1], [47, 48, 1], [48, 49, 1], [49, 50, 1], [50, 51, 1], [51, 52, 1], [52, 53, 1], [53, 54, 1], [54, 55, 1], [55, 56, 1], [56, 57, 1], [57, 58, 1], [58, 59, 1], [59, 60, 1], [60, 61, 1], [61, 62, 1], [62, 63, 1], [63, 64, 1], [64, 65, 1], [65, 66, 1], [66, 67, 1], [67, 68, 1], [68, 69, 1], [69, 70, 1], [70, 71, 1], [71, 72, 1], [72, 73, 1], [73, 74, 1], [74, 75, 1], [75, 76, 1], [76, 77, 1], [77, 78, 1], [78, 79, 1], [79, 80, 1], [80, 81, 1], [81, 82, 1], [82, 83, 1], [83, 84, 1], [84, 85, 1], [85, 86, 1], [86, 87, 1], [87, 88, 1], [88, 89, 1], [89, 90, 1], [90, 91, 1], [91, 92, 1], [92, 93, 1], [93, 94, 1], [94, 95, 1], [95, 96, 1], [96, 97, 1], [97, 98, 1], [98, 99, 1], [99, 100, 1], [100, 101, 1], [101, 102, 1], [102, 103, 1], [103, 104, 1], [104, 105, 1], [105, 106, 1], [106, 107, 1], [107, 108, 1], [108, 109, 1], [109, 110, 1], [110, 111, 1], [111, 112, 1], [112, 113, 1], [113, 114, 1], [114, 115, 1], [115, 116, 1], [116, 117, 1], [117, 118, 1], [118, 119, 1], [119, 120, 1], [120, 121, 1], [121, 122, 1], [122, 123, 1], [123, 124, 1], [124, 125, 1], [125, 126, 1], [126, 127, 1], [127, 128, 1], [128, 129, 1], [129, 130, 1], [130, 131, 1], [131, 132, 1], [132, 133, 1], [133, 134, 1], [134, 135, 1], [135, 136, 1], [136, 137, 1], [137, 138, 1], [138, 139, 1], [139, 140, 1], [140, 141, 1], [141, 142, 1], [142, 143, 1], [143, 144, 1], [144, 145, 1], [145, 146, 1], [146, 147, 1], [147, 148, 1], [148, 149, 1], [149, 150, 1], [150, 151, 1], [151, 152, 1], [152, 153, 1], [153, 154, 1], [154, 155, 1], [155, 156, 1], [156, 157, 1], [157, 158, 1], [158, 159, 1], [159, 160, 1], [160, 161, 1], [161, 162, 1], [162, 163, 1], [163, 164, 1], [164, 165, 1], [165, 166, 1], [166, 167, 1], [167, 168, 1], [168, 169, 1], [169, 170, 1], [170, 171, 1], [171, 172, 1], [172, 173, 1], [173, 174, 1], [174, 175, 1], [175, 176, 1], [176, 177, 1], [177, 178, 1], [178, 179, 1], [179, 180, 1], [180, 181, 1], [181, 182, 1], [182, 183, 1], [183, 184, 1], [184, 185, 1], [185, 186, 1], [186, 187, 1], [187, 188, 1], [188, 189, 1], [189, 190, 1], [190, 191, 1], [191, 192, 1], [192, 193, 1], [193, 194, 1], [194, 195, 1], [195, 196, 1], [196, 197, 1], [197, 198, 1], [198, 199, 1], [199, 200, 1]]) == 398\n assert candidate(n = 100000,rides = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 100000, 99999]]) == 200007\n assert candidate(n = 100000,rides = [[1, 100000, 100000], [50000, 100000, 50000], [25000, 75000, 25000], [1, 50000, 10000], [50001, 100000, 10000]]) == 199999\n assert candidate(n = 20,rides = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1], [19, 20, 1]]) == 38\n assert candidate(n = 100000,rides = [[1, 100000, 1], [1, 100000, 2], [1, 100000, 3], [1, 100000, 4], [1, 100000, 5], [1, 100000, 6], [1, 100000, 7], [1, 100000, 8], [1, 100000, 9], [1, 100000, 10]]) == 100009\n assert candidate(n = 15,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14]]) == 119\n assert candidate(n = 60000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [59999, 60000, 100000]]) == 100028\n assert candidate(n = 80000,rides = [[1, 20000, 1000], [20000, 40000, 1000], [40000, 60000, 1000], [60000, 80000, 1000]]) == 83999\n assert candidate(n = 10000,rides = [[1, 5, 10], [2, 6, 10], [3, 7, 10], [4, 8, 10], [5, 9, 10], [6, 10, 10], [7, 11, 10], [8, 12, 10], [9, 13, 10], [10, 14, 10]]) == 42\n assert candidate(n = 10000,rides = [[1, 10, 5], [2, 11, 5], [3, 12, 5], [4, 13, 5], [5, 14, 5], [6, 15, 5], [7, 16, 5], [8, 17, 5], [9, 18, 5], [10, 19, 5], [11, 20, 5], [12, 21, 5], [13, 22, 5], [14, 23, 5], [15, 24, 5], [16, 25, 5], [17, 26, 5], [18, 27, 5], [19, 28, 5], [20, 29, 5], [21, 30, 5], [22, 31, 5], [23, 32, 5], [24, 33, 5], [25, 34, 5], [26, 35, 5], [27, 36, 5], [28, 37, 5], [29, 38, 5], [30, 39, 5], [31, 40, 5], [32, 41, 5], [33, 42, 5], [34, 43, 5], [35, 44, 5], [36, 45, 5], [37, 46, 5], [38, 47, 5], [39, 48, 5], [40, 49, 5], [41, 50, 5], [42, 51, 5], [43, 52, 5], [44, 53, 5], [45, 54, 5], [46, 55, 5], [47, 56, 5], [48, 57, 5], [49, 58, 5], [50, 59, 5], [51, 60, 5], [52, 61, 5], [53, 62, 5], [54, 63, 5], [55, 64, 5], [56, 65, 5], [57, 66, 5], [58, 67, 5], [59, 68, 5], [60, 69, 5], [61, 70, 5], [62, 71, 5], [63, 72, 5], [64, 73, 5], [65, 74, 5], [66, 75, 5], [67, 76, 5], [68, 77, 5], [69, 78, 5], [70, 79, 5], [71, 80, 5], [72, 81, 5], [73, 82, 5], [74, 83, 5], [75, 84, 5], [76, 85, 5], [77, 86, 5], [78, 87, 5], [79, 88, 5], [80, 89, 5], [81, 90, 5], [82, 91, 5], [83, 92, 5], [84, 93, 5], [85, 94, 5], [86, 95, 5], [87, 96, 5], [88, 97, 5], [89, 98, 5], [90, 99, 5], [91, 100, 5]]) == 154\n assert candidate(n = 120000,rides = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [119998, 119999, 1], [119999, 120000, 100]]) == 112\n"}, "metadata": {"canonical_parameter_names": ["n", "rides"], "leetcode_dataset_entry_point": "Solution().maxTaxiEarnings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long maxTaxiEarnings(int n, vector>& rides) {", "container": "Solution", "callable": "maxTaxiEarnings", "parameters": [{"name": "n", "type": "int"}, {"name": "rides", "type": "vector>&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2009, "task_id": "minimum-number-of-operations-to-make-array-continuous", "difficulty": "Hard", "problem_description": "You are given an integer array nums. In one operation, you can replace any element in nums with any integer.\nnums is considered continuous if both of the following conditions are fulfilled:\n\nAll elements in nums are unique.\nThe difference between the maximum element and the minimum element in nums equals nums.length - 1.\n\nFor example, nums = [4, 2, 5, 3] is continuous, but nums = [1, 2, 3, 5, 6] is not continuous.\nReturn the minimum number of operations to make nums continuous.\n \nExample 1:\n\nInput: nums = [4,2,5,3]\nOutput: 0\nExplanation: nums is already continuous.\n\nExample 2:\n\nInput: nums = [1,2,3,5,6]\nOutput: 1\nExplanation: One possible solution is to change the last element to 4.\nThe resulting array is [1,2,3,5,4], which is continuous.\n\nExample 3:\n\nInput: nums = [1,10,100,1000]\nOutput: 3\nExplanation: One possible solution is to:\n- Change the second element to 2.\n- Change the third element to 3.\n- Change the fourth element to 4.\nThe resulting array is [1,2,3,4], which is continuous.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n1 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 10, 10, 10]) == 3\n assert candidate(nums = [4, 2, 5, 3]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 2, 2, 3, 4, 5]) == 2\n assert candidate(nums = [5, 6, 7, 8, 9, 1]) == 1\n assert candidate(nums = [1, 3, 5, 7, 9]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(nums = [1000000000, 1, 2, 3, 4]) == 1\n assert candidate(nums = [1000000000]) == 0\n assert candidate(nums = [100, 101, 102, 1]) == 1\n assert candidate(nums = [5, 5, 5, 5, 5]) == 4\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 5\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5]) == 1\n assert candidate(nums = [2, 3, 5, 8, 9, 10]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5]) == 0\n assert candidate(nums = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1]) == 4\n assert candidate(nums = [1, 10, 100, 1000]) == 3\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [10, 5, 1, 2, 7]) == 2\n assert candidate(nums = [1, 2, 2, 3, 4]) == 1\n assert candidate(nums = [1, 2, 3, 5, 6]) == 1\n assert candidate(nums = [10, 5, 7, 11, 6]) == 2\n assert candidate(nums = [5, 3, 1, 2, 4]) == 0\n assert candidate(nums = [10, 5, 3, 11, 6]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [5, 3, 1, 4, 2]) == 0\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 0\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 4\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 1000000000, 2000000000, 3000000000, 4000000000]) == 4\n assert candidate(nums = [5, 6, 7, 8, 9, 1, 2, 3, 4, 10]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]) == 16\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 14\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 9\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998]) == 3\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 2, 11, 101, 1001, 10001, 100001, 1000001, 10000001, 100000001, 1000000001]) == 16\n assert candidate(nums = [1, 1000000000]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 9\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 7\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]) == 19\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 66, 78, 91, 105, 120, 136, 153, 171, 190, 210, 231, 253, 276, 300, 325, 351, 378, 406, 435, 465, 496]) == 24\n assert candidate(nums = [10, 21, 32, 43, 54, 65, 76, 87, 98, 109, 120, 131, 142, 153, 164, 175, 186, 197, 208, 219]) == 18\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 4, 5, 5, 6]) == 4\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11]) == 9\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 7\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]) == 15\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 10\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(nums = [5, 6, 15, 16, 25, 26, 35, 36, 45, 46, 55, 56, 65, 66, 75, 76, 85, 86, 95, 96]) == 16\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [3, 7, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == 12\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996, 6, 999999995]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 0\n assert candidate(nums = [2, 1, 3, 4, 7, 6, 5, 8, 9, 10]) == 0\n assert candidate(nums = [1, 3, 6, 10, 15, 21, 28, 36, 45, 55]) == 6\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 7\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 10\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 4\n assert candidate(nums = [1, 2, 3, 5, 6, 7, 8, 10, 11, 12, 13, 15, 16, 17, 18, 20, 21, 22, 23, 25, 26, 27, 28, 30, 31, 32, 33, 35, 36, 37, 38, 40]) == 6\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 15\n assert candidate(nums = [1, 3, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30]) == 7\n assert candidate(nums = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 12\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14, 15, 15, 16]) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300]) == 27\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20]) == 3\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 0\n assert candidate(nums = [1, 2, 3, 1000000000, 2000000000]) == 2\n assert candidate(nums = [1, 10, 19, 28, 37, 46, 55, 64, 73, 82, 91, 100, 109, 118, 127, 136, 145, 154, 163, 172, 181, 190, 199, 208, 217, 226]) == 23\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]) == 0\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205]) == 18\n assert candidate(nums = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 10\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(nums = [1, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140]) == 13\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10, 5, 6, 7, 8, 9, 10]) == 12\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60]) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5]) == 9\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == 5\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 8\n assert candidate(nums = [1000000, 1000001, 1000002, 1000004, 1000005, 1000007, 1000008, 1000010, 1000011, 1000013]) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 5\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 9\n assert candidate(nums = [1, 1000000000, 1000000001, 1000000002, 1000000003, 1000000004, 1000000005, 1000000006, 1000000007, 1000000008, 1000000009, 1000000010, 1000000011, 1000000012, 1000000013]) == 1\n assert candidate(nums = [5, 6, 7, 8, 10, 11, 12, 13, 15, 16, 17, 18, 20]) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 14\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [1, 100, 101, 200, 201, 300, 301, 400, 401, 500, 501, 600, 601, 700, 701, 800, 801, 900, 901, 1000]) == 18\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 18\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60]) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250]) == 22\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10]) == 20\n assert candidate(nums = [1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 13\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 999999995]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500]) == 45\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == 8\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996]) == 5\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 200, 201, 202, 203, 204]) == 5\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [1000000000, 1000000001, 1000000002, 1000000003, 1000000004, 1000000005]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 10\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]) == 18\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 7\n assert candidate(nums = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800, 2900, 3000]) == 30\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == 5\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 14\n assert candidate(nums = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 9\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209]) == 10\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 0\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == 10\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980, 979, 978, 977, 976, 975, 974, 973, 972, 971]) == 0\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 13\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minOperations(vector& nums) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2011, "task_id": "final-value-of-variable-after-performing-operations", "difficulty": "Easy", "problem_description": "There is a programming language with only four operations and one variable X:\n\n++X and X++ increments the value of the variable X by 1.\n--X and X-- decrements the value of the variable X by 1.\n\nInitially, the value of X is 0.\nGiven an array of strings operations containing a list of operations, return the final value of X after performing all the operations.\n \nExample 1:\n\nInput: operations = [\"--X\",\"X++\",\"X++\"]\nOutput: 1\nExplanation: The operations are performed as follows:\nInitially, X = 0.\n--X: X is decremented by 1, X = 0 - 1 = -1.\nX++: X is incremented by 1, X = -1 + 1 = 0.\nX++: X is incremented by 1, X = 0 + 1 = 1.\n\nExample 2:\n\nInput: operations = [\"++X\",\"++X\",\"X++\"]\nOutput: 3\nExplanation: The operations are performed as follows:\nInitially, X = 0.\n++X: X is incremented by 1, X = 0 + 1 = 1.\n++X: X is incremented by 1, X = 1 + 1 = 2.\nX++: X is incremented by 1, X = 2 + 1 = 3.\n\nExample 3:\n\nInput: operations = [\"X++\",\"++X\",\"--X\",\"X--\"]\nOutput: 0\nExplanation: The operations are performed as follows:\nInitially, X = 0.\nX++: X is incremented by 1, X = 0 + 1 = 1.\n++X: X is incremented by 1, X = 1 + 1 = 2.\n--X: X is decremented by 1, X = 2 - 1 = 1.\nX--: X is decremented by 1, X = 1 - 1 = 0.\n\n \nConstraints:\n\n1 <= operations.length <= 100\noperations[i] will be either \"++X\", \"X++\", \"--X\", or \"X--\".\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(operations = ['X++', '++X', '--X', 'X--']) == 0\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++']) == 5\n assert candidate(operations = ['--X', '--X', 'X--', 'X--']) == -4\n assert candidate(operations = ['++X', '++X', '++X', '++X']) == 4\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++']) == 4\n assert candidate(operations = ['--X', 'X++', 'X++']) == 1\n assert candidate(operations = ['--X', '--X', '--X', '--X']) == -4\n assert candidate(operations = ['--X', '--X', '--X', '--X', '--X']) == -5\n assert candidate(operations = ['--X', '--X', 'X++', '++X']) == 0\n assert candidate(operations = ['++X', '++X', 'X++']) == 3\n assert candidate(operations = ['--X', '--X', 'X++', '++X', '--X']) == -1\n assert candidate(operations = ['++X', 'X--', '--X', 'X++']) == 0\n assert candidate(operations = ['X++', 'X--', '++X', '--X']) == 0\n assert candidate(operations = ['++X', '++X', '++X', '++X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X']) == -12\n assert candidate(operations = ['X++', 'X++', 'X++', '--X', '--X', '--X', '--X', '--X', 'X++', 'X++', 'X++']) == 1\n assert candidate(operations = ['--X', '--X', 'X++', 'X++', 'X--', 'X--', 'X++', '++X', '--X', 'X++', '--X', '++X', 'X--', '--X', 'X++', 'X++']) == 0\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X']) == 0\n assert candidate(operations = ['++X', '++X', '++X', '++X', 'X--', 'X--', 'X--', 'X--', 'X--', 'X--', 'X--', 'X--', 'X--', 'X--']) == -6\n assert candidate(operations = ['--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++']) == 0\n assert candidate(operations = ['X--', '--X', 'X--', '--X', 'X--', '--X', 'X--', '--X', 'X--', '--X', 'X--', '--X', 'X--', '--X', 'X--', '--X']) == -16\n assert candidate(operations = ['++X', '--X', '++X', '--X', '++X', '--X']) == 0\n assert candidate(operations = ['++X', 'X++', '--X', 'X--', '++X', 'X++', '--X', 'X--', '++X', 'X++', '--X', 'X--']) == 0\n assert candidate(operations = ['X--', '--X', 'X++', '++X', '--X', 'X--', '--X', '++X', 'X++']) == -1\n assert candidate(operations = ['++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++']) == 0\n assert candidate(operations = ['X++', 'X++', '--X', 'X++', 'X++', '--X', '--X', 'X++', '--X', 'X++', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X']) == 1\n assert candidate(operations = ['--X', '--X', 'X--', 'X++', '++X', '++X', 'X--', '--X', '++X', '--X']) == -2\n assert candidate(operations = ['++X', 'X--', '--X', 'X++', 'X--', '++X', 'X--', '--X', 'X++', '++X']) == 0\n assert candidate(operations = ['++X', 'X++', '--X', 'X--', '++X', 'X++', '--X', 'X--', '++X', 'X++', '--X', 'X--', '++X', 'X++', '--X', 'X--', '++X', 'X++']) == 2\n assert candidate(operations = ['++X', 'X--', '--X', 'X++', '++X', '--X', 'X++']) == 1\n assert candidate(operations = ['--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '++X', '++X', '++X', '++X', '++X', '++X', '++X', '++X', '++X', '++X']) == -5\n assert candidate(operations = ['++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X']) == 0\n assert candidate(operations = ['++X', '++X', '--X', '--X', '++X', '++X', '--X', '--X', '++X', '++X', '--X', '--X', '++X', '++X', '--X', '--X', '++X', '++X']) == 2\n assert candidate(operations = ['--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X']) == -12\n assert candidate(operations = ['X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X']) == 0\n assert candidate(operations = ['++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X', '--X']) == 0\n assert candidate(operations = ['X++', '--X', '++X', 'X--', '++X', 'X++', '--X', '--X', '++X', 'X++']) == 2\n assert candidate(operations = ['++X', '++X', '++X', '++X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X']) == -4\n assert candidate(operations = ['X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X']) == 0\n assert candidate(operations = ['--X', 'X++', '++X', '--X', 'X++', '--X', 'X--', 'X++', '--X', '++X']) == 0\n assert candidate(operations = ['++X', '++X', '++X', '--X', '--X', '--X', '++X', 'X++', '--X']) == 1\n assert candidate(operations = ['++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X']) == -1\n assert candidate(operations = ['--X', '--X', 'X++', 'X--', 'X--', 'X--', 'X--', 'X--', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++']) == 0\n assert candidate(operations = ['++X', '--X', 'X++', '++X', '--X', 'X--', '++X', 'X++']) == 2\n assert candidate(operations = ['--X', 'X--', '--X', 'X--', '--X', 'X--', '++X', 'X++', '++X', 'X++', '++X', 'X++', '++X', 'X++']) == 2\n assert candidate(operations = ['X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X']) == 0\n assert candidate(operations = ['--X', '++X', '--X', '++X', '--X', '++X', '--X', '++X']) == 0\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X--', 'X--', 'X--', 'X--', 'X++', 'X++', 'X--', 'X--']) == 0\n assert candidate(operations = ['X--', '--X', '++X', 'X++', 'X--', '--X', '++X', 'X++', 'X--', '--X', '++X', 'X++', 'X--', '--X', '++X', 'X++', 'X--', '--X', '++X', 'X++']) == 0\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X']) == -4\n assert candidate(operations = ['X++', 'X++', '--X', '--X', 'X++', '--X', 'X++', '--X', 'X--', 'X++', '--X', 'X++', '--X', 'X--', 'X++', '--X', 'X++', '--X', 'X--', 'X++', '--X', 'X++', '--X', 'X--', 'X++', '--X', 'X++', '--X', 'X--', 'X++', '--X']) == -5\n assert candidate(operations = ['X++', 'X++', '--X', '--X', '++X', 'X--', '++X', '--X', '++X', '--X']) == 0\n assert candidate(operations = ['X++', 'X++', '++X', '--X', 'X--', 'X--', '--X', '++X', 'X--', '--X']) == -2\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++']) == 12\n assert candidate(operations = ['--X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', '--X', 'X++', '--X', '++X', 'X--', '--X', 'X++']) == -2\n assert candidate(operations = ['--X', '--X', '--X', '--X', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++']) == 4\n assert candidate(operations = ['--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X']) == -1\n assert candidate(operations = ['X--', '--X', '++X', 'X++', 'X--', '--X', '++X', 'X++']) == 0\n assert candidate(operations = ['X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', '++X', 'X++', '--X', '--X', '++X', 'X++']) == 2\n assert candidate(operations = ['--X', '--X', '--X', '--X', '--X', '--X', '++X', '++X', '++X', '++X', '++X', '++X', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++']) == 8\n assert candidate(operations = ['--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++']) == 0\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++']) == 57\n assert candidate(operations = ['X++', '--X', '++X', 'X--', '++X', '--X', 'X++', '++X', '--X', 'X--']) == 0\n assert candidate(operations = ['--X', '--X', '--X', '--X', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++']) == 37\n assert candidate(operations = ['X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++']) == 2\n assert candidate(operations = ['X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X']) == 0\n assert candidate(operations = ['X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X']) == 0\n assert candidate(operations = ['--X', '--X', '--X', 'X++', 'X++', 'X++', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', 'X--', 'X--', '++X', '++X']) == 0\n assert candidate(operations = ['X++', 'X--', '++X', '--X', 'X++', 'X--', '++X', '--X', 'X++', 'X--', '++X', '--X', 'X++', 'X--', '++X', '--X', 'X++', 'X--', '++X', '--X']) == 0\n assert candidate(operations = ['X++', 'X--', '++X', '--X', 'X--', '++X', 'X--', '++X', 'X--', '++X', 'X--', '++X']) == 0\n assert candidate(operations = ['X++', '--X', '++X', '--X', 'X++', '--X', 'X--']) == -1\n assert candidate(operations = ['--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++']) == 0\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++']) == 2\n assert candidate(operations = ['X--', 'X--', '--X', '--X', 'X++', 'X++', '++X']) == -1\n assert candidate(operations = ['X++', 'X++', 'X++', '--X', '--X', '--X', 'X++', 'X++', '--X', '--X', 'X++', 'X++', 'X++', '--X', '--X']) == 1\n assert candidate(operations = ['++X', '++X', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++']) == 2\n assert candidate(operations = ['--X', '--X', '--X', '--X', '--X', '++X', '++X', '++X', '++X', '++X', 'X++', 'X++', 'X++']) == 3\n assert candidate(operations = ['++X', 'X++', '--X', 'X--', '++X', '--X', 'X++', '++X']) == 2\n assert candidate(operations = ['X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X', 'X--', '--X', 'X++', '++X']) == 2\n assert candidate(operations = ['X++', '++X', 'X++', '++X', '--X', '--X', 'X--', '--X', 'X++', '++X', '--X', 'X--', '++X', 'X++']) == 2\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X']) == -4\n assert candidate(operations = ['X++', 'X++', '--X', '--X', 'X++', 'X++', 'X++', '--X', '--X', '--X']) == 0\n assert candidate(operations = ['X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', 'X++', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X', '--X']) == 0\n assert candidate(operations = ['X--', '--X', 'X++', '++X', 'X--', 'X--', '--X', '++X', 'X--', 'X--', 'X++', '++X']) == -2\n assert candidate(operations = ['X++', 'X++', '--X', '--X', 'X++', 'X--', 'X++', '--X', 'X++', 'X--', '++X', '--X']) == 0\n assert candidate(operations = ['++X', 'X--', '++X', 'X--', '++X', 'X--', '++X', 'X--', '++X', 'X--', '++X', 'X--']) == 0\n assert candidate(operations = ['X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X', 'X++', '--X']) == 0\n assert candidate(operations = ['--X', 'X--', '++X', 'X++', '--X', 'X--', '++X', 'X++', '--X', 'X--', '++X', 'X++']) == 0\n assert candidate(operations = ['++X', '++X', '++X', '--X', 'X--', '--X', 'X--', '--X', '++X', '--X']) == -2\n"}, "metadata": {"canonical_parameter_names": ["operations"], "leetcode_dataset_entry_point": "Solution().finalValueAfterOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int finalValueAfterOperations(vector& operations) {", "container": "Solution", "callable": "finalValueAfterOperations", "parameters": [{"name": "operations", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2012, "task_id": "sum-of-beauty-in-the-array", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums. For each index i (1 <= i <= nums.length - 2) the beauty of nums[i] equals:\n\n2, if nums[j] < nums[i] < nums[k], for all 0 <= j < i and for all i < k <= nums.length - 1.\n1, if nums[i - 1] < nums[i] < nums[i + 1], and the previous condition is not satisfied.\n0, if none of the previous conditions holds.\n\nReturn the sum of beauty of all nums[i] where 1 <= i <= nums.length - 2.\n \nExample 1:\n\nInput: nums = [1,2,3]\nOutput: 2\nExplanation: For each index i in the range 1 <= i <= 1:\n- The beauty of nums[1] equals 2.\n\nExample 2:\n\nInput: nums = [2,4,6,4]\nOutput: 1\nExplanation: For each index i in the range 1 <= i <= 2:\n- The beauty of nums[1] equals 1.\n- The beauty of nums[2] equals 0.\n\nExample 3:\n\nInput: nums = [3,2,1]\nOutput: 0\nExplanation: For each index i in the range 1 <= i <= 1:\n- The beauty of nums[1] equals 0.\n\n \nConstraints:\n\n3 <= nums.length <= 105\n1 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 100, 8, 6, 90, 101]) == 1\n assert candidate(nums = [9, 7, 5, 3, 1]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [5, 3, 4, 2, 1]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 16\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == 0\n assert candidate(nums = [2, 4, 6, 4]) == 1\n assert candidate(nums = [1, 100, 101, 102, 99]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [5, 1, 4, 3, 6, 7]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 16\n assert candidate(nums = [100000, 99999, 100001, 99998, 100002]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 14\n assert candidate(nums = [3, 2, 1]) == 0\n assert candidate(nums = [1, 5, 2, 5, 3, 5, 4, 5]) == 0\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 0\n assert candidate(nums = [1, 3, 2, 3, 5, 2, 6, 2]) == 1\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 0\n assert candidate(nums = [1, 2, 3]) == 2\n assert candidate(nums = [1, 3, 2, 5, 4, 6]) == 0\n assert candidate(nums = [1, 6, 4, 3, 5, 7, 8]) == 3\n assert candidate(nums = [1, 5, 2, 4, 3, 6]) == 0\n assert candidate(nums = [1, 5, 3, 7, 9, 11, 13, 2, 14]) == 3\n assert candidate(nums = [10, 20, 15, 25, 20, 30, 25, 35, 30, 40, 35, 45, 40, 50, 45]) == 0\n assert candidate(nums = [1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8, 7, 8, 9, 8, 9, 10]) == 8\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 95, 94, 93, 92, 91]) == 16\n assert candidate(nums = [5, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12, 13, 14, 15]) == 10\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 0\n assert candidate(nums = [10, 20, 30, 25, 24, 35, 40, 39, 45, 50]) == 6\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3]) == 2\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == 0\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [3, 1, 4, 2, 5, 8, 7, 10, 9, 12, 11]) == 2\n assert candidate(nums = [1, 5, 3, 4, 2, 8, 6, 7, 9, 11, 10]) == 3\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 24\n assert candidate(nums = [5, 3, 4, 2, 6, 1, 7, 9, 8, 10]) == 2\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8]) == 0\n assert candidate(nums = [10, 20, 15, 25, 30, 5, 35, 40, 2, 45]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 9, 8, 10]) == 4\n assert candidate(nums = [10, 20, 11, 30, 12, 40, 13, 50, 14, 60, 15]) == 0\n assert candidate(nums = [1, 2, 3, 100, 2, 3, 4, 5, 6, 7]) == 6\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20]) == 0\n assert candidate(nums = [1, 10, 3, 5, 8, 12, 7, 6, 9, 11, 15, 14, 13, 16, 18, 17, 20, 19, 21, 22]) == 8\n assert candidate(nums = [90, 100, 110, 120, 115, 130, 140, 150, 145, 160, 170, 180, 175, 190, 200]) == 14\n assert candidate(nums = [1, 3, 5, 4, 6, 7, 2, 8, 9, 10]) == 6\n assert candidate(nums = [1, 2, 3, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 22\n assert candidate(nums = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]) == 46\n assert candidate(nums = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009]) == 16\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 8\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991]) == 0\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 8, 7, 10, 9, 12, 11]) == 2\n assert candidate(nums = [1, 20, 3, 40, 5, 60, 7, 80, 9, 100]) == 0\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 11, 12, 13, 14, 15]) == 15\n assert candidate(nums = [1, 2, 3, 100, 4, 5, 6, 7, 8, 9]) == 8\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 0\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15]) == 16\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 46\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 95, 85, 75, 65, 55, 45, 35, 25, 15, 5]) == 8\n assert candidate(nums = [1, 2, 3, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 3\n assert candidate(nums = [5, 1, 4, 3, 6, 8, 2, 9, 7, 10]) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20, 23, 22, 25, 24]) == 0\n assert candidate(nums = [1, 20, 3, 15, 4, 10, 5, 25, 6]) == 0\n assert candidate(nums = [1, 3, 5, 2, 4, 6, 8, 7, 9, 11]) == 6\n assert candidate(nums = [5, 1, 4, 3, 6, 2, 8, 7, 10, 9]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 28\n assert candidate(nums = [5, 1, 3, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 23\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [10, 20, 30, 25, 40, 35, 50, 45, 60, 55]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 56\n assert candidate(nums = [10, 20, 30, 25, 40, 35, 50, 45, 60]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 25\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 11, 12]) == 4\n assert candidate(nums = [10, 20, 30, 25, 35, 40, 45, 50, 39, 41]) == 6\n assert candidate(nums = [1, 100, 50, 200, 150, 250, 200, 300, 250, 350, 300, 400, 350, 450, 400, 500, 450, 550, 500, 600]) == 0\n assert candidate(nums = [10, 20, 30, 15, 25, 35, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == 14\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 21]) == 0\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8]) == 0\n assert candidate(nums = [30, 20, 10, 25, 15, 5, 35, 25, 15, 40, 30, 20, 50, 40, 30]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 26\n assert candidate(nums = [5, 3, 4, 2, 1, 6, 7, 8]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 1, 20]) == 17\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25]) == 22\n assert candidate(nums = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 14\n assert candidate(nums = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 99999]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 11]) == 8\n assert candidate(nums = [1, 2, 5, 3, 6, 4, 7, 8, 10, 9]) == 6\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 14, 13, 12, 11, 10]) == 21\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 0\n assert candidate(nums = [5, 8, 3, 9, 4, 10, 6, 11, 7, 12]) == 0\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 1\n assert candidate(nums = [1, 1000, 2, 999, 3, 998, 4, 997, 5, 996, 6, 995, 7, 994, 8, 993, 9, 992, 10, 991]) == 0\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0]) == 0\n assert candidate(nums = [20, 10, 30, 5, 25, 15, 35, 40, 50, 60]) == 6\n assert candidate(nums = [5, 1, 4, 2, 3, 6, 0, 8, 7, 9]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 36\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 25\n assert candidate(nums = [1, 2, 3, 100, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [100, 1, 101, 2, 102, 3, 103, 4, 104]) == 0\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 9, 10, 11, 12, 13, 14, 15]) == 12\n assert candidate(nums = [3, 1, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10]) == 8\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 16\n assert candidate(nums = [1, 3, 5, 7, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15]) == 4\n assert candidate(nums = [1, 5, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]) == 22\n assert candidate(nums = [100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000]) == 0\n assert candidate(nums = [10, 11, 9, 12, 8, 13, 7, 14, 6, 15, 5, 16, 4, 17, 3, 18, 2, 19, 1, 20]) == 0\n assert candidate(nums = [5, 1, 4, 3, 6, 8, 2, 9, 7]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50]) == 11\n assert candidate(nums = [50, 40, 60, 50, 70, 60, 80, 70, 90, 80, 100, 90, 110, 100, 120, 110, 130, 120, 140, 130]) == 0\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 22, 23, 24, 25, 26]) == 8\n assert candidate(nums = [1, 5, 3, 4, 6, 2, 7, 8, 9, 10]) == 7\n assert candidate(nums = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4]) == 16\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12]) == 0\n assert candidate(nums = [10, 20, 30, 29, 28, 27, 26, 25, 24, 23]) == 2\n assert candidate(nums = [1, 2, 3, 100, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 14\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 16\n assert candidate(nums = [1, 3, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20, 23, 22, 25, 24]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 10]) == 21\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, 3, 2, 4, 6, 5, 7, 9, 8, 10, 11, 12, 13, 14, 15]) == 14\n assert candidate(nums = [1, 3, 5, 7, 9, 8, 11, 10, 13, 15]) == 8\n assert candidate(nums = [10, 20, 15, 25, 30, 5, 35, 40, 2, 45, 50]) == 4\n assert candidate(nums = [1, 2, 100, 3, 4, 101, 5, 6, 102, 7, 8]) == 4\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == 0\n assert candidate(nums = [10, 20, 30, 25, 35, 40, 36, 45, 50, 55]) == 8\n assert candidate(nums = [5, 1, 4, 3, 6, 2, 7, 8, 10, 9]) == 4\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().sumOfBeauties", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int sumOfBeauties(vector& nums) {", "container": "Solution", "callable": "sumOfBeauties", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2014, "task_id": "longest-subsequence-repeated-k-times", "difficulty": "Hard", "problem_description": "You are given a string s of length n, and an integer k. You are tasked to find the longest subsequence repeated k times in string s.\nA subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.\nA subsequence seq is repeated k times in the string s if seq * k is a subsequence of s, where seq * k represents a string constructed by concatenating seq k times.\n\nFor example, \"bba\" is repeated 2 times in the string \"bababcba\", because the string \"bbabba\", constructed by concatenating \"bba\" 2 times, is a subsequence of the string \"bababcba\".\n\nReturn the longest subsequence repeated k times in string s. If multiple such subsequences are found, return the lexicographically largest one. If there is no such subsequence, return an empty string.\n \nExample 1:\n\n\nInput: s = \"letsleetcode\", k = 2\nOutput: \"let\"\nExplanation: There are two longest subsequences repeated 2 times: \"let\" and \"ete\".\n\"let\" is the lexicographically largest one.\n\nExample 2:\n\nInput: s = \"bb\", k = 2\nOutput: \"b\"\nExplanation: The longest subsequence repeated 2 times is \"b\".\n\nExample 3:\n\nInput: s = \"ab\", k = 2\nOutput: \"\"\nExplanation: There is no subsequence repeated 2 times. Empty string is returned.\n\n \nConstraints:\n\nn == s.length\n2 <= n, k <= 2000\n2 <= n < k * 8\ns consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"aabbcc\",k = 3) == \"\"\n assert candidate(s = \"zzzzzzzzz\",k = 4) == \"zz\"\n assert candidate(s = \"zzzzzzzzzz\",k = 5) == \"zz\"\n assert candidate(s = \"abcabcabcabc\",k = 4) == \"abc\"\n assert candidate(s = \"abcdabcabc\",k = 3) == \"abc\"\n assert candidate(s = \"abababababab\",k = 3) == \"abab\"\n assert candidate(s = \"aabbbccccc\",k = 3) == \"c\"\n assert candidate(s = \"letsleetcode\",k = 2) == \"let\"\n assert candidate(s = \"ab\",k = 2) == \"\"\n assert candidate(s = \"zzzzzzzzzzzzzz\",k = 5) == \"zz\"\n assert candidate(s = \"aaaabbbbcccc\",k = 2) == \"cc\"\n assert candidate(s = \"aaaabbbb\",k = 2) == \"bb\"\n assert candidate(s = \"aabbccddeeff\",k = 2) == \"f\"\n assert candidate(s = \"abcabcabc\",k = 3) == \"abc\"\n assert candidate(s = \"abcdabcdabcd\",k = 3) == \"abcd\"\n assert candidate(s = \"bb\",k = 2) == \"b\"\n assert candidate(s = \"abcdeabcdeabcde\",k = 3) == \"abcde\"\n assert candidate(s = \"abcdefghi\",k = 1) == \"abcdefghi\"\n assert candidate(s = \"aabbcc\",k = 2) == \"c\"\n assert candidate(s = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\",k = 16) == \"qq\"\n assert candidate(s = \"mnopmnopmnop\",k = 6) == \"\"\n assert candidate(s = \"abcabcabcabc\",k = 3) == \"cab\"\n assert candidate(s = \"abcdefabcdefabcdefabcdef\",k = 4) == \"abcdef\"\n assert candidate(s = \"aabbaaccdd\",k = 3) == \"a\"\n assert candidate(s = \"abcdefgabcdefgabcdefg\",k = 3) == \"abcdefg\"\n assert candidate(s = \"kkkkkkkkkkkkkkkk\",k = 16) == \"k\"\n assert candidate(s = \"aaaabbbbccccddddeeeeffffgggghhhhiiii\",k = 3) == \"i\"\n assert candidate(s = \"abcdefghijklaaaaaaabbbbbbbbbccccccccc\",k = 5) == \"cc\"\n assert candidate(s = \"xyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxyxy\",k = 8) == \"yxyx\"\n assert candidate(s = \"abababababababababababababab\",k = 7) == \"abab\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",k = 5) == \"zzzz\"\n assert candidate(s = \"aabaaaabbbaaa\",k = 4) == \"aa\"\n assert candidate(s = \"xyzxyzxyzxyzxyzxyz\",k = 2) == \"xyzxyzxyz\"\n assert candidate(s = \"aaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbcccccccccccccc\",k = 5) == \"aaa\"\n assert candidate(s = \"ababababababababababababababababab\",k = 10) == \"ba\"\n assert candidate(s = \"abacabadabacabadabacabadabacabadabacabadabacabad\",k = 4) == \"abaabaaba\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabcabcabc\",k = 5) == \"cabcab\"\n assert candidate(s = \"mississippi\",k = 2) == \"ssi\"\n assert candidate(s = \"ppppqqrrrrrssstttt\",k = 3) == \"t\"\n assert candidate(s = \"abcabcabcabcabcabcabc\",k = 3) == \"cabcab\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzz\",k = 10) == \"z\"\n assert candidate(s = \"abcabcabcabcabcabc\",k = 3) == \"abcabc\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 20) == \"zzz\"\n assert candidate(s = \"abababababababab\",k = 8) == \"ab\"\n assert candidate(s = \"mnopqrqponmlkjihgfedcba\",k = 2) == \"q\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",k = 5) == \"abcabc\"\n assert candidate(s = \"qqwweerrttyyuuiiooppllaaasssdddfffggghhjjkk\",k = 3) == \"s\"\n assert candidate(s = \"aabbccddeeefffggg\",k = 2) == \"g\"\n assert candidate(s = \"aaabbbcccddd\",k = 3) == \"d\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd\",k = 5) == \"dabcdabc\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabc\",k = 10) == \"abc\"\n assert candidate(s = \"abcabcabcabcabcabcabcabcabcabca\",k = 5) == \"bcabca\"\n assert candidate(s = \"zzzzzzzzzzzz\",k = 5) == \"zz\"\n assert candidate(s = \"aaaabbbbccccdddddd\",k = 4) == \"d\"\n assert candidate(s = \"xzyxzyxzyxzyxzyxzyxzyxzyxzyxzyxzy\",k = 4) == \"zyxzyx\"\n assert candidate(s = \"aabbccddeeffgg\",k = 2) == \"g\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzz\",k = 20) == \"z\"\n assert candidate(s = \"ababababababab\",k = 4) == \"ba\"\n assert candidate(s = \"ababababababababab\",k = 5) == \"ba\"\n assert candidate(s = \"mnopqrsmnopqrsmnopqrsmnopqrsmnopqrs\",k = 3) == \"smnopqr\"\n assert candidate(s = \"abcdefghijabcdefghijabcdefghijabcdefghij\",k = 4) == \"abcdefghij\"\n assert candidate(s = \"aaaaaaaaaa\",k = 2) == \"aaaaa\"\n assert candidate(s = \"qwertyqwertyqwerty\",k = 3) == \"qwerty\"\n assert candidate(s = \"xyzzzzzzzzzzzxyzzzzzzzzzzzzxyzzzzzzzzzzzz\",k = 3) == \"xyzzzzzzzzzzz\"\n assert candidate(s = \"ababababababababababababababababab\",k = 16) == \"ba\"\n assert candidate(s = \"aabbccddeeefff\",k = 2) == \"f\"\n assert candidate(s = \"abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef\",k = 6) == \"fabcde\"\n assert candidate(s = \"abcdefgabcdefgabcdefg\",k = 2) == \"gabcdef\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 10) == \"zzzz\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 25) == \"z\"\n assert candidate(s = \"aaabbbcccdddeeefffggghhhiii\",k = 4) == \"\"\n assert candidate(s = \"abcdabcdbacdb\",k = 2) == \"cdab\"\n assert candidate(s = \"xyxyxyxyxyxy\",k = 4) == \"yx\"\n assert candidate(s = \"abcabcabcabcabcabcabcabc\",k = 4) == \"abcabc\"\n assert candidate(s = \"aabaaabaaabaaabaaab\",k = 5) == \"aab\"\n assert candidate(s = \"abcdefghijklaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbcccccccccccccc\",k = 6) == \"bbb\"\n assert candidate(s = \"abcabcabcabcabc\",k = 5) == \"abc\"\n assert candidate(s = \"mmmmmmnnnnnnnnnnoooooo\",k = 5) == \"nn\"\n assert candidate(s = \"mmmmnnnnooooppppqqqqrrrrssssttttuuuuvvvvwwwwxxxxxyyyyyzzzzz\",k = 5) == \"z\"\n assert candidate(s = \"abcdabcdabcdabcdabcdabcdabcdabcd\",k = 8) == \"abcd\"\n assert candidate(s = \"zzzzzzzzzzzzz\",k = 5) == \"zz\"\n assert candidate(s = \"axbyczdxeyfzgyhz\",k = 2) == \"xyz\"\n assert candidate(s = \"aaabbbcccdddeeefff\",k = 4) == \"\"\n assert candidate(s = \"xyzxyzxyzxyzxyzxyzxyzxyzxyzxyzxyz\",k = 10) == \"zxy\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 2) == \"z\"\n assert candidate(s = \"abcdefghijabcdefghijabcdefghij\",k = 3) == \"abcdefghij\"\n assert candidate(s = \"abcdefghabcdefghabcdefgh\",k = 3) == \"abcdefgh\"\n assert candidate(s = \"zzzzyyyxxxwww\",k = 4) == \"z\"\n assert candidate(s = \"xyzxyzxyzxyzxyz\",k = 4) == \"zxy\"\n"}, "metadata": {"canonical_parameter_names": ["s", "k"], "leetcode_dataset_entry_point": "Solution().longestSubsequenceRepeatedK", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string longestSubsequenceRepeatedK(string s, int k) {", "container": "Solution", "callable": "longestSubsequenceRepeatedK", "parameters": [{"name": "s", "type": "string"}, {"name": "k", "type": "int"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2016, "task_id": "maximum-difference-between-increasing-elements", "difficulty": "Easy", "problem_description": "Given a 0-indexed integer array nums of size n, find the maximum difference between nums[i] and nums[j] (i.e., nums[j] - nums[i]), such that 0 <= i < j < n and nums[i] < nums[j].\nReturn the maximum difference. If no such i and j exists, return -1.\n \nExample 1:\n\nInput: nums = [7,1,5,4]\nOutput: 4\nExplanation:\nThe maximum difference occurs with i = 1 and j = 2, nums[j] - nums[i] = 5 - 1 = 4.\nNote that with i = 1 and j = 0, the difference nums[j] - nums[i] = 7 - 1 = 6, but i > j, so it is not valid.\n\nExample 2:\n\nInput: nums = [9,4,3,2]\nOutput: -1\nExplanation:\nThere is no i and j such that i < j and nums[i] < nums[j].\n\nExample 3:\n\nInput: nums = [1,5,2,10]\nOutput: 9\nExplanation:\nThe maximum difference occurs with i = 0 and j = 3, nums[j] - nums[i] = 10 - 1 = 9.\n\n \nConstraints:\n\nn == nums.length\n2 <= n <= 1000\n1 <= nums[i] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [9, 4, 3, 2]) == -1\n assert candidate(nums = [5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1, 2, 999999999]) == 999999998\n assert candidate(nums = [1, 100, 1, 100, 1]) == 99\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1]) == -1\n assert candidate(nums = [1, 999999999, 2, 999999998]) == 999999998\n assert candidate(nums = [10, 20, 20, 10, 30]) == 20\n assert candidate(nums = [1, 5, 2, 10]) == 9\n assert candidate(nums = [1, 1, 1, 1]) == -1\n assert candidate(nums = [1, 3, 2, 4, 3, 5]) == 4\n assert candidate(nums = [10, 1, 10, 1, 10]) == 9\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [7, 1, 5, 4]) == 4\n assert candidate(nums = [1, 3, 6, 7, 9, 14, 10]) == 13\n assert candidate(nums = [1, 2, 1, 2, 1]) == 1\n assert candidate(nums = [5, 4, 3, 2, 1, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 11]) == 1\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 8\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n assert candidate(nums = [1000000000, 999999999, 999999998, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [1000000000, 999999999, 1, 1000000000, 2, 999999998, 3, 1000000000, 4, 999999997]) == 999999999\n assert candidate(nums = [100, 100, 100, 100, 101, 100, 100, 100]) == 1\n assert candidate(nums = [2, 3, 10, 6, 4, 8, 1, 5, 7, 9]) == 8\n assert candidate(nums = [10, 1, 2, 8, 1, 5, 6, 3, 9]) == 8\n assert candidate(nums = [1000000000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 18\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997]) == 999999999\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 38\n assert candidate(nums = [3, 2, 1, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]) == 6\n assert candidate(nums = [1, 2, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 29\n assert candidate(nums = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 1\n assert candidate(nums = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10]) == 9\n assert candidate(nums = [1, 3, 2, 3, 100, 1, 2, 3, 4]) == 99\n assert candidate(nums = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 9\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 31]) == 30\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1, 2, 3, 4]) == 3\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 1\n assert candidate(nums = [2, 1, 5, 3, 4, 8, 7, 6, 9, 10, 1]) == 9\n assert candidate(nums = [8, 11, 9, 8, 10, 12]) == 4\n assert candidate(nums = [10, 9, 10, 8, 9, 7, 8, 6, 7, 5, 6, 4, 5, 3, 4, 2, 3, 1, 2]) == 1\n assert candidate(nums = [1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 9\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 150]) == 50\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 90\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1]) == 9\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 11, 12, 13, 14, 15]) == 14\n assert candidate(nums = [5, 4, 3, 2, 1, 10, 11, 12, 13]) == 12\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == -1\n assert candidate(nums = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110]) == 10\n assert candidate(nums = [999999999, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 99\n assert candidate(nums = [3, 3, 3, 1, 2, 2, 2, 5, 5, 5]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 19\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 19\n assert candidate(nums = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == -1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 12]) == 11\n assert candidate(nums = [1, 2, 3, 100, 1, 2, 3, 101, 1, 2, 3, 102, 1, 2, 3, 103, 1, 2, 3, 104]) == 103\n assert candidate(nums = [3, 3, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 8\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6]) == 5\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(nums = [1, 2, 2, 2, 2, 2, 2, 2, 2, 3]) == 2\n assert candidate(nums = [5, 1, 4, 3, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20]) == 20\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 1\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 18\n assert candidate(nums = [5, 2, 6, 1, 9, 4, 3, 7, 8]) == 8\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4]) == -1\n assert candidate(nums = [10, 20, 15, 25, 30, 5, 10, 40, 35, 45, 50]) == 45\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(nums = [1, 5, 3, 7, 9, 2, 6, 8, 4, 10]) == 9\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1]) == 90\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 10\n assert candidate(nums = [5, 3, 6, 7, 2, 5, 4, 8, 9, 1]) == 7\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 21]) == 20\n assert candidate(nums = [1, 3, 2, 4, 5, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 19\n assert candidate(nums = [5, 4, 3, 2, 1, 10]) == 9\n assert candidate(nums = [3, 3, 3, 1, 1, 1, 2, 2, 2, 5, 5, 5, 4, 4, 4]) == 4\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 9\n assert candidate(nums = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 9\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11]) == 10\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 9\n assert candidate(nums = [5, 11, 2, 14, 1, 3, 10, 6, 12, 4, 15, 8]) == 14\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996]) == -1\n assert candidate(nums = [100, 1, 101, 2, 102, 3, 103, 4, 104, 5, 105, 6, 106, 7, 107, 8, 108, 9, 109, 10]) == 108\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 19\n assert candidate(nums = [5, 1, 9, 2, 8, 3, 7, 4, 6, 10, 1, 9, 2, 8, 3, 7, 4, 6, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 4\n assert candidate(nums = [3, 2, 6, 5, 0, 3]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11]) == 10\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 14\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(nums = [50, 20, 30, 10, 40, 60, 25, 35, 55, 45, 70, 65, 80, 75, 90, 85, 100, 95]) == 90\n assert candidate(nums = [2, 3, 1, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 11\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11]) == 10\n assert candidate(nums = [1, 1000000000, 2, 999999999, 3, 999999998, 4, 999999997, 5, 999999996]) == 999999999\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 10]) == 9\n assert candidate(nums = [1, 2, 3, 4, 100, 5, 6, 7, 8, 9, 10]) == 99\n assert candidate(nums = [5, 2, 3, 1, 4, 7, 6, 8]) == 7\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 1\n assert candidate(nums = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 9\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2]) == -1\n assert candidate(nums = [100, 100, 100, 100, 101, 100, 100, 100, 100, 100]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 10\n assert candidate(nums = [10, 9, 2, 5, 3, 7, 101, 18]) == 99\n assert candidate(nums = [50, 25, 75, 100, 200, 150, 175, 225, 275, 300, 250, 325, 350]) == 325\n assert candidate(nums = [10, 20, 10, 30, 20, 40, 30, 50, 40]) == 40\n assert candidate(nums = [10, 5, 1, 7, 3, 6, 4]) == 6\n assert candidate(nums = [1000000000, 999999999, 999999998, 999999997, 999999996, 1000000001]) == 5\n assert candidate(nums = [100, 1, 101, 2, 102, 3, 103, 4, 104, 5]) == 103\n assert candidate(nums = [5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9]) == 4\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().maximumDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumDifference(vector& nums) {", "container": "Solution", "callable": "maximumDifference", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2017, "task_id": "grid-game", "difficulty": "Medium", "problem_description": "You are given a 0-indexed 2D array grid of size 2 x n, where grid[r][c] represents the number of points at position (r, c) on the matrix. Two robots are playing a game on this matrix.\nBoth robots initially start at (0, 0) and want to reach (1, n-1). Each robot may only move to the right ((r, c) to (r, c + 1)) or down ((r, c) to (r + 1, c)).\nAt the start of the game, the first robot moves from (0, 0) to (1, n-1), collecting all the points from the cells on its path. For all cells (r, c) traversed on the path, grid[r][c] is set to 0. Then, the second robot moves from (0, 0) to (1, n-1), collecting the points on its path. Note that their paths may intersect with one another.\nThe first robot wants to minimize the number of points collected by the second robot. In contrast, the second robot wants to maximize the number of points it collects. If both robots play optimally, return the number of points collected by the second robot.\n \nExample 1:\n\n\nInput: grid = [[2,5,4],[1,5,1]]\nOutput: 4\nExplanation: The optimal path taken by the first robot is shown in red, and the optimal path taken by the second robot is shown in blue.\nThe cells visited by the first robot are set to 0.\nThe second robot will collect 0 + 0 + 4 + 0 = 4 points.\n\nExample 2:\n\n\nInput: grid = [[3,3,1],[8,5,2]]\nOutput: 4\nExplanation: The optimal path taken by the first robot is shown in red, and the optimal path taken by the second robot is shown in blue.\nThe cells visited by the first robot are set to 0.\nThe second robot will collect 0 + 3 + 1 + 0 = 4 points.\n\nExample 3:\n\n\nInput: grid = [[1,3,1,15],[1,3,3,1]]\nOutput: 7\nExplanation: The optimal path taken by the first robot is shown in red, and the optimal path taken by the second robot is shown in blue.\nThe cells visited by the first robot are set to 0.\nThe second robot will collect 0 + 1 + 3 + 3 + 0 = 7 points.\n\n \nConstraints:\n\ngrid.length == 2\nn == grid[r].length\n1 <= n <= 5 * 104\n1 <= grid[r][c] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 4, 3, 2, 1]]) == 9\n assert candidate(grid = [[1, 3, 1, 15], [1, 3, 3, 1]]) == 7\n assert candidate(grid = [[2, 5, 4], [1, 5, 1]]) == 4\n assert candidate(grid = [[10, 10, 10], [1, 1, 1]]) == 2\n assert candidate(grid = [[3, 3, 1], [8, 5, 2]]) == 4\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [9, 18, 27, 36, 45, 54, 63, 72, 81, 90]]) == 9\n assert candidate(grid = [[100, 200, 300, 400, 500], [500, 400, 300, 200, 100]]) == 900\n assert candidate(grid = [[100000, 100000, 100000, 100000, 100000], [1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 10, 3, 40, 5, 60, 7, 80, 9, 100], [100, 9, 80, 7, 60, 5, 40, 3, 20, 1]]) == 256\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 5\n assert candidate(grid = [[100000, 100000, 100000], [1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]]) == 19\n assert candidate(grid = [[100000, 90000, 80000, 70000, 60000, 50000], [50000, 60000, 70000, 80000, 90000, 100000]]) == 180000\n assert candidate(grid = [[23456, 12345, 67890, 45678, 34567], [76543, 89012, 12345, 67890, 54321]]) == 148135\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 84\n assert candidate(grid = [[100000, 1, 100000, 1, 100000, 1], [1, 100000, 1, 100000, 1, 100000]]) == 100002\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 9\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 155\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 15\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]]) == 7\n assert candidate(grid = [[1, 3, 5, 7, 9, 11, 13, 15, 17, 19], [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]]) == 75\n assert candidate(grid = [[5, 10, 15, 20, 25, 30, 35], [35, 30, 25, 20, 15, 10, 5]]) == 90\n assert candidate(grid = [[7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [16, 15, 14, 13, 12, 11, 10, 9, 8, 7]]) == 70\n assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10]]) == 90\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]]) == 25\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 8\n assert candidate(grid = [[5, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 5]]) == 3\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 27\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]]) == 35\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 10\n assert candidate(grid = [[100000, 99999, 99998, 99997, 99996], [1, 2, 3, 4, 5]]) == 10\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]]) == 9\n assert candidate(grid = [[99999, 99998, 99997, 99996, 99995], [1, 2, 3, 4, 5]]) == 10\n assert candidate(grid = [[1, 1, 100000], [100000, 1, 1]]) == 100000\n assert candidate(grid = [[100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1], [1, 100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000]]) == 200003\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]) == 13\n assert candidate(grid = [[100, 200, 300, 400, 500, 600, 700, 800, 900, 1000], [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100]]) == 4000\n assert candidate(grid = [[100000, 99999, 99998, 99997, 99996], [1, 2, 3, 4, 5]]) == 10\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]]) == 6\n assert candidate(grid = [[10, 20, 30, 40, 50, 60], [60, 50, 40, 30, 20, 10]]) == 150\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]]) == 13\n assert candidate(grid = [[1, 100, 1], [100, 1, 100]]) == 100\n assert candidate(grid = [[1, 100000, 1, 100000, 1], [100000, 1, 100000, 1, 100000]]) == 100001\n assert candidate(grid = [[9, 8, 7, 6, 5, 4, 3, 2, 1], [1, 2, 3, 4, 5, 6, 7, 8, 9]]) == 10\n assert candidate(grid = [[10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 89\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 40\n assert candidate(grid = [[10, 20, 30, 40, 50], [50, 40, 30, 20, 10]]) == 90\n assert candidate(grid = [[5, 4, 3, 2, 1], [1, 2, 3, 4, 5]]) == 3\n assert candidate(grid = [[100, 200, 300, 400, 500], [500, 400, 300, 200, 100]]) == 900\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25], [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 234\n assert candidate(grid = [[1, 99999, 99999, 99999, 99999], [99999, 99999, 99999, 99999, 99999]]) == 199998\n assert candidate(grid = [[5, 10, 15, 20, 25, 30], [30, 25, 20, 15, 10, 5]]) == 75\n assert candidate(grid = [[100000, 100000, 100000, 100000], [1, 1, 1, 1]]) == 3\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 40\n assert candidate(grid = [[100000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999]]) == 18\n assert candidate(grid = [[1, 2, 3, 4, 5], [5, 5, 5, 5, 5]]) == 10\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 9\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]]) == 23\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 84\n assert candidate(grid = [[1, 5, 2, 7, 3, 8, 4, 9], [9, 4, 8, 3, 7, 2, 5, 1]]) == 24\n assert candidate(grid = [[1, 1, 1, 1, 1], [2, 2, 2, 2, 2]]) == 3\n assert candidate(grid = [[100000, 100000, 100000, 100000, 100000], [100000, 100000, 100000, 100000, 100000]]) == 200000\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 8\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 950\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]]) == 9\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25], [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 234\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100000], [100000, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 100004\n assert candidate(grid = [[5000, 5000, 5000, 5000, 5000], [1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]]) == 155\n assert candidate(grid = [[100000, 100000, 100000, 100000, 100000], [1, 2, 3, 4, 5]]) == 10\n assert candidate(grid = [[5, 5, 5, 5, 5, 5, 5, 5, 5, 5], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]]) == 30\n assert candidate(grid = [[1, 10, 100, 1000, 10000], [10000, 1000, 100, 10, 1]]) == 11000\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 15\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]]) == 9\n assert candidate(grid = [[5, 10, 15, 20, 25, 30, 35, 40, 45, 50], [50, 45, 40, 35, 30, 25, 20, 15, 10, 5]]) == 200\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().gridGame", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long gridGame(vector>& grid) {", "container": "Solution", "callable": "gridGame", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2018, "task_id": "check-if-word-can-be-placed-in-crossword", "difficulty": "Medium", "problem_description": "You are given an m x n matrix board, representing the current state of a crossword puzzle. The crossword contains lowercase English letters (from solved words), ' ' to represent any empty cells, and '#' to represent any blocked cells.\nA word can be placed horizontally (left to right or right to left) or vertically (top to bottom or bottom to top) in the board if:\n\nIt does not occupy a cell containing the character '#'.\nThe cell each letter is placed in must either be ' ' (empty) or match the letter already on the board.\nThere must not be any empty cells ' ' or other lowercase letters directly left or right of the word if the word was placed horizontally.\nThere must not be any empty cells ' ' or other lowercase letters directly above or below the word if the word was placed vertically.\n\nGiven a string word, return true if word can be placed in board, or false otherwise.\n \nExample 1:\n\n\nInput: board = [[\"#\", \" \", \"#\"], [\" \", \" \", \"#\"], [\"#\", \"c\", \" \"]], word = \"abc\"\nOutput: true\nExplanation: The word \"abc\" can be placed as shown above (top to bottom).\n\nExample 2:\n\n\nInput: board = [[\" \", \"#\", \"a\"], [\" \", \"#\", \"c\"], [\" \", \"#\", \"a\"]], word = \"ac\"\nOutput: false\nExplanation: It is impossible to place the word because there will always be a space/letter above or below it.\nExample 3:\n\n\nInput: board = [[\"#\", \" \", \"#\"], [\" \", \" \", \"#\"], [\"#\", \" \", \"c\"]], word = \"ca\"\nOutput: true\nExplanation: The word \"ca\" can be placed as shown above (right to left). \n\n \nConstraints:\n\nm == board.length\nn == board[i].length\n1 <= m * n <= 2 * 105\nboard[i][j] will be ' ', '#', or a lowercase English letter.\n1 <= word.length <= max(m, n)\nword will contain only lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(board = [['#', ' ', '#'], [' ', ' ', '#'], ['#', ' ', 'c']],word = \"ca\") == True\n assert candidate(board = [['a'], ['b'], ['c'], ['d'], ['e']],word = \"abcde\") == True\n assert candidate(board = [['#', ' ', '#'], [' ', ' ', '#'], ['#', ' ', 'c']],word = \"ca\") == True\n assert candidate(board = [['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i']],word = \"ihg\") == True\n assert candidate(board = [['a', ' ', 'a'], [' ', ' ', ' '], ['a', ' ', 'a']],word = \"aba\") == True\n assert candidate(board = [['#', ' ', '#'], ['a', 'b', 'c'], ['#', ' ', '#']],word = \"cba\") == True\n assert candidate(board = [['a', 'b', 'c'], ['d', 'e', 'f'], ['g', 'h', 'i']],word = \"def\") == True\n assert candidate(board = [['a', 'b', 'c'], ['#', '#', '#'], ['g', 'h', 'i']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', ' '], ['#', 'a', '#'], [' ', ' ', ' ']],word = \"a\") == True\n assert candidate(board = [['#', '#', '#'], ['#', ' ', '#'], ['#', ' ', '#']],word = \"a\") == True\n assert candidate(board = [['#', ' ', '#'], [' ', ' ', '#'], ['#', 'c', ' ']],word = \"abc\") == True\n assert candidate(board = [[' ', '#', 'a'], [' ', '#', 'c'], [' ', '#', 'a']],word = \"ac\") == False\n assert candidate(board = [[' ', '#', 'a'], [' ', '#', 'c'], [' ', '#', 'a']],word = \"ac\") == False\n assert candidate(board = [[' ', ' ', ' ', '#'], [' ', ' ', ' ', '#'], [' ', ' ', ' ', '#']],word = \"test\") == False\n assert candidate(board = [['#', '#', '#'], [' ', ' ', ' '], ['#', '#', '#']],word = \"ab\") == False\n assert candidate(board = [['#', ' ', '#'], [' ', ' ', '#'], ['#', 'c', ' ']],word = \"abc\") == True\n assert candidate(board = [['#', '#', '#', '#', '#'], ['#', ' ', ' ', ' ', '#'], ['#', ' ', '#', ' ', '#'], ['#', ' ', ' ', ' ', '#'], ['#', '#', '#', '#', '#']],word = \"test\") == False\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"python\") == False\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ']],word = \"abcd\") == True\n assert candidate(board = [['#', '#', 'a', '#', '#'], ['#', '#', 'b', '#', '#'], ['#', '#', 'c', '#', '#'], ['#', '#', 'd', '#', '#'], ['#', '#', '#', '#', '#']],word = \"abcd\") == True\n assert candidate(board = [[' ', ' ', '#', '#', '#', ' '], [' ', ' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ', ' '], [' ', ' ', '#', '#', '#', ' ']],word = \"test\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['a', 'b', 'c', 'd', 'e'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"abcde\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#', '#']],word = \"abcdefg\") == False\n assert candidate(board = [['#', ' ', ' ', ' ', '#'], [' ', 'a', ' ', 'b', ' '], ['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#']],word = \"abc\") == True\n assert candidate(board = [['#', 'a', '#'], ['b', ' ', 'c'], ['#', 'd', '#'], [' ', 'e', ' ']],word = \"abcde\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"find\") == False\n assert candidate(board = [[' ', '#', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', ' ', ' ', '#']],word = \"abcde\") == True\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], ['#', ' ', ' ', '#'], ['#', '#', '#', '#']],word = \"a\") == False\n assert candidate(board = [['a', 'b', 'c'], ['#', '#', '#'], [' ', ' ', ' '], [' ', ' ', ' '], ['#', 'a', 'b']],word = \"abc\") == True\n assert candidate(board = [[' ', '#', ' ', ' ', '#', ' '], ['#', ' ', '#', ' ', '#', '#'], [' ', '#', ' ', '#', ' ', ' '], ['#', '#', ' ', '#', ' ', '#']],word = \"hello\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' ']],word = \"ghijkl\") == True\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', 'a', ' ', ' '], ['#', ' ', 'b', ' '], ['#', '#', '#', '#']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', ' ', ' '], ['#', 'a', ' ', ' '], ['#', ' ', 'b', ' '], ['#', ' ', ' ', 'c']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"hello\") == True\n assert candidate(board = [['#', ' ', '#'], ['a', 'b', 'c'], [' ', ' ', ' '], ['d', 'e', 'f'], ['#', ' ', '#']],word = \"abcdef\") == False\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"abc\") == False\n assert candidate(board = [['#', ' ', '#', ' '], [' ', ' ', ' ', ' '], [' ', ' ', '#', ' '], [' ', ' ', ' ', ' ']],word = \"ab\") == True\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', 'a', ' ', ' '], [' ', ' ', 'b', ' '], ['#', ' ', ' ', 'c']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], ['#', ' ', ' ', 'a'], ['#', '#', 'b', 'c']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], ['a', 'b', 'c', 'd', 'e'], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"abcde\") == True\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], [' ', '#', '#', ' '], [' ', ' ', ' ', ' ']],word = \"ab\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['c', 'b', 'a', ' ', ' '], [' ', 'd', 'e', 'f', ' '], ['#', ' ', '#', ' ', '#']],word = \"abcdef\") == False\n assert candidate(board = [[' ', '#', ' ', '#', ' '], ['#', 'a', '#', ' ', '#'], ['#', '#', '#', ' ', '#'], ['#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', ' ']],word = \"abc\") == False\n assert candidate(board = [['#', '#', '#'], ['#', ' ', '#'], ['#', ' ', '#'], ['#', '#', '#']],word = \"ab\") == True\n assert candidate(board = [['#', '#', '#', '#', '#', '#', '#'], ['#', ' ', ' ', ' ', ' ', ' ', '#'], ['#', ' ', '#', '#', '#', ' ', '#'], ['#', ' ', '#', 'a', '#', ' ', '#'], ['#', ' ', '#', 'b', '#', ' ', '#'], ['#', ' ', '#', 'c', '#', ' ', '#'], ['#', '#', '#', '#', '#', '#', '#']],word = \"abc\") == True\n assert candidate(board = [['#', 'a', '#'], ['#', '#', '#'], ['#', 'a', '#']],word = \"aa\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], ['#', 'a', '#', 'c', '#'], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"ac\") == True\n assert candidate(board = [[' ', ' ', ' ', ' '], ['#', 'a', 'b', '#'], [' ', ' ', ' ', ' '], ['#', 'd', 'c', '#']],word = \"abcd\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', 'a', ' ', 'b', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"ab\") == False\n assert candidate(board = [['#', ' ', ' ', ' ', ' ', ' ', '#'], ['#', '#', ' ', '#', '#', ' ', '#'], ['#', ' ', 'a', ' ', ' ', ' ', '#'], ['#', '#', ' ', 'b', '#', ' ', '#'], ['#', ' ', ' ', ' ', ' ', ' ', '#']],word = \"abc\") == True\n assert candidate(board = [[' ', '#', ' ', '#', ' '], [' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' '], [' ', '#', ' ', '#', ' ']],word = \"test\") == False\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['e', 'd', 'c', 'b', 'a'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"abcde\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], ['#', 'a', 'b', 'c', '#'], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"cba\") == True\n assert candidate(board = [['#', '#', '#', '#', '#'], ['#', ' ', ' ', ' ', '#'], ['#', ' ', '#', ' ', '#'], ['#', ' ', ' ', ' ', '#'], ['#', '#', '#', '#', '#']],word = \"abc\") == True\n assert candidate(board = [['#', '#', '#', '#', '#'], ['#', 'a', ' ', ' ', '#'], ['#', ' ', ' ', 'b', '#'], ['#', ' ', 'c', ' ', '#'], ['#', '#', '#', '#', '#']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', '#', ' ', ' '], ['#', ' ', 'a', ' ', '#'], [' ', ' ', '#', ' ', ' '], ['#', ' ', 'c', ' ', '#'], [' ', ' ', '#', ' ', ' ']],word = \"play\") == False\n assert candidate(board = [[' ', '#', '#', '#', ' '], ['#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', '#'], ['#', '#', '#', '#', ' ']],word = \"abc\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' ']],word = \"mnopqr\") == True\n assert candidate(board = [['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' ']],word = \"abcdef\") == True\n assert candidate(board = [['#', '#', '#', '#'], ['#', ' ', ' ', '#'], ['#', ' ', ' ', '#'], ['#', '#', '#', '#']],word = \"word\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' ', ' '], ['#', 'a', ' ', ' ', 'b', '#'], ['#', ' ', ' ', ' ', ' ', '#'], ['#', 'c', ' ', ' ', 'd', '#'], ['#', ' ', ' ', ' ', ' ', '#'], ['#', '#', '#', '#', '#', '#']],word = \"abcd\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' ']],word = \"abc\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"abcdefghi\") == False\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', 'a', ' ', ' '], [' ', ' ', 'b', ' '], [' ', ' ', ' ', 'c']],word = \"abc\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"python\") == False\n assert candidate(board = [['#', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ']],word = \"world\") == True\n assert candidate(board = [['#', ' ', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', '#']],word = \"abcdef\") == False\n assert candidate(board = [['#', ' ', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', 'a', ' ', 'a', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', '#']],word = \"banana\") == False\n assert candidate(board = [['#', ' ', '#', ' ', '#', ' ', '#'], ['#', 'a', '#', 'b', '#', 'c', '#'], ['#', ' ', '#', ' ', '#', ' ', '#'], ['#', 'd', '#', 'e', '#', 'f', '#'], ['#', ' ', '#', ' ', '#', ' ', '#']],word = \"abcdef\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', '#', 'a', '#', '#'], ['#', '#', 'b', '#', '#'], ['#', '#', 'c', '#', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"abc\") == False\n assert candidate(board = [[' ', '#', ' ', ' ', ' '], [' ', ' ', ' ', '#', ' '], [' ', '#', ' ', ' ', ' '], [' ', ' ', ' ', '#', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"abcde\") == True\n assert candidate(board = [[' ', ' ', '#', ' ', ' '], ['#', 'a', '#', ' ', '#'], [' ', ' ', '#', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"abc\") == False\n assert candidate(board = [['a', 'b', ' ', 'd', 'e'], ['#', '#', 'c', '#', '#'], ['e', 'd', ' ', 'b', 'a'], ['#', '#', 'c', '#', '#'], ['a', 'b', ' ', 'd', 'e']],word = \"abcde\") == True\n assert candidate(board = [[' ', '#', '#', '#', ' '], ['#', 'a', '#', 'b', '#'], ['#', '#', '#', '#', '#'], ['#', 'c', '#', 'd', '#'], [' ', '#', '#', '#', ' ']],word = \"abcd\") == False\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], ['#', 'a', '#', ' '], ['#', 'b', '#', ' '], ['#', 'c', '#', ' ']],word = \"abc\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', ' ', ' ', ' ']],word = \"abcdef\") == True\n assert candidate(board = [['#', 'a', 'b', 'c', '#'], [' ', ' ', ' ', ' ', ' '], ['#', 'd', 'e', 'f', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"abcdef\") == False\n assert candidate(board = [['#', 'a', '#', 'b', '#'], [' ', ' ', ' ', ' ', ' '], ['#', 'c', '#', 'd', '#'], [' ', ' ', ' ', ' ', ' '], ['#', 'e', '#', 'f', '#']],word = \"abcdef\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"abcd\") == False\n assert candidate(board = [['#', ' ', ' ', ' ', '#'], ['#', '#', ' ', '#', '#'], ['#', ' ', ' ', ' ', '#'], ['#', '#', ' ', '#', '#'], ['#', ' ', ' ', ' ', '#']],word = \"game\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', '#', ' ', '#'], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', 'k', ' ', ' ', 'l', ' '], ['#', ' ', ' ', ' ', ' ', ' ', 'm'], ['#', '#', '#', '#', '#', '#', '#']],word = \"klm\") == True\n assert candidate(board = [['#', ' ', '#'], [' ', 'a', ' '], ['#', ' ', '#'], [' ', 'b', ' '], ['#', ' ', '#']],word = \"aba\") == True\n assert candidate(board = [['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#']],word = \"a\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' ', ' '], ['#', 'a', '#', 'b', '#', 'c'], [' ', ' ', ' ', ' ', ' ', ' '], ['#', 'd', '#', 'e', '#', 'f'], [' ', ' ', ' ', ' ', ' ', ' ']],word = \"abcdef\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"world\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' ', ' ', '#'], ['#', ' ', ' ', ' ', ' ', ' ', 'j'], ['#', ' ', '#', ' ', '#', ' ', 'i'], ['#', ' ', ' ', ' ', ' ', ' ', 'h'], ['#', ' ', '#', ' ', '#', ' ', 'g'], ['#', ' ', ' ', ' ', ' ', ' ', 'f'], ['#', '#', '#', '#', '#', '#', '#']],word = \"ghij\") == False\n assert candidate(board = [['#', ' ', '#'], [' ', ' ', ' '], [' ', ' ', '#'], [' ', '#', ' ']],word = \"abc\") == True\n assert candidate(board = [['#', ' ', ' ', ' ', '#'], [' ', ' ', '#', ' ', ' '], [' ', 'a', '#', 'b', ' '], ['#', ' ', '#', ' ', '#']],word = \"abcd\") == True\n assert candidate(board = [['#', '#', '#', '#', '#'], ['#', ' ', ' ', ' ', '#'], ['#', ' ', 'a', ' ', '#'], ['#', ' ', ' ', ' ', '#'], ['#', '#', '#', '#', '#']],word = \"aaa\") == True\n assert candidate(board = [['#', ' ', ' ', ' ', ' ', ' ', '#'], [' ', 'g', ' ', 'h', ' ', 'i', ' '], ['#', ' ', '#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#', '#', '#']],word = \"ghji\") == True\n assert candidate(board = [['#', '#', '#', '#'], ['#', ' ', ' ', ' '], ['#', ' ', '#', ' '], ['#', ' ', ' ', ' '], ['#', '#', '#', '#']],word = \"code\") == False\n assert candidate(board = [['#', 'a', 'b', 'c'], ['#', 'd', 'e', 'f'], ['#', 'g', 'h', 'i'], ['#', 'j', 'k', 'l']],word = \"mnop\") == False\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', '#', ' ', ' '], ['#', ' ', ' ', ' ', '#'], [' ', ' ', '#', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"abcd\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', ' '], ['#', ' ', 'a', ' ', ' '], ['#', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', ' ']],word = \"abc\") == False\n assert candidate(board = [['#', '#', '#', '#', '#'], ['#', 'a', '#', 'b', '#'], ['#', '#', '#', '#', '#'], ['#', 'c', '#', 'd', '#'], ['#', '#', '#', '#', '#']],word = \"abcd\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', '#', ' ', '#'], ['#', ' ', ' ', ' ', ' ', ' ', ' '], ['#', ' ', 'n', ' ', ' ', 'o', ' '], ['#', ' ', ' ', ' ', ' ', ' ', 'p'], ['#', '#', '#', '#', '#', '#', '#']],word = \"pon\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"abc\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' '], ['#', 'a', 'b', 'c', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"abc\") == True\n assert candidate(board = [['#', ' ', ' ', ' ', ' ', ' ', '#'], ['#', '#', ' ', '#', '#', ' ', '#'], ['#', ' ', ' ', ' ', ' ', ' ', '#'], ['#', '#', ' ', '#', '#', ' ', '#'], ['#', ' ', ' ', ' ', ' ', ' ', '#']],word = \"abcdefgh\") == False\n assert candidate(board = [[' ', ' ', ' ', '#'], [' ', ' ', ' ', '#'], [' ', ' ', ' ', '#'], [' ', ' ', ' ', '#'], ['a', 'b', 'c', 'd']],word = \"abcd\") == True\n assert candidate(board = [['a', ' ', 'c'], ['b', ' ', 'd'], [' ', ' ', ' ']],word = \"abcd\") == False\n assert candidate(board = [[' ', ' ', '#', ' ', ' '], ['#', ' ', '#', ' ', '#'], [' ', ' ', '#', ' ', ' '], ['#', ' ', '#', ' ', '#'], [' ', ' ', '#', ' ', ' '], ['#', ' ', '#', ' ', '#'], [' ', ' ', '#', ' ', ' ']],word = \"abacaba\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#', ' ', '#'], [' ', 'a', ' ', 'b', ' ', 'c', ' '], ['#', ' ', '#', ' ', '#', ' ', '#'], [' ', 'd', ' ', 'e', ' ', 'f', ' ']],word = \"abcdef\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', '#', 'a', '#', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', 'c', '#', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"race\") == False\n assert candidate(board = [['#', ' ', ' ', '#'], [' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], ['#', ' ', ' ', '#']],word = \"word\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#', ' ', '#'], ['#', 'g', '#', 'h', '#', 'i', '#'], ['#', ' ', '#', ' ', '#', ' ', '#'], ['#', 'j', '#', 'k', '#', 'l', '#'], ['#', ' ', '#', ' ', '#', ' ', '#']],word = \"ghijkl\") == False\n assert candidate(board = [['#', ' ', ' ', ' ', '#'], ['#', ' ', ' ', ' ', '#'], ['#', ' ', ' ', ' ', '#'], ['#', ' ', ' ', ' ', '#'], ['#', ' ', ' ', ' ', '#']],word = \"word\") == False\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], [' ', '#', ' ', ' '], [' ', ' ', ' ', ' ']],word = \"a\") == True\n assert candidate(board = [['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#']],word = \"abcde\") == True\n assert candidate(board = [[' ', ' ', ' ', '#'], ['#', 'b', 'c', '#'], ['#', ' ', ' ', '#'], ['#', 'd', ' ', 'e']],word = \"bcde\") == True\n assert candidate(board = [['#', '#', '#', '#', '#'], ['#', ' ', ' ', ' ', '#'], ['#', ' ', ' ', ' ', '#'], ['#', ' ', ' ', ' ', '#'], ['#', '#', '#', '#', '#']],word = \"hello\") == False\n assert candidate(board = [['a', 'b', 'c', 'd', 'e'], ['#', '#', '#', '#', '#'], ['e', 'd', 'c', 'b', 'a'], ['#', '#', '#', '#', '#'], ['a', 'b', 'c', 'd', 'e']],word = \"abcde\") == True\n assert candidate(board = [['#', '#', '#'], ['a', ' ', 'a'], ['#', ' ', '#'], ['b', ' ', 'b'], ['#', '#', '#']],word = \"aba\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', '#', ' ', ' '], ['#', ' ', ' ', ' ', '#'], [' ', ' ', '#', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"java\") == False\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', 'a', ' ', 'a', ' '], ['#', ' ', '#', ' ', '#'], [' ', 'b', ' ', 'b', ' '], ['#', ' ', '#', ' ', '#']],word = \"abba\") == False\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', 'a', 'b', 'c', ' '], ['#', ' ', '#', ' ', '#']],word = \"abc\") == False\n assert candidate(board = [['#', '#', '#', '#', '#', '#'], ['#', ' ', ' ', ' ', ' ', '#'], ['#', ' ', 'a', 'b', ' ', '#'], ['#', ' ', ' ', ' ', ' ', '#'], ['#', '#', '#', '#', '#', '#']],word = \"ab\") == False\n assert candidate(board = [[' ', ' ', '#', ' ', ' '], [' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' '], [' ', ' ', '#', ' ', ' ']],word = \"hello\") == True\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', '#'], ['#', ' ', 'a', ' ', '#'], ['#', ' ', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"a\") == True\n assert candidate(board = [['a', ' ', ' ', '#'], [' ', 'b', ' ', '#'], [' ', ' ', 'c', ' '], ['#', '#', '#', '#']],word = \"abc\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', ' ', ' ', '#'], [' ', ' ', ' ', ' ', ' '], ['#', ' ', '#', ' ', '#']],word = \"car\") == True\n assert candidate(board = [['#', '#', '#'], ['#', '#', '#'], ['#', '#', '#']],word = \"a\") == False\n assert candidate(board = [['a', 'b', 'c'], ['d', '#', 'e'], ['f', 'g', 'h'], ['i', 'j', 'k']],word = \"def\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], [' ', '#', 'a', '#', ' '], [' ', '#', ' ', '#', ' '], [' ', '#', 'b', '#', ' '], [' ', ' ', ' ', ' ', ' ']],word = \"ba\") == False\n assert candidate(board = [['#', ' ', '#'], ['a', ' ', 'b'], ['#', ' ', '#'], ['c', ' ', 'd'], ['#', ' ', '#']],word = \"abcd\") == False\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', '#', '#', ' '], [' ', '#', '#', ' '], [' ', ' ', ' ', ' ']],word = \"abcd\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', '#', ' ', '#'], ['#', ' ', '#', ' ', '#', ' ', '#']],word = \"abc\") == False\n assert candidate(board = [['#', ' ', '#'], ['f', 'e', 'd'], [' ', ' ', ' '], ['c', 'b', 'a'], ['#', ' ', '#']],word = \"abcdef\") == False\n assert candidate(board = [[' ', '#', ' ', '#', ' '], ['#', 'a', '#', 'c', '#'], [' ', '#', ' ', '#', ' '], ['#', ' ', '#', 'a', '#']],word = \"ca\") == False\n assert candidate(board = [[' ', ' ', ' ', ' '], [' ', ' ', ' ', ' '], ['#', 'a', 'b', 'c'], [' ', ' ', ' ', ' ']],word = \"abc\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', '#'], ['#', ' ', '#', ' ', '#'], [' ', ' ', ' ', ' ', '#'], ['#', ' ', '#', ' ', '#']],word = \"abcde\") == True\n assert candidate(board = [['#', ' ', '#', ' ', '#'], [' ', 'c', 'b', 'a', ' '], ['#', ' ', '#', ' ', '#']],word = \"abc\") == False\n assert candidate(board = [[' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' '], ['#', '#', '#', '#', '#'], [' ', ' ', ' ', ' ', ' ']],word = \"cross\") == True\n"}, "metadata": {"canonical_parameter_names": ["board", "word"], "leetcode_dataset_entry_point": "Solution().placeWordInCrossword", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool placeWordInCrossword(vector>& board, string word) {", "container": "Solution", "callable": "placeWordInCrossword", "parameters": [{"name": "board", "type": "vector>&"}, {"name": "word", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2019, "task_id": "the-score-of-students-solving-math-expression", "difficulty": "Hard", "problem_description": "You are given a string s that contains digits 0-9, addition symbols '+', and multiplication symbols '*' only, representing a valid math expression of single digit numbers (e.g., 3+5*2). This expression was given to n elementary school students. The students were instructed to get the answer of the expression by following this order of operations:\n\nCompute multiplication, reading from left to right; Then,\nCompute addition, reading from left to right.\n\nYou are given an integer array answers of length n, which are the submitted answers of the students in no particular order. You are asked to grade the answers, by following these rules:\n\nIf an answer equals the correct answer of the expression, this student will be rewarded 5 points;\nOtherwise, if the answer could be interpreted as if the student applied the operators in the wrong order but had correct arithmetic, this student will be rewarded 2 points;\nOtherwise, this student will be rewarded 0 points.\n\nReturn the sum of the points of the students.\n \nExample 1:\n\n\nInput: s = \"7+3*1*2\", answers = [20,13,42]\nOutput: 7\nExplanation: As illustrated above, the correct answer of the expression is 13, therefore one student is rewarded 5 points: [20,13,42]\nA student might have applied the operators in this wrong order: ((7+3)*1)*2 = 20. Therefore one student is rewarded 2 points: [20,13,42]\nThe points for the students are: [2,5,0]. The sum of the points is 2+5+0=7.\n\nExample 2:\n\nInput: s = \"3+5*2\", answers = [13,0,10,13,13,16,16]\nOutput: 19\nExplanation: The correct answer of the expression is 13, therefore three students are rewarded 5 points each: [13,0,10,13,13,16,16]\nA student might have applied the operators in this wrong order: ((3+5)*2 = 16. Therefore two students are rewarded 2 points: [13,0,10,13,13,16,16]\nThe points for the students are: [5,0,0,5,5,2,2]. The sum of the points is 5+0+0+5+5+2+2=19.\n\nExample 3:\n\nInput: s = \"6+0*1\", answers = [12,9,6,4,8,6]\nOutput: 10\nExplanation: The correct answer of the expression is 6.\nIf a student had incorrectly done (6+0)*1, the answer would also be 6.\nBy the rules of grading, the students will still be rewarded 5 points (as they got the correct answer), not 2 points.\nThe points for the students are: [0,0,5,0,0,5]. The sum of the points is 10.\n\n \nConstraints:\n\n3 <= s.length <= 31\ns represents a valid expression that contains only digits 0-9, '+', and '*' only.\nAll the integer operands in the expression are in the inclusive range [0, 9].\n1 <= The count of all operators ('+' and '*') in the math expression <= 15\nTest data are generated such that the correct answer of the expression is in the range of [0, 1000].\nn == answers.length\n1 <= n <= 104\n0 <= answers[i] <= 1000\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"3+5*2\",answers = [13, 0, 10, 13, 13, 16, 16]) == 19\n assert candidate(s = \"1+2*3+4*5\",answers = [14, 23, 13, 47, 23, 53]) == 2\n assert candidate(s = \"7+3*1*2\",answers = [20, 13, 42]) == 7\n assert candidate(s = \"5*4+3+2\",answers = [27, 20, 17, 25, 20, 30]) == 5\n assert candidate(s = \"5*3+2*2\",answers = [19, 17, 15, 13, 21]) == 5\n assert candidate(s = \"9*7+3*8\",answers = [78, 108, 70, 63, 136, 54, 110, 39, 103, 97]) == 0\n assert candidate(s = \"1+2*3+4\",answers = [11, 13, 15, 9]) == 9\n assert candidate(s = \"6+0*1\",answers = [12, 9, 6, 4, 8, 6]) == 10\n assert candidate(s = \"1+2*3+4\",answers = [23, 18, 21, 9, 10, 17, 14, 22, 20, 15]) == 4\n assert candidate(s = \"9+8*7+6*5+4*3+2*1\",answers = [268, 280, 292, 304, 316, 328, 340, 352, 364, 376]) == 0\n assert candidate(s = \"5+6*2+7*3+8*1\",answers = [63, 104, 80, 77, 63, 120]) == 2\n assert candidate(s = \"1*5+2*7+3*6+4\",answers = [56, 50, 47, 53, 58, 45, 51, 46, 49, 52]) == 2\n assert candidate(s = \"2*9+5*6*7+8\",answers = [226, 488, 628, 624, 226, 508]) == 0\n assert candidate(s = \"4*6+3*2+5*1+7*8+9*0\",answers = [74, 76, 78, 80, 82, 84, 86, 88, 90, 92]) == 2\n assert candidate(s = \"7+6*5+4*3+2*1\",answers = [181, 175, 169, 163, 157, 151, 145, 139, 133, 127]) == 4\n assert candidate(s = \"1*2*3*4*5+6\",answers = [126, 12, 36, 24, 126, 126]) == 15\n assert candidate(s = \"9*8+7*6+5*4\",answers = [203, 230, 247, 274, 263, 290, 307, 334, 343, 370]) == 0\n assert candidate(s = \"1+2*3+4*5+6\",answers = [71, 51, 83, 47, 79, 53, 77, 67, 89, 57, 59, 73, 41, 87, 85, 61, 65, 75]) == 20\n assert candidate(s = \"9+8*2*4+1\",answers = [153, 73, 161, 177, 145, 153]) == 4\n assert candidate(s = \"8*7+9*6+4\",answers = [158, 202, 156, 134, 164, 148, 162, 174]) == 0\n assert candidate(s = \"9+7*8+5*4\",answers = [155, 143, 139, 147, 135, 149, 153, 151, 157]) == 0\n assert candidate(s = \"7*3+1*2*4+6*5\",answers = [62, 122, 86, 74, 62, 86]) == 2\n assert candidate(s = \"1+2+3+4+5+6+7+8+9\",answers = [45, 44, 46, 43, 47, 42, 48, 41, 49]) == 5\n assert candidate(s = \"5*5*5+4*4*4+3*3*3+2*2*2+1*1*1\",answers = [657, 681, 679, 678, 680, 677, 676, 675, 674, 673, 672, 671, 670, 669, 668, 667, 666, 665, 664, 663]) == 14\n assert candidate(s = \"1*2*3+4*5+6*7+8*9\",answers = [204, 205, 203, 206, 202, 207, 201]) == 2\n assert candidate(s = \"8*9+7*6+5*4+3*2\",answers = [167, 173, 179, 185, 191, 197, 203, 209, 215, 221]) == 0\n assert candidate(s = \"3+8*5*2+7+6*4\",answers = [173, 185, 197, 209, 221, 233, 245, 257, 269, 281]) == 0\n assert candidate(s = \"5*6+7*2+8*1+9\",answers = [104, 100, 111, 110, 115, 120, 108, 116, 106, 118]) == 0\n assert candidate(s = \"2*3+4*5+6\",answers = [30, 46, 28, 52, 34, 38, 40, 42, 44, 50]) == 4\n assert candidate(s = \"3*4+2*5+1*6+8\",answers = [58, 54, 59, 65, 62, 68, 63, 66, 57, 60]) == 2\n assert candidate(s = \"5+9*3+8*2\",answers = [89, 71, 106, 58, 95, 125, 86, 92, 91]) == 2\n assert candidate(s = \"8*7+6*5+4*3+2*1\",answers = [134, 135, 133, 136, 132, 137, 131]) == 0\n assert candidate(s = \"1*2*3*4*5+6+7+8+9\",answers = [120, 150, 315, 369, 225, 252, 360, 270, 288]) == 7\n assert candidate(s = \"6+3*5*2+9*1\",answers = [48, 39, 69, 102, 57, 78]) == 0\n assert candidate(s = \"4*3+2*8+1*7+6\",answers = [63, 59, 66, 71, 60, 69, 64, 73, 68, 61]) == 0\n assert candidate(s = \"2*9+8*7+6*5+4*3\",answers = [192, 172, 162, 152, 187, 202, 207, 182, 197, 177, 167, 157, 184, 169, 159, 179, 199, 174, 189]) == 4\n assert candidate(s = \"2*1+1*2+3*2+2*3+4*3+3*4+5*4+4*5+6*5+5*6\",answers = [194, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214]) == 22\n assert candidate(s = \"1*2+3*4+5*6+7*8+9\",answers = [159, 173, 187, 201, 215, 229, 243, 257, 271, 285]) == 4\n assert candidate(s = \"6+5*4+3*2+1\",answers = [55, 51, 47, 43, 39, 35, 31, 27, 23, 19]) == 4\n assert candidate(s = \"9*8*7*6*5+4*3+2*1\",answers = [151230, 151228, 151229, 151231, 151232]) == 0\n assert candidate(s = \"9+1*8+2*3+7*4\",answers = [77, 81, 90, 83, 94, 100, 88, 97, 91, 105]) == 2\n assert candidate(s = \"9*8+7*6+5*4+3*2+1*0\",answers = [168, 172, 176, 180, 184, 188, 192, 196, 200, 204]) == 2\n assert candidate(s = \"2+3*4+5*6+7\",answers = [157, 172, 187, 202, 217, 232, 247, 262, 277, 292]) == 6\n assert candidate(s = \"9*0+8*1+7*2\",answers = [23, 15, 16, 8, 3, 17, 24, 22, 18, 9]) == 5\n assert candidate(s = \"1*2+3*4+5*6+7*8+9*0\",answers = [120, 93, 115, 132, 108, 114, 102, 130, 128, 124, 123, 125, 126, 127, 129, 121, 122, 131, 133, 134]) == 2\n assert candidate(s = \"1+1*1+1*1+1*1+1*1+1*1+1*1+1*1\",answers = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 10, 11, 12, 13, 14, 15, 16, 17, 18]) == 25\n assert candidate(s = \"9*8+7*6+5*4+3*2+1\",answers = [383, 410, 437, 464, 491, 518, 545, 572, 599, 626]) == 4\n assert candidate(s = \"3*3+2*2+1*1\",answers = [15, 12, 13, 14, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 7\n assert candidate(s = \"7*1+6*2+5*3\",answers = [47, 37, 41, 43, 49, 53, 55, 57, 61, 63]) == 2\n assert candidate(s = \"4*1*3+5*2\",answers = [22, 14, 16, 17, 18, 19, 20, 21, 23]) == 5\n assert candidate(s = \"9+8*7+6*5+4*3+2*1\",answers = [383, 357, 347, 358, 356, 365, 359, 348, 350, 351, 349, 352, 353, 354, 355, 346, 345, 364, 366, 367]) == 2\n assert candidate(s = \"8*2+3*9+4*1+5\",answers = [69, 76, 108, 98, 63, 110, 95, 80, 73, 83]) == 0\n assert candidate(s = \"8+9*2+3*4*5+6\",answers = [222, 185, 223, 197, 196, 231, 229, 226, 220, 225, 221, 228, 227, 219, 218, 217, 230, 232, 233, 234]) == 2\n assert candidate(s = \"9*9+8*8+7*7+6*6\",answers = [320, 311, 314, 317, 323, 332, 335, 338, 341, 347, 344, 350, 353, 356, 359, 365, 368, 371, 374, 380, 383, 386, 389, 395, 392, 398]) == 0\n assert candidate(s = \"8*9+7*6+5*4+3*2+1\",answers = [163, 177, 181, 185, 189, 193, 197, 201, 205, 209]) == 4\n assert candidate(s = \"9*2+1*6+4*5+8*3\",answers = [124, 122, 121, 126, 125, 123, 127, 120, 128, 119]) == 2\n assert candidate(s = \"2+3*4+5*6\",answers = [106, 110, 74, 86, 62, 140, 106, 128]) == 0\n assert candidate(s = \"9*3+8*2+7*1\",answers = [55, 63, 95, 100, 111, 120, 123, 115, 116, 119, 102, 87, 90, 83, 93]) == 0\n assert candidate(s = \"1*9+8*2+3*7+5\",answers = [85, 100, 80, 88, 93, 95, 91, 107, 105, 98]) == 0\n assert candidate(s = \"1*2+3*4+5*6\",answers = [101, 39, 45, 81, 29, 143, 51, 17, 135, 65]) == 0\n assert candidate(s = \"6*4+3*2+1*5+7\",answers = [45, 43, 47, 52, 46, 44, 48, 50, 49, 51]) == 2\n assert candidate(s = \"2*3+4*5+6*7+8*9+0\",answers = [234, 248, 262, 276, 290, 304, 318, 332, 346, 360]) == 0\n assert candidate(s = \"2+3*4+5*6+7\",answers = [107, 110, 113, 104, 116, 109, 115, 108, 111, 112]) == 2\n assert candidate(s = \"8*7+4*2+1\",answers = [65, 100, 57, 60, 93, 120, 81, 65, 96, 104]) == 10\n assert candidate(s = \"2*3+5*6+7\",answers = [41, 101, 38, 47, 110, 83, 37, 53, 61, 56]) == 2\n assert candidate(s = \"9*8+7*6+5*4+3*2+1\",answers = [234, 197, 207, 198, 209, 205, 214, 218, 216, 215, 213, 212, 210, 211, 208, 206, 204, 203, 202, 201]) == 2\n assert candidate(s = \"5*5+4*4+3*3+2*2\",answers = [105, 85, 135, 90, 110, 100, 120, 115, 130, 95, 101, 125, 80, 91, 87, 83, 89]) == 6\n assert candidate(s = \"1*3+2*4+5*6+7*8\",answers = [109, 113, 137, 141, 145, 149, 153, 161, 165, 169]) == 2\n assert candidate(s = \"3*6+2*7+8*9\",answers = [134, 132, 136, 130, 128, 138, 140, 126, 142]) == 2\n assert candidate(s = \"1*2+3*4+5*6+7*8\",answers = [497, 524, 551, 578, 605, 632, 659, 686, 713, 740]) == 2\n assert candidate(s = \"1+2+3+4+5+6+7+8+9+0\",answers = [45, 46, 44, 43, 47, 48, 42]) == 5\n assert candidate(s = \"4*2+1*3+5*6+7\",answers = [51, 49, 67, 51, 67, 69]) == 0\n assert candidate(s = \"9*1+8*2+7*3+6\",answers = [92, 110, 113, 92, 113, 110]) == 0\n assert candidate(s = \"8+7*6+5*4+3*2+1*0\",answers = [177, 185, 184, 186, 183, 182, 181, 180, 179, 178, 176, 175, 174, 173, 172, 171, 170, 169, 168, 167]) == 2\n assert candidate(s = \"1*2+3*4+5*6+7*8+9*0\",answers = [88, 92, 96, 100, 104, 108, 112, 116, 120, 124]) == 7\n assert candidate(s = \"8*3+2*7+9*5+4*1\",answers = [124, 116, 127, 119, 118, 120, 121, 117, 126, 122]) == 2\n assert candidate(s = \"9*8+7*6+5*4+3*2+1*0\",answers = [162, 178, 194, 210, 226, 242, 258, 274, 290, 306]) == 4\n assert candidate(s = \"3*5+2*4+6\",answers = [33, 50, 38, 46, 40, 64, 54, 28, 58, 42]) == 0\n assert candidate(s = \"9+8*7*6*5*4*3*2*1\",answers = [362880, 51840, 29160, 120960, 60480, 90720]) == 0\n assert candidate(s = \"9+8*7+6*5+4*3+2*1+0\",answers = [389, 388, 390, 391, 387, 392, 386]) == 2\n assert candidate(s = \"1+2*3+4*5+6*7+8*9\",answers = [528, 526, 527, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545]) == 10\n assert candidate(s = \"2*3+4*5+6*7\",answers = [65, 51, 47, 45, 41, 37, 35, 31, 29, 27]) == 0\n assert candidate(s = \"5*3*6+2*8+1\",answers = [91, 100, 110, 120, 95, 93, 99, 105, 94, 101, 97, 96, 102, 98, 103, 92, 90, 104, 106, 91]) == 0\n assert candidate(s = \"3+5*6+7*2+8\",answers = [109, 119, 80, 103, 109, 119]) == 2\n assert candidate(s = \"8*3+4*2+5\",answers = [37, 70, 100, 61, 51, 41, 37]) == 12\n assert candidate(s = \"9*8*7*6*5\",answers = [151200, 134400, 141120, 147840, 120960, 130680, 127020, 133680, 123540]) == 0\n assert candidate(s = \"6*3+4*2+1+5*3\",answers = [44, 53, 49, 41, 57, 61, 56, 67, 65, 46]) == 2\n assert candidate(s = \"3*3*3*3*3+2+1\",answers = [244, 242, 243, 245, 246, 247]) == 5\n assert candidate(s = \"8*6+5*3+2*1\",answers = [56, 51, 106, 103, 83, 96, 90, 113, 78, 111, 54, 122]) == 0\n assert candidate(s = \"7*6+5*4+3*2+1*0\",answers = [62, 57, 67, 72, 69, 75, 77, 74, 71, 52, 64, 76, 78, 73, 53, 65, 70, 66, 68, 61, 56, 60, 59, 58, 55, 54, 51, 50, 49]) == 7\n assert candidate(s = \"8*3+7*2+9*4\",answers = [118, 154, 106, 94, 210, 142, 126, 130, 182, 166]) == 0\n assert candidate(s = \"5*3+2*8+9*7\",answers = [108, 131, 128, 136, 119, 131, 142, 123, 127, 131]) == 0\n assert candidate(s = \"3*8+2*6+5*9+1*7\",answers = [140, 138, 137, 142, 141, 139, 143, 136, 144, 145]) == 2\n assert candidate(s = \"1+2*3+4*5+6*7+8*9\",answers = [277, 278, 276, 275, 279, 280, 274]) == 2\n assert candidate(s = \"4*4+3*3+2*2+1*1\",answers = [31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 7\n assert candidate(s = \"9*3+8*2+7*6+5\",answers = [139, 167, 145, 151, 146, 158, 147, 148, 152, 150]) == 2\n assert candidate(s = \"7*2+3*9+1*6+5*8\",answers = [155, 148, 149, 151, 147, 152, 150, 146, 154, 153]) == 0\n assert candidate(s = \"1+2*3+4*5+6\",answers = [78, 54, 72, 86, 94, 104, 118, 126, 138, 158]) == 0\n assert candidate(s = \"3*6+2*5+4*7\",answers = [54, 59, 66, 74, 81, 83, 88, 60, 71, 78]) == 0\n assert candidate(s = \"8*7+5*6+2\",answers = [65, 106, 122, 158, 162, 232, 250, 188, 210, 202]) == 0\n assert candidate(s = \"7*6+5*3+2*4+1\",answers = [74, 78, 83, 79, 87, 81, 85, 76, 82, 86]) == 0\n assert candidate(s = \"5+4*3+2*1+0\",answers = [19, 25, 17, 15, 23, 27, 30]) == 7\n assert candidate(s = \"2+5*3*2+4\",answers = [40, 42, 38, 50, 36, 74, 68, 54, 82, 80]) == 7\n assert candidate(s = \"5*9+4*8+3*7\",answers = [102, 105, 116, 121, 135, 132, 93, 113, 143, 150]) == 0\n assert candidate(s = \"4+3*2*1+5\",answers = [21, 19, 17, 15, 13, 11, 9, 7, 5, 3]) == 7\n assert candidate(s = \"3*3+2*2+1*1\",answers = [14, 16, 12, 18, 15, 13, 17, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 19]) == 7\n assert candidate(s = \"6+7*8+9*2\",answers = [169, 137, 154, 131, 166, 152, 145, 158, 170]) == 0\n assert candidate(s = \"1*2*3*4*5\",answers = [120, 20, 60, 30, 10, 240, 15, 40, 6]) == 5\n assert candidate(s = \"5+9*8+7*6+4*3+2*1\",answers = [279, 283, 287, 291, 295, 299, 303, 307, 311, 315]) == 2\n"}, "metadata": {"canonical_parameter_names": ["s", "answers"], "leetcode_dataset_entry_point": "Solution().scoreOfStudents", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int scoreOfStudents(string s, vector& answers) {", "container": "Solution", "callable": "scoreOfStudents", "parameters": [{"name": "s", "type": "string"}, {"name": "answers", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2022, "task_id": "convert-1d-array-into-2d-array", "difficulty": "Easy", "problem_description": "You are given a 0-indexed 1-dimensional (1D) integer array original, and two integers, m and n. You are tasked with creating a 2-dimensional (2D) array with m rows and n columns using all the elements from original.\nThe elements from indices 0 to n - 1 (inclusive) of original should form the first row of the constructed 2D array, the elements from indices n to 2 * n - 1 (inclusive) should form the second row of the constructed 2D array, and so on.\nReturn an m x n 2D array constructed according to the above procedure, or an empty 2D array if it is impossible.\n \nExample 1:\n\n\nInput: original = [1,2,3,4], m = 2, n = 2\nOutput: [[1,2],[3,4]]\nExplanation: The constructed 2D array should contain 2 rows and 2 columns.\nThe first group of n=2 elements in original, [1,2], becomes the first row in the constructed 2D array.\nThe second group of n=2 elements in original, [3,4], becomes the second row in the constructed 2D array.\n\nExample 2:\n\nInput: original = [1,2,3], m = 1, n = 3\nOutput: [[1,2,3]]\nExplanation: The constructed 2D array should contain 1 row and 3 columns.\nPut all three elements in original into the first row of the constructed 2D array.\n\nExample 3:\n\nInput: original = [1,2], m = 1, n = 1\nOutput: []\nExplanation: There are 2 elements in original.\nIt is impossible to fit 2 elements in a 1x1 2D array, so return an empty 2D array.\n\n \nConstraints:\n\n1 <= original.length <= 5 * 104\n1 <= original[i] <= 105\n1 <= m, n <= 4 * 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(original = [5, 6, 7, 8, 9, 10, 11, 12],m = 4,n = 2) == [[5, 6], [7, 8], [9, 10], [11, 12]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9],m = 3,n = 3) == [[1, 2, 3], [4, 5, 6], [7, 8, 9]]\n assert candidate(original = [9, 10, 11, 12, 13, 14],m = 2,n = 3) == [[9, 10, 11], [12, 13, 14]]\n assert candidate(original = [1, 2],m = 1,n = 1) == []\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8],m = 4,n = 2) == [[1, 2], [3, 4], [5, 6], [7, 8]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],m = 3,n = 4) == [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]\n assert candidate(original = [3, 3, 3, 3, 3, 3],m = 2,n = 3) == [[3, 3, 3], [3, 3, 3]]\n assert candidate(original = [9, 8, 7, 6, 5, 4, 3, 2, 1],m = 3,n = 3) == [[9, 8, 7], [6, 5, 4], [3, 2, 1]]\n assert candidate(original = [1, 2, 3, 4, 5, 6],m = 2,n = 3) == [[1, 2, 3], [4, 5, 6]]\n assert candidate(original = [10, 20, 30, 40, 50],m = 5,n = 1) == [[10], [20], [30], [40], [50]]\n assert candidate(original = [5, 6, 7, 8, 9, 10],m = 2,n = 3) == [[5, 6, 7], [8, 9, 10]]\n assert candidate(original = [42, 43, 44, 45, 46, 47, 48, 49, 50],m = 3,n = 3) == [[42, 43, 44], [45, 46, 47], [48, 49, 50]]\n assert candidate(original = [1, 2, 3, 4],m = 2,n = 2) == [[1, 2], [3, 4]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 2,n = 5) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]]\n assert candidate(original = [25, 26, 27],m = 3,n = 1) == [[25], [26], [27]]\n assert candidate(original = [1, 2, 3],m = 1,n = 3) == [[1, 2, 3]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],m = 4,n = 4) == [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]\n assert candidate(original = [5, 6, 7, 8, 9],m = 1,n = 5) == [[5, 6, 7, 8, 9]]\n assert candidate(original = [15, 16, 17, 18, 19, 20, 21, 22, 23, 24],m = 5,n = 2) == [[15, 16], [17, 18], [19, 20], [21, 22], [23, 24]]\n assert candidate(original = [1],m = 1,n = 1) == [[1]]\n assert candidate(original = [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41],m = 3,n = 4) == [[30, 31, 32, 33], [34, 35, 36, 37], [38, 39, 40, 41]]\n assert candidate(original = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],m = 4,n = 3) == [[10, 11, 12], [13, 14, 15], [16, 17, 18], [19, 20, 21]]\n assert candidate(original = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36],m = 6,n = 6) == []\n assert candidate(original = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 7,n = 5) == []\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],m = 5,n = 6) == [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30]]\n assert candidate(original = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],m = 5,n = 2) == [[1000, 2000], [3000, 4000], [5000, 6000], [7000, 8000], [9000, 10000]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],m = 5,n = 5) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25]]\n assert candidate(original = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200],m = 3,n = 4) == [[100, 200, 300, 400], [500, 600, 700, 800], [900, 1000, 1100, 1200]]\n assert candidate(original = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],m = 10,n = 5) == [[1, 3, 5, 7, 9], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29], [31, 33, 35, 37, 39], [41, 43, 45, 47, 49], [51, 53, 55, 57, 59], [61, 63, 65, 67, 69], [71, 73, 75, 77, 79], [81, 83, 85, 87, 89], [91, 93, 95, 97, 99]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 5,n = 4) == [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20]]\n assert candidate(original = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],m = 5,n = 5) == [[1, 3, 5, 7, 9], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29], [31, 33, 35, 37, 39], [41, 43, 45, 47, 49]]\n assert candidate(original = [12345],m = 1,n = 1) == [[12345]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],m = 5,n = 8) == [[1, 2, 3, 4, 5, 6, 7, 8], [9, 10, 11, 12, 13, 14, 15, 16], [17, 18, 19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30, 31, 32], [33, 34, 35, 36, 37, 38, 39, 40]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],m = 3,n = 5) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]]\n assert candidate(original = [99, 88, 77, 66, 55, 44, 33, 22, 11],m = 3,n = 3) == [[99, 88, 77], [66, 55, 44], [33, 22, 11]]\n assert candidate(original = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 4,n = 4) == [[5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20]]\n assert candidate(original = [42],m = 1,n = 1) == [[42]]\n assert candidate(original = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195, 205, 215, 225, 235, 245, 255],m = 5,n = 5) == []\n assert candidate(original = [8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160],m = 5,n = 4) == [[8, 16, 24, 32], [40, 48, 56, 64], [72, 80, 88, 96], [104, 112, 120, 128], [136, 144, 152, 160]]\n assert candidate(original = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],m = 10,n = 5) == [[1, 3, 5, 7, 9], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29], [31, 33, 35, 37, 39], [41, 43, 45, 47, 49], [51, 53, 55, 57, 59], [61, 63, 65, 67, 69], [71, 73, 75, 77, 79], [81, 83, 85, 87, 89], [91, 93, 95, 97, 99]]\n assert candidate(original = [9, 8, 7, 6, 5, 4, 3, 2, 1],m = 3,n = 3) == [[9, 8, 7], [6, 5, 4], [3, 2, 1]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],m = 10,n = 1) == [[1], [2], [3], [4], [5], [6], [7], [8], [9], [10]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24],m = 6,n = 4) == [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20], [21, 22, 23, 24]]\n assert candidate(original = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240],m = 6,n = 4) == [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120], [130, 140, 150, 160], [170, 180, 190, 200], [210, 220, 230, 240]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60],m = 6,n = 10) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60]]\n assert candidate(original = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],m = 3,n = 5) == [[15, 14, 13, 12, 11], [10, 9, 8, 7, 6], [5, 4, 3, 2, 1]]\n assert candidate(original = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50],m = 5,n = 5) == [[2, 4, 6, 8, 10], [12, 14, 16, 18, 20], [22, 24, 26, 28, 30], [32, 34, 36, 38, 40], [42, 44, 46, 48, 50]]\n assert candidate(original = [123, 456, 789, 101112, 131415, 161718, 192021, 222324, 252627, 282930, 313233, 343536, 373839, 404142, 434445],m = 3,n = 5) == [[123, 456, 789, 101112, 131415], [161718, 192021, 222324, 252627, 282930], [313233, 343536, 373839, 404142, 434445]]\n assert candidate(original = [45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],m = 10,n = 10) == []\n assert candidate(original = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 6,n = 5) == []\n assert candidate(original = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],m = 2,n = 5) == [[1000, 2000, 3000, 4000, 5000], [6000, 7000, 8000, 9000, 10000]]\n assert candidate(original = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],m = 3,n = 4) == [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120]]\n assert candidate(original = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],m = 10,n = 10) == []\n assert candidate(original = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70],m = 5,n = 6) == [[99, 98, 97, 96, 95, 94], [93, 92, 91, 90, 89, 88], [87, 86, 85, 84, 83, 82], [81, 80, 79, 78, 77, 76], [75, 74, 73, 72, 71, 70]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],m = 7,n = 7) == []\n assert candidate(original = [5, 15, 25, 35, 45, 55, 65, 75],m = 2,n = 4) == [[5, 15, 25, 35], [45, 55, 65, 75]]\n assert candidate(original = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],m = 5,n = 3) == [[5, 10, 15], [20, 25, 30], [35, 40, 45], [50, 55, 60], [65, 70, 75]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],m = 10,n = 5) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30], [31, 32, 33, 34, 35], [36, 37, 38, 39, 40], [41, 42, 43, 44, 45], [46, 47, 48, 49, 50]]\n assert candidate(original = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],m = 10,n = 10) == []\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60],m = 6,n = 10) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60]]\n assert candidate(original = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80],m = 4,n = 4) == [[5, 10, 15, 20], [25, 30, 35, 40], [45, 50, 55, 60], [65, 70, 75, 80]]\n assert candidate(original = [1, 2, 3, 4, 5],m = 1,n = 5) == [[1, 2, 3, 4, 5]]\n assert candidate(original = [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42],m = 7,n = 3) == [[42, 42, 42], [42, 42, 42], [42, 42, 42], [42, 42, 42], [42, 42, 42], [42, 42, 42], [42, 42, 42]]\n assert candidate(original = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90],m = 6,n = 3) == [[5, 10, 15], [20, 25, 30], [35, 40, 45], [50, 55, 60], [65, 70, 75], [80, 85, 90]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40],m = 8,n = 5) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20], [21, 22, 23, 24, 25], [26, 27, 28, 29, 30], [31, 32, 33, 34, 35], [36, 37, 38, 39, 40]]\n assert candidate(original = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120],m = 6,n = 10) == [[2, 4, 6, 8, 10, 12, 14, 16, 18, 20], [22, 24, 26, 28, 30, 32, 34, 36, 38, 40], [42, 44, 46, 48, 50, 52, 54, 56, 58, 60], [62, 64, 66, 68, 70, 72, 74, 76, 78, 80], [82, 84, 86, 88, 90, 92, 94, 96, 98, 100], [102, 104, 106, 108, 110, 112, 114, 116, 118, 120]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],m = 4,n = 5) == [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]\n assert candidate(original = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],m = 4,n = 4) == [[1, 3, 5, 7], [9, 11, 13, 15], [17, 19, 21, 23], [25, 27, 29, 31]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],m = 5,n = 6) == [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24], [25, 26, 27, 28, 29, 30]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],m = 10,n = 10) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50], [51, 52, 53, 54, 55, 56, 57, 58, 59, 60], [61, 62, 63, 64, 65, 66, 67, 68, 69, 70], [71, 72, 73, 74, 75, 76, 77, 78, 79, 80], [81, 82, 83, 84, 85, 86, 87, 88, 89, 90], [91, 92, 93, 94, 95, 96, 97, 98, 99, 100]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27],m = 3,n = 9) == [[1, 2, 3, 4, 5, 6, 7, 8, 9], [10, 11, 12, 13, 14, 15, 16, 17, 18], [19, 20, 21, 22, 23, 24, 25, 26, 27]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],m = 4,n = 4) == [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]]\n assert candidate(original = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60],m = 4,n = 5) == [[3, 6, 9, 12, 15], [18, 21, 24, 27, 30], [33, 36, 39, 42, 45], [48, 51, 54, 57, 60]]\n assert candidate(original = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],m = 2,n = 5) == [[5, 10, 15, 20, 25], [30, 35, 40, 45, 50]]\n assert candidate(original = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80],m = 4,n = 5) == [[99, 98, 97, 96, 95], [94, 93, 92, 91, 90], [89, 88, 87, 86, 85], [84, 83, 82, 81, 80]]\n assert candidate(original = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400],m = 4,n = 6) == [[100, 200, 300, 400, 500, 600], [700, 800, 900, 1000, 1100, 1200], [1300, 1400, 1500, 1600, 1700, 1800], [1900, 2000, 2100, 2200, 2300, 2400]]\n assert candidate(original = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160],m = 4,n = 4) == [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120], [130, 140, 150, 160]]\n assert candidate(original = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],m = 2,n = 5) == [[1000, 2000, 3000, 4000, 5000], [6000, 7000, 8000, 9000, 10000]]\n assert candidate(original = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1010, 1111, 1212, 1313, 1414, 1515, 1616, 1717, 1818, 1919, 2020, 2121, 2222, 2323, 2424, 2525],m = 5,n = 5) == [[101, 202, 303, 404, 505], [606, 707, 808, 909, 1010], [1111, 1212, 1313, 1414, 1515], [1616, 1717, 1818, 1919, 2020], [2121, 2222, 2323, 2424, 2525]]\n assert candidate(original = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986],m = 3,n = 5) == [[100000, 99999, 99998, 99997, 99996], [99995, 99994, 99993, 99992, 99991], [99990, 99989, 99988, 99987, 99986]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],m = 5,n = 10) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40], [41, 42, 43, 44, 45, 46, 47, 48, 49, 50]]\n assert candidate(original = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],m = 5,n = 3) == [[10, 20, 30], [40, 50, 60], [70, 80, 90], [100, 110, 120], [130, 140, 150]]\n assert candidate(original = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135],m = 9,n = 4) == [[100, 101, 102, 103], [104, 105, 106, 107], [108, 109, 110, 111], [112, 113, 114, 115], [116, 117, 118, 119], [120, 121, 122, 123], [124, 125, 126, 127], [128, 129, 130, 131], [132, 133, 134, 135]]\n assert candidate(original = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26],m = 2,n = 13) == [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26]]\n assert candidate(original = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],m = 5,n = 3) == [[100, 200, 300], [400, 500, 600], [700, 800, 900], [1000, 1100, 1200], [1300, 1400, 1500]]\n"}, "metadata": {"canonical_parameter_names": ["original", "m", "n"], "leetcode_dataset_entry_point": "Solution().construct2DArray", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector> construct2DArray(vector& original, int m, int n) {", "container": "Solution", "callable": "construct2DArray", "parameters": [{"name": "original", "type": "vector&"}, {"name": "m", "type": "int"}, {"name": "n", "type": "int"}], "return_type": "vector>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2023, "task_id": "number-of-pairs-of-strings-with-concatenation-equal-to-target", "difficulty": "Medium", "problem_description": "Given an array of digit strings nums and a digit string target, return the number of pairs of indices (i, j) (where i != j) such that the concatenation of nums[i] + nums[j] equals target.\n \nExample 1:\n\nInput: nums = [\"777\",\"7\",\"77\",\"77\"], target = \"7777\"\nOutput: 4\nExplanation: Valid pairs are:\n- (0, 1): \"777\" + \"7\"\n- (1, 0): \"7\" + \"777\"\n- (2, 3): \"77\" + \"77\"\n- (3, 2): \"77\" + \"77\"\n\nExample 2:\n\nInput: nums = [\"123\",\"4\",\"12\",\"34\"], target = \"1234\"\nOutput: 2\nExplanation: Valid pairs are:\n- (0, 1): \"123\" + \"4\"\n- (2, 3): \"12\" + \"34\"\n\nExample 3:\n\nInput: nums = [\"1\",\"1\",\"1\"], target = \"11\"\nOutput: 6\nExplanation: Valid pairs are:\n- (0, 1): \"1\" + \"1\"\n- (1, 0): \"1\" + \"1\"\n- (0, 2): \"1\" + \"1\"\n- (2, 0): \"1\" + \"1\"\n- (1, 2): \"1\" + \"1\"\n- (2, 1): \"1\" + \"1\"\n\n \nConstraints:\n\n2 <= nums.length <= 100\n1 <= nums[i].length <= 100\n2 <= target.length <= 100\nnums[i] and target consist of digits.\nnums[i] and target do not have leading zeros.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = ['777', '7', '77', '77'],target = \"7777\") == 4\n assert candidate(nums = ['10', '11', '1'],target = \"101\") == 1\n assert candidate(nums = ['1234', '56', '78', '9'],target = \"123456\") == 1\n assert candidate(nums = ['99', '9', '999'],target = \"9999\") == 2\n assert candidate(nums = ['50', '2', '5', '0'],target = \"5025\") == 0\n assert candidate(nums = ['10', '100', '1'],target = \"10100\") == 1\n assert candidate(nums = ['123', '4', '12', '34'],target = \"1234\") == 2\n assert candidate(nums = ['50', '5', '500'],target = \"505\") == 1\n assert candidate(nums = ['1', '1', '1'],target = \"11\") == 6\n assert candidate(nums = ['123', '234', '345', '456', '567', '678', '789', '890'],target = \"123234\") == 1\n assert candidate(nums = ['66', '666', '6666', '66666'],target = \"66666666\") == 2\n assert candidate(nums = ['33', '3', '333', '3333', '33'],target = \"333333\") == 4\n assert candidate(nums = ['555', '55', '5', '5555'],target = \"555555\") == 2\n assert candidate(nums = ['1', '1', '2', '2', '3', '3'],target = \"11\") == 2\n assert candidate(nums = ['78', '87', '7', '8'],target = \"7887\") == 1\n assert candidate(nums = ['7777', '777', '77', '7'],target = \"7777777\") == 2\n assert candidate(nums = ['0', '00', '000', '0000'],target = \"0000\") == 2\n assert candidate(nums = ['001', '010', '100', '1'],target = \"1001\") == 2\n assert candidate(nums = ['15', '51', '1515', '151', '515'],target = \"151515\") == 3\n assert candidate(nums = ['10', '01', '100', '001', '1000', '0001'],target = \"1001\") == 1\n assert candidate(nums = ['789', '897', '978', '78', '89', '97'],target = \"789897\") == 1\n assert candidate(nums = ['10', '20', '30', '40', '50'],target = \"1020\") == 1\n assert candidate(nums = ['1234', '5678', '4321', '8765'],target = \"12345678\") == 1\n assert candidate(nums = ['111', '222', '333', '444', '555', '666', '777', '888', '999'],target = \"111222\") == 1\n assert candidate(nums = ['5', '55', '555', '5555', '55555'],target = \"555555\") == 4\n assert candidate(nums = ['9', '99', '999', '9999'],target = \"999999\") == 2\n assert candidate(nums = ['18', '81', '181', '818', '1818'],target = \"181818\") == 3\n assert candidate(nums = ['20', '02', '2', '2002'],target = \"200202\") == 1\n assert candidate(nums = ['5', '55', '555', '5555'],target = \"55555\") == 4\n assert candidate(nums = ['9', '99', '999', '9999', '99999'],target = \"999999\") == 4\n assert candidate(nums = ['90', '09', '9', '0'],target = \"9009\") == 1\n assert candidate(nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9'],target = \"12\") == 1\n assert candidate(nums = ['111', '222', '333', '111', '222'],target = \"111222\") == 4\n assert candidate(nums = ['222', '2222', '2', '22', '22222'],target = \"22222222\") == 2\n assert candidate(nums = ['1234', '5678', '12', '34', '56', '78'],target = \"12345678\") == 1\n assert candidate(nums = ['111', '222', '333', '444'],target = \"111222\") == 1\n assert candidate(nums = ['98765', '4321', '9876', '54321'],target = \"987654321\") == 2\n assert candidate(nums = ['90', '909', '09', '9'],target = \"90909\") == 2\n assert candidate(nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '09'],target = \"09\") == 1\n assert candidate(nums = ['100000', '10000', '1000', '100', '10', '1'],target = \"10000010000\") == 1\n assert candidate(nums = ['0', '0', '0', '0'],target = \"00\") == 12\n assert candidate(nums = ['8', '88', '888', '8888'],target = \"88888\") == 4\n assert candidate(nums = ['123', '456', '789', '0', '1', '2'],target = \"123456\") == 1\n assert candidate(nums = ['111111', '11111', '1111', '111', '11'],target = \"111111111\") == 4\n assert candidate(nums = ['100', '200', '300', '400', '500'],target = \"100200\") == 1\n assert candidate(nums = ['123', '234', '345', '456', '567'],target = \"123234\") == 1\n assert candidate(nums = ['1234', '4321', '2341', '3412', '5678', '8765', '6785', '7856'],target = \"12344321\") == 1\n assert candidate(nums = ['123', '345', '567', '789'],target = \"123345\") == 1\n assert candidate(nums = ['10', '20', '30', '40', '50'],target = \"2030\") == 1\n assert candidate(nums = ['0000', '000', '00', '0'],target = \"00000000\") == 0\n assert candidate(nums = ['0001', '10', '01', '1'],target = \"00011\") == 1\n assert candidate(nums = ['123', '456', '789', '0'],target = \"123456\") == 1\n assert candidate(nums = ['16', '61', '161', '6', '1661'],target = \"166161\") == 1\n assert candidate(nums = ['21', '12', '22', '11', '2112'],target = \"211221\") == 1\n assert candidate(nums = ['42', '424', '2', '4'],target = \"4242\") == 1\n assert candidate(nums = ['777', '77', '7', '7777'],target = \"777777\") == 2\n assert candidate(nums = ['11', '11', '11', '11', '11'],target = \"1111\") == 20\n assert candidate(nums = ['19', '91', '191', '9', '1991'],target = \"199191\") == 1\n assert candidate(nums = ['987654321', '123456789', '1234', '4321'],target = \"987654321123456789\") == 1\n assert candidate(nums = ['111111', '1111', '111', '11', '1'],target = \"111111111111\") == 0\n assert candidate(nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'],target = \"12\") == 1\n assert candidate(nums = ['1', '1', '1', '1', '1', '1', '1', '1', '1', '1'],target = \"11\") == 90\n assert candidate(nums = ['101', '101', '101', '101'],target = \"101101\") == 12\n assert candidate(nums = ['8888', '888', '88', '8', '88', '888', '8888'],target = \"88888888\") == 2\n assert candidate(nums = ['22', '2', '222', '2222'],target = \"222222\") == 2\n assert candidate(nums = ['123456', '654321', '1234', '4321', '5678', '8765'],target = \"123456654321\") == 1\n assert candidate(nums = ['12', '21', '11', '22'],target = \"1221\") == 1\n assert candidate(nums = ['55', '555', '5555', '55555'],target = \"5555555\") == 4\n assert candidate(nums = ['14', '41', '144', '4'],target = \"1441\") == 1\n assert candidate(nums = ['8', '88', '888', '8888', '88888', '888888'],target = \"8888888\") == 6\n assert candidate(nums = ['12', '23', '34', '45', '56'],target = \"2345\") == 1\n assert candidate(nums = ['12345', '54321', '123', '321', '12', '21'],target = \"1234554321\") == 1\n assert candidate(nums = ['55', '5', '555', '5555'],target = \"55555\") == 4\n assert candidate(nums = ['987', '654', '321', '654'],target = \"987654\") == 2\n assert candidate(nums = ['111', '11', '1', '1111', '11111'],target = \"1111111\") == 4\n assert candidate(nums = ['1234', '4321', '2341', '3412'],target = \"12344321\") == 1\n assert candidate(nums = ['101', '01', '10', '1'],target = \"1010\") == 0\n assert candidate(nums = ['8', '88', '888', '8888', '88888'],target = \"888888888\") == 2\n assert candidate(nums = ['6', '66', '666', '6666'],target = \"666666\") == 2\n assert candidate(nums = ['10', '01', '0', '1'],target = \"1001\") == 1\n assert candidate(nums = ['10', '20', '30', '40', '50', '60', '70', '80', '90'],target = \"1020\") == 1\n assert candidate(nums = ['111', '11', '1', '1111'],target = \"111111\") == 2\n assert candidate(nums = ['1', '2', '3', '4', '5'],target = \"12\") == 1\n assert candidate(nums = ['111', '222', '112', '121', '211'],target = \"111222\") == 1\n assert candidate(nums = ['12345', '23456', '34567', '45678', '56789'],target = \"1234523456\") == 1\n assert candidate(nums = ['12', '12', '12', '12'],target = \"1212\") == 12\n assert candidate(nums = ['555', '55', '5', '5555', '55555'],target = \"5555555\") == 4\n assert candidate(nums = ['23', '32', '232', '2', '3223'],target = \"233223\") == 1\n assert candidate(nums = ['11', '22', '33', '44', '55', '66', '77', '88', '99'],target = \"1122\") == 1\n assert candidate(nums = ['123', '321', '213', '132', '231', '312'],target = \"123213\") == 1\n assert candidate(nums = ['12', '21', '121', '212'],target = \"1212\") == 0\n assert candidate(nums = ['555', '555', '555', '555', '555'],target = \"555555\") == 20\n assert candidate(nums = ['89', '98', '8998', '9889'],target = \"899889\") == 2\n assert candidate(nums = ['22', '222', '2', '2222'],target = \"222222\") == 2\n assert candidate(nums = ['23', '32', '123', '456', '654', '321'],target = \"23456\") == 1\n assert candidate(nums = ['9876', '8765', '7654', '6543', '5432', '4321', '3210', '2109'],target = \"98768765\") == 1\n assert candidate(nums = ['1010', '0101', '10', '01', '101', '010'],target = \"10100101\") == 1\n assert candidate(nums = ['90', '80', '70', '60'],target = \"7080\") == 1\n assert candidate(nums = ['101', '010', '10', '01'],target = \"101010\") == 1\n assert candidate(nums = ['9', '99', '999', '9999'],target = \"99999999\") == 0\n assert candidate(nums = ['5050', '50', '5', '500', '5000'],target = \"505050\") == 2\n assert candidate(nums = ['12', '21', '121', '112'],target = \"12112\") == 2\n assert candidate(nums = ['13', '31', '1', '3'],target = \"1331\") == 1\n assert candidate(nums = ['2', '22', '222', '2222', '22222'],target = \"222222\") == 4\n assert candidate(nums = ['2020', '20', '2', '0202'],target = \"202020\") == 2\n assert candidate(nums = ['12', '23', '34', '45', '56', '67', '78', '89'],target = \"1223\") == 1\n assert candidate(nums = ['999', '99', '9', '9999'],target = \"9999999\") == 2\n assert candidate(nums = ['00', '0', '000', '0000'],target = \"000000\") == 2\n assert candidate(nums = ['17', '71', '1717', '717', '177'],target = \"171717\") == 2\n assert candidate(nums = ['987', '876', '765', '654', '543'],target = \"987876\") == 1\n assert candidate(nums = ['12', '23', '34', '45', '56', '67', '78', '89', '90'],target = \"1223\") == 1\n assert candidate(nums = ['12', '12', '12', '12', '12', '12', '12', '12', '12', '12'],target = \"1212\") == 90\n assert candidate(nums = ['00', '000', '0000', '00000'],target = \"00000000\") == 2\n assert candidate(nums = ['1010', '10', '1', '101', '10101'],target = \"10101010\") == 0\n assert candidate(nums = ['12', '23', '34', '45', '56'],target = \"1223\") == 1\n assert candidate(nums = ['55', '5', '555', '5555'],target = \"5555\") == 2\n assert candidate(nums = ['1234', '456', '12', '3456'],target = \"123456\") == 1\n assert candidate(nums = ['45', '54', '4', '5'],target = \"4554\") == 1\n assert candidate(nums = ['10', '01', '100', '1'],target = \"101\") == 2\n assert candidate(nums = ['100', '10', '1', '1000'],target = \"1001000\") == 1\n assert candidate(nums = ['1111', '111', '11', '1'],target = \"11111111\") == 0\n assert candidate(nums = ['11', '111', '1111', '11111'],target = \"111111111\") == 2\n assert candidate(nums = ['9876', '8769', '7698', '6987', '987', '876', '769', '698'],target = \"98768769\") == 1\n assert candidate(nums = ['12345', '67890', '123', '4567890'],target = \"1234567890\") == 2\n assert candidate(nums = ['9', '9', '9', '9', '9', '9', '9', '9', '9', '9'],target = \"99\") == 90\n assert candidate(nums = ['123', '456', '789', '1234'],target = \"123456\") == 1\n assert candidate(nums = ['1234', '5678', '91011', '121314'],target = \"12345678\") == 1\n"}, "metadata": {"canonical_parameter_names": ["nums", "target"], "leetcode_dataset_entry_point": "Solution().numOfPairs", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int numOfPairs(vector& nums, string target) {", "container": "Solution", "callable": "numOfPairs", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "target", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2024, "task_id": "maximize-the-confusion-of-an-exam", "difficulty": "Medium", "problem_description": "A teacher is writing a test with n true/false questions, with 'T' denoting true and 'F' denoting false. He wants to confuse the students by maximizing the number of consecutive questions with the same answer (multiple trues or multiple falses in a row).\nYou are given a string answerKey, where answerKey[i] is the original answer to the ith question. In addition, you are given an integer k, the maximum number of times you may perform the following operation:\n\nChange the answer key for any question to 'T' or 'F' (i.e., set answerKey[i] to 'T' or 'F').\n\nReturn the maximum number of consecutive 'T's or 'F's in the answer key after performing the operation at most k times.\n \nExample 1:\n\nInput: answerKey = \"TTFF\", k = 2\nOutput: 4\nExplanation: We can replace both the 'F's with 'T's to make answerKey = \"TTTT\".\nThere are four consecutive 'T's.\n\nExample 2:\n\nInput: answerKey = \"TFFT\", k = 1\nOutput: 3\nExplanation: We can replace the first 'T' with an 'F' to make answerKey = \"FFFT\".\nAlternatively, we can replace the second 'T' with an 'F' to make answerKey = \"TFFF\".\nIn both cases, there are three consecutive 'F's.\n\nExample 3:\n\nInput: answerKey = \"TTFTTFTT\", k = 1\nOutput: 5\nExplanation: We can replace the first 'F' to make answerKey = \"TTTTTFTT\"\nAlternatively, we can replace the second 'F' to make answerKey = \"TTFTTTTT\". \nIn both cases, there are five consecutive 'T's.\n\n \nConstraints:\n\nn == answerKey.length\n1 <= n <= 5 * 104\nanswerKey[i] is either 'T' or 'F'\n1 <= k <= n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(answerKey = \"TTTTFFFF\",k = 2) == 6\n assert candidate(answerKey = \"FFFFFF\",k = 3) == 6\n assert candidate(answerKey = \"TFFTFFTFFTFT\",k = 3) == 10\n assert candidate(answerKey = \"TFTFTFTF\",k = 2) == 5\n assert candidate(answerKey = \"FFTFFT\",k = 2) == 6\n assert candidate(answerKey = \"FFTTFFTTFF\",k = 5) == 10\n assert candidate(answerKey = \"FFTFFTFF\",k = 2) == 8\n assert candidate(answerKey = \"TFTFTFTFTF\",k = 4) == 9\n assert candidate(answerKey = \"T\",k = 1) == 1\n assert candidate(answerKey = \"FFTFFTFF\",k = 3) == 8\n assert candidate(answerKey = \"TTFF\",k = 2) == 4\n assert candidate(answerKey = \"TFTFTFTF\",k = 4) == 8\n assert candidate(answerKey = \"FTFTFTFT\",k = 2) == 5\n assert candidate(answerKey = \"TTFTTFTT\",k = 1) == 5\n assert candidate(answerKey = \"TF TFT TFTF\",k = 3) == 10\n assert candidate(answerKey = \"FFFFFFFF\",k = 5) == 8\n assert candidate(answerKey = \"FFFFFFT\",k = 2) == 7\n assert candidate(answerKey = \"FTFTFTFTFTFT\",k = 5) == 11\n assert candidate(answerKey = \"TTTTFFT\",k = 1) == 5\n assert candidate(answerKey = \"TTTTTTFTTTTT\",k = 2) == 12\n assert candidate(answerKey = \"TTTTTT\",k = 0) == 6\n assert candidate(answerKey = \"TTTTT\",k = 0) == 5\n assert candidate(answerKey = \"TFFTFFTT\",k = 3) == 7\n assert candidate(answerKey = \"TTTTFFTFFT\",k = 3) == 8\n assert candidate(answerKey = \"FTFFTFFT\",k = 3) == 8\n assert candidate(answerKey = \"TTTTTTTT\",k = 3) == 8\n assert candidate(answerKey = \"TFFT\",k = 1) == 3\n assert candidate(answerKey = \"FFFFFFF\",k = 3) == 7\n assert candidate(answerKey = \"FFFFF\",k = 3) == 5\n assert candidate(answerKey = \"FFFFF\",k = 0) == 5\n assert candidate(answerKey = \"TFFFFF\",k = 2) == 6\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT\",k = 20) == 38\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFT\",k = 4) == 9\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFF\",k = 10) == 16\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFT\",k = 8) == 16\n assert candidate(answerKey = \"TTTTTTTFFFFFFFFFFFFFFTTTTTTTTTTTTTTTTTTTTTT\",k = 15) == 43\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTT\",k = 5) == 16\n assert candidate(answerKey = \"TFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 25) == 51\n assert candidate(answerKey = \"TFFTFTFTFTFTFTFTFTFT\",k = 10) == 20\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTTTTTTTTTT\",k = 15) == 24\n assert candidate(answerKey = \"TTFTFTFFTFTF\",k = 4) == 10\n assert candidate(answerKey = \"TFFFFFFFFFTTTTTTTTTT\",k = 6) == 16\n assert candidate(answerKey = \"TTFTFTFTFT\",k = 4) == 10\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFT\",k = 8) == 17\n assert candidate(answerKey = \"TFFTFFTFFTFFTFFTFFTFFTFFTFFT\",k = 21) == 28\n assert candidate(answerKey = \"TFTFTFTFTFTFTFTFTFTF\",k = 10) == 20\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\",k = 20) == 32\n assert candidate(answerKey = \"FFFFFFFFTTTTTTTT\",k = 5) == 13\n assert candidate(answerKey = \"TFFTFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFFTFT\",k = 7) == 23\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFFFFFFFFFFFFF\",k = 20) == 28\n assert candidate(answerKey = \"FFFFFFFFFTTTTTTTTT\",k = 5) == 14\n assert candidate(answerKey = \"FTTFTTFTTFFTFTTFFT\",k = 11) == 18\n assert candidate(answerKey = \"FFFFFFFFTTTTTTFFFFFFFFTTTTTTTTT\",k = 9) == 25\n assert candidate(answerKey = \"TFTFTFTFTFTFTFTF\",k = 10) == 16\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTT\",k = 10) == 16\n assert candidate(answerKey = \"FFFFFFFFTTTTTTTTTTFT\",k = 2) == 13\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\",k = 0) == 44\n assert candidate(answerKey = \"TTTFFFFTTTFFTFTFFF\",k = 3) == 9\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 20) == 41\n assert candidate(answerKey = \"FTTTFTTFTTFTTFTTFT\",k = 7) == 18\n assert candidate(answerKey = \"TFTFTFTFTF\",k = 5) == 10\n assert candidate(answerKey = \"FFFTTTFFFFTTTTFF\",k = 5) == 12\n assert candidate(answerKey = \"TTFFFFFFFFTTTTTTTTTTTTFFFFFFF\",k = 8) == 22\n assert candidate(answerKey = \"TTTFFFTTTFFFTTTFFF\",k = 5) == 11\n assert candidate(answerKey = \"FFFFFFFFFTTTTTTTTTTTTTT\",k = 10) == 23\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFTFTFT\",k = 2) == 5\n assert candidate(answerKey = \"TTFTFTFTFTFTFTFT\",k = 5) == 12\n assert candidate(answerKey = \"FFTTFFTTFFTTFFTTFF\",k = 10) == 18\n assert candidate(answerKey = \"TTTTFFFFFFFFFFFFTTTTTTTTTTTT\",k = 15) == 28\n assert candidate(answerKey = \"TTFTFTFTFTFTFTFTFTFTFT\",k = 12) == 22\n assert candidate(answerKey = \"TTTTTTTTTTFFFFFFFFFFFFFFFFF\",k = 11) == 27\n assert candidate(answerKey = \"TTTTTTTTTFFFFFFF\",k = 5) == 14\n assert candidate(answerKey = \"FTFFTFFTFFTFFTFFTFF\",k = 10) == 19\n assert candidate(answerKey = \"TTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 7) == 16\n assert candidate(answerKey = \"FFFFFFFFFTTTTT\",k = 5) == 14\n assert candidate(answerKey = \"TFFTFTFTFFTTFTFT\",k = 3) == 9\n assert candidate(answerKey = \"TFTFTFTFTFTFTFTFTF\",k = 6) == 13\n assert candidate(answerKey = \"TTTFTFTFTFTFTFTF\",k = 6) == 15\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTTT\",k = 15) == 17\n assert candidate(answerKey = \"FFTFTFTFTFFTFTFTFT\",k = 6) == 15\n assert candidate(answerKey = \"FFFFFFFFTTTTTFFFFF\",k = 4) == 12\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFTTTTTTTTTTTTTTTT\",k = 8) == 38\n assert candidate(answerKey = \"FFFFFFFFTTTTTTTTTT\",k = 12) == 18\n assert candidate(answerKey = \"TTTTTTFFTFFTFFFF\",k = 4) == 12\n assert candidate(answerKey = \"TFTFTFTFTFTFTFTFTF\",k = 9) == 18\n assert candidate(answerKey = \"TTTTTTTTTTFFTTFFTT\",k = 5) == 18\n assert candidate(answerKey = \"TTTFFFFTTTFFFFTTTFFFFTTT\",k = 6) == 18\n assert candidate(answerKey = \"TTFFTTFFTFFTFFTT\",k = 7) == 15\n assert candidate(answerKey = \"FFTTFFFTTF\",k = 2) == 7\n assert candidate(answerKey = \"FFFFFFFF\",k = 0) == 8\n assert candidate(answerKey = \"FFFFFFFFFTTTTTTT\",k = 6) == 15\n assert candidate(answerKey = \"TTFTTTFTFTFTFTFFTFTF\",k = 4) == 12\n assert candidate(answerKey = \"TTTTTTTTTTFFFFFFFFFF\",k = 8) == 18\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\",k = 20) == 36\n assert candidate(answerKey = \"TTTFFFFTTTTFTTTFFTTT\",k = 7) == 20\n assert candidate(answerKey = \"TFFTFTFTFTFTFTFTFT\",k = 8) == 17\n assert candidate(answerKey = \"TTFFFTFTFTFTFFFT\",k = 6) == 15\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFT\",k = 5) == 11\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 20) == 38\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\",k = 25) == 32\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 15) == 31\n assert candidate(answerKey = \"TFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTF\",k = 20) == 41\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFT\",k = 9) == 18\n assert candidate(answerKey = \"TTTTTFFTTTTFFTT\",k = 4) == 15\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 15) == 28\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT\",k = 0) == 48\n assert candidate(answerKey = \"FFTFTFFTFTFFTFTFFTFT\",k = 5) == 14\n assert candidate(answerKey = \"TTFFFFFFFFFFFFFFFFFT\",k = 3) == 20\n assert candidate(answerKey = \"TFFTFFTFFTFFTFFTFF\",k = 10) == 18\n assert candidate(answerKey = \"FFFFFFFFTTTTTTTTFFFFFFFFTTTTTTTT\",k = 8) == 24\n assert candidate(answerKey = \"TTTTTTFTTTTTFTTTTTFTTTTT\",k = 7) == 24\n assert candidate(answerKey = \"TFFFFFFFTTTTTTTTTT\",k = 10) == 18\n assert candidate(answerKey = \"TFTFTFTFTFTFTFTFTFTF\",k = 15) == 20\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTTTTTTTTTTTTTTTT\",k = 25) == 30\n assert candidate(answerKey = \"FTTFTTFTTFFTFTTFFTFFTFTTFTT\",k = 22) == 27\n assert candidate(answerKey = \"TTFFFFFFFFFFFFFFFFFF\",k = 10) == 20\n assert candidate(answerKey = \"FFFFFFFFFTTTTTTT\",k = 7) == 16\n assert candidate(answerKey = \"TFTFTFTFTFTFTFTFTFTFTFTFTFTF\",k = 18) == 28\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 10) == 21\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTTTTTTTT\",k = 15) == 22\n assert candidate(answerKey = \"FFTTFFTFFTFFTFFT\",k = 4) == 12\n assert candidate(answerKey = \"TTTTTFFFFF\",k = 2) == 7\n assert candidate(answerKey = \"TTTFFFTTTFFFTTTFFFTTTFFFTTTFFTFTFFTT\",k = 15) == 32\n assert candidate(answerKey = \"TFFTFFTTFFTTFFTTFFTT\",k = 9) == 19\n assert candidate(answerKey = \"FTFTFTTTTTFTFTFT\",k = 6) == 16\n assert candidate(answerKey = \"TTTTTTTTTTTTTTTTTTTTTTTTTTTT\",k = 20) == 28\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFF\",k = 15) == 17\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFTFT\",k = 8) == 17\n assert candidate(answerKey = \"TFFTFFTFFTFFTFFTFFTFFTFFTFFT\",k = 12) == 28\n assert candidate(answerKey = \"TTTTFFTTFFTTFF\",k = 4) == 12\n assert candidate(answerKey = \"FTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 12) == 25\n assert candidate(answerKey = \"TFFFFFFFTTTTTTTT\",k = 7) == 16\n assert candidate(answerKey = \"TTTTTTTTTT\",k = 0) == 10\n assert candidate(answerKey = \"TFFTFFTFFTFFTFFTFFTFFT\",k = 7) == 21\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFFFFFFFFFFFFFF\",k = 20) == 29\n assert candidate(answerKey = \"TTFTFTFTFTFTFTFTFTFTFTFTFTFTFTFT\",k = 24) == 32\n assert candidate(answerKey = \"TTFTTTTTTTTTTTTTTTTT\",k = 1) == 20\n assert candidate(answerKey = \"TTFFTFTFFTFFTFTFFTFFTFFTTFFTFTFFTFFTFFTFFTFTFFTFF\",k = 6) == 19\n assert candidate(answerKey = \"TTFTFTFTFTFTFTFTFTFTFTFT\",k = 12) == 24\n assert candidate(answerKey = \"TTTTTTTTTFFFFFFF\",k = 6) == 15\n assert candidate(answerKey = \"FFFFFFFFFFFFFFFFFFFFFFFF\",k = 15) == 24\n"}, "metadata": {"canonical_parameter_names": ["answerKey", "k"], "leetcode_dataset_entry_point": "Solution().maxConsecutiveAnswers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxConsecutiveAnswers(string answerKey, int k) {", "container": "Solution", "callable": "maxConsecutiveAnswers", "parameters": [{"name": "answerKey", "type": "string"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2025, "task_id": "maximum-number-of-ways-to-partition-an-array", "difficulty": "Hard", "problem_description": "You are given a 0-indexed integer array nums of length n. The number of ways to partition nums is the number of pivot indices that satisfy both conditions:\n\n1 <= pivot < n\nnums[0] + nums[1] + ... + nums[pivot - 1] == nums[pivot] + nums[pivot + 1] + ... + nums[n - 1]\n\nYou are also given an integer k. You can choose to change the value of one element of nums to k, or to leave the array unchanged.\nReturn the maximum possible number of ways to partition nums to satisfy both conditions after changing at most one element.\n \nExample 1:\n\nInput: nums = [2,-1,2], k = 3\nOutput: 1\nExplanation: One optimal approach is to change nums[0] to k. The array becomes [3,-1,2].\nThere is one way to partition the array:\n- For pivot = 2, we have the partition [3,-1 | 2]: 3 + -1 == 2.\n\nExample 2:\n\nInput: nums = [0,0,0], k = 1\nOutput: 2\nExplanation: The optimal approach is to leave the array unchanged.\nThere are two ways to partition the array:\n- For pivot = 1, we have the partition [0 | 0,0]: 0 == 0 + 0.\n- For pivot = 2, we have the partition [0,0 | 0]: 0 + 0 == 0.\n\nExample 3:\n\nInput: nums = [22,4,-25,-20,-15,15,-16,7,19,-10,0,-13,-14], k = -33\nOutput: 4\nExplanation: One optimal approach is to change nums[2] to k. The array becomes [22,4,-33,-20,-15,15,-16,7,19,-10,0,-13,-14].\nThere are four ways to partition the array.\n\n \nConstraints:\n\nn == nums.length\n2 <= n <= 105\n-105 <= k, nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == 0\n assert candidate(nums = [0, 0, 0],k = 1) == 2\n assert candidate(nums = [5, 5, 5, 5, 5],k = 5) == 0\n assert candidate(nums = [100000, -100000, 100000, -100000],k = 0) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5],k = -3) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = -5) == 1\n assert candidate(nums = [1, 0, 1, 0, 1, 0],k = 1) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 55) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5],k = -15) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [2, -1, 2],k = 3) == 1\n assert candidate(nums = [1, 2, 3, 4, 5],k = 9) == 0\n assert candidate(nums = [-1, 1, -1, 1, -1],k = 0) == 3\n assert candidate(nums = [22, 4, -25, -20, -15, 15, -16, 7, 19, -10, 0, -13, -14],k = -33) == 4\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000],k = 15000) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 1\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000],k = 0) == 4\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80, 90, -90, 100, -100],k = 50) == 9\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105],k = 60) == 0\n assert candidate(nums = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1],k = 1) == 14\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1],k = 0) == 3\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],k = 0) == 1\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, -150000],k = 25000) == 0\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1],k = 0) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 1\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15],k = 0) == 1\n assert candidate(nums = [22, 4, -25, -20, -15, 15, -16, 7, 19, -10, 0, -13, -14, 22, 4, -25, -20, -15, 15, -16, 7, 19, -10, 0, -13, -14],k = -33) == 1\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16, 17, -18, 19, -20],k = 5) == 1\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40],k = 0) == 3\n assert candidate(nums = [-100000, -99999, -99998, -99997, -99996],k = 50000) == 0\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000],k = 550000) == 0\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],k = 105) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 15) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],k = 525) == 1\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9],k = 0) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 210) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = -5) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1],k = 2) == 4\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 50) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1],k = 0) == 2\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums = [10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000, -10000],k = 0) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 55) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 0) == 7\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400],k = 50) == 3\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75],k = 420) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 780) == 0\n assert candidate(nums = [-10, 20, -30, 40, -50, 60, -70, 80, -90, 100],k = 0) == 1\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000, -100000],k = 0) == 2\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000],k = 10500) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 0) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 1) == 5\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 2100) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 110) == 0\n assert candidate(nums = [-100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000, -100000, 100000],k = 0) == 9\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 1910) == 1\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40],k = 0) == 3\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 15) == 1\n assert candidate(nums = [100000, -100000, 100000, -100000, 100000],k = 0) == 3\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],k = 65) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 100) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],k = 1275) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21],k = 10) == 0\n assert candidate(nums = [0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5],k = 0) == 5\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 5) == 10\n assert candidate(nums = [-100000, 0, 100000, 0, -100000, 0, 100000, 0, -100000],k = 50000) == 0\n assert candidate(nums = [10000, -10000, 20000, -20000, 30000, -30000, 40000, -40000, 50000],k = -10000) == 3\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1],k = 0) == 4\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 1\n assert candidate(nums = [10000, -5000, 20000, -10000, 15000, -5000, 20000, -10000, 15000],k = 10000) == 2\n assert candidate(nums = [-10, 10, -20, 20, -30, 30, -40, 40],k = 0) == 3\n assert candidate(nums = [22, 4, -25, -20, -15, 15, -16, 7, 19, -10, 0, -13, -14, 30, -30],k = -33) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 120) == 0\n assert candidate(nums = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000],k = 5500000) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 500) == 1\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 0) == 4\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5],k = 10) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 100) == 1\n assert candidate(nums = [22, 4, -25, -20, -15, 15, -16, 7, 19, -10, 0, -13, -14],k = 100) == 0\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],k = 5) == 1\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],k = 0) == 0\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],k = 50) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 8) == 0\n assert candidate(nums = [-10000, 10000, -10000, 10000, -10000, 10000, -10000, 10000],k = 5000) == 3\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == 1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == 19\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 120) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 20) == 0\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90],k = 0) == 2\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],k = 1) == 2\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],k = 10) == 1\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 0) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 2) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = -55) == 0\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 55000) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],k = 225) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = -50) == 1\n assert candidate(nums = [-100000, -90000, -80000, -70000, -60000, -50000, -40000, -30000, -20000, -10000],k = -55000) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 1) == 14\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 0) == 9\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],k = 210) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 275) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -18, -19, -20],k = -10) == 1\n assert candidate(nums = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000],k = 50000) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 55) == 0\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 500000) == 1\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],k = 1) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 100) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900],k = 4500) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 550) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 190) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 100) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().waysToPartition", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int waysToPartition(vector& nums, int k) {", "container": "Solution", "callable": "waysToPartition", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2027, "task_id": "minimum-moves-to-convert-string", "difficulty": "Easy", "problem_description": "You are given a string s consisting of n characters which are either 'X' or 'O'.\nA move is defined as selecting three consecutive characters of s and converting them to 'O'. Note that if a move is applied to the character 'O', it will stay the same.\nReturn the minimum number of moves required so that all the characters of s are converted to 'O'.\n \nExample 1:\n\nInput: s = \"XXX\"\nOutput: 1\nExplanation: XXX -> OOO\nWe select all the 3 characters and convert them in one move.\n\nExample 2:\n\nInput: s = \"XXOX\"\nOutput: 2\nExplanation: XXOX -> OOOX -> OOOO\nWe select the first 3 characters in the first move, and convert them to 'O'.\nThen we select the last 3 characters and convert them so that the final string contains all 'O's.\nExample 3:\n\nInput: s = \"OOOO\"\nOutput: 0\nExplanation: There are no 'X's in s to convert.\n\n \nConstraints:\n\n3 <= s.length <= 1000\ns[i] is either 'X' or 'O'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"XXXXXXXXXX\") == 4\n assert candidate(s = \"OOXOOX\") == 2\n assert candidate(s = \"OOXOOXOOXO\") == 3\n assert candidate(s = \"OOXXOOXXOO\") == 2\n assert candidate(s = \"XXOX\") == 2\n assert candidate(s = \"OXOXOXOXOX\") == 3\n assert candidate(s = \"XOOOXXOOOX\") == 3\n assert candidate(s = \"XXX\") == 1\n assert candidate(s = \"OOOO\") == 0\n assert candidate(s = \"XOOXOX\") == 2\n assert candidate(s = \"OXOXOX\") == 2\n assert candidate(s = \"OOOXXOOOXXOOO\") == 2\n assert candidate(s = \"XOXOXOXOXO\") == 3\n assert candidate(s = \"XXXXXX\") == 2\n assert candidate(s = \"XOOXOOXOOX\") == 4\n assert candidate(s = \"XXXXXXXXX\") == 3\n assert candidate(s = \"XOXOXO\") == 2\n assert candidate(s = \"OOXXOOX\") == 2\n assert candidate(s = \"OOXOXO\") == 1\n assert candidate(s = \"XOOOOXOOXOXXXX\") == 4\n assert candidate(s = \"XOOXOXOOXOXOXO\") == 4\n assert candidate(s = \"OOXOXOXXOXXOOXOX\") == 4\n assert candidate(s = \"XOXOXOXOXOXOXOXOXOXOXOXOXOXOXO\") == 8\n assert candidate(s = \"XOXOOXOXOOXOXOXOXOOXOXOXOOXOXOXOOXO\") == 9\n assert candidate(s = \"XOOXOXOOXOOXOOXOOXOOXOOXOOXOOX\") == 10\n assert candidate(s = \"XOXOXXOOXOXOXXXOXO\") == 5\n assert candidate(s = \"XOOXOXOOXOXOOXOXOOX\") == 5\n assert candidate(s = \"OOXOOXOOXOOXOO\") == 4\n assert candidate(s = \"XOXOXOXOXOXOXOXOXOXOXOXOXO\") == 7\n assert candidate(s = \"OXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOX\") == 12\n assert candidate(s = \"OXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOX\") == 9\n assert candidate(s = \"XOOOXOOOXOOOXOOOXOOO\") == 5\n assert candidate(s = \"XOOXOXOXOXOXOXOX\") == 5\n assert candidate(s = \"OOOOOOOOOOOOOOOOO\") == 0\n assert candidate(s = \"OOOOOOOOOOOOOOOOOOO\") == 0\n assert candidate(s = \"XXOOOOXXOOOOXXOOOOXXOOOOXXOOOOXXOOOOXXOOOOXX\") == 8\n assert candidate(s = \"OOXXOOXXOOXXXX\") == 4\n assert candidate(s = \"XOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXO\") == 9\n assert candidate(s = \"XOOXXOOXXOOXXOOXX\") == 5\n assert candidate(s = \"XOXOXOXOXOOOXOXO\") == 4\n assert candidate(s = \"XXXOXOXOXOXO\") == 3\n assert candidate(s = \"XXOOXOXOXOXOXX\") == 4\n assert candidate(s = \"OXXOXOXOXOXO\") == 3\n assert candidate(s = \"XXXXXXXXXXXXXXXXXXX\") == 7\n assert candidate(s = \"OOXOXOXOXOOO\") == 2\n assert candidate(s = \"OXOXOXOXOXOX\") == 3\n assert candidate(s = \"XXOOXOXOXOXOXXOXOXXOXOXXOXOXXOXOXX\") == 10\n assert candidate(s = \"XOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOX\") == 14\n assert candidate(s = \"XOXOXOXOXOXO\") == 3\n assert candidate(s = \"XOOOXXXXOOOXXXXOOO\") == 5\n assert candidate(s = \"XXOXOXOXOXOXOXOXOXOXOXOXOX\") == 7\n assert candidate(s = \"XXOOXXOOXXOOXXOOXXOOX\") == 6\n assert candidate(s = \"XXXXXXXXXXXXXXXX\") == 6\n assert candidate(s = \"XXXOXOXOXOXOXOXO\") == 4\n assert candidate(s = \"XOXXXXXXXXXOXOXOXOXOXOXOXO\") == 8\n assert candidate(s = \"XOXOXXXXXXXXXOXXXXXXXXXOXXXXXXXXXOXXXXXXXXXO\") == 13\n assert candidate(s = \"OOXOXOXOXOXOXOXO\") == 4\n assert candidate(s = \"XOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXO\") == 12\n assert candidate(s = \"OXOXOXOXOXOXOXOXOXOXOX\") == 6\n assert candidate(s = \"OOXXOOXXOOXXOOXXOOXXOO\") == 5\n assert candidate(s = \"OXOXOXOXOXOXOXOXOXOXOXOX\") == 6\n assert candidate(s = \"XXXXXXXXXOOOOOOOOOXXXXXXXXX\") == 6\n assert candidate(s = \"XXOOXXOOXXOOXXOOXX\") == 5\n assert candidate(s = \"XOOXOOXOOXOOXOOX\") == 6\n assert candidate(s = \"OOXOXOXOXOXOXOXOXOXOXOXOXOXOXOOO\") == 7\n assert candidate(s = \"OOXOOXOOXOOXOOXO\") == 5\n assert candidate(s = \"XXXXXXXXXXXXX\") == 5\n assert candidate(s = \"XXOOXOXOXOXOXO\") == 4\n assert candidate(s = \"XXXOOOOXOXOOXOXO\") == 3\n assert candidate(s = \"XOXOXOXOXOXOXOXOXOXOXOXO\") == 6\n assert candidate(s = \"XXOOXXOOXXOOXX\") == 4\n assert candidate(s = \"XOOXOOXOOXOXOX\") == 5\n assert candidate(s = \"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO\") == 0\n assert candidate(s = \"XXOOXOXOXOXOXOXOXO\") == 5\n assert candidate(s = \"XOOXOOXOOXOOXOOXOOX\") == 7\n assert candidate(s = \"OOOXXXOOOXXXOOO\") == 2\n assert candidate(s = \"XXXOXOXOXXXO\") == 3\n assert candidate(s = \"XOXOXXOOXOXO\") == 3\n assert candidate(s = \"OXXXXOOOXXXXOOOXXX\") == 5\n assert candidate(s = \"OOOXOXOXOXOXOXOOOO\") == 3\n assert candidate(s = \"XOOXOOXOOXOOXOOXOOXOOX\") == 8\n assert candidate(s = \"OOXOOXOOXOOXOOXOOXOO\") == 6\n assert candidate(s = \"OOXOOXOOXOOXOOX\") == 5\n assert candidate(s = \"XXXXXXXXXXXXXXXXXXXXXXXX\") == 8\n assert candidate(s = \"OOXOXOXOXOXOXOOO\") == 3\n assert candidate(s = \"XOXXOXXOXXOXXOXX\") == 6\n assert candidate(s = \"XXOOXOXOXOXOXOXOXOXX\") == 6\n assert candidate(s = \"XOOXOOXOOXOOXOOXOOXOOXOOXOOXOOXOOXOOXO\") == 13\n assert candidate(s = \"XOXOXOXOXOXOXO\") == 4\n assert candidate(s = \"OXOXOXOXOXOXOX\") == 4\n assert candidate(s = \"XXOXOXOXOXOXOXOXOXOX\") == 6\n assert candidate(s = \"XXXXOXXXXOXXXXO\") == 5\n assert candidate(s = \"XOXOXOXOXOXOXOXOXOXOXOXOXOXO\") == 7\n assert candidate(s = \"XOOXOXOOXOXOOXOXOOXOXOOX\") == 6\n assert candidate(s = \"OOOOXXOOXXOOXX\") == 3\n assert candidate(s = \"XXOOXXOOXXOOXXOOXXOOXXOOXXOOX\") == 8\n assert candidate(s = \"XXXXOOXXXXOOXXXXOO\") == 6\n assert candidate(s = \"XXOXXOXXOXXOXX\") == 5\n assert candidate(s = \"OOOOOOOOOOOOO\") == 0\n assert candidate(s = \"OOXXXXXXOOXXXXXXOOXXXXXX\") == 6\n assert candidate(s = \"XOXOXXXOXOXOXXX\") == 4\n assert candidate(s = \"XOXOXOXOXOXOXOXOXO\") == 5\n assert candidate(s = \"XOXOXOOXOXOX\") == 4\n assert candidate(s = \"XXOOXXOOXXOOXXOOXXOO\") == 5\n assert candidate(s = \"XXXXXXXXXXXXXXXXXX\") == 6\n assert candidate(s = \"XXXXXXXXXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXO\") == 13\n assert candidate(s = \"XXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOX\") == 9\n assert candidate(s = \"XXOXOXOXOXOXOXOX\") == 5\n assert candidate(s = \"XOOXOOXOOXOOXOOXOOXOOXOOX\") == 9\n assert candidate(s = \"XOOOXOOOXOOOXOOO\") == 4\n assert candidate(s = \"OOXXOOXXOOXXOO\") == 3\n assert candidate(s = \"XOXOXOXOXOXOX\") == 4\n assert candidate(s = \"XOXOXOXOXOXOXOXOXOXO\") == 5\n assert candidate(s = \"XXOXOXOXOXOX\") == 4\n assert candidate(s = \"OOXOXOXOXO\") == 2\n assert candidate(s = \"XOOOXXOOOOXXOOOXXOOO\") == 4\n assert candidate(s = \"OOXOOXOOXOOXOOXOOXOOXOOX\") == 8\n assert candidate(s = \"XXOXOXOXOXOXOX\") == 4\n assert candidate(s = \"OXOXOXOXOXOXOXOXOX\") == 5\n assert candidate(s = \"OXOOXOOXOOXOOXOOXOOXOOX\") == 8\n assert candidate(s = \"OOXOOXOOXOOXOOXOOXOOXOOXOOXOO\") == 9\n assert candidate(s = \"OXXOXOXXOXOXXOXO\") == 5\n assert candidate(s = \"XXXXXXXXOXOXO\") == 4\n assert candidate(s = \"XXXXXXXXOOOXXXXX\") == 5\n assert candidate(s = \"OOXXOOXXOOXXOOXXOOXXOOXXOO\") == 6\n assert candidate(s = \"OOXOOXOOXOOXOOXOOXOOXOOXOOXOOXOOXOOXOO\") == 12\n assert candidate(s = \"XOOXOXXOXOXXOX\") == 5\n assert candidate(s = \"OOOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOO\") == 9\n assert candidate(s = \"OXOXOXOXOXOXOXOXOXO\") == 5\n assert candidate(s = \"OXOXOXOXOXOXO\") == 3\n assert candidate(s = \"XXXXOXXXXOXXXXOXXXXOXXXXOXXXXOXXXXO\") == 11\n assert candidate(s = \"XOXOXXXXXXXXOXXXXXXXXX\") == 7\n assert candidate(s = \"XOOXOOXOOXOOXOOXOOXOOXOOXOOXOOXOOX\") == 12\n assert candidate(s = \"XOOOXXOOOXXOOOXXOOO\") == 4\n assert candidate(s = \"OOOXOXOXOXOXOXOXOXOXOXOOOO\") == 5\n assert candidate(s = \"XOXXOXOXXOXOXXOXOXXOXXO\") == 7\n assert candidate(s = \"OOXOXOXOXOXOXOXOXOXOXOXOXO\") == 6\n assert candidate(s = \"OOOOOOOOOOOOOO\") == 0\n assert candidate(s = \"XXOXXOXXOXXO\") == 4\n assert candidate(s = \"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO\") == 0\n assert candidate(s = \"OXOXOXOXOXOXOXOX\") == 4\n assert candidate(s = \"XXXXXXXXXXXXXXXXXOOOOOOOOOOOO\") == 6\n assert candidate(s = \"OOOOOOOOOOOOOOOOOO\") == 0\n assert candidate(s = \"XXXXXXXXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOX\") == 11\n assert candidate(s = \"XXXOOXOXOOXOXX\") == 4\n assert candidate(s = \"XOXOXOXOXOXOXOXO\") == 4\n assert candidate(s = \"XOOOOXOOOOXOOOOXOOOO\") == 4\n assert candidate(s = \"XOOXXOOXXOOXXOOX\") == 5\n assert candidate(s = \"OOOXOXOXOXOXOOOO\") == 3\n assert candidate(s = \"OOXOOXOOXOOXOOXOOXOOXOOXOOXOOXOOXOOX\") == 12\n assert candidate(s = \"XOOOOXOOOXOOO\") == 3\n assert candidate(s = \"XXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXX\") == 11\n assert candidate(s = \"OOXOXOXOXOXOXOXOXO\") == 4\n assert candidate(s = \"XOXOXOOXOXOXOO\") == 4\n assert candidate(s = \"XOOOOXOOOOXOOOOXOOOOXOOOO\") == 5\n assert candidate(s = \"XOOXOXOXOXOX\") == 4\n assert candidate(s = \"OOXOOOXOOOXOOOXOOOXOOOXOOOXOOOXOOOXOOOXOOO\") == 10\n assert candidate(s = \"XXOOXXOOXXOO\") == 3\n assert candidate(s = \"XXXXXXXXOOOOXXXXXXXX\") == 6\n assert candidate(s = \"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\") == 14\n assert candidate(s = \"XXXXXXXXXXXXXXXXX\") == 6\n assert candidate(s = \"XOXOOXOXOOXOXOXO\") == 4\n assert candidate(s = \"OXOOXOOOXOXOOXOO\") == 4\n assert candidate(s = \"XXOXOXXOXOXOXXOX\") == 5\n assert candidate(s = \"OOOOOOOOOOOOOOOOOOOOOOOOOOOO\") == 0\n assert candidate(s = \"XXXXXXXXXXXXXX\") == 5\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().minimumMoves", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumMoves(string s) {", "container": "Solution", "callable": "minimumMoves", "parameters": [{"name": "s", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2028, "task_id": "find-missing-observations", "difficulty": "Medium", "problem_description": "You have observations of n + m 6-sided dice rolls with each face numbered from 1 to 6. n of the observations went missing, and you only have the observations of m rolls. Fortunately, you have also calculated the average value of the n + m rolls.\nYou are given an integer array rolls of length m where rolls[i] is the value of the ith observation. You are also given the two integers mean and n.\nReturn an array of length n containing the missing observations such that the average value of the n + m rolls is exactly mean. If there are multiple valid answers, return any of them. If no such array exists, return an empty array.\nThe average value of a set of k numbers is the sum of the numbers divided by k.\nNote that mean is an integer, so the sum of the n + m rolls should be divisible by n + m.\n \nExample 1:\n\nInput: rolls = [3,2,4,3], mean = 4, n = 2\nOutput: [6,6]\nExplanation: The mean of all n + m rolls is (3 + 2 + 4 + 3 + 6 + 6) / 6 = 4.\n\nExample 2:\n\nInput: rolls = [1,5,6], mean = 3, n = 4\nOutput: [2,3,2,2]\nExplanation: The mean of all n + m rolls is (1 + 5 + 6 + 2 + 3 + 2 + 2) / 7 = 3.\n\nExample 3:\n\nInput: rolls = [1,2,3,4], mean = 6, n = 4\nOutput: []\nExplanation: It is impossible for the mean to be 6 no matter what the 4 missing rolls are.\n\n \nConstraints:\n\nm == rolls.length\n1 <= n, m <= 105\n1 <= rolls[i], mean <= 6\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rolls = [1, 2],mean = 3,n = 2) == [5, 4]\n assert candidate(rolls = [1, 3, 5],mean = 2,n = 2) == []\n assert candidate(rolls = [5, 5, 5, 5],mean = 5,n = 4) == [5, 5, 5, 5]\n assert candidate(rolls = [5, 6, 6, 6],mean = 5,n = 3) == [4, 4, 4]\n assert candidate(rolls = [6, 6, 6, 6],mean = 6,n = 3) == [6, 6, 6]\n assert candidate(rolls = [3, 3, 3, 3, 3, 3],mean = 3,n = 6) == [3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 2, 3, 4],mean = 6,n = 4) == []\n assert candidate(rolls = [1, 5, 6],mean = 3,n = 4) == [3, 2, 2, 2]\n assert candidate(rolls = [5, 5, 5, 5],mean = 5,n = 5) == [5, 5, 5, 5, 5]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1],mean = 2,n = 6) == [3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [3, 2, 4, 3],mean = 4,n = 2) == [6, 6]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6],mean = 5,n = 6) == [4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [1, 1, 1, 1],mean = 2,n = 4) == [3, 3, 3, 3]\n assert candidate(rolls = [3],mean = 4,n = 1) == [5]\n assert candidate(rolls = [6],mean = 6,n = 1) == [6]\n assert candidate(rolls = [1, 1, 1],mean = 2,n = 3) == [3, 3, 3]\n assert candidate(rolls = [6, 6, 6],mean = 5,n = 3) == [4, 4, 4]\n assert candidate(rolls = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],mean = 3,n = 10) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6],mean = 3,n = 6) == [3, 3, 3, 2, 2, 2]\n assert candidate(rolls = [1],mean = 6,n = 5) == []\n assert candidate(rolls = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],mean = 6,n = 15) == [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(rolls = [3, 3, 3, 3, 3, 3],mean = 4,n = 3) == [6, 6, 6]\n assert candidate(rolls = [1, 1, 1, 1],mean = 2,n = 10) == [3, 3, 3, 3, 2, 2, 2, 2, 2, 2]\n assert candidate(rolls = [1, 1, 1, 1, 1],mean = 5,n = 5) == []\n assert candidate(rolls = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],mean = 3,n = 5) == [5, 5, 5, 5, 5]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 4,n = 20) == []\n assert candidate(rolls = [3, 3, 3, 3, 3, 3],mean = 3,n = 3) == [3, 3, 3]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 2,n = 12) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 6, 3, 4, 2, 5],mean = 3,n = 5) == [3, 3, 2, 2, 2]\n assert candidate(rolls = [2, 4, 6, 1, 3, 5],mean = 4,n = 3) == [5, 5, 5]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1],mean = 4,n = 12) == [5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [1, 6, 1, 6, 1, 6],mean = 4,n = 3) == [5, 5, 5]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6],mean = 6,n = 10) == [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(rolls = [1, 2, 3, 4, 5],mean = 4,n = 5) == [5, 5, 5, 5, 5]\n assert candidate(rolls = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],mean = 4,n = 20) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [3, 3, 3, 3],mean = 5,n = 5) == []\n assert candidate(rolls = [5, 1, 5, 1, 5, 1],mean = 4,n = 2) == []\n assert candidate(rolls = [1, 2, 3, 4, 5, 6, 6, 5, 4, 3, 2, 1, 6, 5, 4, 3, 2, 1],mean = 4,n = 18) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],mean = 3,n = 15) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 2,n = 15) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 1, 1, 1, 1],mean = 2,n = 10) == [3, 3, 3, 3, 3, 2, 2, 2, 2, 2]\n assert candidate(rolls = [6, 5, 4, 3, 2, 1],mean = 3,n = 7) == [3, 3, 3, 3, 2, 2, 2]\n assert candidate(rolls = [1, 2, 3],mean = 2,n = 9) == [2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(rolls = [4, 4, 4, 4, 4, 4, 4, 4],mean = 4,n = 1) == [4]\n assert candidate(rolls = [2, 2, 2, 2, 2, 2],mean = 2,n = 12) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 2,n = 20) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [2, 3, 4, 5, 6],mean = 4,n = 6) == [4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6],mean = 4,n = 3) == [5, 5, 5]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],mean = 6,n = 12) == [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(rolls = [6, 4, 6, 4, 6, 4],mean = 5,n = 5) == [5, 5, 5, 5, 5]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 3,n = 10) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(rolls = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],mean = 5,n = 12) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(rolls = [6, 5, 4, 3, 2, 1],mean = 4,n = 10) == [5, 5, 5, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [5, 1, 5, 1, 5, 1],mean = 3,n = 6) == [3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [4, 4, 4, 4, 4, 4],mean = 5,n = 1) == []\n assert candidate(rolls = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],mean = 5,n = 10) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6],mean = 6,n = 6) == [6, 6, 6, 6, 6, 6]\n assert candidate(rolls = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],mean = 3,n = 20) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 1,n = 10) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6],mean = 6,n = 6) == [6, 6, 6, 6, 6, 6]\n assert candidate(rolls = [1, 1, 2, 2, 3, 3],mean = 3,n = 3) == [5, 5, 5]\n assert candidate(rolls = [2, 2, 2, 2, 2, 2, 2, 2, 2],mean = 3,n = 6) == [5, 5, 5, 4, 4, 4]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 2,n = 10) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],mean = 6,n = 18) == [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(rolls = [1, 6, 1, 6, 1, 6],mean = 4,n = 6) == [5, 5, 5, 4, 4, 4]\n assert candidate(rolls = [1, 6, 1, 6, 1, 6],mean = 4,n = 3) == [5, 5, 5]\n assert candidate(rolls = [2, 2, 2, 2, 2, 2, 2],mean = 3,n = 4) == [5, 5, 5, 4]\n assert candidate(rolls = [1, 2, 3, 4, 5],mean = 2,n = 1) == []\n assert candidate(rolls = [2, 4, 6, 5, 4, 3, 2],mean = 4,n = 5) == [5, 5, 4, 4, 4]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6],mean = 5,n = 5) == [4, 4, 4, 4, 3]\n assert candidate(rolls = [6, 6, 6, 6],mean = 4,n = 8) == [3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6],mean = 5,n = 20) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],mean = 3,n = 10) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [6, 5, 4, 3, 2, 1],mean = 4,n = 5) == [5, 5, 5, 4, 4]\n assert candidate(rolls = [1, 2, 3, 4, 5],mean = 3,n = 5) == [3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],mean = 4,n = 5) == [6, 6, 6, 5, 5]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],mean = 4,n = 12) == [5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 4,n = 5) == []\n assert candidate(rolls = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],mean = 4,n = 10) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6],mean = 3,n = 10) == [2, 2, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(rolls = [4, 5, 6, 1, 2, 3],mean = 4,n = 6) == [5, 5, 5, 4, 4, 4]\n assert candidate(rolls = [1, 2, 2, 3, 3, 4, 5, 6],mean = 3,n = 10) == [3, 3, 3, 3, 3, 3, 3, 3, 2, 2]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 2,n = 5) == [4, 4, 4, 4, 4]\n assert candidate(rolls = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6],mean = 4,n = 5) == [5, 5, 5, 4, 4]\n assert candidate(rolls = [5, 5, 5, 5, 5],mean = 5,n = 5) == [5, 5, 5, 5, 5]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 2,n = 18) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [5, 5, 5, 5, 5, 5],mean = 4,n = 6) == [3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],mean = 5,n = 10) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(rolls = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],mean = 4,n = 10) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1],mean = 2,n = 9) == [3, 3, 3, 3, 3, 3, 3, 2, 2]\n assert candidate(rolls = [4, 4, 4, 4, 4, 4],mean = 4,n = 3) == [4, 4, 4]\n assert candidate(rolls = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],mean = 4,n = 5) == [6, 6, 6, 6, 6]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 3,n = 20) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(rolls = [6],mean = 1,n = 5) == []\n assert candidate(rolls = [3, 3, 3, 3, 3, 3],mean = 4,n = 3) == [6, 6, 6]\n assert candidate(rolls = [2, 4, 6, 8, 10],mean = 4,n = 5) == [2, 2, 2, 2, 2]\n assert candidate(rolls = [6, 6, 6, 6, 6],mean = 6,n = 1) == [6]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6],mean = 4,n = 12) == [5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [3, 3, 3, 3, 3, 3],mean = 4,n = 10) == [5, 5, 5, 5, 5, 5, 4, 4, 4, 4]\n assert candidate(rolls = [6, 6, 6, 6],mean = 5,n = 2) == [3, 3]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6],mean = 5,n = 3) == [3, 3, 3]\n assert candidate(rolls = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],mean = 5,n = 20) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(rolls = [3, 3, 3, 3, 3],mean = 5,n = 5) == []\n assert candidate(rolls = [6, 5, 4, 3, 2, 1],mean = 4,n = 6) == [5, 5, 5, 4, 4, 4]\n assert candidate(rolls = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6],mean = 6,n = 10) == [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6],mean = 4,n = 5) == [5, 5, 5, 4, 4]\n assert candidate(rolls = [3, 3, 3, 3, 3, 3],mean = 4,n = 5) == [6, 5, 5, 5, 5]\n assert candidate(rolls = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],mean = 2,n = 20) == [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],mean = 5,n = 10) == []\n assert candidate(rolls = [1, 2, 3, 4, 5],mean = 3,n = 7) == [3, 3, 3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],mean = 5,n = 5) == [4, 4, 4, 4, 4]\n assert candidate(rolls = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],mean = 5,n = 15) == [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n assert candidate(rolls = [1, 1, 2, 2, 3, 3],mean = 3,n = 6) == [4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],mean = 3,n = 10) == [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]\n assert candidate(rolls = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],mean = 3,n = 5) == [3, 3, 3, 3, 3]\n assert candidate(rolls = [1, 2, 3],mean = 4,n = 3) == [6, 6, 6]\n"}, "metadata": {"canonical_parameter_names": ["rolls", "mean", "n"], "leetcode_dataset_entry_point": "Solution().missingRolls", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector missingRolls(vector& rolls, int mean, int n) {", "container": "Solution", "callable": "missingRolls", "parameters": [{"name": "rolls", "type": "vector&"}, {"name": "mean", "type": "int"}, {"name": "n", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2029, "task_id": "stone-game-ix", "difficulty": "Medium", "problem_description": "Alice and Bob continue their games with stones. There is a row of n stones, and each stone has an associated value. You are given an integer array stones, where stones[i] is the value of the ith stone.\nAlice and Bob take turns, with Alice starting first. On each turn, the player may remove any stone from stones. The player who removes a stone loses if the sum of the values of all removed stones is divisible by 3. Bob will win automatically if there are no remaining stones (even if it is Alice's turn).\nAssuming both players play optimally, return true if Alice wins and false if Bob wins.\n \nExample 1:\n\nInput: stones = [2,1]\nOutput: true\nExplanation: The game will be played as follows:\n- Turn 1: Alice can remove either stone.\n- Turn 2: Bob removes the remaining stone. \nThe sum of the removed stones is 1 + 2 = 3 and is divisible by 3. Therefore, Bob loses and Alice wins the game.\n\nExample 2:\n\nInput: stones = [2]\nOutput: false\nExplanation: Alice will remove the only stone, and the sum of the values on the removed stones is 2. \nSince all the stones are removed and the sum of values is not divisible by 3, Bob wins the game.\n\nExample 3:\n\nInput: stones = [5,1,2,4,3]\nOutput: false\nExplanation: Bob will always win. One possible way for Bob to win is shown below:\n- Turn 1: Alice can remove the second stone with value 1. Sum of removed stones = 1.\n- Turn 2: Bob removes the fifth stone with value 3. Sum of removed stones = 1 + 3 = 4.\n- Turn 3: Alices removes the fourth stone with value 4. Sum of removed stones = 1 + 3 + 4 = 8.\n- Turn 4: Bob removes the third stone with value 2. Sum of removed stones = 1 + 3 + 4 + 2 = 10.\n- Turn 5: Alice removes the first stone with value 5. Sum of removed stones = 1 + 3 + 4 + 2 + 5 = 15.\nAlice loses the game because the sum of the removed stones (15) is divisible by 3. Bob wins the game.\n\n \nConstraints:\n\n1 <= stones.length <= 105\n1 <= stones[i] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(stones = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == True\n assert candidate(stones = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == False\n assert candidate(stones = [3, 6, 9, 12, 15]) == False\n assert candidate(stones = [2, 1]) == True\n assert candidate(stones = [1, 2, 3, 6, 9, 12, 15]) == False\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(stones = [3, 3, 3]) == False\n assert candidate(stones = [3, 3, 3, 3, 3, 3, 3, 3, 1]) == False\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(stones = [1, 5, 9, 13, 17, 21]) == True\n assert candidate(stones = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == False\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(stones = [5, 1, 2, 4, 3]) == False\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == False\n assert candidate(stones = [3, 6, 9, 12, 15, 18, 21]) == False\n assert candidate(stones = [1, 5, 7, 11, 13, 17, 19]) == True\n assert candidate(stones = [10, 20, 30, 40, 50]) == False\n assert candidate(stones = [3, 6, 9]) == False\n assert candidate(stones = [1, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73]) == True\n assert candidate(stones = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4]) == True\n assert candidate(stones = [2]) == False\n assert candidate(stones = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == True\n assert candidate(stones = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == False\n assert candidate(stones = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6]) == False\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == True\n assert candidate(stones = [0, 3, 6, 9, 12, 15, 18, 21, 24, 27]) == False\n assert candidate(stones = [3, 9, 27, 81, 243, 729, 2187, 6561, 19683]) == False\n assert candidate(stones = [1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 2]) == True\n assert candidate(stones = [1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5]) == False\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3]) == True\n assert candidate(stones = [2, 2, 2, 1, 1, 1, 0, 0, 0]) == False\n assert candidate(stones = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45]) == False\n assert candidate(stones = [1, 2, 4, 5, 7, 8, 10, 11]) == True\n assert candidate(stones = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == True\n assert candidate(stones = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == False\n assert candidate(stones = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == False\n assert candidate(stones = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62, 65, 68, 71, 74, 77, 80, 83, 86]) == False\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == True\n assert candidate(stones = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120, 125, 130, 135, 140, 145, 150]) == True\n assert candidate(stones = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62, 65, 68, 71, 74, 77, 80]) == False\n assert candidate(stones = [1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 1]) == True\n assert candidate(stones = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28]) == False\n assert candidate(stones = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90]) == False\n assert candidate(stones = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == False\n assert candidate(stones = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29]) == False\n assert candidate(stones = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == False\n assert candidate(stones = [5, 1, 2, 4, 3, 5, 1, 2, 4, 3, 5, 1, 2, 4, 3, 5, 1, 2, 4, 3, 5, 1, 2, 4, 3, 5, 1, 2, 4, 3]) == True\n assert candidate(stones = [1, 2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 8, 8, 8, 9, 10, 10, 10, 11, 12, 12, 12, 13, 14, 15, 16, 16, 17, 18, 18, 19, 19, 20]) == False\n assert candidate(stones = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == False\n assert candidate(stones = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == False\n assert candidate(stones = [3, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51]) == False\n assert candidate(stones = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == False\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == True\n assert candidate(stones = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17]) == True\n assert candidate(stones = [1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4]) == True\n assert candidate(stones = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]) == True\n assert candidate(stones = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == False\n assert candidate(stones = [1, 2, 2, 2, 1, 1, 2, 2, 1, 1, 1, 2, 2, 2, 1]) == True\n assert candidate(stones = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) == False\n assert candidate(stones = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58, 61, 64, 67, 70, 73, 76, 79, 82, 85, 88]) == False\n assert candidate(stones = [1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8]) == False\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == True\n assert candidate(stones = [3, 6, 9, 12, 15, 1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22]) == False\n assert candidate(stones = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]) == True\n assert candidate(stones = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87]) == False\n assert candidate(stones = [99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119]) == False\n assert candidate(stones = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == True\n assert candidate(stones = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == False\n assert candidate(stones = [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3]) == True\n assert candidate(stones = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == True\n assert candidate(stones = [3, 6, 9, 2, 5, 8, 11, 14, 17, 20]) == True\n assert candidate(stones = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == False\n assert candidate(stones = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60]) == False\n assert candidate(stones = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == False\n assert candidate(stones = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == True\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(stones = [1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19, 20, 22, 23, 25, 26, 28, 29]) == True\n assert candidate(stones = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == False\n assert candidate(stones = [1, 2, 2, 1, 2, 1, 2, 2, 1]) == True\n assert candidate(stones = [1, 2, 2, 2, 3, 3, 3, 3, 4, 5, 6, 6, 6, 6, 7, 8, 9]) == False\n assert candidate(stones = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75]) == False\n assert candidate(stones = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59]) == False\n assert candidate(stones = [1001, 1004, 1007, 1010, 1013, 1016, 1019, 1022, 1025, 1028, 1031, 1034, 1037, 1040, 1043, 1046, 1049, 1052, 1055, 1058]) == False\n assert candidate(stones = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7]) == True\n assert candidate(stones = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == False\n assert candidate(stones = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]) == True\n assert candidate(stones = [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49]) == False\n assert candidate(stones = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == True\n assert candidate(stones = [1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6]) == True\n assert candidate(stones = [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == False\n assert candidate(stones = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144, 153, 162, 171, 180]) == False\n assert candidate(stones = [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119]) == True\n assert candidate(stones = [1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == True\n assert candidate(stones = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1]) == True\n assert candidate(stones = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7]) == True\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == False\n assert candidate(stones = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35, 38, 41, 44, 47, 50, 53, 56, 59, 62, 65, 68, 71, 74, 77, 80, 83, 86, 89]) == False\n assert candidate(stones = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == False\n assert candidate(stones = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58]) == False\n assert candidate(stones = [1, 2, 2, 1, 2, 2, 1, 2]) == True\n assert candidate(stones = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3]) == False\n assert candidate(stones = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == False\n assert candidate(stones = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]) == False\n assert candidate(stones = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == False\n assert candidate(stones = [3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == True\n assert candidate(stones = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11]) == True\n assert candidate(stones = [1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5]) == True\n"}, "metadata": {"canonical_parameter_names": ["stones"], "leetcode_dataset_entry_point": "Solution().stoneGameIX", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool stoneGameIX(vector& stones) {", "container": "Solution", "callable": "stoneGameIX", "parameters": [{"name": "stones", "type": "vector&"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2030, "task_id": "smallest-k-length-subsequence-with-occurrences-of-a-letter", "difficulty": "Hard", "problem_description": "You are given a string s, an integer k, a letter letter, and an integer repetition.\nReturn the lexicographically smallest subsequence of s of length k that has the letter letter appear at least repetition times. The test cases are generated so that the letter appears in s at least repetition times.\nA subsequence is a string that can be derived from another string by deleting some or no characters without changing the order of the remaining characters.\nA string a is lexicographically smaller than a string b if in the first position where a and b differ, string a has a letter that appears earlier in the alphabet than the corresponding letter in b.\n \nExample 1:\n\nInput: s = \"leet\", k = 3, letter = \"e\", repetition = 1\nOutput: \"eet\"\nExplanation: There are four subsequences of length 3 that have the letter 'e' appear at least 1 time:\n- \"lee\" (from \"leet\")\n- \"let\" (from \"leet\")\n- \"let\" (from \"leet\")\n- \"eet\" (from \"leet\")\nThe lexicographically smallest subsequence among them is \"eet\".\n\nExample 2:\n\n\nInput: s = \"leetcode\", k = 4, letter = \"e\", repetition = 2\nOutput: \"ecde\"\nExplanation: \"ecde\" is the lexicographically smallest subsequence of length 4 that has the letter \"e\" appear at least 2 times.\n\nExample 3:\n\nInput: s = \"bb\", k = 2, letter = \"b\", repetition = 2\nOutput: \"bb\"\nExplanation: \"bb\" is the only subsequence of length 2 that has the letter \"b\" appear at least 2 times.\n\n \nConstraints:\n\n1 <= repetition <= k <= s.length <= 5 * 104\ns consists of lowercase English letters.\nletter is a lowercase English letter, and appears in s at least repetition times.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"bb\",k = 2,letter = \"b\",repetition = 2) == \"bb\"\n assert candidate(s = \"leetcode\",k = 4,letter = \"e\",repetition = 2) == \"ecde\"\n assert candidate(s = \"leet\",k = 3,letter = \"e\",repetition = 1) == \"eet\"\n assert candidate(s = \"aabbc\",k = 3,letter = \"a\",repetition = 1) == \"aab\"\n assert candidate(s = \"abacabad\",k = 4,letter = \"a\",repetition = 2) == \"aaaa\"\n assert candidate(s = \"zzzzz\",k = 3,letter = \"z\",repetition = 3) == \"zzz\"\n assert candidate(s = \"abcdedcba\",k = 5,letter = \"d\",repetition = 1) == \"abcda\"\n assert candidate(s = \"zzzzzaaaaa\",k = 5,letter = \"a\",repetition = 3) == \"aaaaa\"\n assert candidate(s = \"apple\",k = 3,letter = \"p\",repetition = 1) == \"ape\"\n assert candidate(s = \"abacabadabacaba\",k = 7,letter = \"a\",repetition = 3) == \"aaaaaaa\"\n assert candidate(s = \"azbzczdz\",k = 4,letter = \"z\",repetition = 2) == \"abzz\"\n assert candidate(s = \"abcdedcba\",k = 5,letter = \"c\",repetition = 1) == \"abcba\"\n assert candidate(s = \"xyzxyzxyz\",k = 5,letter = \"z\",repetition = 2) == \"xxyzz\"\n assert candidate(s = \"abcdedcba\",k = 5,letter = \"c\",repetition = 2) == \"abcca\"\n assert candidate(s = \"zzzz\",k = 2,letter = \"z\",repetition = 2) == \"zz\"\n assert candidate(s = \"abcabcabc\",k = 6,letter = \"a\",repetition = 2) == \"aababc\"\n assert candidate(s = \"abcdabcdabcd\",k = 9,letter = \"b\",repetition = 3) == \"ababcabcd\"\n assert candidate(s = \"elephant\",k = 4,letter = \"e\",repetition = 1) == \"eant\"\n assert candidate(s = \"zazbzazbzazb\",k = 8,letter = \"z\",repetition = 4) == \"abzazbzz\"\n assert candidate(s = \"babcbabcbabc\",k = 5,letter = \"b\",repetition = 3) == \"aabbb\"\n assert candidate(s = \"abcdedcbaabcdedcbaabcdedcba\",k = 15,letter = \"c\",repetition = 3) == \"aaabcaabcdedcba\"\n assert candidate(s = \"aaaaaaaaaaaabbbbbbbbbbccccccccccdddddddddd\",k = 20,letter = \"c\",repetition = 4) == \"aaaaaaaaaaaabbbbcccc\"\n assert candidate(s = \"aaaaaabbbbbbcccccc\",k = 12,letter = \"b\",repetition = 4) == \"aaaaaabbbbbb\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\",k = 26,letter = \"z\",repetition = 1) == \"aabcdefghijklmnopqrstuvwxz\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 13,letter = \"m\",repetition = 1) == \"abcdefghijklm\"\n assert candidate(s = \"mississippi\",k = 5,letter = \"i\",repetition = 2) == \"iiipi\"\n assert candidate(s = \"zyxwvutsrqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\",k = 26,letter = \"a\",repetition = 2) == \"ayxwvutsrqponmlkjihgfedcba\"\n assert candidate(s = \"ababababababababababababababababababababababab\",k = 10,letter = \"a\",repetition = 3) == \"aaaaaaaaaa\"\n assert candidate(s = \"xyzyxyzyxyzyxyzyzyzyxyzyzyzyzyzyxyzyxyzyzyzyzyzy\",k = 15,letter = \"x\",repetition = 3) == \"xxxxxxxyyyyzyzy\"\n assert candidate(s = \"aabbccddeeff\",k = 8,letter = \"c\",repetition = 3) == \"aabbccd\"\n assert candidate(s = \"zzzzzaaaaabbbb\",k = 10,letter = \"a\",repetition = 4) == \"zaaaaabbbb\"\n assert candidate(s = \"mississippi\",k = 4,letter = \"i\",repetition = 2) == \"iiii\"\n assert candidate(s = \"mississippi\",k = 6,letter = \"i\",repetition = 2) == \"iiippi\"\n assert candidate(s = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",k = 50,letter = \"z\",repetition = 10) == \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\"\n assert candidate(s = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",k = 20,letter = \"a\",repetition = 2) == \"aabbccddeeffgghhiijj\"\n assert candidate(s = \"banana\",k = 4,letter = \"a\",repetition = 2) == \"aana\"\n assert candidate(s = \"abcdabcdabcd\",k = 8,letter = \"b\",repetition = 3) == \"abababcd\"\n assert candidate(s = \"abcdefghijklmnopqrstuvwxyz\",k = 10,letter = \"m\",repetition = 2) == \"abcdefghm\"\n assert candidate(s = \"abracadabra\",k = 7,letter = \"a\",repetition = 3) == \"aaaabra\"\n assert candidate(s = \"zyxzyxzyx\",k = 5,letter = \"x\",repetition = 2) == \"xxzyx\"\n assert candidate(s = \"abracadabraabracadabra\",k = 12,letter = \"a\",repetition = 4) == \"aaaaaaaaabra\"\n assert candidate(s = \"racecar\",k = 5,letter = \"e\",repetition = 1) == \"acear\"\n assert candidate(s = \"abcdabcabcabc\",k = 9,letter = \"c\",repetition = 3) == \"aabcabcac\"\n assert candidate(s = \"qwertyuiopasdfghjklzxcvbnmqwerty\",k = 12,letter = \"r\",repetition = 2) == \"erabnmqwerty\"\n assert candidate(s = \"xyzyzyzyzyx\",k = 7,letter = \"y\",repetition = 3) == \"xyyyyyx\"\n"}, "metadata": {"canonical_parameter_names": ["s", "k", "letter", "repetition"], "leetcode_dataset_entry_point": "Solution().smallestSubsequence", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string smallestSubsequence(string s, int k, char letter, int repetition) {", "container": "Solution", "callable": "smallestSubsequence", "parameters": [{"name": "s", "type": "string"}, {"name": "k", "type": "int"}, {"name": "letter", "type": "char"}, {"name": "repetition", "type": "int"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2032, "task_id": "two-out-of-three", "difficulty": "Easy", "problem_description": "Given three integer arrays nums1, nums2, and nums3, return a distinct array containing all the values that are present in at least two out of the three arrays. You may return the values in any order.\n \nExample 1:\n\nInput: nums1 = [1,1,3,2], nums2 = [2,3], nums3 = [3]\nOutput: [3,2]\nExplanation: The values that are present in at least two arrays are:\n- 3, in all three arrays.\n- 2, in nums1 and nums2.\n\nExample 2:\n\nInput: nums1 = [3,1], nums2 = [2,3], nums3 = [1,2]\nOutput: [2,3,1]\nExplanation: The values that are present in at least two arrays are:\n- 2, in nums2 and nums3.\n- 3, in nums1 and nums2.\n- 1, in nums1 and nums3.\n\nExample 3:\n\nInput: nums1 = [1,2,2], nums2 = [4,3,3], nums3 = [5]\nOutput: []\nExplanation: No value is present in at least two arrays.\n\n \nConstraints:\n\n1 <= nums1.length, nums2.length, nums3.length <= 100\n1 <= nums1[i], nums2[j], nums3[k] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [5, 6, 7],nums2 = [5, 6, 8],nums3 = [7, 6, 9]) == [5, 6, 7]\n assert candidate(nums1 = [100],nums2 = [100],nums3 = [100]) == [100]\n assert candidate(nums1 = [5, 5, 5],nums2 = [5, 5, 5],nums3 = [5, 5, 5]) == [5]\n assert candidate(nums1 = [10, 20, 30],nums2 = [40, 50, 60],nums3 = [10, 50, 90]) == [10, 50]\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6],nums3 = [7, 8, 9]) == []\n assert candidate(nums1 = [10, 20, 30],nums2 = [20, 30, 40],nums3 = [30, 40, 50]) == [20, 30, 40]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1],nums3 = [1, 3, 5, 7, 9]) == [1, 2, 3, 4, 5]\n assert candidate(nums1 = [1, 2],nums2 = [2, 3],nums3 = [3, 4]) == [2, 3]\n assert candidate(nums1 = [1, 2, 2],nums2 = [4, 3, 3],nums3 = [5]) == []\n assert candidate(nums1 = [1, 1, 3, 2],nums2 = [2, 3],nums3 = [3]) == [2, 3]\n assert candidate(nums1 = [3, 1],nums2 = [2, 3],nums3 = [1, 2]) == [1, 2, 3]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 6, 7, 8, 9],nums3 = [3, 4, 5, 10, 11]) == [3, 4, 5]\n assert candidate(nums1 = [10],nums2 = [10, 20],nums3 = [10, 30]) == [10]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14],nums3 = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums3 = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == []\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [15, 25, 35, 45, 55],nums3 = [20, 30, 40, 50, 60]) == [20, 30, 40, 50]\n assert candidate(nums1 = [1, 2, 3, 1, 2, 3],nums2 = [3, 4, 5, 3, 4, 5],nums3 = [5, 6, 7, 5, 6, 7]) == [3, 5]\n assert candidate(nums1 = [99, 98, 97, 96, 95],nums2 = [94, 93, 92, 91, 90],nums3 = [95, 94, 93, 92, 91]) == [91, 92, 93, 94, 95]\n assert candidate(nums1 = [6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5],nums3 = [5, 6, 7]) == [5, 6, 7]\n assert candidate(nums1 = [50, 50, 50, 50],nums2 = [50, 50, 50, 50],nums3 = [50, 50, 50, 50]) == [50]\n assert candidate(nums1 = [5, 10, 15, 20],nums2 = [10, 20, 30, 40],nums3 = [15, 20, 25, 30]) == [10, 15, 20, 30]\n assert candidate(nums1 = [50, 51, 52, 53, 54, 55],nums2 = [55, 56, 57, 58, 59],nums3 = [59, 60, 61, 62, 63]) == [55, 59]\n assert candidate(nums1 = [7, 7, 7, 7, 7],nums2 = [7, 7, 7, 7, 8],nums3 = [7, 7, 7, 7, 9]) == [7]\n assert candidate(nums1 = [15, 25, 35, 45, 55],nums2 = [55, 65, 75, 85, 95],nums3 = [15, 25, 35, 45, 55]) == [15, 25, 35, 45, 55]\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [2, 2, 2, 2, 2],nums3 = [1, 2, 3, 4, 5]) == [1, 2]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45],nums3 = [10, 25, 40, 55]) == [10, 25, 40]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [5, 15, 25, 35, 45],nums3 = [10, 20, 30, 40, 50]) == [10, 20, 30, 40, 50]\n assert candidate(nums1 = [60, 61, 62, 63],nums2 = [63, 64, 65, 66],nums3 = [66, 67, 68, 69]) == [63, 66]\n assert candidate(nums1 = [1, 1, 2, 2],nums2 = [2, 2, 3, 3],nums3 = [3, 3, 1, 1]) == [1, 2, 3]\n assert candidate(nums1 = [50, 51, 52, 53, 54],nums2 = [55, 56, 57, 58, 59],nums3 = [50, 51, 52, 53, 54]) == [50, 51, 52, 53, 54]\n assert candidate(nums1 = [1, 1, 1, 2, 2, 3],nums2 = [2, 2, 2, 3, 3, 3],nums3 = [3, 3, 3, 4, 4, 4]) == [2, 3]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [50, 60, 70, 80, 90],nums3 = [90, 10, 20, 30, 100]) == [10, 20, 30, 50, 90]\n assert candidate(nums1 = [10, 20, 30, 40],nums2 = [40, 50, 60],nums3 = [10, 50, 70]) == [10, 40, 50]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6],nums2 = [2, 3, 4, 5, 6, 7],nums3 = [3, 4, 5, 6, 7, 8]) == [2, 3, 4, 5, 6, 7]\n assert candidate(nums1 = [99, 98, 97],nums2 = [96, 95, 94],nums3 = [93, 92, 91]) == []\n assert candidate(nums1 = [7, 14, 21, 28],nums2 = [14, 28, 42, 56],nums3 = [21, 42, 63, 84]) == [14, 21, 28, 42]\n assert candidate(nums1 = [99, 100],nums2 = [1, 2],nums3 = [3, 4]) == []\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 1, 1, 1],nums3 = [2, 2, 2, 2]) == [1]\n assert candidate(nums1 = [90, 91, 92],nums2 = [91, 92, 93],nums3 = [92, 93, 94]) == [91, 92, 93]\n assert candidate(nums1 = [10, 20, 30],nums2 = [20, 30, 40],nums3 = [30, 40, 50]) == [20, 30, 40]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [4, 5, 6, 7, 8],nums3 = [5, 8, 9, 10, 11]) == [4, 5, 8]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 4, 3, 2, 1],nums3 = [1, 3, 5, 7, 9]) == [1, 2, 3, 4, 5]\n assert candidate(nums1 = [20, 30, 40, 50],nums2 = [50, 60, 70, 80],nums3 = [80, 90, 100, 20]) == [20, 50, 80]\n assert candidate(nums1 = [10, 20, 30],nums2 = [30, 40, 50],nums3 = [50, 60, 70]) == [30, 50]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums3 = [21, 22, 23, 24, 25, 1, 2, 3]) == [1, 2, 3]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums3 = [5, 10, 15, 20]) == [5, 10, 15, 20]\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],nums3 = [1, 4, 7, 10]) == [1, 4, 7, 10]\n assert candidate(nums1 = [10, 20, 30],nums2 = [30, 40, 50],nums3 = [50, 60, 70, 10]) == [10, 30, 50]\n assert candidate(nums1 = [99, 98, 97, 96, 95],nums2 = [94, 95, 96, 97, 98],nums3 = [93, 94, 95, 96, 97]) == [94, 95, 96, 97, 98]\n assert candidate(nums1 = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],nums2 = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],nums3 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]\n assert candidate(nums1 = [4, 5, 6],nums2 = [7, 8, 9],nums3 = [4, 7, 10]) == [4, 7]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [4, 5, 6, 7, 8],nums3 = [7, 8, 9, 10, 1]) == [1, 4, 5, 7, 8]\n assert candidate(nums1 = [10, 20, 30, 40],nums2 = [30, 40, 50, 60],nums3 = [50, 60, 70, 80]) == [30, 40, 50, 60]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [60, 70, 80, 90, 10],nums3 = [11, 22, 33, 44, 50]) == [10, 50]\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],nums3 = [1, 3, 5, 7, 9]) == [1, 3, 5, 7, 9]\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11],nums2 = [2, 4, 6, 8, 10, 12],nums3 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(nums1 = [10, 20, 30, 40],nums2 = [20, 30, 40, 50],nums3 = [30, 40, 50, 60]) == [20, 30, 40, 50]\n assert candidate(nums1 = [10],nums2 = [20, 30, 40, 50, 10],nums3 = [10, 60, 70, 80, 90]) == [10]\n assert candidate(nums1 = [9, 8, 7, 6, 5, 4, 3, 2, 1],nums2 = [1, 3, 5, 7, 9],nums3 = [2, 4, 6, 8, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 6, 7, 8, 9],nums3 = [9, 1, 2, 3]) == [1, 2, 3, 5, 9]\n assert candidate(nums1 = [25, 50, 75, 100],nums2 = [50, 100, 125, 150],nums3 = [100, 150, 200, 25]) == [25, 50, 100]\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],nums3 = [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6],nums3 = [7, 8, 9]) == []\n assert candidate(nums1 = [60, 61, 62, 63, 64],nums2 = [65, 66, 67, 68, 69],nums3 = [60, 61, 62, 63, 64, 65]) == [60, 61, 62, 63, 64, 65]\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 2, 3, 4],nums3 = [1, 5, 6, 7]) == [1]\n assert candidate(nums1 = [90, 91, 92, 93],nums2 = [91, 92, 93, 94],nums3 = [92, 93, 94, 95]) == [91, 92, 93, 94]\n assert candidate(nums1 = [10, 20, 30],nums2 = [30, 40, 50],nums3 = [50, 60, 10]) == [10, 30, 50]\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],nums3 = [1, 5, 9, 10, 11]) == [1, 5, 9, 10]\n assert candidate(nums1 = [1, 2],nums2 = [1, 3],nums3 = [1, 4]) == [1]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [10, 20, 60, 70, 80],nums3 = [30, 40, 50, 60, 90]) == [10, 20, 30, 40, 50, 60]\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],nums3 = [3, 6, 9, 12]) == [3, 6, 9]\n assert candidate(nums1 = [1, 1, 1, 1],nums2 = [1, 2, 2, 2],nums3 = [1, 2, 3, 3]) == [1, 2]\n assert candidate(nums1 = [99, 98, 97],nums2 = [97, 96, 95],nums3 = [95, 94, 93]) == [95, 97]\n assert candidate(nums1 = [50, 51, 52, 53, 54],nums2 = [50, 55, 56, 57, 58],nums3 = [50, 51, 59, 60, 61]) == [50, 51]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [5, 6, 7, 8, 9],nums3 = [9, 10, 1, 11, 12]) == [1, 5, 9]\n assert candidate(nums1 = [1, 4, 7, 9],nums2 = [2, 4, 7, 10],nums3 = [3, 4, 8, 9]) == [4, 7, 9]\n assert candidate(nums1 = [7, 8, 9],nums2 = [10, 11, 12],nums3 = [13, 14, 15]) == []\n assert candidate(nums1 = [25, 50, 75],nums2 = [50, 100],nums3 = [25, 50, 125]) == [25, 50]\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [3, 4, 5, 6, 7],nums3 = [5, 6, 7, 8, 9]) == [3, 4, 5, 6, 7]\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6],nums3 = [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [1, 20, 31, 42, 53, 64, 75, 86, 97, 108],nums3 = [3, 22, 33, 44, 55, 66, 77, 88, 99, 100]) == [20, 100]\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [20, 30, 40, 50, 60],nums3 = [30, 40, 50, 60, 70]) == [20, 30, 40, 50, 60]\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],nums3 = [5, 10, 15, 20, 25]) == [5, 10]\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],nums3 = [3, 4, 5, 6, 7]) == [3, 4, 5, 6, 7]\n assert candidate(nums1 = [2, 4, 6, 8, 10],nums2 = [1, 3, 5, 7, 9],nums3 = [2, 4, 6, 8, 10]) == [2, 4, 6, 8, 10]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1],nums3 = [3, 4, 5, 6, 7, 8, 9, 10, 1, 2]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums1 = [5, 10, 15, 20, 25],nums2 = [25, 30, 35, 40, 45],nums3 = [45, 50, 55, 60, 65]) == [25, 45]\n assert candidate(nums1 = [1, 2, 3],nums2 = [1, 2, 4, 5],nums3 = [2, 3, 4, 6]) == [1, 2, 3, 4]\n assert candidate(nums1 = [5, 10, 15, 20, 25],nums2 = [10, 15, 20, 25, 30],nums3 = [15, 20, 25, 30, 35]) == [10, 15, 20, 25, 30]\n assert candidate(nums1 = [33, 44, 55, 66],nums2 = [22, 33, 44, 55],nums3 = [11, 22, 33, 44]) == [22, 33, 44, 55]\n assert candidate(nums1 = [20, 30, 40, 50],nums2 = [20, 30, 40],nums3 = [20, 30]) == [20, 30, 40]\n assert candidate(nums1 = [5, 15, 25, 35],nums2 = [5, 15, 45, 55],nums3 = [5, 25, 45, 65]) == [5, 15, 25, 45]\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20],nums3 = [1, 11, 3, 13, 5, 15, 7, 17, 9, 19]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],nums3 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3],nums2 = [1, 2, 3, 4, 5, 6],nums3 = [3, 4, 5, 6, 7, 8]) == [1, 2, 3, 4, 5, 6]\n assert candidate(nums1 = [11, 22, 33, 44, 55],nums2 = [55, 66, 77, 88, 99],nums3 = [99, 11, 22, 33, 111]) == [11, 22, 33, 55, 99]\n assert candidate(nums1 = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums3 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [1, 2, 3, 4, 5, 7, 9]\n assert candidate(nums1 = [90, 91, 92],nums2 = [92, 93, 94],nums3 = [94, 95, 96, 97, 90]) == [90, 92, 94]\n assert candidate(nums1 = [1, 1, 2, 2, 3],nums2 = [3, 3, 4, 4, 5],nums3 = [5, 5, 6, 6, 7]) == [3, 5]\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 2],nums3 = [2, 2, 2, 2, 2]) == [1, 2]\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2", "nums3"], "leetcode_dataset_entry_point": "Solution().twoOutOfThree", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector twoOutOfThree(vector& nums1, vector& nums2, vector& nums3) {", "container": "Solution", "callable": "twoOutOfThree", "parameters": [{"name": "nums1", "type": "vector&"}, {"name": "nums2", "type": "vector&"}, {"name": "nums3", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2033, "task_id": "minimum-operations-to-make-a-uni-value-grid", "difficulty": "Medium", "problem_description": "You are given a 2D integer grid of size m x n and an integer x. In one operation, you can add x to or subtract x from any element in the grid.\nA uni-value grid is a grid where all the elements of it are equal.\nReturn the minimum number of operations to make the grid uni-value. If it is not possible, return -1.\n \nExample 1:\n\n\nInput: grid = [[2,4],[6,8]], x = 2\nOutput: 4\nExplanation: We can make every element equal to 4 by doing the following: \n- Add x to 2 once.\n- Subtract x from 6 once.\n- Subtract x from 8 twice.\nA total of 4 operations were used.\n\nExample 2:\n\n\nInput: grid = [[1,5],[2,3]], x = 1\nOutput: 5\nExplanation: We can make every element equal to 3.\n\nExample 3:\n\n\nInput: grid = [[1,2],[3,4]], x = 2\nOutput: -1\nExplanation: It is impossible to make every element equal.\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 105\n1 <= m * n <= 105\n1 <= x, grid[i][j] <= 104\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[1, 5], [2, 3]],x = 1) == 5\n assert candidate(grid = [[10, 10], [10, 10]],x = 5) == 0\n assert candidate(grid = [[10, 10], [10, 10]],x = 3) == 0\n assert candidate(grid = [[10, 12], [14, 16]],x = 2) == 4\n assert candidate(grid = [[5, 5, 5], [5, 5, 5], [5, 5, 5]],x = 1) == 0\n assert candidate(grid = [[2, 4], [6, 8]],x = 2) == 4\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],x = 1) == 20\n assert candidate(grid = [[1, 2], [3, 4]],x = 2) == -1\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],x = 5) == 0\n assert candidate(grid = [[1, 1, 1], [1, 1, 1]],x = 3) == 0\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],x = 2) == -1\n assert candidate(grid = [[1, 1], [2, 2]],x = 3) == -1\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 1, 1]],x = 1) == 0\n assert candidate(grid = [[1, 2, 3], [6, 5, 4], [7, 8, 9]],x = 1) == 20\n assert candidate(grid = [[1, 3, 5, 7], [9, 11, 13, 15], [17, 19, 21, 23]],x = 2) == 36\n assert candidate(grid = [[7, 14, 21, 28, 35], [42, 49, 56, 63, 70], [77, 84, 91, 98, 105], [112, 119, 126, 133, 140]],x = 7) == 100\n assert candidate(grid = [[100, 200, 300], [400, 500, 600], [700, 800, 900]],x = 100) == 20\n assert candidate(grid = [[5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],x = 1) == 36\n assert candidate(grid = [[1, 2, 3, 4, 5, 6], [7, 8, 9, 10, 11, 12], [13, 14, 15, 16, 17, 18]],x = 1) == 81\n assert candidate(grid = [[1, 2], [3, 4], [5, 6]],x = 1) == 9\n assert candidate(grid = [[1, 5, 9], [13, 17, 21], [25, 29, 33]],x = 4) == 20\n assert candidate(grid = [[7, 14, 21], [14, 28, 42], [21, 42, 63]],x = 7) == 17\n assert candidate(grid = [[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]],x = 1) == 8\n assert candidate(grid = [[2, 4, 6, 8], [10, 12, 14, 16], [18, 20, 22, 24]],x = 2) == 36\n assert candidate(grid = [[1, 2], [3, 4], [5, 7]],x = 2) == -1\n assert candidate(grid = [[7, 7, 7], [7, 8, 7], [7, 7, 7]],x = 1) == 1\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],x = 1) == 0\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]],x = 2) == -1\n assert candidate(grid = [[7, 11, 15], [19, 23, 27], [31, 35, 39]],x = 2) == 40\n assert candidate(grid = [[1, 1, 1], [2, 2, 2], [3, 3, 3]],x = 1) == 6\n assert candidate(grid = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],x = 15) == -1\n assert candidate(grid = [[1, 3, 5, 7, 9], [2, 4, 6, 8, 10], [3, 5, 7, 9, 11]],x = 2) == -1\n assert candidate(grid = [[3, 6, 9, 12], [15, 18, 21, 24], [27, 30, 33, 36], [39, 42, 45, 48]],x = 3) == 64\n assert candidate(grid = [[100, 200], [300, 400]],x = 100) == 4\n assert candidate(grid = [[1001, 1002, 1003, 1004], [1005, 1006, 1007, 1008], [1009, 1010, 1011, 1012]],x = 1) == 36\n assert candidate(grid = [[3, 6, 9, 12], [6, 12, 18, 24], [9, 18, 27, 36], [12, 24, 36, 48]],x = 3) == 54\n assert candidate(grid = [[1, 3, 5], [7, 9, 11], [13, 15, 17]],x = 2) == 20\n assert candidate(grid = [[1, 1, 1], [1, 1, 1], [1, 2, 1]],x = 1) == 1\n assert candidate(grid = [[5000, 5000, 5000], [5000, 5000, 5000], [5000, 5000, 5000]],x = 1000) == 0\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],x = 3) == -1\n assert candidate(grid = [[5, 10, 15], [20, 25, 30], [35, 40, 45]],x = 5) == 20\n assert candidate(grid = [[2, 4, 6], [8, 10, 12], [14, 16, 18]],x = 2) == 20\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]],x = 7) == -1\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],x = 1) == 100\n assert candidate(grid = [[10, 20, 30, 40, 50], [60, 70, 80, 90, 100]],x = 10) == 25\n assert candidate(grid = [[10, 20, 30], [20, 30, 40], [30, 40, 50]],x = 10) == 8\n assert candidate(grid = [[2, 4, 6], [8, 10, 12], [14, 16, 18]],x = 5) == -1\n assert candidate(grid = [[4, 8, 12, 16], [8, 16, 24, 32], [12, 24, 36, 48], [16, 32, 48, 64]],x = 4) == 54\n assert candidate(grid = [[4, 8, 12], [16, 20, 24], [28, 32, 36]],x = 4) == 20\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 2]],x = 1) == 1\n assert candidate(grid = [[101, 202, 303], [404, 505, 606], [707, 808, 909]],x = 101) == 20\n assert candidate(grid = [[7, 14, 21, 28], [35, 42, 49, 56], [63, 70, 77, 84]],x = 7) == 36\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]],x = 5) == -1\n assert candidate(grid = [[1, 3, 5, 7, 9], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29]],x = 2) == 56\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],x = 4) == -1\n assert candidate(grid = [[1, 5, 9], [2, 6, 10], [3, 7, 11]],x = 2) == -1\n assert candidate(grid = [[1, 3, 5, 7, 9], [11, 13, 15, 17, 19], [21, 23, 25, 27, 29], [31, 33, 35, 37, 39]],x = 2) == 100\n assert candidate(grid = [[101, 102, 103], [104, 105, 106], [107, 108, 109]],x = 1) == 20\n assert candidate(grid = [[1, 4, 7, 10], [13, 16, 19, 22], [25, 28, 31, 34]],x = 3) == 36\n assert candidate(grid = [[1, 2, 3], [2, 3, 4], [3, 4, 5]],x = 1) == 8\n assert candidate(grid = [[1, 5, 9], [2, 6, 10], [3, 7, 11]],x = 3) == -1\n assert candidate(grid = [[5, 5, 5], [5, 5, 5], [5, 5, 10]],x = 5) == 1\n assert candidate(grid = [[5, 10, 15, 20], [25, 30, 35, 40], [45, 50, 55, 60]],x = 5) == 36\n assert candidate(grid = [[1, 2, 3], [4, 5, 6], [7, 8, 9]],x = 10) == -1\n assert candidate(grid = [[5, 9, 13], [17, 21, 25], [29, 33, 37]],x = 4) == 20\n assert candidate(grid = [[3, 6, 9], [12, 15, 18], [21, 24, 27]],x = 3) == 20\n assert candidate(grid = [[10, 20, 30], [40, 50, 60], [70, 80, 90]],x = 10) == 20\n assert candidate(grid = [[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1]],x = 5) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 2, 1, 1]],x = 1) == 1\n assert candidate(grid = [[3, 3, 3, 3, 3], [3, 3, 3, 3, 3], [3, 3, 3, 3, 4]],x = 1) == 1\n assert candidate(grid = [[3, 9, 15], [12, 15, 18], [21, 24, 27]],x = 3) == 17\n assert candidate(grid = [[5, 15, 25, 35], [45, 55, 65, 75], [85, 95, 105, 115], [125, 135, 145, 155]],x = 10) == 64\n assert candidate(grid = [[2, 4, 6], [8, 10, 12], [14, 16, 18]],x = 3) == -1\n assert candidate(grid = [[100, 102, 104], [106, 108, 110], [112, 114, 116]],x = 2) == 20\n assert candidate(grid = [[3, 9, 15], [21, 27, 33], [39, 45, 51]],x = 6) == 20\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 2, 1]],x = 1) == 1\n assert candidate(grid = [[5, 15, 25], [35, 45, 55], [65, 75, 85]],x = 10) == 20\n assert candidate(grid = [[1, 1, 1, 2], [1, 1, 2, 2], [1, 2, 2, 3]],x = 1) == 7\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]],x = 1) == 0\n assert candidate(grid = [[123, 456, 789], [1011, 1213, 1415], [1617, 1819, 2021]],x = 3) == -1\n assert candidate(grid = [[1, 3, 5, 7], [9, 11, 13, 15], [17, 19, 21, 23], [25, 27, 29, 31]],x = 2) == 64\n assert candidate(grid = [[5, 10, 15, 20], [10, 20, 30, 40], [15, 30, 45, 60]],x = 5) == 30\n assert candidate(grid = [[2, 4, 6, 8, 10], [12, 14, 16, 18, 20], [22, 24, 26, 28, 30]],x = 2) == 56\n assert candidate(grid = [[1, 5, 9, 13, 17], [21, 25, 29, 33, 37], [41, 45, 49, 53, 57]],x = 4) == 56\n assert candidate(grid = [[2, 4, 6, 8], [10, 12, 14, 16], [18, 20, 22, 24], [26, 28, 30, 32]],x = 2) == 64\n assert candidate(grid = [[7, 14, 21], [28, 35, 42], [49, 56, 63]],x = 7) == 20\n assert candidate(grid = [[10, 20, 30, 40], [50, 60, 70, 80], [90, 100, 110, 120]],x = 10) == 36\n assert candidate(grid = [[5, 15, 25, 35], [45, 55, 65, 75], [85, 95, 105, 115]],x = 10) == 36\n assert candidate(grid = [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]],x = 1) == 36\n assert candidate(grid = [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15]],x = 1) == 56\n assert candidate(grid = [[3, 6, 9, 12], [15, 18, 21, 24], [27, 30, 33, 36]],x = 3) == 36\n assert candidate(grid = [[1, 4, 7, 10], [2, 5, 8, 11], [3, 6, 9, 12]],x = 3) == -1\n assert candidate(grid = [[4, 8, 12, 16], [20, 24, 28, 32], [36, 40, 44, 48]],x = 4) == 36\n assert candidate(grid = [[2, 4, 6], [8, 10, 12], [14, 16, 18]],x = 1) == 40\n assert candidate(grid = [[11, 22, 33], [44, 55, 66], [77, 88, 99]],x = 11) == 20\n"}, "metadata": {"canonical_parameter_names": ["grid", "x"], "leetcode_dataset_entry_point": "Solution().minOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minOperations(vector>& grid, int x) {", "container": "Solution", "callable": "minOperations", "parameters": [{"name": "grid", "type": "vector>&"}, {"name": "x", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2035, "task_id": "partition-array-into-two-arrays-to-minimize-sum-difference", "difficulty": "Hard", "problem_description": "You are given an integer array nums of 2 * n integers. You need to partition nums into two arrays of length n to minimize the absolute difference of the sums of the arrays. To partition nums, put each element of nums into one of the two arrays.\nReturn the minimum possible absolute difference.\n \nExample 1:\n\n\nInput: nums = [3,9,7,3]\nOutput: 2\nExplanation: One optimal partition is: [3,9] and [7,3].\nThe absolute difference between the sums of the arrays is abs((3 + 9) - (7 + 3)) = 2.\n\nExample 2:\n\nInput: nums = [-36,36]\nOutput: 72\nExplanation: One optimal partition is: [-36] and [36].\nThe absolute difference between the sums of the arrays is abs((-36) - (36)) = 72.\n\nExample 3:\n\n\nInput: nums = [2,-1,0,4,-2,-9]\nOutput: 0\nExplanation: One optimal partition is: [2,4,-9] and [-1,0,-2].\nThe absolute difference between the sums of the arrays is abs((2 + 4 + -9) - (-1 + 0 + -2)) = 0.\n\n \nConstraints:\n\n1 <= n <= 15\nnums.length == 2 * n\n-107 <= nums[i] <= 107\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [3, 9, 7, 3]) == 2\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8]) == 0\n assert candidate(nums = [10000000, -10000000, 10000000, -10000000, 10000000, -10000000, 10000000, -10000000]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 0\n assert candidate(nums = [10000000, -10000000, 5000000, -5000000, 2500000, -2500000]) == 5000000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 30]) == 0\n assert candidate(nums = [10000000, -10000000, 5000000, -5000000, 2500000, -2500000, 1250000, -1250000]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [2, -1, 0, 4, -2, -9]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8]) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40]) == 0\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 0\n assert candidate(nums = [10000000, -10000000, 10000000, -10000000, 10000000, -10000000, 10000000, -10000000, 10000000, -10000000, 10000000, -10000000, 10000000, -10000000, 10000000, -10000000]) == 0\n assert candidate(nums = [10000000, -10000000, 10000000, -10000000, 10000000, -10000000]) == 20000000\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600]) == 0\n assert candidate(nums = [-36, 36]) == 72\n assert candidate(nums = [-1, -2, -3, -4, -5, -6]) == 1\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16]) == 0\n assert candidate(nums = [-1000, 1000, -1500, 1500, -2000, 2000, -2500, 2500, -3000, 3000, -3500, 3500, -4000, 4000, -4500, 4500]) == 0\n assert candidate(nums = [987654, -987654, 876543, -876543, 765432, -765432, 654321, -654321, 543210, -543210, 432109, -432109, 321098, -321098, 210987, -210987]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 0\n assert candidate(nums = [1000000, -1000000, 500000, -500000, 250000, -250000, 125000, -125000, 62500, -62500, 31250, -31250, 15625, -15625, 7812, -7812]) == 0\n assert candidate(nums = [5, -5, 15, -15, 25, -25, 35, -35, 45, -45, 55, -55, 65, -65, 75, -75]) == 0\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500, 600, -600, 700, -700, 800, -800]) == 0\n assert candidate(nums = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]) == 0\n assert candidate(nums = [1234567, -7654321, 8901234, -4321098, 5678901, -1234567, 8765432, -2345678, 9876543, -3456789, 4567890, -5678901, 6789012, -6789012, 7890123, -7890123]) == 7307\n assert candidate(nums = [1000000, -1000000, 2000000, -2000000, 3000000, -3000000, 4000000, -4000000, 5000000, -5000000, 6000000, -6000000, 7000000, -7000000, 8000000, -8000000]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 1\n assert candidate(nums = [10000000, 10000000, 10000000, 10000000, 10000000, 10000000, -10000000, -10000000, -10000000, -10000000, -10000000, -10000000]) == 0\n assert candidate(nums = [0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1, 0, 1, 0, -1]) == 0\n assert candidate(nums = [-9, 9, -8, 8, -7, 7, -6, 6, -5, 5, -4, 4, -3, 3, -2, 2]) == 0\n assert candidate(nums = [-1000, 1000, -2000, 2000, -3000, 3000, -4000, 4000, -5000, 5000, -6000, 6000, -7000, 7000, -8000, 8000]) == 0\n assert candidate(nums = [1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16]) == 0\n assert candidate(nums = [-1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1]) == 0\n assert candidate(nums = [12345, -12345, 67890, -67890, 11111, -11111, 22222, -22222, 33333, -33333, 44444, -44444, 55555, -55555, 66666, -66666]) == 0\n assert candidate(nums = [123, 456, 789, -123, -456, -789, 321, 654, 987, -321, -654, -987, 234, 567, 890, -234, -567, -890]) == 4\n assert candidate(nums = [10000000, -10000000, 20000000, -20000000, 30000000, -30000000, 40000000, -40000000, 50000000, -50000000, 60000000, -60000000, 70000000, -70000000, 80000000, -80000000]) == 0\n assert candidate(nums = [-1, 2, -3, 4, -5, 6, -7, 8, -9, 10, -11, 12, -13, 14, -15, 16]) == 0\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000]) == 0\n assert candidate(nums = [-10000, 10000, -20000, 20000, -30000, 30000, -40000, 40000, -50000, 50000, -60000, 60000, -70000, 70000, -80000, 80000]) == 0\n assert candidate(nums = [5, 2, 9, 11, 15, 18, 3, 7, 14, 6, 10, 4, 8, 13, 1, 12]) == 0\n assert candidate(nums = [100000, -100000, 200000, -200000, 300000, -300000, 400000, -400000, 500000, -500000, 600000, -600000, 700000, -700000, 800000, -800000]) == 0\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8]) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8]) == 0\n assert candidate(nums = [-100, -200, -300, -400, -500, 500, 400, 300, 200, 100, 0, 100, 200, 300, 400, 500]) == 100\n assert candidate(nums = [9999999, -9999999, 4999999, -4999999, 2499999, -2499999, 1249999, -1249999, 624999, -624999, 312499, -312499, 156249, -156249, 78124, -78124]) == 0\n assert candidate(nums = [1000, -500, 2000, -1500, 3000, -2500, 4000, -3500, 5000, -4500, 6000, -5500, 7000, -6500, 8000, -7500]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 0\n assert candidate(nums = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 0\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10, 11, -11, 12, -12, 13, -13, 14, -14, 15, -15]) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80]) == 0\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000, 1100, -1200, 1300, -1400, 1500, -1600]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15, -16]) == 0\n assert candidate(nums = [1000000, -1000000, 500000, -500000, 250000, -250000, 750000, -750000, 375000, -375000, 187500, -187500, 937500, -937500, 468750, -468750]) == 0\n assert candidate(nums = [-7, -5, -3, -1, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23]) == 0\n assert candidate(nums = [100, 200, 300, 400, -500, 600, -700, 800, -900, 1000, -1100, 1200, -1300, 1400, -1500, 1600]) == 0\n assert candidate(nums = [-5, 5, -10, 10, -15, 15, -20, 20, -25, 25, -30, 30, -35, 35, -40, 40]) == 0\n assert candidate(nums = [-100, 100, -200, 200, -300, 300, -400, 400, -500, 500, -600, 600, -700, 700, -800, 800]) == 0\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80]) == 0\n assert candidate(nums = [-5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5]) == 0\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 0\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 0\n assert candidate(nums = [-10, 10, -20, 20, -30, 30, -40, 40, -50, 50, -60, 60, -70, 70, -80, 80]) == 0\n assert candidate(nums = [23, 45, 67, 89, 12, 34, 56, 78, 90, 11, 33, 55, 77, 99, 22, 44]) == 3\n assert candidate(nums = [10000000, 9000000, 8000000, 7000000, 6000000, 5000000, 4000000, 3000000, 2000000, 1000000, 0, -1000000, -2000000, -3000000, -4000000, -5000000]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000]) == 0\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 0\n assert candidate(nums = [10000000, -9999999, 9999998, -9999997, 9999996, -9999995, 9999994, -9999993, 9999992, -9999991, 9999990, -9999989, 9999988, -9999987, 9999986, -9999985]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 100000]) == 99999\n assert candidate(nums = [9999999, -9999999, 8888888, -8888888, 7777777, -7777777, 6666666, -6666666, 5555555, -5555555, 4444444, -4444444, 3333333, -3333333, 2222222, -2222222]) == 0\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155]) == 0\n assert candidate(nums = [0, 1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8]) == 0\n assert candidate(nums = [5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5, 5, -5]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600]) == 0\n assert candidate(nums = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 0\n assert candidate(nums = [5, 3, 8, 1, 9, 2, 6, 4, 7, 0, 11, 13, 15, 17, 19, 21]) == 1\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85]) == 0\n assert candidate(nums = [1000000, 2000000, 3000000, 4000000, 5000000, 6000000, 7000000, 8000000, 9000000, 10000000, 11000000, 12000000, 13000000, 14000000, 15000000, 16000000]) == 0\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15, -16]) == 0\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumDifference", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumDifference(vector& nums) {", "container": "Solution", "callable": "minimumDifference", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2037, "task_id": "minimum-number-of-moves-to-seat-everyone", "difficulty": "Easy", "problem_description": "There are n availabe seats and n students standing in a room. You are given an array seats of length n, where seats[i] is the position of the ith seat. You are also given the array students of length n, where students[j] is the position of the jth student.\nYou may perform the following move any number of times:\n\nIncrease or decrease the position of the ith student by 1 (i.e., moving the ith student from position x to x + 1 or x - 1)\n\nReturn the minimum number of moves required to move each student to a seat such that no two students are in the same seat.\nNote that there may be multiple seats or students in the same position at the beginning.\n \nExample 1:\n\nInput: seats = [3,1,5], students = [2,7,4]\nOutput: 4\nExplanation: The students are moved as follows:\n- The first student is moved from position 2 to position 1 using 1 move.\n- The second student is moved from position 7 to position 5 using 2 moves.\n- The third student is moved from position 4 to position 3 using 1 move.\nIn total, 1 + 2 + 1 = 4 moves were used.\n\nExample 2:\n\nInput: seats = [4,1,5,9], students = [1,3,2,6]\nOutput: 7\nExplanation: The students are moved as follows:\n- The first student is not moved.\n- The second student is moved from position 3 to position 4 using 1 move.\n- The third student is moved from position 2 to position 5 using 3 moves.\n- The fourth student is moved from position 6 to position 9 using 3 moves.\nIn total, 0 + 1 + 3 + 3 = 7 moves were used.\n\nExample 3:\n\nInput: seats = [2,2,6,6], students = [1,3,2,6]\nOutput: 4\nExplanation: Note that there are two seats at position 2 and two seats at position 6.\nThe students are moved as follows:\n- The first student is moved from position 1 to position 2 using 1 move.\n- The second student is moved from position 3 to position 6 using 3 moves.\n- The third student is not moved.\n- The fourth student is not moved.\nIn total, 1 + 3 + 0 + 0 = 4 moves were used.\n\n \nConstraints:\n\nn == seats.length == students.length\n1 <= n <= 100\n1 <= seats[i], students[j] <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(seats = [5, 5, 5, 5],students = [5, 5, 5, 5]) == 0\n assert candidate(seats = [10, 20, 30],students = [5, 15, 25]) == 15\n assert candidate(seats = [4, 1, 5, 9],students = [1, 3, 2, 6]) == 7\n assert candidate(seats = [1, 1, 1, 1],students = [1, 1, 1, 1]) == 0\n assert candidate(seats = [3, 1, 5],students = [2, 7, 4]) == 4\n assert candidate(seats = [1, 1, 1],students = [1, 1, 1]) == 0\n assert candidate(seats = [50, 50, 50],students = [49, 50, 51]) == 2\n assert candidate(seats = [10, 20, 30],students = [15, 25, 35]) == 15\n assert candidate(seats = [10, 20, 30],students = [1, 2, 3]) == 54\n assert candidate(seats = [100, 1, 50],students = [50, 100, 1]) == 0\n assert candidate(seats = [10, 20, 30, 40, 50],students = [5, 15, 25, 35, 45]) == 25\n assert candidate(seats = [100, 1, 50, 50],students = [50, 1, 100, 50]) == 0\n assert candidate(seats = [100, 1, 2, 3, 4],students = [1, 2, 3, 4, 100]) == 0\n assert candidate(seats = [100, 90, 80, 70],students = [70, 80, 90, 100]) == 0\n assert candidate(seats = [50, 50, 50],students = [50, 50, 50]) == 0\n assert candidate(seats = [10, 1, 100],students = [5, 10, 99]) == 5\n assert candidate(seats = [1, 2, 3, 4, 5],students = [5, 4, 3, 2, 1]) == 0\n assert candidate(seats = [2, 2, 6, 6],students = [1, 3, 2, 6]) == 4\n assert candidate(seats = [1, 3, 5, 7, 9],students = [2, 4, 6, 8, 10]) == 5\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 495\n assert candidate(seats = [5, 5, 5, 5, 5, 5],students = [1, 2, 3, 4, 5, 6]) == 11\n assert candidate(seats = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 495\n assert candidate(seats = [10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],students = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95]) == 95\n assert candidate(seats = [20, 30, 40, 50, 60, 70, 80],students = [15, 25, 35, 45, 55, 65, 75]) == 35\n assert candidate(seats = [50, 50, 50, 50, 50, 50],students = [45, 45, 45, 55, 55, 55]) == 30\n assert candidate(seats = [3, 3, 8, 8, 10, 10, 13, 13],students = [2, 3, 6, 8, 9, 10, 12, 15]) == 7\n assert candidate(seats = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],students = [95, 85, 75, 65, 55, 45, 35, 25, 15, 5]) == 0\n assert candidate(seats = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],students = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28]) == 20\n assert candidate(seats = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],students = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(seats = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],students = [10, 1, 9, 2, 8, 3, 7, 4, 6, 5]) == 0\n assert candidate(seats = [1, 100, 1, 100, 1, 100],students = [50, 50, 50, 50, 50, 50]) == 297\n assert candidate(seats = [25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25],students = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 300\n assert candidate(seats = [90, 80, 70, 60, 50, 40, 30],students = [10, 20, 30, 40, 50, 60, 70]) == 140\n assert candidate(seats = [1, 100, 1, 100, 1, 100, 1, 100, 1, 100],students = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 495\n assert candidate(seats = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],students = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 250\n assert candidate(seats = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],students = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 30\n assert candidate(seats = [99, 100, 1, 2, 3, 4],students = [5, 6, 7, 8, 9, 1]) == 191\n assert candidate(seats = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100],students = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(seats = [30, 10, 20, 40, 50, 60],students = [5, 15, 25, 35, 45, 55]) == 30\n assert candidate(seats = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 980\n assert candidate(seats = [1, 5, 9, 13, 17, 21, 25, 29],students = [2, 6, 10, 14, 18, 22, 26, 30]) == 8\n assert candidate(seats = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],students = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 9\n assert candidate(seats = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99],students = [99, 97, 95, 93, 91, 89, 87, 85, 83, 81, 79, 77, 75, 73, 71, 69, 67, 65, 63, 61, 59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 0\n assert candidate(seats = [5, 5, 5, 5, 5],students = [1, 2, 3, 4, 5]) == 10\n assert candidate(seats = [2, 2, 2, 3, 3, 3, 5, 5, 5, 6, 6, 6],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 32\n assert candidate(seats = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41],students = [41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 0\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],students = [95, 85, 75, 65, 55, 45, 35, 25, 15, 5]) == 50\n assert candidate(seats = [8, 12, 20, 25, 30, 35],students = [5, 10, 15, 22, 31, 36]) == 15\n assert candidate(seats = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],students = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == 90\n assert candidate(seats = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96],students = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59]) == 450\n assert candidate(seats = [5, 3, 8, 9, 2, 10],students = [4, 6, 7, 1, 11, 15]) == 11\n assert candidate(seats = [5, 20, 35, 50, 65, 80, 95, 110, 125, 140],students = [10, 25, 40, 55, 70, 85, 100, 115, 130, 145]) == 50\n assert candidate(seats = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],students = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29]) == 10\n assert candidate(seats = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],students = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 45\n assert candidate(seats = [50, 50, 50, 50, 50],students = [49, 50, 51, 52, 53]) == 7\n assert candidate(seats = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 130\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],students = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155, 165, 175, 185, 195]) == 100\n assert candidate(seats = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],students = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91]) == 40\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],students = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 0\n assert candidate(seats = [2, 3, 5, 6, 8, 11, 13],students = [1, 4, 7, 9, 10, 12, 15]) == 12\n assert candidate(seats = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],students = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(seats = [10, 25, 40, 55, 70, 85, 100, 115, 130, 145],students = [5, 20, 35, 50, 65, 80, 95, 110, 125, 140]) == 50\n assert candidate(seats = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],students = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 540\n assert candidate(seats = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],students = [1, 7, 13, 19, 24, 29, 34, 38, 44, 49]) == 17\n assert candidate(seats = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6],students = [6, 5, 5, 4, 4, 3, 3, 2, 2, 1]) == 0\n assert candidate(seats = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],students = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1]) == 0\n assert candidate(seats = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 25\n assert candidate(seats = [1, 3, 6, 8, 10, 15],students = [2, 4, 5, 7, 9, 16]) == 6\n assert candidate(seats = [50, 40, 30, 20, 10, 100, 90, 80, 70, 60],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 495\n assert candidate(seats = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],students = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 10\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],students = [1, 11, 21, 31, 41, 51, 61, 71, 81, 91]) == 90\n assert candidate(seats = [3, 8, 15, 22, 29],students = [1, 6, 13, 21, 28]) == 8\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],students = [95, 85, 75, 65, 55, 45, 35, 25, 15, 5, 105, 115, 125, 135, 145]) == 75\n assert candidate(seats = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39],students = [1, 5, 9, 13, 17, 21, 25, 29, 33, 37]) == 20\n assert candidate(seats = [1, 2, 3, 4, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 42\n assert candidate(seats = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],students = [3, 7, 12, 17, 22, 27, 32, 37, 42, 47, 52, 57]) == 35\n assert candidate(seats = [1, 4, 6, 9, 12, 15],students = [3, 5, 7, 10, 13, 16]) == 7\n assert candidate(seats = [10, 10, 20, 20, 30, 30, 40, 40, 50, 50],students = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 210\n assert candidate(seats = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],students = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(seats = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],students = [45, 46, 47, 48, 49, 51, 52, 53, 54, 55]) == 30\n assert candidate(seats = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 100\n assert candidate(seats = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 31\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],students = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 0\n assert candidate(seats = [2, 3, 5, 7, 11, 13, 17, 19],students = [1, 4, 6, 8, 10, 12, 14, 16]) == 12\n assert candidate(seats = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],students = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29]) == 15\n assert candidate(seats = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],students = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 10\n assert candidate(seats = [1, 3, 6, 8, 10, 15],students = [2, 4, 7, 9, 11, 16]) == 6\n assert candidate(seats = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 17\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],students = [9, 19, 29, 39, 49, 59, 69, 79, 89, 99]) == 10\n assert candidate(seats = [95, 96, 97, 98, 99, 100],students = [1, 2, 3, 4, 5, 6]) == 564\n assert candidate(seats = [5, 15, 25, 35, 45, 55],students = [1, 7, 17, 27, 37, 47]) == 44\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],students = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 540\n assert candidate(seats = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],students = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 890\n assert candidate(seats = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],students = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 0\n assert candidate(seats = [5, 6, 8, 10, 15, 17, 20, 25, 30, 35],students = [4, 5, 7, 10, 12, 16, 18, 22, 28, 34]) == 15\n assert candidate(seats = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],students = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == 50\n assert candidate(seats = [2, 2, 4, 4, 6, 6, 8, 8, 10, 10],students = [1, 3, 3, 5, 5, 7, 7, 9, 9, 11]) == 10\n assert candidate(seats = [20, 20, 20, 20, 20],students = [19, 20, 21, 22, 23]) == 7\n assert candidate(seats = [95, 55, 10, 30, 70],students = [5, 90, 60, 40, 80]) == 35\n assert candidate(seats = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],students = [1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19, 21, 22, 23, 24]) == 800\n assert candidate(seats = [1, 2, 2, 3, 4, 4, 5, 5, 6, 6],students = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6]) == 3\n"}, "metadata": {"canonical_parameter_names": ["seats", "students"], "leetcode_dataset_entry_point": "Solution().minMovesToSeat", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minMovesToSeat(vector& seats, vector& students) {", "container": "Solution", "callable": "minMovesToSeat", "parameters": [{"name": "seats", "type": "vector&"}, {"name": "students", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2038, "task_id": "remove-colored-pieces-if-both-neighbors-are-the-same-color", "difficulty": "Medium", "problem_description": "There are n pieces arranged in a line, and each piece is colored either by 'A' or by 'B'. You are given a string colors of length n where colors[i] is the color of the ith piece.\nAlice and Bob are playing a game where they take alternating turns removing pieces from the line. In this game, Alice moves first.\n\nAlice is only allowed to remove a piece colored 'A' if both its neighbors are also colored 'A'. She is not allowed to remove pieces that are colored 'B'.\nBob is only allowed to remove a piece colored 'B' if both its neighbors are also colored 'B'. He is not allowed to remove pieces that are colored 'A'.\nAlice and Bob cannot remove pieces from the edge of the line.\nIf a player cannot make a move on their turn, that player loses and the other player wins.\n\nAssuming Alice and Bob play optimally, return true if Alice wins, or return false if Bob wins.\n \nExample 1:\n\nInput: colors = \"AAABABB\"\nOutput: true\nExplanation:\nAAABABB -> AABABB\nAlice moves first.\nShe removes the second 'A' from the left since that is the only 'A' whose neighbors are both 'A'.\n\nNow it's Bob's turn.\nBob cannot make a move on his turn since there are no 'B's whose neighbors are both 'B'.\nThus, Alice wins, so return true.\n\nExample 2:\n\nInput: colors = \"AA\"\nOutput: false\nExplanation:\nAlice has her turn first.\nThere are only two 'A's and both are on the edge of the line, so she cannot move on her turn.\nThus, Bob wins, so return false.\n\nExample 3:\n\nInput: colors = \"ABBBBBBBAAA\"\nOutput: false\nExplanation:\nABBBBBBBAAA -> ABBBBBBBAA\nAlice moves first.\nHer only option is to remove the second to last 'A' from the right.\n\nABBBBBBBAA -> ABBBBBBAA\nNext is Bob's turn.\nHe has many options for which 'B' piece to remove. He can pick any.\n\nOn Alice's second turn, she has no more pieces that she can remove.\nThus, Bob wins, so return false.\n\n \nConstraints:\n\n1 <= colors.length <= 105\ncolors consists of only the letters 'A' and 'B'\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(colors = \"AABBAABB\") == False\n assert candidate(colors = \"AAAAAAAAA\") == True\n assert candidate(colors = \"AAABAAAAABBBB\") == True\n assert candidate(colors = \"ABABABABAB\") == False\n assert candidate(colors = \"AABBBBAAA\") == False\n assert candidate(colors = \"BBBBB\") == False\n assert candidate(colors = \"BBBAAAABB\") == True\n assert candidate(colors = \"AAAAAAAA\") == True\n assert candidate(colors = \"AAAAA\") == True\n assert candidate(colors = \"AAABBBAAABBBA\") == False\n assert candidate(colors = \"AAABABB\") == True\n assert candidate(colors = \"AABBBBAA\") == False\n assert candidate(colors = \"AAAABBBB\") == False\n assert candidate(colors = \"BBBBBBBBB\") == False\n assert candidate(colors = \"ABBBBBBBAAA\") == False\n assert candidate(colors = \"ABABABABABA\") == False\n assert candidate(colors = \"ABABABAB\") == False\n assert candidate(colors = \"AAAAABBAAA\") == True\n assert candidate(colors = \"AABAABBBBAAA\") == False\n assert candidate(colors = \"ABABAB\") == False\n assert candidate(colors = \"BBBAAABB\") == False\n assert candidate(colors = \"ABAAABAA\") == True\n assert candidate(colors = \"AA\") == False\n assert candidate(colors = \"BBBBAAAABBB\") == False\n assert candidate(colors = \"AAAABBBAA\") == True\n assert candidate(colors = \"AABBBAAABBB\") == False\n assert candidate(colors = \"ABABABABABABAB\") == False\n assert candidate(colors = \"AAABBBAAABBBAABBBAAABBBAABBB\") == False\n assert candidate(colors = \"AABBABBABBABBABBABBA\") == False\n assert candidate(colors = \"ABAABAABAABAABAABA\") == False\n assert candidate(colors = \"BBBBBBBBBBAAAABBB\") == False\n assert candidate(colors = \"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\") == False\n assert candidate(colors = \"AAABAAAABBAAABBBBAAAABBB\") == True\n assert candidate(colors = \"AABAABAABAABAABAA\") == False\n assert candidate(colors = \"AABBBAAABBBAABBAAABBBAABB\") == False\n assert candidate(colors = \"BBBBBBBBBBABBBBBBBBB\") == False\n assert candidate(colors = \"ABABABABABABABABABABAB\") == False\n assert candidate(colors = \"ABABABABABABABABABABABABABABABABABAB\") == False\n assert candidate(colors = \"AAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBB\") == False\n assert candidate(colors = \"AABBBAAABBBAAABBB\") == False\n assert candidate(colors = \"AABBAABBBAABBBAABBBAABBA\") == False\n assert candidate(colors = \"ABABABABABABABABABABABABABABABABABABABABAB\") == False\n assert candidate(colors = \"AAABAAAAAAAAABBBBBBB\") == True\n assert candidate(colors = \"AAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBB\") == True\n assert candidate(colors = \"ABABABABABABABABA\") == False\n assert candidate(colors = \"BBBBBBBBBBAAAAAAAAAAB\") == False\n assert candidate(colors = \"BBBAAAABBBAAAABBBAAAABBBAAAABBBAAAABBB\") == True\n assert candidate(colors = \"BBABBABBABBABBABB\") == False\n assert candidate(colors = \"BAAAAAAAAAABBBBBBBBBB\") == False\n assert candidate(colors = \"AAABAAABBBAAABBBBAA\") == False\n assert candidate(colors = \"AABBBAAAABBBAAB\") == False\n assert candidate(colors = \"AABBAAAABBAAAABB\") == True\n assert candidate(colors = \"BBBAABBBAAABBBAABBB\") == False\n assert candidate(colors = \"AAAABBBAAABBBAAABBBAAABBBAAABBBAAABBBAAABBB\") == True\n assert candidate(colors = \"AAAAAAAAAABBBBBBBBBBB\") == False\n assert candidate(colors = \"AAAABBBBBBAAAABBBBBB\") == False\n assert candidate(colors = \"AAAAAABAAAAAABAAAAAAB\") == True\n assert candidate(colors = \"BBBAAAAAAAAABBBBBB\") == True\n assert candidate(colors = \"BBABABABABABABABABAB\") == False\n assert candidate(colors = \"AAABBBAAABBBAAABBBAAABBBAAABBBAAABBB\") == False\n assert candidate(colors = \"AAAAAAAAAAAAAAAAAAAAAAAAA\") == True\n assert candidate(colors = \"AAAAAAAABBBBBBBBBB\") == False\n assert candidate(colors = \"ABBBAAAAABBAAAAAAA\") == True\n assert candidate(colors = \"BBBAAAABBAAAABBAAAABBAAAABBAAAABB\") == True\n assert candidate(colors = \"AAAABAAAABBAAAABBAAAABBAAAABBAAAAB\") == True\n assert candidate(colors = \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\") == True\n assert candidate(colors = \"AAAAAAAAAAAAAABBBBBBBBBBBB\") == True\n assert candidate(colors = \"AAAAAAAAAAAAAAAAA\") == True\n assert candidate(colors = \"AABBBAAAAABBBBAAA\") == True\n assert candidate(colors = \"AAAAAAAAAABBBBBBBBBB\") == False\n assert candidate(colors = \"AAABBBAAAABBBAAABBBAAABBBAA\") == True\n assert candidate(colors = \"AAABAAAABAAABAAAABAA\") == True\n assert candidate(colors = \"AAAAAAAAAAAAAAAAAA\") == True\n assert candidate(colors = \"AAAAAAAAABBBBBBBBAABBBBBBBBA\") == False\n assert candidate(colors = \"BBBAAAABBBAAAABBB\") == True\n assert candidate(colors = \"ABABABAAAABBBABAABAB\") == True\n assert candidate(colors = \"ABBBAAAABBAAAABBBA\") == True\n assert candidate(colors = \"AAABBBAABBBAAABBBA\") == False\n assert candidate(colors = \"AAABBBAABBBAABBBAAB\") == False\n assert candidate(colors = \"AAABBBAAAABBBAAABBBAA\") == True\n assert candidate(colors = \"ABABABABABABABABABABABABABABABAB\") == False\n assert candidate(colors = \"BBBAAAABBBAAAABAA\") == True\n assert candidate(colors = \"AAABBBAAAABBBAAAABBBAAA\") == True\n assert candidate(colors = \"BBBBBAABAAAAAAABBB\") == True\n assert candidate(colors = \"AAABBAAAABBAAAABBAAAABBBAAAABB\") == True\n assert candidate(colors = \"BBBBBAAAAAAAAABBBBB\") == True\n assert candidate(colors = \"AAAAAAAAABBBBBBBBBBBB\") == False\n assert candidate(colors = \"BABAABABABABABABAB\") == False\n assert candidate(colors = \"AAABBBBAABBBBAA\") == False\n assert candidate(colors = \"BBAAABBBAAABBBAAABB\") == True\n assert candidate(colors = \"AAABAAABAAABAAABA\") == True\n assert candidate(colors = \"AAABBBAAABBBAAABBBAAABBBAAABBB\") == False\n assert candidate(colors = \"BBBBBBBBBB\") == False\n assert candidate(colors = \"BBAAAABBBAAABBBAAABB\") == True\n assert candidate(colors = \"AAAAAAAAAABBBBBBBB\") == True\n assert candidate(colors = \"BBBBBAAAABBBBBBBAAAAA\") == False\n assert candidate(colors = \"BBBBBAAAABBBBBAAAABBBBBAAAABBBBB\") == False\n assert candidate(colors = \"AAAAABBBBBAAAAABBBBBAAAAA\") == True\n assert candidate(colors = \"ABBBAAAABBAAAABBBAABA\") == True\n assert candidate(colors = \"AAAABBBBAAAABBBBAAAABBBB\") == False\n assert candidate(colors = \"BBBBAAAABBBBBBBBAAA\") == False\n assert candidate(colors = \"ABABABABABABABABABABABABABABABABAB\") == False\n assert candidate(colors = \"BBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBB\") == True\n assert candidate(colors = \"BBBBBBAAAABBBBBBBBAAA\") == False\n assert candidate(colors = \"AABAAAAAAABBBBBBBBA\") == False\n assert candidate(colors = \"BBBAABBBAAAABBBAAABBB\") == False\n assert candidate(colors = \"ABABABABAAAAAAAABBBBBBBB\") == False\n assert candidate(colors = \"BBAAAABBBAAAABBAAA\") == True\n assert candidate(colors = \"BBAABBAAAABBAAAABBBB\") == True\n assert candidate(colors = \"AAABBBAABBAAABBBAAAAAAABBBB\") == True\n assert candidate(colors = \"AAAAABBAAAABBAAAAB\") == True\n assert candidate(colors = \"ABBBAAAABBBBAAA\") == False\n assert candidate(colors = \"BBBBBBBBBBBBBBBBB\") == False\n assert candidate(colors = \"BBBBBBAAAAAAAAAA\") == True\n assert candidate(colors = \"BBAAAABBBAAAABBBAAAABBB\") == True\n assert candidate(colors = \"ABBBAAAABBBAAAABB\") == True\n assert candidate(colors = \"BBBBBAABBBBAABBBBAABBBBA\") == False\n assert candidate(colors = \"BBBBBBBBBBBBBBBBBBBBBBBBB\") == False\n assert candidate(colors = \"BBBBBBBAAAAAAAAAAAABB\") == True\n assert candidate(colors = \"AAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBB\") == False\n assert candidate(colors = \"ABABABABABABABABABABABABABABABABABABABAB\") == False\n assert candidate(colors = \"BBBBAAAABBBBBAAAABBBBBAAAABB\") == False\n assert candidate(colors = \"AABAAABAABAAABAAA\") == True\n assert candidate(colors = \"ABABABABABABABABAB\") == False\n assert candidate(colors = \"BBBAAAABBAAAABBAAAABBB\") == True\n assert candidate(colors = \"AAAAAAAAAAAAAAAAABBBBBBBBBBBAAAAAAAAAAAAAAAAABBBBBBBBBBB\") == True\n assert candidate(colors = \"AABBBAAABBAAAABBAAAAB\") == True\n assert candidate(colors = \"AAABAAABAAABAAABAAABAAAB\") == True\n assert candidate(colors = \"ABABABABABABABABABABABABABAB\") == False\n assert candidate(colors = \"AAAAAABBBBBBAAA\") == True\n assert candidate(colors = \"BBBAAAABBBAAAABBBAAAABBB\") == True\n assert candidate(colors = \"ABABABABABABABABABABA\") == False\n assert candidate(colors = \"AAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBB\") == False\n assert candidate(colors = \"AAAABBAABBABBAABBBAAA\") == True\n assert candidate(colors = \"ABAAAABBBBAABBBBAA\") == False\n assert candidate(colors = \"AAABAAAABBBBAAAABBBBAAAABBBBAAAABBB\") == True\n assert candidate(colors = \"AAAAAAAAAAAAABBBBBBBBBBBBB\") == False\n assert candidate(colors = \"AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBB\") == False\n assert candidate(colors = \"BABAABBAABBBBAAAABBBB\") == False\n assert candidate(colors = \"AABBAABBAABBAAA\") == True\n assert candidate(colors = \"AAAAAAAAABBBBBBBB\") == True\n assert candidate(colors = \"BBBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAAAA\") == True\n assert candidate(colors = \"BBAABBAAAABBBBAAAAABBBAAABBBAAABBBB\") == True\n assert candidate(colors = \"AAAAAAAAABBAAAAAAAAA\") == True\n assert candidate(colors = \"AAAABBBAAAABBB\") == True\n assert candidate(colors = \"AABBAAAABBBAAAABBB\") == True\n assert candidate(colors = \"AAAAAAAABBBBBBBBBBAAA\") == False\n assert candidate(colors = \"AAAABBBAAAABBBAAAABBB\") == True\n assert candidate(colors = \"AAAAAAAAABBBBBBB\") == True\n assert candidate(colors = \"BBAAAABBAAAABBAAAABBAAAABBB\") == True\n assert candidate(colors = \"AABBBAAAABBBAAA\") == True\n assert candidate(colors = \"BBBBBBBBAAAABBBBBBB\") == False\n assert candidate(colors = \"BBBBBAAAABBBBBAAAABBBBBAAAABBBBBAAAABBBBBAAAABBBBB\") == False\n assert candidate(colors = \"BBABABABBABABABBABABABBB\") == False\n assert candidate(colors = \"BBAABBAAAABBAAAABBAAAABBB\") == True\n assert candidate(colors = \"BBBAAAABBAAAABBB\") == True\n assert candidate(colors = \"BBBBBBBBBBBBBBBBBB\") == False\n assert candidate(colors = \"AAAABBBBAAAA\") == True\n assert candidate(colors = \"BBBBAABBBAABBBAAB\") == False\n assert candidate(colors = \"AAAAAAAAAA\") == True\n assert candidate(colors = \"BBBBBBAAAABBBBBBAAAABBBBBB\") == False\n assert candidate(colors = \"BAAABAAABAAABBB\") == True\n assert candidate(colors = \"AAABBBAAAABBBAAAABBB\") == True\n assert candidate(colors = \"AAAAAABBBBAAAABBBBAAAAA\") == True\n assert candidate(colors = \"BBBAAAAAAAABBBBBB\") == True\n assert candidate(colors = \"AAABBBAABBBAAABBBAABBB\") == False\n assert candidate(colors = \"BABABABABABABABAB\") == False\n assert candidate(colors = \"AABAAAAABBAAABAAAAABB\") == True\n assert candidate(colors = \"BBBBBAAAABBBBBAAAABBBBBAAAABBBBBAAAABBBBB\") == False\n assert candidate(colors = \"BBBAAABBBAAABBBAAA\") == False\n assert candidate(colors = \"AAABAAAAAAAABBBBBBB\") == True\n assert candidate(colors = \"BBBBBBBBAAAAAAAAAA\") == True\n assert candidate(colors = \"ABABABABABABABABABAB\") == False\n assert candidate(colors = \"ABBBBAAAAAABBBBBAAA\") == False\n assert candidate(colors = \"AAABAAABBBABBAAA\") == True\n assert candidate(colors = \"AABBBAAAAAAAAABBBBB\") == True\n assert candidate(colors = \"BBAAAABBBAAAABBBAAAABBBAAA\") == True\n assert candidate(colors = \"BBBBBBBAAAAAAAAAA\") == True\n assert candidate(colors = \"AABBBAAAABBBAAAABBB\") == True\n assert candidate(colors = \"AAAAAAAAAABBBBBBBBAAAAAAAAAABBBBBBBB\") == True\n assert candidate(colors = \"AABAAABAAABAAABAAABAAABAAABAAABAAAB\") == True\n assert candidate(colors = \"BBBBBAAAABBBBBAAAAABBBBBAAABBBAAAB\") == False\n"}, "metadata": {"canonical_parameter_names": ["colors"], "leetcode_dataset_entry_point": "Solution().winnerOfGame", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool winnerOfGame(string colors) {", "container": "Solution", "callable": "winnerOfGame", "parameters": [{"name": "colors", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2039, "task_id": "the-time-when-the-network-becomes-idle", "difficulty": "Medium", "problem_description": "There is a network of n servers, labeled from 0 to n - 1. You are given a 2D integer array edges, where edges[i] = [ui, vi] indicates there is a message channel between servers ui and vi, and they can pass any number of messages to each other directly in one second. You are also given a 0-indexed integer array patience of length n.\nAll servers are connected, i.e., a message can be passed from one server to any other server(s) directly or indirectly through the message channels.\nThe server labeled 0 is the master server. The rest are data servers. Each data server needs to send its message to the master server for processing and wait for a reply. Messages move between servers optimally, so every message takes the least amount of time to arrive at the master server. The master server will process all newly arrived messages instantly and send a reply to the originating server via the reversed path the message had gone through.\nAt the beginning of second 0, each data server sends its message to be processed. Starting from second 1, at the beginning of every second, each data server will check if it has received a reply to the message it sent (including any newly arrived replies) from the master server:\n\nIf it has not, it will resend the message periodically. The data server i will resend the message every patience[i] second(s), i.e., the data server i will resend the message if patience[i] second(s) have elapsed since the last time the message was sent from this server.\nOtherwise, no more resending will occur from this server.\n\nThe network becomes idle when there are no messages passing between servers or arriving at servers.\nReturn the earliest second starting from which the network becomes idle.\n \nExample 1:\n\n\nInput: edges = [[0,1],[1,2]], patience = [0,2,1]\nOutput: 8\nExplanation:\nAt (the beginning of) second 0,\n- Data server 1 sends its message (denoted 1A) to the master server.\n- Data server 2 sends its message (denoted 2A) to the master server.\n\nAt second 1,\n- Message 1A arrives at the master server. Master server processes message 1A instantly and sends a reply 1A back.\n- Server 1 has not received any reply. 1 second (1 < patience[1] = 2) elapsed since this server has sent the message, therefore it does not resend the message.\n- Server 2 has not received any reply. 1 second (1 == patience[2] = 1) elapsed since this server has sent the message, therefore it resends the message (denoted 2B).\n\nAt second 2,\n- The reply 1A arrives at server 1. No more resending will occur from server 1.\n- Message 2A arrives at the master server. Master server processes message 2A instantly and sends a reply 2A back.\n- Server 2 resends the message (denoted 2C).\n...\nAt second 4,\n- The reply 2A arrives at server 2. No more resending will occur from server 2.\n...\nAt second 7, reply 2D arrives at server 2.\n\nStarting from the beginning of the second 8, there are no messages passing between servers or arriving at servers.\nThis is the time when the network becomes idle.\n\nExample 2:\n\n\nInput: edges = [[0,1],[0,2],[1,2]], patience = [0,10,10]\nOutput: 3\nExplanation: Data servers 1 and 2 receive a reply back at the beginning of second 2.\nFrom the beginning of the second 3, the network becomes idle.\n\n \nConstraints:\n\nn == patience.length\n2 <= n <= 105\npatience[0] == 0\n1 <= patience[i] <= 105 for 1 <= i < n\n1 <= edges.length <= min(105, n * (n - 1) / 2)\nedges[i].length == 2\n0 <= ui, vi < n\nui != vi\nThere are no duplicate edges.\nEach server can directly or indirectly reach another server.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(edges = [[0, 1], [1, 2]],patience = [0, 2, 1]) == 8\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 2], [1, 3], [2, 3]],patience = [0, 5, 5, 5]) == 3\n assert candidate(edges = [[0, 1], [1, 3], [3, 4], [2, 4]],patience = [0, 1, 2, 3, 4]) == 15\n assert candidate(edges = [[0, 1], [1, 2], [2, 0]],patience = [0, 2, 1]) == 4\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4]],patience = [0, 1, 2, 3, 4]) == 13\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],patience = [0, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 5\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],patience = [0, 5, 4, 3, 2, 1, 6, 7, 8, 9]) == 28\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4]],patience = [0, 5, 2, 3, 1]) == 16\n assert candidate(edges = [[0, 1], [0, 2], [1, 2]],patience = [0, 10, 10]) == 3\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],patience = [0, 1, 2, 3, 4, 5, 6]) == 8\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],patience = [0, 1, 1, 5, 2, 3, 6]) == 8\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6]],patience = [0, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5]],patience = [0, 4, 3, 2, 1, 5]) == 4\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 0], [0, 2], [1, 3], [4, 6], [5, 7], [8, 10], [9, 11], [12, 14]],patience = [0, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15]) == 13\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],patience = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 8\n assert candidate(edges = [[0, 1], [1, 2], [2, 0], [0, 3], [3, 4], [4, 5], [5, 0], [0, 6], [6, 7], [7, 8], [8, 9], [9, 0]],patience = [0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 5\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 0], [0, 2], [1, 3], [4, 6], [5, 7], [8, 10]],patience = [0, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11]) == 9\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],patience = [0, 5, 7, 3, 2, 1, 6, 4, 8, 9, 11]) == 11\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0]],patience = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == 23\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25]],patience = [0, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 100\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22]],patience = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 9\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]],patience = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 58\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],patience = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 7\n assert candidate(edges = [[0, 1], [1, 2], [0, 3], [3, 4], [2, 4], [4, 5], [5, 6]],patience = [0, 2, 1, 3, 4, 5, 6]) == 15\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0]],patience = [0, 100, 90, 80, 70, 60, 50, 40, 30]) == 9\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9]],patience = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 4\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26]],patience = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 16\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 0], [0, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 0]],patience = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 11\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],patience = [0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]) == 12\n assert candidate(edges = [[0, 1], [0, 3], [1, 2], [1, 4], [2, 5], [2, 7], [3, 6], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [10, 20]],patience = [0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22]) == 9\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9]],patience = [0, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 5\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],patience = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == 7\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0]],patience = [0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12]) == 27\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [7, 17], [8, 18], [8, 19], [9, 20], [9, 21]],patience = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]) == 7\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [10, 20], [19, 21], [20, 22], [11, 23], [12, 24], [13, 25], [14, 26], [15, 27], [16, 28], [17, 29], [29, 30], [28, 31], [27, 32], [26, 33], [25, 34], [24, 35], [23, 36]],patience = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]) == 13\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [5, 16], [6, 17], [6, 18], [6, 19], [7, 20], [7, 21], [7, 22], [8, 23], [8, 24], [8, 25]],patience = [0, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2]) == 7\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19]],patience = [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900]) == 29\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11], [4, 12], [5, 13], [5, 14], [6, 15], [6, 16], [7, 17], [7, 18], [8, 19], [8, 20]],patience = [0, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 12\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [0, 6], [0, 7], [0, 8], [0, 9], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9]],patience = [0, 99, 98, 97, 96, 95, 94, 93, 92, 91]) == 3\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14]],patience = [0, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 15, 14, 13, 12, 11]) == 12\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [0, 4], [1, 5], [1, 6], [2, 7], [2, 8], [3, 9], [3, 10], [4, 11], [4, 12]],patience = [0, 7, 7, 7, 7, 2, 2, 2, 2, 2, 2, 2, 2]) == 7\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30]],patience = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 9\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],patience = [0, 15, 10, 20, 5, 12, 8, 6, 4, 7, 3]) == 11\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 0]],patience = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58]) == 31\n assert candidate(edges = [[0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 6], [1, 7], [2, 8], [2, 9], [3, 10], [3, 11], [4, 12], [4, 13], [5, 14], [5, 15], [6, 16], [6, 17], [7, 18], [7, 19], [8, 20], [8, 21], [9, 22], [9, 23], [10, 24], [10, 25], [11, 26], [11, 27], [12, 28], [12, 29], [13, 30], [13, 31], [14, 32], [14, 33], [15, 34], [15, 35]],patience = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]) == 7\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],patience = [0, 5, 5, 3, 3, 1, 1, 4, 4, 2, 2]) == 11\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20], [10, 21], [10, 22], [11, 23], [11, 24], [12, 25], [12, 26], [13, 27], [13, 28], [14, 29], [14, 30]],patience = [0, 3, 2, 1, 6, 5, 4, 7, 8, 9, 12, 11, 10, 15, 14, 13, 18, 17, 16, 19, 20, 21, 24, 23, 22, 27, 26, 25, 28, 29, 30, 31, 32, 33, 34, 35]) == 9\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30], [30, 31], [31, 32], [32, 33], [33, 34], [34, 35], [35, 36], [36, 37], [37, 38], [38, 39]],patience = [0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 119\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [0, 5], [5, 6], [6, 0], [0, 7], [7, 8], [8, 9], [9, 0]],patience = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(edges = [[0, 1], [0, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10]],patience = [0, 2, 5, 3, 4, 7, 8, 6, 1, 9, 10]) == 12\n assert candidate(edges = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29]],patience = [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 116\n"}, "metadata": {"canonical_parameter_names": ["edges", "patience"], "leetcode_dataset_entry_point": "Solution().networkBecomesIdle", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int networkBecomesIdle(vector>& edges, vector& patience) {", "container": "Solution", "callable": "networkBecomesIdle", "parameters": [{"name": "edges", "type": "vector>&"}, {"name": "patience", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2040, "task_id": "kth-smallest-product-of-two-sorted-arrays", "difficulty": "Hard", "problem_description": "Given two sorted 0-indexed integer arrays nums1 and nums2 as well as an integer k, return the kth (1-based) smallest product of nums1[i] * nums2[j] where 0 <= i < nums1.length and 0 <= j < nums2.length.\n \nExample 1:\n\nInput: nums1 = [2,5], nums2 = [3,4], k = 2\nOutput: 8\nExplanation: The 2 smallest products are:\n- nums1[0] * nums2[0] = 2 * 3 = 6\n- nums1[0] * nums2[1] = 2 * 4 = 8\nThe 2nd smallest product is 8.\n\nExample 2:\n\nInput: nums1 = [-4,-2,0,3], nums2 = [2,4], k = 6\nOutput: 0\nExplanation: The 6 smallest products are:\n- nums1[0] * nums2[1] = (-4) * 4 = -16\n- nums1[0] * nums2[0] = (-4) * 2 = -8\n- nums1[1] * nums2[1] = (-2) * 4 = -8\n- nums1[1] * nums2[0] = (-2) * 2 = -4\n- nums1[2] * nums2[0] = 0 * 2 = 0\n- nums1[2] * nums2[1] = 0 * 4 = 0\nThe 6th smallest product is 0.\n\nExample 3:\n\nInput: nums1 = [-2,-1,0,1,2], nums2 = [-3,-1,2,4,5], k = 3\nOutput: -6\nExplanation: The 3 smallest products are:\n- nums1[0] * nums2[4] = (-2) * 5 = -10\n- nums1[0] * nums2[3] = (-2) * 4 = -8\n- nums1[4] * nums2[0] = 2 * (-3) = -6\nThe 3rd smallest product is -6.\n\n \nConstraints:\n\n1 <= nums1.length, nums2.length <= 5 * 104\n-105 <= nums1[i], nums2[j] <= 105\n1 <= k <= nums1.length * nums2.length\nnums1 and nums2 are sorted.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums1 = [-100000, 100000],nums2 = [-100000, 100000],k = 1) == -10000000000\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-1, 0, 1],k = 4) == 0\n assert candidate(nums1 = [-100000, -50000, 0, 50000, 100000],nums2 = [-100000, -50000, 0, 50000, 100000],k = 12) == 0\n assert candidate(nums1 = [-10, -9, -8, -7, -6],nums2 = [-5, -4, -3, -2, -1],k = 1) == 6\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],k = 25) == 90\n assert candidate(nums1 = [2, 5],nums2 = [3, 4],k = 2) == 8\n assert candidate(nums1 = [-4, -2, 0, 3],nums2 = [2, 4],k = 6) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5],k = 10) == 5\n assert candidate(nums1 = [-100000, 100000],nums2 = [-100000, 100000],k = 2) == -10000000000\n assert candidate(nums1 = [-5, -3, -1, 1, 3, 5],nums2 = [-5, -3, -1, 1, 3, 5],k = 18) == -1\n assert candidate(nums1 = [-2, -1, 0, 1, 2],nums2 = [-3, -1, 2, 4, 5],k = 3) == -6\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [1, 2, 3, 4, 5],k = 25) == 25\n assert candidate(nums1 = [-10, -5, -1],nums2 = [1, 5, 10],k = 5) == -10\n assert candidate(nums1 = [1, 2, 3],nums2 = [4, 5, 6],k = 5) == 10\n assert candidate(nums1 = [0, 0, 0],nums2 = [0, 0, 0],k = 5) == 0\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0],k = 12) == 0\n assert candidate(nums1 = [-100, -50, -10, -5, 0, 5, 10, 50, 100],nums2 = [-100, -50, -10, -5, 0, 5, 10, 50, 100],k = 200) == 10001\n assert candidate(nums1 = [-5, -4, -3, -2, -1],nums2 = [-5, -4, -3, -2, -1],k = 12) == 6\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-10000, 0, 10000],k = 7) == 0\n assert candidate(nums1 = [-25, -15, -5, 5, 15, 25],nums2 = [-25, -15, -5, 0, 5, 15, 25],k = 30) == 75\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1],k = 25) == 1\n assert candidate(nums1 = [-50000, -25000, 0, 25000, 50000],nums2 = [-10000, -5000, 0, 5000, 10000],k = 7) == -125000000\n assert candidate(nums1 = [-50000, -25000, 0, 25000, 50000],nums2 = [-10000, -5000, 0, 5000, 10000],k = 125000) == 500000001\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [-1, -1, -1, -1, -1],k = 25) == -1\n assert candidate(nums1 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 50) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],k = 20) == 50\n assert candidate(nums1 = [-9, -3, 0, 1, 5],nums2 = [-6, -2, 1, 4, 7],k = 9) == -3\n assert candidate(nums1 = [-50000, -25000, 0, 25000, 50000],nums2 = [-50000, -25000, 0, 25000, 50000],k = 124999) == 2500000001\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-100, -50, 0, 50, 100],k = 10) == 0\n assert candidate(nums1 = [-1, -2, -3, -4, -5, 1, 2, 3, 4, 5],nums2 = [-1, -2, -3, -4, -5, 1, 2, 3, 4, 5],k = 49) == -2\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],k = 24) == 72\n assert candidate(nums1 = [-100, -50, 0, 50, 100],nums2 = [-200, -100, 0, 100, 200],k = 10) == 0\n assert candidate(nums1 = [-10, -5, -1, 0, 1, 5, 10],nums2 = [-20, -15, -10, -5, 0, 5, 10, 15, 20],k = 20) == -15\n assert candidate(nums1 = [-1000, -500, -100, -50, -10, -5, -1, 0, 1, 5, 10, 50, 100, 500, 1000],nums2 = [-1000, -500, -100, -50, -10, -5, -1, 0, 1, 5, 10, 50, 100, 500, 1000],k = 1000) == 1000001\n assert candidate(nums1 = [-50000, -25000, 0, 25000, 50000],nums2 = [-50000, -25000, 0, 25000, 50000],k = 1250000) == 2500000001\n assert candidate(nums1 = [-50, -25, 0, 25, 50],nums2 = [-50, -25, 0, 25, 50],k = 12) == 0\n assert candidate(nums1 = [100000],nums2 = [-100000, 0, 100000],k = 2) == 0\n assert candidate(nums1 = [-100000, 100000],nums2 = [-1, 1],k = 1) == -100000\n assert candidate(nums1 = [-1000, -900, -800],nums2 = [800, 900, 1000],k = 8) == -720000\n assert candidate(nums1 = [-100000, -50000, -10000, -5000, -1000, -500, -100, -50, -10, -5, 0, 5, 10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000],nums2 = [-100000, -50000, -10000, -5000, -1000, -500, -100, -50, -10, -5, 0, 5, 10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000],k = 1000000) == 10000000001\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [-9, -7, -5, -3, -1],k = 15) == -15\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-10, -5, 0, 5, 10],k = 15) == 0\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-10, -5, 0, 5, 10],k = 13) == 0\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 45) == 20\n assert candidate(nums1 = [100, 200, 300, 400, 500],nums2 = [1, 2, 3, 4, 5],k = 20) == 1500\n assert candidate(nums1 = [1, 1, 1, 1, 1],nums2 = [1, 1, 1, 1, 1],k = 1) == 1\n assert candidate(nums1 = [10000, 20000, 30000, 40000, 50000],nums2 = [-10000, -20000, -30000, -40000, -50000],k = 12) == -900000000\n assert candidate(nums1 = [-2, -1, 0, 1, 2],nums2 = [-2, -1, 0, 1, 2, 3, 4, 5],k = 15) == 0\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11],nums2 = [2, 4, 6, 8, 10, 12],k = 36) == 132\n assert candidate(nums1 = [10, 20, 30, 40, 50],nums2 = [-5, -10, -15, -20, -25],k = 10) == -600\n assert candidate(nums1 = [-1000, -500, -100, 0, 100, 500, 1000],nums2 = [-1000, -500, -100, 0, 100, 500, 1000],k = 48) == 1000000\n assert candidate(nums1 = [-2, 0, 2],nums2 = [-2, 0, 2],k = 3) == 0\n assert candidate(nums1 = [-1, -1, 0, 1, 1],nums2 = [-1, -1, 0, 1, 1],k = 12) == 0\n assert candidate(nums1 = [-100, -50, 0, 50, 100],nums2 = [-200, -100, 0, 100, 200],k = 50) == 20001\n assert candidate(nums1 = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],nums2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],k = 100) == 380\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-1, 0, 1],k = 3) == 0\n assert candidate(nums1 = [10000, 20000, 30000, 40000, 50000],nums2 = [-1, -2, -3, -4, -5],k = 15) == -90000\n assert candidate(nums1 = [-100, -50, 0, 50, 100],nums2 = [-100, -50, 0, 50, 100],k = 1000) == 10001\n assert candidate(nums1 = [-50000, -25000, 0, 25000, 50000],nums2 = [-50000, -25000, 0, 25000, 50000],k = 125000000) == 2500000001\n assert candidate(nums1 = [-10000, -5000, -1000, -500, -100, -50, -10, -5, -1, 0, 1, 5, 10, 50, 100, 500, 1000, 5000, 10000],nums2 = [-10000, -5000, -1000, -500, -100, -50, -10, -5, -1, 0, 1, 5, 10, 50, 100, 500, 1000, 5000, 10000],k = 361) == 100000000\n assert candidate(nums1 = [-1, 1],nums2 = [-100000, 100000],k = 1) == -100000\n assert candidate(nums1 = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 324) == 40\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-100000, -10000, -1000, -100, -10, -1, 0, 1, 10, 100, 1000, 10000, 100000],k = 100) == 100001\n assert candidate(nums1 = [-1, -1, -1, -1, -1],nums2 = [-1, -1, -1, -1, -1],k = 1) == 1\n assert candidate(nums1 = [-3, -2, -1, 0, 1, 2, 3],nums2 = [-3, -2, -1, 0, 1, 2, 3],k = 21) == 0\n assert candidate(nums1 = [-1000, -500, -100, -50, -10, -5, -1, 0, 1, 5, 10, 50, 100, 500, 1000],nums2 = [-1000, -500, -100, -50, -10, -5, -1, 0, 1, 5, 10, 50, 100, 500, 1000],k = 22500) == 1000001\n assert candidate(nums1 = [-1, -1, -1, -1, -1],nums2 = [-1, -1, -1, -1, -1],k = 20) == 1\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-100000, -10000, -1000, -100, -10, -1, 0, 1, 10, 100, 1000, 10000, 100000],k = 13) == 0\n assert candidate(nums1 = [-50000, -25000, 0, 25000, 50000],nums2 = [-50000, -25000, 0, 25000, 50000],k = 500000) == 2500000001\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-1, 0, 1],k = 5) == 0\n assert candidate(nums1 = [-5, -3, -1, 1, 3, 5],nums2 = [-5, -3, -1, 1, 3, 5],k = 15) == -3\n assert candidate(nums1 = [-50000, -40000, -30000, -20000, -10000, 0, 10000, 20000, 30000, 40000, 50000],nums2 = [-50000, -40000, -30000, -20000, -10000, 0, 10000, 20000, 30000, 40000, 50000],k = 1000000) == 2500000001\n assert candidate(nums1 = [-9, -7, -5, -3, -1],nums2 = [-9, -7, -5, -3, -1],k = 24) == 63\n assert candidate(nums1 = [-50000, -25000, 0, 25000, 50000],nums2 = [-50000, -25000, 0, 25000, 50000],k = 24999) == 2500000001\n assert candidate(nums1 = [-1, -1, -1, -1],nums2 = [-1, -1, -1, -1],k = 10) == 1\n assert candidate(nums1 = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 240\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-1, 0, 1],k = 4) == 0\n assert candidate(nums1 = [0, 0, 0, 0, 0],nums2 = [0, 0, 0, 0, 0],k = 10) == 0\n assert candidate(nums1 = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],nums2 = [-9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],k = 100) == -15\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-2, -1, 0, 1, 2],k = 8) == -5\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-10, -5, 0, 5, 10],k = 10) == 0\n assert candidate(nums1 = [-1, -1, -1, -1],nums2 = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],k = 5) == 1\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [2, 4, 6, 8, 10],k = 12) == 20\n assert candidate(nums1 = [-1000, -900, -800, -700, -600],nums2 = [-1000, -900, -800, -700, -600],k = 20) == 800000\n assert candidate(nums1 = [-100, -50, 0, 50, 100],nums2 = [-100, -50, 0, 50, 100],k = 12) == 0\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-10, -5, 0, 5, 10],k = 12) == 0\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-100000, -50000, -10000, -5000, -1000, -500, -100, -50, -10, -5, -1, 0, 1, 5, 10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000],k = 50) == 5\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-10, -5, 0, 5, 10],k = 25) == 100\n assert candidate(nums1 = [-1, 0, 1],nums2 = [-100, 0, 100],k = 4) == 0\n assert candidate(nums1 = [-5, -3, -1, 0, 1, 3, 5],nums2 = [-6, -4, -2, 0, 2, 4, 6],k = 15) == -4\n assert candidate(nums1 = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 441) == 100\n assert candidate(nums1 = [-1000, -500, 0, 500, 1000],nums2 = [-1000, -500, 0, 500, 1000],k = 1250) == 1000001\n assert candidate(nums1 = [-5, -3, -1, 1, 3, 5],nums2 = [-6, -4, -2, 0, 2, 4, 6],k = 15) == -4\n assert candidate(nums1 = [-9, -7, -5, -3, -1],nums2 = [1, 3, 5, 7, 9],k = 10) == -27\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [-5, -4, -3, -2, -1],k = 25) == -1\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 50) == 24\n assert candidate(nums1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],nums2 = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 45) == -36\n assert candidate(nums1 = [-3, -2, -1, 0, 1, 2, 3],nums2 = [-3, -2, -1, 0, 1, 2, 3],k = 20) == 0\n assert candidate(nums1 = [-1, -1, -1, -1, 1, 1, 1, 1],nums2 = [-1, -1, -1, -1, 1, 1, 1, 1],k = 32) == -1\n assert candidate(nums1 = [1, 3, 5, 7, 9],nums2 = [-9, -7, -5, -3, -1],k = 25) == -1\n assert candidate(nums1 = [-50000, -40000, -30000, 0, 30000, 40000, 50000],nums2 = [-50000, 0, 50000],k = 20) == 2500000000\n assert candidate(nums1 = [1, 2, 3, 4, 5],nums2 = [-5, -4, -3, -2, -1],k = 15) == -6\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-10, -5, 0, 5, 10],k = 20) == 50\n assert candidate(nums1 = [-1, 1, -1, 1, -1],nums2 = [-1, 1, -1, 1, -1],k = 10) == -1\n assert candidate(nums1 = [-9, -6, -3, 0, 3, 6, 9],nums2 = [-9, -6, -3, 0, 3, 6, 9],k = 49) == 81\n assert candidate(nums1 = [-10, -5, 0, 5, 10],nums2 = [-20, -15, -10, -5, 0, 5, 10, 15, 20],k = 30) == 25\n assert candidate(nums1 = [-100, -50, -25, -10, -5, -1, 0, 1, 5, 10, 25, 50, 100],nums2 = [-100, -50, -25, -10, -5, -1, 0, 1, 5, 10, 25, 50, 100],k = 100) == 5\n assert candidate(nums1 = [-5, -4, -3, -2, -1],nums2 = [1, 2, 3, 4, 5],k = 25) == -1\n"}, "metadata": {"canonical_parameter_names": ["nums1", "nums2", "k"], "leetcode_dataset_entry_point": "Solution().kthSmallestProduct", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long kthSmallestProduct(vector& nums1, vector& nums2, long long k) {", "container": "Solution", "callable": "kthSmallestProduct", "parameters": [{"name": "nums1", "type": "vector&"}, {"name": "nums2", "type": "vector&"}, {"name": "k", "type": "long long"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2042, "task_id": "check-if-numbers-are-ascending-in-a-sentence", "difficulty": "Easy", "problem_description": "A sentence is a list of tokens separated by a single space with no leading or trailing spaces. Every token is either a positive number consisting of digits 0-9 with no leading zeros, or a word consisting of lowercase English letters.\n\nFor example, \"a puppy has 2 eyes 4 legs\" is a sentence with seven tokens: \"2\" and \"4\" are numbers and the other tokens such as \"puppy\" are words.\n\nGiven a string s representing a sentence, you need to check if all the numbers in s are strictly increasing from left to right (i.e., other than the last number, each number is strictly smaller than the number on its right in s).\nReturn true if so, or false otherwise.\n \nExample 1:\n\n\nInput: s = \"1 box has 3 blue 4 red 6 green and 12 yellow marbles\"\nOutput: true\nExplanation: The numbers in s are: 1, 3, 4, 6, 12.\nThey are strictly increasing from left to right: 1 < 3 < 4 < 6 < 12.\n\nExample 2:\n\nInput: s = \"hello world 5 x 5\"\nOutput: false\nExplanation: The numbers in s are: 5, 5. They are not strictly increasing.\n\nExample 3:\n\n\nInput: s = \"sunset is at 7 51 pm overnight lows will be in the low 50 and 60 s\"\nOutput: false\nExplanation: The numbers in s are: 7, 51, 50, 60. They are not strictly increasing.\n\n \nConstraints:\n\n3 <= s.length <= 200\ns consists of lowercase English letters, spaces, and digits from 0 to 9, inclusive.\nThe number of tokens in s is between 2 and 100, inclusive.\nThe tokens in s are separated by a single space.\nThere are at least two numbers in s.\nEach number in s is a positive number less than 100, with no leading zeros.\ns contains no leading or trailing spaces.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"start 99 end 100\") == True\n assert candidate(s = \"1 apple 2 banana 3 cherry 4 date\") == True\n assert candidate(s = \"100 99 98 97 96\") == False\n assert candidate(s = \"5 15 25 35 45 55\") == True\n assert candidate(s = \"there are 10 cars 20 bikes and 30 trucks\") == True\n assert candidate(s = \"the times 10 20 30 40 50 are correct\") == True\n assert candidate(s = \"5 6 7 8 9 10 11\") == True\n assert candidate(s = \"the quick brown fox jumps over 1 lazy 2 dogs\") == True\n assert candidate(s = \"10 20 30 40 50\") == True\n assert candidate(s = \"start 1 end 2\") == True\n assert candidate(s = \"5 6 7 8 7\") == False\n assert candidate(s = \"but 100 99 98 are not\") == False\n assert candidate(s = \"100 99 98 97 96 95 94 93 92 91 90\") == False\n assert candidate(s = \"9 10 11 12 13\") == True\n assert candidate(s = \"i have 1 cat 2 dogs and 3 fish\") == True\n assert candidate(s = \"the temperature rose from 23 to 28 degrees\") == True\n assert candidate(s = \"hello world 5 x 5\") == False\n assert candidate(s = \"start 1 end 1\") == False\n assert candidate(s = \"the temperature is 23 degrees and will rise to 28 by afternoon\") == True\n assert candidate(s = \"he has 3 cats and 7 dogs\") == True\n assert candidate(s = \"the temperature is 23 degrees and rising to 28\") == True\n assert candidate(s = \"1 2 3 4 5 6 7 8 9\") == True\n assert candidate(s = \"2 apple 3 4 banana 5 6\") == True\n assert candidate(s = \"i have 1 apple 2 oranges and 3 bananas\") == True\n assert candidate(s = \"i saw 1 2 3 4 5 6 7 8 9 10\") == True\n assert candidate(s = \"i have 1 cat 2 dogs and 3 hamsters\") == True\n assert candidate(s = \"sunset is at 7 51 pm overnight lows will be in the low 50 and 60 s\") == False\n assert candidate(s = \"9 10 11\") == True\n assert candidate(s = \"1 2 3 apple 4 5\") == True\n assert candidate(s = \"9 8 7 6 5 4 3 2 1\") == False\n assert candidate(s = \"0 is not a valid number 1 is\") == False\n assert candidate(s = \"3 14 15 9 26 53 59\") == False\n assert candidate(s = \"3 5 7 9 11 13 15\") == True\n assert candidate(s = \"the temperature is 23 degrees and will rise to 30\") == True\n assert candidate(s = \"5 6 7 8 9 10\") == True\n assert candidate(s = \"100 99\") == False\n assert candidate(s = \"100 101 102\") == True\n assert candidate(s = \"10 20 30 25 40\") == False\n assert candidate(s = \"1 box has 3 blue 4 red 6 green and 12 yellow marbles\") == True\n assert candidate(s = \"one two 3 four 5 six 7\") == True\n assert candidate(s = \"she sold 12 eggs for 24 dollars\") == True\n assert candidate(s = \"we started with 50 employees and now we have 75\") == True\n assert candidate(s = \"the quick brown fox jumps over 13 lazy dogs and 14 sleeping cats\") == True\n assert candidate(s = \"there are 100 ants 110 bees and 120 wasps\") == True\n assert candidate(s = \"the measurements are 10 20 30 40 50 60 70\") == True\n assert candidate(s = \"1 car 2 trucks 3 motorcycles 4 bicycles\") == True\n assert candidate(s = \"she ate 2 apples and then 3 apples later\") == True\n assert candidate(s = \"123 124 125 126 127 128 129\") == True\n assert candidate(s = \"she turned 21 years old in 2022 and will turn 22 in 2023\") == False\n assert candidate(s = \"the heights are 30 45 60 75 90\") == True\n assert candidate(s = \"the sequence of numbers is 1 2 4 8 16 32 and 64\") == True\n assert candidate(s = \"he scored 50 60 75 80 and 90 in exams\") == True\n assert candidate(s = \"repeating numbers 1 1 2 2 3 3\") == False\n assert candidate(s = \"the journey took 3 hours and 4 hours on different days\") == True\n assert candidate(s = \"in the year 2001 we had 1 event in 2003 we had 4 events in 2005 we had 6 events\") == False\n assert candidate(s = \"lets count 1 2 3 4 5 6 7 8 9 10 and check if they are increasing\") == True\n assert candidate(s = \"the sequence is 1 2 3 4 5 6 7 8 9 10\") == True\n assert candidate(s = \"the temperature decreased from 30 degrees to 25 degrees then to 20 degrees\") == False\n assert candidate(s = \"3 little pigs 10 11 12 13 14 15\") == True\n assert candidate(s = \"1 one 2 two 3 three 4 four 5 five 6 six 7 seven\") == True\n assert candidate(s = \"in the year 1990 1995 there were 2000 2005 cars\") == True\n assert candidate(s = \"the sequence 1 3 5 7 9 is strictly increasing\") == True\n assert candidate(s = \"12 monkeys and 13 apes and 14 elephants\") == True\n assert candidate(s = \"the areas are 1 4 9 16 25 36 and 49\") == True\n assert candidate(s = \"a1 b2 c3 6 7 8 9 10\") == True\n assert candidate(s = \"1000 apples 2000 bananas 3000 cherries 4000 dates\") == True\n assert candidate(s = \"the book had 5 chapters and the next book had 8 chapters\") == True\n assert candidate(s = \"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25\") == True\n assert candidate(s = \"a1 b2 c3 4 d5 e6 f7 g8 h9 i10\") == True\n assert candidate(s = \"we have 100 books 200 magazines and 300 newspapers\") == True\n assert candidate(s = \"42 is the answer to life 43 the universe and 44 everything\") == True\n assert candidate(s = \"he received 10 calls in the morning and 15 in the afternoon\") == True\n assert candidate(s = \"the temperature rose from 20 degrees to 22 and then to 25\") == True\n assert candidate(s = \"one 2 three 4 five 6 seven 8 nine 10\") == True\n assert candidate(s = \"12 monkeys and 13 gorillas but only 7 chimpanzees\") == False\n assert candidate(s = \"the temperature was 10 degrees at 1 oclock and 12 degrees at 2 oclock and 15 degrees at 3 oclock\") == False\n assert candidate(s = \"the temperature rose from 20 to 22 then to 25\") == True\n assert candidate(s = \"the times are 12 24 36 48 and 60\") == True\n assert candidate(s = \"the weights are 1 2 3 5 8 13 and 21\") == True\n assert candidate(s = \"she baked 5 cakes 10 muffins and 15 brownies\") == True\n assert candidate(s = \"the steps are 100 200 300 400 500\") == True\n assert candidate(s = \"there are 100 ants 200 bees 300 flies and 400 spiders\") == True\n assert candidate(s = \"the number 10 comes before 20 and 30\") == True\n assert candidate(s = \"the sales increased from 100 units to 150 units last quarter\") == True\n assert candidate(s = \"the numbers 1 2 3 4 5 6 7 8 9 10 are in ascending order\") == True\n assert candidate(s = \"the increments are 1 2 3 4 5 6 7 8\") == True\n assert candidate(s = \"alpha 1 beta 2 gamma 3 delta 4 epsilon 5 zeta 6 eta 7 theta 8 iota 9 kappa 10 lambda 11 mu 12 nu 13 xi 14 omicron 15 pi 16 rho 17 sigma 18 tau 19 upsilon 20 phi 21 chi 22 psi 23 omega 24\") == True\n assert candidate(s = \"the sequence of numbers is 1 3 6 10 15 21 and 28\") == True\n assert candidate(s = \"in the year 1800 there were 1801 people in this town 1802\") == True\n assert candidate(s = \"20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39\") == True\n assert candidate(s = \"she baked 5 cakes 10 pies and 15 tarts\") == True\n assert candidate(s = \"the positions are 10 20 30 40 50 60 and 70\") == True\n assert candidate(s = \"58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77\") == True\n assert candidate(s = \"the volumes are 10 100 1000 10000 and 100000\") == True\n assert candidate(s = \"the temperature rose from 10 to 20 then to 30 degrees\") == True\n assert candidate(s = \"in the year 2000 we had 100 participants and in 2005 we had 150 participants\") == False\n assert candidate(s = \"the project took 1 month and then 2 months to complete\") == True\n assert candidate(s = \"the sequence 1 3 5 7 9 11 13 15 17 19 is strictly increasing\") == True\n assert candidate(s = \"the numbers are 1 2 3 but then 2 again\") == False\n assert candidate(s = \"a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10 k 11 l 12 m 13 n 14 o 15 p 16 q 17 r 18 s 19 t 20\") == True\n assert candidate(s = \"increasing by one 1 2 3 4 5 6 7 8 9\") == True\n assert candidate(s = \"the temperature today is 30 degrees 31 tomorrow 32 the day after\") == True\n assert candidate(s = \"the sequence is 1 3 5 7 9 11 13\") == True\n assert candidate(s = \"the garden has 1 tulip 3 roses 5 daisies 7 sunflowers\") == True\n assert candidate(s = \"we planted 50 trees 100 bushes and 200 flowers\") == True\n assert candidate(s = \"in 1999 there were 2000 cars and in 2001 there were 2002 cars\") == True\n assert candidate(s = \"we collected 15 apples 20 oranges and 25 bananas\") == True\n assert candidate(s = \"one 1 two 2 three 3 four 4 five 5 six 6 seven 7 eight 8 nine 9 ten 10 eleven 11\") == True\n assert candidate(s = \"3 cats 5 dogs 7 birds 9 fish\") == True\n assert candidate(s = \"99 98 97 96 95 94 93 92 91 90\") == False\n assert candidate(s = \"she sold 1 apple 2 oranges 3 bananas 4 grapes 5 watermelons 6 pineapples\") == True\n assert candidate(s = \"the speed increased from 20 kmph to 30 kmph and then to 40 kmph\") == True\n assert candidate(s = \"the distances are 1000 2000 3000 4000 and 5000\") == True\n assert candidate(s = \"we climbed 100 meters then 200 meters and finally 300 meters\") == True\n assert candidate(s = \"the time is 12 13 14 15 16 17 18 19 20 21 22 23\") == True\n assert candidate(s = \"there were 5 kids 6 teenagers 7 adults in the room\") == True\n assert candidate(s = \"the company grew from 1000 employees to 1500 employees last year\") == True\n assert candidate(s = \"he won 1 race and then 2 races in a row\") == True\n assert candidate(s = \"the first year 1990 was followed by 1991 and then 1992\") == True\n assert candidate(s = \"1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10\") == False\n assert candidate(s = \"the sequence 10 20 30 40 50 60 70 80 90 100 is ascending\") == True\n assert candidate(s = \"in the year 2020 2021 2022 and 2023\") == True\n assert candidate(s = \"the ages are 5 10 15 20 25 30\") == True\n assert candidate(s = \"the numbers 10 20 30 40 50 are increasing\") == True\n assert candidate(s = \"in the sequence 2 4 6 8 10 12 14 16 18 20 all numbers are in increasing order\") == True\n assert candidate(s = \"there are 2 cars 4 trucks and 6 motorcycles\") == True\n assert candidate(s = \"random 5 10 20 15 25 30 29 35 40 45\") == False\n assert candidate(s = \"20 apples and 25 oranges but only 15 bananas\") == False\n assert candidate(s = \"a quick brown fox jumps over 1 lazy dog then 2 sleepy dogs\") == True\n assert candidate(s = \"the ages are 25 30 35 40 45 50 55\") == True\n assert candidate(s = \"she sold sea shells by the sea shore 1 2 3 4 5 6 7 8 9 10 11 12\") == True\n assert candidate(s = \"39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58\") == True\n assert candidate(s = \"there are 100 bottles of beer on the wall 101 102 103\") == True\n assert candidate(s = \"in the year 2020 we had 21 cars 23 trucks and 25 buses\") == False\n assert candidate(s = \"compare these numbers 10 20 30 40 50 60 70 80 90 100\") == True\n assert candidate(s = \"decreasing numbers 5 4 3 2 1\") == False\n assert candidate(s = \"there are 30 apples 40 oranges 50 bananas 60 grapes 70 strawberries 80 blueberries\") == True\n assert candidate(s = \"the temperature rose from 20 to 25 to 30 degrees\") == True\n assert candidate(s = \"random order 1 3 2 4 5\") == False\n assert candidate(s = \"a1 b2 c3 d4 e5 f6 g7 h8 i9 j10 11 12 13 14 15 16 17 18 19 20\") == True\n assert candidate(s = \"the chapters are numbered 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\") == True\n assert candidate(s = \"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20\") == True\n assert candidate(s = \"the ages are 5 10 15 20 25 30 35 40\") == True\n assert candidate(s = \"the quick brown fox jumps over 1 lazy dog 2\") == True\n assert candidate(s = \"she played 1 game 2 matches 3 tournaments\") == True\n assert candidate(s = \"we counted 1 bird 2 cats 3 dogs 4 elephants 5 foxes 6 giraffes 7 hippos\") == True\n assert candidate(s = \"she saw 5 stars 10 planets and 15 galaxies\") == True\n assert candidate(s = \"23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43\") == True\n assert candidate(s = \"even numbers 2 4 6 8 10 12 14 16 18 20\") == True\n assert candidate(s = \"strictly increasing 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\") == True\n assert candidate(s = \"in a race 10 runners came first 20 second and 30 third\") == True\n assert candidate(s = \"the clock struck 1 pm 2 pm 3 pm 4 pm\") == True\n assert candidate(s = \"the sequence of numbers is 3 9 27 81 and 243\") == True\n assert candidate(s = \"mixed numbers 1 20 2 30 3\") == False\n assert candidate(s = \"in the year 2000 2001 2002 the world changed\") == True\n assert candidate(s = \"a sequence of 1 2 3 4 5 6 7 8 9 10 numbers\") == True\n assert candidate(s = \"a sequence of numbers like 10 20 30 40 50 should be increasing\") == True\n assert candidate(s = \"the values are 2 4 8 16 32\") == True\n assert candidate(s = \"42 cats 43 dogs 44 elephants 45 flamingos\") == True\n assert candidate(s = \"77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96\") == True\n assert candidate(s = \"abc 1 def 2 ghi 3 jkl 4 mno 5 pqr 6 stu 7 vwx 8 yz 9 10\") == True\n assert candidate(s = \"nested numbers like 10 in 11 the 12 and 13 final\") == True\n assert candidate(s = \"99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115\") == True\n assert candidate(s = \"99 100 101 102 103 104 105 106\") == True\n assert candidate(s = \"96 97 98 99 100 101 102 103 104 105 106 107 108 109 110\") == True\n assert candidate(s = \"the children are 1 year old 2 years old 3 years old 4 years old\") == True\n assert candidate(s = \"100 apples 101 oranges 102 bananas\") == True\n assert candidate(s = \"my password is 123 and my pin is 124 and my secret number is 125\") == True\n assert candidate(s = \"the team scored 2 goals in the first half and 3 goals in the second half\") == True\n assert candidate(s = \"the prices are 5 10 15 20 25\") == True\n assert candidate(s = \"decreasing numbers 20 19 18 17 16 15 14 13 12 11 10\") == False\n assert candidate(s = \"the sequence is 1 4 9 16 25 and 36\") == True\n assert candidate(s = \"there are 3 cats 5 dogs and 7 birds in the zoo\") == True\n assert candidate(s = \"the quick brown fox jumps over the lazy dog 1 2 3 4 5\") == True\n assert candidate(s = \"he collected 2 seashells by the sea 4 on the beach and 6 in the sand\") == True\n assert candidate(s = \"1 2 3 4 5 6 7 8 9 10\") == True\n assert candidate(s = \"a quick brown fox jumps over the lazy dog 1 2 3 4 5\") == True\n assert candidate(s = \"there are 100 apples 101 oranges and 102 bananas\") == True\n assert candidate(s = \"the levels are 10 20 30 40 50 60 70 80 90\") == True\n assert candidate(s = \"007 is not a valid number but 7 8 9 are valid numbers\") == False\n assert candidate(s = \"two digit numbers 10 20 30 40 50\") == True\n assert candidate(s = \"the quick brown fox jumps over the lazy dog 1 2 3 4 5 6 7 8 9 10\") == True\n assert candidate(s = \"99 100 99 101 102 103 104 105 106 107 108 109 110 111 112 113 114\") == False\n assert candidate(s = \"a series of 1 3 5 7 9 11 13 15 17 19 odd numbers\") == True\n assert candidate(s = \"we have 10 apples 20 oranges 30 bananas and 30 grapes\") == False\n assert candidate(s = \"the number sequence is 1 2 3 4 5 6 7 8 9\") == True\n assert candidate(s = \"he ran 1 mile in 5 minutes then 2 miles in 10 minutes\") == False\n assert candidate(s = \"99 bottles of beer on the wall 98 bottles of beer\") == False\n assert candidate(s = \"the heights are 100 200 300 400 and 500\") == True\n assert candidate(s = \"the numbers 5 10 15 20 25 30 35 40 45 50 are increasing\") == True\n assert candidate(s = \"30 apples 40 oranges 50 bananas 60 grapes\") == True\n assert candidate(s = \"a 1 b 2 c 3 d 4 e 5 f 6 g 7 h 8 i 9 j 10\") == True\n assert candidate(s = \"21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40\") == True\n assert candidate(s = \"the counts are 1 2 3 4 5 6 7 8 9 10\") == True\n assert candidate(s = \"the first 2 books have 3 chapters each and the 5 next books have 6 chapters each\") == True\n assert candidate(s = \"1234 5678 91011 121314\") == True\n assert candidate(s = \"the temperature rose from 5 degrees to 10 degrees then to 15 degrees\") == True\n assert candidate(s = \"single digit numbers 1 2 3 4 5\") == True\n assert candidate(s = \"a quick brown fox jumps over 1 3 5 lazy dogs\") == True\n assert candidate(s = \"she has 10 red balloons 20 blue ones and 30 green ones\") == True\n assert candidate(s = \"a 1 digit number 10 two digit numbers 100 three digit numbers\") == True\n assert candidate(s = \"in the series 2 4 6 8 10 the numbers are strictly increasing\") == True\n assert candidate(s = \"we planted 1 tree 2 bushes 3 flowers 4 vines and 5 cacti\") == True\n assert candidate(s = \"the sequence is 1 1 2 3 5 8 and 13\") == False\n"}, "metadata": {"canonical_parameter_names": ["s"], "leetcode_dataset_entry_point": "Solution().areNumbersAscending", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool areNumbersAscending(string s) {", "container": "Solution", "callable": "areNumbersAscending", "parameters": [{"name": "s", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2044, "task_id": "count-number-of-maximum-bitwise-or-subsets", "difficulty": "Medium", "problem_description": "Given an integer array nums, find the maximum possible bitwise OR of a subset of nums and return the number of different non-empty subsets with the maximum bitwise OR.\nAn array a is a subset of an array b if a can be obtained from b by deleting some (possibly zero) elements of b. Two subsets are considered different if the indices of the elements chosen are different.\nThe bitwise OR of an array a is equal to a[0] OR a[1] OR ... OR a[a.length - 1] (0-indexed).\n \nExample 1:\n\nInput: nums = [3,1]\nOutput: 2\nExplanation: The maximum possible bitwise OR of a subset is 3. There are 2 subsets with a bitwise OR of 3:\n- [3]\n- [3,1]\n\nExample 2:\n\nInput: nums = [2,2,2]\nOutput: 7\nExplanation: All non-empty subsets of [2,2,2] have a bitwise OR of 2. There are 23 - 1 = 7 total subsets.\n\nExample 3:\n\nInput: nums = [3,2,1,5]\nOutput: 6\nExplanation: The maximum possible bitwise OR of a subset is 7. There are 6 subsets with a bitwise OR of 7:\n- [3,5]\n- [3,1,5]\n- [3,2,5]\n- [3,2,1,5]\n- [2,5]\n- [2,1,5]\n \nConstraints:\n\n1 <= nums.length <= 16\n1 <= nums[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [15, 15, 15]) == 7\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5]) == 255\n assert candidate(nums = [3, 2, 1, 5]) == 6\n assert candidate(nums = [6, 2, 1, 3, 4]) == 17\n assert candidate(nums = [6, 2, 1, 5, 4]) == 17\n assert candidate(nums = [5, 1, 1, 2, 5]) == 12\n assert candidate(nums = [1, 3, 5, 7, 9]) == 10\n assert candidate(nums = [1]) == 1\n assert candidate(nums = [2, 2, 2]) == 7\n assert candidate(nums = [1, 3, 7, 15, 31]) == 16\n assert candidate(nums = [15, 15, 15, 15]) == 15\n assert candidate(nums = [1, 2, 4, 8]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50]) == 16\n assert candidate(nums = [5, 5, 5, 5, 5]) == 31\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 65535\n assert candidate(nums = [15, 7, 3, 1]) == 8\n assert candidate(nums = [16, 8, 4, 2, 1]) == 1\n assert candidate(nums = [3, 1]) == 2\n assert candidate(nums = [1, 3, 7, 15]) == 8\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1]) == 255\n assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 65535\n assert candidate(nums = [10, 20, 30, 40]) == 5\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 1]) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 64594\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35]) == 52\n assert candidate(nums = [5, 10, 15, 20, 25, 30]) == 44\n assert candidate(nums = [1, 2, 4, 8, 16, 32]) == 1\n assert candidate(nums = [8, 4, 2, 1, 15, 7, 3]) == 85\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 65535\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3]) == 32768\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == 64594\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 859\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1, 128, 64, 32, 16, 8, 4, 2, 1]) == 6561\n assert candidate(nums = [16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384, 16384]) == 65535\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 32767\n assert candidate(nums = [32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]) == 1\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 7, 6, 5, 4, 3, 2, 1]) == 16203\n assert candidate(nums = [1048576, 524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32]) == 1\n assert candidate(nums = [31, 15, 7, 3, 1, 31, 15, 7, 3, 1, 31, 15, 7, 3, 1, 31]) == 61440\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 32297\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, 7, 6, 5, 4, 3, 2, 1, 0]) == 64812\n assert candidate(nums = [13, 7, 15, 3, 1, 8, 2, 4]) == 205\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 32297\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 64897\n assert candidate(nums = [1, 5, 11, 5, 1, 11, 5, 1, 11, 5, 1, 11, 5, 1]) == 14880\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1023]) == 32768\n assert candidate(nums = [15, 7, 3, 1]) == 8\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 255\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 511\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64]) == 1\n assert candidate(nums = [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]) == 65535\n assert candidate(nums = [15, 15, 15, 15, 15]) == 31\n assert candidate(nums = [31, 15, 7, 3, 1]) == 16\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 1\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536]) == 1\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1]) == 128\n assert candidate(nums = [31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 64594\n assert candidate(nums = [65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 32768\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023]) == 512\n assert candidate(nums = [31, 28, 29, 30, 31, 30, 29, 28]) == 228\n assert candidate(nums = [17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17]) == 65535\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 171\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1]) == 109\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 65535\n assert candidate(nums = [3, 6, 12, 24, 48, 96, 192, 384]) == 21\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597]) == 22336\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 255\n assert candidate(nums = [8, 16, 24, 32, 40, 48, 56, 64]) == 109\n assert candidate(nums = [255, 128, 64, 32, 16, 8, 4, 2, 1, 256, 512, 1024, 2048, 4096, 8192, 16384]) == 257\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 65535\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40]) == 150\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128]) == 1\n assert candidate(nums = [31, 14, 7, 3, 1, 31, 14, 7, 3, 1]) == 768\n assert candidate(nums = [1048575, 524287, 262143, 131071, 65535, 32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31]) == 32768\n assert candidate(nums = [255, 255, 255, 255, 255, 255, 255, 255]) == 255\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600]) == 62449\n assert candidate(nums = [14, 7, 3, 1, 14, 7, 3, 1]) == 189\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == 65535\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562]) == 13\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8]) == 255\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 1, 1, 1, 1, 1, 1]) == 32768\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1, 128, 64, 32, 16, 8, 4, 2, 1]) == 6561\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90, 99, 108, 117, 126, 135, 144]) == 48108\n assert candidate(nums = [32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1, 0]) == 32768\n assert candidate(nums = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32, 64, 64, 128, 128]) == 6561\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195]) == 170\n assert candidate(nums = [13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13]) == 65535\n assert candidate(nums = [1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 512\n assert candidate(nums = [32767, 16383, 8191, 4095, 2047, 1023, 511, 255, 127, 63, 31, 15, 7, 3, 1]) == 16384\n assert candidate(nums = [5, 3, 10, 14, 15, 1, 2, 8, 4, 6, 7, 11, 12, 13, 9]) == 32297\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 48609\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768]) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160]) == 59421\n assert candidate(nums = [127, 63, 31, 15, 7, 3, 1]) == 64\n assert candidate(nums = [5, 5, 10, 10, 15, 15, 20, 20, 25, 25, 30, 30, 35, 35, 40, 40]) == 59922\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 1, 10, 100, 1000, 10000, 100000]) == 2592\n assert candidate(nums = [31, 15, 7, 3, 1, 63, 127, 255, 511, 1023, 1, 2, 4, 8, 16, 32]) == 32768\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128]) == 1\n assert candidate(nums = [255, 127, 63, 31, 15, 7, 3, 1]) == 128\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32767]) == 32769\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72]) == 109\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535]) == 32768\n assert candidate(nums = [15, 30, 45, 60, 75, 90, 105, 120, 135, 150, 165, 180, 195, 210, 225, 240]) == 63775\n assert candidate(nums = [128, 64, 32, 16, 8, 4, 2, 1]) == 1\n assert candidate(nums = [14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14]) == 65535\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 65535\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 32297\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3]) == 12611\n assert candidate(nums = [1, 3, 7, 15, 31, 63, 127]) == 64\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64]) == 1\n assert candidate(nums = [7, 3, 2, 1, 6, 5, 4, 8, 10, 9, 11, 12, 13, 14, 15, 16]) == 32297\n assert candidate(nums = [12, 14, 7, 1, 9, 3, 11]) == 102\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().countMaxOrSubsets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countMaxOrSubsets(vector& nums) {", "container": "Solution", "callable": "countMaxOrSubsets", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2045, "task_id": "second-minimum-time-to-reach-destination", "difficulty": "Hard", "problem_description": "A city is represented as a bi-directional connected graph with n vertices where each vertex is labeled from 1 to n (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [ui, vi] denotes a bi-directional edge between vertex ui and vertex vi. Every vertex pair is connected by at most one edge, and no vertex has an edge to itself. The time taken to traverse any edge is time minutes.\nEach vertex has a traffic signal which changes its color from green to red and vice versa every change minutes. All signals change at the same time. You can enter a vertex at any time, but can leave a vertex only when the signal is green. You cannot wait at a vertex if the signal is green.\nThe second minimum value is defined as the smallest value strictly larger than the minimum value.\n\nFor example the second minimum value of [2, 3, 4] is 3, and the second minimum value of [2, 2, 4] is 4.\n\nGiven n, edges, time, and change, return the second minimum time it will take to go from vertex 1 to vertex n.\nNotes:\n\nYou can go through any vertex any number of times, including 1 and n.\nYou can assume that when the journey starts, all signals have just turned green.\n\n \nExample 1:\n        \n\nInput: n = 5, edges = [[1,2],[1,3],[1,4],[3,4],[4,5]], time = 3, change = 5\nOutput: 13\nExplanation:\nThe figure on the left shows the given graph.\nThe blue path in the figure on the right is the minimum time path.\nThe time taken is:\n- Start at 1, time elapsed=0\n- 1 -> 4: 3 minutes, time elapsed=3\n- 4 -> 5: 3 minutes, time elapsed=6\nHence the minimum time needed is 6 minutes.\n\nThe red path shows the path to get the second minimum time.\n- Start at 1, time elapsed=0\n- 1 -> 3: 3 minutes, time elapsed=3\n- 3 -> 4: 3 minutes, time elapsed=6\n- Wait at 4 for 4 minutes, time elapsed=10\n- 4 -> 5: 3 minutes, time elapsed=13\nHence the second minimum time is 13 minutes. \n\nExample 2:\n\n\nInput: n = 2, edges = [[1,2]], time = 3, change = 2\nOutput: 11\nExplanation:\nThe minimum time path is 1 -> 2 with time = 3 minutes.\nThe second minimum time path is 1 -> 2 -> 1 -> 2 with time = 11 minutes.\n \nConstraints:\n\n2 <= n <= 104\nn - 1 <= edges.length <= min(2 * 104, n * (n - 1) / 2)\nedges[i].length == 2\n1 <= ui, vi <= n\nui != vi\nThere are no duplicate edges.\nEach vertex can be reached directly or indirectly from every other vertex.\n1 <= time, change <= 103\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 2,edges = [[1, 2]],time = 3,change = 2) == 11\n assert candidate(n = 3,edges = [[1, 2], [2, 3]],time = 2,change = 3) == 10\n assert candidate(n = 3,edges = [[1, 2], [2, 3]],time = 5,change = 5) == 35\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [3, 5], [4, 5], [5, 6]],time = 2,change = 4) == 18\n assert candidate(n = 4,edges = [[1, 2], [2, 3], [3, 4], [1, 4]],time = 2,change = 3) == 8\n assert candidate(n = 4,edges = [[1, 2], [1, 3], [3, 4], [2, 4]],time = 2,change = 3) == 10\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 6]],time = 4,change = 7) == 32\n assert candidate(n = 5,edges = [[1, 2], [1, 3], [1, 4], [3, 4], [4, 5]],time = 3,change = 5) == 13\n assert candidate(n = 4,edges = [[1, 2], [2, 3], [3, 4]],time = 5,change = 7) == 33\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 5], [5, 6]],time = 4,change = 7) == 22\n assert candidate(n = 4,edges = [[1, 2], [2, 3], [3, 4], [4, 1]],time = 2,change = 3) == 8\n assert candidate(n = 14,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]],time = 1,change = 2) == 29\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 9], [10, 11], [12, 13], [14, 15]],time = 8,change = 11) == 38\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 12], [10, 12], [11, 12], [1, 12]],time = 5,change = 7) == 19\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [1, 10]],time = 2,change = 3) == 8\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 7], [6, 8], [7, 9], [8, 10]],time = 3,change = 5) == 13\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9]],time = 5,change = 4) == 29\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [7, 8], [9, 10], [11, 12]],time = 3,change = 4) == 14\n assert candidate(n = 50,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 26], [13, 27], [14, 28], [14, 29], [15, 30], [15, 31], [16, 32], [16, 33], [17, 34], [17, 35], [18, 36], [18, 37], [19, 38], [19, 39], [20, 40], [20, 41], [21, 42], [21, 43], [22, 44], [22, 45], [23, 46], [23, 47], [24, 48], [24, 49], [25, 50]],time = 3,change = 5) == 33\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [10, 21], [11, 22], [11, 23], [12, 24], [12, 25], [13, 24], [13, 25]],time = 5,change = 7) == 38\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 6], [3, 7], [4, 6], [4, 7], [5, 6], [5, 7]],time = 5,change = 8) == 26\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],time = 8,change = 12) == 184\n assert candidate(n = 9,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]],time = 4,change = 6) == 28\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 12], [10, 12], [11, 12]],time = 3,change = 5) == 26\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 10], [9, 11], [12, 14], [13, 15]],time = 5,change = 8) == 26\n assert candidate(n = 11,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11]],time = 9,change = 12) == 57\n assert candidate(n = 11,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [1, 5], [1, 6], [1, 7], [2, 8], [2, 9], [3, 10], [3, 11]],time = 6,change = 8) == 28\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9]],time = 7,change = 10) == 47\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = 3,change = 5) == 53\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [5, 12], [6, 13], [6, 14], [7, 15], [7, 16], [8, 17], [8, 18], [9, 19], [9, 20]],time = 6,change = 9) == 42\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15], [12, 13], [13, 14], [14, 15]],time = 5,change = 8) == 37\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 7]],time = 4,change = 5) == 24\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 6], [6, 7]],time = 3,change = 4) == 22\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8]],time = 3,change = 5) == 43\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],time = 4,change = 7) == 92\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15]],time = 7,change = 9) == 43\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 12], [10, 11], [11, 12], [5, 7], [4, 6]],time = 3,change = 7) == 20\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 10]],time = 7,change = 10) == 47\n assert candidate(n = 14,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [7, 13], [8, 14], [1, 5], [1, 7], [2, 8], [2, 10], [3, 9], [3, 11], [4, 12], [4, 14], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14]],time = 6,change = 13) == 18\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],time = 3,change = 4) == 14\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 6], [7, 8], [9, 10]],time = 4,change = 5) == 14\n assert candidate(n = 16,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 5], [3, 7], [4, 6], [4, 7], [5, 8], [5, 9], [6, 8], [6, 10], [7, 9], [7, 10], [8, 11], [8, 12], [9, 11], [9, 12], [10, 13], [10, 14], [11, 13], [11, 15], [12, 14], [12, 15], [13, 16], [14, 16], [15, 16]],time = 5,change = 10) == 50\n assert candidate(n = 8,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8]],time = 4,change = 6) == 28\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],time = 4,change = 6) == 124\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 5], [3, 7], [4, 6], [4, 7], [5, 8], [5, 9], [6, 8], [6, 10], [7, 9], [7, 10], [8, 11], [8, 12], [9, 11], [10, 12]],time = 8,change = 12) == 64\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = 2,change = 3) == 32\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 16], [8, 17], [9, 18], [9, 19], [10, 20], [11, 16], [12, 17], [13, 18], [14, 19], [15, 20]],time = 5,change = 8) == 42\n assert candidate(n = 18,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18]],time = 5,change = 6) == 101\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 8], [9, 10]],time = 2,change = 4) == 12\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [6, 16], [6, 17], [7, 18], [7, 19], [8, 20], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],time = 4,change = 7) == 22\n assert candidate(n = 11,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11], [2, 3], [5, 7], [6, 8], [9, 10]],time = 3,change = 5) == 16\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [3, 5], [4, 6], [5, 7], [5, 8], [6, 9], [7, 9], [8, 9]],time = 5,change = 7) == 24\n assert candidate(n = 20,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],time = 3,change = 5) == 93\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 8], [7, 8]],time = 4,change = 6) == 28\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10]],time = 7,change = 10) == 54\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 5], [3, 7], [4, 6], [4, 7], [5, 8], [6, 8], [7, 8]],time = 6,change = 5) == 46\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [7, 12]],time = 2,change = 3) == 14\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [4, 6], [5, 6]],time = 10,change = 12) == 34\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [1, 10], [5, 15], [9, 19]],time = 4,change = 6) == 32\n assert candidate(n = 16,edges = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [2, 7], [3, 8], [3, 9], [4, 10], [4, 11], [5, 12], [5, 13], [6, 14], [6, 15], [7, 16], [8, 9], [10, 11], [12, 13], [14, 15], [16, 15]],time = 3,change = 5) == 16\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [1, 12]],time = 2,change = 3) == 8\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = 6,change = 8) == 86\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 8], [7, 8]],time = 6,change = 9) == 42\n assert candidate(n = 20,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],time = 3,change = 6) == 123\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 10], [9, 11], [12, 14], [13, 15]],time = 2,change = 5) == 12\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10], [5, 11], [6, 12], [7, 8], [9, 10], [11, 12]],time = 3,change = 5) == 16\n assert candidate(n = 15,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],time = 4,change = 3) == 94\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [5, 6], [7, 8], [8, 9], [5, 8], [6, 7], [5, 7], [6, 8]],time = 4,change = 6) == 16\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10]],time = 3,change = 4) == 22\n assert candidate(n = 12,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],time = 7,change = 9) == 97\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [3, 8], [4, 9], [4, 10]],time = 6,change = 8) == 28\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 12], [9, 13], [10, 14], [11, 15]],time = 2,change = 3) == 10\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 9]],time = 6,change = 5) == 36\n assert candidate(n = 12,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],time = 3,change = 5) == 63\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 7], [6, 7]],time = 5,change = 4) == 29\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 9], [10, 11], [12, 13], [14, 15]],time = 5,change = 6) == 22\n assert candidate(n = 25,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [2, 6], [2, 7], [3, 8], [3, 9], [3, 10], [4, 11], [4, 12], [4, 13], [5, 14], [5, 15], [6, 16], [6, 17], [7, 18], [7, 19], [8, 20], [8, 21], [8, 22], [9, 23], [9, 24], [10, 25], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20], [21, 22], [23, 24], [24, 25]],time = 3,change = 6) == 18\n assert candidate(n = 10,edges = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = 7,change = 13) == 137\n assert candidate(n = 6,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 6], [1, 4], [1, 5], [2, 6], [3, 4], [3, 6]],time = 7,change = 10) == 27\n assert candidate(n = 8,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 8], [7, 8]],time = 3,change = 4) == 19\n assert candidate(n = 15,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 9], [10, 11], [12, 13], [14, 15]],time = 3,change = 7) == 17\n assert candidate(n = 10,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10]],time = 3,change = 5) == 26\n assert candidate(n = 7,edges = [[1, 2], [1, 3], [1, 4], [2, 5], [3, 5], [4, 6], [5, 7], [6, 7]],time = 7,change = 5) == 47\n assert candidate(n = 9,edges = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9]],time = 6,change = 5) == 56\n"}, "metadata": {"canonical_parameter_names": ["n", "edges", "time", "change"], "leetcode_dataset_entry_point": "Solution().secondMinimum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int secondMinimum(int n, vector>& edges, int time, int change) {", "container": "Solution", "callable": "secondMinimum", "parameters": [{"name": "n", "type": "int"}, {"name": "edges", "type": "vector>&"}, {"name": "time", "type": "int"}, {"name": "change", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2047, "task_id": "number-of-valid-words-in-a-sentence", "difficulty": "Easy", "problem_description": "A sentence consists of lowercase letters ('a' to 'z'), digits ('0' to '9'), hyphens ('-'), punctuation marks ('!', '.', and ','), and spaces (' ') only. Each sentence can be broken down into one or more tokens separated by one or more spaces ' '.\nA token is a valid word if all three of the following are true:\n\nIt only contains lowercase letters, hyphens, and/or punctuation (no digits).\nThere is at most one hyphen '-'. If present, it must be surrounded by lowercase characters (\"a-b\" is valid, but \"-ab\" and \"ab-\" are not valid).\nThere is at most one punctuation mark. If present, it must be at the end of the token (\"ab,\", \"cd!\", and \".\" are valid, but \"a!b\" and \"c.,\" are not valid).\n\nExamples of valid words include \"a-b.\", \"afad\", \"ba-c\", \"a!\", and \"!\".\nGiven a string sentence, return the number of valid words in sentence.\n \nExample 1:\n\nInput: sentence = \"cat and dog\"\nOutput: 3\nExplanation: The valid words in the sentence are \"cat\", \"and\", and \"dog\".\n\nExample 2:\n\nInput: sentence = \"!this 1-s b8d!\"\nOutput: 0\nExplanation: There are no valid words in the sentence.\n\"!this\" is invalid because it starts with a punctuation mark.\n\"1-s\" and \"b8d\" are invalid because they contain digits.\n\nExample 3:\n\nInput: sentence = \"alice and bob are playing stone-game10\"\nOutput: 5\nExplanation: The valid words in the sentence are \"alice\", \"and\", \"bob\", \"are\", and \"playing\".\n\"stone-game10\" is invalid because it contains digits.\n\n \nConstraints:\n\n1 <= sentence.length <= 1000\nsentence only contains lowercase English letters, digits, ' ', '-', '!', '.', and ','.\nThere will be at least 1 token.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(sentence = \"no-digits123 or symbols#allowed\") == 2\n assert candidate(sentence = \"a.b.c\") == 0\n assert candidate(sentence = \"hello-world, this-is-a-test\") == 1\n assert candidate(sentence = \"hello-\") == 0\n assert candidate(sentence = \"a-\") == 0\n assert candidate(sentence = \"singleletter a b c d e f g\") == 8\n assert candidate(sentence = \"valid-words only\") == 2\n assert candidate(sentence = \"a\") == 1\n assert candidate(sentence = \"hello world! this is a test.\") == 6\n assert candidate(sentence = \"hello-world, my.name-is Qwen\") == 2\n assert candidate(sentence = \"ending-with-punctuation!\") == 0\n assert candidate(sentence = \"invalid--double-dash\") == 0\n assert candidate(sentence = \"multiple spaces between words\") == 4\n assert candidate(sentence = \"123\") == 0\n assert candidate(sentence = \"multiple--hyphens\") == 0\n assert candidate(sentence = \"valid-hyphenated-word\") == 0\n assert candidate(sentence = \"-invalid invalid- invalid-!\") == 0\n assert candidate(sentence = \"well-well, well!\") == 2\n assert candidate(sentence = \"singleletter\") == 1\n assert candidate(sentence = \"a! b. c?\") == 3\n assert candidate(sentence = \"hello-world\") == 1\n assert candidate(sentence = \"a-b-c\") == 0\n assert candidate(sentence = \"-world\") == 0\n assert candidate(sentence = \"a-b-c d-e f-g\") == 2\n assert candidate(sentence = \"-b\") == 0\n assert candidate(sentence = \"no-digits-allowed 123 456-789\") == 0\n assert candidate(sentence = \"alice and bob are playing stone-game10\") == 5\n assert candidate(sentence = \"no-dash-here\") == 0\n assert candidate(sentence = \"a-b!\") == 1\n assert candidate(sentence = \"valid-word here!\") == 2\n assert candidate(sentence = \"a-b- c d\") == 2\n assert candidate(sentence = \"valid-word here and another-valid one!\") == 5\n assert candidate(sentence = \"a-b-c-d.e.f!\") == 0\n assert candidate(sentence = \"singleletter a b c\") == 4\n assert candidate(sentence = \"a-b. afad ba-c a! .\") == 5\n assert candidate(sentence = \"a.b-c\") == 0\n assert candidate(sentence = \"hello!world\") == 0\n assert candidate(sentence = \",\") == 1\n assert candidate(sentence = \"a!b\") == 0\n assert candidate(sentence = \"-ab cd- ef-\") == 0\n assert candidate(sentence = \"hello-world, my name is john-doe.\") == 5\n assert candidate(sentence = \"!this 1-s b8d!\") == 0\n assert candidate(sentence = \"trailingpunctuation. comma, exclamation!\") == 3\n assert candidate(sentence = \"punctuation,in,middle,a-b.c\") == 0\n assert candidate(sentence = \"invalid-end-\") == 0\n assert candidate(sentence = \"-invalid start\") == 1\n assert candidate(sentence = \"valid-word here! and here.\") == 4\n assert candidate(sentence = \"!\") == 1\n assert candidate(sentence = \"valid-word-here!\") == 0\n assert candidate(sentence = \"punctuation,at,end.\") == 0\n assert candidate(sentence = \"a-b.c\") == 0\n assert candidate(sentence = \"cat and dog\") == 3\n assert candidate(sentence = \".\") == 1\n assert candidate(sentence = \"-invalid-start\") == 0\n assert candidate(sentence = \"a.b\") == 0\n assert candidate(sentence = \"hello-world!\") == 1\n assert candidate(sentence = \"punctuation! marks, are: allowed?\") == 4\n assert candidate(sentence = \"punctuation.only,\") == 0\n assert candidate(sentence = \"valid-word- valid-word-\") == 0\n assert candidate(sentence = \"word-with-digit1\") == 0\n assert candidate(sentence = \"punctuation-after-hyphen-! invalid\") == 1\n assert candidate(sentence = \"word-with-digit-and-punctuation-1,\") == 0\n assert candidate(sentence = \"valid-word, valid-word!\") == 2\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word?\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word@123\") == 1\n assert candidate(sentence = \"valid-word-with-hyphen-and-punctuation!\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!\") == 1\n assert candidate(sentence = \"valid-word, invalid-word2\") == 1\n assert candidate(sentence = \"word-with-hyphen-and-punctuation-after-hyphen-,\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@\") == 1\n assert candidate(sentence = \"word-with-digit-and-hyphen-1b\") == 0\n assert candidate(sentence = \"word-with-digit-and-hyphen-1b-\") == 0\n assert candidate(sentence = \"valid-word-123\") == 0\n assert candidate(sentence = \"word-with-punctuation,at,end.\") == 0\n assert candidate(sentence = \"multiple---hyphens-in-a-row\") == 0\n assert candidate(sentence = \"word-with-hyphen-\") == 0\n assert candidate(sentence = \"word-with-digit-in-middle-1word\") == 0\n assert candidate(sentence = \"punctuation-inside-word!word\") == 0\n assert candidate(sentence = \"a-b-c d-e-f g-h\") == 1\n assert candidate(sentence = \"word-with-punctuation-and-digit1!\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-punctuation-after-hyphen-!\") == 0\n assert candidate(sentence = \"-word-with-leading-hyphen\") == 0\n assert candidate(sentence = \"word-with-digit-and-hyphen-b--1\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@?!#abc\") == 1\n assert candidate(sentence = \"word-with-punctuation! word-without\") == 1\n assert candidate(sentence = \"word. word- word!\") == 2\n assert candidate(sentence = \"hyphenated-word- is valid\") == 2\n assert candidate(sentence = \"no-spaces\") == 1\n assert candidate(sentence = \"word-with-digit-and-hyphen-1-word\") == 0\n assert candidate(sentence = \"word! word- word. word?\") == 3\n assert candidate(sentence = \"hyphen-at-end-\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word!\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@!\") == 1\n assert candidate(sentence = \"multiple---hyphens\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-exclamation!\") == 0\n assert candidate(sentence = \"valid-word- valid-word!\") == 1\n assert candidate(sentence = \"word word, word! word.\") == 4\n assert candidate(sentence = \"word-with-digit-and-hyphen-b--\") == 0\n assert candidate(sentence = \"valid-word- word-with-hyphen\") == 0\n assert candidate(sentence = \"word-with-digit1-and-punctuation!\") == 0\n assert candidate(sentence = \"punctuation-in-middle-of-word!word\") == 0\n assert candidate(sentence = \"word!word\") == 0\n assert candidate(sentence = \"singleletter singleletter! singleletter.\") == 3\n assert candidate(sentence = \"word-with-digit-at-end1!\") == 0\n assert candidate(sentence = \"word-with-digit-and-hyphen-1--b\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#\") == 1\n assert candidate(sentence = \"word-with-punctuation-and-hyphen-word-123\") == 0\n assert candidate(sentence = \"multiple--dashes are invalid\") == 2\n assert candidate(sentence = \"word-with-punctuation.at.end,invalid\") == 0\n assert candidate(sentence = \"word-with-digit1-and-punctuation.\") == 0\n assert candidate(sentence = \"valid-word-with-punctuation-at-end,\") == 0\n assert candidate(sentence = \"single-hyphenated-word a-b\") == 1\n assert candidate(sentence = \"123 word- word! word?\") == 2\n assert candidate(sentence = \"a.b!\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-punctuation, word-with-hyphen-and-punctuation.\") == 0\n assert candidate(sentence = \"valid-word- valid-word- valid-word\") == 1\n assert candidate(sentence = \"punctuation-only! and !only-punctuation\") == 2\n assert candidate(sentence = \"hello-world- is not valid\") == 3\n assert candidate(sentence = \"word-with-valid-hyphen word-with--invalid-hyphen\") == 0\n assert candidate(sentence = \"valid-word valid-word- valid-word\") == 2\n assert candidate(sentence = \"word-with-digit-and-hyphen-and-punctuation-1-word!\") == 0\n assert candidate(sentence = \"invalid-1word and valid-word\") == 2\n assert candidate(sentence = \"word-with-punctuation,at,end!\") == 0\n assert candidate(sentence = \"word- word\") == 1\n assert candidate(sentence = \"word-with-punctuations!word-with-punctuations!word-with-punctuations.\") == 0\n assert candidate(sentence = \"valid-ending-punctuation.\") == 0\n assert candidate(sentence = \"word-with-punctuation,word\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@?!\") == 1\n assert candidate(sentence = \"word..\") == 0\n assert candidate(sentence = \"word-with-multiple-hyphens-and-punctuation-,\") == 0\n assert candidate(sentence = \"multiple-spaces between words\") == 3\n assert candidate(sentence = \"word-with-hyphen-123\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word-\") == 1\n assert candidate(sentence = \"word-with-punctuations!word-with-punctuations!word-with-punctuations!word-with-punctuations!word-with-punctuations.\") == 0\n assert candidate(sentence = \"valid!word\") == 0\n assert candidate(sentence = \"word- word- valid\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-123\") == 1\n assert candidate(sentence = \"a--b\") == 0\n assert candidate(sentence = \"word-hyphenated-word word- word. word?\") == 2\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!\") == 1\n assert candidate(sentence = \"word-with-digit-and-hyphen-b1\") == 0\n assert candidate(sentence = \"word- word! word@\") == 2\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@?!#abc-def,word\") == 1\n assert candidate(sentence = \"word-with-hyphen- valid-word\") == 1\n assert candidate(sentence = \"word-with-digit-and-punctuation1-,\") == 0\n assert candidate(sentence = \"validwordwithmultiplepunctuations,,,\") == 0\n assert candidate(sentence = \"valid-word-with-hyphen-and-comma, valid.\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@?!#\") == 1\n assert candidate(sentence = \"word,word,word\") == 0\n assert candidate(sentence = \"valid-word-with-punctuation-at-end!\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123!\") == 1\n assert candidate(sentence = \"word,with,commas and.punctuations\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word@!\") == 2\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123?\") == 1\n assert candidate(sentence = \"valid-word, valid-word. valid-word! valid-word\") == 4\n assert candidate(sentence = \"word-with-hyphen-and-punctuation,\") == 0\n assert candidate(sentence = \"word-with-space-in-word\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-punctuation word-with-hyphen-and-punctuation-\") == 0\n assert candidate(sentence = \"multiple---hyphens-in-word\") == 0\n assert candidate(sentence = \"word,word\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word?\") == 2\n assert candidate(sentence = \"123 456 789\") == 0\n assert candidate(sentence = \"punctuation!in!the!middle\") == 0\n assert candidate(sentence = \"multiple-punctuation,,\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-digit-1\") == 0\n assert candidate(sentence = \"word-with-digit123\") == 0\n assert candidate(sentence = \"word-with-digit123 and another-word!\") == 2\n assert candidate(sentence = \"a!b.c\") == 0\n assert candidate(sentence = \"multiple-punctuation!!\") == 0\n assert candidate(sentence = \"word-with123-hyphen\") == 0\n assert candidate(sentence = \"only!only only.only only-\") == 0\n assert candidate(sentence = \"word1 word2- word3- word4\") == 0\n assert candidate(sentence = \"word-with-hyphen- word\") == 1\n assert candidate(sentence = \"valid-word\") == 1\n assert candidate(sentence = \"-word\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word\") == 1\n assert candidate(sentence = \"word-with-1digit\") == 0\n assert candidate(sentence = \"word-with-punctuations,word-with-punctuations,word-with-punctuations,word-with-punctuations,word-with-punctuations!\") == 0\n assert candidate(sentence = \"valid-word, and invalid-word1\") == 2\n assert candidate(sentence = \"word-with-punctuation-in-middle.a\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word@?\") == 2\n assert candidate(sentence = \"word-with-hyphen-and-period.\") == 0\n assert candidate(sentence = \"word-with-multiple-hyphens-and-punctuation-,and valid-word!\") == 1\n assert candidate(sentence = \"word-with-punctuations,word-with-punctuations.\") == 0\n assert candidate(sentence = \"valid-word followed-by-number123\") == 1\n assert candidate(sentence = \"single-punctuation!\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@123\") == 1\n assert candidate(sentence = \"word word- word! word-\") == 2\n assert candidate(sentence = \"word-! word- word-\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc123\") == 1\n assert candidate(sentence = \"word-with-digit-and-hyphen-and-punctuation-word-1.\") == 0\n assert candidate(sentence = \"word-with-hyphen word-with-hyphen- word-with-hyphen\") == 0\n assert candidate(sentence = \"valid-word! another-valid-word?\") == 1\n assert candidate(sentence = \"word-with-digit-and-punctuation1,\") == 0\n assert candidate(sentence = \"word-with-punctuation.at-end\") == 0\n assert candidate(sentence = \"valid-word, invalid-word123\") == 1\n assert candidate(sentence = \"!valid valid. valid-\") == 1\n assert candidate(sentence = \"valid-word.\") == 1\n assert candidate(sentence = \"word-with-digit-and-punctuation1-.\") == 0\n assert candidate(sentence = \"a a-b a-b-c a-b-c-d\") == 2\n assert candidate(sentence = \"word-with-trailing-punctuation,\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-punctuation-after-hyphen-.\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@123\") == 1\n assert candidate(sentence = \"multiple spaces\") == 2\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word?\") == 1\n assert candidate(sentence = \"multiple-punctuation..\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@?!#abc-123\") == 1\n assert candidate(sentence = \"word! word- word. word-\") == 2\n assert candidate(sentence = \"valid-word followed-by-digits123\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc\") == 1\n assert candidate(sentence = \"word-with-digit-and-hyphen--b-1\") == 0\n assert candidate(sentence = \"hello-world- is-not-valid\") == 0\n assert candidate(sentence = \"word-with-punctuations!word-with-punctuations!\") == 0\n assert candidate(sentence = \"-a\") == 0\n assert candidate(sentence = \"nohyphens here!\") == 2\n assert candidate(sentence = \"word-with-punctuation-at-start!word\") == 0\n assert candidate(sentence = \"leading!and-trailing!punctuation!\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def!\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc\") == 1\n assert candidate(sentence = \"no-dashes-here but-here-are-too-many-dashes\") == 0\n assert candidate(sentence = \"word-hyphen- word\") == 1\n assert candidate(sentence = \"valid-word-with-hyphen-and-punctuation.\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-punctuation!\") == 0\n assert candidate(sentence = \"valid-word, valid-word. valid-word!\") == 3\n assert candidate(sentence = \"word-with-punctuation.at.end.\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word-\") == 1\n assert candidate(sentence = \"a!b!c\") == 0\n assert candidate(sentence = \"word-with-number1234 and valid-word\") == 2\n assert candidate(sentence = \"word,word!\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word@\") == 2\n assert candidate(sentence = \"word1 word2 word3 word4\") == 0\n assert candidate(sentence = \"word-with-punctuation,at,end!invalid\") == 0\n assert candidate(sentence = \"complex-word-with-punctuation,\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@?!#abc-def!\") == 1\n assert candidate(sentence = \"word-with-punctuations!word-with-punctuations!word-with-punctuations!word-with-punctuations.\") == 0\n assert candidate(sentence = \"single-letter-word a\") == 1\n assert candidate(sentence = \"word-with-trailing-hyphen-\") == 0\n assert candidate(sentence = \"punctuation.multiple\") == 0\n assert candidate(sentence = \"multi-hyphen-word-123\") == 0\n assert candidate(sentence = \"word-with-hyphen word-with-hyphen-\") == 0\n assert candidate(sentence = \"valid-word a valid-word- valid-word\") == 3\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc123\") == 1\n assert candidate(sentence = \"word-with-digit-and-punctuation-1.\") == 0\n assert candidate(sentence = \"word-with-digit-and-hyphen-b-1--\") == 0\n assert candidate(sentence = \"word!word!\") == 0\n assert candidate(sentence = \"!word .word ,word\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-punctuation- word\") == 1\n assert candidate(sentence = \"invalid-punctuation, invalid-punctuation! invalid-punctuation?\") == 3\n assert candidate(sentence = \"a.b.c.d\") == 0\n assert candidate(sentence = \"multi-hyphenated-word-should-fail\") == 0\n assert candidate(sentence = \"valid-word!\") == 1\n assert candidate(sentence = \"punctuation!in!middle\") == 0\n assert candidate(sentence = \"trailing-hyphen- invalid-hyphen-\") == 0\n assert candidate(sentence = \"single-letter a\") == 2\n assert candidate(sentence = \"word-with-digit-and-hyphen--b1\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-period-and-comma,./\") == 0\n assert candidate(sentence = \"word-with-punctuations! word\") == 1\n assert candidate(sentence = \"word-with-2-hyphens-a-b-c\") == 0\n assert candidate(sentence = \"word-with--double-hyphen\") == 0\n assert candidate(sentence = \"a.b-c!d.e\") == 0\n assert candidate(sentence = \"this-is-valid-1\") == 0\n assert candidate(sentence = \"valid-word! valid-word!\") == 2\n assert candidate(sentence = \"word-with-hyphen-and-digit1-\") == 0\n assert candidate(sentence = \"a!b-c.d.e\") == 0\n assert candidate(sentence = \"a.b-c.d.e\") == 0\n assert candidate(sentence = \"word-with-digit-and-punctuation1-!\") == 0\n assert candidate(sentence = \"1word 12word word3\") == 0\n assert candidate(sentence = \"word-with-punctuation,word-with-punctuation, word-with-punctuation!word-with-punctuation.\") == 0\n assert candidate(sentence = \"a!b.c-d.e\") == 0\n assert candidate(sentence = \"valid-word-1 valid-word-2\") == 0\n assert candidate(sentence = \"word!word another-word,\") == 1\n assert candidate(sentence = \"a.b-c.d!e\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def\") == 1\n assert candidate(sentence = \"a-b.c.d\") == 0\n assert candidate(sentence = \"mid,dash\") == 0\n assert candidate(sentence = \"valid.word\") == 0\n assert candidate(sentence = \"valid-word valid-word-\") == 1\n assert candidate(sentence = \"word-with-punctuations,word\") == 0\n assert candidate(sentence = \"word-with-digit-and-punctuation1.\") == 0\n assert candidate(sentence = \"word-with-digit-and-hyphen-word-1\") == 0\n assert candidate(sentence = \"word-!\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-comma,\") == 0\n assert candidate(sentence = \"-hyphen-at-start\") == 0\n assert candidate(sentence = \"single-punctuation-mark.\") == 0\n assert candidate(sentence = \"!invalid-start-word invalid-end-word!\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def!\") == 1\n assert candidate(sentence = \"a-b-c-d\") == 0\n assert candidate(sentence = \"word-with-punctuations,word-with-punctuations,word-with-punctuations!\") == 0\n assert candidate(sentence = \"word-with-digit-at-end1.\") == 0\n assert candidate(sentence = \"valid-word-!\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@?!#abc-def\") == 1\n assert candidate(sentence = \"multiple-hyphens-in--one-word\") == 0\n assert candidate(sentence = \"a valid-word- valid-word valid-word-\") == 2\n assert candidate(sentence = \"double--hyphen invalid\") == 1\n assert candidate(sentence = \"validwordwithmultiplepunctuations...\") == 0\n assert candidate(sentence = \"!a-b\") == 0\n assert candidate(sentence = \"word! word- word. word@\") == 3\n assert candidate(sentence = \"valid-word- valid-word valid-word\") == 2\n assert candidate(sentence = \"leading-hyphen invalid-hyphen\") == 2\n assert candidate(sentence = \"a.b.c!\") == 0\n assert candidate(sentence = \"invalid-word- punctuation-here.\") == 1\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def\") == 1\n assert candidate(sentence = \"valid-word-here, and-this.is!ok\") == 0\n assert candidate(sentence = \"valid-word, valid-word.\") == 2\n assert candidate(sentence = \"valid-word valid-word valid-word-\") == 2\n assert candidate(sentence = \"word-h word-hyphenated word-!\") == 2\n assert candidate(sentence = \"another!valid!word\") == 0\n assert candidate(sentence = \"word-with.punctuation\") == 0\n assert candidate(sentence = \"valid-word- valid-hyphenated-word\") == 0\n assert candidate(sentence = \"valid-word word-with-hyphen-\") == 1\n assert candidate(sentence = \"word-with-hyphen-and-punctuation! word-with-hyphen-and-punctuation!\") == 0\n assert candidate(sentence = \"single-letter a valid-word\") == 3\n assert candidate(sentence = \"valid-word-with-hyphen-and-punctuation,\") == 0\n assert candidate(sentence = \"word-with-hyphen-and-punctuation.\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word!\") == 1\n assert candidate(sentence = \"end! punctuation\") == 2\n assert candidate(sentence = \"word-with-digit-at-end1\") == 0\n assert candidate(sentence = \"hyphenated-word-\") == 0\n assert candidate(sentence = \"valid-word,\") == 1\n assert candidate(sentence = \"-word-with-hyphen\") == 0\n assert candidate(sentence = \"only-allowed-here\") == 0\n assert candidate(sentence = \"word-with-digit-in-hyphen-1-word\") == 0\n assert candidate(sentence = \"mixed-case Words Are Invalid\") == 4\n assert candidate(sentence = \"-leading-hyphen\") == 0\n assert candidate(sentence = \"word-with-punctuation!at!the!end\") == 0\n assert candidate(sentence = \"validwordwithmultiplepunctuations!!!\") == 0\n assert candidate(sentence = \"valid-word word-with-hyphen\") == 1\n assert candidate(sentence = \"word-with-digit1-and-punctuation,\") == 0\n assert candidate(sentence = \"word-with-hyphen123\") == 0\n assert candidate(sentence = \"word-with-punctuation!at!end\") == 0\n assert candidate(sentence = \"word-hyphenated word- word. word?\") == 3\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123\") == 1\n assert candidate(sentence = \"word-with-digit-at-end1,\") == 0\n assert candidate(sentence = \"word word- word! word?\") == 3\n assert candidate(sentence = \"valid-word,another-valid-word\") == 0\n assert candidate(sentence = \"trailing-punctuations,, are! invalid\") == 2\n assert candidate(sentence = \"word-with-punctuation!and-more\") == 0\n assert candidate(sentence = \"123abc and abc123 are invalid\") == 3\n assert candidate(sentence = \"word-with-digit-and-hyphen--b\") == 0\n assert candidate(sentence = \"word-with-digit-and-hyphen-b-1\") == 0\n assert candidate(sentence = \"valid-word! valid-word, valid-word.\") == 3\n assert candidate(sentence = \"no-hyphens allowed\") == 2\n assert candidate(sentence = \"word-with-digit-and-punctuation-1!\") == 0\n assert candidate(sentence = \"multiple spaces between words\") == 4\n assert candidate(sentence = \"triple-hyphen---word\") == 0\n assert candidate(sentence = \"punctuation,,comma and space\") == 2\n assert candidate(sentence = \"valid-word-2!\") == 0\n assert candidate(sentence = \"word-with-digit1-and-hyphen-b\") == 0\n assert candidate(sentence = \"valid-hyphen-word word- word\") == 1\n assert candidate(sentence = \"word- word- word- word.\") == 1\n assert candidate(sentence = \"word!!\") == 0\n assert candidate(sentence = \"trailing-hyphen-\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@\") == 1\n assert candidate(sentence = \"word- word- word- word\") == 1\n assert candidate(sentence = \"word-!!\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-123\") == 1\n assert candidate(sentence = \"word-with-digit-and-punctuation1!\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#\") == 1\n assert candidate(sentence = \"word-with-multiple-punctuations!!!\") == 0\n assert candidate(sentence = \"word-with-punctuations!.\") == 0\n assert candidate(sentence = \"word1- word2- word3- word4-\") == 0\n assert candidate(sentence = \"multiple--hyphens-are!invalid\") == 0\n assert candidate(sentence = \"word-hyphenated-word- word- word. word-123@?!#abc-def,word@?!#abc-def,word@?!#abc123\") == 1\n assert candidate(sentence = \"valid-word- valid-word- valid-word-\") == 0\n assert candidate(sentence = \"valid-word-with-punctuation-at-end.\") == 0\n assert candidate(sentence = \"word-with-digit-and-hyphen1-b\") == 0\n assert candidate(sentence = \"multi-hyphen-usage-is-not-allowed\") == 0\n assert candidate(sentence = \"word-with! punctuation\") == 2\n assert candidate(sentence = \"valid-word valid-word valid-word\") == 3\n assert candidate(sentence = \"valid-word-1 valid-word-2 valid-word-3\") == 0\n assert candidate(sentence = \"word-with-punctuations,word-with-punctuations,word-with-punctuations,word-with-punctuations!\") == 0\n assert candidate(sentence = \"word-with-digit-in-hyphen-word-1\") == 0\n assert candidate(sentence = \"word-\") == 0\n assert candidate(sentence = \"word-with-digit-and-hyphen-1-b\") == 0\n assert candidate(sentence = \"valid,word valid.word valid-word!\") == 1\n"}, "metadata": {"canonical_parameter_names": ["sentence"], "leetcode_dataset_entry_point": "Solution().countValidWords", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countValidWords(string sentence) {", "container": "Solution", "callable": "countValidWords", "parameters": [{"name": "sentence", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2048, "task_id": "next-greater-numerically-balanced-number", "difficulty": "Medium", "problem_description": "An integer x is numerically balanced if for every digit d in the number x, there are exactly d occurrences of that digit in x.\nGiven an integer n, return the smallest numerically balanced number strictly greater than n.\n \nExample 1:\n\nInput: n = 1\nOutput: 22\nExplanation: \n22 is numerically balanced since:\n- The digit 2 occurs 2 times. \nIt is also the smallest numerically balanced number strictly greater than 1.\n\nExample 2:\n\nInput: n = 1000\nOutput: 1333\nExplanation: \n1333 is numerically balanced since:\n- The digit 1 occurs 1 time.\n- The digit 3 occurs 3 times. \nIt is also the smallest numerically balanced number strictly greater than 1000.\nNote that 1022 cannot be the answer because 0 appeared more than 0 times.\n\nExample 3:\n\nInput: n = 3000\nOutput: 3133\nExplanation: \n3133 is numerically balanced since:\n- The digit 1 occurs 1 time.\n- The digit 3 occurs 3 times.\nIt is also the smallest numerically balanced number strictly greater than 3000.\n\n \nConstraints:\n\n0 <= n <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 0) == 1\n assert candidate(n = 122333) == 123233\n assert candidate(n = 3000) == 3133\n assert candidate(n = 1222) == 1333\n assert candidate(n = 55555) == 122333\n assert candidate(n = 1234) == 1333\n assert candidate(n = 112233) == 122333\n assert candidate(n = 122133) == 122333\n assert candidate(n = 1234567) == 1242444\n assert candidate(n = 999999) == 1224444\n assert candidate(n = 123456) == 132233\n assert candidate(n = 1) == 22\n assert candidate(n = 1000) == 1333\n assert candidate(n = 1224444) == 1242444\n assert candidate(n = 987654) == 1224444\n assert candidate(n = 122) == 212\n assert candidate(n = 122333444) == 122666666\n assert candidate(n = 2233445566) == 2233535555\n assert candidate(n = 122444) == 123233\n assert candidate(n = 3333333) == 3334444\n assert candidate(n = 666666) == 1224444\n assert candidate(n = 11222233) == 12255555\n assert candidate(n = 444444) == 515555\n assert candidate(n = 1223334444) == 1223343444\n assert candidate(n = 2222222) == 2241444\n assert candidate(n = 44445555) == 51225555\n assert candidate(n = 6665554443332211) == 6665554444155666\n assert candidate(n = 1233333) == 1242444\n assert candidate(n = 122111333) == 122666666\n assert candidate(n = 22333444) == 22515555\n assert candidate(n = 123321) == 123323\n assert candidate(n = 98765) == 122333\n assert candidate(n = 665544332211) == 665551556666\n assert candidate(n = 400000) == 422444\n assert candidate(n = 123456789) == 126266666\n assert candidate(n = 1223334) == 1224444\n assert candidate(n = 5555555) == 6166666\n assert candidate(n = 223334444555) == 223336166666\n assert candidate(n = 111) == 122\n assert candidate(n = 7777777) == 12255555\n assert candidate(n = 1112233) == 1224444\n assert candidate(n = 122333444555555) == 122333445445555\n assert candidate(n = 2233444) == 2241444\n assert candidate(n = 1222333) == 1224444\n assert candidate(n = 2121212121) == 2123334444\n assert candidate(n = 122444455555) == 122444545555\n assert candidate(n = 12233344) == 12255555\n assert candidate(n = 666666555444333222111) == 666666555444333224155\n assert candidate(n = 1000000) == 1224444\n assert candidate(n = 22222222) == 22515555\n assert candidate(n = 122333444555666) == 122333445445555\n assert candidate(n = 1221221) == 1224444\n assert candidate(n = 5555544332211) == 5555544333144\n assert candidate(n = 1233322) == 1242444\n assert candidate(n = 4444) == 14444\n assert candidate(n = 122334444) == 122666666\n assert candidate(n = 1222233333) == 1223334444\n assert candidate(n = 1333331) == 1422444\n"}, "metadata": {"canonical_parameter_names": ["n"], "leetcode_dataset_entry_point": "Solution().nextBeautifulNumber", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int nextBeautifulNumber(int n) {", "container": "Solution", "callable": "nextBeautifulNumber", "parameters": [{"name": "n", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2049, "task_id": "count-nodes-with-the-highest-score", "difficulty": "Medium", "problem_description": "There is a binary tree rooted at 0 consisting of n nodes. The nodes are labeled from 0 to n - 1. You are given a 0-indexed integer array parents representing the tree, where parents[i] is the parent of node i. Since node 0 is the root, parents[0] == -1.\nEach node has a score. To find the score of a node, consider if the node and the edges connected to it were removed. The tree would become one or more non-empty subtrees. The size of a subtree is the number of the nodes in it. The score of the node is the product of the sizes of all those subtrees.\nReturn the number of nodes that have the highest score.\n \nExample 1:\n\n\nInput: parents = [-1,2,0,2,0]\nOutput: 3\nExplanation:\n- The score of node 0 is: 3 * 1 = 3\n- The score of node 1 is: 4 = 4\n- The score of node 2 is: 1 * 1 * 2 = 2\n- The score of node 3 is: 4 = 4\n- The score of node 4 is: 4 = 4\nThe highest score is 4, and three nodes (node 1, node 3, and node 4) have the highest score.\n\nExample 2:\n\n\nInput: parents = [-1,2,0]\nOutput: 2\nExplanation:\n- The score of node 0 is: 2 = 2\n- The score of node 1 is: 2 = 2\n- The score of node 2 is: 1 * 1 = 1\nThe highest score is 2, and two nodes (node 0 and node 1) have the highest score.\n\n \nConstraints:\n\nn == parents.length\n2 <= n <= 105\nparents[0] == -1\n0 <= parents[i] <= n - 1 for i != 0\nparents represents a valid binary tree.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(parents = [-1, 0, 0, 2, 2, 3, 3]) == 5\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2]) == 1\n assert candidate(parents = [-1, 2, 0, 2, 0]) == 3\n assert candidate(parents = [-1, 0, 1, 2, 3]) == 3\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == 2\n assert candidate(parents = [-1, 0, 1, 2, 2]) == 3\n assert candidate(parents = [-1, 0, 0, 1, 1]) == 3\n assert candidate(parents = [-1, 1, 1, 2, 2, 3, 3]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 3, 3]) == 1\n assert candidate(parents = [-1, 0, 0, 2, 2]) == 3\n assert candidate(parents = [-1, 0, 1, 1, 3, 3]) == 4\n assert candidate(parents = [-1, 2, 0]) == 2\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 62, 62, 63, 63, 64, 64, 65, 65, 66, 66, 67, 67, 68, 68, 69, 69, 70, 70, 71, 71, 72, 72, 73, 73, 74, 74, 75, 75, 76, 76, 77, 77, 78, 78, 79, 79, 80, 80, 81, 81, 82, 82, 83, 83, 84, 84, 85, 85, 86, 86, 87, 87, 88, 88, 89, 89, 90, 90]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == 2\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 2, 3, 3, 4, 4]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8, 9, 9, 9]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 1\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20, 20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 24]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 2\n assert candidate(parents = [-1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]) == 2\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30]) == 2\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19]) == 1\n assert candidate(parents = [-1, 0, 0, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 1\n assert candidate(parents = [-1, 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 28, 28, 30, 30, 32, 32, 34, 34, 36, 36]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 1\n assert candidate(parents = [-1, 0, 0, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 8, 8, 8]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 1\n assert candidate(parents = [-1, 0, 0, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200]) == 2\n assert candidate(parents = [-1, 0, 1, 0, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12]) == 2\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47, 48, 48, 49, 49, 50, 50, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55, 56, 56, 57, 57, 58, 58, 59, 59, 60, 60]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 2, 3, 3, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 1\n assert candidate(parents = [-1, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4]) == 2\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6]) == 1\n assert candidate(parents = [-1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14]) == 2\n assert candidate(parents = [-1, 0, 0, 0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 1\n assert candidate(parents = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 2\n assert candidate(parents = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45]) == 1\n assert candidate(parents = [-1, 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 16, 16, 18, 18, 20, 20, 22, 22, 24, 24, 26, 26, 28, 28, 30, 30, 32, 32]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5]) == 1\n assert candidate(parents = [-1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15]) == 1\n"}, "metadata": {"canonical_parameter_names": ["parents"], "leetcode_dataset_entry_point": "Solution().countHighestScoreNodes", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countHighestScoreNodes(vector& parents) {", "container": "Solution", "callable": "countHighestScoreNodes", "parameters": [{"name": "parents", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2050, "task_id": "parallel-courses-iii", "difficulty": "Hard", "problem_description": "You are given an integer n, which indicates that there are n courses labeled from 1 to n. You are also given a 2D integer array relations where relations[j] = [prevCoursej, nextCoursej] denotes that course prevCoursej has to be completed before course nextCoursej (prerequisite relationship). Furthermore, you are given a 0-indexed integer array time where time[i] denotes how many months it takes to complete the (i+1)th course.\nYou must find the minimum number of months needed to complete all the courses following these rules:\n\nYou may start taking a course at any time if the prerequisites are met.\nAny number of courses can be taken at the same time.\n\nReturn the minimum number of months needed to complete all the courses.\nNote: The test cases are generated such that it is possible to complete every course (i.e., the graph is a directed acyclic graph).\n \nExample 1:\n\n\nInput: n = 3, relations = [[1,3],[2,3]], time = [3,2,5]\nOutput: 8\nExplanation: The figure above represents the given graph and the time required to complete each course. \nWe start course 1 and course 2 simultaneously at month 0.\nCourse 1 takes 3 months and course 2 takes 2 months to complete respectively.\nThus, the earliest time we can start course 3 is at month 3, and the total time required is 3 + 5 = 8 months.\n\nExample 2:\n\n\nInput: n = 5, relations = [[1,5],[2,5],[3,5],[3,4],[4,5]], time = [1,2,3,4,5]\nOutput: 12\nExplanation: The figure above represents the given graph and the time required to complete each course.\nYou can start courses 1, 2, and 3 at month 0.\nYou can complete them after 1, 2, and 3 months respectively.\nCourse 4 can be taken only after course 3 is completed, i.e., after 3 months. It is completed after 3 + 4 = 7 months.\nCourse 5 can be taken only after courses 1, 2, 3, and 4 have been completed, i.e., after max(1,2,3,7) = 7 months.\nThus, the minimum time needed to complete all the courses is 7 + 5 = 12 months.\n\n \nConstraints:\n\n1 <= n <= 5 * 104\n0 <= relations.length <= min(n * (n - 1) / 2, 5 * 104)\nrelations[j].length == 2\n1 <= prevCoursej, nextCoursej <= n\nprevCoursej != nextCoursej\nAll the pairs [prevCoursej, nextCoursej] are unique.\ntime.length == n\n1 <= time[i] <= 104\nThe given graph is a directed acyclic graph.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,relations = [[1, 2], [1, 3], [2, 4], [3, 4]],time = [4, 2, 3, 1]) == 8\n assert candidate(n = 3,relations = [[1, 3], [2, 3]],time = [3, 2, 5]) == 8\n assert candidate(n = 6,relations = [[1, 2], [2, 3], [3, 4], [1, 5], [5, 6], [4, 6]],time = [1, 2, 3, 4, 5, 6]) == 16\n assert candidate(n = 1,relations = [],time = [5]) == 5\n assert candidate(n = 4,relations = [[1, 2], [2, 3], [3, 4]],time = [1, 2, 3, 4]) == 10\n assert candidate(n = 5,relations = [[1, 5], [2, 5], [3, 5], [3, 4], [4, 5]],time = [1, 2, 3, 4, 5]) == 12\n assert candidate(n = 9,relations = [[1, 4], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],time = [5, 5, 5, 5, 5, 5, 5, 5, 5]) == 35\n assert candidate(n = 12,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10], [10, 11], [10, 12]],time = [2, 3, 4, 1, 5, 6, 7, 8, 9, 3, 12, 4]) == 37\n assert candidate(n = 8,relations = [[1, 3], [1, 4], [2, 5], [2, 6], [3, 7], [4, 7], [5, 8], [6, 8]],time = [2, 3, 2, 3, 2, 3, 4, 5]) == 11\n assert candidate(n = 8,relations = [[1, 2], [2, 4], [1, 3], [3, 5], [3, 6], [4, 6], [5, 7], [6, 7], [7, 8]],time = [1, 3, 2, 4, 5, 6, 1, 8]) == 23\n assert candidate(n = 20,relations = [[1, 11], [2, 11], [3, 11], [4, 11], [5, 11], [6, 11], [7, 11], [8, 11], [9, 11], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],time = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 20\n assert candidate(n = 9,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9]],time = [5, 10, 15, 20, 25, 30, 35, 40, 45]) == 100\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 5], [5, 6], [5, 7], [4, 8], [7, 8], [8, 9], [9, 10]],time = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 50\n assert candidate(n = 12,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10]],time = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) == 126\n assert candidate(n = 11,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 66\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [4, 9], [5, 10], [5, 11], [6, 12], [6, 13], [7, 14], [7, 15], [8, 13], [9, 14], [10, 15], [11, 15]],time = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 5\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == 62\n assert candidate(n = 12,relations = [[1, 6], [2, 6], [3, 6], [4, 7], [5, 7], [6, 8], [6, 9], [7, 10], [8, 11], [9, 11], [10, 12], [11, 12]],time = [1, 1, 1, 1, 1, 2, 2, 3, 4, 5, 6, 7]) == 20\n assert candidate(n = 25,relations = [[1, 6], [2, 6], [3, 7], [4, 7], [5, 7], [6, 8], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25]],time = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5]) == 64\n assert candidate(n = 15,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 15]],time = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == 95\n assert candidate(n = 8,relations = [[1, 3], [2, 3], [3, 4], [4, 5], [4, 6], [5, 7], [6, 7], [7, 8]],time = [10, 20, 30, 40, 50, 60, 70, 80]) == 300\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2]) == 17\n assert candidate(n = 15,relations = [[1, 6], [2, 6], [3, 7], [4, 7], [5, 7], [6, 8], [7, 8], [8, 9], [8, 10], [9, 11], [10, 11], [11, 12], [11, 13], [12, 14], [13, 14], [14, 15]],time = [4, 5, 2, 6, 3, 1, 8, 9, 2, 7, 5, 6, 4, 3, 10]) == 54\n assert candidate(n = 7,relations = [[1, 3], [1, 4], [2, 3], [2, 4], [3, 5], [4, 5], [5, 7], [6, 7]],time = [2, 3, 4, 5, 1, 6, 7]) == 16\n assert candidate(n = 11,relations = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],time = [1, 2, 3, 4, 5, 1, 1, 1, 1, 1, 1]) == 15\n assert candidate(n = 6,relations = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 6]],time = [1, 2, 3, 4, 5, 6]) == 15\n assert candidate(n = 12,relations = [[1, 3], [2, 3], [3, 4], [3, 5], [4, 6], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],time = [2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 73\n assert candidate(n = 8,relations = [[1, 3], [2, 3], [3, 4], [3, 5], [4, 6], [5, 6], [6, 7], [6, 8]],time = [5, 3, 10, 2, 8, 4, 1, 6]) == 33\n assert candidate(n = 12,relations = [[1, 5], [2, 5], [3, 5], [1, 6], [2, 6], [3, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12]],time = [2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7]) == 32\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [1, 4], [1, 5], [2, 6], [3, 6], [4, 6], [5, 6], [6, 7], [7, 8], [7, 9], [7, 10], [8, 11], [9, 11], [10, 11], [11, 12], [12, 13], [12, 14], [12, 15]],time = [2, 3, 4, 5, 1, 6, 7, 8, 9, 2, 5, 1, 3, 4, 5]) == 40\n assert candidate(n = 20,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(n = 7,relations = [[1, 2], [1, 4], [2, 3], [2, 5], [4, 6], [5, 6], [6, 7]],time = [5, 4, 3, 2, 1, 10, 15]) == 35\n assert candidate(n = 15,relations = [[1, 6], [2, 6], [3, 6], [4, 6], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],time = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5]) == 40\n assert candidate(n = 30,relations = [[1, 10], [2, 10], [3, 11], [4, 11], [5, 11], [6, 12], [7, 12], [8, 12], [9, 12], [10, 13], [11, 13], [12, 14], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 26], [26, 27], [27, 28], [28, 29], [29, 30]],time = [2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1]) == 62\n assert candidate(n = 12,relations = [[1, 3], [2, 3], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9], [6, 10], [7, 10], [8, 11], [9, 11], [10, 12], [11, 12]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) == 42\n assert candidate(n = 8,relations = [[1, 3], [2, 3], [3, 4], [1, 5], [2, 5], [5, 6], [6, 7], [7, 8]],time = [2, 3, 1, 2, 4, 3, 2, 1]) == 13\n assert candidate(n = 12,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [1, 6], [1, 7], [1, 8], [2, 9], [2, 10], [3, 11], [4, 12]],time = [3, 2, 5, 1, 6, 7, 4, 8, 9, 2, 5, 1]) == 53\n assert candidate(n = 7,relations = [[1, 4], [2, 4], [3, 4], [1, 5], [2, 5], [3, 5], [4, 6], [5, 6], [4, 7], [5, 7]],time = [3, 2, 5, 4, 3, 7, 5]) == 16\n assert candidate(n = 9,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [9, 10]],time = [3, 2, 5, 4, 3, 2, 5, 4, 3, 2]) == 18\n assert candidate(n = 9,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [1, 6], [1, 7], [2, 8], [3, 9]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 45\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 47\n assert candidate(n = 15,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [8, 11], [9, 12], [9, 13], [10, 14], [11, 14], [12, 15], [13, 15]],time = [2, 3, 2, 4, 3, 1, 5, 6, 7, 8, 4, 3, 2, 5, 6]) == 28\n assert candidate(n = 20,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19], [10, 20]],time = [2, 3, 4, 5, 1, 6, 7, 8, 9, 2, 5, 1, 3, 4, 5, 6, 7, 8, 9, 10]) == 105\n assert candidate(n = 13,relations = [[1, 3], [2, 3], [3, 4], [3, 5], [4, 6], [5, 6], [6, 7], [6, 8], [7, 9], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13]],time = [4, 3, 5, 2, 6, 7, 8, 9, 3, 4, 10, 1, 2]) == 51\n assert candidate(n = 15,relations = [[1, 10], [1, 11], [2, 10], [3, 11], [4, 12], [5, 12], [6, 13], [7, 13], [8, 14], [9, 14], [10, 15], [11, 15], [12, 15], [13, 15], [14, 15]],time = [5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 1, 1, 1, 1, 1]) == 16\n assert candidate(n = 20,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19], [10, 20]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 210\n assert candidate(n = 15,relations = [[1, 4], [2, 5], [3, 6], [4, 7], [5, 7], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15]],time = [2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1]) == 35\n assert candidate(n = 9,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],time = [4, 3, 2, 1, 4, 3, 2, 1, 4]) == 24\n assert candidate(n = 8,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [4, 6], [5, 7], [6, 7], [7, 8]],time = [5, 4, 3, 2, 1, 1, 2, 3]) == 17\n assert candidate(n = 8,relations = [[1, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8]],time = [10, 20, 30, 40, 50, 60, 70, 80]) == 210\n assert candidate(n = 10,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 55\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],time = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(n = 20,relations = [[1, 5], [2, 6], [3, 7], [4, 8], [1, 9], [2, 10], [3, 11], [4, 12], [5, 13], [6, 14], [7, 15], [8, 16], [9, 17], [10, 18], [11, 19], [12, 20], [13, 15], [14, 16], [15, 17], [16, 18], [17, 19], [18, 20], [19, 20]],time = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 12\n assert candidate(n = 20,relations = [[1, 2], [1, 3], [2, 4], [2, 5], [3, 6], [3, 7], [4, 8], [5, 8], [6, 9], [7, 9], [8, 10], [8, 11], [9, 12], [9, 13], [10, 14], [11, 14], [12, 15], [13, 15], [14, 16], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 138\n assert candidate(n = 7,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [6, 7]],time = [3, 2, 5, 4, 1, 6, 8]) == 27\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [4, 6], [5, 7], [6, 7], [7, 8], [8, 9], [9, 10]],time = [1, 2, 3, 2, 3, 2, 3, 4, 5, 6]) == 27\n assert candidate(n = 6,relations = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],time = [1000, 2000, 3000, 4000, 5000, 6000]) == 21000\n assert candidate(n = 7,relations = [[1, 4], [2, 4], [3, 4], [4, 5], [4, 6], [5, 7], [6, 7]],time = [1, 1, 1, 3, 2, 2, 1]) == 7\n assert candidate(n = 10,relations = [[1, 2], [1, 3], [2, 4], [3, 4], [4, 5], [5, 6], [5, 7], [6, 8], [7, 8], [8, 9], [9, 10]],time = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 47\n"}, "metadata": {"canonical_parameter_names": ["n", "relations", "time"], "leetcode_dataset_entry_point": "Solution().minimumTime", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumTime(int n, vector>& relations, vector& time) {", "container": "Solution", "callable": "minimumTime", "parameters": [{"name": "n", "type": "int"}, {"name": "relations", "type": "vector>&"}, {"name": "time", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2053, "task_id": "kth-distinct-string-in-an-array", "difficulty": "Easy", "problem_description": "A distinct string is a string that is present only once in an array.\nGiven an array of strings arr, and an integer k, return the kth distinct string present in arr. If there are fewer than k distinct strings, return an empty string \"\".\nNote that the strings are considered in the order in which they appear in the array.\n \nExample 1:\n\nInput: arr = [\"d\",\"b\",\"c\",\"b\",\"c\",\"a\"], k = 2\nOutput: \"a\"\nExplanation:\nThe only distinct strings in arr are \"d\" and \"a\".\n\"d\" appears 1st, so it is the 1st distinct string.\n\"a\" appears 2nd, so it is the 2nd distinct string.\nSince k == 2, \"a\" is returned. \n\nExample 2:\n\nInput: arr = [\"aaa\",\"aa\",\"a\"], k = 1\nOutput: \"aaa\"\nExplanation:\nAll strings in arr are distinct, so the 1st string \"aaa\" is returned.\n\nExample 3:\n\nInput: arr = [\"a\",\"b\",\"a\"], k = 3\nOutput: \"\"\nExplanation:\nThe only distinct string is \"b\". Since there are fewer than 3 distinct strings, we return an empty string \"\".\n\n \nConstraints:\n\n1 <= k <= arr.length <= 1000\n1 <= arr[i].length <= 5\narr[i] consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(arr = ['a'],k = 1) == \"a\"\n assert candidate(arr = ['a', 'a', 'b', 'b', 'c', 'c', 'd'],k = 1) == \"d\"\n assert candidate(arr = ['apple', 'banana', 'apple', 'orange', 'banana', 'kiwi'],k = 2) == \"kiwi\"\n assert candidate(arr = ['apple', 'banana', 'apple', 'orange', 'banana', 'grape'],k = 2) == \"grape\"\n assert candidate(arr = ['aaa', 'aa', 'a'],k = 1) == \"aaa\"\n assert candidate(arr = ['a', 'b', 'c', 'd', 'e', 'f'],k = 6) == \"f\"\n assert candidate(arr = ['repeat', 'repeat', 'repeat'],k = 1) == \"\"\n assert candidate(arr = ['apple', 'banana', 'cherry', 'date'],k = 1) == \"apple\"\n assert candidate(arr = ['hello', 'world', 'hello', 'world'],k = 2) == \"\"\n assert candidate(arr = ['x', 'y', 'z', 'x', 'y', 'z'],k = 2) == \"\"\n assert candidate(arr = ['apple', 'apple', 'banana', 'banana', 'cherry'],k = 3) == \"\"\n assert candidate(arr = ['apple', 'banana', 'apple', 'orange'],k = 2) == \"orange\"\n assert candidate(arr = ['repeat', 'repeat', 'repeat', 'repeat'],k = 1) == \"\"\n assert candidate(arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],k = 10) == \"j\"\n assert candidate(arr = ['unique', 'distinct', 'strings', 'unique'],k = 2) == \"strings\"\n assert candidate(arr = ['unique'],k = 1) == \"unique\"\n assert candidate(arr = ['same', 'same', 'same', 'same'],k = 1) == \"\"\n assert candidate(arr = ['apple', 'banana', 'cherry'],k = 1) == \"apple\"\n assert candidate(arr = ['hello', 'world', 'hello', 'python', 'world', 'code'],k = 3) == \"\"\n assert candidate(arr = ['a', 'b', 'a'],k = 3) == \"\"\n assert candidate(arr = ['one', 'two', 'three', 'four', 'five'],k = 5) == \"five\"\n assert candidate(arr = ['a', 'a', 'a', 'a', 'a'],k = 1) == \"\"\n assert candidate(arr = ['test', 'test', 'test'],k = 1) == \"\"\n assert candidate(arr = ['d', 'b', 'c', 'b', 'c', 'a'],k = 2) == \"a\"\n assert candidate(arr = ['hello', 'world', 'hello', 'python', 'world'],k = 1) == \"python\"\n assert candidate(arr = ['single'],k = 2) == \"\"\n assert candidate(arr = ['xyz', 'zyx', 'zyx', 'xyz', 'zyx'],k = 1) == \"\"\n assert candidate(arr = ['abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh', 'abcdefghi', 'abcdefghij'],k = 5) == \"abcdefgh\"\n assert candidate(arr = ['unique', 'strings', 'only', 'here', 'unique', 'strings', 'here', 'unique'],k = 2) == \"\"\n assert candidate(arr = ['longer', 'string', 'values', 'are', 'also', 'allowed', 'in', 'this', 'example'],k = 2) == \"string\"\n assert candidate(arr = ['unique1', 'unique2', 'unique3', 'unique4', 'unique5', 'unique6', 'unique7', 'unique8', 'unique9', 'unique10'],k = 5) == \"unique5\"\n assert candidate(arr = ['same', 'word', 'same', 'word', 'same', 'word', 'same', 'word', 'same'],k = 1) == \"\"\n assert candidate(arr = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],k = 7) == \"seven\"\n assert candidate(arr = ['x', 'y', 'x', 'y', 'x', 'y', 'x', 'y', 'x', 'y', 'x', 'y', 'x', 'y', 'x', 'y', 'x', 'y', 'x', 'y'],k = 1) == \"\"\n assert candidate(arr = ['test', 'testing', 'test', 'testing', 'test', 'testing'],k = 1) == \"\"\n assert candidate(arr = ['abcd', 'efgh', 'ijkl', 'mnop', 'qrst', 'uvwx', 'yzab', 'cdef', 'ghij', 'klmn', 'opqr', 'stuv', 'wxyz'],k = 13) == \"wxyz\"\n assert candidate(arr = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty'],k = 20) == \"twenty\"\n assert candidate(arr = ['short', 'longerstring', 'shorter', 'longeststring', 'short', 'shorter', 'longerstring'],k = 2) == \"\"\n assert candidate(arr = ['abcd', 'abc', 'ab', 'a', 'abcd', 'abc', 'ab', 'a', 'abcd', 'abc', 'ab', 'a'],k = 3) == \"\"\n assert candidate(arr = ['abc', 'def', 'ghi', 'abc', 'jkl', 'ghi', 'mno'],k = 4) == \"\"\n assert candidate(arr = ['same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'unique'],k = 1) == \"unique\"\n assert candidate(arr = ['x', 'y', 'x', 'y', 'x', 'y', 'x', 'y', 'x', 'y', 'unique'],k = 6) == \"\"\n assert candidate(arr = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z'],k = 1) == \"\"\n assert candidate(arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],k = 26) == \"z\"\n assert candidate(arr = ['unique', 'distinct', 'unique', 'distinct', 'unique', 'distinct', 'unique', 'distinct', 'unique', 'distinct'],k = 5) == \"\"\n assert candidate(arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],k = 27) == \"\"\n assert candidate(arr = ['test', 'testcase', 'testing', 'test', 'testcase', 'test', 'test', 'testcase', 'testing', 'testing'],k = 3) == \"\"\n assert candidate(arr = ['xy', 'yx', 'xx', 'yy', 'xz', 'zx', 'yz', 'zy', 'xxyy', 'xyxy', 'yxyx', 'yxyy', 'xyyx', 'xyyy', 'yyxx', 'yyxy', 'yyyx', 'yyyy'],k = 10) == \"xyxy\"\n assert candidate(arr = ['xyz', 'zyx', 'wxy', 'yxw', 'uvw', 'vuw', 'wuv', 'abc', 'cab', 'bac'],k = 2) == \"zyx\"\n assert candidate(arr = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'abc', 'def', 'ghi'],k = 5) == \"vwx\"\n assert candidate(arr = ['same', 'different', 'same', 'different', 'same', 'different', 'same', 'different'],k = 2) == \"\"\n assert candidate(arr = ['a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 'a', 'b', 'c', 'd', 'a', 'b', 'c', 'd'],k = 10) == \"\"\n assert candidate(arr = ['aaaaa', 'aaaab', 'aaaba', 'aabaa', 'abaaa', 'baaaa', 'abcde', 'bcdea', 'cdeab', 'decab', 'efghi', 'fghie', 'ghief', 'hiefg', 'iefgh', 'jklmn', 'klmno', 'lmnop', 'mnopq', 'nopqr', 'opqrs', 'pqrst', 'qrstu', 'rstuv', 'stuvw', 'tuvwx', 'uvwxy', 'vwxyz'],k = 15) == \"iefgh\"\n assert candidate(arr = ['unique', 'string', 'in', 'this', 'array'],k = 5) == \"array\"\n assert candidate(arr = ['loop', 'pool', 'look', 'cool', 'cool', 'lopo', 'loopo'],k = 3) == \"look\"\n assert candidate(arr = ['repeated', 'repeated', 'repeated', 'repeated', 'repeated', 'repeated'],k = 1) == \"\"\n assert candidate(arr = ['abc', 'acb', 'bac', 'bca', 'cab', 'cba', 'abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb', 'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', 'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', 'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba'],k = 25) == \"dabc\"\n assert candidate(arr = ['same', 'word', 'same', 'word', 'same'],k = 2) == \"\"\n assert candidate(arr = ['complex', 'input', 'with', 'various', 'strings', 'complex', 'input', 'with', 'various', 'strings', 'complex', 'input', 'with', 'various', 'strings'],k = 5) == \"\"\n assert candidate(arr = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],k = 9) == \"\"\n assert candidate(arr = ['repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'repeat', 'unique'],k = 21) == \"\"\n assert candidate(arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],k = 15) == \"o\"\n assert candidate(arr = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],k = 15) == \"\"\n assert candidate(arr = ['abcd', 'dcba', 'abcd', 'dcba', 'abcd'],k = 2) == \"\"\n assert candidate(arr = ['unique', 'strings', 'here', 'are', 'distinct', 'elements', 'with', 'no', 'repeats'],k = 10) == \"\"\n assert candidate(arr = ['apple', 'banana', 'apple', 'cherry', 'date', 'banana', 'fig'],k = 4) == \"\"\n assert candidate(arr = ['abcd', 'ab', 'a', 'abcde', 'abcd', 'abc', 'ab', 'a'],k = 3) == \"\"\n assert candidate(arr = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven'],k = 7) == \"seven\"\n assert candidate(arr = ['first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth'],k = 1) == \"first\"\n assert candidate(arr = ['aabb', 'abab', 'bbaa', 'abba', 'baab', 'baba', 'aabb', 'abab'],k = 1) == \"bbaa\"\n assert candidate(arr = ['a', 'a', 'a', 'b', 'b', 'c', 'c', 'c', 'c', 'd', 'd', 'd', 'd', 'd'],k = 4) == \"\"\n assert candidate(arr = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],k = 5) == \"five\"\n assert candidate(arr = ['repeat', 'repeat', 'distinct', 'repeat', 'distinct', 'distinct', 'distinct', 'repeat', 'distinct', 'distinct', 'distinct', 'distinct', 'distinct', 'distinct', 'distinct', 'distinct', 'distinct', 'distinct', 'distinct', 'distinct'],k = 6) == \"\"\n assert candidate(arr = ['same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'same', 'different'],k = 2) == \"\"\n assert candidate(arr = ['abcd', 'abdc', 'acbd', 'acdb', 'adbc', 'adcb', 'bacd', 'badc', 'bcad', 'bcda', 'bdac', 'bdca', 'cabd', 'cadb', 'cbad', 'cbda', 'cdab', 'cdba', 'dabc', 'dacb', 'dbac', 'dbca', 'dcab', 'dcba'],k = 20) == \"dacb\"\n assert candidate(arr = ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a'],k = 10) == \"\"\n assert candidate(arr = ['apple', 'banana', 'apple', 'orange', 'banana', 'grape', 'kiwi', 'grape'],k = 4) == \"\"\n assert candidate(arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],k = 5) == \"e\"\n assert candidate(arr = ['same', 'same', 'same', 'same', 'same', 'unique', 'unique', 'unique'],k = 1) == \"\"\n assert candidate(arr = ['abcd', 'abcde', 'abcdef', 'abcdefg', 'abcdefgh'],k = 3) == \"abcdef\"\n assert candidate(arr = ['aabb', 'abab', 'abba', 'baab', 'baba', 'bbaa', 'aaaa', 'bbbb', 'cccc', 'dddd'],k = 5) == \"baba\"\n assert candidate(arr = ['aaa', 'aab', 'aac', 'aad', 'aae', 'aaf', 'aag', 'aah', 'aai', 'aaj', 'aak'],k = 10) == \"aaj\"\n assert candidate(arr = ['only', 'one', 'distinct', 'string', 'here', 'in', 'this', 'array'],k = 1) == \"only\"\n assert candidate(arr = ['apple', 'banana', 'apple', 'orange', 'banana', 'grape', 'kiwi'],k = 4) == \"\"\n assert candidate(arr = ['apple', 'banana', 'cherry', 'banana', 'date', 'elderberry', 'fig', 'grape', 'fig', 'honeydew'],k = 5) == \"grape\"\n assert candidate(arr = ['repeat', 'repeat', 'repeat', 'distinct', 'distinct', 'distinct', 'kth', 'distinct'],k = 3) == \"\"\n assert candidate(arr = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen'],k = 10) == \"ten\"\n assert candidate(arr = ['a', 'ab', 'abc', 'abcd', 'abcde', 'a', 'ab', 'abc', 'abcd'],k = 3) == \"\"\n assert candidate(arr = ['a', 'b', 'c', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'],k = 10) == \"m\"\n assert candidate(arr = ['repeated', 'repeated', 'repeated', 'repeated', 'repeated', 'repeated', 'repeated'],k = 1) == \"\"\n assert candidate(arr = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z'],k = 1) == \"\"\n assert candidate(arr = ['aaaaa', 'aaaab', 'aaaba', 'aabaa', 'abaaa', 'baaaa', 'abcde', 'bcdea', 'cdeab', 'decab'],k = 8) == \"bcdea\"\n assert candidate(arr = ['test', 'testing', 'tested', 'testable', 'testify', 'testing'],k = 2) == \"tested\"\n assert candidate(arr = ['abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd', 'abcd'],k = 1) == \"\"\n assert candidate(arr = ['test', 'testing', 'tested', 'testing', 'tested', 'test', 'testing'],k = 2) == \"\"\n assert candidate(arr = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz'],k = 5) == \"mno\"\n assert candidate(arr = ['x', 'y', 'x', 'y', 'x', 'y', 'z', 'w', 'z', 'w', 'z', 'w', 'v', 'u', 'v', 'u', 't', 's', 'r', 'q', 'p'],k = 10) == \"\"\n assert candidate(arr = ['repeat', 'distinct', 'repeat', 'distinct', 'repeat', 'distinct', 'repeat', 'distinct', 'repeat', 'distinct'],k = 5) == \"\"\n assert candidate(arr = ['unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique', 'unique'],k = 1) == \"\"\n assert candidate(arr = ['abcd', 'dcba', 'adbc', 'bdac', 'cadb', 'dacb', 'abcd', 'dcba'],k = 5) == \"\"\n assert candidate(arr = ['apple', 'banana', 'cherry', 'apple', 'banana', 'date', 'fig', 'grape', 'fig'],k = 4) == \"\"\n assert candidate(arr = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yza'],k = 10) == \"\"\n assert candidate(arr = ['same', 'same', 'same', 'different', 'different', 'unique'],k = 3) == \"\"\n assert candidate(arr = ['repeated', 'distinct', 'value', 'repeated', 'value', 'distinct', 'unique'],k = 4) == \"\"\n assert candidate(arr = ['same', 'same', 'different', 'different', 'unique'],k = 3) == \"\"\n assert candidate(arr = ['abc', 'def', 'abc', 'def', 'abc', 'def', 'abc', 'def', 'ghi', 'jkl'],k = 3) == \"\"\n assert candidate(arr = ['abcd', 'abcde', 'abcdef', 'abc', 'ab', 'a', '', 'a', 'ab', 'abc'],k = 5) == \"\"\n assert candidate(arr = ['abcd', 'dcba', 'abcd', 'dcba', 'abcd', 'dcba'],k = 3) == \"\"\n assert candidate(arr = ['apple', 'banana', 'cherry', 'apple', 'banana', 'date', 'fig', 'grape'],k = 4) == \"grape\"\n assert candidate(arr = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z'],k = 5) == \"\"\n"}, "metadata": {"canonical_parameter_names": ["arr", "k"], "leetcode_dataset_entry_point": "Solution().kthDistinct", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string kthDistinct(vector& arr, int k) {", "container": "Solution", "callable": "kthDistinct", "parameters": [{"name": "arr", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2054, "task_id": "two-best-non-overlapping-events", "difficulty": "Medium", "problem_description": "You are given a 0-indexed 2D integer array of events where events[i] = [startTimei, endTimei, valuei]. The ith event starts at startTimei and ends at endTimei, and if you attend this event, you will receive a value of valuei. You can choose at most two non-overlapping events to attend such that the sum of their values is maximized.\nReturn this maximum sum.\nNote that the start time and end time is inclusive: that is, you cannot attend two events where one of them starts and the other ends at the same time. More specifically, if you attend an event with end time t, the next event must start at or after t + 1.\n \nExample 1:\n\n\nInput: events = [[1,3,2],[4,5,2],[2,4,3]]\nOutput: 4\nExplanation: Choose the green events, 0 and 1 for a sum of 2 + 2 = 4.\n\nExample 2:\n\n\nInput: events = [[1,3,2],[4,5,2],[1,5,5]]\nOutput: 5\nExplanation: Choose event 2 for a sum of 5.\n\nExample 3:\n\n\nInput: events = [[1,5,3],[1,5,1],[6,6,5]]\nOutput: 8\nExplanation: Choose events 0 and 2 for a sum of 3 + 5 = 8.\n \nConstraints:\n\n2 <= events.length <= 105\nevents[i].length == 3\n1 <= startTimei <= endTimei <= 109\n1 <= valuei <= 106\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(events = [[1, 1000000000, 1000000], [1000000000, 1000000000, 1000000]]) == 1000000\n assert candidate(events = [[1, 10, 1], [2, 3, 2], [4, 5, 3], [6, 7, 4], [8, 9, 5]]) == 9\n assert candidate(events = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]]) == 19\n assert candidate(events = [[10, 20, 15], [20, 30, 10], [1, 10, 5]]) == 15\n assert candidate(events = [[1, 10, 4], [1, 10, 5], [5, 10, 3]]) == 5\n assert candidate(events = [[1, 3, 2], [4, 5, 2], [2, 4, 3]]) == 4\n assert candidate(events = [[1, 3, 2], [4, 5, 2], [1, 5, 5]]) == 5\n assert candidate(events = [[1, 2, 4], [3, 4, 3], [2, 3, 1]]) == 7\n assert candidate(events = [[1, 5, 3], [1, 5, 1], [6, 6, 5]]) == 8\n assert candidate(events = [[1, 3, 5], [2, 5, 6], [4, 6, 7], [5, 7, 8]]) == 13\n assert candidate(events = [[1, 5, 10], [6, 10, 10], [11, 15, 10], [16, 20, 10]]) == 20\n assert candidate(events = [[2, 2, 1], [3, 3, 2], [4, 4, 3], [5, 5, 4], [6, 6, 5]]) == 9\n assert candidate(events = [[1, 10, 10], [2, 3, 5], [4, 5, 7], [6, 7, 9]]) == 16\n assert candidate(events = [[1, 2, 100], [3, 4, 200], [5, 6, 300], [7, 8, 400], [9, 10, 500], [11, 12, 600]]) == 1100\n assert candidate(events = [[1, 5, 1], [1, 4, 2], [2, 5, 3], [2, 4, 4], [3, 6, 5], [3, 5, 6], [4, 7, 7], [4, 6, 8], [5, 8, 9], [5, 7, 10]]) == 14\n assert candidate(events = [[1, 10, 5], [1, 10, 6], [1, 10, 7], [1, 10, 8], [1, 10, 9]]) == 9\n assert candidate(events = [[1, 2, 1], [1, 2, 2], [1, 2, 3], [1, 2, 4], [1, 2, 5], [1, 2, 6], [1, 2, 7], [1, 2, 8], [1, 2, 9], [1, 2, 10], [1, 2, 11], [1, 2, 12], [1, 2, 13], [1, 2, 14], [1, 2, 15]]) == 15\n assert candidate(events = [[1, 3, 1], [2, 3, 2], [3, 3, 3], [4, 5, 4], [5, 5, 5], [6, 7, 6], [7, 7, 7]]) == 12\n assert candidate(events = [[1, 10, 1], [2, 9, 2], [3, 8, 3], [4, 7, 4], [5, 6, 5], [11, 20, 6], [12, 19, 7], [13, 18, 8], [14, 17, 9], [15, 16, 10]]) == 15\n assert candidate(events = [[1, 1000000, 1], [1000001, 2000000, 2], [2000001, 3000000, 3], [3000001, 4000000, 4], [4000001, 5000000, 5], [5000001, 6000000, 6], [6000001, 7000000, 7], [7000001, 8000000, 8], [8000001, 9000000, 9], [9000001, 10000000, 10]]) == 19\n assert candidate(events = [[1, 2, 1], [3, 4, 2], [5, 6, 3], [7, 8, 4], [9, 10, 5], [11, 12, 6], [13, 14, 7]]) == 13\n assert candidate(events = [[1, 5, 5], [6, 10, 10], [11, 15, 15], [16, 20, 20], [21, 25, 25]]) == 45\n assert candidate(events = [[1, 1000000000, 1000000], [2, 1000000000, 2000000], [3, 1000000000, 3000000], [4, 1000000000, 4000000], [5, 1000000000, 5000000]]) == 5000000\n assert candidate(events = [[1, 2, 100], [3, 4, 200], [5, 6, 300], [7, 8, 400], [9, 10, 500]]) == 900\n assert candidate(events = [[1, 5, 1], [6, 10, 2], [11, 15, 3], [16, 20, 4], [21, 25, 5], [26, 30, 6]]) == 11\n assert candidate(events = [[1, 2, 1000000], [2, 3, 900000], [3, 4, 800000], [4, 5, 700000], [5, 6, 600000], [6, 7, 500000], [7, 8, 400000], [8, 9, 300000], [9, 10, 200000], [10, 11, 100000]]) == 1800000\n assert candidate(events = [[1, 1000000000, 1], [2, 1000000000, 2], [3, 1000000000, 3], [4, 1000000000, 4], [5, 1000000000, 5]]) == 5\n assert candidate(events = [[1, 1000000000, 1], [1000000000, 1000000000, 1000000]]) == 1000000\n assert candidate(events = [[1, 5, 10], [2, 6, 20], [3, 7, 30], [4, 8, 40], [5, 9, 50]]) == 50\n assert candidate(events = [[1, 100, 1], [101, 200, 2], [201, 300, 3], [301, 400, 4], [401, 500, 5], [501, 600, 6], [601, 700, 7], [701, 800, 8], [801, 900, 9], [901, 1000, 10]]) == 19\n assert candidate(events = [[1, 2, 100], [2, 3, 200], [3, 4, 300], [4, 5, 400], [5, 6, 500]]) == 800\n assert candidate(events = [[1, 1, 10], [2, 2, 20], [3, 3, 30], [4, 4, 40], [5, 5, 50], [6, 6, 60], [7, 7, 70], [8, 8, 80], [9, 9, 90], [10, 10, 100], [11, 11, 110], [12, 12, 120], [13, 13, 130], [14, 14, 140], [15, 15, 150]]) == 290\n assert candidate(events = [[1, 2, 1000000], [3, 4, 2000000], [5, 6, 3000000], [7, 8, 4000000], [9, 10, 5000000]]) == 9000000\n assert candidate(events = [[1, 1, 10], [2, 2, 9], [3, 3, 8], [4, 4, 7], [5, 5, 6], [6, 6, 5], [7, 7, 4], [8, 8, 3], [9, 9, 2], [10, 10, 1], [11, 11, 100], [12, 12, 99], [13, 13, 98], [14, 14, 97], [15, 15, 96]]) == 199\n assert candidate(events = [[1, 1, 1000000], [2, 2, 999999], [3, 3, 999998], [4, 4, 999997], [5, 5, 999996]]) == 1999999\n assert candidate(events = [[1, 1000000000, 1], [2, 999999999, 1000000], [3, 999999998, 2000000], [4, 999999997, 3000000]]) == 3000000\n assert candidate(events = [[1, 5, 100], [5, 10, 200], [10, 15, 300], [15, 20, 400], [20, 25, 500], [25, 30, 600], [30, 35, 700], [35, 40, 800], [40, 45, 900], [45, 50, 1000]]) == 1800\n assert candidate(events = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50], [6, 7, 60], [7, 8, 70], [8, 9, 80], [9, 10, 90], [10, 11, 100], [11, 12, 110], [12, 13, 120], [13, 14, 130], [14, 15, 140], [15, 16, 150]]) == 280\n assert candidate(events = [[1, 2, 1], [3, 4, 2], [5, 6, 3], [7, 8, 4], [9, 10, 5], [11, 12, 6], [13, 14, 7], [15, 16, 8], [17, 18, 9], [19, 20, 10], [21, 22, 11], [23, 24, 12], [25, 26, 13], [27, 28, 14], [29, 30, 15]]) == 29\n assert candidate(events = [[1, 2, 10], [3, 4, 20], [5, 6, 30], [7, 8, 40], [9, 10, 50], [11, 12, 60], [13, 14, 70], [15, 16, 80], [17, 18, 90], [19, 20, 100], [21, 22, 110], [23, 24, 120], [25, 26, 130], [27, 28, 140], [29, 30, 150]]) == 290\n assert candidate(events = [[1, 2, 1000000], [3, 4, 999999], [5, 6, 999998], [7, 8, 999997], [9, 10, 999996], [11, 12, 999995], [13, 14, 999994], [15, 16, 999993], [17, 18, 999992], [19, 20, 999991]]) == 1999999\n assert candidate(events = [[1, 5, 1000000], [1, 5, 900000], [1, 5, 800000], [1, 5, 700000], [1, 5, 600000], [1, 5, 500000], [1, 5, 400000], [1, 5, 300000], [1, 5, 200000], [1, 5, 100000]]) == 1000000\n assert candidate(events = [[1, 2, 10], [1, 2, 11], [1, 2, 12], [1, 2, 13], [1, 2, 14], [1, 2, 15]]) == 15\n assert candidate(events = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [1, 6, 6], [1, 7, 7], [1, 8, 8], [1, 9, 9], [1, 10, 10]]) == 10\n assert candidate(events = [[10, 20, 100], [20, 30, 200], [30, 40, 300], [40, 50, 400], [50, 60, 500], [60, 70, 600]]) == 1000\n assert candidate(events = [[1, 1, 100], [2, 2, 200], [3, 3, 300], [4, 4, 400], [5, 5, 500], [6, 6, 600], [7, 7, 700], [8, 8, 800], [9, 9, 900], [10, 10, 1000]]) == 1900\n assert candidate(events = [[1, 10, 1], [2, 11, 2], [3, 12, 3], [4, 13, 4], [5, 14, 5], [6, 15, 6], [7, 16, 7], [8, 17, 8], [9, 18, 9], [10, 19, 10]]) == 10\n assert candidate(events = [[1, 3, 100], [2, 5, 200], [3, 7, 300], [4, 10, 400], [5, 12, 500], [6, 15, 600], [7, 17, 700], [8, 18, 800], [9, 19, 900]]) == 1200\n assert candidate(events = [[1, 2, 10], [1, 3, 20], [1, 4, 30], [1, 5, 40], [1, 6, 50], [1, 7, 60], [1, 8, 70], [1, 9, 80], [1, 10, 90]]) == 90\n assert candidate(events = [[1, 5, 3], [1, 5, 1], [6, 6, 5], [7, 8, 4]]) == 9\n assert candidate(events = [[1, 1, 1], [2, 10, 2], [3, 9, 3], [4, 8, 4], [5, 7, 5], [6, 6, 6], [7, 5, 7], [8, 4, 8], [9, 3, 9], [10, 2, 10], [11, 1, 11]]) == 22\n assert candidate(events = [[1, 5, 1], [2, 6, 2], [3, 7, 3], [4, 8, 4], [5, 9, 5], [6, 10, 6], [7, 11, 7], [8, 12, 8], [9, 13, 9], [10, 14, 10]]) == 15\n assert candidate(events = [[1, 10, 1], [2, 20, 2], [3, 30, 3], [4, 40, 4], [5, 50, 5], [6, 60, 6], [7, 70, 7], [8, 80, 8], [9, 90, 9], [10, 100, 10]]) == 10\n assert candidate(events = [[1, 1000000000, 1000000], [2, 999999999, 2000000], [3, 999999998, 3000000], [4, 999999997, 4000000]]) == 4000000\n assert candidate(events = [[1, 10, 100], [11, 20, 200], [21, 30, 300], [31, 40, 400], [41, 50, 500], [51, 60, 600], [61, 70, 700], [71, 80, 800], [81, 90, 900], [91, 100, 1000], [1, 50, 500000], [51, 100, 500000]]) == 1000000\n assert candidate(events = [[1, 3, 5], [3, 5, 5], [5, 7, 5], [7, 9, 5], [9, 11, 5]]) == 10\n assert candidate(events = [[1, 100, 1], [2, 99, 2], [3, 98, 3], [4, 97, 4], [5, 96, 5], [6, 95, 6], [7, 94, 7], [8, 93, 8], [9, 92, 9], [10, 91, 10]]) == 10\n assert candidate(events = [[1, 5, 10], [2, 6, 20], [3, 7, 30], [4, 8, 40], [5, 9, 50], [6, 10, 60], [7, 11, 70], [8, 12, 80], [9, 13, 90], [10, 14, 100]]) == 150\n assert candidate(events = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1]]) == 2\n assert candidate(events = [[1, 2, 10], [2, 3, 20], [3, 4, 30], [4, 5, 40], [5, 6, 50]]) == 80\n assert candidate(events = [[1, 5, 10], [2, 5, 20], [3, 5, 30], [4, 5, 40], [5, 5, 50], [6, 10, 60], [7, 10, 70], [8, 10, 80], [9, 10, 90], [10, 10, 100]]) == 150\n assert candidate(events = [[1, 1, 1000000], [1000000000, 1000000000, 1], [500000000, 500000000, 2], [600000000, 600000000, 3], [700000000, 700000000, 4], [800000000, 800000000, 5]]) == 1000005\n assert candidate(events = [[1, 10, 5], [10, 20, 10], [20, 30, 15], [30, 40, 20], [40, 50, 25], [50, 60, 30], [60, 70, 35], [70, 80, 40], [80, 90, 45], [90, 100, 50]]) == 90\n assert candidate(events = [[1, 1, 1000000], [2, 2, 999999], [3, 3, 999998], [4, 4, 999997], [5, 5, 999996], [6, 6, 999995], [7, 7, 999994], [8, 8, 999993], [9, 9, 999992], [10, 10, 999991]]) == 1999999\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14], [15, 16, 15]]) == 28\n assert candidate(events = [[1, 5, 3], [2, 4, 5], [6, 8, 7], [9, 11, 10], [12, 15, 12], [16, 20, 15]]) == 27\n assert candidate(events = [[1, 10, 10], [2, 3, 20], [4, 5, 30], [6, 7, 40], [8, 9, 50], [11, 12, 60]]) == 110\n assert candidate(events = [[1, 10, 10], [11, 20, 20], [21, 30, 30], [31, 40, 40], [41, 50, 50], [51, 60, 60], [61, 70, 70], [71, 80, 80], [81, 90, 90], [91, 100, 100]]) == 190\n assert candidate(events = [[1, 3, 1], [4, 6, 2], [7, 9, 3], [10, 12, 4], [13, 15, 5], [16, 18, 6], [19, 21, 7], [22, 24, 8], [25, 27, 9], [28, 30, 10]]) == 19\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12], [13, 14, 13], [14, 15, 14]]) == 26\n assert candidate(events = [[1, 3, 3], [3, 5, 2], [5, 7, 1], [7, 9, 4], [9, 11, 5], [11, 13, 6]]) == 10\n assert candidate(events = [[1, 2, 5], [3, 4, 10], [5, 6, 15], [7, 8, 20], [9, 10, 25], [11, 12, 30], [13, 14, 35], [15, 16, 40]]) == 75\n assert candidate(events = [[1, 2, 1], [3, 4, 2], [5, 6, 3], [7, 8, 4], [9, 10, 5], [11, 12, 6], [13, 14, 7], [15, 16, 8], [17, 18, 9], [19, 20, 10]]) == 19\n assert candidate(events = [[1, 1000000000, 10], [2, 999999999, 20], [3, 999999998, 30], [4, 999999997, 40], [5, 999999996, 50], [6, 999999995, 60], [7, 999999994, 70], [8, 999999993, 80], [9, 999999992, 90], [10, 999999991, 100]]) == 100\n assert candidate(events = [[1, 1, 1000000], [2, 2, 1000000], [3, 3, 1000000], [4, 4, 1000000], [5, 5, 1000000], [6, 6, 1000000], [7, 7, 1000000], [8, 8, 1000000], [9, 9, 1000000], [10, 10, 1000000]]) == 2000000\n assert candidate(events = [[1, 1000000000, 1], [2, 1000000000, 2], [3, 1000000000, 3]]) == 3\n assert candidate(events = [[1, 10, 1], [10, 20, 2], [20, 30, 3], [30, 40, 4], [40, 50, 5], [50, 60, 6], [60, 70, 7], [70, 80, 8], [80, 90, 9], [90, 100, 10], [1, 100, 11], [2, 99, 12], [3, 98, 13], [4, 97, 14], [5, 96, 15]]) == 18\n assert candidate(events = [[1, 3, 2], [2, 4, 3], [3, 5, 4], [4, 6, 5], [5, 7, 6], [6, 8, 7], [7, 9, 8], [8, 10, 9], [9, 11, 10]]) == 17\n assert candidate(events = [[1, 1000000000, 1], [2, 1000000000, 2], [3, 1000000000, 3], [4, 1000000000, 4]]) == 4\n assert candidate(events = [[1, 3, 10], [2, 5, 8], [4, 6, 6], [7, 8, 5], [8, 10, 7], [9, 12, 4]]) == 17\n assert candidate(events = [[1, 1000000000, 1000000], [1000000001, 2000000000, 2000000], [2000000001, 3000000000, 3000000], [3000000001, 4000000000, 4000000], [4000000001, 5000000000, 5000000]]) == 9000000\n assert candidate(events = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10], [11, 11, 11], [12, 12, 12], [13, 13, 13], [14, 14, 14], [15, 15, 15]]) == 29\n assert candidate(events = [[1, 1000000000, 1], [1000000001, 2000000000, 2], [2000000001, 3000000000, 3], [3000000001, 4000000000, 4], [4000000001, 5000000000, 5], [5000000001, 6000000000, 6], [6000000001, 7000000000, 7], [7000000001, 8000000000, 8], [8000000001, 9000000000, 9], [9000000001, 10000000000, 10]]) == 19\n assert candidate(events = [[1, 2, 50], [3, 4, 60], [5, 6, 70], [7, 8, 80], [9, 10, 90], [11, 12, 100], [13, 14, 110], [15, 16, 120], [17, 18, 130], [19, 20, 140], [21, 22, 150], [23, 24, 160], [25, 26, 170], [27, 28, 180], [29, 30, 190]]) == 370\n assert candidate(events = [[1, 3, 10], [2, 4, 20], [3, 5, 30], [4, 6, 40], [5, 7, 50], [6, 8, 60], [7, 9, 70], [8, 10, 80]]) == 130\n assert candidate(events = [[1, 2, 100], [3, 5, 200], [6, 8, 300], [9, 10, 400], [11, 12, 500]]) == 900\n assert candidate(events = [[1, 2, 1], [1, 2, 2], [1, 2, 3], [1, 2, 4], [1, 2, 5], [1, 2, 6], [1, 2, 7], [1, 2, 8], [1, 2, 9], [1, 2, 10]]) == 10\n assert candidate(events = [[1, 5, 5], [2, 6, 10], [3, 7, 15], [4, 8, 20], [5, 9, 25], [6, 10, 30], [7, 11, 35], [8, 12, 40], [9, 13, 45], [10, 14, 50]]) == 75\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8]]) == 14\n assert candidate(events = [[1, 3, 2], [1, 3, 3], [1, 3, 4], [1, 3, 5], [1, 3, 6], [1, 3, 7], [1, 3, 8], [1, 3, 9], [1, 3, 10], [1, 3, 11], [1, 3, 12], [1, 3, 13], [1, 3, 14], [1, 3, 15], [1, 3, 16]]) == 16\n assert candidate(events = [[1, 1000000000, 1000000], [2, 999999999, 999999], [3, 999999998, 999998]]) == 1000000\n assert candidate(events = [[1, 5, 10], [2, 6, 20], [3, 7, 30], [4, 8, 40], [5, 9, 50], [6, 10, 60], [7, 11, 70], [8, 12, 80], [9, 13, 90], [10, 14, 100], [11, 15, 110], [12, 16, 120], [13, 17, 130], [14, 18, 140], [15, 19, 150]]) == 250\n assert candidate(events = [[1, 10, 100], [11, 20, 200], [21, 30, 300], [31, 40, 400], [41, 50, 500], [51, 60, 600], [61, 70, 700], [71, 80, 800], [81, 90, 900], [91, 100, 1000]]) == 1900\n assert candidate(events = [[1, 1000000000, 1000000], [2, 3, 500000], [4, 5, 600000], [6, 7, 400000], [8, 9, 700000], [10, 1000000000, 800000]]) == 1500000\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10], [11, 12, 11], [12, 13, 12]]) == 22\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9], [10, 11, 10]]) == 18\n assert candidate(events = [[1, 2, 1], [2, 3, 2], [3, 4, 3], [4, 5, 4], [5, 6, 5], [6, 7, 6], [7, 8, 7], [8, 9, 8], [9, 10, 9]]) == 16\n"}, "metadata": {"canonical_parameter_names": ["events"], "leetcode_dataset_entry_point": "Solution().maxTwoEvents", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxTwoEvents(vector>& events) {", "container": "Solution", "callable": "maxTwoEvents", "parameters": [{"name": "events", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2055, "task_id": "plates-between-candles", "difficulty": "Medium", "problem_description": "There is a long table with a line of plates and candles arranged on top of it. You are given a 0-indexed string s consisting of characters '*' and '|' only, where a '*' represents a plate and a '|' represents a candle.\nYou are also given a 0-indexed 2D integer array queries where queries[i] = [lefti, righti] denotes the substring s[lefti...righti] (inclusive). For each query, you need to find the number of plates between candles that are in the substring. A plate is considered between candles if there is at least one candle to its left and at least one candle to its right in the substring.\n\nFor example, s = \"||**||**|*\", and a query [3, 8] denotes the substring \"*||**|\". The number of plates between candles in this substring is 2, as each of the two plates has at least one candle in the substring to its left and right.\n\nReturn an integer array answer where answer[i] is the answer to the ith query.\n \nExample 1:\n\n\nInput: s = \"**|**|***|\", queries = [[2,5],[5,9]]\nOutput: [2,3]\nExplanation:\n- queries[0] has two plates between candles.\n- queries[1] has three plates between candles.\n\nExample 2:\n\n\nInput: s = \"***|**|*****|**||**|*\", queries = [[1,17],[4,5],[14,17],[5,11],[15,16]]\nOutput: [9,0,0,0,0]\nExplanation:\n- queries[0] has nine plates between candles.\n- The other queries have zero plates between candles.\n\n \nConstraints:\n\n3 <= s.length <= 105\ns consists of '*' and '|' characters.\n1 <= queries.length <= 105\nqueries[i].length == 2\n0 <= lefti <= righti < s.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s = \"**|**|***|\",queries = [[2, 5], [5, 9]]) == [2, 3]\n assert candidate(s = \"***||***\",queries = [[0, 5], [2, 4]]) == [0, 0]\n assert candidate(s = \"*|*|*|*|*|*|*|\",queries = [[0, 7], [1, 6], [2, 5]]) == [3, 2, 1]\n assert candidate(s = \"|||***|||\",queries = [[0, 8], [1, 7], [2, 6]]) == [3, 3, 3]\n assert candidate(s = \"||*|*|*|*|*|*|\",queries = [[0, 10], [1, 9], [2, 8], [3, 7]]) == [4, 4, 2, 2]\n assert candidate(s = \"|||****|****|****||\",queries = [[0, 10], [5, 15], [1, 4]]) == [4, 4, 0]\n assert candidate(s = \"*|*|*|*|*|\",queries = [[0, 5], [1, 4]]) == [2, 1]\n assert candidate(s = \"|*|*|*|*|*|*|*|*|*|*|\",queries = [[0, 10], [1, 9], [2, 8], [3, 7]]) == [5, 3, 3, 1]\n assert candidate(s = \"|||*****|||\",queries = [[0, 2], [3, 8], [7, 10]]) == [0, 0, 0]\n assert candidate(s = \"*|*|*|*|*|*|*|*|*|*|*|\",queries = [[0, 11], [1, 10], [2, 9], [3, 8]]) == [5, 4, 3, 2]\n assert candidate(s = \"*|*|*|*|*|*|*|*|*|*|\",queries = [[0, 10], [1, 9], [2, 8], [3, 7]]) == [4, 4, 2, 2]\n assert candidate(s = \"***|**|*****|**||**|*\",queries = [[1, 17], [4, 5], [14, 17], [5, 11], [15, 16]]) == [9, 0, 0, 0, 0]\n assert candidate(s = \"***||****|**|\",queries = [[0, 4], [5, 8], [9, 11]]) == [0, 0, 0]\n"}, "metadata": {"canonical_parameter_names": ["s", "queries"], "leetcode_dataset_entry_point": "Solution().platesBetweenCandles", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector platesBetweenCandles(string s, vector>& queries) {", "container": "Solution", "callable": "platesBetweenCandles", "parameters": [{"name": "s", "type": "string"}, {"name": "queries", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2056, "task_id": "number-of-valid-move-combinations-on-chessboard", "difficulty": "Hard", "problem_description": "There is an 8 x 8 chessboard containing n pieces (rooks, queens, or bishops). You are given a string array pieces of length n, where pieces[i] describes the type (rook, queen, or bishop) of the ith piece. In addition, you are given a 2D integer array positions also of length n, where positions[i] = [ri, ci] indicates that the ith piece is currently at the 1-based coordinate (ri, ci) on the chessboard.\nWhen making a move for a piece, you choose a destination square that the piece will travel toward and stop on.\n\nA rook can only travel horizontally or vertically from (r, c) to the direction of (r+1, c), (r-1, c), (r, c+1), or (r, c-1).\nA queen can only travel horizontally, vertically, or diagonally from (r, c) to the direction of (r+1, c), (r-1, c), (r, c+1), (r, c-1), (r+1, c+1), (r+1, c-1), (r-1, c+1), (r-1, c-1).\nA bishop can only travel diagonally from (r, c) to the direction of (r+1, c+1), (r+1, c-1), (r-1, c+1), (r-1, c-1).\n\nYou must make a move for every piece on the board simultaneously. A move combination consists of all the moves performed on all the given pieces. Every second, each piece will instantaneously travel one square towards their destination if they are not already at it. All pieces start traveling at the 0th second. A move combination is invalid if, at a given time, two or more pieces occupy the same square.\nReturn the number of valid move combinations​​​​​.\nNotes:\n\nNo two pieces will start in the same square.\nYou may choose the square a piece is already on as its destination.\nIf two pieces are directly adjacent to each other, it is valid for them to move past each other and swap positions in one second.\n\n \nExample 1:\n\n\nInput: pieces = [\"rook\"], positions = [[1,1]]\nOutput: 15\nExplanation: The image above shows the possible squares the piece can move to.\n\nExample 2:\n\n\nInput: pieces = [\"queen\"], positions = [[1,1]]\nOutput: 22\nExplanation: The image above shows the possible squares the piece can move to.\n\nExample 3:\n\n\nInput: pieces = [\"bishop\"], positions = [[4,3]]\nOutput: 12\nExplanation: The image above shows the possible squares the piece can move to.\n\n \nConstraints:\n\nn == pieces.length \nn == positions.length\n1 <= n <= 4\npieces only contains the strings \"rook\", \"queen\", and \"bishop\".\nThere will be at most one queen on the chessboard.\n1 <= ri, ci <= 8\nEach positions[i] is distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(pieces = ['bishop'],positions = [[4, 3]]) == 12\n assert candidate(pieces = ['queen', 'rook'],positions = [[1, 1], [2, 2]]) == 309\n assert candidate(pieces = ['rook', 'rook'],positions = [[1, 1], [8, 8]]) == 223\n assert candidate(pieces = ['queen', 'rook'],positions = [[2, 2], [5, 5]]) == 340\n assert candidate(pieces = ['rook', 'queen', 'bishop'],positions = [[1, 1], [5, 5], [8, 8]]) == 2907\n assert candidate(pieces = ['rook', 'queen', 'bishop'],positions = [[1, 1], [2, 2], [3, 3]]) == 3289\n assert candidate(pieces = ['rook', 'rook'],positions = [[1, 1], [1, 3]]) == 189\n assert candidate(pieces = ['rook'],positions = [[1, 1]]) == 15\n assert candidate(pieces = ['rook', 'bishop'],positions = [[1, 1], [4, 3]]) == 173\n assert candidate(pieces = ['bishop', 'bishop'],positions = [[2, 2], [7, 7]]) == 80\n assert candidate(pieces = ['bishop', 'bishop'],positions = [[2, 2], [6, 6]]) == 84\n assert candidate(pieces = ['queen', 'bishop'],positions = [[1, 1], [4, 4]]) == 280\n assert candidate(pieces = ['bishop', 'rook', 'bishop'],positions = [[3, 4], [5, 5], [7, 6]]) == 1265\n assert candidate(pieces = ['queen'],positions = [[1, 1]]) == 22\n assert candidate(pieces = ['rook', 'bishop'],positions = [[1, 1], [4, 4]]) == 205\n assert candidate(pieces = ['rook', 'queen', 'bishop'],positions = [[1, 1], [5, 5], [4, 3]]) == 4421\n assert candidate(pieces = ['queen', 'rook', 'bishop'],positions = [[1, 1], [2, 2], [4, 3]]) == 3161\n assert candidate(pieces = ['rook', 'bishop', 'rook', 'bishop'],positions = [[1, 1], [2, 2], [3, 3], [4, 4]]) == 16893\n assert candidate(pieces = ['queen', 'rook'],positions = [[1, 1], [8, 8]]) == 327\n assert candidate(pieces = ['queen', 'rook', 'rook'],positions = [[1, 1], [8, 8], [1, 8]]) == 4163\n assert candidate(pieces = ['rook', 'queen', 'bishop'],positions = [[3, 3], [5, 5], [7, 2]]) == 3589\n assert candidate(pieces = ['queen', 'bishop', 'bishop'],positions = [[1, 1], [8, 8], [1, 8]]) == 1232\n assert candidate(pieces = ['queen', 'rook', 'bishop', 'rook'],positions = [[1, 1], [1, 8], [8, 1], [8, 8]]) == 32176\n assert candidate(pieces = ['queen', 'rook', 'bishop', 'rook'],positions = [[1, 1], [8, 8], [3, 3], [6, 6]]) == 44166\n assert candidate(pieces = ['queen', 'queen'],positions = [[3, 3], [6, 6]]) == 638\n assert candidate(pieces = ['rook', 'rook', 'rook', 'rook'],positions = [[1, 1], [1, 8], [8, 1], [8, 8]]) == 33009\n assert candidate(pieces = ['bishop', 'bishop', 'rook', 'rook'],positions = [[1, 1], [8, 8], [4, 4], [5, 5]]) == 7561\n assert candidate(pieces = ['queen', 'bishop', 'rook', 'bishop'],positions = [[1, 1], [8, 8], [4, 4], [4, 1]]) == 15440\n assert candidate(pieces = ['rook', 'rook', 'rook'],positions = [[1, 1], [1, 8], [8, 1]]) == 2753\n assert candidate(pieces = ['rook', 'queen', 'bishop', 'rook'],positions = [[1, 1], [8, 8], [4, 4], [2, 2]]) == 51937\n assert candidate(pieces = ['rook', 'queen', 'bishop', 'rook'],positions = [[1, 1], [5, 5], [8, 8], [8, 1]]) == 38251\n assert candidate(pieces = ['queen', 'rook', 'rook', 'bishop'],positions = [[1, 1], [1, 8], [8, 1], [8, 8]]) == 29034\n assert candidate(pieces = ['queen', 'queen', 'rook'],positions = [[3, 3], [4, 4], [2, 2]]) == 8446\n assert candidate(pieces = ['queen', 'bishop', 'rook', 'rook'],positions = [[1, 1], [8, 8], [1, 8], [8, 1]]) == 29034\n assert candidate(pieces = ['queen', 'rook'],positions = [[4, 4], [7, 7]]) == 400\n assert candidate(pieces = ['rook', 'rook', 'bishop'],positions = [[1, 1], [8, 8], [4, 4]]) == 3034\n assert candidate(pieces = ['queen', 'rook', 'bishop'],positions = [[2, 2], [7, 7], [3, 8]]) == 2590\n assert candidate(pieces = ['rook', 'rook'],positions = [[4, 4], [5, 5]]) == 193\n assert candidate(pieces = ['rook', 'queen', 'bishop'],positions = [[1, 4], [4, 4], [7, 4]]) == 3784\n assert candidate(pieces = ['rook', 'bishop', 'queen'],positions = [[1, 1], [8, 8], [4, 4]]) == 2681\n assert candidate(pieces = ['bishop', 'bishop', 'bishop', 'bishop'],positions = [[2, 2], [2, 7], [7, 2], [7, 7]]) == 6400\n assert candidate(pieces = ['queen', 'bishop', 'rook'],positions = [[8, 1], [1, 8], [4, 4]]) == 2110\n assert candidate(pieces = ['queen', 'bishop', 'rook'],positions = [[2, 2], [3, 3], [5, 5]]) == 3484\n assert candidate(pieces = ['bishop', 'rook', 'queen', 'rook'],positions = [[3, 3], [4, 4], [5, 5], [6, 6]]) == 44433\n assert candidate(pieces = ['queen', 'bishop', 'bishop'],positions = [[1, 1], [3, 3], [6, 6]]) == 2162\n assert candidate(pieces = ['rook', 'queen', 'rook', 'bishop'],positions = [[1, 1], [5, 5], [8, 1], [1, 8]]) == 41166\n assert candidate(pieces = ['rook', 'rook', 'queen'],positions = [[1, 1], [1, 8], [8, 8]]) == 4163\n assert candidate(pieces = ['bishop', 'rook', 'queen'],positions = [[3, 3], [4, 3], [3, 4]]) == 3142\n assert candidate(pieces = ['rook', 'rook', 'bishop', 'bishop'],positions = [[1, 2], [1, 7], [2, 1], [2, 8]]) == 10952\n assert candidate(pieces = ['bishop', 'rook', 'rook', 'bishop'],positions = [[1, 2], [3, 3], [6, 7], [8, 6]]) == 10473\n assert candidate(pieces = ['rook', 'bishop', 'bishop', 'queen'],positions = [[1, 1], [2, 2], [3, 3], [4, 4]]) == 26725\n assert candidate(pieces = ['queen', 'rook', 'bishop'],positions = [[1, 1], [8, 8], [4, 4]]) == 4145\n assert candidate(pieces = ['bishop', 'rook', 'queen', 'rook'],positions = [[1, 8], [2, 2], [5, 5], [8, 1]]) == 42649\n assert candidate(pieces = ['queen', 'rook', 'bishop', 'rook'],positions = [[1, 1], [2, 2], [3, 3], [4, 4]]) == 35461\n assert candidate(pieces = ['rook', 'rook', 'rook'],positions = [[1, 1], [2, 2], [3, 3]]) == 2709\n assert candidate(pieces = ['rook', 'bishop'],positions = [[2, 2], [3, 6]]) == 172\n assert candidate(pieces = ['queen', 'queen'],positions = [[1, 1], [8, 8]]) == 462\n assert candidate(pieces = ['rook', 'bishop'],positions = [[1, 1], [8, 1]]) == 118\n assert candidate(pieces = ['queen', 'rook', 'bishop'],positions = [[1, 1], [2, 2], [3, 3]]) == 2842\n assert candidate(pieces = ['bishop', 'bishop', 'rook', 'rook'],positions = [[2, 2], [7, 7], [1, 1], [8, 8]]) == 13998\n assert candidate(pieces = ['queen', 'bishop', 'bishop', 'rook'],positions = [[4, 4], [3, 3], [6, 6], [1, 1]]) == 39585\n assert candidate(pieces = ['rook', 'rook', 'rook'],positions = [[1, 1], [8, 8], [4, 4]]) == 3079\n assert candidate(pieces = ['queen', 'rook', 'bishop'],positions = [[1, 1], [4, 5], [8, 2]]) == 2308\n assert candidate(pieces = ['bishop', 'bishop'],positions = [[3, 3], [6, 6]]) == 124\n assert candidate(pieces = ['bishop', 'rook', 'rook'],positions = [[1, 1], [8, 1], [8, 8]]) == 1600\n assert candidate(pieces = ['rook', 'rook', 'bishop', 'queen'],positions = [[1, 1], [8, 8], [3, 3], [6, 6]]) == 56730\n assert candidate(pieces = ['rook', 'bishop', 'rook'],positions = [[2, 2], [3, 3], [4, 4]]) == 2185\n assert candidate(pieces = ['queen', 'rook', 'rook'],positions = [[1, 1], [5, 5], [5, 6]]) == 4182\n assert candidate(pieces = ['rook', 'rook', 'bishop', 'bishop'],positions = [[1, 1], [1, 8], [8, 1], [8, 8]]) == 12485\n assert candidate(pieces = ['queen', 'rook', 'rook'],positions = [[4, 4], [1, 1], [8, 8]]) == 5890\n assert candidate(pieces = ['bishop', 'bishop', 'rook'],positions = [[2, 2], [7, 7], [1, 8]]) == 1112\n assert candidate(pieces = ['bishop', 'bishop', 'rook', 'rook'],positions = [[1, 1], [1, 8], [8, 1], [8, 8]]) == 12485\n assert candidate(pieces = ['bishop', 'rook', 'rook', 'queen'],positions = [[4, 4], [1, 1], [1, 8], [8, 8]]) == 49107\n assert candidate(pieces = ['queen', 'rook', 'bishop', 'rook'],positions = [[3, 3], [5, 5], [2, 2], [6, 6]]) == 37434\n assert candidate(pieces = ['queen', 'bishop'],positions = [[2, 2], [7, 7]]) == 220\n assert candidate(pieces = ['queen', 'queen', 'queen'],positions = [[2, 2], [3, 3], [4, 4]]) == 13103\n assert candidate(pieces = ['queen', 'bishop'],positions = [[1, 1], [8, 8]]) == 156\n assert candidate(pieces = ['queen', 'queen'],positions = [[2, 2], [7, 7]]) == 548\n assert candidate(pieces = ['bishop', 'bishop', 'rook', 'rook'],positions = [[2, 2], [3, 3], [6, 6], [7, 7]]) == 18260\n assert candidate(pieces = ['rook', 'bishop', 'queen'],positions = [[3, 3], [6, 6], [5, 5]]) == 4230\n assert candidate(pieces = ['rook', 'bishop', 'rook', 'bishop'],positions = [[1, 1], [8, 8], [2, 2], [7, 7]]) == 10336\n assert candidate(pieces = ['queen', 'rook', 'rook'],positions = [[1, 1], [1, 8], [8, 1]]) == 4286\n assert candidate(pieces = ['queen', 'rook'],positions = [[4, 4], [8, 1]]) == 412\n assert candidate(pieces = ['rook', 'rook', 'rook', 'rook', 'bishop'],positions = [[1, 1], [1, 8], [8, 1], [8, 8], [4, 4]]) == 437408\n assert candidate(pieces = ['rook', 'rook', 'queen', 'bishop'],positions = [[1, 1], [8, 8], [4, 4], [5, 5]]) == 74604\n assert candidate(pieces = ['queen', 'rook', 'rook'],positions = [[5, 5], [1, 1], [8, 8]]) == 5890\n assert candidate(pieces = ['bishop', 'bishop', 'rook'],positions = [[2, 2], [7, 7], [4, 4]]) == 1150\n assert candidate(pieces = ['queen', 'rook', 'bishop'],positions = [[4, 4], [1, 1], [8, 8]]) == 2681\n assert candidate(pieces = ['queen', 'bishop', 'rook'],positions = [[3, 3], [6, 6], [1, 1]]) == 4107\n assert candidate(pieces = ['queen', 'queen'],positions = [[1, 2], [8, 7]]) == 476\n assert candidate(pieces = ['queen', 'queen'],positions = [[2, 3], [3, 2]]) == 518\n assert candidate(pieces = ['bishop', 'bishop'],positions = [[1, 1], [8, 8]]) == 44\n assert candidate(pieces = ['bishop', 'bishop', 'bishop'],positions = [[2, 2], [5, 5], [8, 8]]) == 460\n assert candidate(pieces = ['rook', 'rook'],positions = [[1, 1], [1, 8]]) == 205\n assert candidate(pieces = ['rook', 'rook', 'bishop'],positions = [[1, 1], [8, 1], [4, 4]]) == 2764\n assert candidate(pieces = ['queen', 'queen', 'rook'],positions = [[1, 1], [8, 8], [4, 4]]) == 6380\n assert candidate(pieces = ['rook', 'queen', 'bishop', 'rook'],positions = [[1, 1], [2, 2], [3, 3], [4, 4]]) == 41894\n assert candidate(pieces = ['queen', 'rook'],positions = [[1, 1], [8, 1]]) == 309\n assert candidate(pieces = ['bishop', 'bishop', 'bishop'],positions = [[2, 3], [4, 5], [6, 7]]) == 728\n assert candidate(pieces = ['bishop', 'bishop', 'bishop'],positions = [[2, 2], [4, 4], [6, 6]]) == 792\n"}, "metadata": {"canonical_parameter_names": ["pieces", "positions"], "leetcode_dataset_entry_point": "Solution().countCombinations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countCombinations(vector& pieces, vector>& positions) {", "container": "Solution", "callable": "countCombinations", "parameters": [{"name": "pieces", "type": "vector&"}, {"name": "positions", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2057, "task_id": "smallest-index-with-equal-value", "difficulty": "Easy", "problem_description": "Given a 0-indexed integer array nums, return the smallest index i of nums such that i mod 10 == nums[i], or -1 if such index does not exist.\nx mod y denotes the remainder when x is divided by y.\n \nExample 1:\n\nInput: nums = [0,1,2]\nOutput: 0\nExplanation: \ni=0: 0 mod 10 = 0 == nums[0].\ni=1: 1 mod 10 = 1 == nums[1].\ni=2: 2 mod 10 = 2 == nums[2].\nAll indices have i mod 10 == nums[i], so we return the smallest index 0.\n\nExample 2:\n\nInput: nums = [4,3,2,1]\nOutput: 2\nExplanation: \ni=0: 0 mod 10 = 0 != nums[0].\ni=1: 1 mod 10 = 1 != nums[1].\ni=2: 2 mod 10 = 2 == nums[2].\ni=3: 3 mod 10 = 3 != nums[3].\n2 is the only index which has i mod 10 == nums[i].\n\nExample 3:\n\nInput: nums = [1,2,3,4,5,6,7,8,9,0]\nOutput: -1\nExplanation: No index satisfies i mod 10 == nums[i].\n\n \nConstraints:\n\n1 <= nums.length <= 100\n0 <= nums[i] <= 9\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [0, 5, 0, 5, 0, 5, 0, 5, 0, 5]) == 0\n assert candidate(nums = [4, 3, 2, 1]) == 2\n assert candidate(nums = [7, 8, 9, 0, 1, 2, 3, 4, 5, 6]) == -1\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [0, 10, 20, 30, 40]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 1, 3, 5, 7, 9]) == 9\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 7\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == -1\n assert candidate(nums = [3, 6, 9, 2, 5, 8, 1, 4, 7, 0]) == -1\n assert candidate(nums = [0, 10, 20, 30]) == 0\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [3, 0, 1, 4, 2, 5, 9, 6, 7, 8]) == 5\n assert candidate(nums = [0, 1, 2]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == -1\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == -1\n assert candidate(nums = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0]) == 8\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 9\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == -1\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == 4\n assert candidate(nums = [1, 10, 2, 20, 3, 30, 4, 40, 5, 50]) == 2\n assert candidate(nums = [0, 9, 1, 8, 2, 7, 3, 6, 4, 5, 0, 9, 1, 8, 2, 7, 3, 6, 4, 5]) == 0\n assert candidate(nums = [6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7]) == 3\n assert candidate(nums = [0, 2, 4, 6, 8, 0, 2, 4, 6, 8]) == 0\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9, 1, 3, 5, 7, 9]) == 9\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 0\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6]) == -1\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == 0\n assert candidate(nums = [4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 0]) == -1\n assert candidate(nums = [6, 3, 8, 6, 2, 9, 1, 3, 4, 7, 6, 3, 8, 6, 2, 9, 1, 3, 4, 7]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3]) == 1\n assert candidate(nums = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0]) == -1\n assert candidate(nums = [1, 3, 5, 7, 9, 0, 2, 4, 6, 8, 1, 3, 5, 7, 9, 0, 2, 4, 6, 8, 1, 3, 5, 7, 9, 0, 2, 4, 6, 8]) == -1\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9]) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 1\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == -1\n assert candidate(nums = [1, 0, 3, 2, 5, 4, 7, 6, 9, 8, 1, 0, 3, 2, 5, 4, 7, 6, 9, 8]) == -1\n assert candidate(nums = [4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3]) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1\n assert candidate(nums = [8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9]) == 4\n assert candidate(nums = [4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4, 1, 2, 3, 4, 5, 6]) == 1\n assert candidate(nums = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0]) == 8\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == 0\n assert candidate(nums = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4]) == -1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0]) == 8\n assert candidate(nums = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 9\n assert candidate(nums = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 5\n assert candidate(nums = [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6]) == 6\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]) == 7\n assert candidate(nums = [1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2]) == -1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == -1\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]) == -1\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == -1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [10, 22, 33, 44, 55, 66, 77, 88, 99, 0]) == -1\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 4\n assert candidate(nums = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90]) == 0\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == -1\n assert candidate(nums = [9, 0, 9, 0, 9, 0, 9, 0, 9, 0]) == -1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 3\n assert candidate(nums = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [1, 3, 5, 7, 9, 2, 4, 6, 8, 0]) == 8\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4]) == -1\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [0, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 0\n assert candidate(nums = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == 3\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 2\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 5\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 0\n assert candidate(nums = [1, 0, 9, 8, 7, 6, 5, 4, 3, 2]) == -1\n assert candidate(nums = [5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4]) == -1\n assert candidate(nums = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0]) == 8\n assert candidate(nums = [8, 6, 4, 2, 0, 9, 7, 5, 3, 1]) == -1\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == -1\n assert candidate(nums = [1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == -1\n assert candidate(nums = [6, 3, 9, 2, 4, 1, 5, 8, 0, 7, 6, 3, 9, 2, 4, 1, 5, 8, 0, 7, 6, 3, 9, 2, 4, 1, 5, 8, 0, 7, 6, 3, 9, 2, 4, 1, 5, 8, 0, 7]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2]) == -1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == -1\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().smallestEqual", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int smallestEqual(vector& nums) {", "container": "Solution", "callable": "smallestEqual", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2058, "task_id": "find-the-minimum-and-maximum-number-of-nodes-between-critical-points", "difficulty": "Medium", "problem_description": "A critical point in a linked list is defined as either a local maxima or a local minima.\nA node is a local maxima if the current node has a value strictly greater than the previous node and the next node.\nA node is a local minima if the current node has a value strictly smaller than the previous node and the next node.\nNote that a node can only be a local maxima/minima if there exists both a previous node and a next node.\nGiven a linked list head, return an array of length 2 containing [minDistance, maxDistance] where minDistance is the minimum distance between any two distinct critical points and maxDistance is the maximum distance between any two distinct critical points. If there are fewer than two critical points, return [-1, -1].\n \nExample 1:\n\n\nInput: head = [3,1]\nOutput: [-1,-1]\nExplanation: There are no critical points in [3,1].\n\nExample 2:\n\n\nInput: head = [5,3,1,2,5,1,2]\nOutput: [1,3]\nExplanation: There are three critical points:\n- [5,3,1,2,5,1,2]: The third node is a local minima because 1 is less than 3 and 2.\n- [5,3,1,2,5,1,2]: The fifth node is a local maxima because 5 is greater than 2 and 1.\n- [5,3,1,2,5,1,2]: The sixth node is a local minima because 1 is less than 5 and 2.\nThe minimum distance is between the fifth and the sixth node. minDistance = 6 - 5 = 1.\nThe maximum distance is between the third and the sixth node. maxDistance = 6 - 3 = 3.\n\nExample 3:\n\n\nInput: head = [1,3,2,2,3,2,2,2,7]\nOutput: [3,3]\nExplanation: There are two critical points:\n- [1,3,2,2,3,2,2,2,7]: The second node is a local maxima because 3 is greater than 1 and 2.\n- [1,3,2,2,3,2,2,2,7]: The fifth node is a local maxima because 3 is greater than 2 and 2.\nBoth the minimum and maximum distances are between the second and the fifth node.\nThus, minDistance and maxDistance is 5 - 2 = 3.\nNote that the last node is not considered a local maxima because it does not have a next node.\n\n \nConstraints:\n\nThe number of nodes in the list is in the range [2, 105].\n1 <= Node.val <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(head = list_node([1, 2, 3, 4, 3, 2, 1, 2, 3, 4])) == [3, 3]\n assert candidate(head = list_node([1, 3, 2, 4, 3, 5, 4, 6, 5])) == [1, 6]\n assert candidate(head = list_node([1, 3, 2, 2, 3, 2, 2, 2, 7])) == [3, 3]\n assert candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) == [-1, -1]\n assert candidate(head = list_node([5, 4, 3, 2, 1])) == [-1, -1]\n assert candidate(head = list_node([1, 2, 3, 4, 3, 2, 1])) == [-1, -1]\n assert candidate(head = list_node([5, 3, 1, 2, 5, 1, 2])) == [1, 3]\n assert candidate(head = list_node([1, 2, 3, 4, 5])) == [-1, -1]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])) == [-1, -1]\n assert candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1])) == [-1, -1]\n assert candidate(head = list_node([1, 2, 3, 2, 1, 2, 3, 2, 1])) == [2, 4]\n assert candidate(head = list_node([1, 2, 3, 2, 1, 2, 3])) == [2, 2]\n assert candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == [-1, -1]\n assert candidate(head = list_node([1, 1, 1, 1, 1])) == [-1, -1]\n assert candidate(head = list_node([2, 4, 1, 1, 3, 5, 6, 4, 2])) == [5, 5]\n assert candidate(head = list_node([2, 4, 1, 1, 3, 9, 8])) == [4, 4]\n assert candidate(head = list_node([1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6])) == [1, 8]\n assert candidate(head = list_node([3, 1])) == [-1, -1]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9])) == [8, 8]\n assert candidate(head = list_node([1, 2, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3])) == [3, 14]\n assert candidate(head = list_node([2, 4, 3, 5, 1, 3, 2, 4, 6, 7, 5, 6, 8, 7, 9, 8, 10])) == [1, 14]\n assert candidate(head = list_node([1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1])) == [3, 15]\n assert candidate(head = list_node([1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10])) == [1, 17]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3])) == [2, 24]\n assert candidate(head = list_node([1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2])) == [2, 18]\n assert candidate(head = list_node([10, 20, 15, 25, 30, 20, 10, 5, 15, 25, 35, 40, 35, 30, 25, 20, 15, 10, 5])) == [1, 10]\n assert candidate(head = list_node([10, 20, 10, 30, 20, 40, 30, 50, 40, 60, 50, 70, 60, 80, 70, 90, 80, 100, 90])) == [1, 16]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])) == [1, 1]\n assert candidate(head = list_node([1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1])) == [3, 18]\n assert candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9])) == [-1, -1]\n assert candidate(head = list_node([5, 4, 3, 2, 1, 2, 3, 4, 5, 6])) == [-1, -1]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == [-1, -1]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 3, 2, 1, 2, 3, 4, 5, 3, 2, 1])) == [3, 7]\n assert candidate(head = list_node([1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18])) == [1, 16]\n assert candidate(head = list_node([1, 5, 2, 6, 3, 7, 4, 8, 5, 9, 6, 10, 7, 11, 8, 12, 9, 13, 10])) == [1, 16]\n assert candidate(head = list_node([1, 1, 2, 1, 1, 3, 1, 1, 2, 1, 1, 3, 1, 1, 2, 1, 1, 3, 1, 1, 3])) == [3, 15]\n assert candidate(head = list_node([5, 3, 1, 2, 5, 1, 2, 3, 4, 2, 1, 3, 5, 7, 6, 8])) == [1, 12]\n assert candidate(head = list_node([5, 10, 15, 20, 25, 30, 25, 20, 15, 10, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50])) == [5, 5]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5])) == [1, 1]\n assert candidate(head = list_node([1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10])) == [1, 16]\n assert candidate(head = list_node([1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8])) == [1, 12]\n assert candidate(head = list_node([100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81])) == [-1, -1]\n assert candidate(head = list_node([1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2])) == [-1, -1]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4])) == [8, 8]\n assert candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])) == [-1, -1]\n assert candidate(head = list_node([3, 3, 3, 1, 3, 3, 3, 3, 1, 3, 3, 3, 3, 1, 3, 3, 3])) == [5, 10]\n assert candidate(head = list_node([2, 4, 2, 6, 2, 8, 2, 10, 2, 12, 2, 14, 2, 16, 2])) == [1, 12]\n assert candidate(head = list_node([1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 5, 6, 4, 7, 3, 8, 2, 9, 1, 10])) == [1, 17]\n assert candidate(head = list_node([1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 6, 5, 7, 4, 8, 3, 9, 2, 10, 1])) == [1, 17]\n assert candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 95, 90, 85, 80, 75, 70, 65, 60, 55, 50])) == [-1, -1]\n assert candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5])) == [8, 8]\n assert candidate(head = list_node([1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1, 10, 1])) == [1, 16]\n assert candidate(head = list_node([5, 1, 2, 1, 5, 1, 2, 1, 5, 1, 2, 1, 5, 1, 2, 1, 5, 1, 2, 1])) == [1, 17]\n assert candidate(head = list_node([1, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9])) == [1, 16]\n assert candidate(head = list_node([1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2])) == [1, 17]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5, 4, 3, 4, 5])) == [2, 10]\n assert candidate(head = list_node([1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1])) == [3, 18]\n assert candidate(head = list_node([1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == [1, 16]\n assert candidate(head = list_node([1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1])) == [2, 24]\n assert candidate(head = list_node([2, 4, 6, 8, 10, 8, 6, 4, 2, 4, 6, 8, 10, 8, 6, 4, 2, 4, 6, 8, 10, 8, 6, 4, 2])) == [4, 16]\n assert candidate(head = list_node([5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1])) == [4, 12]\n assert candidate(head = list_node([1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1])) == [1, 42]\n assert candidate(head = list_node([100, 200, 300, 400, 500, 400, 300, 200, 100, 200, 300, 200, 100])) == [2, 6]\n assert candidate(head = list_node([1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1])) == [3, 12]\n assert candidate(head = list_node([1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1])) == [6, 12]\n assert candidate(head = list_node([1, 3, 5, 7, 9, 7, 5, 3, 1, 3, 5, 7, 9, 7, 5, 3, 1])) == [4, 8]\n assert candidate(head = list_node([1, 1, 2, 1, 1, 3, 1, 1, 2, 1, 1, 3, 1, 1, 2, 1, 1, 3, 1, 1])) == [3, 15]\n assert candidate(head = list_node([1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16])) == [1, 14]\n assert candidate(head = list_node([1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1])) == [1, 9]\n assert candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])) == [-1, -1]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 4, 3, 2, 1])) == [9, 9]\n assert candidate(head = list_node([1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1])) == [1, 18]\n assert candidate(head = list_node([9, 8, 7, 6, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == [5, 5]\n assert candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6])) == [8, 8]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == [-1, -1]\n assert candidate(head = list_node([1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 101, 102, 103, 104, 105])) == [-1, -1]\n assert candidate(head = list_node([1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == [1, 14]\n assert candidate(head = list_node([1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1])) == [6, 12]\n assert candidate(head = list_node([1, 2, 3, 4, 3, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1])) == [2, 6]\n assert candidate(head = list_node([1, 3, 5, 4, 6, 7, 8, 6, 9])) == [1, 5]\n assert candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == [9, 9]\n assert candidate(head = list_node([100, 90, 100, 80, 100, 70, 100, 60, 100, 50, 100])) == [1, 8]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5])) == [4, 12]\n assert candidate(head = list_node([1, 2, 3, 2, 1, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8])) == [1, 15]\n assert candidate(head = list_node([1, 10, 2, 9, 3, 8, 4, 7, 5, 6, 5, 7, 4, 8, 3, 9, 2, 10, 1])) == [1, 16]\n assert candidate(head = list_node([1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1])) == [-1, -1]\n assert candidate(head = list_node([5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5])) == [5, 10]\n assert candidate(head = list_node([10, 20, 10, 30, 10, 40, 10, 50, 10, 60, 10, 70, 10, 80, 10, 90, 10])) == [1, 14]\n assert candidate(head = list_node([100, 200, 100, 200, 100, 200, 100, 200, 100, 200, 100, 200])) == [1, 9]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == [-1, -1]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])) == [9, 9]\n assert candidate(head = list_node([5, 4, 3, 2, 1, 2, 3, 4, 5, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])) == [5, 5]\n assert candidate(head = list_node([5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5])) == [1, 16]\n assert candidate(head = list_node([1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12])) == [1, 17]\n assert candidate(head = list_node([1, 2, 3, 4, 3, 2, 3, 4, 5, 4, 3, 2, 1])) == [2, 5]\n assert candidate(head = list_node([1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1])) == [1, 24]\n assert candidate(head = list_node([100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991])) == [-1, -1]\n assert candidate(head = list_node([1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2])) == [2, 16]\n assert candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])) == [-1, -1]\n assert candidate(head = list_node([10, 20, 30, 20, 10, 20, 30, 20, 10, 20, 30, 20, 10])) == [2, 8]\n assert candidate(head = list_node([10, 20, 30, 20, 10, 5, 15, 25, 35, 25, 15, 5, 10, 20, 30])) == [3, 9]\n assert candidate(head = list_node([5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5])) == [4, 8]\n assert candidate(head = list_node([1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2])) == [1, 17]\n assert candidate(head = list_node([1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4, 1, 3, 2, 4])) == [1, 25]\n assert candidate(head = list_node([1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7])) == [1, 10]\n assert candidate(head = list_node([1, 3, 5, 7, 9, 7, 5, 3, 1, 2, 4, 6, 8, 10, 8, 6, 4, 2])) == [4, 9]\n assert candidate(head = list_node([100000, 99999, 100001, 100002, 100000, 100003, 100001, 100004, 100002, 100005])) == [1, 7]\n assert candidate(head = list_node([1, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1])) == [1, 18]\n assert candidate(head = list_node([10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10])) == [-1, -1]\n assert candidate(head = list_node([5, 10, 5, 15, 5, 20, 5, 25, 5, 30, 5])) == [1, 8]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1])) == [4, 8]\n assert candidate(head = list_node([1, 2, 3, 2, 1, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1, 1, 2, 3, 2, 1])) == [5, 15]\n assert candidate(head = list_node([1, 2, 3, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5])) == [1, 13]\n assert candidate(head = list_node([1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14])) == [1, 12]\n assert candidate(head = list_node([100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100])) == [-1, -1]\n assert candidate(head = list_node([1, 2, 3, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1])) == [3, 6]\n assert candidate(head = list_node([5, 4, 3, 4, 5, 6, 5, 6, 7, 8, 7, 8, 9, 8, 9, 10])) == [1, 11]\n"}, "metadata": {"canonical_parameter_names": ["head"], "leetcode_dataset_entry_point": "Solution().nodesBetweenCriticalPoints", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector nodesBetweenCriticalPoints(ListNode* head) {", "container": "Solution", "callable": "nodesBetweenCriticalPoints", "parameters": [{"name": "head", "type": "ListNode*"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2059, "task_id": "minimum-operations-to-convert-number", "difficulty": "Medium", "problem_description": "You are given a 0-indexed integer array nums containing distinct numbers, an integer start, and an integer goal. There is an integer x that is initially set to start, and you want to perform operations on x such that it is converted to goal. You can perform the following operation repeatedly on the number x:\nIf 0 <= x <= 1000, then for any index i in the array (0 <= i < nums.length), you can set x to any of the following:\n\nx + nums[i]\nx - nums[i]\nx ^ nums[i] (bitwise-XOR)\n\nNote that you can use each nums[i] any number of times in any order. Operations that set x to be out of the range 0 <= x <= 1000 are valid, but no more operations can be done afterward.\nReturn the minimum number of operations needed to convert x = start into goal, and -1 if it is not possible.\n \nExample 1:\n\nInput: nums = [2,4,12], start = 2, goal = 12\nOutput: 2\nExplanation: We can go from 2 → 14 → 12 with the following 2 operations.\n- 2 + 12 = 14\n- 14 - 2 = 12\n\nExample 2:\n\nInput: nums = [3,5,7], start = 0, goal = -4\nOutput: 2\nExplanation: We can go from 0 → 3 → -4 with the following 2 operations. \n- 0 + 3 = 3\n- 3 - 7 = -4\nNote that the last operation sets x out of the range 0 <= x <= 1000, which is valid.\n\nExample 3:\n\nInput: nums = [2,8,16], start = 0, goal = 1\nOutput: -1\nExplanation: There is no way to convert 0 into 1.\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n-109 <= nums[i], goal <= 109\n0 <= start <= 1000\nstart != goal\nAll the integers in nums are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [10, 20, 30],start = 100,goal = 50) == 2\n assert candidate(nums = [1, 2, 3],start = 5,goal = 5) == 2\n assert candidate(nums = [5, 15, 25],start = 10,goal = 30) == 2\n assert candidate(nums = [10, 20, 30],start = 100,goal = 300) == 7\n assert candidate(nums = [500, 500, 500],start = 1,goal = 1001) == 2\n assert candidate(nums = [1, 3, 5, 7, 9],start = 0,goal = 10) == 2\n assert candidate(nums = [1, 3, 5, 7, 9],start = 1000,goal = 0) == 112\n assert candidate(nums = [10, 20, 30, 40, 50],start = 100,goal = 0) == 2\n assert candidate(nums = [10, 20, 30],start = 100,goal = 200) == 4\n assert candidate(nums = [500, 501, 502],start = 500,goal = 505) == 4\n assert candidate(nums = [1000, -1000, 500],start = 0,goal = 1000) == 1\n assert candidate(nums = [-1000, 1000],start = 0,goal = 0) == 2\n assert candidate(nums = [7, 14, 28],start = 1,goal = 28) == 4\n assert candidate(nums = [100, 200, 300],start = 100,goal = 1000) == 3\n assert candidate(nums = [100, 200, 300],start = 500,goal = 1000) == 2\n assert candidate(nums = [1],start = 0,goal = 1000) == 1000\n assert candidate(nums = [500, 500],start = 500,goal = 1000) == 1\n assert candidate(nums = [7, 14, 21],start = 7,goal = 0) == 1\n assert candidate(nums = [1000],start = 1000,goal = 0) == 1\n assert candidate(nums = [2, 4, 12],start = 2,goal = 12) == 2\n assert candidate(nums = [1, 1000],start = 0,goal = 1001) == 2\n assert candidate(nums = [1, 3, 5, 7, 9],start = 500,goal = 500) == 2\n assert candidate(nums = [-1, -2, -3],start = 5,goal = -5) == 1\n assert candidate(nums = [100, 200, 300],start = 500,goal = 100) == 2\n assert candidate(nums = [1, 1000],start = 500,goal = 1500) == 1\n assert candidate(nums = [3, 5, 7],start = 0,goal = -4) == 2\n assert candidate(nums = [1, 2, 3],start = 1000,goal = 0) == 334\n assert candidate(nums = [500, 500, 500],start = 100,goal = 500) == -1\n assert candidate(nums = [10, 20, 30],start = 50,goal = 110) == 2\n assert candidate(nums = [2, 8, 16],start = 0,goal = 1) == -1\n assert candidate(nums = [1000, 500, 250],start = 1,goal = 1000) == -1\n assert candidate(nums = [1, 2, 3, 4, 5],start = 1,goal = 5) == 1\n assert candidate(nums = [1, 2, 3, 4, 5],start = 5,goal = 0) == 1\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],start = 50,goal = 1000) == 10\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987],start = 1,goal = 1000) == 3\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],start = 1000,goal = 0) == 22\n assert candidate(nums = [128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768],start = 500,goal = 1000) == -1\n assert candidate(nums = [256, 512, 768, 1024],start = 0,goal = 1024) == 1\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],start = 500,goal = 1) == -1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 10,goal = 1000) == 10\n assert candidate(nums = [10, 20, 30, 40, 50],start = 1000,goal = 0) == 20\n assert candidate(nums = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],start = 500,goal = 1000) == 6\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113],start = 0,goal = 999) == 9\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],start = 10,goal = 500) == 490\n assert candidate(nums = [13, 21, 34, 55, 89, 144, 233, 377, 610, 987],start = 500,goal = 1000) == 3\n assert candidate(nums = [256, 128, 64, 32, 16, 8, 4, 2, 1],start = 500,goal = 999) == 5\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],start = 1000,goal = 0) == 18\n assert candidate(nums = [999, 1, 2, 3, 4, 5],start = 0,goal = 999) == 1\n assert candidate(nums = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048],start = 512,goal = 0) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],start = 5,goal = 100) == 10\n assert candidate(nums = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100],start = 50,goal = 999) == 10\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],start = 1,goal = 98) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],start = 100,goal = 1000) == 48\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],start = 50,goal = 1000) == 106\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],start = 500,goal = 1000) == 17\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],start = 100,goal = 256) == 3\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],start = 25,goal = 1000) == 20\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],start = 1,goal = 999) == 36\n assert candidate(nums = [10, 20, 30, 40, 50],start = 500,goal = -100) == -1\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29],start = 1,goal = 999) == 36\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47],start = 50,goal = 999) == 21\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 500,goal = 0) == 5\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31],start = 1,goal = 1000) == 33\n assert candidate(nums = [13, 19, 23, 29, 31, 37, 41, 43, 47, 53],start = 200,goal = 300) == 2\n assert candidate(nums = [1, 10, 100, 1000],start = 1,goal = 1000) == 2\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],start = 500,goal = 0) == 3\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],start = 100,goal = 1000) == 10\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41],start = 100,goal = 999) == 23\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99, 110],start = 10,goal = 1000) == 9\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],start = 1,goal = 1000) == 5\n assert candidate(nums = [1, 100, 200, 300, 400, 500, 600, 700, 800, 900],start = 0,goal = 1000) == 2\n assert candidate(nums = [333, 667, 999],start = 1,goal = 999) == 2\n assert candidate(nums = [999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008],start = 1,goal = 1000) == 1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],start = 0,goal = 1000) == 4\n assert candidate(nums = [64, 128, 256, 512],start = 100,goal = 1024) == -1\n assert candidate(nums = [2, 3, 5, 8, 13, 21, 34, 55, 89, 144],start = 10,goal = 200) == 3\n assert candidate(nums = [123, 456, 789],start = 321,goal = 654) == 2\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],start = 1000,goal = 0) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290],start = 50,goal = 1000) == 4\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],start = 500,goal = 1000) == 500\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987],start = 100,goal = 0) == 3\n assert candidate(nums = [999, 1000, 1001, 1002, 1003],start = 500,goal = 1500) == 1\n assert candidate(nums = [13, 26, 39, 52, 65, 78, 91, 104, 117, 130],start = 100,goal = 200) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 0,goal = 500) == 5\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],start = 500,goal = 1000) == 1\n assert candidate(nums = [100, 200, 300, 400, 500],start = 10,goal = 999) == -1\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29],start = 100,goal = 999) == 31\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],start = 500,goal = 1000) == 500\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],start = 1024,goal = 1) == 2\n assert candidate(nums = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110],start = 100,goal = 1000) == 9\n assert candidate(nums = [101, 202, 303, 404, 505, 606, 707, 808, 909, 1000],start = 500,goal = 1500) == 1\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],start = 100,goal = 2048) == -1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],start = 100,goal = 511) == 5\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],start = 100,goal = 99) == 1\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 50,goal = 1000) == 10\n assert candidate(nums = [123, 456, 789],start = 100,goal = 900) == 6\n assert candidate(nums = [29, 31, 37, 41, 43, 47, 53, 59, 61, 67],start = 5,goal = 1000) == 15\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],start = 50,goal = 500) == 6\n assert candidate(nums = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000],start = 1,goal = 1000000000) == 2\n assert candidate(nums = [333, 667, 999],start = 500,goal = 1000) == 6\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],start = 500,goal = 400) == 6\n assert candidate(nums = [11, 22, 33, 44, 55, 66, 77, 88, 99],start = 500,goal = 200) == 4\n assert candidate(nums = [3, 7, 11, 15, 19, 23, 27, 31, 35, 39],start = 200,goal = 500) == 8\n assert candidate(nums = [17, 18, 19, 20, 21, 22, 23, 24, 25, 26],start = 500,goal = 550) == 2\n assert candidate(nums = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],start = 1,goal = 1000) == 11\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 50,goal = 990) == 10\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],start = 100,goal = -100) == -1\n assert candidate(nums = [13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],start = 500,goal = 999) == 7\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],start = 0,goal = 500) == 10\n assert candidate(nums = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97],start = 100,goal = 1000) == 10\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],start = 50,goal = 999) == 11\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],start = 500,goal = 1024) == 3\n assert candidate(nums = [100, 200, 300, 400, 500],start = 999,goal = 1) == -1\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512],start = 512,goal = 1000) == 3\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],start = 50,goal = 150) == 1\n assert candidate(nums = [1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987],start = 50,goal = 987) == 3\n assert candidate(nums = [23, 45, 67, 89, 101],start = 100,goal = 1) == 1\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],start = 1,goal = 1000) == 200\n assert candidate(nums = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],start = 500,goal = 1024) == 3\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],start = 1,goal = 999) == 54\n assert candidate(nums = [100, 200, 300, 400, 500],start = 100,goal = 500) == 1\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],start = 500,goal = 1005) == 11\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],start = 1,goal = 1001) == 100\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],start = 1,goal = 999) == 1\n assert candidate(nums = [100, 200, 300, 400, 500],start = 50,goal = 500) == -1\n assert candidate(nums = [-1, 1, -2, 2, -4, 4, -8, 8, -16, 16],start = 500,goal = 1) == 33\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],start = 1,goal = 1000) == 999\n assert candidate(nums = [666, 333, 111, 777, 888, 999, 222, 444, 555],start = 111,goal = 777) == 1\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],start = 0,goal = 1000) == 1000\n assert candidate(nums = [-100, -50, -25, 0, 25, 50, 100],start = 50,goal = 250) == 2\n assert candidate(nums = [999, 998, 997, 996, 995, 994, 993, 992, 991, 990],start = 1,goal = 1000) == 1\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],start = 1000,goal = 1) == 50\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],start = 10,goal = 99) == 4\n assert candidate(nums = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024],start = 500,goal = 999) == 4\n"}, "metadata": {"canonical_parameter_names": ["nums", "start", "goal"], "leetcode_dataset_entry_point": "Solution().minimumOperations", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumOperations(vector& nums, int start, int goal) {", "container": "Solution", "callable": "minimumOperations", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "start", "type": "int"}, {"name": "goal", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2060, "task_id": "check-if-an-original-string-exists-given-two-encoded-strings", "difficulty": "Hard", "problem_description": "An original string, consisting of lowercase English letters, can be encoded by the following steps:\n\nArbitrarily split it into a sequence of some number of non-empty substrings.\nArbitrarily choose some elements (possibly none) of the sequence, and replace each with its length (as a numeric string).\nConcatenate the sequence as the encoded string.\n\nFor example, one way to encode an original string \"abcdefghijklmnop\" might be:\n\nSplit it as a sequence: [\"ab\", \"cdefghijklmn\", \"o\", \"p\"].\nChoose the second and third elements to be replaced by their lengths, respectively. The sequence becomes [\"ab\", \"12\", \"1\", \"p\"].\nConcatenate the elements of the sequence to get the encoded string: \"ab121p\".\n\nGiven two encoded strings s1 and s2, consisting of lowercase English letters and digits 1-9 (inclusive), return true if there exists an original string that could be encoded as both s1 and s2. Otherwise, return false.\nNote: The test cases are generated such that the number of consecutive digits in s1 and s2 does not exceed 3.\n \nExample 1:\n\nInput: s1 = \"internationalization\", s2 = \"i18n\"\nOutput: true\nExplanation: It is possible that \"internationalization\" was the original string.\n- \"internationalization\" \n -> Split: [\"internationalization\"]\n -> Do not replace any element\n -> Concatenate: \"internationalization\", which is s1.\n- \"internationalization\"\n -> Split: [\"i\", \"nternationalizatio\", \"n\"]\n -> Replace: [\"i\", \"18\", \"n\"]\n -> Concatenate: \"i18n\", which is s2\n\nExample 2:\n\nInput: s1 = \"l123e\", s2 = \"44\"\nOutput: true\nExplanation: It is possible that \"leetcode\" was the original string.\n- \"leetcode\" \n -> Split: [\"l\", \"e\", \"et\", \"cod\", \"e\"]\n -> Replace: [\"l\", \"1\", \"2\", \"3\", \"e\"]\n -> Concatenate: \"l123e\", which is s1.\n- \"leetcode\" \n -> Split: [\"leet\", \"code\"]\n -> Replace: [\"4\", \"4\"]\n -> Concatenate: \"44\", which is s2.\n\nExample 3:\n\nInput: s1 = \"a5b\", s2 = \"c5b\"\nOutput: false\nExplanation: It is impossible.\n- The original string encoded as s1 must start with the letter 'a'.\n- The original string encoded as s2 must start with the letter 'c'.\n\n \nConstraints:\n\n1 <= s1.length, s2.length <= 40\ns1 and s2 consist of digits 1-9 (inclusive), and lowercase English letters only.\nThe number of consecutive digits in s1 and s2 does not exceed 3.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(s1 = \"a1b\",s2 = \"a1b1\") == False\n assert candidate(s1 = \"ab123cd\",s2 = \"a3bcd\") == False\n assert candidate(s1 = \"ab123cd\",s2 = \"abc5\") == False\n assert candidate(s1 = \"123\",s2 = \"onetwothree\") == False\n assert candidate(s1 = \"1a\",s2 = \"a\") == False\n assert candidate(s1 = \"a9b\",s2 = \"a10b\") == False\n assert candidate(s1 = \"a1b1c1d1\",s2 = \"abcd\") == False\n assert candidate(s1 = \"a1a1a1\",s2 = \"a3a3\") == False\n assert candidate(s1 = \"a1b1\",s2 = \"ab\") == False\n assert candidate(s1 = \"a5b\",s2 = \"c5b\") == False\n assert candidate(s1 = \"abc\",s2 = \"3\") == True\n assert candidate(s1 = \"h3ll0\",s2 = \"hello\") == False\n assert candidate(s1 = \"123\",s2 = \"3\") == False\n assert candidate(s1 = \"a1b2c3\",s2 = \"a1b23c\") == True\n assert candidate(s1 = \"internationalization\",s2 = \"i18n\") == True\n assert candidate(s1 = \"a1b\",s2 = \"ab\") == False\n assert candidate(s1 = \"a1b2c3\",s2 = \"a1b5\") == False\n assert candidate(s1 = \"z1x2c3v\",s2 = \"zx9\") == False\n assert candidate(s1 = \"a1b2c3d4\",s2 = \"a1b2c34d\") == True\n assert candidate(s1 = \"1a1b1c\",s2 = \"3abc\") == False\n assert candidate(s1 = \"a\",s2 = \"1\") == True\n assert candidate(s1 = \"ab1\",s2 = \"a1b\") == True\n assert candidate(s1 = \"123\",s2 = \"321\") == True\n assert candidate(s1 = \"ab\",s2 = \"a2\") == False\n assert candidate(s1 = \"a2b\",s2 = \"aaab\") == True\n assert candidate(s1 = \"a1b1\",s2 = \"2\") == False\n assert candidate(s1 = \"a1b2c3\",s2 = \"abc6\") == False\n assert candidate(s1 = \"abc\",s2 = \"abc\") == True\n assert candidate(s1 = \"hello\",s2 = \"5\") == True\n assert candidate(s1 = \"l123e\",s2 = \"44\") == True\n assert candidate(s1 = \"123abc\",s2 = \"3abc\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"a2b2c2d2e2f2g2h2i2j2k2l2m2n2o2p2q2r2s2t2u2v2w2x2y2z26\") == False\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == False\n assert candidate(s1 = \"a5b5c5\",s2 = \"abc15\") == True\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(s1 = \"a2b2c2\",s2 = \"aabbcc\") == False\n assert candidate(s1 = \"abc12def45\",s2 = \"abcdef123\") == False\n assert candidate(s1 = \"1a2b3c4d5e6f7g8h9i\",s2 = \"abcdefghi\") == False\n assert candidate(s1 = \"x9y8z7\",s2 = \"xyz321\") == True\n assert candidate(s1 = \"a1b2c3\",s2 = \"abc123\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\",s2 = \"10abcdefghijklmnopqrstuvwxyz10abcdefghijklmnopqrstuvwxyz10\") == False\n assert candidate(s1 = \"123abc456\",s2 = \"9abc10\") == False\n assert candidate(s1 = \"a2b2c2d2e2f2g2h2i2j2k2l2m2n2o2p2q2r2s2t2u2v2w2x2y2z2\",s2 = \"abcdefghij10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\") == False\n assert candidate(s1 = \"123456\",s2 = \"654321\") == True\n assert candidate(s1 = \"abcdefghij123456789012\",s2 = \"abcdefghij123456789012\") == True\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz2\") == False\n assert candidate(s1 = \"1a2b3c4d\",s2 = \"aabbcccdddd\") == False\n assert candidate(s1 = \"1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"1abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"abcdefghijklmnopqrstuvwxyza1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\") == False\n assert candidate(s1 = \"abc12def45\",s2 = \"abcdef19\") == False\n assert candidate(s1 = \"abc1def2ghi3\",s2 = \"a1b1c1d1e1f1g1h1i1\") == False\n assert candidate(s1 = \"a1b1c1\",s2 = \"abc1\") == False\n assert candidate(s1 = \"1a2b3c4d\",s2 = \"1234abcd\") == True\n assert candidate(s1 = \"11a2b\",s2 = \"aaaaaaaaaab\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j0\",s2 = \"abcdefghij10\") == False\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"abcdefghijklmnopqrstuvwxyz1\") == False\n assert candidate(s1 = \"abcdefghij123456789\",s2 = \"abcdefghij1234567891\") == False\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == True\n assert candidate(s1 = \"a5b5c5d5e5\",s2 = \"abcde25\") == True\n assert candidate(s1 = \"a2b3c4d5e6f7g8h9i10\",s2 = \"abcdefghi10\") == False\n assert candidate(s1 = \"abcdefghij1234567890\",s2 = \"abcdefghij123456789\") == True\n assert candidate(s1 = \"1a2b3c4d5e6f7g8h9i10j11k12l13m14n15o16p17q18r19s20t21u22v23w24x25y26z27\",s2 = \"abcdefghijklmnopqrstuvwxyza27\") == False\n assert candidate(s1 = \"abc123def\",s2 = \"abc12def3\") == True\n assert candidate(s1 = \"a12b34c56\",s2 = \"a12b34c56\") == True\n assert candidate(s1 = \"l10n\",s2 = \"leetcode\") == False\n assert candidate(s1 = \"1a2b3c4d5e\",s2 = \"a1b2c3d4e5\") == True\n assert candidate(s1 = \"123abc\",s2 = \"321cba\") == False\n assert candidate(s1 = \"1a2b3c4d5e6f7g8h9i10j\",s2 = \"abcdefghij1\") == False\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"abcdefghijklmnopqrstuvwxyz26\") == False\n assert candidate(s1 = \"a4b2c3\",s2 = \"aaaaabbbccc\") == False\n assert candidate(s1 = \"a3b\",s2 = \"aaab\") == False\n assert candidate(s1 = \"a2b3c4\",s2 = \"aaabbbcccc\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6\",s2 = \"abcdefghijklmnopqrstuvwxyz123456\") == False\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"z1y1x1w1v1u1t1s1r1q1p1o1n1m1l1k1j1i1h1g1f1e1d1c1b1a1\") == False\n assert candidate(s1 = \"a2b3c\",s2 = \"aabbccc\") == False\n assert candidate(s1 = \"abc123def456ghi789\",s2 = \"abcdef789ghi123456\") == True\n assert candidate(s1 = \"a2b3c4\",s2 = \"a9\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\",s2 = \"abcdefghijklmnopqrstuvwxyz1234567890abcdefghijklmnopqrstuvwxyz1234567890\") == False\n assert candidate(s1 = \"abc123def\",s2 = \"abcdef123\") == True\n assert candidate(s1 = \"123abc\",s2 = \"12abc3\") == True\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26a1b2\",s2 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z127a1b2\") == False\n assert candidate(s1 = \"1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"abcdefghijklmnopqrstuvwxyz1\") == False\n assert candidate(s1 = \"111abc222def333\",s2 = \"333abc222def111\") == True\n assert candidate(s1 = \"abcdefghij1234567891\",s2 = \"abcdefghij123456789\") == False\n assert candidate(s1 = \"12abc\",s2 = \"a1b2c\") == True\n assert candidate(s1 = \"x1y2z3\",s2 = \"xyz123\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26a27b28c29d30\",s2 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z126a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z126a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z126a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z126\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\") == True\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"abcdefghijklmnopqrstuvwxyza1\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(s1 = \"11abc\",s2 = \"abcdefghij1\") == False\n assert candidate(s1 = \"a5b5c5\",s2 = \"aaaaabbbbbccccc\") == False\n assert candidate(s1 = \"a5b3c2d\",s2 = \"abc10d\") == True\n assert candidate(s1 = \"9z\",s2 = \"zzzzzzzzz\") == False\n assert candidate(s1 = \"a1b2c3d4e5\",s2 = \"a1b2c3d4e5\") == True\n assert candidate(s1 = \"a1b1c1\",s2 = \"a1b1c1d0\") == False\n assert candidate(s1 = \"a12b\",s2 = \"aaaaaaaaaaaaab\") == True\n assert candidate(s1 = \"abcde123fghi\",s2 = \"abcdefghi123\") == True\n assert candidate(s1 = \"1a2b3c4d5e6f7g8h9i1j2k3l4m5n6o7p8q9r1s2t3u4v5w6x7y8z9\",s2 = \"1abcdefghijklmnopqrstuvwxyza2b3c4d5e6f7g8h9i1j2k3l4m5n6o7p8q9r1s2t3u4v5w6x7y8z9\") == False\n assert candidate(s1 = \"abc123def456\",s2 = \"abcdef123456\") == True\n assert candidate(s1 = \"123abc123\",s2 = \"321cba321\") == True\n assert candidate(s1 = \"abcdefghij10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\") == False\n assert candidate(s1 = \"abcdefghij1234567891\",s2 = \"abcdefghij1234567891\") == True\n assert candidate(s1 = \"a2b3c4\",s2 = \"ab2c3d4\") == False\n assert candidate(s1 = \"123abc\",s2 = \"15c\") == False\n assert candidate(s1 = \"abc12def\",s2 = \"a15f\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26a28b29c30d31e32f33g34h35i36j37k38l39m40\",s2 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z126a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z126\") == False\n assert candidate(s1 = \"l123e\",s2 = \"leetcode\") == True\n assert candidate(s1 = \"a2b3c4d5e6f7g8h9i10j11k12l13m14n15o16p17q18r19s20t21u22v23w24x25y26z27a28b29c30d31e32f33g34h35i36j37k38l39m40\",s2 = \"abcdefghijklmnopqrstuvwxyz12345678910111213141516171819202122232425262728293031323334353637383940\") == False\n assert candidate(s1 = \"abc12def\",s2 = \"abcdefghijkl\") == False\n assert candidate(s1 = \"1234\",s2 = \"1234\") == True\n assert candidate(s1 = \"abc12\",s2 = \"ab11c\") == False\n assert candidate(s1 = \"1a2b3c4d5e6f7g8h9i10j\",s2 = \"abcdefghij10\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10\",s2 = \"abcdefghij10\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"abcdefghijklmnopqrstuvwxyz1234567891011121314151617181920212223242526\") == False\n assert candidate(s1 = \"12ab3c\",s2 = \"a1b2c3\") == True\n assert candidate(s1 = \"abc1def2ghi3jkl4mno5pqr6stu7vwx8yz9\",s2 = \"a1b2c3d4e5f6g7h8i9jklmnopqrstuvwxyz\") == False\n assert candidate(s1 = \"a1b2c3d4\",s2 = \"a111b1111c11111d111111\") == False\n assert candidate(s1 = \"a9b8c7d6e5f4g3h2i1\",s2 = \"abcdefghi123456789\") == True\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"abcdefghijklmnopqrstuvwxyz1234567891011121314151617181920212223242526abcdefghijklmnopqrstuvwxyz1234567891011121314151617181920212223242526\") == False\n assert candidate(s1 = \"abcdefghij123456789\",s2 = \"abcdefghij1234567890\") == True\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1\",s2 = \"abcdefghij\") == False\n assert candidate(s1 = \"abcde1234567890\",s2 = \"0987654321edcba\") == True\n assert candidate(s1 = \"9a8b7c6d5e4f3g2h1i0j9k8l7m6n5o4p3q2r1s0t9u8v7w6x5y4z3\",s2 = \"zyxwvutsrqponmlkjihgfedcba34567890123\") == False\n assert candidate(s1 = \"1a1b1c\",s2 = \"abc1\") == False\n assert candidate(s1 = \"abc123def456ghi789jkl012mno345pqr678stu901vwx234yz567\",s2 = \"abcdefghijklmnopqrstu901vwx234yz567jkl012mno345pqr678ghi789def456abc123\") == True\n assert candidate(s1 = \"abcd1234\",s2 = \"a3b2cd4\") == False\n assert candidate(s1 = \"a2b2c2d2e2f2g2h2i2j2k2l2m2n2o2p2q2r2s2t2u2v2w2x2y2z2\",s2 = \"abcdefghijklnmopqrstuvwxyz22\") == False\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"a2b2c2d2e2f2g2h2i2j2k2l2m2n2o2p2q2r2s2t2u2v2w2x2y2z2\") == False\n assert candidate(s1 = \"ab1cd2ef3\",s2 = \"a1b1c1d1e1f1\") == False\n assert candidate(s1 = \"l10n\",s2 = \"leet1c2d\") == False\n assert candidate(s1 = \"1a2b3c4d5e\",s2 = \"11111\") == False\n assert candidate(s1 = \"123456789\",s2 = \"abcdefghi9\") == False\n assert candidate(s1 = \"1a2b3c4d5e6f7g8h9i10\",s2 = \"abcdefghij10\") == False\n assert candidate(s1 = \"a9b\",s2 = \"aaaaaaaaaab\") == True\n assert candidate(s1 = \"l10e\",s2 = \"leetcode\") == False\n assert candidate(s1 = \"12ab34cd56\",s2 = \"15abcd\") == False\n assert candidate(s1 = \"123abc\",s2 = \"abc123\") == True\n assert candidate(s1 = \"abcdefghij12345678901234\",s2 = \"abcdefghij12345678901234\") == True\n assert candidate(s1 = \"leetcode\",s2 = \"l2e8\") == False\n assert candidate(s1 = \"a1b2c3\",s2 = \"a12b3c\") == True\n assert candidate(s1 = \"1a2b3c\",s2 = \"6\") == False\n assert candidate(s1 = \"1a2b3c4d5e6f7g8h9i10j11k12\",s2 = \"abcdefghijk11lm12\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z11a2b3c4d5e6f7g8h9i10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\") == False\n assert candidate(s1 = \"123abc456def789ghi101112\",s2 = \"123abc456def789ghi101112\") == True\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"1abcdefghijklmnopqrstuvwxyza2b3c4d5e6f7g8h9i10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\") == False\n assert candidate(s1 = \"123abc456\",s2 = \"9abc101\") == False\n assert candidate(s1 = \"a2b2c2d2e2f2g2h2i2j2k2l2m2n2o2p2q2r2s2t2u2v2w2x2y2z2\",s2 = \"a2b2c2d2e2f2g2h2i2j2k2l2m2n2o2p2q2r2s2t2u2v2w2x2y2z2\") == True\n assert candidate(s1 = \"1a2a3a4a5a6a7a8a9a\",s2 = \"aaaaaaaaaab\") == False\n assert candidate(s1 = \"abcdefghij123456789\",s2 = \"abcdefghij123456789\") == True\n assert candidate(s1 = \"a1b2c3d4\",s2 = \"abcd\") == False\n assert candidate(s1 = \"a9b9c\",s2 = \"abcdefghiabcdefghi\") == False\n assert candidate(s1 = \"abc123\",s2 = \"a1b1c123\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"z25y24x23w22v21u20t19s18r17q16p15o14n13m12l11k10j9i8h7g6f5e4d3c2b1a1\") == False\n assert candidate(s1 = \"abcdefghij123456789\",s2 = \"abcdefghij12345678\") == True\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9\",s2 = \"abcdefghi\") == False\n assert candidate(s1 = \"abc11\",s2 = \"abcdefghij1\") == False\n assert candidate(s1 = \"abcdefghij1234567890123\",s2 = \"abcdefghij1234567890123\") == True\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\",s2 = \"abcdefghijklmnopqrst1020\") == False\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1\",s2 = \"abcdefghi1\") == False\n assert candidate(s1 = \"a5b2c3\",s2 = \"aaaaaaaaabbccc\") == False\n assert candidate(s1 = \"a5b5c5d5\",s2 = \"10abcde5\") == False\n assert candidate(s1 = \"abcde123\",s2 = \"a4bcd3\") == True\n assert candidate(s1 = \"abcdefghij10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"abcdefghijklmnopqrstuvwxyz1234567891011121314151617181920212223242526\") == False\n assert candidate(s1 = \"abc123\",s2 = \"123abc\") == True\n assert candidate(s1 = \"a12b3c4\",s2 = \"a1b22c4\") == False\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz2\") == False\n assert candidate(s1 = \"a9b9c9d9e9f9g9h9i9j9k9l9m9n9o9p9q9r9s9t9u9v9w9x9y9z9\",s2 = \"aaaaaaaaabbbbbbbbcccccccccddddddddddeeeeeeeeeffffffffggggggggghhhhhhhhiiiiiiiiiijjjjjjjjjkkkkkkkkklllllllllmmmmmmmmmnnnnnnnnnoooooooooopppppppppqqqqqqqqqrrrrrrrrrssssssssstttttttttuuuuuuuuuvvvvvvvvvwwwwwwwwwxxxxxxxxxyyyyyyyyyzzzzzzzzz\") == False\n assert candidate(s1 = \"1a2b3c\",s2 = \"a1b2c3\") == True\n assert candidate(s1 = \"abc123def\",s2 = \"a1b1c3d4e5f6\") == False\n assert candidate(s1 = \"a2b3c4d5e6f7g8h9i10j11k12l13m14n15o16p17q18r19s20t21u22v23w24x25y26z27\",s2 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z127\") == False\n assert candidate(s1 = \"9a9b9c9d\",s2 = \"81abcd\") == False\n assert candidate(s1 = \"x9y9z9\",s2 = \"xxxxxxxxxxxyyyyyyyyzzzzzzzzz\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15\",s2 = \"abcdefghijklmnop123456789101112131415\") == False\n assert candidate(s1 = \"abc1def2ghi3\",s2 = \"abcdefghi\") == False\n assert candidate(s1 = \"a9b9c9\",s2 = \"aaaaaaaaabbbbbbbbcccccccccc\") == False\n assert candidate(s1 = \"abc123\",s2 = \"a1b2c3123\") == False\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"1abcdefghijklmnopqrstuvwxyz\") == False\n assert candidate(s1 = \"a1b1c\",s2 = \"abc\") == False\n assert candidate(s1 = \"abcdefghij10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z126\") == False\n assert candidate(s1 = \"a1b2c3d4\",s2 = \"abcd10\") == False\n assert candidate(s1 = \"a2b3c4d5e6f7g8h9i10j11\",s2 = \"abcdefghij10jk11\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26a1b2c3d4e5f6g7h8i9j10k11l12m13n14o15p16q17r18s19t20u21v22w23x24y25z26\",s2 = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz12345678910111213141516171819202122232425261234567891011121314151617181920212223242526\") == False\n assert candidate(s1 = \"abcdefghij12345678901\",s2 = \"abcdefghij12345678901\") == True\n assert candidate(s1 = \"a1b2c3d4e5\",s2 = \"15\") == False\n assert candidate(s1 = \"1a2b3c\",s2 = \"abc123\") == False\n assert candidate(s1 = \"ab3c\",s2 = \"abc3\") == True\n assert candidate(s1 = \"abcde12345\",s2 = \"abcde54321\") == True\n assert candidate(s1 = \"abc1def2ghi3\",s2 = \"abcdefg1h1i\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11\",s2 = \"abcdefghijk11\") == False\n assert candidate(s1 = \"a1b2c3d4e5f6g7h8i9j10k11\",s2 = \"abcdefghijk123\") == False\n assert candidate(s1 = \"abcdefghij1234567890\",s2 = \"abcdefghij1234567890\") == True\n assert candidate(s1 = \"a1b1c1d1e1f1g1h1i1j1k1l1m1n1o1p1q1r1s1t1u1v1w1x1y1z1\",s2 = \"abcdefghijklmnopqrstuvwxyz123\") == False\n assert candidate(s1 = \"a10b\",s2 = \"aaaaaaaaaab\") == False\n"}, "metadata": {"canonical_parameter_names": ["s1", "s2"], "leetcode_dataset_entry_point": "Solution().possiblyEquals", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool possiblyEquals(string s1, string s2) {", "container": "Solution", "callable": "possiblyEquals", "parameters": [{"name": "s1", "type": "string"}, {"name": "s2", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2062, "task_id": "count-vowel-substrings-of-a-string", "difficulty": "Easy", "problem_description": "A substring is a contiguous (non-empty) sequence of characters within a string.\nA vowel substring is a substring that only consists of vowels ('a', 'e', 'i', 'o', and 'u') and has all five vowels present in it.\nGiven a string word, return the number of vowel substrings in word.\n \nExample 1:\n\nInput: word = \"aeiouu\"\nOutput: 2\nExplanation: The vowel substrings of word are as follows (underlined):\n- \"aeiouu\"\n- \"aeiouu\"\n\nExample 2:\n\nInput: word = \"unicornarihan\"\nOutput: 0\nExplanation: Not all 5 vowels are present, so there are no vowel substrings.\n\nExample 3:\n\nInput: word = \"cuaieuouac\"\nOutput: 7\nExplanation: The vowel substrings of word are as follows (underlined):\n- \"cuaieuouac\"\n- \"cuaieuouac\"\n- \"cuaieuouac\"\n- \"cuaieuouac\"\n- \"cuaieuouac\"\n- \"cuaieuouac\"\n- \"cuaieuouac\"\n\n \nConstraints:\n\n1 <= word.length <= 100\nword consists of lowercase English letters only.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"aeiou\") == 1\n assert candidate(word = \"aeiofvuaeiou\") == 3\n assert candidate(word = \"uoiea\") == 1\n assert candidate(word = \"aeiouxaeeiaouoieua\") == 28\n assert candidate(word = \"aeiaaioaaaaeiiiiouuuooaauuaeiu\") == 175\n assert candidate(word = \"aeiaaioaaaaeiiiiouuuoo\") == 55\n assert candidate(word = \"aeiouaeiouaeiou\") == 66\n assert candidate(word = \"unicornarihan\") == 0\n assert candidate(word = \"aaaaaeeeeeeiiiiioooooouuuuu\") == 25\n assert candidate(word = \"aeiouu\") == 2\n assert candidate(word = \"a\") == 0\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(word = \"vowelsaeiou\") == 1\n assert candidate(word = \"cuaieuouac\") == 7\n assert candidate(word = \"aeiooauuieoiau\") == 41\n assert candidate(word = \"bcdfeioau\") == 1\n assert candidate(word = \"zzzzzaeiouzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(word = \"aeiouaeiouxyzaeiouaeiouxyzaeiou\") == 43\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 496\n assert candidate(word = \"aeiouxyzaeiouaeiou\") == 22\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 1326\n assert candidate(word = \"aeiouxyzaeiou\") == 2\n assert candidate(word = \"xyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyz\") == 63\n assert candidate(word = \"aeiouuuueeiooiaaaeeoioioiaaaeeuuuiooiiuaeiouaeiouaeiouaeiouaeiou\") == 1565\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiou\") == 231\n assert candidate(word = \"aeiouaeiouxyzaeiouaeiouxyzaeiouaeiou\") == 63\n assert candidate(word = \"uoieaueoiaueoiaueoiaueoi\") == 208\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 666\n assert candidate(word = \"aeioubcdfghjklmnpqrstvwxyzaeiou\") == 2\n assert candidate(word = \"aeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyz\") == 63\n assert candidate(word = \"aeioubaeioucaeioudeaeioufaeioubaeioucaeioudeaeioufaeioubaeioucaeioudeaeiouf\") == 15\n assert candidate(word = \"bcdaeioufghijklmnopqrstuvwxyz\") == 1\n assert candidate(word = \"aeiouwxyzaeiouwxyzaeiouwxyzaeiouwxyz\") == 4\n assert candidate(word = \"xayaioeoiuaueoieoiauiouio\") == 139\n assert candidate(word = \"aeioubaeiouaeioubaeiouxyzaeiouaeiouaeioubaeiou\") == 90\n assert candidate(word = \"aeioubaeioucaeiou\") == 3\n assert candidate(word = \"bcaeiouaeiouaieouacb\") == 77\n assert candidate(word = \"aeiouaeiouxyzaeiouaeiouxyz\") == 42\n assert candidate(word = \"aieouaeiouaieouaeiouaieouaeiouaieou\") == 490\n assert candidate(word = \"aeiouuueeiooiaaaeeoioioiaaaeeuuuiooiiu\") == 348\n assert candidate(word = \"aeioubaeiouaeioucaeiou\") == 23\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouzzzzzzzzz\") == 231\n assert candidate(word = \"aeiouxyzaeiouxyzaeiouxyzaeiouxyzaeiouxyzaeiouxyzaeiouxyzaeiouxyz\") == 8\n assert candidate(word = \"aeiouxyzzyxwvutsrqponmlkjihgfedcbaeiouaeiou\") == 22\n assert candidate(word = \"aeiouxyaeiouaeiou\") == 22\n assert candidate(word = \"aeeeeiiiioouuuaeiouaaaeioueee\") == 247\n assert candidate(word = \"aeiouxyzaeiouxyzaeiouxyzaeiouxyzaeiouxyz\") == 5\n assert candidate(word = \"aeioucaeioubaeiouaeiou\") == 23\n assert candidate(word = \"aeiouxyzaeiouxyzaeiouxyzaeiouxyzaeiou\") == 5\n assert candidate(word = \"xyzaeiouaeiouxyzaeiouaeiouxyz\") == 42\n assert candidate(word = \"mnopqrstuvwxyaeiouaeiouxyzaeiouxyzzyxwvutsrqponmlkjihgfedcbaeiou\") == 23\n assert candidate(word = \"bcaeiouc\") == 1\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 4656\n assert candidate(word = \"aeioueoiuaeiouaeioua\") == 125\n assert candidate(word = \"aabbccddeeeffgghhiijjkkllmmnnooouuupppqqrrsstttuuuvvvwwxxyyzz\") == 0\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 1081\n assert candidate(word = \"aeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyz\") == 105\n assert candidate(word = \"aeiouaeiouxxxaeiouaeiou\") == 42\n assert candidate(word = \"aebcioudfeiauoceioua\") == 2\n assert candidate(word = \"aouieaeioueaouieaeiou\") == 139\n assert candidate(word = \"aeiouaeiouabcdeiouaeiouabcdeiouaeiou\") == 64\n assert candidate(word = \"zzzzzvvvvvaeeeiioouuuaeiou\") == 44\n assert candidate(word = \"uoieaueoiaueoiaueoiaueoiaeiou\") == 317\n assert candidate(word = \"bcdfeaioueaiouaeioueaioueaiou\") == 229\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 1596\n assert candidate(word = \"ueaiaoueoiuaeiouaeiouaeiou\") == 245\n assert candidate(word = \"aeiaeiouoieiouaeiou\") == 93\n assert candidate(word = \"aeioubaeioucaeioudaeioufaeioubaeioucaeioudaeioufaeioubaeioucaeioudaeioufxyzaeioubaeioucaeioudaeioufaeioubaeioucaeioudaeiouf\") == 20\n assert candidate(word = \"uoieaueoiaueoiaueoiaueoiaeiouaeiouaeiouaeiouaeiou\") == 1027\n assert candidate(word = \"aeiooouiaeiouaeiou\") == 92\n assert candidate(word = \"aeioubaeiouaeioubaeiouxyzaeiouaeiouaeioubaeiouxyzaeiouaeioubaeiou\") == 112\n assert candidate(word = \"aabbccddeeffggahhiiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 0\n assert candidate(word = \"xyzaeiouaeiouxyz\") == 21\n assert candidate(word = \"aeioueoiuaeiouaeioueoiuaeiouaeioueoiu\") == 529\n assert candidate(word = \"zzzzzaeiouzzzzzzzzzz\") == 1\n assert candidate(word = \"zbcdefghijklmnopqrstuvwxyaeiou\") == 1\n assert candidate(word = \"bcdfgohueaioeuncdfeoiu\") == 5\n assert candidate(word = \"aeioubaeioucaeioudaeioubaeioucaeioudaeioubaeioucaeiou\") == 9\n assert candidate(word = \"xaaaeeeiiiiooooouuuuuaaaeiiiou\") == 131\n assert candidate(word = \"eiaouoieaueioaeioaeiaoueioea\") == 253\n assert candidate(word = \"aeiouaeiouaeiouxyzaeiouaeiouaeiouxyzaeiouaeiou\") == 153\n assert candidate(word = \"aeiouxyzaeiouxyzaeiouxyz\") == 3\n assert candidate(word = \"mnopqrstuvwxyaeiouaeiouxyz\") == 21\n assert candidate(word = \"aeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyz\") == 84\n assert candidate(word = \"xyzaeiouaeiouaeiouaeiouaeiouaeiouxyz\") == 351\n assert candidate(word = \"baeiouaeiouaeiouaeiouaeiou\") == 231\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 0\n assert candidate(word = \"aeioubaeioucaeioudeaeiouf\") == 5\n assert candidate(word = \"oiueaeiouaeiouaeiouaeiouaeiouaeiou\") == 461\n assert candidate(word = \"aeioubaeiouaeiouaeiouaeiou\") == 137\n assert candidate(word = \"zzzzzaeiouzzzzz\") == 1\n assert candidate(word = \"baeioucaeiouaeioucb\") == 22\n assert candidate(word = \"eiouaeioua\") == 21\n assert candidate(word = \"aeioubaeiouaeioubaeiou\") == 23\n assert candidate(word = \"xyzabcdeioufghijklmnopqrstuvwaeiou\") == 1\n assert candidate(word = \"aeiouaeeeeeiioouuuuuaeiou\") == 146\n assert candidate(word = \"abcdeioua\") == 1\n assert candidate(word = \"aeioubaeioucaeioudeaeioufaeioubaeioucaeioudeaeiouf\") == 10\n assert candidate(word = \"aeioueaioueaioueaioueaioueaiou\") == 350\n assert candidate(word = \"aeioubaeiouaeioubaeiouaeiou\") == 43\n assert candidate(word = \"aeiouaeiouaebcdeaeiouaeiou\") == 63\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouaeiou\") == 351\n assert candidate(word = \"aeiouaeiouaeiouaeiou\") == 136\n assert candidate(word = \"xyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiou\") == 84\n assert candidate(word = \"aeiouzyxwvutsrqponmlkjihgfedcbaeiou\") == 2\n assert candidate(word = \"aeiouzzzzzzzzzzzzzzzzzzzz\") == 1\n assert candidate(word = \"aeiouxyzzyxwvutsrqponmlkjihgfedcbaeiouaeiouaeiouxyzaeiouxyzzyxwvutsrqponmlkjihgfedcbaeiou\") == 69\n assert candidate(word = \"eiouaeiouaeiouaeiouaeiouaeiou\") == 325\n assert candidate(word = \"aeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyzaeiouaeiouxyz\") == 147\n assert candidate(word = \"xzaeiouaeiouaeiouaeiouaeioux\") == 231\n"}, "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().countVowelSubstrings", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countVowelSubstrings(string word) {", "container": "Solution", "callable": "countVowelSubstrings", "parameters": [{"name": "word", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2063, "task_id": "vowels-of-all-substrings", "difficulty": "Medium", "problem_description": "Given a string word, return the sum of the number of vowels ('a', 'e', 'i', 'o', and 'u') in every substring of word.\nA substring is a contiguous (non-empty) sequence of characters within a string.\nNote: Due to the large constraints, the answer may not fit in a signed 32-bit integer. Please be careful during the calculations.\n \nExample 1:\n\nInput: word = \"aba\"\nOutput: 6\nExplanation: \nAll possible substrings are: \"a\", \"ab\", \"aba\", \"b\", \"ba\", and \"a\".\n- \"b\" has 0 vowels in it\n- \"a\", \"ab\", \"ba\", and \"a\" have 1 vowel each\n- \"aba\" has 2 vowels in it\nHence, the total sum of vowels = 0 + 1 + 1 + 1 + 1 + 2 = 6. \n\nExample 2:\n\nInput: word = \"abc\"\nOutput: 3\nExplanation: \nAll possible substrings are: \"a\", \"ab\", \"abc\", \"b\", \"bc\", and \"c\".\n- \"a\", \"ab\", and \"abc\" have 1 vowel each\n- \"b\", \"bc\", and \"c\" have 0 vowels each\nHence, the total sum of vowels = 1 + 1 + 1 + 0 + 0 + 0 = 3.\n\nExample 3:\n\nInput: word = \"ltcd\"\nOutput: 0\nExplanation: There are no vowels in any substring of \"ltcd\".\n\n \nConstraints:\n\n1 <= word.length <= 105\nword consists of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word = \"e\") == 1\n assert candidate(word = \"aeiou\") == 35\n assert candidate(word = \"abc\") == 3\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(word = \"aeiaaioaaaaeiiiiouuuooaauuaeiuiauuuuaeioaaaaeaiaioieoieiieoioioieouieiiaiaeiieoieouuiooaoaaiiaeiieeiooieiei\") == 209934\n assert candidate(word = \"bcbcbcbcbc\") == 0\n assert candidate(word = \"aeiaaioaaaaeiiiiouuuooaauuaeiu\") == 4960\n assert candidate(word = \"aeiaaioaaaaeiiiiouuuooaauuaeiuiaoiuuaeiuuaieiiaaaeeiuuoiuuuuuuu\") == 43680\n assert candidate(word = \"ltcd\") == 0\n assert candidate(word = \"aba\") == 6\n assert candidate(word = \"u\") == 1\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyz\") == 604\n assert candidate(word = \"a\") == 1\n assert candidate(word = \"o\") == 1\n assert candidate(word = \"b\") == 0\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(word = \"i\") == 1\n assert candidate(word = \"\") == 0\n assert candidate(word = \"bbaaeekkeeaabbaaeekkeeaabbaaeekkeeaabb\") == 6576\n assert candidate(word = \"uvijqet\") == 34\n assert candidate(word = \"aieouaeiouaeiouaeiouaeiouaeiouaeiouaeiouaeiou\") == 16215\n assert candidate(word = \"uuygqijetbvrcw\") == 150\n assert candidate(word = \"mississippi\") == 98\n assert candidate(word = \"vowels\") == 22\n assert candidate(word = \"aeiouaeiouaeiou\") == 680\n assert candidate(word = \"abcdefghijabcdefghijabcdefghijabcdefghij\") == 3412\n assert candidate(word = \"cccccdcccc\") == 0\n assert candidate(word = \"aovnwqoeirqoweoirqoweoirquw\") == 1949\n assert candidate(word = \"congratulations\") == 299\n assert candidate(word = \"xyzaeiouxyzaeiouxyz\") == 820\n assert candidate(word = \"bcbcbcbcbcbcbcbcbcbc\") == 0\n assert candidate(word = \"vvvuuuooooiiiaaaaeeeee\") == 1900\n assert candidate(word = \"consonants\") == 76\n assert candidate(word = \"vowelvowelvowel\") == 278\n assert candidate(word = \"supercalifragilisticexpialidocious\") == 3282\n assert candidate(word = \"aquickbrownfoxjumpsoverthelazydog\") == 2016\n assert candidate(word = \"leetcode\") == 58\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzzyxwvutsrqponmlkjihgfedcba\") == 3860\n assert candidate(word = \"sequence\") == 62\n assert candidate(word = \"aovvoaoaueuioeaueoaiouaoieaouioeaouioiea\") == 11218\n assert candidate(word = \"aeeee\") == 35\n assert candidate(word = \"aeioouaeiou\") == 286\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(word = \"bbbbbbbbbbbbbbbbbbbbbbba\") == 24\n assert candidate(word = \"hello\") == 13\n assert candidate(word = \"uoiea\") == 35\n assert candidate(word = \"bcdfghjklmnpqrstvwxyz\") == 0\n assert candidate(word = \"ffaaabbbccc\") == 94\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiou\") == 2925\n assert candidate(word = \"qweoiauoieqweoiauoieqweoiauoie\") == 4016\n assert candidate(word = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == 4562\n assert candidate(word = \"rhythms\") == 0\n assert candidate(word = \"bbbbbebbbb\") == 30\n assert candidate(word = \"aabbccddeeeffgg\") == 221\n assert candidate(word = \"beautiful\") == 101\n assert candidate(word = \"aeiouaeiouaeiouaeiouaeiouaeiou\") == 4960\n assert candidate(word = \"dddddeoeddd\") == 103\n assert candidate(word = \"aeiouaeiouaeiouaeiou\") == 1540\n assert candidate(word = \"vowel\") == 16\n assert candidate(word = \"xylophone\") == 54\n assert candidate(word = \"repetitiveeeee\") == 350\n assert candidate(word = \"repetition\") == 118\n assert candidate(word = \"characters\") == 78\n assert candidate(word = \"uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu\") == 13244\n assert candidate(word = \"uvaeiouz\") == 98\n assert candidate(word = \"aovylqjwhepfuciphg\") == 280\n assert candidate(word = \"uoieaoueioauoiea\") == 816\n assert candidate(word = \"zzzzzzzzzzz\") == 0\n assert candidate(word = \"eeeeeaeeee\") == 220\n assert candidate(word = \"aaaaabaaaaa\") == 250\n assert candidate(word = \"abacaxabayabac\") == 280\n assert candidate(word = \"aeiouaeiou\") == 220\n assert candidate(word = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == 0\n assert candidate(word = \"programming\") == 90\n assert candidate(word = \"aeiaoeiaoeiaoeiaoeiaoeiaoeiaoeiaoeiaoei\") == 10660\n assert candidate(word = \"ouqofyrcjgz\") == 63\n assert candidate(word = \"aeiaeaieaa\") == 220\n assert candidate(word = \"vowelsarefun\") == 158\n assert candidate(word = \"abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz\") == 4718\n"}, "metadata": {"canonical_parameter_names": ["word"], "leetcode_dataset_entry_point": "Solution().countVowels", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long countVowels(string word) {", "container": "Solution", "callable": "countVowels", "parameters": [{"name": "word", "type": "string"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2064, "task_id": "minimized-maximum-of-products-distributed-to-any-store", "difficulty": "Medium", "problem_description": "You are given an integer n indicating there are n specialty retail stores. There are m product types of varying amounts, which are given as a 0-indexed integer array quantities, where quantities[i] represents the number of products of the ith product type.\nYou need to distribute all products to the retail stores following these rules:\n\nA store can only be given at most one product type but can be given any amount of it.\nAfter distribution, each store will have been given some number of products (possibly 0). Let x represent the maximum number of products given to any store. You want x to be as small as possible, i.e., you want to minimize the maximum number of products that are given to any store.\n\nReturn the minimum possible x.\n \nExample 1:\n\nInput: n = 6, quantities = [11,6]\nOutput: 3\nExplanation: One optimal way is:\n- The 11 products of type 0 are distributed to the first four stores in these amounts: 2, 3, 3, 3\n- The 6 products of type 1 are distributed to the other two stores in these amounts: 3, 3\nThe maximum number of products given to any store is max(2, 3, 3, 3, 3, 3) = 3.\n\nExample 2:\n\nInput: n = 7, quantities = [15,10,10]\nOutput: 5\nExplanation: One optimal way is:\n- The 15 products of type 0 are distributed to the first three stores in these amounts: 5, 5, 5\n- The 10 products of type 1 are distributed to the next two stores in these amounts: 5, 5\n- The 10 products of type 2 are distributed to the last two stores in these amounts: 5, 5\nThe maximum number of products given to any store is max(5, 5, 5, 5, 5, 5, 5) = 5.\n\nExample 3:\n\nInput: n = 1, quantities = [100000]\nOutput: 100000\nExplanation: The only optimal way is:\n- The 100000 products of type 0 are distributed to the only store.\nThe maximum number of products given to any store is max(100000) = 100000.\n\n \nConstraints:\n\nm == quantities.length\n1 <= m <= n <= 105\n1 <= quantities[i] <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 5,quantities = [10, 20, 30, 40, 50]) == 50\n assert candidate(n = 3,quantities = [100, 100, 100]) == 100\n assert candidate(n = 10,quantities = [1, 1, 1, 1, 1, 1, 1, 1, 1, 100000]) == 100000\n assert candidate(n = 3,quantities = [1, 100000]) == 50000\n assert candidate(n = 2,quantities = [50000, 50000]) == 50000\n assert candidate(n = 50000,quantities = [1, 2, 3, 4, 5]) == 1\n assert candidate(n = 10,quantities = [100000, 1, 100000, 1, 100000, 1, 100000, 1, 100000, 1]) == 100000\n assert candidate(n = 2,quantities = [100000, 100000]) == 100000\n assert candidate(n = 7,quantities = [15, 10, 10]) == 5\n assert candidate(n = 10,quantities = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]) == 10\n assert candidate(n = 5,quantities = [10, 10, 10, 10, 10]) == 10\n assert candidate(n = 5,quantities = [1, 1, 1, 1, 1]) == 1\n assert candidate(n = 6,quantities = [11, 6]) == 3\n assert candidate(n = 5,quantities = [1, 2, 3, 4, 5]) == 5\n assert candidate(n = 100000,quantities = [1]) == 1\n assert candidate(n = 10,quantities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(n = 50000,quantities = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 4\n assert candidate(n = 50000,quantities = [100000, 100000]) == 4\n assert candidate(n = 100,quantities = [100000]) == 1000\n assert candidate(n = 10,quantities = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1\n assert candidate(n = 3,quantities = [50, 50, 50]) == 50\n assert candidate(n = 2,quantities = [100, 1]) == 100\n assert candidate(n = 3,quantities = [100, 200, 300]) == 300\n assert candidate(n = 1,quantities = [100000]) == 100000\n assert candidate(n = 100000,quantities = [100000]) == 1\n assert candidate(n = 8,quantities = [12, 24, 36, 48, 60, 72, 84, 96]) == 96\n assert candidate(n = 95000,quantities = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000, 130000, 140000, 150000, 160000, 170000, 180000, 190000, 200000]) == 23\n assert candidate(n = 100000,quantities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1\n assert candidate(n = 80000,quantities = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000]) == 2\n assert candidate(n = 50000,quantities = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1\n assert candidate(n = 100000,quantities = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195]) == 2\n assert candidate(n = 9,quantities = [10, 100, 1000, 10000, 100000, 100, 10, 1, 1000000]) == 1000000\n assert candidate(n = 75000,quantities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 1\n assert candidate(n = 100000,quantities = [10000, 20000, 30000, 40000, 50000]) == 2\n assert candidate(n = 45000,quantities = [50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000, 50000]) == 35\n assert candidate(n = 15000,quantities = [50000, 40000, 30000, 20000, 10000]) == 10\n assert candidate(n = 80000,quantities = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000]) == 1\n assert candidate(n = 20000,quantities = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500]) == 1\n assert candidate(n = 90000,quantities = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3, 1]) == 3\n assert candidate(n = 10,quantities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 10\n assert candidate(n = 40000,quantities = [500, 499, 498, 497, 496, 495, 494, 493, 492, 491, 490, 489, 488, 487, 486, 485, 484, 483, 482, 481, 480, 479, 478, 477, 476, 475, 474, 473, 472, 471, 470]) == 1\n assert candidate(n = 100000,quantities = [100000, 50000, 30000, 20000, 10000]) == 3\n assert candidate(n = 40000,quantities = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 1\n assert candidate(n = 30000,quantities = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500]) == 2\n assert candidate(n = 50000,quantities = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999]) == 20\n assert candidate(n = 30000,quantities = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000]) == 6\n assert candidate(n = 60000,quantities = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980]) == 34\n assert candidate(n = 10,quantities = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 500\n assert candidate(n = 60000,quantities = [15000, 15000, 15000, 15000, 15000, 15000]) == 2\n assert candidate(n = 99999,quantities = [100000, 99999, 99998, 99997, 99996, 99995]) == 7\n assert candidate(n = 1,quantities = [1000000]) == 1000000\n assert candidate(n = 80000,quantities = [1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019]) == 1\n assert candidate(n = 6,quantities = [10, 20, 30, 40, 50, 60]) == 60\n assert candidate(n = 15,quantities = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 150\n assert candidate(n = 90000,quantities = [90000, 100, 200, 300, 400, 500, 600, 700, 800]) == 2\n assert candidate(n = 7,quantities = [5, 15, 25, 35, 45, 55, 65]) == 65\n assert candidate(n = 10,quantities = [1000, 2000, 3000, 4000, 5000]) == 2000\n assert candidate(n = 50000,quantities = [1, 10, 100, 1000, 10000, 100000]) == 3\n assert candidate(n = 100000,quantities = [10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000, 10000]) == 4\n assert candidate(n = 30000,quantities = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000]) == 8\n assert candidate(n = 20000,quantities = [500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500]) == 1\n assert candidate(n = 40000,quantities = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 14\n assert candidate(n = 75000,quantities = [99999, 1, 2, 3, 4, 5]) == 2\n assert candidate(n = 50000,quantities = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512]) == 1\n assert candidate(n = 45000,quantities = [45000, 22500, 15000, 11250, 9000]) == 3\n assert candidate(n = 25000,quantities = [10000, 20000, 30000, 40000, 50000]) == 7\n assert candidate(n = 50000,quantities = [10000, 15000, 20000, 25000, 30000]) == 2\n assert candidate(n = 100000,quantities = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 1\n assert candidate(n = 90000,quantities = [9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000, 9000]) == 2\n assert candidate(n = 10000,quantities = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000]) == 22\n assert candidate(n = 75000,quantities = [20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000]) == 3\n assert candidate(n = 100000,quantities = [50000, 50000, 50000, 50000]) == 2\n assert candidate(n = 90000,quantities = [1, 10, 100, 1000, 10000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 17\n assert candidate(n = 99999,quantities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1\n assert candidate(n = 50000,quantities = [25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000, 25000]) == 5\n assert candidate(n = 50000,quantities = [100000]) == 2\n assert candidate(n = 75000,quantities = [75000, 75000, 75000, 75000, 75000, 75000, 75000, 75000, 75000, 75000]) == 10\n assert candidate(n = 60000,quantities = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000]) == 10\n assert candidate(n = 50000,quantities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 1\n assert candidate(n = 100000,quantities = [100000, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2\n assert candidate(n = 50000,quantities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1\n assert candidate(n = 20,quantities = [15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110]) == 110\n assert candidate(n = 10000,quantities = [10000, 9999, 9998, 9997, 9996, 9995, 9994, 9993, 9992, 9991]) == 10\n assert candidate(n = 30000,quantities = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024]) == 1\n assert candidate(n = 80000,quantities = [5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000, 5000]) == 1\n assert candidate(n = 55000,quantities = [10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000, 110000, 120000, 130000, 140000, 150000]) == 22\n assert candidate(n = 45000,quantities = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980]) == 45\n assert candidate(n = 1,quantities = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 1000000\n assert candidate(n = 90000,quantities = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1\n assert candidate(n = 3,quantities = [99999, 99999, 99999]) == 99999\n assert candidate(n = 60000,quantities = [1, 10, 100, 1000, 10000, 100000]) == 2\n assert candidate(n = 55000,quantities = [77777, 88888, 99999, 111111, 222222, 333333, 444444]) == 26\n assert candidate(n = 55000,quantities = [150000, 125000, 100000, 75000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 11\n assert candidate(n = 60000,quantities = [99999, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 2\n assert candidate(n = 60000,quantities = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999]) == 34\n assert candidate(n = 80000,quantities = [8000, 8001, 8002, 8003, 8004, 8005, 8006, 8007, 8008, 8009]) == 2\n assert candidate(n = 50000,quantities = [100000, 200000, 300000, 400000]) == 20\n assert candidate(n = 20000,quantities = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]) == 100\n assert candidate(n = 30000,quantities = [30000, 30001, 30002, 30003, 30004, 30005, 30006, 30007, 30008, 30009, 30010, 30011, 30012, 30013, 30014, 30015, 30016, 30017, 30018, 30019]) == 21\n assert candidate(n = 100000,quantities = [50000, 50000, 50000, 50000, 50000]) == 3\n assert candidate(n = 100000,quantities = [10000, 15000, 20000, 25000, 30000]) == 1\n assert candidate(n = 75000,quantities = [12345, 67890, 11111, 22222, 33333, 44444, 55555]) == 4\n assert candidate(n = 50000,quantities = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1\n assert candidate(n = 30000,quantities = [9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999, 9999]) == 11\n assert candidate(n = 25000,quantities = [50000, 100000, 150000, 200000, 250000, 300000]) == 43\n assert candidate(n = 100,quantities = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]) == 20\n assert candidate(n = 80000,quantities = [20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000, 20000]) == 17\n assert candidate(n = 25000,quantities = [200000, 150000, 100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3, 1]) == 23\n"}, "metadata": {"canonical_parameter_names": ["n", "quantities"], "leetcode_dataset_entry_point": "Solution().minimizedMaximum", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimizedMaximum(int n, vector& quantities) {", "container": "Solution", "callable": "minimizedMaximum", "parameters": [{"name": "n", "type": "int"}, {"name": "quantities", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2065, "task_id": "maximum-path-quality-of-a-graph", "difficulty": "Hard", "problem_description": "There is an undirected graph with n nodes numbered from 0 to n - 1 (inclusive). You are given a 0-indexed integer array values where values[i] is the value of the ith node. You are also given a 0-indexed 2D integer array edges, where each edges[j] = [uj, vj, timej] indicates that there is an undirected edge between the nodes uj and vj, and it takes timej seconds to travel between the two nodes. Finally, you are given an integer maxTime.\nA valid path in the graph is any path that starts at node 0, ends at node 0, and takes at most maxTime seconds to complete. You may visit the same node multiple times. The quality of a valid path is the sum of the values of the unique nodes visited in the path (each node's value is added at most once to the sum).\nReturn the maximum quality of a valid path.\nNote: There are at most four edges connected to each node.\n \nExample 1:\n\n\nInput: values = [0,32,10,43], edges = [[0,1,10],[1,2,15],[0,3,10]], maxTime = 49\nOutput: 75\nExplanation:\nOne possible path is 0 -> 1 -> 0 -> 3 -> 0. The total time taken is 10 + 10 + 10 + 10 = 40 <= 49.\nThe nodes visited are 0, 1, and 3, giving a maximal path quality of 0 + 32 + 43 = 75.\n\nExample 2:\n\n\nInput: values = [5,10,15,20], edges = [[0,1,10],[1,2,10],[0,3,10]], maxTime = 30\nOutput: 25\nExplanation:\nOne possible path is 0 -> 3 -> 0. The total time taken is 10 + 10 = 20 <= 30.\nThe nodes visited are 0 and 3, giving a maximal path quality of 5 + 20 = 25.\n\nExample 3:\n\n\nInput: values = [1,2,3,4], edges = [[0,1,10],[1,2,11],[2,3,12],[1,3,13]], maxTime = 50\nOutput: 7\nExplanation:\nOne possible path is 0 -> 1 -> 3 -> 1 -> 0. The total time taken is 10 + 13 + 13 + 10 = 46 <= 50.\nThe nodes visited are 0, 1, and 3, giving a maximal path quality of 1 + 2 + 4 = 7.\n\n \nConstraints:\n\nn == values.length\n1 <= n <= 1000\n0 <= values[i] <= 108\n0 <= edges.length <= 2000\nedges[j].length == 3 \n0 <= uj < vj <= n - 1\n10 <= timej, maxTime <= 100\nAll the pairs [uj, vj] are unique.\nThere are at most four edges connected to each node.\nThe graph may not be connected.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(values = [10, 20, 30, 40, 50],edges = [[0, 1, 10], [0, 2, 20], [1, 3, 30], [2, 4, 40]],maxTime = 100) == 70\n assert candidate(values = [100, 200, 300, 400],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 0, 10]],maxTime = 50) == 1000\n assert candidate(values = [5, 5, 5, 5, 5],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 0, 10]],maxTime = 40) == 15\n assert candidate(values = [5, 5, 5, 5],edges = [[0, 1, 10], [0, 2, 10], [2, 3, 10]],maxTime = 25) == 10\n assert candidate(values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 5, 10], [4, 6, 10], [5, 7, 10], [6, 8, 10], [7, 9, 10]],maxTime = 50) == 3\n assert candidate(values = [1, 2, 3, 4, 5],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10]],maxTime = 20) == 4\n assert candidate(values = [1, 1, 1, 1, 1],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10]],maxTime = 40) == 3\n assert candidate(values = [5, 10, 15, 20],edges = [[0, 1, 10], [1, 2, 10], [0, 3, 10]],maxTime = 30) == 25\n assert candidate(values = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [1, 5, 10], [2, 6, 10], [3, 7, 10], [4, 8, 10], [5, 9, 10]],maxTime = 100) == 27\n assert candidate(values = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10]],maxTime = 90) == 25\n assert candidate(values = [5, 5, 5, 5, 5, 5],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10]],maxTime = 30) == 10\n assert candidate(values = [10, 20, 30, 40, 50],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10]],maxTime = 50) == 90\n assert candidate(values = [5, 5, 5, 5],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 3, 10]],maxTime = 30) == 10\n assert candidate(values = [1, 2, 3, 4],edges = [[0, 1, 10], [1, 2, 11], [2, 3, 12], [1, 3, 13]],maxTime = 50) == 7\n assert candidate(values = [10, 20, 30, 40, 50],edges = [[0, 1, 10], [0, 2, 20], [1, 3, 15], [2, 3, 25], [3, 4, 10]],maxTime = 60) == 70\n assert candidate(values = [1, 2, 3, 4],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10]],maxTime = 10) == 1\n assert candidate(values = [1, 2, 3, 4, 5, 6],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10]],maxTime = 60) == 12\n assert candidate(values = [0, 32, 10, 43],edges = [[0, 1, 10], [1, 2, 15], [0, 3, 10]],maxTime = 49) == 75\n assert candidate(values = [10, 20, 30],edges = [[0, 1, 10], [1, 2, 10]],maxTime = 25) == 30\n assert candidate(values = [10, 20, 30],edges = [[0, 1, 10], [1, 2, 20]],maxTime = 30) == 30\n assert candidate(values = [10, 20, 30, 40, 50],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 0, 10]],maxTime = 50) == 150\n assert candidate(values = [10],edges = [],maxTime = 100) == 10\n assert candidate(values = [100, 0, 0, 0],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10]],maxTime = 10) == 100\n assert candidate(values = [100, 50, 200, 300, 150, 250, 400],edges = [[0, 1, 20], [0, 2, 30], [0, 3, 40], [1, 4, 10], [1, 5, 20], [2, 6, 30], [3, 6, 40], [4, 5, 50], [5, 6, 60]],maxTime = 120) == 700\n assert candidate(values = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 5, 10], [4, 6, 10], [5, 7, 10], [6, 8, 10], [7, 9, 10], [8, 9, 10]],maxTime = 80) == 2500\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 8, 10], [5, 9, 10], [6, 7, 10], [6, 8, 10], [7, 8, 10], [7, 9, 10], [8, 9, 10]],maxTime = 50) == 110\n assert candidate(values = [10, 10, 10, 10, 10],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [1, 2, 10], [1, 3, 10], [1, 4, 10], [2, 3, 10], [2, 4, 10], [3, 4, 10]],maxTime = 40) == 40\n assert candidate(values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [1, 5, 10], [1, 6, 10], [1, 7, 10], [2, 8, 10], [2, 9, 10], [3, 10, 10], [3, 11, 10], [4, 12, 10], [4, 13, 10], [5, 14, 10], [5, 15, 10], [6, 16, 10], [6, 17, 10], [7, 18, 10], [7, 19, 10], [8, 14, 10], [8, 15, 10], [9, 16, 10], [9, 17, 10], [10, 18, 10], [10, 19, 10], [11, 14, 10], [11, 15, 10], [12, 16, 10], [12, 17, 10], [13, 18, 10], [13, 19, 10]],maxTime = 100) == 10\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120],edges = [[0, 1, 10], [0, 2, 20], [1, 3, 15], [2, 4, 25], [3, 5, 10], [4, 6, 15], [5, 7, 20], [6, 8, 10], [7, 9, 15], [8, 10, 20], [9, 11, 10]],maxTime = 120) == 210\n assert candidate(values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 7, 10], [5, 8, 10], [6, 8, 10], [7, 9, 10], [8, 9, 10]],maxTime = 80) == 8\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 0, 10], [0, 2, 15], [1, 3, 15], [2, 4, 15], [3, 5, 15], [4, 6, 15], [5, 7, 15], [6, 8, 15], [7, 9, 15], [8, 0, 15], [9, 1, 15]],maxTime = 150) == 550\n assert candidate(values = [5, 10, 15, 20, 25, 30, 35],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 0, 10]],maxTime = 50) == 70\n assert candidate(values = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10]],maxTime = 55) == 600\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 5, 10], [4, 6, 10], [5, 7, 10], [6, 8, 10], [7, 9, 10]],maxTime = 50) == 9\n assert candidate(values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [1, 2, 10], [1, 3, 10], [1, 4, 10], [2, 3, 10], [2, 4, 10], [3, 4, 10]],maxTime = 100) == 5\n assert candidate(values = [10, 20, 30, 40, 50, 60],edges = [[0, 1, 10], [0, 2, 10], [1, 2, 15], [1, 3, 20], [2, 4, 25], [3, 4, 30], [4, 5, 15]],maxTime = 70) == 90\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 5, 10], [4, 6, 10], [5, 7, 10], [6, 8, 10], [7, 9, 10], [8, 0, 10]],maxTime = 90) == 310\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 8, 10], [5, 9, 10], [6, 7, 10], [6, 8, 10], [7, 8, 10], [8, 9, 10], [0, 3, 10], [0, 4, 10], [1, 5, 10], [2, 7, 10], [3, 8, 10], [4, 9, 10], [5, 6, 10]],maxTime = 60) == 37\n assert candidate(values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [3, 8, 10], [4, 9, 10], [4, 10, 10], [5, 11, 10], [5, 12, 10], [6, 13, 10], [6, 14, 10], [7, 15, 10], [7, 16, 10], [8, 17, 10], [8, 18, 10], [9, 19, 10]],maxTime = 150) == 8\n assert candidate(values = [1, 2, 3, 4, 5],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 4, 10]],maxTime = 40) == 9\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 5, 10], [4, 6, 10], [5, 7, 10], [6, 8, 10], [7, 9, 10]],maxTime = 100) == 310\n assert candidate(values = [100, 200, 100, 200, 100, 200, 100, 200],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 7, 10]],maxTime = 50) == 500\n assert candidate(values = [50, 20, 30, 40],edges = [[0, 1, 10], [0, 2, 20], [0, 3, 30], [1, 2, 15], [1, 3, 25], [2, 3, 10]],maxTime = 40) == 80\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [1, 2, 10], [1, 3, 10], [1, 4, 10], [2, 3, 10], [2, 4, 10], [3, 4, 10]],maxTime = 35) == 100\n assert candidate(values = [5, 10, 15, 20, 25, 30],edges = [[0, 1, 10], [1, 2, 15], [2, 3, 20], [3, 4, 25], [4, 5, 30], [0, 3, 35], [1, 4, 40]],maxTime = 100) == 50\n assert candidate(values = [5, 10, 15, 20, 25, 30, 35, 40],edges = [[0, 1, 10], [1, 2, 15], [2, 3, 20], [3, 4, 25], [4, 5, 30], [5, 6, 35], [6, 7, 40], [0, 7, 10]],maxTime = 100) == 80\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 8, 10], [5, 9, 10]],maxTime = 80) == 27\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 0, 10]],maxTime = 50) == 20\n assert candidate(values = [30, 20, 10, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 0, 10], [0, 5, 10], [1, 6, 10], [2, 7, 10], [3, 8, 10], [4, 9, 10]],maxTime = 150) == 550\n assert candidate(values = [30, 20, 10, 40, 50],edges = [[0, 1, 10], [0, 2, 15], [0, 3, 20], [0, 4, 25], [1, 2, 5], [1, 3, 15], [1, 4, 25], [2, 3, 10], [2, 4, 20], [3, 4, 5]],maxTime = 60) == 150\n assert candidate(values = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10], [14, 15, 10], [15, 16, 10], [16, 17, 10], [17, 18, 10], [18, 19, 10]],maxTime = 190) == 275\n assert candidate(values = [9, 8, 7, 6, 5, 4, 3, 2, 1],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [1, 4, 10], [1, 5, 10], [2, 6, 10], [2, 7, 10], [3, 8, 10], [4, 8, 10], [5, 6, 10]],maxTime = 60) == 31\n assert candidate(values = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],edges = [[0, 1, 10], [1, 2, 10], [0, 3, 10], [3, 4, 10], [2, 5, 10], [5, 6, 10], [4, 7, 10], [7, 8, 10], [6, 9, 10]],maxTime = 100) == 145\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 15], [0, 2, 20], [1, 3, 25], [2, 4, 30], [3, 5, 35], [4, 6, 40], [5, 7, 45], [6, 8, 50], [7, 9, 55], [8, 9, 60]],maxTime = 150) == 13\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [1, 4, 10], [1, 5, 10], [2, 6, 10], [2, 7, 10], [3, 8, 10], [3, 9, 10]],maxTime = 50) == 150\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10], [14, 0, 10]],maxTime = 140) == 850\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 7, 10], [5, 8, 10], [6, 8, 10], [7, 9, 10], [8, 9, 10]],maxTime = 100) == 510\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],edges = [[0, 1, 10], [1, 2, 15], [2, 3, 20], [3, 4, 25], [4, 5, 10], [5, 6, 30], [6, 7, 10], [7, 8, 25], [8, 9, 20], [9, 10, 15], [10, 11, 20], [11, 12, 15], [12, 13, 10], [13, 14, 30]],maxTime = 200) == 210\n assert candidate(values = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 0, 10]],maxTime = 90) == 3500\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [1, 5, 10], [1, 6, 10], [2, 7, 10], [2, 8, 10], [3, 9, 10], [3, 10, 10], [4, 11, 10], [4, 12, 10], [5, 13, 10], [6, 14, 10], [7, 15, 10], [8, 16, 10], [9, 17, 10], [10, 18, 10], [11, 19, 10], [12, 13, 10], [14, 15, 10], [16, 17, 10], [18, 19, 10]],maxTime = 150) == 142\n assert candidate(values = [100, 200, 300, 400, 500],edges = [[0, 1, 20], [0, 2, 30], [1, 3, 25], [2, 4, 35], [3, 4, 40]],maxTime = 150) == 1500\n assert candidate(values = [50, 60, 70, 80, 90, 100, 110, 120, 130, 140],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 7, 10], [5, 8, 10], [6, 8, 10], [7, 9, 10], [8, 9, 10], [3, 4, 15], [5, 6, 15]],maxTime = 120) == 950\n assert candidate(values = [100, 200, 300, 400, 500],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 0, 10]],maxTime = 50) == 1500\n assert candidate(values = [50, 20, 10, 30, 40, 60],edges = [[0, 1, 10], [1, 2, 15], [1, 3, 20], [2, 3, 25], [3, 4, 10], [4, 5, 30]],maxTime = 100) == 150\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 3, 10], [3, 4, 10], [1, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 1, 10]],maxTime = 60) == 22\n assert candidate(values = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 8, 10], [5, 9, 10], [6, 7, 10], [6, 8, 10], [7, 8, 10]],maxTime = 100) == 40\n assert candidate(values = [5, 10, 15, 20, 25, 30],edges = [[0, 1, 10], [1, 2, 15], [2, 3, 20], [3, 4, 25], [4, 5, 30], [0, 5, 35]],maxTime = 70) == 35\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10]],maxTime = 90) == 15\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 7, 10], [5, 8, 10], [6, 8, 10], [7, 9, 10], [8, 9, 10], [0, 3, 30], [1, 5, 30], [2, 4, 30]],maxTime = 90) == 450\n assert candidate(values = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1, 10], [0, 2, 15], [1, 3, 20], [2, 4, 25], [3, 5, 10], [4, 6, 30], [5, 7, 10], [6, 8, 25], [7, 9, 20]],maxTime = 150) == 3100\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [1, 5, 10], [2, 6, 10], [3, 7, 10], [4, 8, 10], [5, 9, 10], [6, 9, 10], [7, 9, 10], [8, 9, 10]],maxTime = 50) == 15\n assert candidate(values = [100000000, 200000000, 300000000, 400000000],edges = [[0, 1, 20], [1, 2, 30], [2, 3, 25], [3, 0, 35]],maxTime = 100) == 600000000\n assert candidate(values = [50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 20], [1, 3, 15], [2, 3, 25], [3, 4, 10], [4, 5, 15]],maxTime = 100) == 380\n assert candidate(values = [100, 200, 300, 400, 500],edges = [[0, 1, 20], [1, 2, 30], [2, 3, 25], [3, 4, 35], [4, 0, 40]],maxTime = 120) == 800\n assert candidate(values = [10, 20, 30, 40, 50],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 0, 10], [1, 3, 15], [2, 4, 20]],maxTime = 50) == 150\n assert candidate(values = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 7, 10], [5, 8, 10], [6, 8, 10], [7, 9, 10], [8, 9, 10], [0, 5, 20], [1, 6, 20], [2, 7, 20], [3, 8, 20], [4, 9, 20]],maxTime = 120) == 275\n assert candidate(values = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [4, 8, 10], [5, 9, 10], [6, 7, 10], [6, 8, 10], [7, 8, 10], [8, 9, 10], [0, 3, 10], [0, 4, 10], [1, 5, 10], [2, 7, 10], [3, 8, 10], [4, 9, 10], [5, 6, 10], [0, 5, 10], [1, 6, 10], [2, 3, 10], [3, 9, 10], [4, 5, 10], [6, 9, 10], [7, 9, 10]],maxTime = 100) == 5500\n assert candidate(values = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10], [14, 15, 10]],maxTime = 150) == 40\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10], [14, 0, 10]],maxTime = 150) == 1180\n assert candidate(values = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [0, 5, 10], [0, 6, 10], [0, 7, 10], [0, 8, 10], [0, 9, 10], [1, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10], [14, 15, 10], [15, 16, 10], [16, 17, 10], [17, 18, 10], [18, 19, 10]],maxTime = 50) == 3\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [1, 4, 10], [2, 5, 10], [2, 6, 10], [3, 7, 10], [3, 8, 10], [4, 9, 10], [5, 6, 10], [7, 8, 10], [8, 9, 10]],maxTime = 90) == 390\n assert candidate(values = [100, 200, 300, 400, 500],edges = [[0, 1, 20], [0, 2, 20], [1, 3, 20], [2, 3, 20], [3, 4, 20], [1, 2, 20]],maxTime = 80) == 1000\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 0, 10]],maxTime = 90) == 350\n assert candidate(values = [8, 6, 7, 5, 3, 0, 9],edges = [[0, 1, 15], [1, 2, 20], [2, 3, 25], [3, 4, 30], [4, 5, 35], [5, 6, 40], [6, 0, 45]],maxTime = 100) == 21\n assert candidate(values = [5, 10, 15, 20, 25, 30],edges = [[0, 1, 10], [1, 2, 15], [2, 3, 20], [3, 4, 25], [4, 5, 30], [0, 5, 10]],maxTime = 100) == 70\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],edges = [[0, 1, 10], [0, 2, 10], [1, 3, 10], [2, 4, 10], [3, 5, 10], [4, 6, 10], [5, 7, 10], [6, 8, 10], [7, 9, 10], [9, 0, 10]],maxTime = 100) == 390\n assert candidate(values = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],edges = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10]],maxTime = 150) == 360\n assert candidate(values = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],edges = [[0, 1, 10], [0, 9, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10]],maxTime = 80) == 35\n assert candidate(values = [10, 20, 30, 40, 50],edges = [[0, 1, 10], [0, 2, 10], [0, 3, 10], [0, 4, 10], [1, 2, 10], [1, 3, 10], [1, 4, 10], [2, 3, 10], [2, 4, 10], [3, 4, 10]],maxTime = 30) == 100\n"}, "metadata": {"canonical_parameter_names": ["values", "edges", "maxTime"], "leetcode_dataset_entry_point": "Solution().maximalPathQuality", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximalPathQuality(vector& values, vector>& edges, int maxTime) {", "container": "Solution", "callable": "maximalPathQuality", "parameters": [{"name": "values", "type": "vector&"}, {"name": "edges", "type": "vector>&"}, {"name": "maxTime", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2068, "task_id": "check-whether-two-strings-are-almost-equivalent", "difficulty": "Easy", "problem_description": "Two strings word1 and word2 are considered almost equivalent if the differences between the frequencies of each letter from 'a' to 'z' between word1 and word2 is at most 3.\nGiven two strings word1 and word2, each of length n, return true if word1 and word2 are almost equivalent, or false otherwise.\nThe frequency of a letter x is the number of times it occurs in the string.\n \nExample 1:\n\nInput: word1 = \"aaaa\", word2 = \"bccb\"\nOutput: false\nExplanation: There are 4 'a's in \"aaaa\" but 0 'a's in \"bccb\".\nThe difference is 4, which is more than the allowed 3.\n\nExample 2:\n\nInput: word1 = \"abcdeef\", word2 = \"abaaacc\"\nOutput: true\nExplanation: The differences between the frequencies of each letter in word1 and word2 are at most 3:\n- 'a' appears 1 time in word1 and 4 times in word2. The difference is 3.\n- 'b' appears 1 time in word1 and 1 time in word2. The difference is 0.\n- 'c' appears 1 time in word1 and 2 times in word2. The difference is 1.\n- 'd' appears 1 time in word1 and 0 times in word2. The difference is 1.\n- 'e' appears 2 times in word1 and 0 times in word2. The difference is 2.\n- 'f' appears 1 time in word1 and 0 times in word2. The difference is 1.\n\nExample 3:\n\nInput: word1 = \"cccddabba\", word2 = \"babababab\"\nOutput: true\nExplanation: The differences between the frequencies of each letter in word1 and word2 are at most 3:\n- 'a' appears 2 times in word1 and 4 times in word2. The difference is 2.\n- 'b' appears 2 times in word1 and 5 times in word2. The difference is 3.\n- 'c' appears 3 times in word1 and 0 times in word2. The difference is 3.\n- 'd' appears 2 times in word1 and 0 times in word2. The difference is 2.\n\n \nConstraints:\n\nn == word1.length == word2.length\n1 <= n <= 100\nword1 and word2 consist only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(word1 = \"cccddabba\",word2 = \"babababab\") == True\n assert candidate(word1 = \"aaa\",word2 = \"bbb\") == True\n assert candidate(word1 = \"aabbcc\",word2 = \"ccbbaa\") == True\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(word1 = \"pqrstu\",word2 = \"utsrpq\") == True\n assert candidate(word1 = \"mnop\",word2 = \"ponm\") == True\n assert candidate(word1 = \"abcabcabc\",word2 = \"bcbcbcbcb\") == True\n assert candidate(word1 = \"aaaa\",word2 = \"bccb\") == False\n assert candidate(word1 = \"xyz\",word2 = \"zyx\") == True\n assert candidate(word1 = \"abcdeef\",word2 = \"abaaacc\") == True\n assert candidate(word1 = \"abc\",word2 = \"abc\") == True\n assert candidate(word1 = \"hello\",word2 = \"world\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggeeffddccbbaa\") == True\n assert candidate(word1 = \"abcabcabc\",word2 = \"abcabcabc\") == True\n assert candidate(word1 = \"zzzz\",word2 = \"zzzz\") == True\n assert candidate(word1 = \"aabbcc\",word2 = \"bbccdd\") == True\n assert candidate(word1 = \"abc\",word2 = \"xyz\") == True\n assert candidate(word1 = \"zzz\",word2 = \"zzz\") == True\n assert candidate(word1 = \"aabbcc\",word2 = \"abcabc\") == True\n assert candidate(word1 = \"abcdef\",word2 = \"fedcba\") == True\n assert candidate(word1 = \"aabbcc\",word2 = \"abc\") == True\n assert candidate(word1 = \"abcd\",word2 = \"dcba\") == True\n assert candidate(word1 = \"abc\",word2 = \"def\") == True\n assert candidate(word1 = \"abcdefg\",word2 = \"gfedcba\") == True\n assert candidate(word1 = \"almostequivalent\",word2 = \"equivalentalmost\") == True\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"zyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(word1 = \"abacabadabacabad\",word2 = \"babaabacabacabac\") == True\n assert candidate(word1 = \"abcdefghijl\",word2 = \"abcdefghijllll\") == True\n assert candidate(word1 = \"aabbaabbaabb\",word2 = \"bbaabbaabbab\") == True\n assert candidate(word1 = \"hello world\",word2 = \"world hello\") == True\n assert candidate(word1 = \"frequency\",word2 = \"requeency\") == True\n assert candidate(word1 = \"aaaabbbbccccddddeeeffffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz\",word2 = \"zzzyyyxxxwwvvvuuuutttsssrqqqpppoonnmmlllkkkjjjiiihhhgggfffffeeedddccccbbbbaaaa\") == True\n assert candidate(word1 = \"xyzxyzxyzxyzxyz\",word2 = \"zyxzyxzyxzyxzyx\") == True\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzxxwwvvttrrppoonnmmllkkjjiihhggeeddbbccaabb\") == True\n assert candidate(word1 = \"mississippi\",word2 = \"ssipimisip\") == True\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzza\") == True\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyz\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == False\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzzzyyyxxxwwvvuuttrrssqqpponnmlkkjjiihhggffeeddccbbaa\") == True\n assert candidate(word1 = \"xyzxyzxyzxyzxyzxyz\",word2 = \"xyzxyzxyzxyzxyzxyx\") == True\n assert candidate(word1 = \"xylophone\",word2 = \"polyxhnon\") == True\n assert candidate(word1 = \"almost\",word2 = \"almosttttt\") == False\n assert candidate(word1 = \"aaaabbbb\",word2 = \"bbbbaaaa\") == True\n assert candidate(word1 = \"almostequivalent\",word2 = \"almostequivalen\") == True\n assert candidate(word1 = \"testtesttest\",word2 = \"setttestsett\") == True\n assert candidate(word1 = \"abcdefghij\",word2 = \"jihgfedcba\") == True\n assert candidate(word1 = \"aaaaabbbbcccc\",word2 = \"bbbbbccccddddd\") == False\n assert candidate(word1 = \"aaabbbccc\",word2 = \"bbcccaaa\") == True\n assert candidate(word1 = \"abababababababababababababababababababab\",word2 = \"babababababababababababababababababababaa\") == True\n assert candidate(word1 = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnoooo\",word2 = \"bbbbaaaaccccddddeeeeffffgggghhhhiiiijjjjkkkkllllmmmmnnnnooo\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzxxwvwuvttsrqpqponmlkjihgfedcbazyxwvutsrqponmlkjihgfedcba\") == True\n assert candidate(word1 = \"banana\",word2 = \"nanaba\") == True\n assert candidate(word1 = \"python\",word2 = \"pythooon\") == True\n assert candidate(word1 = \"abacabadabacabad\",word2 = \"bacadabacadaba\") == True\n assert candidate(word1 = \"almostequivalent\",word2 = \"quivalentalmosta\") == True\n assert candidate(word1 = \"frequency\",word2 = \"frequncey\") == True\n assert candidate(word1 = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq\",word2 = \"qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqz\") == True\n assert candidate(word1 = \"frequencycheck\",word2 = \"checkfrequency\") == True\n assert candidate(word1 = \"aabbbcccddddeee\",word2 = \"eeeeddddccccbbbbaaa\") == True\n assert candidate(word1 = \"abracadabra\",word2 = \"alakazam\") == True\n assert candidate(word1 = \"aabbbccc\",word2 = \"bbaaccdd\") == True\n assert candidate(word1 = \"abcdefghijlll\",word2 = \"abcdefghijllll\") == True\n assert candidate(word1 = \"abcdefghijabcdefghij\",word2 = \"abcdefghijabcdefghii\") == True\n assert candidate(word1 = \"ppppqqqqrrrrssss\",word2 = \"ttttuuuuvvvv\") == False\n assert candidate(word1 = \"abababababababab\",word2 = \"babababababababa\") == True\n assert candidate(word1 = \"aaaaaaaabbbbbbbbbbcccccccccc\",word2 = \"ccccccccccbbbbbbbbbbaaaaaaaabbbb\") == False\n assert candidate(word1 = \"aaabbbccc\",word2 = \"bbbaacccd\") == True\n assert candidate(word1 = \"abcabcabcabc\",word2 = \"bcbcbcbcbcbc\") == False\n assert candidate(word1 = \"mississippi\",word2 = \"pississim\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzxxwwvvttrrssqqppoonnmmllkkjjiihhggffeeddccbbaa\") == True\n assert candidate(word1 = \"aaaaabbbbccccdddd\",word2 = \"bbbbbccccddddaaaaa\") == True\n assert candidate(word1 = \"xylophone\",word2 = \"polynomial\") == True\n assert candidate(word1 = \"aaaabbbbcccc\",word2 = \"cccbbbbaaa\") == True\n assert candidate(word1 = \"asdfghjkl\",word2 = \"lkjhgfdsa\") == True\n assert candidate(word1 = \"hello\",word2 = \"yellow\") == True\n assert candidate(word1 = \"almostequivalent\",word2 = \"quivalentalmost\") == True\n assert candidate(word1 = \"abcdefghij\",word2 = \"abcdefghijk\") == True\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"acabacabacababa\") == True\n assert candidate(word1 = \"abcdefgabcdefgabcdefgabcdefg\",word2 = \"gfedcbagfedcbagfedcbagfedcb\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzxxwwvvttrrqqppoonnmmllkkjjiihhggeeffeeddccbbaa\") == True\n assert candidate(word1 = \"hellothere\",word2 = \"heellooerr\") == True\n assert candidate(word1 = \"abcdeffghijklmnopqrstuvwxyz\",word2 = \"mnopqrstuvwxyzabcdefghijkl\") == True\n assert candidate(word1 = \"abcabcabc\",word2 = \"bcabcbac\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"abcdefghijklmnopqrstuvwxyz\") == True\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(word1 = \"equaldiffffe\",word2 = \"equaldifffff\") == True\n assert candidate(word1 = \"racecar\",word2 = \"carrace\") == True\n assert candidate(word1 = \"mississippi\",word2 = \"bississippi\") == True\n assert candidate(word1 = \"abacabadabacabad\",word2 = \"abcabcabcabc\") == False\n assert candidate(word1 = \"aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkk\",word2 = \"ffffgggghhhhiiiijjjjkkkkaaaabbbbccccddddeeee\") == True\n assert candidate(word1 = \"abcdefg\",word2 = \"ghfedcba\") == True\n assert candidate(word1 = \"pythonprogramming\",word2 = \"programmingpython\") == True\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(word1 = \"abcdabcdabcdabcdabcdabcd\",word2 = \"abcdabcdabcdabcdabcdabc\") == True\n assert candidate(word1 = \"abcdefghijk\",word2 = \"abcdefghijl\") == True\n assert candidate(word1 = \"aaaaaaaaaaa\",word2 = \"bbbbbbbbbbb\") == False\n assert candidate(word1 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\",word2 = \"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == True\n assert candidate(word1 = \"ababababababababababababababababababababab\",word2 = \"bababababababababababababababababababababa\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == True\n assert candidate(word1 = \"aabbbcccddd\",word2 = \"aaabbbcc\") == True\n assert candidate(word1 = \"mississippi\",word2 = \"ssissippi\") == True\n assert candidate(word1 = \"programming\",word2 = \"mmprogain\") == True\n assert candidate(word1 = \"aaabbbccc\",word2 = \"bbbaaacc\") == True\n assert candidate(word1 = \"aaaaabbbbcccccddddd\",word2 = \"aaabbbcccdddd\") == True\n assert candidate(word1 = \"banana\",word2 = \"ananaa\") == True\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"cbacabacabacabc\") == True\n assert candidate(word1 = \"abcabcabcabc\",word2 = \"bcdbcdabcdabcd\") == False\n assert candidate(word1 = \"aaaaaaaabbbbbbbccccccdddddeeeeeffffff\",word2 = \"ffffffeeeeeee/ddddddccccbbbbbbaaaaaa\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == True\n assert candidate(word1 = \"abcdabcdabcdabcd\",word2 = \"bcdbcdbcdbcdbcdb\") == False\n assert candidate(word1 = \"abcdabcdabcdabcd\",word2 = \"dcbaabcdabcdabcd\") == True\n assert candidate(word1 = \"abcdefghij\",word2 = \"abcdefghix\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzyyxxwwvvuuttsrqpponnml lkjihgfedcba\") == True\n assert candidate(word1 = \"abcdefghi\",word2 = \"ihgfedcba\") == True\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyza\",word2 = \"bcdefghijklmnopqrstuvwxyzzz\") == True\n assert candidate(word1 = \"frequency\",word2 = \"frequnecy\") == True\n assert candidate(word1 = \"aaabbbcccddd\",word2 = \"aaaabbbbccccdddd\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\") == True\n assert candidate(word1 = \"abcde\",word2 = \"fghij\") == True\n assert candidate(word1 = \"abcabcabcabcabc\",word2 = \"bcbcbcbcbcbcb\") == False\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\") == False\n assert candidate(word1 = \"abcdabcdabcdabcd\",word2 = \"abcdeabcdeabcdeabcde\") == False\n assert candidate(word1 = \"abcdefghijklmnopqrstuvwxyzz\",word2 = \"abcdefghijklmnopqrstuvwxyyz\") == True\n assert candidate(word1 = \"aabbbcccdddee\",word2 = \"eeedddcccbbaa\") == True\n assert candidate(word1 = \"uvwxyz\",word2 = \"vwxyz\") == True\n assert candidate(word1 = \"aaaaabbbbccccc\",word2 = \"bbbaaaaaccccc\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzzzyyyxxwwvvuuttssrrqqppoonnmmllkkjjiihhggffeeddccbbaa\") == True\n assert candidate(word1 = \"pythonprogramming\",word2 = \"rogrammingpython\") == True\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"abacabadabacaba\") == True\n assert candidate(word1 = \"aaaaaabbbbbbccccccdddddeeeeee\",word2 = \"eeeeeeaaaaaabbbbbbccccccddddde\") == True\n assert candidate(word1 = \"abcabcabcabcabc\",word2 = \"cccbbbbaaaabcabc\") == True\n assert candidate(word1 = \"aabbccddeeffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz\",word2 = \"zzyyxxwwvvuuttrrssqqppoonnmlkkjjiihhggffeeddccbbaa\") == True\n assert candidate(word1 = \"abacabadabacaba\",word2 = \"abcabcabcabcabc\") == True\n assert candidate(word1 = \"qwerasdfzxcv\",word2 = \"asdfzxcvqwer\") == True\n assert candidate(word1 = \"mnopqr\",word2 = \"mnopqz\") == True\n assert candidate(word1 = \"mnopqr\",word2 = \"rqponm\") == True\n assert candidate(word1 = \"abcdefg\",word2 = \"ghijklm\") == True\n assert candidate(word1 = \"abcdefghijllll\",word2 = \"abcdefghijlll\") == True\n assert candidate(word1 = \"aaaaaaaaabbbbbbbbbbccccccccccdddddddddeeeeeeeeeeffffffffffgggggggggghhhhhhhhhhiiiiiiiiiijjjjjjjjjjkkkkkkkkkkllllllllllmmmmmmmmmmnnnnnnnnnnooooooooooppppppppppqqqqqqqqqqrrrrrrrrrrssssssssssttttttttttuuuuuuuuuuvvvvvvvvvvwwwwwwwwwwxxxxxxxxxxxyyyyyyyyyyzzzzzzzzzz\",word2 = \"zzzzzzzzzzyyyyyyyyyyxxxxxxxxxxwwwwwwwwwwvvvvvvvvvvuuuuuuuuuuttttttttttssssssssssrrrrrrrrrrqqqqqqqqqqpppppppppooooooooollllllllllkkkkkkkkkkjjjjjjjjjiiiiiiiiiijjjjjjjjjjhhhhhhhhhhhggggggggggffffffffeeeeeeeeeeeeddddddddddccccccccccbbbbbbbbbbbbaaaaaaaaaa\") == False\n assert candidate(word1 = \"abcdabcdabcd\",word2 = \"dcbaefghefgh\") == True\n assert candidate(word1 = \"mississippi\",word2 = \"missiisssipp\") == True\n assert candidate(word1 = \"aaaabbbbccccdddd\",word2 = \"bbbaaaacccddde\") == True\n assert candidate(word1 = \"qwert\",word2 = \"qwerty\") == True\n assert candidate(word1 = \"aaaabbbbcccc\",word2 = \"ddddeeeeffff\") == False\n assert candidate(word1 = \"programming\",word2 = \"grammipnorg\") == True\n assert candidate(word1 = \"aaaabbbbccccdddd\",word2 = \"ddddccccbbbbaaaa\") == True\n assert candidate(word1 = \"aabccddeeff\",word2 = \"abccddeeffggh\") == True\n"}, "metadata": {"canonical_parameter_names": ["word1", "word2"], "leetcode_dataset_entry_point": "Solution().checkAlmostEquivalent", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "bool checkAlmostEquivalent(string word1, string word2) {", "container": "Solution", "callable": "checkAlmostEquivalent", "parameters": [{"name": "word1", "type": "string"}, {"name": "word2", "type": "string"}], "return_type": "bool", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2070, "task_id": "most-beautiful-item-for-each-query", "difficulty": "Medium", "problem_description": "You are given a 2D integer array items where items[i] = [pricei, beautyi] denotes the price and beauty of an item respectively.\nYou are also given a 0-indexed integer array queries. For each queries[j], you want to determine the maximum beauty of an item whose price is less than or equal to queries[j]. If no such item exists, then the answer to this query is 0.\nReturn an array answer of the same length as queries where answer[j] is the answer to the jth query.\n \nExample 1:\n\nInput: items = [[1,2],[3,2],[2,4],[5,6],[3,5]], queries = [1,2,3,4,5,6]\nOutput: [2,4,5,5,6,6]\nExplanation:\n- For queries[0]=1, [1,2] is the only item which has price <= 1. Hence, the answer for this query is 2.\n- For queries[1]=2, the items which can be considered are [1,2] and [2,4]. \n The maximum beauty among them is 4.\n- For queries[2]=3 and queries[3]=4, the items which can be considered are [1,2], [3,2], [2,4], and [3,5].\n The maximum beauty among them is 5.\n- For queries[4]=5 and queries[5]=6, all items can be considered.\n Hence, the answer for them is the maximum beauty of all items, i.e., 6.\n\nExample 2:\n\nInput: items = [[1,2],[1,2],[1,3],[1,4]], queries = [1]\nOutput: [4]\nExplanation: \nThe price of every item is equal to 1, so we choose the item with the maximum beauty 4. \nNote that multiple items can have the same price and/or beauty. \n\nExample 3:\n\nInput: items = [[10,1000]], queries = [5]\nOutput: [0]\nExplanation:\nNo item has a price less than or equal to 5, so no item can be chosen.\nHence, the answer to the query is 0.\n\n \nConstraints:\n\n1 <= items.length, queries.length <= 105\nitems[i].length == 2\n1 <= pricei, beautyi, queries[j] <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(items = [[10, 1000]],queries = [5]) == [0]\n assert candidate(items = [[100, 5], [50, 4], [200, 3], [150, 2], [300, 1]],queries = [50, 100, 150, 200, 250, 300]) == [4, 5, 5, 5, 5, 5]\n assert candidate(items = [[1, 5], [2, 9], [3, 12], [4, 15], [5, 18]],queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [5, 12, 18, 18, 18, 18, 18, 18, 18, 18]\n assert candidate(items = [[5, 10], [4, 4], [6, 8], [7, 12]],queries = [3, 5, 7, 10]) == [0, 10, 12, 12]\n assert candidate(items = [[5, 10], [3, 5], [10, 15], [1, 1]],queries = [3, 7, 10]) == [5, 10, 15]\n assert candidate(items = [[1, 2], [1, 2], [1, 3], [1, 4]],queries = [1]) == [4]\n assert candidate(items = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1]],queries = [1, 2, 3, 4, 5, 6]) == [5, 5, 5, 5, 5, 5]\n assert candidate(items = [[5, 1], [3, 2], [7, 4], [2, 3]],queries = [8, 6, 4, 2, 1]) == [4, 3, 3, 3, 0]\n assert candidate(items = [[1, 2], [3, 2], [2, 4], [5, 6], [3, 5]],queries = [1, 2, 3, 4, 5, 6]) == [2, 4, 5, 5, 6, 6]\n assert candidate(items = [[5, 10], [7, 15], [8, 20]],queries = [6, 9, 12]) == [10, 20, 20]\n assert candidate(items = [[100, 1], [99, 2], [98, 3], [97, 4], [96, 5]],queries = [96, 97, 98, 99, 100]) == [5, 5, 5, 5, 5]\n assert candidate(items = [[5, 1], [3, 2], [7, 4], [2, 6], [9, 8]],queries = [1, 3, 5, 7, 9, 11]) == [0, 6, 6, 6, 8, 8]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [5, 4, 3, 2, 1]) == [5, 4, 3, 2, 1]\n assert candidate(items = [[2, 3], [5, 5], [6, 7], [8, 8]],queries = [1, 4, 6, 9]) == [0, 3, 7, 8]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],queries = [1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]\n assert candidate(items = [[1, 1], [2, 3], [2, 5], [3, 4], [3, 6], [4, 7], [4, 8], [5, 9]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [1, 5, 6, 8, 9, 9, 9, 9, 9]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[10, 100], [20, 200], [30, 300], [40, 400], [50, 500], [60, 600], [70, 700], [80, 800], [90, 900], [100, 1000]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(items = [[5, 5], [5, 6], [5, 7], [5, 8], [5, 9], [5, 10]],queries = [4, 5, 6]) == [0, 10, 10]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55]) == [5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 2], [1, 3], [1, 4], [1, 5], [1, 6]],queries = [1, 1, 1, 1, 1]) == [6, 6, 6, 6, 6]\n assert candidate(items = [[1, 1000], [1, 900], [1, 800], [1, 700], [1, 600], [1, 500], [1, 400], [1, 300], [1, 200], [1, 100]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]\n assert candidate(items = [[1, 10], [2, 15], [3, 5], [4, 20], [5, 10], [6, 25], [7, 30], [8, 20], [9, 5], [10, 15]],queries = [1, 3, 5, 7, 9, 10]) == [10, 15, 20, 30, 30, 30]\n assert candidate(items = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == [100, 100, 100, 100, 100, 100, 100, 100, 100, 100]\n assert candidate(items = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1000000000, 1000000000]],queries = [500000000, 1000000000, 1500000000]) == [0, 1000000000, 1000000000]\n assert candidate(items = [[1, 1000], [2, 900], [3, 800], [4, 700], [5, 600]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000]\n assert candidate(items = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105]) == [0, 10, 10, 20, 20, 30, 30, 40, 40, 50, 50, 60, 60, 70, 70, 80, 80, 90, 90, 100, 100]\n assert candidate(items = [[1, 100], [10, 200], [100, 300], [1000, 400], [10000, 500]],queries = [1, 5, 50, 500, 5000, 50000, 100000]) == [100, 100, 200, 300, 400, 500, 500]\n assert candidate(items = [[2, 2], [2, 3], [2, 4], [2, 5], [2, 6], [2, 7], [2, 8], [2, 9], [2, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500], [600, 600], [700, 700], [800, 800], [900, 900], [1000, 1000]],queries = [99, 199, 299, 399, 499, 599, 699, 799, 899, 999, 1001]) == [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [1, 3, 5, 7, 9, 11]) == [1, 3, 5, 7, 9, 10]\n assert candidate(items = [[5, 5], [10, 10], [15, 15], [20, 20], [25, 25], [30, 30], [35, 35], [40, 40], [45, 45], [50, 50]],queries = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == [0, 0, 5, 5, 10, 10, 10, 15, 15, 20]\n assert candidate(items = [[50, 100], [25, 200], [75, 150], [100, 250], [125, 300]],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130]) == [0, 0, 200, 200, 200, 200, 200, 200, 200, 250, 250, 250, 300]\n assert candidate(items = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5]],queries = [10]) == [5]\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n assert candidate(items = [[1, 50], [2, 40], [3, 30], [4, 20], [5, 10], [6, 5]],queries = [0, 1, 2, 3, 4, 5, 6, 7]) == [0, 50, 50, 50, 50, 50, 50, 50]\n assert candidate(items = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [10, 60], [15, 70], [20, 80], [25, 90], [30, 100]],queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31]) == [10, 30, 50, 50, 50, 60, 60, 70, 70, 70, 80, 80, 90, 90, 90, 100]\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(items = [[10, 1], [10, 2], [10, 3], [10, 4], [10, 5]],queries = [5, 10, 15]) == [0, 5, 5]\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(items = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10]],queries = [5, 4, 3, 2, 1]) == [10, 10, 10, 10, 10]\n assert candidate(items = [[1, 10], [10, 1], [100, 100], [1000, 1], [10000, 10000], [100000, 1], [1000000, 1000000]],queries = [1, 5, 10, 50, 100, 500, 1000, 5000, 10000, 50000, 100000, 500000, 1000000, 1500000]) == [10, 10, 10, 10, 100, 100, 100, 100, 10000, 10000, 10000, 10000, 1000000, 1000000]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[100, 500], [200, 1000], [300, 1500], [400, 2000], [500, 2500]],queries = [50, 150, 250, 350, 450, 550]) == [0, 500, 1000, 1500, 2000, 2500]\n assert candidate(items = [[1, 10], [3, 20], [2, 30], [5, 40], [4, 50]],queries = [1, 2, 3, 4, 5]) == [10, 30, 30, 50, 50]\n assert candidate(items = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],queries = [1]) == [10]\n assert candidate(items = [[5, 1], [4, 2], [3, 3], [2, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19]],queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [1, 5, 9, 13, 17, 19, 19, 19, 19, 19]\n assert candidate(items = [[1, 20], [2, 19], [3, 18], [4, 17], [5, 16], [6, 15], [7, 14], [8, 13], [9, 12], [10, 11]],queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(items = [[1, 5], [2, 4], [3, 3], [4, 2], [5, 1], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10], [1, 11], [1, 12], [1, 13], [1, 14], [1, 15]],queries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15]\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105]) == [0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]\n assert candidate(items = [[1, 1], [10, 2], [100, 3], [1000, 4], [10000, 5], [100000, 6], [1000000, 7], [10000000, 8], [100000000, 9], [1000000000, 10]],queries = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == [5, 6, 7, 8, 9, 10, 10, 10, 10, 10]\n assert candidate(items = [[10, 5], [20, 4], [30, 3], [40, 2], [50, 1]],queries = [15, 25, 35, 45, 55]) == [5, 5, 5, 5, 5]\n assert candidate(items = [[1, 2], [2, 4], [3, 6], [4, 8], [5, 10]],queries = [6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(items = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],queries = [1]) == [10]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]) == [5, 4, 3, 2, 1, 10, 9, 8, 7, 6]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]],queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21]) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 20]\n assert candidate(items = [[1, 10], [10, 20], [100, 30], [1000, 40], [10000, 5], [100000, 6], [1000000, 7], [10000000, 8], [100000000, 9], [1000000000, 10]],queries = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]) == [10, 20, 30, 40, 40, 40, 40, 40, 40, 40]\n assert candidate(items = [[10, 100], [20, 200], [30, 300], [40, 400], [50, 500]],queries = [5, 15, 25, 35, 45, 55]) == [0, 100, 200, 300, 400, 500]\n assert candidate(items = [[100, 100], [200, 200], [300, 300], [400, 400], [500, 500]],queries = [50, 150, 250, 350, 450, 550]) == [0, 100, 200, 300, 400, 500]\n assert candidate(items = [[1, 100], [50, 50], [100, 10], [150, 1], [200, 50], [250, 100], [300, 150], [350, 200], [400, 250], [450, 300]],queries = [25, 50, 75, 125, 175, 225, 275, 325, 375, 425]) == [100, 100, 100, 100, 100, 100, 100, 150, 200, 250]\n assert candidate(items = [[1, 1000000000], [2, 999999999], [3, 999999998], [4, 999999997], [5, 999999996]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000, 1000000000]\n assert candidate(items = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95]) == [0, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(items = [[1000000000, 1], [999999999, 2], [999999998, 3], [999999997, 4], [999999996, 5]],queries = [1, 2, 3, 4, 5]) == [0, 0, 0, 0, 0]\n assert candidate(items = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],queries = [10, 15, 20, 25]) == [10, 16, 20, 20]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]],queries = [1, 3, 5, 7, 9, 11, 13, 15]) == [1, 3, 5, 7, 9, 11, 13, 15]\n assert candidate(items = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(items = [[10, 1], [9, 2], [8, 3], [7, 4], [6, 5], [5, 6], [4, 7], [3, 8], [2, 9], [1, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[5, 1], [5, 2], [5, 3], [5, 4], [5, 5]],queries = [4, 5, 6]) == [0, 5, 5]\n assert candidate(items = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5]],queries = [1]) == [5]\n assert candidate(items = [[1, 2], [3, 5], [2, 6], [4, 8], [5, 10], [6, 12], [7, 14], [8, 16], [9, 18], [10, 20]],queries = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]) == [6, 8, 12, 16, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(items = [[1, 100], [100, 1], [1, 200], [100, 2], [1, 300], [100, 3], [1, 400], [100, 4], [1, 500], [100, 5]],queries = [1, 50, 100, 150, 200]) == [500, 500, 500, 500, 500]\n assert candidate(items = [[1, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 6], [3, 7], [3, 8], [3, 9], [3, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [1, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 1000000000], [1000000000, 1]],queries = [500000000, 1000000000]) == [1000000000, 1000000000]\n assert candidate(items = [[1000000000, 1], [2000000000, 2], [3000000000, 3], [4000000000, 4], [5000000000, 5]],queries = [500000000, 1500000000, 2500000000, 3500000000, 4500000000, 5500000000]) == [0, 1, 2, 3, 4, 5]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]) == [5, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]\n assert candidate(items = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14]],queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [14, 13, 12, 11, 10, 9, 8, 7, 6, 5]\n assert candidate(items = [[5, 5], [5, 6], [5, 7], [5, 8], [5, 9]],queries = [1, 2, 3, 4, 5, 6]) == [0, 0, 0, 0, 9, 9]\n assert candidate(items = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],queries = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]\n assert candidate(items = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 20, 30, 40, 50, 50, 50, 50, 50, 50]\n assert candidate(items = [[1, 1000000000], [2, 999999999], [3, 999999998], [4, 999999997], [5, 999999996]],queries = [1, 2, 3, 4, 5]) == [1000000000, 1000000000, 1000000000, 1000000000, 1000000000]\n assert candidate(items = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],queries = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110]) == [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]\n assert candidate(items = [[5, 20], [5, 18], [5, 16], [5, 14], [5, 12], [5, 10], [5, 8], [5, 6], [5, 4], [5, 2]],queries = [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) == [0, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20]\n assert candidate(items = [[1, 10], [2, 9], [3, 8], [4, 7], [5, 6], [6, 5], [7, 4], [8, 3], [9, 2], [10, 1]],queries = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 10], [2, 10], [3, 10], [4, 10], [5, 10], [6, 10], [7, 10], [8, 10], [9, 10], [10, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1, 9], [2, 8], [3, 7], [4, 6], [5, 5], [6, 4], [7, 3], [8, 2], [9, 1], [10, 0]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]\n assert candidate(items = [[1, 1], [2, 2], [2, 3], [3, 4], [3, 5], [4, 6], [4, 7], [5, 8], [5, 9], [6, 10]],queries = [2, 4, 6, 8, 10]) == [3, 7, 10, 10, 10]\n assert candidate(items = [[1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [1, 6], [1, 7], [1, 8], [1, 9], [1, 10]],queries = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]\n assert candidate(items = [[1000000000, 1], [1, 1000000000], [500000000, 500000000], [250000000, 250000000]],queries = [1000000000, 1, 500000000, 250000000, 0]) == [1000000000, 1000000000, 1000000000, 1000000000, 0]\n assert candidate(items = [[1, 1000000000], [1000000000, 1]],queries = [1, 1000000000]) == [1000000000, 1000000000]\n assert candidate(items = [[100, 500], [200, 400], [300, 300], [400, 200], [500, 100]],queries = [50, 150, 250, 350, 450, 550]) == [0, 500, 500, 500, 500, 500]\n assert candidate(items = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(items = [[1000000000, 999999999], [1000000000, 1000000000], [1000000000, 1000000001]],queries = [1000000000, 999999999, 1000000001]) == [1000000001, 0, 1000000001]\n assert candidate(items = [[10, 100], [20, 200], [30, 300], [40, 400], [50, 500], [60, 600], [70, 700], [80, 800], [90, 900], [100, 1000]],queries = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105]) == [0, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(items = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600], [7, 700], [8, 800], [9, 900], [10, 1000]],queries = [1, 3, 5, 7, 9, 11]) == [100, 300, 500, 700, 900, 1000]\n assert candidate(items = [[1, 1], [2, 3], [3, 5], [4, 7], [5, 9], [6, 11], [7, 13], [8, 15], [9, 17], [10, 19]],queries = [1, 5, 10, 15, 20, 25, 30]) == [1, 9, 19, 19, 19, 19, 19]\n assert candidate(items = [[1, 100], [2, 90], [3, 80], [4, 70], [5, 60], [6, 50], [7, 40], [8, 30], [9, 20], [10, 10]],queries = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) == [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100]\n"}, "metadata": {"canonical_parameter_names": ["items", "queries"], "leetcode_dataset_entry_point": "Solution().maximumBeauty", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector maximumBeauty(vector>& items, vector& queries) {", "container": "Solution", "callable": "maximumBeauty", "parameters": [{"name": "items", "type": "vector>&"}, {"name": "queries", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2071, "task_id": "maximum-number-of-tasks-you-can-assign", "difficulty": "Hard", "problem_description": "You have n tasks and m workers. Each task has a strength requirement stored in a 0-indexed integer array tasks, with the ith task requiring tasks[i] strength to complete. The strength of each worker is stored in a 0-indexed integer array workers, with the jth worker having workers[j] strength. Each worker can only be assigned to a single task and must have a strength greater than or equal to the task's strength requirement (i.e., workers[j] >= tasks[i]).\nAdditionally, you have pills magical pills that will increase a worker's strength by strength. You can decide which workers receive the magical pills, however, you may only give each worker at most one magical pill.\nGiven the 0-indexed integer arrays tasks and workers and the integers pills and strength, return the maximum number of tasks that can be completed.\n \nExample 1:\n\nInput: tasks = [3,2,1], workers = [0,3,3], pills = 1, strength = 1\nOutput: 3\nExplanation:\nWe can assign the magical pill and tasks as follows:\n- Give the magical pill to worker 0.\n- Assign worker 0 to task 2 (0 + 1 >= 1)\n- Assign worker 1 to task 1 (3 >= 2)\n- Assign worker 2 to task 0 (3 >= 3)\n\nExample 2:\n\nInput: tasks = [5,4], workers = [0,0,0], pills = 1, strength = 5\nOutput: 1\nExplanation:\nWe can assign the magical pill and tasks as follows:\n- Give the magical pill to worker 0.\n- Assign worker 0 to task 0 (0 + 5 >= 5)\n\nExample 3:\n\nInput: tasks = [10,15,30], workers = [0,10,10,10,10], pills = 3, strength = 10\nOutput: 2\nExplanation:\nWe can assign the magical pills and tasks as follows:\n- Give the magical pill to worker 0 and worker 1.\n- Assign worker 0 to task 0 (0 + 10 >= 10)\n- Assign worker 1 to task 1 (10 + 10 >= 15)\nThe last pill is not given because it will not make any worker strong enough for the last task.\n\n \nConstraints:\n\nn == tasks.length\nm == workers.length\n1 <= n, m <= 5 * 104\n0 <= pills <= m\n0 <= tasks[i], workers[j], strength <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(tasks = [100, 200, 300],workers = [50, 150, 250, 350],pills = 2,strength = 100) == 3\n assert candidate(tasks = [10, 20, 30],workers = [30, 40, 50],pills = 0,strength = 10) == 3\n assert candidate(tasks = [10, 15, 30],workers = [0, 10, 10, 10, 10],pills = 3,strength = 10) == 2\n assert candidate(tasks = [100, 200, 300],workers = [100, 100, 100, 100, 100],pills = 2,strength = 100) == 2\n assert candidate(tasks = [1, 2, 3, 4, 5],workers = [5, 5, 5, 5, 5],pills = 5,strength = 5) == 5\n assert candidate(tasks = [1, 2, 3, 4, 5],workers = [5, 5, 5, 5, 5],pills = 0,strength = 1) == 5\n assert candidate(tasks = [5, 5, 5, 5],workers = [1, 1, 1, 1],pills = 4,strength = 4) == 4\n assert candidate(tasks = [100, 200, 300],workers = [150, 250, 350],pills = 1,strength = 100) == 3\n assert candidate(tasks = [1, 2, 3, 4, 5],workers = [5, 5, 5, 5, 5],pills = 0,strength = 2) == 5\n assert candidate(tasks = [100, 200, 300],workers = [150, 250, 350],pills = 2,strength = 50) == 3\n assert candidate(tasks = [10, 20, 30, 40, 50],workers = [5, 15, 25, 35, 45],pills = 2,strength = 10) == 4\n assert candidate(tasks = [1, 2, 3, 4, 5],workers = [5, 5, 5, 5, 5],pills = 2,strength = 5) == 5\n assert candidate(tasks = [5, 4],workers = [0, 0, 0],pills = 1,strength = 5) == 1\n assert candidate(tasks = [10, 20, 30, 40, 50],workers = [1, 2, 3, 4, 5],pills = 5,strength = 10) == 1\n assert candidate(tasks = [10, 20, 30, 40, 50],workers = [5, 15, 25, 35, 45],pills = 0,strength = 10) == 4\n assert candidate(tasks = [9, 8, 7, 6, 5],workers = [4, 4, 4, 4, 4],pills = 5,strength = 5) == 5\n assert candidate(tasks = [3, 6, 7, 11],workers = [6, 8, 9],pills = 2,strength = 3) == 3\n assert candidate(tasks = [1, 1, 1, 1, 1],workers = [1, 1, 1, 1, 1],pills = 5,strength = 0) == 5\n assert candidate(tasks = [10, 20, 30, 40, 50],workers = [5, 15, 25, 35, 45],pills = 5,strength = 10) == 5\n assert candidate(tasks = [1, 2, 3, 4, 5],workers = [5, 5, 5, 5, 5],pills = 5,strength = 0) == 5\n assert candidate(tasks = [1, 1, 1, 1],workers = [1, 1, 1, 1],pills = 4,strength = 0) == 4\n assert candidate(tasks = [1, 10, 100, 1000],workers = [1, 10, 100, 1000],pills = 2,strength = 500) == 4\n assert candidate(tasks = [3, 2, 1],workers = [0, 3, 3],pills = 1,strength = 1) == 3\n assert candidate(tasks = [1, 1, 1, 1, 1],workers = [1, 1, 1, 1, 1],pills = 0,strength = 0) == 5\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],pills = 10,strength = 5) == 20\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],workers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pills = 0,strength = 1) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],workers = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],pills = 10,strength = 5) == 30\n assert candidate(tasks = [3, 6, 9, 12, 15],workers = [3, 6, 9, 12, 15],pills = 2,strength = 3) == 5\n assert candidate(tasks = [1000000000, 1000000000, 1000000000],workers = [1000000000, 1000000000, 1000000000],pills = 3,strength = 0) == 3\n assert candidate(tasks = [1, 1, 1, 1, 1],workers = [1, 1, 1, 1, 1],pills = 3,strength = 1) == 5\n assert candidate(tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],workers = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100],pills = 10,strength = 0) == 10\n assert candidate(tasks = [50, 100, 150, 200, 250],workers = [40, 80, 120, 160, 200],pills = 3,strength = 60) == 4\n assert candidate(tasks = [5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110],pills = 5,strength = 20) == 11\n assert candidate(tasks = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59],workers = [50, 51, 52, 53, 54, 55, 56, 57, 58, 59],pills = 5,strength = 1) == 10\n assert candidate(tasks = [100, 200, 300, 400, 500],workers = [100, 150, 200, 250, 300],pills = 2,strength = 100) == 4\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],workers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pills = 10,strength = 0) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pills = 5,strength = 10) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5],workers = [1, 1, 1, 1, 1],pills = 5,strength = 4) == 5\n assert candidate(tasks = [3, 6, 9, 12, 15],workers = [3, 6, 9, 12, 15],pills = 0,strength = 10) == 5\n assert candidate(tasks = [500000000, 500000000, 500000000, 500000000, 500000000],workers = [500000000, 500000000, 500000000, 500000000, 500000000],pills = 5,strength = 0) == 5\n assert candidate(tasks = [1, 3, 5, 7, 9],workers = [10, 20, 30, 40, 50],pills = 2,strength = 5) == 5\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],workers = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],pills = 5,strength = 0) == 10\n assert candidate(tasks = [1000000000],workers = [999999999],pills = 1,strength = 1) == 1\n assert candidate(tasks = [1, 2, 3, 4, 5],workers = [10, 20, 30, 40, 50],pills = 2,strength = 5) == 5\n assert candidate(tasks = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],workers = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950],pills = 5,strength = 100) == 9\n assert candidate(tasks = [1000, 2000, 3000],workers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],pills = 5,strength = 500) == 1\n assert candidate(tasks = [5, 15, 25, 35, 45],workers = [1, 11, 21, 31, 41],pills = 2,strength = 10) == 4\n assert candidate(tasks = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],workers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],pills = 15,strength = 1) == 15\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pills = 5,strength = 1) == 10\n assert candidate(tasks = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],workers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],pills = 10,strength = 0) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],workers = [20, 40, 60, 80, 100, 120, 140, 160, 180, 200, 220, 240, 260, 280, 300, 320, 340, 360, 380, 400],pills = 10,strength = 20) == 20\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pills = 10,strength = 0) == 10\n assert candidate(tasks = [1000, 2000, 3000, 4000, 5000],workers = [500, 1000, 1500, 2000, 2500],pills = 4,strength = 1000) == 3\n assert candidate(tasks = [10, 20, 30, 40, 50],workers = [10, 20, 30, 40, 50],pills = 0,strength = 0) == 5\n assert candidate(tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],workers = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145],pills = 7,strength = 50) == 15\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],workers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],pills = 5,strength = 5) == 10\n assert candidate(tasks = [1, 3, 5, 7, 9, 11, 13, 15],workers = [2, 4, 6, 8, 10, 12, 14, 16],pills = 3,strength = 2) == 8\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pills = 5,strength = 2) == 10\n assert candidate(tasks = [5, 10, 15, 20, 25, 30],workers = [10, 15, 20, 25, 30, 35],pills = 3,strength = 5) == 6\n assert candidate(tasks = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pills = 3,strength = 5) == 10\n assert candidate(tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],workers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],pills = 5,strength = 50) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],workers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],pills = 5,strength = 10) == 20\n assert candidate(tasks = [100, 200, 300, 400, 500],workers = [150, 250, 350, 450, 550],pills = 3,strength = 100) == 5\n assert candidate(tasks = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pills = 3,strength = 20) == 10\n assert candidate(tasks = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],workers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pills = 5,strength = 1) == 10\n assert candidate(tasks = [5, 15, 25, 35, 45],workers = [1, 1, 1, 1, 1],pills = 5,strength = 40) == 4\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],pills = 10,strength = 4) == 10\n assert candidate(tasks = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],workers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],pills = 5,strength = 50) == 10\n assert candidate(tasks = [50, 50, 50, 50, 50],workers = [100, 100, 100, 100, 100],pills = 2,strength = 10) == 5\n assert candidate(tasks = [500, 400, 300, 200, 100],workers = [100, 200, 300, 400, 500],pills = 2,strength = 100) == 5\n assert candidate(tasks = [100, 150, 200, 250, 300],workers = [50, 100, 150, 200, 250],pills = 2,strength = 50) == 4\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pills = 5,strength = 1) == 10\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],workers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],pills = 10,strength = 0) == 10\n assert candidate(tasks = [100, 200, 300, 400, 500],workers = [100, 200, 300, 400, 500],pills = 5,strength = 500) == 5\n assert candidate(tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pills = 5,strength = 0) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],workers = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pills = 7,strength = 3) == 15\n assert candidate(tasks = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],workers = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],pills = 5,strength = 0) == 10\n assert candidate(tasks = [999999999, 999999998, 999999997, 999999996, 999999995],workers = [1000000000, 1000000000, 1000000000, 1000000000, 1000000000],pills = 2,strength = 1) == 5\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pills = 0,strength = 1) == 10\n assert candidate(tasks = [5, 25, 50, 75, 100],workers = [10, 20, 30, 40, 50],pills = 3,strength = 20) == 3\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pills = 0,strength = 0) == 10\n assert candidate(tasks = [9, 18, 27, 36, 45, 54, 63, 72, 81, 90],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pills = 10,strength = 9) == 10\n assert candidate(tasks = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],workers = [900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000, 2100, 2200, 2300, 2400, 2500, 2600, 2700, 2800],pills = 10,strength = 200) == 20\n assert candidate(tasks = [1, 5, 9, 13, 17, 21, 25],workers = [2, 6, 10, 14, 18, 22, 26],pills = 3,strength = 1) == 7\n assert candidate(tasks = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pills = 4,strength = 10) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],pills = 5,strength = 1) == 10\n assert candidate(tasks = [500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],workers = [500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],pills = 3,strength = 200) == 11\n assert candidate(tasks = [1000, 2000, 3000, 4000, 5000],workers = [500, 1500, 2500, 3500, 4500],pills = 2,strength = 1000) == 4\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pills = 10,strength = 1) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],pills = 5,strength = 1) == 10\n assert candidate(tasks = [1000000000, 1000000000],workers = [1000000000, 1000000000],pills = 1,strength = 0) == 2\n assert candidate(tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],pills = 10,strength = 10) == 10\n assert candidate(tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],workers = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],pills = 5,strength = 10) == 2\n assert candidate(tasks = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],workers = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],pills = 5,strength = 1) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],workers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pills = 0,strength = 0) == 10\n assert candidate(tasks = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],workers = [20, 22, 24, 26, 28, 30, 32, 34, 36, 38],pills = 5,strength = 10) == 10\n assert candidate(tasks = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],workers = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],pills = 5,strength = 10) == 20\n assert candidate(tasks = [90, 80, 70, 60, 50, 40, 30, 20, 10],workers = [10, 20, 30, 40, 50, 60, 70, 80, 90],pills = 4,strength = 20) == 9\n assert candidate(tasks = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],workers = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],pills = 0,strength = 100) == 10\n assert candidate(tasks = [50, 60, 70, 80, 90],workers = [40, 50, 60, 70, 80],pills = 3,strength = 10) == 4\n assert candidate(tasks = [500, 500, 500, 500, 500],workers = [250, 250, 250, 250, 250],pills = 5,strength = 250) == 5\n assert candidate(tasks = [10, 10, 10, 10, 10],workers = [1, 1, 1, 1, 1],pills = 5,strength = 9) == 5\n assert candidate(tasks = [1000000000, 1000000000, 1000000000],workers = [1000000000, 1000000000, 1000000000],pills = 1,strength = 0) == 3\n assert candidate(tasks = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],workers = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950],pills = 5,strength = 50) == 9\n assert candidate(tasks = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],workers = [50, 150, 250, 350, 450, 550, 650, 750, 850, 950],pills = 10,strength = 100) == 10\n assert candidate(tasks = [100, 200, 300, 400, 500, 600],workers = [100, 200, 300, 400, 500, 600],pills = 0,strength = 0) == 6\n assert candidate(tasks = [1000000000],workers = [1000000000],pills = 0,strength = 0) == 1\n assert candidate(tasks = [5, 15, 25, 35, 45, 55],workers = [10, 20, 30, 40, 50, 60],pills = 3,strength = 10) == 6\n assert candidate(tasks = [1000000000],workers = [1000000000],pills = 1,strength = 0) == 1\n assert candidate(tasks = [9, 8, 7, 6, 5, 4, 3, 2, 1],workers = [1, 2, 3, 4, 5, 6, 7, 8, 9],pills = 0,strength = 2) == 9\n assert candidate(tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],workers = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],pills = 5,strength = 10) == 10\n assert candidate(tasks = [1, 3, 5, 7, 9],workers = [2, 4, 6, 8, 10],pills = 2,strength = 1) == 5\n assert candidate(tasks = [10000, 20000, 30000, 40000, 50000],workers = [1000, 2000, 3000, 4000, 5000],pills = 5,strength = 10000) == 1\n assert candidate(tasks = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],workers = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],pills = 5,strength = 5) == 9\n assert candidate(tasks = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],workers = [100, 200, 300, 400, 500],pills = 5,strength = 500) == 5\n assert candidate(tasks = [500000000, 500000000],workers = [500000000, 500000000],pills = 2,strength = 0) == 2\n assert candidate(tasks = [50, 100, 150, 200, 250],workers = [100, 150, 200, 250, 300],pills = 3,strength = 50) == 5\n assert candidate(tasks = [9, 18, 27, 36, 45, 54],workers = [12, 24, 36, 48, 60, 72],pills = 5,strength = 6) == 6\n assert candidate(tasks = [10, 10, 10, 10, 10],workers = [10, 10, 10, 10, 10],pills = 5,strength = 0) == 5\n"}, "metadata": {"canonical_parameter_names": ["tasks", "workers", "pills", "strength"], "leetcode_dataset_entry_point": "Solution().maxTaskAssign", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxTaskAssign(vector& tasks, vector& workers, int pills, int strength) {", "container": "Solution", "callable": "maxTaskAssign", "parameters": [{"name": "tasks", "type": "vector&"}, {"name": "workers", "type": "vector&"}, {"name": "pills", "type": "int"}, {"name": "strength", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2073, "task_id": "time-needed-to-buy-tickets", "difficulty": "Easy", "problem_description": "There are n people in a line queuing to buy tickets, where the 0th person is at the front of the line and the (n - 1)th person is at the back of the line.\nYou are given a 0-indexed integer array tickets of length n where the number of tickets that the ith person would like to buy is tickets[i].\nEach person takes exactly 1 second to buy a ticket. A person can only buy 1 ticket at a time and has to go back to the end of the line (which happens instantaneously) in order to buy more tickets. If a person does not have any tickets left to buy, the person will leave the line.\nReturn the time taken for the person initially at position k (0-indexed) to finish buying tickets.\n \nExample 1:\n\nInput: tickets = [2,3,2], k = 2\nOutput: 6\nExplanation:\n\nThe queue starts as [2,3,2], where the kth person is underlined.\nAfter the person at the front has bought a ticket, the queue becomes [3,2,1] at 1 second.\nContinuing this process, the queue becomes [2,1,2] at 2 seconds.\nContinuing this process, the queue becomes [1,2,1] at 3 seconds.\nContinuing this process, the queue becomes [2,1] at 4 seconds. Note: the person at the front left the queue.\nContinuing this process, the queue becomes [1,1] at 5 seconds.\nContinuing this process, the queue becomes [1] at 6 seconds. The kth person has bought all their tickets, so return 6.\n\n\nExample 2:\n\nInput: tickets = [5,1,1,1], k = 0\nOutput: 8\nExplanation:\n\nThe queue starts as [5,1,1,1], where the kth person is underlined.\nAfter the person at the front has bought a ticket, the queue becomes [1,1,1,4] at 1 second.\nContinuing this process for 3 seconds, the queue becomes [4] at 4 seconds.\nContinuing this process for 4 seconds, the queue becomes [] at 8 seconds. The kth person has bought all their tickets, so return 8.\n\n\n \nConstraints:\n\nn == tickets.length\n1 <= n <= 100\n1 <= tickets[i] <= 100\n0 <= k < n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(tickets = [5, 1, 1, 1],k = 0) == 8\n assert candidate(tickets = [4, 3, 2, 1],k = 1) == 9\n assert candidate(tickets = [100, 100, 100],k = 1) == 299\n assert candidate(tickets = [1],k = 0) == 1\n assert candidate(tickets = [10, 10, 10],k = 2) == 30\n assert candidate(tickets = [10, 10, 10],k = 0) == 28\n assert candidate(tickets = [10, 10, 10],k = 1) == 29\n assert candidate(tickets = [1, 2, 3, 4, 5],k = 4) == 15\n assert candidate(tickets = [2, 3, 2],k = 2) == 6\n assert candidate(tickets = [100, 100, 100],k = 2) == 300\n assert candidate(tickets = [1, 1, 1, 1],k = 2) == 3\n assert candidate(tickets = [1, 1, 1, 1],k = 1) == 2\n assert candidate(tickets = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 19) == 110\n assert candidate(tickets = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1, 5, 4, 3, 2, 1],k = 10) == 59\n assert candidate(tickets = [9, 3, 5, 7, 1, 2, 6],k = 4) == 5\n assert candidate(tickets = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 91\n assert candidate(tickets = [7, 2, 9, 1, 8, 3, 6, 4, 5],k = 6) == 39\n assert candidate(tickets = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],k = 15) == 86\n assert candidate(tickets = [1, 2, 3, 4, 5, 4, 3, 2, 1],k = 8) == 9\n assert candidate(tickets = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 15) == 76\n assert candidate(tickets = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == 91\n assert candidate(tickets = [25, 30, 15, 20, 10],k = 3) == 85\n assert candidate(tickets = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 5) == 44\n assert candidate(tickets = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 4) == 25\n assert candidate(tickets = [5, 2, 3, 1, 4],k = 2) == 11\n assert candidate(tickets = [5, 1, 2, 3, 4],k = 0) == 15\n assert candidate(tickets = [3, 1, 5, 4, 2],k = 3) == 14\n assert candidate(tickets = [7, 8, 9, 10, 11, 12, 13, 14, 15],k = 8) == 99\n assert candidate(tickets = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 10\n assert candidate(tickets = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 8) == 29\n assert candidate(tickets = [9, 3, 8, 4, 6, 7, 5, 2, 1],k = 1) == 19\n assert candidate(tickets = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 19) == 20\n assert candidate(tickets = [1, 5, 3, 4, 2, 6, 7, 8],k = 5) == 31\n assert candidate(tickets = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 15) == 28\n assert candidate(tickets = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2, 6, 5, 3, 5, 9, 2],k = 10) == 192\n assert candidate(tickets = [5, 4, 3, 2, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1],k = 19) == 20\n assert candidate(tickets = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 0) == 81\n assert candidate(tickets = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 4) == 395\n assert candidate(tickets = [1, 2, 3, 4, 3, 2, 1],k = 5) == 12\n assert candidate(tickets = [5, 3, 5, 2, 4, 1, 3],k = 3) == 11\n assert candidate(tickets = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4],k = 10) == 43\n assert candidate(tickets = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == 85\n assert candidate(tickets = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 5) == 16\n assert candidate(tickets = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == 45\n assert candidate(tickets = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 9) == 90\n assert candidate(tickets = [1, 2, 3, 4, 5, 4, 3, 2, 1],k = 4) == 25\n assert candidate(tickets = [2, 6, 3, 4, 5, 1],k = 2) == 13\n assert candidate(tickets = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 9) == 10\n assert candidate(tickets = [20, 1, 20, 1, 20],k = 2) == 61\n assert candidate(tickets = [25, 30, 5, 10, 15],k = 1) == 85\n assert candidate(tickets = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2],k = 8) == 9\n assert candidate(tickets = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 4) == 35\n assert candidate(tickets = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == 40\n assert candidate(tickets = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 0) == 45\n assert candidate(tickets = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],k = 0) == 1\n assert candidate(tickets = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 156\n assert candidate(tickets = [5, 4, 3, 2, 1],k = 0) == 15\n assert candidate(tickets = [4, 2, 3, 3, 1, 4, 2, 3],k = 5) == 22\n assert candidate(tickets = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 50) == 104\n assert candidate(tickets = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 19) == 210\n assert candidate(tickets = [5, 6, 7, 8, 9],k = 2) == 30\n assert candidate(tickets = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 49) == 162\n assert candidate(tickets = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == 6\n assert candidate(tickets = [10, 15, 5, 20, 25, 30, 5],k = 4) == 104\n assert candidate(tickets = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 0) == 55\n assert candidate(tickets = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == 35\n assert candidate(tickets = [1, 5, 2, 3, 4, 5],k = 5) == 20\n assert candidate(tickets = [3, 1, 5, 2, 4, 6],k = 3) == 9\n assert candidate(tickets = [20, 15, 10, 5, 1],k = 0) == 51\n assert candidate(tickets = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 0) == 1\n assert candidate(tickets = [2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],k = 19) == 20\n assert candidate(tickets = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == 41\n assert candidate(tickets = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == 11\n assert candidate(tickets = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == 156\n assert candidate(tickets = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],k = 9) == 30\n assert candidate(tickets = [10, 1, 10, 1, 10, 1, 10],k = 3) == 4\n assert candidate(tickets = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 0) == 163\n assert candidate(tickets = [10, 5, 4, 6, 3, 8, 2],k = 4) == 19\n assert candidate(tickets = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == 55\n assert candidate(tickets = [2, 5, 3, 4, 1, 2],k = 2) == 13\n assert candidate(tickets = [10, 20, 30, 40, 50],k = 2) == 118\n assert candidate(tickets = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],k = 0) == 393\n assert candidate(tickets = [3, 2, 1, 4, 5, 6],k = 5) == 21\n assert candidate(tickets = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 25) == 238\n assert candidate(tickets = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4],k = 5) == 36\n assert candidate(tickets = [20, 15, 10, 5, 1],k = 1) == 46\n assert candidate(tickets = [5, 4, 3, 2, 1, 5, 4, 3, 2, 1],k = 9) == 10\n assert candidate(tickets = [3, 3, 3, 3, 3],k = 2) == 13\n assert candidate(tickets = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],k = 5) == 96\n assert candidate(tickets = [50, 50, 50, 50, 50],k = 2) == 248\n assert candidate(tickets = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 7) == 38\n assert candidate(tickets = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11],k = 9) == 110\n assert candidate(tickets = [7, 8, 9, 10, 11, 12, 13, 14],k = 5) == 79\n assert candidate(tickets = [3, 5, 2, 4, 1],k = 2) == 8\n assert candidate(tickets = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 3) == 24\n assert candidate(tickets = [1, 1, 1, 2, 2, 2, 3, 3, 3],k = 6) == 16\n assert candidate(tickets = [5, 4, 3, 2, 1],k = 2) == 12\n assert candidate(tickets = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],k = 8) == 29\n assert candidate(tickets = [50, 30, 20, 10, 90, 80, 70, 60],k = 4) == 410\n"}, "metadata": {"canonical_parameter_names": ["tickets", "k"], "leetcode_dataset_entry_point": "Solution().timeRequiredToBuy", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int timeRequiredToBuy(vector& tickets, int k) {", "container": "Solution", "callable": "timeRequiredToBuy", "parameters": [{"name": "tickets", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2074, "task_id": "reverse-nodes-in-even-length-groups", "difficulty": "Medium", "problem_description": "You are given the head of a linked list.\nThe nodes in the linked list are sequentially assigned to non-empty groups whose lengths form the sequence of the natural numbers (1, 2, 3, 4, ...). The length of a group is the number of nodes assigned to it. In other words,\n\nThe 1st node is assigned to the first group.\nThe 2nd and the 3rd nodes are assigned to the second group.\nThe 4th, 5th, and 6th nodes are assigned to the third group, and so on.\n\nNote that the length of the last group may be less than or equal to 1 + the length of the second to last group.\nReverse the nodes in each group with an even length, and return the head of the modified linked list.\n \nExample 1:\n\n\nInput: head = [5,2,6,3,9,1,7,3,8,4]\nOutput: [5,6,2,3,9,1,4,8,3,7]\nExplanation:\n- The length of the first group is 1, which is odd, hence no reversal occurs.\n- The length of the second group is 2, which is even, hence the nodes are reversed.\n- The length of the third group is 3, which is odd, hence no reversal occurs.\n- The length of the last group is 4, which is even, hence the nodes are reversed.\n\nExample 2:\n\n\nInput: head = [1,1,0,6]\nOutput: [1,0,1,6]\nExplanation:\n- The length of the first group is 1. No reversal occurs.\n- The length of the second group is 2. The nodes are reversed.\n- The length of the last group is 1. No reversal occurs.\n\nExample 3:\n\n\nInput: head = [1,1,0,6,5]\nOutput: [1,0,1,5,6]\nExplanation:\n- The length of the first group is 1. No reversal occurs.\n- The length of the second group is 2. The nodes are reversed.\n- The length of the last group is 2. The nodes are reversed.\n\n \nConstraints:\n\nThe number of nodes in the list is in the range [1, 105].\n0 <= Node.val <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert is_same_list(candidate(head = list_node([1, 2, 3])), list_node([1, 3, 2]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5])), list_node([1, 3, 2, 5, 4]))\n assert is_same_list(candidate(head = list_node([1, 2])), list_node([1, 2]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4])), list_node([1, 3, 2, 4]))\n assert is_same_list(candidate(head = list_node([1, 1, 0, 6])), list_node([1, 0, 1, 6]))\n assert is_same_list(candidate(head = list_node([100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991])), list_node([100000, 99998, 99999, 99997, 99996, 99995, 99991, 99992, 99993, 99994]))\n assert is_same_list(candidate(head = list_node([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])), list_node([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9])), list_node([1, 3, 2, 4, 5, 6, 7, 8, 9]))\n assert is_same_list(candidate(head = list_node([1, 1, 0, 6, 5])), list_node([1, 0, 1, 5, 6]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11]))\n assert is_same_list(candidate(head = list_node([1])), list_node([1]))\n assert is_same_list(candidate(head = list_node([5, 2, 6, 3, 9, 1, 7, 3, 8, 4])), list_node([5, 6, 2, 3, 9, 1, 4, 8, 3, 7]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7])), list_node([1, 3, 2, 4, 5, 6, 7]))\n assert is_same_list(candidate(head = list_node([0])), list_node([0]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 12, 11]))\n assert is_same_list(candidate(head = list_node([2, 4, 3])), list_node([2, 3, 4]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90])), list_node([10, 30, 20, 40, 50, 60, 70, 80, 90]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6])), list_node([1, 3, 2, 4, 5, 6]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8])), list_node([1, 3, 2, 4, 5, 6, 8, 7]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24, 25, 26, 27, 28, 36, 35, 34, 33, 32, 31, 30, 29, 40, 39, 38, 37]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10])), list_node([1, 1, 1, 2, 2, 2, 4, 3, 3, 3, 4, 4, 5, 5, 5, 7, 7, 7, 6, 6, 6, 8, 8, 8, 9, 9, 9, 10, 10, 10]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59])), list_node([1, 5, 3, 7, 9, 11, 19, 17, 15, 13, 21, 23, 25, 27, 29, 41, 39, 37, 35, 33, 31, 43, 45, 47, 49, 51, 53, 55, 59, 57]))\n assert is_same_list(candidate(head = list_node([29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([29, 27, 28, 26, 25, 24, 20, 21, 22, 23, 19, 18, 17, 16, 15, 9, 10, 11, 12, 13, 14, 8, 7, 6, 5, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24, 25, 26, 27, 28, 32, 31, 30, 29]))\n assert is_same_list(candidate(head = list_node([1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26])), list_node([1, 2, 3, 5, 4, 7, 11, 8, 9, 6, 10, 13, 12, 15, 14, 20, 21, 18, 19, 16, 17, 26, 27, 24, 25, 22, 23]))\n assert is_same_list(candidate(head = list_node([23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([23, 21, 22, 20, 19, 18, 14, 15, 16, 17, 13, 12, 11, 10, 9, 3, 4, 5, 6, 7, 8, 1, 2]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 16, 17, 18]))\n assert is_same_list(candidate(head = list_node([5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])), list_node([5, 3, 4, 2, 1, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 25, 24, 23, 22]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24, 25, 26]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31])), list_node([1, 5, 3, 7, 9, 11, 19, 17, 15, 13, 21, 23, 25, 27, 29, 31]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 19, 18, 17, 16]))\n assert is_same_list(candidate(head = list_node([1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6])), list_node([1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41])), list_node([1, 5, 3, 7, 9, 11, 19, 17, 15, 13, 21, 23, 25, 27, 29, 41, 39, 37, 35, 33, 31]))\n assert is_same_list(candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 10, 9, 8, 7, 6, 5, 4])), list_node([10, 8, 9, 7, 6, 5, 1, 2, 3, 4, 10, 9, 8, 7, 6, 10, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9]))\n assert is_same_list(candidate(head = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34])), list_node([2, 6, 4, 8, 10, 12, 20, 18, 16, 14, 22, 24, 26, 28, 30, 34, 32]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([5, 3, 2, 6, 9, 1, 7, 3, 8, 4, 2, 7, 5, 9, 3, 6, 8, 0, 1, 2])), list_node([5, 2, 3, 6, 9, 1, 4, 8, 3, 7, 2, 7, 5, 9, 3, 6, 8, 0, 1, 2]))\n assert is_same_list(candidate(head = list_node([1, 1, 0, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0])), list_node([1, 0, 1, 6, 5, 4, 0, 1, 2, 3, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49])), list_node([1, 5, 3, 7, 9, 11, 19, 17, 15, 13, 21, 23, 25, 27, 29, 41, 39, 37, 35, 33, 31, 49, 47, 45, 43]))\n assert is_same_list(candidate(head = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44])), list_node([2, 6, 4, 8, 10, 12, 20, 18, 16, 14, 22, 24, 26, 28, 30, 42, 40, 38, 36, 34, 32, 44]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15])), list_node([9, 7, 8, 6, 5, 4, 0, 1, 2, 3, -1, -2, -3, -4, -5, -11, -10, -9, -8, -7, -6, -15, -14, -13, -12]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24, 25, 26, 27, 28, 36, 35, 34, 33, 32, 31, 30, 29]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200])), list_node([10, 30, 20, 40, 50, 60, 100, 90, 80, 70, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([5, 1, 9, 3, 7, 2, 6, 4, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24])), list_node([5, 9, 1, 3, 7, 2, 10, 8, 4, 6, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24, 25, 26, 27, 28, 36, 35, 34, 33, 32, 31, 30, 29, 37, 38, 39, 40, 41, 42, 43, 44, 45, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4])), list_node([9, 7, 8, 6, 5, 4, 0, 1, 2, 3, 9, 8, 7, 6, 5, 9, 0, 1, 2, 3, 4, 8, 7, 6, 5, 4]))\n assert is_same_list(candidate(head = list_node([5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23])), list_node([5, 2, 1, 3, 4, 5, 9, 8, 7, 6, 10, 11, 12, 13, 14, 20, 19, 18, 17, 16, 15, 21, 22, 23]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0])), list_node([9, 7, 8, 6, 5, 4, 0, 1, 2, 3, 9, 8, 7, 6, 5, 9, 0, 1, 2, 3, 4, 8, 7, 6, 5, 4, 3, 2, 0, 1]))\n assert is_same_list(candidate(head = list_node([50000, 40000, 30000, 20000, 10000, 0, 10000, 20000, 30000, 40000, 50000, 60000, 70000, 80000, 90000, 100000])), list_node([50000, 30000, 40000, 20000, 10000, 0, 40000, 30000, 20000, 10000, 50000, 60000, 70000, 80000, 90000, 100000]))\n assert is_same_list(candidate(head = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62])), list_node([2, 6, 4, 8, 10, 12, 20, 18, 16, 14, 22, 24, 26, 28, 30, 42, 40, 38, 36, 34, 32, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62]))\n assert is_same_list(candidate(head = list_node([1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30, 33, 32, 35, 34, 37, 36, 39, 38, 41, 40, 43, 42, 45, 44, 47, 46, 49, 48, 51, 50])), list_node([1, 2, 3, 5, 4, 7, 11, 8, 9, 6, 10, 13, 12, 15, 14, 20, 21, 18, 19, 16, 17, 23, 22, 25, 24, 27, 26, 29, 37, 34, 35, 32, 33, 30, 31, 28, 36, 39, 38, 41, 40, 43, 42, 45, 44, 50, 51, 48, 49, 46, 47]))\n assert is_same_list(candidate(head = list_node([0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1])), list_node([0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]))\n assert is_same_list(candidate(head = list_node([1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13])), list_node([1, 2, 1, 2, 3, 3, 5, 5, 4, 4, 6, 6, 7, 7, 8, 11, 10, 10, 9, 9, 8, 11, 12, 12, 13, 13]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15])), list_node([1, 2, 1, 2, 3, 3, 5, 5, 4, 4, 6, 6, 7, 7, 8, 11, 10, 10, 9, 9, 8, 11, 12, 12, 13, 13, 14, 14, 15, 15]))\n assert is_same_list(candidate(head = list_node([1, 3, 2, 4, 5, 7, 6, 8, 9, 11, 10, 12, 13, 15, 14, 16, 17, 19, 18, 20, 21, 23, 22, 24, 25, 27, 26, 28, 29, 30])), list_node([1, 2, 3, 4, 5, 7, 11, 9, 8, 6, 10, 12, 13, 15, 14, 21, 20, 18, 19, 17, 16, 23, 22, 24, 25, 27, 26, 28, 30, 29]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 14, 13, 12, 11]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24, 25, 26, 27, 28, 30, 29]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 23, 22]))\n assert is_same_list(candidate(head = list_node([27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([27, 25, 26, 24, 23, 22, 18, 19, 20, 21, 17, 16, 15, 14, 13, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 17, 16]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33])), list_node([1, 5, 3, 7, 9, 11, 19, 17, 15, 13, 21, 23, 25, 27, 29, 33, 31]))\n assert is_same_list(candidate(head = list_node([0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1])), list_node([0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1]))\n assert is_same_list(candidate(head = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 105, 110, 115, 120])), list_node([5, 15, 10, 20, 25, 30, 50, 45, 40, 35, 55, 60, 65, 70, 75, 105, 100, 95, 90, 85, 80, 110, 115, 120]))\n assert is_same_list(candidate(head = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42])), list_node([2, 6, 4, 8, 10, 12, 20, 18, 16, 14, 22, 24, 26, 28, 30, 42, 40, 38, 36, 34, 32]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24, 25, 26, 27, 28, 36, 35, 34, 33, 32, 31, 30, 29, 37, 38, 39, 40, 41, 42, 43, 44, 45, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 80, 79]))\n assert is_same_list(candidate(head = list_node([5, 2, 6, 3, 9, 1, 7, 3, 8, 4, 10, 11, 12, 13, 14, 15, 16])), list_node([5, 6, 2, 3, 9, 1, 4, 8, 3, 7, 10, 11, 12, 13, 14, 16, 15]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17])), list_node([1, 2, 1, 2, 3, 3, 5, 5, 4, 4, 6, 6, 7, 7, 8, 11, 10, 10, 9, 9, 8, 11, 12, 12, 13, 13, 14, 14, 17, 17, 16, 16, 15, 15]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15]))\n assert is_same_list(candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23])), list_node([10, 8, 9, 7, 6, 5, 1, 2, 3, 4, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 23, 22]))\n assert is_same_list(candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30])), list_node([10, 8, 9, 7, 6, 5, 1, 2, 3, 4, 0, 11, 12, 13, 14, 20, 19, 18, 17, 16, 15, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24, 25, 26, 27, 28, 36, 35, 34, 33, 32, 31, 30, 29, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24]))\n assert is_same_list(candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10])), list_node([10, 8, 9, 7, 6, 5, 1, 2, 3, 4, 0, -1, -2, -3, -4, -10, -9, -8, -7, -6, -5]))\n assert is_same_list(candidate(head = list_node([5, 4, 3, 2, 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24])), list_node([5, 3, 4, 2, 1, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 22, 23, 24]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([30, 28, 29, 27, 26, 25, 21, 22, 23, 24, 20, 19, 18, 17, 16, 10, 11, 12, 13, 14, 15, 9, 8, 7, 6, 5, 4, 3, 1, 2]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]))\n assert is_same_list(candidate(head = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40])), list_node([2, 6, 4, 8, 10, 12, 20, 18, 16, 14, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40]))\n assert is_same_list(candidate(head = list_node([0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1])), list_node([0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0]))\n assert is_same_list(candidate(head = list_node([49, 47, 45, 43, 41, 39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1])), list_node([49, 45, 47, 43, 41, 39, 31, 33, 35, 37, 29, 27, 25, 23, 21, 9, 11, 13, 15, 17, 19, 1, 3, 5, 7]))\n assert is_same_list(candidate(head = list_node([50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([50, 48, 49, 47, 46, 45, 41, 42, 43, 44, 40, 39, 38, 37, 36, 30, 31, 32, 33, 34, 35, 29, 28, 27, 26, 25, 24, 23, 15, 16, 17, 18, 19, 20, 21, 22, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([9, 7, 8, 6, 5, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250])), list_node([10, 30, 20, 40, 50, 60, 100, 90, 80, 70, 110, 120, 130, 140, 150, 210, 200, 190, 180, 170, 160, 250, 240, 230, 220]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 16]))\n assert is_same_list(candidate(head = list_node([1, 1, 0, 6, 5, 4, 3, 2, 1, 0, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([1, 0, 1, 6, 5, 4, 0, 1, 2, 3, 9, 8, 7, 6, 5, 1, 2, 3, 4]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])), list_node([1, 3, 2, 4, 5, 6, 10, 9, 8, 7, 11, 12, 13, 14, 15, 21, 20, 19, 18, 17, 16, 25, 24, 23, 22]))\n assert is_same_list(candidate(head = list_node([26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([26, 24, 25, 23, 22, 21, 17, 18, 19, 20, 16, 15, 14, 13, 12, 6, 7, 8, 9, 10, 11, 5, 4, 3, 2, 1]))\n"}, "metadata": {"canonical_parameter_names": ["head"], "leetcode_dataset_entry_point": "Solution().reverseEvenLengthGroups", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "ListNode* reverseEvenLengthGroups(ListNode* head) {", "container": "Solution", "callable": "reverseEvenLengthGroups", "parameters": [{"name": "head", "type": "ListNode*"}], "return_type": "ListNode*", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2075, "task_id": "decode-the-slanted-ciphertext", "difficulty": "Medium", "problem_description": "A string originalText is encoded using a slanted transposition cipher to a string encodedText with the help of a matrix having a fixed number of rows rows.\noriginalText is placed first in a top-left to bottom-right manner.\n\nThe blue cells are filled first, followed by the red cells, then the yellow cells, and so on, until we reach the end of originalText. The arrow indicates the order in which the cells are filled. All empty cells are filled with ' '. The number of columns is chosen such that the rightmost column will not be empty after filling in originalText.\nencodedText is then formed by appending all characters of the matrix in a row-wise fashion.\n\nThe characters in the blue cells are appended first to encodedText, then the red cells, and so on, and finally the yellow cells. The arrow indicates the order in which the cells are accessed.\nFor example, if originalText = \"cipher\" and rows = 3, then we encode it in the following manner:\n\nThe blue arrows depict how originalText is placed in the matrix, and the red arrows denote the order in which encodedText is formed. In the above example, encodedText = \"ch ie pr\".\nGiven the encoded string encodedText and number of rows rows, return the original string originalText.\nNote: originalText does not have any trailing spaces ' '. The test cases are generated such that there is only one possible originalText.\n \nExample 1:\n\nInput: encodedText = \"ch ie pr\", rows = 3\nOutput: \"cipher\"\nExplanation: This is the same example described in the problem description.\n\nExample 2:\n\n\nInput: encodedText = \"iveo eed l te olc\", rows = 4\nOutput: \"i love leetcode\"\nExplanation: The figure above denotes the matrix that was used to encode originalText. \nThe blue arrows show how we can find originalText from encodedText.\n\nExample 3:\n\n\nInput: encodedText = \"coding\", rows = 1\nOutput: \"coding\"\nExplanation: Since there is only 1 row, both originalText and encodedText are the same.\n\n \nConstraints:\n\n0 <= encodedText.length <= 106\nencodedText consists of lowercase English letters and ' ' only.\nencodedText is a valid encoding of some originalText that does not have trailing spaces.\n1 <= rows <= 1000\nThe testcases are generated such that there is only one possible originalText.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(encodedText = \"a\",rows = 1) == \"a\"\n assert candidate(encodedText = \"abcd efg hijk\",rows = 3) == \"aeibfjcgd\"\n assert candidate(encodedText = \"a b c d\",rows = 2) == \"a c b\"\n assert candidate(encodedText = \"coding\",rows = 1) == \"coding\"\n assert candidate(encodedText = \"abc def ghi jkl mno\",rows = 5) == \"adgbec\"\n assert candidate(encodedText = \"ab c de\",rows = 2) == \"a bd ec\"\n assert candidate(encodedText = \"ch ie pr\",rows = 3) == \"cipher\"\n assert candidate(encodedText = \"iveo eed l te olc\",rows = 4) == \"i love leetcode\"\n assert candidate(encodedText = \"python programming is fun\",rows = 4) == \"ppm yriftonuhggorn\"\n assert candidate(encodedText = \"algorithms and data structures\",rows = 5) == \"ah telmdrsgsauo trai\"\n assert candidate(encodedText = \"hello world from leetcode challenges\",rows = 6) == \"hrmt nel c gld ocl do fw\"\n assert candidate(encodedText = \"t a c o s e q u i r r e s e l l f o o d s o u p\",rows = 5) == \"t e s q f a s o u o c e u i o o l r s\"\n assert candidate(encodedText = \"one two three four five six\",rows = 3) == \"oh nrfeei ev e t wf oos ui rx\"\n assert candidate(encodedText = \"programming challenges are fun\",rows = 4) == \"pilrrneeogn g gfrceahm\"\n assert candidate(encodedText = \"filling the matrix in a slanted manner\",rows = 6) == \"f t aaitr nnlhi tnlexaei n g\"\n assert candidate(encodedText = \"p y trh e t s o n a\",rows = 3) == \"pe y t t nrs h\"\n assert candidate(encodedText = \"m e t a l l i c a\",rows = 3) == \"mai elc t\"\n assert candidate(encodedText = \"\",rows = 10) == \"\"\n assert candidate(encodedText = \"padding with spaces at the end \",rows = 5) == \"pwc aiet dtsh dh e i n g a s\"\n assert candidate(encodedText = \"a b c d e f g h i\",rows = 9) == \"abcd\"\n assert candidate(encodedText = \"qo su me ve rt\",rows = 5) == \"qsmvoue\"\n assert candidate(encodedText = \"sh jfuew xq z r e\",rows = 3) == \"sw h x jqrf u\"\n assert candidate(encodedText = \"this is a test string\",rows = 5) == \"ti ghstsi esa\"\n assert candidate(encodedText = \"abcdef ghijkl mnopqr stuvwx yz\",rows = 5) == \"agmsybhntzcioudjpekf\"\n assert candidate(encodedText = \"a quick brown fox jumps over the lazy dog\",rows = 6) == \"a fp z bostqrx uo iwc\"\n assert candidate(encodedText = \"wcy hmu eai xfi\",rows = 3) == \"wu c xy f ei ah\"\n assert candidate(encodedText = \"two words\",rows = 1) == \"two words\"\n assert candidate(encodedText = \"th qzih xof c \",rows = 3) == \"th h c x qoz\"\n assert candidate(encodedText = \"ab c d e f g h i j\",rows = 10) == \"a b ef d c\"\n assert candidate(encodedText = \"programming in python is fun\",rows = 3) == \"pgnr oiignsr apfmyumti\"\n assert candidate(encodedText = \"spaces in between words\",rows = 4) == \"s twpiwoanerc ede ns\"\n assert candidate(encodedText = \"qjewukcuvm xs ezmrg\",rows = 4) == \"qcsmju rev wmu\"\n assert candidate(encodedText = \"this is a longer example to test the decoding function\",rows = 8) == \"t epteharlei esle oi\"\n assert candidate(encodedText = \"q w e r t y u i o p\",rows = 4) == \"q y r w\"\n assert candidate(encodedText = \"a q o q r s\",rows = 6) == \"aqoq\"\n assert candidate(encodedText = \"abcdefghi jklmnop qrstuv wx yz\",rows = 5) == \"ahntybiouzc pvdj ekf\"\n assert candidate(encodedText = \"i s l a n d o f d r e a m s\",rows = 3) == \"i r s e o l a f a m n\"\n assert candidate(encodedText = \"s h e e l s s f i r e\",rows = 5) == \"se hls e\"\n assert candidate(encodedText = \"abc def ghi jkl mno pqr stu vwx yz\",rows = 6) == \"afjosb k cgl hd\"\n assert candidate(encodedText = \"hello world this is a test\",rows = 5) == \"hwtsteoh elri slls od\"\n assert candidate(encodedText = \"c o n s t a n t i n o p o l i s\",rows = 6) == \"csnno ott n\"\n assert candidate(encodedText = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",rows = 5) == \"a l w g r b m x h s c n y i t d o j e\"\n assert candidate(encodedText = \"this is a test of the emergency broadcast system\",rows = 6) == \"t tedththnceieecamss ys te i mso\"\n assert candidate(encodedText = \"x w v u t s r q p o n m l k j i h g f e d c b a\",rows = 26) == \"x\"\n assert candidate(encodedText = \"keep it secret keep it safe\",rows = 6) == \"kicketre p\"\n assert candidate(encodedText = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",rows = 26) == \"a\"\n assert candidate(encodedText = \"hello world from the other side\",rows = 4) == \"hr eeltrldh l esof rw\"\n assert candidate(encodedText = \"data structures and algorithms\",rows = 8) == \"d uast\"\n assert candidate(encodedText = \"abcdefghij klmnopqrst uvwxyz\",rows = 3) == \"a tbk cludmvenwfoxgpyhqi\"\n assert candidate(encodedText = \"singleword\",rows = 10) == \"s\"\n assert candidate(encodedText = \"the quick brown fox jumps over the lazy dog\",rows = 6) == \"tkfshdh o eoebxo r vqojuwi\"\n assert candidate(encodedText = \"thisisaverylongstringthatwillbereconstructedusingtheslantedciphertechnique\",rows = 7) == \"tlhcunehoaostcintniehsgwsndnisitgcstlrtarluvibenr\"\n assert candidate(encodedText = \"one\",rows = 1) == \"one\"\n assert candidate(encodedText = \"z y x w v u t s r q p o n m l k j i h g f e d c b a\",rows = 5) == \"z o d t i y n c s h x m b r g w l q v\"\n assert candidate(encodedText = \"t h e q u i c k b r o w n f o x j u m p s o v e r t h e l a z y d o g\",rows = 7) == \"tcnjohy hk uve ebfme d qropr uox i\"\n assert candidate(encodedText = \"abcdefgh ijklmnop qrstuvwx yz this is a test\",rows = 5) == \"ajs ibkt sclu dmv aenw foxtgp h\"\n assert candidate(encodedText = \"a quick movement of the enemy will jeopardize five gunboats\",rows = 7) == \"aofme b v yofoqet piumhwaieeicn kt\"\n assert candidate(encodedText = \"slantedtranspositioncipheriscomplexandfun\",rows = 7) == \"sdpoeltonarsnat\"\n assert candidate(encodedText = \"one two three four five six seven eight nine ten eleven twelve\",rows = 4) == \"oun nr ee el fietigvwvheoetn tsnthiiwrxnee eles ef\"\n assert candidate(encodedText = \"abcdefghij\",rows = 1) == \"abcdefghij\"\n assert candidate(encodedText = \"x y z \",rows = 3) == \"x zy\"\n assert candidate(encodedText = \"machine learning is fascinating\",rows = 7) == \"mnagaerc h\"\n assert candidate(encodedText = \"lqtk e o mu yzfe ot i g rya wne l oxtesn gdeo\",rows = 5) == \"luie q gtygldkz e frooeeyx aoo\"\n assert candidate(encodedText = \"p r o g r a m m i n g l a n g u a g e s\",rows = 5) == \"p n g a n r g e m g o m g\"\n assert candidate(encodedText = \"wecoloveleetcode\",rows = 2) == \"weeectocloodvee\"\n assert candidate(encodedText = \"example of a very long encoded text\",rows = 7) == \"e eon x rnca aygm po lfe\"\n assert candidate(encodedText = \"longer text with multiple spaces in between\",rows = 3) == \"lheo snm guielnrt ibtpeeltxewt e sewpi\"\n assert candidate(encodedText = \"it wof eit ss dp\",rows = 4) == \"iftst w\"\n assert candidate(encodedText = \"a b c d e\",rows = 5) == \"a b c\"\n assert candidate(encodedText = \"abcd efgh ijkl mnop qrst uvwx yz\",rows = 5) == \"ag rxbhms c ntdio je\"\n assert candidate(encodedText = \"the quick brown fox jumps over lazy dogs\",rows = 4) == \"trmzhopyews n dq ooufvgioescxrk\"\n assert candidate(encodedText = \"special characters !@#$%^&*() are allowed in the text\",rows = 10) == \"s c * ep t!( e e@)ccr#ihsaal\"\n assert candidate(encodedText = \"thisisaverylongtextthatneedstobeencodedusingaslantedtranspositioncipher\",rows = 8) == \"trtsdsaohyttelnilhodasoabuintesgnatv\"\n assert candidate(encodedText = \"spaces are handled correctly\",rows = 5) == \"s h tp a laancycrdoeels\"\n assert candidate(encodedText = \"f l e x i b l e r e s o u r c e s\",rows = 5) == \"fi oe lbrus ele x\"\n assert candidate(encodedText = \"t h e q u i c k b r o w n f o x j u m p s o v e r l a z y d o g s\",rows = 3) == \"t v n h e e r f o q l x u a i z j c y u k m d p b o s r g o\"\n assert candidate(encodedText = \"a b c d e f g h i\",rows = 9) == \"a de c b\"\n assert candidate(encodedText = \"python programming is fun\",rows = 3) == \"po ygitrsha omfnmu ip\"\n assert candidate(encodedText = \"spaces between words are preserved\",rows = 3) == \"sn p a c pewrsoe rs de srb ve et dwae\"\n assert candidate(encodedText = \"keep calm and code on\",rows = 2) == \"knede pc ocdael mo\"\n assert candidate(encodedText = \"abcdefgh ijklmnop qrstuv wxyz\",rows = 4) == \"a p bi wcjqxdkryelsfmg\"\n assert candidate(encodedText = \"decoding slanted transposition cipher is challenging\",rows = 7) == \"d si gestipcclrthoaaidnnitn\"\n assert candidate(encodedText = \"a quick brown fox jumps over the lazy dog\",rows = 3) == \"af otqxhu eij culkma pzbsyr oodwvn\"\n assert candidate(encodedText = \"the quick brown fox jumps over the lazy dog and then some more text to fill\",rows = 8) == \"tbj der hrutonefeomhg wpe sqns au lifocok\"\n assert candidate(encodedText = \"empty string test\",rows = 1) == \"empty string test\"\n assert candidate(encodedText = \"u p d o w n w i d e t h i n g s\",rows = 4) == \"uwdi pnen g dwt o\"\n assert candidate(encodedText = \"this is a test of the emergency broadcast system\",rows = 5) == \"tteythe isebsstmry eosiorasfg a\"\n assert candidate(encodedText = \"shorttext\",rows = 1) == \"shorttext\"\n assert candidate(encodedText = \"a quick brown fox jumps over the lazy dog\",rows = 5) == \"arjry ou qwmtdunphoi secf ko\"\n assert candidate(encodedText = \"a bcd efgh ijklm nopqrst uvwxy z\",rows = 5) == \"aekry fls gmtz h b nc d\"\n assert candidate(encodedText = \"one two three four five six seven eight nine ten\",rows = 4) == \"o x nf neosi uentrvew e ofnt i etvenheir e\"\n assert candidate(encodedText = \"a b c d e\",rows = 5) == \"abcd\"\n assert candidate(encodedText = \"thisisaverylongtextthatneedstobeencodedproperly\",rows = 6) == \"teeeerhrxenoiytdcsltsiohsna\"\n assert candidate(encodedText = \"the quick brown fox jumps over a lazy dog\",rows = 3) == \"tneh ref oaqx u lijacuzkmy p bsdr o\"\n assert candidate(encodedText = \"one two three four five six seven\",rows = 3) == \"oeene e s fitoxwu ors e v e ntfh\"\n assert candidate(encodedText = \"pythonprogramminglanguageisawesome\",rows = 5) == \"priuwyonaetggghrloan\"\n assert candidate(encodedText = \"sl yz vx qu tm\",rows = 4) == \"sz l\"\n assert candidate(encodedText = \"this is a long encoded text for testing\",rows = 7) == \"tsln fsh octoi noes gd a\"\n assert candidate(encodedText = \"abcdefghij klmnopqrst uvwxyz\",rows = 3) == \"a b ck dl emufnvgowhpxiqyjr\"\n assert candidate(encodedText = \"a quick brown fox jumps over the lazy dog\",rows = 4) == \"awsl n aq ozufvyioe cxrdk o jtbur\"\n assert candidate(encodedText = \"a b c d e\",rows = 5) == \"a b c\"\n assert candidate(encodedText = \"a bcd efgh ijklm nopqrst uvwxyz\",rows = 6) == \"a mqu r eibfc\"\n assert candidate(encodedText = \"a a a a a a a a a a\",rows = 10) == \"aaa\"\n assert candidate(encodedText = \"exampleofasingleword\",rows = 1) == \"exampleofasingleword\"\n assert candidate(encodedText = \"the quick brown fox jumps over lazy dogs\",rows = 5) == \"t xvdhb eoerjrg ou sqwmlunpi c\"\n assert candidate(encodedText = \"a very long text that is used to test the edge cases of the problem statement\",rows = 10) == \"ao ea ntut vghsee aerttye\"\n assert candidate(encodedText = \"a b c d e f g h i j k l m n o p q r s t u v w x y z\",rows = 6) == \"ae n w j s f o xb k t g pc l hd\"\n assert candidate(encodedText = \"onewordonly\",rows = 1) == \"onewordonly\"\n assert candidate(encodedText = \"python is an interpreted high level general purpose programming language\",rows = 6) == \"piiepayngrrntthaoghe lguorl ranpepag rvumeieermstlp e adn\"\n assert candidate(encodedText = \"abcdefghijklmnopqrstuvwxyz\",rows = 10) == \"adb\"\n assert candidate(encodedText = \"abcdefghijklmnopqrstuvwxyz\",rows = 26) == \"a\"\n assert candidate(encodedText = \"slantedtranspositioncipherexample\",rows = 10) == \"strlea\"\n"}, "metadata": {"canonical_parameter_names": ["encodedText", "rows"], "leetcode_dataset_entry_point": "Solution().decodeCiphertext", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string decodeCiphertext(string encodedText, int rows) {", "container": "Solution", "callable": "decodeCiphertext", "parameters": [{"name": "encodedText", "type": "string"}, {"name": "rows", "type": "int"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2076, "task_id": "process-restricted-friend-requests", "difficulty": "Hard", "problem_description": "You are given an integer n indicating the number of people in a network. Each person is labeled from 0 to n - 1.\nYou are also given a 0-indexed 2D integer array restrictions, where restrictions[i] = [xi, yi] means that person xi and person yi cannot become friends, either directly or indirectly through other people.\nInitially, no one is friends with each other. You are given a list of friend requests as a 0-indexed 2D integer array requests, where requests[j] = [uj, vj] is a friend request between person uj and person vj.\nA friend request is successful if uj and vj can be friends. Each friend request is processed in the given order (i.e., requests[j] occurs before requests[j + 1]), and upon a successful request, uj and vj become direct friends for all future friend requests.\nReturn a boolean array result, where each result[j] is true if the jth friend request is successful or false if it is not.\nNote: If uj and vj are already direct friends, the request is still successful.\n \nExample 1:\n\nInput: n = 3, restrictions = [[0,1]], requests = [[0,2],[2,1]]\nOutput: [true,false]\nExplanation:\nRequest 0: Person 0 and person 2 can be friends, so they become direct friends. \nRequest 1: Person 2 and person 1 cannot be friends since person 0 and person 1 would be indirect friends (1--2--0).\n\nExample 2:\n\nInput: n = 3, restrictions = [[0,1]], requests = [[1,2],[0,2]]\nOutput: [true,false]\nExplanation:\nRequest 0: Person 1 and person 2 can be friends, so they become direct friends.\nRequest 1: Person 0 and person 2 cannot be friends since person 0 and person 1 would be indirect friends (0--2--1).\n\nExample 3:\n\nInput: n = 5, restrictions = [[0,1],[1,2],[2,3]], requests = [[0,4],[1,2],[3,1],[3,4]]\nOutput: [true,false,true,false]\nExplanation:\nRequest 0: Person 0 and person 4 can be friends, so they become direct friends.\nRequest 1: Person 1 and person 2 cannot be friends since they are directly restricted.\nRequest 2: Person 3 and person 1 can be friends, so they become direct friends.\nRequest 3: Person 3 and person 4 cannot be friends since person 0 and person 1 would be indirect friends (0--4--3--1).\n\n \nConstraints:\n\n2 <= n <= 1000\n0 <= restrictions.length <= 1000\nrestrictions[i].length == 2\n0 <= xi, yi <= n - 1\nxi != yi\n1 <= requests.length <= 1000\nrequests[j].length == 2\n0 <= uj, vj <= n - 1\nuj != vj\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 4,restrictions = [[0, 2], [1, 3]],requests = [[0, 1], [2, 3], [0, 3]]) == [True, True, False]\n assert candidate(n = 4,restrictions = [],requests = [[0, 1], [1, 2], [2, 3], [3, 0]]) == [True, True, True, True]\n assert candidate(n = 4,restrictions = [[0, 2], [1, 3]],requests = [[0, 1], [2, 3], [1, 2]]) == [True, True, False]\n assert candidate(n = 5,restrictions = [[0, 1], [1, 2], [2, 3]],requests = [[0, 4], [1, 2], [3, 1], [3, 4]]) == [True, False, True, False]\n assert candidate(n = 6,restrictions = [[1, 4], [2, 5]],requests = [[0, 3], [1, 2], [3, 4]]) == [True, True, True]\n assert candidate(n = 6,restrictions = [[0, 1], [2, 3], [4, 5]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 0], [5, 1]]) == [True, True, True, True, True, True]\n assert candidate(n = 6,restrictions = [[0, 1], [2, 3], [4, 5]],requests = [[0, 2], [1, 3], [4, 5], [2, 4]]) == [True, True, False, True]\n assert candidate(n = 3,restrictions = [[0, 1]],requests = [[1, 2], [0, 2]]) == [True, False]\n assert candidate(n = 3,restrictions = [[0, 1]],requests = [[0, 2], [2, 1]]) == [True, False]\n assert candidate(n = 10,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],requests = [[0, 5], [2, 7], [4, 9], [1, 6]]) == [True, True, True, True]\n assert candidate(n = 12,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11]],requests = [[0, 2], [1, 3], [4, 6], [5, 7], [8, 10], [9, 11], [0, 5], [2, 7], [4, 9], [6, 11]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 7,restrictions = [[0, 6], [1, 5], [2, 4]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0]]) == [True, True, True, False, True, True, False]\n assert candidate(n = 20,restrictions = [[0, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 10]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 9,restrictions = [[0, 3], [1, 4], [2, 5], [6, 8]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 0], [7, 1], [8, 2]]) == [True, True, False, True, True, True, True, False, True, True, False, False, True, True, True, False, False, True]\n assert candidate(n = 7,restrictions = [[0, 3], [1, 4], [2, 5], [3, 6], [4, 0], [5, 1], [6, 2]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0]]) == [True, True, False, True, True, False, False]\n assert candidate(n = 10,restrictions = [[0, 2], [1, 3], [4, 6], [5, 7], [8, 9]],requests = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [0, 9], [1, 8], [2, 7], [3, 6], [4, 3], [5, 2], [6, 1], [7, 0], [8, 5], [9, 4]]) == [True, True, True, True, False, True, False, True, True, False, False, False, False, True, False]\n assert candidate(n = 15,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 0], [14, 1]]) == [True, True, True, True, True, True, True, True, True, True, True, True, False, False, False]\n assert candidate(n = 8,restrictions = [[0, 4], [1, 5], [2, 6], [3, 7]],requests = [[0, 1], [2, 3], [4, 5], [6, 7], [0, 5]]) == [True, True, True, True, False]\n assert candidate(n = 10,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [True, True, True, True, False]\n assert candidate(n = 8,restrictions = [[0, 7], [1, 6], [2, 5], [3, 4]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0]]) == [True, True, True, False, True, True, True, False]\n assert candidate(n = 9,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0], [0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 0], [8, 1]],requests = [[0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 0], [6, 1], [7, 2], [8, 3]]) == [True, True, True, True, False, False, False, False, False]\n assert candidate(n = 12,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False]\n assert candidate(n = 15,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 5], [9, 10], [10, 11], [11, 12], [12, 9], [13, 14], [14, 13]],requests = [[0, 3], [1, 4], [2, 0], [3, 1], [4, 2], [5, 8], [6, 9], [7, 10], [8, 11], [9, 12], [10, 5], [11, 6], [12, 7]]) == [True, True, False, False, False, False, True, True, True, False, True, True, True]\n assert candidate(n = 12,restrictions = [[0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11]],requests = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [0, 11]]) == [True, True, True, True, True, True, True]\n assert candidate(n = 8,restrictions = [[0, 4], [1, 5], [2, 6], [3, 7]],requests = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4], [0, 5], [1, 6], [2, 7], [3, 4]]) == [True, True, True, True, True, True, True, True, False, False, False, False]\n assert candidate(n = 8,restrictions = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4]],requests = [[0, 4], [1, 5], [2, 6], [3, 7], [0, 5], [1, 6], [2, 7], [3, 4]]) == [True, True, True, True, False, False, False, False]\n assert candidate(n = 8,restrictions = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4]],requests = [[0, 4], [1, 5], [2, 6], [3, 7]]) == [True, True, True, True]\n assert candidate(n = 10,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],requests = [[0, 5], [2, 7], [4, 9], [1, 6], [3, 8]]) == [True, True, True, True, True]\n assert candidate(n = 10,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]],requests = [[0, 2], [1, 3], [4, 6], [5, 7], [8, 0], [9, 1]]) == [True, True, True, True, True, True]\n assert candidate(n = 7,restrictions = [[0, 3], [1, 4], [2, 5], [3, 6], [4, 0], [5, 1], [6, 2]],requests = [[0, 6], [1, 5], [2, 4], [3, 0], [4, 1], [5, 2], [6, 3]]) == [True, False, True, False, False, False, False]\n assert candidate(n = 15,restrictions = [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == [True, True, True, True, False, True, True, True, True, False, True, True, True, True]\n assert candidate(n = 8,restrictions = [[0, 2], [1, 3], [4, 6], [5, 7]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 0], [0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [5, 0], [6, 1], [7, 2]]) == [True, False, True, True, True, False, True, True, False, False, True, False, False, False, True, False]\n assert candidate(n = 15,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 0]],requests = [[0, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12], [12, 14], [14, 1]]) == [True, True, True, True, True, True, False, True]\n assert candidate(n = 9,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [0, 8]],requests = [[0, 8], [1, 7], [2, 6], [3, 5], [4, 8], [0, 7], [1, 6], [2, 5], [3, 4]]) == [False, True, True, True, True, False, False, False, False]\n assert candidate(n = 10,restrictions = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0], [0, 2], [2, 4], [4, 6], [6, 8], [8, 0]]) == [True, True, True, True, False, True, True, True, True, False, True, True, False, True, False]\n assert candidate(n = 10,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 0], [9, 1]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 15,restrictions = [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [5, 10], [6, 11], [7, 12], [8, 13], [9, 14]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0]]) == [True, True, True, True, False, True, True, True, True, False, True, True, True, True, True]\n assert candidate(n = 7,restrictions = [[0, 2], [1, 3], [4, 6]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0], [0, 3], [1, 4], [2, 5]]) == [True, False, True, True, True, False, True, False, False, True]\n assert candidate(n = 12,restrictions = [[0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 6], [0, 7], [1, 8], [2, 9], [3, 10], [4, 11], [5, 6]]) == [True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False]\n assert candidate(n = 10,restrictions = [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9]],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5], [5, 0], [6, 1], [7, 2], [8, 3], [9, 4]]) == [True, True, False, True, True, False, False, False, False, False]\n assert candidate(n = 15,restrictions = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 11], [10, 12], [11, 13], [12, 14], [13, 0], [14, 1]],requests = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8], [7, 0]]) == [True, True, True, True, True, True, False, True]\n assert candidate(n = 12,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]],requests = [[0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 0], [7, 1], [8, 2], [9, 3], [10, 4], [11, 5]]) == [True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 7,restrictions = [[0, 2], [1, 3], [4, 6]],requests = [[0, 1], [2, 3], [4, 5], [5, 6], [0, 3], [2, 5]]) == [True, True, True, False, False, True]\n assert candidate(n = 9,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 0]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 0], [8, 1]]) == [True, True, True, True, True, True, False, False, False]\n assert candidate(n = 9,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 0]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 0], [8, 1], [0, 4]]) == [True, True, True, True, True, True, False, False, True, True]\n assert candidate(n = 15,restrictions = [[0, 14], [1, 13], [2, 12], [3, 11], [4, 10], [5, 9], [6, 8]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 0], [0, 13], [1, 12], [2, 11], [3, 10], [4, 9], [5, 8], [6, 7]]) == [True, True, True, True, True, True, True, False, True, True, True, True, True, True, False, False, False, False, False, False, False, True]\n assert candidate(n = 5,restrictions = [[0, 2], [1, 3]],requests = [[0, 1], [2, 3], [1, 4], [3, 4]]) == [True, True, True, False]\n assert candidate(n = 7,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6]],requests = [[0, 6], [1, 5], [2, 4], [3, 0], [4, 1], [5, 2], [6, 3]]) == [True, True, True, True, False, False, True]\n assert candidate(n = 20,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 0]],requests = [[0, 10], [1, 11], [2, 12], [3, 13], [4, 14], [5, 15], [6, 16], [7, 17], [8, 18], [9, 19], [0, 5], [1, 6], [2, 7], [3, 8], [4, 9], [10, 15], [11, 16], [12, 17], [13, 18], [14, 19]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10,restrictions = [[0, 1], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9]],requests = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]]) == [True, True, True, True, False]\n assert candidate(n = 8,restrictions = [[0, 1], [2, 3], [4, 5], [5, 6], [6, 7]],requests = [[0, 2], [1, 4], [3, 5], [5, 7], [0, 7], [4, 6]]) == [True, True, True, True, False, True]\n assert candidate(n = 15,restrictions = [[0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [10, 11], [11, 12], [12, 10], [13, 14]],requests = [[0, 4], [1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12], [9, 13], [10, 14], [11, 0], [12, 1], [13, 2], [14, 3]]) == [True, True, True, True, True, True, True, True, True, True, True, False, False, False, False]\n assert candidate(n = 8,restrictions = [[0, 2], [1, 3], [4, 6], [5, 7]],requests = [[0, 1], [2, 3], [4, 5], [6, 7], [0, 2], [1, 3], [4, 6], [5, 7], [0, 4], [2, 6], [1, 5], [3, 7], [0, 6], [2, 4], [1, 7], [3, 5]]) == [True, True, True, True, False, False, False, False, True, True, True, True, False, False, False, False]\n assert candidate(n = 7,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 0]],requests = [[0, 3], [1, 4], [2, 5], [3, 6], [4, 0], [5, 1], [6, 2]]) == [True, True, True, False, False, False, False]\n assert candidate(n = 10,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]],requests = [[0, 9], [1, 0], [2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6], [8, 7], [9, 8]]) == [False, False, False, False, False, False, False, False, False, False]\n assert candidate(n = 12,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11]],requests = [[0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [6, 0], [7, 1], [8, 2], [9, 3], [10, 4], [11, 5]]) == [True, True, True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]],requests = [[0, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 5]]) == [True, True, True, True, True, True]\n assert candidate(n = 10,restrictions = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [0, 9]]) == [True, True, True, True, False, True, True, True, True, False]\n assert candidate(n = 8,restrictions = [[0, 3], [1, 4], [2, 5], [3, 6], [4, 7]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [0, 7], [1, 6]]) == [True, True, True, True, True, True, False, False]\n assert candidate(n = 12,restrictions = [[0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11]],requests = [[0, 5], [1, 4], [2, 3], [6, 11], [7, 10], [8, 9], [0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [True, True, True, True, True, True, False, False, False, False, False, False]\n assert candidate(n = 10,restrictions = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 9], [9, 5]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 12,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11]],requests = [[0, 2], [1, 3], [4, 6], [5, 7], [8, 10], [9, 11], [0, 11], [1, 10], [2, 9], [3, 8], [4, 7], [5, 6]]) == [True, True, True, True, True, True, True, True, True, True, False, False]\n assert candidate(n = 11,restrictions = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9], [8, 10], [9, 0], [10, 1]]) == [True, True, True, True, True, True, True, True, True, False, False]\n assert candidate(n = 20,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15], [16, 17], [18, 19]],requests = [[0, 2], [1, 3], [4, 6], [5, 7], [8, 10], [9, 11], [12, 14], [13, 15], [16, 18], [17, 19], [0, 19], [1, 18], [2, 17], [3, 16], [4, 15], [5, 14], [6, 13], [7, 12], [8, 11], [9, 10]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False]\n assert candidate(n = 12,restrictions = [[0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [0, 7], [1, 8], [2, 9], [3, 10], [4, 11], [5, 6]]) == [True, True, True, True, True, False, False, False, False, False, False]\n assert candidate(n = 15,restrictions = [[0, 7], [1, 8], [2, 9], [3, 10], [4, 11], [5, 12], [6, 13], [7, 14]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14]]) == [True, True, True, True, True, True, False, True, True, True, True, True, True, False]\n assert candidate(n = 9,restrictions = [[0, 1], [2, 3], [4, 5], [6, 7]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 0], [8, 1], [0, 8], [1, 7], [2, 6], [3, 5], [4, 3], [5, 2], [6, 1], [7, 0], [8, 6], [0, 4], [1, 5], [2, 7], [3, 8]]) == [True, True, True, True, True, True, True, False, False, True, True, True, True, False, False, False, False, True, True, True, False, False]\n assert candidate(n = 12,restrictions = [[0, 3], [1, 4], [2, 5], [6, 9], [7, 10], [8, 11]],requests = [[0, 1], [1, 2], [3, 4], [4, 5], [6, 7], [7, 8], [9, 10], [10, 11], [0, 6], [1, 7], [2, 8], [3, 9], [4, 10], [5, 11], [0, 2], [1, 3], [4, 6], [5, 7], [8, 10], [9, 11]]) == [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, True]\n assert candidate(n = 6,restrictions = [[0, 1], [2, 3], [4, 5]],requests = [[0, 2], [1, 3], [2, 4], [3, 5], [0, 5], [1, 4]]) == [True, True, True, True, False, False]\n assert candidate(n = 10,restrictions = [[0, 5], [1, 6], [2, 7], [3, 8], [4, 9]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 0], [5, 6], [6, 7], [7, 8], [8, 9], [9, 5]]) == [True, True, True, True, True, True, True, True, True, True]\n assert candidate(n = 10,restrictions = [[0, 9], [1, 8], [2, 7], [3, 6], [4, 5]],requests = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 0]]) == [True, True, True, True, False, True, True, True, True, False]\n assert candidate(n = 8,restrictions = [[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7]],requests = [[0, 3], [1, 4], [2, 5], [3, 6], [4, 7], [0, 1], [2, 3], [4, 5], [6, 7]]) == [True, True, True, True, True, False, False, False, False]\n"}, "metadata": {"canonical_parameter_names": ["n", "restrictions", "requests"], "leetcode_dataset_entry_point": "Solution().friendRequests", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector friendRequests(int n, vector>& restrictions, vector>& requests) {", "container": "Solution", "callable": "friendRequests", "parameters": [{"name": "n", "type": "int"}, {"name": "restrictions", "type": "vector>&"}, {"name": "requests", "type": "vector>&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2078, "task_id": "two-furthest-houses-with-different-colors", "difficulty": "Easy", "problem_description": "There are n houses evenly lined up on the street, and each house is beautifully painted. You are given a 0-indexed integer array colors of length n, where colors[i] represents the color of the ith house.\nReturn the maximum distance between two houses with different colors.\nThe distance between the ith and jth houses is abs(i - j), where abs(x) is the absolute value of x.\n \nExample 1:\n\n\nInput: colors = [1,1,1,6,1,1,1]\nOutput: 3\nExplanation: In the above image, color 1 is blue, and color 6 is red.\nThe furthest two houses with different colors are house 0 and house 3.\nHouse 0 has color 1, and house 3 has color 6. The distance between them is abs(0 - 3) = 3.\nNote that houses 3 and 6 can also produce the optimal answer.\n\nExample 2:\n\n\nInput: colors = [1,8,3,8,3]\nOutput: 4\nExplanation: In the above image, color 1 is blue, color 8 is yellow, and color 3 is green.\nThe furthest two houses with different colors are house 0 and house 4.\nHouse 0 has color 1, and house 4 has color 3. The distance between them is abs(0 - 4) = 4.\n\nExample 3:\n\nInput: colors = [0,1]\nOutput: 1\nExplanation: The furthest two houses with different colors are house 0 and house 1.\nHouse 0 has color 0, and house 1 has color 1. The distance between them is abs(0 - 1) = 1.\n\n \nConstraints:\n\nn == colors.length\n2 <= n <= 100\n0 <= colors[i] <= 100\nTest data are generated such that at least two houses have different colors.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(colors = [10, 20, 10, 10, 10]) == 3\n assert candidate(colors = [10, 20, 30, 40, 50]) == 4\n assert candidate(colors = [100, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 9\n assert candidate(colors = [3, 1, 3, 3, 3]) == 3\n assert candidate(colors = [1, 1, 1, 6, 1, 1, 1]) == 3\n assert candidate(colors = [1, 2, 3, 4, 5]) == 4\n assert candidate(colors = [5, 5, 5, 5, 1]) == 4\n assert candidate(colors = [5, 5, 5, 5, 5, 2]) == 5\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 9\n assert candidate(colors = [7, 7, 7, 7, 7, 7, 7, 7, 7, 8]) == 9\n assert candidate(colors = [1, 1, 2, 1, 1]) == 2\n assert candidate(colors = [1, 1, 2, 1, 1, 1, 1]) == 4\n assert candidate(colors = [100, 99, 98, 97, 96, 95]) == 5\n assert candidate(colors = [2, 2, 2, 2, 3, 2]) == 4\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 5, 5, 2]) == 9\n assert candidate(colors = [0, 1]) == 1\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 9\n assert candidate(colors = [1, 1, 1, 1, 1, 2]) == 5\n assert candidate(colors = [1, 8, 3, 8, 3]) == 4\n assert candidate(colors = [1, 1, 2, 1, 1, 1, 1, 1, 1, 1]) == 7\n assert candidate(colors = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 9\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 2]) == 7\n assert candidate(colors = [100, 0, 100, 100, 100]) == 3\n assert candidate(colors = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 9\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 2, 1]) == 8\n assert candidate(colors = [4, 4, 4, 4, 4, 4, 4, 4, 4, 2]) == 9\n assert candidate(colors = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == 18\n assert candidate(colors = [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 0]) == 30\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1]) == 33\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 32\n assert candidate(colors = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 32\n assert candidate(colors = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 57\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 55\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 20\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 29\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 21\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 31\n assert candidate(colors = [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 19\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 71\n assert candidate(colors = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]) == 29\n assert candidate(colors = [1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10]) == 29\n assert candidate(colors = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10]) == 20\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]) == 52\n assert candidate(colors = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 77\n assert candidate(colors = [10, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 10]) == 54\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1]) == 80\n assert candidate(colors = [34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35]) == 81\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 59\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 77\n assert candidate(colors = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == 19\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 21\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 57\n assert candidate(colors = [7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 9]) == 75\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 17\n assert candidate(colors = [1, 1, 1, 1, 2, 1, 1, 1, 1, 1]) == 5\n assert candidate(colors = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 1]) == 29\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 52\n assert candidate(colors = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == 55\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 10\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 57\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1]) == 19\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2]) == 55\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50]) == 90\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == 19\n assert candidate(colors = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 99\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6]) == 56\n assert candidate(colors = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4]) == 75\n assert candidate(colors = [34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35]) == 56\n assert candidate(colors = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]) == 77\n assert candidate(colors = [1, 2, 2, 2, 2, 2, 2, 2, 2, 1]) == 8\n assert candidate(colors = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 18\n assert candidate(colors = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 1]) == 53\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 5, 5]) == 10\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 45\n assert candidate(colors = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2]) == 52\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 68\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 78\n assert candidate(colors = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 2]) == 78\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 17\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1]) == 30\n assert candidate(colors = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 1]) == 77\n assert candidate(colors = [1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1]) == 5\n assert candidate(colors = [100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100, 0, 100]) == 29\n assert candidate(colors = [99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 0]) == 71\n assert candidate(colors = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 9\n assert candidate(colors = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 11\n assert candidate(colors = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 87\n assert candidate(colors = [10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1, 10, 1]) == 19\n assert candidate(colors = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 1]) == 49\n"}, "metadata": {"canonical_parameter_names": ["colors"], "leetcode_dataset_entry_point": "Solution().maxDistance", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxDistance(vector& colors) {", "container": "Solution", "callable": "maxDistance", "parameters": [{"name": "colors", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2079, "task_id": "watering-plants", "difficulty": "Medium", "problem_description": "You want to water n plants in your garden with a watering can. The plants are arranged in a row and are labeled from 0 to n - 1 from left to right where the ith plant is located at x = i. There is a river at x = -1 that you can refill your watering can at.\nEach plant needs a specific amount of water. You will water the plants in the following way:\n\nWater the plants in order from left to right.\nAfter watering the current plant, if you do not have enough water to completely water the next plant, return to the river to fully refill the watering can.\nYou cannot refill the watering can early.\n\nYou are initially at the river (i.e., x = -1). It takes one step to move one unit on the x-axis.\nGiven a 0-indexed integer array plants of n integers, where plants[i] is the amount of water the ith plant needs, and an integer capacity representing the watering can capacity, return the number of steps needed to water all the plants.\n \nExample 1:\n\nInput: plants = [2,2,3,3], capacity = 5\nOutput: 14\nExplanation: Start at the river with a full watering can:\n- Walk to plant 0 (1 step) and water it. Watering can has 3 units of water.\n- Walk to plant 1 (1 step) and water it. Watering can has 1 unit of water.\n- Since you cannot completely water plant 2, walk back to the river to refill (2 steps).\n- Walk to plant 2 (3 steps) and water it. Watering can has 2 units of water.\n- Since you cannot completely water plant 3, walk back to the river to refill (3 steps).\n- Walk to plant 3 (4 steps) and water it.\nSteps needed = 1 + 1 + 2 + 3 + 3 + 4 = 14.\n\nExample 2:\n\nInput: plants = [1,1,1,4,2,3], capacity = 4\nOutput: 30\nExplanation: Start at the river with a full watering can:\n- Water plants 0, 1, and 2 (3 steps). Return to river (3 steps).\n- Water plant 3 (4 steps). Return to river (4 steps).\n- Water plant 4 (5 steps). Return to river (5 steps).\n- Water plant 5 (6 steps).\nSteps needed = 3 + 3 + 4 + 4 + 5 + 5 + 6 = 30.\n\nExample 3:\n\nInput: plants = [7,7,7,7,7,7,7], capacity = 8\nOutput: 49\nExplanation: You have to refill before watering each plant.\nSteps needed = 1 + 1 + 2 + 2 + 3 + 3 + 4 + 4 + 5 + 5 + 6 + 6 + 7 = 49.\n\n \nConstraints:\n\nn == plants.length\n1 <= n <= 1000\n1 <= plants[i] <= 106\nmax(plants[i]) <= capacity <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(plants = [1000000],capacity = 1000000) == 1\n assert candidate(plants = [3, 2, 4, 2, 1],capacity = 6) == 17\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacity = 1) == 100\n assert candidate(plants = [5, 5, 5, 5, 5],capacity = 5) == 25\n assert candidate(plants = [10, 10, 10],capacity = 10) == 9\n assert candidate(plants = [1, 1, 1, 4, 2, 3],capacity = 4) == 30\n assert candidate(plants = [1, 2, 3, 4, 5],capacity = 10) == 13\n assert candidate(plants = [1, 2, 3],capacity = 6) == 3\n assert candidate(plants = [5, 8, 6],capacity = 10) == 9\n assert candidate(plants = [1, 1, 1, 1, 1],capacity = 5) == 5\n assert candidate(plants = [2, 2, 3, 3],capacity = 5) == 14\n assert candidate(plants = [3, 2, 4, 2, 1],capacity = 4) == 17\n assert candidate(plants = [7, 7, 7, 7, 7, 7, 7],capacity = 8) == 49\n assert candidate(plants = [2, 4, 5, 1, 2],capacity = 6) == 17\n assert candidate(plants = [10],capacity = 10) == 1\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 15) == 146\n assert candidate(plants = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],capacity = 5) == 961\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 25) == 242\n assert candidate(plants = [9, 8, 7, 6, 5, 4, 3, 2, 1],capacity = 10) == 41\n assert candidate(plants = [2, 3, 2, 1, 4, 2, 1, 3, 2, 1, 4, 2, 1],capacity = 6) == 77\n assert candidate(plants = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4],capacity = 3) == 138\n assert candidate(plants = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],capacity = 50) == 88\n assert candidate(plants = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],capacity = 10) == 362\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 10) == 200\n assert candidate(plants = [2, 4, 5, 1, 2],capacity = 5) == 17\n assert candidate(plants = [7, 2, 5, 9, 3, 8, 4, 6, 1, 1, 1, 1],capacity = 15) == 42\n assert candidate(plants = [1, 3, 2, 4, 2, 1, 3, 2, 1, 4, 2, 1],capacity = 5) == 78\n assert candidate(plants = [5, 8, 6, 10, 2, 1, 1, 1, 1, 1],capacity = 12) == 32\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacity = 20) == 152\n assert candidate(plants = [2, 4, 5, 1, 2, 3, 4, 5, 6, 7, 8],capacity = 12) == 71\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacity = 10) == 54\n assert candidate(plants = [9, 1, 5, 3, 7, 8, 4, 2],capacity = 10) == 42\n assert candidate(plants = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],capacity = 20) == 213\n assert candidate(plants = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],capacity = 30) == 2881\n assert candidate(plants = [2, 4, 6, 8, 10],capacity = 10) == 23\n assert candidate(plants = [1000000, 500000, 1000000, 500000, 1000000, 500000],capacity = 1000000) == 36\n assert candidate(plants = [100, 200, 300, 400, 500],capacity = 1000) == 13\n assert candidate(plants = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],capacity = 3) == 900\n assert candidate(plants = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],capacity = 150) == 68\n assert candidate(plants = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],capacity = 15) == 4499\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacity = 10) == 88\n assert candidate(plants = [1, 3, 2, 5, 4, 3, 2, 1],capacity = 5) == 50\n assert candidate(plants = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],capacity = 3) == 400\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacity = 18) == 52\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacity = 10) == 249\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacity = 15) == 68\n assert candidate(plants = [9, 1, 2, 3, 4, 5, 6, 7, 8],capacity = 10) == 65\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 10) == 200\n assert candidate(plants = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],capacity = 20) == 88\n assert candidate(plants = [5, 8, 6, 7, 4, 9],capacity = 12) == 28\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 4) == 400\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacity = 5) == 84\n assert candidate(plants = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],capacity = 5) == 200\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 25) == 180\n assert candidate(plants = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],capacity = 15) == 225\n assert candidate(plants = [2, 4, 6, 8, 10],capacity = 12) == 19\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 10) == 127\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacity = 2) == 511\n assert candidate(plants = [3, 1, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1, 3, 2, 1],capacity = 4) == 407\n assert candidate(plants = [5, 8, 6, 7, 9, 4, 2],capacity = 10) == 37\n assert candidate(plants = [7, 3, 5, 8, 10, 2, 6, 4, 9, 1],capacity = 15) == 52\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],capacity = 20) == 78\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacity = 1) == 6724\n assert candidate(plants = [7, 3, 6, 2, 5, 4, 9, 1, 8],capacity = 12) == 49\n assert candidate(plants = [9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9],capacity = 15) == 126\n assert candidate(plants = [100, 200, 100],capacity = 150) == 9\n assert candidate(plants = [100, 200, 300, 400, 500],capacity = 1000) == 13\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacity = 15) == 38\n assert candidate(plants = [100, 200, 300, 400, 500],capacity = 500) == 23\n assert candidate(plants = [5, 8, 6, 10, 2, 9, 4],capacity = 12) == 41\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacity = 5) == 2878\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 10) == 10082\n assert candidate(plants = [1000000, 1000000, 1000000],capacity = 1000000) == 9\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacity = 10) == 249\n assert candidate(plants = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],capacity = 10) == 146\n assert candidate(plants = [9, 8, 7, 6, 5, 4, 3, 2, 1],capacity = 5) == 67\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacity = 15) == 46\n assert candidate(plants = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],capacity = 14) == 200\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],capacity = 25) == 296\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],capacity = 20) == 177\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],capacity = 15) == 368\n assert candidate(plants = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],capacity = 14) == 200\n assert candidate(plants = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9],capacity = 10) == 276\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacity = 1) == 900\n"}, "metadata": {"canonical_parameter_names": ["plants", "capacity"], "leetcode_dataset_entry_point": "Solution().wateringPlants", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int wateringPlants(vector& plants, int capacity) {", "container": "Solution", "callable": "wateringPlants", "parameters": [{"name": "plants", "type": "vector&"}, {"name": "capacity", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2081, "task_id": "sum-of-k-mirror-numbers", "difficulty": "Hard", "problem_description": "A k-mirror number is a positive integer without leading zeros that reads the same both forward and backward in base-10 as well as in base-k.\n\nFor example, 9 is a 2-mirror number. The representation of 9 in base-10 and base-2 are 9 and 1001 respectively, which read the same both forward and backward.\nOn the contrary, 4 is not a 2-mirror number. The representation of 4 in base-2 is 100, which does not read the same both forward and backward.\n\nGiven the base k and the number n, return the sum of the n smallest k-mirror numbers.\n \nExample 1:\n\nInput: k = 2, n = 5\nOutput: 25\nExplanation:\nThe 5 smallest 2-mirror numbers and their representations in base-2 are listed as follows:\n base-10 base-2\n 1 1\n 3 11\n 5 101\n 7 111\n 9 1001\nTheir sum = 1 + 3 + 5 + 7 + 9 = 25. \n\nExample 2:\n\nInput: k = 3, n = 7\nOutput: 499\nExplanation:\nThe 7 smallest 3-mirror numbers are and their representations in base-3 are listed as follows:\n base-10 base-3\n 1 1\n 2 2\n 4 11\n 8 22\n 121 11111\n 151 12121\n 212 21212\nTheir sum = 1 + 2 + 4 + 8 + 121 + 151 + 212 = 499.\n\nExample 3:\n\nInput: k = 7, n = 17\nOutput: 20379000\nExplanation: The 17 smallest 7-mirror numbers are:\n1, 2, 3, 4, 5, 6, 8, 121, 171, 242, 292, 16561, 65656, 2137312, 4602064, 6597956, 6958596\n\n \nConstraints:\n\n2 <= k <= 9\n1 <= n <= 30\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(k = 2,n = 1) == 1\n assert candidate(k = 5,n = 8) == 638\n assert candidate(k = 8,n = 15) == 5818\n assert candidate(k = 9,n = 5) == 15\n assert candidate(k = 9,n = 6) == 21\n assert candidate(k = 8,n = 9) == 158\n assert candidate(k = 4,n = 8) == 1498\n assert candidate(k = 9,n = 30) == 18627530\n assert candidate(k = 2,n = 10) == 1772\n assert candidate(k = 4,n = 10) == 3224\n assert candidate(k = 3,n = 7) == 499\n assert candidate(k = 5,n = 10) == 1940\n assert candidate(k = 9,n = 10) == 509\n assert candidate(k = 9,n = 20) == 156242\n assert candidate(k = 4,n = 15) == 233041\n assert candidate(k = 6,n = 12) == 1297\n assert candidate(k = 8,n = 20) == 94182\n assert candidate(k = 3,n = 5) == 136\n assert candidate(k = 5,n = 15) == 20526195\n assert candidate(k = 2,n = 5) == 25\n assert candidate(k = 2,n = 30) == 2609044274\n assert candidate(k = 7,n = 17) == 20379000\n assert candidate(k = 7,n = 28) == 115121130305\n assert candidate(k = 5,n = 25) == 6849225412\n assert candidate(k = 3,n = 20) == 2863752\n assert candidate(k = 8,n = 28) == 7054305\n assert candidate(k = 7,n = 35) == 639048703165\n assert candidate(k = 9,n = 15) == 3203\n assert candidate(k = 5,n = 20) == 1000828708\n assert candidate(k = 7,n = 15) == 6822448\n assert candidate(k = 6,n = 25) == 7009551\n assert candidate(k = 8,n = 25) == 1651182\n assert candidate(k = 6,n = 30) == 28888231\n assert candidate(k = 2,n = 25) == 20005383\n assert candidate(k = 6,n = 28) == 19806423\n assert candidate(k = 4,n = 22) == 22726545\n assert candidate(k = 9,n = 29) == 16185088\n assert candidate(k = 5,n = 28) == 19101218022\n assert candidate(k = 9,n = 27) == 11349704\n assert candidate(k = 8,n = 17) == 27727\n assert candidate(k = 6,n = 15) == 4383\n assert candidate(k = 5,n = 30) == 43401017264\n assert candidate(k = 4,n = 28) == 721411086\n assert candidate(k = 3,n = 28) == 44192979\n assert candidate(k = 4,n = 20) == 12448815\n assert candidate(k = 9,n = 25) == 7586042\n assert candidate(k = 7,n = 19) == 91104965\n assert candidate(k = 9,n = 35) == 33584024\n assert candidate(k = 9,n = 28) == 13750746\n assert candidate(k = 2,n = 28) == 759196316\n assert candidate(k = 4,n = 25) == 38898160\n assert candidate(k = 6,n = 20) == 156389\n assert candidate(k = 3,n = 30) == 155059889\n assert candidate(k = 8,n = 18) == 41058\n assert candidate(k = 7,n = 20) == 321578997\n assert candidate(k = 7,n = 25) == 3428700695\n assert candidate(k = 8,n = 30) == 66619574\n assert candidate(k = 6,n = 18) == 41849\n assert candidate(k = 7,n = 30) == 241030621167\n"}, "metadata": {"canonical_parameter_names": ["k", "n"], "leetcode_dataset_entry_point": "Solution().kMirror", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long kMirror(int k, int n) {", "container": "Solution", "callable": "kMirror", "parameters": [{"name": "k", "type": "int"}, {"name": "n", "type": "int"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2085, "task_id": "count-common-words-with-one-occurrence", "difficulty": "Easy", "problem_description": "Given two string arrays words1 and words2, return the number of strings that appear exactly once in each of the two arrays.\n \nExample 1:\n\nInput: words1 = [\"leetcode\",\"is\",\"amazing\",\"as\",\"is\"], words2 = [\"amazing\",\"leetcode\",\"is\"]\nOutput: 2\nExplanation:\n- \"leetcode\" appears exactly once in each of the two arrays. We count this string.\n- \"amazing\" appears exactly once in each of the two arrays. We count this string.\n- \"is\" appears in each of the two arrays, but there are 2 occurrences of it in words1. We do not count this string.\n- \"as\" appears once in words1, but does not appear in words2. We do not count this string.\nThus, there are 2 strings that appear exactly once in each of the two arrays.\n\nExample 2:\n\nInput: words1 = [\"b\",\"bb\",\"bbb\"], words2 = [\"a\",\"aa\",\"aaa\"]\nOutput: 0\nExplanation: There are no strings that appear in each of the two arrays.\n\nExample 3:\n\nInput: words1 = [\"a\",\"ab\"], words2 = [\"a\",\"a\",\"a\",\"ab\"]\nOutput: 1\nExplanation: The only string that appears exactly once in each of the two arrays is \"ab\".\n\n \nConstraints:\n\n1 <= words1.length, words2.length <= 1000\n1 <= words1[i].length, words2[j].length <= 30\nwords1[i] and words2[j] consists only of lowercase English letters.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(words1 = ['one'],words2 = ['two']) == 0\n assert candidate(words1 = ['unique'],words2 = ['unique']) == 1\n assert candidate(words1 = ['b', 'bb', 'bbb'],words2 = ['a', 'aa', 'aaa']) == 0\n assert candidate(words1 = ['distinct'],words2 = ['distinct', 'distinct']) == 0\n assert candidate(words1 = ['a', 'b', 'c'],words2 = ['c', 'b', 'a']) == 3\n assert candidate(words1 = ['same', 'same'],words2 = ['same', 'same', 'same']) == 0\n assert candidate(words1 = ['a', 'ab'],words2 = ['a', 'a', 'a', 'ab']) == 1\n assert candidate(words1 = ['hello', 'world'],words2 = ['hello', 'world', 'hello']) == 1\n assert candidate(words1 = ['hello', 'world'],words2 = ['hello', 'world']) == 2\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['banana', 'apple', 'date']) == 2\n assert candidate(words1 = ['leetcode', 'is', 'amazing', 'as', 'is'],words2 = ['amazing', 'leetcode', 'is']) == 2\n assert candidate(words1 = ['repeat', 'repeat'],words2 = ['repeat', 'repeat']) == 0\n assert candidate(words1 = ['python', 'java', 'c++', 'javascript'],words2 = ['c++', 'java', 'python', 'python', 'javascript', 'java', 'c++', 'javascript', 'c++', 'javascript']) == 0\n assert candidate(words1 = ['abc', 'def', 'ghi', 'jkl'],words2 = ['def', 'ghi', 'jkl', 'mno', 'pqr', 'abc', 'def', 'ghi', 'jkl']) == 1\n assert candidate(words1 = ['python', 'java', 'c++', 'ruby'],words2 = ['java', 'c++', 'ruby', 'python', 'python', 'java']) == 2\n assert candidate(words1 = ['alpha', 'beta', 'gamma', 'delta'],words2 = ['delta', 'gamma', 'beta', 'alpha', 'alpha', 'beta', 'gamma', 'delta']) == 0\n assert candidate(words1 = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z'],words2 = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z']) == 0\n assert candidate(words1 = ['one', 'two', 'three', 'four', 'five'],words2 = ['two', 'three', 'four', 'five', 'six', 'seven', 'eight']) == 4\n assert candidate(words1 = ['hello', 'world', 'hello'],words2 = ['world', 'hello', 'hello', 'world']) == 0\n assert candidate(words1 = ['cat', 'dog', 'bird', 'fish'],words2 = ['cat', 'dog', 'bird', 'fish', 'dog', 'bird']) == 2\n assert candidate(words1 = ['hello', 'hello', 'world'],words2 = ['hello', 'world', 'world', 'world']) == 0\n assert candidate(words1 = ['cat', 'dog', 'fish'],words2 = ['dog', 'cat', 'bird', 'fish', 'dog', 'fish']) == 1\n assert candidate(words1 = ['a', 'b', 'c', 'd', 'e'],words2 = ['f', 'g', 'h', 'i', 'j']) == 0\n assert candidate(words1 = ['alpha', 'beta', 'gamma', 'delta'],words2 = ['alpha', 'beta', 'gamma', 'delta', 'delta']) == 3\n assert candidate(words1 = ['one', 'two', 'three', 'four', 'five', 'six'],words2 = ['three', 'four', 'seven', 'eight', 'nine', 'one', 'two']) == 4\n assert candidate(words1 = ['one', 'two', 'three', 'four'],words2 = ['four', 'three', 'two', 'one', 'one', 'two', 'three', 'four', 'four', 'three', 'two', 'one']) == 0\n assert candidate(words1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],words2 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']) == 0\n assert candidate(words1 = ['same', 'word', 'multiple'],words2 = ['same', 'word', 'multiple', 'same', 'word', 'multiple']) == 0\n assert candidate(words1 = ['test', 'case', 'one'],words2 = ['case', 'test', 'one', 'one', 'test', 'case']) == 0\n assert candidate(words1 = ['same', 'word', 'repeated'],words2 = ['same', 'word', 'repeated', 'same', 'word', 'repeated']) == 0\n assert candidate(words1 = ['hello', 'world', 'hello', 'world'],words2 = ['hello', 'world', 'hello', 'world', 'hello', 'world']) == 0\n assert candidate(words1 = ['x', 'y', 'z'],words2 = ['x', 'y', 'z', 'x', 'y', 'z']) == 0\n assert candidate(words1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'],words2 = ['a', 'b', 'b', 'c', 'd', 'd', 'e', 'f', 'f', 'g']) == 4\n assert candidate(words1 = ['car', 'truck', 'bus', 'van', 'car', 'truck'],words2 = ['bus', 'van', 'motorcycle', 'bicycle', 'bus', 'van', 'truck']) == 0\n assert candidate(words1 = ['cat', 'dog', 'fish', 'bird'],words2 = ['dog', 'cat', 'cat', 'fish', 'dog', 'bird']) == 2\n assert candidate(words1 = ['a', 'b', 'c', 'd', 'e'],words2 = ['f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'd', 'e']) == 5\n assert candidate(words1 = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'],words2 = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']) == 0\n assert candidate(words1 = ['same', 'word', 'repeated', 'multiple', 'times'],words2 = ['times', 'repeated', 'multiple', 'same', 'word', 'word']) == 4\n assert candidate(words1 = ['one', 'two', 'three', 'four'],words2 = ['four', 'three', 'two', 'one', 'one', 'two', 'three', 'four']) == 0\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['banana', 'apple', 'cherry', 'apple']) == 2\n assert candidate(words1 = ['a', 'b', 'c', 'd'],words2 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']) == 4\n assert candidate(words1 = ['a', 'b', 'c', 'd'],words2 = ['a', 'b', 'c', 'd', 'a', 'b', 'c', 'd']) == 0\n assert candidate(words1 = ['x', 'y', 'z', 'w', 'v'],words2 = ['x', 'y', 'z', 'w', 'v', 'x', 'y', 'z', 'w', 'v', 'x', 'y', 'z', 'w', 'v', 'x', 'y', 'z', 'w', 'v']) == 0\n assert candidate(words1 = ['a', 'b', 'c', 'd', 'e'],words2 = ['e', 'd', 'c', 'b', 'a', 'a', 'b', 'c', 'd', 'e']) == 0\n assert candidate(words1 = ['unique', 'words', 'only', 'once', 'here'],words2 = ['words', 'only', 'once', 'here', 'unique', 'twice', 'unique']) == 4\n assert candidate(words1 = ['x', 'y', 'z'],words2 = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z']) == 0\n assert candidate(words1 = ['cat', 'dog', 'elephant', 'frog', 'cat'],words2 = ['dog', 'frog', 'giraffe', 'elephant', 'hippo']) == 3\n assert candidate(words1 = ['cat', 'dog', 'fish'],words2 = ['fish', 'dog', 'cat', 'dog', 'cat']) == 1\n assert candidate(words1 = ['python', 'java', 'c', 'cpp'],words2 = ['python', 'java', 'java', 'csharp']) == 1\n assert candidate(words1 = ['unique', 'words', 'only', 'here'],words2 = ['here', 'only', 'words', 'unique', 'unique']) == 3\n assert candidate(words1 = ['hello', 'world', 'hello'],words2 = ['world', 'hello', 'world', 'hello', 'world', 'hello']) == 0\n assert candidate(words1 = ['hello', 'world', 'python', 'java', 'csharp'],words2 = ['python', 'java', 'csharp', 'hello', 'ruby', 'scala', 'world', 'python', 'java']) == 3\n assert candidate(words1 = ['x', 'y', 'z'],words2 = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z']) == 0\n assert candidate(words1 = ['unique', 'word', 'only', 'in', 'this', 'array'],words2 = ['unique', 'only', 'word', 'in', 'that', 'array']) == 5\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['banana', 'cherry', 'apple', 'apple']) == 2\n assert candidate(words1 = ['apple', 'banana', 'cherry', 'date'],words2 = ['banana', 'cherry', 'fig', 'grape']) == 2\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['banana', 'apple', 'apple', 'cherry', 'date']) == 2\n assert candidate(words1 = ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz', 'abc'],words2 = ['mno', 'pqr', 'stu', 'vwx', 'yz', 'abc', 'def', 'ghi', 'jkl', 'mno']) == 7\n assert candidate(words1 = ['apple', 'banana', 'cherry', 'date'],words2 = ['banana', 'date', 'fig', 'grape', 'apple']) == 3\n assert candidate(words1 = ['apple', 'banana', 'cherry', 'date', 'elderberry'],words2 = ['banana', 'cherry', 'elderberry', 'fig', 'grape', 'apple', 'date']) == 5\n assert candidate(words1 = ['a', 'b', 'c', 'a', 'b', 'c'],words2 = ['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c']) == 0\n assert candidate(words1 = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z'],words2 = ['x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z', 'x', 'y', 'z']) == 0\n assert candidate(words1 = ['sun', 'moon', 'star', 'planet', 'sun', 'moon'],words2 = ['star', 'planet', 'comet', 'asteroid', 'planet', 'star']) == 0\n assert candidate(words1 = ['alpha', 'beta', 'gamma', 'delta', 'epsilon'],words2 = ['gamma', 'delta', 'zeta', 'eta', 'theta', 'epsilon', 'delta']) == 2\n assert candidate(words1 = ['python', 'java', 'csharp'],words2 = ['java', 'csharp', 'python', 'python']) == 2\n assert candidate(words1 = ['python', 'java', 'c++'],words2 = ['c++', 'java', 'python', 'java', 'python', 'c++', 'python']) == 0\n assert candidate(words1 = ['cat', 'dog', 'mouse'],words2 = ['dog', 'cat', 'cat', 'mouse', 'dog']) == 1\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['banana', 'cherry', 'apple', 'banana']) == 2\n assert candidate(words1 = ['same', 'words', 'in', 'both', 'arrays'],words2 = ['same', 'words', 'in', 'both', 'arrays']) == 5\n assert candidate(words1 = ['single'],words2 = ['single', 'single', 'single', 'single']) == 0\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['cherry', 'banana', 'apple', 'apple']) == 2\n assert candidate(words1 = ['abc', 'def', 'ghi'],words2 = ['def', 'ghi', 'jkl', 'def', 'ghi']) == 0\n assert candidate(words1 = ['foo', 'bar', 'baz', 'qux', 'quux', 'corge', 'grault'],words2 = ['foo', 'bar', 'baz', 'qux', 'quux', 'corge', 'grault', 'grault']) == 6\n assert candidate(words1 = ['foo', 'bar', 'baz', 'qux'],words2 = ['foo', 'bar', 'qux', 'quux']) == 3\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['banana', 'apple', 'cherry', 'banana']) == 2\n assert candidate(words1 = ['hello', 'hello', 'world'],words2 = ['world', 'world', 'hello', 'hello', 'hello']) == 0\n assert candidate(words1 = ['one', 'two', 'three', 'four', 'five'],words2 = ['five', 'four', 'three', 'two', 'one']) == 5\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['banana', 'apple', 'cherry', 'cherry']) == 2\n assert candidate(words1 = ['unique', 'words', 'only'],words2 = ['only', 'words', 'unique', 'words']) == 2\n assert candidate(words1 = ['red', 'blue', 'green'],words2 = ['red', 'red', 'blue', 'green', 'blue', 'green']) == 0\n assert candidate(words1 = ['cat', 'dog', 'mouse', 'elephant'],words2 = ['dog', 'mouse', 'cat', 'tiger', 'elephant', 'dog']) == 3\n assert candidate(words1 = ['test', 'case', 'input'],words2 = ['input', 'test', 'case', 'input', 'test', 'case', 'input', 'test', 'case']) == 0\n assert candidate(words1 = ['hello', 'world', 'hello', 'world'],words2 = ['hello', 'world', 'world', 'hello']) == 0\n assert candidate(words1 = ['first', 'second', 'third', 'fourth'],words2 = ['fourth', 'third', 'second', 'first', 'first', 'second', 'third', 'fourth', 'first', 'second', 'third', 'fourth']) == 0\n assert candidate(words1 = ['one', 'two', 'three', 'four', 'five'],words2 = ['two', 'three', 'five', 'six', 'seven', 'eight', 'nine', 'one', 'four']) == 5\n assert candidate(words1 = ['repeated', 'repeated', 'words', 'in', 'both', 'arrays'],words2 = ['repeated', 'words', 'in', 'both', 'arrays', 'arrays']) == 3\n assert candidate(words1 = ['x', 'y', 'z'],words2 = ['z', 'y', 'x']) == 3\n assert candidate(words1 = ['a', 'b', 'c', 'd'],words2 = ['a', 'a', 'b', 'c', 'c', 'd', 'd', 'd']) == 1\n assert candidate(words1 = ['single'],words2 = ['single']) == 1\n assert candidate(words1 = ['hello', 'world', 'python', 'java'],words2 = ['python', 'java', 'hello', 'world', 'world', 'hello']) == 2\n assert candidate(words1 = ['a', 'b', 'c', 'd', 'e'],words2 = ['a', 'a', 'b', 'c', 'c', 'd', 'e', 'e']) == 2\n assert candidate(words1 = ['python', 'java', 'c', 'cpp'],words2 = ['java', 'c', 'cpp', 'ruby']) == 3\n assert candidate(words1 = ['unique', 'string', 'in', 'each', 'array'],words2 = ['different', 'string', 'in', 'each', 'array']) == 4\n assert candidate(words1 = ['single'],words2 = ['single', 'single', 'single']) == 0\n assert candidate(words1 = ['apple', 'banana', 'cherry'],words2 = ['banana', 'cherry', 'date']) == 2\n assert candidate(words1 = ['repeat', 'repeat', 'repeat'],words2 = ['repeat', 'repeat', 'repeat', 'repeat']) == 0\n assert candidate(words1 = ['red', 'blue', 'green', 'yellow', 'red'],words2 = ['blue', 'green', 'purple', 'yellow', 'blue', 'green']) == 1\n assert candidate(words1 = ['foo', 'bar', 'baz', 'qux', 'quux'],words2 = ['qux', 'quux', 'foo', 'bar', 'baz', 'corge', 'grault', 'foo']) == 4\n assert candidate(words1 = ['example', 'test', 'case'],words2 = ['test', 'case', 'example', 'example', 'test', 'case']) == 0\n assert candidate(words1 = ['unique'],words2 = ['unique', 'unique', 'unique']) == 0\n assert candidate(words1 = ['x', 'y', 'z', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'],words2 = ['x', 'y', 'z', 'w', 'v', 'u', 't', 's', 'r', 'q', 'p', 'o', 'n', 'm', 'l', 'k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a', 'x', 'y', 'z']) == 23\n assert candidate(words1 = ['a', 'b', 'c', 'd', 'e', 'f', 'g'],words2 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'c', 'd', 'e', 'f', 'g']) == 0\n assert candidate(words1 = ['unique'],words2 = ['unique', 'unique', 'unique', 'unique']) == 0\n"}, "metadata": {"canonical_parameter_names": ["words1", "words2"], "leetcode_dataset_entry_point": "Solution().countWords", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countWords(vector& words1, vector& words2) {", "container": "Solution", "callable": "countWords", "parameters": [{"name": "words1", "type": "vector&"}, {"name": "words2", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2086, "task_id": "minimum-number-of-food-buckets-to-feed-the-hamsters", "difficulty": "Medium", "problem_description": "You are given a 0-indexed string hamsters where hamsters[i] is either:\n\n'H' indicating that there is a hamster at index i, or\n'.' indicating that index i is empty.\n\nYou will add some number of food buckets at the empty indices in order to feed the hamsters. A hamster can be fed if there is at least one food bucket to its left or to its right. More formally, a hamster at index i can be fed if you place a food bucket at index i - 1 and/or at index i + 1.\nReturn the minimum number of food buckets you should place at empty indices to feed all the hamsters or -1 if it is impossible to feed all of them.\n \nExample 1:\n\n\nInput: hamsters = \"H..H\"\nOutput: 2\nExplanation: We place two food buckets at indices 1 and 2.\nIt can be shown that if we place only one food bucket, one of the hamsters will not be fed.\n\nExample 2:\n\n\nInput: hamsters = \".H.H.\"\nOutput: 1\nExplanation: We place one food bucket at index 2.\n\nExample 3:\n\n\nInput: hamsters = \".HHH.\"\nOutput: -1\nExplanation: If we place a food bucket at every empty index as shown, the hamster at index 2 will not be able to eat.\n\n \nConstraints:\n\n1 <= hamsters.length <= 105\nhamsters[i] is either'H' or '.'.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(hamsters = \"H\") == -1\n assert candidate(hamsters = \"H.H.H.H.H.H\") == 3\n assert candidate(hamsters = \"HH.H.H.H.H.H.H.H.H.H.H.H.H.H\") == -1\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H.H\") == 5\n assert candidate(hamsters = \".....\") == 0\n assert candidate(hamsters = \".\") == 0\n assert candidate(hamsters = \"H..H\") == 2\n assert candidate(hamsters = \"H.H\") == 1\n assert candidate(hamsters = \"H....H\") == 2\n assert candidate(hamsters = \"H.H.H.H.H\") == 3\n assert candidate(hamsters = \"HHHH\") == -1\n assert candidate(hamsters = \"H.H.H.H.H.H.H\") == 4\n assert candidate(hamsters = \"HH\") == -1\n assert candidate(hamsters = \"H.H.HH\") == -1\n assert candidate(hamsters = \".HHH.\") == -1\n assert candidate(hamsters = \"HH.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H\") == -1\n assert candidate(hamsters = \"HH.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H\") == -1\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H.H.H.H.H.H.H\") == 8\n assert candidate(hamsters = \"HH.HH.HH\") == -1\n assert candidate(hamsters = \"H.H.H\") == 2\n assert candidate(hamsters = \"HH.H.H.H.H\") == -1\n assert candidate(hamsters = \"H.H.H.H\") == 2\n assert candidate(hamsters = \"HH.HH\") == -1\n assert candidate(hamsters = \"HH.H.H.H.H.H.H.H.H.H.H\") == -1\n assert candidate(hamsters = \"HH.H.H.H.H.H.H.H.H.H.H.H\") == -1\n assert candidate(hamsters = \".H.H.\") == 1\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H\") == 4\n assert candidate(hamsters = \"H.HH\") == -1\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H.H.H.H.H\") == 7\n assert candidate(hamsters = \"HHHHHH\") == -1\n assert candidate(hamsters = \"HH.H.H\") == -1\n assert candidate(hamsters = \"HH.H\") == -1\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H\") == 5\n assert candidate(hamsters = \"HH.H.H.H.H.H.H\") == -1\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H\") == 10\n assert candidate(hamsters = \"HH.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H\") == -1\n assert candidate(hamsters = \"HH.H.HH\") == -1\n assert candidate(hamsters = \"......\") == 0\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H.H.H\") == 6\n assert candidate(hamsters = \"...\") == 0\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H.H\") == 9\n assert candidate(hamsters = \"H.H.HH.H.H\") == 4\n assert candidate(hamsters = \"H.....H\") == 2\n assert candidate(hamsters = \"H.H.H.H.H.H.H\") == 4\n assert candidate(hamsters = \"H.....H\") == 2\n assert candidate(hamsters = \".......\") == 0\n assert candidate(hamsters = \"HH.HHHHH.HH\") == -1\n assert candidate(hamsters = \".H.H.\") == 1\n assert candidate(hamsters = \"H.H.H.H.HH\") == -1\n assert candidate(hamsters = \"........\") == 0\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H\") == 5\n assert candidate(hamsters = \"..H.H..\") == 1\n assert candidate(hamsters = \"H.H.H.H.H\") == 3\n assert candidate(hamsters = \"HH.H.H.HH\") == -1\n assert candidate(hamsters = \"HH\") == -1\n assert candidate(hamsters = \"H.HH.H\") == 2\n assert candidate(hamsters = \"HH.HH.HH.HH.HH.HH.HH.HH\") == -1\n assert candidate(hamsters = \"...\") == 0\n assert candidate(hamsters = \"H.\") == 1\n assert candidate(hamsters = \"H.H..H.H\") == 2\n assert candidate(hamsters = \"H.......H\") == 2\n assert candidate(hamsters = \"..H..H..\") == 2\n assert candidate(hamsters = \"HHHHH\") == -1\n assert candidate(hamsters = \"HH.HH\") == -1\n assert candidate(hamsters = \"HH.H.H.H.HH\") == -1\n assert candidate(hamsters = \"H...H\") == 2\n assert candidate(hamsters = \"HH.HHH.HH\") == -1\n assert candidate(hamsters = \"........\") == 0\n assert candidate(hamsters = \"H.H.H.HH.H\") == 3\n assert candidate(hamsters = \"HH.HH.HH.HH\") == -1\n assert candidate(hamsters = \"H.H.H.H\") == 2\n assert candidate(hamsters = \".\") == 0\n assert candidate(hamsters = \"HHHHHHHHHH\") == -1\n assert candidate(hamsters = \".HHH.\") == -1\n assert candidate(hamsters = \"H.H.H.HH\") == -1\n assert candidate(hamsters = \".H\") == 1\n assert candidate(hamsters = \".H.H.H.H.\") == 2\n assert candidate(hamsters = \"H.H.H\") == 2\n assert candidate(hamsters = \"H\") == -1\n assert candidate(hamsters = \".........\") == 0\n assert candidate(hamsters = \".H.H.H.H.H.H.H.H.H.\") == 5\n assert candidate(hamsters = \".H.H.H.H.H.H.H.H.\") == 4\n assert candidate(hamsters = \"HHHHHHH\") == -1\n assert candidate(hamsters = \"HH...HH\") == -1\n assert candidate(hamsters = \"H.H.H.H.H.H.H.H.H.H.H.H\") == 6\n assert candidate(hamsters = \"H......H\") == 2\n assert candidate(hamsters = \"H.H\") == 1\n assert candidate(hamsters = \"HH.HH.HH.HH.HH\") == -1\n assert candidate(hamsters = \"H..H\") == 2\n assert candidate(hamsters = \"HH..HH\") == -1\n assert candidate(hamsters = \"HHHH\") == -1\n"}, "metadata": {"canonical_parameter_names": ["hamsters"], "leetcode_dataset_entry_point": "Solution().minimumBuckets", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumBuckets(string hamsters) {", "container": "Solution", "callable": "minimumBuckets", "parameters": [{"name": "hamsters", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2087, "task_id": "minimum-cost-homecoming-of-a-robot-in-a-grid", "difficulty": "Medium", "problem_description": "There is an m x n grid, where (0, 0) is the top-left cell and (m - 1, n - 1) is the bottom-right cell. You are given an integer array startPos where startPos = [startrow, startcol] indicates that initially, a robot is at the cell (startrow, startcol). You are also given an integer array homePos where homePos = [homerow, homecol] indicates that its home is at the cell (homerow, homecol).\nThe robot needs to go to its home. It can move one cell in four directions: left, right, up, or down, and it can not move outside the boundary. Every move incurs some cost. You are further given two 0-indexed integer arrays: rowCosts of length m and colCosts of length n.\n\nIf the robot moves up or down into a cell whose row is r, then this move costs rowCosts[r].\nIf the robot moves left or right into a cell whose column is c, then this move costs colCosts[c].\n\nReturn the minimum total cost for this robot to return home.\n \nExample 1:\n\n\nInput: startPos = [1, 0], homePos = [2, 3], rowCosts = [5, 4, 3], colCosts = [8, 2, 6, 7]\nOutput: 18\nExplanation: One optimal path is that:\nStarting from (1, 0)\n-> It goes down to (2, 0). This move costs rowCosts[2] = 3.\n-> It goes right to (2, 1). This move costs colCosts[1] = 2.\n-> It goes right to (2, 2). This move costs colCosts[2] = 6.\n-> It goes right to (2, 3). This move costs colCosts[3] = 7.\nThe total cost is 3 + 2 + 6 + 7 = 18\nExample 2:\n\nInput: startPos = [0, 0], homePos = [0, 0], rowCosts = [5], colCosts = [26]\nOutput: 0\nExplanation: The robot is already at its home. Since no moves occur, the total cost is 0.\n\n \nConstraints:\n\nm == rowCosts.length\nn == colCosts.length\n1 <= m, n <= 105\n0 <= rowCosts[r], colCosts[c] <= 104\nstartPos.length == 2\nhomePos.length == 2\n0 <= startrow, homerow < m\n0 <= startcol, homecol < n\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(startPos = [2, 2],homePos = [0, 0],rowCosts = [1, 10, 1],colCosts = [1, 10, 1]) == 22\n assert candidate(startPos = [3, 3],homePos = [0, 0],rowCosts = [10, 20, 30, 40],colCosts = [5, 15, 25, 35]) == 105\n assert candidate(startPos = [1, 0],homePos = [2, 3],rowCosts = [5, 4, 3],colCosts = [8, 2, 6, 7]) == 18\n assert candidate(startPos = [0, 0],homePos = [2, 2],rowCosts = [1, 10, 1],colCosts = [1, 10, 1]) == 22\n assert candidate(startPos = [0, 0],homePos = [2, 2],rowCosts = [1, 1, 1],colCosts = [1, 1, 1]) == 4\n assert candidate(startPos = [1, 1],homePos = [1, 1],rowCosts = [1, 2, 3],colCosts = [4, 5, 6]) == 0\n assert candidate(startPos = [2, 2],homePos = [0, 0],rowCosts = [1, 1, 1],colCosts = [1, 1, 1]) == 4\n assert candidate(startPos = [0, 1],homePos = [2, 1],rowCosts = [3, 2, 1],colCosts = [4, 5]) == 3\n assert candidate(startPos = [0, 0],homePos = [0, 0],rowCosts = [5],colCosts = [26]) == 0\n assert candidate(startPos = [2, 2],homePos = [2, 2],rowCosts = [1, 2],colCosts = [3, 4]) == 0\n assert candidate(startPos = [3, 2],homePos = [0, 0],rowCosts = [1, 2, 3, 4],colCosts = [5, 6, 7]) == 17\n assert candidate(startPos = [0, 1],homePos = [3, 3],rowCosts = [3, 2, 1, 4],colCosts = [4, 3, 2, 1]) == 10\n assert candidate(startPos = [0, 2],homePos = [2, 2],rowCosts = [10, 20, 30],colCosts = [5, 5, 5]) == 50\n assert candidate(startPos = [2, 3],homePos = [1, 1],rowCosts = [1, 1, 1],colCosts = [1, 1, 1, 1]) == 3\n assert candidate(startPos = [2, 3],homePos = [1, 0],rowCosts = [5, 4, 3],colCosts = [8, 2, 6, 7]) == 20\n assert candidate(startPos = [0, 1],homePos = [2, 2],rowCosts = [1, 2, 3],colCosts = [4, 5, 6]) == 11\n assert candidate(startPos = [3, 3],homePos = [7, 7],rowCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],colCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 8\n assert candidate(startPos = [1, 2],homePos = [3, 4],rowCosts = [5, 4, 3, 2],colCosts = [1, 2, 3, 4, 5]) == 14\n assert candidate(startPos = [0, 4],homePos = [4, 0],rowCosts = [1, 1, 1, 1, 1],colCosts = [1, 1, 1, 1, 1]) == 8\n assert candidate(startPos = [9, 0],homePos = [9, 9],rowCosts = [100],colCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 540\n assert candidate(startPos = [0, 0],homePos = [9, 9],rowCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],colCosts = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 99\n assert candidate(startPos = [9, 0],homePos = [0, 9],rowCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],colCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 99\n assert candidate(startPos = [2, 3],homePos = [2, 3],rowCosts = [5, 4, 3],colCosts = [8, 2, 6, 7]) == 0\n assert candidate(startPos = [5, 2],homePos = [0, 0],rowCosts = [1, 2, 3, 4, 5, 6],colCosts = [6, 5, 4, 3, 2, 1]) == 26\n assert candidate(startPos = [2, 1],homePos = [2, 1],rowCosts = [1000, 2000, 3000, 4000],colCosts = [5000, 6000, 7000, 8000, 9000]) == 0\n assert candidate(startPos = [0, 9],homePos = [0, 0],rowCosts = [1],colCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 450\n assert candidate(startPos = [2, 3],homePos = [4, 1],rowCosts = [3, 2, 1, 4, 5],colCosts = [6, 7, 8, 9]) == 24\n assert candidate(startPos = [1, 2],homePos = [3, 4],rowCosts = [1, 2, 3, 4],colCosts = [4, 3, 2, 1]) == 8\n assert candidate(startPos = [0, 9],homePos = [9, 0],rowCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],colCosts = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 1080\n assert candidate(startPos = [5, 2],homePos = [2, 5],rowCosts = [10, 20, 30, 40, 50, 60],colCosts = [60, 50, 40, 30, 20, 10]) == 180\n assert candidate(startPos = [1, 1],homePos = [3, 3],rowCosts = [5, 10, 15, 20],colCosts = [10, 20, 30, 40]) == 105\n assert candidate(startPos = [2, 2],homePos = [7, 2],rowCosts = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11],colCosts = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 35\n assert candidate(startPos = [2, 4],homePos = [2, 4],rowCosts = [100, 200, 300],colCosts = [100, 200, 300, 400, 500]) == 0\n assert candidate(startPos = [2, 2],homePos = [2, 2],rowCosts = [100, 200, 300, 400, 500],colCosts = [100, 200, 300, 400, 500]) == 0\n assert candidate(startPos = [0, 5],homePos = [5, 0],rowCosts = [10, 20, 30, 40, 50, 60],colCosts = [60, 50, 40, 30, 20, 10]) == 400\n assert candidate(startPos = [1, 2],homePos = [4, 3],rowCosts = [100, 200, 300, 400, 500],colCosts = [10, 20, 30, 40]) == 1240\n assert candidate(startPos = [0, 3],homePos = [3, 0],rowCosts = [10, 20, 30, 40],colCosts = [5, 6, 7, 8]) == 108\n assert candidate(startPos = [4, 4],homePos = [0, 0],rowCosts = [10, 20, 30, 40, 50],colCosts = [1, 2, 3, 4, 5]) == 110\n assert candidate(startPos = [1, 3],homePos = [4, 1],rowCosts = [2, 3, 5, 7, 11],colCosts = [13, 17, 19, 23]) == 59\n assert candidate(startPos = [5, 0],homePos = [0, 5],rowCosts = [1, 1, 1, 1, 1],colCosts = [1, 2, 3, 4, 5]) == 19\n assert candidate(startPos = [5, 5],homePos = [0, 0],rowCosts = [1, 1, 1, 1, 1, 1],colCosts = [1, 1, 1, 1, 1, 1]) == 10\n assert candidate(startPos = [3, 3],homePos = [0, 0],rowCosts = [10000, 9000, 8000, 7000],colCosts = [6000, 5000, 4000, 3000]) == 42000\n assert candidate(startPos = [5, 5],homePos = [0, 0],rowCosts = [10, 20, 30, 40, 50, 60],colCosts = [6, 5, 4, 3, 2, 1]) == 170\n assert candidate(startPos = [0, 5],homePos = [5, 0],rowCosts = [2, 2, 2, 2, 2, 2],colCosts = [2, 2, 2, 2, 2, 2]) == 20\n assert candidate(startPos = [5, 5],homePos = [0, 0],rowCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],colCosts = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 550\n assert candidate(startPos = [3, 3],homePos = [1, 1],rowCosts = [100, 200, 300, 400],colCosts = [400, 300, 200, 100]) == 1000\n assert candidate(startPos = [7, 7],homePos = [2, 2],rowCosts = [11, 10, 9, 8, 7, 6, 5, 4, 3, 2],colCosts = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 60\n assert candidate(startPos = [5, 5],homePos = [0, 0],rowCosts = [9, 8, 7, 6, 5, 4],colCosts = [3, 2, 1, 4, 5, 6]) == 50\n assert candidate(startPos = [0, 0],homePos = [4, 5],rowCosts = [10, 20, 30, 40, 50],colCosts = [5, 15, 25, 35, 45, 55]) == 315\n assert candidate(startPos = [4, 4],homePos = [6, 6],rowCosts = [5, 1, 2, 3, 4, 3, 2, 1, 5, 10],colCosts = [10, 1, 2, 3, 4, 3, 2, 1, 5, 10]) == 10\n assert candidate(startPos = [3, 3],homePos = [0, 0],rowCosts = [10, 20, 30, 40],colCosts = [40, 30, 20, 10]) == 150\n assert candidate(startPos = [0, 0],homePos = [5, 5],rowCosts = [1, 2, 3, 4, 5, 6],colCosts = [6, 5, 4, 3, 2, 1]) == 35\n assert candidate(startPos = [0, 9],homePos = [9, 0],rowCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],colCosts = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 18\n assert candidate(startPos = [3, 2],homePos = [0, 0],rowCosts = [1, 1, 1, 1],colCosts = [1, 1, 1]) == 5\n assert candidate(startPos = [1, 0],homePos = [3, 2],rowCosts = [1, 1, 1, 1],colCosts = [1, 1, 1]) == 4\n assert candidate(startPos = [1, 2],homePos = [3, 0],rowCosts = [1, 1, 1, 1],colCosts = [1, 1, 1]) == 4\n assert candidate(startPos = [0, 0],homePos = [4, 4],rowCosts = [1, 2, 3, 4, 5],colCosts = [5, 4, 3, 2, 1]) == 24\n assert candidate(startPos = [10, 5],homePos = [10, 5],rowCosts = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],colCosts = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 0\n assert candidate(startPos = [0, 0],homePos = [3, 3],rowCosts = [1, 2, 3, 4],colCosts = [1, 1, 1, 1]) == 12\n assert candidate(startPos = [5, 5],homePos = [1, 1],rowCosts = [10, 20, 30, 40, 50, 60],colCosts = [15, 25, 35, 45, 55, 65]) == 300\n assert candidate(startPos = [2, 2],homePos = [4, 4],rowCosts = [1, 1, 1, 1, 1],colCosts = [1, 1, 1, 1, 1]) == 4\n assert candidate(startPos = [0, 4],homePos = [4, 0],rowCosts = [1, 2, 3, 4, 5],colCosts = [5, 10, 15, 20, 25]) == 64\n assert candidate(startPos = [2, 0],homePos = [2, 4],rowCosts = [1, 2, 3],colCosts = [10, 20, 30, 40, 50]) == 140\n assert candidate(startPos = [3, 1],homePos = [0, 3],rowCosts = [5, 10, 15, 20],colCosts = [1, 2, 3, 4]) == 37\n assert candidate(startPos = [5, 5],homePos = [5, 5],rowCosts = [1, 1, 1, 1, 1, 1],colCosts = [1, 1, 1, 1, 1, 1]) == 0\n assert candidate(startPos = [2, 2],homePos = [2, 2],rowCosts = [100, 200, 300],colCosts = [100, 200, 300]) == 0\n assert candidate(startPos = [2, 2],homePos = [2, 2],rowCosts = [1000, 2000, 3000],colCosts = [100, 200, 300]) == 0\n assert candidate(startPos = [5, 5],homePos = [0, 0],rowCosts = [10, 20, 30, 40, 50, 60],colCosts = [5, 15, 25, 35, 45, 55]) == 275\n assert candidate(startPos = [0, 3],homePos = [4, 0],rowCosts = [1, 2, 3, 4, 5],colCosts = [5, 4, 3, 2, 1]) == 26\n assert candidate(startPos = [3, 4],homePos = [0, 0],rowCosts = [10, 20, 30, 40],colCosts = [5, 15, 25, 35, 45]) == 140\n assert candidate(startPos = [4, 4],homePos = [4, 4],rowCosts = [1, 2, 3, 4, 5],colCosts = [5, 4, 3, 2, 1]) == 0\n assert candidate(startPos = [2, 2],homePos = [4, 4],rowCosts = [1, 2, 3, 4, 5],colCosts = [5, 4, 3, 2, 1]) == 12\n assert candidate(startPos = [4, 4],homePos = [1, 1],rowCosts = [5, 10, 15, 20, 25],colCosts = [1, 2, 3, 4, 5]) == 54\n assert candidate(startPos = [0, 2],homePos = [4, 2],rowCosts = [10, 20, 30, 40, 50],colCosts = [1, 2, 3]) == 140\n assert candidate(startPos = [4, 0],homePos = [0, 4],rowCosts = [10, 20, 30, 40, 50],colCosts = [50, 40, 30, 20, 10]) == 200\n assert candidate(startPos = [0, 5],homePos = [5, 0],rowCosts = [1, 1, 1, 1, 1, 1],colCosts = [99, 98, 97, 96, 95, 94]) == 490\n assert candidate(startPos = [1, 1],homePos = [3, 3],rowCosts = [1, 1, 1, 1, 1],colCosts = [1, 1, 1, 1, 1]) == 4\n assert candidate(startPos = [3, 0],homePos = [0, 3],rowCosts = [1, 2, 3, 4],colCosts = [1, 1, 1, 1, 1]) == 9\n assert candidate(startPos = [4, 0],homePos = [4, 4],rowCosts = [1, 2, 3, 4, 5],colCosts = [5, 10, 15, 20, 25]) == 70\n assert candidate(startPos = [1, 5],homePos = [3, 2],rowCosts = [1, 2, 3, 4],colCosts = [5, 4, 3, 2, 1]) == 13\n"}, "metadata": {"canonical_parameter_names": ["startPos", "homePos", "rowCosts", "colCosts"], "leetcode_dataset_entry_point": "Solution().minCost", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minCost(vector& startPos, vector& homePos, vector& rowCosts, vector& colCosts) {", "container": "Solution", "callable": "minCost", "parameters": [{"name": "startPos", "type": "vector&"}, {"name": "homePos", "type": "vector&"}, {"name": "rowCosts", "type": "vector&"}, {"name": "colCosts", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2088, "task_id": "count-fertile-pyramids-in-a-land", "difficulty": "Hard", "problem_description": "A farmer has a rectangular grid of land with m rows and n columns that can be divided into unit cells. Each cell is either fertile (represented by a 1) or barren (represented by a 0). All cells outside the grid are considered barren.\nA pyramidal plot of land can be defined as a set of cells with the following criteria:\n\nThe number of cells in the set has to be greater than 1 and all cells must be fertile.\nThe apex of a pyramid is the topmost cell of the pyramid. The height of a pyramid is the number of rows it covers. Let (r, c) be the apex of the pyramid, and its height be h. Then, the plot comprises of cells (i, j) where r <= i <= r + h - 1 and c - (i - r) <= j <= c + (i - r).\n\nAn inverse pyramidal plot of land can be defined as a set of cells with similar criteria:\n\nThe number of cells in the set has to be greater than 1 and all cells must be fertile.\nThe apex of an inverse pyramid is the bottommost cell of the inverse pyramid. The height of an inverse pyramid is the number of rows it covers. Let (r, c) be the apex of the pyramid, and its height be h. Then, the plot comprises of cells (i, j) where r - h + 1 <= i <= r and c - (r - i) <= j <= c + (r - i).\n\nSome examples of valid and invalid pyramidal (and inverse pyramidal) plots are shown below. Black cells indicate fertile cells.\n\nGiven a 0-indexed m x n binary matrix grid representing the farmland, return the total number of pyramidal and inverse pyramidal plots that can be found in grid.\n \nExample 1:\n\n\nInput: grid = [[0,1,1,0],[1,1,1,1]]\nOutput: 2\nExplanation: The 2 possible pyramidal plots are shown in blue and red respectively.\nThere are no inverse pyramidal plots in this grid. \nHence total number of pyramidal and inverse pyramidal plots is 2 + 0 = 2.\n\nExample 2:\n\n\nInput: grid = [[1,1,1],[1,1,1]]\nOutput: 2\nExplanation: The pyramidal plot is shown in blue, and the inverse pyramidal plot is shown in red. \nHence the total number of plots is 1 + 1 = 2.\n\nExample 3:\n\n\nInput: grid = [[1,1,1,1,0],[1,1,1,1,1],[1,1,1,1,1],[0,1,0,0,1]]\nOutput: 13\nExplanation: There are 7 pyramidal plots, 3 of which are shown in the 2nd and 3rd figures.\nThere are 6 inverse pyramidal plots, 2 of which are shown in the last figure.\nThe total number of plots is 7 + 6 = 13.\n\n \nConstraints:\n\nm == grid.length\nn == grid[i].length\n1 <= m, n <= 1000\n1 <= m * n <= 105\ngrid[i][j] is either 0 or 1.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(grid = [[0, 0, 0], [0, 1, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[0, 1, 1, 0], [1, 1, 1, 1]]) == 2\n assert candidate(grid = [[1, 1, 0, 1, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == 5\n assert candidate(grid = [[0, 0, 0, 0], [0, 1, 0, 0], [0, 1, 1, 0], [0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 30\n assert candidate(grid = [[1, 1, 0, 1], [1, 1, 1, 1], [0, 1, 1, 0]]) == 3\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1]]) == 14\n assert candidate(grid = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]) == 8\n assert candidate(grid = [[1, 1, 1], [1, 1, 1]]) == 2\n assert candidate(grid = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 0], [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], [0, 1, 0, 0, 1]]) == 13\n assert candidate(grid = [[0, 1, 1, 0, 0, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1]]) == 4\n assert candidate(grid = [[1, 1], [1, 1]]) == 0\n assert candidate(grid = [[1, 0, 1], [0, 1, 0], [1, 0, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 15\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 5\n assert candidate(grid = [[0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0, 0]]) == 32\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0], [0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 0, 0, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 0, 0, 0, 0, 0, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 1, 1, 1, 1, 0, 1, 0]]) == 54\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 120\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]) == 2\n assert candidate(grid = [[0, 0, 1, 0, 0], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0], [0, 0, 1, 0, 0], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0]]) == 24\n assert candidate(grid = [[1, 1, 1, 0, 0, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1]]) == 34\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 32\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 1, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 6\n assert candidate(grid = [[0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0]]) == 8\n assert candidate(grid = [[0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 1, 1, 0, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 0, 1, 1, 1, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0, 1, 0, 0], [0, 1, 1, 1, 0, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 36\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 0, 1, 0], [0, 1, 0, 1, 0, 0, 1, 0, 1, 0], [0, 1, 0, 1, 1, 1, 1, 0, 1, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 0, 0, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 24\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 41\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0]]) == 88\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1]]) == 80\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 1, 0, 1, 0, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0]]) == 10\n assert candidate(grid = [[1, 0, 1, 0, 1, 0], [0, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 0], [1, 0, 1, 0, 1, 0]]) == 16\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 1140\n assert candidate(grid = [[0, 0, 1, 0, 0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 1, 0, 0, 0]]) == 75\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1], [0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [1, 0, 1, 0, 1]]) == 12\n assert candidate(grid = [[1, 0, 0, 0, 1], [0, 1, 0, 1, 0], [0, 0, 1, 0, 0], [0, 1, 0, 1, 0], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 1, 0, 1, 0, 1, 0, 0], [0, 1, 1, 1, 1, 1, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0]]) == 4\n assert candidate(grid = [[1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1], [0, 1, 0, 1, 0], [1, 1, 1, 1, 1], [1, 0, 1, 0, 1], [1, 1, 1, 1, 1]]) == 8\n assert candidate(grid = [[1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1], [0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1]]) == 50\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[0, 1, 1, 1, 0], [1, 1, 1, 1, 1], [0, 1, 1, 1, 0], [0, 0, 1, 0, 0], [0, 0, 0, 0, 0]]) == 10\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 128\n assert candidate(grid = [[1, 0, 1, 0, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0]]) == 19\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 18\n assert candidate(grid = [[1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 1, 0, 0, 0], [0, 0, 1, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 1, 0], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1]]) == 0\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 0]]) == 40\n assert candidate(grid = [[1, 1, 1, 0, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 14\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 1, 0, 1, 0, 1], [1, 0, 1, 0, 0, 0, 0, 1, 0, 1], [1, 0, 1, 1, 1, 1, 1, 0, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 0\n assert candidate(grid = [[0, 1, 1, 0, 1, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 0, 1, 1, 0, 1]]) == 14\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 100\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0]]) == 177\n assert candidate(grid = [[1, 1, 1, 0, 0, 0, 1, 1, 1], [0, 1, 0, 0, 0, 0, 0, 1, 0], [1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 8\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 24\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]) == 53\n assert candidate(grid = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]) == 32\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]]) == 0\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0, 1, 1], [1, 0, 1, 1, 1, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 4\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]) == 200\n assert candidate(grid = [[1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 0, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1]]) == 54\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0], [1, 0, 1, 0, 1, 0, 1], [0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0], [0, 1, 0, 1, 0, 1, 0, 1], [1, 0, 1, 0, 1, 0, 1, 0]]) == 0\n assert candidate(grid = [[0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0], [0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0]]) == 112\n"}, "metadata": {"canonical_parameter_names": ["grid"], "leetcode_dataset_entry_point": "Solution().countPyramids", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countPyramids(vector>& grid) {", "container": "Solution", "callable": "countPyramids", "parameters": [{"name": "grid", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2089, "task_id": "find-target-indices-after-sorting-array", "difficulty": "Easy", "problem_description": "You are given a 0-indexed integer array nums and a target element target.\nA target index is an index i such that nums[i] == target.\nReturn a list of the target indices of nums after sorting nums in non-decreasing order. If there are no target indices, return an empty list. The returned list must be sorted in increasing order.\n \nExample 1:\n\nInput: nums = [1,2,5,2,3], target = 2\nOutput: [1,2]\nExplanation: After sorting, nums is [1,2,2,3,5].\nThe indices where nums[i] == 2 are 1 and 2.\n\nExample 2:\n\nInput: nums = [1,2,5,2,3], target = 3\nOutput: [3]\nExplanation: After sorting, nums is [1,2,2,3,5].\nThe index where nums[i] == 3 is 3.\n\nExample 3:\n\nInput: nums = [1,2,5,2,3], target = 5\nOutput: [4]\nExplanation: After sorting, nums is [1,2,2,3,5].\nThe index where nums[i] == 5 is 4.\n\n \nConstraints:\n\n1 <= nums.length <= 100\n1 <= nums[i], target <= 100\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [100, 99, 98, 97, 96],target = 98) == [2]\n assert candidate(nums = [10, 20, 30, 40, 50],target = 50) == [4]\n assert candidate(nums = [7, 7, 7, 7, 7],target = 8) == []\n assert candidate(nums = [10, 20, 30, 40, 50],target = 25) == []\n assert candidate(nums = [1, 3, 5, 7, 9],target = 0) == []\n assert candidate(nums = [50, 40, 30, 20, 10],target = 15) == []\n assert candidate(nums = [100, 100, 100],target = 100) == [0, 1, 2]\n assert candidate(nums = [1, 2, 5, 2, 3],target = 3) == [3]\n assert candidate(nums = [2, 4, 6, 8, 10],target = 2) == [0]\n assert candidate(nums = [5, 5, 5, 5, 5],target = 5) == [0, 1, 2, 3, 4]\n assert candidate(nums = [1, 1, 1, 1, 1],target = 1) == [0, 1, 2, 3, 4]\n assert candidate(nums = [5, 4, 3, 2, 1],target = 3) == [2]\n assert candidate(nums = [1, 3, 5, 7, 9],target = 2) == []\n assert candidate(nums = [1, 2, 2, 2, 3, 4],target = 2) == [1, 2, 3]\n assert candidate(nums = [1, 2, 5, 2, 3],target = 2) == [1, 2]\n assert candidate(nums = [50, 50, 50, 50, 50],target = 50) == [0, 1, 2, 3, 4]\n assert candidate(nums = [5, 5, 5, 5, 5],target = 6) == []\n assert candidate(nums = [1, 3, 5, 7, 9],target = 10) == []\n assert candidate(nums = [100, 1, 100, 1, 100],target = 1) == [0, 1]\n assert candidate(nums = [1, 2, 5, 2, 3],target = 5) == [4]\n assert candidate(nums = [1, 1, 1, 1, 1],target = 2) == []\n assert candidate(nums = [1, 3, 5, 7, 9],target = 4) == []\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = 4) == [6, 7]\n assert candidate(nums = [5, 4, 3, 2, 1],target = 3) == [2]\n assert candidate(nums = [90, 80, 70, 60, 50, 40, 30, 20, 10],target = 45) == []\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 50) == [4]\n assert candidate(nums = [99, 98, 97, 96, 95, 94, 93, 92, 91, 90],target = 95) == [5]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10],target = 7) == [6]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],target = 5) == [4]\n assert candidate(nums = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45],target = 27) == [8]\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1],target = 4) == [3]\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6],target = 5) == [4]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60],target = 35) == [6]\n assert candidate(nums = [100, 100, 99, 99, 98, 98, 97, 97],target = 99) == [4, 5]\n assert candidate(nums = [45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31],target = 37) == [6]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 1) == [0]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = 8) == [3]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 10) == []\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 5) == [4]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],target = 20) == []\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1],target = 4) == [3]\n assert candidate(nums = [42, 24, 36, 18, 54, 30, 48, 27, 60, 39],target = 30) == [3]\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1],target = 5) == [4]\n assert candidate(nums = [100, 50, 30, 70, 20],target = 30) == [1]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],target = 50) == [4]\n assert candidate(nums = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8],target = 8) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [42, 23, 37, 23, 42, 37],target = 37) == [2, 3]\n assert candidate(nums = [1, 1, 2, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],target = 4) == [7, 8, 9, 10]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7],target = 15) == [8]\n assert candidate(nums = [100, 99, 98, 97, 96, 95],target = 98) == [3]\n assert candidate(nums = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],target = 55) == [5]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],target = 15) == [7]\n assert candidate(nums = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],target = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 10) == [9]\n assert candidate(nums = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1],target = 2) == [5, 6, 7, 8, 9]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 55) == []\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 1) == [0]\n assert candidate(nums = [7, 14, 21, 28, 35, 42, 49, 56, 63, 70],target = 35) == [4]\n assert candidate(nums = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5],target = 3) == [6, 7, 8]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],target = 20) == [9]\n assert candidate(nums = [100, 99, 98, 97, 96],target = 97) == [1]\n assert candidate(nums = [8, 6, 6, 6, 8, 6, 8, 6, 8, 6, 6, 6, 6, 6],target = 6) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [42, 27, 89, 10, 56, 23, 50, 78, 34, 67],target = 50) == [5]\n assert candidate(nums = [7, 7, 7, 7, 7, 7, 7, 7, 7, 7],target = 8) == []\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],target = 10) == [18, 19]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],target = 40) == [3]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 11) == []\n assert candidate(nums = [8, 6, 7, 5, 3, 0, 9],target = 7) == [4]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1, 3, 2, 4, 5, 6, 7, 8, 9, 10],target = 5) == [4]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 10) == [9]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14],target = 13) == [12]\n assert candidate(nums = [50, 20, 30, 40, 10],target = 30) == [2]\n assert candidate(nums = [100, 1, 50, 20, 30, 60, 40],target = 30) == [2]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 6) == [5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15) == [14]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 10],target = 10) == [9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 15) == [14]\n assert candidate(nums = [50, 50, 50, 50, 50, 50],target = 50) == [0, 1, 2, 3, 4, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],target = 8) == [7]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 11) == []\n assert candidate(nums = [10, 20, 30, 40, 50],target = 20) == [1]\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10, 20, 10, 20],target = 20) == [5, 6, 7, 8, 9]\n assert candidate(nums = [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15) == [5]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],target = 17) == []\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91],target = 95) == [4]\n assert candidate(nums = [50, 20, 30, 10, 40],target = 30) == [2]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],target = 50) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],target = 6) == []\n assert candidate(nums = [3, 1, 2, 5, 4, 2, 3, 3, 5, 1],target = 3) == [4, 5, 6]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],target = 50) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(nums = [1],target = 2) == []\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5],target = 6) == []\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],target = 18) == [8]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 5) == [4]\n assert candidate(nums = [100, 1, 100, 1, 100, 1, 100],target = 1) == [0, 1, 2]\n assert candidate(nums = [3, 1, 2, 3, 1, 2, 3, 1, 2, 3],target = 2) == [3, 4, 5]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],target = 5) == [4]\n assert candidate(nums = [50, 20, 30, 40, 10],target = 20) == [1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],target = 10) == []\n assert candidate(nums = [50, 20, 30, 40, 10, 60, 70, 80, 90, 100],target = 40) == [3]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 10) == [9]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 21) == []\n assert candidate(nums = [3, 1, 2, 5, 4],target = 4) == [3]\n assert candidate(nums = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15) == [8]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10],target = 15) == [5]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],target = 55) == []\n assert candidate(nums = [10, 20, 10, 20, 10, 20],target = 10) == [0, 1, 2]\n assert candidate(nums = [50, 40, 30, 20, 10],target = 30) == [2]\n assert candidate(nums = [100, 200, 300, 400, 500],target = 250) == []\n assert candidate(nums = [50, 40, 30, 20, 10],target = 20) == [1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],target = 15) == [14]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],target = 6) == [5]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],target = 25) == [12]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],target = 5) == [4]\n assert candidate(nums = [3, 1, 2, 4, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],target = 3) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n assert candidate(nums = [42, 37, 58, 54, 19, 91, 49, 100, 65, 28, 74, 99, 96, 33, 80, 78, 60, 82, 97, 71],target = 74) == [11]\n"}, "metadata": {"canonical_parameter_names": ["nums", "target"], "leetcode_dataset_entry_point": "Solution().targetIndices", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector targetIndices(vector& nums, int target) {", "container": "Solution", "callable": "targetIndices", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "target", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2090, "task_id": "k-radius-subarray-averages", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array nums of n integers, and an integer k.\nThe k-radius average for a subarray of nums centered at some index i with the radius k is the average of all elements in nums between the indices i - k and i + k (inclusive). If there are less than k elements before or after the index i, then the k-radius average is -1.\nBuild and return an array avgs of length n where avgs[i] is the k-radius average for the subarray centered at index i.\nThe average of x elements is the sum of the x elements divided by x, using integer division. The integer division truncates toward zero, which means losing its fractional part.\n\nFor example, the average of four elements 2, 3, 1, and 5 is (2 + 3 + 1 + 5) / 4 = 11 / 4 = 2.75, which truncates to 2.\n\n \nExample 1:\n\n\nInput: nums = [7,4,3,9,1,8,5,2,6], k = 3\nOutput: [-1,-1,-1,5,4,4,-1,-1,-1]\nExplanation:\n- avg[0], avg[1], and avg[2] are -1 because there are less than k elements before each index.\n- The sum of the subarray centered at index 3 with radius 3 is: 7 + 4 + 3 + 9 + 1 + 8 + 5 = 37.\n Using integer division, avg[3] = 37 / 7 = 5.\n- For the subarray centered at index 4, avg[4] = (4 + 3 + 9 + 1 + 8 + 5 + 2) / 7 = 4.\n- For the subarray centered at index 5, avg[5] = (3 + 9 + 1 + 8 + 5 + 2 + 6) / 7 = 4.\n- avg[6], avg[7], and avg[8] are -1 because there are less than k elements after each index.\n\nExample 2:\n\nInput: nums = [100000], k = 0\nOutput: [100000]\nExplanation:\n- The sum of the subarray centered at index 0 with radius 0 is: 100000.\n avg[0] = 100000 / 1 = 100000.\n\nExample 3:\n\nInput: nums = [8], k = 100000\nOutput: [-1]\nExplanation: \n- avg[0] is -1 because there are less than k elements before and after index 0.\n\n \nConstraints:\n\nn == nums.length\n1 <= n <= 105\n0 <= nums[i], k <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == [-1, -1, 3, 4, 5, 6, 7, 8, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0],k = 2) == [-1, -1, 0, -1, -1]\n assert candidate(nums = [100000],k = 0) == [100000]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 4) == [-1, -1, -1, -1, 5, 5, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 2) == [-1, -1, 3, 4, 5, 6, 7, -1, -1]\n assert candidate(nums = [8],k = 100000) == [-1]\n assert candidate(nums = [1, 2, 3, 4, 5],k = 2) == [-1, -1, 3, -1, -1]\n assert candidate(nums = [5],k = 0) == [5]\n assert candidate(nums = [5, 5, 5, 5, 5],k = 1) == [-1, 5, 5, 5, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 4) == [-1, -1, -1, -1, 5, 6, -1, -1, -1, -1]\n assert candidate(nums = [7, 4, 3, 9, 1, 8, 5, 2, 6],k = 3) == [-1, -1, -1, 5, 4, 4, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5],k = 1) == [-1, 2, 3, 4, -1]\n assert candidate(nums = [99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110],k = 3) == [-1, -1, -1, 102, 103, 104, 105, 106, 107, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 7) == [-1, -1, -1, -1, -1, -1, -1, 8, 9, 10, 11, 12, 13, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 0) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 5) == [-1, -1, -1, -1, -1, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 12) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, 1600, 1700, 1800, 1900, 2000],k = 5) == [-1, -1, -1, -1, -1, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500, -1, -1, -1, -1, -1]\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 0) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 0) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 3) == [-1, -1, -1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, -1, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 7) == [-1, -1, -1, -1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 3) == [-1, -1, -1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, -1, -1, -1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 4) == [-1, -1, -1, -1, 5, 4, -1, -1, -1, -1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],k = 3) == [-1, -1, -1, 2, 1, 1, 1, 2, -1, -1, -1]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 4) == [-1, -1, -1, -1, 6, 5, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 10) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],k = 2) == [-1, -1, 3, 2, 1, 1, 1, 2, 3, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 7) == [-1, -1, -1, -1, -1, -1, -1, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 3) == [-1, -1, -1, 7, 9, 11, 13, -1, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 4) == [-1, -1, -1, -1, 0, 0, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 9) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 2) == [-1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],k = 4) == [-1, -1, -1, -1, 5000, 6000, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 5) == [-1, -1, -1, -1, -1, 6, 7, 8, 9, 10, -1, -1, -1, -1, -1]\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == [-1, -1, -1, -1, -1, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, -1, -1, -1, -1, -1]\n assert candidate(nums = [100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991],k = 2) == [-1, -1, 99998, 99997, 99996, 99995, 99994, 99993, -1, -1]\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],k = 4) == [-1, -1, -1, -1, 99995, 99994, -1, -1, -1, -1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],k = 4) == [-1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 6) == [-1, -1, -1, -1, -1, -1, 7, 8, 9, 10, 11, 12, 13, 14, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 5) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == [-1, -1, -1, -1, -1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1],k = 1) == [-1, 8, 7, 6, 5, 4, 3, 2, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9],k = 8) == [-1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 8) == [-1, -1, -1, -1, -1, -1, -1, -1, 90, 100, 110, 120, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [99999, 88888, 77777, 66666, 55555, 44444, 33333, 22222, 11111, 0],k = 4) == [-1, -1, -1, -1, 55555, 44444, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 9) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, 10, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 9) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, 10, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 4) == [-1, -1, -1, -1, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 0) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 2) == [-1, -1, 3, 4, 5, 6, 7, 8, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 5) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 4) == [-1, -1, -1, -1, 60000, 50000, -1, -1, -1, -1]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 2) == [-1, -1, 15, 20, 25, 30, 35, 40, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 9) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, 5, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100000, 0, 100000, 0, 100000, 0, 100000, 0, 100000, 0],k = 2) == [-1, -1, 60000, 40000, 60000, 40000, 60000, 40000, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 5) == [-1, -1, -1, -1, -1, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 5) == [-1, -1, -1, -1, -1, 600, 700, 800, 900, 1000, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 5) == [-1, -1, -1, -1, -1, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, 1300, 1400, 1500],k = 3) == [-1, -1, -1, 400, 500, 600, 700, 800, 900, 1000, 1100, 1200, -1, -1, -1]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [-1, -1, -1, -1, -1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],k = 0) == [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 4) == [-1, -1, -1, -1, 5, 6, 7, 8, 9, 10, 11, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 5) == [-1, -1, -1, -1, -1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 5) == [-1, -1, -1, -1, -1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 3) == [-1, -1, -1, 40, 50, 60, 70, -1, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 3) == [-1, -1, -1, 0, 0, 0, 0, -1, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [-1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 9, 1],k = 1) == [-1, 5, 5, 5, 5, 4, 6, 4, -1]\n assert candidate(nums = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40],k = 5) == [-1, -1, -1, -1, -1, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, -1, -1, -1, -1, -1]\n assert candidate(nums = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],k = 2) == [-1, -1, 3, 2, 1, 1, 1, 2, 3, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [-1, -1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, -1, -1]\n assert candidate(nums = [100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000],k = 2) == [-1, -1, 80000, 70000, 60000, 50000, 40000, 30000, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 2) == [-1, -1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 2) == [-1, -1, 30, 40, 50, 60, 70, 80, -1, -1]\n assert candidate(nums = [99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999, 99999],k = 4) == [-1, -1, -1, -1, 99999, 99999, -1, -1, -1, -1]\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],k = 4) == [-1, -1, -1, -1, 100000, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 20) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 3) == [-1, -1, -1, 40, 50, 60, 70, -1, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39],k = 7) == [-1, -1, -1, -1, -1, -1, -1, 15, 17, 19, 21, 23, 25, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 2) == [-1, -1, 300, 400, 500, 600, 700, 800, -1, -1]\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 5) == [-1, -1, -1, -1, -1, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, -1, -1, -1, -1, -1]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200],k = 4) == [-1, -1, -1, -1, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, -1, -1, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 2) == [-1, -1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, -1, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],k = 5) == [-1, -1, -1, -1, -1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],k = 1) == [-1, 3, 5, 7, 9, 11, 13, 15, 17, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 10) == [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]\n assert candidate(nums = [6, 10, 4, 1, 5, 9, 2, 6, 5, 3, 5],k = 2) == [-1, -1, 5, 5, 4, 4, 5, 5, 4, -1, -1]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 2) == [-1, -1, 0, 0, 0, 0, 0, 0, -1, -1]\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().getAverages", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector getAverages(vector& nums, int k) {", "container": "Solution", "callable": "getAverages", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2091, "task_id": "removing-minimum-and-maximum-from-array", "difficulty": "Medium", "problem_description": "You are given a 0-indexed array of distinct integers nums.\nThere is an element in nums that has the lowest value and an element that has the highest value. We call them the minimum and maximum respectively. Your goal is to remove both these elements from the array.\nA deletion is defined as either removing an element from the front of the array or removing an element from the back of the array.\nReturn the minimum number of deletions it would take to remove both the minimum and maximum element from the array.\n \nExample 1:\n\nInput: nums = [2,10,7,5,4,1,8,6]\nOutput: 5\nExplanation: \nThe minimum element in the array is nums[5], which is 1.\nThe maximum element in the array is nums[1], which is 10.\nWe can remove both the minimum and maximum by removing 2 elements from the front and 3 elements from the back.\nThis results in 2 + 3 = 5 deletions, which is the minimum number possible.\n\nExample 2:\n\nInput: nums = [0,-4,19,1,8,-2,-3,5]\nOutput: 3\nExplanation: \nThe minimum element in the array is nums[1], which is -4.\nThe maximum element in the array is nums[2], which is 19.\nWe can remove both the minimum and maximum by removing 3 elements from the front.\nThis results in only 3 deletions, which is the minimum number possible.\n\nExample 3:\n\nInput: nums = [101]\nOutput: 1\nExplanation: \nThere is only one element in the array, which makes it both the minimum and maximum element.\nWe can remove it with 1 deletion.\n\n \nConstraints:\n\n1 <= nums.length <= 105\n-105 <= nums[i] <= 105\nThe integers in nums are distinct.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [2, 10, 7, 5, 4, 1, 8, 6]) == 5\n assert candidate(nums = [100000, -100000, 50000, -50000]) == 2\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5]) == 2\n assert candidate(nums = [100000, -100000, 50000, -50000, 25000, -25000]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(nums = [101]) == 1\n assert candidate(nums = [3, 1, 2, 4, 5]) == 3\n assert candidate(nums = [100000, -100000, 50000, -50000, 0]) == 2\n assert candidate(nums = [0, -4, 19, 1, 8, -2, -3, 5]) == 3\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5]) == 2\n assert candidate(nums = [1, 3, 2]) == 2\n assert candidate(nums = [3, 1]) == 2\n assert candidate(nums = [3, 2, 1]) == 2\n assert candidate(nums = [5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 2\n assert candidate(nums = [-1, 1]) == 2\n assert candidate(nums = [5, 3, 1, 2, 4]) == 3\n assert candidate(nums = [5, 3, 1, 4, 2]) == 3\n assert candidate(nums = [99, 97, 95, 93, 91, 89, 87, 85, 83, 81, 79, 77, 75, 73, 71, 69, 67, 65, 63, 61, 59, 57, 55, 53, 51]) == 2\n assert candidate(nums = [-100000, -99999, -99998, -99997, -99996, -99995, -99994, -99993, -99992, -99991, -99990, -99989, -99988, -99987, -99986, -99985, -99984, -99983, -99982, -99981, -99980, -99979, -99978, -99977, -99976, -99975, -99974, -99973, -99972, -99971, -99970, 100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990, 99989, 99988, 99987, 99986, 99985, 99984, 99983, 99982, 99981, 99980, 99979, 99978, 99977, 99976, 99975, 99974, 99973, 99972, 99971, 99970]) == 32\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90]) == 2\n assert candidate(nums = [-50000, 49999, -49999, 49998, -49998, 49997, -49997, 49996, -49996, 49995]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100]) == 2\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [3, 1, 2, 5, 4, 6, 7, 8, 9, 10]) == 3\n assert candidate(nums = [-7, 10, 5, -3, 2, 8, 0, -1, 6, 4]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [1, 100, 2, 99, 3, 98, 4, 97, 5, 96, 6, 95, 7, 94, 8, 93, 9, 92, 10, 91]) == 2\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 10\n assert candidate(nums = [3, 7, 1, 9, 5, 2, 8, 4, 6]) == 4\n assert candidate(nums = [100, 200, 300, 400, 500, -100, -200, -300, -400, -500]) == 6\n assert candidate(nums = [100, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]) == 2\n assert candidate(nums = [30, 20, 10, 0, -10, -20, -30, 40, 50, 60, 70, 80, 90, 100]) == 8\n assert candidate(nums = [30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [1, 99999, 2, 99998, 3, 99997, 4, 99996, 5, 99995]) == 2\n assert candidate(nums = [-1, -5, -3, -7, -2, -6, -4]) == 4\n assert candidate(nums = [100, 200, 300, 400, 500, -100, -200, -300, -400, -500, 0]) == 7\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100, 1, 2, 3, 4, 6, 7, 8, 9, 11, 12, 13, 14]) == 13\n assert candidate(nums = [9, 3, 5, 2, 7, 6, 1, 8, 4]) == 4\n assert candidate(nums = [100000, -100000, 50000, -50000, 25000, -25000, 75000, -75000, 12500, -12500]) == 2\n assert candidate(nums = [15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 135, 145, 155]) == 2\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 2\n assert candidate(nums = [3, 1, 2, 5, 4]) == 4\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 1]) == 2\n assert candidate(nums = [5, 3, 8, 6, 2, 7, 4, 1, 9]) == 2\n assert candidate(nums = [5, 2, 8, 3, 7, 6, 4, 10, 1, 9]) == 3\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 10]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]) == 2\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 2\n assert candidate(nums = [1000, 999, 998, 997, 996, 995, 994, 993, 992, 991, 990, 989, 988, 987, 986, 985, 984, 983, 982, 981, 980]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]) == 2\n assert candidate(nums = [1, 9, 2, 8, 3, 7, 4, 6, 5]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 2\n assert candidate(nums = [25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 100]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]) == 2\n assert candidate(nums = [5, 1, 4, 2, 3, 6, 8, 7, 10, 9]) == 4\n assert candidate(nums = [3, 2, 1, 4, 5, 6, 7, 8, 9, 10]) == 4\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 2\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [-5, -10, -3, -1, -8, -2, -7, -4, -6, -9]) == 4\n assert candidate(nums = [3, 1, 2]) == 2\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -1]) == 2\n assert candidate(nums = [0, -1, 1, -2, 2, -3, 3, -4, 4, -5, 5, -6, 6, -7, 7, -8, 8, -9, 9, -10, 10]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 2\n assert candidate(nums = [10, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 9, 7, 9, 3, 2, 3, 8, 4, 6, 2, 6, 4, 3, 3, 8, 3, 2, 7, 9, 5, 0, 2, 8, 8, 4, 1, 9, 7, 1, 6, 9, 3, 9, 9, 3, 7]) == 22\n assert candidate(nums = [40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21]) == 2\n assert candidate(nums = [-1, 1, -2, 2, -3, 3, -4, 4, 0]) == 3\n assert candidate(nums = [1, 10, 3, 8, 5, 2, 7, 4, 6, 9]) == 2\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 6\n assert candidate(nums = [1000, 100, 10, 1, 0, -1, -10, -100, -1000, 500, 50, 5, 0.5, 0.05, 0.005, 0.0005, 5e-05]) == 9\n assert candidate(nums = [100000, -100000, 50000, -50000, 25000, -25000, 12500, -12500, 6250, -6250]) == 2\n assert candidate(nums = [-10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 2\n assert candidate(nums = [50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50]) == 2\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 2\n assert candidate(nums = [10, 2, 8, 6, 7, 3, 5, 1, 9, 4]) == 4\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 11\n assert candidate(nums = [-100000, 100000, 1, -1, 50000, -50000, 99999, -99999, 42, -42]) == 2\n assert candidate(nums = [7, 3, 5, 2, 8, 6, 4, 1]) == 4\n assert candidate(nums = [39, 37, 35, 33, 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 2\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 2\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20]) == 2\n assert candidate(nums = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 2\n assert candidate(nums = [20, 18, 19, 16, 17, 14, 15, 12, 13, 10, 11, 8, 9, 6, 7, 4, 5, 2, 3, 1]) == 2\n assert candidate(nums = [9, 3, 15, 1, 12, 7, 8, 6, 10, 2]) == 4\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 2\n assert candidate(nums = [5, 1, 9, 3, 7, 2, 8, 4, 6]) == 3\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9]) == 2\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 9, 19, 29, 39, 49, 59, 69, 79, 89, 99, 8, 18, 28, 38, 48, 58, 68, 78, 88, 98, 7, 17, 27, 37, 47, 57, 67, 77, 87, 97, 6, 16, 26, 36, 46, 56, 66, 76, 86, 96, 5, 15, 25, 35, 45, 55, 65, 75, 85, 95, 4, 14, 24, 34, 44, 54, 64, 74, 84, 94, 3, 13, 23, 33, 43, 53, 63, 73, 83, 93, 2, 12, 22, 32, 42, 52, 62, 72, 82, 92, 1, 11, 21, 31, 41, 51, 61, 71, 81, 91]) == 20\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 19, 18, 20]) == 2\n assert candidate(nums = [1, 100000, 2, 99999, 3, 99998, 4, 99997, 5, 99996, 6, 99995, 7, 99994, 8, 99993, 9, 99992, 10, 99991, 11, 99990, 12, 99989, 13, 99988, 14, 99987, 15, 99986, 16, 99985, 17, 99984, 18, 99983, 19, 99982, 20, 99981, 21, 99980, 22, 99979, 23, 99978, 24, 99977, 25, 99976, 26, 99975, 27, 99974, 28, 99973, 29, 99972, 30, 99971]) == 2\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 11\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7]) == 2\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().minimumDeletions", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumDeletions(vector& nums) {", "container": "Solution", "callable": "minimumDeletions", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2092, "task_id": "find-all-people-with-secret", "difficulty": "Hard", "problem_description": "You are given an integer n indicating there are n people numbered from 0 to n - 1. You are also given a 0-indexed 2D integer array meetings where meetings[i] = [xi, yi, timei] indicates that person xi and person yi have a meeting at timei. A person may attend multiple meetings at the same time. Finally, you are given an integer firstPerson.\nPerson 0 has a secret and initially shares the secret with a person firstPerson at time 0. This secret is then shared every time a meeting takes place with a person that has the secret. More formally, for every meeting, if a person xi has the secret at timei, then they will share the secret with person yi, and vice versa.\nThe secrets are shared instantaneously. That is, a person may receive the secret and share it with people in other meetings within the same time frame.\nReturn a list of all the people that have the secret after all the meetings have taken place. You may return the answer in any order.\n \nExample 1:\n\nInput: n = 6, meetings = [[1,2,5],[2,3,8],[1,5,10]], firstPerson = 1\nOutput: [0,1,2,3,5]\nExplanation:\nAt time 0, person 0 shares the secret with person 1.\nAt time 5, person 1 shares the secret with person 2.\nAt time 8, person 2 shares the secret with person 3.\nAt time 10, person 1 shares the secret with person 5.​​​​\nThus, people 0, 1, 2, 3, and 5 know the secret after all the meetings.\n\nExample 2:\n\nInput: n = 4, meetings = [[3,1,3],[1,2,2],[0,3,3]], firstPerson = 3\nOutput: [0,1,3]\nExplanation:\nAt time 0, person 0 shares the secret with person 3.\nAt time 2, neither person 1 nor person 2 know the secret.\nAt time 3, person 3 shares the secret with person 0 and person 1.\nThus, people 0, 1, and 3 know the secret after all the meetings.\n\nExample 3:\n\nInput: n = 5, meetings = [[3,4,2],[1,2,1],[2,3,1]], firstPerson = 1\nOutput: [0,1,2,3,4]\nExplanation:\nAt time 0, person 0 shares the secret with person 1.\nAt time 1, person 1 shares the secret with person 2, and person 2 shares the secret with person 3.\nNote that person 2 can share the secret at the same time as receiving it.\nAt time 2, person 3 shares the secret with person 4.\nThus, people 0, 1, 2, 3, and 4 know the secret after all the meetings.\n\n \nConstraints:\n\n2 <= n <= 105\n1 <= meetings.length <= 105\nmeetings[i].length == 3\n0 <= xi, yi <= n - 1\nxi != yi\n1 <= timei <= 105\n1 <= firstPerson <= n - 1\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(n = 3,meetings = [[0, 1, 10], [1, 2, 20]],firstPerson = 1) == [0, 1, 2]\n assert candidate(n = 10,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9]],firstPerson = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 3,meetings = [[0, 1, 1], [1, 2, 2], [0, 2, 3]],firstPerson = 2) == [0, 1, 2]\n assert candidate(n = 5,meetings = [[3, 4, 2], [1, 2, 1], [2, 3, 1]],firstPerson = 1) == [0, 1, 2, 3, 4]\n assert candidate(n = 7,meetings = [[0, 1, 10], [1, 2, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10]],firstPerson = 3) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 4,meetings = [[3, 1, 3], [1, 2, 2], [0, 3, 3]],firstPerson = 3) == [0, 1, 3]\n assert candidate(n = 7,meetings = [[0, 2, 1], [1, 3, 2], [2, 4, 3], [3, 5, 4], [4, 6, 5]],firstPerson = 3) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 3,meetings = [[0, 1, 10], [1, 2, 20], [2, 0, 30]],firstPerson = 2) == [0, 1, 2]\n assert candidate(n = 3,meetings = [[0, 1, 1], [1, 2, 2], [0, 2, 3]],firstPerson = 1) == [0, 1, 2]\n assert candidate(n = 7,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 6,meetings = [[1, 2, 5], [2, 3, 8], [1, 5, 10]],firstPerson = 1) == [0, 1, 2, 3, 5]\n assert candidate(n = 7,meetings = [[0, 2, 1], [1, 3, 1], [4, 5, 1], [5, 6, 1]],firstPerson = 2) == [0, 2]\n assert candidate(n = 15,meetings = [[0, 1, 5], [1, 2, 10], [2, 3, 15], [3, 4, 20], [4, 5, 25], [5, 6, 30], [6, 7, 35], [7, 8, 40], [8, 9, 45], [9, 10, 50], [10, 11, 55], [11, 12, 60], [12, 13, 65], [13, 14, 70], [14, 0, 75]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 10,meetings = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [0, 4, 1], [1, 5, 2], [2, 6, 2], [3, 7, 2], [4, 8, 2], [5, 9, 3], [6, 9, 3], [7, 9, 3], [8, 9, 3]],firstPerson = 9) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 12,meetings = [[0, 1, 1], [1, 2, 2], [2, 0, 3], [3, 4, 4], [4, 5, 5], [5, 3, 6], [6, 7, 7], [7, 8, 8], [8, 6, 9], [9, 10, 10], [10, 11, 11], [11, 9, 12]],firstPerson = 1) == [0, 1, 2]\n assert candidate(n = 7,meetings = [[0, 1, 1], [0, 2, 1], [1, 3, 2], [1, 4, 2], [2, 5, 3], [2, 6, 3]],firstPerson = 2) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 11,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 0, 11]],firstPerson = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(n = 12,meetings = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 0, 1], [0, 5, 2], [1, 6, 2], [2, 7, 2], [3, 8, 2], [4, 9, 2], [5, 10, 2], [6, 11, 2], [7, 0, 2], [8, 1, 2], [9, 2, 2], [10, 3, 2], [11, 4, 2]],firstPerson = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(n = 20,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19]],firstPerson = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(n = 12,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 0, 12]],firstPerson = 6) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(n = 20,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [19, 0, 20]],firstPerson = 10) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(n = 8,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8], [0, 7, 9], [1, 6, 10], [2, 5, 11], [3, 4, 12]],firstPerson = 4) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 10,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10], [0, 2, 11], [1, 3, 12], [2, 4, 13], [3, 5, 14], [4, 6, 15], [5, 7, 16], [6, 8, 17], [7, 9, 18], [8, 0, 19], [9, 1, 20]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 10,meetings = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 8,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 12,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11]],firstPerson = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(n = 6,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 0, 6]],firstPerson = 1) == [0, 1, 2, 3, 4, 5]\n assert candidate(n = 8,meetings = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 0, 1]],firstPerson = 3) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 12,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 0, 12]],firstPerson = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(n = 9,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 0, 9], [0, 5, 10]],firstPerson = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(n = 20,meetings = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 12, 1], [12, 13, 1], [13, 14, 1], [14, 15, 1], [15, 16, 1], [16, 17, 1], [17, 18, 1], [18, 19, 1], [19, 0, 1]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(n = 15,meetings = [[0, 1, 10], [0, 2, 10], [1, 3, 20], [1, 4, 20], [2, 5, 30], [2, 6, 30], [3, 7, 40], [3, 8, 40], [4, 9, 50], [4, 10, 50], [5, 11, 60], [5, 12, 60], [6, 13, 70], [6, 14, 70]],firstPerson = 7) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 10,meetings = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1]],firstPerson = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 10,meetings = [[0, 9, 1], [1, 8, 2], [2, 7, 3], [3, 6, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9]],firstPerson = 5) == [0, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 15,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 8,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [0, 7, 8], [1, 6, 8], [2, 5, 8], [3, 4, 8]],firstPerson = 0) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 6,meetings = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50]],firstPerson = 1) == [0, 1, 2, 3, 4, 5]\n assert candidate(n = 10,meetings = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 0, 2], [1, 3, 3], [2, 4, 3], [3, 5, 3], [4, 6, 3], [5, 7, 3], [6, 8, 3], [7, 9, 3], [8, 0, 3], [9, 1, 3]],firstPerson = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 10,meetings = [[0, 9, 1], [1, 8, 2], [2, 7, 3], [3, 6, 4], [4, 5, 5], [5, 4, 5], [6, 3, 4], [7, 2, 3], [8, 1, 2], [9, 0, 1]],firstPerson = 5) == [0, 4, 5, 9]\n assert candidate(n = 15,meetings = [[0, 1, 1], [0, 2, 1], [1, 3, 2], [1, 4, 2], [2, 5, 3], [2, 6, 3], [3, 7, 4], [3, 8, 4], [4, 9, 5], [4, 10, 5], [5, 11, 6], [5, 12, 6], [6, 13, 7], [6, 14, 7]],firstPerson = 7) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 10,meetings = [[0, 9, 1], [0, 8, 1], [1, 7, 2], [1, 6, 2], [2, 5, 3], [2, 4, 3], [3, 3, 4], [4, 2, 4], [5, 1, 5], [6, 0, 5]],firstPerson = 5) == [0, 1, 2, 4, 5, 6, 8, 9]\n assert candidate(n = 10,meetings = [[0, 1, 1], [0, 2, 1], [0, 3, 1], [0, 4, 1], [0, 5, 1], [0, 6, 1], [0, 7, 1], [0, 8, 1], [0, 9, 1]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 8,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8]],firstPerson = 7) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 9,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 0, 9], [0, 2, 10], [1, 3, 11], [2, 4, 12], [3, 5, 13], [4, 6, 14], [5, 7, 15], [6, 8, 16], [7, 0, 17], [8, 1, 18]],firstPerson = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(n = 8,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8], [1, 3, 9], [3, 5, 10], [5, 7, 11], [7, 1, 12]],firstPerson = 3) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 10,meetings = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 7, 5], [7, 8, 5], [8, 9, 5]],firstPerson = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 12,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 0, 12], [0, 11, 13]],firstPerson = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(n = 7,meetings = [[0, 1, 1], [0, 2, 1], [1, 3, 2], [1, 4, 2], [2, 5, 3], [2, 6, 3], [3, 4, 4], [3, 5, 5], [4, 6, 6], [5, 6, 7]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 10,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 15,meetings = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10], [7, 8, 10], [8, 9, 10], [9, 10, 10], [10, 11, 10], [11, 12, 10], [12, 13, 10], [13, 14, 10]],firstPerson = 7) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 7,meetings = [[0, 1, 10], [1, 2, 20], [2, 3, 30], [3, 4, 40], [4, 5, 50], [5, 6, 60], [0, 6, 70]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 10,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10], [0, 9, 11], [1, 8, 12], [2, 7, 13], [3, 6, 14], [4, 5, 15]],firstPerson = 5) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 8,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7]],firstPerson = 3) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 7,meetings = [[0, 1, 1], [0, 2, 2], [1, 3, 3], [2, 4, 4], [3, 5, 5], [4, 6, 6], [5, 6, 7]],firstPerson = 2) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 6,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5]],firstPerson = 1) == [0, 1, 2, 3, 4, 5]\n assert candidate(n = 10,meetings = [[0, 9, 10], [1, 2, 10], [3, 4, 10], [5, 6, 10], [7, 8, 10], [1, 3, 10], [2, 4, 10], [5, 7, 10], [6, 8, 10]],firstPerson = 1) == [0, 1, 2, 3, 4, 9]\n assert candidate(n = 10,meetings = [[0, 1, 1], [1, 2, 2], [2, 0, 3], [0, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 0, 11]],firstPerson = 3) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 10,meetings = [[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 2], [4, 5, 3], [5, 6, 3], [6, 7, 4], [7, 8, 4], [8, 9, 5]],firstPerson = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 8,meetings = [[0, 1, 1], [2, 3, 2], [4, 5, 3], [6, 7, 4], [0, 2, 5], [1, 3, 6], [2, 4, 7], [3, 5, 8], [4, 6, 9], [5, 7, 10]],firstPerson = 3) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 7,meetings = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5], [5, 6, 5], [6, 0, 5]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 8,meetings = [[0, 1, 10], [1, 2, 10], [2, 3, 10], [3, 4, 10], [4, 5, 10], [5, 6, 10], [6, 7, 10]],firstPerson = 3) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 6,meetings = [[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 2], [4, 5, 3], [5, 0, 3], [1, 4, 4], [2, 5, 5]],firstPerson = 2) == [0, 1, 2, 3, 4, 5]\n assert candidate(n = 7,meetings = [[0, 1, 10], [1, 2, 15], [2, 3, 20], [3, 4, 25], [4, 5, 30], [5, 6, 35], [6, 0, 40]],firstPerson = 6) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 15,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14]],firstPerson = 7) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 8,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 0, 8], [0, 3, 9], [1, 5, 10]],firstPerson = 3) == [0, 1, 2, 3, 4, 5, 6, 7]\n assert candidate(n = 10,meetings = [[0, 4, 5], [4, 5, 5], [0, 1, 6], [1, 2, 6], [2, 3, 7], [3, 4, 7], [4, 6, 8], [5, 7, 9], [6, 8, 10], [7, 9, 11]],firstPerson = 4) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 20,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 15, 15], [15, 16, 16], [16, 17, 17], [17, 18, 18], [18, 19, 19], [19, 0, 20]],firstPerson = 19) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(n = 15,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15], [0, 7, 16], [7, 11, 17], [11, 14, 18]],firstPerson = 7) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 7,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 0, 7], [0, 6, 8]],firstPerson = 3) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 15,meetings = [[0, 1, 1], [2, 3, 1], [4, 5, 1], [6, 7, 1], [8, 9, 1], [10, 11, 1], [12, 13, 1], [13, 14, 1], [0, 2, 2], [1, 3, 2], [4, 6, 2], [5, 7, 2], [8, 10, 2], [9, 11, 2], [12, 14, 2], [13, 0, 3], [14, 1, 3], [0, 4, 3], [1, 5, 3], [2, 6, 3], [3, 7, 3], [4, 8, 3], [5, 9, 3], [6, 10, 3], [7, 11, 3], [8, 12, 3], [9, 13, 3], [10, 14, 3]],firstPerson = 7) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 10,meetings = [[0, 1, 1], [0, 2, 1], [1, 3, 2], [1, 4, 2], [2, 5, 3], [2, 6, 3], [3, 4, 4], [3, 5, 5], [4, 6, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10], [9, 0, 11], [0, 3, 12], [1, 5, 13], [2, 4, 14]],firstPerson = 3) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 15,meetings = [[0, 1, 1], [1, 2, 1], [2, 3, 2], [3, 4, 2], [4, 5, 3], [5, 6, 3], [6, 7, 4], [7, 8, 4], [8, 9, 5], [9, 10, 5], [10, 11, 6], [11, 12, 6], [12, 13, 7], [13, 14, 7], [14, 0, 8]],firstPerson = 0) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 10,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 0, 10]],firstPerson = 9) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(n = 7,meetings = [[0, 1, 1], [1, 2, 2], [0, 3, 3], [3, 4, 4], [0, 5, 5], [5, 6, 6], [2, 4, 7], [1, 6, 8]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6]\n assert candidate(n = 6,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [0, 5, 6]],firstPerson = 1) == [0, 1, 2, 3, 4, 5]\n assert candidate(n = 15,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 12, 12], [12, 13, 13], [13, 14, 14], [14, 0, 15]],firstPerson = 7) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 10,meetings = [[0, 9, 10], [1, 8, 10], [2, 7, 10], [3, 6, 10], [4, 5, 10], [0, 1, 20], [1, 2, 20], [2, 3, 20], [3, 4, 20], [4, 5, 20]],firstPerson = 9) == [0, 1, 2, 3, 4, 5, 9]\n assert candidate(n = 12,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 9, 9], [9, 10, 10], [10, 11, 11], [11, 0, 12], [0, 6, 13], [1, 7, 14], [2, 8, 15], [3, 9, 16], [4, 10, 17], [5, 11, 18]],firstPerson = 6) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(n = 6,meetings = [[0, 1, 5], [1, 2, 5], [2, 3, 5], [3, 4, 5], [4, 5, 5]],firstPerson = 1) == [0, 1, 2, 3, 4, 5]\n assert candidate(n = 9,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 6, 6], [6, 7, 7], [7, 8, 8], [8, 0, 9], [0, 2, 10], [1, 3, 11], [2, 4, 12], [3, 5, 13], [4, 6, 14], [5, 7, 15], [6, 8, 16], [7, 0, 17], [8, 1, 18]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8]\n assert candidate(n = 15,meetings = [[0, 1, 10], [1, 2, 11], [2, 3, 12], [3, 4, 13], [4, 5, 14], [5, 6, 15], [6, 7, 16], [7, 8, 17], [8, 9, 18], [9, 10, 19], [10, 11, 20], [11, 12, 21], [12, 13, 22], [13, 14, 23]],firstPerson = 7) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(n = 6,meetings = [[0, 1, 1], [1, 2, 2], [2, 3, 3], [3, 4, 4], [4, 5, 5], [5, 0, 6], [0, 2, 7], [1, 3, 8], [2, 4, 9], [3, 5, 10]],firstPerson = 0) == [0, 1, 2, 3, 4, 5]\n assert candidate(n = 12,meetings = [[0, 1, 1], [1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1], [10, 11, 1], [11, 0, 1]],firstPerson = 1) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]\n assert candidate(n = 7,meetings = [[0, 1, 1], [0, 2, 2], [0, 3, 3], [1, 4, 4], [1, 5, 5], [2, 6, 6], [3, 6, 6], [4, 5, 5], [4, 6, 6], [5, 6, 6]],firstPerson = 3) == [0, 1, 2, 3, 4, 5, 6]\n"}, "metadata": {"canonical_parameter_names": ["n", "meetings", "firstPerson"], "leetcode_dataset_entry_point": "Solution().findAllPeople", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector findAllPeople(int n, vector>& meetings, int firstPerson) {", "container": "Solution", "callable": "findAllPeople", "parameters": [{"name": "n", "type": "int"}, {"name": "meetings", "type": "vector>&"}, {"name": "firstPerson", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2094, "task_id": "finding-3-digit-even-numbers", "difficulty": "Easy", "problem_description": "You are given an integer array digits, where each element is a digit. The array may contain duplicates.\nYou need to find all the unique integers that follow the given requirements:\n\nThe integer consists of the concatenation of three elements from digits in any arbitrary order.\nThe integer does not have leading zeros.\nThe integer is even.\n\nFor example, if the given digits were [1, 2, 3], integers 132 and 312 follow the requirements.\nReturn a sorted array of the unique integers.\n \nExample 1:\n\nInput: digits = [2,1,3,0]\nOutput: [102,120,130,132,210,230,302,310,312,320]\nExplanation: All the possible integers that follow the requirements are in the output array. \nNotice that there are no odd integers or integers with leading zeros.\n\nExample 2:\n\nInput: digits = [2,2,8,8,2]\nOutput: [222,228,282,288,822,828,882]\nExplanation: The same digit can be used as many times as it appears in digits. \nIn this example, the digit 8 is used twice each time in 288, 828, and 882. \n\nExample 3:\n\nInput: digits = [3,7,5]\nOutput: []\nExplanation: No even integers can be formed using the given digits.\n\n \nConstraints:\n\n3 <= digits.length <= 100\n0 <= digits[i] <= 9\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(digits = [1, 1, 1, 1, 1, 1]) == []\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == []\n assert candidate(digits = [2, 4, 6, 8, 0]) == [204, 206, 208, 240, 246, 248, 260, 264, 268, 280, 284, 286, 402, 406, 408, 420, 426, 428, 460, 462, 468, 480, 482, 486, 602, 604, 608, 620, 624, 628, 640, 642, 648, 680, 682, 684, 802, 804, 806, 820, 824, 826, 840, 842, 846, 860, 862, 864]\n assert candidate(digits = [1, 0, 2, 4, 3, 5, 7, 9]) == [102, 104, 120, 124, 130, 132, 134, 140, 142, 150, 152, 154, 170, 172, 174, 190, 192, 194, 204, 210, 214, 230, 234, 240, 250, 254, 270, 274, 290, 294, 302, 304, 310, 312, 314, 320, 324, 340, 342, 350, 352, 354, 370, 372, 374, 390, 392, 394, 402, 410, 412, 420, 430, 432, 450, 452, 470, 472, 490, 492, 502, 504, 510, 512, 514, 520, 524, 530, 532, 534, 540, 542, 570, 572, 574, 590, 592, 594, 702, 704, 710, 712, 714, 720, 724, 730, 732, 734, 740, 742, 750, 752, 754, 790, 792, 794, 902, 904, 910, 912, 914, 920, 924, 930, 932, 934, 940, 942, 950, 952, 954, 970, 972, 974]\n assert candidate(digits = [2, 1, 3, 0]) == [102, 120, 130, 132, 210, 230, 302, 310, 312, 320]\n assert candidate(digits = [0, 2, 4, 6, 8]) == [204, 206, 208, 240, 246, 248, 260, 264, 268, 280, 284, 286, 402, 406, 408, 420, 426, 428, 460, 462, 468, 480, 482, 486, 602, 604, 608, 620, 624, 628, 640, 642, 648, 680, 682, 684, 802, 804, 806, 820, 824, 826, 840, 842, 846, 860, 862, 864]\n assert candidate(digits = [1, 0, 0, 0]) == [100]\n assert candidate(digits = [2, 4, 6, 8]) == [246, 248, 264, 268, 284, 286, 426, 428, 462, 468, 482, 486, 624, 628, 642, 648, 682, 684, 824, 826, 842, 846, 862, 864]\n assert candidate(digits = [1, 3, 5, 7, 9]) == []\n assert candidate(digits = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == [102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == []\n assert candidate(digits = [2, 2, 8, 8, 2]) == [222, 228, 282, 288, 822, 828, 882]\n assert candidate(digits = [3, 7, 5]) == []\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == [102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [0, 0, 0]) == []\n assert candidate(digits = [0, 2, 2, 2, 4, 4, 4, 6, 6, 6, 8, 8, 8]) == [202, 204, 206, 208, 220, 222, 224, 226, 228, 240, 242, 244, 246, 248, 260, 262, 264, 266, 268, 280, 282, 284, 286, 288, 402, 404, 406, 408, 420, 422, 424, 426, 428, 440, 442, 444, 446, 448, 460, 462, 464, 466, 468, 480, 482, 484, 486, 488, 602, 604, 606, 608, 620, 622, 624, 626, 628, 640, 642, 644, 646, 648, 660, 662, 664, 666, 668, 680, 682, 684, 686, 688, 802, 804, 806, 808, 820, 822, 824, 826, 828, 840, 842, 844, 846, 848, 860, 862, 864, 866, 868, 880, 882, 884, 886, 888]\n assert candidate(digits = [1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0]) == [100, 102, 110, 112, 120, 122, 130, 132, 200, 202, 210, 212, 220, 222, 230, 232, 300, 302, 310, 312, 320, 322, 330, 332]\n assert candidate(digits = [9, 9, 9, 0, 0, 0, 1, 1, 1, 2]) == [100, 102, 110, 112, 120, 190, 192, 200, 210, 290, 900, 902, 910, 912, 920, 990, 992]\n assert candidate(digits = [9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [0, 0, 0, 1, 1, 1, 2, 2, 2]) == [100, 102, 110, 112, 120, 122, 200, 202, 210, 212, 220, 222]\n assert candidate(digits = [0, 0, 2, 4, 6, 8]) == [200, 204, 206, 208, 240, 246, 248, 260, 264, 268, 280, 284, 286, 400, 402, 406, 408, 420, 426, 428, 460, 462, 468, 480, 482, 486, 600, 602, 604, 608, 620, 624, 628, 640, 642, 648, 680, 682, 684, 800, 802, 804, 806, 820, 824, 826, 840, 842, 846, 860, 862, 864]\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 0]) == [990]\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0]) == [200, 202, 220, 222]\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [9, 9, 9, 0, 0, 0, 1, 1, 1]) == [100, 110, 190, 900, 910, 990]\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0]) == [100, 110]\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == []\n assert candidate(digits = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0, 0]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8]) == [888]\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 0]) == [550]\n assert candidate(digits = [0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == []\n assert candidate(digits = [2, 2, 0, 0, 8, 8]) == [200, 202, 208, 220, 228, 280, 282, 288, 800, 802, 808, 820, 822, 828, 880, 882]\n assert candidate(digits = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [800, 808, 880, 888]\n assert candidate(digits = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4]) == [112, 114, 122, 124, 132, 134, 142, 144, 212, 214, 222, 224, 232, 234, 242, 244, 312, 314, 322, 324, 332, 334, 342, 344, 412, 414, 422, 424, 432, 434, 442, 444]\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 0]) == [550]\n assert candidate(digits = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [2, 4, 6, 8, 0, 2, 4, 6, 8, 0]) == [200, 202, 204, 206, 208, 220, 224, 226, 228, 240, 242, 244, 246, 248, 260, 262, 264, 266, 268, 280, 282, 284, 286, 288, 400, 402, 404, 406, 408, 420, 422, 424, 426, 428, 440, 442, 446, 448, 460, 462, 464, 466, 468, 480, 482, 484, 486, 488, 600, 602, 604, 606, 608, 620, 622, 624, 626, 628, 640, 642, 644, 646, 648, 660, 662, 664, 668, 680, 682, 684, 686, 688, 800, 802, 804, 806, 808, 820, 822, 824, 826, 828, 840, 842, 844, 846, 848, 860, 862, 864, 866, 868, 880, 882, 884, 886]\n assert candidate(digits = [0, 0, 1, 2, 4, 6]) == [100, 102, 104, 106, 120, 124, 126, 140, 142, 146, 160, 162, 164, 200, 204, 206, 210, 214, 216, 240, 246, 260, 264, 400, 402, 406, 410, 412, 416, 420, 426, 460, 462, 600, 602, 604, 610, 612, 614, 620, 624, 640, 642]\n assert candidate(digits = [4, 4, 4, 4, 4, 4, 4]) == [444]\n assert candidate(digits = [4, 4, 4, 4, 1, 1, 1, 1, 0, 0, 0, 0]) == [100, 104, 110, 114, 140, 144, 400, 404, 410, 414, 440, 444]\n assert candidate(digits = [0, 2, 2, 0, 4, 6, 8]) == [200, 202, 204, 206, 208, 220, 224, 226, 228, 240, 242, 246, 248, 260, 262, 264, 268, 280, 282, 284, 286, 400, 402, 406, 408, 420, 422, 426, 428, 460, 462, 468, 480, 482, 486, 600, 602, 604, 608, 620, 622, 624, 628, 640, 642, 648, 680, 682, 684, 800, 802, 804, 806, 820, 822, 824, 826, 840, 842, 846, 860, 862, 864]\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [112, 122, 212, 222]\n assert candidate(digits = [0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9]) == [124, 126, 128, 132, 134, 136, 138, 142, 146, 148, 152, 154, 156, 158, 162, 164, 168, 172, 174, 176, 178, 182, 184, 186, 192, 194, 196, 198, 214, 216, 218, 234, 236, 238, 246, 248, 254, 256, 258, 264, 268, 274, 276, 278, 284, 286, 294, 296, 298, 312, 314, 316, 318, 324, 326, 328, 342, 346, 348, 352, 354, 356, 358, 362, 364, 368, 372, 374, 376, 378, 382, 384, 386, 392, 394, 396, 398, 412, 416, 418, 426, 428, 432, 436, 438, 452, 456, 458, 462, 468, 472, 476, 478, 482, 486, 492, 496, 498, 512, 514, 516, 518, 524, 526, 528, 532, 534, 536, 538, 542, 546, 548, 562, 564, 568, 572, 574, 576, 578, 582, 584, 586, 592, 594, 596, 598, 612, 614, 618, 624, 628, 632, 634, 638, 642, 648, 652, 654, 658, 672, 674, 678, 682, 684, 692, 694, 698, 712, 714, 716, 718, 724, 726, 728, 732, 734, 736, 738, 742, 746, 748, 752, 754, 756, 758, 762, 764, 768, 782, 784, 786, 792, 794, 796, 798, 812, 814, 816, 824, 826, 832, 834, 836, 842, 846, 852, 854, 856, 862, 864, 872, 874, 876, 892, 894, 896, 912, 914, 916, 918, 924, 926, 928, 932, 934, 936, 938, 942, 946, 948, 952, 954, 956, 958, 962, 964, 968, 972, 974, 976, 978, 982, 984, 986]\n assert candidate(digits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [100, 102, 110, 112, 120, 122, 200, 202, 210, 212, 220, 222]\n assert candidate(digits = [2, 4, 6, 8, 0, 0, 0, 0, 0, 0]) == [200, 204, 206, 208, 240, 246, 248, 260, 264, 268, 280, 284, 286, 400, 402, 406, 408, 420, 426, 428, 460, 462, 468, 480, 482, 486, 600, 602, 604, 608, 620, 624, 628, 640, 642, 648, 680, 682, 684, 800, 802, 804, 806, 820, 824, 826, 840, 842, 846, 860, 862, 864]\n assert candidate(digits = [1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == [112, 114, 116, 118, 122, 124, 126, 128, 132, 134, 136, 138, 142, 144, 146, 148, 152, 154, 156, 158, 162, 164, 166, 168, 172, 174, 176, 178, 182, 184, 186, 188, 192, 194, 196, 198, 212, 214, 216, 218, 222, 224, 226, 228, 232, 234, 236, 238, 242, 244, 246, 248, 252, 254, 256, 258, 262, 264, 266, 268, 272, 274, 276, 278, 282, 284, 286, 288, 292, 294, 296, 298, 312, 314, 316, 318, 322, 324, 326, 328, 332, 334, 336, 338, 342, 344, 346, 348, 352, 354, 356, 358, 362, 364, 366, 368, 372, 374, 376, 378, 382, 384, 386, 388, 392, 394, 396, 398, 412, 414, 416, 418, 422, 424, 426, 428, 432, 434, 436, 438, 442, 444, 446, 448, 452, 454, 456, 458, 462, 464, 466, 468, 472, 474, 476, 478, 482, 484, 486, 488, 492, 494, 496, 498, 512, 514, 516, 518, 522, 524, 526, 528, 532, 534, 536, 538, 542, 544, 546, 548, 552, 554, 556, 558, 562, 564, 566, 568, 572, 574, 576, 578, 582, 584, 586, 588, 592, 594, 596, 598, 612, 614, 616, 618, 622, 624, 626, 628, 632, 634, 636, 638, 642, 644, 646, 648, 652, 654, 656, 658, 662, 664, 666, 668, 672, 674, 676, 678, 682, 684, 686, 688, 692, 694, 696, 698, 712, 714, 716, 718, 722, 724, 726, 728, 732, 734, 736, 738, 742, 744, 746, 748, 752, 754, 756, 758, 762, 764, 766, 768, 772, 774, 776, 778, 782, 784, 786, 788, 792, 794, 796, 798, 812, 814, 816, 818, 822, 824, 826, 828, 832, 834, 836, 838, 842, 844, 846, 848, 852, 854, 856, 858, 862, 864, 866, 868, 872, 874, 876, 878, 882, 884, 886, 888, 892, 894, 896, 898, 912, 914, 916, 918, 922, 924, 926, 928, 932, 934, 936, 938, 942, 944, 946, 948, 952, 954, 956, 958, 962, 964, 966, 968, 972, 974, 976, 978, 982, 984, 986, 988, 992, 994, 996, 998]\n assert candidate(digits = [0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 444, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 666, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 888, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [222]\n assert candidate(digits = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == []\n assert candidate(digits = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [222]\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 2]) == [112]\n assert candidate(digits = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == [112, 122, 132, 212, 222, 232, 312, 322, 332]\n assert candidate(digits = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]) == [102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == []\n assert candidate(digits = [1, 0, 2, 3, 4, 5, 6, 7, 8, 9]) == [102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == []\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == []\n assert candidate(digits = [5, 5, 5, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [222, 252, 522, 552]\n assert candidate(digits = [1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]) == [112, 122, 212, 222]\n assert candidate(digits = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == [100, 110]\n assert candidate(digits = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == [118, 188, 818, 888]\n assert candidate(digits = [5, 0, 5, 0, 5, 0, 5, 0, 5, 0]) == [500, 550]\n assert candidate(digits = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) == [102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 0, 0]) == [100, 102, 104, 106, 108, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 420, 422, 424, 426, 428, 430, 432, 434, 436, 438, 440, 442, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 470, 472, 474, 476, 478, 480, 482, 484, 486, 488, 490, 492, 494, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 522, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 544, 546, 548, 550, 552, 554, 556, 558, 560, 562, 564, 566, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 588, 590, 592, 594, 596, 598, 600, 602, 604, 606, 608, 610, 612, 614, 616, 618, 620, 622, 624, 626, 628, 630, 632, 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 668, 670, 672, 674, 676, 678, 680, 682, 684, 686, 688, 690, 692, 694, 696, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 722, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 744, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 766, 768, 770, 772, 774, 776, 778, 780, 782, 784, 786, 788, 790, 792, 794, 796, 798, 800, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 830, 832, 834, 836, 838, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 870, 872, 874, 876, 878, 880, 882, 884, 886, 890, 892, 894, 896, 898, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 944, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 966, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986, 988, 990, 992, 994, 996, 998]\n assert candidate(digits = [2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2]) == [200, 202, 220, 222]\n assert candidate(digits = [1, 0, 2, 0, 3, 0, 4, 0, 5, 0]) == [100, 102, 104, 120, 124, 130, 132, 134, 140, 142, 150, 152, 154, 200, 204, 210, 214, 230, 234, 240, 250, 254, 300, 302, 304, 310, 312, 314, 320, 324, 340, 342, 350, 352, 354, 400, 402, 410, 412, 420, 430, 432, 450, 452, 500, 502, 504, 510, 512, 514, 520, 524, 530, 532, 534, 540, 542]\n assert candidate(digits = [4, 4, 4, 4, 4, 4, 4, 4, 4, 4]) == [444]\n assert candidate(digits = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]) == [222]\n assert candidate(digits = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]) == []\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == []\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == []\n assert candidate(digits = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2]) == [112, 122, 212, 222]\n assert candidate(digits = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == [100, 102, 104, 106, 108, 120, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 190, 192, 194, 196, 198, 200, 204, 206, 208, 210, 214, 216, 218, 230, 234, 236, 238, 240, 246, 248, 250, 254, 256, 258, 260, 264, 268, 270, 274, 276, 278, 280, 284, 286, 290, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 324, 326, 328, 340, 342, 346, 348, 350, 352, 354, 356, 358, 360, 362, 364, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 390, 392, 394, 396, 398, 400, 402, 406, 408, 410, 412, 416, 418, 420, 426, 428, 430, 432, 436, 438, 450, 452, 456, 458, 460, 462, 468, 470, 472, 476, 478, 480, 482, 486, 490, 492, 496, 498, 500, 502, 504, 506, 508, 510, 512, 514, 516, 518, 520, 524, 526, 528, 530, 532, 534, 536, 538, 540, 542, 546, 548, 560, 562, 564, 568, 570, 572, 574, 576, 578, 580, 582, 584, 586, 590, 592, 594, 596, 598, 600, 602, 604, 608, 610, 612, 614, 618, 620, 624, 628, 630, 632, 634, 638, 640, 642, 648, 650, 652, 654, 658, 670, 672, 674, 678, 680, 682, 684, 690, 692, 694, 698, 700, 702, 704, 706, 708, 710, 712, 714, 716, 718, 720, 724, 726, 728, 730, 732, 734, 736, 738, 740, 742, 746, 748, 750, 752, 754, 756, 758, 760, 762, 764, 768, 780, 782, 784, 786, 790, 792, 794, 796, 798, 800, 802, 804, 806, 810, 812, 814, 816, 820, 824, 826, 830, 832, 834, 836, 840, 842, 846, 850, 852, 854, 856, 860, 862, 864, 870, 872, 874, 876, 890, 892, 894, 896, 900, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 924, 926, 928, 930, 932, 934, 936, 938, 940, 942, 946, 948, 950, 952, 954, 956, 958, 960, 962, 964, 968, 970, 972, 974, 976, 978, 980, 982, 984, 986]\n assert candidate(digits = [1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6]) == [122, 124, 126, 132, 134, 136, 142, 144, 146, 152, 154, 156, 162, 164, 166, 212, 214, 216, 224, 226, 232, 234, 236, 242, 244, 246, 252, 254, 256, 262, 264, 266, 312, 314, 316, 322, 324, 326, 332, 334, 336, 342, 344, 346, 352, 354, 356, 362, 364, 366, 412, 414, 416, 422, 424, 426, 432, 434, 436, 442, 446, 452, 454, 456, 462, 464, 466, 512, 514, 516, 522, 524, 526, 532, 534, 536, 542, 544, 546, 552, 554, 556, 562, 564, 566, 612, 614, 616, 622, 624, 626, 632, 634, 636, 642, 644, 646, 652, 654, 656, 662, 664]\n assert candidate(digits = [0, 1, 2, 2, 4, 6, 8, 8, 8, 9]) == [102, 104, 106, 108, 120, 122, 124, 126, 128, 140, 142, 146, 148, 160, 162, 164, 168, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 224, 226, 228, 240, 242, 246, 248, 260, 262, 264, 268, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 402, 406, 408, 410, 412, 416, 418, 420, 422, 426, 428, 460, 462, 468, 480, 482, 486, 488, 490, 492, 496, 498, 602, 604, 608, 610, 612, 614, 618, 620, 622, 624, 628, 640, 642, 648, 680, 682, 684, 688, 690, 692, 694, 698, 802, 804, 806, 808, 810, 812, 814, 816, 818, 820, 822, 824, 826, 828, 840, 842, 846, 848, 860, 862, 864, 868, 880, 882, 884, 886, 888, 890, 892, 894, 896, 898, 902, 904, 906, 908, 910, 912, 914, 916, 918, 920, 922, 924, 926, 928, 940, 942, 946, 948, 960, 962, 964, 968, 980, 982, 984, 986, 988]\n assert candidate(digits = [2, 2, 2, 2, 2]) == [222]\n assert candidate(digits = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == [112, 114, 122, 124, 132, 134, 142, 144, 152, 154, 212, 214, 224, 232, 234, 242, 244, 252, 254, 312, 314, 322, 324, 332, 334, 342, 344, 352, 354, 412, 414, 422, 424, 432, 434, 442, 452, 454, 512, 514, 522, 524, 532, 534, 542, 544, 552, 554]\n assert candidate(digits = [7, 7, 7, 7, 7, 8, 8, 8, 8, 8]) == [778, 788, 878, 888]\n assert candidate(digits = [0, 1, 1, 1, 2, 2, 2, 3, 3, 3]) == [102, 110, 112, 120, 122, 130, 132, 202, 210, 212, 220, 222, 230, 232, 302, 310, 312, 320, 322, 330, 332]\n assert candidate(digits = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == []\n assert candidate(digits = [5, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8, 0, 2, 4, 6, 8]) == [200, 202, 204, 206, 208, 220, 222, 224, 226, 228, 240, 242, 244, 246, 248, 250, 252, 254, 256, 258, 260, 262, 264, 266, 268, 280, 282, 284, 286, 288, 400, 402, 404, 406, 408, 420, 422, 424, 426, 428, 440, 442, 444, 446, 448, 450, 452, 454, 456, 458, 460, 462, 464, 466, 468, 480, 482, 484, 486, 488, 500, 502, 504, 506, 508, 520, 522, 524, 526, 528, 540, 542, 544, 546, 548, 560, 562, 564, 566, 568, 580, 582, 584, 586, 588, 600, 602, 604, 606, 608, 620, 622, 624, 626, 628, 640, 642, 644, 646, 648, 650, 652, 654, 656, 658, 660, 662, 664, 666, 668, 680, 682, 684, 686, 688, 800, 802, 804, 806, 808, 820, 822, 824, 826, 828, 840, 842, 844, 846, 848, 850, 852, 854, 856, 858, 860, 862, 864, 866, 868, 880, 882, 884, 886, 888]\n"}, "metadata": {"canonical_parameter_names": ["digits"], "leetcode_dataset_entry_point": "Solution().findEvenNumbers", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector findEvenNumbers(vector& digits) {", "container": "Solution", "callable": "findEvenNumbers", "parameters": [{"name": "digits", "type": "vector&"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2095, "task_id": "delete-the-middle-node-of-a-linked-list", "difficulty": "Medium", "problem_description": "You are given the head of a linked list. Delete the middle node, and return the head of the modified linked list.\nThe middle node of a linked list of size n is the ⌊n / 2⌋th node from the start using 0-based indexing, where ⌊x⌋ denotes the largest integer less than or equal to x.\n\nFor n = 1, 2, 3, 4, and 5, the middle nodes are 0, 1, 1, 2, and 2, respectively.\n\n \nExample 1:\n\n\nInput: head = [1,3,4,7,1,2,6]\nOutput: [1,3,4,1,2,6]\nExplanation:\nThe above figure represents the given linked list. The indices of the nodes are written below.\nSince n = 7, node 3 with value 7 is the middle node, which is marked in red.\nWe return the new list after removing this node. \n\nExample 2:\n\n\nInput: head = [1,2,3,4]\nOutput: [1,2,4]\nExplanation:\nThe above figure represents the given linked list.\nFor n = 4, node 2 with value 3 is the middle node, which is marked in red.\n\nExample 3:\n\n\nInput: head = [2,1]\nOutput: [2]\nExplanation:\nThe above figure represents the given linked list.\nFor n = 2, node 1 with value 1 is the middle node, which is marked in red.\nNode 0 with value 2 is the only node remaining after removing node 1.\n \nConstraints:\n\nThe number of nodes in the list is in the range [1, 105].\n1 <= Node.val <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert is_same_list(candidate(head = list_node([1, 2, 3])), list_node([1, 3]))\n assert is_same_list(candidate(head = list_node([2, 1])), list_node([2]))\n assert candidate(head = list_node([1])) == None\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])), list_node([1, 2, 3, 4, 5, 7, 8, 9, 10]))\n assert is_same_list(candidate(head = list_node([1, 2])), list_node([1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5])), list_node([1, 2, 4, 5]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4])), list_node([1, 2, 4]))\n assert is_same_list(candidate(head = list_node([1, 3, 4, 7, 1, 2, 6])), list_node([1, 3, 4, 1, 2, 6]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6])), list_node([1, 2, 3, 5, 6]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21])), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]))\n assert is_same_list(candidate(head = list_node([7, 7, 7, 7, 7, 7, 7, 7, 7, 7])), list_node([7, 7, 7, 7, 7, 7, 7, 7, 7]))\n assert is_same_list(candidate(head = list_node([5, 4, 3, 2, 1])), list_node([5, 4, 2, 1]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21])), list_node([1, 3, 5, 7, 9, 13, 15, 17, 19, 21]))\n assert is_same_list(candidate(head = list_node([5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5])), list_node([5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]))\n assert is_same_list(candidate(head = list_node([10, 9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([10, 9, 8, 7, 6, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60])), list_node([5, 10, 15, 20, 25, 30, 40, 45, 50, 55, 60]))\n assert is_same_list(candidate(head = list_node([100000, 99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991])), list_node([100000, 99999, 99998, 99997, 99996, 99994, 99993, 99992, 99991]))\n assert is_same_list(candidate(head = list_node([31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1])), list_node([31, 29, 27, 25, 23, 21, 19, 17, 13, 11, 9, 7, 5, 3, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9])), list_node([1, 2, 3, 4, 6, 7, 8, 9]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25])), list_node([1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])), list_node([1, 2, 3, 4, 5, 7, 8, 9, 10, 11]))\n assert is_same_list(candidate(head = list_node([1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000])), list_node([1000, 2000, 3000, 4000, 5000, 7000, 8000, 9000, 10000]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1])), list_node([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8])), list_node([1, 2, 3, 4, 6, 7, 8]))\n assert is_same_list(candidate(head = list_node([1, 2, 2, 1])), list_node([1, 2, 1]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100])), list_node([10, 20, 30, 40, 50, 70, 80, 90, 100]))\n assert is_same_list(candidate(head = list_node([21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1])), list_node([21, 19, 17, 15, 13, 9, 7, 5, 3, 1]))\n assert is_same_list(candidate(head = list_node([5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10])), list_node([5, 4, 3, 2, 1, 0, -1, -2, -4, -5, -6, -7, -8, -9, -10]))\n assert candidate(head = list_node([5])) == None\n assert is_same_list(candidate(head = list_node([100000, 99999, 99998, 99997, 99996, 99995])), list_node([100000, 99999, 99998, 99996, 99995]))\n assert is_same_list(candidate(head = list_node([1, 3, 4, 7, 1, 2, 6, 8])), list_node([1, 3, 4, 7, 2, 6, 8]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2])), list_node([9, 8, 7, 6, 5, 4, 2, 1, 0, -1, -2]))\n assert is_same_list(candidate(head = list_node([100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000])), list_node([100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]))\n assert is_same_list(candidate(head = list_node([21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21])), list_node([21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21]))\n assert is_same_list(candidate(head = list_node([5, 3, 1, 4, 7, 6, 2, 8, 9])), list_node([5, 3, 1, 4, 6, 2, 8, 9]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])), list_node([1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12]))\n assert is_same_list(candidate(head = list_node([5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5])), list_node([5, 4, 3, 2, 1, -1, -2, -3, -4, -5]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13])), list_node([1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110])), list_node([10, 20, 30, 40, 50, 70, 80, 90, 100, 110]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])), list_node([1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15]))\n assert is_same_list(candidate(head = list_node([1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])), list_node([1, 3, 2, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20]))\n assert is_same_list(candidate(head = list_node([10, 20, 30, 40, 50, 60, 70, 80])), list_node([10, 20, 30, 40, 60, 70, 80]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1])), list_node([9, 8, 7, 6, 4, 3, 2, 1]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17])), list_node([1, 3, 5, 7, 11, 13, 15, 17]))\n assert is_same_list(candidate(head = list_node([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30])), list_node([2, 4, 6, 8, 10, 12, 14, 18, 20, 22, 24, 26, 28, 30]))\n assert is_same_list(candidate(head = list_node([1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1])), list_node([1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1]))\n assert is_same_list(candidate(head = list_node([9, 8, 7, 6, 5, 4, 3, 2, 1, 0])), list_node([9, 8, 7, 6, 5, 3, 2, 1, 0]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 2, 1])), list_node([1, 2, 2, 1]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19])), list_node([1, 3, 5, 7, 9, 13, 15, 17, 19]))\n assert is_same_list(candidate(head = list_node([7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7])), list_node([7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7]))\n assert is_same_list(candidate(head = list_node([99, 88, 77, 66, 55, 44, 33, 22, 11])), list_node([99, 88, 77, 66, 44, 33, 22, 11]))\n assert is_same_list(candidate(head = list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25])), list_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]))\n assert is_same_list(candidate(head = list_node([5, 3, 8, 6, 2, 9, 1, 7, 4])), list_node([5, 3, 8, 6, 9, 1, 7, 4]))\n assert is_same_list(candidate(head = list_node([1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29])), list_node([1, 3, 5, 7, 9, 11, 13, 17, 19, 21, 23, 25, 27, 29]))\n"}, "metadata": {"canonical_parameter_names": ["head"], "leetcode_dataset_entry_point": "Solution().deleteMiddle", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "ListNode* deleteMiddle(ListNode* head) {", "container": "Solution", "callable": "deleteMiddle", "parameters": [{"name": "head", "type": "ListNode*"}], "return_type": "ListNode*", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2096, "task_id": "step-by-step-directions-from-a-binary-tree-node-to-another", "difficulty": "Medium", "problem_description": "You are given the root of a binary tree with n nodes. Each node is uniquely assigned a value from 1 to n. You are also given an integer startValue representing the value of the start node s, and a different integer destValue representing the value of the destination node t.\nFind the shortest path starting from node s and ending at node t. Generate step-by-step directions of such path as a string consisting of only the uppercase letters 'L', 'R', and 'U'. Each letter indicates a specific direction:\n\n'L' means to go from a node to its left child node.\n'R' means to go from a node to its right child node.\n'U' means to go from a node to its parent node.\n\nReturn the step-by-step directions of the shortest path from node s to node t.\n \nExample 1:\n\n\nInput: root = [5,1,2,3,null,6,4], startValue = 3, destValue = 6\nOutput: \"UURL\"\nExplanation: The shortest path is: 3 → 1 → 5 → 2 → 6.\n\nExample 2:\n\n\nInput: root = [2,1], startValue = 2, destValue = 1\nOutput: \"L\"\nExplanation: The shortest path is: 2 → 1.\n\n \nConstraints:\n\nThe number of nodes in the tree is n.\n2 <= n <= 105\n1 <= Node.val <= n\nAll the values in the tree are unique.\n1 <= startValue, destValue <= n\nstartValue != destValue\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18]),startValue = 3,destValue = 18) == \"UURR\"\n assert candidate(root = tree_node([2, 1]),startValue = 2,destValue = 1) == \"L\"\n assert candidate(root = tree_node([5, 1, 2, 3, None, 6, 4]),startValue = 3,destValue = 6) == \"UURL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7]),startValue = 4,destValue = 7) == \"UURR\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]),startValue = 8,destValue = 10) == \"UURL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),startValue = 8,destValue = 15) == \"UUURRR\"\n assert candidate(root = tree_node([1, 2]),startValue = 2,destValue = 1) == \"U\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),startValue = 1,destValue = 15) == \"RRR\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),startValue = 8,destValue = 14) == \"UUURRL\"\n assert candidate(root = tree_node([3, 1, 4, None, 2]),startValue = 2,destValue = 4) == \"UUR\"\n assert candidate(root = tree_node([3, 1, 2]),startValue = 2,destValue = 1) == \"UL\"\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 12, 17, 22, 27, 32, 38, 1, 4, 6, 8, 11, 13, 16, 18, 19, 21, 23, 24, 26, 28, 30, 31, 33, 34, 36, 37, 39, 40]),startValue = 37,destValue = 4) == \"U\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]),startValue = 45,destValue = 50) == \"UUUUURLLRL\"\n assert candidate(root = tree_node([5, 1, 2, 3, 8, 6, 4, 9, None, None, 10]),startValue = 9,destValue = 10) == \"UURR\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),startValue = 12,destValue = 14) == \"UURL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),startValue = 16,destValue = 19) == \"UURR\"\n assert candidate(root = tree_node([1, 2, 3, None, None, 6, 7, 8, 9, None, None, 12, 13, None, None, 16, 17]),startValue = 16,destValue = 17) == \"UR\"\n assert candidate(root = tree_node([5, 1, 2, 3, None, 6, 4, 8, None, None, None, 9]),startValue = 8,destValue = 9) == \"UUURRL\"\n assert candidate(root = tree_node([5, 1, 2, 3, 6, None, 4, 7, 8, None, None, 9, 10, None, None, 11, 12, None, None, 13, 14, None, None, 15, 16]),startValue = 7,destValue = 16) == \"URRR\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),startValue = 4,destValue = 17) == \"LR\"\n assert candidate(root = tree_node([50, 25, 75, 12, 37, 62, 87, 6, 20, None, 40, None, 59, 80, 90]),startValue = 6,destValue = 80) == \"UUURRL\"\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 18, 1, None, 6, None, 11, 13, None, None, None, None, None, None, None]),startValue = 3,destValue = 13) == \"UURLR\"\n assert candidate(root = tree_node([1, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10, None, 11, None, 12]),startValue = 7,destValue = 12) == \"LLLLL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]),startValue = 21,destValue = 28) == \"UUUURRLL\"\n assert candidate(root = tree_node([1, 2, None, 3, 4, None, 5, 6, None, None, 7, 8, 9]),startValue = 6,destValue = 9) == \"R\"\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 12, 17, 22, 27, 32, 38, 1, 4, 6, 8, 11, 13, 16, 18, 19, 21, 23, 24, 26, 28, 30, 31, 33, 34, 36, 37, 39, 40]),startValue = 4,destValue = 37) == \"R\"\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, 1, None, 6, None, 14, 20, None, None, None, None, None, 13, 16, 19]),startValue = 3,destValue = 20) == \"UURRR\"\n assert candidate(root = tree_node([3, 1, 2, None, None, None, 4, None, 5, None, None, None, 6, None, None, None, None, None, None, 7]),startValue = 1,destValue = 7) == \"\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),startValue = 10,destValue = 19) == \"UULRR\"\n assert candidate(root = tree_node([50, 25, 75, 12, 37, 62, 87, 6, 18, 31, 43, 55, 59, 81, 93, 3, 9, 15, 21, 27, 35, 39, 47, 51, 57, 61, 67, 71, 77, 83, 89, 95, 1, 5, 7, 11, 13, 17, 19, 23, 29, 33, 37, 41, 45, 49, 53, 58, 63, 65, 69, 73, 75, 79, 85, 88, 91, 94, 97, 99]),startValue = 55,destValue = 88) == \"UURLLL\"\n assert candidate(root = tree_node([200, 100, 300, 50, 150, 250, 350, 25, 75, 125, 175, 225, 275, 325, 375, 10, 40, 60, 90, 130, 160, 180, 210, 240, 260, 290, 310, 340, 360, 390]),startValue = 10,destValue = 390) == \"UUUURRRL\"\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, 6, 7, None, None, None, None, 8, 9, None, None, None, None, 10]),startValue = 10,destValue = 8) == \"\"\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, None, None, 6, 7, None, None, 8, 9]),startValue = 6,destValue = 9) == \"URR\"\n assert candidate(root = tree_node([1, 2, 3, None, None, 4, 5, 6, None, None, 7, 8, None, None, 9, 10, 11, 12, 13, 14, None, None, None, None, None, None, None, 15, 16, None, 17, None, None, 18]),startValue = 6,destValue = 18) == \"LLLLRL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]),startValue = 12,destValue = 24) == \"L\"\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, 1, None, 6]),startValue = 3,destValue = 7) == \"UR\"\n assert candidate(root = tree_node([5, 1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),startValue = 8,destValue = 15) == \"UUURRR\"\n assert candidate(root = tree_node([3, 5, 1, 6, 2, 0, 8, None, None, 7, 4]),startValue = 5,destValue = 1) == \"UR\"\n assert candidate(root = tree_node([30, 15, 45, 10, 20, 40, 50, 5, 12, None, 25, 35, 48, None, None, None, 18, None, None, None, None, None, None, None, None, 22, None, None, None, None, None, None, None, None, None, None]),startValue = 5,destValue = 22) == \"RL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, None, None, 14, 15, None, None, None, None, None, 16, 17, 18, 19, 20]),startValue = 8,destValue = 19) == \"UUURLRL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),startValue = 14,destValue = 11) == \"UUULRR\"\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, 1, None, 6]),startValue = 1,destValue = 6) == \"UURL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),startValue = 16,destValue = 20) == \"UUURLL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),startValue = 5,destValue = 11) == \"R\"\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 30, 60, 85, 110, 140, 160, 180]),startValue = 85,destValue = 140) == \"UUURLR\"\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, None, 5, 6, None, None, None, None, 7, 8, None, None, None, None, 9, 10]),startValue = 9,destValue = 10) == \"\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]),startValue = 10,destValue = 45) == \"URLR\"\n assert candidate(root = tree_node([15, 10, 20, 8, 12, 18, 25, 6, 9, 11, 13, 16, 19, 22, 28, 5, 7, None, None, None, None, None, None, 14, None, None, None, None, None, 17, None, None, None, None, None, None, 21, None, None, None, None, None, None, None, None, None, None, None, None, 24, None, None, None, None, None, None, 26, None, 27]),startValue = 5,destValue = 27) == \"\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]),startValue = 12,destValue = 49) == \"LR\"\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 10, 35, 65, 85, 115, 135, 165, 185]),startValue = 10,destValue = 185) == \"UUURRR\"\n assert candidate(root = tree_node([5, 1, 2, 3, 9, None, 6, 4, None, None, None, None, 8]),startValue = 4,destValue = 9) == \"UUR\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, None, None, 20, 21, 22, None, 24, 25, 26, 27, 28]),startValue = 20,destValue = 27) == \"UUURRR\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),startValue = 19,destValue = 7) == \"UUUURR\"\n assert candidate(root = tree_node([5, 1, 2, 3, None, 6, 4, 8, 9, None, None, 12, 13, None, None, 16, 17, None, None, None, 18, 19, 20, None, None, None, None, 22, 23, 24, 25, 26, 27, 28, None, None, None, None, None, None, None, None, None, None, None, 30]),startValue = 16,destValue = 28) == \"LRL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),startValue = 7,destValue = 1) == \"UU\"\n assert candidate(root = tree_node([1, None, 2, None, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9, None, 10]),startValue = 1,destValue = 10) == \"RRRRRRRRR\"\n assert candidate(root = tree_node([30, 15, 45, 10, 20, 40, 50, 5, 12, 18, 25, 35, 48, 2, 8, 13, 16, 19, 23, 32, 38, 43, 47, 49, 1, 6, 9, 11, 14, 17, 21, 22, 24, 26, 29, 31, 33, 37, 41, 42, 44, 46, 51]),startValue = 42,destValue = 46) == \"UURL\"\n assert candidate(root = tree_node([1, 2, 3, 4, None, 5, 6, 7, None, 8, 9, 10, None, None, 11, 12, None, None, 13, 14, None, None, 15]),startValue = 11,destValue = 15) == \"R\"\n assert candidate(root = tree_node([1, 2, 3, None, None, 6, 4, None, None, None, 5]),startValue = 5,destValue = 1) == \"UUU\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]),startValue = 10,destValue = 60) == \"UUURRRLL\"\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 13, 18, 1, None, 6]),startValue = 3,destValue = 6) == \"URL\"\n assert candidate(root = tree_node([10, 5, 15, 3, 7, 12, 20, 1, 4, 6, 8, None, 17, 16, 25, 0, 2, None, None, None, None, None, None, 9]),startValue = 3,destValue = 25) == \"UURRR\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, None, None, None, None, None, None, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]),startValue = 16,destValue = 30) == \"UUUURLLLL\"\n assert candidate(root = tree_node([100, 50, 150, 25, 75, 125, 175, 12, 37, 62, 87, 112, 137, 162, 187, 6, 18, 31, 43, 55, 59, 81, 93, 107, 118, 127, 133, 147, 153, 167, 173, 183, 193, 3, 9, 15, 21, 27, 33, 39, 45, 49, 53, 58, 63, 65, 69, 73, 75, 79, 85, 88, 91, 94, 97, 99, 103, 109, 115, 121, 123, 129, 131, 139, 141, 149, 151, 157, 159, 165, 169, 171, 179, 181, 189, 191, 199]),startValue = 69,destValue = 171) == \"UUUULRLLL\"\n assert candidate(root = tree_node([5, 1, 2, 3, 8, None, 6, 4, None, None, 9, 10, 11]),startValue = 4,destValue = 11) == \"UUURRR\"\n assert candidate(root = tree_node([5, 1, 2, 3, 6, 7, 4, None, None, None, None, None, None, 8, 9, 10, 11, None, None, 12, 13]),startValue = 8,destValue = 13) == \"LR\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]),startValue = 19,destValue = 38) == \"L\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, None, 8, None, 9, None, 10, None, 11, None, 12, None, 13, None, 14, None, 15]),startValue = 2,destValue = 14) == \"URLRR\"\n assert candidate(root = tree_node([3, 5, 1, 6, 2, 0, 8, None, None, 7, 4]),startValue = 5,destValue = 0) == \"URL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]),startValue = 10,destValue = 40) == \"LL\"\n assert candidate(root = tree_node([5, 1, 2, 3, None, 6, 4, 8, 9, None, None, 12, 13, None, None, 16, 17, None, None, None, 18, 19, 20, None, None, None, None, 22, 23, 24, 25, 26, 27, 28, None, None, None, None, None, None, None, None, None, None, None, 30, None, None, None, 34, 35, 36, 37, 38, 39, 40, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 45]),startValue = 34,destValue = 40) == \"\"\n assert candidate(root = tree_node([50, 25, 75, 10, 30, 60, 80, 5, 15, 27, 33, 55, 65, 77, 85]),startValue = 5,destValue = 65) == \"UUURLR\"\n assert candidate(root = tree_node([5, 2, 8, 1, 3, 6, 9, None, None, 4, 7, None, None, None, None, 10, 11]),startValue = 10,destValue = 11) == \"UR\"\n assert candidate(root = tree_node([10, 5, 15, 3, 7, None, 18, None, 4, None, None, None, None, None, 8]),startValue = 3,destValue = 7) == \"UR\"\n assert candidate(root = tree_node([5, 1, 2, 3, None, 6, 4, 8, 9, None, None, 12, 13, None, None, 16, 17, None, None, None, 18, 19, 20, None, None, None, None, 22, 23, 24, 25, 26, 27, 28, None, None, None, None, None, None, None, None, None, None, None, 30, None, None, None, 34, 35, 36, 37, 38, 39, 40, None, None, None, None, None, None, None, None, None, None, None, None, None, None, 45, None, None, None, 49, 50, 51, 52, 53, 54, 55]),startValue = 49,destValue = 55) == \"\"\n assert candidate(root = tree_node([1, 2, 3, None, None, None, 4, None, 5, 6, None, None, None, None, None, 7, 8]),startValue = 1,destValue = 8) == \"\"\n assert candidate(root = tree_node([2, 1, 3, None, None, 4, 5]),startValue = 3,destValue = 5) == \"R\"\n assert candidate(root = tree_node([20, 10, 30, 5, 15, 25, 35, 3, 7, 13, 17, 23, 27, 33, 37, 2, 4, 6, 8, 12, 14, 16, 18, 22, 24, 26, 28, 32, 34, 36, 38]),startValue = 8,destValue = 32) == \"UUUURRLL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]),startValue = 8,destValue = 19) == \"URR\"\n assert candidate(root = tree_node([3, 5, 1, 6, 2, 0, 8, None, None, 7, 4, None, None, None, None]),startValue = 6,destValue = 7) == \"URL\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),startValue = 3,destValue = 14) == \"RL\"\n assert candidate(root = tree_node([1, 2, 3, None, 4, None, 5, None, 6, None, 7, None, 8, None, 9]),startValue = 1,destValue = 9) == \"RRRR\"\n assert candidate(root = tree_node([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]),startValue = 14,destValue = 12) == \"UULL\"\n assert candidate(root = tree_node([8, 3, 10, 1, 6, None, 14, None, None, 4, 7, 13]),startValue = 7,destValue = 13) == \"UUURRL\"\n"}, "metadata": {"canonical_parameter_names": ["root", "startValue", "destValue"], "leetcode_dataset_entry_point": "Solution().getDirections", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "string getDirections(TreeNode* root, int startValue, int destValue) {", "container": "Solution", "callable": "getDirections", "parameters": [{"name": "root", "type": "TreeNode*"}, {"name": "startValue", "type": "int"}, {"name": "destValue", "type": "int"}], "return_type": "string", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2097, "task_id": "valid-arrangement-of-pairs", "difficulty": "Hard", "problem_description": "You are given a 0-indexed 2D integer array pairs where pairs[i] = [starti, endi]. An arrangement of pairs is valid if for every index i where 1 <= i < pairs.length, we have endi-1 == starti.\nReturn any valid arrangement of pairs.\nNote: The inputs will be generated such that there exists a valid arrangement of pairs.\n \nExample 1:\n\nInput: pairs = [[5,1],[4,5],[11,9],[9,4]]\nOutput: [[11,9],[9,4],[4,5],[5,1]]\nExplanation:\nThis is a valid arrangement since endi-1 always equals starti.\nend0 = 9 == 9 = start1 \nend1 = 4 == 4 = start2\nend2 = 5 == 5 = start3\n\nExample 2:\n\nInput: pairs = [[1,3],[3,2],[2,1]]\nOutput: [[1,3],[3,2],[2,1]]\nExplanation:\nThis is a valid arrangement since endi-1 always equals starti.\nend0 = 3 == 3 = start1\nend1 = 2 == 2 = start2\nThe arrangements [[2,1],[1,3],[3,2]] and [[3,2],[2,1],[1,3]] are also valid.\n\nExample 3:\n\nInput: pairs = [[1,2],[1,3],[2,1]]\nOutput: [[1,2],[2,1],[1,3]]\nExplanation:\nThis is a valid arrangement since endi-1 always equals starti.\nend0 = 2 == 2 = start1\nend1 = 1 == 1 = start2\n\n \nConstraints:\n\n1 <= pairs.length <= 105\npairs[i].length == 2\n0 <= starti, endi <= 109\nstarti != endi\nNo two pairs are exactly the same.\nThere exists a valid arrangement of pairs.\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(pairs = [[0, 1], [1, 2], [2, 3], [3, 4]]) == [[0, 1], [1, 2], [2, 3], [3, 4]]\n assert candidate(pairs = [[0, 1], [1, 2], [2, 3], [3, 0]]) == [[0, 1], [1, 2], [2, 3], [3, 0]]\n assert candidate(pairs = [[1, 2], [1, 3], [2, 1]]) == [[1, 2], [2, 1], [1, 3]]\n assert candidate(pairs = [[10, 20], [20, 30], [30, 40], [40, 50]]) == [[10, 20], [20, 30], [30, 40], [40, 50]]\n assert candidate(pairs = [[1, 3], [3, 2], [2, 1]]) == [[1, 3], [3, 2], [2, 1]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 100]]) == [[100, 200], [200, 300], [300, 100]]\n assert candidate(pairs = [[10, 20], [20, 30], [30, 40], [40, 10]]) == [[10, 20], [20, 30], [30, 40], [40, 10]]\n assert candidate(pairs = [[5, 1], [4, 5], [11, 9], [9, 4]]) == [[11, 9], [9, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[1, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 1]]) == [[1, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 1]]\n assert candidate(pairs = [[7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 7]]) == [[7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 7]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 100]]) == [[100, 200], [200, 300], [300, 400], [400, 500], [500, 100]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [3, 5], [5, 2], [2, 4], [4, 1]]) == [[1, 3], [3, 5], [5, 2], [2, 4], [4, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [3, 5]]) == [[1, 3], [3, 5], [5, 1], [1, 2], [2, 3], [3, 4], [4, 5]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 11], [11, 12], [12, 13], [13, 1]]) == [[1, 11], [11, 12], [12, 13], [13, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [1, 10], [10, 11], [11, 1]]) == [[1, 10], [10, 11], [11, 1], [1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 1]]) == [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7]]) == [[1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1]]) == [[1, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 3], [3, 5]]) == [[1, 3], [3, 5], [5, 1], [1, 2], [2, 3], [3, 4], [4, 5]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 21], [21, 22], [22, 23], [23, 24], [24, 25], [25, 1]]\n assert candidate(pairs = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1]]) == [[1, 5], [5, 1], [1, 4], [4, 1], [1, 3], [3, 1], [1, 2], [2, 1]]\n assert candidate(pairs = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 1], [1, 60], [60, 70], [70, 80], [80, 1]]) == [[1, 60], [60, 70], [70, 80], [80, 1], [1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 1]]\n assert candidate(pairs = [[5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 5]]) == [[5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 5]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 100], [100, 400], [400, 500], [500, 100]]) == [[100, 400], [400, 500], [500, 100], [100, 200], [200, 300], [300, 100]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [2, 7], [7, 8], [8, 9], [9, 10], [10, 2]]) == [[1, 2], [2, 7], [7, 8], [8, 9], [9, 10], [10, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]\n assert candidate(pairs = [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 1], [1, 13], [13, 2]]) == [[1, 3], [3, 5], [5, 7], [7, 9], [9, 11], [11, 1], [1, 13], [13, 2]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 1], [1, 3], [3, 2], [2, 4], [4, 3], [3, 1], [1, 4], [4, 2], [2, 1]]) == [[1, 4], [4, 2], [2, 1], [1, 3], [3, 1], [1, 2], [2, 4], [4, 3], [3, 2], [2, 3], [3, 4], [4, 1]]\n assert candidate(pairs = [[1, 2], [3, 1], [2, 3], [4, 2], [3, 5], [5, 4], [4, 1]]) == [[3, 5], [5, 4], [4, 2], [4, 1], [1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1], [7, 8], [8, 9], [9, 10], [10, 7]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]\n assert candidate(pairs = [[10, 20], [20, 30], [30, 40], [40, 50], [50, 10], [10, 30], [30, 50], [50, 20], [20, 40], [40, 10]]) == [[10, 30], [30, 50], [50, 20], [20, 40], [40, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 10]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [1, 10], [10, 11], [11, 1], [12, 13], [13, 14], [14, 12]]) == [[1, 10], [10, 11], [11, 1], [1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1, 999], [999, 2], [2, 998], [998, 3], [3, 997], [997, 4], [4, 996], [996, 5], [5, 995], [995, 1]]) == [[1, 999], [999, 2], [2, 998], [998, 3], [3, 997], [997, 4], [4, 996], [996, 5], [5, 995], [995, 1]]\n assert candidate(pairs = [[1, 9], [9, 7], [7, 3], [3, 5], [5, 1], [1, 8], [8, 6], [6, 2], [2, 4], [4, 1]]) == [[1, 8], [8, 6], [6, 2], [2, 4], [4, 1], [1, 9], [9, 7], [7, 3], [3, 5], [5, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == [[1, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 4]]) == [[1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1000000, 2000000], [2000000, 3000000], [3000000, 1000000], [500000, 1000000]]) == [[500000, 1000000], [1000000, 2000000], [2000000, 3000000], [3000000, 1000000]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 100]]) == [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 100]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 7], [7, 4], [8, 9], [9, 10], [10, 8]]) == [[1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 20], [20, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 4]]) == [[1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1000, 2000], [2000, 3000], [3000, 1000], [1000, 4000], [4000, 5000], [5000, 6000], [6000, 1000]]) == [[1000, 4000], [4000, 5000], [5000, 6000], [6000, 1000], [1000, 2000], [2000, 3000], [3000, 1000]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 1]]\n assert candidate(pairs = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 5]]) == [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 5]]\n assert candidate(pairs = [[1, 11], [11, 21], [21, 31], [31, 41], [41, 51], [51, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 1], [1, 11], [11, 21], [21, 31], [31, 41], [41, 51], [51, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [1, 6], [6, 7], [7, 8], [8, 1], [1, 9], [9, 10], [10, 1]]) == [[1, 9], [9, 10], [10, 1], [1, 6], [6, 7], [7, 8], [8, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[5, 6], [6, 5], [5, 7], [7, 5], [5, 8], [8, 5], [5, 9], [9, 5], [5, 10], [10, 5]]) == [[5, 10], [10, 5], [5, 9], [9, 5], [5, 8], [8, 5], [5, 7], [7, 5], [5, 6], [6, 5]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 1], [1, 20], [20, 3], [3, 21], [21, 1]]) == [[1, 20], [20, 3], [3, 21], [21, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 16], [16, 17], [17, 18], [18, 19], [19, 1]]\n assert candidate(pairs = [[7, 8], [8, 9], [9, 10], [10, 11], [11, 7], [7, 12], [12, 8]]) == [[7, 12], [12, 8], [8, 9], [9, 10], [10, 11], [11, 7], [7, 8]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 100]]) == [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 100]]\n assert candidate(pairs = [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55], [55, 60], [60, 5]]) == [[5, 10], [10, 15], [15, 20], [20, 25], [25, 30], [30, 35], [35, 40], [40, 45], [45, 50], [50, 55], [55, 60], [60, 5]]\n assert candidate(pairs = [[7, 8], [8, 9], [9, 10], [10, 11], [11, 7], [7, 9], [9, 11], [11, 8]]) == [[7, 9], [9, 11], [11, 8], [8, 9], [9, 10], [10, 11], [11, 7], [7, 8]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 11], [14, 15], [15, 16], [16, 14], [17, 18], [18, 19], [19, 20], [20, 17]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[1, 9], [9, 10], [10, 11], [11, 12], [12, 1], [1, 13], [13, 14], [14, 15], [15, 1], [1, 16], [16, 17], [17, 18], [18, 1]]) == [[1, 16], [16, 17], [17, 18], [18, 1], [1, 13], [13, 14], [14, 15], [15, 1], [1, 9], [9, 10], [10, 11], [11, 12], [12, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 11], [11, 12], [12, 13], [13, 14], [14, 15], [15, 1]]\n assert candidate(pairs = [[1, 11], [11, 21], [21, 31], [31, 41], [41, 51], [51, 61], [61, 71], [71, 81], [81, 91], [91, 1]]) == [[1, 11], [11, 21], [21, 31], [31, 41], [41, 51], [51, 61], [61, 71], [71, 81], [81, 91], [91, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [1, 10], [10, 2]]) == [[1, 10], [10, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [1, 2]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 100], [100, 600], [600, 700], [700, 800], [800, 900], [900, 100]]) == [[100, 600], [600, 700], [700, 800], [800, 900], [900, 100], [100, 200], [200, 300], [300, 400], [400, 500], [500, 100]]\n assert candidate(pairs = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 1], [60, 70], [70, 80], [80, 90], [90, 100], [100, 60]]) == [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 1]]\n assert candidate(pairs = [[5, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 5]]) == [[5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 5], [5, 1], [1, 2], [2, 3], [3, 4], [4, 5]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [4, 5], [5, 6], [6, 4], [7, 8], [8, 9], [9, 7], [1, 4], [4, 7], [7, 1]]) == [[1, 4], [4, 5], [5, 6], [6, 4], [4, 7], [7, 8], [8, 9], [9, 7], [7, 1], [1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 1]]) == [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 1]]\n assert candidate(pairs = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 1]]) == [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 1]]\n assert candidate(pairs = [[1, 1000000000], [1000000000, 999999999], [999999999, 888888888], [888888888, 1]]) == [[1, 1000000000], [1000000000, 999999999], [999999999, 888888888], [888888888, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1], [1, 10], [10, 11], [11, 12], [12, 1]]) == [[1, 10], [10, 11], [11, 12], [12, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1], [6, 7], [7, 8], [8, 9], [9, 10], [10, 6], [11, 12], [12, 13], [13, 11], [14, 15], [15, 16], [16, 14], [17, 18], [18, 19], [19, 20], [20, 17], [21, 22], [22, 23], [23, 21]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 1], [1, 4], [4, 5], [5, 1], [1, 6], [6, 7], [7, 1]]) == [[1, 6], [6, 7], [7, 1], [1, 4], [4, 5], [5, 1], [1, 2], [2, 3], [3, 1]]\n assert candidate(pairs = [[3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 3]]) == [[3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 3]]\n assert candidate(pairs = [[11, 22], [22, 33], [33, 44], [44, 55], [55, 66], [66, 77], [77, 88], [88, 99], [99, 11]]) == [[11, 22], [22, 33], [33, 44], [44, 55], [55, 66], [66, 77], [77, 88], [88, 99], [99, 11]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 100], [100, 300], [300, 500], [500, 200]]) == [[100, 300], [300, 500], [500, 200], [200, 300], [300, 400], [400, 500], [500, 100], [100, 200]]\n assert candidate(pairs = [[1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 1], [1, 11], [11, 21], [21, 31], [31, 41], [41, 51], [51, 61], [61, 71], [71, 81], [81, 91], [91, 1]]) == [[1, 11], [11, 21], [21, 31], [31, 41], [41, 51], [51, 61], [61, 71], [71, 81], [81, 91], [91, 1], [1, 10], [10, 20], [20, 30], [30, 40], [40, 50], [50, 60], [60, 70], [70, 80], [80, 90], [90, 100], [100, 1]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 1], [5, 6], [6, 7], [7, 5]]) == [[1, 2], [2, 3], [3, 4], [4, 1]]\n assert candidate(pairs = [[1, 2], [2, 1], [1, 3], [3, 1], [1, 4], [4, 1], [1, 5], [5, 1], [1, 6], [6, 1], [1, 7], [7, 1], [1, 8], [8, 1], [1, 9], [9, 1], [1, 10], [10, 1]]) == [[1, 10], [10, 1], [1, 9], [9, 1], [1, 8], [8, 1], [1, 7], [7, 1], [1, 6], [6, 1], [1, 5], [5, 1], [1, 4], [4, 1], [1, 3], [3, 1], [1, 2], [2, 1]]\n assert candidate(pairs = [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000], [1000, 100]]) == [[100, 200], [200, 300], [300, 400], [400, 500], [500, 600], [600, 700], [700, 800], [800, 900], [900, 1000], [1000, 100]]\n assert candidate(pairs = [[1, 2], [2, 3], [3, 4], [4, 1], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 4]]) == [[1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10], [10, 4], [4, 1]]\n assert candidate(pairs = [[123, 456], [456, 789], [789, 101], [101, 112], [112, 234], [234, 345], [345, 123]]) == [[123, 456], [456, 789], [789, 101], [101, 112], [112, 234], [234, 345], [345, 123]]\n"}, "metadata": {"canonical_parameter_names": ["pairs"], "leetcode_dataset_entry_point": "Solution().validArrangement", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector> validArrangement(vector>& pairs) {", "container": "Solution", "callable": "validArrangement", "parameters": [{"name": "pairs", "type": "vector>&"}], "return_type": "vector>", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2099, "task_id": "find-subsequence-of-length-k-with-the-largest-sum", "difficulty": "Easy", "problem_description": "You are given an integer array nums and an integer k. You want to find a subsequence of nums of length k that has the largest sum.\nReturn any such subsequence as an integer array of length k.\nA subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.\n \nExample 1:\n\nInput: nums = [2,1,3,3], k = 2\nOutput: [3,3]\nExplanation:\nThe subsequence has the largest sum of 3 + 3 = 6.\nExample 2:\n\nInput: nums = [-1,-2,3,4], k = 3\nOutput: [-1,3,4]\nExplanation: \nThe subsequence has the largest sum of -1 + 3 + 4 = 6.\n\nExample 3:\n\nInput: nums = [3,4,3,3], k = 2\nOutput: [3,4]\nExplanation:\nThe subsequence has the largest sum of 3 + 4 = 7. \nAnother possible subsequence is [4, 3].\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n-105 <= nums[i] <= 105\n1 <= k <= nums.length\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [5, 3, 1, 2, 4],k = 5) == [5, 3, 1, 2, 4]\n assert candidate(nums = [10, 10, 10, 10, 10],k = 3) == [10, 10, 10]\n assert candidate(nums = [0, 0, 0, 0],k = 2) == [0, 0]\n assert candidate(nums = [-1, -2, 3, 4],k = 3) == [-1, 3, 4]\n assert candidate(nums = [1, 2, 3, 4, 5],k = 3) == [3, 4, 5]\n assert candidate(nums = [5, 1, 2, 3, 4],k = 3) == [5, 3, 4]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],k = 5) == [6, 7, 8, 9, 10]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(nums = [-1, -2, -3, -4],k = 2) == [-1, -2]\n assert candidate(nums = [-1, -1, -1, -1, -1],k = 3) == [-1, -1, -1]\n assert candidate(nums = [100, 200, 300, 400, 500],k = 4) == [200, 300, 400, 500]\n assert candidate(nums = [1],k = 1) == [1]\n assert candidate(nums = [2, 1, 3, 3],k = 2) == [3, 3]\n assert candidate(nums = [-10, -20, -30, -40],k = 2) == [-10, -20]\n assert candidate(nums = [5, 4, 3, 2, 1],k = 4) == [5, 4, 3, 2]\n assert candidate(nums = [100000, -100000, 50000, -50000, 0],k = 2) == [100000, 50000]\n assert candidate(nums = [100000, -100000, 200000, -200000],k = 2) == [100000, 200000]\n assert candidate(nums = [10, -2, 0, 5],k = 2) == [10, 5]\n assert candidate(nums = [5, 1, 2, 4, 3],k = 3) == [5, 4, 3]\n assert candidate(nums = [3, 4, 3, 3],k = 2) == [4, 3]\n assert candidate(nums = [-5, -4, -3, -2, -1],k = 2) == [-2, -1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],k = 10) == [16, 17, 18, 19, 20, 21, 22, 23, 24, 25]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 15) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5, 6, -6, 7, -7, 8, -8, 9, -9, 10, -10],k = 10) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -100, -200, -300, -400, -500, -600, -700, -800, -900, -1000],k = 10) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 3) == [100, 90, 80]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 7) == [50, 50, 50, 50, 50, 50, 50]\n assert candidate(nums = [-1, -2, -3, -4, -5],k = 3) == [-1, -2, -3]\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000],k = 4) == [300, 500, 700, 900]\n assert candidate(nums = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50],k = 7) == [10, 20, 30, 40, 50, -10, -20]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],k = 7) == [-1, -2, -3, -4, -5, -6, -7]\n assert candidate(nums = [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],k = 6) == [0, 1, 2, 3, 4, 5]\n assert candidate(nums = [100000, -50000, 100000, -50000, 100000],k = 3) == [100000, 100000, 100000]\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100],k = 5) == [10, 30, 50, 70, 90]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 15) == [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10, -11, -12, -13, -14, -15],k = 3) == [-1, -2, -3]\n assert candidate(nums = [100, 200, 300, 400, 500],k = 1) == [500]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [10, 20, 30, 40, 50, -10, -20, -30, -40, -50],k = 5) == [10, 20, 30, 40, 50]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130],k = 7) == [70, 80, 90, 100, 110, 120, 130]\n assert candidate(nums = [-10, 100, -20, 200, -30, 300, -40, 400, -50, 500, -60, 600, -70, 700, -80, 800],k = 8) == [100, 200, 300, 400, 500, 600, 700, 800]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [10, -1, 2, 9, 3, 8, 4, 7, 5, 6],k = 5) == [10, 9, 8, 7, 6]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],k = 15) == [2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n assert candidate(nums = [99999, 99998, 99997, 99996, 99995, 99994, 99993, 99992, 99991, 99990],k = 3) == [99999, 99998, 99997]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],k = 3) == [100, 90, 80]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 5) == [1, 2, 3, 4, 5]\n assert candidate(nums = [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000],k = 8) == [100000, 100000, 100000, 100000, 100000, 100000, 100000, 100000]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 15) == [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5],k = 7) == [10, 9, 8, 7, 6, 5, 4]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 3) == [1, 1, 1]\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50, -50, 60, -60, 70, -70, 80, -80, 90, -90, 100, -100],k = 10) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 20) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [10, -1, 2, -3, 4, -5, 6, -7, 8, -9],k = 5) == [10, 2, 4, 6, 8]\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, -60, -70, -80, -90],k = 15) == [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, -10, -20, -30, -40]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 5) == [1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == [9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [100, -100, 200, -200, 300, -300, 400, -400, 500, -500],k = 5) == [100, 200, 300, 400, 500]\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 15) == [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, -1, -2, -3, -4, -5]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 4) == [-1, -2, -3, -4]\n assert candidate(nums = [100, -200, 300, -400, 500, -600, 700, -800, 900, -1000, 1100, -1200, 1300],k = 7) == [100, 300, 500, 700, 900, 1100, 1300]\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],k = 10) == [6, 6, 7, 7, 8, 8, 9, 9, 10, 10]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 4) == [50, 50, 50, 50]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],k = 5) == [60, 70, 80, 90, 100]\n assert candidate(nums = [100000, -100000, 50000, -50000, 0, 25000, -25000, 75000, -75000],k = 3) == [100000, 50000, 75000]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 10) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14],k = 10) == [7, 6, 9, 8, 11, 10, 13, 12, 15, 14]\n assert candidate(nums = [-100, -200, -300, -400, -500],k = 3) == [-100, -200, -300]\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100],k = 8) == [1000, 900, 800, 700, 600, 500, 400, 300]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 10) == [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10],k = 5) == [1, 3, 5, 7, 9]\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100],k = 3) == [-10, -20, -30]\n assert candidate(nums = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],k = 10) == [50, 50, 50, 50, 50, 50, 50, 50, 50, 50]\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5],k = 6) == [1, -1, 2, 3, 4, 5]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10) == [6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [-100, -200, -300, -400, -500, -600, -700, -800, -900, -1000, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],k = 10) == [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]\n assert candidate(nums = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0],k = 6) == [9, 8, 7, 6, 5, 4]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 3) == [0, 0, 0]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 7) == [9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 10) == [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]\n assert candidate(nums = [10000, -10000, 20000, -20000, 30000, -30000, 40000, -40000],k = 4) == [10000, 20000, 30000, 40000]\n assert candidate(nums = [-1, -2, -3, -4, -5, -6, -7, -8, -9, -10],k = 3) == [-1, -2, -3]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [0, 0, 0, 0, 0]\n assert candidate(nums = [9, 1, 2, 3, 4, 5, 6, 7, 8, 10],k = 5) == [9, 6, 7, 8, 10]\n assert candidate(nums = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500],k = 10) == [300, 400, 500, 300, 400, 500, 200, 300, 400, 500]\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59],k = 20) == [21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59]\n assert candidate(nums = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],k = 6) == [25, 30, 35, 40, 45, 50]\n assert candidate(nums = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],k = 5) == [0, 0, 0, 0, 0]\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],k = 7) == [1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],k = 10) == [11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],k = 10) == [6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100, -110],k = 5) == [-10, -20, -30, -40, -50]\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],k = 8) == [15, 14, 13, 12, 11, 10, 9, 8]\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],k = 25) == [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]\n assert candidate(nums = [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195, 97, 48, 24, 12, 6, 3, 1],k = 10) == [100000, 50000, 25000, 12500, 6250, 3125, 1562, 781, 390, 195]\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1, 1, -1],k = 8) == [1, 1, 1, 1, 1, 1, 1, 1]\n assert candidate(nums = [-10, -20, -30, -40, -50, 100, 200],k = 3) == [-10, 100, 200]\n"}, "metadata": {"canonical_parameter_names": ["nums", "k"], "leetcode_dataset_entry_point": "Solution().maxSubsequence", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector maxSubsequence(vector& nums, int k) {", "container": "Solution", "callable": "maxSubsequence", "parameters": [{"name": "nums", "type": "vector&"}, {"name": "k", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2100, "task_id": "find-good-days-to-rob-the-bank", "difficulty": "Medium", "problem_description": "You and a gang of thieves are planning on robbing a bank. You are given a 0-indexed integer array security, where security[i] is the number of guards on duty on the ith day. The days are numbered starting from 0. You are also given an integer time.\nThe ith day is a good day to rob the bank if:\n\nThere are at least time days before and after the ith day,\nThe number of guards at the bank for the time days before i are non-increasing, and\nThe number of guards at the bank for the time days after i are non-decreasing.\n\nMore formally, this means day i is a good day to rob the bank if and only if security[i - time] >= security[i - time + 1] >= ... >= security[i] <= ... <= security[i + time - 1] <= security[i + time].\nReturn a list of all days (0-indexed) that are good days to rob the bank. The order that the days are returned in does not matter.\n \nExample 1:\n\nInput: security = [5,3,3,3,5,6,2], time = 2\nOutput: [2,3]\nExplanation:\nOn day 2, we have security[0] >= security[1] >= security[2] <= security[3] <= security[4].\nOn day 3, we have security[1] >= security[2] >= security[3] <= security[4] <= security[5].\nNo other days satisfy this condition, so days 2 and 3 are the only good days to rob the bank.\n\nExample 2:\n\nInput: security = [1,1,1,1,1], time = 0\nOutput: [0,1,2,3,4]\nExplanation:\nSince time equals 0, every day is a good day to rob the bank, so return every day.\n\nExample 3:\n\nInput: security = [1,2,3,4,5,6], time = 2\nOutput: []\nExplanation:\nNo day has 2 days before it that have a non-increasing number of guards.\nThus, no day is a good day to rob the bank, so return an empty list.\n\n \nConstraints:\n\n1 <= security.length <= 105\n0 <= security[i], time <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(security = [3, 3, 5, 5, 5, 5, 2, 2, 2, 3],time = 2) == [6, 7]\n assert candidate(security = [1, 1, 1, 1, 1],time = 0) == [0, 1, 2, 3, 4]\n assert candidate(security = [1, 2, 2, 3, 3, 4, 5, 5, 6, 6],time = 1) == [2, 4, 7]\n assert candidate(security = [6, 5, 4, 3, 2, 1],time = 2) == []\n assert candidate(security = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1],time = 1) == [2, 4, 6, 8]\n assert candidate(security = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0],time = 0) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n assert candidate(security = [1, 2, 2, 3, 3, 4],time = 1) == [2, 4]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],time = 3) == []\n assert candidate(security = [1, 2, 2, 3, 3, 4, 5],time = 1) == [2, 4]\n assert candidate(security = [3, 3, 5, 5, 5, 5, 2, 2, 1, 1],time = 2) == []\n assert candidate(security = [1, 1, 1, 2, 2, 2, 3, 3, 3],time = 2) == [2, 5]\n assert candidate(security = [100, 90, 80, 70, 60, 50, 60, 70, 80, 90, 100],time = 4) == [5]\n assert candidate(security = [3, 3, 3, 3, 3, 3, 3],time = 3) == [3]\n assert candidate(security = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],time = 4) == [4, 5]\n assert candidate(security = [1],time = 0) == [0]\n assert candidate(security = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1],time = 2) == []\n assert candidate(security = [3, 3, 5, 5, 5, 5, 4, 4, 4, 3],time = 3) == []\n assert candidate(security = [1, 2, 3, 4, 5, 6],time = 2) == []\n assert candidate(security = [1, 2, 3, 3, 3, 3, 2, 2, 1],time = 2) == []\n assert candidate(security = [5, 3, 3, 3, 5, 6, 2],time = 2) == [2, 3]\n assert candidate(security = [1, 2, 3, 2, 1, 0, 1, 0, 1, 2, 3],time = 1) == [5, 7]\n assert candidate(security = [6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6],time = 2) == [5]\n assert candidate(security = [1, 2, 2, 3, 4, 5, 5, 4, 3, 2, 1],time = 3) == []\n assert candidate(security = [6, 5, 4, 3, 2, 1],time = 3) == []\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],time = 3) == []\n assert candidate(security = [1, 2],time = 1) == []\n assert candidate(security = [2, 1],time = 1) == []\n assert candidate(security = [1, 3, 3, 3, 3, 2, 2, 2, 2],time = 2) == [5, 6]\n assert candidate(security = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],time = 5) == [23]\n assert candidate(security = [1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0],time = 2) == [2, 6, 10, 14, 18, 22, 26]\n assert candidate(security = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],time = 10) == [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(security = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7],time = 2) == [8]\n assert candidate(security = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],time = 10) == [10, 11, 12, 13, 14, 15]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],time = 5) == [10]\n assert candidate(security = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],time = 0) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]\n assert candidate(security = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],time = 3) == [11]\n assert candidate(security = [5, 3, 3, 3, 3, 5, 6, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1],time = 3) == [3, 11, 12, 13]\n assert candidate(security = [1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 1],time = 2) == [3, 6, 9, 13, 16, 19]\n assert candidate(security = [1, 2, 3, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5],time = 2) == []\n assert candidate(security = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],time = 10) == [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]\n assert candidate(security = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12],time = 2) == []\n assert candidate(security = [1, 2, 3, 2, 1, 0, 1, 0, 1, 2, 3, 2, 1, 0, 1],time = 2) == []\n assert candidate(security = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5],time = 2) == [8, 16]\n assert candidate(security = [7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7],time = 3) == [4, 8, 9, 10, 11, 15]\n assert candidate(security = [1, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2],time = 1) == [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22]\n assert candidate(security = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6],time = 3) == [11]\n assert candidate(security = [1, 3, 2, 2, 2, 1, 2, 2, 2, 3, 1, 1, 1],time = 1) == [2, 3, 5, 7, 8, 10, 11]\n assert candidate(security = [1, 2, 3, 4, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1],time = 4) == [8, 9, 17]\n assert candidate(security = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],time = 2) == [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36]\n assert candidate(security = [1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 2, 2],time = 2) == [4, 8, 12]\n assert candidate(security = [10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10],time = 4) == [12]\n assert candidate(security = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3],time = 4) == [4, 5]\n assert candidate(security = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],time = 5) == [10]\n assert candidate(security = [5, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4],time = 5) == []\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],time = 6) == [10, 11, 12, 13, 14]\n assert candidate(security = [5, 3, 3, 3, 5, 6, 2, 2, 2, 1, 1, 1, 2, 2, 2],time = 3) == [9, 10, 11]\n assert candidate(security = [1, 2, 2, 1, 0, 0, 1, 1, 2, 2],time = 1) == [4, 5, 7]\n assert candidate(security = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],time = 4) == [19]\n assert candidate(security = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],time = 4) == [9]\n assert candidate(security = [5, 3, 3, 3, 5, 6, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],time = 2) == [2, 3, 7, 8, 9, 10, 11, 12, 13, 14]\n assert candidate(security = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],time = 5) == [5, 6, 7, 8, 9, 10, 11]\n assert candidate(security = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],time = 5) == []\n assert candidate(security = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0],time = 4) == []\n assert candidate(security = [2, 3, 3, 2, 2, 1, 1, 2, 2, 3, 3, 2, 1, 1, 2, 2],time = 2) == [5, 6, 12, 13]\n assert candidate(security = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1],time = 3) == [4]\n assert candidate(security = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0],time = 2) == []\n assert candidate(security = [10, 10, 10, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],time = 4) == []\n assert candidate(security = [1, 2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7, 8, 9, 8, 9, 10, 11, 10, 11, 12, 11, 12, 13],time = 4) == []\n assert candidate(security = [3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3],time = 2) == [2, 5, 6, 7, 8, 9, 12]\n assert candidate(security = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 5],time = 3) == [8, 16]\n assert candidate(security = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1],time = 1) == [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5],time = 3) == [10]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],time = 4) == [10]\n assert candidate(security = [5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 5],time = 4) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]\n assert candidate(security = [1, 2, 3, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5, 4, 5],time = 2) == []\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6],time = 8) == [10]\n assert candidate(security = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],time = 7) == [7, 8, 9]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],time = 4) == [10]\n assert candidate(security = [3, 2, 1, 2, 1, 0, 1, 0, 1, 2, 3, 2, 1, 2, 1, 0, 1, 0, 1, 2],time = 2) == []\n assert candidate(security = [1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6],time = 3) == [11, 23]\n assert candidate(security = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9],time = 3) == [5]\n assert candidate(security = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 1],time = 3) == []\n assert candidate(security = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],time = 5) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n assert candidate(security = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],time = 3) == []\n assert candidate(security = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10, 0, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],time = 5) == [10, 11]\n assert candidate(security = [9, 8, 7, 6, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 2, 1],time = 4) == [4]\n assert candidate(security = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1],time = 2) == [4, 5, 8, 9, 12, 13, 16, 17, 20, 21]\n assert candidate(security = [2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5],time = 2) == [2, 5, 6, 7, 8, 9, 12, 13, 14, 17, 18, 19, 22, 23, 24, 27]\n assert candidate(security = [3, 3, 5, 5, 4, 4, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],time = 3) == [5]\n assert candidate(security = [3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0, 0],time = 3) == [4, 8, 12, 13]\n assert candidate(security = [1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2, 1, 1, 1, 2, 2, 2],time = 2) == [4, 5, 6, 10, 11, 12, 16, 17, 18]\n assert candidate(security = [1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7, 9, 8, 10, 9, 11, 10, 12, 11],time = 3) == []\n assert candidate(security = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],time = 4) == [5, 20]\n assert candidate(security = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],time = 7) == [19]\n assert candidate(security = [1, 2, 3, 2, 1, 2, 1, 2, 3, 4, 3, 2, 1, 2, 1, 2, 3, 4, 5, 4, 3, 2, 1],time = 3) == []\n assert candidate(security = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11],time = 3) == [5]\n assert candidate(security = [1, 3, 2, 3, 1, 2, 3, 2, 1, 2, 1, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 1, 2, 3, 2, 1, 2, 1, 3, 2, 1],time = 2) == [13]\n assert candidate(security = [5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0],time = 5) == [5]\n assert candidate(security = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2],time = 2) == [2, 3, 4, 5, 6, 7]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 5, 5, 6, 7, 8, 9, 10],time = 3) == [5, 6, 7]\n assert candidate(security = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],time = 5) == [5, 6, 7, 8, 9, 10]\n assert candidate(security = [8, 8, 8, 8, 8, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8],time = 2) == [2, 5, 6, 7, 8, 9, 12]\n assert candidate(security = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],time = 10) == [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46]\n assert candidate(security = [1, 3, 2, 3, 2, 1, 2, 3, 2, 1],time = 1) == [2, 5]\n assert candidate(security = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16],time = 5) == []\n assert candidate(security = [1, 2, 3, 4, 3, 2, 3, 4, 5, 6, 5, 4, 5, 6, 7, 8, 9],time = 2) == [5, 11]\n assert candidate(security = [8, 7, 6, 5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],time = 6) == [7]\n assert candidate(security = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],time = 12) == [12, 13]\n assert candidate(security = [1, 2, 3, 4, 5, 5, 5, 5, 5, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24],time = 7) == []\n assert candidate(security = [1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1],time = 2) == [3, 4, 5, 6, 7, 8, 9]\n assert candidate(security = [10, 9, 8, 7, 6, 5, 6, 7, 8, 9, 10],time = 2) == [5]\n assert candidate(security = [5, 5, 4, 4, 4, 5, 6, 7, 8, 8],time = 2) == [2, 3, 4]\n assert candidate(security = [5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5],time = 2) == [10, 11]\n assert candidate(security = [5, 4, 3, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],time = 3) == [4]\n assert candidate(security = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 9, 9, 8, 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1],time = 3) == []\n assert candidate(security = [9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9],time = 5) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33]\n assert candidate(security = [3, 3, 5, 5, 5, 5, 5, 5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 1, 1, 1],time = 3) == [11]\n assert candidate(security = [1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3, 2, 1, 2, 3],time = 2) == [4, 8, 12]\n assert candidate(security = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],time = 5) == [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]\n assert candidate(security = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1],time = 2) == []\n assert candidate(security = [1, 3, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2],time = 2) == []\n assert candidate(security = [1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],time = 5) == [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]\n assert candidate(security = [1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1],time = 1) == [1, 4, 5, 8, 9, 12, 13, 16, 17, 20]\n"}, "metadata": {"canonical_parameter_names": ["security", "time"], "leetcode_dataset_entry_point": "Solution().goodDaysToRobBank", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "vector goodDaysToRobBank(vector& security, int time) {", "container": "Solution", "callable": "goodDaysToRobBank", "parameters": [{"name": "security", "type": "vector&"}, {"name": "time", "type": "int"}], "return_type": "vector", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2101, "task_id": "detonate-the-maximum-bombs", "difficulty": "Medium", "problem_description": "You are given a list of bombs. The range of a bomb is defined as the area where its effect can be felt. This area is in the shape of a circle with the center as the location of the bomb.\nThe bombs are represented by a 0-indexed 2D integer array bombs where bombs[i] = [xi, yi, ri]. xi and yi denote the X-coordinate and Y-coordinate of the location of the ith bomb, whereas ri denotes the radius of its range.\nYou may choose to detonate a single bomb. When a bomb is detonated, it will detonate all bombs that lie in its range. These bombs will further detonate the bombs that lie in their ranges.\nGiven the list of bombs, return the maximum number of bombs that can be detonated if you are allowed to detonate only one bomb.\n \nExample 1:\n\n\nInput: bombs = [[2,1,3],[6,1,4]]\nOutput: 2\nExplanation:\nThe above figure shows the positions and ranges of the 2 bombs.\nIf we detonate the left bomb, the right bomb will not be affected.\nBut if we detonate the right bomb, both bombs will be detonated.\nSo the maximum bombs that can be detonated is max(1, 2) = 2.\n\nExample 2:\n\n\nInput: bombs = [[1,1,5],[10,10,5]]\nOutput: 1\nExplanation:\nDetonating either bomb will not detonate the other bomb, so the maximum number of bombs that can be detonated is 1.\n\nExample 3:\n\n\nInput: bombs = [[1,2,3],[2,3,1],[3,4,2],[4,5,3],[5,6,4]]\nOutput: 5\nExplanation:\nThe best bomb to detonate is bomb 0 because:\n- Bomb 0 detonates bombs 1 and 2. The red circle denotes the range of bomb 0.\n- Bomb 2 detonates bomb 3. The blue circle denotes the range of bomb 2.\n- Bomb 3 detonates bomb 4. The green circle denotes the range of bomb 3.\nThus all 5 bombs are detonated.\n\n \nConstraints:\n\n1 <= bombs.length <= 100\nbombs[i].length == 3\n1 <= xi, yi, ri <= 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(bombs = [[10, 10, 5], [15, 15, 5], [20, 20, 5]]) == 1\n assert candidate(bombs = [[1, 1, 5], [2, 2, 5], [3, 3, 5], [4, 4, 5]]) == 4\n assert candidate(bombs = [[1, 1, 1], [2, 2, 1], [3, 3, 1]]) == 1\n assert candidate(bombs = [[1, 1, 100], [1, 1, 50], [1, 1, 25]]) == 3\n assert candidate(bombs = [[1, 1, 10], [10, 10, 10], [5, 5, 5]]) == 2\n assert candidate(bombs = [[1, 1, 10], [10, 10, 1], [5, 5, 5]]) == 2\n assert candidate(bombs = [[1, 1, 5], [10, 10, 5]]) == 1\n assert candidate(bombs = [[1, 2, 3], [2, 3, 1], [3, 4, 2], [4, 5, 3], [5, 6, 4]]) == 5\n assert candidate(bombs = [[5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1]]) == 1\n assert candidate(bombs = [[0, 0, 100], [50, 50, 100], [100, 100, 100]]) == 3\n assert candidate(bombs = [[100, 100, 1], [101, 101, 1], [102, 102, 1]]) == 1\n assert candidate(bombs = [[1, 1, 2], [2, 2, 2], [3, 3, 2], [4, 4, 2]]) == 4\n assert candidate(bombs = [[1, 1, 1], [1, 1, 1], [1, 1, 1]]) == 3\n assert candidate(bombs = [[2, 1, 3], [6, 1, 4]]) == 2\n assert candidate(bombs = [[1, 1, 3], [2, 2, 3], [3, 3, 3], [4, 4, 3]]) == 4\n assert candidate(bombs = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1]]) == 1\n assert candidate(bombs = [[5, 5, 3], [6, 6, 1], [7, 7, 4]]) == 3\n assert candidate(bombs = [[5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8]]) == 4\n assert candidate(bombs = [[10, 10, 10], [20, 20, 10], [30, 30, 10]]) == 1\n assert candidate(bombs = [[10, 10, 1], [20, 10, 1], [30, 10, 1], [40, 10, 1], [50, 10, 1], [60, 10, 1], [70, 10, 1], [80, 10, 1], [90, 10, 1], [100, 10, 1]]) == 1\n assert candidate(bombs = [[100, 100, 10], [100, 110, 10], [100, 120, 10], [110, 100, 10], [110, 110, 10], [110, 120, 10], [120, 100, 10], [120, 110, 10], [120, 120, 10]]) == 9\n assert candidate(bombs = [[0, 0, 1], [1, 0, 1], [2, 0, 1], [3, 0, 1], [4, 0, 1], [5, 0, 1], [6, 0, 1]]) == 7\n assert candidate(bombs = [[10, 10, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5], [30, 30, 5], [35, 35, 5], [40, 40, 5]]) == 1\n assert candidate(bombs = [[50, 50, 10], [60, 60, 20], [70, 70, 30], [80, 80, 40], [90, 90, 50]]) == 5\n assert candidate(bombs = [[10, 10, 3], [10, 13, 3], [13, 10, 3], [13, 13, 3], [16, 16, 3], [16, 19, 3], [19, 16, 3], [19, 19, 3]]) == 4\n assert candidate(bombs = [[1, 1, 10], [1, 10, 10], [10, 1, 10], [10, 10, 10], [15, 15, 15], [15, 5, 15], [5, 15, 15], [20, 20, 5]]) == 8\n assert candidate(bombs = [[0, 0, 1], [1, 0, 1], [2, 0, 1], [3, 0, 1], [4, 0, 1], [5, 0, 1], [6, 0, 1], [7, 0, 1], [8, 0, 1], [9, 0, 1]]) == 10\n assert candidate(bombs = [[50, 50, 5], [55, 50, 5], [60, 50, 5], [65, 50, 5], [70, 50, 5], [75, 50, 5], [80, 50, 5], [85, 50, 5], [90, 50, 5], [95, 50, 5], [100, 50, 5], [105, 50, 5], [110, 50, 5], [115, 50, 5], [120, 50, 5], [125, 50, 5], [130, 50, 5], [135, 50, 5], [140, 50, 5], [145, 50, 5]]) == 20\n assert candidate(bombs = [[100, 100, 10], [110, 100, 10], [120, 100, 10], [130, 100, 10], [140, 100, 10], [150, 100, 10], [160, 100, 10], [170, 100, 10], [180, 100, 10]]) == 9\n assert candidate(bombs = [[1, 2, 1], [2, 3, 1], [3, 4, 1], [4, 5, 1], [5, 6, 1], [6, 7, 1], [7, 8, 1], [8, 9, 1], [9, 10, 1]]) == 1\n assert candidate(bombs = [[50, 50, 5], [60, 50, 5], [70, 50, 5], [80, 50, 5], [50, 60, 5], [50, 70, 5], [50, 80, 5], [50, 90, 5], [50, 100, 5], [60, 60, 15]]) == 6\n assert candidate(bombs = [[100, 100, 50], [200, 100, 50], [100, 200, 50], [200, 200, 50], [150, 150, 100]]) == 5\n assert candidate(bombs = [[10, 10, 1], [20, 20, 1], [30, 30, 1], [40, 40, 1], [50, 50, 1], [60, 60, 1], [70, 70, 1], [80, 80, 1], [90, 90, 1], [100, 100, 100]]) == 8\n assert candidate(bombs = [[5, 5, 5], [5, 15, 5], [15, 5, 5], [15, 15, 5], [10, 10, 20]]) == 5\n assert candidate(bombs = [[1, 1, 5], [2, 2, 10], [3, 3, 2], [4, 4, 8], [5, 5, 1]]) == 5\n assert candidate(bombs = [[1, 1, 100], [1, 1, 100], [1, 1, 100], [1, 1, 100], [1, 1, 100]]) == 5\n assert candidate(bombs = [[0, 0, 20], [5, 0, 15], [10, 0, 10], [15, 0, 5], [20, 0, 1], [25, 0, 20], [30, 0, 15], [35, 0, 10], [40, 0, 5]]) == 9\n assert candidate(bombs = [[0, 0, 1], [2, 0, 1], [0, 2, 1], [2, 2, 1], [1, 1, 1.5]]) == 5\n assert candidate(bombs = [[50, 50, 15], [60, 50, 20], [70, 50, 10], [50, 60, 25], [50, 70, 12], [50, 80, 5]]) == 6\n assert candidate(bombs = [[0, 0, 10], [10, 0, 20], [20, 0, 30], [30, 0, 40], [40, 0, 50], [50, 0, 60], [60, 0, 70], [70, 0, 80], [80, 0, 90]]) == 9\n assert candidate(bombs = [[1, 1, 10], [10, 1, 10], [1, 10, 10], [10, 10, 10], [5, 5, 5], [15, 15, 15]]) == 6\n assert candidate(bombs = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [1, 6, 6], [1, 7, 7], [1, 8, 8], [1, 9, 9], [1, 10, 10]]) == 10\n assert candidate(bombs = [[1, 1, 10], [20, 20, 10], [30, 30, 10], [40, 40, 10], [50, 50, 10], [60, 60, 10]]) == 1\n assert candidate(bombs = [[100, 100, 50], [200, 200, 50], [300, 300, 50], [100, 200, 60], [200, 300, 70]]) == 1\n assert candidate(bombs = [[10, 10, 1], [15, 15, 2], [20, 20, 3], [25, 25, 4], [30, 30, 5]]) == 1\n assert candidate(bombs = [[5, 5, 1], [5, 6, 1], [5, 7, 1], [5, 8, 1], [5, 9, 1]]) == 5\n assert candidate(bombs = [[1, 1, 10], [2, 2, 20], [3, 3, 30], [4, 4, 40], [5, 5, 50], [6, 6, 60]]) == 6\n assert candidate(bombs = [[5, 5, 20], [10, 5, 20], [15, 5, 20], [20, 5, 20], [25, 5, 20], [30, 5, 20], [35, 5, 20], [40, 5, 20], [45, 5, 20], [50, 5, 20]]) == 10\n assert candidate(bombs = [[1, 1, 100], [200, 200, 100], [400, 400, 100], [600, 600, 100], [800, 800, 100], [1000, 1000, 100], [1200, 1200, 100], [1400, 1400, 100], [1600, 1600, 100], [1800, 1800, 100]]) == 1\n assert candidate(bombs = [[0, 0, 10], [20, 20, 10], [10, 10, 15], [30, 30, 20]]) == 3\n assert candidate(bombs = [[10, 10, 15], [20, 20, 15], [30, 30, 15], [40, 40, 15], [50, 50, 15], [60, 60, 15], [70, 70, 15], [80, 80, 15], [90, 90, 15]]) == 9\n assert candidate(bombs = [[10, 10, 15], [20, 20, 15], [30, 30, 15], [40, 40, 15], [50, 50, 15], [60, 60, 15], [70, 70, 15]]) == 7\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10]]) == 10\n assert candidate(bombs = [[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6], [5, 6, 7], [6, 7, 8], [7, 8, 9], [8, 9, 10]]) == 8\n assert candidate(bombs = [[100, 100, 100], [200, 100, 100], [300, 100, 100], [400, 100, 100], [500, 100, 100], [600, 100, 100], [700, 100, 100], [800, 100, 100], [900, 100, 100]]) == 9\n assert candidate(bombs = [[0, 0, 1], [1, 0, 1], [2, 0, 1], [3, 0, 1], [4, 0, 1], [5, 0, 1], [6, 0, 1], [7, 0, 1], [8, 0, 1], [9, 0, 1], [10, 0, 1]]) == 11\n assert candidate(bombs = [[1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1]]) == 1\n assert candidate(bombs = [[10, 10, 5], [15, 10, 5], [20, 10, 5], [25, 10, 5], [30, 10, 5], [35, 10, 5], [40, 10, 5], [45, 10, 5]]) == 8\n assert candidate(bombs = [[1, 1, 100], [1, 101, 100], [101, 101, 100], [101, 1, 100], [51, 51, 100], [51, 1, 100], [1, 51, 100], [101, 51, 100], [51, 101, 100]]) == 9\n assert candidate(bombs = [[1, 1, 2], [2, 2, 2], [3, 3, 2], [4, 4, 2], [5, 5, 2], [6, 6, 2]]) == 6\n assert candidate(bombs = [[10, 10, 20], [30, 30, 20], [50, 50, 20], [70, 70, 20], [90, 90, 20], [110, 110, 20], [130, 130, 20], [150, 150, 20], [170, 170, 20], [190, 190, 20], [210, 210, 20], [230, 230, 20], [250, 250, 20], [270, 270, 20], [290, 290, 20]]) == 1\n assert candidate(bombs = [[5, 5, 2], [10, 5, 2], [15, 5, 2], [20, 5, 2], [25, 5, 2], [30, 5, 2], [35, 5, 2], [40, 5, 2], [45, 5, 2], [50, 5, 2], [55, 5, 2]]) == 1\n assert candidate(bombs = [[10, 10, 15], [20, 20, 25], [30, 30, 35], [40, 40, 45], [50, 50, 55]]) == 5\n assert candidate(bombs = [[100, 100, 100], [200, 200, 50], [300, 300, 25], [400, 400, 12.5]]) == 1\n assert candidate(bombs = [[5, 5, 10], [15, 5, 10], [5, 15, 10], [15, 15, 10], [10, 10, 5]]) == 5\n assert candidate(bombs = [[1, 1, 2], [2, 2, 2], [3, 3, 2], [4, 4, 2], [5, 5, 2], [6, 6, 2], [7, 7, 2], [8, 8, 2], [9, 9, 2]]) == 9\n assert candidate(bombs = [[10, 10, 25], [15, 10, 15], [10, 15, 20], [5, 10, 10], [10, 5, 15]]) == 5\n assert candidate(bombs = [[1, 1, 3], [4, 4, 3], [7, 1, 3], [4, 7, 3], [10, 10, 3]]) == 2\n assert candidate(bombs = [[1, 1, 5], [1, 6, 5], [6, 1, 5], [6, 6, 5], [3, 3, 1]]) == 5\n assert candidate(bombs = [[1, 1, 1000], [2, 2, 1000], [3, 3, 1000], [4, 4, 1000], [5, 5, 1000], [6, 6, 1000], [7, 7, 1000], [8, 8, 1000]]) == 8\n assert candidate(bombs = [[0, 0, 1], [1, 1, 1], [2, 2, 1], [3, 3, 1], [4, 4, 1], [5, 5, 1], [6, 6, 1], [7, 7, 1], [8, 8, 1], [9, 9, 1]]) == 1\n assert candidate(bombs = [[100, 100, 50], [150, 100, 50], [200, 100, 50], [250, 100, 50], [300, 100, 50], [350, 100, 50], [400, 100, 50], [450, 100, 50]]) == 8\n assert candidate(bombs = [[0, 0, 5], [10, 0, 5], [5, 5, 5], [15, 5, 5]]) == 1\n assert candidate(bombs = [[10, 10, 5], [15, 10, 5], [10, 15, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5]]) == 4\n assert candidate(bombs = [[0, 0, 10], [15, 0, 10], [30, 0, 10], [22, 0, 5]]) == 2\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10], [11, 11, 11], [12, 12, 12], [13, 13, 13], [14, 14, 14], [15, 15, 15]]) == 15\n assert candidate(bombs = [[0, 0, 10], [20, 0, 10], [40, 0, 10], [60, 0, 10], [80, 0, 10], [100, 0, 10], [120, 0, 10], [140, 0, 10], [160, 0, 10], [180, 0, 10]]) == 1\n assert candidate(bombs = [[5, 5, 5], [10, 10, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5], [30, 30, 5], [35, 35, 5], [40, 40, 5]]) == 1\n assert candidate(bombs = [[50, 50, 50], [60, 60, 50], [70, 70, 50], [80, 80, 50], [90, 90, 50], [100, 100, 50]]) == 6\n assert candidate(bombs = [[50, 50, 50], [100, 100, 50], [150, 150, 50], [200, 200, 50], [250, 250, 50], [300, 300, 50], [350, 350, 50], [400, 400, 50], [450, 450, 50]]) == 1\n assert candidate(bombs = [[0, 0, 10], [10, 0, 10], [20, 0, 10], [30, 0, 10], [40, 0, 10], [50, 0, 10]]) == 6\n assert candidate(bombs = [[10, 10, 5], [15, 15, 3], [20, 20, 4], [25, 25, 2], [30, 30, 6]]) == 1\n assert candidate(bombs = [[10, 10, 15], [15, 15, 15], [20, 20, 15], [25, 25, 15], [30, 30, 15]]) == 5\n assert candidate(bombs = [[10, 10, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5], [30, 30, 5]]) == 1\n assert candidate(bombs = [[1, 1, 100], [101, 101, 100], [201, 201, 100], [301, 301, 100], [401, 401, 100]]) == 1\n assert candidate(bombs = [[5, 5, 3], [7, 5, 3], [9, 5, 3], [11, 5, 3], [13, 5, 3]]) == 5\n assert candidate(bombs = [[1, 1, 5], [2, 2, 5], [3, 3, 5], [4, 4, 5], [5, 5, 5], [6, 6, 5], [7, 7, 5], [8, 8, 5], [9, 9, 5]]) == 9\n assert candidate(bombs = [[10000, 10000, 5000], [15000, 10000, 10000], [20000, 10000, 3000], [10000, 20000, 6000], [25000, 25000, 8000]]) == 3\n assert candidate(bombs = [[1, 1, 1], [1, 2, 2], [1, 3, 3], [1, 4, 4], [1, 5, 5], [1, 6, 6], [1, 7, 7], [1, 8, 8], [1, 9, 9]]) == 9\n assert candidate(bombs = [[1000, 1000, 1000], [2000, 2000, 500], [3000, 3000, 250], [4000, 4000, 125]]) == 1\n assert candidate(bombs = [[0, 0, 10], [10, 0, 10], [20, 0, 10], [30, 0, 10], [40, 0, 10]]) == 5\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5]]) == 5\n assert candidate(bombs = [[10, 10, 50], [20, 20, 40], [30, 30, 30], [40, 40, 20], [50, 50, 10]]) == 5\n assert candidate(bombs = [[5, 5, 10], [10, 10, 10], [15, 15, 10], [20, 20, 10], [25, 25, 10], [30, 30, 10], [35, 35, 10]]) == 7\n assert candidate(bombs = [[10, 10, 10], [20, 20, 10], [30, 30, 10], [40, 40, 10], [50, 50, 10], [60, 60, 10], [70, 70, 10], [80, 80, 10], [90, 90, 10], [100, 100, 10], [110, 110, 10], [120, 120, 10], [130, 130, 10], [140, 140, 10], [150, 150, 10]]) == 1\n assert candidate(bombs = [[1, 1, 10], [10, 1, 5], [10, 10, 15], [20, 20, 10]]) == 4\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7]]) == 7\n assert candidate(bombs = [[1, 1, 10], [10, 1, 5], [1, 10, 5], [5, 5, 2], [7, 7, 7]]) == 5\n assert candidate(bombs = [[1, 1, 10000], [2, 2, 10000], [3, 3, 10000], [4, 4, 10000], [5, 5, 10000], [6, 6, 10000], [7, 7, 10000], [8, 8, 10000], [9, 9, 10000], [10, 10, 10000]]) == 10\n assert candidate(bombs = [[10, 10, 1], [11, 11, 2], [12, 12, 3], [13, 13, 4], [14, 14, 5], [15, 15, 6], [16, 16, 7], [17, 17, 8], [18, 18, 9], [19, 19, 10]]) == 10\n assert candidate(bombs = [[0, 0, 10], [10, 0, 10], [20, 0, 10], [15, 5, 5]]) == 4\n assert candidate(bombs = [[1, 1, 10], [11, 1, 10], [21, 1, 10], [1, 11, 10], [11, 11, 10], [21, 11, 10], [1, 21, 10], [11, 21, 10], [21, 21, 10]]) == 9\n assert candidate(bombs = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15]]) == 5\n assert candidate(bombs = [[1, 1, 10], [2, 1, 10], [3, 1, 10], [4, 1, 10], [5, 1, 10], [6, 1, 10], [7, 1, 10], [8, 1, 10], [9, 1, 10], [10, 1, 10]]) == 10\n assert candidate(bombs = [[1, 1, 5], [2, 2, 5], [3, 3, 5], [4, 4, 5], [5, 5, 5], [6, 6, 5], [7, 7, 5], [8, 8, 5], [9, 9, 5], [10, 10, 5], [11, 11, 5], [12, 12, 5], [13, 13, 5], [14, 14, 5], [15, 15, 5]]) == 15\n assert candidate(bombs = [[0, 0, 1], [1, 2, 2], [2, 4, 3], [3, 6, 4], [4, 8, 5], [5, 10, 6], [6, 12, 7], [7, 14, 8], [8, 16, 9]]) == 8\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9]]) == 9\n assert candidate(bombs = [[5, 5, 5], [10, 10, 5], [15, 15, 5], [20, 20, 5], [25, 25, 5], [30, 30, 5], [35, 35, 5], [40, 40, 5], [45, 45, 5], [50, 50, 5]]) == 1\n assert candidate(bombs = [[0, 0, 50], [50, 0, 50], [100, 0, 50], [150, 0, 50], [200, 0, 50], [250, 0, 50], [300, 0, 50], [350, 0, 50], [400, 0, 50]]) == 9\n assert candidate(bombs = [[10, 10, 5], [20, 20, 5], [30, 30, 5], [40, 40, 5], [50, 50, 5], [60, 60, 5], [70, 70, 5], [80, 80, 5], [90, 90, 5], [100, 100, 5], [110, 110, 5], [120, 120, 5], [130, 130, 5], [140, 140, 5], [150, 150, 5]]) == 1\n assert candidate(bombs = [[10, 10, 3], [12, 12, 2], [15, 15, 1], [18, 18, 4], [20, 20, 5]]) == 2\n assert candidate(bombs = [[10, 10, 5], [15, 10, 10], [20, 10, 3], [10, 20, 6], [25, 25, 8]]) == 3\n assert candidate(bombs = [[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4], [5, 5, 5], [6, 6, 6], [7, 7, 7], [8, 8, 8], [9, 9, 9], [10, 10, 10], [11, 11, 11], [12, 12, 12], [13, 13, 13]]) == 13\n assert candidate(bombs = [[100, 100, 50], [200, 200, 50], [300, 300, 50], [250, 250, 100]]) == 3\n assert candidate(bombs = [[1, 1, 5], [5, 1, 5], [9, 1, 5], [13, 1, 5]]) == 4\n"}, "metadata": {"canonical_parameter_names": ["bombs"], "leetcode_dataset_entry_point": "Solution().maximumDetonation", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maximumDetonation(vector>& bombs) {", "container": "Solution", "callable": "maximumDetonation", "parameters": [{"name": "bombs", "type": "vector>&"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2103, "task_id": "rings-and-rods", "difficulty": "Easy", "problem_description": "There are n rings and each ring is either red, green, or blue. The rings are distributed across ten rods labeled from 0 to 9.\nYou are given a string rings of length 2n that describes the n rings that are placed onto the rods. Every two characters in rings forms a color-position pair that is used to describe each ring where:\n\nThe first character of the ith pair denotes the ith ring's color ('R', 'G', 'B').\nThe second character of the ith pair denotes the rod that the ith ring is placed on ('0' to '9').\n\nFor example, \"R3G2B1\" describes n == 3 rings: a red ring placed onto the rod labeled 3, a green ring placed onto the rod labeled 2, and a blue ring placed onto the rod labeled 1.\nReturn the number of rods that have all three colors of rings on them.\n \nExample 1:\n\n\nInput: rings = \"B0B6G0R6R0R6G9\"\nOutput: 1\nExplanation: \n- The rod labeled 0 holds 3 rings with all colors: red, green, and blue.\n- The rod labeled 6 holds 3 rings, but it only has red and blue.\n- The rod labeled 9 holds only a green ring.\nThus, the number of rods with all three colors is 1.\n\nExample 2:\n\n\nInput: rings = \"B0R0G0R9R0B0G0\"\nOutput: 1\nExplanation: \n- The rod labeled 0 holds 6 rings with all colors: red, green, and blue.\n- The rod labeled 9 holds only a red ring.\nThus, the number of rods with all three colors is 1.\n\nExample 3:\n\nInput: rings = \"G4\"\nOutput: 0\nExplanation: \nOnly one ring is given. Thus, no rods have all three colors.\n\n \nConstraints:\n\nrings.length == 2 * n\n1 <= n <= 100\nrings[i] where i is even is either 'R', 'G', or 'B' (0-indexed).\nrings[i] where i is odd is a digit from '0' to '9' (0-indexed).\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2\") == 3\n assert candidate(rings = \"R9G9B9R9G9B9R9G9B9\") == 1\n assert candidate(rings = \"G4\") == 0\n assert candidate(rings = \"R0G0R0G0R0G0\") == 0\n assert candidate(rings = \"G0G1G2G3G4G5G6G7G8G9\") == 0\n assert candidate(rings = \"B0B1B2B3B4B5B6B7B8B9\") == 0\n assert candidate(rings = \"G1G2G3G4G5G6G7G8G9G0\") == 0\n assert candidate(rings = \"R1R2R3R4R5R6R7R8R9R0\") == 0\n assert candidate(rings = \"B0B6G0R6R0R6G9\") == 1\n assert candidate(rings = \"R9G9B9\") == 1\n assert candidate(rings = \"B1B2B3B4B5B6B7B8B9B0\") == 0\n assert candidate(rings = \"R0R0G0G0B0B0R1R1G1G1B1B1\") == 2\n assert candidate(rings = \"B0R0G0R9R0B0G0\") == 1\n assert candidate(rings = \"R0G1B2R3G4B5R6G7B8R9\") == 0\n assert candidate(rings = \"R1R1R1G1G1G1B1B1B1\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0R1R2R3R4R5R6R7R8R9\") == 0\n assert candidate(rings = \"R9G9B9R9G9B9\") == 1\n assert candidate(rings = \"R0G0B0R1G0B0R2G0B0R3G0B0R4G0B0R5G0B0R6G0B0R7G0B0R8G0B0R9G0B0\") == 1\n assert candidate(rings = \"R5G5B5R5G5B5R5G5B5\") == 1\n assert candidate(rings = \"R1G1B1R2G2B2R3G3B3\") == 3\n assert candidate(rings = \"B9B9B9G9G9G9R9R9R9\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R1G1B1R2G2B2\") == 2\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9\") == 10\n assert candidate(rings = \"R0G0B0R2G2B2R4G4B4R6G6B6R8G8B8\") == 5\n assert candidate(rings = \"R9G9B9R8G8B8R7G7B7\") == 3\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R1G1B1R1G1B1R1G1B1R1G1B1R2G2B2R2G2B2R2G2B2R2G2B2\") == 3\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9\") == 10\n assert candidate(rings = \"R0G1B2R3G4B5R6G7B8R9G0B1R2G3B4R5G6B7R8G9B0R1G2B3R4G5B6R7G8B9\") == 10\n assert candidate(rings = \"R0G1B2R3G4B5R6G7B8R9G0B1R2G3B4R5G6B7R8G9B0R1G2B3R4G5B6R7G8B9R0G1B2R3G4B5\") == 10\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R0G0B0R1G1B1R2G2B2R3G3B3R0G0B0\") == 4\n assert candidate(rings = \"R0R0G0G0B0B0R1R1G1G1B1B1R2R2G2G2B2B2R3R3G3G3B3B3R4R4G4G4B4B4R5R5G5G5B5B5\") == 6\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0R1G0B1R2G0B2R3G0B3R4G0B4R5G0B5R6G0B6R7G0B7R8G0B8R9G0B9R0G0B0R1G0B1R2G0B2R3G0B3R4G0B4R5G0B5R6G0B6R7G0B7R8G0B8R9G0B9\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R5G5B5R5G5B5R5G5B5R5G5B5R5G5B5\") == 10\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R9G9B9\") == 10\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5\") == 10\n assert candidate(rings = \"R0G1B2R3G4B5R6G7B8R9G0B1R2G3B4R5G6B7R8G9B0\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R1G1B1\") == 10\n assert candidate(rings = \"R5G5B5R5G5B5R5G5B5R5G5B5R5G5B5R5G5B5R5G5B5R5G5B5R5G5B5\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1\") == 10\n assert candidate(rings = \"R0R0R0R0R0R0R0R0R0R0G0G0G0G0G0G0G0G0G0G0G0G0B0B0B0B0B0B0B0B0B0B0\") == 1\n assert candidate(rings = \"R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2\") == 0\n assert candidate(rings = \"R0G0B0R0G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9\") == 9\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0\") == 10\n assert candidate(rings = \"R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3\") == 0\n assert candidate(rings = \"R0G0B0R1G0B0R2G0B0R3G0B0R4G0B0R5G0B0R6G0B0R7G0B0R8G0B0R9G0B0R0G0B0R1G0B0\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R9G9B9R9G9B9\") == 10\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R0G0B0R0G0B0\") == 10\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3R3G3B3\") == 10\n assert candidate(rings = \"R0G1B2R3G4B5R6G7B8R9G0B1R2G3B4R5G6B7R8G9B0R1G1B1R2G2B2R3G3B3\") == 4\n assert candidate(rings = \"R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3R1G2B3\") == 0\n assert candidate(rings = \"R9G9B9R8G8B8R7G7B7R6G6B6R5G5B5R4G4B4R3G3B3R2G2B2R1G1B1R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R1G1B1R1G1B1R1G1B1R2G2B2R2G2B2R2G2B2R3G3B3\") == 4\n assert candidate(rings = \"R0R0R0R0R0R1R1R1R1R1R2R2R2R2R2R3R3R3R3R3R4R4R4R4R4R5R5R5R5R5R6R6R6R6R6R7R7R7R7R7R8R8R8R8R8R9R9R9R9R9\") == 0\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0G0B0R1G1B1R1G1B2G2B2R2G2B3G3B3R3G3B4G4B4R4G4B5G5B5R5G5B6G6B6R6G6B7G7B7R7G7B8G8B8R8G8B9G9B9R9G9B9\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R8G8B8\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1\") == 2\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1\") == 2\n assert candidate(rings = \"R9G8B7R6G5B4R3G2B1R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5\") == 6\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R7G7B7R7G7B7R7G7B7\") == 10\n assert candidate(rings = \"R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2\") == 0\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9\") == 10\n assert candidate(rings = \"R9G9B9R8G8B8R7G7B7R6G6B6R5G5B5R4G4B4R3G3B3R2G2B2R1G1B1R0G0B0\") == 10\n assert candidate(rings = \"R0G1B2R3G4B5R6G7B8R9G0B1R2G3B4R5G6B7R8G9B0R1G2B3R4G5B6R7G8B9R0G1B2R3G4B5R6G7B8R9G0\") == 10\n assert candidate(rings = \"R0B0G1R1B1G2R2B2G3R3B3G4R4B4G5R5B5G6R6B6G7R7B7G8R8B8G9R9B9\") == 9\n assert candidate(rings = \"R0G0B0G0B0R0B0G0R0R0G0B0R0G0B0R0R0G0R0G0B0R0B0G0R0G0R0B0G0R0\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0R0\") == 0\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R6G6B6R6G6B6R6G6B6R6G6B6\") == 10\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R4G4B4R4G4B4R4G4B4R4G4B4R4G4B4R4G4B4R4G4B4R4G4B4\") == 10\n assert candidate(rings = \"R0R0R0G0G0G0B0B0B0R1R1R1G1G1G1B1B1B1R2R2R2G2G2G2B2B2B2\") == 3\n assert candidate(rings = \"R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1R1G1B1\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0R0R0R0R0R0R0R0R0R0G0G0G0G0G0G0G0G0G0G0G0B0B0B0B0B0B0B0B0B0B0B0B0\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4\") == 10\n assert candidate(rings = \"R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2R0G1B2\") == 0\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R1G1B1R1G1B1R1G1B1R1G1B1\") == 2\n assert candidate(rings = \"G0B0R0G1B1R1G2B2R2G3B3R3G4B4R4G5B5R5G6B6R6G7B7R7G8B8R8G9B9R9G0B0R0G1B1R1G2B2R2G3B3R3G4B4R4G5B5R5G6B6R6G7B7R7G8B8R8G9B9R9\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0R1G0B0\") == 1\n assert candidate(rings = \"B9G9R9B8G8R8B7G7R7B6G6R6B5G5R5B4G4R4B3G3R3B2G2R2B1G1R1B0G0R0B9G9R9B8G8R8B7G7R7B6G6R6B5G5R5B4G4R4B3G3R3B2G2R2B1G1R1B0G0R0\") == 10\n assert candidate(rings = \"R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0\") == 10\n assert candidate(rings = \"B0G0B0G0B0R1G1R1G1R1B2G2B2G2G2R3G3R3G3G3B4G4B4G4G4R5G5R5G5G5B6G6B6G6G6R7G7R7G7G7B8G8B8G8G8R9G9R9G9G9B9G9B9G9G9\") == 1\n assert candidate(rings = \"G0B0R0G1B1R1G2B2R2G3B3R3G4B4R4G5B5R5G6B6R6G7B7R7G8B8R8G9B9R9G0B1R2G3B4R5G6B7R8G9B0\") == 10\n assert candidate(rings = \"R0G0B0R0G1B1R0G2B2R0G3B3R0G4B4R0G5B5R0G6B6R0G7B7R0G8B8R0G9B9\") == 1\n assert candidate(rings = \"R0G0B0R1G1B1R2G2B2R3G3B3R4G4B4R5G5B5R6G6B6R7G7B7R8G8B8R9G9B9R0G0B0\") == 10\n assert candidate(rings = \"R0B1G2R3B4G5R6B7G8R9B0G1R2B3G4R5B6G7R8B9G0R1B2G3R4B5G6R7B8G9\") == 10\n assert candidate(rings = \"B9G8R7B6G5R4B3G2R1B0G9R8B7G6R5B4G3R2B1G0R9B8G7R6B5G4R3B2G1R0\") == 10\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n assert candidate(rings = \"R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0R0G0B0\") == 1\n"}, "metadata": {"canonical_parameter_names": ["rings"], "leetcode_dataset_entry_point": "Solution().countPoints", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int countPoints(string rings) {", "container": "Solution", "callable": "countPoints", "parameters": [{"name": "rings", "type": "string"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2104, "task_id": "sum-of-subarray-ranges", "difficulty": "Medium", "problem_description": "You are given an integer array nums. The range of a subarray of nums is the difference between the largest and smallest element in the subarray.\nReturn the sum of all subarray ranges of nums.\nA subarray is a contiguous non-empty sequence of elements within an array.\n \nExample 1:\n\nInput: nums = [1,2,3]\nOutput: 4\nExplanation: The 6 subarrays of nums are the following:\n[1], range = largest - smallest = 1 - 1 = 0 \n[2], range = 2 - 2 = 0\n[3], range = 3 - 3 = 0\n[1,2], range = 2 - 1 = 1\n[2,3], range = 3 - 2 = 1\n[1,2,3], range = 3 - 1 = 2\nSo the sum of all ranges is 0 + 0 + 0 + 1 + 1 + 2 = 4.\nExample 2:\n\nInput: nums = [1,3,3]\nOutput: 4\nExplanation: The 6 subarrays of nums are the following:\n[1], range = largest - smallest = 1 - 1 = 0\n[3], range = 3 - 3 = 0\n[3], range = 3 - 3 = 0\n[1,3], range = 3 - 1 = 2\n[3,3], range = 3 - 3 = 0\n[1,3,3], range = 3 - 1 = 2\nSo the sum of all ranges is 0 + 0 + 0 + 2 + 0 + 2 = 4.\n\nExample 3:\n\nInput: nums = [4,-2,-3,4,1]\nOutput: 59\nExplanation: The sum of all subarray ranges of nums is 59.\n\n \nConstraints:\n\n1 <= nums.length <= 1000\n-109 <= nums[i] <= 109\n\n \nFollow-up: Could you find a solution with O(n) time complexity?\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(nums = [-1, -2, -3, -4]) == 10\n assert candidate(nums = [0, 0, 0, 0]) == 0\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 165\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 165\n assert candidate(nums = [1, -1, 1, -1, 1, -1]) == 30\n assert candidate(nums = [4, -2, -3, 4, 1]) == 59\n assert candidate(nums = [3, 2, 2, 2, 1]) == 8\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000]) == 20000000000\n assert candidate(nums = [10, 20, 30, 40, 50]) == 200\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 20\n assert candidate(nums = [0, 0, 0, 0, 0]) == 0\n assert candidate(nums = [1, 2, 3, 4, 5]) == 20\n assert candidate(nums = [100, 100, 100, 100]) == 0\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000]) == 12000000000\n assert candidate(nums = [1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [10, -10, 20, -20, 30, -30]) == 700\n assert candidate(nums = [10, 20, 30, 40, 50]) == 200\n assert candidate(nums = [1, 2, 2, 2, 3]) == 8\n assert candidate(nums = [5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [-10, -20, -30, -40, -50]) == 200\n assert candidate(nums = [1, 3, 3]) == 4\n assert candidate(nums = [1, 2, 3]) == 4\n assert candidate(nums = [-10, 100, -20, 200, -30, 300]) == 3580\n assert candidate(nums = [5]) == 0\n assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1, 0, 1]) == 66\n assert candidate(nums = [-1, 4, -2, 3, -3]) == 60\n assert candidate(nums = [1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 45\n assert candidate(nums = [1, 0, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 384\n assert candidate(nums = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]) == 16500\n assert candidate(nums = [1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) == 64\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40, 50]) == 2400\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 190\n assert candidate(nums = [10, 20, 30, 25, 15, 10, 5, 2, 1, 0]) == 743\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 105\n assert candidate(nums = [15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 560\n assert candidate(nums = [5, 3, 8, 1, 4]) == 57\n assert candidate(nums = [10, 20, 30, 25, 15, 5]) == 240\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4]) == 168\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000]) == 12000000000\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 330\n assert candidate(nums = [5, 1, 4, 2, 8, 3]) == 77\n assert candidate(nums = [1, 2, 2, 3, 3, 4, 4, 5, 5]) == 60\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7, -8, -9, -10]) == 1540\n assert candidate(nums = [100, 200, 300, 400, 500, -500, -400, -300, -200, -100]) == 29000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 560\n assert candidate(nums = [100, 200, 300, 400, 500]) == 2000\n assert candidate(nums = [10, 20, 30, 40, 50, -50, -40, -30, -20, -10]) == 2900\n assert candidate(nums = [1000000000, -1000000000, 1000000000, -1000000000, 1000000000]) == 20000000000\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5]) == 635\n assert candidate(nums = [1000000000, 1000000000, 1000000000, 1000000000]) == 0\n assert candidate(nums = [100, 200, 300, 400, 500, 100, 200, 300, 400, 500, 100, 200, 300, 400, 500]) == 36000\n assert candidate(nums = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 1540\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4]) == 40\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [100, 10, 1, 0, 1, 10, 100]) == 1149\n assert candidate(nums = [-1, 0, 1, -1, 0, 1, -1, 0, 1]) == 66\n assert candidate(nums = [9, -8, 7, -6, 5, -4, 3, -2, 1]) == 444\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 330\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5]) == 80\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1]) == 28\n assert candidate(nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9]) == 480\n assert candidate(nums = [10, 1, 20, 2, 30, 3, 40, 4, 50, 5]) == 1655\n assert candidate(nums = [1, 2, 3, 4, 5, -1, -2, -3, -4, -5]) == 240\n assert candidate(nums = [10, -10, 20, -20, 30, -30, 40, -40]) == 1680\n assert candidate(nums = [10, 20, 10, 20, 10, 20, 10]) == 210\n assert candidate(nums = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) == 45\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000, 250000000, -250000000]) == 21000000000\n assert candidate(nums = [150, 140, 130, 120, 110, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 5600\n assert candidate(nums = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 1650\n assert candidate(nums = [19, 17, 15, 13, 11, 9, 7, 5, 3, 1]) == 330\n assert candidate(nums = [5, 8, 6, 7, 9, 1, 2, 3, 4, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1736\n assert candidate(nums = [9, 7, 5, 3, 1]) == 40\n assert candidate(nums = [5, 8, 3, 7, 9, 1]) == 87\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1000, 900, 800, 700, 600, 500, 400, 300, 200, 100, 0]) == 22000\n assert candidate(nums = [3, 1, 2, 4, 5, 6, 7, 8, 9, 10]) == 180\n assert candidate(nums = [-1, -2, -3, -4, -5]) == 20\n assert candidate(nums = [10, -5, 3, 7, -2, 8]) == 172\n assert candidate(nums = [1, 2, 3, 4, 3, 2, 1]) == 42\n assert candidate(nums = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 165\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]) == 330\n assert candidate(nums = [1, 2, 3, 4, 5, 4, 3, 2, 1]) == 90\n assert candidate(nums = [-1, -5, -9, -3, -6]) == 59\n assert candidate(nums = [100, 200, 300, 400, 500, 600]) == 3500\n assert candidate(nums = [1, 5, 3, 7, 9, 2, 6, 8, 4, 10]) == 283\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]) == 560\n assert candidate(nums = [5, 4, 3, 2, 1]) == 20\n assert candidate(nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 165\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5]) == 240\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 1650\n assert candidate(nums = [5, 2, 9, 1, 5, 6]) == 99\n assert candidate(nums = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == 328\n assert candidate(nums = [1, 3, 2, 5, 4, 7, 6, 9, 8, 11, 10, 13, 12, 15, 14]) == 651\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1540\n assert candidate(nums = [1, 10, 2, 9, 3, 8, 4, 7, 5, 6]) == 285\n assert candidate(nums = [100, -100, 200, -200, 300]) == 4000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 90, 80, 70, 60, 50, 40, 30, 20, 10]) == 8550\n assert candidate(nums = [9, 7, 5, 3, 1, 2, 4, 6, 8, 10]) == 235\n assert candidate(nums = [10, -20, 30, -40, 50, -60, 70, -80, 90, -100]) == 6150\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1000000000, 1000000000, -1000000000, -1000000000]) == 8000000000\n assert candidate(nums = [-1, 2, -3, 4, -5]) == 70\n assert candidate(nums = [1000000000, -1000000000, 500000000, -500000000, 250000000]) == 15250000000\n assert candidate(nums = [100, -200, 300, -400, 500]) == 7000\n assert candidate(nums = [5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5]) == 220\n assert candidate(nums = [5, 3, 1, 2, 4]) == 27\n assert candidate(nums = [5, 2, 3, 1, 4, 6, 8, 7, 9, 0]) == 244\n assert candidate(nums = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39]) == 2660\n assert candidate(nums = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2]) == 45\n assert candidate(nums = [5, 3, 8, 1, 4]) == 57\n assert candidate(nums = [5, 2, 4, 6, 1, 3]) == 60\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1]) == 56\n assert candidate(nums = [1, -1, 2, -2, 3, -3, 4, -4, 5, -5]) == 330\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]) == 1650\n assert candidate(nums = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5]) == 0\n assert candidate(nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) == 0\n assert candidate(nums = [1, -1, 1, -1, 1, -1, 1, -1, 1, -1]) == 90\n assert candidate(nums = [5, 3, 8, 2, 7]) == 53\n assert candidate(nums = [5, 1, 4, 3, 2]) == 29\n assert candidate(nums = [1, 2, 3, -1, -2, -3, 4, 5, 6]) == 201\n assert candidate(nums = [1, -2, 3, -4, 5, -6, 7, -8, 9, -10, 11, -12, 13, -14, 15]) == 2135\n assert candidate(nums = [-10, -20, -30, -40, -50, -60, -70, -80, -90, -100]) == 1650\n assert candidate(nums = [1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 3]) == 392\n assert candidate(nums = [1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000]) == 165000\n assert candidate(nums = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150]) == 5600\n assert candidate(nums = [7, 6, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, -6, -7]) == 560\n assert candidate(nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]) == 1540\n"}, "metadata": {"canonical_parameter_names": ["nums"], "leetcode_dataset_entry_point": "Solution().subArrayRanges", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "long long subArrayRanges(vector& nums) {", "container": "Solution", "callable": "subArrayRanges", "parameters": [{"name": "nums", "type": "vector&"}], "return_type": "long long", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2105, "task_id": "watering-plants-ii", "difficulty": "Medium", "problem_description": "Alice and Bob want to water n plants in their garden. The plants are arranged in a row and are labeled from 0 to n - 1 from left to right where the ith plant is located at x = i.\nEach plant needs a specific amount of water. Alice and Bob have a watering can each, initially full. They water the plants in the following way:\n\nAlice waters the plants in order from left to right, starting from the 0th plant. Bob waters the plants in order from right to left, starting from the (n - 1)th plant. They begin watering the plants simultaneously.\nIt takes the same amount of time to water each plant regardless of how much water it needs.\nAlice/Bob must water the plant if they have enough in their can to fully water it. Otherwise, they first refill their can (instantaneously) then water the plant.\nIn case both Alice and Bob reach the same plant, the one with more water currently in his/her watering can should water this plant. If they have the same amount of water, then Alice should water this plant.\n\nGiven a 0-indexed integer array plants of n integers, where plants[i] is the amount of water the ith plant needs, and two integers capacityA and capacityB representing the capacities of Alice's and Bob's watering cans respectively, return the number of times they have to refill to water all the plants.\n \nExample 1:\n\nInput: plants = [2,2,3,3], capacityA = 5, capacityB = 5\nOutput: 1\nExplanation:\n- Initially, Alice and Bob have 5 units of water each in their watering cans.\n- Alice waters plant 0, Bob waters plant 3.\n- Alice and Bob now have 3 units and 2 units of water respectively.\n- Alice has enough water for plant 1, so she waters it. Bob does not have enough water for plant 2, so he refills his can then waters it.\nSo, the total number of times they have to refill to water all the plants is 0 + 0 + 1 + 0 = 1.\n\nExample 2:\n\nInput: plants = [2,2,3,3], capacityA = 3, capacityB = 4\nOutput: 2\nExplanation:\n- Initially, Alice and Bob have 3 units and 4 units of water in their watering cans respectively.\n- Alice waters plant 0, Bob waters plant 3.\n- Alice and Bob now have 1 unit of water each, and need to water plants 1 and 2 respectively.\n- Since neither of them have enough water for their current plants, they refill their cans and then water the plants.\nSo, the total number of times they have to refill to water all the plants is 0 + 1 + 1 + 0 = 2.\n\nExample 3:\n\nInput: plants = [5], capacityA = 10, capacityB = 8\nOutput: 0\nExplanation:\n- There is only one plant.\n- Alice's watering can has 10 units of water, whereas Bob's can has 8 units. Since Alice has more water in her can, she waters this plant.\nSo, the total number of times they have to refill is 0.\n\n \nConstraints:\n\nn == plants.length\n1 <= n <= 105\n1 <= plants[i] <= 106\nmax(plants[i]) <= capacityA, capacityB <= 109\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(plants = [5],capacityA = 10,capacityB = 8) == 0\n assert candidate(plants = [1000000, 1000000, 1000000],capacityA = 1000000,capacityB = 1000000) == 1\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacityA = 15,capacityB = 15) == 3\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacityA = 10,capacityB = 10) == 5\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 1,capacityB = 1) == 8\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacityA = 15,capacityB = 15) == 3\n assert candidate(plants = [2, 2, 3, 3],capacityA = 5,capacityB = 5) == 1\n assert candidate(plants = [1000000],capacityA = 1000000,capacityB = 1000000) == 0\n assert candidate(plants = [2, 2, 3, 3],capacityA = 3,capacityB = 4) == 2\n assert candidate(plants = [1, 10, 1, 10, 1, 10, 1, 10],capacityA = 10,capacityB = 10) == 6\n assert candidate(plants = [5, 8, 6],capacityA = 10,capacityB = 10) == 1\n assert candidate(plants = [10, 10, 10, 10, 10],capacityA = 10,capacityB = 10) == 3\n assert candidate(plants = [1, 2, 3, 4, 5],capacityA = 5,capacityB = 5) == 2\n assert candidate(plants = [10, 8, 6, 4, 2],capacityA = 10,capacityB = 8) == 2\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacityA = 5,capacityB = 5) == 8\n assert candidate(plants = [1, 1, 1, 1, 1],capacityA = 1,capacityB = 1) == 3\n assert candidate(plants = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],capacityA = 150,capacityB = 100) == 4\n assert candidate(plants = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],capacityA = 50,capacityB = 50) == 5\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 1,capacityB = 1) == 29\n assert candidate(plants = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],capacityA = 30,capacityB = 30) == 8\n assert candidate(plants = [1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10, 10, 10],capacityA = 10,capacityB = 12) == 17\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacityA = 20,capacityB = 20) == 5\n assert candidate(plants = [1000000, 500000, 1000000, 500000, 1000000, 500000, 1000000, 500000, 1000000, 500000],capacityA = 1000000,capacityB = 1000000) == 8\n assert candidate(plants = [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8],capacityA = 15,capacityB = 15) == 18\n assert candidate(plants = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36],capacityA = 20,capacityB = 30) == 9\n assert candidate(plants = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10],capacityA = 10,capacityB = 10) == 12\n assert candidate(plants = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],capacityA = 55,capacityB = 65) == 8\n assert candidate(plants = [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],capacityA = 5,capacityB = 5) == 22\n assert candidate(plants = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],capacityA = 15,capacityB = 20) == 6\n assert candidate(plants = [10, 20, 30, 40, 50, 40, 30, 20, 10],capacityA = 25,capacityB = 25) == 7\n assert candidate(plants = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],capacityA = 1000000,capacityB = 1000000) == 8\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],capacityA = 20,capacityB = 25) == 11\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 5,capacityB = 5) == 0\n assert candidate(plants = [1000000, 1000000, 1000000, 1000000, 1000000],capacityA = 1000000,capacityB = 1000000) == 3\n assert candidate(plants = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],capacityA = 30,capacityB = 35) == 7\n assert candidate(plants = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100],capacityA = 50,capacityB = 60) == 16\n assert candidate(plants = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],capacityA = 100,capacityB = 100) == 11\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacityA = 10,capacityB = 10) == 12\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],capacityA = 10,capacityB = 10) == 16\n assert candidate(plants = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50],capacityA = 10,capacityB = 35) == 9\n assert candidate(plants = [2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacityA = 15,capacityB = 20) == 6\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacityA = 10,capacityB = 5) == 7\n assert candidate(plants = [100, 150, 200, 250, 300, 350, 400, 450, 500],capacityA = 200,capacityB = 300) == 8\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 1,capacityB = 1) == 28\n assert candidate(plants = [20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacityA = 10,capacityB = 10) == 16\n assert candidate(plants = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],capacityA = 50,capacityB = 50) == 8\n assert candidate(plants = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150],capacityA = 150,capacityB = 150) == 8\n assert candidate(plants = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991, 999990, 999989, 999988, 999987, 999986, 999985, 999984, 999983, 999982, 999981],capacityA = 2000000,capacityB = 2000000) == 8\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],capacityA = 20,capacityB = 10) == 13\n assert candidate(plants = [100, 90, 80, 70, 60, 50, 40, 30, 20, 10],capacityA = 150,capacityB = 120) == 4\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],capacityA = 15,capacityB = 15) == 19\n assert candidate(plants = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],capacityA = 30,capacityB = 60) == 8\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 2,capacityB = 2) == 8\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],capacityA = 7,capacityB = 8) == 12\n assert candidate(plants = [250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250],capacityA = 500,capacityB = 500) == 11\n assert candidate(plants = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30],capacityA = 25,capacityB = 25) == 7\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20],capacityA = 10,capacityB = 10) == 16\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49],capacityA = 25,capacityB = 30) == 19\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacityA = 5,capacityB = 5) == 28\n assert candidate(plants = [50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50],capacityA = 50,capacityB = 50) == 115\n assert candidate(plants = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953, 976, 488, 244, 122, 61],capacityA = 1000000,capacityB = 500000) == 1\n assert candidate(plants = [1000000, 500000, 1000000, 500000],capacityA = 1000000,capacityB = 1000000) == 2\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],capacityA = 20,capacityB = 20) == 10\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacityA = 5,capacityB = 10) == 13\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1],capacityA = 5,capacityB = 5) == 8\n assert candidate(plants = [3, 2, 4, 1, 2, 4, 3, 1, 2, 3],capacityA = 5,capacityB = 5) == 4\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 1,capacityB = 1) == 28\n assert candidate(plants = [500, 400, 300, 200, 100, 100, 200, 300, 400, 500],capacityA = 500,capacityB = 500) == 6\n assert candidate(plants = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],capacityA = 15,capacityB = 15) == 7\n assert candidate(plants = [100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100],capacityA = 100,capacityB = 100) == 18\n assert candidate(plants = [1000000, 500000, 250000, 125000, 62500, 31250, 15625, 7812, 3906, 1953],capacityA = 500000,capacityB = 500000) == 3\n assert candidate(plants = [5, 7, 3, 8, 6, 10, 4, 9, 2, 1],capacityA = 10,capacityB = 12) == 5\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 2,capacityB = 2) == 8\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacityA = 15,capacityB = 15) == 7\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacityA = 10,capacityB = 9) == 13\n assert candidate(plants = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],capacityA = 500000,capacityB = 500000) == 10\n assert candidate(plants = [100, 200, 150, 50, 300, 250, 350, 400, 450, 500],capacityA = 500,capacityB = 600) == 4\n assert candidate(plants = [1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000, 1000000],capacityA = 2000000,capacityB = 1500000) == 6\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],capacityA = 14,capacityB = 16) == 12\n assert candidate(plants = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30],capacityA = 25,capacityB = 20) == 10\n assert candidate(plants = [100, 200, 300, 400, 500, 400, 300, 200, 100],capacityA = 300,capacityB = 300) == 5\n assert candidate(plants = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10],capacityA = 25,capacityB = 20) == 4\n assert candidate(plants = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3],capacityA = 5,capacityB = 5) == 18\n assert candidate(plants = [3, 2, 4, 2, 1, 2, 4, 3, 2, 1, 3, 2, 4, 2, 1],capacityA = 5,capacityB = 5) == 7\n assert candidate(plants = [100, 200, 300, 400, 500, 600, 700, 800, 900, 1000],capacityA = 500,capacityB = 400) == 8\n assert candidate(plants = [1000000, 999999, 999998, 999997, 999996, 999995, 999994, 999993, 999992, 999991],capacityA = 1000000,capacityB = 1000000) == 8\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],capacityA = 15,capacityB = 15) == 8\n assert candidate(plants = [100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71],capacityA = 150,capacityB = 150) == 26\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],capacityA = 10,capacityB = 10) == 7\n assert candidate(plants = [5, 6, 7, 8, 9, 10, 9, 8, 7, 6, 5],capacityA = 10,capacityB = 10) == 9\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],capacityA = 25,capacityB = 25) == 14\n assert candidate(plants = [5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5],capacityA = 5,capacityB = 5) == 13\n assert candidate(plants = [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10],capacityA = 5,capacityB = 5) == 20\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],capacityA = 10,capacityB = 10) == 11\n assert candidate(plants = [5, 8, 6, 7, 5, 4, 3, 2, 1, 9],capacityA = 10,capacityB = 8) == 7\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31],capacityA = 20,capacityB = 25) == 11\n assert candidate(plants = [9, 8, 7, 6, 5, 4, 3, 2, 1],capacityA = 10,capacityB = 10) == 4\n assert candidate(plants = [10, 5, 15, 20, 25, 30, 35, 40, 45, 50],capacityA = 25,capacityB = 30) == 8\n assert candidate(plants = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],capacityA = 1,capacityB = 1) == 18\n assert candidate(plants = [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5],capacityA = 5,capacityB = 5) == 18\n assert candidate(plants = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25],capacityA = 12,capacityB = 15) == 20\n assert candidate(plants = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],capacityA = 15,capacityB = 15) == 8\n assert candidate(plants = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29],capacityA = 25,capacityB = 30) == 8\n assert candidate(plants = [5, 15, 25, 35, 45, 55, 65, 75, 85, 95],capacityA = 100,capacityB = 100) == 5\n"}, "metadata": {"canonical_parameter_names": ["plants", "capacityA", "capacityB"], "leetcode_dataset_entry_point": "Solution().minimumRefill", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int minimumRefill(vector& plants, int capacityA, int capacityB) {", "container": "Solution", "callable": "minimumRefill", "parameters": [{"name": "plants", "type": "vector&"}, {"name": "capacityA", "type": "int"}, {"name": "capacityB", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}} +{"question_id": 2106, "task_id": "maximum-fruits-harvested-after-at-most-k-steps", "difficulty": "Hard", "problem_description": "Fruits are available at some positions on an infinite x-axis. You are given a 2D integer array fruits where fruits[i] = [positioni, amounti] depicts amounti fruits at the position positioni. fruits is already sorted by positioni in ascending order, and each positioni is unique.\nYou are also given an integer startPos and an integer k. Initially, you are at the position startPos. From any position, you can either walk to the left or right. It takes one step to move one unit on the x-axis, and you can walk at most k steps in total. For every position you reach, you harvest all the fruits at that position, and the fruits will disappear from that position.\nReturn the maximum total number of fruits you can harvest.\n \nExample 1:\n\n\nInput: fruits = [[2,8],[6,3],[8,6]], startPos = 5, k = 4\nOutput: 9\nExplanation: \nThe optimal way is to:\n- Move right to position 6 and harvest 3 fruits\n- Move right to position 8 and harvest 6 fruits\nYou moved 3 steps and harvested 3 + 6 = 9 fruits in total.\n\nExample 2:\n\n\nInput: fruits = [[0,9],[4,1],[5,7],[6,2],[7,4],[10,9]], startPos = 5, k = 4\nOutput: 14\nExplanation: \nYou can move at most k = 4 steps, so you cannot reach position 0 nor 10.\nThe optimal way is to:\n- Harvest the 7 fruits at the starting position 5\n- Move left to position 4 and harvest 1 fruit\n- Move right to position 6 and harvest 2 fruits\n- Move right to position 7 and harvest 4 fruits\nYou moved 1 + 3 = 4 steps and harvested 7 + 1 + 2 + 4 = 14 fruits in total.\n\nExample 3:\n\n\nInput: fruits = [[0,3],[6,4],[8,5]], startPos = 3, k = 2\nOutput: 0\nExplanation:\nYou can move at most k = 2 steps and cannot reach any position with fruits.\n\n \nConstraints:\n\n1 <= fruits.length <= 105\nfruits[i].length == 2\n0 <= startPos, positioni <= 2 * 105\npositioni-1 < positioni for any i > 0 (0-indexed)\n1 <= amounti <= 104\n0 <= k <= 2 * 105\n\n", "canonical_tests": {"language": "python", "source": "def check(candidate):\n assert candidate(fruits = [[0, 9], [4, 1], [5, 7], [6, 2], [7, 4], [10, 9]],startPos = 5,k = 4) == 14\n assert candidate(fruits = [[1, 100], [50, 100], [100, 100]],startPos = 75,k = 25) == 100\n assert candidate(fruits = [[100000, 10000]],startPos = 90000,k = 20000) == 10000\n assert candidate(fruits = [[0, 1], [2, 1], [4, 1], [6, 1], [8, 1], [10, 1]],startPos = 5,k = 5) == 3\n assert candidate(fruits = [[1, 100], [2, 100], [3, 100], [4, 100], [5, 100], [6, 100], [7, 100], [8, 100], [9, 100], [10, 100]],startPos = 5,k = 10) == 800\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5]],startPos = 1,k = 5) == 15\n assert candidate(fruits = [[1, 10], [2, 10], [3, 10]],startPos = 1,k = 5) == 30\n assert candidate(fruits = [[1, 2], [3, 4], [5, 6]],startPos = 4,k = 3) == 10\n assert candidate(fruits = [[1, 5], [2, 3], [4, 8], [6, 7], [8, 2]],startPos = 5,k = 5) == 18\n assert candidate(fruits = [[1, 10000], [20000, 10000]],startPos = 10000,k = 10000) == 10000\n assert candidate(fruits = [[10, 5], [20, 5], [30, 5], [40, 5], [50, 5]],startPos = 30,k = 15) == 10\n assert candidate(fruits = [[10000, 10000], [20000, 10000], [30000, 10000]],startPos = 20000,k = 10000) == 20000\n assert candidate(fruits = [[0, 3], [6, 4], [8, 5]],startPos = 3,k = 2) == 0\n assert candidate(fruits = [[1, 2], [3, 4], [7, 8], [10, 10]],startPos = 5,k = 5) == 18\n assert candidate(fruits = [[1, 2], [3, 4], [5, 6], [7, 8]],startPos = 4,k = 5) == 18\n assert candidate(fruits = [[10, 10], [20, 20], [30, 30]],startPos = 15,k = 10) == 20\n assert candidate(fruits = [[2, 8], [6, 3], [8, 6]],startPos = 5,k = 4) == 9\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]],startPos = 8,k = 6) == 77\n assert candidate(fruits = [[1, 1], [3, 2], [5, 3], [7, 4], [9, 5], [11, 6], [13, 7], [15, 8], [17, 9], [19, 10]],startPos = 10,k = 9) == 40\n assert candidate(fruits = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9]],startPos = 45,k = 30) == 18\n assert candidate(fruits = [[1, 1], [3, 2], [5, 3], [7, 4], [9, 5], [11, 6], [13, 7], [15, 8], [17, 9]],startPos = 8,k = 12) == 39\n assert candidate(fruits = [[5, 20], [10, 15], [15, 10], [20, 5], [25, 10]],startPos = 12,k = 10) == 35\n assert candidate(fruits = [[1, 5], [4, 10], [6, 15], [10, 20], [15, 25], [20, 30]],startPos = 10,k = 15) == 75\n assert candidate(fruits = [[1, 1000], [10, 1000], [20, 1000], [30, 1000], [40, 1000]],startPos = 25,k = 20) == 2000\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12]],startPos = 6,k = 10) == 72\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],startPos = 1,k = 10) == 55\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],startPos = 5,k = 5) == 45\n assert candidate(fruits = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9]],startPos = 50,k = 30) == 26\n assert candidate(fruits = [[2, 5], [5, 5], [7, 5], [10, 5], [15, 5], [20, 5], [25, 5], [30, 5]],startPos = 15,k = 15) == 25\n assert candidate(fruits = [[1, 50], [2, 50], [3, 50], [4, 50], [5, 50], [6, 50], [7, 50], [8, 50], [9, 50], [10, 50]],startPos = 5,k = 10) == 400\n assert candidate(fruits = [[5, 15], [10, 20], [15, 25], [20, 30], [25, 35], [30, 40]],startPos = 18,k = 12) == 105\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],startPos = 5,k = 4) == 35\n assert candidate(fruits = [[1, 5], [3, 10], [6, 15], [8, 20], [10, 25]],startPos = 5,k = 7) == 60\n assert candidate(fruits = [[5, 100], [10, 200], [15, 300], [20, 400], [25, 500], [30, 600], [35, 700], [40, 800], [45, 900]],startPos = 20,k = 20) == 3000\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],startPos = 5,k = 9) == 52\n assert candidate(fruits = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11]],startPos = 5,k = 12) == 35\n assert candidate(fruits = [[2, 3], [4, 5], [6, 7], [8, 9], [10, 11], [12, 13], [14, 15]],startPos = 7,k = 10) == 55\n assert candidate(fruits = [[2, 8], [5, 10], [7, 3], [11, 15], [15, 7]],startPos = 8,k = 10) == 28\n assert candidate(fruits = [[5, 2], [10, 4], [15, 6], [20, 8], [25, 10], [30, 12], [35, 14]],startPos = 18,k = 25) == 50\n assert candidate(fruits = [[1, 100], [10, 100], [20, 100], [30, 100], [40, 100], [50, 100]],startPos = 25,k = 20) == 200\n assert candidate(fruits = [[1, 100], [100, 200], [200, 300], [300, 400], [400, 500]],startPos = 250,k = 200) == 900\n assert candidate(fruits = [[1, 1], [3, 2], [5, 3], [7, 4], [9, 5], [11, 6], [13, 7], [15, 8], [17, 9], [19, 10]],startPos = 10,k = 10) == 40\n assert candidate(fruits = [[1, 5], [10, 5], [20, 5], [30, 5], [40, 5], [50, 5], [60, 5], [70, 5], [80, 5], [90, 5], [100, 5]],startPos = 50,k = 40) == 25\n assert candidate(fruits = [[1, 1000], [2, 1000], [3, 1000], [4, 1000], [5, 1000], [6, 1000], [7, 1000], [8, 1000], [9, 1000], [10, 1000]],startPos = 5,k = 9) == 8000\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13]],startPos = 7,k = 6) == 70\n assert candidate(fruits = [[1, 2000], [2, 2000], [3, 2000], [4, 2000], [5, 2000], [6, 2000], [7, 2000], [8, 2000], [9, 2000], [10, 2000]],startPos = 5,k = 10) == 16000\n assert candidate(fruits = [[2, 3], [4, 6], [6, 9], [8, 12], [10, 15]],startPos = 6,k = 8) == 42\n assert candidate(fruits = [[5, 100], [10, 200], [15, 300], [20, 400], [25, 500]],startPos = 12,k = 22) == 1400\n assert candidate(fruits = [[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9], [9, 10]],startPos = 5,k = 9) == 49\n assert candidate(fruits = [[2, 9], [5, 8], [12, 7], [18, 6], [25, 5], [32, 4], [39, 3], [46, 2], [53, 1]],startPos = 25,k = 20) == 26\n assert candidate(fruits = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12], [13, 14], [15, 16], [17, 18], [19, 20]],startPos = 10,k = 15) == 98\n assert candidate(fruits = [[1, 10], [4, 20], [6, 30], [9, 40], [12, 50], [15, 60], [18, 70], [21, 80], [24, 90]],startPos = 12,k = 18) == 390\n assert candidate(fruits = [[5, 3], [10, 5], [15, 8], [20, 12], [25, 15], [30, 20]],startPos = 18,k = 12) == 47\n assert candidate(fruits = [[2, 5], [4, 3], [5, 10], [7, 2], [8, 6], [10, 1]],startPos = 6,k = 7) == 21\n assert candidate(fruits = [[5, 1], [7, 2], [9, 3], [11, 4], [13, 5]],startPos = 10,k = 6) == 12\n assert candidate(fruits = [[1, 50], [2, 60], [3, 70], [4, 80], [5, 90], [6, 100], [7, 110], [8, 120], [9, 130], [10, 140]],startPos = 5,k = 15) == 950\n assert candidate(fruits = [[1, 10], [5, 20], [10, 30], [15, 40], [20, 50]],startPos = 15,k = 18) == 120\n assert candidate(fruits = [[5, 2], [10, 3], [15, 4], [20, 5], [25, 6], [30, 7], [35, 8], [40, 9]],startPos = 22,k = 12) == 18\n assert candidate(fruits = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]],startPos = 8,k = 12) == 10\n assert candidate(fruits = [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1], [6, 1], [7, 1], [8, 1], [9, 1], [10, 1], [11, 1], [12, 1], [13, 1], [14, 1], [15, 1]],startPos = 8,k = 7) == 8\n assert candidate(fruits = [[1, 1000], [5, 1000], [10, 1000], [15, 1000], [20, 1000], [25, 1000], [30, 1000], [35, 1000], [40, 1000]],startPos = 20,k = 25) == 5000\n assert candidate(fruits = [[1, 100], [5, 200], [10, 300], [15, 400], [20, 500]],startPos = 10,k = 18) == 1200\n assert candidate(fruits = [[1, 5], [3, 5], [5, 5], [7, 5], [9, 5], [11, 5], [13, 5], [15, 5], [17, 5], [19, 5]],startPos = 10,k = 9) == 25\n assert candidate(fruits = [[2, 8], [6, 3], [8, 6], [12, 4], [14, 2], [18, 10], [20, 7]],startPos = 10,k = 12) == 23\n assert candidate(fruits = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10], [110, 11], [120, 12], [130, 13], [140, 14], [150, 15]],startPos = 80,k = 30) == 38\n assert candidate(fruits = [[1, 10], [3, 20], [5, 30], [7, 40], [9, 50], [11, 60], [13, 70], [15, 80], [17, 90]],startPos = 8,k = 14) == 390\n assert candidate(fruits = [[0, 100], [10, 100], [20, 100], [30, 100], [40, 100]],startPos = 20,k = 10) == 200\n assert candidate(fruits = [[5, 10], [15, 10], [25, 10], [35, 10], [45, 10], [55, 10], [65, 10]],startPos = 15,k = 35) == 40\n assert candidate(fruits = [[1, 10], [2, 20], [3, 30], [4, 40], [5, 50], [6, 60], [7, 70], [8, 80], [9, 90], [10, 100]],startPos = 5,k = 10) == 520\n assert candidate(fruits = [[1, 2], [4, 3], [7, 4], [10, 5], [13, 6], [16, 7], [19, 8], [22, 9], [25, 10]],startPos = 10,k = 10) == 26\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],startPos = 5,k = 9) == 52\n assert candidate(fruits = [[1, 1000], [2000, 1000], [3000, 1000], [4000, 1000], [5000, 1000]],startPos = 2500,k = 2000) == 2000\n assert candidate(fruits = [[5, 5], [15, 5], [25, 5], [35, 5], [45, 5], [55, 5], [65, 5]],startPos = 30,k = 25) == 15\n assert candidate(fruits = [[5, 10], [10, 20], [15, 30], [20, 40], [25, 50], [30, 60], [35, 70], [40, 80]],startPos = 25,k = 15) == 260\n assert candidate(fruits = [[2, 8], [6, 3], [8, 6], [12, 7], [16, 5]],startPos = 5,k = 8) == 16\n assert candidate(fruits = [[1, 10000], [2, 10000], [3, 10000], [4, 10000], [5, 10000]],startPos = 3,k = 100000) == 50000\n assert candidate(fruits = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],startPos = 50,k = 50) == 450\n assert candidate(fruits = [[1, 3], [4, 7], [6, 2], [8, 8], [10, 5]],startPos = 5,k = 7) == 22\n assert candidate(fruits = [[10, 5], [20, 10], [30, 15], [40, 20], [50, 25], [60, 30], [70, 35], [80, 40], [90, 45], [100, 50]],startPos = 55,k = 30) == 105\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]],startPos = 3,k = 15) == 55\n assert candidate(fruits = [[10, 100], [20, 200], [30, 300], [40, 400], [50, 500], [60, 600], [70, 700], [80, 800], [90, 900], [100, 1000]],startPos = 50,k = 40) == 3500\n assert candidate(fruits = [[10, 1], [20, 1], [30, 1], [40, 1], [50, 1], [60, 1], [70, 1], [80, 1], [90, 1], [100, 1]],startPos = 55,k = 45) == 5\n assert candidate(fruits = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5], [30, 6], [35, 7]],startPos = 20,k = 20) == 22\n assert candidate(fruits = [[10, 10], [20, 20], [30, 30], [40, 40], [50, 50], [60, 60], [70, 70], [80, 80], [90, 90], [100, 100]],startPos = 55,k = 45) == 400\n assert candidate(fruits = [[2, 5], [5, 10], [10, 8], [15, 7], [20, 6]],startPos = 12,k = 15) == 25\n assert candidate(fruits = [[5, 5], [15, 5], [25, 5], [35, 5], [45, 5], [55, 5]],startPos = 30,k = 18) == 10\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15]],startPos = 8,k = 10) == 99\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]],startPos = 10,k = 15) == 182\n assert candidate(fruits = [[0, 9], [4, 1], [5, 7], [6, 2], [7, 4], [10, 9], [12, 5], [15, 6], [18, 7]],startPos = 5,k = 10) == 33\n assert candidate(fruits = [[1, 1], [3, 1], [5, 1], [7, 1], [9, 1], [11, 1], [13, 1], [15, 1], [17, 1], [19, 1]],startPos = 10,k = 9) == 5\n assert candidate(fruits = [[1, 5], [3, 10], [5, 15], [7, 20], [9, 25], [11, 30], [13, 35], [15, 40], [17, 45], [19, 50]],startPos = 10,k = 15) == 245\n assert candidate(fruits = [[1, 1000], [2000, 2000], [3000, 3000], [4000, 4000], [5000, 5000]],startPos = 2500,k = 2500) == 12000\n assert candidate(fruits = [[5, 1], [10, 2], [15, 3], [20, 4], [25, 5], [30, 6], [35, 7], [40, 8]],startPos = 22,k = 15) == 18\n assert candidate(fruits = [[2, 1], [5, 3], [8, 5], [11, 2], [14, 6]],startPos = 7,k = 9) == 13\n assert candidate(fruits = [[10, 5], [15, 10], [20, 15], [25, 20], [30, 25], [35, 30]],startPos = 20,k = 25) == 100\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9]],startPos = 5,k = 15) == 45\n assert candidate(fruits = [[1, 5], [2, 5], [3, 5], [4, 5], [5, 5], [6, 5], [7, 5], [8, 5], [9, 5], [10, 5]],startPos = 5,k = 4) == 25\n assert candidate(fruits = [[1, 100], [10, 100], [20, 100], [30, 100], [40, 100]],startPos = 25,k = 20) == 200\n assert candidate(fruits = [[1, 1], [3, 2], [5, 3], [7, 4], [9, 5], [11, 6], [13, 7], [15, 8], [17, 9], [19, 10]],startPos = 10,k = 8) == 30\n assert candidate(fruits = [[10, 5], [20, 5], [30, 5], [40, 5], [50, 5], [60, 5], [70, 5], [80, 5]],startPos = 40,k = 25) == 15\n assert candidate(fruits = [[2, 8], [6, 3], [8, 6], [10, 9], [12, 4], [14, 2], [16, 5]],startPos = 5,k = 8) == 22\n assert candidate(fruits = [[0, 2], [2, 4], [4, 6], [6, 8], [8, 10], [10, 12], [12, 14]],startPos = 6,k = 6) == 44\n assert candidate(fruits = [[1, 5], [10, 10], [20, 15], [30, 20], [40, 25], [50, 30]],startPos = 25,k = 20) == 45\n assert candidate(fruits = [[5, 5], [15, 15], [25, 25], [35, 35], [45, 45]],startPos = 25,k = 20) == 105\n assert candidate(fruits = [[0, 100], [10, 100], [20, 100], [30, 100], [40, 100], [50, 100]],startPos = 25,k = 40) == 400\n assert candidate(fruits = [[10, 5000], [20, 5000], [30, 5000], [40, 5000], [50, 5000], [60, 5000], [70, 5000]],startPos = 35,k = 29) == 15000\n assert candidate(fruits = [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9], [10, 11]],startPos = 5,k = 12) == 35\n assert candidate(fruits = [[1, 1000], [5, 2000], [10, 3000], [20, 4000], [30, 5000]],startPos = 15,k = 18) == 9000\n assert candidate(fruits = [[1, 5], [2, 6], [3, 7], [4, 8], [5, 9], [6, 10], [7, 11], [8, 12]],startPos = 4,k = 10) == 68\n assert candidate(fruits = [[1, 1000], [10, 2000], [20, 3000], [30, 4000], [40, 5000], [50, 6000]],startPos = 25,k = 25) == 15000\n assert candidate(fruits = [[100, 10], [200, 20], [300, 30], [400, 40], [500, 50], [600, 60], [700, 70], [800, 80], [900, 90]],startPos = 500,k = 300) == 260\n assert candidate(fruits = [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10], [11, 11], [12, 12], [13, 13], [14, 14], [15, 15], [16, 16], [17, 17], [18, 18], [19, 19], [20, 20]],startPos = 10,k = 10) == 165\n assert candidate(fruits = [[1, 100], [2, 200], [3, 300], [4, 400], [5, 500], [6, 600]],startPos = 3,k = 10) == 2100\n assert candidate(fruits = [[10, 1], [20, 2], [30, 3], [40, 4], [50, 5], [60, 6], [70, 7], [80, 8], [90, 9], [100, 10]],startPos = 55,k = 40) == 30\n"}, "metadata": {"canonical_parameter_names": ["fruits", "startPos", "k"], "leetcode_dataset_entry_point": "Solution().maxTotalFruits", "problem_source": "newfacade/LeetCodeDataset", "interface_source": "leetcode/codeSnippets"}, "language": "cpp", "interface": {"raw_signature": "int maxTotalFruits(vector>& fruits, int startPos, int k) {", "container": "Solution", "callable": "maxTotalFruits", "parameters": [{"name": "fruits", "type": "vector>&"}, {"name": "startPos", "type": "int"}, {"name": "k", "type": "int"}], "return_type": "int", "signature_source": "leetcode/codeSnippets", "type_source": "leetcode/codeSnippets"}}